From: JC Gumbart (gumbart_at_ks.uiuc.edu)
Date: Tue Jan 09 2007 - 23:55:16 CST

AFAIK, the $sel frame __ command doesn't globally update everything, but
rather only the coordinates for that selection. It's much more useful to do
things this way so that you can compare the same selection across different
frames if you want.

-----Original Message-----
From: owner-vmd-l_at_ks.uiuc.edu [mailto:owner-vmd-l_at_ks.uiuc.edu] On Behalf Of
Myunggi Yi
Sent: Tuesday, January 09, 2007 10:15 PM
To: vmd-l_at_ks.uiuc.edu
Subject: vmd-l: changing frame

Dear VMD users,

I'm calculating 2D Mean Squared Displacement(MSD) to get diffusion
coefficient.
The following is my script.
I don't know why I get different results with and without "this line"
in the script.
I think I should have the same results because my selection "sel" is
always a residue of the "low_sel" selection.

Is there anything wrong in my script?

+++++++++++++++++++++++++++++++++++++++++
proc diffu_xy { sel f1 } {
    set fout [open $f1 w]
    set nf [molinfo top get numframes]
    set low_sel [atomselect top "resid 4 to 37"]

    for { set i 0 } { $i < $nf } { incr i } {
        $low_sel frame $i
        $sel frame $i <=== "this line"
        set com [measure center $low_sel weight mass]
        lappend cxy [vecsub [measure center $sel weight mass] $com]
    }

    set ds 0.0
    puts $fout "0 0.0"

    for { set i 1 } { $i < 5000 } { incr i } {
        for { set j 0 } { $j < [expr $nf - $i] } { incr j } {
            set k [expr $j + $i]
            set x [expr [lindex [lindex $cxy $k] 0] - \
                        [lindex [lindex $cxy $j] 0]]
            set y [expr [lindex [lindex $cxy $k] 1] - \
                        [lindex [lindex $cxy $j] 1]]
            set ds [expr $ds + ($x * $x + $y * $y)]
        }
        puts $fout "$i [expr $ds/($nf-$i)]"
        set ds 0.0
    }
    unset cxy
    close $fout
}

mol new ../../noWAT.parm7 type parm7 waitfor all
mol addfile ../unwrap.binpos type binpos waitfor all

set sel [atomselect top "resid 4"]
diffu_xy $sel cen-diff5.dat

set sel [atomselect top "resid 5"]
diffu_xy $sel cen-diff6.dat
.
.
.
+++++++++++++++++++++++++++++++++++++++

-- 
Best wishes,
MYUNGGI YI