Fixed LJ-14 error in free energy
authorErik Lindahl <erik@kth.se>
Thu, 22 Nov 2012 17:28:45 +0000 (18:28 +0100)
committerErik Lindahl <erik@kth.se>
Thu, 22 Nov 2012 17:28:45 +0000 (18:28 +0100)
This bug was introduced when I implemented the new separate
1,4-evaluation of free energies, and failed to take the
now-included 6.0 & 12.0 prefactors in c6 & c12 into account.
The net effect is merely that it altered the softcore power
slightly, which caused it to deviate somewhat from the reference
value in the regression testing.

Change-Id: I70fb7e6da7186b0f10b654d060e1e1275f3676e9

src/gmxlib/nonbonded/nb_free_energy.c

index 9400c8a89927666e7d85b16cfa16d49adc2d4554..a4bbe5b51247a78a77b70efb91e0eafcf640f854 100644 (file)
@@ -638,8 +638,11 @@ nb_free_energy_evaluate_single(real r2,real sc_r_power,real alpha_coul,real alph
     {
         if((c6[i] > 0) && (c12[i] > 0))
         {
-            sigma6[i]       = c12[i]/c6[i];
-            sigma2[i]       = pow(c12[i]/c6[i],1.0/3.0);
+            /* The c6 & c12 coefficients now contain the constants 6.0 and 12.0, respectively.
+             * Correct for this by multiplying with (1/12.0)/(1/6.0)=6.0/12.0=0.5.
+             */
+            sigma6[i]       = 0.5*c12[i]/c6[i];
+            sigma2[i]       = pow(0.5*c12[i]/c6[i],1.0/3.0);
             /* should be able to get rid of this ^^^ internal pow call eventually.  Will require agreement on
              what data to store externally.  Can't be fixed without larger scale changes, so not 4.6 */
             if (sigma6[i] < sigma6_min) { /* for disappearing coul and vdw with soft core at the same time */