From ad04784363b7d8f7500061c6302337628cb87744 Mon Sep 17 00:00:00 2001 From: Janosh Riebesell Date: Thu, 27 Jul 2023 13:14:15 -0700 Subject: [PATCH] use vi correctly in VaspErrorHandler.check --- custodian/vasp/handlers.py | 48 +++++++++++++++++++++----------------- 1 file changed, 26 insertions(+), 22 deletions(-) diff --git a/custodian/vasp/handlers.py b/custodian/vasp/handlers.py index d45c3106..12168a81 100644 --- a/custodian/vasp/handlers.py +++ b/custodian/vasp/handlers.py @@ -620,28 +620,32 @@ def correct(self): # NOTE: This is the algo_tet handler response. # set ALGO to normal algo = vi["INCAR"].get("ALGO", "Normal").lower() - if (algo in ["all", "damped"] or (50 <= vi.incar.get("IALGO", 38) <= 59)) and vi.incar.get("ISMEAR", 1) < 0: - if self.error_count["algo_tet"] == 0: - # first recovery attempt is to set ALGO to fast. Could fail again in which - # case we end up here again if some other handler switches algo back to all/damped. - # This time try the recovery below. - actions.append({"dict": "INCAR", "action": {"_set": {"ALGO": "Fast"}}}) - if self.error_count["algo_tet"] == 1: - # ALGO=All/Damped / IALGO=5X often fails with ISMEAR < 0. There are two options VASP - # suggests: 1) Use ISMEAR = 0 (and a small sigma) to get the SCF to converge. - # 2) Use ALGO = Damped but only *after* an ISMEAR = 0 run where the wavefunction - # has been stored and read in for the subsequent run. - # - # For simplicity, we go with Option 1 here, but if the user wants high-quality - # DOS then they should consider running a subsequent job with ISMEAR = -5 and - # ALGO = Damped, provided the wavefunction has been stored. - actions.append({"dict": "INCAR", "action": {"_set": {"ISMEAR": 0, "SIGMA": 0.05}}}) - if vi.incar.get("NEDOS") or vi.incar.get("EMIN") or vi.incar.get("EMAX"): - warnings.warn( - "This looks like a DOS run. You may want to follow-up this job with ALGO = Damped" - " and ISMEAR = -5, using the wavefunction from the current job.", - UserWarning, - ) + + if "algo_tet" in self.errors: + if (algo in ["all", "damped"] or (50 <= vi["INCAR"].get("IALGO", 38) <= 59)) and vi["INCAR"].get( + "ISMEAR", 1 + ) < 0: + if self.error_count["algo_tet"] == 0: + # first recovery attempt is to set ALGO to fast. Could fail again in which + # case we end up here again if some other handler switches algo back to all/damped. + # This time try the recovery below. + actions.append({"dict": "INCAR", "action": {"_set": {"ALGO": "Fast"}}}) + if self.error_count["algo_tet"] == 1: + # ALGO=All/Damped / IALGO=5X often fails with ISMEAR < 0. There are two options VASP + # suggests: 1) Use ISMEAR = 0 (and a small sigma) to get the SCF to converge. + # 2) Use ALGO = Damped but only *after* an ISMEAR = 0 run where the wavefunction + # has been stored and read in for the subsequent run. + # + # For simplicity, we go with Option 1 here, but if the user wants high-quality + # DOS then they should consider running a subsequent job with ISMEAR = -5 and + # ALGO = Damped, provided the wavefunction has been stored. + actions.append({"dict": "INCAR", "action": {"_set": {"ISMEAR": 0, "SIGMA": 0.05}}}) + if vi["INCAR"].get("NEDOS") or vi["INCAR"].get("EMIN") or vi["INCAR"].get("EMAX"): + warnings.warn( + "This looks like a DOS run. You may want to follow-up this job with ALGO = Damped" + " and ISMEAR = -5, using the wavefunction from the current job.", + UserWarning, + ) VaspModder(vi=vi).apply_actions(actions) return {"errors": list(self.errors), "actions": actions}