Blog
How to Visualize a GROMACS Trajectory in VMD: A Step-by-Step Beginner’s Guide
- June 29, 2026
- Posted by: Stem Skills Lab
- Category: Molecular Modeling

To visualize a GROMACS trajectory in VMD, first remove periodic-boundary artifacts with gmx trjconv -pbc mol -center so the protein stops jumping across the box. Then load the structure file (.gro or .tpr) into VMD, load the corrected .xtc trajectory into the same molecule, choose a NewCartoon representation, and press play to animate. Export frames or a movie with the Movie Maker plugin.
You ran your first simulation, the log says it finished, and now you have a folder of files you cannot read. A trajectory is just numbers until you can watch the molecule move. VMD is the tool most structural biologists reach for to turn a GROMACS .xtc file into an animation you can actually see, analyze, and put in a thesis. This guide takes you from raw output to a playing cartoon view and a saved movie, and it explains the one step that trips up almost every beginner: the protein that appears to fly apart or jump across the screen.
This is a spoke in our learn molecular dynamics with GROMACS series. It assumes you already have a finished run, so if you have not produced a trajectory yet, start with our walkthrough on running your first simulation. To see where visualization fits into a research career, the full computational biology skills roadmap lays out the path.
What is VMD and why use it for GROMACS output?
VMD (Visual Molecular Dynamics) is a free molecular graphics and analysis program built by the Theoretical and Computational Biophysics Group at the University of Illinois Urbana-Champaign. It was designed from the start for trajectories rather than single structures, which is why it handles million-atom systems and long simulations more comfortably than viewers built mainly for static images. The original description is worth quoting directly: VMD is “a molecular graphics program designed for the display and analysis of molecular assemblies, in particular biopolymers such as proteins and nucleic acids” (Humphrey, Dalke and Schulten, Journal of Molecular Graphics, 1996).
That 1996 paper has been cited in more than 50,000 publications according to Google Scholar, which tells you how standard this tool is in the field. For a GROMACS user the practical draw is native file support: VMD reads GROMACS .gro, .tpr, .xtc, and .trr files through its built-in molfile plugins, so no format conversion is needed before loading. The current stable release is VMD 1.9.3, available for Windows, macOS, and Linux from the official site after a short free registration.
Which GROMACS files do you need to open?
You need two things: a structure file that defines the atoms and their bonds, and a trajectory file that holds the coordinates at each saved frame. From a standard GROMACS run you will use one file from each column below.
| Role | GROMACS file | What it gives VMD |
|---|---|---|
| Structure / topology | .tpr (preferred) or .gro | Atom names, elements, and bonds. A .tpr carries real bond information; a .gro alone makes VMD guess bonds from distance. |
| Trajectory | .xtc (compressed) or .trr (full precision) | The coordinates for every frame you wrote during the run. |
Load the structure first, then add the trajectory on top of it. If you load only the .gro, you still get a usable view; loading the .tpr gives cleaner bonds because GROMACS already knows the connectivity.
How do you fix the protein that jumps across the box?
This is the problem that confuses every beginner. When you open a raw trajectory, the protein looks like it shatters, drifts off one edge, or teleports to the other side of the box between frames. Nothing is wrong with your simulation. GROMACS uses periodic boundary conditions, so a molecule that crosses one face of the simulation box reappears on the opposite face. The coordinates are correct; they just need to be made whole and re-centered before they look right.
Fix this with gmx trjconv before you ever open VMD. The widely used command, drawn from the canonical GROMACS protein tutorial, is:
gmx trjconv -s md.tpr -f md.xtc -o md_noPBC.xtc -pbc mol -centerGROMACS will prompt you twice. For “Select group for centering” choose Protein, and for “Select group for output” choose System. The -pbc mol option keeps each molecule intact, and -center puts your protein in the middle of the box. If the molecule still appears to hop between frames, run a second pass that removes jumps:
gmx trjconv -s md.tpr -f md_noPBC.xtc -o md_final.xtc -pbc nojumpThe full option list for these flags is documented in the official gmx trjconv reference. Justin Lemkul’s GROMACS tutorials are the standard worked example of this exact recentering step, and they are the reference most labs point new students to.
You can also fix wrapping inside VMD using its bundled PBC Tools. After loading the trajectory, open the Tk Console and run pbc wrap -center com -centersel "protein" -compound res -all. Doing it in trjconv first is cleaner because the corrected file is then ready for any tool, not just VMD.
How do you load the trajectory into VMD step by step?
There are two routes. Use whichever you find easier; they produce the same result.
Using the menus
- Open VMD. Three windows appear: the main control window, the OpenGL display, and the console.
- Go to File > New Molecule. Browse to your
md.tpr(ormd.gro) and click Load. The structure appears in the display. - With that molecule highlighted in the main window, go to File > Load Data Into Molecule. Select your corrected
md_noPBC.xtcand click Load. The frame counter at the bottom of the main window climbs as the frames import.
Loading the trajectory into the existing molecule, rather than as a new molecule, is the step beginners miss. If you load the .xtc as a brand-new molecule it has no atom names or bonds and shows nothing useful.
Using the command line or Tk Console
You can skip the menus entirely. Launch both files at once from a terminal:
vmd md.tpr md_noPBC.xtcOr, from the VMD Tk Console (Extensions > Tk Console), type:
mol new md.tpr
mol addfile md_noPBC.xtc waitfor allThe waitfor all keyword tells VMD to finish loading every frame before returning control, which is handy when scripting.
Want the guided, hands-on version?
Our live Molecular Modeling & MD Simulations cohort bootcamp takes you from zero to running real docking and MD workflows, with a portfolio project for your grad-school applications.
How do you make the protein look good with representations?
By default VMD draws every atom as a line, which is hard to read. Representations control how each selection of atoms is drawn and colored. Open Graphics > Representations to set them up.
A clean starting point for a protein with a bound ligand uses three representations:
- Protein backbone as cartoon. In the Selected Atoms box type
protein, set Drawing Method to NewCartoon, and set Coloring Method to Secondary Structure. This shows helices and sheets in distinct colors. - Ligand as sticks. Click Create Rep, type a selection such as
resname LIG(replace LIG with your ligand’s residue name), and set Drawing Method to Licorice. Now the drug molecule stands out inside the pocket. - Hide the water. Water dominates the view. Either leave it out of your selections or create a representation for
waterand double-click it to switch it off.
VMD selection syntax is the same language used across the program, so protein and name CA, resid 50 to 60, and within 4 of resname LIG all work. This is one reason VMD doubles as an analysis tool, not just a viewer.
How do you play and export the animation?
The animation controls sit at the bottom of the main VMD window. Press the play arrow to run the trajectory, drag the slider to scrub to any frame, and use the speed control to slow it down. The small step field lets you skip frames if the run is long.
To save a shareable movie, use Extensions > Visualization > Movie Maker. Choose a working directory, pick the “Trajectory” movie type, name the output, and click Make Movie. Movie Maker drives an external encoder for compressed formats, so on some systems you will install a helper such as FFmpeg first; you can always fall back to rendering a numbered sequence of image frames and assembling them yourself.
For a single high-quality still for a paper or poster, set up your view, then use File > Render and pick the built-in Tachyon ray tracer to produce a clean rendered image rather than a screenshot.
VMD vs other trajectory viewers: which should a student use?
VMD is not the only option, and the right choice depends on what you are producing. The table compares the three tools students reach for most.
| Tool | Best for | GROMACS trajectory support | License | Learning curve |
|---|---|---|---|---|
| VMD | Large or long MD trajectories, built-in analysis (RMSD, RMSF, distances) | Native .xtc, .trr, .gro, .tpr | Free for academic/non-commercial use | Moderate |
| PyMOL | Publication-quality static figures of single poses | Trajectories via load_traj; conversion often easier | Open-source build free; commercial build paid | Moderate |
| UCSF ChimeraX | Modern interface, presentations, teaching | Reads MD trajectories through its open command | Free for academic use | Gentle |
For most GROMACS work the answer is simple: use VMD to inspect and analyze the trajectory, then switch to PyMOL or ChimeraX if you want a single glossy figure. Learning VMD first pays off because the same selection language and analysis plugins carry into the rest of an MD workflow, including RMSD and RMSF analysis.
Frequently asked questions
Why does my protein break apart or fly off the screen in VMD?
Because of periodic boundary conditions. The molecule crossed the edge of the simulation box and reappeared on the other side. The coordinates are correct; run gmx trjconv -pbc mol -center (and, if needed, a second pass with -pbc nojump) before loading, or use pbc wrap inside VMD.
Do I need to convert my .xtc file before opening it in VMD?
No. VMD reads .xtc, .trr, .gro, and .tpr natively through its molfile plugins. The only processing you should do first is the PBC correction with gmx trjconv, which keeps the visualization clean.
Should I load the .gro or the .tpr as my structure file?
Prefer the .tpr. It contains the real bond information from your topology, so VMD draws connectivity correctly. A .gro file alone forces VMD to guess bonds from interatomic distances, which can misdraw unusual residues or ligands.
Is VMD free for students?
Yes. VMD is distributed free of charge for academic and other non-commercial use under the University of Illinois license. You register once on the official site, then download the build for your operating system.
Can VMD do analysis, or is it only for making pictures?
It does both. Beyond visualization, VMD ships plugins for RMSD trajectory alignment, RMSF, distances, hydrogen bonds, and more under the Extensions menu, which is why it is often the only viewer a GROMACS user needs.
Want the guided, hands-on version?
Our live Molecular Modeling & MD Simulations cohort bootcamp takes you from zero to running real docking and MD workflows, with a portfolio project for your grad-school applications.
Written by the StemSkills Lab team, structural and computational scientists with more than 10 years of combined experience in sequence and structural bioinformatics, drug discovery and design, and multiscale molecular modeling.