mythos.simulators.io

Common data structures for simulator I/O.

Classes

SimulatorTrajectory

A trajectory of a simulation run.

Module Contents

class mythos.simulators.io.SimulatorTrajectory[source]

A trajectory of a simulation run.

rigid_body: jax_md.rigid_body.RigidBody
metadata: jax.numpy.ndarray | None = None
__post_init__() None[source]
with_state_metadata(metadata: Any) SimulatorTrajectory[source]

Set the same metadata for all states in the trajectory.

filter(filter_fn: collections.abc.Callable[[Any], bool]) SimulatorTrajectory[source]

Filter the trajectory based on metadata.

Parameters:

filter_fn – A function that takes in metadata and returns a boolean indicating whether to keep the state.

Returns:

A new SimulatorTrajectory with only the states that pass the filter.

slice(key: int | slice | jax.numpy.ndarray | list) SimulatorTrajectory[source]

Slice the trajectory.

length() int[source]

Return the length of the trajectory.

Note, that this may have been more natural to implement as the built-in __len__ method. However, the chex.dataclass decorator overrides that method to be compatabile with the abc.Mapping interface

See here: https://github.com/google-deepmind/chex/blob/8af2c9e8a19f3a57d9bd283c2a34148aef952f60/chex/_src/dataclass.py#L50

__add__(other: SimulatorTrajectory) SimulatorTrajectory[source]

Concatenate two trajectories.

to_file(filepath: pathlib.Path, box_size: mythos.utils.types.Vector3D = (0, 0, 0)) None[source]

Write the trajectory to an oxDNA file.

Note that the SimulatorTrajectory does not store several of the fields necessary to fully reconstruct an oxDNA trajectory file (e.g. times, box size, velocities, angular momenta, and energies). Thus, times are filled with a monotonic sequence, while the rest of these fields are filled with 0’s. The resultant file can be used for inspection and visualization of non-time-dependent state-by-state spatial information only.

Parameters:
  • filepath – The path to write the trajectory file to.

  • box_size – The box size in 3 dimensions to write to the file. defaults to (0,0,0).