Written and maintained by CASRAI Editorial Board
Last updated
OpenMM is a free, open-source Python toolkit for molecular simulation. You write a short Python script that loads a structure, picks a force field, and runs molecular dynamics on whichever hardware platform is available. This guide shows how to install it, run a first simulation from the official getting-started example, and read what comes out. Facts were checked against the OpenMM user guide and the project repository on 2026-11-08.
What OpenMM is used for in research
OpenMM is a library, not a point-and-click application. According to its documentation it is script-based: you describe the system, the integrator and the output in Python, and the same script runs on the CPU or a GPU. The user guide also describes a Script Builder (section 3.6 of the application guide) that generates a starting script for you. Researchers typically use it for molecular dynamics of proteins, nucleic acids and lipids in explicit solvent, and for custom simulation protocols that are easier to express in code than in a fixed input file.
The project is open source. The repository states that most of the code is MIT or LGPL licensed, with portions copyright 2008-2025 Stanford University and the Authors; the licence texts are in the repository under docs-source/licenses/Licenses.txt. Check that file for the licence of any component you redistribute.
If you work with protein structures more broadly, see the CASRAI guides on ProDy for protein dynamics analysis, PyMOL for molecular graphics, and ColabFold for structure prediction, which fit before and after a simulation run.
Install or access (official source only)
The OpenMM documentation lists these installation routes. Use one environment manager consistently rather than mixing them.
- conda:
conda install -c conda-forge openmm - conda with CUDA:
conda install -c conda-forge openmm cuda-version=12 - pip:
pip install openmm - pip with a GPU backend:
pip install openmm[cuda12],openmm[cuda13],openmm[hip6]oropenmm[hip7]
Verify the installation with python -m openmm.testInstallation. The test reports which platforms OpenMM can use on your machine.
Step-by-step: run a first simulation
The getting-started guide (Example 3-1, simulatePdb.py) simulates the villin headpiece in explicit solvent from a PDB file. Save your input structure as input.pdb and run:
- Import the modules:
from openmm.app import *,from openmm import *,from openmm.unit import *, andfrom sys import stdout. - Load the structure:
pdb = PDBFile('input.pdb'). - Choose a force field:
forcefield = ForceField('amber19-all.xml', 'amber19/tip3pfb.xml'). In the guide,amber19-all.xmlcovers proteins, DNA, RNA and lipids, andamber19/tip3pfb.xmlsupplies TIP3P-FB water and ions. - Build the system:
system = forcefield.createSystem(pdb.topology, nonbondedMethod=PME, nonbondedCutoff=1*nanometer, constraints=HBonds). - Create the integrator:
integrator = LangevinMiddleIntegrator(300*kelvin, 1/picosecond, 0.004*picoseconds). - Create the simulation and set starting coordinates:
simulation = Simulation(pdb.topology, system, integrator), thensimulation.context.setPositions(pdb.positions). - Relax the structure:
simulation.minimizeEnergy(). - Add reporters:
simulation.reporters.append(DCDReporter('output.dcd', 1000))andsimulation.reporters.append(StateDataReporter(stdout, 1000, step=True, potentialEnergy=True, temperature=True)). - Run:
simulation.step(10000).
With a 0.004 ps (4 fs) step, 10,000 steps cover 40 ps of simulated time, and a reporting interval of 1000 steps writes ten frames and ten log lines. That is a smoke test, not a production run.
Output and how to read it
The StateDataReporter log
The reporter prints comma-separated values by default (a separator parameter changes this). The options documented in the guide are step, time, progress, remainingTime, potentialEnergy, kineticEnergy, totalEnergy, temperature, volume, density and speed. In the example you request step, potential energy and temperature, so each line gives the step number, potential energy and instantaneous temperature. Read it for stability: a temperature that hovers near the 300 K target and an energy that settles rather than climbs steadily are what you expect after minimisation. The progress and remainingTime options only work if you pass totalSteps.
The trajectory file
output.dcd holds the coordinates saved every 1000 steps. OpenMM can write PDB, PDBx/mmCIF, DCD and XTC trajectories; the example uses DCDReporter(filename, interval). A DCD file contains coordinates only, so keep the matching topology (the input PDB) beside it. Load both in a viewer such as PyMOL, or analyse them with a Python package such as ProDy.
Record what you ran
For reproducibility, store with each trajectory the OpenMM version, the force-field files, the integrator settings, the platform and precision, and the script itself. These are the inputs that determine the result, and they are all visible in the script above.
Platform selection and troubleshooting
OpenMM runs on the Reference, CPU, CUDA, OpenCL and HIP platforms. By default it uses the fastest available one. CUDA is for NVIDIA GPUs (CUDA 12 or later in the guide) and HIP is for AMD GPUs and needs HIP/ROCm.
- Check what was found: run
python -m openmm.testInstallationand read which platforms it lists. - Force a platform: set the environment variable
OPENMM_DEFAULT_PLATFORM, or passPlatform.getPlatform(...)as an extra argument toSimulation. - Choose a device or precision: the platform properties
DeviceIndexandPrecisionare passed with the platform. - GPU not used: confirm you installed a GPU-enabled build (the
cuda12,cuda13orhipextras above), not the plain package. - Progress or time remaining missing from the log: add
totalStepstoStateDataReporter.
Free alternatives
Other molecular dynamics packages cover similar ground with different workflows. Names only; consult each project’s documentation for features and licences.
| Package | Notes |
|---|---|
| GROMACS | Separate molecular dynamics package |
| NAMD | Separate molecular dynamics package |
| AMBER | Force-field family also used in OpenMM (amber19 files above) |
| LAMMPS | See the CASRAI guide to LAMMPS molecular dynamics: install, run, read output |
FAQ
What is OpenMM?
A Python library and toolkit for molecular simulation, driven by scripts and able to run on CPUs and GPUs.
How do I install OpenMM?
Use conda install -c conda-forge openmm or pip install openmm, then verify with python -m openmm.testInstallation.
Does OpenMM need a GPU?
No. It has Reference and CPU platforms. CUDA, OpenCL and HIP platforms use GPUs, and the default is the fastest platform available.
Which trajectory formats can OpenMM write?
PDB, PDBx/mmCIF, DCD and XTC.
Sources
- OpenMM User Guide, Getting Started and Running Simulations, read 2026-11-08.
- OpenMM project repository, github.com/openmm/openmm, read 2026-11-08.







