Added check in grompp for shells and inputrec issues.
authorDavid van der Spoel <spoel@xray.bmc.uu.se>
Mon, 23 Jun 2014 08:42:00 +0000 (10:42 +0200)
committerGerrit Code Review <gerrit@gerrit.gromacs.org>
Tue, 24 Jun 2014 18:51:53 +0000 (20:51 +0200)
Some combinations of inputrec settings do not work with shells,
in particular nstcalcenergy > 1 or use of a twin range cutoff.
This is now checked for in grompp. Fixes #1376.

Change-Id: I4382bcf5231920b22c725a7cf8e7b4e17c2526d9

src/kernel/grompp.c

index 2831a3dbb5e261729da3cabaaefff5c3c2dc20b5..d8a0e71c1f51728b6f1b6b5b5f040fed4e5fc206 100644 (file)
@@ -365,6 +365,41 @@ static void check_vel(gmx_mtop_t *mtop, rvec v[])
     }
 }
 
+static void check_shells_inputrec(gmx_mtop_t *mtop,
+                                  t_inputrec *ir,
+                                  warninp_t wi)
+{
+    gmx_mtop_atomloop_all_t aloop;
+    t_atom                 *atom;
+    int                     a, nshells = 0;
+    char                    warn_buf[STRLEN];
+
+    aloop = gmx_mtop_atomloop_all_init(mtop);
+    while (gmx_mtop_atomloop_all_next(aloop, &a, &atom))
+    {
+        if (atom->ptype == eptShell ||
+            atom->ptype == eptBond)
+        {
+            nshells++;
+        }
+    }
+    if (IR_TWINRANGE(*ir) && (nshells > 0))
+    {
+        snprintf(warn_buf, STRLEN, 
+                 "The combination of using shells and a twin-range cut-off is not supported");
+        warning_error(wi, warn_buf);
+    }
+    if ((nshells > 0) && (ir->nstcalcenergy != 1))
+    {
+        set_warning_line(wi, "unknown", -1);
+        snprintf(warn_buf, STRLEN, 
+                 "There are %d shells, changing nstcalcenergy from %d to 1", 
+                 nshells, ir->nstcalcenergy);
+        ir->nstcalcenergy = 1;
+        warning(wi, warn_buf);
+    }
+}
+
 static gmx_bool nint_ftype(gmx_mtop_t *mtop, t_molinfo *mi, int ftype)
 {
     int nint, mb;
@@ -1712,6 +1747,9 @@ int cmain (int argc, char *argv[])
         check_vel(sys, state.v);
     }
 
+    /* check for shells and inpurecs */
+    check_shells_inputrec(sys, ir, wi);
+
     /* check masses */
     check_mol(sys, wi);