Code

OpenMM

GPU molecular dynamics for biomolecules and other systems.

openmaterials.ai / codes / OpenMM

OpenMM: GPU molecular dynamics with a Python API and custom forces

A molecular dynamics library whose custom forces and integrators take a mathematical expression and run on CPUs and GPUs with little or no speed loss, now with PyTorch potentials.

What it is and how it works

Forces from an expression

CustomAngleForce('k*(theta-theta0)^2') is a complete new interaction. OpenMM compiles the expression for the CPU or GPU it runs on, often with little or no speed difference from a hand-written force (Eastman 2017).

CPU and GPU platforms

CUDA, OpenCL, HIP and CPU backends, ARM and PowerPC. DHFR with 23,558 atoms runs at 367 ns/day on a Titan X (Eastman 2017) and 1031 ns/day on an AMD V620 (Eastman 2023).

Machine-learned potentials

TorchForce embeds any TorchScript model. MLPotential('ani2x') builds a pure or mixed ML/MM system. NNPOps runs ANI-2x 5.7 times faster than TorchANI (Eastman 2023).

Input pipelines

A PDB file with a ForceField XML, or Amber prmtop, CHARMM, Gromacs and Desmond files. Forces and energies checked against Amber 16, Gromacs and CHARMM (Eastman 2017).

Polarizable force fields

AMOEBA with multipoles to quadrupoles and induced dipoles. DHFR runs at 20.90 ns/day on a Titan X with extrapolated polarization, 10.09 mutual (Eastman 2017).

Sampling and scale

Metadynamics natively or via PLUMED, collective variables from any energy term. A 1,067,095-atom virus runs at 32.3 to 70.9 ns/day on one to four A100s (Eastman 2023).

What people do with it

AlphaFold structure relaxation

Predicted structures relax by gradient descent in Amber99sb with OpenMM 7.3.1. This removes stereochemical violations without loss of accuracy. The CASP14 median is 0.96 Angstrom r.m.s.d.95. Jumper 2021

ColabFold on a single GPU

The AlphaFold2_mmseqs2 notebook relaxes predictions with Amber force fields, citing OpenMM 7. MMseqs2 search is 40 to 60 times faster. One GPU predicts close to 1000 structures a day. Mirdita 2022

SWISS-MODEL homology models

The ProMod3 engine removes clashes and distortions by energy minimization with the OpenMM library and the CHARMM27 force field. The repository holds 1,067,355 SWISS-MODEL models. Waterhouse 2018

How it is used

  1. Load a structure

    PDBFile with ForceField('amber99sbildn.xml', 'tip3p.xml'), or AmberPrmtopFile.

  2. Create the System

    createSystem with PME, a 1 nm cutoff and HBonds constraints (Eastman 2017).

  3. Pick the dynamics

    A Langevin integrator at 300 K (Eastman 2017), MonteCarloBarostat for pressure.

  4. Run and report

    StateDataReporter for temperature and energy, DCDReporter for the trajectory.

  5. Extend

    Custom forces and integrators, TorchForce models or MLPotential mixed systems.

What OpenMM is, how it works and what it is used for, from the papers listed as sources. Every number links to its paper.Poster pageDownload the poster (PNG, 1920 x 1080)

What OpenMM is

OpenMM is a molecular dynamics engine with a Python API and GPU kernels. Biomolecular simulation is its main use, and it also runs machine-learned potentials. It provides integrators, thermostats, barostats and custom forces. On the map it serves the quantities obtained from its trajectories.

In more detail

Architecture and forces

OpenMM is a layered library. Python classes sit on top, custom forces and integrators in the middle, and computational kernels loaded as plugins at the bottom, so one script runs on a CPU or a GPU (Eastman 2017). Standard forces include Lennard-Jones, PME and generalized Born solvent. Ten custom force classes, from CustomBondForce to CustomManyParticleForce, accept an algebraic expression, and CustomIntegrator writes an integration algorithm the same way. AMOEBA uses spherical harmonics in a quasi-internal frame with DIIS or extrapolated polarization for the induced dipoles, and Drude particles offer a second polarizable model. OpenMM 8 adds TorchForce and OpenMM-ML (Eastman 2023).

Numerics and scale

