Simulation and Visualisation of n-body problem (gravitational force only, no collisions ) using Python.
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.
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:
- Create a new .py file in the directory
- Import core modules: VVCalculation, render
- Initiate a galaxy with the method of class galaxy: VVCalculation.Galaxy()
- Saturate the galaxy with some stars: gal.newstar( VVCalculation.star( x1,y1,z1,vx,vy,vz,mass ) )
- Choose number of integration steps needed to be calculated: iterations = 1000
- Run the calculation by using calculate method from VVCalculation module: VVCalculation.calculate(gal, dt, iterations)
- Start rendering with the redersim method from render module: render.rendersim(frames, iterations, gal, Trace = True, Autoscale = True, ShowAxes = True)