JuliaCon 2026 (JuliaMolSim minisymposium)
Mathematics for Materials Modelling, Institute of Mathematics, EPFL
August 13, 2026
% Blackboard Bold % Calligraphic % Positive definite symmetric matrices
% Script % Fraktur % Other Symbols % Alternative definition, safer % % % General Physics/Math % Geometry and Neighborhoods % Hessian Related % Harmonic Oscillators % Simplified/Indexed Notation % Other Specific Notation $$
\[ \definecolor{gris_C}{RGB}{96,96,96} \definecolor{blanc_C}{RGB}{255,255,255} \definecolor{pistache_C}{RGB}{176,204,78} \definecolor{pistache2_C}{RGB}{150,171,91} \definecolor{jaune_C}{RGB}{253,235,125} \definecolor{jaune2_C}{RGB}{247,208,92} \defineclor{darkblue}{RGB}{} \definecolor{orange_C}{RGB}{244,157,84} \definecolor{orange2_C}{RGB}{239,119,87} \definecolor{bleu_C}{RGB}{126,151,206} \definecolor{bleu2_C}{RGB}{90,113,180} \definecolor{vert_C}{RGB}{96,180,103} \definecolor{vert2_C}{RGB}{68,141,96} \definecolor{pistache_light_C}{RGB}{235,241,212} \definecolor{jaune_light_C}{RGB}{254,250,224} \definecolor{orange_light_C}{RGB}{251,230,214} \definecolor{bleu_light_C}{RGB}{222,229,241} \definecolor{vert_light_C}{RGB}{216,236,218} \]
Molly.jl - minimal implementations of classical methodsThermodynamic equilibrium: time-symmetric microscopic dynamics & static macroscopic state (no net observable flux)
Nonequilibrium steady state (NESS): non-reversible dynamics from non-conservative forces and net macroscopic fluxes
Transport coefficients: constants in constitutive equations (heat/Fourier, diffusion/Fick, viscosity/Newton, conductivity/Ohm…)
Sensitivities of macroscopic fluxes to external stimuli
Quantitative input in macroscopic models (Navier–Stokes, reaction-diffusion models…)
\[ \mathcal{J} = -\kappa\,\nabla T \qquad \text{(Fourier's law)} \]
The energy flux is proportional to the temperature gradientNonequilibrium dynamics
\[ \mathrm{d}X_t^\eta = \color{blue}{b(X_t^\eta)\,\mathrm{d}t + \sigma(X_t^\eta)\,\mathrm{d}W_t} + \color{red}{\eta\,F(X_t^\eta)\,\mathrm{d}t} \]
Equilibrium MD (Langevin, dissipative particle dynamics…) + nonequilibrium forcing, of magnitude \(\eta\)
The state \(X^\eta_t\in\mathcal{X}\) (positions and momenta) evolves stochastically
The NESS is an invariant probability measure \(\mu_\eta \in \mathcal{P}(\mathcal{X})\) under \(X^\eta\)
Equilibrium is characterized by an explicit steady-state (Gibbs distribution) \[ \color{blue}{\mu_0(\mathrm{d}x) = \frac1{Z(\beta)}\mathrm{e}^{-\beta E}\,\mathrm{d}x} \]
Linear response
Given a flux observable \(R:\mathcal{X}\to\mathbb{R}\) with \(\langle R\rangle_{\eta=0} = 0\), the macroscopic flux is \[ \langle R\rangle_\eta = \int_\mathcal{X}R(x)\,\mu_\eta(\mathrm{d}x) \]
The transport coefficient is the sensitivity of the flux to the forcing \[ \alpha_{F,R} = \lim_{\eta\to 0}\,\frac1\eta \langle R\rangle_\eta = \int_{\mathcal{X}}R(x)\,\partial_\eta\left.\mu_\eta(\mathrm{d}x)\right|_{\eta=0} \]
Challenge: derivative of a high-dimensional integral
Recent review1 of computational approaches and numerical analysis
Nonequilibrium molecular dynamics
Fix \(\eta>0\), run the nonequilibrium dynamics and make finite difference + ergodic approximations \[ \widehat\alpha_{T,\eta}^{\,\mathrm{NEMD}} = \frac{1}{\eta}\,\frac1T\int_0^T R(X_t^\eta)\,\mathrm{d}t \]
Variance \(\mathcal O(T^{-1}\eta^{-2})\): \(\eta\gg 1 \rightarrow\) low variance/high bias or \(\eta\ll 1 \rightarrow\) high variance/low bias
Green–Kubo
Linear response theory gives the Green-Kubo formula \[ \alpha_{F,R} = \int_0^{\infty} \mathbb E_{X_0\sim \mu_0}\left[R(X_t^{0})\,S_F(X_0^{0})\right]\,\mathrm{d}t \]
Integrand is an average over equilibrium paths of the dynamics \(X^0\)
\(S_F:\mathcal{X}\to\mathbb{R}\) is the conjugate flux observable, explicit in terms of \(F\)
Simple estimator \[ \widehat\alpha_T^{\,\mathrm{GK}} = \frac1{K}\sum_{k=1}^K \int_0^T R(X_t^{0,(k)})S_{F,R}(X_0^{0,(k)})\,\mathrm{d}t \]
Unbiased when \(T\to\infty\), but time-truncation \(\rightarrow\) bias/variance tradeoff
Transient methods (relaxation towards1 or away from2 equilibrium) also express \(\alpha_{F,R}\) using integrated correlation functions
Shearing force profile \[ F(q,v) = \sum_{i=1}^N m_i^{-1}\sin\!\left(\frac{2\pi q_{i,y}}{L}\right)\mathbf{e}_{v,x} \]
Velocity response \[ R(q,v) = \frac1N\sum_{i=1}^N v_{i,x}\,\mathrm{e}^{2\mathrm{i}\pi q_{i,y}/L} \]
\(R\) is an empirical principal Fourier coefficient of the velocity profile
\(\alpha_{F,R}\) gives an estimate of the shear viscosity
Molly.jlMD in pure Julia, part of JuliaMolSim. Main developer: Joe Greener (Laboratory of Molecular Biology, Cambridge UK)
Main focus is differentiable simulation to parametrize biomolecular force fields1
Growing feature list (standard interaction terms, particle mesh Ewald, standard integrators, thermostats and barostats, constraints via SHAKE/RATTLE, neighbour lists, some enhanced sampling and free-energy estimators)
Compatibility with atomistic simulation ecosystem (AtomsBase.jl and AtomsCalculators.jl interfaces, units with Unitful.jl, parsing/writing with Chemfiles.jl, OpenMM force fields, ASE, GPU acceleration with KernelAbstractions.jl)
Extensible: simple use of custom interaction terms, loggers and simulators
Molly.jlSystem setup
using Molly, Unitful
import Molly.AtomsCalculators
const force_unit, energy_unit = u"pN", u"pN*Å" # define your physical conditions
const N, T, ρ = 216, 85u"K", 1.41u"g/cm^3" # number of atoms, temperature, density
const m = 39.95u"u" # mass of an argon atom
const ϵ = uconvert(energy_unit, 0.0103u"eV") # Lennard-Jones energy
const σ, rc = 3.405u"Å", 2σ # interaction and cutoff length
const L = uconvert(u"Å", cbrt(N * m / ρ)) # box length
const γ = m / uconvert(u"ps", σ * sqrt(m / ϵ)) # friction (for Langevin)
const dt, β = 2.0u"fs", inv(Unitful.k * T)
boundary = CubicBoundary(L, L, L) # system setup
coords = place_atoms_on_cubic_lattice(6, 6, 6, boundary)
velocities = [random_velocity(m, T) for i in 1:N]
atoms = [Atom(index=i, ϵ=ϵ, σ=σ, mass=m) for i in 1:N]
lj = LennardJones(cutoff=ShiftedForceCutoff(rc), use_neighbors=true) # Lennard-Jones pairwise potential
nf = CellListMapNeighborFinder(eligible=trues(N, N), n_steps=1,
unit_cell=boundary, dist_cutoff=rc) # setup neighbor list
integrator = LangevinSplitting(dt=dt, temperature=T, friction=γ,
remove_CM_motion=0, splitting="ABOBA") # underdamped Langevin integrator
sys = System(atoms=atoms, coords=coords, velocities=velocities, boundary=boundary,
pairwise_inters=(lj,), neighbor_finder=nf,
force_units=force_unit, energy_units=energy_unit)
function fourier_flux(s::System, args...; kwargs...) # define the flux observable
return sum(s.velocities[i][1] * exp(2im * π * s.coords[i][2] / L)
for i in 1:N) / N
end
const TR = typeof(fourier_flux(sys))Run with simulate!(sys,integrator,n_steps)
NEMD
Only requires defining a custom interaction (a type, and a method for AtomsCalculators.forces)
struct ShearForcing{F,T} # interaction type
force_profile::F
η::T
end
function AtomsCalculators.forces(s::System,
inter::ShearForcing, args...; kwargs...) # force computation
f = ustrip_vec.(similar(s.coords)) * s.force_units
@inbounds for i in eachindex(f)
fx = inter.η * inter.force_profile(s.coords[i][2]) # force in x according to y-position
f[i] = SVector(fx, zero(fx), zero(fx))
end
return f
end
profile(y) = sin(2π * y / L) * force_unit # sinusoidal force profile
forcing = ShearForcing(profile, 5.0)
sys_nemd = System(sys; general_inters=(forcing,),
loggers=(R=GeneralObservableLogger(fourier_flux, TR, 1),)) # log the fluxGreen–Kubo
Only requires adding a TimeCorrelationLogger
function shear_conjugate_flux(s::System, args...; kwargs...) # define the conjugate flux S_F
return β * sum(s.velocities[i][1] * sin(2π * s.coords[i][2] / L)
for i in 1:N) * s.force_units
end
const TS = typeof(shear_conjugate_flux(sys))
n_corr = 7500 # correlation window
gk = TimeCorrelationLogger(shear_conjugate_flux, fourier_flux,
TS, TR, 1, n_corr)
sys_gk = System(sys; loggers=(gk=gk,)) # log the autocorrelationEvery NEMD estimate is one \(100\,\mathrm{ps}\) trajectory
Green–Kubo estimate combines fifty \(450\,\mathrm{ps}\) trajectories (\(\approx 4.89 \times\) NEMD budget)
Both within \(15\%\) of the NIST reference despite crude interaction model (Lennard-Jones) and small system size (\(N=216\))
Run on a cluster of laptops at a CECAM summer school1
Variance reduction is an important objective
Macroscopically, forcing and flux are co-determined by a constitutive equation \(\overline{R} = \alpha_{F,R}\,\overline{F}\)
NEMD fixes \(\overline{F}\) and measures \(\overline{R}\) (a conductance); the dual approach fixes \(\overline{R}\) and measures the average forcing needed to sustain it (a resistance)
Stochastic generalization1 of the Norton method of Evans and Morriss2
Constrained dynamics
Recall the NEMD dynamics \[ \mathrm{d}X_t^\eta =\color{blue}{ b(X_t^\eta)\,\mathrm{d}t + \sigma(X_t^\eta)\,\mathrm{d}W_t} + \color{red}{\eta F(X_t^\eta)\,\mathrm{d}t} \]
Replace the constant forcing magnitude \(\eta\) by a stochastic forcing process \[ \mathrm{d}Y_t^r =\color{blue}{ b(Y_t^r)\,\mathrm{d}t + \sigma(Y_t^r)\,\mathrm{d}W_t} +\,\color{green}{ F(Y_t^r)\mathrm{d}\Lambda_t^r} \]
chosen so that the flux is fixed exactly \[ R(Y_t^r) = r,\qquad \forall\, t\geqslant 0 \]
This determines \(\Lambda^r\) as \[ \Lambda_t^r = \int_0^t \lambda(Y_s^r)\,\mathrm{d}s + \int_0^t \widetilde\lambda(Y_s^r)\,\mathrm{d}W_s \] for explicit observables \(\lambda:\mathcal{X}\to\mathbb{R}\) and \(\widetilde\lambda:\mathcal{X}\to \mathbb{R}^{1\times d}\)
Reciprocal estimator of the linear response
\[ \alpha_{F,R} = \lim_{\eta\to 0}\frac{\langle R\rangle_\eta}{\eta} \qquad \alpha^*_{F,R} = \lim_{r\to 0}\frac{r}{\langle \lambda\rangle_r} \]
Measure a resistance by averaging \(\lambda\) along the constrained trajectory
Dual pair of nonequilibrium ensembles wrt flux/forcing
Fixed exactly vs fixed on average by the steady state (like the microcanonical and canonical duality for energy/temperature)
Averaging \(\lambda\) discards the martingale component \(\widetilde\lambda\) variance reduction with a control variate
Molly (a type, and a method for Molly.simulate!)Compare finite-difference/ergodic estimators of the linear responses (\(N=1000\))
Agreement in the linear regime, and well beyond
We do not expect \(\alpha_{F,R} = \alpha^*_{F,R}\) in general, but consistency in the thermodynamic limit \(N\to\infty\) (counterexamples exist)
The asymptotic variance \(\sigma^2(f)\approx\mathrm{Var}(f)\tau_{\mathrm{corr}}(f)\) is the prefactor in the CLT for ergodic averages
Expected scaling in \(N\) is \(\sigma^2(f)\asymp N^{-1}\) by a spatial CLT
Constant-flux asymptotic variance shows anomalous scaling, due to \(\mathrm{Var}(\lambda)\asymp N^{-5/3}\) (also observe \(\tau_{\mathrm{corr}}(\lambda) \ll \tau_{\mathrm{corr}}(R)\))
Similar results for the constant-flux method in nonequilibrium DPD1
Transport coefficients are a computational and mathematical challenge
Innovative variance reduction methods are needed, and have to be tested beyond toy examples (realistic systems, realistic simulation budgets)
Molly.jl helps bridge the gap between promising mathematical ideas and promising algorithms
Most of the theory for the constant-flux method is still open (some work currently under way1)
Thank you !