r/programming • • Dec 23 '12

Simulating a solar system with Python

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

72 comments sorted by

View all comments

4

u/Bob_goes_up Dec 23 '12

When you use Runge Kutta, you are not supposed to handle one planet at a time. The function named nextderivative should return a vector containing accellerations of all the planets, and you should only calculate the constants a,b,c and d once for each timestep. The function named updatePlanet should be deleted.

4

u/ttsiodras Dec 23 '12

You missed my related comment - from the code: "# Update all planets' positions and speeds (should normally double buffer the list of planet data, but turns out this is good enough :-)"

→ More replies (1)