With AMBER99SB-ILDN, TIP3P and PME, DHFR (23,558 atoms) runs at 367 ns/day on a Titan X Pascal and 13.0 ns/day on four Core i7 cores at a 2 fs step, and 706 ns/day at 5 fs with hydrogen mass repartitioning (Eastman 2017). Both GPUs of one K80 run a simulation 22 to 62 percent faster than one GPU. Single and mixed precision run at similar speed while double precision drops to 18.1 ns/day on the Titan X. In OpenMM 8 the HIP backend reaches 1031 ns/day for DHFR on an AMD V620, four NVLink A100 GPUs run the 1,067,095-atom satellite tobacco mosaic virus at 70.9 ns/day, and NNPOps lifts ANI-2x on a 53-atom inhibitor from 9.8 to 56 ns/day, against 281 ns/day for OpenFF 2.0.0 (Eastman 2023).

Interfaces and related packages

Systems arrive from PDB files with XML force fields or from Amber, CHARMM, Gromacs and Desmond input files, so users keep their tools (Eastman 2017). The code is developed on GitHub under the openmm organization and available from openmm.org. OpenMM-Torch bridges to PyTorch, OpenMM-ML wraps ANI-1ccx and ANI-2x, and the SPICE dataset of omega-B97M-D3BJ/def2-TZVPPD energies and forces over 15 elements is meant to train further potentials (Eastman 2023). OpenFF and GAFF handle small molecules. On the map, run_md.py reads potential energy through getPotentialEnergy(), temperature through StateDataReporter, the pressure setpoint from MonteCarloBarostat and the trajectory through DCDReporter.

Validation

In 1 ns constant-energy runs of DHFR repeated ten times, the energy drift is 1.557 kJ/mol/ps in single precision, -0.0047 in mixed and -0.0062 in double. Mixed precision gives a very large benefit at low cost (Eastman 2017). Forces and energies for DHFR and the 2KOC RNA hairpin loaded through each input pipeline were compared with Amber 16, Gromacs 4.6.5 and CHARMM-LITE c40b1. Production pipelines use the code. AlphaFold relaxes its predictions in Amber99sb with OpenMM 7.3.1 (Jumper 2021), ColabFold relaxes in Amber force fields and cites OpenMM 7 (Mirdita 2022), and ProMod3 in SWISS-MODEL ends with an energy minimization in OpenMM with CHARMM27 (Waterhouse 2018).

What it computes on the map

4 quantities, drawn by tier with the data flow between them. Dashed boxes are intermediate quantities. Select one for its formula and the other codes that compute it.

Open the full mapShare this submap
Embed this submap
<iframe src="https://openmaterials.ai/m/c56731602651/400000000100008010?embed=1" title="OpenMM on the OpenMaterials map" width="100%" height="480" loading="lazy" style="border:1px solid #EBEBEB;border-radius:6px"></iframe>

Each quantity with the interface the representation records.

  • PressureMonteCarloBarostat(pressure*atmosphere, ...) (run_md.py:234)atm
  • TemperatureStateDataReporter(temperature=True) (run_md.py:213-220)kelvin
  • TotalEnergygetPotentialEnergy().value_in_unit(kilojoule_per_mole) (run_md.py:44)ev
  • Trajectoryapp.DCDReporter('production.dcd') (drug-protein-ligand-md/run_md.py:298-299)

References

The code

The papers that describe the code; cite them when you use it.

  1. P. Eastman, J. Swails, J. D. Chodera et al., OpenMM 7: Rapid development of high performance algorithms for molecular dynamics, PLOS Computational Biology, 2017. doi.org/10.1371/journal.pcbi.1005659
  2. P. Eastman, R. Galvelis, R. P. Peláez et al., OpenMM 8: Molecular Dynamics Simulation with Machine Learning Potentials, The Journal of Physical Chemistry B, 2023. doi.org/10.1021/acs.jpcb.3c06662

Applications

Highly cited studies that cite the code, with a few picked by hand.

  1. A. Waterhouse, M. Bertoni, S. Bienert et al., SWISS-MODEL: homology modelling of protein structures and complexes, Nucleic Acids Research, 2018. doi.org/10.1093/nar/gky427
  2. J. Jumper, R. Evans, A. Pritzel et al., Highly accurate protein structure prediction with AlphaFold, Nature, 2021. doi.org/10.1038/s41586-021-03819-2
  3. M. Mirdita, K. Schütze, Y. Moriwaki et al., ColabFold: making protein folding accessible to all, Nature Methods, 2022. doi.org/10.1038/s41592-022-01488-1

How to cite

P. Eastman, J. Swails, J. D. Chodera, et al., OpenMM 7: Rapid development of high performance algorithms for molecular dynamics, PLoS Comput. Biol. 13, e1005659 (2017)

doi.org/10.1371/journal.pcbi.1005659