Run simulation¶
The mdrun program executes molecular dynamics simulations using the
DROPPS/CGPS OpenMM-based backend.
It consumes a runtime file generated by dps grompp and produces:
trajectory files (XTC)
energy & log files
checkpoint files
final wrapped configuration (PDB)
This is analogous to gmx mdrun in GROMACS.
Implemented in mdrun.py.
Overview¶
dps mdrun:
Loads all runtime data (system, topology, integrator parameters, positions) from a .tpr pickle generated by
dps grompp.Sets up the OpenMM integrator (Langevin).
Automatically selects the best available compute platform:
CUDA → OpenCL → CPU.Applies optional: - energy minimization - velocity initialization - center-of-mass motion removal - pressure coupling (MC barostat)
Configures reporters for: - screen log - file log - trajectory (XTC) - checkpoint
Runs warming phase (if enabled).
Runs production dynamics.
Writes the final wrapped PDB file to disk.
Usage¶
Run a simulation:
dps mdrun -s run.tpr -o output/run
Resume from a checkpoint:
dps mdrun -s run.tpr -cpi output/run.chk -o output/run2
Arguments¶
Required¶
- -s, --run-input FILE¶
Runtime file produced by
dps grompp(Python pickle format).
- -o, --output-prefix PREFIX¶
Prefix for all output files:
PREFIX.logPREFIX.xtcPREFIX.chkPREFIX.pdb
Optional¶
- -cpi, --checkpoint FILE¶
Checkpoint file from a previous run. If provided:
no minimization is performed
no warming is performed
velocities & box come from checkpoint
Simulation Workflow¶
### 1. Load runtime data
with open(args.run_input, "rb") as f:
loaded = pickle.load(f)
Loaded fields include:
parameters(MDP dictionary)mdsystem(OpenMM System)mdtopologypositionspdb_raw(for final PDB writing)
### 2. Set up Langevin integrator
temperature = parameters["production_temperature"] * kelvin
friction = parameters["friction"] / picosecond
timestep = parameters["dt"] * picosecond
### 3. Automatic platform selection
Preferred order:
['CUDA', 'OpenCL', 'CPU']
Platform-specific features:
CUDA:
DeviceIndex=0,Precision=mixedOpenCL: similar
CPU: no properties
Aborts if no platform is available.
### 4. Center-of-mass motion removal
If comm_mode = Linear:
mdsystem.addForce(openmm.CMMotionRemover(...))
Otherwise a warning is printed.
### 5. Pressure coupling (optional)
If pcoulp = True:
mdsystem.addForce(openmm.MonteCarloBarostat(pressure, temperature, tau_P))
### 6. Energy minimization
Performed only if:
minimize = Truein parametersno checkpoint is used
Done using:
simulation.minimizeEnergy(force_tol, max_steps)
Maximum force and RMS force are reported.
### 7. Reporters
Supported reporters:
screen log (printed to STDOUT)
file log (written to
PREFIX.log)XTC trajectory (
PREFIX.xtc)checkpoint files (
PREFIX.chk)
Configuration is driven by parameters:
nst_screenlogscreenlog_grpsnst_filelogfilelog_grpsnst_xoutnst_cp
### 8. Velocity initialization
If gen_vel = True:
simulation.context.setVelocitiesToTemperature(initial_T)
### 9. Warming schedule (optional)
If:
initial temperature < production temperature
no checkpoint is used
Then temperature is raised gradually:
for T in range(T_initial, T_final):
simulation.integrator.setTemperature(T)
simulation.step(step_per_kelvin)
Temperature update every 10 K printed.
### 10. Production dynamics
Simulation length:
parameters["nsteps"]
Temperature is set to the final production temperature.
If a checkpoint is supplied:
simulation.loadCheckpoint(args.checkpoint)
### 11. Final wrapping and PDB writing
Final coordinates:
positions = simulation.context.getState(getPositions=True)
.getPositions(asNumpy=True).value_in_unit(nanometer)
Box vectors:
box_vec = [Lx, Ly, Lz]
Coordinates wrapped:
wrapped = positions % box_vec
Final PDB written with preserved metadata from pdb_raw:
write_pdb(PREFIX.pdb, box_vec, ...)