From 07f2d6a944a0059ce1acd15f1659574efe77c9d9 Mon Sep 17 00:00:00 2001 From: Berk Hess Date: Tue, 24 Jun 2014 16:10:31 +0200 Subject: [PATCH] Fixed the sign of mass perturbed contribution Corrected the sign of the kinetic energy contribution to dHdl and dH. Fixes #1527. Change-Id: Ia1a2f708cdbba9a5a120a2ba8510cc2498f4d054 --- src/mdlib/update.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/mdlib/update.c b/src/mdlib/update.c index d19d6015bb..0ffa5e3fde 100644 --- a/src/mdlib/update.c +++ b/src/mdlib/update.c @@ -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; -- 2.22.0