本文整理汇总了Python中pymatgen.io.vasp.inputs.Incar类的典型用法代码示例。如果您正苦于以下问题:Python Incar类的具体用法?Python Incar怎么用?Python Incar使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Incar类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_lsorbit_magmom
def test_lsorbit_magmom(self):
magmom1 = [[0.0, 0.0, 3.0], [0, 1, 0], [2, 1, 2]]
magmom2 = [-1, -1, -1, 0, 0, 0, 0, 0]
ans_string1 = "LSORBIT = True\nMAGMOM = 0.0 0.0 3.0 0 1 0 2 1 2\n"
ans_string2 = "LSORBIT = True\nMAGMOM = 3*3*-1 3*5*0\n"
ans_string3 = "LSORBIT = False\nMAGMOM = 2*-1 2*9\n"
incar = Incar({})
incar["MAGMOM"] = magmom1
incar["LSORBIT"] = "T"
self.assertEqual(ans_string1, str(incar))
incar["MAGMOM"] = magmom2
incar["LSORBIT"] = "T"
self.assertEqual(ans_string2, str(incar))
incar = Incar.from_string(ans_string1)
self.assertEqual(incar["MAGMOM"], [[0.0, 0.0, 3.0], [0, 1, 0], [2, 1, 2]])
incar = Incar.from_string(ans_string2)
self.assertEqual(
incar["MAGMOM"],
[[-1, -1, -1], [-1, -1, -1], [-1, -1, -1], [0, 0, 0], [0, 0, 0], [0, 0, 0], [0, 0, 0], [0, 0, 0]],
)
incar = Incar.from_string(ans_string3)
self.assertFalse(incar["LSORBIT"])
self.assertEqual(incar["MAGMOM"], [-1, -1, 9, 9])
示例2: run_major_axis_anisotropy_calculations
def run_major_axis_anisotropy_calculations(submit=True):
"""
Perform static calculations with the magnetic axis along
100, 010, and 001.
Kwargs:
submit (bool): Whether or not to submit the job.
"""
if not os.path.isdir('MAE'):
os.mkdir('MAE')
os.chdir('MAE')
for d in ['100', '010', '001']:
if not os.path.isdir(d):
os.path.mkdir(d)
os.chdir(d)
os.system('cp ../CONTCAR POSCAR')
os.system('cp ../POTCAR .')
axis = [float(char) for char in d]
# Small positive number, see vasp manual
if d in ['001', '010']:
axis[0] = 0.00000001
else:
axis[1] = 0.00000001
saxis = ' '.join(axis)
incar_dict = INCAR_DICT
incar_dict.update({'EDIFF': 1e-8, 'GGA_COMPAT': False, 'ISMEAR': -5,
'LORBIT': 11, 'LSORBIT': True, 'LWAVE': False,
'LCHARG': False, 'LAECHG': False,
'MAGMOM': get_magmom_string(), 'SAXIS': saxis})
Incar.from_dict(incar_dict).write_file('INCAR')
if submit:
os.system(submission_command)
示例3: test_as_dict_and_from_dict
def test_as_dict_and_from_dict(self):
d = self.incar.as_dict()
incar2 = Incar.from_dict(d)
self.assertEqual(self.incar, incar2)
d["MAGMOM"] = [Magmom([1, 2, 3]).as_dict()]
incar3 = Incar.from_dict(d)
self.assertEqual(incar3["MAGMOM"], [Magmom([1, 2, 3])])
示例4: relax
def relax(dim=2, submit=True, force_overwrite=False):
"""
Writes input files and (optionally) submits a self-consistent
relaxation. Should be run before pretty much anything else, in
order to get the right energy and structure of the material.
Args:
dim (int): 2 for relaxing a 2D material, 3 for a 3D material.
submit (bool): Whether or not to submit the job.
force_overwrite (bool): Whether or not to overwrite files
if an already converged vasprun.xml exists in the
directory.
"""
if force_overwrite or not utl.is_converged(os.getcwd()):
directory = os.getcwd().split('/')[-1]
# vdw_kernel.bindat file required for VDW calculations.
if VDW_KERNEL:
os.system('cp {} .'.format(VDW_KERNEL))
# KPOINTS
Kpoints.automatic_density(Structure.from_file('POSCAR'),
1000).write_file('KPOINTS')
# INCAR
INCAR_DICT.update(
{'MAGMOM': utl.get_magmom_string(Structure.from_file('POSCAR'))}
)
Incar.from_dict(INCAR_DICT).write_file('INCAR')
# POTCAR
utl.write_potcar()
# Special tasks only performed for 2D materials.
if dim == 2:
# Ensure 20A interlayer vacuum
utl.ensure_vacuum(Structure.from_file('POSCAR'), 20)
# Remove all z k-points.
kpts_lines = open('KPOINTS').readlines()
with open('KPOINTS', 'w') as kpts:
for line in kpts_lines[:3]:
kpts.write(line)
kpts.write(kpts_lines[3].split()[0] + ' '
+ kpts_lines[3].split()[1] + ' 1')
# Submission script
if dim == 2:
binary = VASP_TWOD_BIN
elif dim == 3:
binary = VASP_STD_BIN
if QUEUE_SYSTEM == 'pbs':
utl.write_pbs_runjob(directory, 1, 16, '800mb', '6:00:00', binary)
submission_command = 'qsub runjob'
elif QUEUE_SYSTEM == 'slurm':
utl.write_slurm_runjob(directory, 16, '800mb', '6:00:00', binary)
submission_command = 'sbatch runjob'
if submit:
os.system(submission_command)
示例5: run_major_axis_anisotropy_calculations
def run_major_axis_anisotropy_calculations(submit=True):
"""
Perform static calculations with the magnetic axis along
100, 010, and 001.
Args:
submit (bool): Whether or not to submit the job.
"""
if not os.path.isdir('MAE'):
os.mkdir('MAE')
os.chdir('MAE')
for d in ['100', '010', '001']:
if not os.path.isdir(d):
os.mkdir(d)
os.chdir(d)
os.system('cp ../CONTCAR POSCAR')
os.system('cp ../POTCAR .')
axis = [float(char) for char in d]
# Small positive number, see vasp manual
if d in ['001', '010']:
axis[0] = 0.00000001
else:
axis[1] = 0.00000001
saxis = ' '.join(axis)
incar_dict = INCAR_DICT
incar_dict.update({'EDIFF': 1e-8,
'GGA_COMPAT': False,
'ISMEAR': -5,
'LORBIT': 11,
'LSORBIT': True,
'LWAVE': False,
'LCHARG': False,
'LAECHG': False,
'MAGMOM': get_magmom_string(
Structure.from_file('POSCAR')
),
'SAXIS': saxis})
Incar.from_dict(incar_dict).write_file('INCAR')
if QUEUE_SYSTEM == 'pbs':
utl.write_pbs_runjob(directory, 1, 16, '800mb', '6:00:00',
VASP_TWOD_BIN)
submission_command = 'qsub runjob'
elif QUEUE_SYSTEM == 'slurm':
utl.write_slurm_runjob(directory, 16, '800mb', '6:00:00',
VASP_TWOD_BIN)
submission_command = 'sbatch runjob'
if submit:
os.system(submission_command)
示例6: run_hse_prep_calculation
def run_hse_prep_calculation(dim=2, submit=True):
"""
Submits a quick static calculation to calculate the IBZKPT
file using a smaller number of k-points (200/atom instead of
1000/atom). The other outputs from this calculation are
essentially useless.
Args:
dim (int): 2 for relaxing a 2D material, 3 for a 3D material.
submit (bool): Whether or not to submit the job.
"""
if not os.path.isdir('hse_prep'):
os.mkdir('hse_prep')
os.chdir('hse_prep')
os.system('cp ../CONTCAR ./POSCAR')
if os.path.isfile('../POTCAR'):
os.system('cp POTCAR .')
relax(dim=2, submit=False)
incar_dict = Incar.from_file('INCAR').as_dict()
incar_dict.update({'NSW': 0, 'NELM': 1, 'LWAVE': False, 'LCHARG': False,
'LAECHG': False})
Incar.from_dict(incar_dict).write_file('INCAR')
Kpoints.automatic_density(
Structure.from_file('POSCAR'), 200
).write_file('KPOINTS')
if dim == 2:
kpts_lines = open('KPOINTS').readlines()
with open('KPOINTS', 'w') as kpts:
for line in kpts_lines[:3]:
kpts.write(line)
kpts.write(kpts_lines[3].split()[0] + ' '
+ kpts_lines[3].split()[1] + ' 1')
if QUEUE == 'pbs':
write_pbs_runjob('{}_prep'.format(
os.getcwd().split('/')[-2]), 1, 16, '800mb', '6:00:00', VASP)
submission_command = 'qsub runjob'
elif QUEUE == 'slurm':
write_slurm_runjob('{}_prep'.format(
os.getcwd().split('/')[-2]), 16, '800mb', '6:00:00', VASP)
submission_command = 'sbatch runjob'
if submit:
os.system(submission_command)
os.chdir('../')
示例7: __init__
def __init__(self, name, incar, poscar, potcar, kpoints,
qadapter=None, **kwargs ):
"""
default INCAR from config_dict
"""
self.name = name
self.incar = Incar.from_dict(incar.as_dict())
self.poscar = Poscar.from_dict(poscar.as_dict())
self.potcar = Potcar.from_dict(potcar.as_dict())
self.kpoints = Kpoints.from_dict(kpoints.as_dict())
self.extra = kwargs
if qadapter is not None:
self.qadapter = qadapter.from_dict(qadapter.to_dict())
else:
self.qadapter = None
config_dict = {}
config_dict['INCAR'] = self.incar.as_dict()
config_dict['POSCAR'] = self.poscar.as_dict()
#caution the key and the value are not always the same
config_dict['POTCAR'] = self.potcar.as_dict()
#dict(zip(self.potcar.as_dict()['symbols'],
#self.potcar.as_dict()['symbols']))
config_dict['KPOINTS'] = self.kpoints.as_dict()
#self.user_incar_settings = self.incar.as_dict()
DictVaspInputSet.__init__(self, name, config_dict,
ediff_per_atom=False, **kwargs)
示例8: setup
def setup(self):
"""
setup static jobs for all the calibrate objects
copies CONTCAR to POSCAR
sets NSW = 0
"""
for cal in self.cal_objs:
for i, jdir in enumerate(cal.old_job_dir_list):
job_dir = self.job_dir + os.sep \
+ jdir.replace(os.sep, '_').replace('.', '_') \
+ os.sep + 'STATIC'
logger.info('setting up job in {}'.format(job_dir))
cal.incar = Incar.from_file(jdir + os.sep + 'INCAR')
cal.incar['EDIFF'] = '1E-6'
cal.incar['NSW'] = 0
cal.potcar = Potcar.from_file(jdir + os.sep + 'POTCAR')
cal.kpoints = Kpoints.from_file(jdir + os.sep + 'KPOINTS')
contcar_file = jdir + os.sep + 'CONTCAR'
if os.path.isfile(contcar_file):
logger.info('setting poscar file from {}'
.format(contcar_file))
cal.poscar = Poscar.from_file(contcar_file)
cal.add_job(job_dir=job_dir)
else:
logger.critical("""CONTCAR doesnt exist.
Setting up job using input set in the old
calibration directory""")
cal.poscar = Poscar.from_file(jdir + os.sep + 'POSCAR')
cal.add_job(job_dir=job_dir)
示例9: run_task
def run_task(self, fw_spec):
chgcar_start = False
# read the VaspInput from the previous run
poscar = Poscar.from_file(zpath('POSCAR'))
incar = Incar.from_file(zpath('INCAR'))
# figure out what GGA+U values to use and override them
# LDAU values to use
mpvis = MPVaspInputSet()
ggau_incar = mpvis.get_incar(poscar.structure).as_dict()
incar_updates = {k: ggau_incar[k] for k in ggau_incar.keys() if 'LDAU' in k}
for k in ggau_incar:
# update any parameters not set explicitly in previous INCAR
if k not in incar and k in ggau_incar:
incar_updates[k] = ggau_incar[k]
incar.update(incar_updates) # override the +U keys
# start from the CHGCAR of previous run
if os.path.exists('CHGCAR'):
incar['ICHARG'] = 1
chgcar_start = True
# write back the new INCAR to the current directory
incar.write_file('INCAR')
return FWAction(stored_data={'chgcar_start': chgcar_start})
示例10: run_pbe_calculation
def run_pbe_calculation(dim=2, submit=True, force_overwrite=False):
"""
Setup and submit a normal PBE calculation for band structure along
high symmetry k-paths.
Args:
dim (int): 2 for relaxing a 2D material, 3 for a 3D material.
submit (bool): Whether or not to submit the job.
force_overwrite (bool): Whether or not to overwrite files
if an already converged vasprun.xml exists in the
directory.
"""
PBE_INCAR_DICT = {'EDIFF': 1e-6, 'IBRION': 2, 'ISIF': 3,
'ISMEAR': 1, 'NSW': 0, 'LVTOT': True, 'LVHAR': True,
'LORBIT': 1, 'LREAL': 'Auto', 'NPAR': 4,
'PREC': 'Accurate', 'LWAVE': True, 'SIGMA': 0.1,
'ENCUT': 500, 'ISPIN': 2}
directory = os.getcwd().split('/')[-1]
if not os.path.isdir('pbe_bands'):
os.mkdir('pbe_bands')
if force_overwrite or not is_converged('pbe_bands'):
os.system('cp CONTCAR pbe_bands/POSCAR')
if os.path.isfile('POTCAR'):
os.system('cp POTCAR pbe_bands/')
PBE_INCAR_DICT.update({'MAGMOM': get_magmom_string()})
Incar.from_dict(PBE_INCAR_DICT).write_file('pbe_bands/INCAR')
structure = Structure.from_file('POSCAR')
kpath = HighSymmKpath(structure)
Kpoints.automatic_linemode(20, kpath).write_file('pbe_bands/KPOINTS')
os.chdir('pbe_bands')
if dim == 2:
remove_z_kpoints()
if QUEUE == 'pbs':
write_pbs_runjob(directory, 1, 16, '800mb', '6:00:00', VASP)
submission_command = 'qsub runjob'
elif QUEUE == 'slurm':
write_slurm_runjob(directory, 16, '800mb', '6:00:00', VASP)
submission_command = 'sbatch runjob'
if submit:
os.system(submission_command)
os.chdir('../')
示例11: test_quad_efg
def test_quad_efg(self):
incar1 = Incar({})
incar1["LEFG"] = True
incar1["QUAD_EFG"] = [0.0, 146.6, -25.58]
ans_string1 = "LEFG = True\nQUAD_EFG = 0.0 146.6 -25.58\n"
self.assertEqual(ans_string1, str(incar1))
incar2 = Incar.from_string(ans_string1)
self.assertEqual(ans_string1, str(incar2))
示例12: test_lsorbit_magmom
def test_lsorbit_magmom(self):
magmom1 = [[0.0, 0.0, 3.0], [0, 1, 0], [2, 1, 2]]
magmom2 = [-1, -1, -1, 0, 0, 0, 0, 0]
magmom4 = [Magmom([1.0, 2.0, 2.0])]
ans_string1 = "LANGEVIN_GAMMA = 10 10 10\nLSORBIT = True\n" \
"MAGMOM = 0.0 0.0 3.0 0 1 0 2 1 2\n"
ans_string2 = "LANGEVIN_GAMMA = 10\nLSORBIT = True\n" \
"MAGMOM = 3*3*-1 3*5*0\n"
ans_string3 = "LSORBIT = False\nMAGMOM = 2*-1 2*9\n"
ans_string4_nolsorbit = "LANGEVIN_GAMMA = 10\nLSORBIT = False\nMAGMOM = 1*3.0\n"
ans_string4_lsorbit = "LANGEVIN_GAMMA = 10\nLSORBIT = True\nMAGMOM = 1.0 2.0 2.0\n"
incar = Incar({})
incar["MAGMOM"] = magmom1
incar["LSORBIT"] = "T"
incar["LANGEVIN_GAMMA"] = [10, 10, 10]
self.assertEqual(ans_string1, str(incar))
incar["MAGMOM"] = magmom2
incar["LSORBIT"] = "T"
incar["LANGEVIN_GAMMA"] = 10
self.assertEqual(ans_string2, str(incar))
incar["MAGMOM"] = magmom4
incar["LSORBIT"] = "F"
self.assertEqual(ans_string4_nolsorbit, str(incar))
incar["LSORBIT"] = "T"
self.assertEqual(ans_string4_lsorbit, str(incar))
incar = Incar.from_string(ans_string1)
self.assertEqual(incar["MAGMOM"],
[[0.0, 0.0, 3.0], [0, 1, 0], [2, 1, 2]])
self.assertEqual(incar["LANGEVIN_GAMMA"], [10, 10, 10])
incar = Incar.from_string(ans_string2)
self.assertEqual(incar["MAGMOM"], [[-1, -1, -1], [-1, -1, -1],
[-1, -1, -1], [0, 0, 0],
[0, 0, 0], [0, 0, 0],
[0, 0, 0], [0, 0, 0]])
self.assertEqual(incar["LANGEVIN_GAMMA"], [10])
incar = Incar.from_string(ans_string3)
self.assertFalse(incar["LSORBIT"])
self.assertEqual(incar["MAGMOM"], [-1, -1, 9, 9])
示例13: from_dict
def from_dict(cls, d):
incar = Incar.from_dict(d["incar"])
poscar = Poscar.from_dict(d["poscar"])
potcar = Potcar.from_dict(d["potcar"])
kpoints = Kpoints.from_dict(d["kpoints"])
qadapter = None
if d["qadapter"] is not None:
qadapter = CommonAdapter.from_dict(d["qadapter"])
return MPINTVaspInputSet(d["name"], incar, poscar, potcar,
kpoints, qadapter, **d["kwargs"])
示例14: test_optics
def test_optics(self):
self.mpopticsparamset = MPOpticsNonSCFVaspInputSet.from_previous_vasp_run(
'{}/static_silicon'.format(test_dir), output_dir='optics_test_dir',
nedos=1145)
self.assertTrue(os.path.exists('optics_test_dir/CHGCAR'))
incar = Incar.from_file('optics_test_dir/INCAR')
self.assertTrue(incar['LOPTICS'])
self.assertEqual(incar['NEDOS'], 1145)
#Remove the directory in which the inputs have been created
shutil.rmtree('optics_test_dir')
示例15: test_write
def test_write(self):
tmp_dir = "VaspInput.testing"
self.vinput.write_input(tmp_dir)
filepath = os.path.join(tmp_dir, "INCAR")
incar = Incar.from_file(filepath)
self.assertEqual(incar["NSW"], 99)
for name in ("INCAR", "POSCAR", "POTCAR", "KPOINTS"):
os.remove(os.path.join(tmp_dir, name))
os.rmdir(tmp_dir)