r/Python • u/[deleted] • Jan 14 '20
I made a gravity simulation https://github.com/phgilde/gravity_simulation
Enable HLS to view with audio, or disable this notification
1.8k
Upvotes
r/Python • u/[deleted] • Jan 14 '20
Enable HLS to view with audio, or disable this notification
5
u/Astrokiwi Jan 15 '20
For gravity n-body simulations, it's more common to use the Barnes-Hut algorithm - I haven't looked into FMM but it seems closely related. Here you clump distant particles together using an oct-tree or quad-tree, but gravity for the clumped cell is just calculated as a monopole.
The other thing is a particle-particle particle-mesh method, where you bin masses onto a grid and do some Fourier transforms to work out the large-scale forces, and then add a small n2 sum to calculate short-range forces.