fixed incorrect TPI results with dynamic box
authorBerk Hess <hess@kth.se>
Mon, 6 Aug 2012 18:52:59 +0000 (20:52 +0200)
committerBerk Hess <hess@kth.se>
Mon, 6 Aug 2012 18:52:59 +0000 (20:52 +0200)
TPI with a box in the -rerun file different from the tpr gave systematic
errors. In Gromacs 4.0 there was a minor error, but not systematic.
Now TPI with any box setup is fully correct. Fixes #799

Change-Id: I69279874c2d1192e63efa224a0f035d43e919e88

src/mdlib/tpi.c

index 8fb735306f9517ff6e0f45d2088cf98fb8c708da..4c2e396107c70190b99ea6b0b9c5a7f24c3b93ee 100644 (file)
@@ -417,8 +417,9 @@ double do_tpi(FILE *fplog,t_commrec *cr,
         {
             copy_rvec(rerun_fr.x[i],state->x[i]);
         }
+        copy_mat(rerun_fr.box,state->box);
         
-        V = det(rerun_fr.box);
+        V = det(state->box);
         logV = log(V);
         
         bStateChanged = TRUE;
@@ -565,18 +566,18 @@ double do_tpi(FILE *fplog,t_commrec *cr,
                 cr->nnodes = 1;
                 do_force(fplog,cr,inputrec,
                          step,nrnb,wcycle,top,top_global,&top_global->groups,
-                         rerun_fr.box,state->x,&state->hist,
+                         state->box,state->x,&state->hist,
                          f,force_vir,mdatoms,enerd,fcd,
                          lambda,NULL,fr,NULL,mu_tot,t,NULL,NULL,FALSE,
                          GMX_FORCE_NONBONDED |
-                         (bNS ? GMX_FORCE_NS | GMX_FORCE_DOLR : 0) |
+                         (bNS ? GMX_FORCE_DYNAMICBOX | GMX_FORCE_NS | GMX_FORCE_DOLR : 0) |
                          (bStateChanged ? GMX_FORCE_STATECHANGED : 0)); 
                 cr->nnodes = nnodes;
                 bStateChanged = FALSE;
                 bNS = FALSE;
                 
                 /* Calculate long range corrections to pressure and energy */
-                calc_dispcorr(fplog,inputrec,fr,step,top_global->natoms,rerun_fr.box,
+                calc_dispcorr(fplog,inputrec,fr,step,top_global->natoms,state->box,
                               lambda,pres,vir,&prescorr,&enercorr,&dvdlcorr);
                 /* figure out how to rearrange the next 4 lines MRS 8/4/2009 */
                 enerd->term[F_DISPCORR] = enercorr;