A problem of the forces-tutorial

From: (zhangning19850204_at_hotmail.com)
Date: Thu Apr 08 2010 - 07:18:33 CDT

I am a begginer in NAMD. I have a problem in "Example 4: Improving Efficiency" of the namd tutorial forces-tutorial
Having read the NAMD ug, I am still not clear that why the addatom and clearconfig are used in the "calcforces { }" ,since a addatom has been used above the function.
The tclforcesscript as follows:

set targetMark "1.00"
set targets {}
set masses {}

set inStream [open $targetAtomPdb r]
foreach line [split [read $inStream] \n] {
   ..........................................
}
close $inStream

# make list of atoms
set atoms {}
foreach target $targets {
    foreach {segname resid atom} $target { break }
    set atomindex [atomid $segname $resid $atom]
    lappend atoms $atomindex
    addatom $atomindex
}

set numatoms [llength $atoms]

if { $numatoms > 0 } {
    set applyforce 1
} else {
    print "WARNING: no target atoms have been detected"
    set applyforce 0
}

# Take force factor from NAMD config file
............................................

set forcecount $forcesRecalcFreq
set printcount 0

proc calcforces { } {
    global atoms numatoms masses linaccel_namd angaccel_namd forces
    global applyforce forcesRecalcFreq
    global forcecount printcount
    global PI
    
    if { $applyforce } {
     # Apply forces
     foreach atom $atoms force $forces {
     addforce $atom $force
 }
 
 # Check to see if we're about to recalculate forces
 # next time step. If so, clearconfig and re-add atoms
 if { $forcecount == [expr $forcesRecalcFreq - 1] } {
     print "Adding atoms prior to reconfiguring forces at $printcount"
     foreach atom $atoms {
     addatom $atom
     }
 }
 
 if { $forcecount == $forcesRecalcFreq } {
     print "Recalculating forces at $printcount"
     
    .....................................................
  
  lappend forces $force
     }
     
     print "Step ${printcount}: Recalculated [llength $forces] forces"
     
     set forcecount 0
     
     # Vital to clearconfig after calculating forces, else
     # coordinates will be retrieved every timestep, erasing
     # much of the potential speed gains
     clearconfig
 }
    }
    incr forcecount
    incr printcount
    return
}

I will appreciate the help!

=============================================================================

Dr. Ning Zhang
School of Energy and Power Engineering
Dalian University of Technology
Dalian 116021, China
=============================================================================

This archive was generated by hypermail 2.1.6 : Wed Feb 29 2012 - 15:54:00 CST