# Packing spheres inside a geometry

I am looking for packing spheres (can be monodisperse or polydisperse with known radii distribtuions) inside a geometry. I am sure this is a well explored scientific problem with applications in different fields. This being the case, is there anyone who knows a library/code which can achieve this?

Note: The packing need not be the highest solids volume fraction possible for the given geometry.

• It's a really difficult problem. Do you want to achieve a certain packing density? If yes, that needs some sort of simulations. Do you know that maximum packing density is when you put the spheres in a FCC lattice? Also, your geometry is just a cube or you have a fancy irregular shape geometry? You missed a lot of information here. – Alone Programmer Jan 23 at 20:35
• The objective is to achieve a specified packing density with a max limit of 0.6. The geometry would be arbitrary and not just cube. Otherwise, I can write a script for FCC lattice which can achieve about 0.74 max packing. – SKPS Jan 23 at 20:40
• That's a really tough problem to reach packing density of 0.6. With simple random putting the spheres in a cube you could achieve a packing density of 0.3 right away, but beyond 0.3, you need to do mechanical simulation of packing the spheres and that needs lots of information about their mechanical properties and more importantly their contact mechanics information. – Alone Programmer Jan 23 at 20:44
• Yes, I could understand. I am not looking for writing a program for this. Question is if there are packages/libraries to achieve this packing. For example, this. – SKPS Jan 23 at 20:47
• The answer is no! – Alone Programmer Jan 23 at 20:49

A possibility is to use Lloyd's method , it works as follows:

1. Choose N points randomly in the input geometry
2. Compute the Voronoi diagram of the points clipped by the input geometry
3. Replace each point by the centroid of its Voronoi cell
4. If not converged, goto 2

The algorithm is implemented in my geogram library  (works for an arbitrary geometry, bounded by a closed triangulated surface). An in-browser demo is available for a cube geometry  (or "flat torus" periodic space).

Note: it evenly distribute the points in the input geometry, but does not necessarily generates a tight packing.

The packing of spheres (or non-spherical particles) within a geometry can be achieved quite reliably using the Discrete Element Method. I refer you to the following introduction article (written by me and co-workers) on the topic: https://onlinelibrary.wiley.com/doi/full/10.1002/cjce.23501

Briefly, the discrete element method (DEM) is a molecular dynamics inspired techniques where you calculate the motion of each individual particles by integration Newton's law of motion for each of them. The particle-particle and particle-wall contacts are handled by allowing for minute overlap between the particles (which are very small). These overlaps are then used within simple contact models. These models may be simple (linear spring) or more complex (hertzian spring + damping) and they have parameters which you have to tune to reproduce the mechanical behavior of your particles. These parameters are generally the static coefficient of friction or the rolling coefficient of friction.

DEM is relatively computationnaly intensive because you need to track all particles. However, using MPI, you can generally simulation a large amount of particles (over a million). There are also extensions of DEM to non-spherical particles.

There are some good open source codes such as :

DEM can even be coupled to CFD in what is referred to as CFD-DEM. You can look at the following journal article for a short introduction to it (written by my PhD student and I): https://onlinelibrary.wiley.com/doi/full/10.1002/cjce.23686

You can look at the following online movies made by my group for an illustration. For pure DEM : https://www.youtube.com/watch?v=__5UGx4fQps