openmmml.models.fennixpotential.FeNNixPotentialImpl#

class openmmml.models.fennixpotential.FeNNixPotentialImpl(name: str, modelPath: str | None)#

Implementation of FeNNix potentials for OpenMM.

The FeNNol library is used to load FeNNix models and evaluate energies and forces. This implementation can use local files for models or automatically download them from the FeNNol-PMC repository.

To use one of the pre-trained FeNNix models, specify it by name. For example:

>>> potential = MLPotential('fennix-bio1-small')

Other available models include ‘fennix-bio1-medium’, ‘fennix-bio1-small-finetune-ions’, and ‘fennix-bio1-medium-finetune-ions’.

To use a local .fnx file, specify ‘fennix’ as the model name, and supply the modelPath argument, e.g.,

>>> potential = MLPotential('fennix', modelPath='custom_fennix_model.fnx')
__init__(name: str, modelPath: str | None) None#

Initialize the FeNNixPotentialImpl.

Parameters:
  • name (str) – The name of the model. Options include the pre-trained models ‘fennix-bio1-small’, ‘fennix-bio1-medium’, ‘fennix-bio1-small-finetune-ions’, and ‘fennix-bio1-medium-finetune-ions’, or ‘fennix’ to load a local model file.

  • modelPath (str, optional) – A path to the model file to load.

Methods

__init__(name, modelPath)

Initialize the FeNNixPotentialImpl.

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.

getMLLongRange()

Returns whether ML interactions are local (False), or long-ranged (True) when periodic boundary conditions are present.

getSupportedEmbeddings()

Retrieves a list of names of supported embedding methods (for the creation of mixed ML/MM systems) specific to this potential.

Attributes

KNOWN_MODELS

addForces(topology: Topology, system: System, atoms: Iterable[int] | None, forceGroup: int, charge: int = 0, precision: str = 'single', **args) None#

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.