Skip to content

Commit acdd5af

Browse files
author
Shyue Ping Ong
committed
Add from_prev_incar method.
1 parent a49f43b commit acdd5af

File tree

2 files changed

+25
-0
lines changed

2 files changed

+25
-0
lines changed

pymatgen/io/vasp/sets.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1281,6 +1281,22 @@ def incar(self) -> Incar:
12811281
incar[p] = self.prev_incar[p]
12821282
return incar
12831283

1284+
@classmethod
1285+
def from_prev_calc(cls, prev_calc_dir, **kwargs):
1286+
"""
1287+
Generate a set of VASP input files for static calculations from a directory of previous VASP run.
1288+
1289+
Args:
1290+
prev_calc_dir (str): Directory containing the outputs(
1291+
vasprun.xml and OUTCAR) of previous vasp run.
1292+
**kwargs: All kwargs supported by MatPESStaticSet, other than prev_incar
1293+
and prev_structure and prev_kpoints which are determined from
1294+
the prev_calc_dir.
1295+
"""
1296+
vrun = sorted(f for f in os.listdir(prev_calc_dir) if f.startswith("vasprun.xml"))[-1]
1297+
v = Vasprun(os.path.join(prev_calc_dir, vrun))
1298+
return cls(v.final_structure, prev_incar=v.incar, **kwargs)
1299+
12841300

12851301
class MPScanStaticSet(MPScanRelaxSet):
12861302
"""

tests/io/vasp/test_sets.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -847,6 +847,15 @@ def test_functionals(self):
847847
diff_potcar = MatPESStaticSet(self.struct, user_potcar_functional="PBE")
848848
assert str(diff_potcar.potcar[0]) == str(PotcarSingle.from_symbol_and_functional("Fe_pv", "PBE"))
849849

850+
def test_from_prev_calc(self):
851+
vis = MatPESStaticSet.from_prev_calc(f"{TEST_FILES_DIR}/relaxation")
852+
incar = vis.incar
853+
assert incar["GGA"] == "Pe"
854+
assert incar["ALGO"] == "Normal"
855+
assert vis.potcar_symbols == ["Li_sv"]
856+
assert vis.potcar.functional == "PBE_54"
857+
assert vis.kpoints is None
858+
850859

851860
class TestMPNonSCFSet(PymatgenTest):
852861
def setUp(self):

0 commit comments

Comments
 (0)