00001 #pragma ident "$Id: RungeKuttaFehlberg.hpp 2457 2010-08-18 14:20:12Z coandrei $"
00002
00009 #ifndef GPSTK_RUNGE_KUTTA_FEHLBERG_HPP
00010 #define GPSTK_RUNGE_KUTTA_FEHLBERG_HPP
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036 #include "Integrator.hpp"
00037
00038
00039 namespace gpstk
00040 {
00041
00044
00057 class RungeKuttaFehlberg : public Integrator
00058 {
00059 public:
00060
00061 struct RKF78Param
00062 {
00063 double a[13] ;
00064 double b[13][12] ;
00065 double c1[13] ;
00066 double c2[13] ;
00067 };
00068
00069 public:
00070
00072 RungeKuttaFehlberg();
00073
00075 virtual ~RungeKuttaFehlberg()
00076 { };
00077
00079 void test();
00080
00088 virtual Vector<double> integrateTo(const double& t,
00089 const Vector<double>& y,
00090 EquationOfMotion* peom,
00091 const double& tf );
00092
00094 RungeKuttaFehlberg& setAccuracy(const double& accuracy)
00095 { accuracyEps = accuracy; return (*this);}
00096
00098 RungeKuttaFehlberg& setMinStepSize(const double& step)
00099 { minStepSize = step; return (*this ); }
00100
00102 RungeKuttaFehlberg& setAdaptive(const bool& adaptive = true)
00103 { isAdaptive = adaptive; return (*this); }
00104
00105
00106 protected:
00107
00108
00109 Vector<double> integrateFixedStep(const double& t,
00110 const Vector<double>& y,
00111 EquationOfMotion* peom,
00112 const double& tf );
00113
00114 Vector<double> integrateAdaptive(const double& t,
00115 const Vector<double>& y,
00116 EquationOfMotion* peom,
00117 const double& tf );
00118
00119
00120
00121
00122
00123
00124 int rkfqcs(double& x,
00125 Vector<double>& y,
00126 const double& htry,
00127 const double& accuracy,
00128 EquationOfMotion* peom,
00129 Vector<double>& yscal,
00130 double& hdid,
00131 double& hnext);
00132
00133
00134
00135
00136 int rkfs78(const double& x,
00137 const Vector<double>& y,
00138 const double& h,
00139 EquationOfMotion* peom,
00140 Vector<double>& yout,
00141 Vector<double>& yerr);
00142
00143 protected:
00144
00146 double accuracyEps;
00147
00149 double minStepSize;
00150
00152 bool isAdaptive;
00153
00155 static const double RKF_EPS;
00156
00158 static const double RKF_MAXSTEP;
00159
00160 private:
00161
00163 const static struct RKF78Param rkf78_param;
00164
00165
00166 double A(int i){ return rkf78_param.a[i]; }
00167
00168 double B(int i, int j){ return rkf78_param.b[i][j]; }
00169
00170 double C(int i){ return rkf78_param.c1[i]; }
00171
00172 double C2(int i){ return rkf78_param.c2[i]; }
00173
00174 double DC(int i){ return (rkf78_param.c1[i]-rkf78_param.c2[i]); }
00175
00176
00177 };
00178
00179
00180
00181 }
00182
00183
00184 #endif // GPSTK_RUNGE_KUTTA_FEHLBERG_HPP
00185