Tcl forces

From: Manuela Cavallari (
Date: Thu Jun 16 2005 - 05:51:05 CDT

Dear all,
my goal is to perform a simulation keeping the z coordinate of
a particular atom fixed, whilst the x y coordinate are free.
To this purpose, I've tried to use the Tcl interface and the
calcforces procedure to set to zero the z component of the force
acting on the target atom at each timestep, but without success,
that is, the z coordinate of the target atom changes.
Here's my tcl script:

# definition of the output file
set outcoor [open 1594.coor w]

# definition of the id of the target atom
set aid 1594
addatom $aid

# calcforces procedure
proc calcforces {} {

global aid outcoor outforc

# get and print the coordinate of the target atom
#to check the result of the calculation
loadcoords p
set rtarget $p($aid)
puts $outcoor "$rtarget"

# get force on the atom target
loadtotalforces f
if {[array exists f]} {

# define the force to apply to the target atom
set ftarget $f($aid)

# z component
set fn [lindex $ftarget 2]
set fz [expr -$fn]

# x component
set fx 0

# y component
set fy 0

lappend fzero $fx $fy $fz

# add the zeroing force fzero to the target atom
addforce $aid $fzero

Where's the problem?

If someone knows another way to fix the z component of one atom,
please let me now!

Thank you so much for the attention,
best regards
Manuela Cavallari

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