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

Monodisperse Percus--Yevick fluid at several densities

Binary-mixture Percus–Yevick pair correlations

Binary-mixture Percus--Yevick pair correlations

Percus Yevick mixture solver workflow

Percus Yevick mixture solver workflow

Scattering Example: Percus Yevick Structure Factor and Phase Function

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.

Analytical evaluation scaling

Analytical evaluation scaling

RSA generation scaling

RSA generation scaling

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.

Minimal random sequential adsorption

Minimal random sequential adsorption

Periodic-boundary RSA packing

Periodic-boundary RSA packing

Comparing radius samplers

Comparing radius samplers

Equilibrating an RSA configuration with Metropolis moves

Equilibrating an RSA configuration with Metropolis moves

A full workflow example with PackLab

A full workflow example with PackLab

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.

Single-particle scattering amplitudes

Single-particle scattering amplitudes

Mixture phase function with a structure factor

Mixture phase function with a structure factor

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

Metropolis hard-sphere samples versus Percus--Yevick

Convergence of the Percus–Yevick reference

Convergence of the Percus--Yevick reference

PackLab Percus–Yevick versus the Tsang et al. reference

PackLab Percus--Yevick versus the Tsang et al. reference

PackLab monodisperse Percus–Yevick versus Tsang et al.

PackLab monodisperse Percus--Yevick versus Tsang et al.

RSA ensemble versus a Percus–Yevick reference

RSA ensemble versus a Percus--Yevick reference

Gallery generated by Sphinx-Gallery