From: Axel Kohlmeyer (akohlmey_at_cmm.chem.upenn.edu)
Date: Tue Dec 11 2007 - 21:50:14 CST

On Wed, 12 Dec 2007, Anil Kumar wrote:

anil,

it won't work "black box" style. your problem is almost orthogonal
to what VMD was written for. if you didn't notice
eddi's idea (which is equivalent to what i already suggested
before without going into detail) here some more explanations.

you have to first read in your trajectory (pre-requisite
the total number of atoms does not change). now VMD assumes,
that atom names do not change over the course of a trajectory,
so after the first frame, it will only read the coordinates.

now you can store a single property, per frame and per atom
in the user field, but you have to write a (tcl) script that
reads the whole trajectory file and for each frames encodes
the atom type - as eddi suggested - as numbers 1,2,... and
so on. example 5.3 and 5.4 at:
http://www.theochem.ruhr-uni-bochum.de/~axel.kohlmeyer/cpmd-vmd/part3.html#chap5_sect3
have an example on how you can store a property in the user
field and read data from an external file. you'll have to
merge this and adapt it for your purposes.

finally, you have the option to visualize the result either
by using the User colorization or building multiple representations
where you use selections of the kind "user == 1" , "user == 2"
and pick the appropriate color for each of the atom types.
of course, that requires activating the "update color" flag
in the first and "update selection" flag in the second case.

hope that helps,
   axel.
AK>
AK> Hi Eddi,
AK>
AK> I tried with the script you sent me but unfortunately it did not
AK> work for me. First when I run the script it gave this error ::
AK>
AK> _____________________________________
AK> >Main< (N1000) 5 % source script.tcl
AK>
AK> number of atoms is set to 1000
AK> molecule 0: 1000 frames
AK> setting user values for molecule 0
AK> can't read "usr": no such variable
AK> ____________________________________
AK>
AK> Then I modified a segment of script in this way
AK>
AK> if { $name == "Na" } {
AK> set usr 0
AK> } else {
AK> set usr 1
AK> }
AK>
AK> This time script run but still it is not changing the color.
AK>
AK>
AK> Thanks
AK> Anil
AK>
AK>
AK>
AK>
AK>
AK>
AK>
AK> Eduard Schreiner said:
AK> > Hi Anil,
AK> >
AK> > a script like the one below would do the job.
AK> > Before I explain it, let me point some things:
AK> >
AK> > 1. This is a quick solution and there might be better ways to do that
AK> > 2. The script needs an additional file containing all the names for every
AK> > atom
AK> > in every step, let's call it "allcrystalline.name" (actually I took the
AK> > first column of the trajectory you sent and removed all "Atom" and "1000")
AK> > 3. The script is not safe in the sense that it does not check, whether
AK> > this additional name file is synchronous to the trajectory.
AK> > 4. Might be there are some other drawbacks, but it works (at least for me)
AK> >
AK> >
AK> > #=======================
AK> > set molid 0
AK> > set nr_atoms 1000
AK> > #here I manually set these numbers
AK> > puts "number of atoms is set to $nr_atoms"
AK> >
AK> > set nr_fr [molinfo $molid get numframes]
AK> > puts "molecule $molid: $nr_fr frames"
AK> >
AK> > set fp [open "allcrystalline.name" r]
AK> > #this is the additional file I told about
AK> > puts "setting user values for molecule $molid"
AK> >
AK> > for {set j 0} {$j < $nr_fr} {incr j} {
AK> > #going through the trajectory
AK> > for {set i 0} {$i < $nr_atoms} {incr i} {
AK> > set name [gets $fp]
AK> > #here an entry from "allcrystalline.name" is read
AK> > if { $name == "Na" } { set usr 0 } else {
AK> > if { $name == "Ar" } { set usr 1 }
AK> > }
AK> > #and the variable usr is set depending on the name
AK> > set sel [atomselect $molid "index $i" frame $j]
AK> > #select the i'th atom in the current frame
AK> > $sel set user $usr
AK> > #set the user value for this atom
AK> > $sel delete; unset sel
AK> > }
AK> > }
AK> >
AK> > unset j
AK> > unset nr_fr
AK> > unset fp
AK> > unset i
AK> > unset name
AK> > unset nr_atoms
AK> >
AK> > #====================
AK> >
AK> > After you applied the above script, you can select the coloring according
AK> > to
AK> > the user value, or select the corresponding atoms directly .....
AK> >
AK> >
AK> >
AK> > Eddi
AK> >
AK> >
AK> >
AK> >
AK> > On Tuesday 11 December 2007 11:20, Anil Kumar wrote:
AK> >> Dear Eddi and all,
AK> >>
AK> >>
AK> >> First, thank you for your reply. Yes I am using graphical interface and
AK> >> I
AK> >> checked it after activating the
AK> >> 1. Update selection every frame
AK> >> 2. Update color every frame.
AK> >>
AK> >> But unfortunately it did not work. I am attaching my trajectory file
AK> >> with
AK> >> this email and I would appreciate if any of you could solve this
AK> >> problem.
AK> >>
AK> >> Thanks
AK> >> Anil
AK> >>
AK> >> > > On Dec 11, 2007 2:06 PM, Eduard Schreiner <eduard.schreiner_at_rub.de >
AK> >>
AK> >> wrote:
AK> >> > > > Hi Anil,
AK> >> > > >
AK> >> > > > I assume you are using the graphical interface.
AK> >> > > > It sounds like the selection is not updated every frame.
AK> >> > > > Thus, activate:
AK> >> > > > "Update SelectionEvery Frame"
AK> >> > > > and
AK> >> > > > "Update Color Every Frame"
AK> >> > > > for your selections in
AK> >> > > > Graphics -> Representations -> Trajectory
AK> >> > > >
AK> >> > > >
AK> >> > > > Hope this helps.
AK> >> > > >
AK> >> > > >
AK> >> > > > Eddi
AK> >> > > >
AK> >> > > > On Tuesday 11 December 2007 05:43, Anil Kumar wrote:
AK> >> > > > > Dear all,
AK> >> > > > >
AK> >> > > > > I want to make a movie, in VMD, of a trajectory(xyz coordinate
AK> >> > > >
AK> >> > > > file)
AK> >> > > >
AK> >> > > > > which is obtained from MC simulation. Trajectory file has two
AK> >> type
AK> >> > > >
AK> >> > > > of
AK> >> > > >
AK> >> > > > > atoms (say A and B). Initial configuration has 10% of A atoms
AK> >> and
AK> >> > > >
AK> >> > > > 90% of B
AK> >> > > >
AK> >> > > > > atoms. During the simulation number of A type atoms increases
AK> >> and
AK> >> > > >
AK> >> > > > number
AK> >> > > >
AK> >> > > > > of B type atoms decreases. Final configuration has say 80% of A
AK> >> and
AK> >> > > >
AK> >> > > > 20% of
AK> >> > > >
AK> >> > > > > B atoms.
AK> >> > > > >
AK> >> > > > > 1. Now I have given two elemental name for A and B atoms (say Ar
AK> >> &
AK> >> > > >
AK> >> > > > Na).
AK> >> > > >
AK> >> > > > > When I visualize this file in VMD. Then color code it shows only
AK> >> > > >
AK> >> > > > from the
AK> >> > > >
AK> >> > > > > initial configuration(I mean 10% of particles have color A and
AK> >> 90%
AK> >> > > >
AK> >> > > > of
AK> >> > > >
AK> >> > > > > particles have color B.) But it can't visualize the way the
AK> >> number
AK> >> > > >
AK> >> > > > of A
AK> >> > > >
AK> >> > > > > particles have increased during simulation.
AK> >> > > > >
AK> >> > > > >
AK> >> > > > > 2. Also, If I take only A type of Atoms in my trajectory file,
AK> >> so
AK> >> > > >
AK> >> > > > this
AK> >> > > >
AK> >> > > > > trajectory file contains different number of Atoms in different
AK> >> > > >
AK> >> > > > frame(As
AK> >> > > >
AK> >> > > > > number of A type atoms increases during simulation). VMD can't
AK> >> > > >
AK> >> > > > visualize
AK> >> > > >
AK> >> > > > > this file.
AK> >> > > > >
AK> >> > > > > Could you please help me how to visualize above both type of
AK> >> > > >
AK> >> > > > trajectory
AK> >> > > >
AK> >> > > > > in VMD.
AK> >> > > > >
AK> >> > > > >
AK> >> > > > > Thanking you in anticipation.
AK> >> > > > >
AK> >> > > > > With Best Regards,
AK> >> > > > > Anil
AK> >> > > > >
AK> >> > > > >
AK> >> > > > >
AK> >> > > > >
AK> >> > > > >
AK> >> > > > > **************************
AK> >> > > > > Anil Kumar
AK> >> > > > > Research Scholar
AK> >> > > > > Theoretical Sciences Unit
AK> >> > > > > JNCASR, Bangalore
AK> >> > > > > India -560064
AK> >> > > > > Phone : 080-22082834
AK> >> > > > > Mob. : 09342399856
AK> >> > > > > Email:anilk_at_jncasr.ac.in
AK> >> > > > > **************************
AK> >> > > >
AK> >> > > > --
AK> >> > > >
AK> >> > > > --
AK> >> > > >
AK> >> > > >
AK> >> > > > =====================================================================
AK> >> > > >========
AK> >>
AK> >> Eduard Schreiner e-mail:
AK> >> > > > eduard.schreiner_at_theochem.rub.de
AK> >> > > > Lehrstuhl fuer Theoretische Chemie Phone: ++49
AK> >> > > > (0)234/32-22121
AK> >> > > > Ruhr-Universitaet Bochum - NC 03/52 Fax: ++49
AK> >> > > > (0)234/32-14045
AK> >> > > > D-44780 Bochum
AK> >> > > > http://www.theochem.rub.de
AK> >> > > >
AK> >> > > > =
AK> >>
AK> >> *************************
AK> >> Anil Kumar,
AK> >> Graduate Student,
AK> >> Theoretical Sciences Unit,
AK> >> JNCASR, Bangalore -560064
AK> >> India
AK> >> Phone : +91 80 2208 2834
AK> >> ***************************
AK> >
AK> > --
AK> >
AK> > --
AK> >
AK> > =============================================================================
AK> > Eduard Schreiner e-mail:
AK> > eduard.schreiner_at_theochem.rub.de
AK> > Lehrstuhl fuer Theoretische Chemie Phone: ++49 (0)234/32-22121
AK> > Ruhr-Universitaet Bochum - NC 03/52 Fax: ++49 (0)234/32-14045
AK> > D-44780 Bochum http://www.theochem.rub.de
AK> > =============================================================================
AK> >
AK>
AK>
AK> *************************
AK> Anil Kumar,
AK> Graduate Student,
AK> Theoretical Sciences Unit,
AK> JNCASR, Bangalore -560064
AK> India
AK> Phone : +91 80 2208 2834
AK> ***************************
AK>

-- 
=======================================================================
Axel Kohlmeyer   akohlmey_at_cmm.chem.upenn.edu   http://www.cmm.upenn.edu
   Center for Molecular Modeling   --   University of Pennsylvania
Department of Chemistry, 231 S.34th Street, Philadelphia, PA 19104-6323
tel: 1-215-898-1582,  fax: 1-215-573-6233,  office-tel: 1-215-898-5425
=======================================================================
If you make something idiot-proof, the universe creates a better idiot.