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


Python Vasp.restart方法代码示例

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


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

示例1: test_lsorbit

# 需要导入模块: from pylada.vasp import Vasp [as 别名]
# 或者: from pylada.vasp.Vasp import restart [as 别名]
def test_lsorbit():
    from collections import namedtuple
    from pickle import loads, dumps
    from pylada.vasp import Vasp

    Restart = namedtuple('Restart', ['success', 'lmaxmix', 'lvhar'])
    a = Vasp()
    o = a._input['lsorbit']
    d = {'LSorbit': o.__class__}
    assert a.lsorbit is None
    assert a.nonscf == False
    assert a._input['lsorbit'].keyword == 'lsorbit'
    assert a._input['nonscf'].keyword is None
    assert o.output_map(vasp=a) is None
    assert eval(repr(o), d).output_map(vasp=a) is None
    assert eval(repr(o), d).value is None
    assert loads(dumps(o)).value is None

    a.lsorbit = True
    assert a.nonscf
    assert a.lsorbit
    try:
        a._input['lsorbit'].output_map(vasp=a)
    except ValueError:
        pass
    else:
        raise Exception()
    a.restart = Restart(False, 7, False)
    try:
        a._input['lsorbit'].output_map(vasp=a)
    except ValueError:
        pass
    else:
        raise Exception()
    a.restart = Restart(True, 7, False)
    assert 'lsorbit' in o.output_map(vasp=a)
    assert o.output_map(vasp=a)['lsorbit'] == '.TRUE.'
    assert a.lmaxmix == 7
    a.lmaxmix = 5
    a.restart = Restart(True, 6, False)
    assert 'lsorbit' in o.output_map(vasp=a)
    assert o.output_map(vasp=a)['lsorbit'] == '.TRUE.'
    assert a.lmaxmix == 6
    assert loads(dumps(o)).value is True
    assert eval(repr(o), d).value is True
开发者ID:pylada,项目名称:pylada-light,代码行数:47,代码来源:test_lsorbit.py

示例2: test_istruc

# 需要导入模块: from pylada.vasp import Vasp [as 别名]
# 或者: from pylada.vasp.Vasp import restart [as 别名]
def test_istruc():
  from collections import namedtuple
  from pickle import loads, dumps
  from os import remove
  from os.path import join, exists
  from shutil import rmtree
  from tempfile import mkdtemp
  from pylada.vasp.files import POSCAR, CONTCAR
  from pylada.vasp import Vasp
  from pylada.crystal import Structure, read, specieset, write
  from pylada.error import ValueError

  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")

  Extract = namedtuple("Extract", ['directory', 'success', 'structure'])
  a = Vasp()
  o = a._input['istruc']
  d = {'IStruc': o.__class__}

  directory = mkdtemp()
  try: 
    assert a.istruc == 'auto'
    assert o.output_map(vasp=a, outdir=directory, structure=structure) is None
    assert eval(repr(o), d).value == 'auto'
    assert loads(dumps(o)).value == 'auto'
    assert exists(join(directory, POSCAR))
    remove(join(directory, POSCAR))

    # check reading from outcar but only on success.
    a.restart = Extract(directory, False, structure.copy())
    a.restart.structure[1].pos[0] += 0.02
    assert a.istruc == 'auto'
    assert o.output_map(vasp=a, outdir=directory, structure=structure) is None
    assert exists(join(directory, POSCAR))
    other = read.poscar(join(directory, POSCAR), types=specieset(structure))
    assert abs(other[1].pos[0] - 0.25) < 1e-8
    assert abs(other[1].pos[0] - 0.27) > 1e-8
    # check reading from outcar but only on success.
    a.restart = Extract(directory, True, structure.copy())
    a.restart.structure[1].pos[0] += 0.02
    assert a.istruc == 'auto'
    assert o.output_map(vasp=a, outdir=directory, structure=structure) is None
    assert exists(join(directory, POSCAR))
    other = read.poscar(join(directory, POSCAR), types=specieset(structure))
    assert abs(other[1].pos[0] - 0.25) > 1e-8
    assert abs(other[1].pos[0] - 0.27) < 1e-8

    # Now check CONTCAR
    write.poscar(structure, join(directory, CONTCAR))
    assert a.istruc == 'auto'
    assert o.output_map(vasp=a, outdir=directory, structure=structure) is None
    assert exists(join(directory, POSCAR))
    other = read.poscar(join(directory, POSCAR), types=specieset(structure))
    assert abs(other[1].pos[0] - 0.25) < 1e-8
    assert abs(other[1].pos[0] - 0.27) > 1e-8

    # Check some failure modes.
    write.poscar(structure, join(directory, CONTCAR))
    structure[0].type = 'Ge'
    a.restart = None
    try: o.output_map(vasp=a, outdir=directory, structure=structure)
    except ValueError: pass
    else: raise Exception()
    structure[0].type = 'Si'
    structure.add_atom(0.25,0,0, 'Si')
    try: o.output_map(vasp=a, outdir=directory, structure=structure)
    except ValueError: pass
    else: raise Exception()

  finally: rmtree(directory)
