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

Binary-mixture composition at fixed volume fraction

Binary-mixture composition at fixed volume fraction

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

Analytical wavenumber-grid cost

Analytical wavenumber-grid cost

Percus–Yevick mixture-size scaling

Percus--Yevick mixture-size scaling

Metropolis sampling cost per sweep

Metropolis sampling cost per sweep

RSA generation scaling

RSA generation scaling

RSA cost at different target fractions

RSA cost at different target fractions

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 single-sphere examples explore size, wavelength, and optical contrast. The mixture examples compare independent scattering with a structure-corrected Percus–Yevick reference. The latter is an analytical 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

Single-sphere wavelength sweep

Single-sphere wavelength sweep

Effect of optical contrast

Effect of optical contrast

Independent scattering from a size mixture

Independent scattering from a size mixture

Validation and comparison#

These examples make complementary validation checks:

  • compare an ensemble of explicit, finite RSA packings with a matching Percus–Yevick reference, including the RSA standard error, and repeat the comparison across packing fractions;

  • 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 across mixture sizes and volume fractions.

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

Grid refinement across mixture regimes

Grid refinement across mixture regimes

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 ensembles across packing fractions

RSA ensembles across packing fractions

RSA ensemble versus a Percus–Yevick reference

RSA ensemble versus a Percus--Yevick reference

Gallery generated by Sphinx-Gallery