How to visualize region‐based walls (wall/gran) in LAMMPS?

Dear LAMMPS developers,

I’m having trouble visualizing walls (e.g., wall/gran) that are defined via regions or planes in LAMMPS. I came across some example images that mention using VMD for visualization, but I’m unsure how to actually display these walls once I install VMD.

https://docs.lammps.org/fix_wall_gran_region.html
https://www.lammps.org/movies.html#granregion

  1. VMD Approach

• I’ve seen references stating the walls were created with regions in LAMMPS and then shown in VMD, but I haven’t found a step‐by‐step explanation of how to do this. Does anyone have tips or a sample workflow?

  1. VTK/ParaView Alternative

• I’m more familiar with ParaView and VTK (often used with LIGGGHTS). Is there a recommended way to visualize region‐based walls using VTK output from LAMMPS?

Any guidance, tutorials, or example scripts would be greatly appreciated. I’d love to see how other users handle this.

Thanks in advance!

First off, LAMMPS has no option to output regions in any visualizable form directly, so any visualization has to recreate the region with inside the visualization too of choice.

With VMD you have two options:

  • you can recreate any regions using Tcl scripting since VMD has the “graphics” command that allows to draw graphics primitives. https://www.ks.uiuc.edu/Research/vmd/vmd-1.9.3/ug/node129.html. These graphics primitives are static and attached to a specific “VMD molecule”. To make them dynamic, you would need to delete and re-create the visualization in a function attached to the timestep progress.
  • VMD can also read triangle meshes from text mode STL files. LAMMPS has source code for a simple tool, stlbin2txt.cpp, in the tools folder to convert binary STL files to text.

Using Tcl scripting in VMD is very flexible and but requires some practice and familiarity with both VMD and Tcl. Some 20 years ago, I wrote a tutorial that included a section about adding graphics to trajectory using VMD including dynamic changes. Remarkably, it is still available online at: Visualization and Analysis of Quantum Chemical and Molecular Dynamics Data with VMD

1 Like

Awesome!

Appreciate…

@ponpoko Inspired by your question, I have started writing a region2vmd command that can help with the process. At least it can assist in debugging where regions are placed.

You can see a draft pull request with the code on GitHub. There are still many limitations, though, and this is more of a proof-of-concept implementation.

The following example input:

region box block -20 20 -20 20 -20 20
create_box 5 box
region c1 cone x 10 0 0 10 0 20
create_atoms 1 single 0.0 10.0 0.0
create_atoms 2 single 19.9 10.0 0.0

region c2 cylinder y 0 0 5 0 20
create_atoms 3 single 0.0 0.0 0.0
create_atoms 4 single 0.0 19.9 0.0

region sph sphere -10 -10 -10 15
create_atoms 5 single -10 -10 -10

mass * 1.0

write_dump all atom regions.lammpstrj
region2vmd regions.vmd command "mol default style VDW" &
    command "set oldtop [mol new regions.lammpstrj waitfor all]" &
    command "pbc box -center origin -style tubes" &
    region c1 region c2 color red region sph &
    color yellow material Glass1 region box

should produce two files (with the code from pull request), regions.lammpstrj and regions.vmd. Those files can be loaded into VMD with vmd -e regions.vmd and then adjusted into a visualization like the following (the atoms are placed at critical points of the regions).

Any feedback and particularly suggestions for improvements are welcome.

5 Likes

Wow, thank you so much for your help! I really appreciate how kind you are to guide a novice like me in using VMD. I’ll try applying your suggestion to my script and will share an update if I succeed. Thanks again! :pray: