Tutorial T04: Rigid Water Benchmark (SPC/E vs. TIP3P)
This tutorial evaluates the ParticleDynamics v1.2.0 biomolecular and aqueous Workflow stack in GROMACS units (Float32 with deterministic fixed-point force accumulation (force_accumulation=:fixed64) against the rigid-water benchmarks of Berendsen, Grigera & Straatsma (1987), Jorgensen et al. (1983), Reddy & Berkowitz (1989), and Vega & Abascal (2011):
Thermodynamics, Dispersion-Tail Accounting & GPU Barostat Parity: Isobaric–isothermal (
NPT, , , ) comparison of SPC/E and TIP3P bulk density, configurational energy , and enthalpy of vaporization across both GPU-resident barostats, StochasticCellRescaling(DeviceCRescale, with aFloat64shadow box inv1.2.0) andMonteCarloBarostat(DeviceMonteCarloBarostat,scale=:molecules), showing density parity at thestatistical precision level once the Lennard-Jones cutoff is made continuous via vdw_modifier=:potential_shift, together with an explicit accounting of the/ dispersion pressure tail omitted at .Volume Fluctuations (Isothermal Compressibility): Evaluation of water's isothermal compressibility
from NPT volume fluctuations across both barostats (reported separately without pooling, exposing finite-horizon convergence requirements for MC volume fluctuations), capturing SPC/E's lower compressibility relative to TIP3P.Static Dielectric Constant & Kirkwood
: Total box dipole moment fluctuations under tin-foil Ewald boundaries over 1.28 ns, reproducing the Vega & Abascal (2011) ordering where TIP3P overestimates the dielectric constant ( vs.) while SPC/E sits below experiment ( vs. Vega & Abascal, Reddy & Berkowitz , and experimental ). Tetrahedral Structure & Rigid Geometry: Oxygen–oxygen radial distribution function
contrasting SPC/E's sharp first hydration shell and distinct tetrahedral second peak at against TIP3P's nearly flat second shell, alongside GPUSETTLE/RATTLE(settle_mode=:df64) constraint checks ( , zero NaNs across production steps).
Trajectory Visualization
tutorials/render_movies.py --targets T04).
What You Will Learn
Configuring a 3-site rigid water
ParticleSystemin GROMACS units with per-type masses, charges, and intramolecularTopologyexclusions.Combining
ClusterPairList(force_accumulation=:fixed64),PairTable, andC²-continuousESPelectrostatics (continuity=:c2,B2ProlateWindowwindowing, and shared-memoryCompactFFTup to256³), tuned automatically to a target relative RMS force error withtune_electrostatics, plus full-dispersionDispersionESP(LJPME) for cutoff-independent bulk density.Enforcing rigid water geometry on the GPU via
RigidWaterConstraint(SETTLE/RATTLE, warp-cooperative:df64precision) at with bothCSVRandBAOABFastthermostats.Running zero-sync GPU NPT dynamics with both
StochasticCellRescalingandMonteCarloBarostat(scale=:molecules, adaptive equilibration tuning followed by fixed-step production for detailed balance), monitored viaThermodynamicObservable,PressureObservable,BoxObservable,TableWriter,InMemoryWriter, andstep_many!.
Running the Tutorial
All scripts live in tutorials/T04_rigid_water_spce_tip3p/:
# Quick GPU smoke check (N_mol = 216, rc = 0.78 nm)
TUTORIAL_FAST=1 julia --project tutorials/T04_rigid_water_spce_tip3p/run.jl
TUTORIAL_FAST=1 julia --project tutorials/T04_rigid_water_spce_tip3p/analyze.jl
# Full production validation (N_mol = 1000, rc = 1.20 nm, 1.28 ns C-rescale & MC + 0.64 ns LJPME)
julia --project tutorials/T04_rigid_water_spce_tip3p/run.jl
julia --project tutorials/T04_rigid_water_spce_tip3p/analyze.jl
# Regenerate documentation figures (300 DPI)
python3 tutorials/T04_rigid_water_spce_tip3p/plot.pyPhysics Background
Rigid 3-Site Water Models & GROMACS Units
We work in standard GROMACS molecular units: length in
Both SPC/E (Berendsen et al. 1987) and TIP3P (Jorgensen et al. 1983) place a single Lennard-Jones site on oxygen (
| Model | ||||||||
|---|---|---|---|---|---|---|---|---|
| SPC/E | ||||||||
| TIP3P |
Although both models carry nearly identical monomer dipole moments (
Cutoff Continuity, Dispersion Tails & Virial–MC Parity
A subtle statistical-mechanics requirement governs parity between a virial barostat (StochasticCellRescaling) and an energy-difference barostat (MonteCarloBarostat):
Unshifted cutoff discontinuity (
vdw_modifier=:none): Truncatingabruptly at leaves a step jump from up to, corresponding to an attractive impulsive force . Because the smooth molecular virial omits this delta-function impulse whereas Monte Carlo volume moves evaluate across the discontinuity, an unshifted cutoff creates an impulsive pressure contributionso
. At , an MC barostat therefore compresses the box relative to a smooth-virial barostat by .Continuous potential shift (
vdw_modifier=:potential_shift): Shifting the short-range Lennard-Jones potential by(the GROMACS default) leaves all pair forces identical while eliminating the energy jump at . Combined withC²-ESPelectrostatics (whose real-space pair potential, force, and second derivative vanish smoothly at), the thermodynamic pressure identity holds without impulsive corrections, bringingStochasticCellRescalingandMonteCarloBarostatinto statistical agreement.Long-range dispersion tail accounting: Truncating Lennard-Jones interactions at
withvdw_modifier=:potential_shiftomits an attractive long-range dispersion pressure tail of for SPC/E andfor TIP3P. Via , omitting this tail lowers the simulated bulk density by () for SPC/E and () for TIP3P. Consequently: Extrapolating T04's truncated SPC/E density (
) to full dispersion gives , consistent with Berendsen et al. (1987) ( ), the NIST Standard Reference Simulation Website (SRSW) ( at), Tutorial T06's dual-mesh DispersionESP(LJPME) SPC/E bulk liquid core ( at, where thermal expansion across accounts for ), and Tutorial T07's truncated pure SPC/E density ( , shifted down by from its larger omitted tail).The numerical closeness of T04's uncorrected truncated SPC/E density (
) to Vega & Abascal's (2011) tail-corrected table entry ( ) is an apples-to-oranges coincidence rather than a justification for neglecting of dispersion pressure. For fresh runs, run.jlincludes a dedicatedspce_ljpme_crescalerun withDispersionESP(vdw_modifier=:none) to measure full-dispersion SPC/E density directly alongside the truncated parity matrix.For enthalpy of vaporization, the analytical energy shift + tail correction (
for SPC/E, for TIP3P) is applied to report , where Vega & Abascal (2011) list raw for SPC/E, giving after subtracting Berendsen's polarization self-energy.
Fluctuation Observables & Half-Step Configurational Accuracy
- Isothermal compressibility (
): From NPT volume fluctuations at bath temperature ,
- Static dielectric constant (
): Under conducting tin-foil Ewald boundary conditions ( boundary=:tin_foil, Neumann 1983), the total box dipole moment determines the static permittivity and Kirkwood correlation factor:
Because both analyze.jl uses 8-block leave-one-block-out jackknife estimation (eliminating short-block mean-subtraction bias while capturing temporal correlations across Debye relaxation times
Half-step vs. full-step temperature at
: For rigid water, each molecule has 6 degrees of freedom: 3 low-frequency translational modes and 3 hindered rotational librational modes at . Both half-stepCSVR(matching GROMACS leap-frogv-rescale) andBAOABFastcontrol the half-step/midpoint momentum distribution so the configurational ensemble samples . Because only 3 of the 6 rigid-water degrees of freedom are librational, the full-step velocity-Verlet kinetic temperature exhibits half the 1D harmonic shadow shift:
Workflow API Walkthrough
1. Water System, ClusterPairList(:fixed64), and tune_electrostatics for C²-ESP
tutorials/T04_rigid_water_spce_tip3p/run.jl constructs an (O, H1, H2) geometry and intramolecular Coulomb exclusions, pairs PairTable with ClusterPairList(force_accumulation=:fixed64), and calls tune_electrostatics once on the thermalized liquid to select the fastest C²-ESP + CompactFFT configuration meeting relative RMS force error
using ParticleDynamics
tbl = PairTable(
sigma=[0.316557, 0.0],
epsilon=[0.650194, 0.0],
cutoff=[1.20, 0.0],
type_names=[:O, :H],
)
lj = LennardJones(
pair_table=tbl,
pairs=:neighborlist,
vdw_modifier=:potential_shift,
neighborlist=ClusterPairList(buffer=0.12, force_accumulation=:fixed64),
)
esp_init = ESP(
coulomb_prefactor=138.93545764498226,
real_cutoff=1.20,
tolerance=5e-4,
continuity=:c2,
net_charge=:error,
boundary=:tin_foil,
)
# Automatically benchmark C²-ESP orders and CompactFFT meshes on the GPU state
tuned = tune_electrostatics(state(sim), esp_init; target=5e-4, objective=:time, orders=(4, 5))
# On N_mol = 1000, rc = 1.20 nm: mesh = (14, 14, 14), order = 4, rel_err = 1.99e-4, CompactFFT = true
esp_pinned = ESP(
coulomb_prefactor=138.93545764498226,
real_cutoff=1.20,
tolerance=tuned.force.tolerance,
order=tuned.force.order,
continuity=:c2,
mesh=tuned.mesh,
net_charge=:error,
boundary=:tin_foil,
)Pinning mesh=(14, 14, 14) preserves the 2-3-5-7 smooth shared-memory CompactFFT kernel plan throughout NPT volume fluctuations while keeping relative electrostatic force error at spce_ljpme_crescale), run.jl sets vdw_modifier=:none on LennardJones and appends DispersionESP(real_cutoff=1.20, tolerance=5e-4).
2. GPU-Resident NPT with StochasticCellRescaling and MonteCarloBarostat
Both GPU-resident barostats are executed inside CUDA-graph super-batches (step_many!) together with warp-cooperative :df64 SETTLE/RATTLE constraints (RigidWaterConstraint). Reusing the same rw_constr object across equilibration and production prepare!(sim) calls keeps the attached GPU constraint workspace alive in place:
all_grp = Group(:all, AllSelection())
rw_constr = RigidWaterConstraint(triples; oh=0.1000, hh=0.163298, settle_mode=:df64)
# Barostat 1: GPU-resident Stochastic Cell Rescaling (DeviceCRescale)
baro_cr = StochasticCellRescaling(
pressure=0.0602214076, # 1 bar in kJ/(mol·nm³)
kT=2.4789570296, # 298.15 K
compressibility=4.5e-5 / 0.0602214076,
tau=1.0, # ps
interval=10,
seed=UInt64(1401),
)
# Barostat 2: GPU-resident Molecular Monte Carlo Barostat (DeviceMonteCarloBarostat)
# Equilibrate with adaptive tuning (`tune=true`), then freeze `log_volume_step` (`tune=false`)
# during production to satisfy detailed balance:
baro_mc_eq = MonteCarloBarostat(
pressure=0.0602214076,
kT=2.4789570296,
interval=25,
log_volume_step=0.004,
scale=:molecules,
tune=true,
seed=UInt64(2402),
)
# ... run NPT equilibration via `step_many!` ...
tuned_frac = barostat_diagnostics(sim).log_volume_step
baro_mc_prod = MonteCarloBarostat(
pressure=0.0602214076,
kT=2.4789570296,
interval=25,
log_volume_step=tuned_frac,
scale=:molecules,
tune=false,
seed=UInt64(3402),
)3. Production Logging (TableWriter, InMemoryWriter, and BoxObservable)
In the recorded production dataset below (1.28 ns for C-rescale, 0.48 ns for MC parity, partitioned into 8 contiguous blocks), TableWriter streams ThermodynamicObservable, PressureObservable, and BoxObservable every 200 steps (0.4 ps), while InMemoryWriter buffers coordinates block-by-block for PBC-whole box dipole run! dispatches 199-step GPU super-batches (step_many!), sustaining 4,410–6,406 steps/s on an RTX 3090 for run.jl now sets prod_parity = 640_000 (1.28 ns, matching C-rescale).
Results & Literature Comparison
Part A: Bulk Thermodynamics, Barostat Parity & Isothermal Compressibility

