Physics

Newton's second law $$F = ma$$ was used to calculate the accelerations of each mass. My code uses Newton's second law for a collection of point masses.

\begin{equation} m _{j}\frac{d^2 \vec{r(t)}_{\,j}}{dt^2} = \sum_{i \neq j}\frac{Gm_{i}m_{j}}{{\mid \vec{r}_{\,i} - \vec{r}_{\,j} \mid}^3}(\vec{r}_{\,i} - \vec{r}_{\,j}). \label{eq1} \end{equation}

I used barycentric coordinates where the origin is set at the center of mass for a group of point masses. Units for mass were in solar masses, distance in AU's, and time in 1/2pi years.
So in my unit system, $$1m = 1{solarmass}$$ $$1length = 1{Astronomical}{Unit}$$ $$1t = 1/(2\pi){years}$$ This allowed the for the gravitational constant to have a value of 1. $$G = 1$$ This alternate set of units simplified the code wherever G appeared. The value of the gravitational constant in standard units, is $$G = 6.67384 X 10^{-11}m^{3}kg^{-1}s^{-2}$$

Numerical Method

LeapFrog is an algorithm that is used to numerically solve second order ordinary differential equations, such as Newton's second law for a collection of point masses.

\begin{equation} x_{n+1} = x_{n-1} + 2v_{n}dt \label{eq2} \end{equation}

\begin{equation} v_{n+1} = v_{n-1} + 2adt \end{equation}