From: Axel Kohlmeyer (akohlmey_at_cmm.chem.upenn.edu)
Date: Sat Sep 08 2007 - 20:37:28 CDT

On Sat, 8 Sep 2007, jo hanna wrote:

JH> Hi
JH>
JH> Could anyone please advise why the first script works but the second script
JH> retuns the following error: vecsub two vectors don't have the same size

JH> for {set i 0} {$i<$nf} {incr i} {
JH>
JH> global M_PI
JH>
JH> $A frame $i
JH> $E frame $i
JH> $F frame $i
JH>
JH> set atoms [atomselect top {index 2 4 5}]

.... another potential memory leak.
you have to move atomselect definitions
outside of the loop or use "$atoms delete"
at the end of the loop (wastes time, though).
you have to see atomselect and its corresponding
call to the selection with delete like malloc(3)/free(3)
in c/c++ programming.

JH> $atoms frame $i
JH>
JH> set coords [$atoms get {x y z}]

this will return a list with 3(!!) coordinate triples

JH> set av [lindex $coords 2]
JH> set ev [lindex $coords 4]
JH> set fv [lindex $coords 5]

so this has to become:

set av [lindex $coords 0]
set ev [lindex $coords 1]
set fv [lindex $coords 2]

note that the lists returned by selections
are always sorted by index.

cheers,
   axel.

JH> set ae [vecsub $av $ev]
JH> set af [vecsub $av $fv]
JH>
JH> puts $outfile "[expr acos([vecdot $ae $af]/([veclength $ae] * [veclength
JH> $af])) *(180.0/$M_PI)]"
JH>
JH>
JH> }
JH> close $outfile
JH> **
JH>

-- 
=======================================================================
Axel Kohlmeyer   akohlmey_at_cmm.chem.upenn.edu   http://www.cmm.upenn.edu
   Center for Molecular Modeling   --   University of Pennsylvania
Department of Chemistry, 231 S.34th Street, Philadelphia, PA 19104-6323
tel: 1-215-898-1582,  fax: 1-215-573-6233,  office-tel: 1-215-898-5425
=======================================================================
If you make something idiot-proof, the universe creates a better idiot.