From: JAVAD NOROOZI (noroozijavad_at_REMOVE_yahoo.com)
Date: Wed Jan 07 2015 - 00:48:34 CST

Hi,I am trying to get kinetic energy of an atomselection (updated every frame), but i keep getting same kinetic energy for all frames (whereas the temp is rising in the simulation)
Here is the tcl script ,
###### top is the coordinate dcd , 1 is the velocity dcd#Sum is kinetic energy
________________________________________-set outfil [open energy.dat w]
set nf [molinfo top get numframes]
set sel [atomselect top "all"]
# kinetic energy calculation loop
for { set i 0 } { $i <= $nf } { incr i } {
$sel frame $i
$sel update
set sum 0
set INDEX [$sel get index]

set velocitysel [atomselect 1 "index $INDEX"]

foreach m [$velocitysel get mass] v [$velocitysel get {x y z}] {
set sum [expr $sum +0.5 * $m * [vecdot $v $v]]
}

puts $outfil "$f \t $sum"

}
close $outfil