Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix breaking change to ISMEAR=-5 handling for NKPT<4 #336

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 4 additions & 17 deletions custodian/vasp/handlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -192,25 +192,12 @@ def correct(self, directory="./"):
if self.errors.intersection(["tet", "dentet"]):
# 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

# Missing AMIN error handler:
# previously, custodian would kill the job without letting it run if AMIN was flagged
Expand Down
17 changes: 0 additions & 17 deletions tests/vasp/test_handlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,11 +106,6 @@ def test_subspace(self) -> None:

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

handler.check()
dct = handler.correct()
assert dct["errors"] == ["tet"]
Expand Down Expand Up @@ -157,11 +152,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 +505,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
Loading