Search All of the Math Forum:
Views expressed in these public forums are not endorsed by
NCTM or The Math Forum.



Adaptive RungeKutta integrators
Posted:
Apr 29, 2011 8:32 AM


Hello,
I'm making a personal library of ODE integrators. I want to have three integrators:
1) A traditional 4thorder RungeKutta integrator. Simplest method, easiest to get right. Ideally, I'd like to add an adaptive step size.
2) A 4th+5th order adaptive step size integrator of the RungeKutta family. Like the DormandPrince or similar.
3) A BulirschStoer method with Richardson extrapolation.
I have two questions pertaining the first two integrators:
1) I already have the basic 4thorder RK method implemented. I think that the simplest reasonable way to give it an adaptive step size is to use the midpoint method, like this:
! ! Variables needed for 4thorder RungeKutta ! k1 = dY(t, Y) k2 = dY(t + h/2, Y + k1*h/2) k3 = dY(t + h/2, Y + k2*h/2) k4 = dY(t + h , Y + k3*h)
! ! The second also gives me the midpoint method. ! Y_rk4 = Y + (k1 + 2*k2 + 2*k3 + k4) * h/6 Y_mid = Y + k2 * h
! ! Error estimate and new step size. ! error = abs(Y_rk4  Y_mid) / ( abs(Y_rk4) * rtol )
h = h * (rtol / error) ** (1/2)
if (error > rtol) then ... go back and try again ... end if
Does this look reasonable?
2) My second question is shorter. There are several 4th+5th order methods of the RungeKutta family:
* DormandPrince * Fehlberg * CashKarp
Which one should I pick?
Thanks for the help.
Daniel.



