From: Josh Vermaas (vermaas2_at_illinois.edu)
Date: Thu Oct 30 2014 - 09:55:16 CDT

Hi Ondřej,

I think you can fix this by changing the line:
set owsel [atomselect top "index $ow"]
to:
set owsel [atomselect top "index $ow" frame $i]

New atomselections default to picking the currently active frame
(usually the last one if you don't explicitly change it with animate),
so in principle that is at least part of the problem. Does your platinum
atom ever move? I'm surprised to see constant distances, since if your
platinum molecule moves at all, the distance should nevertheless change.
You may also need to issue a $sel2 update to recalculate the
atomselection at each frame, since in principle the water molecule
nearest to the platinum atom is supposed to change (see the docs:
http://www.ks.uiuc.edu/Research/vmd/current/ug/node121.html).

-Josh Vermaas

On 10/30/2014 08:49 AM, Ondrej Kroutil wrote:
> Dear VMD users,
> I modified distance.tcl to get distance between water oxygen atom
> and platinum atom. There is always 1 confined water molecule in the
> selection but this molecule can have different id during simulation (1
> water molecule is replaced by another and so on).
> First I select whole water molecule (sel2), than I get an index of
> OW atom (set ndx [$sel2 list] and set ow [lindex $ndx 0]). I need to
> select whole water molecule because I will need to get also distances
> between Pt and HW1 and Pt and HW2.
> The problem is that after processing of a script displayed below I
> always get thist Pt-OW distance in the last frame for all frames:
>
> 0 3.5100714578446253
> 1 3.5100714578446253
> 2 3.5100714578446253
> 3 3.5100714578446253
> 4 3.5100714578446253
> ...
>
> There is maybe problem with update of selection or variable but I
> cannot find it. I'm sorry I bother you with such a easy thing. I
> really tried hard to solve it by myself and but I didn't succeeded ...
> Thanks a lot.
>
> Ondrej Kroutil
>
> ********************** **********************
> SCRIPT:
> ********************** **********************
> set sel1 [atomselect top "name Pt"]
> set sel2 [atomselect top "same resid as (name OW and
> sqrt((x-6.81)*(x-6.81) + (y-6.81)*(y-6.81)) < 1.2 and within 5 of name
> Pt)"]
> set nf [molinfo top get numframes]
> set outfile [open pok.dat w]
>
> for {set i 0} {$i < $nf} {incr i} {
>
> puts "frame $i of $nf"
> $sel1 frame $i
> $sel2 frame $i
>
> set ndx [$sel2 list]
> set ow [lindex $ndx 0]
> set owsel [atomselect top "index $ow"]
>
> set com1 [measure center $sel1]
> set com2 [measure center $owsel]
>
> set simdata($i.r) [veclength [vecsub $com1 $com2]]
> puts $outfile "$i $simdata($i.r)"
>
> $owsel delete
> unset ow
> unset com2
> unset com1
> unset simdata
> }
> close $outfile
> ********************** **********************
>
> --
> Ondřej Kroutil
> ,, Faculty of Health and Social Studies
> ----"))' University of South Bohemia
> OOO Jirovcova 24, Ceske Budejovice
> OOO The Czech Republic
> | OO E-mail: okroutil_at_gmail.com
> <mailto:okroutil_at_gmail.com>
> >------ O Mobile: +420 736 537 190