Skip to content

Equilibration and MD

autopath.equilibration.Equilibration

Orchestrate the multi-stage equilibration/relaxation protocol before production MD.

Loads a JSON protocol describing minimization and equilibration stages, applies progressively weakened positional restraints, warms the system from a low temperature to the target, and saves the final equilibrated structure and system XML.

Parameters:

Name Type Description Default
topology Topology

OpenMM topology of the system to equilibrate.

None
system System

OpenMM system (force field parameters, bonds, etc.).

None
out_dir str

Directory where equilibration outputs are written.

'equilibration'
restrained_minimization bool

If True, run a staged restrained minimization (recommended); otherwise run a single unconstrained minimization.

True
restrained_minimization_only bool

If True, stop after minimization and return the minimized system without running the warm-up or equilibration MD.

False
protocol_fname str

Path to the JSON file specifying the minimization and equilibration stages.

'autopath/data/eq_lig-prot_5ns_4fs.json'
save_freq int

Reporter output interval in steps (default 6250 ≈ 0.025 ns at 4 fs).

6250
is_membrane bool

If True, use a semi-isotropic membrane barostat for NPT stages.

False
platform str

OpenMM platform name ("CUDA", "OpenCL", "CPU", or "fastest" to auto-select).

'fastest'
verbose int

Reporter verbosity: 0 = no CSV, 1 = CSV without energies, 2 = full thermodynamic CSV output.

2

from_json

from_json(fname: str = None) -> dict

Load and parse the equilibration protocol from a JSON file.

Populates all protocol-derived attributes on this instance (components_lookup, minimization_scheme, equilibration_scheme, warmup_scheme, temperatures, step counts, and total simulation time).

Parameters:

Name Type Description Default
fname str

Path to the JSON protocol file.

None

Returns:

Type Description
dict

The full parsed protocol dictionary.

Raises:

Type Description
FileNotFoundError

If fname does not exist.

JSONDecodeError

If fname is not valid JSON.

to_json

to_json(fname: str = None) -> None

Write the current protocol (with run metadata) to a JSON file.

Adds datetime and time_elapsed keys to the protocol dict before serialization so the output captures when and how long the run took.

Parameters:

Name Type Description Default
fname str

Destination JSON file path.

None

Raises:

Type Description
FileNotFoundError

If the directory containing fname does not exist.

run

run(pdb_file: str = None, run_id: str = None) -> openmm.System

Execute the full equilibration pipeline and return the final system.

