From: Axel Kohlmeyer (
Date: Thu Sep 29 2011 - 10:08:37 CDT

On Thu, Sep 29, 2011 at 10:49 AM, <> wrote:
> Hi Axel,

hi john,

> I've been trying to map the velocity fields into VMD's "user" fields, so I can animate the trajectory using rendering based on my custom data (added in postprocessing to velocity fields in the LAMMPS trajectory). I've never used TCL before, and I ended up with this - which I run after loading the trajectory:

here is a modified version that should work.

set framecount [molinfo top get numframes]
set sel [atomselect top all]

for {set frame_no 0} {$frame_no<$framecount} {incr frame_no} {
        $sel frame $frame_no
        $sel set {user user2 user3} [$sel get {vx vy vz}]
$sel delete

> ... and I think I'm nearly there, but it's still not working: the same values seem to appear in the user fields for each frame in the trajectory. I'm guessing that it simply copies over all the previous data with whatever was in the last trajectory frame processed, as so I end up with all frames having the same data as present in the last frame. Doubtless I've done something stupid here, and I was wondering if you could help?

> I also took a look at the webpage you sent, regarding the "molfile" plugin, which mentions the "LAMMPSREMAPFIELDS" environment variable. This variable would seem to do the job, but I'm not sure how to use it; would I have to write a TCL script which sets this variable, and then load the trajectory via the TCL script for these mappings to take effect? That seems like it would be a simple 3-line script using the "topo" command namespace, but I've not been able to get it to work.

LAMMPSREMAPFIELDS is a (global) environment variable, i.e. something
that you'd set with
export or setenv from the shell prompt. you can also access those
variables from inside tcl using
the "env" array. e.g.:

global env
set env(LAMMPSREMAPFIELDS) {vz=c_1,vy=c_2,vz=c_3}

mol new mytrajectory.dump type lammpstrj waitfor all

the latter tcl command will now read a trajectory from
mytrajectory.dump in lammps
custom format into a new "molecule" of VMD and in the process read the data from
the computes 1, 2, and 3 as velocity components.

to move them into a user field, you still need the Tcl loop outlined above.

> Also, does the remapping in the "molfile" plugin use TCL to perform this mapping? The little script I wrote above seems very

no. the remapping in the plugin is done _before_ the molfile API is invoked.
that is why you _have_ to map any per timestep data to any of the velocity
components as this is currently the only per timestep data (next to coordinates,
of course) that can be passed through the molfile API.

> slow, which is to be expected I suppose as it uses TCL to interface with the VMD data. Is there a "native code" interface alternative, which I assume could be a lot faster?

there is no "native code" way to do this shuffling around.
hopefully my suggested change makes the copying a bit faster.


> Cheers,
> John.
> ---- Original message ----
>>Date: Wed, 28 Sep 2011 20:27:16 -0400
>>From: (on behalf of Axel Kohlmeyer <>)
>>Subject: Re: vmd-l: VMD with LAMMPS trjaectory - help?
>>hi john,
>>On Wed, Sep 28, 2011 at 7:20 PM,  <> wrote:
>>> Hi all,
>>> I'm visualising LAMMPS trajectories using VMD 1.9.
>>> The data I wish to visualise is a little odd, in the sense that it changes in an slightly unorthodox way; the number of atoms, and the "type" of the atoms, can change during the simulation.
>>> I discovered that VMD has problems with trajectories where the number of atoms can differ between frames, and I got around this by estimating an upper bound of the number of atoms which would be present. I then postprocess to effectively add a "buffer region" at the end of each frame to allow for expansion and contraction of the system. This seems to work okay, but my current problem occurs when the number of atoms is fixed throughout the simulation:
>>> I have not been able to discover a way to make VMD recognise certain changes over the course of the trajectory. I tell LAMMPS to write out the atom serial, molecule id, atom type and coordinates for each frame with the data sorted on the atom serial. I've tried reflecting the changes in the system by changing both the molecule id and the atom type for visualisation (ie I postprocess the "real" trajectory, and write an altered version for visualisation purposes), and VMD seems to simply use whatever information was present in the first frame of whatever trajectory it loaded.
>>yes. that is by design. this massively reduces the amount of memory that
>>VMD consumes for the - by far more common - case of this information
>>not changing over the course of a trajectory.
>>> I've verified this behaviour by writing single and multiple trajectory frames (before and after the changes occur), and when I deal with individual frames the data appears as I intended; where multiple frames are present, VMD does not reflect any changes in the system via altering the molecule id and/or atom type over the course of the trajectory.
>>> Is there a way to make VMD reflect such changes during a trajectory, and not simply use the data present in the initial trajectory frame? If this is not possible with a LAMMPS-style trajectory, is there a VMD-compatible trajectory format which does support such "dynamic" changes?
>>there are two options.
>>VMD currently only supports additional per frame information in the
>>x-,y-, and z-velocity component and the LAMMPS plugins supports this.
>>via remapping you can direct any property into one of those three
>>fields. see:
>>you can then make selections based on the vx,vy, or vz value
>>or use them for colorization or first copy them into one of the
>>user fields.
>>this still requires all frames to be of the same size.
>>the second option is to read a variable size .xyz trajectory through
>>the topotools plugin.
>>this does the "buffering" automatically, and you can reflect whatever
>>change you want
>>in the atom name. the drawback of this approach is that it - for
>>efficiency reasons -
>>does not preserve the order of atoms and thus does not work for
>>systems with bonds
>>(you can still try using VDW in combination with DynamicBonds). see:
>>    axel.
>>> Thanks,
>>> John.
>>Dr. Axel Kohlmeyer
>>Institute for Computational Molecular Science
>>Temple University, Philadelphia PA, USA.

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