Re: Multiple successive addforce calls

From: Benjamin Bouvier (
Date: Thu Jun 05 2008 - 15:05:40 CDT

On Thu, 05 Jun 2008 21:02:46 +0200, Peter Freddolino
<> wrote:

> 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?

Hi Peter,
Thanks for the answer. It is indeed consistent, since I used loadforces in
my test... But if loadforces only reports the last call to addforce, how
were you able to check that all addforce calls get honored in the
simulation? I'd really like to make sure that my TCL script is doing what
I want it to do before I spend any major computing power ;-)


> Looks like we'll need to describe the fact that all forces will be
> applied and properly fix the loadforces behavior...
> Best,
> Peter
> 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:47:54 CST