Watch a Million Particles Collide

Article written: 17 Feb , 2013
Updated: 30 Dec , 2015

What happens when you give 1,000,000 particles their own gravity and spring repulsion and send them out to play? Watch the video above and find out.

This was created by David Moore, a self-taught computer programmer, aspiring physicist and student at San Diego Miramar College. It’s a custom code made with SDL/C++ and 8 days of render time. According to David there’s a bug at the end “where particles can get arbitrarily high energy… but before that it’s very physically accurate!”

It’s fascinating to watch the attraction process take place — one might envision a similar process occurring in the early Universe with the formation of the first galaxies and galactic clusters out of a hot, uniform state. Plus it’s great to see young talented minds like David’s working on such projects for fun!

There just might be hope for us after all.

Video by David Moore

, , , , ,

18 Responses

  1. Zoutsteen from Holland says

    interesting, now try it with an initial velocity vector for every partical going left to right. (not random). Pythagoras tells me its relevant.

    • Evan O'Connor says

      Lorentz tells me its irrelevant (

      • Zoutsteen from Holland says

        Peace to Lorentz, that dude is right with the math.

        Lets test it out with 4 planets forming a square with a 10 light seconds to the side. With and without a velocity vector. And for testing’s sake, we stick the planets to their (relative)place with a skewer. (We’re only testing 1 variable.)


        Without velocity after 5 seconds

        Center of mass: center of square


        With velocity after 5 seconds

        Center of mass: …. very close to center of square. Just not quite.

  2. zkank says

    For me, it’s ideal to envision the very beginnings of a protoplanetary disk out of a nebula with this.

  3. lcrowell says

    What is interesting is there seems to be something similar to a collective or statistical behavior similar to a phase change. At a certain point in this evolution there seems to be a sort of bubbling or bursting behavior. This seems to reflect something similar to a phase change from gas to liquid states. The bursting activity also seems to have similarities to latent heat.


  4. filledout says

    Hardly remarkable, this is 2D & buggy. Self taught indeed.

  5. John Stock says

    I’m surprised this is news. Any young programmer who is also interested in Physics has written something similar. I was around 16 I think.

    • David Moore says

      It’s pretty basic, yeah, but, you’re aware it’s O(n log(n)), and not O(n^2), right? If you check my channel, you can see a similar simulation I made when I was 16. I only calculated collisions between two particles w/ momentum conservation, and this led to horrible bugs. I also used O(n^2), and so could only do on the order of 1,000 to 2,000 particles. Learning the ins and outs (OOP and quadtrees and using the force method instead of the method I just described) took a little longer 🙂

      And, come on, eight days of computer time. About 10 GFLOPS processor, 8*24*3600 seconds, that’s a lot of floating point operations! Hell, I’d read a story just about that.

  6. Edward Morbius says

    I wrote a program that does the exact same thing as his and it has the same problem with particles gaining energy when the density becomes too high. That’s what causes the explosion.

    • lcrowell says

      I have seen simulations of galaxy collisions run on supercomputers which have similar behavior. If the effect in this code is “real” then it should persist on various scales, such as the number of particles. This though does seem to be a point of controversy with this however.


      • Edward Morbius says

        The problem is with how the simulation works. It’s not emergent behavior. It’s caused by the simulation not being continuous. It’s not a bug in the code. If you decrease the size of the time step the simulation becomes more accurate, because the particles move slower, and the blobs grow larger before they explode but they still wind up exploding. The explosion happens in the core of the blobs where the pressure is highest and the particles get pushed so close together that the collision code tries to force them apart and the particles gain excess energy.

      • David Moore says

        Actually, I thought this at first, but the timestep is really really small, and doesn’t account for the amount of energy gained. It’s actually because I calculated the collision physics pretty naively, as a “close enough” sort of thing. If a large number of particles are within colliding distance/really close together, sometimes the spring force between a pair isn’t calculated. Which one isn’t calculated is arbitrary (meaning, depends on the code), but it changes over time. So basically, a particle might not experience the repulsive force for several frames, so it ignores it, and when the repulsive force kicks back in again, it’s now further up in the spring’s potential! So it’s gained energy randomly, and the spring pushes out with a huge force.

        But yes, timestep can do the same thing (though, you could account for it in integration code by using a hookean potential 1/2kr^2), where you move up in a potential well w/o actually having the energy needed. (and, in newtonian mechanics, that’s gibberish)

  7. Torbjörn Larsson says

    Interesting how mesoscale fluidic behavior kicks in (at clusters of some tens to hundreds of particles), then the macroscale fluidic behavior becomes visible.

    one might envision a similar process occurring in the early Universe with the formation of the first galaxies and galactic clusters out of a hot, uniform state.

    As I remember it, it is claimed that a problem with the big bang cosmologies was that they couldn’t predict large scale structures at all, or perhaps the kind we see. Of course all that changed with the inflationary cosmologies and their primordial fluctuations, as seen in the CMB remnants as well.

  8. it’s like coalescing dust particles

  9. I calculate the mass of a photon
    and written in my book Complete Unified Theory (pages – 424, 1998), Lot of
    application is there. One example is given here that in what way 1000000 photons
    make Planck constant? We know Planck
    constant = h / 2 Pi = 6.5821220 x 10^-16 ev-s. We can get this
    result as

    Planck Constant = (10^6 photons / root of 2) x energy of a
    photon = 6.583008021 x 10^-16 ev-s were, 2 = angular quantum number (j = l
    + ½, l = 0), similarly graviton
    particles acts to follow this rule.

    We know the gravitational force between nucleons is

    F = G mM / r^2 = 1.8667 x
    10^-34 Newton, where, m = M = mass of Proton and r = distance = 10^-15 meter.

    I calculate the energy of a
    graviton = 1.7511×10^-58 Jules. If we consider 1000000 gravitons (for m) and
    1000000 gravitons (for M) in the above equation and distance = r = 1 ? = 10^-10
    meter, then we get, force between two particles is 1.168437 x10^-36 Newton. This
    value is 159.766 times smaller than Proton Proton force. Therefore, the mass of
    a photon and graviton is correct. The video action of 1000000 particles assumes
    to be practical in the case of particles coagulations.

    Thanks to Mr. David Moore.

    Nirmalendu Das.

    Dated: 18-02-2012.

  10. bugzzz says

    Very cool.

  11. Skipdallas says

    Mesmerizing, and very cool! Good work Mr. Moore!

Comments are closed.