Packing3D: An Open-Source Analytical Framework for Computing Packing Density and Mixing Indices Using Partial Spherical Volumes Journal: Computer Physics Communications

Freddie Barter, Christopher R. K. Windows-Yule · 2025

Read Packing3D: An Open-Source Analytical Framework for Computing Packing Density and Mixing Indices Using Partial Spherical Volumes Journal: Computer Physics Communications by Freddie Barter, Christopher R. K. Windows-Yule (2025) in the Tower of Babel, a free online library of public-domain works preserved in clean, searchable text. No sign-up. The full text is served as a plain-text file at a predictable URL, where text is present: https://antarctic-labs.com/tower-of-babel/arxiv-2506-08852.txt.

Introduction

Counting how tightly grains pack in a simulated powder sounds simple, yet a 2025 paper by Freddie Barter and Christopher Windows-Yule shows the usual method lies. Counting only grain centers inside each box of space makes the density jump at box edges, which corrupts the measure.

Their open-source Julia package, Packing3D, instead computes the exact share of each sphere that falls inside each cell, for flat and round meshes alike. Closed-form math covers the ways spheres and caps can overlap. Checks against perfect crystal lattices hit the true densities exactly, and the jumps at cell edges vanish. The tool also reports mixing measures and stays light on memory as particle counts grow.

Catalog record

CREATORFreddie Barter, Christopher R. K. Windows-Yule
YEAR2025
COLLECTIONPAPERS
FORMATTXT
FILE SIZE36 KB
VERSION1.0
LICENSEhttp://creativecommons.org/licenses/by/4.0/
RIGHTSCC BY
SOURCEarXiv

Source: https://arxiv.org/abs/2506-08852

Browse the full library · About the Tower of Babel

Full text

The opening of the work, from the library's hosted text:

