Repository: materialsproject/custodian
Pull request #161 (2020-11-30 15:17:04)

detect POSMAP and BZINT, and SGRCON errors in Vasp 6
Small modification to VASP `handlers.py` in order to properly detect the POSMAP, SGRCON, and BZINTS errors in VASP 6, which formats the error messages differently than VASP 5.

I also updated the posmap error handler so that it 1) will not repeat the same action indefinitely and 2) tries both reducing and increasing the value of SYMPREC, as suggested by the VASP error message.


Patch:
diff --git a/custodian/vasp/handlers.py b/custodian/vasp/handlers.py
index 44088afb..ad8003ea 100644
--- a/custodian/vasp/handlers.py
+++ b/custodian/vasp/handlers.py
@@ -66,11 +66,12 @@ class VaspErrorHandler(ErrorHandler):
 
     error_msgs = {
         "tet": [
-            "Tetrahedron method fails for NKPT<4",
+            "Tetrahedron method fails",
             "Fatal error detecting k-mesh",
             "Fatal error: unable to match k-point",
             "Routine TETIRR needs special values",
             "Tetrahedron method fails (number of k-points < 4)",
+            "BZINTS"
         ],
         "inv_rot_mat": [
             "rotation matrix was not found (increase " "SYMPREC)"
@@ -84,7 +85,7 @@ class VaspErrorHandler(ErrorHandler):
         "dentet": ["DENTET"],
         "too_few_bands": ["TOO FEW BANDS"],
         "triple_product": ["ERROR: the triple product of the basis vectors"],
-        "rot_matrix": ["Found some non-integer element in rotation matrix"],
+        "rot_matrix": ["Found some non-integer element in rotation matrix", "SGRCON"],
         "brions": ["BRIONS problems: POTIM should be increased"],
         "pricel": ["internal error in subroutine PRICEL"],
         "zpotrf": ["LAPACK: Routine ZPOTRF failed"],
@@ -99,7 +100,7 @@ class VaspErrorHandler(ErrorHandler):
         "elf_kpar": ["ELF: KPAR>1 not implemented"],
         "elf_ncl": ["WARNING: ELF not implemented for non collinear case"],
         "rhosyg": ["RHOSYG"],
-        "posmap": ["POSMAP internal error: symmetry equivalent atom not found"],
+        "posmap": ["POSMAP"],
         "point_group": ["group operation missing"],
     }
 
@@ -465,7 +466,19 @@ class VaspErrorHandler(ErrorHandler):
             actions.append({"dict": "INCAR", "action": {"_set": {"SYMPREC": 1e-4}}})
 
         if "posmap" in self.errors:
-            actions.append({"dict": "INCAR", "action": {"_set": {"SYMPREC": 1e-6}}})
+            # VASP advises to decrease or increase SYMPREC by an order of magnitude
+            # the default SYMPREC value is 1e-5
+            if self.error_count["posmap"] == 0:
+                # first, reduce by 10x
+                orig_symprec = vi["INCAR"].get("SYMPREC", 1e-5)
+                actions.append({"dict": "INCAR", "action": {"_set": {"SYMPREC": orig_symprec / 10}}})
+            elif self.error_count["posmap"] == 1:
+                # next, increase by 100x (10x the original)
+                orig_symprec = vi["INCAR"].get("SYMPREC", 1e-6)
+                actions.append({"dict": "INCAR", "action": {"_set": {"SYMPREC": orig_symprec * 100}}})
+            else:
+                # if we have already corrected twice, there's nothing else to do
+                pass
 
         if "point_group" in self.errors:
             actions.append({"dict": "INCAR", "action": {"_set": {"ISYM": 0}}})


Test patch:
diff --git a/custodian/vasp/tests/test_handlers.py b/custodian/vasp/tests/test_handlers.py
index c6d3d3b0..0a8669ec 100644
--- a/custodian/vasp/tests/test_handlers.py
+++ b/custodian/vasp/tests/test_handlers.py
@@ -214,6 +214,11 @@ class VaspErrorHandlerTest(unittest.TestCase):
         shutil.copy("KPOINTS.orig", "KPOINTS")
         os.remove("KPOINTS.orig")
 
+    def test_rot_matrix_vasp6(self):
+        h = VaspErrorHandler("vasp6.sgrcon")
+        self.assertEqual(h.check(), True)
+        self.assertEqual(h.correct()["errors"], ["rot_matrix"])
+
     def test_to_from_dict(self):
         h = VaspErrorHandler("random_name")
         h2 = VaspErrorHandler.from_dict(h.as_dict())
@@ -283,7 +288,14 @@ class VaspErrorHandlerTest(unittest.TestCase):
         self.assertEqual(h.check(), True)
         self.assertEqual(h.correct()["errors"], ["posmap"])
         i = Incar.from_file("INCAR")
-        self.assertEqual(i["SYMPREC"], 1e-6)
+        self.assertAlmostEqual(i["SYMPREC"], 1e-6)
+
+    def test_posmap_vasp6(self):
+        h = VaspErrorHandler("vasp6.posmap")
+        self.assertEqual(h.check(), True)
+        self.assertEqual(h.correct()["errors"], ["posmap"])
+        i = Incar.from_file("INCAR")
+        self.assertAlmostEqual(i["SYMPREC"], 1e-6)
 
     def test_point_group(self):
         h = VaspErrorHandler("vasp.point_group")
@@ -308,6 +320,15 @@ class VaspErrorHandlerTest(unittest.TestCase):
         i = Incar.from_file("INCAR")
         self.assertEqual(i["SYMPREC"], 1e-08)
 
+    def test_bzint_vasp6(self):
+        # the BZINT error message is formatted differently in VASP6 compared to VASP5
+        h = VaspErrorHandler("vasp6.bzint")
+        self.assertEqual(h.check(), True)
+        self.assertEqual(h.correct()["errors"], ["tet"])
+        i = Incar.from_file("INCAR")
+        self.assertEqual(i["ISMEAR"], 0)
+        self.assertEqual(i["SIGMA"], 0.05)
+
     def test_too_large_kspacing(self):
         shutil.copy("INCAR.kspacing", "INCAR")
         vi = VaspInput.from_directory(".")
diff --git a/test_files/vasp6.bzint b/test_files/vasp6.bzint
new file mode 100644
index 00000000..6b4a81ee
--- /dev/null
+++ b/test_files/vasp6.bzint
@@ -0,0 +1,16 @@
+ -----------------------------------------------------------------------------
+|                                                                             |
+|     EEEEEEE  RRRRRR   RRRRRR   OOOOOOO  RRRRRR      ###     ###     ###     |
+|     E        R     R  R     R  O     O  R     R     ###     ###     ###     |
+|     E        R     R  R     R  O     O  R     R     ###     ###     ###     |
+|     EEEEE    RRRRRR   RRRRRR   O     O  RRRRRR       #       #       #      |
+|     E        R   R    R   R    O     O  R   R                               |
+|     E        R    R   R    R   O     O  R    R      ###     ###     ###     |
+|     EEEEEEE  R     R  R     R  OOOOOOO  R     R     ###     ###     ###     |
+|                                                                             |
+|     VERY BAD NEWS! internal error in subroutine BZINTS: Tetrahedron         |
+|     method fails (number of k-points < 4) 3                                 |
+|                                                                             |
+|       ---->  I REFUSE TO CONTINUE WITH THIS SICK JOB ... BYE!!! <----       |
+|                                                                             |
+ -----------------------------------------------------------------------------
\ No newline at end of file
diff --git a/test_files/vasp6.posmap b/test_files/vasp6.posmap
new file mode 100644
index 00000000..f3d8358e
--- /dev/null
+++ b/test_files/vasp6.posmap
@@ -0,0 +1,17 @@
+ -----------------------------------------------------------------------------
+|                                                                             |
+|     EEEEEEE  RRRRRR   RRRRRR   OOOOOOO  RRRRRR      ###     ###     ###     |
+|     E        R     R  R     R  O     O  R     R     ###     ###     ###     |
+|     E        R     R  R     R  O     O  R     R     ###     ###     ###     |
+|     EEEEE    RRRRRR   RRRRRR   O     O  RRRRRR       #       #       #      |
+|     E        R   R    R   R    O     O  R   R                               |
+|     E        R    R   R    R   O     O  R    R      ###     ###     ###     |
+|     EEEEEEE  R     R  R     R  OOOOOOO  R     R     ###     ###     ###     |
+|                                                                             |
+|     VERY BAD NEWS! internal error in subroutinePOSMAP:symmetry              |
+|     equivalent atom not found, you might try decreasing or increasing       |
+|     SYMPREC by an order of magnitude. 54                                    |
+|                                                                             |
+|       ---->  I REFUSE TO CONTINUE WITH THIS SICK JOB ... BYE!!! <----       |
+|                                                                             |
+ -----------------------------------------------------------------------------
\ No newline at end of file
diff --git a/test_files/vasp6.sgrcon b/test_files/vasp6.sgrcon
new file mode 100644
index 00000000..1c287e93
--- /dev/null
+++ b/test_files/vasp6.sgrcon
@@ -0,0 +1,16 @@
+ -----------------------------------------------------------------------------
+|                                                                             |
+|     EEEEEEE  RRRRRR   RRRRRR   OOOOOOO  RRRRRR      ###     ###     ###     |
+|     E        R     R  R     R  O     O  R     R     ###     ###     ###     |
+|     E        R     R  R     R  O     O  R     R     ###     ###     ###     |
+|     EEEEE    RRRRRR   RRRRRR   O     O  RRRRRR       #       #       #      |
+|     E        R   R    R   R    O     O  R   R                               |
+|     E        R    R   R    R   O     O  R    R      ###     ###     ###     |
+|     EEEEEEE  R     R  R     R  OOOOOOO  R     R     ###     ###     ###     |
+|                                                                             |
+|     VERY BAD NEWS! internal error in subroutineSGRCON:Found some            |
+|     non-integer element in rotation matrix 3                                |
+|                                                                             |
+|       ---->  I REFUSE TO CONTINUE WITH THIS SICK JOB ... BYE!!! <----       |
+|                                                                             |
+ -----------------------------------------------------------------------------
\ No newline at end of file