Particles in a box simulation David Fleming, Oct 2015
A more complete description of the code can be found here
Given n particles modeled as hard spheres, allow them to interact with each other via perfectly elastic collisions. The particles are constrained to a 2D box via periodic boundary conditions. The simulation advances via the following algorithm:
-
For each particle, check to see if it interacts with any other particle (O(N^2))
-
Check to see if particle has left the box, if so, place it on the opposite side
-
Move the particles: x' = x + v * dt
-
Repeat until time > MAX