From: Myunggi Yi (myunggi_at_gmail.com)
Date: Tue Jan 09 2007 - 22:15:11 CST

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