Re: tclforces: switch from md with external forces to standard md

From: Peter Freddolino (
Date: Fri Jan 09 2009 - 15:49:35 CST

I'm afraid I need to eat my hat a bit here... based on Vlad's
description I looked into the code and found a place where it looked
like a flag wasn't set if no forces were applied, which would lead to
the behavior he described. However, having done some testing on my own
(and looked over things more) I see that my first impression was
incorrect. At least in my tests the forces do not persist past the last
step they are applied, at least for tclforces (they do in IMD, but this
is by design). They only bug (and this is a bug) I can find is in the
loadforces command, which is not updated if new forces aren't added,
even though the actual forces being applied appear to be.

So, Vlad, it's clear why loadforces is showing you the last force, and
this is a bug and will be fixed. However, the forces shouldn't actually
be persisting... can you test a bit more and/or give some hard data on
why you think this is the case for your system? In my tests the force
application clearly stops after you stop calling addforces.

Thanks, and apologies for my error.

Jerome Henin wrote:
> Hi all,
> On Thu, Jan 8, 2009 at 2:38 PM, Peter Freddolino <> wrote:
>> Hi Vlad,
>> the forces are not cumulative, but they may persist until changed.
> One may or may not call this a bug, but... what would it cost to fix it?
> Best,
> Jerome
>> Adding a zero force to each atom when you want to turn off the forces
>> should fix things.
>> Best,
>> Peter
>> Vlad Cojocaru wrote:
>>> Dear namd users,
>>> I have another question regarding tclforces.
>>> I would like that my tcl script switches at specific intervals between
>>> simulation with external forces and standard md simulation.
>>> So, I introduced a flag and invoked the "addforce" command only if the
>>> flag is defined. After each stint with external forces, I unset the
>>> flag and reset it after the standard md steps.
>>> However, I noticed that once the switch occurs, the external force
>>> does not disappear. In fact the value given by loadforces command
>>> stays constant during the standard md part and equals the last value
>>> from the part with external forces. From the trajectory, I guess that
>>> the external force is still being applied on my system even during the
>>> desired standard md simulation part.
>>> Am I right here? Does "addforce" actually adds up forces added at each
>>> time step ?
>>> If yes, is it possible to alter this behavior and reset the external
>>> force to 0 after specific intervals ?
>>> Thanks for answering
>>> Merry Christmas and Happy New Year to all of you.
>>> Vlad

This archive was generated by hypermail 2.1.6 : Wed Feb 29 2012 - 15:50:21 CST