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

Berk Hess hess at cbr.su.se
Thu Jan 27 15:35:23 CET 2011


I with ask not to give forces, we should not operate on forces.
But I can recall some issues with certain functions requiring a properly
allocated force array.
I think the bonded forces require a force array anyhow.

But this clearing should be conditional.
I can fix it.


On 01/27/2011 02:37 PM, Erik Marklund wrote:
> 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?
> Cheers,

More information about the gromacs.org_gmx-developers mailing list