astep.h
Go to the documentation of this file.
1 /*
2  -------------------------------------------------------------------
3 
4  Copyright (C) 2006-2017, Andrew W. Steiner
5 
6  This file is part of O2scl.
7 
8  O2scl is free software; you can redistribute it and/or modify
9  it under the terms of the GNU General Public License as published by
10  the Free Software Foundation; either version 3 of the License, or
11  (at your option) any later version.
12 
13  O2scl is distributed in the hope that it will be useful,
14  but WITHOUT ANY WARRANTY; without even the implied warranty of
15  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  GNU General Public License for more details.
17 
18  You should have received a copy of the GNU General Public License
19  along with O2scl. If not, see <http://www.gnu.org/licenses/>.
20 
21  -------------------------------------------------------------------
22 */
23 /** \file astep.h
24  \brief Adaptive stepper base class
25 */
26 #ifndef O2SCL_ASTEP_H
27 #define O2SCL_ASTEP_H
28 
29 #include <o2scl/ode_step.h>
30 #include <o2scl/ode_rkck_gsl.h>
31 #include <o2scl/ode_funct.h>
32 
33 #ifndef DOXYGEN_NO_O2NS
34 namespace o2scl {
35 #endif
36 
37  /** \brief Adaptive stepper [abstract base]
38 
39  The adaptive stepper routines are based on one or many
40  applications of ordinary ODE steppers (implemented in \ref
41  ode_step). Each adaptive stepper (\ref astep_gsl or \ref
42  astep_nonadapt) can be used with any of the ODE stepper classes
43  (e.g. \ref ode_rkck_gsl). By default, ode_rkck_gsl is used. To modify
44  the ODE stepper which is used, use the member function
45  \ref set_step() documented below.
46  */
47  template<class vec_y_t=boost::numeric::ublas::vector<double>,
48  class vec_dydx_t=vec_y_t, class vec_yerr_t=vec_y_t,
49  class func_t=ode_funct11 > class astep_base {
50 
51  public:
52 
53  astep_base() {
54  stepp=&def_step;
55  verbose=0;
56  }
57 
58  virtual ~astep_base() {}
59 
60  /** \brief Make an adaptive integration step of the system
61  \c derivs
62 
63  This attempts to take a step of size \c h from the point \c
64  x of an \c n-dimensional system \c derivs starting with \c
65  y. On exit, \c x and \c y contain the new values at the end
66  of the step, \c h contains the size of the step, \c dydx_out
67  contains the derivative at the end of the step, and \c yerr
68  contains the estimated error at the end of the step.
69  */
70  virtual int astep(double &x, double xlimit, double &h,
71  size_t n, vec_y_t &y, vec_dydx_t &dydx_out,
72  vec_yerr_t &yerr, func_t &derivs)=0;
73 
74  /** \brief Make an adaptive integration step of the system
75  \c derivs with derivatives
76 
77  This attempts to take a step of size \c h from the point \c
78  x of an \c n-dimensional system \c derivs starting with \c y
79  and given the initial derivatives \c dydx. On exit, \c x, \c
80  y and \c dydx contain the new values at the end of the step,
81  \c h contains the size of the step, \c dydx contains the
82  derivative at the end of the step, and \c yerr contains the
83  estimated error at the end of the step.
84  */
85  virtual int astep_derivs(double &x, double xlimit, double &h,
86  size_t n, vec_y_t &y, vec_dydx_t &dydx,
87  vec_yerr_t &yerr, func_t &derivs)=0;
88 
89  /** \brief Make an adaptive integration step of the system
90  \c derivs with derivatives
91 
92  This function performs an adaptive integration step with the
93  \c n-dimensional system \c derivs and parameter \c pa. It
94  Begins at \c x with initial stepsize \c h, ensuring that the
95  step goes no farther than \c xlimit. At the end of the step,
96  the size of the step taken is \c h and the new value of \c x
97  is in \c x_out. Initially, the function values and
98  derivatives should be specified in \c y and \c dydx. The
99  function values, derivatives, and the error at the end of
100  the step are given in \c yout, \c yerr, and \c dydx_out.
101  Unlike in \c ode_step objects, the objects \c y, \c yout,
102  \c dydx, and \c dydx_out must all be distinct.
103  */
104  virtual int astep_full(double x, double xlimit, double &x_out,
105  double &h, size_t n, vec_y_t &y, vec_dydx_t &dydx,
106  vec_y_t &yout, vec_yerr_t &yerr,
107  vec_dydx_t &dydx_out, func_t &derivs)=0;
108 
109  /// Set output level
110  int verbose;
111 
112  /** \brief Set stepper
113 
114  This sets the stepper for use in the adaptive step
115  routine. If no stepper is specified, then the default
116  (\ref def_step of type \ref ode_rkck_gsl) is used.
117  */
119  stepp=&step;
120  return 0;
121  }
122 
123  /// The default stepper
125 
126 #ifndef DOXYGEN_INTERNAL
127 
128  protected:
129 
130  /// Pointer to the stepper being used
132 
133 #endif
134 
135  };
136 
137 #ifndef DOXYGEN_NO_O2NS
138 }
139 #endif
140 
141 #endif
The main O<span style=&#39;position: relative; top: 0.3em; font-size: 0.8em&#39;>2</span>scl O$_2$scl names...
Definition: anneal.h:42
ode_step< vec_y_t, vec_dydx_t, vec_yerr_t, func_t > * stepp
Pointer to the stepper being used.
Definition: astep.h:131
virtual int astep(double &x, double xlimit, double &h, size_t n, vec_y_t &y, vec_dydx_t &dydx_out, vec_yerr_t &yerr, func_t &derivs)=0
Make an adaptive integration step of the system derivs.
ode_rkck_gsl< vec_y_t, vec_dydx_t, vec_yerr_t, func_t > def_step
The default stepper.
Definition: astep.h:124
virtual int astep_derivs(double &x, double xlimit, double &h, size_t n, vec_y_t &y, vec_dydx_t &dydx, vec_yerr_t &yerr, func_t &derivs)=0
Make an adaptive integration step of the system derivs with derivatives.
Cash-Karp embedded Runge-Kutta ODE stepper (GSL)
Definition: ode_rkck_gsl.h:68
Adaptive stepper [abstract base].
Definition: astep.h:49
virtual int astep_full(double x, double xlimit, double &x_out, double &h, size_t n, vec_y_t &y, vec_dydx_t &dydx, vec_y_t &yout, vec_yerr_t &yerr, vec_dydx_t &dydx_out, func_t &derivs)=0
Make an adaptive integration step of the system derivs with derivatives.
ODE stepper base [abstract base].
Definition: ode_step.h:41
int set_step(ode_step< vec_y_t, vec_dydx_t, vec_yerr_t, func_t > &step)
Set stepper.
Definition: astep.h:118
int verbose
Set output level.
Definition: astep.h:110

Documentation generated with Doxygen. Provided under the GNU Free Documentation License (see License Information).