Tutorial T01: Equation of State & Transport of the Lennard-Jones Fluid
This tutorial evaluates the ParticleDynamics v1.2.0 high-level Workflow API and fused :ell microcanonical (VelocityVerlet() NVE) GPU engine against two standard benchmarks of liquid-state statistical mechanics:
Thermodynamics (Equation of State): Comparison of tail-corrected GPU NVE simulations (
vdw_modifier=:none, ) against the 33-parameter empirical Modified Benedict–Webb–Rubin (MBWR) correlation of Johnson, Zollweg & Gubbins (1993) across five dense liquid states (with reference to the modern equation of state of Thol et al. 2016), contrasted against the distinct truncated-and-shifted Lennard-Jones fluid (vdw_modifier=:potential_shift, , Thol et al. 2015).Transport (Self-Diffusion): Independent evaluation of the self-diffusion coefficient
in microcanonical NVE production via both the Einstein mean-squared displacement slope ( MSDObservable) and the Green–Kubo velocity autocorrelation integral (VACFObservable), compared against Meier, Laesecke & Kabelac (2004) after applying the Yeh & Hummer (2004) periodic hydrodynamic finite-size correction at .
Trajectory Visualization

_Path-traced Fresnel studio snapshot (tutorials/render_snapshots.py --targets T01) of the dense 3D Lennard-Jones liquid (\rho^_ = 0.80, T^* = 0.90) highlighting a central tagged atom and its first coordination shell inside the periodic simulation cell.*
What You Will Learn
Building a 3D periodic system with
ParticleSystem,Group, andCellListon the:ellGPU backend inFloat64.Equilibrating in the canonical ensemble with
CSVRvia GPU-batchedstep_many!, then switching cleanly to microcanonicalConstantVolume(VelocityVerlet()) NVE on the same GPU state.Distinguishing the full-potential Lennard-Jones fluid (
vdw_modifier=:none+ isotropic dispersion tail corrections) from the truncated-and-shifted LJTS fluid (vdw_modifier=:potential_shift, ), and isolating the effect of potential shifting on NVE energy conservation at matched cutoff.Measuring and cross-checking thermodynamic and transport quantities with
ThermodynamicObservable,VirialObservable,PressureObservable,MSDObservable,VACFObservable,TableWriter, andInMemoryWriter.
Running the Tutorial
All scripts live in tutorials/T01_lj_eos_transport/:
# Quick GPU smoke check (N = 256)
TUTORIAL_FAST=1 julia --project tutorials/T01_lj_eos_transport/run.jl
TUTORIAL_FAST=1 julia --project tutorials/T01_lj_eos_transport/analyze.jl
# Full production validation (N = 2048, rc = 3.5, :ell CellList)
julia --project tutorials/T01_lj_eos_transport/run.jl
julia --project tutorials/T01_lj_eos_transport/analyze.jl
# Regenerate documentation figures (300 DPI)
python3 tutorials/T01_lj_eos_transport/plot.pyPhysics Background
Reduced Units, Long-Range Dispersion Tails, and the LJTS Fluid
We work in standard reduced Lennard-Jones units (
In a finite periodic box, interactions are truncated at a cutoff radius
- Full Lennard-Jones fluid approximated via unshifted cutoff + analytical tail corrections (
vdw_modifier=:none, ): Assuming an isotropic fluid with radial distribution function for , the omitted long-range dispersion contributions to the configurational energy per particle and pressure are
We compare the tail-corrected simulation averages against the 33-parameter MBWR equation of state of Johnson, Zollweg & Gubbins (1993). Because the JZG MBWR formula is an empirical correlation fitted to historical simulation data, it carries a pressure fit uncertainty of roughly
- Truncated-and-shifted Lennard-Jones fluid (
vdw_modifier=:potential_shift, ): Shifting the pair potential byremoves the energy jump at while leaving pair forces unchanged for . Without long-range dispersion tails, this defines a distinct thermodynamic model, the Lennard-Jones truncated-and-shifted (LJTS) fluid (Thol et al. 2015), which has a lower critical temperature, higher pressures, and less negative configurational energies than the full Lennard-Jones fluid at the same. Accordingly, analyze.jlreports LJTS thermodynamics as a separate diagnostic rather than validating it against the full-LJ MBWR correlation.
Einstein vs Green–Kubo Self-Diffusion and Finite-Size Correction
In microcanonical NVE dynamics with zero center-of-mass momentum (
- Einstein relation (
MSDObservable): From the long-time linear slope of the unwrapped mean-squared displacement,
- Green–Kubo relation (
VACFObservable): From the time integral of the velocity autocorrelation function (with equipartition normalization ),
In dense liquids, momentum conservation produces a positive hydrodynamic
Because periodic boundary conditions couple a diffusing particle to its periodic images through hydrodynamic momentum conservation, a finite cubic box of side length
where
Workflow API Walkthrough
1. System Construction, CSVR Equilibration, and NVE Handoff
tutorials/T01_lj_eos_transport/run.jl initializes an CSVR using GPU-batched step_many!, and replaces sim.integrator with microcanonical ConstantVolume(all_grp) (VelocityVerlet()) NVE on the same GPU state:
using ParticleDynamics
all_grp = Group(:all, AllSelection())
lj = LennardJones(
epsilon=1.0,
sigma=1.0,
cutoff=3.5,
vdw_modifier=:none, # compare with :potential_shift at cutoff=2.5
pairs=:neighborlist,
neighborlist=CellList(buffer=0.4, capacity=384, rebuild_interval=10),
)
thermo = ThermodynamicObservable(all_grp; name=:thermo)
virial = VirialObservable(all_grp; name=:virial)
press = PressureObservable(name=:press)
msd_obs = MSDObservable(all_grp; name=:msd)
vacf_obs = VACFObservable(all_grp; name=:vacf)
# Stage 1: Canonical CSVR equilibration with GPU super-batched step_many!
sim = Simulation(
system;
groups=Groups(all_grp),
integrator=Integrator(
dt=0.004,
scheme=VelocityVerlet(),
forces=[lj],
methods=[ConstantVolume(all_grp; thermostat=CSVR(kT=T_target, tau=0.2))],
),
observables=[thermo, virial, press, msd_obs, vacf_obs],
precision=Float64,
seed=seed,
)
prepare!(sim)
step_many!(state(sim), sim.lowlevel_integrator, 0.004, 6_000; compute_energy=false)
# Stage 2: Switch to microcanonical :ell fused VelocityVerlet() NVE
sim.integrator = Integrator(
dt=0.004,
scheme=VelocityVerlet(),
forces=[lj],
methods=[ConstantVolume(all_grp)],
)
prepare!(sim)Before starting NVE production, run.jl removes center-of-mass momentum and runs two brief NVE settle passes (InMemoryWriter) with a one-shot kinetic-energy adjustment
2. EOS Production with TableWriter, VirialObservable, and PressureObservable
During EOS production (20,000 NVE steps = run! executes 24-step CUDA-graph step_many! batches between samples), TableWriter logs temperature, energies, scalar virial
table = TableWriter(
csv_path;
every=25,
observables=[
thermo => [:temperature, :kinetic_energy, :potential_energy, :total_energy],
virial => [:virial],
press => [:pressure, :volume, :density],
],
mode=:replace,
)
sim.writers = Writer[table]
prepare!(sim)
run!(sim, Stage(:eos_production, steps=20_000; reset_step=0, reset_observables=true))In analyze.jl, checking that press.pressure matches thermo.kinetic_energy and virial.virial (to verify_check as a software API consistency check (separate from physical validation) because both observables read the same GPU kinetic-energy and virial accumulators.
Since v1.2.0, CSVR removes center-of-mass momentum every nstcomm = 100 steps by default during canonical equilibration, and MSDObservable uses Float64 unwrapped coordinate tracking regardless of simulation precision.
3. Multi-Window Transport with MSDObservable, VACFObservable, and InMemoryWriter
Because MSDObservable and VACFObservable compute displacements and velocity inner products relative to the current observable reference configuration on the GPU, combining InMemoryWriter with schedule = Between(0, win_steps; every=sample_every) and Stage(...; reset_step=0, reset_observables=true) collects multi-origin ensembles without host velocity dumps:
MSD: 16 independent windows
3,000 steps ( each, sampled every 25 steps = ); Einstein slope fitted over the linear diffusive window .VACF: The recorded production table below used 160 windows
500 steps ( each, sampled every 4 steps = ), grouped into 8 contiguous blocks of 20 windows with plateau . To reduce truncation of the hydrodynamiclong-time tail on fresh runs, run.jlnow defaults tovacf_win_steps = 1_000( , plateau ).
Results & Literature Comparison
Part A: Equation of State vs Johnson, Zollweg & Gubbins (1993)

Across all five tail-corrected GPU NVE runs (vdw_modifier=:none, Float64,
Looking closely at the pressure residuals reveals a systematic negative offset across all five full-LJ states (
At
, sits (, ) below the JZG MBWR value . At
and , the offsets are (, ) and (, ). At
and , the differences are statistically small: (, ) and (relative because is near zero pressure,).
These
Table 1a: Full Lennard-Jones Fluid (:none, + analytical tail) vs JZG (1993) MBWR {#Table-1a:-Full-Lennard-Jones-Fluid-:none,-r_c-3.5\sigma-analytical-tail-vs-JZG-1993-MBWR}
| State ( | NVE | |||||||
|---|---|---|---|---|---|---|---|---|
_(MBWR reference values are evaluated at each run's measured NVE temperature \langle T^_ \rangle$;$z$-scores use only the simulation 8-block SEM and do not include the$\sim 0.5\text{–}1\%$empirical fit uncertainty of JZG 1993. Software API parity check:$\max |P_{\text{obs}} - (2K+W)/(3V)| \le 1.95 \times 10^{-7} across all runs.)*
Table 1b: Truncated-and-Shifted LJTS Fluid (:potential_shift, ; Diagnostic) {#Table-1b:-Truncated-and-Shifted-LJTS-Fluid-:potential_shift,-r_c-2.5\sigma;-Diagnostic}
The three :potential_shift runs represent the distinct LJTS fluid (Thol et al. 2015) rather than the full Lennard-Jones fluid, so they are reported as non-gated diagnostics alongside their thermodynamic offset relative to the full-LJ fluid:
| State ( | Offset vs Full-LJ | Offset vs Full-LJ | NVE | |||
|---|---|---|---|---|---|---|
Note on NVE energy conservation and cutoff confounding: Although the recorded :potential_shift runs at :none runs at vdw_modifier=:potential_shift cleanly, run.jl now includes a matched-cutoff unshifted control (unshifted_rc25_T090_r0800, :none at shift_T090_r0800 on fresh runs.
Part B: Self-Diffusion Transport vs Meier, Laesecke & Kabelac (2004)

At both dense liquid states, the normalized VACF
At
, the recorded Green–Kubo integral and the Einstein MSD slope agree within statistical noise: ( ,). At the denser state
, however,lies below by ( ,). This systematic deficit is physically expected when truncating the Green–Kubo integral at , which cuts off the positive hydrodynamiclong-time tail (more pronounced at higher density). Extending the VACF correlation window to (now the default inrun.jlfor fresh runs) reduces this truncation bias.
| State ( | Meier et al. (2004) Ref. | |||||||
|---|---|---|---|---|---|---|---|---|
Applying the Yeh–Hummer (2004) hydrodynamic shift at
References
J. K. Johnson, J. A. Zollweg, and K. E. Gubbins, "The Lennard-Jones equation of state revisited," Molecular Physics 78(3), 591–618 (1993). DOI: 10.1080/00268979300100411
M. Thol, G. Rutkai, A. Köster, R. Lustig, R. Span, and J. Vrabec, "Equation of state for the Lennard-Jones fluid," J. Phys. Chem. Ref. Data 45(2), 023101 (2016). DOI: 10.1063/1.4945000
M. Thol, G. Rutkai, R. Span, J. Vrabec, and R. Lustig, "Equation of state for the Lennard-Jones truncated and shifted model fluid," Int. J. Thermophys. 36, 25–43 (2015). DOI: 10.1007/s10765-014-1764-4
K. Meier, A. Laesecke, and S. Kabelac, "Transport coefficients of the Lennard-Jones model fluid. I. Viscosity," J. Chem. Phys. 121(8), 3671–3687 (2004). DOI: 10.1063/1.1770695
K. Meier, A. Laesecke, and S. Kabelac, "Transport coefficients of the Lennard-Jones model fluid. II. Self-diffusion," J. Chem. Phys. 121(19), 9526–9535 (2004). DOI: 10.1063/1.1786579
I.-C. Yeh and G. Hummer, "System-size dependence of diffusion coefficients and viscosities from molecular dynamics simulations with periodic boundary conditions," J. Phys. Chem. B 108(40), 15873–15879 (2004). DOI: 10.1021/jp0477147
G. Bussi, D. Donadio, and M. Parrinello, "Canonical sampling through velocity rescaling," J. Chem. Phys. 126(1), 014101 (2007). DOI: 10.1063/1.2408420