From: Leandro Martínez (leandromartinez98_at_gmail.com)
Date: Mon Mar 13 2006 - 10:29:42 CST

Thanks Rui, thanks John, that solved the problem.
Good it was simple.
Best regards,
Leandro.

--------------------------------------
Leandro Martinez
Institute of Chemistry
State University of Campinas
http://www.ime.unicamp.br/~martinez/packmol
---------------------------------------

On 3/13/06, John Stone <johns_at_ks.uiuc.edu> wrote:
>
>
> Hi,
> You should be calling $sel delete inside the innermost loop, in the same
> scope where you're creating the selection! The memory hogging is almost
> certainly a result of delaying that $sel delete until all of
> the loops are overwith, which causes all those selections (except the
> last one) to be "leaked"..
>
> John Stone
> vmd_at_ks.uiuc.edu
>
> On Mon, Mar 13, 2006 at 02:10:16PM +0000, Leandro Martínez wrote:
> > Dear VMD users,
> > I need to visualize the the kinetic energy in each time-step of my
> > simulation.
> > I have written the velocity file for each step with NAMD and converted
> it
> > to pdb file. Then I made a simple script that reads this velocity file,
> > computes
> > the kinetic energy per atom and puts it in the "user field" of each
> atom, in
> > each frame of the trajectory (dcd) file. Everything seems to be working
> > fine,
> > unless for the fact that I can't load all data because it seems that
> using
> > the "user field" is very memory demanding. In principle what I am
> loading is
> > only a single real number for each atom, for each frame, and, therefore,
> it
> > should not require much more memory than the trajectory itself, which I
> > can load very quicky (the system has only 5000 atoms). However,
> > my computer gets very slow and I cannot pass from frames 30 or 31 while
> > filling the "user field". Bellow I attach the script I'm using for doing
> > this, it
> > is based on a script written by John Stone I got from this mail list.
> The
> > reading
> > of the velocity file is very fast, but the script gets extremely slow in
> the
> > next
> > loop and I cannot finish my analysis. Any help on this subject is
> > appreciated.
> > Thank you very much,
> > Leandro.
> >
> > -----------The script: ------------------------------------
> > set numframes [molinfo top get numframes]
> > set numatoms [molinfo top get numatoms]
> > puts "Opening velocity file..."
> > set file [ open ./velocities2.pdb r ]
> > set file [ read $file ]
> > set file [ split $file "\n" ]
> > set i 0
> > puts "Reading velocity file... "
> > foreach line $file {
> > if { [ string range $line 0 3 ] == "ATOM" } {
> > incr i
> > set vx [ string range $line 30 37 ]
> > set vy [ string range $line 38 46 ]
> > set vz [ string range $line 47 54 ]
> > set v2 [ expr $vx*$vx + $vy*$vy + $vz*$vz ]
> > set kinetic [ expr $v2 / 2. ]
> > set ek($i) $kinetic
> > }
> > }
> > #The next step is slow:
> > puts "Setting up atom colors..."
> > set k 0
> > for {set i 0} {$i<$numframes} {incr i} {
> > puts "Setting User data for frame $i ..."
> > for {set j 0} {$j<$numatoms} { incr j } {
> > incr k
> > set sel [atomselect top "index $j"]
> > set mass [$sel get mass]
> > animate goto $i
> > $sel frame $i
> > $sel set user [ expr $mass * $ek($k) ]
> > }
> > }
> > $sel delete
> > ---------------------------------------------------------------------
> >
> >
> > ---------------------------------------------
> > Leandro Martinez
> > Institute of Chemistry
> > State University of Campinas, Brazil
> > http://www.ime.unicamp.br/~martinez/packmol
> > --------------------------------------------
>
> --
> NIH Resource for Macromolecular Modeling and Bioinformatics
> Beckman Institute for Advanced Science and Technology
> University of Illinois, 405 N. Mathews Ave, Urbana, IL 61801
> Email: johns_at_ks.uiuc.edu Phone: 217-244-3349
> WWW: http://www.ks.uiuc.edu/~johns/ Fax: 217-244-6078
>