Re: Invalid command error

From: Axel Kohlmeyer (akohlmey_at_gmail.com)
Date: Mon Jun 30 2014 - 07:44:41 CDT

adam,

this is a question about VMD and not NAMD. please repost your question
to the VMD-l list for a much better chance to get an on-topic answer.

the problem is in the [$centre get ...] lines. $center does not
contain a reference to an atomselect command but simply a number.
try:

set cx [lindex $center 0]
set cy [lindex $center 1]

this is standard Tcl stuff. checkout the sections on managing lists in
the Tcl tutorial on www.tcl.tk for more details.

axel.

On Mon, Jun 30, 2014 at 7:49 AM, Adam Kells <adam.kells_at_ucdconnect.ie> wrote:
> 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
> interest.
> 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
> 0.0"".
>
> Any help much appreciated.
>
> Adam

-- 
Dr. Axel Kohlmeyer  akohlmey_at_gmail.com  http://goo.gl/1wk0
College of Science & Technology, Temple University, Philadelphia PA, USA
International Centre for Theoretical Physics, Trieste. Italy.

This archive was generated by hypermail 2.1.6 : Thu Dec 31 2015 - 23:20:57 CST