Class IRKF

Inheritance Relationships

Base Type

Derived Type

Class Documentation

class IRKF : public lupnt::Integrator

Abstract base for embedded Runge-Kutta-Fehlberg-type integrators with adaptive step-size control.

Step repeatedly calls the subclass-provided Update to compute a low- and high-order solution pair, checks the relative error via ComputeRelError, and shrinks dt and retries (up to IntegratorParams::max_iter times) until the error is within tolerance. RKF45 is the concrete 4(5)-order instantiation used by NumericalOrbitDynamics when IntegratorType::RKF45 is selected.

Subclassed by lupnt::RKF45

Public Functions

inline IRKF(int order)

Construct an embedded RKF-type integrator of the given low-order accuracy order (used by ComputeRelError’s step-size-control exponent).

virtual State Step(const ODE &f, Real t, const State &x, Real dt) override

One adaptive step: repeatedly calls Update and ComputeRelError, shrinking/growing dt until the embedded low/high-order solutions agree to within IntegratorParams::abstol/reltol, or max_iter is exceeded (throws via LUPNT_CHECK in that case).

Parameters:
  • f – Right-hand side dx/dt = f(t, x)

  • t – Current time [s]

  • x – Current state

  • dt – Step size [s]; updated in-place by ComputeRelError

Returns:

Low-order solution after stepping by (the final) dt

bool ComputeRelError(const State &x_new_low, const State &x_new_high, Real &dt)

Compute the relative error norm between the embedded low- and high-order solutions and adjust dt accordingly (PI-type step-size controller).

Called once per iteration inside Step after Update produces x_new_low and x_new_high.

Parameters:
  • x_new_low – Lower-order embedded solution

  • x_new_high – Higher-order embedded solution

  • dt – Step size [s]; rescaled in-place by the step-size controller (clamped to [0.5, 2.0] times its input value) for the next attempt

Returns:

True if the error is within IntegratorParams::abstol/reltol for every component (step accepted); false otherwise (caller should retry with the rescaled dt)

virtual void Update(const ODE &f, Real t, const State &x, Real dt, State &x_new_low, State &x_new_high) = 0

Compute the embedded low- and high-order solution pair for one step of size dt, using the subclass’s Butcher tableau.

Parameters:
  • f – Right-hand side dx/dt = f(t, x)

  • t – Current time [s]

  • x – Current state

  • dt – Step size [s]

  • x_new_low – Output: lower-order solution at t + dt

  • x_new_high – Output: higher-order solution at t + dt

virtual ~IRKF() = default