Fixed the sign of mass perturbed contribution
authorBerk Hess <hess@kth.se>
Tue, 24 Jun 2014 14:10:31 +0000 (16:10 +0200)
committerMark Abraham <mark.j.abraham@gmail.com>
Tue, 24 Jun 2014 15:22:07 +0000 (17:22 +0200)
Corrected the sign of the kinetic energy contribution to dHdl and dH.

Fixes #1527.

Change-Id: Ia1a2f708cdbba9a5a120a2ba8510cc2498f4d054

src/mdlib/update.c

index d19d6015bb05e0d22b484e37e40eb0ea6a680254..0ffa5e3fdec72baf0a3915ae9fca611cb61c0ef0 100644 (file)
@@ -1163,7 +1163,12 @@ static void calc_ke_part_visc(matrix box, rvec x[], rvec v[],
         }
         if (md->nPerturbed && md->bPerturbed[n])
         {
-            dekindl += 0.5*(md->massB[n] - md->massA[n])*iprod(v_corrt, v_corrt);
+            /* The minus sign here might be confusing.
+             * The kinetic contribution from dH/dl doesn't come from
+             * d m(l)/2 v^2 / dl, but rather from d p^2/2m(l) / dl,
+             * where p are the momenta. The difference is only a minus sign.
+             */
+            dekindl -= 0.5*(md->massB[n] - md->massA[n])*iprod(v_corrt, v_corrt);
         }
     }
     ekind->dekindl = dekindl;