本文整理汇总了Python中pymatgen.io.vasp.VaspInput类的典型用法代码示例。如果您正苦于以下问题:Python VaspInput类的具体用法?Python VaspInput怎么用?Python VaspInput使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了VaspInput类的16个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: test_brmix
def test_brmix(self):
h = VaspErrorHandler("vasp.brmix")
self.assertEqual(h.check(), True)
# The first (no good OUTCAR) correction, check IMIX
d = h.correct()
self.assertEqual(d["errors"], ['brmix'])
vi = VaspInput.from_directory(".")
self.assertEqual(vi["INCAR"]["IMIX"], 1)
self.assertTrue(os.path.exists("CHGCAR"))
# The next correction check Gamma and evenize
h.correct()
vi = VaspInput.from_directory(".")
self.assertFalse("IMIX" in vi["INCAR"])
self.assertTrue(os.path.exists("CHGCAR"))
if vi["KPOINTS"].style == Kpoints.supported_modes.Gamma and vi["KPOINTS"].num_kpts < 1:
all_kpts_even = all([
bool(n % 2 == 0) for n in vi["KPOINTS"].kpts[0]
])
self.assertFalse(all_kpts_even)
# The next correction check ISYM and no CHGCAR
h.correct()
vi = VaspInput.from_directory(".")
self.assertEqual(vi["INCAR"]["ISYM"], 0)
self.assertFalse(os.path.exists("CHGCAR"))
shutil.copy("INCAR.nelect", "INCAR")
h = VaspErrorHandler("vasp.brmix")
self.assertEqual(h.check(), False)
d = h.correct()
self.assertEqual(d["errors"], [])
开发者ID:shyamd,项目名称:custodian,代码行数:33,代码来源:test_handlers.py
示例2: check
def check(self):
msg = "Reciprocal lattice and k-lattice belong to different class of" \
" lattices."
vi = VaspInput.from_directory('.')
# According to VASP admins, you can disregard this error
# if symmetry is off
# Also disregard if automatic KPOINT generation is used
if (not vi["INCAR"].get('ISYM', True)) or \
vi[
"KPOINTS"].style == Kpoints.supported_modes.Automatic:
return False
try:
v = Vasprun(self.output_vasprun)
if v.converged:
return False
except:
pass
with open(self.output_filename, "r") as f:
for line in f:
l = line.strip()
if l.find(msg) != -1:
return True
return False
开发者ID:matk86,项目名称:custodian,代码行数:25,代码来源:handlers.py
示例3: correct
def correct(self):
# if change_algo is True, change ALGO = Fast to Normal if ALGO is
# Fast. If still not converging, following Kresse's
# recommendation, we will try two iterations of different mixing
# parameters. If this error is caught again, then kil the job
vi = VaspInput.from_directory(".")
algo = vi["INCAR"].get("ALGO", "Normal")
amix = vi["INCAR"].get("AMIX", 0.4)
bmix = vi["INCAR"].get("BMIX", 1.0)
amin = vi["INCAR"].get("AMIN", 0.1)
actions = []
if self.change_algo:
if algo == "Fast":
backup(VASP_BACKUP_FILES)
actions.append({"dict": "INCAR", "action": {"_set": {"ALGO": "Normal"}}})
elif amix > 0.1 and bmix > 0.01:
# try linear mixing
backup(VASP_BACKUP_FILES)
actions.append({"dict": "INCAR", "action": {"_set": {"AMIX": 0.1, "BMIX": 0.01, "ICHARG": 2}}})
elif bmix < 3.0 and amin > 0.01:
# Try increasing bmix
backup(VASP_BACKUP_FILES)
actions.append({"dict": "INCAR", "action": {"_set": {"AMIN": 0.01, "BMIX": 3.0, "ICHARG": 2}}})
if actions:
VaspModder(vi=vi).apply_actions(actions)
return {"errors": ["Non-converging job"], "actions": actions}
# Unfixable error. Just return None for actions.
else:
return {"errors": ["Non-converging job"], "actions": None}
开发者ID:ornl-abinitio,项目名称:custodian,代码行数:33,代码来源:handlers.py
示例4: test_lrf_comm
def test_lrf_comm(self):
h = LrfCommutatorHandler("std_err.txt")
self.assertEqual(h.check(), True)
d = h.correct()
self.assertEqual(d["errors"], ['lrf_comm'])
vi = VaspInput.from_directory(".")
self.assertEqual(vi["INCAR"]["LPEAD"], True)
开发者ID:shyamd,项目名称:custodian,代码行数:7,代码来源:test_handlers.py
示例5: get_runs
def get_runs(vasp_command, target=1e-3, max_steps=10, mode="linear"):
energy = 0
vinput = VaspInput.from_directory(".")
kpoints = vinput["KPOINTS"].kpts[0]
for i in range(max_steps):
if mode == "linear":
m = [k * (i + 1) for k in kpoints]
else:
m = [k + 1 for k in kpoints]
if i == 0:
settings = None
backup = True
else:
backup = False
v = Vasprun("vasprun.xml")
e_per_atom = v.final_energy / len(v.final_structure)
ediff = abs(e_per_atom - energy)
if ediff < target:
logging.info("Converged to {} eV/atom!".format(ediff))
break
else:
energy = e_per_atom
settings = [
{"dict": "INCAR",
"action": {"_set": {"ISTART": 1}}},
{'dict': 'KPOINTS',
'action': {'_set': {'kpoints': [m]}}},
{"filename": "CONTCAR",
"action": {"_file_copy": {"dest": "POSCAR"}}}]
yield VaspJob(vasp_command, final=False, backup=backup,
suffix=".kpoints.{}".format("x".join(map(str, m))),
settings_override=settings)
开发者ID:czhengsci,项目名称:custodian,代码行数:32,代码来源:converge_kpoints.py
示例6: test_check_correct
def test_check_correct(self):
h = VaspErrorHandler("vasp.teterror")
h.check()
d = h.correct()
self.assertEqual(d["errors"], ['tet'])
self.assertEqual(d["actions"],
[{'action': {'_set': {'ISMEAR': 0}},
'dict': 'INCAR'}])
h = VaspErrorHandler("vasp.teterror", errors_subset_to_catch=["eddrmm"])
self.assertFalse(h.check())
h = VaspErrorHandler("vasp.sgrcon")
h.check()
d = h.correct()
self.assertEqual(d["errors"], ['rot_matrix'])
self.assertEqual(set([a["dict"] for a in d["actions"]]),
{"KPOINTS"})
h = VaspErrorHandler("vasp.real_optlay")
h.check()
d = h.correct()
self.assertEqual(d["errors"], ['real_optlay'])
self.assertEqual(d["actions"],
[{'action': {'_set': {'LREAL': False}},
'dict': 'INCAR'}])
subdir = os.path.join(test_dir, "large_cell_real_optlay")
os.chdir(subdir)
shutil.copy("INCAR", "INCAR.orig")
h = VaspErrorHandler()
h.check()
d = h.correct()
self.assertEqual(d["errors"], ['real_optlay'])
vi = VaspInput.from_directory(".")
self.assertEqual(vi["INCAR"]["LREAL"], True)
h.check()
d = h.correct()
self.assertEqual(d["errors"], ['real_optlay'])
vi = VaspInput.from_directory(".")
self.assertEqual(vi["INCAR"]["LREAL"], False)
shutil.copy("INCAR.orig", "INCAR")
os.remove("INCAR.orig")
os.remove("error.1.tar.gz")
os.remove("error.2.tar.gz")
os.chdir(test_dir)
开发者ID:shyamd,项目名称:custodian,代码行数:46,代码来源:test_handlers.py
示例7: test_oom
def test_oom(self):
vi = VaspInput.from_directory(".")
from custodian.vasp.interpreter import VaspModder
VaspModder(vi=vi).apply_actions([{"dict": "INCAR",
"action": {"_set": {"KPAR": 4}}}])
h = StdErrHandler("std_err.txt.oom", correct_out_of_memory=True)
self.assertEqual(h.check(), True)
d = h.correct()
self.assertEqual(d["errors"], ['out_of_memory'])
self.assertEqual(d["actions"],
[{'dict': 'INCAR',
'action': {'_set': {'KPAR': 2}}}])
h = StdErrHandler("std_err.txt.oom2", correct_out_of_memory=True)
self.assertEqual(h.check(), True)
d = h.correct()
self.assertEqual(d["errors"], ['out_of_memory'])
self.assertEqual(d["actions"],
[{'dict': 'INCAR',
'action': {'_set': {'KPAR': 1}}}])
vi = VaspInput.from_directory(".")
from custodian.vasp.interpreter import VaspModder
VaspModder(vi=vi).apply_actions([{"dict": "INCAR",
"action": {"_set": {"KPAR": 4}}}])
h = StdErrHandler("std_err.txt.emlsp", correct_out_of_memory=True)
self.assertEqual(h.check(), True)
d = h.correct()
self.assertEqual(d["errors"], ['out_of_memory'])
self.assertEqual(d["actions"],
[{'dict': 'INCAR',
'action': {'_set': {'KPAR': 2}}}])
vi = VaspInput.from_directory(".")
from custodian.vasp.interpreter import VaspModder
VaspModder(vi=vi).apply_actions([{"dict": "INCAR",
"action": {"_set": {"KPAR": 4}}}])
h = StdErrHandler("std_err.txt.insufficient_mem", correct_out_of_memory=True)
self.assertEqual(h.check(), True)
d = h.correct()
self.assertEqual(d["errors"], ['out_of_memory'])
self.assertEqual(d["actions"],
[{'dict': 'INCAR',
'action': {'_set': {'KPAR': 2}}}])
开发者ID:xhqu1981,项目名称:custodian,代码行数:44,代码来源:test_handlers.py
示例8: check
def check(self):
vi = VaspInput.from_directory(".")
nelm = vi["INCAR"].get("NELM", 60)
try:
oszicar = Oszicar(self.output_filename)
esteps = oszicar.electronic_steps
if len(esteps) > self.nionic_steps:
return all([len(e) == nelm for e in esteps[-(self.nionic_steps + 1) : -1]])
except:
pass
return False
开发者ID:ornl-abinitio,项目名称:custodian,代码行数:11,代码来源:handlers.py
示例9: test_lrf_comm
def test_lrf_comm(self):
h = StdErrHandler("std_err.txt")
self.assertEqual(h.check(), True)
d = h.correct()
self.assertEqual(d["errors"], ['lrf_comm'])
vi = VaspInput.from_directory(".")
self.assertEqual(vi["INCAR"]["ISTART"], 1)
self.assertEqual(h.check(), True)
d = h.correct()
self.assertEqual(d["errors"], ['lrf_comm'])
self.assertEqual(d["actions"], []) # don't correct twice
开发者ID:xhqu1981,项目名称:custodian,代码行数:12,代码来源:test_handlers.py
示例10: correct
def correct(self):
backup(VASP_BACKUP_FILES | {self.output_filename})
actions = []
vi = VaspInput.from_directory(".")
if "lrf_comm" in self.errors:
if Outcar(zpath(os.path.join(
os.getcwd(), "OUTCAR"))).is_stopped is False:
if not vi["INCAR"].get("LPEAD"):
actions.append({"dict": "INCAR",
"action": {"_set": {"LPEAD": True}}})
VaspModder(vi=vi).apply_actions(actions)
return {"errors": list(self.errors), "actions": actions}
开发者ID:matk86,项目名称:custodian,代码行数:14,代码来源:handlers.py
示例11: test_seg_fault
def test_seg_fault(self):
vi = VaspInput.from_directory(".")
from custodian.vasp.interpreter import VaspModder
VaspModder(vi=vi).apply_actions([{"dict": "INCAR",
"action": {"_set": {"KPAR": 4}}}])
h = StdErrHandler("std_err.txt.seg_fault", correct_seg_fault=True)
self.assertEqual(h.check(), True)
d = h.correct()
self.assertEqual(d["errors"], ['seg_fault'])
self.assertEqual(d["actions"],
[{'dict': 'INCAR',
'action': {'_set': {'ISMEAR': '0'}}}])
self.assertEqual(h.check(), True)
d = h.correct()
self.assertEqual(d["errors"], ['seg_fault'])
# no fix if still seg fault
self.assertEqual(d["actions"], [])
开发者ID:xhqu1981,项目名称:custodian,代码行数:17,代码来源:test_handlers.py
示例12: __init__
def __init__(self, actions=None, strict=True, vi=None):
"""
Initializes a Modder for VaspInput sets
Args:
actions ([Action]): A sequence of supported actions. See
:mod:`custodian.ansible.actions`. Default is None,
which means DictActions and FileActions are supported.
strict (bool): Indicating whether to use strict mode. In non-strict
mode, unsupported actions are simply ignored without any
errors raised. In strict mode, if an unsupported action is
supplied, a ValueError is raised. Defaults to True.
vi (VaspInput): A VaspInput object from the current directory.
Initialized automatically if not passed (but passing it will
avoid having to reparse the directory).
"""
self.vi = vi or VaspInput.from_directory('.')
actions = actions or [FileActions, DictActions]
super(VaspModder, self).__init__(actions, strict)
开发者ID:ProjectFrank,项目名称:custodian,代码行数:19,代码来源:interpreter.py
示例13: run
def run(self):
"""
Perform the actual VASP run.
Returns:
(subprocess.Popen) Used for monitoring.
"""
cmd = list(self.vasp_cmd)
if self.auto_gamma:
vi = VaspInput.from_directory(".")
kpts = vi["KPOINTS"]
if kpts.style == "Gamma" and tuple(kpts.kpts[0]) == (1, 1, 1):
if self.gamma_vasp_cmd is not None and which(
self.gamma_vasp_cmd[-1]):
cmd = self.gamma_vasp_cmd
elif which(cmd[-1] + ".gamma"):
cmd[-1] += ".gamma"
logging.info("Running {}".format(" ".join(cmd)))
with open(self.output_file, 'w') as f:
p = subprocess.Popen(cmd, stdout=f)
return p
开发者ID:ProjectFrank,项目名称:custodian,代码行数:21,代码来源:jobs.py
示例14: test_brmix
def test_brmix(self):
h = VaspErrorHandler("vasp.brmix")
self.assertEqual(h.check(), True)
d = h.correct()
self.assertEqual(d["errors"], ['brmix'])
vi = VaspInput.from_directory(".")
chgcar_exists = os.path.exists("CHGCAR")
if h.error_count['brmix'] > 1:
self.assertFalse(chgcar_exists)
else:
self.assertTrue(chgcar_exists)
if vi["KPOINTS"].style == Kpoints.supported_modes.Gamma and vi["KPOINTS"].num_kpts < 1:
all_kpts_even = all([
bool(n % 2 == 0) for n in vi["KPOINTS"].kpts[0]
])
self.assertFalse(all_kpts_even)
shutil.copy("INCAR.nelect", "INCAR")
h = VaspErrorHandler("vasp.brmix")
self.assertEqual(h.check(), False)
d = h.correct()
self.assertEqual(d["errors"], [])
开发者ID:aykol,项目名称:custodian,代码行数:23,代码来源:test_handlers.py
示例15: run
def run(self):
"""
Perform the actual VASP run.
Returns:
(subprocess.Popen) Used for monitoring.
"""
cmd = list(self.vasp_cmd)
if self.auto_gamma:
vi = VaspInput.from_directory(".")
kpts = vi["KPOINTS"]
if kpts.style == Kpoints.supported_modes.Gamma \
and tuple(kpts.kpts[0]) == (1, 1, 1):
if self.gamma_vasp_cmd is not None and which(
self.gamma_vasp_cmd[-1]):
cmd = self.gamma_vasp_cmd
elif which(cmd[-1] + ".gamma"):
cmd[-1] += ".gamma"
logger.info("Running {}".format(" ".join(cmd)))
with open(self.output_file, 'w') as f_std, \
open(self.stderr_file, "w", buffering=1) as f_err:
# use line buffering for stderr
p = subprocess.Popen(cmd, stdout=f_std, stderr=f_err)
return p
开发者ID:materialsproject,项目名称:custodian,代码行数:24,代码来源:jobs.py
示例16: get_jobs
def get_jobs(args):
# Returns a generator of jobs. Allows of "infinite" jobs.
vasp_command = args.command.split()
# save initial INCAR for rampU runs
n_ramp_u = args.jobs.count('rampU')
ramps = 0
if n_ramp_u:
incar = Incar.from_file('INCAR')
ldauu = incar['LDAUU']
ldauj = incar['LDAUJ']
njobs = len(args.jobs)
post_settings = [] # append to this list to have settings applied on next job
for i, job in enumerate(args.jobs):
final = False if i != njobs - 1 else True
if any(c.isdigit() for c in job):
suffix = "." + job
else:
suffix = ".{}{}".format(job, i + 1)
settings = post_settings
post_settings = []
backup = True if i == 0 else False
copy_magmom = False
vinput = VaspInput.from_directory(".")
if i > 0:
settings.append(
{"file": "CONTCAR",
"action": {"_file_copy": {"dest": "POSCAR"}}})
job_type = job.lower()
auto_npar = True
if args.no_auto_npar:
auto_npar = False
if job_type.startswith("static_derived"):
from pymatgen.io.vasp.sets import MPStaticSet
vis = MPStaticSet.from_prev_calc(
".", user_incar_settings={"LWAVE": True, "EDIFF": 1e-6},
ediff_per_atom=False)
settings.extend([
{"dict" : "INCAR",
"action": {"_set": dict(vis.incar)}},
{'dict': 'KPOINTS',
'action': {'_set': vis.kpoints.as_dict()}}])
if job_type.startswith("static_dielectric_derived"):
from pymatgen.io.vasp.sets import MPStaticSet, MPStaticDielectricDFPTVaspInputSet
# vis = MPStaticSet.from_prev_calc(
# ".", user_incar_settings={"EDIFF": 1e-6, "IBRION": 8,
# "LEPSILON": True, 'LREAL':False,
# "LPEAD": True, "ISMEAR": 0,
# "SIGMA": 0.01},
# ediff_per_atom=False)
vis = MPStaticDielectricDFPTVaspInputSet()
incar = vis.get_incar(vinput["POSCAR"].structure)
unset = {}
for k in ["NPAR", "KPOINT_BSE", "LAECHG", "LCHARG", "LVHAR",
"NSW"]:
incar.pop(k, None)
if k in vinput["INCAR"]:
unset[k] = 1
kpoints = vis.get_kpoints(vinput["POSCAR"].structure)
settings.extend([
{"dict": "INCAR",
"action": {"_set": dict(incar),
"_unset": unset}},
{'dict': 'KPOINTS',
'action': {'_set': kpoints.as_dict()}}])
auto_npar = False
elif job_type.startswith("static"):
m = [i * args.static_kpoint for i in vinput["KPOINTS"].kpts[0]]
settings.extend([
{"dict": "INCAR",
"action": {"_set": {"NSW": 0}}},
{'dict': 'KPOINTS',
'action': {'_set': {'kpoints': [m]}}}])
elif job_type.startswith("nonscf_derived"):
from pymatgen.io.vasp.sets import MPNonSCFSet
vis = MPNonSCFSet.from_prev_calc(".", copy_chgcar=False,
user_incar_settings={"LWAVE": True})
settings.extend([
{"dict": "INCAR",
"action": {"_set": dict(vis.incar)}},
{'dict': 'KPOINTS',
'action': {'_set': vis.kpoints.as_dict()}}])
elif job_type.startswith("optics_derived"):
from pymatgen.io.vasp.sets import MPNonSCFSet
vis = MPNonSCFSet.from_prev_calc(
".", optics=True, copy_chgcar=False,
nedos=2001, mode="uniform", nbands_factor=5,
user_incar_settings={"LWAVE": True, "ALGO": "Exact", "SIGMA": 0.01, "EDIFF": 1e-6},
ediff_per_atom=False)
settings.extend([
{"dict": "INCAR",
"action": {"_set": dict(vis.incar)}},
{'dict': 'KPOINTS',
#.........这里部分代码省略.........
开发者ID:czhengsci,项目名称:custodian,代码行数:101,代码来源:run_vasp.py
注:本文中的pymatgen.io.vasp.VaspInput类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论