Class xlifepp::OdeSolverT#

template<class T>
class OdeSolverT#

Base class for ODE solvers.

OdeSolverT is a base class for ODE solvers. It provides a common interface for all ODE solvers. It stores the function f(t,y) that defines the ODE, the initial and final times, the time step, the initial state, and optional parameters for the function f. It 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 “”)

Note

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

Subclassed by xlifepp::EulerT< T >, xlifepp::Ode45T< T >, xlifepp::OdeSolverTP< T, P >, xlifepp::RK4T< T >

Public Functions

inline void checkData()#

check times and time step

inline number_t nbSteps() const#

number of steps of a constant step method: last step is shortened to end exactly at tf

inline void saveToFile(const string_t &fn) const#

save time steps and states to a file

inline std::vector<T> states() const#

access to states y

inline real_t stepTime(number_t k, number_t n) const#

time of the k-th step of a constant step method (k=0,…,nbSteps())

inline std::vector<real_t> times() const#

access to time step t

inline const std::list<std::pair<real_t, T>> &tys() const#

returns time steps and states