本文整理汇总了Python中pymatgen.io.vaspio.vasp_input.VaspInput.write_input方法的典型用法代码示例。如果您正苦于以下问题:Python VaspInput.write_input方法的具体用法?Python VaspInput.write_input怎么用?Python VaspInput.write_input使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pymatgen.io.vaspio.vasp_input.VaspInput
的用法示例。
在下文中一共展示了VaspInput.write_input方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: VaspInputTest
# 需要导入模块: from pymatgen.io.vaspio.vasp_input import VaspInput [as 别名]
# 或者: from pymatgen.io.vaspio.vasp_input.VaspInput import write_input [as 别名]
class VaspInputTest(unittest.TestCase):
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)
def test_to_from_dict(self):
d = self.vinput.as_dict()
vinput = VaspInput.from_dict(d)
comp = vinput["POSCAR"].structure.composition
self.assertEqual(comp, Composition("Fe4P4O16"))
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)
def test_from_directory(self):
vi = VaspInput.from_directory(test_dir,
optional_files={"CONTCAR.Li2O": Poscar})
self.assertEqual(vi["INCAR"]["ALGO"], "Damped")
self.assertIn("CONTCAR.Li2O", vi)
d = vi.as_dict()
vinput = VaspInput.from_dict(d)
self.assertIn("CONTCAR.Li2O", vinput)