Tutorial T09: Confined Fluids in Slit Nanopores
Scripts: tutorials/T09_slit_nanopore_confinement/run.jl · analyze.jl · plot.py
When a dense simple liquid is confined between two parallel solid walls separated by only a few molecular diameters
This tutorial examines confined Lennard-Jones (LJ) slit-pore phenomenology motivated by Snook & Henderson (1978), Snook & van Megen (1980), and Magda, Tirrell & Davis (1985), while exercising four ParticleDynamics v1.2.0 capabilities:
Zero-sync GPU-capturable
:additiveAbstractExternalPotentialimplementing the 9–3 Steele slit wall withprovides_virial = true, composed additively with bulkLennardJonespair forces insideDeviceEngineCUDA graphs (0 host callbacks per 100 steps).Explicit atomistic crystalline FCC(100) walls via
FreezeGroup(wall; mode=:hold)and multi-typePairTable(with eliminating redundant frozen–frozen pair work and directly exposing fluid-on-wall mechanical forces).Selective
FIREenergy minimization (minimize!(sim; mobile=fluid_group, ...)) relaxing dense confined packings prior to dynamics while leaving frozen wall atoms stationary ( ).Two-stage
BAOABthermalizationCSVRcanonical production on the mobile fluid group, preserving unperturbed molecular lateral diffusionwhile excluding FREEZE_HOLDwall atoms from thermostat degrees of freedom.
Trajectory Visualization
tutorials/render_movies.py --targets T09).
1. Physical Model, Loading Protocol & Statistical-Mechanical Identities
All quantities are expressed in reduced Lennard-Jones units (
Constant-μ loading caveat
The recorded slit-width sweep uses pre-tabulated pore loadings run.jl use higher Widom insertion counts and analyze.jl reports
9–3 Steele Slit-Pore Wall Potential
Two smooth planar walls at
with
Because the two wall-contact adsorption minima lie at
alternating with low-pressure (and net attractive,
Clausius Mechanical–Virial Normal Pressure Identity
Writing the outward force exerted by the fluid on each wall from
Applying the Clausius virial theorem in
Accumulating virial[i, 3] += d_lo * f_lo + d_hi * f_hi inside the external-potential kernel lets PressureObservable recover
Anisotropic Transport & Equilibrium Transverse Plateau
In a slit pore, lateral displacements grow diffusively at long times,
For a hypothetical uniform density profile over width analyze.jl compares
2. ParticleDynamics v1.2.0 API Walkthrough
Zero-Sync :additive GPU-Capturable External Potential
Defining external_force_mode, is_device_capturable, provides_virial, and enqueue_external_forces! lets DeviceEngine capture the 9–3 wall kernel directly inside its single-step and step_many! CUDA graphs with zero host synchronization:
struct Steele93SlitWall{T<:AbstractFloat} <: AbstractExternalPotential
half_H::T; eps_w::T; sig_w::T; zc::T; u_shift::T
calls::Base.RefValue{Int}
end
SC.external_force_mode(::Steele93SlitWall) = :additive
SC.is_device_capturable(::Steele93SlitWall) = true
SC.provides_virial(::Steele93SlitWall) = true
function SC.enqueue_external_forces!(p::Steele93SlitWall{T}, run, energy::Bool, virial::Bool) where {T}
p.calls[] += 1
N = length(run.r[1]); ws = run.neighbors
@cuda threads=256 blocks=cld(N, 256) NL._device_if_valid!(
ws.state, _steele93_slit_kernel!, run.r, run.f, run.energy, run.virial,
p.half_H, p.eps_w, p.sig_w, p.zc, p.u_shift,
energy ? Val(true) : Val(false), virial ? Val(true) : Val(false))
return nothing
endCompose it with bulk LennardJones forces through ExternalPotentialForce(wall):
wall = Steele93SlitWall(Float64; H=H, eps_w=3.5, sig_w=1.0, zc=3.5)
forces = Force[
LennardJones(epsilon=1.0, sigma=1.0, cutoff=2.5, pairs=:neighborlist,
neighborlist=CellList(buffer=0.4, capacity=192, rebuild_interval=15),
vdw_modifier=:potential_shift),
ExternalPotentialForce(wall),
]After warming up the single-step and 20-step CUDA-graph caches, running 100 consecutive steps via step_many!(st, spec, dt, 100; compute_energy=false) records ext_calls_per_100 = 0 host invocations.
Smooth Model Wall vs. Frozen FCC(100) Atomistic Wall (FreezeGroup + PairTable)
To compare the smooth continuum wall against an explicit atomistic solid boundary at FreezeGroup(wall_g; mode=:hold), and zero out wall–wall LJ interactions in PairTable:
pt = PairTable(
sigma=[1.0 1.0; 1.0 1.0],
epsilon=[1.0 1.2; 1.2 0.0], # epsilon_WW = 0: zero frozen-frozen pair work
cutoff=[2.5 2.5; 2.5 0.0],
type_names=[:F, :W],
)
forces = Force[
LennardJones(pair_table=pt, pairs=:neighborlist,
neighborlist=CellList(buffer=0.4, capacity=224, rebuild_interval=15),
vdw_modifier=:potential_shift),
]Because wall–wall forces are identically zero while fluid–wall forces remain active, summing forces[:, 3] over the top and bottom frozen wall groups directly returns the mechanical normal pressure
Wall-model comparison caveat
This comparison is between a smooth continuum wall model and an explicit FCC(100) atomistic wall, not a pure isolation of surface corrugation alone. Integrating the fluid–wall LJ interaction over a semi-infinite continuum slab of density T09_MATCH_CONT_EPSW=1 selects
Selective FIRE Minimization & Two-Stage BAOAB → CSVR Workflow
Each slit simulation runs three stages on the same Simulation object:
# Stage 0: FIRE minimization on mobile fluid atoms (frozen FCC wall moves 0.0 sigma)
res_min = minimize!(sim; method=FIRE(dt_initial=0.005, dt_max=0.05),
force_tolerance=0.5, max_displacement=0.05, max_iterations=1000,
mobile=fluid_g)
# Stage 1: BAOAB Langevin thermalization & structural layering relaxation
run!(sim, Stage(:equil, steps=10_000; progress=false))
# Stage 2: CSVR canonical production (preserves unperturbed molecular diffusion)
sim.integrator = Integrator(
dt=0.004, scheme=VelocityVerlet(), forces=forces,
methods=[ConstantVolume(fluid_g; thermostat=CSVR(kT=1.0, tau=0.5))],
constraints=[FreezeGroup(wall_g; mode=:hold)],
)
prepare!(sim)
run!(sim, Stage(:prod, steps=40_000; reset_step=0, reset_observables=true, progress=false))Switching from BAOAB to CSVR for production avoids artificial Langevin velocity damping of Steele93SlitWall external potential or FreezeGroup) breaks translational invariance, ParticleDynamics v1.2.0 automatically disables CSVR's periodic COM-momentum removal so fluid–wall momentum exchange is preserved.
3. Results & Visual Verification
Oscillatory Density Layering & Solvation Pressure

Multilayer adsorption (Panel a): Every slit width exhibits pronounced wall-contact peaks (
) and interlayer spacing at commensurate widths ( at , at ). At , density oscillations decay by from the wall peaks into a nearly flat mid-pore region with (compared to ).Smooth 9–3 vs. atomistic FCC(100) structure at
(Panel a): Both wall models produce four fluid layers with similar contact peak heights ( smooth vs. atomistic), though the underlying normal pressures differ by ( ).Oscillatory solvation force & mechanical–virial consistency (Panel b):
alternates between high-pressure commensurate integer-layer peaks ( at ) and negative-pressure attractive troughs ( : ; : ; swing ) with mean oscillation wavelength . Direct wall forces and Clausius virial pressures agree across the sweep ( , ). At , ( , ) and ( , ) remain below , reflecting slight underloading of the fixed pre-tabulated configuration.
Anisotropic Diffusion & Smooth vs. FCC Wall Comparison

Unbounded lateral vs. bounded transverse MSD (Panel a): Lateral MSD
grows linearly ( ) across all widths, whereas transverse MSD bends toward its static equilibrium limit . In narrow pores such as , the average reaches of . In the wide pore, however, reaches only of (which exceeds the uniform-slab reference due to wetting-layer weighting) because transverse equilibration requires .Confinement suppression & commensurability modulation (Panel b): As
narrows from , increasing wall-layer packing suppresses from ( ) down to at ( , , ) and at ( ), with commensurability dips at dense integer-layer peaks ( ) qualitatively mirroring Magda, Tirrell & Davis (1985).Smooth 9–3 vs. frozen FCC(100) wall at
(Panel b): Moving from the smooth 9–3 model wall ( ) to the frozen FCC(100) wall ( , continuum , discrete PMF minimum ) lowers lateral diffusivity from to ( , ratio ). Because the two wall setups also differ in normal pressure ( / ), adsorption well shape, lateral box size, and cutoff, this reduction reflects the combined effect of corrugation and wall-model differences rather than corrugation in isolation.
4. Quantitative Production Summary
Production parameters: BAOAB equilibration steps + CSVR production steps (
| Wall | Layers | ||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
| Smooth 9–3 | 2.65 | 216 | 0.909 | 2 | 4.36 | 0.968 | 0.285 / 0.454 | ||||
| Smooth 9–3 | 3.00 | 239 | 0.830 | 2 | 2.97 | 1.250 | 0.530 / 0.667 | ||||
| Smooth 9–3 | 3.25 | 262 | 0.809 | 3 | 3.49 | 0.787 | 0.761 / 0.844 | ||||
| Smooth 9–3 | 3.50 | 284 | 0.789 | 3 | 3.83 | 0.925 | 0.935 / 1.042 | ||||
| Smooth 9–3 | 3.75 | 304 | 0.768 | 3 | 3.64 | 1.012 | 1.071 / 1.260 | ||||
| Smooth 9–3 | 4.00 | 321 | 0.743 | 3 | 3.20 | 1.125 | 1.310 / 1.500 | ||||
| Smooth 9–3 | 4.25 | 359 | 0.767 | 4 | 3.60 | 0.860 | 1.544 / 1.760 | ||||
| Smooth 9–3 | 4.50 | 396 | 0.786 | 4 | 3.77 | 0.950 | 1.654 / 2.042 | ||||
| Smooth 9–3 | 5.00 | 438 | 0.760 | 4 | 3.43 | 1.117 | 2.167 / 2.667 | ||||
| Smooth 9–3 | 5.40 | 494 | 0.780 | 5 | 3.78 | 0.938 | 2.386 / 3.227 | ||||
| Smooth 9–3 | 6.00 | 541 | 0.751 | 5 | 3.58 | 1.087 | 2.950 / 4.167 | ||||
| Smooth 9–3 | 8.00 | 746 | 0.740 | 8 | 3.67 | 0.907 | 4.368 / 8.167 | ||||
| Frozen FCC | 5.00 | 490 | 0.760 | — | 4 main | 3.30 | — | 1.612 / 2.667 |
__Note:
Software, API & Mechanical-Identity Checks
| Software / Identity Check | Measured (ParticleDynamics v1.2.0) | Expected | Status |
|---|---|---|---|
CUDA-graph host callbacks / 100 steps (Steele93SlitWall) | 0 | 0 (zero-sync :additive capture) | CHECK_OK |
FIRE minimization convergence (13/13 systems) | 100% | 100% (:force_tolerance) | CHECK_OK |
Frozen FCC wall displacement (FreezeGroup(:hold)) | 0.0 σ | 0.0 σ | CHECK_OK |
| Clausius mechanical–virial identity | CHECK_OK |
Physical Validation & Quantitative Diagnostics
| Physical Metric / Diagnostic | Measured (ParticleDynamics v1.2.0) | Reference / Context | Category |
|---|---|---|---|
| Wall-contact layering peak | 2.97 (3.67 at | Validation (PASS) | |
| Layer spacing | 0.925 σ, 0.907 σ | Validation (PASS) | |
| Solvation pressure period | Validation (PASS) | ||
| Solvation swing | Validation (PASS) | ||
| Wide-pore center density | 0.721 vs. 0.720 | Bulk center density recovery | Validation (PASS) |
| Lateral diffusion suppression | Validation (PASS) | ||
| Narrow-pore transverse plateau | 0.932 | Validation (PASS) | |
| Wide-pore loading check | Wall: | Confirms slight underloading at fixed | Diagnostic |
| Smooth 9–3 vs. FCC(100) at | Composite wall-model comparison (corrugation + well shape + pressure) | Diagnostic | |
| Wide-pore transverse MSD | Unconverged: | Diagnostic |
5. Running the Tutorial
# Quick GPU smoke verification (7 smooth widths + FCC wall + bulk)
TUTORIAL_FAST=1 julia --project tutorials/T09_slit_nanopore_confinement/run.jl
TUTORIAL_FAST=1 julia --project tutorials/T09_slit_nanopore_confinement/analyze.jl
# Full production validation sweep (12 smooth widths + FCC wall + bulk)
julia --project tutorials/T09_slit_nanopore_confinement/run.jl
julia --project tutorials/T09_slit_nanopore_confinement/analyze.jl
# Optional: match FCC continuum 9–3 prefactor eps_w = (2*pi/3)*rho_s*eps_fw = 3.5
T09_MATCH_CONT_EPSW=1 julia --project tutorials/T09_slit_nanopore_confinement/run.jl
# Regenerate 300-DPI documentation figures
python3 tutorials/T09_slit_nanopore_confinement/plot.pyReferences
I. K. Snook & D. Henderson, "Monte Carlo study of a hard-sphere fluid near a hard wall," J. Chem. Phys. 68, 2134–2139 (1978).
I. K. Snook & W. van Megen, "Solvation forces in simple dense fluids. I," J. Chem. Phys. 72, 2907–2913 (1980).
J. J. Magda, M. Tirrell & H. T. Davis, "Molecular dynamics of narrow, liquid-filled pores," J. Chem. Phys. 83, 1888–1901 (1985).