Random Close Packing Generator In Arbitrary Dimensions

Version 1.0.7 (14.7 KB) by Kenneth
Generate large dense high polydisperse circle, sphere, and hypersphere packings in N-D with periodic, hard, or circular boundaries.
35 Downloads
Updated 16 May 2025

View License

This MATLAB implementation offers a method to generate dense random close packings (RCP) of circles, spheres, or hyperspheres using the Adam optimizer. The tool is ideal for generating dense packings and jammed states, often used in physics simulations and 3D printing. Able to handle very large size ratios, with prior success in generating packings that have particle diameter ratios > 100 in 2D, > 50 in 3D, > 15 in 4D, and > 5 in 5D.
The code supports monodisperse and polydisperse particle size distributions and can handle arbitrary dimensions (2D–ND). The initialize_particlesND function is included to easily initialize packings with a variety of particle size distributions.
Key Features:
  • Supports 2D–ND random close packings.
  • Fully customizable particle size distributions.
  • Plotting functions included to visualize packings
  • Periodic, flat, and circular boundary conditions are available
  • Able to generate packings with size ratios exceeding 100.
How to use:
  1. Add the script to your MATLAB path.
  2. First, call initialize_particlesND to initialize particle positions and diameters.
  3. Then, call CreatePacking using the initial positions and diameters to generate a packing.
  4. See the GitHub page for more detailed instructions and available flags.
Code available on GitHub:
The full source code (including C++ implementation), examples, and documentation are available on the GitHub page.
References
  • Desmond, K. W., & Weeks, E. R. (2014). Influence of particle size distribution on random close packing of spheres. Physical Review E, 90(2), 022204. arXiv:1303.4627
  • Desmond, K. W., & Weeks, E. R. (2009). Random close packing of disks and spheres in confined geometries. Physical Review E, 80(5), 051305. arXiv:0903.0864

Cite As

Kenneth (2026). Random Close Packing Generator In Arbitrary Dimensions (https://www.mathworks.com/matlabcentral/fileexchange/181165-random-close-packing-generator-in-arbitrary-dimensions), MATLAB Central File Exchange. Retrieved .

MATLAB Release Compatibility
Created with R2023b
Compatible with R2022a to R2025a
Platform Compatibility
Windows macOS Linux
Version Published Release Notes
1.0.7

--

1.0.6

--

1.0.4

Updated Examples

1.0.3

Updated Examples

1.0.2

--

1.0.1

--

1.0.0