I've been working on a simulation in javascript. It's a bit of fun.


Add circles by clicking or give new circles velocity by clicking and dragging.

The rules are quite simple:

Note, in the version above the maximum number of circles is limited to 48, old circles pop out of existence as newer ones are created. This is so that it does not slow down on mobiles and it means that you can clear the field to start again without too much hassle.

The circles stick to each other into a close-pack hex pattern. The circle in the middle has six lots of the sticking factor (0.996) on it. The formation of blobs in the first few stages are quite predictable:

Packing of 3 circles Packing of 3 circles Packing of 3 circles
Clusters of 3, 4, and 5 circles.

These circles are the only, and the simplest, way of attaching circles together. This is also the only energy minimum for the circles. This becomes increasingly not true as the number of circles increase.

For example with 6 circles, here are two ways they can be combined: (There are actually 3 ways as you will see later.)

Packing of 6 circles Packing of 6 circles
Different stable ways of combining 6 circles

The number of ways that the circles can be combined as the number of circles increases. However here are the just a few of the most common modes:

Packing of 7 circles Packing of 7 circles
7 circles. Left is the close pack unit cell. The one on the right is less efficient.
Packing of 8 circles Packing of 8 circles
8 circles. Each is one circle added to the previous 7 state combination before.
Packing of 9 circles Packing of 9 circles
9 circles. Watching for rotations, these are one more that above.
Packing of 11 circles Packing of 10 circles
10 and 11 circles. Can see that given a different root the cluster grows differently.
Packing of 10 circles Packing of 11 circles
12 circles. Quite a difference between an efficient packing (left) and not.

To explore the energy levels of the systems I created a modified version that on each frame of the animation runs a complete simulation until it has 'settled down', that is, when the average velocity is below a chosen value. On each of those frames the circles are moved to the middle (so that you can see them easily) and the sum of the distances between each object is drawn on screen as a dot. The dots make up a graph that has frame number on the x-axis and sum-of-r on the y-axis. I'm relating the sum-of-r to be a simple metric of the energy of the cluster (However I think that sqrt(sum(r2)) is a better one). After a few frames an energy band graph is drawn. After a certain number of frames the number of circles in increased. Note that the initial position for each circle at the beginning of each simulation is random inside of a big enough square.

You can try it out for yourself.

If you don't want to wait for that to run, as it does take a while, below are the results for the first 600 simulations:

Packing of 10 circles
The first few energy levels drawn out. Click for larger version.

The first energy levels are not split and form solid bands, but with 6 circles there are three different combinations that are stable, each with a different energy level. You can also tell that the lowest energy level is the most common (the line is denser) followed by the highest energy state. The middle state is the rarest.

Letting the simulation run for much longer (it slows down considerable with more circles) I've some evidence of the different energy levels of up to 11 circles. The graphing is done with a modulo of the screen height, so as it appears that the 8 circles have less energy than 7 it is actually off the top of the picture and rolls back onto the bottom again. I've drawn on what I think are the levels. With some indication of how common they are.

Packing of 10 circles
Energy levels with the levels marked on. Click for larger version (recommended).

This is where I'll call and end to my project for now. I think that it is interesiting to see that with only the implementation of some basic (in this case crude also) physics rules more complex systems develop.

Other things to try:

A friend of mine who wanted no cap on the number of circles: here it is.

The source code for the simulations is open, just right-click and choose view source. It is fun to play with the parameters just keep the (c) MJS 2013 at the bottom.