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.6

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.6
File
packlab-0.6.6-cp313-cp313-win_amd64.whl CPython 3.13 CPython 3.13 Windows x86-64 Details
packlab-0.6.6-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl CPython 3.13 CPython 3.13 Linux glibc 2.27+ x86-64, Linux glibc 2.28+ x86-64 Details
packlab-0.6.6-cp313-cp313-macosx_26_0_arm64.whl CPython 3.13 CPython 3.13 macOS 26.0+ ARM64 Details
packlab-0.6.6-cp312-cp312-win_amd64.whl CPython 3.12 CPython 3.12 Windows x86-64 Details
packlab-0.6.6-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.6-cp312-cp312-macosx_26_0_arm64.whl CPython 3.12 CPython 3.12 macOS 26.0+ ARM64 Details
packlab-0.6.6-cp311-cp311-win_amd64.whl CPython 3.11 CPython 3.11 Windows x86-64 Details
packlab-0.6.6-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl CPython 3.11 CPython 3.11 Linux glibc 2.27+ x86-64, Linux glibc 2.28+ x86-64 Details
packlab-0.6.6-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.6-cp313-cp313-win_amd64.whl

Download URL packlab-0.6.6-cp313-cp313-win_amd64.whl
Size 5.2 MB
Tags CPython 3.13 Windows x86-64
SHA-256 checksum
How to use checksums
d6f56e0f75601c2a4463c6caa6aa550cd60a02eefa20a171771630f389d55335
BLAKE2b-256 checksum
How to use checksums
45cf3e378390ba6fd0bb60da0935a2cb4525d09841e4ed8dbc99bd4878fbdb57
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.6-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl

Download URL packlab-0.6.6-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
2c98005c396f039fdf14b2b2c9fc9dd86c18dd00655426849f2735235a41051f
BLAKE2b-256 checksum
How to use checksums
109bf80f705456591ad6dec71cb094b4823ea39ad7dd4f3e40ad1a1e950e5346
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.6-cp313-cp313-macosx_26_0_arm64.whl

Download URL packlab-0.6.6-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
84966bf97a5cc4fe234bcaf74b9a238ec4f49aef6905d5c73b1d91a12f3f5e89
BLAKE2b-256 checksum
How to use checksums
b2ca79c4cef6f11a109fade1867c4cdb3f6e5c09f4d0c22997d78410794d14ec
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.6-cp312-cp312-win_amd64.whl

Download URL packlab-0.6.6-cp312-cp312-win_amd64.whl
Size 5.2 MB
Tags CPython 3.12 Windows x86-64
SHA-256 checksum
How to use checksums
0be3ce42a66dfd0964c7e89b95e5cac948e27c94890cf965f9c4becfe576e422
BLAKE2b-256 checksum
How to use checksums
bc1b1ad95ce17ef0d9143336a2cd9172d4472d4950f1bbe992193f109f7f962f
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.6-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl

Download URL packlab-0.6.6-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
e2923ec986872afd2fd24157064ac85b8f54b34f84d0379ead324feea2e1d655
BLAKE2b-256 checksum
How to use checksums
dca32b3bf929f1b14760c8a25b3bdbf0b85d7b3c4f55241035a43d18fbf988d5
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.6-cp312-cp312-macosx_26_0_arm64.whl

Download URL packlab-0.6.6-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
efe2b6283da7c57ff833c2fe00ed2d9806d79e7d9303e7fc6dcc09997df42ffc
BLAKE2b-256 checksum
How to use checksums
827a2165640e14e4bf2646d9bc874f4650a9129becb7594b2bd4ef8fee8e9c17
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.6-cp311-cp311-win_amd64.whl

Download URL packlab-0.6.6-cp311-cp311-win_amd64.whl
Size 5.2 MB
Tags CPython 3.11 Windows x86-64
SHA-256 checksum
How to use checksums
d137feb4b48950f412066c4803345d197a07ada4b35473020102c1fbc69d685b
BLAKE2b-256 checksum
How to use checksums
cb1eeec975b8cabe8d483a485944071a9f9cf0c856b9a73fda6746cc58f1db65
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.6-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl

Download URL packlab-0.6.6-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
9208675f89938d1f8636756ec2547889a8982868d05e8772252958594b81688f
BLAKE2b-256 checksum
How to use checksums
971f9cce4f43805e318e7bfa89b3749a8a14ed74f5c2822e12b294d1cf7f2e83
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.6-cp311-cp311-macosx_26_0_arm64.whl

Download URL packlab-0.6.6-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
4ff91532e30eca7b3f21c69ab33411b3cace3dce2c3da90fa72c35804c663d8f
BLAKE2b-256 checksum
How to use checksums
42f4f12697c358d1ac2bc7fb96ced693d9e57ce93f84ea18d58a75452bd0322f
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

This release

0.6.6 This release

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

0.6.1

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