Recorded production runs (:potential_shift, C²-ESP (14, 14, 14) CompactFFT, Float32 :fixed64,
Run (Model | Barostat | Thermostat) | Horizon (ns) | Throughput (steps/s) | Extrap. Full | Vega & Abascal | |||||
|---|---|---|---|---|---|---|---|---|---|
SPC/E | C-rescale | CSVR | |||||||||
SPC/E | MC (:molecules) | CSVR | |||||||||
TIP3P | C-rescale | BAOABFast | |||||||||
TIP3P | MC (:molecules) | BAOABFast | |||||||||
| Experiment (298.15 K, 1 bar) | — | — | — | — | — | — |
(
GPU Barostat Parity (StochasticCellRescaling vs MonteCarloBarostat) & Compressibility Convergence:
SPC/E (
CSVR) density & energy parity: , or (); , or (); vs . Thus density parity is confirmed at thestatistical precision level. TIP3P (
BAOABFast) density & energy parity: , or (); , or (); vs .SPC/E compressibility tension between C-rescale and short MC (
3.23σ): While TIP3P C-rescale ( ) and MC ( ) agree within( ), SPC/E C-rescale ( ) and the short0.48 nsMC run ( ) disagree by (, ). We report both separately rather than pooling incompatible estimates. Because second-moment volume fluctuations equilibrate more slowly than the mean density, and0.48 nsof MC comprises only 8 blocks of( trial moves per block, with relative uncertainty on the 8-block SEM itself), 0.48 nsis too short for converged MC compressibility.run.jlruns MC for the full1.28 nshorizon on fresh runs.Model contrast: On the matched
1.28 nsC-rescale trajectories, SPC/E is denser than TIP3P by (Vega & Abascal: ) and less compressible by (; TIP3P vs SPC/E ).
Part B: Oxygen–Oxygen Structure g_OO(r) & Static Dielectric Constant ε₀

Panel (a) reproduces the structural contrast highlighted by Vega & Abascal (2011): SPC/E forms a sharp first hydration shell at
Panel (b) tracks the cumulative dielectric constant 1.28 ns C-rescale trajectories (3,200 PBC-whole total dipole samples):
| Model | Vega & Abascal (2011) | Kirkwood | ||||||
|---|---|---|---|---|---|---|---|---|
| SPC/E | ||||||||
| TIP3P | ||||||||
| Experiment | — |
(
Comparing directly against the literature values: SPC/E (
References
H. J. C. Berendsen, J. R. Grigera, and T. P. Straatsma, "The missing term in effective pair potentials," J. Phys. Chem. 91(24), 6269–6271 (1987). DOI: 10.1021/j100308a038
W. L. Jorgensen, J. Chandrasekhar, J. D. Madura, R. W. Impey, and M. L. Klein, "Comparison of simple potential functions for simulating liquid water," J. Chem. Phys. 79(2), 926–935 (1983). DOI: 10.1063/1.445869
M. R. Reddy and M. Berkowitz, "The dielectric constant of SPC/E water," Chem. Phys. Lett. 155(2), 173–176 (1989). DOI: 10.1016/0009-2614(89)85344-8
C. Vega and J. L. F. Abascal, "Simulating water with rigid non-polarizable models: a general perspective," Phys. Chem. Chem. Phys. 13(44), 19663–19688 (2011). DOI: 10.1039/C1CP22168J
M. Neumann, "Dipole moment fluctuation formulas in computer simulations of polar systems," Molecular Physics 50(4), 841–858 (1983). DOI: 10.1080/00268978300102721
M. Bernetti and G. Bussi, "Pressure control using stochastic cell rescaling," J. Chem. Phys. 153(11), 114107 (2020). DOI: 10.1063/5.0020514
S. Miyamoto and P. A. Kollman, "SETTLE: An analytical version of the SHAKE and RATTLE algorithm for rigid water models," J. Comput. Chem. 13(8), 952–962 (1992). DOI: 10.1002/jcc.540130805
G. Bussi, D. Donadio, and M. Parrinello, "Canonical sampling through velocity rescaling," J. Chem. Phys. 126(1), 014101 (2007). DOI: 10.1063/1.2408420
B. Leimkuhler and C. Matthews, "Rational construction of stochastic numerical methods for molecular sampling," Appl. Math. Res. eXpress 2013(1), 34–56 (2013). DOI: 10.1093/amrx/abs010