Integrators#

Inspectable Euler, RK4 and adaptive integration of SI state models.

class engineeringkit.integrators.IntegrationResult(t, history, method, evaluations)[source]#

Bases: object

Time [s] and state history with shape (samples, states).

Parameters:
  • t (ndarray)

  • history (ndarray)

  • method (str)

  • evaluations (int)

evaluations: int#
history: ndarray#
method: str#
plot(labels=None, ax=None)[source]#

Plot state histories; labels should include their physical units.

summary()[source]#
Return type:

dict

t: ndarray#
engineeringkit.integrators.integrate_ode(rhs, y0, t, method='RK45', *, rtol=1e-08, atol=1e-10)[source]#

Solve dy/dt = rhs(t, y) on a strictly increasing finite time grid.

euler and rk4 expose explicit fixed-step methods using the supplied grid. Other names select SciPy adaptive methods. Explicit methods are for non-stiff teaching problems; step size controls stability and accuracy. State units follow the caller’s model; time is in seconds.

Return type:

IntegrationResult

Parameters:
  • rhs (Callable)

  • method (str)

  • rtol (float)

  • atol (float)