Fix genion charge summation accuracy
authorBerk Hess <hess@kth.se>
Fri, 10 Nov 2017 09:16:27 +0000 (10:16 +0100)
committerBerk Hess <hess@kth.se>
Fri, 10 Nov 2017 09:16:27 +0000 (10:16 +0100)
genion accumulated the charge is a float, which could cause
underestimation of the net charge for highly charged systems.

Fixes #2290

Change-Id: I22db5284e492f58dcdba99785cd904042d7aab7f

src/gromacs/gmxana/gmx_genion.cpp

index fb15635a25671dd9ac8844cdbffb37fc575d1264..b20cda07f59ca1439834c28693f0e689f15408f6 100644 (file)
@@ -3,7 +3,7 @@
  *
  * Copyright (c) 1991-2000, University of Groningen, The Netherlands.
  * Copyright (c) 2001-2004, The GROMACS development team.
- * Copyright (c) 2013,2014,2015,2016, by the GROMACS development team, led by
+ * Copyright (c) 2013,2014,2015,2016,2017, by the GROMACS development team, led by
  * Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
  * and including many others, as listed in the AUTHORS file in the
  * top-level source directory and at http://www.gromacs.org.
@@ -385,7 +385,7 @@ int gmx_genion(int argc, char *argv[])
     };
     t_topology         top;
     rvec              *x, *v;
-    real               vol, qtot;
+    real               vol;
     matrix             box;
     t_atoms            atoms;
     t_pbc              pbc;
@@ -425,7 +425,7 @@ int gmx_genion(int argc, char *argv[])
     atoms = top.atoms;
 
     /* Compute total charge */
-    qtot = 0;
+    double qtot = 0;
     for (i = 0; (i < atoms.nr); i++)
     {
         qtot += atoms.atom[i].q;