Dense output
A step of a Runge–Kutta scheme evaluates residuals inside the step. A scheme with a continuous extension combines them with other weights,
do while (t < 1._R_P)
call st%begin_step(bx, u)
do k=1, st%stages()
call st%begin_stage(k, bx, DT, u)
if (st%stage_state_is_q(k)) then ; us => u ; else ; call st%stage_state_view(us) ; endif
call st%rhs_register_view(r)
r = -us**2 ! the caller's residual
call st%end_stage(k, bx, DT, u)
enddo
call st%finish_step(bx, DT, u) ! u is u^{n+1}; the residuals are kept until begin_step
do while (i <= size(T_OUT)) ! every output time inside this step
if (T_OUT(i) > t + DT) exit
theta = (T_OUT(i) - t) / DT
call st%dense_output(theta, bx, DT, u, out) ! out = the solution at t + theta DT
print '(F6.2,ES16.2)', T_OUT(i), maxval(abs(out - u0 / (1._R_P + u0 * T_OUT(i))))
i = i + 1
enddo
t = t + DT
enddo$ cookbook_dense_output
dopri-54: a continuous extension of order 4; its weights at theta = 1/2:
0.10013 0.00000 0.39183 -0.02982 0.05893 -0.04498 0.02390
t largest error of the output
0.10 6.87E-04
0.30 1.89E-03
0.35 1.66E-03
0.60 1.09E-03
0.90 6.84E-04- After
finish_step.dense_output(theta, bx, dt, q, u)reads the residuals of the step just finished, still in their registers until the nextbegin_step, and: , one pass of the stage-state kernel, no register of its own. At it is , at to rounding. - The schemes.
butcher_tableau%b_denseholdsand dense_orderits order;dense_weights(bt, theta)evaluates them.dopri-54carries Dormand and Prince's extension of order 4 (1986), as Hairer's DOPRI5 code forms it, with no extra stage:notes/dense-check.pyderives itsin exact rationals and checks every condition to order 4 for every . - Its accuracy. The output's error is the step's, plus the extension's local error, of order
dense_order+ 1 (selah_test_dense: 4.9 observed fordopri-54). - Butcher form only. The low-storage forms keep no residuals.
Hermite's cubic, for any scheme
hermite_output(theta, bx, dt, q, u [, r_end]) interpolates the step of any scheme of the Butcher form by the cubic through dopri-54, calvo-65, the FSAL pairs of #11). For any other scheme you pass it as r_end: you need it anyway, as the next step's first residual. Its order is 3, its local error of order 4 (selah_test_dense: every scheme of order 3 or more):
do while (t < 1._R_P)
call st%begin_step(bx, u)
do k=1, st%stages()
call st%begin_stage(k, bx, DT, u)
if (st%stage_state_is_q(k)) then ; us => u ; else ; call st%stage_state_view(us) ; endif
call st%rhs_register_view(r)
r = -us**2
call st%end_stage(k, bx, DT, u)
enddo
call st%finish_step(bx, DT, u)
r_end = -u**2 ! F(t^{n+1}, q^{n+1}): the next step's first residual
do while (i <= size(T_OUT))
if (T_OUT(i) > t + DT) exit
call st%hermite_output((T_OUT(i) - t) / DT, bx, DT, u, out, r_end=r_end)
print '(F6.2,ES16.2)', T_OUT(i), maxval(abs(out - u0 / (1._R_P + u0 * T_OUT(i))))
i = i + 1
enddo
t = t + DT
enddo$ cookbook_dense_output hermite
t largest error of rk4's Hermite output
0.10 2.66E-03
0.30 1.99E-04
0.35 4.37E-04
0.60 7.80E-05
0.90 1.57E-05The multistep form
In the multistep form, dense_output of ab-k interpolates the residual history the scheme already keeps: