Skip to main content
v2026.11,858 entries · CC-BY 4.0

OpenMM: What It Is and How to Run a First Simulation

How to install OpenMM, run the official villin example, read the reporter log and trajectory, and fix platform problems.

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] or openmm[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:

  1. Import the modules: from openmm.app import *, from openmm import *, from openmm.unit import *, and from sys import stdout.
  2. Load the structure: pdb = PDBFile('input.pdb').
  3. Choose a force field: forcefield = ForceField('amber19-all.xml', 'amber19/tip3pfb.xml'). In the guide, amber19-all.xml covers proteins, DNA, RNA and lipids, and amber19/tip3pfb.xml supplies TIP3P-FB water and ions.
  4. Build the system: system = forcefield.createSystem(pdb.topology, nonbondedMethod=PME, nonbondedCutoff=1*nanometer, constraints=HBonds).
  5. Create the integrator: integrator = LangevinMiddleIntegrator(300*kelvin, 1/picosecond, 0.004*picoseconds).
  6. Create the simulation and set starting coordinates: simulation = Simulation(pdb.topology, system, integrator), then simulation.context.setPositions(pdb.positions).
  7. Relax the structure: simulation.minimizeEnergy().
  8. Add reporters: simulation.reporters.append(DCDReporter('output.dcd', 1000)) and simulation.reporters.append(StateDataReporter(stdout, 1000, step=True, potentialEnergy=True, temperature=True)).
  9. 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.testInstallation and read which platforms it lists.
  • Force a platform: set the environment variable OPENMM_DEFAULT_PLATFORM, or pass Platform.getPlatform(...) as an extra argument to Simulation.
  • Choose a device or precision: the platform properties DeviceIndex and Precision are passed with the platform.
  • GPU not used: confirm you installed a GPU-enabled build (the cuda12, cuda13 or hip extras above), not the plain package.
  • Progress or time remaining missing from the log: add totalSteps to StateDataReporter.

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

Follow CASRAI

Research-administration guidance, standards updates and independent tool reviews.

Ask CASRAI · free to try

Ask about OpenMM: What It Is and How to Run a First Simulation

Ask your first 2 questions free below. Subscribers get 150 a day for $29 a month.

An AI assistant specialized in research administration. It cites the sources behind every answer, labels web answers and says when it can't answer.

Answers draw on CASRAI's guides and dictionary plus the federal and funder documents we index: Federal Register, Grants.gov, Regulations.gov and UKRI.

Works on this site and inside Claude, Cursor and the AI tools you already use.

Everything CASRAI publishes — this page, the dictionary, the guides and the news — stays free to read, with no account and no card.

Referenced across the research world

University of Cambridge logoColumbia University logoCrossref logoUniversity of Edinburgh logoHarvard University logoUniversity of Oxford logoPrinceton University logoStanford School of Medicine logoUniversity College London logoORCID logoUniversity of Cambridge logoColumbia University logoCrossref logoUniversity of Edinburgh logoHarvard University logoUniversity of Oxford logoPrinceton University logoStanford School of Medicine logoUniversity College London logoORCID logo
  • University of Cambridge logo
  • Columbia University logo
  • Crossref logo
  • University of Edinburgh logo
  • Harvard University logo
  • University of Oxford logo
  • Princeton University logo
  • Stanford School of Medicine logo
  • University College London logo
  • ORCID logo

View CASRAI adoption →