Class xlifepp::RK4T#

template<class T>
class RK4T : public xlifepp::OdeSolverT<T>#

Runge-Kutta 4th order method for solving ODEs.

This class implements the Runge-Kutta 4th order method for solving ODEs of the form y’=f(t,y). The method computes the solution by iteratively updating the state y at each time step dt, using the formula: y(t+dt) = y(t) + dt/6 * (k1 + 2*k2 + 2*k3 + k4) where: k1 = f(t,y(t)) k2 = f(t+dt/2, y(t) + dt/2 * k1) k3 = f(t+dt/2, y(t) + dt/2 * k2) k4 = f(t+dt, y(t) + dt * k3) The compute method fills the tys_ list with pairs of (time, state) at each time step. The class also provides methods to access the computed states and times, and to save the results to a file.

Template Parameters:

T – type of the state (real_t, complex_t, Vector<real_t>, Vector<complex_t>, …)

Param f:

function of the ODE y’=f(t,y) with prototype T& f(real_t t, const T& y, T& fty)

Param t0:

initial time

Param tf:

final time

Param dt:

initial time step

Param y0:

initial state

Param na:

name of the method (default is “RK4”)

Note

This class is not meant to be used directly, but as a base class for specific ODE solvers like RK4.