Fast astrophysical N-body simulator
Project description
GravityLab: Astrophysical N-body simulator.
A fast astrophysical N-body simulator.
GravityLab is written in Python and Cython, with performance-critical parts implemented in Cython and the main simulation module written in Python. This makes GravityLab flexible and very fast. The core physics solvers are written in Cython and are optimized to make GravityLab fast. The ODEs governing motions of the bodies are solved using the Leapfrog integration scheme. The Python module is flexible and powerful, while keeping it simple for users to use it.
Installation
Dependencies
The following are required to run GravityLab:
- Cython
- NumPy
- Matplotlib
Install
To install this code, run the following commands in your terminal:
> git clone https://github.com/Kushaalkumar-pothula/gravitylab.git
> cd gravitylab
> python setup.py build_ext --inplace
Usage
You can run the simulation using the gravitylab.simulate
module. This module provides a powerful (yet simple to use) class Simulation
. An instance of the Simulation
class can be instantiated with the following command (parameters not shown here):
from gravitylab.simulate import Simulation
my_simulation = Simulation()
Add initial conditions to a simulation instance:
my_simulation.initial_conditions()
And then run a simulation using the .run()
method:
my_simulation.run()
You can also get the calculated positions returned by the above command:
positions = my_simulation.run()
Next, you can create a plot of the evolution positions throughout the simulation:
my_simulation.plot()
The .plot()
method takes a many parameters, including 3D plotting.
An example for running GravityLab
simulations can be found in gravitylab/example.py
:
> python gravitylab/example.py
Author
This code was written by Kushaal Kumar Pothula. I wrote this code during my 10th grade while learning about numerical simulations during the summer.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.