torch_sim.trajectoryΒΆ

Trajectory format and reporting.

This module provides classes for reading and writing trajectory data in HDF5 format. The core classes (TorchSimTrajectory and TrajectoryReporter) allow efficient storage and retrieval of atomic positions, forces, energies, and other properties from molecular dynamics simulations.

The TorchSimTrajectory does not aim to be a new trajectory standard, but rather a simple interface for storing and retrieving trajectory data from HDF5 files. It aims to support arbitrary arrays from the user in a natural way, allowing it to be seamlessly extended to whatever attributes are important to the user.

Example

Reading and writing a trajectory file:

# Writing to multiple trajectory files with a reporter
reporter = TrajectoryReporter(["traj1.hdf5", "traj2.hdf5"], state_frequency=100)
reporter.report(state, step=0, model=model)

# Reading the file with a TorchSimTrajectory
with TorchSimTrajectory("simulation.hdf5", mode="r") as traj:
    state = traj.get_state(frame=0)

Notes

This module uses PyTables (HDF5) for efficient I/O operations and supports compression to reduce file sizes. It can interoperate with ASE and pymatgen for visualization and analysis.

Classes

TorchSimTrajectory

Trajectory storage and retrieval for molecular dynamics simulations.

TrajectoryReporter

Trajectory reporter for saving simulation data at specified intervals.