Skip to main content

OpenMM CPP Forces Plugin

Linux MacOS Docs License: MIT

This OpenMM plugin contains platform-agnostic forces. They are computed in C++ on the host through OpenMM's CustomCPPForceImpl, and OpenMM's own platforms (Reference, CPU, CUDA, and OpenCL) move positions and forces to and from the device. The plugin therefore has no GPU kernels, and the same build works on every platform.

Force Description
CompositeRMSDForce Deviation of multiple corotating bodies from their reference structures

Composite RMSD

The CompositeRMSDForce class computes the root-mean-square deviation (RMSD) of a set of particle groups from a reference structure, where each group can translate independently but all groups rotate together. For $m$ groups $\mathbf{g}_j$ with $n_j$ particles each and centroids $\mathbf{c}_j$, the composite RMSD is

d_{\rm crms}(\mathbf{r}) = \sqrt{
    \frac{1}{n} \min_{\substack{\mathbf{q} \in \mathbb{R}^4 \\ \|\mathbf{q}\| = 1}}
    \sum_{j=1}^{m} \sum_{i \in \mathbf{g}_j} \left\|
        \mathbf{A}(\mathbf{q})\left(\mathbf{r}_i - \mathbf{c}_j\right)
        - \mathbf{r}_i^{\rm ref} + \mathbf{c}_j^{\rm ref}
    \right\|^2
}

where $n = \sum_{j=1}^{m} n_j$, $\mathbf{r}_i^{\rm ref}$ and $\mathbf{c}_j^{\rm ref}$ are reference positions and centroids, and $\mathbf{A}(\mathbf{q})$ is the rotation matrix of the unit quaternion $\mathbf{q}$. A single rotation aligns all groups, so their relative orientations matter but their relative positions do not. The energy of the force equals $d_{\rm crms}$, which makes it a collective variable for a CustomCVForce.

Documentation

Documentation for this plugin is available at GitHub Pages, including its Python API.

Installation

The plugin requires OpenMM 8.4 or later. It is distributed on the mdtools conda channel:

mamba install -c conda-forge -c mdtools openmm-cpp-forces

and on PyPI, for Linux x86_64 and macOS (Apple Silicon and Intel) with Python 3.10–3.14:

pip install openmm-cpp-forces

Each PyPI release is published once per supported OpenMM version. pip installs the newest one, upgrading OpenMM if needed; to keep an older OpenMM, pin it in the same command, for example pip install "openmm==8.5.*" openmm-cpp-forces:

PyPI release OpenMM
X.Y.Z 8.4
X.Y.Z.post1 8.5
X.Y.Z.post2 8.6

On Intel Macs, OpenMM 8.6 from PyPI only works with Python 3.10, so pip installs the OpenMM 8.5 release there for Python 3.11 and later.

The PyPI wheels work with every OpenMM platform. To run on NVIDIA GPUs, also install the OpenMM CUDA add-on that matches your driver, openmm-cuda-12 or openmm-cuda-13.

To build from source, install OpenMM, CMake, SWIG, numpy, and a C++ compiler, then run:

mkdir build && cd build
cmake .. -DOPENMM_DIR=/path/to/openmm   # defaults to $CONDA_PREFIX
make install
make PythonInstall

Usage

The example below restrains the composite RMSD of two groups of particles with a harmonic potential:

import numpy as np
import openmm as mm
import openmmcppforces as mmcpp

# A toy system: 10 particles split into two groups
num_particles = 10
system = mm.System()
for _ in range(num_particles):
    system.addParticle(1.0)
reference = np.random.default_rng(1234).normal(size=(num_particles, 3))

rmsd = mmcpp.CompositeRMSDForce(reference)
rmsd.addGroup(list(range(5)))
rmsd.addGroup(list(range(5, 10)))

restraint = mm.CustomCVForce("0.5*k*rmsd^2")
restraint.addGlobalParameter("k", 1000.0)  # kJ/mol/nm^2
restraint.addCollectiveVariable("rmsd", rmsd)
system.addForce(restraint)
context = mm.Context(system, mm.VerletIntegrator(0.001))

# Translating each group as a whole leaves the composite RMSD at zero
shift = np.array([[1.0, 0.0, 0.0]] * 5 + [[0.0, 2.0, 0.0]] * 5)
context.setPositions(reference + shift)
print(f"{restraint.getCollectiveVariableValues(context)[0]:.4f} nm")  # 0.0000 nm

# A deformation does not
noise = np.random.default_rng(5678).normal(scale=0.1, size=(num_particles, 3))
context.setPositions(reference + noise)
print(f"{restraint.getCollectiveVariableValues(context)[0]:.4f} nm")  # 0.1326 nm

Copyright

Copyright (c) 2024, Redesign Science

Metadata

Release files for openmm-cpp-forces 0.2.0.post2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Built distributions (wheels)

