Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 

Repository files navigation

3body

Introduction

This small project is a light gravitational simulator written in C++. The goal is to simulate and visualize the trajectories of periodic solutions of the three-body problem.

Physics

The ruling equation for this simulation is pure Newtonian gravitational attraction, with $\vec{F}_{ij}$ the gravitational force of body $j$ on body $i$ defined as:

$$\vec{F}_{ij}=-G\frac{m_im_j}{|\vec{r}_i - \vec{r}_j|^3}(\vec{r}_i - \vec{r}_j)$$

With $G$ the universal gravitational constant and $\vec{r}_i$, $\vec{r}_j$ the positions of bodies $i$, $j$.

Numerical

The simulator uses a fourth-order Runge-Kutta solver with fixed time step.

Parameters

Physical:

  • G: universal gravitational constant
  • mi: mass of body $i$, with $i=1,2,3$
  • (xi, yi): initial positions (for body $i$)
  • (vxi, vyi): initial velocities (for body $i$)

Numerical:

  • t_end: time of simulation
  • dt: timestep
  • sampling: how often the code writes solution in output
  • output: name of output file

To-do

  • Adaptative time step
  • Parser in a header file

About

Simulating and visualizing periodic solutions of the three-body problem

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages