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.
- __init__(name)#
Methods
__init__(name)addForces(topology, system, atoms, forceGroup)Add Force objects to a System to implement the potential function.
createMixedSystem(topology, system, atoms, ...)Creates a mixed system using a potential-specific embedding method.
Returns whether ML interactions are local (False), or long-ranged (True) when periodic boundary conditions are present.
Retrieves a list of names of supported embedding methods (for the creation of mixed ML/MM systems) specific to this potential.
- addForces(topology: Topology, system: System, atoms: Iterable[int] | None, forceGroup: int, 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.
- getMLLongRange() bool | None#
Returns whether ML interactions are local (False), or long-ranged (True) when periodic boundary conditions are present. This controls which interactions are included by some ML/MM embedding methods. Consult the documentation for each embedding method for more details. None can be returned if the nature of the interactions is not known by the MLPotentialImpl.
The default implementation of this method, used if a subclass does not override it, always returns None.
- createMixedSystem(topology: Topology, system: System, atoms: list[int], forceGroup: int, interpolate: bool, embedding: str, **args) System#
Creates a mixed system using a potential-specific embedding method.
This is invoked by MLPotential.createMixedSystem(). It will only be called with one of the names returned by getSupportedEmbeddings(). If subclasses support any potential-specific embedding methods, they must also provide implementations of those methods by overriding this method. If not, it does not need to be implemented.
Each embedding method is responsible for implementing interpolation; if interpolate is True, a global parameter “lambda_interpolate” should be present in the returned system, with the behavior as described by MLPotential.createMixedSystem().
- Parameters:
topology (Topology) – the Topology for which to create a System
system (System) – a System that models the Topology with a conventional force field
atoms (Iterable[int]) – the indices of all atoms whose interactions should be computed with this potential
forceGroup (int) – the force group the ML potential’s Forces should be placed in
interpolate (bool) – if True, create a System that can smoothly interpolate between the conventional and ML potentials
embedding (str) – the name of the embedding method (will always be one in the list returned by the getSupportedEmbeddings() method)
args – any additional arguments for the potential or embedding method
- Returns:
a newly created System object that uses this potential function and the
requested embedding method to model the Topology
- getSupportedEmbeddings() list[str]#
Retrieves a list of names of supported embedding methods (for the creation of mixed ML/MM systems) specific to this potential. If one of these names is provided instead of providing the name of a generic embedding plugin, embedding will be performed by the potential itself.
This is invoked by MLPotential.createMixedSystem(). If a subclass wishes to define one or more potential-specific embedding methods, it should implement this method; otherwise, it does not need to.