Table of built distributions (wheels) for openmm-cpp-forces 0.2.0.post2
File
openmm_cpp_forces-0.2.0.post2-cp314-cp314-manylinux_2_34_x86_64.whl CPython 3.14 CPython 3.14 Linux glibc 2.34+ x86-64 Details
openmm_cpp_forces-0.2.0.post2-cp314-cp314-macosx_11_0_arm64.whl CPython 3.14 CPython 3.14 macOS 11.0+ ARM64 Details
openmm_cpp_forces-0.2.0.post2-cp313-cp313-manylinux_2_34_x86_64.whl CPython 3.13 CPython 3.13 Linux glibc 2.34+ x86-64 Details
openmm_cpp_forces-0.2.0.post2-cp313-cp313-macosx_11_0_arm64.whl CPython 3.13 CPython 3.13 macOS 11.0+ ARM64 Details
openmm_cpp_forces-0.2.0.post2-cp312-cp312-manylinux_2_34_x86_64.whl CPython 3.12 CPython 3.12 Linux glibc 2.34+ x86-64 Details
openmm_cpp_forces-0.2.0.post2-cp312-cp312-macosx_11_0_arm64.whl CPython 3.12 CPython 3.12 macOS 11.0+ ARM64 Details
openmm_cpp_forces-0.2.0.post2-cp311-cp311-manylinux_2_34_x86_64.whl CPython 3.11 CPython 3.11 Linux glibc 2.34+ x86-64 Details
openmm_cpp_forces-0.2.0.post2-cp311-cp311-macosx_11_0_arm64.whl CPython 3.11 CPython 3.11 macOS 11.0+ ARM64 Details
openmm_cpp_forces-0.2.0.post2-cp310-cp310-manylinux_2_34_x86_64.whl CPython 3.10 CPython 3.10 Linux glibc 2.34+ x86-64 Details
openmm_cpp_forces-0.2.0.post2-cp310-cp310-macosx_11_0_arm64.whl CPython 3.10 CPython 3.10 macOS 11.0+ ARM64 Details
openmm_cpp_forces-0.2.0.post2-cp310-cp310-macosx_10_13_x86_64.whl CPython 3.10 CPython 3.10 macOS 10.13+ x86-64 Details

Total release size: 2.9 MB

Release files / openmm_cpp_forces-0.2.0.post2-cp314-cp314-manylinux_2_34_x86_64.whl

Download URL openmm_cpp_forces-0.2.0.post2-cp314-cp314-manylinux_2_34_x86_64.whl
Size 477.1 kB
Tags CPython 3.14 Linux glibc 2.34+ x86-64
SHA-256 checksum
How to use checksums
f7e258cbb7b465b93cfc6281185617bac0a16934784c9fde00ecb7651b048050
BLAKE2b-256 checksum
How to use checksums
b60650e3eacd56ab6e106b3fd677a1ca8b888210e735d7cef62453246aa1867f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 15, 2026.

Transparency log

Release files / openmm_cpp_forces-0.2.0.post2-cp314-cp314-macosx_11_0_arm64.whl

Download URL openmm_cpp_forces-0.2.0.post2-cp314-cp314-macosx_11_0_arm64.whl
Size 90.0 kB
Tags CPython 3.14 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
496e52d531acb364725d00dc9ec4eb6ac2cef99598ef5e33601980d9d06ea7cb
BLAKE2b-256 checksum
How to use checksums
cbf2daadab0d1a1dfce99edf7b36e396f4f585760542cdf1bb97d43c7c6f358a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 15, 2026.

Transparency log

Release files / openmm_cpp_forces-0.2.0.post2-cp313-cp313-manylinux_2_34_x86_64.whl

Download URL openmm_cpp_forces-0.2.0.post2-cp313-cp313-manylinux_2_34_x86_64.whl
Size 478.1 kB
Tags CPython 3.13 Linux glibc 2.34+ x86-64
SHA-256 checksum
How to use checksums
d13ec102be34e1a81444b3c537061b4624708ec9b719998edf69f46fb97a3fc2
BLAKE2b-256 checksum
How to use checksums
ac23be4e9cc3ca431e578ebc78d4dc78539ff8028a4054f78b6f4a96d048f784
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 15, 2026.

Transparency log

Release files / openmm_cpp_forces-0.2.0.post2-cp313-cp313-macosx_11_0_arm64.whl

Download URL openmm_cpp_forces-0.2.0.post2-cp313-cp313-macosx_11_0_arm64.whl
Size 90.0 kB
Tags CPython 3.13 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
923b343cb5b0eb92e4af95db10c58182cb3c44f47ba773af5f4681f9c0fc70d4
BLAKE2b-256 checksum
How to use checksums
f4b64f605d8f9ac0e93bd5d601731ad2a734f28983439da0c64feb125d6b179d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 15, 2026.

Transparency log

