Skip to content

Electrostatics, Dispersion & Pair Lists ​

API reference for long-range 3D periodic electrostatics (PME, PPPM, ESP), 1/r⁶ lattice dispersion (DispersionESP, DispersionPME), nonbonded backend controls, the ClusterPairs Newton-3 engine, and NeighborLists ELL storage. See Electrostatics and Interactions for physical models and parameter guidance.

Workflow electrostatics descriptors and tuning ​

ParticleDynamics.Workflow.ElectrostaticsForce Type
julia
ElectrostaticsForce

Abstract workflow descriptor of a long-range Coulomb solver (PME, PPPM, ESP). At most one may be active, alongside at most one short-range vdW force and one bonded force.

ParticleDynamics.Workflow.PME Type
julia
PME(; coulomb_prefactor, real_cutoff, alpha=nothing, real_space_tolerance=nothing,
      mesh=nothing, mesh_spacing=nothing, order=4, relative_permittivity=1.0,
      net_charge=:error, boundary=:tin_foil, real_space_modifier=:none,
      exclusions=:topology, exclude_bonded=false, scaled_pairs=(),
      pairs=:neighborlist, neighborlist=nothing)

Smooth particle-mesh Ewald (Essmann et al. 1995) with analytic differentiation, computed entirely on the GPU.

Units are the caller's: U = C qᵢqⱼ/r with C = coulomb_prefactor / relative_permittivity, so coulomb_prefactor carries E·L/Q² (≈138.935458 for nm/kJ mol⁻¹/e, ≈14.399645 for Å/eV/e, or 1 in reduced units). alpha is in inverse length units; alternatively real_space_tolerance sets it from erfc(α r_c) = tol (a real-space potential tail criterion, not a force error). mesh=(K₁,K₂,K₃) or mesh_spacing (FFT friendly sizes are chosen) and the B-spline order (stencil width) set the reciprocal accuracy.

Exceptions: exclusions=:topology excludes Topology.exclusions pairs (scale 0); exclude_bonded=true also excludes bonded pairs; scaled_pairs lists (i, j, coul_scale) triples (LJ unchanged, 1.0) or (i, j, coul_scale, lj_scale) 4-tuples (per-pair 1–4 Coulomb and Lennard-Jones scaling, e.g. (i, j, 1/1.2, 0.5) for AMBER) and overrides the other two. Each exception removes or scales the pair's minimum-image interaction while its periodic images remain.

net_charge=:error rejects charged systems; :background adds a uniform neutralising background (energy and virial, no force).

real_space_modifier=:potential_shift subtracts the short-range pair energy at the cutoff from every non-excluded pair inside it (energy only; forces are unchanged), matching the GROMACS coulomb-modifier = Potential-shift Hamiltonian; the default :none is the unshifted Ewald sum.

ParticleDynamics.Workflow.PPPM Type
julia
PPPM(; coulomb_prefactor, real_cutoff, alpha=nothing, real_space_tolerance=nothing,
       mesh=nothing, mesh_spacing=nothing, order=5, differentiation=:ad,
       alias_order=2, kwargs...)

Particle–particle particle–mesh (P3M) with the Hockney–Eastwood optimal influence function for B-spline assignment. differentiation=:ad uses analytic gradients of the assignment weights (one forward and one inverse transform, influence function optimised for AD); :ik forms the electric field in reciprocal space (one forward and three inverse transforms). Alias sums run over |n| ≤ alias_order images per dimension. All other keywords match PME.

The ik forces are not the exact gradient of the reported mesh energy; the energy and virial are those of the discrete influence function.

ParticleDynamics.Workflow.ESP Type
julia
ESP(; coulomb_prefactor, real_cutoff, tolerance=1e-4, split_shape=nothing,
      window_shape=nothing, order=nothing, mesh=nothing, mesh_spacing=nothing,
      kwargs...)

Ewald summation with prolates (Liang, Lu, Barnett, Greengard & Jiang 2026): the Gaussian split is replaced by one built from the prolate spheroidal wave function ψ₀ᶜ, and B-spline assignment by a prolate window of width order grid points. The real-space part vanishes exactly at real_cutoff.

Defaults follow the paper's selection rules for a target relative force error tolerance ε: split_shape c with ψ₀ᶜ(1) = ε (L²-normalised), window_shape from ε/2, order from Table 2 of the paper (5, 5, 6, 7, 8 for ε = 1e-3, 5e-4, 1e-4, 5e-5, 1e-5), and mesh_spacing = π r_c / c. All dimensionless shapes are distinct from the Gaussian alpha (inverse length). Treat the defaults as starting points and measure the error for production settings.

The default window_shape also depends on the precision of the state. A window that decays below 0.02 eps(T)^(2/3) at the mesh Nyquist frequency (4.8e-7 in Float32, 7.3e-13 in Float64) lets round-off into the mesh forces, so where the ε/2 shape falls below that bound the default is the smallest shape that meets it, at the same order. This happens in Float32 for ε ≈ 3.3e-5–4.5e-5 and below ε ≈ 6e-6, and in Float64 from ε ≈ 3e-9 downward. The solver refuses an explicit window below the bound. Float32 forces reach about 2e-6 relative accuracy at best; a tighter tolerance needs a Float64 state.

influence=:optimal (default) uses the analytic-differentiation optimal influence function with alias sums over |n| ≤ alias_order images of the prolate window transform, which compensates the aliasing of the truncated window. influence=:deconvolution uses the plain window deconvolution ĝ/φ̂² of the paper's equation (9). The remaining keywords match PME (alpha/ real_space_tolerance do not apply).

ParticleDynamics.Workflow.electrostatics_spec Function
julia
electrostatics_spec(force) -> Electrostatics.ElectrostaticsSpec
electrostatics_spec(force, T) -> Electrostatics.ElectrostaticsSpec

T is the precision of the state the solver is built for (default Float64); it enters only the default window shape of ESP.

Validated low-level specification of a workflow electrostatics descriptor.

