nanover.omni.openmm module

class nanover.omni.openmm.OpenMMSimulation(name: str | None = None)

Bases: object

A wrapper for OpenMM simulations to run inside the OmniRunner.

The following attributes can be configured after construction: - frame_interval: Number of simulation steps to advance between frames. - include_velocities: Include particle velocities in frames. - include_forces: Include particle forces in frames. - platform_name: Name of OpenMM platform to use when loading the system from XML.

add_contribution_to_work(forces: ndarray[Any, dtype[_ScalarType_co]], positions: ndarray[Any, dtype[_ScalarType_co]])

The expression for the work done on the system by the user is

\[W = \sum_{t = 1}^{n_{steps}} \sum_{i = 1}^{N} \mathbf{F}_{i}(t - 1) \cdot (\mathbf{r}_{i}(t) - \mathbf{r}_{i}(t - 1)))\]

which can be rewritten as

\[W = \sum_{t = 1}^{n_{steps}} \bigg( \sum_{i = 1}^{N} \mathbf{F}_{i}(t - 1) \cdot \mathbf{r}_{i}(t) \bigg) - \bigg( \sum_{i = 1}^{N} \mathbf{F}_{i}(t - 1) \cdot \mathbf{r}_{i}(t - 1) \bigg)\]

where the contribution at each value of t is separated into an previous-step contribution (t-1) and an on-step contribution (t). Doing so enables calculation of the work done on-the-fly without having to save the positions of the atoms at each time step that the user applies an iMD force.

This function calculates the contribution to the work done on the system by the user for a set of forces and positions, and add it to the work done on the system. Only involves the atoms affected by the user interaction.

advance_by_one_step()

Advance the simulation to the next point a frame should be reported, and send that frame.

advance_by_seconds(dt: float)

Advance playback time by some seconds, and advance the simulation to the next frame output. :param dt: Time to advance playback by in seconds (ignored)

advance_to_next_report()

Step the simulation to the next point a frame should be reported, and send that frame.

frame_interval

Number of simulation steps to advance between frames.

classmethod from_simulation(simulation: Simulation, *, name: str | None = None)

Construct this from an existing OpenMM simulation. :param simulation: An existing OpenMM Simulation :param name: An optional name for the simulation instead of default

classmethod from_xml_path(path: PathLike[str], *, name: str | None = None)

Construct this from an existing NanoVer OpenMM XML file at a given path. :param path: Path of the NanoVer OpenMM XML file :param name: An optional name for the simulation instead of filename

include_forces

Include particle forces in frames.

include_velocities

Include particle velocities in frames.

load()

Load and set up the simulation if it isn’t done already.

make_regular_frame(positions: List[List[float]] | ndarray[Any, dtype[float32 | float64]] | None = None)

Make a NanoVer FrameData corresponding to the current state of the simulation. :param positions: Optionally provided particle positions to save fetching them again.

make_topology_frame()

Make a NanoVer FrameData corresponding to the current particle positions and topology of the simulation.

platform_name: str | None

Name of OpenMM platform to use at the time the system is loaded from XML.

reset(app_server: NanoverImdApplication)

Reset the simulation to its initial conditions, reset IMD interactions, and reset frame stream to begin with topology and continue. :param app_server: The app server hosting the frame publisher and imd state