开发者ID:hbwzhsh,项目名称:pylada-light,代码行数:74,代码来源:test_restart.py

示例3: test_istart

# 需要导入模块: from pylada.vasp import Vasp [as 别名]
# 或者: from pylada.vasp.Vasp import restart [as 别名]
def test_istart():
  from time import sleep
  from collections import namedtuple
  from pickle import loads, dumps
  from os import remove, makedirs
  from os.path import join, exists
  from shutil import rmtree
  from tempfile import mkdtemp
  from pylada.vasp.files import WAVECAR
  from pylada.vasp import Vasp
  from pylada.misc import Changedir

  Extract = namedtuple("Extract", ['directory', 'success'])
  a = Vasp()
  o = a._input['istart']
  d = {'IStart': o.__class__}

  directory = mkdtemp()
  if directory in ['/tmp/test', '/tmp/test/']:
    if exists(directory): rmtree(directory)
    makedirs(directory)
  try: 
    assert a.istart == 'auto'
    assert o.output_map(vasp=a, outdir=directory)['istart'] == '0'
    assert eval(repr(o), d).value == 'auto'
    assert loads(dumps(o)).value == 'auto'

    restartdir = join(directory, 'restart')
    with Changedir(restartdir) as pwd: pass
    with open(join(restartdir, WAVECAR), 'w') as file: file.write('hello')

    # do not copy if not successful
    a.restart = Extract(restartdir, False)
    assert o.output_map(vasp=a, outdir=directory)['istart'] == '0'
    assert not exists(join(directory, 'WAVECAR'))

    # do not copy if file is empty
    a.restart = Extract(restartdir, True)
    with open(join(restartdir, WAVECAR), 'w') as file: pass
    assert o.output_map(vasp=a, outdir=directory)['istart'] == '0'
    assert not exists(join(directory, 'WAVECAR'))

    # now should copy
    assert a.istart == 'auto'
    with open(join(restartdir, WAVECAR), 'w') as file: file.write('hello')
    assert o.output_map(vasp=a, outdir=directory)['istart'] == '1'
    assert exists(join(directory, 'WAVECAR'))
      
    # check it copies only latest file.
    with open(join(restartdir, WAVECAR), 'w') as file: 
      file.write('hello')
      file.flush()
    with open(join(restartdir, WAVECAR), 'r') as file: pass
    sleep(1.5)
    with open(join(directory, WAVECAR), 'w') as file: file.write('hello world')
    with open(join(directory, WAVECAR), 'r') as file: pass
    assert o.output_map(vasp=a, outdir=directory)['istart'] == '1'
    assert exists(join(directory, 'WAVECAR'))
    with open(join(directory, WAVECAR), 'r') as file: 
      assert file.read().rstrip().lstrip() == 'hello world'
    
    sleep(0.2)
    with open(join(restartdir, WAVECAR), 'w') as file: file.write('hello')
    assert o.output_map(vasp=a, outdir=directory)['istart'] == '1'
    assert exists(join(directory, 'WAVECAR'))
    with open(join(directory, WAVECAR), 'r') as file: 
      assert file.read().rstrip().lstrip() == 'hello'

    # check if scratch is required
    remove(join(directory, WAVECAR))
    a.istart = 'scratch'
    assert a.istart == 'scratch'
    assert o.output_map(vasp=a, outdir=directory)['istart'] == '0'
    assert eval(repr(o), d).value == 'scratch'
    assert loads(dumps(o)).value == 'scratch'

  finally: 
    if directory not in ['/tmp/test', '/tmp/test/'] and exists(directory):
      rmtree(directory)
