From e336499626008e8ff06b1648c1b7afbab38c949b Mon Sep 17 00:00:00 2001 From: Mark Abraham Date: Sat, 20 Sep 2014 12:48:41 +0200 Subject: [PATCH] Fixed minor issue with NPT conserved energy The value of the number of degrees of freedom in a group is a real, but it was being truncated to an integer before promoting it back to a real. This is wrong, whether or not the number can reasonably be non-integral. This only affected the conserved energy quantity, not the kinetic or total energy used for coupling and output. Change-Id: I5fcb6428dc0e333cabd79262cc2a9cffa5fec03a --- src/gromacs/mdlib/coupling.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/gromacs/mdlib/coupling.c b/src/gromacs/mdlib/coupling.c index 41806dc44b..b156c61fad 100644 --- a/src/gromacs/mdlib/coupling.c +++ b/src/gromacs/mdlib/coupling.c @@ -1236,7 +1236,8 @@ int **init_npt_vars(t_inputrec *ir, t_state *state, t_extmass *MassQ, gmx_bool b real NPT_energy(t_inputrec *ir, t_state *state, t_extmass *MassQ) { - int i, j, nd, ndj, bmass, qmass, ngtcall; + int i, j, bmass, qmass, ngtcall; + real nd, ndj; real ener_npt, reft, eta, kT, tau; double *ivxi, *ixi; double *iQinv; @@ -1319,7 +1320,7 @@ real NPT_energy(t_inputrec *ir, t_state *state, t_extmass *MassQ) reft = max(ir->opts.ref_t[i], 0); kT = BOLTZ * reft; - if (nd > 0) + if (nd > 0.0) { if (IR_NVT_TROTTER(ir)) { @@ -1336,7 +1337,7 @@ real NPT_energy(t_inputrec *ir, t_state *state, t_extmass *MassQ) } else { - ndj = 1; + ndj = 1.0; } ener_npt += ndj*ixi[j]*kT; } -- 2.22.0