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

From: Vlad Cojocaru (Vlad.Cojocaru_at_eml-r.villa-bosch.de)
Date: Mon Jan 12 2009 - 01:57:20 CST

Dear Peter, Dear Jerome,

Thanks a lot for curving in here. I did not unset the external forces
array in my script so I'll try to test that later on. But I agree that
everything I see is in fact a problem with the "loadforces" command
rather than the force application procedure.

I still have a couple of things I do not understand . One is that
"loadforces" does not store any force while the forces are applied on
the COM of a group of atoms rather than on each atom.

Second, you said forces are not cumulated. However, if I look at the
"loadforces" array, I would say they are actually cumulated. If I apply
the external forces for 50 steps, switch to "no forces for the next 100
steps and then switch back to applying external forces, the value below
are stored by "loadforces" (the length of the vector is calculated with
the veclength command). It looks to me that every 2 steps a value of
5.73 is constantly added to the external forces array until external
forces are switched off. After that for 150 steps the "loadforces"
outputs the same value while when switching back to the external forces
regime, it adds on top of the last recorded value.

This could well be a bug of the "loadforces" command and It could be
that the simulation goes right. If I monitor the totalforces (with the
"loadtotalforces" command) the values are constantly between 10 and 100.

I dont think it makes much sense for me to send you the script as its a
long one ... I should probably write first a simplified short form of
the script for testing that reproduces this behavior and then send it to
you. Maybe it would help if you could send me the script you used for
testing before and see if I can reproduce your tests....

Thanks again for your time and best wishes
vlad

TCL: RAMD> NSTEP:2 :: EXTERNAL FORCES ON C7 OF FLO: 0.922844871582
-2.41492289344 -1.24298926924 :: ||forces|| = +5.73
TCL: RAMD> NSTEP:4 :: EXTERNAL FORCES ON C7 OF FLO: 2.76853461475
-7.24476868032 -3.72896780772 :: ||forces|| = 8.60561781951
TCL: RAMD> NSTEP:6 :: EXTERNAL FORCES ON C7 OF FLO: 4.61422435791
-12.0746144672 -6.2149463462 :: ||forces|| = 14.3426963659
TCL: RAMD> NSTEP:8 :: EXTERNAL FORCES ON C7 OF FLO: 6.45991410107
-16.9044602541 -8.70092488468 :: ||forces|| = 20.0797749122
TCL: RAMD> NSTEP:10 :: EXTERNAL FORCES ON C7 OF FLO: 8.30560384424
-21.734306041 -11.1869034232 :: ||forces|| = 25.8168534586
TCL: RAMD> NSTEP:12 :: EXTERNAL FORCES ON C7 OF FLO: 10.1512935874
-26.5641518278 -13.6728819616 :: ||forces|| = 31.5539320048
TCL: RAMD> NSTEP:14 :: EXTERNAL FORCES ON C7 OF FLO: 11.9969833306
-31.3939976147 -16.1588605001 :: ||forces|| = 37.2910105512
TCL: RAMD> NSTEP:16 :: EXTERNAL FORCES ON C7 OF FLO: 13.8426730737
-36.2238434016 -18.6448390386 :: ||forces|| = 43.0280890975
TCL: RAMD> NSTEP:18 :: EXTERNAL FORCES ON C7 OF FLO: 15.6883628169
-41.0536891885 -21.1308175771 :: ||forces|| = 48.7651676439
TCL: RAMD> NSTEP:20 :: EXTERNAL FORCES ON C7 OF FLO: 17.5340525601
-45.8835349754 -23.6167961156 :: ||forces|| = 54.5022461903
TCL: RAMD> NSTEP:22 :: EXTERNAL FORCES ON C7 OF FLO: 19.3797423032
-50.7133807622 -26.102774654 :: ||forces|| = 60.2393247365
TCL: RAMD> NSTEP:24 :: EXTERNAL FORCES ON C7 OF FLO: 21.2254320464
-55.5432265491 -28.5887531925 :: ||forces|| = 65.9764032829
TCL: RAMD> NSTEP:26 :: EXTERNAL FORCES ON C7 OF FLO: 23.0711217896
-60.373072336 -31.074731731 :: ||forces|| = 71.7134818292
TCL: RAMD> NSTEP:28 :: EXTERNAL FORCES ON C7 OF FLO: 24.9168115327
-65.2029181229 -33.5607102695 :: ||forces|| = 77.4505603756
TCL: RAMD> NSTEP:30 :: EXTERNAL FORCES ON C7 OF FLO: 26.7625012759
-70.0327639098 -36.046688808 :: ||forces|| = 83.187638922
TCL: RAMD> NSTEP:32 :: EXTERNAL FORCES ON C7 OF FLO: 28.608191019
-74.8626096966 -38.5326673464 :: ||forces|| = 88.9247174682
TCL: RAMD> NSTEP:34 :: EXTERNAL FORCES ON C7 OF FLO: 30.4538807622
-79.6924554835 -41.0186458849 :: ||forces|| = 94.6617960146
TCL: RAMD> NSTEP:36 :: EXTERNAL FORCES ON C7 OF FLO: 32.2995705054
-84.5223012704 -43.5046244234 :: ||forces|| = 100.398874561
TCL: RAMD> NSTEP:38 :: EXTERNAL FORCES ON C7 OF FLO: 34.1452602485
-89.3521470573 -45.9906029619 :: ||forces|| = 106.135953107
TCL: RAMD> NSTEP:40 :: EXTERNAL FORCES ON C7 OF FLO: 35.9909499917
-94.1819928442 -48.4765815004 :: ||forces|| = 111.873031654
TCL: RAMD> NSTEP:42 :: EXTERNAL FORCES ON C7 OF FLO: 37.8366397349
-99.011838631 -50.9625600388 :: ||forces|| = 117.6101102
TCL: RAMD> NSTEP:44 :: EXTERNAL FORCES ON C7 OF FLO: 39.682329478
-103.841684418 -53.4485385773 :: ||forces|| = 123.347188746
TCL: RAMD> NSTEP:46 :: EXTERNAL FORCES ON C7 OF FLO: 41.5280192212
-108.671530205 -55.9345171158 :: ||forces|| = 129.084267293
TCL: RAMD> NSTEP:48 :: EXTERNAL FORCES ON C7 OF FLO: 43.3737089644
-113.501375992 -58.4204956543 :: ||forces|| = 134.821345839
TCL: RAMD> NSTEP:50 :: EXTERNAL FORCES ON C7 OF FLO: 45.2193987075
-118.331221779 -60.9064741928 :: ||forces|| = 140.558424386
----------------------------------------------------------
TCL: RAMD> NSTEP:52 :: EXTERNAL FORCES ON C7 OF FLO: 47.0650884507
-123.161067565 -63.3924527312 :: ||forces|| = 146.295502931
TCL: RAMD> NSTEP:54 :: EXTERNAL FORCES ON C7 OF FLO: 47.0650884507
-123.161067565 -63.3924527312 :: ||forces|| = 146.295502931
......
TCL: RAMD> NSTEP:150 :: EXTERNAL FORCES ON C7 OF FLO: 47.0650884507
-123.161067565 -63.3924527312 :: ||forces|| = 146.295502931
---------------------------------------------------------
TCL: RAMD> NSTEP:152 :: EXTERNAL FORCES ON C7 OF FLO: 47.9879333223
-125.575990459 -64.6354420005 :: ||forces|| = 149.164042205
TCL: RAMD> NSTEP:154 :: EXTERNAL FORCES ON C7 OF FLO: 49.8336230654
-130.405836246 -67.121420539 :: ||forces|| = 154.901120751
TCL: RAMD> NSTEP:156 :: EXTERNAL FORCES ON C7 OF FLO: 51.6793128086
-135.235682033 -69.6073990774 :: ||forces|| = 160.638199298

