本文整理汇总了Python中pymatgen.io.vaspio.vasp_input.Kpoints.from_file方法的典型用法代码示例。如果您正苦于以下问题:Python Kpoints.from_file方法的具体用法?Python Kpoints.from_file怎么用?Python Kpoints.from_file使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pymatgen.io.vaspio.vasp_input.Kpoints
的用法示例。
在下文中一共展示了Kpoints.from_file方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_kpt_bands_to_dict_from_dict
# 需要导入模块: from pymatgen.io.vaspio.vasp_input import Kpoints [as 别名]
# 或者: from pymatgen.io.vaspio.vasp_input.Kpoints import from_file [as 别名]
def test_kpt_bands_to_dict_from_dict(self):
file_name = os.path.join(test_dir, 'KPOINTS.band')
k = Kpoints.from_file(file_name)
d = k.to_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)
示例2: test_init
# 需要导入模块: from pymatgen.io.vaspio.vasp_input import Kpoints [as 别名]
# 或者: from pymatgen.io.vaspio.vasp_input.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.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, "Line_mode")
filepath = os.path.join(test_dir, "KPOINTS.explicit")
kpoints = Kpoints.from_file(filepath)
self.assertIsNotNone(kpoints.kpts_weights)
filepath = os.path.join(test_dir, "KPOINTS.explicit_tet")
kpoints = Kpoints.from_file(filepath)
self.assertEqual(kpoints.tet_connections, [(6, [1, 2, 3, 4])])
示例3: setUp
# 需要导入模块: from pymatgen.io.vaspio.vasp_input import Kpoints [as 别名]
# 或者: from pymatgen.io.vaspio.vasp_input.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)
示例4: test_kpt_bands_to_dict_from_dict
# 需要导入模块: from pymatgen.io.vaspio.vasp_input import Kpoints [as 别名]
# 或者: from pymatgen.io.vaspio.vasp_input.Kpoints import from_file [as 别名]
def test_kpt_bands_to_dict_from_dict(self):
file_name = os.path.join(test_dir, "KPOINTS.band")
k = Kpoints.from_file(file_name)
d = k.to_dict
示例5: from_previous_vasp_run
# 需要导入模块: from pymatgen.io.vaspio.vasp_input import Kpoints [as 别名]
# 或者: from pymatgen.io.vaspio.vasp_input.Kpoints import from_file [as 别名]
def from_previous_vasp_run(previous_vasp_dir, output_dir='.',
user_incar_settings=None,
make_dir_if_not_present=True):
"""
Generate a set of Vasp input files for static calculations from a
directory of previous Vasp run.
Args:
previous_vasp_dir:
The directory contains the outputs(vasprun.xml and OUTCAR) of
previous vasp run.
output_dir:
The directory to write the VASP input files for the static
calculations. Default to write in the current directory.
make_dir_if_not_present:
Set to True if you want the directory (and the whole path) to
be created if it is not present.
"""
try:
vasp_run = Vasprun(os.path.join(previous_vasp_dir, "vasprun.xml"),
parse_dos=False, parse_eigen=None)
outcar = Outcar(os.path.join(previous_vasp_dir, "OUTCAR"))
previous_incar = Incar.from_file(os.path.join(previous_vasp_dir,
"INCAR"))
kpoints = Kpoints.from_file(os.path.join(previous_vasp_dir,
"KPOINTS"))
except:
traceback.format_exc()
raise RuntimeError("Can't get valid results from previous run")
structure = MPStaticVaspInputSet.get_structure(
vasp_run, outcar)
mpsvip = MPStaticVaspInputSet()
mpsvip.write_input(structure, output_dir, make_dir_if_not_present)
new_incar = Incar.from_file(os.path.join(output_dir, "INCAR"))
# Use previous run INCAR and override necessary parameters
previous_incar.update({"IBRION": -1, "ISMEAR": -5, "LAECHG": True,
"LCHARG": True, "LORBIT": 11, "LVHAR": True,
"LWAVE": False, "NSW": 0, "ICHARG": 0})
# Compare ediff between previous and staticinputset values,
# choose the tigher ediff
previous_incar.update({"EDIFF": min(previous_incar["EDIFF"],
new_incar["EDIFF"])})
# add user settings
if user_incar_settings:
previous_incar.update(user_incar_settings)
previous_incar.write_file(os.path.join(output_dir, "INCAR"))
# Prefer to use k-point scheme from previous run
kpoints_out = Kpoints.from_file(os.path.join(output_dir, "KPOINTS"))
if kpoints.style != kpoints_out.style and \
SymmetryFinder(structure, 0.01).get_lattice_type() != \
"hexagonal":
k_div = (kp + 1 if kp % 2 == 1 else kp
for kp in kpoints_out.kpts[0])
Kpoints.monkhorst_automatic(k_div).write_file(
os.path.join(output_dir, "KPOINTS"))