Class xlifepp::Ode45TP#
-
template<class T, class P>
class Ode45TP : public xlifepp::OdeSolverTP<T, P>#
-
Adaptive Runge-Kutta 4th and 5th order method for solving ODEs with functions depending on parameters.
This class implements an adaptive Runge-Kutta method (RK45) 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 a combination of 4th and 5th order Runge-Kutta methods. The method adjusts the time step based on the estimated error to maintain a specified precision. The compute method fills the tys_ list with pairs of (time, state) at each time step.
- Template Parameters:
-
T – type of the state (real_t, complex_t, Vector<real_t>, Vector<complex_t>, …)
P – type of the parameters (default is double)
- Param f:
-
function of the ODE y’=f(t,y,params) with prototype T& f(real_t t, const T& y, T& fty, P& params)
- Param t0:
-
initial time
- Param tf:
-
final time
- Param dt:
-
initial time step
- Param y0:
-
initial state
- Param prec:
-
relative error precision (default is 1E-6)
- Param pars:
-
parameters for the function f
- Param na:
-
name of the method (default is “ode45”)
- Param nbtry:
-
number of attempts to adjust the time step (default is 12)
- Param minscale:
-
minimum scale factor for adjusting the time step (default is 0.125)
- Param maxscale:
-
maximum scale factor for adjusting the time step (default is 4)
Note
This class is not meant to be used directly, but as a base class for specific ODE solvers like Ode45.