Output¶
output ¶
Output: where a Simulation writes and how often, and the chunked writer (SPEC §7.2, §10.6).
Output is the record (plan task 1b-T01). ChunkedOutput (plan task 1b-T06) writes the
thermo rows and trajectory frames of a run as chunks, thermo.<n>.csv and
trajectory.<n>.traj for n = 0, 1, ..., with a chunk boundary exactly at every restart point
(SPEC §10.6 "Output files at restart points"):
restart_point()closes the current chunks, fsyncs them and their directory (plan task 2-T10; rows and frames in between are flushed, not fsynced) and opens the next pair; it returns the indices the restart file stores (io.restart.OUTPUT_KEYS):output_chunk, the last closed chunk, andoutput_rowsandoutput_frames, the rows and frames in chunks 0 tooutput_chunk. Call it after draining the output queue (AsyncOutput.restart_pointdoes both), then write the restart file. Every restart write is a chunk boundary, a stop request's included.- Resume (
resume_from=those indices) checks the chunks up tooutput_chunk(present, with the stored numbers of rows and frames) and that every later chunk can be deleted, before it touches anything; otherwise it raisesRestartMismatch. Then it deletes the later chunks and opens chunkoutput_chunk + 1. Nothing is ever rewritten: the research engine's resume reread and rewrotemd.traj(workflow.truncate_outputs, up to 770 MB on the NAS).
Rows and frames written after the last restart point (by the asynchronous writer, or before a
crash) are thus in later chunks only. A crash between restart_point and the restart write
leaves the older restart file, and resume from it deletes the newer chunks as well.
Every chunk is complete on its own: each thermo chunk starts with the header, and a chunk without
rows or frames still has both files (an empty trajectory reads as no frames). read_thermo and
read_frames concatenate the chunks in order; ase.io.read(path, index=":") reads one.
This module imports neither torch nor ASE at import time (fm.Output is a light name).
Output
dataclass
¶
Output directory and cadences, in MD steps (defaults: the production settings of §7.7).
trajectory_every and restart_every may be None (no trajectory, no restart files);
thermo rows are always written. directory is kept as given, as a string.
read_thermo ¶
read_thermo(
directory: str | Path,
) -> tuple[list[str], list[list[str]]]
The header and every thermo row over all chunks, in order (rows as strings).
read_frames ¶
read_frames(directory: str | Path) -> list[Atoms]
Every trajectory frame over all chunks, in order.