Skip to content

Commit 7e2f16c

Browse files
authored
Fix LobsterSet (#3771)
* fix potcar_symbols variable value * add tests to check potcar PBE_54 consistency * remove commented code block
1 parent 267963e commit 7e2f16c

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

pymatgen/io/vasp/sets.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2694,7 +2694,7 @@ def incar_updates(self) -> dict:
26942694
"""Get updates to the INCAR config for this calculation type."""
26952695
from pymatgen.io.lobster import Lobsterin
26962696

2697-
potcar_symbols = self.poscar.site_symbols
2697+
potcar_symbols = self.potcar_symbols
26982698

26992699
# predefined basis! Check if the basis is okay! (charge spilling and bandoverlaps!)
27002700
if self.user_supplied_basis is None and self.address_basis_file is None:

tests/io/vasp/test_sets.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1893,7 +1893,10 @@ class TestLobsterSet(PymatgenTest):
18931893
def setUp(self):
18941894
self.set = LobsterSet
18951895
file_path = f"{VASP_IN_DIR}/POSCAR"
1896+
file_path2 = f"{VASP_IN_DIR}/POSCAR.lobster.spin_DOS"
18961897
self.struct = Structure.from_file(file_path)
1898+
self.struct2 = Structure.from_file(file_path2)
1899+
18971900
# test for different parameters!
18981901
self.lobsterset1 = self.set(self.struct, isym=-1, ismear=-5)
18991902
self.lobsterset2 = self.set(self.struct, isym=0, ismear=0)
@@ -1923,6 +1926,9 @@ def setUp(self):
19231926
# test W_sw
19241927
self.lobsterset8 = self.set(Structure.from_file(f"{TEST_FILES_DIR}/electronic_structure/cohp/POSCAR.W"))
19251928

1929+
# test if potcar selection is consistent with PBE_54
1930+
self.lobsterset9 = self.set(self.struct2)
1931+
19261932
def test_incar(self):
19271933
incar1 = self.lobsterset1.incar
19281934
assert "NBANDS" in incar1
@@ -1950,6 +1956,13 @@ def test_kpoints(self):
19501956
def test_potcar(self):
19511957
# PBE_54 is preferred at the moment
19521958
assert self.lobsterset1.user_potcar_functional == "PBE_54"
1959+
# test if potcars selected are consistent with PBE_54
1960+
assert self.lobsterset2.potcar.symbols == ["Fe_pv", "P", "O"]
1961+
# test if error raised contains correct potcar symbol for K element as PBE_54 set
1962+
with pytest.raises(
1963+
OSError, match="You do not have the right POTCAR with functional='PBE_54' and symbol='K_sv'"
1964+
):
1965+
_ = self.lobsterset9.potcar.symbols
19531966

19541967
def test_as_from_dict(self):
19551968
dict_here = self.lobsterset1.as_dict()

0 commit comments

Comments
 (0)