openmmml.models.anipotential.ANIPotentialImpl#

class openmmml.models.anipotential.ANIPotentialImpl(name)#

This is the MLPotentialImpl implementing the ANI potential.

The potential is implemented using TorchANI to build a PyTorch model. A TorchForce is used to add it to the OpenMM System. The ANI1ccx and ANI2x versions are currently supported.

Both ANI1ccx and ANI2x are ensembles of eight models. Averaging over all eight models leads to slightly more accurate results than any one individually. You can optionally use only a single model by specifying the modelIndex argument to select which one to use. This leads to a large improvement in speed, at the cost of a small decrease in accuracy.

TorchForce requires the model to be saved to disk in a separate file. By default it writes a file called ‘animodel.pt’ in the current working directory. You can use the filename argument to specify a different name. For example,

>>> system = potential.createSystem(topology, filename='mymodel.pt')
__init__(name)#

Methods

__init__(name)

addForces(topology, system, atoms, forceGroup)

Add Force objects to a System to implement the potential function.

addForces(topology: Topology, system: System, atoms: Iterable[int] | None, forceGroup: int, filename: str = 'animodel.pt', implementation: str = 'nnpops', modelIndex: int | None = None, **args)#

Add Force objects to a System to implement the potential function.

This is invoked by MLPotential.createSystem(). Subclasses must implement it to create the requested potential function.

Parameters:
  • topology (Topology) – the Topology from which the System is being created

  • system (System) – the System that is being created

  • atoms (Optional[Iterable[int]]) – the indices of atoms the potential should be applied to, or None if it should be applied to the entire System

  • forceGroup (int) – the force group that any newly added Forces should be in

  • args – any additional keyword arguments that were provided to createSystem() are passed to this method. This allows subclasses to customize their behavior based on extra arguments.