Skip to content

Commit

Permalink
Fix breaking change to IBZKPT handling
Browse files Browse the repository at this point in the history
  • Loading branch information
Andrew-S-Rosen committed Jun 12, 2024
1 parent bc9ecbb commit ab5706e
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 27 deletions.
19 changes: 4 additions & 15 deletions custodian/vasp/handlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -193,21 +193,10 @@ def correct(self, directory="./"):
# follow advice in this thread
# https://vasp.at/forum/viewtopic.php?f=3&t=416&p=4047&hilit=dentet#p4047
err_type = "tet" if "tet" in self.errors else "dentet"
if self.error_count[err_type] == 0:
if vi["INCAR"].get("KSPACING"):
# decrease KSPACING by 20% in each direction (approximately double no. of kpoints)
action = {"_set": {"KSPACING": vi["INCAR"].get("KSPACING") * 0.8}}
actions.append({"dict": "INCAR", "action": action})
elif vi["KPOINTS"] and vi["KPOINTS"].num_kpts < 1:
# increase KPOINTS by 20% in each direction (approximately double no. of kpoints)
new_kpts = tuple(int(round(num * 1.2, 0)) for num in vi["KPOINTS"].kpts[0])
actions.append({"dict": "KPOINTS", "action": {"_set": {"kpoints": (new_kpts,)}}})
elif vi["KPOINTS"] and vi["KPOINTS"].num_kpts >= 1:
n_kpts = vi["KPOINTS"].num_kpts * 1.2
new_kpts = tuple([int(round(n_kpts**1 / 3, 0))] * 3)
actions.append(
{"dict": "KPOINTS", "action": {"_set": {"generation_style": "Gamma", "kpoints": (new_kpts,)}}}
)
if vi["INCAR"].get("KSPACING"):
# decrease KSPACING by 20% in each direction (approximately double no. of kpoints)
action = {"_set": {"KSPACING": vi["INCAR"].get("KSPACING") * 0.8}}
actions.append({"dict": "INCAR", "action": action})
else:
actions.append({"dict": "INCAR", "action": {"_set": {"ISMEAR": 0, "SIGMA": 0.05}}})
self.error_count[err_type] += 1
Expand Down
13 changes: 1 addition & 12 deletions tests/vasp/test_handlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ def test_check_correct(self) -> None:
assert dct["errors"] == ["tet"]
assert dct["actions"] == [{"action": {"_set": {"kpoints": ((10, 2, 2),)}}, "dict": "KPOINTS"}]

handler = VaspErrorHandler("vasp.teterror")
handler.check()
dct = handler.correct()
assert dct["errors"] == ["tet"]
Expand Down Expand Up @@ -157,11 +158,6 @@ def test_brions(self) -> None:

def test_dentet(self) -> None:
handler = VaspErrorHandler("vasp.dentet")
handler.check()
dct = handler.correct()
assert dct["errors"] == ["dentet"]
assert dct["actions"] == [{"action": {"_set": {"kpoints": ((10, 2, 2),)}}, "dict": "KPOINTS"}]

handler.check()
dct = handler.correct()
assert dct["errors"] == ["dentet"]
Expand Down Expand Up @@ -515,13 +511,6 @@ def test_bzint_vasp6(self) -> None:
dct = handler.correct()
assert dct["errors"] == ["tet"]
incar = Incar.from_file("INCAR")
assert incar["ISMEAR"] == -5
assert incar["SIGMA"] == 0.05
assert dct["actions"] == [{"action": {"_set": {"kpoints": ((10, 2, 2),)}}, "dict": "KPOINTS"}]

assert handler.check() is True
assert handler.correct()["errors"] == ["tet"]
incar = Incar.from_file("INCAR")
assert incar["ISMEAR"] == 0
assert incar["SIGMA"] == 0.05

Expand Down

0 comments on commit ab5706e

Please sign in to comment.