applying a force to some atoms

From: jing liang (jingliang2015_at_gmail.com)
Date: Sat Jun 27 2015 - 06:22:02 CDT

Hi,

I want to apply a force on certain atoms in my
system.

I wrote the following tcl lines within my namd input
script:

... additional lines for the setup of namd

dcdfreq 100
xstFreq 100
outputEnergies 100

################# TCL SCRIPT ############################
tclForces on
tclForcesScript {

proc calcforces {} {
   loadcoords coords
   loadmasses masses
   print $coords(3433)
}

}
#####################################################
run 10000

I saw that example in:
http://www.ks.uiuc.edu/Research/namd/2.6/ug/node33.html#SECTION00096800000000000000

It should print the coordinates for the atom 3433 but instead it gives me
some errors (below). Am I using the
correct syntax for tcl? Actually, my goal is to apply a restraint force on
the center of mass, is there
some script available for that?

Thanks.

Errors I got:

TCL: can't read "coords(3433)": no such variable
FATAL ERROR: can't read "coords(3433)": no such variable
    while executing
"print $coords(3433)"
    (procedure "calcforces" line 5)
    invoked from within
"calcforces"
------------- Processor 0 Exiting: Called CmiAbort ------------
Reason: FATAL ERROR: can't read "coords(3433)": no such variable
    while executing
"print $coords(3433)"
    (procedure "calcforces" line 5)
    invoked from within
"calcforces"

This archive was generated by hypermail 2.1.6 : Tue Dec 27 2016 - 23:21:11 CST