Skip to content

Bonds, minimization and pressure ​

All quantities are plain numbers in caller-chosen consistent units (length L, energy E, time). Angles are in radians.

Typed bonded interactions ​

Topology sections carry optional labels; each bonded force descriptor applies to the tuples whose label equals its type (:default when a section has no labels). Atom order is preserved: the middle atom of an angle is the vertex, and torsions use the IUPAC signed dihedral φ = atan2(|b2| b1·(b2×b3), (b1×b2)·(b2×b3)) of the ordered quartet.

julia
topology = Topology(bonds=bonds, bond_types=[:backbone, :side, …],
                    angles=angles, dihedrals=dihedrals, impropers=impropers)
forces = Force[
    WCA(epsilon=1.0, sigma=1.0),
    HarmonicBondForce(k=300.0, r0=1.0, type=:backbone),
    FENEBondForce(k=30.0, R0=1.5, type=:side),
    HarmonicAngleForce(k=30.0, theta0=deg2rad(115)),
    PeriodicDihedralForce(k=[1.0, 0.4], n=[1, 3], phase=[0.0, 0.0]),
    HarmonicImproperForce(k=10.0, chi0=0.0),
]
DescriptorPotential
HarmonicBondForce(k, r0)k(r-r0)²/2
FENEBondForce(k, R0)-kR0² log(1-r²/R0²)/2, strictly r < R0
HarmonicAngleForce(k, theta0)k(θ-θ0)²/2; θ0 = π is exact at collinear geometry
CosineSquaredAngleForce(k, theta0)k(cosθ-cosθ0)²/2
UreyBradleyAngleForce(k_theta, theta0, k_r, r13)harmonic angle + k_r(r13-r13⁰)²/2
PeriodicDihedralForce(k, n, phase)Σ k_m[1+cos(n_mφ-δ_m)]
OPLSDihedralForce(K1, K2, K3, K4)½[K1(1+cosφ)+K2(1-cos2φ)+K3(1+cos3φ)+K4(1-cos4φ)]
RyckaertBellemansDihedralForce(C)Σ Cn cos(ψ)^n, ψ = φ-π
HarmonicImproperForce(k, chi0)k·wrap(χ-χ0)²/2 (torsion-style, ordered quartet)
PeriodicImproperForce(k, n, phase)Fourier form on impropers

Every label must be assigned exactly once per section; missing or duplicate assignments raise an error. Torsions and impropers require 3D. Invalid geometry (zero-length bonds, collinear torsion planes, FENE beyond R0) raises DomainError with the topology index. Per-pair 1–4 LJ and Coulomb scaling is supported on the :cluster backend via 4-tuple (i, j, coul_scale, lj_scale) exceptions or set_lj_exceptions! (see Interactions).

Holonomic constraints and HMR ​

Pass Constraint descriptors in Integrator(...; constraints=[...]) to enforce rigid water geometry, solute hydrogen-bond distance constraints, or particle-freeze restraints directly in the workflow API:

julia
integrator = Integrator(
    dt=4.0e-3,                                    # 4 fs with HMR (ps units)
    scheme=BAOABFast(),
    forces=forces,
    methods=[Langevin(all; gamma=1.0, kT=2.494)],
    constraints=[
        RigidWaterConstraint(water_triples; oh=0.1, hh=0.163298, settle_mode=:df64),
        HBondConstraints(mass_cutoff=1.5, tolerance=1e-7),
    ],
)
  • RigidWaterConstraint(triples; oh, hh, tolerance=nothing, maxiter=50, settle_mode=:df64): attaches disjoint (O, H1, H2) rigid three-site water molecules using closed-form Miyamoto–Kollman SETTLE/RATTLE inside the fused GPU rigid-water integrator across NVE, CSVR, BAOAB, and BAOABFast runs — including mixed solute + water systems. settle_mode selects :df64 (default double-float precision with exact COM impulse conservation), :f32, or :f64.

  • ConstraintClusterSpec(pairs; tolerance=nothing, maxiter=100, project_initial=false, constraint_mode=:df64, constraint_f64=false): attaches explicit (i, j, d) holonomic distance constraints, partitioned into independent analytical register-resident clusters (X–H, X–H₂, X–H₃, X–H₄, plus shared-memory general fallback clusters) that overlap concurrently with rigid-water integration inside CUDA graphs. constraint_mode defaults to :df64 (Dekker–Knuth double-float precision with 0 B local spill) on Float32 states, :f64 on Float64 states (or when constraint_f64=true), and :f32 as an opt-in fast mode.

  • HBondConstraints(; pairs=nothing, hydrogen_types=nothing, mass_cutoff=1.5, bond_lengths=nothing, ...): automatically selects non-water hydrogen-involving bonds from system.topology.bonds by hydrogen_types or atomic mass <= mass_cutoff (resolving target lengths from bond_lengths, matching HarmonicBondForce.r0, or initial minimum-image distances).

  • FreezeGroup(group; mode=:hold|:spring, k=0.0, steps=nothing, include_energy=true): clamps positions or adds harmonic position restraints (see Dynamics).

For hydrogen mass repartitioning (HMR) and low-level SimulationState setup, ConstraintClusters also exposes host helpers alongside attach_rigid_water! and attach_constraint_clusters!:

julia
h_cons, remaining_bonds = ConstraintClusters.extract_hbond_constraints(
    raw_bonds, masses; exclude_atoms=water_atoms,
)
masses_hmr = ConstraintClusters.apply_hmr(
    masses, h_cons; hydrogen_mass=1.5, exclude_atoms=water_atoms,
)
attach_constraint_clusters!(st, h_cons; tolerance=1e-7, maxiter=50)

