Skip to content
This repository has been archived by the owner on May 29, 2022. It is now read-only.

pauljxtan/nbody

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

42 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

nbody

N-body simulations in C++.

Integrators

  • NBodyRK4: Integrates a system of N gravitationally interacting bodies using the 4th-order Runge-Kutta method, with adaptive step sizes. This is a direct, particle-particle integration with O(N^2) complexity -- prohibitively slow for large N. (Stay tuned for faster integrators.)

Quick start

  • Input parameter file: params
  • Output data file: results
$ ./src/integrate -p params -w results

(Note: standard output is switched off if writing to file)

Input parameter file

  • First row: Number of bodies, number of dimensions, integration duration, initial time step, desired accuracy
  • Each remaining row: Mass of body, initial position in each dimension, initial speed in each dimension

Real-time plotting

An example Python script (requires matplotlib) plot_realtime_N3.py is included for viewing the orbits in real time. One could pipe the integration data directly from the simulator like so:

$ ./src/integrate -p params | ./plot_realtime.py [frameskip]

or read it in from a results file:

$ ./plot_realtime.py < results

N.B. This script includes a plethora of hard-coded parameters (for N=3), and may have to be modified to suit your particular system.

To-do

  • Faster methods (tree code, multipole, mean field, etc.)
  • Generalized interaction function

About

N-body simulations in C++

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published