From c1e1e0d7f0df3d5901d618cbedb4a9acb44f6e98 Mon Sep 17 00:00:00 2001 From: Janosh Riebesell Date: Tue, 10 Oct 2023 10:18:17 -0700 Subject: [PATCH] add test_potcar_summary_stats() (#3395) --- pymatgen/io/vasp/inputs.py | 4 ++-- tests/io/vasp/test_inputs.py | 33 ++++++++++++++++++++++++++++++++- 2 files changed, 34 insertions(+), 3 deletions(-) diff --git a/pymatgen/io/vasp/inputs.py b/pymatgen/io/vasp/inputs.py index d2f242c0c27..b4db0bfdad9 100644 --- a/pymatgen/io/vasp/inputs.py +++ b/pymatgen/io/vasp/inputs.py @@ -1,6 +1,6 @@ """ -Classes for reading/manipulating/writing VASP input files. All major VASP input -files. +Classes for reading/manipulating/writing VASP input files. +All major VASP input files. """ from __future__ import annotations diff --git a/tests/io/vasp/test_inputs.py b/tests/io/vasp/test_inputs.py index 6f52a3a3620..3eabbc38cf0 100644 --- a/tests/io/vasp/test_inputs.py +++ b/tests/io/vasp/test_inputs.py @@ -1229,7 +1229,38 @@ def test_from_directory(self): assert "CONTCAR.Li2O" in vasp_input -def test_gen_potcar_summary_stats(tmp_path: Path, monkeypatch: MonkeyPatch): +def test_potcar_summary_stats() -> None: + from pymatgen.io.vasp.inputs import module_dir + + potcar_summary_stats = loadfn(f"{module_dir}/potcar_summary_stats.json.gz") + + assert len(potcar_summary_stats) == 16 + n_potcars_per_functional = { + "PBE": 251, + "PBE_52": 303, + "PBE_54": 326, + "PBE_64": 343, + "LDA": 292, + "LDA_52": 274, + "LDA_54": 295, + "PW91": 169, + "LDA_US": 74, + "PW91_US": 75, + "Perdew_Zunger81": 292, + "PBE_52_W_HASH": 304, + "PBE_54_W_HASH": 327, + "LDA_52_W_HASH": 275, + "LDA_54_W_HASH": 295, + "LDA_64": 297, + } + assert {*potcar_summary_stats} == {*n_potcars_per_functional} + + for key, expected in n_potcars_per_functional.items(): + actual = len(potcar_summary_stats[key]) + assert actual == expected, f"{key=}, {expected=}, {actual=}" + + +def test_gen_potcar_summary_stats(tmp_path: Path, monkeypatch: MonkeyPatch) -> None: """Regenerate the potcar_summary_stats.json.gz file used to validate POTCARs with scrambled POTCARs.""" psp_path = f"{TEST_FILES_DIR}/fake_potcar_library/" summ_stats_file = f"{tmp_path}/fake_potcar_summary_stats.json.gz"