Re: Multiple successive addforce calls

From: Peter Freddolino (
Date: Thu Jun 05 2008 - 15:25:31 CDT

Hi Benjamin,
I just made a methane molecule in vacuum at 0 K and at each timestep
used tcl forces to apply the forces {5 0 0} and {-5 0 0}, and observed
that it remained stationary while loadforces printed {-5 0 0} for the
force on this atom at each step. This is consistent with the code and
with previous experience. To be extra sure, you may want to verify this
for a small set of atoms using your script.

Benjamin Bouvier wrote:
> 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 ;-)
> Best,
> Benjamin
>> 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:49:32 CST