Badge |
Status |
|---|---|
Python versions |
|
Documentation |
|
Continuous integration |
|
Test coverage |
|
PyPI package |
|
PyPI downloads |
|
Anaconda package |
|
Anaconda downloads |
|
Latest Anaconda release |
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.7
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Built distributions (wheels)
| File | Reset | |||
|---|---|---|---|---|
| packlab-0.6.7-cp313-cp313-win_amd64.whl | CPython 3.13 | CPython 3.13 | Windows x86-64 | Details |
| packlab-0.6.7-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.7-cp313-cp313-macosx_26_0_arm64.whl | CPython 3.13 | CPython 3.13 | macOS 26.0+ ARM64 | Details |
| packlab-0.6.7-cp312-cp312-win_amd64.whl | CPython 3.12 | CPython 3.12 | Windows x86-64 | Details |
| packlab-0.6.7-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.7-cp312-cp312-macosx_26_0_arm64.whl | CPython 3.12 | CPython 3.12 | macOS 26.0+ ARM64 | Details |
| packlab-0.6.7-cp311-cp311-win_amd64.whl | CPython 3.11 | CPython 3.11 | Windows x86-64 | Details |
| packlab-0.6.7-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.7-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.7-cp313-cp313-win_amd64.whl
| Download URL | packlab-0.6.7-cp313-cp313-win_amd64.whl |
|---|---|
| Size | 5.2 MB |
| Tags | CPython 3.13 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
fb6e1ad4260f49c45cf05305b6422aead5728e4d02f6125f46e1deb6bd40e498
|
|
BLAKE2b-256 checksum How to use checksums |
0f74c8e7d005af0ed8b3d3e7578281dc30da731931f0efd4758dfa625f76e071
|
| 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.7-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
| Download URL | packlab-0.6.7-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 |
ad1a68280ec33afaa10d8a594f439a48578df601a4e4de68cc3654abb517edcc
|
|
BLAKE2b-256 checksum How to use checksums |
0ace0a42f98270d85c68522658512d555da3a405a26a8711ae7c2543f234a300
|
| 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.7-cp313-cp313-macosx_26_0_arm64.whl
| Download URL | packlab-0.6.7-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 |
20ff863a7b52fd8219d7a4a028a8bec6d6c60788ea6e824465a3a0811b88337c
|
|
BLAKE2b-256 checksum How to use checksums |
5d0a9c39beef37f0acdcb2cb0d8fad527e4646acc9b4f812a32dc8e2cc941e5a
|
| 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.7-cp312-cp312-win_amd64.whl
| Download URL | packlab-0.6.7-cp312-cp312-win_amd64.whl |
|---|---|
| Size | 5.2 MB |
| Tags | CPython 3.12 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
31c2f9c40d4a699ba2c52baabcd108504f920b77d9642cc9fafea201962c9b61
|
|
BLAKE2b-256 checksum How to use checksums |
c20c9a74bd970f56b5cfc1ac29517255812614d7417a6222efb80a969584e18f
|
| 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.7-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
| Download URL | packlab-0.6.7-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 |
ac0a2743a764925cfe4954b4d5e350f93510aaf2a6f57565665d581f1306f551
|
|
BLAKE2b-256 checksum How to use checksums |
905b8ff25e2d5fe3f123b68d26abdd14105c086742d1792f753d0310ec032523
|
| 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.7-cp312-cp312-macosx_26_0_arm64.whl
| Download URL | packlab-0.6.7-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 |
9bcde5cb0ccdc7238154fda66671e2c2fbb18943a887e4d7c1c040ce8f4fbdd4
|
|
BLAKE2b-256 checksum How to use checksums |
06e8b4264f4922b9ada6efde0c08cf071553c16cf751f067baaa1e6de7823d99
|
| 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.7-cp311-cp311-win_amd64.whl
| Download URL | packlab-0.6.7-cp311-cp311-win_amd64.whl |
|---|---|
| Size | 5.2 MB |
| Tags | CPython 3.11 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
b33f43bbe539c5fedc35bfd3400444382724a4073f03ea61f5b9e5a71c0b9bb2
|
|
BLAKE2b-256 checksum How to use checksums |
eec8cb117eb23f3bcf4cb3693cb892339f0da4d40ba4cde52593a1425647996a
|
| 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.7-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
| Download URL | packlab-0.6.7-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 |
42200f111b002ff2004be54f21ed6663e9c31bdee2023d2c29e2059aeab91b6d
|
|
BLAKE2b-256 checksum How to use checksums |
1e8f3f4961f728605c123574d1bc6750cd6ca41fa2e201f95fe8ba7596daa284
|
| 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.7-cp311-cp311-macosx_26_0_arm64.whl
| Download URL | packlab-0.6.7-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 |
f54a63421933a9e8c86dbad680ec85d490b5aa85ecdff1d3d700482431d661ef
|
|
BLAKE2b-256 checksum How to use checksums |
882e0658240d288c39ba968d1d697beebc4a0a1352b988bf54b89d669fb710b1
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.9.25
|