本文整理汇总了Python中pylada.vasp.Vasp类的典型用法代码示例。如果您正苦于以下问题:Python Vasp类的具体用法?Python Vasp怎么用?Python Vasp使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Vasp类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: test_alias
def test_alias():
from pylada.vasp import Vasp
from pylada.error import ValueError
a = Vasp()
assert a.ismear is None
assert a._input['ismear'].keyword == 'ismear'
assert a._input['ismear'].output_map() is None
map = a._input['ismear'].aliases
assert len(map) != 0
for i, items in map.items():
for item in items:
a.ismear = item
assert a.ismear == items[0]
assert 'ismear' in a._input['ismear'].output_map()
assert a._input['ismear'].output_map()['ismear'] == str(i)
a.ismear = i
assert a.ismear == items[0]
a.ismear = str(i)
assert a.ismear == items[0]
try:
a.lmaxmix = 'a'
except ValueError:
pass
else:
raise Exception()
开发者ID:,项目名称:,代码行数:27,代码来源:
示例2: test_system
def test_system():
from pylada.crystal.cppwrappers import Structure
from pylada.vasp import Vasp
a = Vasp()
b = Structure()
assert a.system is None
assert a._input['system'].keyword == 'system'
assert a._input['system'].output_map(vasp=a, structure=b) is None
a.system = 'system'
assert a.system == 'system'
assert 'system' in a._input['system'].output_map(vasp=a, structure=b)
assert a._input['system'].output_map(vasp=a, structure=b)['system'] == 'system'
b.name = 'hello'
assert 'system' in a._input['system'].output_map(vasp=a, structure=b)
assert a._input['system'].output_map(vasp=a, structure=b)['system'] == 'system: hello'
a.system = None
assert a.system is None
assert 'system' in a._input['system'].output_map(vasp=a, structure=b)
assert a._input['system'].output_map(vasp=a, structure=b)['system'] == 'hello'
a.system = None
assert a.system is None
assert 'system' in a._input['system'].output_map(vasp=a, structure=b)
assert a._input['system'].output_map(vasp=a, structure=b)['system'] == 'hello'
开发者ID:mdavezac,项目名称:LaDa,代码行数:28,代码来源:system.py
示例3: vasp
def vasp(Specie):
from pylada.vasp import Vasp
from pylada.vasp.specie import U, nlep
vasp = Vasp()
vasp.species = {'A': Specie([]), 'B': Specie([]), 'X': Specie([])}
for key in list(vasp._input.keys()):
if key not in ['ldau']:
del vasp._input[key]
return vasp
开发者ID:pylada,项目名称:pylada-light,代码行数:9,代码来源:test_uparams_attribute.py
示例4: test
def test(tmpdir, path):
from numpy import all, abs
from quantities import kbar, eV, angstrom
from pylada.crystal import Structure
from pylada.vasp import Vasp
from pylada.vasp.relax import Relax
from pylada import default_comm
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.prec = "accurate"
vasp.ediff = 1e-5
vasp.encut = 1
vasp.ismear = "fermi"
vasp.sigma = 0.01
vasp.relaxation = "volume"
vasp.add_specie = "Si", "{0}/pseudos/Si".format(path)
functional = Relax(copy=vasp)
assert abs(functional.ediff - 1e-5) < 1e-8
assert functional.prec == 'Accurate'
result = functional(structure, outdir=str(tmpdir), comm=default_comm,
relaxation="volume ionic cellshape")
assert result.success
assert result.stress.units == kbar and all(abs(result.stress) < 1e0)
assert result.forces.units == eV / angstrom and all(abs(result.forces) < 1e-1)
assert result.total_energy.units == eV and all(
abs(result.total_energy + 10.668652 * eV) < 1e-2)
开发者ID:pylada,项目名称:pylada-light,代码行数:33,代码来源:test_runrelax.py
示例5: test
def test(tmpdir, path):
from numpy import abs
from pylada.crystal import Structure
from pylada.vasp import Vasp
from pylada.vasp.emass import effective_mass, EMass
from pylada import default_comm
structure = Structure([[0, 0.5, 0.5], [0.5, 0, 0.5], [0.5, 0.5, 0]], scale=5.55, 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.prec = "accurate"
vasp.ediff = 25e-5
vasp.encut = 1.4
vasp.ismear = "fermi"
vasp.sigma = 0.01
vasp.relaxation = "volume"
vasp.add_specie = "Si", "{0}/pseudos/Si".format(path)
emass = EMass(copy=vasp)
assert abs(emass.encut - 1.4) < 1e-8
assert abs(emass.ediff - 25e-5) < 1e-10
result = effective_mass(vasp, structure, outdir=str(tmpdir), comm=default_comm,
emassparams={'ediff': 1e-8})
result.emass
assert result.success
result = emass(structure, outdir=str(tmpdir), comm=default_comm,
emassparams={'ediff': 1e-8})
assert result.success
开发者ID:pylada,项目名称:pylada-light,代码行数:30,代码来源:test_runmass.py
示例6: test
def test(path):
from shutil import rmtree
from tempfile import mkdtemp
from pylada.crystal import Structure
from pylada.vasp import Vasp
from epirelax import epitaxial
from pylada import default_comm
structure = Structure([[0, 0.5, 0.5],[0.5, 0, 0.5], [0.5, 0.5, 0]], scale=5.55, 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.prec = "accurate"
vasp.ediff = 1e-5
vasp.encut = 1.4
vasp.ismear = "fermi"
vasp.sigma = 0.01
vasp.relaxation = "volume"
vasp.add_specie = "Si", "{0}/pseudos/Si".format(path)
directory = mkdtemp()
try:
result = epitaxial(vasp, structure, outdir=directory, epiconv=1e-4, comm=default_comm)
assert result.success
finally:
rmtree(directory)
pass
开发者ID:georgeyumnam,项目名称:pylada,代码行数:28,代码来源:runepidoc.py
示例7: test
def test(path):
from os import makedirs
from os.path import exists
from shutil import rmtree
from tempfile import mkdtemp
from pylada.crystal import Structure
from pylada.vasp import Vasp
from pylada import default_comm
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.prec = "accurate"
vasp.ediff = 1e-5
vasp.encut = 1
vasp.ismear = "fermi"
vasp.sigma = 0.01
vasp.relaxation = "volume"
vasp.add_specie = "Si", "{0}/pseudos/Si".format(path)
directory = mkdtemp()
if directory == '/tmp/test' or directory == '/tmp/test/':
if exists(directory): rmtree(directory)
makedirs(directory)
try:
result = vasp(structure, outdir=directory, comm=default_comm)
assert result.success
finally:
if directory != '/tmp/test' and directory != '/tmp/test/':
rmtree(directory)
开发者ID:georgeyumnam,项目名称:pylada,代码行数:32,代码来源:run.py
示例8: __call__
def __call__(self, structure, outdir=None, **kwargs ):
from copy import deepcopy
from os import getcwd
from os.path import join
from pylada.misc import RelativePath
from pylada.error import ExternalRunFailed
from pylada.vasp.extract import Extract
from pylada.vasp import Vasp
from pylada.vasp.relax import Relax
# make this function stateless.
structure_ = structure.copy()
outdir = getcwd() if outdir is None else RelativePath(outdir).path
############ Calc 1 ###############
name = self.names[0]
## functional for Calc 1
relax = Relax(copy=deepcopy(self.vasp))
relax.relaxation = "volume ionic cellshape"
relax.maxiter = 10
relax.keep_steps = True
relax.first_trial = { "kpoints": "\n0\nAuto\n10", "encut": 0.9 }
## end of the functional
params = deepcopy(kwargs)
fulldir = join(outdir, name)
## if this calculation has not been done run it
output = relax(structure_, outdir=fulldir, **params)
if not output.success:
raise ExternalRunFailed("VASP calculation did not succeed.")
############ Calc 2 ###############
name = self.names[1]
## functional for Calc 2
wfn = Vasp(copy=deepcopy(self.vasp))
wfn.isym = 1
wfn.ismear = -5
wfn.nbands=24*len(structure_)
wfn.kpoints="\n0\nGamma\n4 4 4\n0. 0. 0.\n"
## end of the functional
params = deepcopy(kwargs)
fulldir = join(outdir, name)
## if this calculation has not been done, run it
output = wfn(structure_, outdir=fulldir, restart=output, **params)
if not output.success:
raise ExternalRunFailed("VASP calculation did not succeed.")
return self.Extract(fulldir)
开发者ID:pylada,项目名称:tutorial,代码行数:54,代码来源:custom_chain.py
示例9: test_choice
def test_choice():
from pickle import loads, dumps
from pylada.vasp import Vasp
a = Vasp()
assert a.ispin is None
assert a._input['ispin'].keyword == 'ispin'
assert a._input['ispin'].output_map() is None
a.ispin = 1
assert a.ispin == 1
assert 'ispin' in a._input['ispin'].output_map()
assert a._input['ispin'].output_map()['ispin'] == '1'
a.ispin = 2
assert a.ispin == 2
assert 'ispin' in a._input['ispin'].output_map()
assert a._input['ispin'].output_map()['ispin'] == '2'
a.ispin = None
assert a.ispin is None
assert a._input['ispin'].keyword == 'ispin'
assert a._input['ispin'].output_map() is None
try:
a.ispin = 5
except:
pass
else:
raise RuntimeError()
a.ispin = '1'
assert a.ispin == 1
a.ispin = '2'
assert a.ispin == 2
try:
a.ispin = '3'
except:
pass
else:
raise RuntimeError()
a.ispin = None
o = a._input['ispin']
d = {'ChoiceKeyword': o.__class__}
assert repr(eval(repr(o), d)) == repr(o)
assert eval(repr(o), d).output_map() is None
assert repr(loads(dumps(o))) == repr(o)
a.ispin = 2
o = a._input['ispin']
assert repr(eval(repr(o), d)) == repr(o)
assert eval(repr(o), d).output_map()['ispin'] == '2'
assert repr(loads(dumps(o))) == repr(o)
开发者ID:,项目名称:,代码行数:51,代码来源:
示例10: vasp
def vasp():
from os.path import join, dirname
from pylada.vasp import Vasp
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')
return vasp
开发者ID:,项目名称:,代码行数:13,代码来源:
示例11: test
def test(path):
from glob import glob
from os.path import join
from shutil import rmtree
from tempfile import mkdtemp
from numpy import all, abs
from quantities import kbar, eV, angstrom
from pylada.crystal import Structure
from pylada.vasp import Vasp
from pylada.vasp.relax import Relax
from pylada import default_comm
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.prec = "accurate"
vasp.ediff = 1e-5
vasp.encut = 1
vasp.ismear = "fermi"
vasp.sigma = 0.01
vasp.relaxation = "volume"
vasp.add_specie = "Si", "{0}/pseudos/Si".format(path)
directory = mkdtemp()
try:
functional = Relax(copy=vasp)
assert abs(functional.ediff - 1e-5) < 1e-8
assert functional.prec == 'Accurate'
result = functional(structure, outdir=directory, comm=default_comm,
relaxation="volume ionic cellshape")
assert result.success
def sortme(a): return int(a.split('/')[-1])
dirs = sorted(glob(join(join(directory, '*'), '[0-9]')), key=sortme)
# for previous, current in zip(dirs, dirs[1:]):
# assert len(check_output(['diff', join(previous, 'CONTCAR'), join(current, 'POSCAR')])) == 0
# assert len(check_output(['diff', join(current, 'CONTCAR'), join(directory, 'POSCAR')])) == 0
assert result.stress.units == kbar and all(abs(result.stress) < 1e0)
assert result.forces.units == eV/angstrom and all(abs(result.forces) < 1e-1)
assert result.total_energy.units == eV and all(abs(result.total_energy + 10.668652*eV) < 1e-2)
finally:
if directory != '/tmp/test/relax': rmtree(directory)
pass
开发者ID:georgeyumnam,项目名称:pylada,代码行数:45,代码来源:runrelax.py
示例12: test_nelect
def test_nelect():
from os.path import dirname
from pickle import loads, dumps
from pylada.vasp import Vasp
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")
a = Vasp()
a.add_specie = "Si", "{0}/pseudos/Si".format(dirname(__file__))
assert a.extraelectron is None
assert a._input['extraelectron'].output_map() is None
assert a._input['nelect'].output_map() is None
a.extraelectron = 0
assert a.extraelectron == 0
assert a.nelect is None
assert a._input['extraelectron'].output_map() is None
assert a._input['nelect'].output_map() is None
a.extraelectron = 1
assert a.extraelectron == 1
assert a.nelect is None
assert 'nelect' in a._input['extraelectron'].output_map(vasp=a, structure=structure)
assert abs(float(a._input['extraelectron'].output_map(
vasp=a, structure=structure)['nelect']) - 9.0) < 1e-8
assert a._input['nelect'].output_map() is None
a.nelect = 1
a.extraelectron = -1
assert a.extraelectron == -1
assert a.nelect is None
assert 'nelect' in a._input['extraelectron'].output_map(vasp=a, structure=structure)
assert abs(float(a._input['extraelectron'].output_map(
vasp=a, structure=structure)['nelect']) - 7.0) < 1e-8
assert a._input['nelect'].output_map() is None
o = a._input['extraelectron']
d = {'ExtraElectron': o.__class__}
assert repr(eval(repr(o), d)) == repr(o)
assert abs(float(eval(repr(o), d).output_map(
vasp=a, structure=structure)['nelect']) - 7.0) < 1e-8
assert repr(loads(dumps(o))) == repr(o)
a.nelect = 8
assert a.nelect == 8
assert a.extraelectron is None
assert 'nelect' in a._input['nelect'].output_map()
assert abs(float(a._input['nelect'].output_map()['nelect']) - 8.0) < 1e-8
assert a._input['extraelectron'].output_map() is None
o = a._input['nelect']
d = {'NElect': o.__class__}
assert repr(eval(repr(o), d)) == repr(o)
assert abs(float(eval(repr(o), d).output_map()['nelect']) - 8.0) < 1e-8
assert repr(loads(dumps(o))) == repr(o)
开发者ID:pylada,项目名称:pylada-light,代码行数:53,代码来源:test_vasp_nelect.py
示例13: test
def test(path):
from shutil import rmtree
from os.path import exists
from os import makedirs
from tempfile import mkdtemp
from numpy import abs
from pylada.crystal import Structure
from pylada.vasp import Vasp
from pylada.vasp.emass import effective_mass, EMass
from pylada import default_comm
structure = Structure([[0, 0.5, 0.5],[0.5, 0, 0.5], [0.5, 0.5, 0]], scale=5.55, 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.prec = "accurate"
vasp.ediff = 25e-5
vasp.encut = 1.4
vasp.ismear = "fermi"
vasp.sigma = 0.01
vasp.relaxation = "volume"
vasp.add_specie = "Si", "{0}/pseudos/Si".format(path)
emass = EMass(copy=vasp)
assert abs(emass.encut - 1.4) < 1e-8
assert abs(emass.ediff - 25e-5) < 1e-10
directory = "/tmp/test" #mkdtemp()
if exists(directory) and directory == '/tmp/test': rmtree(directory)
if not exists(directory): makedirs(directory)
try:
result = effective_mass(vasp, structure, outdir=directory, comm=default_comm,
emassparams={'ediff': 1e-8})
result.emass
assert result.success
result = emass(structure, outdir=directory, comm=default_comm,
emassparams={'ediff': 1e-8})
assert result.success
finally:
if directory != '/tmp/test': rmtree(directory)
pass
开发者ID:mdavezac,项目名称:LaDa,代码行数:43,代码来源:runmass.py
示例14: test
def test(tmpdir, path):
from pylada.crystal import Structure
from pylada.vasp import Vasp
from pylada import default_comm
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.prec = "accurate"
vasp.ediff = 1e-5
vasp.encut = 1
vasp.ismear = "fermi"
vasp.sigma = 0.01
vasp.relaxation = "volume"
vasp.add_specie = "Si", "{0}/pseudos/Si".format(path)
result = vasp(structure, outdir=str(tmpdir), comm=default_comm)
assert result.success
开发者ID:pylada,项目名称:pylada-light,代码行数:20,代码来源:test_run.py
示例15: test_bool
def test_bool():
from pickle import loads, dumps
from pylada.vasp import Vasp
a = Vasp()
assert a._input['addgrid'].keyword == 'addgrid'
assert a._input['addgrid'].output_map() is None
assert a.addgrid is None
a.addgrid = False
assert a.addgrid is False
assert 'addgrid' in a._input['addgrid'].output_map()
assert a._input['addgrid'].output_map()['addgrid'] == '.FALSE.'
a.addgrid = True
assert a.addgrid is True
assert 'addgrid' in a._input['addgrid'].output_map()
assert a._input['addgrid'].output_map()['addgrid'] == '.TRUE.'
a.addgrid = None
assert a._input['addgrid'].keyword == 'addgrid'
assert a._input['addgrid'].output_map() is None
a.addgrid = 0
assert a.addgrid is False
a.addgrid = False
o = a._input['addgrid']
d = {'BoolKeyword': o.__class__}
assert repr(eval(repr(o), d)) == repr(o)
assert eval(repr(o), d).output_map()['addgrid'] == '.FALSE.'
assert repr(loads(dumps(o))) == repr(o)
a.addgrid = True
o = a._input['addgrid']
assert repr(eval(repr(o), d)) == repr(o)
assert eval(repr(o), d).output_map()['addgrid'] == '.TRUE.'
assert repr(loads(dumps(o))) == repr(o)
a.addgrid = None
o = a._input['addgrid']
assert repr(eval(repr(o), d)) == repr(o)
assert eval(repr(o), d).output_map() is None
assert repr(loads(dumps(o))) == repr(o)
开发者ID:mdavezac,项目名称:LaDa,代码行数:38,代码来源:keywords.py
示例16: test_lsorbit
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,代码行数:45,代码来源:test_lsorbit.py
示例17: test_istruc
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,代码行数:72,代码来源:test_restart.py
示例18: test_istart
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,代码行数:79,代码来源:test_restart.py
示例19: test_icharg
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,代码行数:101,代码来源:test_restart.py
示例20: test_istart
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,代码行数:88,代码来源:restart.py
注:本文中的pylada.vasp.Vasp类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论