- Python 100%
| n_body | ||
| .gitignore | ||
| body.py | ||
| damp_osc.py | ||
| damp_osc_with_rk_single.py | ||
| dampened_oscillator.png | ||
| draw.py | ||
| draw_old.py | ||
| energy.png | ||
| energy_n_body.py | ||
| gravity_sim.py | ||
| n_body.py | ||
| new_energy_n_body.py | ||
| one_body.png | ||
| one_body.py | ||
| README.md | ||
| rk.py | ||
| spring.py | ||
| test.py | ||
| test_particle_sim.py | ||
| velocity_verlet_11_body_energy.png | ||
| velocity_verlet_11_body_energy_zoomed.png | ||
| velocity_verlet_11_body_momentum.png | ||
| velocity_verlet_27_body_energy.png | ||
| velocity_verlet_27_body_energy_zoomed.png | ||
| velocity_verlet_27_body_momentum.png | ||
Setup
pip install numpy pyglet matplotlib panda3d
matplotlib is not necessary if not plotting
Note:
new_energy_n_body.py and n_body.py are the only ones that will currently run due to changes made to rendering. Other files haven't been updated with the new syntax yet.
To-do
- Gravity on Earth
- Build a 2d renderer based on Pyglet
- Implement multi-object rendering
- Reuse old shapes
- Implement collisions
- Come up with different models for bodies colliding
- Supoort for different types of collisions (and respective energy+momentum changes)
- Build a 3d renderer based on Panda3D
- Switch to Barnes-Hut method for approximations for particles
- Springs
- Diff eq. support
- Two-body problems
- One fixed body
- N-body problems
- basic N-body problems
- add functions to support moving center of mass
- add functions to model changing mass overtime
- energy support (to make it accurate to real life)
- Particle simulation
- Fluid simulation
Switched from RK4 to velocity verlet for significant performance gains, and energy+momentum conservation.
Example System
Energy and momentum graphs for an 27 body gravitational system with velocity verlet (time step = 0.05): Total energy = -24902.30544431605; Total energy final (1000 seconds) = -24902.30544250108
Note: Not sure what the spikes are. They are likely due to improper "collision" handling (there is no collision handling, instead 0 acceleration is added if the delta position is less than sum of radii, where the radii have a minimum radius of 1, despite "true" raidus being proportional to cbrt of mass, which would give sub pixel radii)
Zoomed in energy plot
<p_x, p_y, p_z> represent each of the 3 lines. Total momentum = <687898.600061, 198487.305684, 0>; Total momentum final (1000 seconds) = <-733713.21844474, 3488328.45607243, 0.>


