当前位置: 首页>>代码示例>>Python>>正文


Python Vasp.write_incar方法代码示例

本文整理汇总了Python中pylada.vasp.Vasp.write_incar方法的典型用法代码示例。如果您正苦于以下问题:Python Vasp.write_incar方法的具体用法?Python Vasp.write_incar怎么用?Python Vasp.write_incar使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在pylada.vasp.Vasp的用法示例。


在下文中一共展示了Vasp.write_incar方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_incar

# 需要导入模块: from pylada.vasp import Vasp [as 别名]
# 或者: from pylada.vasp.Vasp import write_incar [as 别名]
def test_incar():
  from shutil import rmtree
  from tempfile import mkdtemp
  from os.path import join, dirname
  from quantities import eV
  from pylada.vasp import Vasp, read_incar
  from pylada.crystal import Structure
  structure = Structure([[0, 0.5, 0.5],[0.5, 0, 0.5], [0.5, 0.5, 0]], scale=5.43, name='has a name')\
                       .add_atom(0,0,0, "Si")\
                       .add_atom(0.25,0.25,0.25, "Si")

  vasp = Vasp()
  vasp.kpoints    = "Automatic generation\n0\nMonkhorst\n2 2 2\n0 0 0"
  vasp.precision  = "accurate"
  vasp.ediff      = 1e-5
  vasp.encut      = 1
  vasp.ismear     = "metal"
  vasp.sigma      = 0.06
  vasp.relaxation = "volume"
  vasp.add_specie = "Si", join(dirname(__file__), 'pseudos', 'Si')

  directory = mkdtemp()
  try: 
    vasp.write_incar(path=join(directory, 'INCAR'), structure=structure)
    other = read_incar(join(directory, 'INCAR'))
    assert abs(other.ediff - 1e-5)  < 1e-8
    assert abs(other.encut - 245.345) < 1e-8
    assert abs(other.sigma - 0.06 * eV) < 1e-8
    assert other.ibrion     == 2
    assert other.icharg     == 'atomic'
    assert other.isif       == 7
    assert other.ismear     == 'metal'
    assert other.istart     == 'scratch'
    assert other.lcharg     == False
    assert other.nsw        == 50
    assert other.relaxation == 'volume'
    assert other.system     == 'has a name'
    with open(join(directory, 'INCAR'), 'a') as file:
      file.write('\nSOMETHing = 0.5\n')
    other = read_incar(join(directory, 'INCAR'))
    assert abs(other.ediff - 1e-5)  < 1e-8
    assert abs(other.encut - 245.345) < 1e-8
    assert abs(other.sigma - 0.06 * eV) < 1e-8
    assert other.ibrion     == 2
    assert other.icharg     == 'atomic'
    assert other.isif       == 7
    assert other.ismear     == 'metal'
    assert other.istart     == 'scratch'
    assert other.lcharg     == False
    assert other.nsw        == 50
    assert other.relaxation == 'volume'
    assert other.system     == 'has a name'
    assert 'something' in other._input
    assert isinstance(other.something, float)
    assert abs(other.something - 0.5) < 1e-8
  finally: 
    rmtree(directory)
    pass
开发者ID:hbwzhsh,项目名称:pylada-light,代码行数:60,代码来源:test_incar.py

示例2: test

# 需要导入模块: from pylada.vasp import Vasp [as 别名]
# 或者: from pylada.vasp.Vasp import write_incar [as 别名]
def test(path):
    from shutil import rmtree
    from tempfile import mkdtemp
    from os.path import join
    from quantities import eV
    from pylada.vasp import Vasp, read_incar
    from pylada.crystal import Structure

    structure = (
        Structure([[0, 0.5, 0.5], [0.5, 0, 0.5], [0.5, 0.5, 0]], scale=5.43, name="has a name")
        .add_atom(0, 0, 0, "Si")
        .add_atom(0.25, 0.25, 0.25, "Si")
    )

    vasp = Vasp()
    vasp.kpoints = "Automatic generation\n0\nMonkhorst\n2 2 2\n0 0 0"
    vasp.precision = "accurate"
    vasp.ediff = 1e-5
    vasp.encut = 1
    vasp.ismear = "metal"
    vasp.sigma = 0.06
    vasp.relaxation = "volume"
    vasp.add_specie = "Si", "{0}/pseudos/Si".format(path)

    directory = mkdtemp()
    try:
        vasp.write_incar(path=join(directory, "INCAR"), structure=structure)
        other = read_incar(join(directory, "INCAR"))
        assert abs(other.ediff - 1e-5) < 1e-8
        assert abs(other.encut - 245.345) < 1e-8
        assert abs(other.sigma - 0.06 * eV) < 1e-8
        assert other.ibrion == 2
        assert other.icharg == "atomic"
        assert other.isif == 7
        assert other.ismear == "metal"
        assert other.istart == "scratch"
        assert other.lcharg == False
        assert other.nsw == 50
        assert other.relaxation == "volume"
        assert other.system == "has a name"
        with open(join(directory, "INCAR"), "a") as file:
            file.write("\nSOMETHing = 0.5\n")
        other = read_incar(join(directory, "INCAR"))
        assert abs(other.ediff - 1e-5) < 1e-8
        assert abs(other.encut - 245.345) < 1e-8
        assert abs(other.sigma - 0.06 * eV) < 1e-8
        assert other.ibrion == 2
        assert other.icharg == "atomic"
        assert other.isif == 7
        assert other.ismear == "metal"
        assert other.istart == "scratch"
        assert other.lcharg == False
        assert other.nsw == 50
        assert other.relaxation == "volume"
        assert other.system == "has a name"
        assert "something" in other._input
        assert isinstance(other.something, float)
        assert abs(other.something - 0.5) < 1e-8
    finally:
        rmtree(directory)
        pass
开发者ID:georgeyumnam,项目名称:pylada,代码行数:63,代码来源:incar.py


注:本文中的pylada.vasp.Vasp.write_incar方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。