Efficient packing of non-overlapping Spheres and Shells with radii drown from Gaussian distribution with a certain mean and standard deviation



I would like to create a box of certain size (let say 5um x 5um x 5um) that efficiently packs a certain number of non-overlapping Spheres and another box that packs a number of non-overlapping Shells. The radius of the Spheres and the inner and outer radii of the shells are random variable drown from Gaussian distribution with certain mean and STD. Below is a picture to illustrate what I am aiming for (was done using molecular dynamics packing code developed by M. Skoge )

I tried the following structure groups: 1- Gaussian random particle distribution. 2- Linear random particle distribution and 3- Uniform random particle distribution. The problem is that these three have very low packing efficiency. By that I mean, there are so many spacing between the spheres (picture below). They are not as dense as the picture above. Which is very critical to me. Also, the radius is just a random number between r_min and r_max. Finally, they don’t give you the option to simulate shells or any other nano objects but spheres.

I guess my questions are: 1- How to make the radii of the sphere follow Gaussian distribution?
2- How to optimize the packing so that we can maximize the density with no gaps?
3- How to simulate random shell particles and not just spheres?



Hi @Pascal

Thank you for your questions in the KX. I am working on it right now.

  1. I think it can be easily done by using the randn command to assign a normal distribution for the radii.
  2. it should also be possible to increase the packing efficiency by increasing the “retry” value in the script, given you have set a high enough value for the “n sphere”.
  3. For a shell particle, did you mean like a sphere with empty core? If so, we can make use of the mesh order to do this.

I am working on some example files and will update the post as soon as I have them ready.

By the way, do you need the particles randomly distributed or you are working with some lattice structure? the latter one can speed up the time to calculate the positions on the particle. I can explain further once I have the files ready.


Hi @kchow,

Thanks a lot for your follow up.

I did increase the retry and n sphere. But I think the way Lumerical does the packing isn’t very efficient. It’s an optimization problem that’s why I mentioned "molecular dynamics packing code developed by M. Skoge " It will be great if lumerical can implement this algorithm.

Here is another example of efficient packing (videos on this website) http://math.lbl.gov/voro++/examples/cylinder/

For the shell, I meant that the shell has material n1,k1 and the inner volume has n2, k2 with r1 is from gaussian distribution with Mean1 and STD1 and r2 random variable form Gaussian with Mean2 and STD2. Similar to the picture below


Hi @Pascal

I think I have implemented requirement (1) and (3) in this FDTD file particles.fsp (544.9 KB)
. Now the particle radius should be distributed normally. You can define the radius mean and standard deviation. I have also define r1 and r2 for a shell particle like you said (you could also define different materials to it too!))

For (2), we will need some time to look into the information you provided. For now, the only way to increase the packing efficiency is that you will need to use a high value or “retry”. Note that the current algorithm can take a while if you have an extremely large number for “retry”. At the point, if you have too many particles in the CAD, you may experience some slow down in the CAD. I have added an option “detailed rendering” in the script. If you set this to 0, it will be using wireframe to speed up the graphical rendering process like discussed in this post. The index monitor in the fsp file will also allow you to check the spacing between particles in a cross section.

I will update you once we have some comments for the algorithm you suggested. Thank you for you patience.


Hi @kchow

Thanks a lot for this. It is really helpful. Efficient packing is an optimization problem that a lot of researchers need to implement. It might be useful to include an efficient packing algorithm in Lumerical but I am not sure how feasible that is.

Thanks for your help!


Hi @kchow

I would like to revisit the optimized packing problem. I was wondering if you guys at Lumerical are interested in integrating the “molecular dynamics packing” into the random particle distribution structure group as a way of maximizing the number of nano-particles packed in a given volume.

thx :slight_smile:


Hi @Pascal,

I am on a vacation right now but I can try to provide some brief response for now.

I would assume that’ s possible to implement the code, but it will be the R&D team’s decision. Looks like the code from the site you suggested (http://math.lbl.gov/voro++/examples/cylinder/) is a C++ code. I guess the easiest thing to do for now is to use run the C++ code and generate, say a text file that contains information like positions and spheres of the particles. Then pass the text file to Lumerical to generate the efficiently packed volume.

If a better integration between the 3rd party tool is required, one can consider using the Matlab API or Python API interface to achieve that.


Hi @kchow,

I did run the code and generated the packing efficiently. I generate a text file that has the position and radius of the spheres. Would you mind elaborating on how to import that text file into lumerical and create a structure group for these spheres?


hi @Pascal

Once you have a text file that contains the position and radius, then you can try to import that to Lumerical and create the particles. Below files give you an example how this can be done. the Text file format is x y z r, separated by a tab. Make sure you put the files in the same working directory, or FDTD has the correct working directory to look for the file.

pos_rad.txt (67 Bytes)
import_particles_from_text_file.fsp (267.0 KB)