Examples#
The gallery is organised by the question each workflow answers:
Monte Carlo creates explicit RSA packings and samples fixed-volume equilibrium hard-sphere configurations with Metropolis moves.
Analytical evaluates Percus–Yevick mixture models and scattering quantities without generating a packing.
Scattering evaluates optional PyMieSim-backed optical amplitudes and phase functions for individual spheres and analytical mixtures.
Validation compares RSA and Metropolis estimates with their analytical counterparts.
Benchmarks records reproducible runtime, scaling, and memory measurements for supported workflows.
Start with the minimal RSA example, then use the Metropolis and validation examples when you need an equilibrium hard-sphere workflow or want to assess agreement with the analytical reference. Use benchmarks to measure computational cost for a clearly specified machine and workload; they do not establish physical agreement between models.
Analytical models#
Examples that solve the Percus–Yevick hard-sphere model directly. The
scattering workflow builds on this result and requires the optional
packlab[scattering] installation extra.
Monodisperse Percus–Yevick fluid at several densities
Scattering Example: Percus Yevick Structure Factor and Phase Function
Benchmarks#
This category contains reproducible performance benchmarks for PackLab’s public workflows. Each benchmark should state the machine and software environment, workload parameters, repetitions, timing method, and the metric being reported (for example runtime, throughput, or peak memory).
Benchmarks measure computational cost. They are distinct from the validation examples, which assess numerical resolution or compare models with matched physical inputs.
Monte-Carlo hard-sphere workflows#
Examples that generate explicit random sequential adsorption configurations. They cover the basic simulation setup, periodic boundary conditions, radius distributions, visualisation, and pair-correlation estimates. The Metropolis example starts from an RSA configuration but then uses a separate equilibrium hard-sphere workflow with fixed particle count and radii.
Equilibrating an RSA configuration with Metropolis moves
Scattering#
Examples for the optional PyMieSim-backed scattering workflow. Install the extra before running them:
$ pip install "packlab[scattering]"
The first example treats individual sphere sizes independently. The second combines the optical amplitudes with a Percus–Yevick mixture structure factor; it is an analytical scattering calculation, not a simulation of an RSA configuration.
Validation and comparison#
These examples make three complementary validation checks:
compare an ensemble of explicit, finite RSA packings with a matching Percus–Yevick reference, including the RSA standard error;
compare samples from a fixed-volume Metropolis hard-sphere chain with the same Percus–Yevick reference;
compare PackLab’s binary-mixture Percus–Yevick solution with digitised Percus–Yevick curves from Tsang et al. (2001);
compare PackLab’s monodisperse Percus–Yevick solution at $f=0.2$ and $f=0.3$ with digitised curves from the same reference;
verify convergence of the numerical Percus–Yevick inverse transform by refining its wavenumber grid.
RSA is an irreversible, history-dependent packing process. Metropolis samples the equilibrium hard-sphere ensemble only after adequate burn-in and sampling. Percus–Yevick is an analytical equilibrium reference, so agreement with RSA is informative but is not an expectation of exact equality.
Metropolis hard-sphere samples versus Percus–Yevick
PackLab Percus–Yevick versus the Tsang et al. reference
PackLab monodisperse Percus–Yevick versus Tsang et al.