xnn.common.deploy.openmm_force#

xnn potentials in OpenMM: a TorchForce for openmm-torch and an "xnn" potential for openmm-ml.

A model runs inside an OpenMM simulation as an openmm-torch TorchForce, alone or on a subset of the atoms of a classical system (ML/MM):

from openmmml import MLPotential

potential = MLPotential("xnn", model="mace-off23-small")
system = potential.createSystem(topology)                                # all atoms
mixed = potential.createMixedSystem(topology, mm_system, ligand_atoms)   # ML/MM

The "xnn" name is registered with openmm-ml through the openmmml.potentials entry point. Without openmm-ml, create_torch_force() builds the force directly. The force evaluates the TorchScript export of the model (TorchScriptPotential, the reference implementation, with its own neighbor list), converts OpenMM’s nanometers and kJ/mol to and from xnn’s Angstrom and eV, and returns the energy and the forces of every particle (zero outside the model’s atoms).

Module Attributes

KJ_PER_MOL_PER_EV

the elementary charge times Avogadro's number, over 1000).

ANGSTROM_PER_NM

Angstrom per nanometer.

Functions

create_torch_force(model, topology[, atoms, ...])

An openmm-torch TorchForce evaluating model on the atoms of an OpenMM topology.

openmm_potential(model, atomic_numbers[, ...])

The scripted OpenMMPotential of a model.

Classes

OpenMMPotential(potential, atomic_numbers[, ...])

A scriptable module with openmm-torch's calling convention.

XNNPotentialImpl(model[, total_charge, ...])

openmm-ml's implementation of the "xnn" potential: one TorchForce per system.

XNNPotentialImplFactory()

Creates XNNPotentialImpl for MLPotential("xnn", model=...) (openmm-ml).