Simulating Brownian motion was a self-chosen mini-project at the beginning of my PhD. You can find the model on github. An adaptive time stepping scheme is used, where the particles trajectories to collision are predicted. Using Euler-forward in time allows to either reverse the normal-to-wall momentum for collision with a wall or to exchange the momentum with another particle based on the ideas of elastic collision. The phenomenon of gravity is also implemented into the code, revealing some interesting dynamics. The time-stepping procedure is energy-conserving.

Starting with two sets of particles (blue vs red) in either half of the domain, the particles will first fall to the ground, but the released kinetic energy will keep them bouncing off each other and blue and red will eventually mix. As there is no sink of energy in the system this game of collisions keeps on going forever. Mixing of two sets of particles, including gravity Corresponding video can be found here

In another setting (this time without gravity) a fixed seed is placed in the middle of the domain. This seed does not move and forces every particle to stop once touched. The result is a fractal that grows by caught particles and stretches out into the domain until no free particle is left. Building fractals via Brownian motion Corresponding video can be found here