From: Axel Kohlmeyer (
Date: Mon Nov 15 2010 - 22:06:45 CST

2010/11/15 JhonY. I. <>:
> I'd like to know details on how color assignment to atoms according to
> atomic stress can be done.
> I've found a following anwer in VMD mail list.
> Yes, you can do this. Probably the easiest way to accomplish this
> would be:
>   1) load the trajectory XYZ into VMD
>   2) Load the resultant force values into the per-atom-per-timestep
>      "user" field
>   3) Color by "user"
>   4) use the VMD movie maker plugin to make your movie
> and maybe even
>   5) Extra credit for using the "draw multiple frames" feature
>      in the trajectory tab to make a single still image that captures
>      the interesting parts of your force/dynamics all at once.
> Step 2) is the only part that's at all tricky, and a cheap sleazy
> way of accomplishing it with very little script writing is to load your
> XYZ file of resultant force vectors into a sepa! rate molecule, and
> use the "$sel2 get { x y z }" commands to read them out, compute their
> magnitude, and then store them into the original molecule's "user"
> fields with something like "$sel 1 set user $magval". I'm omitting
> the details of the loops over all of the frames, but the main thing
> is getting the data into the user field of the first molecule where
> you've got the MD trajectory loaded. I have a couple of scripts
> that populate the "user" field with such values, if you need
> one as a starting point to try out.
> 1. Here, I think that "$sel2 get { x y z }, $sel 1 set user $magval" might
> be mistyped since there is no description for $sel2 in "$sel 1 set user
> $magval".
> Are these commands correct? Would you explain the meaning of the second
> command, please?

yes, they are correct. to understand the details, you need some
familiarity with tcl syntax and vmd scripting, since a lot is omitted
in the mail that you are quoting.

> 2. I succeeded in demonstrating the motion of system using dcd and psf files
> in VMD.
> I've made a file for atomic stress i! n which three columns are given and
> the second column describe! s atomic stress for a atom corresponding to line
> number.
> Would you let me know what I should do for it in detail to assign color
> assignment to atoms for all of the frames, please?
> If there is a document or a script for it, would you send it to me, please?

the main document is the vmd user's guide, specifically the part about
the tcl script interface. also you should consult a tcl language reference
and have the tcl syntax down.
some additional advanced examples are in this pdf.

> 3. Incidentally asking, when we open a dialogue to load a new file, the
> starting directory is VMD directory.
> Can we change this default directory to another directory such as a
> directory from which we've loaded the a most recently?

not to that. i think this behavior is only true
on windows anyways or wherever you launch
it through a GUI. on linux and from the command
line, the default is the current working directory.
 but you might be able to change the working
directory in your .vmdrc/vmd.rc file.


> Best regards,
>   Luke

Dr. Axel Kohlmeyer
Institute for Computational Molecular Science
Temple University, Philadelphia PA, USA.