Packing3D: An Open-Source Analytical Framework for Computing Packing Density and Mixing Indices Using Partial Spherical Volumes Journal: Computer Physics Communications Freddie Barter, Christopher R. K. Windows-Yule Abstract Accurate quantification of local packing density and mixing in simulations of particulate systems is essential for many industrial applications. Traditional methods which simply count the number of particle centres within a given volume of space (cell) introduce discontinuities at cell boundaries, leading to unreliable measurement of packing density. We introduce Packing3D.jl, an open-source Julia package providing analytic, partial-volume calculations for spheres intersecting Cartesian and cylindrical meshes. Our goals were to (1) eliminate boundary-artefact jumps, (2) maintain high throughput on large datasets, and (3) deliver standard mixing metrics via a unified API. We derive closed-form solutions for single, double and triple spherical-cap intersections, plus sphere–cylinder overlaps. A short-circuit bounding-sphere test shortens computations: fully inside or outside spheres are handled in 𝒪 ⁡ ( 1 ) \mathcal{O}(1) time, and only near-boundary spheres invoke the analytic kernels. We implement efficient mesh-generation routines, principal-cell indexing, and data-splitting functions for time-series analyses. Performance and accuracy were validated against simple cubic and face-centred cubic lattices and via boundary-shift continuity tests. Packing3D.jl converges exactly to theoretical lattice densities, eliminates discontinuities at sub-particle resolution, and processes up to 10 8 10^{8} sphere–cell intersections per second in single-threaded Julia with linear scaling in particle count. Memory usage remains modest (40 B per particle, 48 B per cell). Packing3D.jl provides researchers with continuous, reproducible volume-fraction fields and robust mixing indices at high performance, facilitating sensitivity analyses and optimisation in granular process engineering. The package is freely available at https://github.com/fjbarter/Packing3D.jl . Program Summary Program Title: Packing3D Developer’s repository link: https://github.com/fjbarter/Packing3D.jl Licensing provisions: MIT Programming language: Julia Nature of problem: Accuracy and continuity of packing density calculation by counting centres Solution method: Derive and implement a fast algorithm for analytically calculating particle volumes intersected by planes, providing a continuous and much more accurate measurement of packing density 1 Introduction Granular assemblies underpin processes such as tablet coating, vibro-packing, powder-bed fusion and silo discharge [ 1 , 2 , 3 ] . Powder characterisation required for optimisation of these processes frequently involves calculation of the Hausner ratio H [ 4 ] , defined as H=\phi_{T}/\phi_{B} , where \phi_{T} and \phi_{B} are the ’tapped’ and freely settled bulk packing density of the powder, respectively. Calculation of the Hausner ratio therefore requires measurement of packing density twice, and is dependent on this measurement being accurate and sensitive. Typically, one estimates packing density by first subdividing the domain of interest into a mesh of small volumetric elements (commonly called ‘cells’). In a mesh, each cell is defined by its boundary surfaces (in Cartesian grids, these are rectangular hexahedra; in cylindrical grids, wedge-shaped cylindrical sectors). Once the mesh is in place, the total particle volume within each cell is computed and divided by the cell’s volume to yield a local packing density. In most discrete-element-method (DEM) post-processing routines, the simplest approach is applied: a particle is assigned to the single cell that contains its geometric centre, and its entire volume is counted toward that cell’s total. While straightforward to implement, this ‘centre-counting’ rule produces step changes in packing density whenever a sphere crosses a boundary of the region, leading to inconsistent packing density measurement and distorting mixing indices. Monte-Carlo sampling of the overlapped particle volume can be used to remove the discontinuity, but at prohibitive computational cost [ 5 ] . To close this gap for simulation data, we present Packing3D.jl, a Julia package that generalises the sphere–plane solution to single, double and triple intersections and adds numerical sphere–cylinder overlaps, delivering continuous packing densities and standard mixing metrics (e.g., Lacey index, segregation intensity) on both Cartesian and cylindrical meshes through a single high-level API. Dodd and Theodorou [ 6 ] provided the first analytic expressions for sphere–plane overlaps via cone–pyramid decomposition, laying the groundwork for exact partial-volume calculations. Building on their foundation, Packing3D.jl offers artefact-free, reproducible volume-fraction fields while remaining fast enough for large-scale DEM datasets. In the following sections, we derive the underlying geometry, benchmark our implementation against traditional centre-counting, providing researchers with a reliable, open-source tool for accurate packing and mixing analysis. 2 Mathematical Foundations 2.1 Geometric Primitives We first present a method to calculate the partial volume of a sphere of radius R inside an arbitrary convex cell of orthogonal planar boundaries. A sphere in a given position may intersect one, two, or three such boundaries, provided those of a given direction are separated by a distance greater than the diameter of the sphere. We denote by a , b , and c the signed distances from the sphere’s centre to the three orthogonal planar boundaries. For a given signed distance d to a boundary, where d\in\{a,b,c\} , a sphere overlaps that boundary exactly when -R<d<R . Depending on the number of overlaps, we recognise three base geometric primitives that comprise the partial volume in question: 1. Single spherical cap. A sphere intersecting a single plane at signed distance a from its centre produces a cap of height h=R-a . Its volume is V_{\mathrm{cap}}=\frac{\pi}{3}h^{2}(3R-h) (1) 2. Double-cap intersection. For two orthogonal planes at signed distances a and b from the sphere centre, the partial volume takes the form of an intersection of two spherical caps, denoted a ’double-cap intersection.’ Consider a horizontal cross-section of the sphere at height z . This section is a circle of radius r=\sqrt{R^{2}-z^{2}} , and the area of intersection between this circle and the two overlapped boundaries (which become lines when projected onto the section) is a circular sector of angle \theta_{\mathrm{sector}}=\frac{\pi}{2}-\sin^{-1}\left(\frac{a}{r}\right)-\sin^{-1}\left(\frac{b}{r}\right) (2) minus two triangular areas. The triangle bases are a and b , and the cross-sectional area therefore becomes \begin{split}A(z)=&\frac{1}{2}r^{2}\theta_{\mathrm{sector}}-\\ &\frac{1}{2}a\left(\sqrt{r^{2}-a^{2}}-b\right)-\\ &\frac{1}{2}b\left(\sqrt{r^{2}-b^{2}}-a\right)\end{split} (3) Integrating A(z) then yields an exact closed-form solution for the double-cap intersection volume. 3. Triple-cap intersection. When three orthogonal planes at signed distances a,b,c all intersect the sphere, one again integrates the same cross-sectional formula of Equation 3 , limiting the integration in z so that |z|\leq R-c . Besides the minor triple-cap intersection ( a,b,c>0 ), each of the remaining seven sign-combinations of (\pm a,\pm b,\pm c) reduces to combinations of simpler volumes, and all admit analytic antiderivatives in elementary functions. An illustration of these three different types of analytically solved intersection volumes is given in Figure 1 . By default, sphere–cylinder intersections are simplified by assuming the cylinder’s curvature is negligible compared to that of the sphere, so overlaps are computed as if the sphere intersects a plane tangent to the cylinder. Packing3D does offer a numerical solution for cylindrical boundaries, but it offers minimal benefit for significant computational expense. If the user desires, it can be manually enabled with the accurate_cylindrical boolean keyword argument. Figure 1: Schematic illustration of three partial boundary overlap cases for a spherical particle: ( a ) single boundary intersection, ( b ) double boundary intersection, and ( c ) triple boundary intersection. The red shading indicates a partial volume of interest in each case. Intersecting planes (boundary edges) are indicated by fixed constant values for a given axis (x=a,y=b,z=c) 2.1.1 Cross-section Antiderivative Upon substitution for r and \theta_{sector} into Equation 3 , A(z) becomes: A(z)=\frac{1}{4}\pi(R^{2}-z^{2})\\ -\frac{1}{2}R^{2}\sin^{-1}\left(\frac{a}{R^{2}-z^{2}}\right)+\frac{1}{2}z^{2}\sin^{-1}\left(\frac{a}{R^{2}-z^{2}}\right)\\ -\frac{1}{2}R^{2}\sin^{-1}\left(\frac{b}{R^{2}-z^{2}}\right)+\frac{1}{2}z^{2}\sin^{-1}\left(\frac{b}{R^{2}-z^{2}}\right)\\ -\frac{1}{2}a\sqrt{R^{2}-z^{2}-a^{2}}-\frac{1}{2}b\sqrt{R^{2}-z^{2}-b^{2}}\\ +ab

Read the complete text