1 #ifndef PSPM_ODE_SOLVER_H_ 2 #define PSPM_ODE_SOLVER_H_ 27 OdeSolver(std::string method,
double t_start,
double rtol,
double atol){
29 else if (method ==
"lsoda") type =
ODE_LSODA;
31 throw std::runtime_error(
"Fatal: Unknown ODE method " + method);
33 reset(t_start, rtol, atol);
42 void reset(
double t_start,
double rtol,
double atol){
48 delete sol; sol =
nullptr;
49 solver =
new RKCK45(t_start, rtol, 1e-8);
53 delete sol; sol =
nullptr;
59 template <
class Functor,
class AfterStep>
60 void step_to(
double t_stop,
double &t, std::vector<double>&y, Functor &derivs, AfterStep &after_step){
61 if (t_stop == t || y.size() == 0)
return;
65 sol->
Step_to(t_stop, t, y, derivs, after_step);
72 std::cerr <<
"LSODA Error: istate = " << sol->
get_istate() << std::endl;
void reset(double t_start, double rtol, double atol)
void lsoda_update(Functor &derivs, AfterStep &after_step, const size_t neq, std::vector< double > &y, double *t, const double tout, void *const _data, double rtol=1e-6, double atol=1e-6)
struct OdeSolver::@0 control
void Step_to(double t_stop, double &x, container &y, functor &derivs, AfterStep &after_step)
OdeSolver(std::string method, double t_start, double rtol, double atol)
void step_to(double t_stop, double &t, std::vector< double > &y, Functor &derivs, AfterStep &after_step)