开发者ID:hbwzhsh,项目名称:pylada-light,代码行数:81,代码来源:test_restart.py

示例4: test_icharg

# 需要导入模块: from pylada.vasp import Vasp [as 别名]
# 或者: from pylada.vasp.Vasp import restart [as 别名]
def test_icharg(): 
  from time import sleep
  from collections import namedtuple
  from pickle import loads, dumps
  from os import remove, makedirs
  from os.path import join, exists
  from shutil import rmtree
  from tempfile import mkdtemp
  from pylada.vasp.files import WAVECAR, CHGCAR
  from pylada.vasp import Vasp
  from pylada.misc import Changedir
  from pylada.error import ValueError

  Extract = namedtuple("Extract", ['directory', 'success'])
  a = Vasp()
  o = a._input['icharg']
  d = {'ICharg': o.__class__}

  directory = mkdtemp()
  if directory in ['/tmp/test', '/tmp/test/']:
    if exists(directory): rmtree(directory)
    makedirs(directory)
  try: 
    assert a.icharg == 'auto'
    assert o.output_map(vasp=a, outdir=directory)['icharg'] == '2'
    assert eval(repr(o), d).value == 'auto'
    assert loads(dumps(o)).value == 'auto'

    restartdir = join(directory, 'restart')
    with Changedir(restartdir) as pwd: pass
    with open(join(restartdir, CHGCAR), 'w') as file: file.write('hello')
    with open(join(restartdir, WAVECAR), 'w') as file: file.write('hello')

    # do not copy if not successful
    a.restart = Extract(restartdir, False)
    assert o.output_map(vasp=a, outdir=directory)['icharg'] == '2'
    assert not exists(join(directory, CHGCAR))
    assert not exists(join(directory, WAVECAR))

    # do not copy if empty
    with open(join(restartdir, CHGCAR), 'w') as file: pass
    with open(join(restartdir, WAVECAR), 'w') as file: pass
    a.restart = Extract(restartdir, True)
    assert o.output_map(vasp=a, outdir=directory)['icharg'] == '2'
    assert not exists(join(directory, CHGCAR))
    assert not exists(join(directory, WAVECAR))

    # now copy only CHGCAR
    with open(join(restartdir, CHGCAR), 'w') as file: file.write('hello')
    a.restart = Extract(restartdir, True)
    assert o.output_map(vasp=a, outdir=directory)['icharg'] == '1'
    assert exists(join(directory, CHGCAR))
    assert not exists(join(directory, WAVECAR))
    remove(join(directory, CHGCAR))
    # now copy only CHGCAR with scf
    a.nonscf = True
    a.restart = Extract(restartdir, True)
    assert o.output_map(vasp=a, outdir=directory)['icharg'] == '11'
    assert exists(join(directory, CHGCAR))
    assert not exists(join(directory, WAVECAR))
    remove(join(directory, CHGCAR))

    # now copy both 
    a.nonscf = False
    with open(join(restartdir, WAVECAR), 'w') as file: file.write('hello')
    a.restart = Extract(restartdir, True)
    assert o.output_map(vasp=a, outdir=directory)['icharg'] == '0'
    assert exists(join(directory, CHGCAR))
    assert exists(join(directory, WAVECAR))

    # now copy both with scf
    a.nonscf = True
    a.restart = Extract(restartdir, True)
    assert o.output_map(vasp=a, outdir=directory)['icharg'] == '10'
    assert exists(join(directory, CHGCAR))
    assert exists(join(directory, WAVECAR))

    # now check that latest is copied
    remove(join(restartdir, CHGCAR))
    remove(join(directory, CHGCAR))
    sleep(1.2)
    with open(join(directory, WAVECAR), 'w') as file: file.write('hello world')
    with open(join(directory, WAVECAR), 'r') as file: pass # Buffering issues..
    a.nonscf = False
    a.restart = Extract(restartdir, True)
    assert o.output_map(vasp=a, outdir=directory)['icharg'] == '0'
    assert exists(join(directory, WAVECAR))
    with open(join(directory, WAVECAR), 'r') as file:
      assert file.read().rstrip().lstrip() == 'hello world'
    with open(join(directory, WAVECAR), 'r') as file:
      assert file.read().rstrip().lstrip() != 'hello'

    with open(join(restartdir, WAVECAR), 'w') as file: file.write('hello')
    assert o.output_map(vasp=a, outdir=directory)['icharg'] == '0'
    assert exists(join(directory, WAVECAR))
    with open(join(directory, WAVECAR), 'r') as file:
      assert file.read().rstrip().lstrip() == 'hello'
    with open(join(directory, WAVECAR), 'r') as file:
      assert file.read().rstrip().lstrip() != 'hello world'

