Click and drag within the box above to create all sorts of interesting particle systems. When 'Particle' is selected from the drop down menu, click and drag to shoot particles. When 'Well' is selected, click and drag to create wells of different sizes (the larger the well the stronger the force).

What's this all about?

This just a simple physics simulator that models particles (that have velocities) and wells (which apply 'gravitational' forces). It should also be noted this isn't exactly a true N-Bodies particle system as the individual particles do not have any effect on one another.

The Physics:

In this system there is a one way interaction between Wells and Particles. Each well exerts a force that is inverse proportional to the distance from its center (Force = 1/Distance). This means the further away a particle is from a well the less force it feels, and the closer a particle is the greater the force. As well, when multiple Wells are involved the forces are just summed up. Meaning that each particle really only experiences a single force which is just a sum of all the forces from all the wells. Pretty neat hey?

The Computation:

In order to create the system as accurately as possible I created two types of objects, Wells and Particles of course. Both of these are then managed in a larger object, a particle system, which keeps track of all the objects and their interactions.

This simulation is running at 32 frames/second, meaning that every 0.03125 seconds everything is recalculated and the display is refreshed. In this time the particle system goes through every single particle and adds up all the forces from all the wells then plugs them into an equation that updates the positions of each particle. Not the most efficient solution but it certainly does the job.

One More Nifty Detail:

When you don't have 'Well Collision' on, you'll notice that sometimes when the particles enter inside a Well that they come shooting out with a extremely high velocity. This is due to the fact that the force is inverse proportional to the distance (as mentioned above). So if the particles distance from the center of the mass is very tiny, the force is going to be huge. This in turn causes the well to fling the particles out.

More Experiments