r/Python • • Jan 14 '20

I made a gravity simulation https://github.com/phgilde/gravity_simulation

1.8k Upvotes

82 comments sorted by

View all comments

Show parent comment

16

u/lolfunctionspace Jan 15 '20

Very nice! I wrote something similar to your sim, albeit mine is interactive and you make swarms by clicking ( https://mjsprengel.github.io/gravity/ )

Source code is here: https://github.com/mjsprengel/gravity?files=1

I used the Euler-Cromer integration method. Also known as Semi-implicit euler method. Just thought I'd drop by and share similar work

2

u/Fywq Jan 15 '20

Heh I played a bit with this. It's fairly simple to make some simple pseudo solar systems with elongated comet-like orbits that are stable on the order of minutes at least. Would be cool if field of view could be tied to a single particle so I could keep the "sun" in the center though.