libode
Easy to compile, fast ODE integrators as C++ classes
Loading...
Searching...
No Matches
ode_embedded.h
Go to the documentation of this file.
1#ifndef ODE_EMBEDDED_H_
2#define ODE_EMBEDDED_H_
3
5
6#include <cmath>
7
8#include "ode_io.h"
9#include "ode_util.h"
10#include "ode_adaptive.h"
11
12namespace ode {
13
15class OdeEmbedded : public OdeAdaptive {
16
17 public:
19
24 OdeEmbedded (unsigned long neq, bool need_jac, int lowerord);
26 virtual ~OdeEmbedded ();
27
28 //-------------------
29 //getters and setters
30
32 double get_facsafe () { return(facsafe_); }
34 double get_facmin () { return(facmin_); }
36 double get_facmax () { return(facmax_); }
37
39 void set_facsafe (double facsafe) { facsafe_ = facsafe; }
41 void set_facmin (double facmin) {
42 if ( facmin >= 1.0 )
43 ode_print_exit("facmin must be a number less than 1 in set_facmin()");
44 facmin_ = facmin;
45 }
47 void set_facmax (double facmax) {
48 if ( facmax <= 1.0 )
49 ode_print_exit("facmax must be a number greater than 1 in set_facmax()");
50 facmax_ = facmax;
51 }
52
53 protected:
54
56 double facsafe_;
58 double facmin_;
60 double facmax_;
61
63 double *solemb_;
65 double error (double abstol, double reltol);
67 double facopt (double err);
68
69 //------------------------------------------------
70 //implementation of inherited methods for adapting
71
73 virtual void adapt (double abstol, double reltol);
75 virtual bool is_rejected ();
77 virtual double dt_adapt ();
78
79 private:
81 int lowerord_;
83 bool isrej_;
85 double dtopt_;
86};
87
88} // namespace ode
89
90#endif
Base class implementing solver functions with adaptive time steps.
Base clase implementing methods for embedded Runge-Kutta error estimation.
OdeEmbedded(unsigned long neq, bool need_jac, int lowerord)
constructs
void set_facmin(double facmin)
sets minimum allowable fraction change in time step (a number <1)
virtual double dt_adapt()
simply returns dtopt
double * solemb_
embedded solution array
double get_facmin()
gets minimum allowable fraction change in time step (a number <1)
double facmin_
minimum allowable fraction change in time step
double error(double abstol, double reltol)
calculates error estimate with lower and higher order solutions
double get_facsafe()
gets safety factor applied to time step selection
virtual ~OdeEmbedded()
destructs
double facmax_
maximum allowable fraction change in time step
double facopt(double err)
calculates factor for "optimal" next time step
void set_facsafe(double facsafe)
sets safety factor applied to time step selection
double get_facmax()
gets maximum allowable fraction change in time step (a number >1)
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
void set_facmax(double facmax)
sets maximum allowable fraction change in time step (a number >1)
void ode_print_exit(const char *msg)
print a message and exit with failure
Definition ode_io.cc:17