Visual representation

Generate good looking image/movie with VMD

Responsive image

The objective of this page is to list a few tips that help improve the representation of atomic systems using VMD. The version of VMD I used is 1.9.4a51.

If you are new to LAMMPS, this website is for you, see for example this tutorial for beginners.

Click here if you are looking for help with your project, if you want to support me (for free or not), or if you have any suggestions for these tutorials.

Practical example

If you want to try it yourself with the same system, you can download this LAMMPS trajectory file. The trajectory file corresponds to a mixture of water and toluene, and can be opened with VMD by typing in a terminal:

vmd dump.lammpstrj

The representation

You can change the representation of the atoms by going in Graphics → Representations, and then choose another Drawing Method. My 2 favourite representations are dynamic bonds for large molecules or graphene, and VDW for single atoms or small molecules like water. QuickSurf can also make nice results, like this video. You can apply a representation only to a group of atoms, by choosing a selection in the windows Selected Atoms. To obtain the same result as me, replace All by type 1 in the windows to select the oxygen of the water molecules. Then, tune the radius to 0.8, and increase the resolution (>32 at least). Then, click on Create Rep to create a second representation for the hydrogen of water (type 2), and change the radius to 0.4. Create a third representation for all 3 atom types of toluene by entering type 3 4 5 (hydrogen, oxygen, and carbon atoms). Choose DynamicBonds and increase the resolution. You can see that 'DynamicBonds' is not really good looking by itself, the ends of the bonds are rough. To smooth the representation, create the fourth and last representation (VDW, radius 0.2) for types 3, 4, and 5.

Responsive image

The colours

To change the colours, go to Graphics → Colors. Click on Display, then Background, and choose white instead of black. Then click on Name, and 5 (this is the oxygen atoms), and choose red. Do the same for 4 (carbon → pink), 3 (hydrogen → white), 2 (hydrogen → white). These three colours are standard for oxygen, carbon, and hydrogen. To mark the difference between the water and the toluene, I choose a different colour for atoms of type 1, and entered manually the values 0 0.6, 0.88 in the RGB boxes.

Responsive image


The materials

An often neglected aspect is the texture of the representation, given by the material. Finding the right degree of shininess is often difficult, but its really important if you want a good looking poster or presentation. In the Representations windows, you can choose among several materials. I prefer to create my own. To do so, go in Graphics → Materials. Click on Opaque (this is the one used by default), then hit Create New twice. Two new materials should have appeared, called something like Material23 and Material24. Rename them to MWater and MToluene. For MWater, change Diffuse, Specular, and Shininess, to 0.43, 0.48, and 0.35, respectively. Then, from the Representations windows, change the Material from Opaque to MWater for the two representations that concern water molecules. Do the same for toluene, with values of 0.78, 0.33, and 0.32 for MToluene.

Responsive image

The view

Currently the view is perspective, which is not the best choice if you want a square image of your system. Go in Display, and click Orthographic. You can zoom with the mouse wheel. That is it, the system is ready to be rendered in high resolution.

Responsive image

You can also visualize the borders of your box by typing in the VMD' terminal:

pbc box -center origin -color black -width 2



To generate high resolution image, go in File → Render. Choose Tachyon, add -res 1000 1000 in the Render command cell, and hit Start Rendering. A high resolution image has been created by VMD. You can remove the borders using GIMP or Inkscape for example.


To generate a high resolution movie, go in Extension → Vizualisation, and Movie Maker. If you hit Make Movie directly, the movie generated by VMD will be of poor quality. Instead, we are going to generate a sequence of high resolution images, and assemble these images ourselves. Go in Movie Settings, first hit Trajectory (so the movie will show the system evolving in time, and not rotating on itself), then also uncheck Delete image files. In Rendered, choose Tachyon, then Make Movie. When its done, you can close VMD. If you don't want do redo these steps every time, you can save the VMD state by clicking File → Save vizualisation state. From the terminal, assemble the image into a movie by typing:

ffmpeg -r 60 -i untitled.%05d.ppm -vcodec libx264 -crf 0  -pix_fmt yuv420p myvideo.mp4

You may receive the following error width not divisible by 2 (1363x1134). If that's the case, you can remove one line of pixel with the command:

for file in untitled.*.ppm; do convert $file -crop 1362x1134+0+0 output-$file; done

To convert the video in webp, for web integration, use:

ffmpeg -i myvideo.mp4 -vcodec libwebp -filter:v fps=fps=20 -lossless 1 -loop 0 -preset default -an -vsync 0 -s 1000:1000 CO2.webp

The result should look like this video.

Click here if you are looking for help with your project, if you want to support me (for free or not), or if you have any suggestions for these tutorials.