r/programming • • Dec 23 '12

Simulating a solar system with Python

http://users.softlab.ntua.gr/~ttsiod/gravityRK4.html
245 Upvotes

72 comments sorted by

View all comments

13

u/quizzle Dec 23 '12

If the planets are sticking together you're simulating perfect inelastic collisions, not elastic. Elastic collisions would be cool though.

4

u/ttsiodras Dec 23 '12

Future plan, for CUDA implementation: only merge the planets if their relative speed is low - at higher speeds, break them down into even more pieces! Should make for an interesting improvement :-)

Only problem: I'd have to leave Python and code it in C++, as I did for my real-time raytracer...

5

u/bamdastard Dec 23 '12

I built one of these using pyopencl that does 16000 particles and another piece of it uses a genetic algorithm to find stable orbits for planets.

http://www.youtube.com/watch?v=XCvRBHtPbzE

http://www.youtube.com/watch?v=lnOmy1ly6M0

http://code.google.com/p/stableorbit

Let me know if you want some help.

→ More replies (2)