Repository: materialsproject/custodian
Pull request #191 (2021-11-25 05:50:18)

Address new VASP6 inconsistent Bravais lattice error
In VASP6, there appears to be a new error which I have included below:
```
-----------------------------------------------------------------------------
|                                                                             |
|     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     ###     ###     ###     |
|                                                                             |
|     Inconsistent Bravais lattice types found for crystalline and            |
|     reciprocal lattice:                                                     |
|                                                                             |
|        Crystalline: base-centered monoclinic                                |
|        Reciprocal : triclinic                                               |
|                    (instead of base-centered monoclinic)                    |
|                                                                             |
|     In most cases this is due to inaccuracies in the specification of       |
|     the crytalline lattice vectors.                                         |
|                                                                             |
|     Suggested SOLUTIONS:                                                    |
|      ) Refine the lattice parameters of your structure,                     |
|      ) and/or try changing SYMPREC.                                         |
|                                                                             |
|       ---->  I REFUSE TO CONTINUE WITH THIS SICK JOB ... BYE!!! <----       |
|                                                                             |
 -----------------------------------------------------------------------------
```
It appears to occur when SYMPREC is very low. I have confirmed that increasing SYMPREC resolves the issue, as suggested by VASP. 

I have now addressed this error in Custodian and added test files.


Patch:
diff --git a/custodian/vasp/handlers.py b/custodian/vasp/handlers.py
index 547f8ccf..d1c40033 100644
--- a/custodian/vasp/handlers.py
+++ b/custodian/vasp/handlers.py
@@ -96,6 +96,7 @@ class VaspErrorHandler(ErrorHandler):
         "point_group": ["group operation missing"],
         "symprec_noise": ["determination of the symmetry of your systems shows a strong"],
         "dfpt_ncore": ["PEAD routines do not work for NCORE"],
+        "bravais": ["Inconsistent Bravais lattice"],
     }
 
     def __init__(
@@ -441,6 +442,17 @@ class VaspErrorHandler(ErrorHandler):
             if "NPAR" in vi["INCAR"]:
                 actions.append({"dict": "INCAR", "action": {"_unset": {"NPAR": 0}}})
 
+        if "bravais" in self.errors:
+            # VASP recommends refining the lattice parameters or changing SYMPREC
+            # Appears to occurs when SYMPREC is very low, so we will change it to
+            # the default if it's not already. Let's not increase SYMPREC if it's
+            # already at 1e-4 though.
+            symprec = vi["INCAR"].get("SYMPREC", 1e-5)
+            if symprec < 1e-5:
+                actions.append({"dict": "INCAR", "action": {"_set": {"SYMPREC": 1e-5}}})
+            elif symprec < 1e-4:
+                actions.append({"dict": "INCAR", "action": {"_set": {"SYMPREC": symprec * 10}}})
+
         VaspModder(vi=vi).apply_actions(actions)
         return {"errors": list(self.errors), "actions": actions}
 
diff --git a/requirements-ci.txt b/requirements-ci.txt
index 64f2c384..120a74d7 100644
--- a/requirements-ci.txt
+++ b/requirements-ci.txt
@@ -1,10 +1,10 @@
 pymatgen==2022.0.12
 coverage==5.5
-coveralls==3.3.1
+coveralls==3.3.0
 pytest==6.2.5
 pytest-cov==3.0.0
 mypy==0.910
 pydocstyle==6.1.1
 flake8==4.0.1
 pylint==2.11.1
-black==21.11b1
\ No newline at end of file
+black==21.10b0
\ No newline at end of file


Test patch:
diff --git a/custodian/vasp/tests/test_handlers.py b/custodian/vasp/tests/test_handlers.py
index ac175c67..730a8989 100644
--- a/custodian/vasp/tests/test_handlers.py
+++ b/custodian/vasp/tests/test_handlers.py
@@ -268,6 +268,20 @@ class VaspErrorHandlerTest(unittest.TestCase):
         i = Incar.from_file("INCAR")
         self.assertEqual(i["ISYM"], 0)
 
+    def test_bravais(self):
+        h = VaspErrorHandler("vasp6.bravais")
+        self.assertEqual(h.check(), True)
+        self.assertEqual(h.correct()["errors"], ["bravais"])
+        i = Incar.from_file("INCAR")
+        self.assertEqual(i["SYMPREC"], 1e-4)
+
+        shutil.copy("INCAR.symprec", "INCAR")
+        h = VaspErrorHandler("vasp6.bravais")
+        self.assertEqual(h.check(), True)
+        self.assertEqual(h.correct()["errors"], ["bravais"])
+        i = Incar.from_file("INCAR")
+        self.assertEqual(i["SYMPREC"], 1e-5)
+
     def test_posmap(self):
         h = VaspErrorHandler("vasp.posmap")
         self.assertEqual(h.check(), True)
diff --git a/test_files/INCAR.symprec b/test_files/INCAR.symprec
new file mode 100644
index 00000000..6aa6edd8
--- /dev/null
+++ b/test_files/INCAR.symprec
@@ -0,0 +1,20 @@
+ALGO = All
+EDIFF = 1e-05
+EDIFFG = -0.05
+ENCUT = 400
+GGA = Pe
+IBRION = 2
+ISIF = 2
+ISMEAR = 0
+ISYM = 0
+IVDW = 12
+LASPH = False
+LCHARG = False
+LORBIT = 11
+LREAL = False
+NELM = 150
+NELMIN = 3
+NSW = 300
+PREC = Accurate
+SIGMA = 0.01
+SYMPREC = 1e-08
diff --git a/test_files/vasp6.bravais b/test_files/vasp6.bravais
new file mode 100644
index 00000000..e4a4c401
--- /dev/null
+++ b/test_files/vasp6.bravais
@@ -0,0 +1,43 @@
+ ----------------------------------------------------
+    OOO  PPPP  EEEEE N   N M   M PPPP
+   O   O P   P E     NN  N MM MM P   P
+   O   O PPPP  EEEEE N N N M M M PPPP   -- VERSION
+   O   O P     E     N  NN M   M P
+    OOO  P     EEEEE N   N M   M P
+ ----------------------------------------------------
+ running  128 mpi-ranks, with    1 threads/rank
+ distrk:  each k-point on  128 cores,    1 groups
+ distr:  one band on    1 cores,  128 groups
+ vasp.6.2.1 16May21 (build Jul 28 2021 23:24:15) complex                        
+  
+ POSCAR found type information on POSCAR Cu
+ POSCAR found :  1 types and       1 ions
+ scaLAPACK will be used
+ -----------------------------------------------------------------------------
+|                                                                             |
+|     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     ###     ###     ###     |
+|                                                                             |
+|     Inconsistent Bravais lattice types found for crystalline and            |
+|     reciprocal lattice:                                                     |
+|                                                                             |
+|        Crystalline: base-centered monoclinic                                |
+|        Reciprocal : triclinic                                               |
+|                    (instead of base-centered monoclinic)                    |
+|                                                                             |
+|     In most cases this is due to inaccuracies in the specification of       |
+|     the crytalline lattice vectors.                                         |
+|                                                                             |
+|     Suggested SOLUTIONS:                                                    |
+|      ) Refine the lattice parameters of your structure,                     |
+|      ) and/or try changing SYMPREC.                                         |
+|                                                                             |
+|       ---->  I REFUSE TO CONTINUE WITH THIS SICK JOB ... BYE!!! <----       |
+|                                                                             |
+ -----------------------------------------------------------------------------
+