Skip to content
/ orbit Public

A symplectic integrator for orbital mechanics

Notifications You must be signed in to change notification settings

fionn/orbit

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ORBIT

This code numerically solves the n-body problem using the leapfrog algorithm, a time-reversible symplectic integrator.

Build

Clone and make.

Run

./orbit file, where file contains the number of "planets", their masses and their initial positions and velocities.

Number of planets
Mass of planet
x    y    v_x    v_y

See examples/test2.dat and examples/test3.dat for examples (with stable orbits for n = 2, n = 3 respectively). It prints all output to stdout in the format

x_0    y_0    x_1    y_1    ...    x_n    y_n

for each timestep, where (xi, yi) is the coordinate of the ith planet in the inertial reference frame of the 0th planet (under a coordinate transformation sending the 0th planet to the origin).

The energy and angular momentum of the system are also calculated with energy(), angularmomentum() (commented in main(), ll 153, 154).

3-body