Skip to content

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 , packing constraints break translational symmetry along the wall normal (). The fluid organizes into oscillatory solvation layers, the normal pressure alternates between repulsion and net attraction with a period near the molecular diameter , and single-particle transport splits into unbounded (confinement-hindered) lateral diffusion versus bounded transverse motion .

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:

  1. Zero-sync GPU-capturable :additive AbstractExternalPotential implementing the 9–3 Steele slit wall with provides_virial = true, composed additively with bulk LennardJones pair forces inside DeviceEngine CUDA graphs (0 host callbacks per 100 steps).

  2. Explicit atomistic crystalline FCC(100) walls via FreezeGroup(wall; mode=:hold) and multi-type PairTable (with   eliminating redundant frozen–frozen pair work and directly exposing fluid-on-wall mechanical forces).

  3. Selective FIRE energy minimization (minimize!(sim; mobile=fluid_group, ...)) relaxing dense confined packings prior to dynamics while leaving frozen wall atoms stationary ( ).

  4. Two-stage BAOAB thermalization CSVR canonical production on the mobile fluid group, preserving unperturbed molecular lateral diffusion while excluding FREEZE_HOLD wall atoms from thermostat degrees of freedom.

Trajectory Visualization ​

Live Fresnel Studio Dashboard (T09): Dense Lennard-Jones fluid confined inside a frozen atomistic FCC(100) crystalline slit nanopore (H = 5.0 σ) alongside the oscillatory solvation density profile ρ*(z) (period 0.92 σ) and live mechanical wall normal pressure P_zz(t) (tutorials/render_movies.py --targets T09).

Studio Fresnel snapshot of confined solvation layers in an FCC(100) slit nanopore


1. Physical Model, Loading Protocol & Statistical-Mechanical Identities ​

All quantities are expressed in reduced Lennard-Jones units ( ,  ,  ,   ). Fluid–fluid interactions use a potential-shifted 12–6 LJ potential truncated at    compared against a bulk liquid reference at  ,   (   ,     ,    ).

Constant-μ loading caveat

The recorded slit-width sweep uses pre-tabulated pore loadings   rather than a closed-loop grand-canonical Monte Carlo (GCMC) or iteratively calibrated Widom -matching loop, and the recorded bulk Widom chemical potential carries   uncertainty (    ). At the widest pore   , the measured normal pressures    (   , ) and    (   , ) sit significantly below   , confirming that    was slightly underloaded relative to the bulk reservoir. Fresh runs in run.jl use higher Widom insertion counts and analyze.jl reports   and    for every slit width.

9–3 Steele Slit-Pore Wall Potential ​

Two smooth planar walls at    act on each fluid atom via the integrated semi-infinite continuum 9–3 Steele potential:

with   , strongly wetting amplitude    (unshifted minimum      and shifted minimum   at    ), and cutoff   . To prevent periodic fluid–fluid image interactions through the walls, the periodic simulation box uses     (  ).

Because the two wall-contact adsorption minima lie at    from   , fitting commensurate fluid layers of interlayer spacing    yields high-pressure peaks near

alternating with low-pressure (and net attractive,  ) incommensurate troughs near   . (By comparison, the 10–4–3 wall potential used in Magda, Tirrell & Davis 1985 has   , shifting the   oscillation by  .)

Clausius Mechanical–Virial Normal Pressure Identity ​

Writing the outward force exerted by the fluid on each wall from    , the mechanical normal pressure on the slit walls is:

Applying the Clausius virial theorem in with       gives an identity between the direct wall force and the configurational virial tensor:

Accumulating virial[i, 3] += d_lo * f_lo + d_hi * f_hi inside the external-potential kernel lets PressureObservable recover   automatically, providing a mechanical–virial self-consistency check at every slit width.

Anisotropic Transport & Equilibrium Transverse Plateau ​

In a slit pore, lateral displacements grow diffusively at long times,      (with lateral center-of-mass motion removed for translationally invariant smooth walls, and unmodified for corrugated atomistic walls). By contrast, transverse displacements saturate in the long-time limit to an equilibrium plateau determined by the static density profile :

For a hypothetical uniform density profile over width  ,    . However,   is not an upper bound on : strongly wetting walls push probability density outward into sharp contact layers near     , making the true equilibrium limit     in wider pores. In addition, transverse diffusive equilibration across effective width    takes  . At    (  ,   ),   , exceeding the   production run; over the lag window   ,    has reached only of the equilibrium   plateau (so comparing against   would have passed solely because the curve was unconverged). Accordingly, analyze.jl compares against the empirical   computed from and flags finite-time convergence explicitly.


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:

julia
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
end

Compose it with bulk LennardJones forces through ExternalPotentialForce(wall):

