Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add test_potcar_summary_stats() #3395

Merged
merged 1 commit into from
Oct 10, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions pymatgen/io/vasp/inputs.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down
33 changes: 32 additions & 1 deletion tests/io/vasp/test_inputs.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down