Skip to main content

PackLab logo - sphere packing and correlation curve.

Badge

Status

Python versions

Supported Python versions

Documentation

Documentation status

Continuous integration

Continuous integration status

Test coverage

Test coverage

PyPI package

PyPI version

PyPI downloads

PyPI downloads

Anaconda package

Anaconda version

Anaconda downloads

Anaconda downloads

Latest Anaconda release

Latest Anaconda release date

PackLab

PackLab is an open-source Python package for generating and analysing three-dimensional hard-sphere packings. Its C++ core provides fast random sequential adsorption (RSA), while its analytical tools implement a Percus–Yevick model for mixture correlations and structure factors.

Use PackLab when you need an explicit non-overlapping configuration, a reproducible packing statistic, or a fast analytical reference for validating an RSA result.

Features

  • Random sequential adsorption of mono- and polydisperse spheres.

  • Periodic or finite box domains with configurable stopping criteria.

  • Radius samplers for constant, uniform, normal, log-normal, and discrete distributions.

  • Pair-correlation estimates, packing statistics, and Matplotlib plots.

  • Percus–Yevick mixture solver with automatic, resolution-aware wavenumber grids.

  • Optional PyMieSim integration for scattering and phase-function workflows.

  • Unit-aware quantities throughout, via TypedUnit.

Installation

Install the core package from PyPI:

pip install packlab

Install optional scattering support:

pip install "packlab[scattering]"

The conda package is also available:

conda install -c martinpdes packlab

Verify that the compiled extensions are available with the interpreter you will use for simulations:

python -c "import PackLab; print(PackLab.__version__)"

First RSA packing

Create a periodic domain, choose a radius distribution, configure the RSA stopping conditions, and run the simulation. Dimensional inputs carry units.

from PackLab import monte_carlo, samplers, ureg

domain = monte_carlo.PackingDomain(
    length_x=6 * ureg.micrometer,
    length_y=6 * ureg.micrometer,
    length_z=6 * ureg.micrometer,
    use_periodic_boundaries=True,
)
radii = samplers.UniformRadiusSampler(
    minimum_radius=100 * ureg.nanometer,
    maximum_radius=200 * ureg.nanometer,
    bins=12,
)
options = monte_carlo.RSAOptions()
options.random_seed = 42
options.maximum_attempts = 100_000
options.target_packing_fraction = 0.15

result = monte_carlo.RSASimulator(domain, radii, options).run()
print(result.statistics.packing_fraction_geometry)
result.plot_slice_2d()

Analytical reference

Use the analytical solver for a fast Percus–Yevick reference. With wavenumber="auto", PackLab chooses a zero-inclusive wavenumber grid from the particle radii and requested distance range.

import numpy as np

from PackLab import analytical, ureg

domain = analytical.PercusYevickDomain(
    size=10 * ureg.micrometer,
    radii=[100, 150] * ureg.nanometer,
    volume_fraction=0.15,
    number_fractions=[0.7, 0.3],
)
distances = np.linspace(0.2, 1.5, 300) * ureg.micrometer
solver = analytical.PercusYevickSolver(
    densities=domain.particle_densities_per_radius,
    radii=domain.radii,
    wavenumber="auto",
)
result = solver.compute(distances)
print(result.wavenumber)

For an explicit grid, use analytical.make_wavenumber_grid(...). PackLab warns when a manually supplied grid is too coarse for the requested distances.

Choosing a workflow

  • Use PackLab.monte_carlo when individual centres, sampled radii, box boundaries, or finite-size effects are important.

  • Use PackLab.analytical for fast parameter sweeps and an analytical correlation reference.

  • Use the validation gallery examples to compare a matching RSA configuration against the analytical model.

Documentation and examples

The online documentation contains theory, API reference, and executable examples organised into Monte-Carlo, analytical, and validation workflows.

Building from source

For development, clone the repository and install it in editable mode. A C++20 compiler and CMake are required to build the native extensions.

git clone https://github.com/MartinPdeS/PackLab.git
cd PackLab
pip install -e ".[testing,documentation]"

Testing

Run the test suite with:

pytest

Citing PackLab

If PackLab contributes to academic work, cite the archived Zenodo release you used. Release metadata is included in .zenodo.json.

Contributing and contact

Issues and pull requests are welcome. For questions or collaborations, contact Martin Poinsinet de Sivry-Houle.

Metadata

Release files for PackLab 0.6.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Built distributions (wheels)

Table of built distributions (wheels) for PackLab 0.6.1
File
packlab-0.6.1-cp313-cp313-win_amd64.whl CPython 3.13 CPython 3.13 Windows x86-64 Details
packlab-0.6.1-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl CPython 3.13 CPython 3.13 Linux glibc 2.28+ x86-64, Linux glibc 2.27+ x86-64 Details
packlab-0.6.1-cp313-cp313-macosx_26_0_arm64.whl CPython 3.13 CPython 3.13 macOS 26.0+ ARM64 Details
packlab-0.6.1-cp312-cp312-win_amd64.whl CPython 3.12 CPython 3.12 Windows x86-64 Details
packlab-0.6.1-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl CPython 3.12 CPython 3.12 Linux glibc 2.27+ x86-64, Linux glibc 2.28+ x86-64 Details
packlab-0.6.1-cp312-cp312-macosx_26_0_arm64.whl CPython 3.12 CPython 3.12 macOS 26.0+ ARM64 Details
packlab-0.6.1-cp311-cp311-win_amd64.whl CPython 3.11 CPython 3.11 Windows x86-64 Details
packlab-0.6.1-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl CPython 3.11 CPython 3.11 Linux glibc 2.28+ x86-64, Linux glibc 2.27+ x86-64 Details
packlab-0.6.1-cp311-cp311-macosx_26_0_arm64.whl CPython 3.11 CPython 3.11 macOS 26.0+ ARM64 Details

