| Thread Closed |
[SOLVED] RK4 in solar system simulation (n-body problem) |
Share Thread | Thread Tools |
| Apr21-08, 02:53 AM | #1 |
|
|
[SOLVED] RK4 in solar system simulation (n-body problem)
Hi, i'm making a simulation of the solar system and have so far been using euler's method to integrate my equations of motion - and i'd like to upgrade to a 4th order runge-kutta method.
I'm having alot of trouble understanding the details however: the acceleration of each body is dependent on the current position of every body. the position of a body is dependent on its velocity, which in turn is dependent on its acceleration... Given the general RK4 algorithm: dy/dx = f(x,y) y_(n+1) = y_n + (h/4)(k_1 + 2k_2 + 2k_3 + k_4) k_1 = f(x_n,y_n) k_2 = f(x_n + h/2 , y_n + (h/2)k_1 ) k_3 = f(x_n + h/2 , y_n + (h/2)k_2 ) k_4 = f(x_n + h , y_n + hk_3 ) do i calculate k_1, then increment the positions x for each object; then calculate k_2 based on that, re-increment the positions x for each object; calculate k_3 .. etc .. then use those approximations in the formula for y_(n+1) and repeat? if this is how i'm supposed to do it, how the hell is this going to be more efficient than euler's method? Thanks for your help. |
| Apr23-08, 04:05 PM | #2 |
|
|
No one has experience with a multi-body, 2nd order RK4?
|
| Apr23-08, 06:11 PM | #3 |
|
Mentor
|
Yes, you've got the right idea. One step of RK4 takes more work than one step of Euler, but the error per step is much smaller. Therefore you can increase the step size, decreasing the amount of work, while still having a smaller total error than Euler. You'll have to experiment a bit to find the "right" step size for your situation.
|
| Apr23-08, 08:15 PM | #4 |
|
|
[SOLVED] RK4 in solar system simulation (n-body problem)
awesome thanks!
|
| Thread Closed |
| Thread Tools | |
Similar Threads for: [SOLVED] RK4 in solar system simulation (n-body problem)
|
||||
| Thread | Forum | Replies | ||
| How would the solar system capture an extra solar planet ?? | General Astronomy | 14 | ||
| Single Degree of Freedom System-Video Simulation | General Physics | 3 | ||
| Our solar system | General Astronomy | 9 | ||
| n-body simulation test with sun, earth and moon | Astrophysics | 6 | ||
| n-body simulation | General Astronomy | 2 | ||