Runge-Kutta Base

class pathsim.solvers._rungekutta.ExplicitRungeKutta(*solver_args, **solver_kwargs)[source]

Bases: ExplicitSolver

Base class for explicit Runge-Kutta integrators which implements the timestepping at intermediate stages and the error control if the coefficients for the local truncation error estimate are defined.

Note

This class is not intended to be used directly!!!

n

order of stepping integration scheme

Type:

int

m

order of embedded integration scheme for error control

Type:

int

s

numer of RK stages

Type:

int

history

internal history of past results

Type:

deque[numeric]

beta

safety factor for error control

Type:

float

Ks

slopes at RK stages

Type:

dict

BT

butcher table

Type:

dict[int: None, list[float]], None

TR

coefficients for truncation error estimate

Type:

list[float]

error_controller(dt)[source]

Compute scaling factor for adaptive timestep based on absolute and relative local truncation error estimate, also checks if the error tolerance is achieved and returns a success metric.

Parameters:

dt (float) – integration timestep

Returns:

  • success (bool) – timestep was successful

  • err (float) – truncation error estimate

  • scale (float) – timestep rescale from error controller

step(f, dt)[source]

Performs the (explicit) timestep at the intermediate RK stages for (t+dt) based on the state and input at (t)

Parameters:
  • f (numeric, array[numeric]) – evaluation of function

  • dt (float) – integration timestep

Returns:

  • success (bool) – timestep was successful

  • err (float) – truncation error estimate

  • scale (float) – timestep rescale from error controller

class pathsim.solvers._rungekutta.DiagonallyImplicitRungeKutta(*solver_args, **solver_kwargs)[source]

Bases: ImplicitSolver

Base class for diagonally implicit Runge-Kutta (DIRK) integrators which implements the timestepping at intermediate stages, involving the numerical solution of the implicit update equation and the error control if the coefficients for the local truncation error estimate are defined.

Extensions and checks to also handle explicit first stages (ESDIRK) and additional final evaluation coefficients (not stiffly accurate)

Note

This class is not intended to be used directly!!!

n

order of stepping integration scheme

Type:

int

m

order of embedded integration scheme for error control

Type:

int

s

numer of RK stages

Type:

int

beta

safety factor for error control

Type:

float

Ks

slopes at RK stages

Type:

dict

BT

butcher table

Type:

dict[int: None, list[float]], None

A

coefficients for final solution evaluation

Type:

list[float], None

TR

coefficients for truncation error estimate

Type:

list[float]

error_controller(dt)[source]

Compute scaling factor for adaptive timestep based on absolute and relative local truncation error estimate, also checks if the error tolerance is achieved and returns a success metric.

Parameters:

dt (float) – integration timestep

Returns:

  • success (bool) – timestep was successful

  • err (float) – truncation error estimate

  • scale (float) – timestep rescale from error controller

solve(f, J, dt)[source]

Solves the implicit update equation using the optimizer of the engine.

Parameters:
  • f (array_like) – evaluation of function

  • J (array_like) – evaluation of jacobian of function

  • dt (float) – integration timestep

Returns:

err – residual error of the fixed point update equation

Return type:

float

step(f, dt)[source]

performs the (explicit) timestep at the intermediate RK stages for (t+dt) based on the state and input at (t)

Parameters:
  • f (array_like) – evaluation of function

  • dt (float) – integration timestep

Returns:

  • success (bool) – timestep was successful

  • err (float) – truncation error estimate

  • scale (float) – timestep rescale from error controller