brainpy.integrators.ode.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.

__init__(f, var_type=None, dt=None, name=None, adaptive=None, tol=None, show_code=False, state_delays=None, neutral_delays=None)[source]#

Methods

__init__(f[, var_type, dt, name, adaptive, ...])

build()

cpu()

Move all variable into the CPU device.

cuda()

Move all variables into the GPU device.

load_state_dict(state_dict[, warn])

Copy parameters and buffers from state_dict into this module and its descendants.

load_states(filename[, verbose])

Load the model states.

nodes([method, level, include_self])

Collect all children nodes.

register_implicit_nodes(*nodes[, node_cls])

register_implicit_vars(*variables, ...)

save_states(filename[, variables])

Save the model states.

set_integral(f)

Set the integral function.

state_dict()

Returns a dictionary containing a whole state of the module.

to(device)

Moves all variables into the given device.

tpu()

Move all variables into the TPU device.

train_vars([method, level, include_self])

The shortcut for retrieving all trainable variables.

tree_flatten()

Flattens the object as a PyTree.

tree_unflatten(aux, dynamic_values)

New in version 2.3.1.

unique_name([name, type_])

Get the unique name for this object.

vars([method, level, include_self, ...])

Collect all variables in this node and the children nodes.

Attributes

A

B1

B2

C

arguments

All arguments when calling the numer integrator of the differential equation.

dt

The numerical integration precision.

integral

The integral function.

name

Name of the model.

neutral_delays

neutral delays.

parameters

The parameters defined in the differential equation.

state_delays

State delays.

variables

The variables defined in the differential equation.