From ab5706eef70842b0876d7f23923cfedeeacd82a4 Mon Sep 17 00:00:00 2001 From: Andrew Rosen Date: Wed, 12 Jun 2024 10:37:41 -0700 Subject: [PATCH 1/3] Fix breaking change to IBZKPT handling --- custodian/vasp/handlers.py | 19 ++++--------------- tests/vasp/test_handlers.py | 13 +------------ 2 files changed, 5 insertions(+), 27 deletions(-) diff --git a/custodian/vasp/handlers.py b/custodian/vasp/handlers.py index 9b6a27b5..d5691ba0 100644 --- a/custodian/vasp/handlers.py +++ b/custodian/vasp/handlers.py @@ -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 diff --git a/tests/vasp/test_handlers.py b/tests/vasp/test_handlers.py index d2a4f219..8e6a290f 100644 --- a/tests/vasp/test_handlers.py +++ b/tests/vasp/test_handlers.py @@ -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"] @@ -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"] @@ -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 From 0e2b3f082c3f8315116344254a714484cc5bc00d Mon Sep 17 00:00:00 2001 From: Andrew Rosen Date: Wed, 12 Jun 2024 11:05:57 -0700 Subject: [PATCH 2/3] fix --- custodian/vasp/handlers.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/custodian/vasp/handlers.py b/custodian/vasp/handlers.py index d5691ba0..a005bd98 100644 --- a/custodian/vasp/handlers.py +++ b/custodian/vasp/handlers.py @@ -192,14 +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 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 From b39893870652f63d47486b03a5da9d0dc16d352d Mon Sep 17 00:00:00 2001 From: "Andrew S. Rosen" Date: Wed, 12 Jun 2024 11:08:53 -0700 Subject: [PATCH 3/3] Update test_handlers.py --- tests/vasp/test_handlers.py | 6 ------ 1 file changed, 6 deletions(-) diff --git a/tests/vasp/test_handlers.py b/tests/vasp/test_handlers.py index 8e6a290f..f78ec588 100644 --- a/tests/vasp/test_handlers.py +++ b/tests/vasp/test_handlers.py @@ -105,12 +105,6 @@ def test_subspace(self) -> None: assert dct["actions"] == [{"action": {"_set": {"PREC": "Accurate"}}, "dict": "INCAR"}] 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 = VaspErrorHandler("vasp.teterror") handler.check() dct = handler.correct()