julia
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   , we construct 3-layer FCC(100) crystal slabs (  ,    , innermost atomic planes at   ,  ), pin them with FreezeGroup(wall_g; mode=:hold), and zero out wall–wall LJ interactions in PairTable:

julia
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    and    gives a continuum 9–3 prefactor    , compared with    in the smooth wall. For the discrete 3-layer FCC(100) slab, the Boltzmann-averaged potential of mean force (PMF) minimum is   versus   for the shifted smooth 9–3 wall, yet the resulting normal pressure still differs by (   vs.   ,    , ), and both lateral box size (   vs.  ) and fluid–wall cutoff (   vs.   ) also differ. Consequently, the diffusivity difference mixes corrugation, adsorption well shape, and effective pore width/normal pressure. In fresh runs, setting T09_MATCH_CONT_EPSW=1 selects     to match the continuum 9–3 prefactor.

Selective FIRE Minimization & Two-Stage BAOAB → CSVR Workflow ​

Each slit simulation runs three stages on the same Simulation object:

julia
# 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 while maintaining canonical temperature control strictly on the mobile fluid degrees of freedom (  ). Because a confinement wall (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 ​

Oscillatory solvation layering and solvation pressure in slit nanopores

  • 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 ​

Anisotropic lateral vs transverse MSD and confinement suppression of diffusion

  • 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:  ,  ,     (smooth) /   (FCC  ,  ),   , BAOAB equilibration steps + CSVR production steps ( ), 8-block standard errors. Bulk LJ reference ( ):   ,   ,    ,   .

WallLayers () / Unif. *
Smooth 9–32.652160.909   24.360.968 0.285 / 0.454
Smooth 9–33.002390.830   22.971.250 0.530 / 0.667
Smooth 9–33.252620.809   33.490.787 0.761 / 0.844
Smooth 9–33.502840.789   33.830.925 0.935 / 1.042
Smooth 9–33.753040.768   33.641.012 1.071 / 1.260
Smooth 9–34.003210.743   33.201.125 1.310 / 1.500
Smooth 9–34.253590.767   43.600.860 1.544 / 1.760
Smooth 9–34.503960.786   43.770.950 1.654 / 2.042
Smooth 9–35.004380.760   43.431.117 2.167 / 2.667
Smooth 9–35.404940.780   53.780.938 2.386 / 3.227
Smooth 9–36.005410.751   53.581.087 2.950 / 4.167
Smooth 9–38.007460.740   83.670.907 4.368 / 8.167
Frozen FCC5.004900.760  —4 main3.30— 1.612 / 2.667

__Note:   is the uniform-slab reference, not an upper bound (for wetting walls, the true asymptote   exceeds   at wide pores). At   ,    over    reaches only of   because     .*

Software, API & Mechanical-Identity Checks ​

Software / Identity CheckMeasured (ParticleDynamics v1.2.0)ExpectedStatus
CUDA-graph host callbacks / 100 steps (Steele93SlitWall)00 (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    () (Clausius identity)CHECK_OK

Physical Validation & Quantitative Diagnostics ​

Physical Metric / DiagnosticMeasured (ParticleDynamics v1.2.0)Reference / ContextCategory
Wall-contact layering peak 2.97 (3.67 at  ) (Snook & Henderson 1978)Validation (PASS)
Layer spacing ( , )0.925 σ, 0.907 σ  (Magda et al. 1985)Validation (PASS)
Solvation pressure period     (Snook & van Megen 1980)Validation (PASS)
Solvation swing    ()  (commensurate vs. trough)Validation (PASS)
Wide-pore center density vs. 0.721 vs. 0.720Bulk center density recoveryValidation (PASS)
Lateral diffusion suppression   (   , ) (Magda et al. 1985)Validation (PASS)
Narrow-pore transverse plateau   at 0.932 (equilibrium variance limit)Validation (PASS)
Wide-pore loading check  Wall:   (); Vir:   ()Confirms slight underloading at fixed  Diagnostic
Smooth 9–3 vs. FCC(100) at   ratio   (   );     ()Composite wall-model comparison (corrugation + well shape + pressure)Diagnostic
Wide-pore transverse MSD   at (  vs.    )Unconverged:     Diagnostic

5. Running the Tutorial ​

bash
# 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.py

References ​

  1. I. K. Snook & D. Henderson, "Monte Carlo study of a hard-sphere fluid near a hard wall," J. Chem. Phys. 68, 2134–2139 (1978).

  2. I. K. Snook & W. van Megen, "Solvation forces in simple dense fluids. I," J. Chem. Phys. 72, 2907–2913 (1980).

  3. J. J. Magda, M. Tirrell & H. T. Davis, "Molecular dynamics of narrow, liquid-filled pores," J. Chem. Phys. 83, 1888–1901 (1985).

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