I wanted to see if I could implement the famous Barnes-Hut algorithm using Fortran 90. I decided to constrain my simulations to 2d mainly because rendering 3d volumetric data is a pain. Here are the results of several initial configurations. For context I used a smoothed Newton force and Velocity Verlet Scheme.

Governing Equations: \[\vec{F} = G \frac{m_1 m_2}{r^2 + \epsilon^2} \] \[x(t + \Delta t) = x(t) + v(t) \Delta t + \frac{1}{2} a(t) \Delta t \] \[ a(t + \Delta t) = f(x(t + \Delta t)) \] \[ v(t + \Delta t) = v(t) + \frac{1}{2}(a(t) + a(t + \Delta t)) \Delta t \]

Random Distribution of Position & no Velocity


Random Distribution of Position and Velocity


Random Distribution of Shrunk Position and Velocity


Each simulation has 49k particles. My copy of GNU Fortran started complaining when I was doing file IO with arrays of size 50k. Github