Release files / openmm_cpp_forces-0.2.0.post2-cp312-cp312-manylinux_2_34_x86_64.whl

Download URL openmm_cpp_forces-0.2.0.post2-cp312-cp312-manylinux_2_34_x86_64.whl
Size 476.2 kB
Tags CPython 3.12 Linux glibc 2.34+ x86-64
SHA-256 checksum
How to use checksums
32d35e53d470be21abe7e370476983cbf320bdfadf1fc9072563edf9647df555
BLAKE2b-256 checksum
How to use checksums
b9df4e9f1d570aa89a99046d05b6947e82f8c0e8bbc7d0e49a8a0f225f9166c8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 15, 2026.

Transparency log

Release files / openmm_cpp_forces-0.2.0.post2-cp312-cp312-macosx_11_0_arm64.whl

Download URL openmm_cpp_forces-0.2.0.post2-cp312-cp312-macosx_11_0_arm64.whl
Size 90.2 kB
Tags CPython 3.12 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
923fd669cf9f0aef07b0a5734ae399da90256b0e3da70ec8e9f11a98fdb46e5c
BLAKE2b-256 checksum
How to use checksums
1cf184587381375d6f84350edc824a6027fbfb59ab28eff75ceb9b0834f2111e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 15, 2026.

Transparency log

Release files / openmm_cpp_forces-0.2.0.post2-cp311-cp311-manylinux_2_34_x86_64.whl

Download URL openmm_cpp_forces-0.2.0.post2-cp311-cp311-manylinux_2_34_x86_64.whl
Size 461.8 kB
Tags CPython 3.11 Linux glibc 2.34+ x86-64
SHA-256 checksum
How to use checksums
38932708f0a039ae62f56152df5bdc09b2d9e098881e084d6441acf81011a73a
BLAKE2b-256 checksum
How to use checksums
17fed929c6723bfa239022be245ff34acdf01633ec8e0a18f071c1e6463af6d1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 15, 2026.

Transparency log

Release files / openmm_cpp_forces-0.2.0.post2-cp311-cp311-macosx_11_0_arm64.whl

Download URL openmm_cpp_forces-0.2.0.post2-cp311-cp311-macosx_11_0_arm64.whl
Size 90.1 kB
Tags CPython 3.11 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
a0b9ba297bdf8965efebffd586824b67d9a935e38da6d3e4b2fe627dbc4134c5
BLAKE2b-256 checksum
How to use checksums
7e68429cfd1397cbf93cacfb61cf12aec1b3f10dfff8d03e0e5fac7289ee7f65
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 15, 2026.

Transparency log

Release files / openmm_cpp_forces-0.2.0.post2-cp310-cp310-manylinux_2_34_x86_64.whl

Download URL openmm_cpp_forces-0.2.0.post2-cp310-cp310-manylinux_2_34_x86_64.whl
Size 456.8 kB
Tags CPython 3.10 Linux glibc 2.34+ x86-64
SHA-256 checksum
How to use checksums
c8c1132bc1852eb2c6b01f5f69ac1c83f3eb87ae9cb7103bb9fa31c0cdbdcb08
BLAKE2b-256 checksum
How to use checksums
451bf936c9ae191aa6ab46ee6d317c051f833236746e0dc4d568c0270abfeb3f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 15, 2026.

Transparency log

Release files / openmm_cpp_forces-0.2.0.post2-cp310-cp310-macosx_11_0_arm64.whl

Download URL openmm_cpp_forces-0.2.0.post2-cp310-cp310-macosx_11_0_arm64.whl
Size 90.1 kB
Tags CPython 3.10 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
10019fd2d045a00168fd38bab5b08b8ad368f96d4e3eae439a67c55a905b48ab
BLAKE2b-256 checksum
How to use checksums
c2e3d73540048a5311b2d638a2c74ffcba6b076109b604950249f0b7824d2441
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 15, 2026.

Transparency log

Release files / openmm_cpp_forces-0.2.0.post2-cp310-cp310-macosx_10_13_x86_64.whl

Download URL openmm_cpp_forces-0.2.0.post2-cp310-cp310-macosx_10_13_x86_64.whl
Size 98.3 kB
Tags CPython 3.10 macOS 10.13+ x86-64
SHA-256 checksum
How to use checksums
e3c80561335f24be1e0f658f30fce05c6111ffd9e2f3732fe6d8a5ead4c9aa55
BLAKE2b-256 checksum
How to use checksums
3d80ca12e4a2330c821b129cd454056ad98a8bef3a732c48e76704ab512fcf9a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 15, 2026.

Transparency log

Security for openmm-cpp-forces 0.2.0.post2

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

All 11 files in this release have been uploaded with provenance metadata.

Select from 11 files

Attestation for openmm_cpp_forces-0.2.0.post2-cp314-cp314-manylinux_2_34_x86_64.whl

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 15, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page