#.........这里部分代码省略.........
开发者ID:hbwzhsh,项目名称:pylada-light,代码行数:103,代码来源:test_restart.py

示例5: test_istart

# 需要导入模块: from pylada.vasp import Vasp [as 别名]
# 或者: from pylada.vasp.Vasp import restart [as 别名]
def test_istart():
    from time import sleep
    from collections import namedtuple
    from pickle import loads, dumps
    from os import remove, makedirs
    from os.path import join, exists
    from shutil import rmtree
    from tempfile import mkdtemp
    from pylada.vasp.files import WAVECAR
    from pylada.vasp import Vasp
    from pylada.misc import Changedir

    Extract = namedtuple("Extract", ["directory", "success"])
    a = Vasp()
    o = a._input["istart"]
    d = {"IStart": o.__class__}

    directory = mkdtemp()
    if directory in ["/tmp/test", "/tmp/test/"]:
        if exists(directory):
            rmtree(directory)
        makedirs(directory)
    try:
        assert a.istart == "auto"
        assert o.output_map(vasp=a, outdir=directory)["istart"] == "0"
        assert eval(repr(o), d).value == "auto"
        assert loads(dumps(o)).value == "auto"

        restartdir = join(directory, "restart")
        with Changedir(restartdir) as pwd:
            pass
        with open(join(restartdir, WAVECAR), "w") as file:
            file.write("hello")

        # do not copy if not successful
        a.restart = Extract(restartdir, False)
        assert o.output_map(vasp=a, outdir=directory)["istart"] == "0"
        assert not exists(join(directory, "WAVECAR"))

        # do not copy if file is empty
        a.restart = Extract(restartdir, True)
        with open(join(restartdir, WAVECAR), "w") as file:
            pass
        assert o.output_map(vasp=a, outdir=directory)["istart"] == "0"
        assert not exists(join(directory, "WAVECAR"))

        # now should copy
        assert a.istart == "auto"
        with open(join(restartdir, WAVECAR), "w") as file:
            file.write("hello")
        assert o.output_map(vasp=a, outdir=directory)["istart"] == "1"
        assert exists(join(directory, "WAVECAR"))

        # check it copies only latest file.
        with open(join(restartdir, WAVECAR), "w") as file:
            file.write("hello")
            file.flush()
        with open(join(restartdir, WAVECAR), "r") as file:
            pass
        sleep(1.5)
        with open(join(directory, WAVECAR), "w") as file:
            file.write("hello world")
        with open(join(directory, WAVECAR), "r") as file:
            pass
        assert o.output_map(vasp=a, outdir=directory)["istart"] == "1"
        assert exists(join(directory, "WAVECAR"))
        with open(join(directory, WAVECAR), "r") as file:
            assert file.read().rstrip().lstrip() == "hello world"

        sleep(0.2)
        with open(join(restartdir, WAVECAR), "w") as file:
            file.write("hello")
        assert o.output_map(vasp=a, outdir=directory)["istart"] == "1"
        assert exists(join(directory, "WAVECAR"))
        with open(join(directory, WAVECAR), "r") as file:
            assert file.read().rstrip().lstrip() == "hello"

        # check if scratch is required
        remove(join(directory, WAVECAR))
        a.istart = "scratch"
        assert a.istart == "scratch"
        assert o.output_map(vasp=a, outdir=directory)["istart"] == "0"
        assert eval(repr(o), d).value == "scratch"
        assert loads(dumps(o)).value == "scratch"

    finally:
        if directory not in ["/tmp/test", "/tmp/test/"] and exists(directory):
            rmtree(directory)
开发者ID:georgeyumnam,项目名称:pylada,代码行数:90,代码来源:restart.py

