MDFactoryMDFactory

openmm_utils

OpenMM simulation utilities for box compression and equilibration.

funcmonitor_volume_convergence(volumes, window_size=10, tolerance=0.02)

Check if box volume has converged by comparing running averages.

paramvolumeslist of float

Volume values recorded at each reporting interval.

paramwindow_sizeint
= 10

Number of steps for each running-average window. Default is 10.

paramtolerancefloat
= 0.02

Relative tolerance for convergence (e.g. 0.02 = 2%). Default is 0.02.

Returns

bool

Whether the relative change between consecutive windows is below tolerance.

funcsimulate_compression_until_constant_volume(simulation, steps=100000, tolerance=0.05)tuple[list[float], int, bool]

Run an NPT simulation until the box volume converges.

Step the simulation forward in 1000-step increments, recording the volume after each increment, and stop early when monitor_volume_convergence signals convergence.

paramsimulationopenmm.app.Simulation

An initialized OpenMM simulation with a barostat.

paramstepsint
= 100000

Maximum number of MD steps. Default is 100000.

paramtolerancefloat
= 0.05

Relative volume-change tolerance passed to monitor_volume_convergence. Default is 0.05.

Returns

list of float

Recorded box volumes in nm^3.

funcsimulate_compression_until_density_reached(simulation, mass, steps=100000, target_density=1.0)tuple[list[float], int, bool]

Run an NPT simulation until the system density reaches a target value.

Step the simulation in 1000-step increments and compute the instantaneous density from the total mass and current box volume. Stop early once the density meets or exceeds target_density.

paramsimulationopenmm.app.Simulation

An initialized OpenMM simulation with a barostat.

parammassopenmm.unit.Quantity

Total mass of the system (with OpenMM units attached).

paramstepsint
= 100000

Maximum number of MD steps. Default is 100000.

paramtarget_densityfloat
= 1.0

Target density in g/mL. Default is 1.0.

Returns

list of float

Recorded densities in g/mL at each reporting interval.

funccreate_sphere(u, pdb, top, radius, steps=100000)

Compress a system into a sphere using a harmonic radial restraint.

Apply a custom external force that penalizes atoms beyond radius from the origin, minimize, and run Langevin dynamics to pack the system into a spherical shape.

paramumda.Universe

Reference MDAnalysis Universe whose topology is preserved in the returned object.

parampdbstr or Path

Path to the input PDB file for OpenMM.

paramtopstr or Path

Path to the GROMACS topology file.

paramradiusfloat

Sphere radius in nanometers.

paramstepsint
= 100000

Number of MD steps to run after minimization. Default is 100000.

Returns

MDAnalysis.Universe

Universe with updated positions packed into the sphere. Box dimensions are set to None (non-periodic).

funccompress_box(u, pdb, top, target_density=1.0, pressure=1000.0, steps_compression=200000)

Compress a periodic box to a target density using high-pressure NPT.

Apply a Monte Carlo barostat at elevated pressure, minimize, and run dynamics until the system density reaches target_density.

paramumda.Universe

Reference MDAnalysis Universe whose topology is preserved in the returned object.

parampdbstr or Path

Path to the input PDB file for OpenMM.

paramtopstr or Path

Path to the GROMACS topology file.

paramtarget_densityfloat
= 1.0

Target density in g/mL. Default is 1.0.

parampressurefloat
= 1000.0

Barostat pressure in bar. Default is 1000.0.

paramsteps_compressionint
= 200000

Maximum number of compression MD steps. Default is 200000.

Returns

MDAnalysis.Universe

Universe with compressed positions and updated box dimensions. Positions are wrapped by residue.

funccompress_equilibrate_bilayer(u, pdb, top, pressure=1000.0, steps_compression=200000, steps_equil=0)

Compress and equilibrate a lipid bilayer in two phases.

Phase 1 applies z-coordinate restraints with a membrane barostat at elevated pressure (XY-isotropic, Z-fixed) until volume converges. Phase 2 removes the restraints and continues equilibration at 1 bar.

paramumda.Universe

Reference MDAnalysis Universe whose topology is preserved in the returned object.

parampdbstr or Path

Path to the input PDB file for OpenMM.

paramtopstr or Path

Path to the GROMACS topology file.

parampressurefloat
= 1000.0

Barostat pressure in bar for Phase 1. Default is 1000.0.

paramsteps_compressionint
= 200000

Maximum MD steps for Phase 1 compression. Default is 200000.

paramsteps_equilint
= 0

Maximum MD steps for Phase 2 equilibration. Default is 0.

Returns

MDAnalysis.Universe

Equilibrated bilayer Universe with updated positions and box dimensions. An equilibration_analysis.png plot is also saved.