AdaptiveRKIntegrator

AdaptiveRKIntegrator#

class brainpy.integrators.ode.AdaptiveRKIntegrator(f, var_type=None, dt=None, name=None, adaptive=None, tol=None, show_code=False, state_delays=None, neutral_delays=None)[source]#

Adaptive Runge-Kutta method for ordinary differential equations.

The embedded methods are designed to produce an estimate of the local truncation error of a single Runge-Kutta step, and as result, allow to control the error with adaptive step-size. This is done by having two methods in the tableau, one with order p and one with order \(p-1\).

The lower-order step is given by

\[y^*_{n+1} = y_n + h\sum_{i=1}^s b^*_i k_i,\]

where the \(k_{i}\) are the same as for the higher order method. Then the error is

\[e_{n+1} = y_{n+1} - y^*_{n+1} = h\sum_{i=1}^s (b_i - b^*_i) k_i,\]

which is \(O(h^{p})\). The Butcher Tableau for this kind of method is extended to give the values of \(b_{i}^{*}\)

\[\begin{split}\begin{array}{c|cccc} c_1 & a_{11} & a_{12}& \dots & a_{1s}\\ c_2 & a_{21} & a_{22}& \dots & a_{2s}\\ \vdots & \vdots & \vdots& \ddots& \vdots\\ c_s & a_{s1} & a_{s2}& \dots & a_{ss} \\ \hline & b_1 & b_2 & \dots & b_s\\ & b_1^* & b_2^* & \dots & b_s^*\\ \end{array}\end{split}\]
Parameters:
  • f (callable) – The derivative function.

  • show_code (bool) – Whether show the formatted code.

  • dt (float) – The numerical precision.

  • adaptive (bool) – Whether use the adaptive updating.

  • tol (float) – The error tolerence.

  • var_type (str) – The variable type.