Peter Freddolino wrote:
> Actually, to add to my embarrassment... loadforces actually is *not*
> reporting any incorrect information at all. However, if one doesn't
> unset the array that the forces were loaded into from the previous step,
> everything remains unchanged, because loadforces only sets the array
> elements where forces were actually applied. Vlad, could you check
> and/or send your script? I imagine a similar problem is leading to what
> you're observing in terms of loadforces showing the "old" forces.
> Best,
> Peter
>
> Peter Freddolino wrote:
>
>> 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.
>> Peter
>>
>> Jerome Henin wrote:
>>
>>
>>> Hi all,
>>>
>>> On Thu, Jan 8, 2009 at 2:38 PM, Peter Freddolino <petefred_at_ks.uiuc.edu> 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
>>>>>
>>>>>
>>>>>
>>>>>
>>>>
>>>>
>>>>
>
>

-- 
----------------------------------------------------------------------------
Dr. Vlad Cojocaru
EML Research gGmbH
Schloss-Wolfsbrunnenweg 33
69118 Heidelberg
Tel: ++49-6221-533202
Fax: ++49-6221-533298
e-mail:Vlad.Cojocaru[at]eml-r.villa-bosch.de
http://projects.villa-bosch.de/mcm/people/cojocaru/
----------------------------------------------------------------------------
EML Research gGmbH
Amtgericht Mannheim / HRB 337446
Managing Partner: Dr. h.c. Klaus Tschira
Scientific and Managing Director: Prof. Dr.-Ing. Andreas Reuter
http://www.eml-r.org
----------------------------------------------------------------------------

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