nanover.ase.openmm.runner module
Interactive molecular dynamics runner for ASE with OpenMM.
- class nanover.ase.openmm.runner.ASEOpenMMRunner(simulation: Simulation, imd_params: ImdParams | None = None, logging_params: LoggingParams | None = None, simulation_list: List[Simulation] | None = None)
Bases:
NanoverRunner
A wrapper class for running an interactive OpenMM simulation with ASE.
:param simulations OpenMM simulations to run interactively. :param params IMD parameters to tune the server. :param logging_params Parameters for logging the trajectory of the simulation.
- property app_server
Get the underlying app of the runner.
- close()
Closes the connection and stops the dynamics.
- property discovery_port
- property dynamics
Gets the ASE
MolecularDynamics
object that is running the dynamics.- Returns:
The ASE molecular dynamics object.
- property dynamics_interval
Minimum interval, in seconds, between frames sent to the frame publisher.
- property frame_interval
Gets the interval at which frames are sent, in steps.
- Returns:
The frame interval, in steps.
- classmethod from_xml(simulation_xml: str, params: ImdParams | None = None, logging_params: LoggingParams | None = None)
Initialises a
AseOpenMMIMDRunner
from a simulation XML file serialised withserializer.serialize_simulation()
.- Parameters:
simulation_xml – Path to XML file.
params – The :class: ImdParams to run the server with.
logging_params – The :class:LoggingParams to set up trajectory logging with.
- Returns:
An OpenMM simulation runner.
- classmethod from_xmls(simulation_xmls: List[str], params: ImdParams | None = None, logging_params: LoggingParams | None = None)
Initialises a
AseOpenMMIMDRunner
from a list of simulation XML files serialised withserializer.serialize_simulation()
.- Parameters:
simulation_xmls – Paths to XML files.
params – The :class: ImdParams to run the server with.
logging_params – The :class:LoggingParams to set up trajectory logging with.
- Returns:
An OpenMM simulation runner.
- property is_running
Whether or not the molecular dynamics is currently running on a background thread or not.
- Returns:
True, if molecular dynamics is running, False otherwise.
- list()
- load(index: int)
- next()
- pause()
Pause the simulation, by cancelling any current run.
This method is called whenever a client runs the pause command, described in :mod:nanover.trajectory.frame_server.
- play()
Run the simulation indefinitely
Cancels any current run and then begins running the simulation on a background thread.
This method is called whenever a client runs the play command, described in :mod:nanover.trajectory.frame_server.
- reset()
- run(steps: int | None = None, block: bool | None = None, reset_energy: float | None = None)
Runs the molecular dynamics.
- Parameters:
steps – If passed, will run the given number of steps, otherwise will run forever on a background thread and immediately return.
block – If
False
run in a separate thread. By default, “block” isNone
, which means it is automatically set toTrue
if a number of steps is provided and toFalse
otherwise.reset_energy – Threshold of total energy in kJ/mol above which the simulation is reset to its initial conditions. If a value is provided, the simulation is reset if the total energy is greater than this value, or if the total energy is nan or infinite. If
None
is provided instead, then the simulation will not be automatically reset.
- property running_discovery
- step()
Take a single step of the simulation and stop.
This method is called whenever a client runs the step command, described in :mod:nanover.trajectory.frame_server.
- property time_step
Gets the time step of the simulation, in femtoseconds.
- Returns:
The time step of the simulation.
- property verbose
Whether this OpenMM runner is set to run in verbose mode. If it is, it will print state information every 100 steps using an :class: MDLogger.
- Returns:
True if set to run verbosely, False otherwise.
- class nanover.ase.openmm.runner.ImdParams(address: str | None = None, port: int | None = None, frame_interval: int = 5, time_step: float = 1.0, verbose: bool = False, walls: bool = False, name: str | None = None, discovery: bool = True, discovery_port: int | None = None, platform: str | None = None)
Bases:
object
Class representing parameters for IMD runners.
- address: str | None
- discovery: bool
- discovery_port: int | None
- frame_interval: int
- name: str | None
- platform: str | None
- port: int | None
- time_step: float
- verbose: bool
- walls: bool
- class nanover.ase.openmm.runner.LoggingParams(trajectory_file: str | None = None, write_interval: int = 1)
Bases:
object
Class representing parameters for trajectory logging
- trajectory_file: str | None
- write_interval: int
- class nanover.ase.openmm.runner.TrajectoryLoggerInfo(trajectory_logger: TrajectoryLogger, params: LoggingParams)
Bases:
object
Class giving a view into an ASE MD runners logger parameters.
- Parameters:
trajectory_logger – Trajectory logger performing the logging.
params – Logging parameters.
- property base_trajectory_path
The base trajectory path, without timestamps.
- Returns:
The base trajectory path.
- close()
Close the log.
- property trajectory_path: str
The current trajectory path being outputted to.
- Returns:
The current trajectory path.
- property write_interval
The interval at which log writing is occurring.
- Returns:
The interval at which log writing is occurring, in steps.
- nanover.ase.openmm.runner.openmm_ase_frame_adaptor(ase_atoms: Atoms, frame_publisher: FramePublisher, include_velocities=False, include_forces=False)
Generates and sends frames for a simulation using an :class: OpenMMCalculator.