{"id":8375,"library":"openmm","title":"OpenMM Python Wrapper","description":"OpenMM is a high-performance toolkit for molecular simulation, implemented primarily in C++ with a robust Python wrapper. It enables users to perform complex molecular dynamics simulations with a focus on flexibility and performance, especially on GPUs. Currently at version 8.5.1, OpenMM maintains an active development cycle, regularly releasing updates that include performance enhancements and new features, such as expanded support for machine learning potentials in recent 8.x versions.","status":"active","version":"8.5.1","language":"en","source_language":"en","source_url":"https://github.com/openmm/openmm","tags":["molecular dynamics","simulation","chemistry","physics","GPU","biophysics"],"install":[{"cmd":"pip install openmm","lang":"bash","label":"PyPI"},{"cmd":"conda install -c conda-forge openmm","lang":"bash","label":"Conda"}],"dependencies":[{"reason":"Commonly used for numerical operations and data handling in conjunction with OpenMM.","package":"numpy","optional":false}],"imports":[{"symbol":"openmm","correct":"import openmm"},{"note":"The 'simtk' prefix was deprecated and removed in OpenMM 8.x. Direct import from 'openmm.app' is the correct modern approach.","wrong":"import simtk.openmm.app as app","symbol":"openmm.app","correct":"from openmm.app import *"},{"note":"The 'simtk' prefix was deprecated and removed in OpenMM 8.x. Direct import from 'openmm.unit' is the correct modern approach.","wrong":"import simtk.unit as unit","symbol":"openmm.unit","correct":"from openmm.unit import *"}],"quickstart":{"code":"import openmm.app as app\nimport openmm as mm\nimport openmm.unit as unit\n\n# This example assumes a 'protein.pdb' file exists in the same directory.\n# A minimal PDB can be generated or downloaded, e.g., from RCSB PDB (e.g., 1AKI).\n# For a real simulation, ensure your PDB is properly prepared (e.g., with PDBFixer).\ntry:\n    pdb = app.PDBFile('protein.pdb')\nexcept FileNotFoundError:\n    print(\"Error: 'protein.pdb' not found. Please provide a PDB file for the quickstart.\")\n    exit()\n\n# Create a force field for the system\nforcefield = app.ForceField('amber14-all.xml', 'amber14/tip3pfb.xml')\n\n# Create a system from the PDB topology and force field\nsystem = forcefield.createSystem(pdb.topology,\n                                nonbondedMethod=app.PME,\n                                nonbondedCutoff=1.0*unit.nanometers,\n                                constraints=app.HBonds)\n\n# Create an integrator for advancing the simulation\nintegrator = mm.LangevinMiddleIntegrator(300*unit.kelvin, 1/unit.picosecond, 0.004*unit.picoseconds)\n\n# Create a simulation object\nsimulation = app.Simulation(pdb.topology, system, integrator)\nsimulation.context.setPositions(pdb.positions)\n\n# Minimize energy to relieve bad contacts\nprint('Minimizing energy...')\nsimulation.minimizeEnergy()\nprint(f'Potential energy after minimization: {simulation.context.getState(getEnergy=True).getPotentialEnergy()}')\n\n# Add reporters for output\nsimulation.reporters.append(app.PDBReporter('output.pdb', 1000))\nsimulation.reporters.append(app.StateDataReporter('data.csv', 1000, step=True, potentialEnergy=True, temperature=True, separator=','))\n\n# Run the simulation\nprint('Running simulation...')\nsimulation.step(10000) # Run 10,000 steps\nprint('Simulation complete. Output saved to output.pdb and data.csv')","lang":"python","description":"This quickstart demonstrates a basic molecular dynamics simulation using OpenMM. It loads a PDB file, applies a force field to create a system, sets up a Langevin integrator, performs energy minimization, and then runs a short simulation, saving trajectory and state data. A `protein.pdb` file is required in the execution directory for this example to run."},"warnings":[{"fix":"Change `import simtk.openmm.app as app` to `import openmm.app as app` and similarly for other `simtk` imports.","message":"The `simtk` namespace was removed in OpenMM 8.x. All imports previously under `simtk.openmm` or `simtk.unit` should now be directly imported from `openmm` or `openmm.unit` respectively.","severity":"breaking","affected_versions":"8.0.0+"},{"fix":"Always use quantities from `openmm.unit` (e.g., `300*unit.kelvin`, `1.0*unit.nanometers`) when defining physical parameters.","message":"OpenMM extensively uses a `unit` system. Omitting unit specifications (e.g., `300` instead of `300*unit.kelvin`) for physical quantities will lead to `OpenMMException` or incorrect behavior, as OpenMM expects `openmm.unit.Quantity` objects.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Ensure you have the latest NVIDIA CUDA drivers (for CUDA platform) or OpenCL drivers (for OpenCL platform) installed and correctly configured for your operating system and hardware.","message":"For GPU acceleration (CUDA or OpenCL platforms), appropriate drivers must be installed on your system. Without them, OpenMM will fall back to the slower CPU platform or fail to initialize the specified GPU platform.","severity":"gotcha","affected_versions":"All versions"},{"fix":"For optimal performance, evaluate if a custom force can be implemented using OpenMM's built-in `CustomForce` classes before resorting to `PythonForce`.","message":"OpenMM 8.x introduced `PythonForce` to support machine learning potentials, which has higher overhead than traditional custom forces. If a force can be implemented with existing custom forces, that is generally more performant.","severity":"breaking","affected_versions":"8.0.0+"}],"env_vars":null,"last_verified":"2026-04-16T00:00:00.000Z","next_check":"2026-07-15T00:00:00.000Z","problems":[{"fix":"Try creating a new, clean `conda` environment and reinstalling OpenMM: `conda create -c conda-forge --name openmm_env python=3.9 openmm` then `conda activate openmm_env`. Also ensure system PATH includes necessary OpenMM library directories if installed from standalone installers.","cause":"This error commonly occurs on Windows when OpenMM's C++ libraries or their dependencies are not correctly found by the Python environment, often due to issues with PATH or a corrupted `conda` environment.","error":"ImportError: DLL load failed while importing _openmm: The specified module could not be found."},{"fix":"Append a unit from `openmm.unit` to the numerical value, e.g., change `300` to `300*unit.kelvin` or `1.0` to `1.0*unit.nanometers`.","cause":"A numerical value (float or int) was provided where OpenMM expected a `openmm.unit.Quantity` object with a specified unit.","error":"OpenMMException: Expected a Quantity object but got a float/int."},{"fix":"Install the latest NVIDIA GPU drivers and the CUDA Toolkit appropriate for your system. Verify installation with `python -m openmm.testInstallation`.","cause":"The OpenMM `CUDA` platform could not be initialized. This typically means NVIDIA CUDA Toolkit or compatible drivers are not installed, not correctly configured, or not visible to OpenMM.","error":"OpenMMException: Platform 'CUDA' is not available."}]}