Skip to content

Simulation and Visualisation of n-body problem (gravitational force only, without collisions ) using Python

Notifications You must be signed in to change notification settings

Khauru/gravsimulation

Repository files navigation

gravsimulation

Simulation and Visualisation of n-body problem (gravitational force only, no collisions ) using Python.

Overview

This script can calculate and visualise evolution of n-body problem, by calculating gravitational forces between an arbitrary number of bodies and by using Velocity-Verlet numerical method for integration of Newton's equations of motion. The resulting visualisation is saved as .gif file in current directory.

Usage

See 3body.py, 2body.py, cluster.py for usage examples and try to play with it.

If you want to start a new calculation from scratch, follow these steps:

  1. Create a new .py file in the directory
  2. Import core modules: VVCalculation, render
  3. Initiate a galaxy with the method of class galaxy: VVCalculation.Galaxy()
  4. Saturate the galaxy with some stars: gal.newstar( VVCalculation.star( x1,y1,z1,vx,vy,vz,mass ) )
  5. Choose number of integration steps needed to be calculated: iterations = 1000
  6. Run the calculation by using calculate method from VVCalculation module: VVCalculation.calculate(gal, dt, iterations)
  7. Start rendering with the redersim method from render module: render.rendersim(frames, iterations, gal, Trace = True, Autoscale = True, ShowAxes = True)

Dependencies

Numba

Examples

3body

cluster

ezgif com-gif-maker

galaxy1000b.mp4

About

Simulation and Visualisation of n-body problem (gravitational force only, without collisions ) using Python

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages