Re: Multiple successive addforce calls

From: Peter Freddolino (
Date: Thu Jun 05 2008 - 14:02:46 CDT

Hi Benjamin,
how were you querying the forces that were applied? Did you use loadforces?

Based on a relatively quick reading of the code, it looks to me like all
of the addforce calls are going to be applied in the simulation, but
only the *last* will be printed by loadforces. A quick experiment on
methane seems to confirm this. Is this consistent with what you saw?

Looks like we'll need to describe the fact that all forces will be
applied and properly fix the loadforces behavior...


Benjamin Bouvier wrote:
> More on that :
> I've compared the two approaches below using loadforces. When there is
> only one term per atom, they give the same result. When there are
> multiple terms, they do not...
> It seems that addforce should only be called *once* per atom -
> presumably, when called multiple times on one atom, only the force
> corresponding to the last call is honored... Though as a NAMD newbie,
> I was not able to check in the source whether this is effectively the
> case.
> Can someone confirm this? I found similar questions on the
> mailing-list, but with no replies...
> IMHO, a sentence should be added to the manual to describe addforce's
> behavior more accurately...
> Cheers,
> Benjamin.
> Le Thu, 05 Jun 2008 15:18:16 +0200, Benjamin Bouvier
> <> a écrit:
>> Hi all,
>> I'm using TCLforces to compute custom forces on a group of atoms. The
>> force on a given atom (say, $i) is a sum of several terms (say, $x1,
>> $x2 and $x3).
>> Is it OK to use:
>> addforce $i $x1
>> addforce $i $x2
>> addforce $i $x3
>> or should I do the sum myself, ie:
>> addforce $i [vecadd $x1 $x2 $x3]
>> I'm looking through the code right now, but if anybody knows the
>> answer and would like to spare me some work...
>> Thanks,
>> Benjamin

This archive was generated by hypermail 2.1.6 : Wed Feb 29 2012 - 15:49:32 CST