Added grompp checks for zero atom masses in state B
authorErik Lindahl <erik@kth.se>
Thu, 22 May 2014 21:44:53 +0000 (23:44 +0200)
committerMark Abraham <mark.j.abraham@gmail.com>
Mon, 2 Jun 2014 07:20:52 +0000 (09:20 +0200)
Grompp already issued fatal errors if atoms had zero mass, or
if vsites had non-zero mass, in state A. This patch adds
state B to the same check.

Refs #1433.

Change-Id: Iec3d764ff7db6e7bdc3901d51b475cf2c35fe137

src/gromacs/gmxpreprocess/topio.c

index 52dcdd51cc6edc258b7fd8436fae6ef994592359..e5b97a4d4320dd813de6c441f60b6f57a50867b7 100644 (file)
@@ -173,7 +173,7 @@ double check_mol(gmx_mtop_t *mtop, warninp_t wi)
     char     buf[256];
     int      i, mb, nmol, ri, pt;
     double   q;
-    real     m;
+    real     m, mB;
     t_atoms *atoms;
 
     /* Check mass and charge */
@@ -187,30 +187,31 @@ double check_mol(gmx_mtop_t *mtop, warninp_t wi)
         {
             q += nmol*atoms->atom[i].q;
             m  = atoms->atom[i].m;
+            mB = atoms->atom[i].mB;
             pt = atoms->atom[i].ptype;
             /* If the particle is an atom or a nucleus it must have a mass,
              * else, if it is a shell, a vsite or a bondshell it can have mass zero
              */
-            if ((m <= 0.0) && ((pt == eptAtom) || (pt == eptNucleus)))
+            if (((m <= 0.0) || (mB <= 0.0)) && ((pt == eptAtom) || (pt == eptNucleus)))
             {
                 ri = atoms->atom[i].resind;
-                sprintf(buf, "atom %s (Res %s-%d) has mass %g\n",
+                sprintf(buf, "atom %s (Res %s-%d) has mass %g (state A) / %g (state B)\n",
                         *(atoms->atomname[i]),
                         *(atoms->resinfo[ri].name),
                         atoms->resinfo[ri].nr,
-                        m);
+                        m, mB);
                 warning_error(wi, buf);
             }
             else
-            if ((m != 0) && (pt == eptVSite))
+            if (((m != 0) || (mB != 0)) && (pt == eptVSite))
             {
                 ri = atoms->atom[i].resind;
-                sprintf(buf, "virtual site %s (Res %s-%d) has non-zero mass %g\n"
+                sprintf(buf, "virtual site %s (Res %s-%d) has non-zero mass %g (state A) / %g (state B)\n"
                         "     Check your topology.\n",
                         *(atoms->atomname[i]),
                         *(atoms->resinfo[ri].name),
                         atoms->resinfo[ri].nr,
-                        m);
+                        m, mB);
                 warning_error(wi, buf);
                 /* The following statements make LINCS break! */
                 /* atoms->atom[i].m=0; */