Coulomb’s law simulation with field divergence

This simulation isn’t 100% physically correct since moving charges are governed by Maxwell’s equations. The white cube outlines show the position of the particles in the 3d Barnes-Hut tree. The opacity of the force field is proportional to the magnitude of the force vector, multiplied by a constant to make it visible, then constrained between 0 and 255. Positive divergence is red, negative is blue. While the particles stay in the X/Y plane in this example, the simulator is fully 3d capable. Written in Processing and OpenGL.

3d N-Body Simulation

A 3d version of the n-body simulation code I’ve been working on lately. Mouse left/right to rotate, mouse up/down to zoom. Right click to turn on/off follow mode. Follow mode changes the point of view to a random particle pointing in the direction of it’s acceleration. Left click to reset the simulation. Requires a WEBGL capable browser.
Continue reading “3d N-Body Simulation”

Final 2D N-Body Simulation

Final 2D version of the N-Body simulation using the Barnes-Hut algorithm. The blue lines show the acceleration vector times 25. The grey rectangles represent the tree structure of the particles in memory. Click to reset the sim with random particles. Runs better in Google Chrome or a Firefox 4.0 beta.

Click:
Continue reading “Final 2D N-Body Simulation”

Simple 2D gravity simulation

A simple 2D gravity simulation of particles with random position and momentum using verlet integration. Written with Processing and processing.js. Some particles fly away, some coalesce into a larger masses, and some form stable orbits. At least stable enough to observe for a while. Usually the 200 particles form into a little miniature solar system with a very massive center and several much smaller satellites. I think neatest case is when two large masses form that orbit each other, but it’s pretty rare.

The simulation can run slowly at first, but speeds up as the particles collide and merge together. Really best viewed with Google Chrome.

Click to see:
Continue reading “Simple 2D gravity simulation”