topo package

Subpackages

Note

topo.parameters and topo.reporter have dedicated, curated API pages (Parameters, topo.reporter package) and are intentionally omitted here to avoid duplicate object descriptions.

Submodules

topo.engine module

Shared simulation engine: build the system and set up an OpenMM Simulation.

This is the layer common to every run mode. It does the parts that do not depend on the temperature protocol:

  • build_system() – coarse-grain model, multi-copy replication,

    topology (PSF) dump, COM-motion removal.

  • setup_simulation() – integrator, platform, restart/checkpoint,

    starting coordinates/velocities, reporters, run-metadata header.

  • finalize_simulation() – save checkpoint, write final structure,

    close out run metadata, print wall time.

The temperature protocol (constant-temperature equilibrium vs. annealing / quenching) lives with each runner – see topo.mdrun.protocol. Equilibrium is just the degenerate one-stage schedule, so both protocols share everything in this module. A future nascent-chain (translation) runner can reuse the same build/setup/finalize helpers and supply its own driver loop.

class topo.engine.BuiltSystem(cgModel: Any, system: Any, topology: Any, positions: Any)[source]

Bases: object

Outputs of build_system().

cgModel: Any
positions: Any
system: Any
topology: Any
class topo.engine.RunContext(simulation: Any, checkpoint: str, restart_active: bool, done_steps: int, runinfo_path: str)[source]

Bases: object

Outputs of setup_simulation() needed to run and finalize.

checkpoint: str
done_steps: int
restart_active: bool
runinfo_path: str
simulation: Any
topo.engine.attach_reporters(cfg, simulation, suffix='', append=False, total_steps=None, checkpoint=True)[source]

(Re)attach the checkpoint / trajectory / log reporters for one phase.

Replaces simulation.reporters so the runner can switch output file sets between the quench phase (suffix='_quench') and production (suffix='').

Parameters:
  • suffix (str) – Inserted before the extension: '' -> <outname>.dcd / .log; '_quench' -> <outname>_quench.dcd / .log.

  • append (bool) – Append to (rather than truncate) the DCD/log – used when a restart resumes this phase, so the log header is not re-written.

  • total_steps (int, optional) – Value reported as the run length for the log’s remaining-time/speed columns; defaults to cfg.md_steps. Each phase keeps its own step clock (the quench clock is reset before production), so this is the phase length, not a grand total.

  • checkpoint (bool) – Whether to write the <outname>.chk checkpoint. The quench phase sets this False – it is short and never restarted, so the checkpoint only ever holds production state and a restart resumes production cleanly.

topo.engine.build_system(cfg) BuiltSystem[source]

Build the coarse-grain model and (optionally) replicate it into copies.

Mirrors the original mdrun build block: build the single-chain model, replicate into n_copies non-interacting copies when requested, dump the PSF topology (and a _multi.psf for multi-copy runs), and add a CMMotionRemover only when nstcomm is set.

topo.engine.finalize_simulation(cfg, ctx: RunContext, topology, start_epoch: float) None[source]

Save the final checkpoint, write the last conformation, close metadata.

topo.engine.setup_simulation(cfg, built: BuiltSystem, control_file: str | None = None) RunContext[source]

Create the OpenMM Simulation and bring it to a ready-to-step state.

Handles platform selection, the Langevin integrator (created at ref_t; the protocol driver sets the per-stage temperature), restart/checkpoint loading, starting coordinates/velocities for a fresh run, output reporters, and the run-metadata header. The integrator’s initial temperature is irrelevant to the run because the protocol calls setTemperature before the first step, but ref_t keeps equilibrium runs byte-for-byte identical.