nanover.openmm.runner module
Facilities to run an OpenMM simulation.
- class nanover.openmm.runner.OpenMMRunner(simulation: Simulation | None, name: str | None = None, address: str | None = None, port: int | None = None)
Bases:
NanoverRunner
Convenience class to run an OpenMM simulation.
A
Runner
object wraps an OpenMM simulation. Theapp.Simulation
instance is accessible via thesimulation
attribute.Actually starting the simulation is done with the
run()
method. The method takes a number of steps to run as an argument; by default, the simulation runs indefinitely.By default, one frame is sent to clients every 5 MD steps. This rate can be changed by setting the
frame_interval
attribute. By default, as well, the dynamics is throttled to send 30 frames per seconds (therefore running 150 MD steps per second). This rate can be changed by setting the target interval between frames in seconds with thedynamics_interval
attribute. Setting the interval to 0 causes the dynamics to not be throttled.The verbosity can be adjusted by setting the
verbose
attribute, or by using themake_verbose()
andmake_quiet()
methods.- Parameters:
simulation – The OpenMM simulation to run. It must have an OpenMM force object compatible with iMD. This force can be added using
nanover.openmm.imd.add_imd_force_to_system()
or provided tonanover.openmm.serializer.deserialize_simulation()
with theimd_force
argument.name – A friendly name for the runner. It will be displayed by ESSD.
address – The IP address the server binds to.
port – The port the server listens to.
- property app_server
Get the underlying app of the runner.
- cancel_run(wait: bool = False) None
Cancel molecular dynamics that is running on a background thread.
- Parameters:
wait – Whether to block and wait for the molecular dynamics to halt before returning.
- close()
Closes the connection and stops the dynamics.
- property dynamics_interval
Minimum interval, in seconds, between frames sent to the frame publisher.
- property force_interval: int
Update iMD interactions every N steps.
- property frame_interval: int
Send a frame every N steps.
- classmethod from_xml_input(input_xml: str | PathLike, name: str | None = None, address: str | None = None, port: int | None = None, platform: str | None = None) RunnerClass
Create a runner from a serialized simulation.
- Parameters:
input_xml – Path to an XML serialised OpenMM simulation.
name – A friendly name for the runner. It will be displayed by ESSD.
address – The IP address the server binds to.
port – The port the server listens to.
- Returns:
An instance of the class.
See also
The XML serialized simulation can be produced by
nanover.openmm.serializer.serialize_simulation()
.
- classmethod from_xml_inputs(input_xmls: List[str | PathLike], name: str | None = None, address: str | None = None, port: int | None = None, platform: str | None = None) RunnerClass
Create a runner from a serialized simulation.
- Parameters:
input_xmls – Paths to XML serialised OpenMM simulations.
name – A friendly name for the runner. It will be displayed by ESSD.
address – The IP address the server binds to.
port – The port the server listens to.
- Returns:
An instance of the class.
See also
The XML serialized simulation can be produced by
nanover.openmm.serializer.serialize_simulation()
.
- property include_forces: bool
Optionally include the particle forces in the frame data.
- property include_velocities: bool
Optionally include the particle velocities in the frame data.
- property is_running: bool
Whether or not the molecular dynamics is currently running on a background thread or not. :return: True, if molecular dynamics is running, False otherwise.
- list()
- load(index: int)
- make_quiet() None
Detach the verbosity reporter if it is attached.
See also
- make_verbose() None
Attach a verbosity reporter if it is not already attached.
The verbosity reporter reports the step number, the potential energy in kJ/mol, and the simulation speed in ns/day. This report is displayed every 10 simulation steps.
See also
The
make_quiet()
method removes the verbosity reporter.
- 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.
- property reporter
- reset()
- run(steps: int | None = None, block: bool | None = 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.
- property simulation
- property simulation_entry
- 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 verbose: bool
Returns
True
if the verbosity reporter is attached.
- property verbosity_interval: int
Display the verbosity report every N steps.
If the runner is not verbose, then the verbosity interval is 0. Same wise, if this interval is set to 0, then the runner is made quiet.
- class nanover.openmm.runner.SimulationEntry(simulation: Simulation, name='Unnamed Simulation')
Bases:
object
- reporter: NanoverImdReporter | None
- reset(app_server)