示例6: test_icharg

# 需要导入模块: from pylada.vasp import Vasp [as 别名]
# 或者: from pylada.vasp.Vasp import restart [as 别名]
def test_icharg():
    from time import sleep
    from collections import namedtuple
    from pickle import loads, dumps
    from os import remove, makedirs
    from os.path import join, exists
    from shutil import rmtree
    from tempfile import mkdtemp
    from pylada.vasp.files import WAVECAR, CHGCAR
    from pylada.vasp import Vasp
    from pylada.misc import Changedir
    from pylada.error import ValueError

    Extract = namedtuple("Extract", ["directory", "success"])
    a = Vasp()
    o = a._input["icharg"]
    d = {"ICharg": o.__class__}

    directory = mkdtemp()
    if directory in ["/tmp/test", "/tmp/test/"]:
        if exists(directory):
            rmtree(directory)
        makedirs(directory)
    try:
        assert a.icharg == "auto"
        assert o.output_map(vasp=a, outdir=directory)["icharg"] == "2"
        assert eval(repr(o), d).value == "auto"
        assert loads(dumps(o)).value == "auto"

        restartdir = join(directory, "restart")
        with Changedir(restartdir) as pwd:
            pass
        with open(join(restartdir, CHGCAR), "w") as file:
            file.write("hello")
        with open(join(restartdir, WAVECAR), "w") as file:
            file.write("hello")

        # do not copy if not successful
        a.restart = Extract(restartdir, False)
        assert o.output_map(vasp=a, outdir=directory)["icharg"] == "2"
        assert not exists(join(directory, CHGCAR))
        assert not exists(join(directory, WAVECAR))

        # do not copy if empty
        with open(join(restartdir, CHGCAR), "w") as file:
            pass
        with open(join(restartdir, WAVECAR), "w") as file:
            pass
        a.restart = Extract(restartdir, True)
        assert o.output_map(vasp=a, outdir=directory)["icharg"] == "2"
        assert not exists(join(directory, CHGCAR))
        assert not exists(join(directory, WAVECAR))

        # now copy only CHGCAR
        with open(join(restartdir, CHGCAR), "w") as file:
            file.write("hello")
        a.restart = Extract(restartdir, True)
        assert o.output_map(vasp=a, outdir=directory)["icharg"] == "1"
        assert exists(join(directory, CHGCAR))
        assert not exists(join(directory, WAVECAR))
        remove(join(directory, CHGCAR))
        # now copy only CHGCAR with scf
        a.nonscf = True
        a.restart = Extract(restartdir, True)
        assert o.output_map(vasp=a, outdir=directory)["icharg"] == "11"
        assert exists(join(directory, CHGCAR))
        assert not exists(join(directory, WAVECAR))
        remove(join(directory, CHGCAR))

        # now copy both
        a.nonscf = False
        with open(join(restartdir, WAVECAR), "w") as file:
            file.write("hello")
        a.restart = Extract(restartdir, True)
        assert o.output_map(vasp=a, outdir=directory)["icharg"] == "0"
        assert exists(join(directory, CHGCAR))
        assert exists(join(directory, WAVECAR))

        # now copy both with scf
        a.nonscf = True
        a.restart = Extract(restartdir, True)
        assert o.output_map(vasp=a, outdir=directory)["icharg"] == "10"
        assert exists(join(directory, CHGCAR))
        assert exists(join(directory, WAVECAR))

        # now check that latest is copied
        remove(join(restartdir, CHGCAR))
        remove(join(directory, CHGCAR))
        sleep(1.2)
        with open(join(directory, WAVECAR), "w") as file:
            file.write("hello world")
        with open(join(directory, WAVECAR), "r") as file:
            pass  # Buffering issues..
        a.nonscf = False
        a.restart = Extract(restartdir, True)
        assert o.output_map(vasp=a, outdir=directory)["icharg"] == "0"
        assert exists(join(directory, WAVECAR))
        with open(join(directory, WAVECAR), "r") as file:
            assert file.read().rstrip().lstrip() == "hello world"
        with open(join(directory, WAVECAR), "r") as file:
#.........这里部分代码省略.........
开发者ID:georgeyumnam,项目名称:pylada,代码行数:103,代码来源:restart.py


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