From: Axel Kohlmeyer (akohlmey_at_gmail.com)
Date: Tue Nov 09 2010 - 11:06:31 CST

On Tue, 2010-11-09 at 16:57 +0000, Stephen Cox wrote:
> Hi Axel,

hi steve,

please always keep the list in cc:
thanks.

> Many thanks for your help. I'm nearly there implementing what you
> said. For each frame my external program prints out to one line
> [1 0 0 1 0 0 ..... ] (output file solid.dat) where 1 indicates solid
> and 0 indicates liquid. I have the following script to read this into
> the "user" field:
>
> #################################################
> set molid 0
> set atoms [atomselect $molid {all}]
>
> # read in solid/liquid status
> set n [molinfo $molid get numframes]
>
> puts "reading structural parameter information"
>
> set fp [open "solid.dat" r]
>
> for {set i 0} {$i < $n} {incr i} {
> $atoms frame $i
> set solid($i) [gets $fp]
> $atoms set user $solid($i)

here you are storing the data in an array
and then set the user field. the array is
not needed for that, so the last two lines become

    $atom set user [gets $fp]

> }
>
> close $fp
> #################################################
>
> How can I adapt this script so that the user field is updated every
> frame? At the moment if I source the above script in vmd it seems to
> find the solid particles for that frame only... its probably quite
> simple but I'm quite unfamiliar with scripting in VMD!

you have to tell VMD to update the selection in every step.
this is usually not needed and thus disabled to make
the display updates faster.

go to the "Graphical Representations" window and click
on the "Trajectory" tab. then activate "Update Selection Every Frame"
that should do it.

otherwise you have to check your script for errors on
the vmd command line prompt.

i would suggest to go over the process with a small
system and doing the steps manually, to debug it.

axel.

>
> Best wishes,
>
> Steve
>
> P.S. For clarity, the external program only deals with the oxygen
> atoms hence the "set atoms [atomselect $molid {all}]"...
>
>
> On Tue, Nov 9, 2010 at 2:10 PM, Axel Kohlmeyer <akohlmey_at_gmail.com>
> wrote:
> On Tue, 2010-11-09 at 13:11 +0000, Stephen Cox wrote:
> > Hi,
>
> steve,
>
> > I am trying to visualize the freezing of ice and I have an
> external
> > program that specifies which molecules may be defined as
> solid.
> > Obviously when going from liquid to ice the number of
> "solid"
> > particles changes and this poses a problem when reading in a
> > trajectory coordinate file as all atom descriptors (name,
> mass etc)
> > are read in only from the first frame and vmd doesn't allow
> variable
> > number of atoms in an xyz file (for example). I have tried
> multiple
> > molecule animation but this seems impractical for long
> > trajectories...
> >
> > Is there any way that I can label the atoms defined as solid
> at each
> > frame so that vmd can recognise them? Alternatively, could I
> script an
> > atom selection on a frame by frame basis?
>
>
> the most elegant way to handle this would be to store
> the solid/liquid flag in the "user" field (or "user2",
> user3", "user4"). this is a per atom and per timestep
> property that can be used in a selection. e.g. if you
> flag all solid atoms with -1 and and all liquid with
> +1 then "user < 0.0" will select the solid ones (well,
> you have to tell VMD to update the selection in every
> step in the trajectory tab, too). you can either compute
> this from a VMD script or have your program write the
> information to a file and then read it back into the
> user field. this pdf discusses some examples of how to
> do this.
>
> http://sites.google.com/site/akohlmey/redirect/cpmd-vmd.pdf
>
> the absolute best way would be to change your external
> code to become a plugin for VMD. ;)
>
> let us know if you need any additional pointers.
>
> cheers,
> axel.
>
>
> > Thanks in advance for any help,
> > Steve
>
>
> --
> Dr. Axel Kohlmeyer
> akohlmey_at_gmail.com http://goo.gl/1wk0
>
> Institute for Computational Molecular Science
> Temple University, Philadelphia PA, USA.
>
>

-- 
Dr. Axel Kohlmeyer
akohlmey_at_gmail.com http://goo.gl/1wk0
Institute for Computational Molecular Science
Temple University, Philadelphia PA, USA.