|
10 | 10 |
|
11 | 11 | import numpy as np
|
12 | 12 | import pytest
|
13 |
| -from monty.serialization import loadfn |
14 | 13 | from numpy.testing import assert_allclose
|
15 | 14 | from pytest import approx
|
16 | 15 |
|
|
19 | 18 | from pymatgen.core.structure import Structure
|
20 | 19 | from pymatgen.electronic_structure.core import Magmom, Orbital, OrbitalType, Spin
|
21 | 20 | from pymatgen.entries.compatibility import MaterialsProjectCompatibility
|
22 |
| -from pymatgen.io.vasp.inputs import Kpoints, Poscar |
| 21 | +from pymatgen.io.vasp.inputs import Kpoints, Poscar, Potcar |
23 | 22 | from pymatgen.io.vasp.outputs import (
|
24 | 23 | WSWQ,
|
25 | 24 | BSVasprun,
|
@@ -591,23 +590,27 @@ def test_update_potcar(self):
|
591 | 590 | filepath = f"{TEST_FILES_DIR}/vasprun.xml"
|
592 | 591 | potcar_path = f"{TEST_FILES_DIR}/POTCAR.LiFePO4.gz"
|
593 | 592 | potcar_path2 = f"{TEST_FILES_DIR}/POTCAR2.LiFePO4.gz"
|
| 593 | + |
594 | 594 | vasp_run = Vasprun(filepath, parse_potcar_file=False)
|
595 |
| - assert vasp_run.potcar_spec == [ |
596 |
| - {"titel": "PAW_PBE Li 17Jan2003", "hash": None, "summary_stats": {}}, |
597 |
| - {"titel": "PAW_PBE Fe 06Sep2000", "hash": None, "summary_stats": {}}, |
598 |
| - {"titel": "PAW_PBE Fe 06Sep2000", "hash": None, "summary_stats": {}}, |
599 |
| - {"titel": "PAW_PBE P 17Jan2003", "hash": None, "summary_stats": {}}, |
600 |
| - {"titel": "PAW_PBE O 08Apr2002", "hash": None, "summary_stats": {}}, |
601 |
| - ] |
| 595 | + potcars = Potcar.from_file(potcar_path) |
| 596 | + expected_spec = [{"titel": titel, "hash": None, "summary_stats": {}} for titel in vasp_run.potcar_symbols] |
| 597 | + assert vasp_run.potcar_spec == expected_spec |
| 598 | + |
602 | 599 | vasp_run.update_potcar_spec(potcar_path)
|
603 |
| - assert vasp_run.potcar_spec == loadfn(f"{TEST_FILES_DIR}/test_io_vasp_update_potcar_1.json") |
| 600 | + potcars = Potcar.from_file(potcar_path) |
| 601 | + expected_spec = [] |
| 602 | + for titel in vasp_run.potcar_symbols: |
| 603 | + for potcar in potcars: |
| 604 | + if titel == potcar.TITEL: |
| 605 | + break |
| 606 | + expected_spec += [{"titel": titel, "hash": potcar.md5_header_hash, "summary_stats": potcar._summary_stats}] |
| 607 | + assert vasp_run.potcar_spec == expected_spec |
604 | 608 |
|
605 |
| - vasprun2 = Vasprun(filepath, parse_potcar_file=False) |
606 | 609 | with pytest.raises(ValueError, match="Potcar TITELs do not match Vasprun"):
|
607 |
| - vasprun2.update_potcar_spec(potcar_path2) |
608 |
| - vasp_run = Vasprun(filepath, parse_potcar_file=potcar_path) |
| 610 | + Vasprun(filepath, parse_potcar_file=potcar_path2) |
609 | 611 |
|
610 |
| - assert vasp_run.potcar_spec == loadfn(f"{TEST_FILES_DIR}/test_io_vasp_update_potcar_2.json") |
| 612 | + vasp_run = Vasprun(filepath, parse_potcar_file=potcar_path) |
| 613 | + assert vasp_run.potcar_spec == expected_spec |
611 | 614 |
|
612 | 615 | with pytest.raises(ValueError, match="Potcar TITELs do not match Vasprun"):
|
613 | 616 | Vasprun(filepath, parse_potcar_file=potcar_path2)
|
|
0 commit comments