From: Norman Geist (norman.geist_at_uni-greifswald.de)
Date: Wed Jan 07 2015 - 02:58:12 CST

Hey, if you create an atomselection than the current animation frame is used by default, so you need to set the desired frame for $velocitysel aswell. Actually your use of the coordinate dcd is not necessary at the time as you do not use them.

 

Norman Geist.

 

Von: owner-vmd-l_at_ks.uiuc.edu [mailto:owner-vmd-l_at_ks.uiuc.edu] Im Auftrag von JAVAD NOROOZI
Gesendet: Mittwoch, 7. Januar 2015 07:49
An: vmd-l_at_ks.uiuc.edu
Betreff: vmd-l: Problem with Kinetic Energy of Atomselection

 

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"]

$velocitysel frame $i

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