Skip to content

Commit

Permalink
Handle serial version of VASP when reading the OUTCAR (materialsproje…
Browse files Browse the repository at this point in the history
…ct#2881)

* Handle serial compilation of VASP when reading the OUTCAR

* Compressed OUTCAR file.
  • Loading branch information
gbrunin authored Mar 8, 2023
1 parent 6656ac4 commit 7ddd848
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 1 deletion.
14 changes: 13 additions & 1 deletion pymatgen/io/vasp/outputs.py
Original file line number Diff line number Diff line change
Expand Up @@ -1828,6 +1828,11 @@ def __init__(self, filename):
self.filename = filename
self.is_stopped = False

# Assume a compilation with parallelization enabled.
# Will be checked later.
# If VASP is compiled in serial, the OUTCAR is written slightly differently.
serial_compilation = False

# data from end of OUTCAR
charge = []
mag_x = []
Expand Down Expand Up @@ -1967,6 +1972,11 @@ def __init__(self, filename):
run_stats["cores"] = None
with zopen(filename, "rt") as f:
for line in f:
if "serial" in line:
# activate the serial parallelization
run_stats["cores"] = 1
serial_compilation = True
break
if "running" in line:
if line.split()[1] == "on":
run_stats["cores"] = int(line.split()[2])
Expand Down Expand Up @@ -2000,7 +2010,9 @@ def __init__(self, filename):
for [n] in self.read_table_pattern(
r"\n{3}-{104}\n{3}",
r".+plane waves:\s+(\*{6,}|\d+)",
r"maximum and minimum number of plane-waves",
r"maximum number of plane-waves"
if serial_compilation
else r"maximum and minimum number of plane-waves",
last_one_only=False,
first_one_only=True,
)
Expand Down
5 changes: 5 additions & 0 deletions pymatgen/io/vasp/tests/test_outputs.py
Original file line number Diff line number Diff line change
Expand Up @@ -1405,6 +1405,11 @@ def test_nplwvs(self):
assert outcar.data["nplwv"] == [[None]]
assert outcar.data["nplwvs_at_kpoints"] == [85687]

def test_serial_compilation(self):
outcar = Outcar(self.TEST_FILES_DIR / "OUTCAR.serial.gz")
assert outcar.data["nplwv"] == [[74088]]
assert outcar.data["nplwvs_at_kpoints"] == [4418, 4390, 4421, 4404]

def test_vasp620_format(self):
filepath = self.TEST_FILES_DIR / "OUTCAR.vasp.6.2.0"
outcar = Outcar(filepath)
Expand Down
Binary file added test_files/OUTCAR.serial.gz
Binary file not shown.

0 comments on commit 7ddd848

Please sign in to comment.