本文整理汇总了Python中pymatgen.io.vasp.inputs.Kpoints.from_file方法的典型用法代码示例。如果您正苦于以下问题:Python Kpoints.from_file方法的具体用法?Python Kpoints.from_file怎么用?Python Kpoints.from_file使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pymatgen.io.vasp.inputs.Kpoints
的用法示例。
在下文中一共展示了Kpoints.from_file方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: setup
# 需要导入模块: from pymatgen.io.vasp.inputs import Kpoints [as 别名]
# 或者: from pymatgen.io.vasp.inputs.Kpoints import from_file [as 别名]
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)
示例2: test_kpt_bands_as_dict_from_dict
# 需要导入模块: from pymatgen.io.vasp.inputs import Kpoints [as 别名]
# 或者: from pymatgen.io.vasp.inputs.Kpoints import from_file [as 别名]
def test_kpt_bands_as_dict_from_dict(self):
file_name = os.path.join(test_dir, 'KPOINTS.band')
k = Kpoints.from_file(file_name)
d = k.as_dict()
import json
json.dumps(d)
# This doesn't work
k2 = Kpoints.from_dict(d)
self.assertEqual(k.kpts, k2.kpts)
self.assertEqual(k.style, k2.style)
self.assertEqual(k.kpts_shift, k2.kpts_shift)
self.assertEqual(k.num_kpts, k2.num_kpts)
示例3: setUp
# 需要导入模块: from pymatgen.io.vasp.inputs import Kpoints [as 别名]
# 或者: from pymatgen.io.vasp.inputs.Kpoints import from_file [as 别名]
def setUp(self):
filepath = self.TEST_FILES_DIR / 'INCAR'
incar = Incar.from_file(filepath)
filepath = self.TEST_FILES_DIR / 'POSCAR'
poscar = Poscar.from_file(filepath,check_for_POTCAR=False)
if "PMG_VASP_PSP_DIR" not in os.environ:
os.environ["PMG_VASP_PSP_DIR"] = str(self.TEST_FILES_DIR)
filepath = self.TEST_FILES_DIR / 'POTCAR'
potcar = Potcar.from_file(filepath)
filepath = self.TEST_FILES_DIR / 'KPOINTS.auto'
kpoints = Kpoints.from_file(filepath)
self.vinput = VaspInput(incar, kpoints, poscar, potcar)
示例4: test_write_inputset
# 需要导入模块: from pymatgen.io.vasp.inputs import Kpoints [as 别名]
# 或者: from pymatgen.io.vasp.inputs.Kpoints import from_file [as 别名]
def test_write_inputset(self):
name = 'Test'
incar= Incar.from_file(TEST_STEP1+os.sep+'INCAR')
kpoints = Kpoints.from_file(TEST_STEP1+os.sep+'KPOINTS')
poscar = Poscar.from_file(TEST_STEP1+os.sep+'POSCAR')
potcar = TEST_STEP1+os.sep+'DUMMY_POTSPEC'
#potcar = #Potcar.from_dict({'@class': 'Potcar', 'functional': 'PBE',\
# 'symbols': ['Al'], '@module': 'pymatgen.io.vasp.inputs'})
reuse_path = [TEST_STEP1 + os.sep + 'COPY_FILE']
print (reuse_path)
mvis = MPINTVaspInputSet(name,incar,poscar,potcar,kpoints,reuse_path=reuse_path,test=True)
mvis.write_input(job_dir=TEST_STEP2)
self.assertCountEqual(os.listdir(TEST_STEP2), ['INCAR','KPOINTS','POSCAR','COPY_FILE'])
cleanup = [os.remove(TEST_STEP2+os.sep+f) for f in os.listdir(TEST_STEP2)]
示例5: setUp
# 需要导入模块: from pymatgen.io.vasp.inputs import Kpoints [as 别名]
# 或者: from pymatgen.io.vasp.inputs.Kpoints import from_file [as 别名]
def setUp(self):
filepath = os.path.join(test_dir, 'INCAR')
incar = Incar.from_file(filepath)
filepath = os.path.join(test_dir, 'POSCAR')
poscar = Poscar.from_file(filepath,check_for_POTCAR=False)
if "PMG_VASP_PSP_DIR" not in os.environ:
test_potcar_dir = os.path.abspath(
os.path.join(os.path.dirname(__file__), "..", "..", "..", "..",
"test_files"))
os.environ["PMG_VASP_PSP_DIR"] = test_potcar_dir
filepath = os.path.join(test_dir, 'POTCAR')
potcar = Potcar.from_file(filepath)
filepath = os.path.join(test_dir, 'KPOINTS.auto')
kpoints = Kpoints.from_file(filepath)
self.vinput = VaspInput(incar, kpoints, poscar, potcar)
示例6: setUp
# 需要导入模块: from pymatgen.io.vasp.inputs import Kpoints [as 别名]
# 或者: from pymatgen.io.vasp.inputs.Kpoints import from_file [as 别名]
def setUp(self):
filepath = os.path.join(test_dir, "INCAR")
incar = Incar.from_file(filepath)
filepath = os.path.join(test_dir, "POSCAR")
poscar = Poscar.from_file(filepath)
if "VASP_PSP_DIR" not in os.environ:
test_potcar_dir = os.path.abspath(
os.path.join(os.path.dirname(__file__), "..", "..", "..", "..", "test_files")
)
os.environ["VASP_PSP_DIR"] = test_potcar_dir
filepath = os.path.join(test_dir, "POTCAR")
potcar = Potcar.from_file(filepath)
filepath = os.path.join(test_dir, "KPOINTS.auto")
kpoints = Kpoints.from_file(filepath)
self.vinput = VaspInput(incar, kpoints, poscar, potcar)
示例7: test_init
# 需要导入模块: from pymatgen.io.vasp.inputs import Kpoints [as 别名]
# 或者: from pymatgen.io.vasp.inputs.Kpoints import from_file [as 别名]
def test_init(self):
prev_run = os.path.join(test_dir, "relaxation")
vis = MPNonSCFSet.from_prev_calc(
prev_calc_dir=prev_run, mode="Line", copy_chgcar=False)
self.assertEqual(vis.incar["NSW"], 0)
# Check that the ENCUT has been inherited.
self.assertEqual(vis.incar["ENCUT"], 600)
self.assertEqual(vis.kpoints.style, Kpoints.supported_modes.Reciprocal)
# Check as from dict.
vis = MPNonSCFSet.from_dict(vis.as_dict())
self.assertEqual(vis.incar["NSW"], 0)
# Check that the ENCUT has been inherited.
self.assertEqual(vis.incar["ENCUT"], 600)
self.assertEqual(vis.kpoints.style, Kpoints.supported_modes.Reciprocal)
vis.write_input(self.tmp)
self.assertFalse(os.path.exists(os.path.join(self.tmp, "CHGCAR")))
vis = MPNonSCFSet.from_prev_calc(prev_calc_dir=prev_run,
mode="Line", copy_chgcar=True)
vis.write_input(self.tmp)
self.assertTrue(os.path.exists(os.path.join(self.tmp, "CHGCAR")))
# Code below is just to make sure that the parameters are the same
# between the old MPStaticVaspInputSet and the new MPStaticSet.
# TODO: Delete code below in future.
MPNonSCFVaspInputSet.from_previous_vasp_run(
previous_vasp_dir=prev_run, output_dir=self.tmp, mode="Line")
incar = Incar.from_file(os.path.join(self.tmp, "INCAR"))
for k, v1 in vis.incar.items():
v2 = incar.get(k)
try:
v1 = v1.upper()
v2 = v2.upper()
except:
# Convert strings to upper case for comparison. Ignore other
# types.
pass
self.assertEqual(v1, v2, str(v1)+str(v2))
kpoints = Kpoints.from_file(os.path.join(self.tmp, "KPOINTS"))
self.assertEqual(kpoints.style, vis.kpoints.style)
self.assertArrayAlmostEqual(kpoints.kpts, vis.kpoints.kpts)
示例8: test_init
# 需要导入模块: from pymatgen.io.vasp.inputs import Kpoints [as 别名]
# 或者: from pymatgen.io.vasp.inputs.Kpoints import from_file [as 别名]
def test_init(self):
filepath = os.path.join(test_dir, 'KPOINTS.auto')
kpoints = Kpoints.from_file(filepath)
self.assertEqual(kpoints.kpts, [[10]], "Wrong kpoint lattice read")
filepath = os.path.join(test_dir, 'KPOINTS.cartesian')
kpoints = Kpoints.from_file(filepath)
self.assertEqual(kpoints.kpts,
[[0.25, 0, 0], [0, 0.25, 0], [0, 0, 0.25]],
"Wrong kpoint lattice read")
self.assertEqual(kpoints.kpts_shift, [0.5, 0.5, 0.5],
"Wrong kpoint shift read")
filepath = os.path.join(test_dir, 'KPOINTS')
kpoints = Kpoints.from_file(filepath)
self.kpoints = kpoints
self.assertEqual(kpoints.kpts, [[2, 4, 6]])
filepath = os.path.join(test_dir, 'KPOINTS.band')
kpoints = Kpoints.from_file(filepath)
self.assertIsNotNone(kpoints.labels)
self.assertEqual(kpoints.style, Kpoints.supported_modes.Line_mode)
kpoints_str = str(kpoints)
self.assertEqual(kpoints_str.split("\n")[3], "Reciprocal")
filepath = os.path.join(test_dir, 'KPOINTS.explicit')
kpoints = Kpoints.from_file(filepath)
self.assertIsNotNone(kpoints.kpts_weights)
self.assertEqual(str(kpoints).strip(), """Example file
4
Cartesian
0.0 0.0 0.0 1 None
0.0 0.0 0.5 1 None
0.0 0.5 0.5 2 None
0.5 0.5 0.5 4 None""")
filepath = os.path.join(test_dir, 'KPOINTS.explicit_tet')
kpoints = Kpoints.from_file(filepath)
self.assertEqual(kpoints.tet_connections, [(6, [1, 2, 3, 4])])
示例9: test_style_setter
# 需要导入模块: from pymatgen.io.vasp.inputs import Kpoints [as 别名]
# 或者: from pymatgen.io.vasp.inputs.Kpoints import from_file [as 别名]
def test_style_setter(self):
filepath = os.path.join(test_dir, 'KPOINTS')
kpoints = Kpoints.from_file(filepath)
self.assertEqual(kpoints.style, Kpoints.supported_modes.Monkhorst)
kpoints.style = "G"
self.assertEqual(kpoints.style, Kpoints.supported_modes.Gamma)
示例10: test_style_setter
# 需要导入模块: from pymatgen.io.vasp.inputs import Kpoints [as 别名]
# 或者: from pymatgen.io.vasp.inputs.Kpoints import from_file [as 别名]
def test_style_setter(self):
filepath = self.TEST_FILES_DIR / 'KPOINTS'
kpoints = Kpoints.from_file(filepath)
self.assertEqual(kpoints.style, Kpoints.supported_modes.Monkhorst)
kpoints.style = "G"
self.assertEqual(kpoints.style, Kpoints.supported_modes.Gamma)
示例11: setup_poscar_jobs
# 需要导入模块: from pymatgen.io.vasp.inputs import Kpoints [as 别名]
# 或者: from pymatgen.io.vasp.inputs.Kpoints import from_file [as 别名]
def setup_poscar_jobs(self, scale_list=None, poscar_list=None):
"""
for scaling the latice vectors of the original structure,
scale_list is volume scaling factor list
"""
if scale_list:
for scale in scale_list:
self.set_poscar(scale=scale)
self.set_potcar()
if not self.is_matrix:
job_dir = self.job_dir + os.sep + 'POS' + \
os.sep + 'VOLUME_' + str(scale)
self.add_job(name=job_dir, job_dir=job_dir)
elif poscar_list:
for pos in poscar_list:
# if it is a twod_database run or any general standard database run,
# the incar, kpoints and potcar follow a standard input set
# which will be activated by the twod_database tag set to true
# NOTE: this implementation means that the first turn_knobs tag
# needs to be the poscar objects list
# the database tag will be set to the name of the yaml file with the
# standard input deck definition for that database
# this incar dict provided as the init can be general format
# based on the chosen functional, cutoff
# so self.incar is a vdW incar for re-relaxation in vdW, gga for every
# other calculation or LDA+U for LSDA+U calculations
incar_dict = self.incar.as_dict()
if self.reuse:
# if this is a true list minimally, ['CONTCAR']
# it is to be ensured that the poscar list is a
# list of paths as opposed to list of poscar objects by the turn knobs
# values
# Here pos is the path and r in each self.reuse is the name of the file(s)
# to be reused
# in a reuse calculation the following are possible:
# update incar (Solvation calculations) or reset incar (HSE calculations)
# reset kpoints file with IBZKPT
# copy a CHGCAR or WAVECAR or both perhaps
try:
# first setup of POSCAR initial, INCAR, KPOINTS
poscar = Poscar.from_file(pos + os.sep + 'CONTCAR')
self.logger.info('Read previous relaxed CONTCAR file from {}'.
format(pos))
# check if it is KPOINTS altering job like HSE
if self.Grid_type == 'hse_bands_2D_prep':
# HSE prep calcualtions
# reset the INCAR file with a magmom only if exists
try:
incar_dict = {
'MAGMOM': get_magmom_string(poscar)}
except:
incar_dict = {}
incar_dict = get_2D_incar_hse_prep(incar_dict)
self.set_kpoints(poscar=poscar)
self.logger.info(
'updated input set for HSE 2D prep calcaultion')
elif self.Grid_type == 'hse_bands_2D':
# HSE calculation
# reset the incar and kpoints file builds
# on the preceding calculations (prep calculation)
# IBZKPT
try:
incar_dict = {
'MAGMOM': get_magmom_string(poscar)}
except:
incar_dict = {}
incar_dict = get_2D_incar_hse(incar_dict)
self.set_kpoints(poscar=poscar,
ibzkpth=pos + os.sep + 'IBZKPT')
self.logger.info('updated input set for HSE calcaultion\
using IBZKPT from {0}'.format(pos + os.sep + 'IBZKPT'))
elif self.Grid_type == 'hse_bands':
# general HSE bands
pass
elif self.Grid_type == 'Finer_G_Mesh':
self.logger.info('updating to Finer G Mesh')
kpoint = Kpoints.from_file(pos+os.sep+'KPOINTS')
self.set_kpoints(kpoint=kpoint.kpts[0])
else:
# use the same kpoints file and build from the old
# incar
self.kpoints = Kpoints.from_file(
pos + os.sep + 'KPOINTS')
# decide on how to use incar, use same one or
# update or afresh
if self.reuse_incar == 'old':
incar_dict = Incar.from_file(
pos + os.sep + 'INCAR').as_dict()
elif self.reuse_incar == 'update':
# way to go for cutoff updates, convergence, etc.
# but retain the old functional
incar_dict.update(Incar.from_file(pos + os.sep + 'INCAR').
as_dict())
else:
# use a fresh incar as specified by the init
# way to go for example for LDAU or other
#.........这里部分代码省略.........