Invalid command error

From: Adam Kells (
Date: Mon Jun 30 2014 - 06:49:07 CDT

Hi, I'm an undergraduate intern becoming acquainted with vmd and namd and I
am having trouble writing a code to find the centre of a ring of atoms in a
carbon nanotube. My code is:

proc radius molid {

set file [open "radius_[expr $molid].dat" w]

#Looping from 0 to 8 for the 9 rings that are in my nanotube.

for {set i 0} { $i <= 8} {incr i} {

#Initialise some variables
set sumr 0
set mass1 0
set com {0 0}

#There are 30 atoms per ring so i specify for this loop the ring of
  set sel [atomselect $molid "index [expr $i*30] to [expr ($i*30)+29]"]
  set sx [$sel get x]
  set sy [$sel get y]

#Finding centre of mass.
    foreach coord [$sel get {x y}] m [$sel get mass] {
        set mass1 [expr ($mass1 + $m)]

        set scaled [vecscale $m $coord]
        set com [vecadd $com $scaled]
        set centre [vecscale [expr 1. / $mass1] $com]

set cx [$centre get x]
set cy [$centre get y]

#Using coordinates of centre of mass to find the radius (distance of each
atom from the centre).
  foreach x $sx y $sy {
    set r [expr sqrt(($x - $cx)^2 + ($y - $cy)^2]
  set sumr [expr $sumr + $r]

#Getting the average radius.
  set rad [expr $sumr/19]

puts $file [list $rad]

close $file

The error I keep getting is "invalid command name "6.657242774963378e-5

Any help much appreciated.


This archive was generated by hypermail 2.1.6 : Wed Dec 31 2014 - 23:22:33 CST