![]() |
Object-oriented Scientific Computing Library: Version 0.910
|
00001 /* 00002 ------------------------------------------------------------------- 00003 00004 Copyright (C) 2006-2012, Andrew W. Steiner 00005 00006 This file is part of O2scl. 00007 00008 O2scl is free software; you can redistribute it and/or modify 00009 it under the terms of the GNU General Public License as published by 00010 the Free Software Foundation; either version 3 of the License, or 00011 (at your option) any later version. 00012 00013 O2scl is distributed in the hope that it will be useful, 00014 but WITHOUT ANY WARRANTY; without even the implied warranty of 00015 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00016 GNU General Public License for more details. 00017 00018 You should have received a copy of the GNU General Public License 00019 along with O2scl. If not, see <http://www.gnu.org/licenses/>. 00020 00021 ------------------------------------------------------------------- 00022 */ 00023 00024 #ifndef O2SCL_ADAPT_STEP_H 00025 #define O2SCL_ADAPT_STEP_H 00026 00027 #include <o2scl/ode_step.h> 00028 #include <o2scl/gsl_rkck.h> 00029 #include <o2scl/ode_funct.h> 00030 00031 #ifndef DOXYGENP 00032 namespace o2scl { 00033 #endif 00034 00035 /** \brief Adaptive stepper [abstract base] 00036 00037 The adaptive stepper routines are based on one or many 00038 applications of ordinary ODE steppers (implemented in \ref 00039 ode_step). Each adaptive stepper (gsl_astep or nonadapt_step) can 00040 be used with any of the ODE stepper classes (e.g. gsl_rkck). By 00041 default, gsl_rkck is used. To modify the ODE stepper which is 00042 used, use the member function set_step() documented below. 00043 00044 \note If you use gsl_rkck_fast or gsl_rk8pd_fast, you'll 00045 need to make sure that the argument \c n to astep() or 00046 astep_derivs() below matches the template size parameter 00047 given in the ODE stepper. 00048 */ 00049 template<class func_t=ode_funct<>, 00050 class vec_t=ovector_base, class alloc_vec_t=ovector, 00051 class alloc_t=ovector_alloc> class adapt_step { 00052 00053 public: 00054 00055 adapt_step() { 00056 stepp=&def_step; 00057 verbose=0; 00058 } 00059 00060 virtual ~adapt_step() {} 00061 00062 /** \brief Make an adaptive integration step of the system 00063 \c derivs 00064 00065 This attempts to take a step of size \c h from the point \c 00066 x of an \c n-dimensional system \c derivs starting with \c 00067 y. On exit, \c x and \c y contain the new values at the end 00068 of the step, \c h contains the size of the step, \c dydx_out 00069 contains the derivative at the end of the step, and \c yerr 00070 contains the estimated error at the end of the step. 00071 */ 00072 virtual int astep(double &x, double xlimit, double &h, 00073 size_t n, vec_t &y, vec_t &dydx_out, 00074 vec_t &yerr, func_t &derivs)=0; 00075 00076 /** \brief Make an adaptive integration step of the system 00077 \c derivs with derivatives 00078 00079 This attempts to take a step of size \c h from the point \c 00080 x of an \c n-dimensional system \c derivs starting with \c y 00081 and given the initial derivatives \c dydx. On exit, \c x, \c 00082 y and \c dydx contain the new values at the end of the step, 00083 \c h contains the size of the step, \c dydx contains the 00084 derivative at the end of the step, and \c yerr contains the 00085 estimated error at the end of the step. 00086 */ 00087 virtual int astep_derivs(double &x, double xlimit, double &h, 00088 size_t n, vec_t &y, vec_t &dydx, 00089 vec_t &yerr, func_t &derivs)=0; 00090 00091 /** \brief Make an adaptive integration step of the system 00092 \c derivs with derivatives 00093 00094 This function performs an adaptive integration step with the 00095 \c n-dimensional system \c derivs and parameter \c pa. It 00096 Begins at \c x with initial stepsize \c h, ensuring that the 00097 step goes no farther than \c xlimit. At the end of the step, 00098 the size of the step taken is \c h and the new value of \c x 00099 is in \c x_out. Initially, the function values and 00100 derivatives should be specified in \c y and \c dydx. The 00101 function values, derivatives, and the error at the end of 00102 the step are given in \c yout, \c yerr, and \c dydx_out. 00103 Unlike in \c ode_step objects, the objects \c y, \c yout, 00104 \c dydx, and \c dydx_out must all be distinct. 00105 */ 00106 virtual int astep_full(double x, double xlimit, double &x_out, 00107 double &h, size_t n, vec_t &y, vec_t &dydx, 00108 vec_t &yout, vec_t &yerr, vec_t &dydx_out, 00109 func_t &derivs)=0; 00110 00111 /// Set output level 00112 int verbose; 00113 00114 /** \brief Set stepper 00115 00116 This sets the stepper for use in the adaptive step 00117 routine. If no stepper is specified, then the default 00118 (\ref def_step of type \ref gsl_rkck) is used. 00119 */ 00120 int set_step(ode_step<func_t,vec_t> &step) { 00121 stepp=&step; 00122 return 0; 00123 } 00124 00125 /// The default stepper 00126 gsl_rkck<func_t,vec_t,alloc_vec_t,alloc_t> def_step; 00127 00128 #ifndef DOXYGEN_INTERNAL 00129 00130 protected: 00131 00132 /// Pointer to the stepper being used 00133 ode_step<func_t,vec_t> *stepp; 00134 00135 #endif 00136 00137 }; 00138 00139 #ifndef DOXYGENP 00140 } 00141 #endif 00142 00143 #endif
Documentation generated with Doxygen. Provided under the GNU Free Documentation License (see License Information).