Skip to content

Commit cb4eb21

Browse files
esoteric-ephemeraesoteric-ephemera
authored andcommitted
Add ZVAL to potcar_summary_stats.json; save space by using bz2 compression instead of gz for potcar_summary_stats.json
1 parent a587f20 commit cb4eb21

File tree

4 files changed

+14
-9
lines changed

4 files changed

+14
-9
lines changed

pymatgen/io/vasp/inputs.py

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1689,7 +1689,7 @@ class PotcarSingle:
16891689
)
16901690

16911691
# used for POTCAR validation
1692-
potcar_summary_stats = loadfn(f"{module_dir}/potcar_summary_stats.json.gz")
1692+
potcar_summary_stats = loadfn(f"{module_dir}/potcar_summary_stats.json.bz2")
16931693

16941694
def __init__(self, data: str, symbol: str | None = None) -> None:
16951695
"""
@@ -2369,22 +2369,26 @@ def __repr__(self) -> str:
23692369
def _gen_potcar_summary_stats(
23702370
append: bool = False,
23712371
vasp_psp_dir: str | None = None,
2372-
summary_stats_filename: str = f"{module_dir}/potcar_summary_stats.json.gz",
2372+
summary_stats_filename: str = f"{module_dir}/potcar_summary_stats.json.bz2",
23732373
):
23742374
"""
23752375
This function solely intended to be used for PMG development to regenerate the
2376-
potcar_summary_stats.json.gz file used to validate POTCARs
2376+
potcar_summary_stats.json.bz2 file used to validate POTCARs
23772377
2378-
THIS FUNCTION IS DESTRUCTIVE. It will completely overwrite your potcar_summary_stats.json.gz.
2378+
THIS FUNCTION IS DESTRUCTIVE. It will completely overwrite your potcar_summary_stats.json.bz2.
23792379
23802380
Args:
2381-
append (bool): Change whether data is appended to the existing potcar_summary_stats.json.gz,
2381+
append (bool): Change whether data is appended to the existing potcar_summary_stats.json.bz2,
23822382
or if a completely new file is generated. Defaults to False.
23832383
PMG_VASP_PSP_DIR (str): Change where this function searches for POTCARs
23842384
defaults to the PMG_VASP_PSP_DIR environment variable if not set. Defaults to None.
23852385
summary_stats_filename (str): Name of the output summary stats file. Defaults to
2386-
'<pymatgen_install_dir>/io/vasp/potcar_summary_stats.json.gz'.
2386+
'<pymatgen_install_dir>/io/vasp/potcar_summary_stats.json.bz2'.
23872387
"""
2388+
2389+
if not os.path.isfile(summary_stats_filename):
2390+
dumpfn({func: {} for func in PotcarSingle.functional_dir}, summary_stats_filename)
2391+
23882392
func_dir_exist: dict[str, str] = {}
23892393
vasp_psp_dir = vasp_psp_dir or SETTINGS.get("PMG_VASP_PSP_DIR")
23902394
for func in PotcarSingle.functional_dir:
@@ -2420,6 +2424,7 @@ def _gen_potcar_summary_stats(
24202424
"LEXCH": psp.LEXCH,
24212425
"VRHFIN": psp.VRHFIN.replace(" ", ""),
24222426
"symbol": psp.symbol,
2427+
"ZVAL": psp.ZVAL,
24232428
**psp._summary_stats,
24242429
}
24252430
)
310 KB
Binary file not shown.
-510 KB
Binary file not shown.

tests/io/vasp/test_inputs.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1249,7 +1249,7 @@ def test_from_directory(self):
12491249
def test_potcar_summary_stats() -> None:
12501250
from pymatgen.io.vasp.inputs import module_dir
12511251

1252-
potcar_summary_stats = loadfn(f"{module_dir}/potcar_summary_stats.json.gz")
1252+
potcar_summary_stats = loadfn(f"{module_dir}/potcar_summary_stats.json.bz2")
12531253

12541254
assert len(potcar_summary_stats) == 16
12551255
n_potcars_per_functional = {
@@ -1278,9 +1278,9 @@ def test_potcar_summary_stats() -> None:
12781278

12791279

12801280
def test_gen_potcar_summary_stats(tmp_path: Path, monkeypatch: MonkeyPatch) -> None:
1281-
"""Regenerate the potcar_summary_stats.json.gz file used to validate POTCARs with scrambled POTCARs."""
1281+
"""Regenerate the potcar_summary_stats.json.bz2 file used to validate POTCARs with scrambled POTCARs."""
12821282
psp_path = f"{TEST_FILES_DIR}/fake_potcar_library/"
1283-
summ_stats_file = f"{tmp_path}/fake_potcar_summary_stats.json.gz"
1283+
summ_stats_file = f"{tmp_path}/fake_potcar_summary_stats.json.bz2"
12841284
_gen_potcar_summary_stats(append=False, vasp_psp_dir=psp_path, summary_stats_filename=summ_stats_file)
12851285

12861286
# only checking for two directories to save space, fake POTCAR library is big

0 commit comments

Comments
 (0)