Repository: materialsproject/custodian
Pull request #188 (2021-11-22 12:13:33)

Handle finite difference ncore error
## Summary

The logic already exists for handling errors relating to NCORE during DFPT(the fix is to disable both NCORE and NPAR). 

This PR just adds a check for an alternative error message that arises using `IBRION=6` (finite-differences). The fix remains the same.

I added a test.

If possible, please can you release a new version after merging this PR.


Patch:
diff --git a/custodian/vasp/handlers.py b/custodian/vasp/handlers.py
index e01d7853..3fe29961 100644
--- a/custodian/vasp/handlers.py
+++ b/custodian/vasp/handlers.py
@@ -95,7 +95,7 @@ class VaspErrorHandler(ErrorHandler):
         "posmap": ["POSMAP"],
         "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"],
+        "dfpt_ncore": ["PEAD routines do not work for NCORE", "remove the tag NPAR from the INCAR file"],
         "bravais": ["Inconsistent Bravais lattice"],
     }
 


Test patch:
diff --git a/custodian/vasp/tests/test_handlers.py b/custodian/vasp/tests/test_handlers.py
index 5bdb627e..04675da8 100644
--- a/custodian/vasp/tests/test_handlers.py
+++ b/custodian/vasp/tests/test_handlers.py
@@ -342,6 +342,14 @@ class VaspErrorHandlerTest(unittest.TestCase):
         self.assertTrue("NPAR" not in incar)
         self.assertTrue("NCORE" not in incar)
 
+    def test_finite_difference_ncore(self):
+        h = VaspErrorHandler("vasp.fd_ncore")
+        self.assertEqual(h.check(), True)
+        self.assertEqual(h.correct()["errors"], ["dfpt_ncore"])
+        incar = Incar.from_file("INCAR")
+        self.assertTrue("NPAR" not in incar)
+        self.assertTrue("NCORE" not in incar)
+
     def test_point_group_vasp6(self):
         # the error message is formatted differently in VASP6 compared to VASP5
         h = VaspErrorHandler("vasp6.point_group")