Energy minimization ​

julia
result = minimize!(sim; method=FIRE(dt_initial=1e-3, dt_max=1e-2),
                   force_tolerance=1e-4, max_displacement=0.05,
                   mobile=Group(:solvent, TypeSelection(:W)))

minimize! minimizes a workflow Simulation (or a low-level SimulationState) using its declared forces at fixed box; no thermostat runs and non-mobile particles keep their interactions without moving. Minimization supports all internal nonbonded/bonded/electrostatic/dispersion forces as well as ExternalPotentialForce / AbstractExternalPotential (both :replace MLIPs and :additive external fields) and custom AbstractPairPotential models.

  • FIRE (velocity-Verlet FIRE, requires dt_initial and dt_max) uses forces only and is typically the fastest minimizer for large systems and Float32 states.

  • SteepestDescent (requires initial_step) uses a backtracking Armijo line search on energies and stops with :step_too_small once energy differences fall below floating-point rounding (|F| ≈ √(2 k eps E_term)).

Control stopping with force_tolerance, max_displacement, max_iterations, and max_evaluations. The returned MinimizationResult reports converged, reason, iterations, initial_energy, final_energy, and max_force; always inspect result.converged and result.reason before continuing to dynamics.

Constant-pressure NPT ​

Pass a Barostat descriptor to Integrator(...; barostat=...) for 3D constant-pressure simulations:

julia
# GPU-resident isotropic stochastic cell rescaling (Bernetti & Bussi 2020)
barostat_cr = StochasticCellRescaling(
    pressure=1.0, kT=1.0, compressibility=0.1, tau=0.5,
    interval=10, scale=:molecules, seed=1,
)

# GPU-resident Monte Carlo barostat (:isotropic, :semiisotropic, or :z)
barostat_mc = MonteCarloBarostat(
    pressure=(1.0, 1.0), kT=1.0, interval=25,
    log_volume_step=0.01, mode=:semiisotropic, scale=:molecules,
    tune=true, seed=1,
)

integrator = Integrator(
    dt=4e-3, scheme=BAOABFast(), forces=forces,
    methods=[Langevin(all; gamma=1.0, kT=1.0)],
    barostat=barostat_mc,
)

Units: pressure in E/L³, kT in E, compressibility in L³/E, tau in time. Both barostats scale coordinates with the cell and leave velocities unchanged.

Supported modes, scaling and integrators ​

  • StochasticCellRescaling (mode=:isotropic, scale=:atoms or :molecules): runs fully GPU-resident (DeviceCRescale) inside CUDA graphs whenever interval >= 2 (with automatic host fallback for interval == 1). On non-neutral charged systems (net_charge=:background), the uniform background energy U_bg(V) and virial W_bg(V) refresh dynamically on the GPU at every volume update with zero graph recaptures.

  • MonteCarloBarostat: runs GPU-resident with zero-sync step_many! super-batches and out-of-place zero-restore energy-only trial evaluation (avoiding coordinate rollback on rejected moves and skipping force computation during trials), supporting:

    • mode=:isotropic: uniform scaling of (Lx, Ly, Lz).

    • mode=:semiisotropic: alternating xy and z moves (pressure may be a scalar or (P_xy, P_z) — ideal for lipid bilayers and liquid–vapor slabs).

    • mode=:z (or :z_only): scales Lz at fixed cross-section Lx * Ly.

    • scale=:atoms or scale=:molecules: 3-axis parallel O(1)-pass Euler-tour molecular center-of-mass scaling (40 KB Int16 shared memory up to 10,241 atoms per macromolecule, with an unlimited zero-extra-VRAM global fallback for larger complexes) so rigid waters, ConstraintClusters, and bonded macromolecules translate rigidly without breaking internal constraints.

    • tune=true: adaptive proposal step-size tuning toward target acceptance.

  • Supported integrators: both barostats work with inertial MD (ConstantVolume with NVE, CSVR, or NoseHooverChain under VelocityVerlet()) and Langevin dynamics (VelocityVerlet(), BAOAB, BAOABFast, and GSM), covering all particles at matching kT.

  • Long-range interactions: electrostatics (PME, PPPM, ESP) and lattice dispersion (DispersionESP, DispersionPME) automatically update mesh influence functions, reciprocal virials, and background terms at every cell change.

Diagnostics, restarts and neighbor sizing ​

  • barostat_diagnostics(sim) reports current volume, attempts, acceptance rate, and committed changes; pair with PressureObservable and BoxObservable to record pressure, density, cell lengths, and surface tension time series.

  • GSD frames automatically record log/barostat/state; continue an NPT run via restore_barostat!(sim, read_gsd_log(path, "log/barostat/state")).

  • Monte Carlo moves evaluate the potential energy directly, so the Lennard-Jones cutoff convention matters (vdw_modifier=:potential_shift matches GROMACS).

  • For CellList (:ell), size capacity for the densest volume the run will visit; overflow stops the run rather than silently truncating pairs. Setting interval between 10 and 25 steps balances pressure coupling cost with neighbor-list rebuild frequency.

Full signatures for bonded descriptors, constraints, minimization, and barostats live in the Potentials, MLIPs & Bonded Terms and Constraints, Minimization & Barostats API references.

ParticleDynamics v1.2.0 · GPU-native molecular dynamics in pure Julia · MIT License