Total release size: 28.0 MB

Release files / packlab-0.6.1-cp313-cp313-win_amd64.whl

Download URL packlab-0.6.1-cp313-cp313-win_amd64.whl
Size 5.2 MB
Tags CPython 3.13 Windows x86-64
SHA-256 checksum
How to use checksums
a7b257f4e0cbfceabf7e921ba2d80a9898e7c8b2d09f4b5f2b9dc20b9b0da091
BLAKE2b-256 checksum
How to use checksums
56600e9dcfe5be92c3c1667b473c9f4e56235e77cf72ba7830373b06dde76788
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.9.25

Release files / packlab-0.6.1-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl

Download URL packlab-0.6.1-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Size 1.5 MB
Tags CPython 3.13 Linux glibc 2.27+ x86-64 Linux glibc 2.28+ x86-64
SHA-256 checksum
How to use checksums
4388eb954fcda4c65a9e5a12c299057c4c29687cc479d8ecbb0e00eb11099e6f
BLAKE2b-256 checksum
How to use checksums
c397f77cbb9d4d2748724929661284857e80f4fe583fb44a6041438565c9a3a9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.9.25

Release files / packlab-0.6.1-cp313-cp313-macosx_26_0_arm64.whl

Download URL packlab-0.6.1-cp313-cp313-macosx_26_0_arm64.whl
Size 2.7 MB
Tags CPython 3.13 macOS 26.0+ ARM64
SHA-256 checksum
How to use checksums
f706d4b7800f80f908ef84171948bd4c4b1239f48de1ea3c7b36b2a947ed9181
BLAKE2b-256 checksum
How to use checksums
aedf82c51dc1c312810da6a6cb86f3a68c3df72c282703fd4c19274df8126ceb
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.9.25

Release files / packlab-0.6.1-cp312-cp312-win_amd64.whl

Download URL packlab-0.6.1-cp312-cp312-win_amd64.whl
Size 5.2 MB
Tags CPython 3.12 Windows x86-64
SHA-256 checksum
How to use checksums
668368570a6d531834c98571ab79e011f4115d2097c1a63a4131c2fae159d1c5
BLAKE2b-256 checksum
How to use checksums
d7e1dc979c1ea89022e474a5c629720cdb0d886a21f01002bf029387f0cd26c3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.9.25

Release files / packlab-0.6.1-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl

Download URL packlab-0.6.1-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Size 1.5 MB
Tags CPython 3.12 Linux glibc 2.27+ x86-64 Linux glibc 2.28+ x86-64
SHA-256 checksum
How to use checksums
2ed8b6e98f6295c7dd7a9e3035da592fd15afc3d7db5690305abaa7f323f858d
BLAKE2b-256 checksum
How to use checksums
668099d3c6f48429af3783cebd4afec60b001344f0dccc09d87f49bb42d97e22
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.9.25

Release files / packlab-0.6.1-cp312-cp312-macosx_26_0_arm64.whl

Download URL packlab-0.6.1-cp312-cp312-macosx_26_0_arm64.whl
Size 2.7 MB
Tags CPython 3.12 macOS 26.0+ ARM64
SHA-256 checksum
How to use checksums
93583b0151d3931b30c3f01de5d5dd1f30892a60a5d54af252202df04def4f5e
BLAKE2b-256 checksum
How to use checksums
09fefbbce3d3186e93150a7999bb0f2b308becb66a7a6e893885ed0aa09f750e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.9.25

Release files / packlab-0.6.1-cp311-cp311-win_amd64.whl

Download URL packlab-0.6.1-cp311-cp311-win_amd64.whl
Size 5.2 MB
Tags CPython 3.11 Windows x86-64
SHA-256 checksum
How to use checksums
e588ebca3b0402ab2c3be67a06b79bc9d86aa8d4d208c1b829f8624150d55457
BLAKE2b-256 checksum
How to use checksums
3137a65c3a61451e29193c0ebbea49293b3071f4bac9dbf09c5a637022f2e200
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.9.25

Release files / packlab-0.6.1-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl

Download URL packlab-0.6.1-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Size 1.4 MB
Tags CPython 3.11 Linux glibc 2.27+ x86-64 Linux glibc 2.28+ x86-64
SHA-256 checksum
How to use checksums
066834cda39f6172d732e01ef62e4322ed207896596b97aae0b5b1e5039c74c3
BLAKE2b-256 checksum
How to use checksums
8a358602aaac540c37d7da3a8b45927300ad34beb3372e374f5bea56e48f7988
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.9.25

Release files / packlab-0.6.1-cp311-cp311-macosx_26_0_arm64.whl

Download URL packlab-0.6.1-cp311-cp311-macosx_26_0_arm64.whl
Size 2.7 MB
Tags CPython 3.11 macOS 26.0+ ARM64
SHA-256 checksum
How to use checksums
edc6e441781f26b7f7db0213e49e2ee0ce609228827c5b836c59ece7380b2c16
BLAKE2b-256 checksum
How to use checksums
95cb7a18dfc311830a5e8fcda540b7cdf334420baf1661bc0739095dd478e897
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.9.25

Release history Release notifications | RSS feed

0.7.8

9 release files

0.7.7

9 release files

0.7.5

9 release files

0.7.4

9 release files

0.7.3

9 release files

0.7.2

9 release files

0.7.0

9 release files

0.6.9

9 release files

0.6.8

9 release files

0.6.7

9 release files

0.6.6

9 release files

0.6.5

9 release files

0.6.4

9 release files

0.6.3

9 release files

0.6.2

9 release files

This release

0.6.1 This release

9 release files

0.6.0

9 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page