From 7e2f16c293d4ac4fda08fdaf91851b423c71fc31 Mon Sep 17 00:00:00 2001 From: Aakash Ashok Naik <91958822+naik-aakash@users.noreply.github.com> Date: Tue, 23 Apr 2024 04:17:29 +0200 Subject: [PATCH] Fix LobsterSet (#3771) * fix potcar_symbols variable value * add tests to check potcar PBE_54 consistency * remove commented code block --- pymatgen/io/vasp/sets.py | 2 +- tests/io/vasp/test_sets.py | 13 +++++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/pymatgen/io/vasp/sets.py b/pymatgen/io/vasp/sets.py index 7dd9fd631d3..12e8de59a7e 100644 --- a/pymatgen/io/vasp/sets.py +++ b/pymatgen/io/vasp/sets.py @@ -2694,7 +2694,7 @@ def incar_updates(self) -> dict: """Get updates to the INCAR config for this calculation type.""" from pymatgen.io.lobster import Lobsterin - potcar_symbols = self.poscar.site_symbols + potcar_symbols = self.potcar_symbols # predefined basis! Check if the basis is okay! (charge spilling and bandoverlaps!) if self.user_supplied_basis is None and self.address_basis_file is None: diff --git a/tests/io/vasp/test_sets.py b/tests/io/vasp/test_sets.py index 5cd23e538a3..3b61d57683d 100644 --- a/tests/io/vasp/test_sets.py +++ b/tests/io/vasp/test_sets.py @@ -1893,7 +1893,10 @@ class TestLobsterSet(PymatgenTest): def setUp(self): self.set = LobsterSet file_path = f"{VASP_IN_DIR}/POSCAR" + file_path2 = f"{VASP_IN_DIR}/POSCAR.lobster.spin_DOS" self.struct = Structure.from_file(file_path) + self.struct2 = Structure.from_file(file_path2) + # test for different parameters! self.lobsterset1 = self.set(self.struct, isym=-1, ismear=-5) self.lobsterset2 = self.set(self.struct, isym=0, ismear=0) @@ -1923,6 +1926,9 @@ def setUp(self): # test W_sw self.lobsterset8 = self.set(Structure.from_file(f"{TEST_FILES_DIR}/electronic_structure/cohp/POSCAR.W")) + # test if potcar selection is consistent with PBE_54 + self.lobsterset9 = self.set(self.struct2) + def test_incar(self): incar1 = self.lobsterset1.incar assert "NBANDS" in incar1 @@ -1950,6 +1956,13 @@ def test_kpoints(self): def test_potcar(self): # PBE_54 is preferred at the moment assert self.lobsterset1.user_potcar_functional == "PBE_54" + # test if potcars selected are consistent with PBE_54 + assert self.lobsterset2.potcar.symbols == ["Fe_pv", "P", "O"] + # test if error raised contains correct potcar symbol for K element as PBE_54 set + with pytest.raises( + OSError, match="You do not have the right POTCAR with functional='PBE_54' and symbol='K_sv'" + ): + _ = self.lobsterset9.potcar.symbols def test_as_from_dict(self): dict_here = self.lobsterset1.as_dict()