diff --git a/test_files/vasp.fd_ncore b/test_files/vasp.fd_ncore
new file mode 100644
index 00000000..4479a71a
--- /dev/null
+++ b/test_files/vasp.fd_ncore
@@ -0,0 +1,94 @@
+ running on    4 total cores
+ distrk:  each k-point on    4 cores,    1 groups
+ distr:  one band on    4 cores,    1 groups
+ vasp.6.2.1 16May21 (build Oct 27 2021 18:14:32) complex                        
+  
+ POSCAR found type information on POSCAR Si
+ POSCAR found :  1 types and       2 ions
+ LDA part: xc-table for Pade appr. of Perdew
+ -----------------------------------------------------------------------------
+|                                                                             |
+|           W    W    AA    RRRRR   N    N  II  N    N   GGGG   !!!           |
+|           W    W   A  A   R    R  NN   N  II  NN   N  G    G  !!!           |
+|           W    W  A    A  R    R  N N  N  II  N N  N  G       !!!           |
+|           W WW W  AAAAAA  RRRRR   N  N N  II  N  N N  G  GGG   !            |
+|           WW  WW  A    A  R   R   N   NN  II  N   NN  G    G                |
+|           W    W  A    A  R    R  N    N  II  N    N   GGGG   !!!           |
+|                                                                             |
+|     The requested file  could not be found or opened for reading            |
+|     k-point information. Automatic k-point generation is used as a          |
+|     fallback, which may lead to unwanted results.                           |
+|                                                                             |
+ -----------------------------------------------------------------------------
+
+ POSCAR, INCAR and KPOINTS ok, starting setup
+ FFT: planning ...
+ WAVECAR not read
+ entering main loop
+       N       E                     dE             d eps       ncg     rms          rms(c)
+DAV:   1     0.996962415275E+01    0.99696E+01   -0.38755E+03   320   0.990E+02
+DAV:   2    -0.107362873761E+02   -0.20706E+02   -0.20002E+02   528   0.890E+01
+DAV:   3    -0.110092669164E+02   -0.27298E+00   -0.27298E+00   368   0.129E+01
+DAV:   4    -0.110106362766E+02   -0.13694E-02   -0.13694E-02   536   0.107E+00
+DAV:   5    -0.110106369092E+02   -0.63256E-06   -0.63256E-06   384   0.242E-02    0.475E+00
+DAV:   6    -0.108935926504E+02    0.11704E+00   -0.76196E-02   400   0.145E+00    0.290E+00
+DAV:   7    -0.108394533680E+02    0.54139E-01   -0.14694E-01   408   0.215E+00    0.174E-01
+DAV:   8    -0.108405773821E+02   -0.11240E-02   -0.37811E-03   360   0.467E-01    0.733E-02
+DAV:   9    -0.108407860561E+02   -0.20867E-03   -0.21332E-04   480   0.115E-01    0.561E-02
+DAV:  10    -0.108408113697E+02   -0.25314E-04   -0.30153E-05   352   0.416E-02    0.873E-03
+DAV:  11    -0.108408110959E+02    0.27384E-06   -0.54710E-07   520   0.529E-03    0.207E-03
+DAV:  12    -0.108408114432E+02   -0.34727E-06   -0.58936E-07   352   0.615E-03    0.716E-04
+DAV:  13    -0.108408114482E+02   -0.50019E-08   -0.19743E-09   288   0.399E-04
+   1 F= -.10840811E+02 E0= -.10840811E+02  d E =-.151883E-15
+ -----------------------------------------------------------------------------
+|                                                                             |
+|           W    W    AA    RRRRR   N    N  II  N    N   GGGG   !!!           |
+|           W    W   A  A   R    R  NN   N  II  NN   N  G    G  !!!           |
+|           W    W  A    A  R    R  N N  N  II  N N  N  G       !!!           |
+|           W WW W  AAAAAA  RRRRR   N  N N  II  N  N N  G  GGG   !            |
+|           WW  WW  A    A  R   R   N   NN  II  N   NN  G    G                |
+|           W    W  A    A  R    R  N    N  II  N    N   GGGG   !!!           |
+|                                                                             |
+|     Your timestep is larger than 0.1 Angst.                                 |
+|     For finite differences, this really does not make sense. I will         |
+|     reset POTIM to 0.015. I recommend to use 0.01 to 0.02 for finite        |
+|     differences.                                                            |
+|                                                                             |
+ -----------------------------------------------------------------------------
+
+ Found     1 degrees of freedom:
+ Finite differences POTIM= 0.01500 DOF=   1
+ -----------------------------------------------------------------------------
+|                                                                             |
+|           W    W    AA    RRRRR   N    N  II  N    N   GGGG   !!!           |
+|           W    W   A  A   R    R  NN   N  II  NN   N  G    G  !!!           |
+|           W    W  A    A  R    R  N N  N  II  N N  N  G       !!!           |
+|           W WW W  AAAAAA  RRRRR   N  N N  II  N  N N  G  GGG   !            |
+|           WW  WW  A    A  R   R   N   NN  II  N   NN  G    G                |
+|           W    W  A    A  R    R  N    N  II  N    N   GGGG   !!!           |
+|                                                                             |
+|     The requested file  could not be found or opened for reading            |
+|     k-point information. Automatic k-point generation is used as a          |
+|     fallback, which may lead to unwanted results.                           |
+|                                                                             |
+ -----------------------------------------------------------------------------
+
+ -----------------------------------------------------------------------------
+|                                                                             |
+|     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     ###     ###     ###     |
+|                                                                             |
+|     VASP internal routines have requested a change of the k-point set.      |
+|     Unfortunately, this is only possible if NPAR=number of nodes.           |
+|     Please remove the tag NPAR from the INCAR file and restart the          |
+|     calculation.                                                            |
+|                                                                             |
+|       ---->  I REFUSE TO CONTINUE WITH THIS SICK JOB ... BYE!!! <----       |
+|                                                                             |
+ -----------------------------------------------------------------------------
+