[gmx-developers] Pitfall in do_force() when fr->bTwinRange==TRUE

Erik Marklund erikm at xray.bmc.uu.se
Thu Jan 27 14:37:53 CET 2011

Hi, fellow developers,

In my code I issue a few extra calls to do_force to get the potential 
energy of the system. I figure that, since I don't need the forces, I 
call do_force with the GMX_FORCE_FORCES bit unset in flags (in my case 
flags = GMX_FORCE_STATECHANGED | GMX_FORCE_NS). Thus I figure don't need 
to provide a force array either and call it with f=NULL. However, if 
some kind of twin-range setup is used, the force vector is used by 
do_force() anyway:

/* Reset long range forces if necessary */
         if (fr->bTwinRange)
             /* Reset the (long-range) forces if necessary */
             clear_rvecs(fr->natoms_force_constr,bSepLRF ? fr->f_twin : f);

Why are the forces reset in this case? Do they really need to be, or can 
do_force be safely modified to not clear the force vectors e.g. in case 
they're NULL or if bDoForces == FALSE?


Erik Marklund, PhD student
Dept. of Cell and Molecular Biology, Uppsala University.
Husargatan 3, Box 596,    75124 Uppsala, Sweden
phone:    +46 18 471 4537        fax: +46 18 511 755
erikm at xray.bmc.uu.se    http://folding.bmc.uu.se/

More information about the gromacs.org_gmx-developers mailing list