Workflow API
High-level declarative API for configuring and running GPU particle simulations. For a conceptual tour, see the Workflow overview and Your first simulation.
Package overview
ParticleDynamics.ParticleDynamics Module
GPU-accelerated non-equilibrium particle simulations with Langevin/Brownian/Molecular dynamics.
ParticleDynamics provides a high-level workflow API centered on Simulation, ParticleSystem, workflow forces, methods, observables, writers, and run! with named stages. All state lives on the GPU (CUDA). The low-level API (build_simulation, step!, explicit integrator specs, and SimulationCore) remains available for expert use.
Example
The snippet below shows the workflow style used by the examples.
using ParticleDynamics
N = 256
sigma = 1.0
cfg = hex_random_2d(N, sigma, 0.25; T=Float64)
system = ParticleSystem(cfg; types=[:A], typeids=fill(Int32(1), N), masses=Dict(:A => 1.0))
all_particles = Group(:all, AllSelection())
thermo = ThermodynamicObservable(all_particles; name=:all)
sim = Simulation(
system;
groups=Groups(all_particles),
integrator=Integrator(
dt=2.0e-4,
scheme=VelocityVerlet(),
forces=[WCA(epsilon=10.0, sigma=sigma, pairs=:all)],
methods=[Langevin(all_particles; gamma=50.0, kT=1.0)],
),
observables=[thermo],
writers=[TableWriter("obs.csv"; every=50, observables=[thermo => [:temperature, :potential_energy]])],
)
run!(sim, Stage(:production, steps=200; progress=false))See examples/ for two-temperature baths, bonded polymers, Brownian dynamics, active noise and collision histograms. The manual covers charged systems with long-range electrostatics (PME, PPPM, ESP), typed bonded terms, energy minimization (minimize!), constant pressure (Barostat) and rigid water.
Simulation and system
ParticleDynamics.Workflow.Simulation Type
Simulation(system; groups=Groups(), integrator=nothing, observables=Observable[],
writers=Writer[], device=nothing, precision=Float64, seed=nothing,
spatial_reorder=nothing, reorder_interval=nothing, metadata=Dict())Assemble a particle system, groups, integrator, observables and writers into a simulation. Call run! to prepare it and run one or more stages.
Set spatial_reorder=true (or :auto) to opt into ELL spatial particle reordering (every reorder_interval steps, default 500) when the configuration does not require fixed storage order (:cluster, ExternalPotentialForce, barostats, constraints, or FreezeGroup).
ParticleDynamics.Workflow.ParticleSystem Type
ParticleSystem(data; box, types, typeids, masses, velocities, charges=nothing,
topology=Topology(), metadata=Dict())High-level particle/topology container used to build a workflow Simulation. data may be positions directly, an initializer result with .positions/.box, or a GSD frame (whose particles/charge chunk, if present, provides the charges).
charges accepts a length-N vector, a per-type Dict (:Na => 1.0, …), or a scalar, in the caller's charge unit. They are only used by long-range electrostatics forces (PME, PPPM, ESP) and are never inferred from particle types or force-field parameters.
ParticleDynamics.Workflow.PeriodicBox Type
PeriodicBox(lengths)High-level periodic box descriptor for a workflow ParticleSystem. Supports 2D and 3D boxes.
ParticleDynamics.Workflow.Topology Type
Topology(; bonds=[], bond_types=[], angles=[], angle_types=[], dihedrals=[], dihedral_types=[],
impropers=[], improper_types=[], exclusions=[], molecules=[], metadata=Dict())Topology container used by the workflow API. Each *_types vector is either empty (every tuple carries the label :default) or holds one label per tuple; bonded force descriptors select tuples by these labels. Tuple atom order is kept exactly (it defines angle vertices and torsion signs).
The type-label vectors were added after metadata in the field order. The former 8-argument positional constructor still works and migrates metadata[:angle_types] etc. (as earlier GSD imports stored them).
ParticleDynamics.Workflow.prepare! Function
prepare!(sim)Prepare a Simulation for running: validate its configuration, resolve particle groups, initialize forces and dynamics, and set up measurements and output. Call this again after replacing the integrator.
ParticleDynamics.Workflow.state Function
state(sim)Return the prepared low-level SimulationState backing a workflow Simulation.
Groups
ParticleDynamics.Workflow.Group Type
Group(name, selection; domain=:particles)Named particle selection for methods, observables and writers.
ParticleDynamics.Workflow.Groups Type
Groups(groups...)Name-indexed collection of workflow Group objects.
ParticleDynamics.Workflow.AllSelection Type
AllSelection()Select all particles in a workflow Group.
ParticleDynamics.Workflow.TypeSelection Type
TypeSelection(value)Select particles by type. value may be a symbolic type name such as :A or an integer type id such as 1.
ParticleDynamics.Workflow.IndexSelection Type
IndexSelection(indices)Select an explicit list of 1-based particle indices (duplicates are removed, preserving order).
Nonbonded and general forces
Bonded force descriptors are documented in Potentials, MLIPs & Bonded Terms; long-range Coulomb and 1/r⁶ lattice dispersion forces are documented in Electrostatics, Dispersion & Pair Lists.
ParticleDynamics.Workflow.Force Type
ForceAbstract workflow force descriptor. Concrete force objects describe physical interactions to include in an integrator.
ParticleDynamics.Workflow.ForceField Type
ForceField(; forces=Force[])Container for a set of workflow force objects.
ParticleDynamics.Workflow.LennardJones Type
LennardJones(; epsilon, sigma, cutoff, pairs=:all, mode=:standard, pair_table=nothing, neighborlist=nothing,
vdw_modifier=:none, switch_distance=nothing, scaled_pairs=(), exclude_bonded_pairs=true)Workflow Lennard-Jones force descriptor. vdw_modifier sets the convention at the cutoff: :none truncates, :potential_shift uses u(r) − u(r_c) (the GROMACS default; forces unchanged), :force_switch / :potential_switch smoothly switch the force or potential to zero between switch_distance (default 0.85·cutoff, or 0.85·min(active cutoff) for pair tables) and cutoff (C², no force jump at the cutoff). Set exclude_bonded_pairs=false to apply the nonbonded interaction to bonded pairs as well.
ParticleDynamics.Workflow.WCA Type
WCA(; epsilon, sigma, cutoff=nothing, pairs=:all, mode=:standard, pair_table=nothing,
neighborlist=nothing, exclude_bonded_pairs=true)Workflow Weeks-Chandler-Andersen force descriptor. Set exclude_bonded_pairs=false for models such as Kremer–Grest (FENE + WCA) where WCA repulsion also acts on bonded pairs.
ParticleDynamics.Workflow.SoftRepulsive Type
SoftRepulsive(; epsilon, sigma, cutoff, params=nothing, pairs=:all, pair_table=nothing,
neighborlist=nothing, exclude_bonded_pairs=true)Workflow soft-repulsive force descriptor.
ParticleDynamics.Workflow.PairTable Type
PairTable(; sigma, epsilon, cutoff, type_names)Per-type parameter table for workflow Lennard-Jones and WCA forces. When supplied as per-type vectors, pairs are combined with Lorentz–Berthelot rules: arithmetic mean 0.5*(σ_i + σ_j) for sigma (and cutoff) and geometric mean sqrt(ε_i * ε_j) for epsilon. Explicit ntypes × ntypes matrices are used verbatim.
ParticleDynamics.Workflow.CellList Type
CellList(; buffer=0.4, capacity=96, rebuild_interval=20, spatial_reorder=nothing, reorder_interval=500)Neighbor-list policy for workflow nonbonded forces. Set spatial_reorder=true (or :auto) to enable Hilbert/cell spatial sorting on ELL runs that do not require fixed particle storage order.
ParticleDynamics.Workflow.ClusterPairList Type
ClusterPairList(; buffer=0.1, prune_buffer=nothing, force_accumulation=:float32)Cluster-pair traversal for 3D Lennard-Jones (uniform or pair table) and real-space Coulomb: one fused kernel over a Newton-3 list of 8×8 particle tiles. The list radius is the largest interaction cutoff plus buffer; between rebuilds the list is pruned to the cutoff plus prune_buffer (default buffer/2). Bond exclusions of the vdW term are not supported (use CellList). force_accumulation=:fixed64 (Float32 states) accumulates the pair forces of each slot in 64-bit fixed point (2⁻³⁰ resolution), so the summation is associative and the forces are bitwise reproducible across launches.
ParticleDynamics.Workflow.ExternalPotentialForce Type
ExternalPotentialForce(potential::AbstractExternalPotential)
ExternalPotentialForce(; potential)Workflow force descriptor attaching any AbstractExternalPotential inside a ForceField or Integrator(forces=[...]).
Integrator, schemes and methods
Holonomic constraints, freeze restraints, energy minimization, and barostats passed to Integrator are documented in Constraints, Minimization & Barostats.
ParticleDynamics.Workflow.Integrator Type
Integrator(; dt, scheme=nothing, forces=Force[], methods=Method[],
metadata=Dict(), barostat=nothing, constraints=Constraint[], freeze=nothing)High-level workflow integrator object. It owns the timestep, force objects, methods, holonomic constraints / freeze controls, and optional barostat that define the simulation dynamics.
ParticleDynamics.Workflow.VelocityVerlet Type
VelocityVerlet() selects the workflow velocity-Verlet stepping scheme (Grønbech-Jensen/Farago when paired with Langevin).
ParticleDynamics.Workflow.BAOAB Type
BAOAB(; track_thermo=true) selects the workflow BAOAB Langevin splitting. Set track_thermo=false (or use BAOABFast()) to skip per-step dU/dq tracking.
ParticleDynamics.Workflow.BAOABFast Function
BAOABFast() selects the workflow BAOAB Langevin splitting with track_thermo=false.
ParticleDynamics.Workflow.BAOA Type
BAOA() selects the workflow BAOA Langevin splitting.
ParticleDynamics.Workflow.GSM Type
GSM() selects the workflow Generalized Simulation Method (BAOAB-equivalent Langevin splitting) scheme.
ParticleDynamics.Workflow.EulerHeun Type
EulerHeun() selects the workflow Brownian midpoint scheme.
ParticleDynamics.Workflow.EulerMaruyama Type
EulerMaruyama() selects the workflow Euler-Maruyama scheme.
ParticleDynamics.Workflow.ConstantVolume Type
ConstantVolume(group; thermostat=nothing)Molecular-dynamics method for a particle group, optionally coupled to a workflow thermostat. When thermostat === nothing, the group evolves in the microcanonical NVE limit.
ParticleDynamics.Workflow.Langevin Type
Langevin(group; gamma=nothing, friction_rate=nothing, tau=nothing, kT)Langevin method applied to a workflow group. Supply exactly one of gamma (uniform Stokes drag friction_rate (uniform collision rate tau (relaxation time
ParticleDynamics.Workflow.Brownian Type
Brownian(group; gamma, kT)Brownian dynamics method applied to a workflow group.
ParticleDynamics.Workflow.ActiveOrnsteinUhlenbeck Type
ActiveOrnsteinUhlenbeck(group; gamma, tau=nothing, noise_scale=nothing, spectrum=nothing)Active Ornstein-Uhlenbeck method applied to a workflow group. This method only configures the correlated OU process. Thermal white noise is controlled separately through Brownian or Langevin, so a thermal AOUP model is built by assigning both methods to the same group.
The active OU amplitude is set by noise_scale or by the scales stored in spectrum. Those values are stationary standard deviations of the OU impulse, not bath temperatures.
ParticleDynamics.Workflow.OUSpectrum Type
OUSpectrum(taus, scales)Multi-mode Ornstein-Uhlenbeck spectrum used by ActiveOrnsteinUhlenbeck.
ParticleDynamics.Workflow.CSVR Type
CSVR(; kT, tau, interval=1, nstcomm=100)Canonical stochastic velocity-rescaling thermostat. interval sets the coupling period in steps (nsttcouple; default 1). nstcomm sets the periodic center-of-mass momentum removal interval in steps (default 100; 0 disables).
ParticleDynamics.Workflow.NoseHooverChain Type
NoseHooverChain(; kT, tau, chain_length=5, substeps=5, propagator=:gromacs, chain_masses=nothing, nstcomm=100)Nose-Hoover chain thermostat descriptor for the workflow API. propagator selects :gromacs (default), :lammps, or :legacy. nstcomm sets the periodic center-of-mass momentum removal interval in steps (default 100; 0 disables).
Running and schedules
ParticleDynamics.Workflow.run! Function
run!(sim, nsteps)
run!(sim, stage::Stage)
run!(sim, stages::AbstractVector{<:Stage})Run a workflow Simulation. run! owns the timestep loop, prepares the simulation on first use, and drives scheduled writers automatically.
ParticleDynamics.Workflow.Stage Type
Stage(name; steps, dt=nothing, neighbor_rebuild_interval=nothing, compute_energy=:auto, reset_observables=false, reset_step=nothing, progress=true, max_seconds=Inf)Describe a named block of simulation steps for run!.
ParticleDynamics.Workflow.reset_step! Function
reset_step!(sim, step=0; dt=_current_dt(sim))Reset the visible workflow step counter, keeping workflow_time, interval references, active barostat timestamps, and any pending freeze_until step deadline consistent.
ParticleDynamics.Workflow.reset_observables! Function
reset_observables!(sim) -> simStart a new observation interval: zero the accumulated energies, virials, bath-exchange sums and collision counts, and take the current step as the reference for interval averages and for MSD and VACF observables.
ParticleDynamics.Workflow.Every Type
Every(interval)Trigger a workflow writer or observable action every interval steps.
ParticleDynamics.Workflow.AtSteps Type
AtSteps(steps)Trigger a workflow action at an explicit set of step indices.
ParticleDynamics.Workflow.Between Type
Between(first, last; every)Trigger a workflow action on a regular interval between two step bounds.
Observables
ParticleDynamics.Workflow.Observable Type
ObservableAbstract workflow observable descriptor.
Custom subtypes can plug into the workflow lifecycle by implementing:
observable_default_fields(obs)_observable_data(sim, obs, fields; writer_ctx=nothing)
and optionally overriding:
observable_name(obs)_observable_needs_unwrapped(obs)_observable_field_requires_energy(obs, field)_observable_field_is_interval(obs, field)_observable_field_needs_energy_accumulation(obs, field)_observable_field_uses_virial(obs, field)_prepare_observable!(sim, obs, ctx)_reset_observable!(sim, obs, ctx)
ParticleDynamics.Workflow.ThermodynamicObservable Type
ThermodynamicObservable(group; name=:thermo)Compute thermodynamic quantities for a workflow group.
ParticleDynamics.Workflow.BathExchangeObservable Type
BathExchangeObservable(; name=:bath)Compute bath heat and entropy-exchange diagnostics.
ParticleDynamics.Workflow.VirialObservable Type
VirialObservable(group; name=:virial)Compute scalar virial diagnostics for a workflow group.
ParticleDynamics.Workflow.PressureObservable Type
PressureObservable(; name=:pressure)Compute global mechanical pressure, pressure/virial tensors, slab surface tension, box volume, number density, and cell lengths.
Supported fields:
:pressure: scalar mechanical pressure(2 K + tr(W)) / (D V):volume: cell volume (Lx * Ly * Lzin 3D,Lx * Lyin 2D):density: number densityN / V:box:NamedTupleof cell lengths(Lx, Ly)(2D) or(Lx, Ly, Lz)(3D):Lx,:Ly,:Lz: individual box lengths (Lz = NaNin 2D):pressure_tensor: symmetric mechanical pressure tensor(Pxx, Pyy, Pxy)(2D) or(Pxx, Pyy, Pzz, Pxy, Pxz, Pyz)(3D),P_{αβ} = (K_{αβ} + W_{αβ}) / V:virial_tensor: total virial tensor(Wxx, Wyy, Wxy)(2D) or(Wxx, Wyy, Wzz, Wxy, Wxz, Wyz)(3D):surface_tension:0.5 * Lz * (Pzz - 0.5 * (Pxx + Pyy))in 3D (NaNin 2D)
ParticleDynamics.Workflow.BoxObservable Type
BoxObservable(; name=:box)Compute periodic box geometry (:volume, :density, :box, :Lx, :Ly, :Lz) without requiring energy or virial evaluation.
ParticleDynamics.Workflow.CollisionObservable Type
CollisionObservable(; name=:collisions)Compute collision counts and rates for the simulation.
ParticleDynamics.Workflow.MSDObservable Type
MSDObservable(group; name=:msd, reference=:start)Mean-squared-displacement observable for a workflow group.
ParticleDynamics.Workflow.VACFObservable Type
VACFObservable(group; name=:vacf, reference=:start)Velocity-autocorrelation observable for a workflow group.
Writers and output schedules are documented in I/O & Initial Configurations.