ParticleDynamics.Workflow.electrostatics_from_gsd Function
julia
electrostatics_from_gsd(path; frame=nothing, step=nothing) -> ElectrostaticsForce or nothing

Read the solver settings and exceptions stored in a GSD frame written while electrostatics was attached, and return the matching descriptor (nothing if the frame carries no electrostatics record). frame is a strict 1-based frame index (-1 or nothing = last); step selects by configuration/step.

ParticleDynamics.Workflow.tune_electrostatics Function
julia
tune_electrostatics(st, force; target, reference_tolerance=target/1000,
                    max_mesh=512, spacings=nothing) -> NamedTuple

Choose the cheapest accuracy setting of force that meets a measured relative RMS force error target on the charges and coordinates of st (a state whose neighbor list covers force.real_cutoff).

With objective=:time the search is over every knob that keeps the real-space cutoff, and the fastest complete force evaluation of st (its own vdW term and nonbonded backend included) that meets target wins:

  • PME and PPPM: assignment order (orders, default 4–6 for PME and 5–7 for PPPM), the Ewald α through the real-space tail (real_space_tolerances, default target × (0.01, 0.03, 0.1, 0.3)) and the coarsest passing mesh spacing for each pair;

  • ESP: the tolerance ε and the window width (default width and one point narrower or wider, within the shape's bound).

The error is measured on the Coulomb forces through the state's force path (forces without electrostatics are subtracted), against an ESP reference at reference_tolerance (Float64 states) or an order-6 PME on a grid of spacing r_c/14 (Float32 states, ~5e-6 accurate). The state's solver is restored afterwards. Returns (force, error, time_ms, mesh, candidates), wherecandidates lists every passing setting with its error and time.

The reference is an ESP solve at the same cutoff with prolate tolerance reference_tolerance; ESP converges at fixed cutoff, so it reuses the state's neighbor list. For PME and PPPM the mesh spacing is refined (cutoff, alpha/real_space_tolerance and order are kept). For ESP the tolerance ε is tightened with the paper's rules for shape, width and spacing; refining an ESP mesh alone saturates near ε.

Returns (force, error, time_ms, mesh, reference_error_bound). force is an explicit descriptor (fixed mesh, no hidden retuning), error the measured error against the reference, time_ms the median force-call time and reference_error_bound the reference's own measured change when ε is halved. Electrostatic exceptions are not included in the comparison (they are identical for every candidate).

ParticleDynamics.Workflow.tune_pme_parameters Function
julia
tune_pme_parameters(box, N, charges;
                    rc_candidates=(0.75, 0.85, 0.90, 1.00, 1.10, 1.20),
                    tol=5e-4, order=nothing, method=:c2_esp, dispersion=false,
                    coulomb_prefactor=1.0, relative_permittivity=1.0,
                    precision=Float32, max_mesh=512,
                    state=nothing, benchmark_reps=7) -> NamedTuple

Jointly optimize (rc, alpha/split_shape, mesh) across rc_candidates for long-range electrostatics (method ∈ (:c2_esp, :esp, :pme, :pppm)) and optional co-gridded 1/r⁶ lattice dispersion (dispersion=true), guaranteeing analytical relative RMS force error <= tol across arbitrary orthorhombic box dimensions, unit systems, and particle densities.

In analytical mode (state === nothing, pure CPU, zero GPU calls), candidates are ranked by a hardware-general operation-count cost model balancing Newton-3 direct-space pair work against SMEM spread/gather and 3D FFT work (accounting for the algorithmic CompactFFT boundary). When a charged 3D SimulationState is supplied via state=... on a CUDA-capable device, each passing candidate is timed directly via CUDA.@elapsed (restoring state afterwards) and the fastest measured configuration wins.

Returns a NamedTuple with fields (method, rc, order, mesh, mesh_spacing, alpha, split_shape, window_shape, estimated_error, direct_error, reciprocal_error, estimated_cost, time_ms, force, dispersion_force, dispersion_param, candidates).

ParticleDynamics.Workflow.verlet_buffer_skin Function
julia
verlet_buffer_skin(; kT, dt, min_mass, nstlist, tol=5e-3, max_sigma=nothing,
                     ndim=3, nstprune=nothing, details=false) -> Float64

Compute the minimal safe neighbor-list Verlet buffer skin for a rebuild interval nstlist steps using the Páll & Hess (2013) Gaussian pair-displacement drift bound for target dimensionless energy-drift tolerance tol.

Fully unit-system agnostic: kT (thermal energy k_B T), min_mass (lightest mobile particle mass), dt (timestep in units consistent with sqrt(min_mass * L^2 / kT)), and optional max_sigma (characteristic particle diameter σ_max in length units L) are all supplied in the caller's unit system. Scaling lengths by λ scales the returned skin by λ identically across nm, Å, and reduced Lennard-Jones units.

The 1D radial pair-displacement standard deviation over Δt = nstlist * dt is σ_pair = sqrt(2 kT / min_mass) * Δt, and the dimensionless buffer multiplier z solves √2 C_shell(ndim) G* η I₂(z) = tol where I₂(z) = ½[(1 + z²) Φ̄(z) − z φ(z)] is the exact integrated pair-overshoot tail and η = σ_pair / max_sigma (or 1 when max_sigma === nothing).

Set details=true to return a NamedTuple (skin, prune_buffer, nstprune, sigma_pair, z_factor) including the recommended inner prune_buffer for dual-list ClusterPairList pruning.

Workflow lattice dispersion descriptors and tuning ​

ParticleDynamics.Workflow.DispersionForce Type
julia
DispersionForce

Abstract workflow descriptor of a long-range 1/r⁶ lattice-dispersion solver (DispersionESP, DispersionPME). It complements a LennardJones force: the Lennard-Jones c6 term is split into a short-range part (pair kernel) and a smooth long-range part (mesh), so the dispersion tail is included exactly at any cutoff.

ParticleDynamics.Workflow.DispersionESP Type
julia
DispersionESP(; real_cutoff, tolerance=1e-4, split_shape=nothing, window_shape=nothing,
                order=nothing, mesh=nothing, mesh_spacing=nothing, influence=:optimal, alias_order=2)

C²-continuous prolate lattice dispersion (the dispersion analogue of ESP(continuity=:c2)): the short-range part of −c6/r⁶ and its first two derivatives vanish at real_cutoff, and a C² prolate window spreads √c6ᵢ onto the mesh. real_cutoff must equal the (single) LennardJones cutoff. Geometric c6 tables are split exactly; non-geometric (Lorentz–Berthelot) tables put √c6ᵢᵢ √c6ⱼⱼ on the mesh and keep the residual −(c6ᵢⱼ − √c6ᵢᵢ √c6ⱼⱼ)/r⁶ in real space, C²-switched to zero between lb_switch_fraction·real_cutoff and real_cutoff. Bonded (LJ-excluded) pairs are removed from the mesh too.

The default mesh spacing is π r_c / u_disp with u_disp = u₀/0.78 (u₀ the 1D bandlimit of the split's prolate): Φ̂₆(k) lacks the 1/k² damping of Coulomb, so its mainlobe must sit well inside the window's alias-free band.

ParticleDynamics.Workflow.DispersionPME Type
julia
DispersionPME(; real_cutoff, beta=nothing, real_space_tolerance=1e-4, mesh=nothing,
                mesh_spacing=nothing, order=5, scaled_pairs=())

Gaussian (Essmann / Wennberg, GROMACS LJ-PME-style) lattice dispersion with B-spline assignment, for cross-checks: e^{−β²r²}(1 + β²r² + β⁴r⁴/2)/r⁶ in real space.

ParticleDynamics.Workflow.dispersion_spec Function
julia
dispersion_spec(force, T=Float64) -> Electrostatics.DispersionSpec
ParticleDynamics.Workflow.dispersion_from_gsd Function
julia
dispersion_from_gsd(path; frame=nothing, step=nothing) -> DispersionForce or nothing

Descriptor of the lattice-dispersion solver (and any log/dispersion/exceptions) recorded in a GSD frame (nothing if the frame carries no dispersion record). frame is a strict 1-based frame index (-1 or nothing = last); step selects by configuration/step.

ParticleDynamics.Workflow.tune_dispersion Function
julia
tune_dispersion(st, force::DispersionESP; target, reference_tolerance=max(target / 1000, 1e-8))
    -> (force, mesh, relative_force_error)

Measure the relative RMS force error of force on st against a tight DispersionESP reference at the same cutoff, and return a DispersionESP descriptor whose measured error is at or below target (using the coarsest mesh that meets target). Restores st's previous dispersion state before returning.

Reciprocal-space multiple time stepping (RESPA) ​

Symplectic BAOAB-RESPA / r-RESPA evaluates the long-range reciprocal mesh (electrostatics and optional lattice dispersion) every mts_mesh_interval inner steps with exact outer impulse scaling and automated resonance checking.

ParticleDynamics.Workflow.RespaStabilityReport Type
julia
RespaStabilityReport

Diagnostic report returned by check_respa_stability assessing the linear stability and parametric-resonance safety of reciprocal-space multiple time stepping (mts_mesh_interval = M).

Fields

  • safe::Bool: true when the outer timestep lies within the validated stability window for the selected integrator, constraints, and cutoff.

  • mts_interval::Int: reciprocal-space evaluation interval M >= 1.

  • inner_dt::Float64: fast-force inner timestep dt (in caller's time_unit).

  • outer_dt::Float64: slow-force outer timestep M * dt (in caller's time_unit).

  • fastest_period::Float64: estimated shortest physical oscillation period T_min of unconstrained degrees of freedom (in caller's time_unit).

  • nyquist_limit::Float64: Nyquist barrier T_min / 2 (in caller's time_unit).

  • regime::Symbol: one of :single_timestep, :safe_gold_standard, :safe_damped_baoab, :caution_stiff_recip, or :unsafe_resonance.

  • warnings::Vector{String}: non-empty list of physical warnings and caveats.

  • recommendation::String: actionable guidance for production settings.

ParticleDynamics.Workflow.check_respa_stability Function
julia
check_respa_stability(; dt, mts_mesh_interval=2, real_cutoff=0.9, integrator=:baoab,
                        hydrogen_constrained=true, hmr_mass=1.0, dispersion=false,
                        time_unit=:ps) -> RespaStabilityReport

Evaluate the resonance and linear stability safety of reciprocal-space multiple time stepping (BAOAB-RESPA / r-RESPA) where the reciprocal mesh (Coulomb and optional lattice dispersion) is evaluated every mts_mesh_interval steps with outer timestep outer_dt = mts_mesh_interval * dt.

Keywords

  • dt::Real: inner (fast-force) timestep in time_unit.

  • mts_mesh_interval::Integer=2: reciprocal-space evaluation cadence M >= 1.

  • real_cutoff::Real=0.9: direct-space real cutoff (nm for :ps/:fs, σ for :reduced).

  • integrator::Symbol=:baoab: one of :baoab, :gsm, :nve, :csvr, :nhc.

  • hydrogen_constrained::Bool=true: whether X-H bonds / rigid water are constrained.

  • hmr_mass::Real=1.0: hydrogen mass factor (1.0 standard, 3.0-4.0 for HMR).

  • dispersion::Bool=false: true when long-range 1/r⁶ lattice dispersion (LJPME/DispersionESP) is active.

  • time_unit::Symbol=:ps: unit of dt (:ps, :fs, or :reduced).

Stability Regimes

  • :safe_gold_standard: e.g. 2 fs / 4 fs (M = 2) for NVE, CSVR, NHC, or BAOAB with H-constraints.

  • :safe_damped_baoab: e.g. 4 fs / 8 fs (M = 2) with HMR and Langevin-damped :baoab at real_cutoff >= 0.85 nm.

  • :caution_stiff_recip: usable but close to reciprocal force stiffening bounds (short cutoffs).

  • :unsafe_resonance: outer timestep excites parametric impulse resonance (e.g. > 5.0 fs for NVE/CSVR, > 8.5 fs for BAOAB, > 6.5 fs for short-cutoff LJPME with real_cutoff < 0.80 nm, or > 2.5 fs for unconstrained H in NVE).

ParticleDynamics.Workflow.respa_engine_config Function
julia
respa_engine_config(; mts_mesh_interval=2, dt, strict=true,
                      real_cutoff=0.9, integrator=:baoab,
                      hydrogen_constrained=true, hmr_mass=1.0,
                      dispersion=false, time_unit=:ps,
                      base=DeviceEngine.engine_config(), kwargs...) -> DeviceEngine.EngineConfig

Validate reciprocal-space multiple time stepping via check_respa_stability and return a DeviceEngine.EngineConfig with mts_mesh_interval enabled.

When strict=true (default) and report.safe == false, throws an ArgumentError explaining the resonance violation and recommended safe parameters. Additional EngineConfig keyword overrides (such as max_batch_steps or mesh_priority) are forwarded via kwargs....

Low-level electrostatics and dispersion coupling ​

ParticleDynamics.SimulationCore.attach_electrostatics! Function
julia
attach_electrostatics!(st, spec::Electrostatics.ElectrostaticsSpec;
                       charges=nothing, exceptions=()) -> st

Attach a long-range Coulomb solver to a 3D state. charges (build-time particle order, caller's charge unit) replace st.charge; when omitted the state must already carry charges. exceptions lists (i, j, scale) triples in build-time ids: the pair's home-image interaction C qᵢqⱼ/r is scaled by scale (0 excludes it) while periodic images keep the full interaction.

Setup validates the box (real_cutoff below half the shortest box length, orthorhombic 3D), plans cuFFT transforms and computes the influence function. The state moves to the cluster-pair backend (charged systems), which keeps its storage order unsorted.

julia
attach_electrostatics!(st, force::ElectrostaticsForce; charges=nothing, exceptions=())

Low-level convenience: attach the solver described by a workflow descriptor to an existing state.

ParticleDynamics.SimulationCore.detach_electrostatics! Function
julia
detach_electrostatics!(st) -> st

Remove the long-range solver (charges stay stored) and clear the global virial contribution.

ParticleDynamics.SimulationCore.set_charges! Function
julia
set_charges!(st, q) -> st

Replace the per-particle charges (q in build-time particle order). With an attached solver the net-charge policy is re-checked and the background term refreshed. Forces are invalidated.

ParticleDynamics.SimulationCore.charges Function
julia
charges(st) -> Vector or nothing

Host copy of the charges in build-time particle order.

ParticleDynamics.SimulationCore.electrostatic_energy Function
julia
electrostatic_energy(st) -> NamedTuple

Diagnostic breakdown of the electrostatic energy at the current coordinates: real (real-space pairs plus exception corrections), self, reciprocal (mesh), background and total, plus the reciprocal virial tensor reciprocal_virial (xx, yy, zz, xy, xz, yz). Uses scratch buffers; the state's force and energy buffers are untouched. Not for the hot path.

ParticleDynamics.SimulationCore.attach_dispersion! Function
julia
attach_dispersion!(st, spec::Electrostatics.DispersionSpec) -> st

Attach a long-range 1/r⁶ lattice-dispersion solver to a 3D Lennard-Jones state. The mesh carries −√c6ᵢ √c6ⱼ Φ₆(r) for every periodic pair (including the mandatory k = 0 term in the energy and the diagonal virial); the cluster-pair kernel carries −c6 (1/r⁶ − Φ₆) inside the cutoff. The Lennard-Jones cutoff must equal spec.real_cutoff, and the c6 coefficients must mix geometrically. LJ-excluded (bonded) pairs are removed from the mesh as well. The state moves to the cluster-pair backend.

ParticleDynamics.SimulationCore.detach_dispersion! Function
julia
detach_dispersion!(st) -> st
ParticleDynamics.SimulationCore.dispersion_energy Function
julia
dispersion_energy(st) -> NamedTuple

Diagnostic mesh, self and k = 0 parts of the lattice-dispersion energy (host read, scratch buffers; not for the hot path).

Electrostatics module and spectral primitives ​

ParticleDynamics.Electrostatics Module

Native GPU long-range electrostatics.

Electrostatics implements particle-mesh Coulomb solvers that share one mesh engine: smooth particle-mesh Ewald (SPME, analytic differentiation), P3M with optimal influence functions (AD or ik differentiation), and Ewald summation with prolates (ESP, Liang et al. 2026). The radial split, the assignment window and the influence function are separate policy types, but only the validated combinations listed in ElectrostaticsSpec can be built.

Production force evaluation runs entirely on the GPU: Julia CUDA kernels for real space, exceptions, spreading, the spectral solve and gathering, plus cuFFT R2C/C2R transforms with preallocated plans. Host code only validates input, generates coefficients (prolate functions, window corrections) and plans transforms at setup. The convention sheet (units, normalisation, signs) is in the electrostatics manual page.

ParticleDynamics.Electrostatics.ElectrostaticsSpec Type
julia
ElectrostaticsSpec

Validated, host-side description of a long-range Coulomb solver. Built by the workflow descriptors PME, PPPM and ESP; only the combinations those constructors produce are supported:

influencesplitwindowdifferentiation
:spmeGaussianB-splineanalytic
:p3m_adGaussianB-splineanalytic, optimal AD influence
:p3m_ikGaussianB-splineik (three field transforms)
:espprolateprolateanalytic, optimal AD influence (alias sums)
:esp_deconvolutionprolateprolateanalytic, plain window deconvolution

Fields: coulomb_prefactor, relative_permittivity (C = prefactor/εᵣ), real_cutoff, split, window, mesh ((K₁,K₂,K₃)) or mesh_spacing, influence, alias_order (P3M alias sums), net_charge (:error or :background), boundary (:tin_foil), and real_space_modifier: :none (unshifted), or :potential_shift, which subtracts the short-range pair energy at the cutoff from every non-excluded pair inside it (energy only, forces unchanged; the GROMACS Potential-shift convention). Prolate splits vanish at the cutoff, so the shift is zero for ESP.

ParticleDynamics.Electrostatics.ElectrostaticsSolver Type
julia
ElectrostaticsSolver{T}

Concretely typed solver attached to a SimulationState (st.electrostatics). It holds no references to particle arrays: positions, charges, forces and energy buffers are passed on every call, so force-slot swaps, midpoint evaluations and spatial reordering are safe.

ParticleDynamics.Electrostatics.DispersionSpec Type
julia
DispersionSpec

Validated host-side description of a long-range 1/r⁶ lattice dispersion solver (DispersionPME or DispersionESP). Uses analytic differentiation (1 forward and 1 inverse FFT per evaluation) and includes the mandatory k = 0 mode in both energy and diagonal global virial.

ParticleDynamics.Electrostatics.GaussianSplit Type
julia
GaussianSplit(alpha)

Conventional Ewald split erfc(αr)/r + erf(αr)/r with alpha in inverse length units.

ParticleDynamics.Electrostatics.ProlateSplit Type
julia
ProlateSplit(cutoff, shape)

Ewald split with prolates (ESP): χ(x) ∝ ψ₀ᶜ(x) on [0, 1] with bandlimit c = shape, zero beyond x = 1, so the short-range part vanishes exactly at r = cutoff. Device evaluation uses a Chebyshev interpolant of E_s(t) and the exact derivative of that same polynomial for forces.

ParticleDynamics.Electrostatics.C2ProlateSplit Type
julia
C2ProlateSplit(cutoff, shape)

C²-continuous prolate Ewald split built from Slepian's generalized prolate Φ₂ᶜ(x) = (1 − x²)² φ(x) on [0, 1] (χ(1) = χ'(1) = 0), so the short-range potential, force, and second derivative all vanish identically at r = cutoff: V_s(r_c) = V_s'(r_c) = V_s''(r_c) = 0.

ParticleDynamics.Electrostatics.FewestPSWFC2Split Type
julia
FewestPSWFC2Split(cutoff, shape; nquad=128)

Optimal C²-continuous prolate Ewald split built from the fewest even PSWFs span{ψ₀ᶜ, ψ₂ᶜ, ψ₄ᶜ} (w(1) = w'(1) = 0, Theorem 3.3 of Jiang, Liang & Lu, arXiv:2611.23737). Achieves exact V_s(r_c) = V_s'(r_c) = V_s''(r_c) = 0 with a ~14–16% narrower spectral bandlimit than the Jacobi-weighted Φ₂ᶜ split.

ParticleDynamics.Electrostatics.GaussianDispersionSplit Type
julia
GaussianDispersionSplit(beta)

Essmann / Wennberg Gaussian 1/r⁶ split (beta in inverse length units): V_{6,s}(r) = e^{−β²r²}(1 + β²r² + ½ β⁴r⁴) / r⁶, Φ₆(0) = β⁶ / 6.

ParticleDynamics.Electrostatics.C2ProlateDispersionSplit Type
julia
C2ProlateDispersionSplit(cutoff, shape)

C²-continuous compactly supported 1/r⁶ split built from Φ₂ᶜ(x) on [0, 1]: A₆(t) = ∫₀ᵗ x⁵ Φ₂ᶜ(x) dx / m₅, V_{6,s}(r) = (1 − A₆(r/r_c)) / r⁶. Satisfies V_{6,s}(r_c) = V_{6,s}'(r_c) = V_{6,s}''(r_c) = 0 identically, while Φ₆(r) = A₆(r/r_c) / r⁶ is even analytic in r² at r = 0.

ParticleDynamics.Electrostatics.FewestPSWFC2DispersionSplit Type
julia
FewestPSWFC2DispersionSplit(cutoff, shape; nquad=128)

Optimal 4-PSWF C²-continuous 1/r⁶ dispersion split (Jiang, Liang & Lu, arXiv:2611.23737 §3.3): w ∈ span{ψ₀ᶜ, ψ₂ᶜ, ψ₄ᶜ, ψ₆ᶜ} with R₆(1) = R₆'(1) = R₆''(1) = 0, L₆(r) = R₆(r/r_c)/r⁶, and exact cancellation-free smooth part Φ₆(r) = s₆(r/r_c)/r_c⁶.

ParticleDynamics.Electrostatics.BSplineWindow Type
julia
BSplineWindow(order)

Cardinal B-spline M_P (Essmann et al. 1995) of order P = stencil width; order 4 is cubic interpolation. Node k receives M_P(u − k), so the support is floor(u) − P + 1 … floor(u).

ParticleDynamics.Electrostatics.ProlateWindow Type
julia
ProlateWindow(order, shape)

Prolate assignment window of ESP: W(x) = ψ₀ᶜ(2x/P) − ψ₀ᶜ(1) for |x| ≤ P/2 grid spacings (c = shape), centred on the particle. The constant edge = ψ₀ᶜ(1) makes the weights vanish at the edge of the support, so the mesh energy is continuous when a particle moves from one cell to the next; the window transform, the influence function and the deconvolution all use the same shifted window. Device evaluation uses one polynomial per stencil node and its exact derivative (ProlatePolyStencil); the Chebyshev interpolant of the shifted ψ stored here is the reference evaluation.

ParticleDynamics.Electrostatics.C2ProlateWindow Type
julia
C2ProlateWindow(order, shape)

C²-continuous assignment window of width order grid points.

For order ≠ 4, built from Slepian's generalized prolate Φ₃ᶜ(y) = (1 − y²)³ φ(y) (W(x) = Φ₃ᶜ(2x/P) on |x| ≤ P/2). Because Φ₃ᶜ(±1) = (Φ₃ᶜ)'(±1) = (Φ₃ᶜ)''(±1) = 0 identically (edge = 0), mesh energies, analytic-differentiation mesh forces (dW/du), and force derivatives (d²W/du²) are all continuous across every grid plane.

For order == 4 (4³ = 64-point stencil), built as the symmetric degree-7 C²(ℝ) piecewise-polynomial partition-of-unity window (Σ_k W(x − k) ≡ 1, vanishing through the second derivative at |x| = 2) that minimizes spectral-weighted analytic-differentiation aliasing for split bandwidth shape. Its exact node monomials are used directly by ProlatePolyStencil{4,T,8,2} in both Float32 and Float64.

ParticleDynamics.Electrostatics.B2ProlateWindow Type
julia
B2ProlateWindow(order, tolerance)

Charge- and dipole-conserving C²(ℝ) prolate spreading/interpolation window φ*_P = B₂ * g of width order ∈ 4..10 grid points for target relative force tolerance tolerance (Jiang, Liang & Lu, arXiv:2611.23737 §4.5).

ParticleDynamics.Electrostatics.ProlateFunction Type
julia
ProlateFunction(c)

Order-zero prolate spheroidal wave function ψ₀ᶜ with bandlimit c, normalised so that ψ(0) = 1. Stored as coefficients of the even Legendre polynomials P_0, P_2, P_4, ….

ParticleDynamics.Electrostatics.GeneralizedProlateFunction Type
julia
GeneralizedProlateFunction(c, alpha)

Jacobi-weighted generalized prolate spheroidal wave function Φ_α^c(x) on [-1, 1] with boundary vanishing order alpha ≥ 0, normalised so Φ_α^c(0) = 1.

ParticleDynamics.Electrostatics.prolate_shape_for_tolerance Function
julia
prolate_shape_for_tolerance(ε) -> c

Bandlimit c with ψ₀ᶜ(1) = ε for the L²-normalised (‖ψ₀ᶜ‖ = 1 on [-1, 1]) prolate function: the selection rule of Liang et al. (2026), eq. (15), used for both the splitting kernel and the assignment window. It reproduces the c values of the paper's Table 2 (e.g. ε = 1e-4 → c ≈ 12.024).

ParticleDynamics.Electrostatics.generalized_prolate_shape_for_tolerance Function
julia
generalized_prolate_shape_for_tolerance(ε, alpha) -> c

Shape c of GeneralizedProlateFunction(c, alpha) whose spectral sidelobe bound matches the ESP calibration (max_sidelobe = 0.30 ε, reproducing Table 2 of Liang et al. 2026 within 0.5% at alpha = 0 while extending cleanly to alpha = 2, 3).

ParticleDynamics.Electrostatics.fewest_pswf_c2_coulomb_shape Function
julia
fewest_pswf_c2_coulomb_shape(ε) -> c_s

Bandlimit c_s for the 3-PSWF C² Coulomb split meeting relative force truncation error ≤ ε: matches c2_bandwidth(ε) of Jiang, Liang & Lu (arXiv:2611.23737) — prolate_shape_for_tolerance(ε), raised slightly only where the 3-PSWF truncation error exceeds ε (e.g. 1e-3 → 9.50, 1e-4 → 12.02, 1e-5 → 14.52).

ParticleDynamics.Electrostatics.fewest_pswf_c2_dispersion_shape Function
julia
fewest_pswf_c2_dispersion_shape(ε) -> c_s

Bandlimit c_s for the 4-PSWF C² 1/r⁶ dispersion split calibrated directly to true ν = 6 relative force truncation error ≤ ε (e.g. 1e-4 → ≈ 14.3, 1e-5 → ≈ 16.8).

ParticleDynamics.Electrostatics.dispersion_beta_from_tolerance Function
julia
dispersion_beta_from_tolerance(cutoff, tol) -> β

Gaussian dispersion parameter solving e^{−β²r_c²}(1 + β²r_c² + ½ β⁴r_c⁴) = tol.

Nonbonded backends, modifiers and exceptions ​

3D states choose between :ell (slot-major ELL per-particle neighbor rows) and :cluster (fused Newton-3 8×8 cluster tiles via ClusterPairs). Attaching electrostatics switches a state to :cluster automatically.

ParticleDynamics.SimulationCore.set_nonbonded_backend! Function
julia
set_nonbonded_backend!(st, backend; prune_buffer=nothing, skin=nothing, list_intervals=nothing) -> st

Select the short-range nonbonded traversal of a 3D state.

  • :ell (default): per-particle neighbor rows; the vdW kernel and the real-space Coulomb kernel each traverse them.

  • :cluster: the fused cluster-pair engine (ClusterPairs) evaluates Lennard-Jones and the real-space Coulomb term (exclusions and scaled pairs included) in one kernel over a Newton-3 cluster-pair list; the mesh part of an attached electrostatics solver is unchanged. Supported vdW terms: none, uniform LJ and pair-table LJ, with bond exclusions of the LJ term. The dense neighbor list is released while the backend is active.

The cluster list radius is max(vdW cutoff, real_cutoff) + skin (the skin of the dense list the state was built with). Between rebuilds the list is pruned to the interaction cutoff plus prune_buffer (default skin/2) and re-pruned when a particle has moved more than half of it; prune_buffer=0 gives an exact list for fixed coordinates. skin replaces the list skin.

list_intervals=(nstlist, nstprune) (opt-in) replaces the displacement triggers by fixed intervals, as GROMACS's dual pair list with a Verlet buffer: the list is rebuilt every nstlist and pruned every nstprune steps (0: only at rebuilds). Exactness then rests on the buffers being large enough for the motion over those intervals (GROMACS sizes them from verlet-buffer-tolerance); a pair can enter the cutoff unseen when they are not.

ParticleDynamics.SimulationCore.nonbonded_backend Function
julia
nonbonded_backend(st) -> Symbol

The short-range traversal of st: :ell or :cluster.

ParticleDynamics.SimulationCore.set_vdw_modifier! Function
julia
set_vdw_modifier!(st, modifier; switch_distance=nothing) -> st

Lennard-Jones convention at the cutoff (GROMACS vdw-modifier):

  • :none: truncates pair energy and force at r_c;

  • :potential_shift: uses u(r) − u(r_c) for every pair inside r_c (forces unchanged);

  • :force_switch: Steinbach–Brooks / GROMACS C² force switch between switch_distance and r_c;

  • :potential_switch: quintic Hermite C² potential taper between switch_distance and r_c.

Only Lennard-Jones states (nonbonded=:lj) take non-:none modifiers.

ParticleDynamics.SimulationCore.vdw_modifier Function
julia
vdw_modifier(st) -> Symbol

Current Lennard-Jones cutoff modifier (:none, :potential_shift, :force_switch, or :potential_switch).

ParticleDynamics.SimulationCore.set_force_accumulation! Function
julia
set_force_accumulation!(st, mode) -> st

Set the slot force accumulation mode of the :cluster nonbonded backend:

  • :float32 (default): native floating-point relaxed atomics;

  • :fixed64 / :auto: deterministic 64-bit integer fixed-point accumulation on Float32 states (2⁻³⁰ resolution, clamped at ±2⁶⁰ per atomic add; bitwise reproducible across launches).

ParticleDynamics.SimulationCore.force_accumulation Function
julia
force_accumulation(st) -> Symbol

Current cluster-pair slot force accumulation mode (:float32, :fixed64, or :auto).

ParticleDynamics.SimulationCore.set_lj_exceptions! Function
julia
set_lj_exceptions!(st, exceptions) -> st

Set per-pair Lennard-Jones scaling exceptions on a 3D state. Each entry is (i, j) (full exclusion, scale 0.0) or (i, j, lj_scale) in build-time particle ids (0 ≤ lj_scale; entries with lj_scale == 1 are dropped). When non-empty, switches the state to the :cluster nonbonded backend.

ParticleDynamics.SimulationCore.lj_exceptions Function
julia
lj_exceptions(st) -> Vector{Tuple{Int32,Int32,Float64}}

Copy of the state's per-pair Lennard-Jones scaling exceptions (i, j, lj_scale) in build-time particle ids.

ClusterPairs module ​

ParticleDynamics.ClusterPairs Module

Cluster-pair GPU nonbonded engine.

ClusterPairs evaluates the short-range nonbonded forces (Lennard-Jones and the real-space part of a Coulomb split) in one fused kernel over a cluster-pair list:

  • particles are grouped into spatially compact clusters of 8 and super-clusters of 64;

  • the list stores, per super-cluster, the j-clusters within the list radius with one 8-bit interaction mask per j-cluster half (a warp), so each interacting pair appears once (Newton's third law);

  • a thread block of 64 threads evaluates an 8×8 tile per i-cluster and j-cluster, keeps the i-atoms in shared memory, and reduces j-forces with warp shuffles;

  • excluded and scaled pairs are bit masks in the tile, so the kernel computes their correction directly instead of in a separate pass;

  • the Coulomb term is C qᵢqⱼ (1/r + P(r²)) with a polynomial P fitted to the split (Ewald, prolate) or exact (reaction field), so no erfc/exp is evaluated per pair.

The pair physics (ClusterPairs.pair_force) is one device function shared by every kernel variant.

ParticleDynamics.ClusterPairs.ClusterPairEngine Type
julia
ClusterPairEngine

Cluster-pair nonbonded engine for one 3D state: the list, the LJ description (kind, type table or per-type separable factors) and the Coulomb polynomial. The list is rebuilt when a particle moved more than half the skin since the build and re-pruned when it moved more than half the prune buffer since the last prune. rmax is the largest interaction cutoff; the list radius is rmax + skin and the prune radius rmax + prune_buffer.

ParticleDynamics.ClusterPairs.CoulombPolynomial Type
julia
CoulombPolynomial{T,NE,NF}

Device description of the short-range Coulomb kernel: prefactor C, cutoff rc2, energy shift eshift, whether a mesh carries the full 1/r (has_mesh), and monomial coefficients of the energy and force polynomials.

ParticleDynamics.ClusterPairs.DispersionPolynomial Type
julia
DispersionPolynomial{T,NE,NF,MONO}

Device description of the smooth long-range part Φ₆(r) of a 1/r⁶ lattice-dispersion split (Electrostatics.AbstractDispersionSplit) inside its cutoff: energy polynomial pe ≈ Φ₆ and force polynomial pf ≈ −(1/r) dΦ₆/dr, both in x = r²·sx − 1 ∈ [−1, 1]. The pair kernel then evaluates −c6 (1/r⁶ − Φ₆) inside r_c (C² to zero at r_c for the prolate split), while the mesh carries −s6ᵢ s6ⱼ Φ₆ for every periodic pair. active=false is the inert placeholder.

ParticleDynamics.ClusterPairs.coulomb_polynomial Function
julia
coulomb_polynomial(split, C; T=Float32, cutoff=nothing, eshift=0, tol=nothing, energy_tol=nothing)

Fit the long-range correction of an Ewald or prolate split on [0, cutoff²] (the split's own cutoff for prolates). Tolerances are relative to the largest value of each function. The Float32 force polynomial uses tolerance-aware fitting clamp(split_tol / 500, 1e-7, 1e-6) (keeping polynomial error ≥ 500× finer than the splitting error and pair forces within ~1–2e-6), while the energy polynomial uses 1e-8; Float64 uses 1e-13 (Gaussian) and 1e-11 (prolate).

ParticleDynamics.ClusterPairs.coulomb_reaction_field Function
julia
coulomb_reaction_field(C, cutoff; eps_r=1, eps_rf=Inf, T=Float32)

Reaction-field Coulomb (eps_rf = Inf or 0 is the conducting medium) with the energy shifted to zero at the cutoff: e = C qᵢqⱼ/εᵣ (1/r + k r² − c), k = (ε_rf − εᵣ)/((2ε_rf + εᵣ) r_c³), c = 1/r_c + k r_c².

ParticleDynamics.ClusterPairs.dispersion_polynomial Function
julia
dispersion_polynomial(split; T=Float32, cutoff=nothing, lb_switch_fraction=0.85, tol=nothing, energy_tol=nothing)

Fit Φ₆ and −(1/r)dΦ₆/dr of a dispersion split on [0, r_c²] (relative tolerances as coulomb_polynomial: tolerance-aware clamp(split_tol / 500, 1e-7, 1e-6) for forces and 1e-8 for energies in Float32, 1e-11 in Float64). Non-geometric (Lorentz–Berthelot) residual −(c6 − s6ᵢs6ⱼ)/r⁶ is C²-switched to zero on [r_sw, r_c].

NeighborLists module ​

Dense and stencil neighbor lists use slot-major ELL storage: zero-based neighbor slot t for one-based particle i is stored at t * N + i. cap is a hard per-row capacity; overflow raises ParticleDynamics.NeighborLists.NeighborCapacityError (reporting required_capacity) and marks the list invalid instead of silently dropping neighbors.

ParticleDynamics.NeighborLists Module

Neighbor list builders and query utilities used by the force kernels.

NeighborLists implements three strategies:

Dense and stencil lists use slot-major ELL storage: slot t (zero based) of particle i (one based) is at t*N + i in neighbors_flat. Bond adjacency is a separate CSR structure. The all-pairs sentinel stores no neighbor rows.

ParticleDynamics.NeighborLists.AbstractNeighborMatrix Type
julia
AbstractNeighborMatrix

Common supertype for neighbor containers. Cell-list containers provide:

  • neighbors_flat, counts: slot-major ELL rows addressed by _ell_index.

  • neighbors_index: legacy compatibility field, NOT ELL row offsets.

  • cap: maximum number of stored neighbors per particle (sets memory layout).

  • skin: additional radial buffer used by update_needed! to delay rebuilds.

  • N, D: particle count and dimensionality.

The all-pairs sentinel has no stored rows. valid becomes true only after a successful capacity-checked build. required_capacity records the largest required row, including neighbors that could not fit in a failed build.

ParticleDynamics.NeighborLists.NeighborMatrix Type
julia
NeighborMatrix{T}

Dense neighbor matrix that bins particles into a regular grid (nx×ny×nz) with cell size cutoff + skin. Suitable for uniform-cutoff Lennard-Jones/WCA simulations and the regression tests. The ELL arrays (neighbors_flat, counts) store particle IDs; MIC handling happens inside the force kernels.

ParticleDynamics.NeighborLists.StencilNeighborMatrix Type
julia
StencilNeighborMatrix{T}

Neighbor list variant where each particle carries its own interaction radius (rlist, rlist2), for mixtures of different particle diameters. The per-particle cutoff is σ_i + skin, so the skin argument still controls rebuild latency.

ParticleDynamics.NeighborLists.AllPairsNeighborMatrix Type

AllPairsNeighborMatrix

Lightweight sentinel type indicating that all-to-all interactions should be computed (no neighbor list), using periodic MIC and excluding i==j.

Fields are kept minimal but include skin so existing calls that read st.nbh.skin continue to work without changes. Useful for validating a force path without a cell list.

ParticleDynamics.NeighborLists.NeighborCapacityError Type

A neighbor build required more entries per particle than its fixed cap.

ParticleDynamics.NeighborLists.build_neighbors_dense! Function
julia
build_neighbors_dense!(rx, ry[, rz]; box, cutoff, cap, skin)

Construct a NeighborMatrix with uniform cutoff cutoff and displacement buffer skin. The default path taken by build_simulation (e.g. cutoff = 2^(1/6)σ, skin = cutoff/2 for WCA).

Arguments

  • rx, ry[, rz]: Position components in [-L/2, L/2).

  • box: (Lx, Ly[, Lz]) periodic extents.

  • cutoff: Interaction cutoff; must be consistent with the potential (WCA or LJ).

  • cap: Maximum stored neighbors per particle (e.g. Int32(250) in the WCA example).

  • skin: Additional tolerance that delays rebuilds until particles move by ≈ skin/2. Typical values are 0.3–0.5 σ.

ParticleDynamics.NeighborLists.build_neighbors_stencil! Function
julia
build_neighbors_stencil!(rx, ry[, rz]; box, rcut_particle, cap, skin)

Stencil neighbor list where each particle i owns a cutoff rcut_particle[i]. Use it to mix, e.g., σ=5 and σ=1 particles by passing per-type cutoffs computed from the Lorentz mixing rule.

ParticleDynamics.NeighborLists.build_neighbors_stencil_by_types! Function
julia
build_neighbors_stencil_by_types!(rx, ry[, rz]; box, typeid, rcut_pair, cap, skin)

Variant of build_neighbors_stencil! where the per-particle cutoff is derived from a type–type lookup table rcut_pair (e.g. a 2×2 matrix for two particle sizes).

ParticleDynamics.NeighborLists.update_needed! Function
julia
update_needed!(nbh, rx, ry[, rz]; skin, Lx, Ly[, Lz], step)

Check whether the maximum displacement since the last rebuild exceeds skin/2, or whether the adaptive rebuild interval (target_interval) has elapsed. Simulation force evaluation checks the actual force-time coordinates, including temporary midpoint positions. The step-boundary maintenance check is also controlled by neigh_interval; it cannot disable force-time safety checks.

ParticleDynamics.NeighborLists.update_neighbors_inplace! Function
julia
update_neighbors_inplace!(nbh, rx, ry[, rz]; box, step=0)

Re-bin particles into cells, rebuild the ELL neighbor rows, and record the reference coordinates used by update_needed!. Called by step! whenever the accumulated displacement exceeds skin/2 or when the user forces an update (e.g. after randomizing the configuration).

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