Simulation Engine: Interface

class mlip.simulation.simulation_engine.SimulationEngine(atoms: Atoms, force_field: ForceField, config: SimulationConfig)

Abstract base class of a simulation engine that can be implemented by different backends and can, in principle, run many types of simulations (e.g., MD or energy minimizations).

Config

The config class corresponding to the engine. Needs to be overridden by the child classes.

simulation_state_class

The class that is used for the simulation state. By default, this is the SimulationState class. Usually, the derived simulation engines won’t override this. However, an advanced user of the library could use this to customize the simulation state class for their own purposes via an inheritance pattern.

__init__(atoms: Atoms, force_field: ForceField, config: SimulationConfig) None

Constructor that initializes the simulation state and an empty list of loggers. Engine-specific initialization is then delegated to ._initialize()

Parameters:
  • atoms – The atoms of the system to simulate.

  • force_field – The force field to use in the simulation.

  • config – The configuration/settings of the simulation.

Raises:

ValueError – if input system has only one atom.

abstractmethod run() None

Runs the simulation and populates the simulation state during the run. Note that this method should only be called once and its behaviour will not be defined if called a second time.

attach_logger(logger: Callable[[SimulationState], None]) None

Adds a logger to the list of loggers of the simulation engine.

The logger function must only take in a single argument, the simulation state, and it shall not return anything.

Parameters:

logger – The logger to add.

abstractmethod _initialize(atoms: Atoms, force_field: ForceField, config: SimulationConfig) None

Subclasses should implement this method to handle their specific initialization.

Parameters:
  • atoms – The atoms of the system to simulate.

  • force_field – The force field to use in the simulation.

  • config – The configuration/settings of the simulation.