Add missing Ewald correction for pme-user
authorBerk Hess <hess@kth.se>
Thu, 2 Nov 2017 08:42:39 +0000 (09:42 +0100)
committerBerk Hess <hess@kth.se>
Thu, 2 Nov 2017 08:42:39 +0000 (09:42 +0100)
With coulomb-type = pme-user, the Ewald mesh energy was not subtracted
leading to (very) incorrect Coulomb energies and forces.

Fixes #2286

Change-Id: Idfef9896d484e254264150e718c5516a832a2ad4

src/gromacs/tables/forcetable.cpp

index 04eae447f76929965d45e3896b08f082487577f1..55dbfc4b83aa4aa3f22f5c602719677119caec47 100644 (file)
@@ -1425,9 +1425,10 @@ t_forcetable *make_tables(FILE *out,
 
     for (int k = 0; (k < etiNR); k++)
     {
-        /* Now fill data for tables that should not be read (perhaps
-           overwriting data that was read but should not be used) */
-        if (!ETAB_USER(tabsel[k]))
+        /* Now fill data for tables that have not been read
+         * or add the Ewald long-range correction for Ewald user tables.
+         */
+        if (tabsel[k] != etabUSER)
         {
             real scale = table->scale;
             if (fr->bBHAM && (fr->bham_b_max != 0) && tabsel[k] == etabEXPMIN)