Steps performed:

  1. Build the simulation with a Langevin integrator.
  2. Add harmonic positional restraints for each component in components_lookup.
  3. Run restrained energy minimization (staged or single-pass).
  4. Remove and re-add restraints anchored to the minimized geometry, then explicitly apply the warmup force constants (the re-added forces' construction defaults do not survive the context reinitialize; see the comment at the call site).
  5. Warm up from T_initial to T_final in NVT, restrained.
  6. Run the staged restrained equilibration (NVT → NPT).
  7. Remove all restraint forces and save outputs.

Parameters:

Name Type Description Default
pdb_file str

Path to the starting structure PDB file.

None
run_id str

String identifier appended to output filenames (e.g. walker index).

None

Returns:

Type Description
System

The equilibrated system with all restraint forces removed.

autopath.equilibration.free_window_start

free_window_start(state_csv: str, protocol, component: str = 'ligand', n_frames: int = None)

First frame of the trailing window in which component is unrestrained.

The window length is the summed duration of the last equilibration stages whose force constant for component is zero; its start is located on the Time (ps) column of the equilibration state CSV, which has one row per trajectory frame.

Parameters:

Name Type Description Default
state_csv str

equilibration_<run_id>.csv written next to the trajectory.

required
protocol str or dict

Equilibration protocol (JSON path or loaded dict) used for the run.

required
component str

Key of components_lookup (default "ligand").

'ligand'
n_frames int

Number of trajectory frames; checked against the CSV rows when given.

None

Returns:

Type Description
int or None

Index of the first frame of the unrestrained window; None (with a warning) if component is not in the protocol or is restrained in the last stage.

Raises:

Type Description
ValueError

If the CSV does not match n_frames.

autopath.vanilla_md.VanillaMD

Unbiased (plain) MD runner for AutoPath production simulations.

Runs a standard NVT Langevin MD simulation, optionally with harmonic positional restraints on a subset of atoms (e.g. protein Cα). Outputs trajectory, checkpoint, system XML, and a final PDB.

Parameters:

Name Type Description Default
system System

OpenMM System object containing all force field terms.

None
topology Topology

OpenMM topology of the full system.

None
restrained_atoms list of int

Atom indices to restrain with harmonic positional restraints during the simulation. Typically protein Cα atoms. None disables restraints.

None
timestep float

Integration timestep in picoseconds. Default is 0.004 ps (4 fs), enabled by hydrogen-mass repartitioning.

0.004
temperature float

Simulation temperature in Kelvin.

300
save_freq int

Interval (in steps) between checkpoint and trajectory saves. Default 25 000 (0.1 ns at 4 fs).

25000
out_dir str

Directory where trajectory, checkpoint, system XML, and PDB are written.

'MD'
platform str

OpenMM platform name or "fastest" to auto-select the best available platform.

'fastest'
verbose int

Verbosity level passed to the trajectory reporter (0 = silent, higher values add more output columns).

2

run

run(checkpoint_file: str = None, pdb_file: str = None, state_file: str = None, run_id: str = None, MD_time: int = 10, restart_velocities: bool = False)

Run a production MD simulation.

Loads initial state from a checkpoint or PDB, optionally applies harmonic positional restraints, and integrates for the requested simulation time.

Parameters:

Name Type Description Default
checkpoint_file str

Path to a binary OpenMM checkpoint file. Takes precedence over pdb_file. Checkpoints are platform/device specific; prefer state_file when the hardware may differ.

None
state_file str

Path to a portable OpenMM State XML (written by save_simulation). Takes precedence over both other options.

None
pdb_file str

Path to a PDB file used to set initial positions and box vectors when no checkpoint is available. Velocities are initialised at temperature.

None
run_id str

Label used as a prefix for all output files written to self.out_dir.

None
MD_time int

Total simulation time in nanoseconds.

10
restart_velocities bool

When True, reassign velocities from a Maxwell–Boltzmann distribution at temperature after loading the initial state.

False

Returns:

Type Description
None

Checkpoint, system XML, trajectory, and final PDB are written to self.out_dir.

autopath.relax_md.RelaxMD

Short equilibration / relaxation MD runner.

Performs energy minimization, temperature ramp-up, and a brief NPT run to relax the system before production MD. Harmonic positional restraints are applied to the ligand during relaxation and removed before saving, so that the returned system is unrestrained and ready for downstream stages.

Parameters:

Name Type Description Default
topology Topology

OpenMM topology of the full system.

None
ligand_atoms list of int

Atom indices belonging to the ligand; used for COM-distance tracking and positional restraints.

None
pocket_atoms list of int

Atom indices of the binding-pocket residues; used for COM-distance tracking.

None
out_dir str

Directory where checkpoint, system XML, and PDB files are written.

'relax_md'
is_membrane bool

When True, a membrane-compatible semi-isotropic barostat is used instead of the default isotropic one.

False
timestep float

Integration timestep in picoseconds. Default is 0.004 ps (4 fs), enabled by hydrogen-mass repartitioning.

0.004
temp float

Simulation temperature in Kelvin.

300
platform str

OpenMM platform name or "fastest" to auto-select the best available platform.

'fastest'
Note

Force group 19 is reserved for the temporary ligand restraints.

run

run(system: str = None, checkpoint_file: str = None, pdb_file: str = None, state_xml_file: str = None, run_id: str = None, npt_steps: int = 12500) -> System

Run relaxation MD: minimize, warm up, and perform a short NPT run.

The ligand is harmonically restrained during the run; the restraints are removed before the outputs are written.

Parameters:

Name Type Description Default
system System

OpenMM System object containing all force field terms. Modified in-place (barostat added, temporary restraints removed).

None
checkpoint_file str

Path to a binary OpenMM checkpoint file from a previous run. Takes precedence over state_xml_file and pdb_file when more than one is supplied.

None
pdb_file str

Path to a PDB file used to set initial positions when no checkpoint is available.

None
state_xml_file str

Path to a portable OpenMM State XML. Only box, positions and velocities are applied, not its global parameters.

None
run_id str

Label used as a prefix for all output files written to self.out_dir.

None
npt_steps int

Number of integration steps for both the warm-up phase and the NPT run.

12500

Returns:

Type Description
System

The relaxed system with the barostat added and temporary restraint forces removed. Checkpoint, system XML, and final PDB are written to self.out_dir.