diff --git a/pymatgen/io/vasp/outputs.py b/pymatgen/io/vasp/outputs.py index 6619d0a43fc..9af84743be7 100644 --- a/pymatgen/io/vasp/outputs.py +++ b/pymatgen/io/vasp/outputs.py @@ -1301,7 +1301,7 @@ def _parse_chemical_shielding_calculation(self, elem): def _parse_calculation(self, elem): try: - istep = {i.attrib["name"]: float(i.text) for i in elem.find("energy").findall("i")} + istep = {i.attrib["name"]: _vasprun_float(i.text) for i in elem.find("energy").findall("i")} except AttributeError: # not all calculations have an energy istep = {} esteps = [] diff --git a/tests/files/.pytest-split-durations b/tests/files/.pytest-split-durations index c90b5b457ea..5764afe09a3 100644 --- a/tests/files/.pytest-split-durations +++ b/tests/files/.pytest-split-durations @@ -2169,7 +2169,7 @@ "tests/io/vasp/test_outputs.py::TestVasprun::test_potcar_not_found": 0.1334625000017695, "tests/io/vasp/test_outputs.py::TestVasprun::test_projected_magnetisation": 4.4185712080216035, "tests/io/vasp/test_outputs.py::TestVasprun::test_runtype": 14.43198950093938, - "tests/io/vasp/test_outputs.py::TestVasprun::test_sc_step_overflow": 1.980604083975777, + "tests/io/vasp/test_outputs.py::TestVasprun::test_float_overflow": 1.980604083975777, "tests/io/vasp/test_outputs.py::TestVasprun::test_search_for_potcar": 0.2289056670269929, "tests/io/vasp/test_outputs.py::TestVasprun::test_selective_dynamics": 1.798271125066094, "tests/io/vasp/test_outputs.py::TestVasprun::test_smart_efermi": 2.6953831250430085, diff --git a/tests/files/vasprun.xml.sc_overflow b/tests/files/vasprun.xml.sc_overflow index 71efc1821fc..22e19a74916 100644 --- a/tests/files/vasprun.xml.sc_overflow +++ b/tests/files/vasprun.xml.sc_overflow @@ -891,7 +891,7 @@ - 0.41466569 -0.04234049 0.05092706 + ********** -0.04234049 0.05092706 0.23840217 0.09338135 -0.08187019 -0.45497113 0.03109806 -0.23055151 -0.41847023 0.03902084 -0.19336882 diff --git a/tests/io/vasp/test_outputs.py b/tests/io/vasp/test_outputs.py index a372ec94078..d89b744ab1b 100644 --- a/tests/io/vasp/test_outputs.py +++ b/tests/io/vasp/test_outputs.py @@ -578,13 +578,17 @@ def test_smart_efermi(self): smart_fermi = vrun.calculate_efermi() assert smart_fermi == approx(6.0165) - def test_sc_step_overflow(self): + def test_float_overflow(self): + # test we interpret VASP's *********** for overflowed values as NaNs + # https://github.com/materialsproject/pymatgen/pull/3452 filepath = f"{TEST_FILES_DIR}/vasprun.xml.sc_overflow" with pytest.warns(UserWarning, match="Float overflow .* encountered in vasprun"): vasp_run = Vasprun(filepath) - vasp_run = Vasprun(filepath) - estep = vasp_run.ionic_steps[0]["electronic_steps"][29] - assert np.isnan(estep["e_wo_entrp"]) + first_ionic_step = vasp_run.ionic_steps[0] + elec_step = first_ionic_step["electronic_steps"][29] + assert np.isnan(elec_step["e_wo_entrp"]) + assert np.isnan(elec_step["e_fr_energy"]) + assert np.isnan(first_ionic_step["forces"]).any() def test_update_potcar(self): filepath = f"{TEST_FILES_DIR}/vasprun.xml"