30 double sc, d, g, err=0.0;
34 for (i=0; i<
neq_; i++) {
36 sc = abstol + reltol*fabs(
sol_[i]);
38 if ( g > err ) err = g;
47 double fac =
facsafe_*pow(1.0/err, 1.0/(lowerord_ + 1.0));
58 double err =
error(abstol, reltol);
60 isrej_ = ( err >= 1.0 ) ?
true :
false;
Base class implementing solver functions with adaptive time steps.
unsigned long neq_
number of equations in the system of ODEs
double dt_
time step is stored and updated during solves
double * sol_
array for the solution, changing over time
OdeEmbedded(unsigned long neq, bool need_jac, int lowerord)
constructs
virtual double dt_adapt()
simply returns dtopt
double * solemb_
embedded solution array
double facmin_
minimum allowable fraction change in time step
double error(double abstol, double reltol)
calculates error estimate with lower and higher order solutions
virtual ~OdeEmbedded()
destructs
double facmax_
maximum allowable fraction change in time step
double facopt(double err)
calculates factor for "optimal" next time step
virtual bool is_rejected()
simply returns isrej
virtual void adapt(double abstol, double reltol)
does the calculations to determine isrej and dtopt
double facsafe_
safety factor applied to time step selection
double ode_min2(double a, double b)
Simple minimum of two doubles.
double ode_max2(double a, double b)
Simple maximum of two doubles.