00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00033 #ifndef _RUNGEKUTTAFEHLBERGIVPODESOLVER_HPP_
00034 #define _RUNGEKUTTAFEHLBERGIVPODESOLVER_HPP_
00035
00036 #include "AbstractOneStepIvpOdeSolver.hpp"
00037 #include "AbstractOdeSystem.hpp"
00038 #include "OdeSolution.hpp"
00039
00040 #include <vector>
00041
00053 class RungeKuttaFehlbergIvpOdeSolver : public AbstractIvpOdeSolver
00054 {
00055 friend class TestRungeKuttaFehlbergIvpOdeSolver;
00056
00057 private:
00058
00059
00060
00061
00062 double m1932o2197;
00063 double m7200o2197;
00064 double m7296o2197;
00065 double m12o13;
00066 double m439o216;
00067 double m3680o513;
00068 double m845o4104;
00069 double m8o27;
00070 double m3544o2565;
00071 double m1859o4104;
00072 double m1o360;
00073 double m128o4275;
00074 double m2197o75240;
00075 double m2o55;
00076 double m25o216;
00077 double m1408o2565;
00078 double m2197o4104;
00079 std::vector<double> mError;
00080 std::vector<double> mk1;
00081 std::vector<double> mk2;
00082 std::vector<double> mk3;
00083 std::vector<double> mk4;
00084 std::vector<double> mk5;
00085 std::vector<double> mk6;
00086 std::vector<double> myk2;
00087 std::vector<double> myk3;
00088 std::vector<double> myk4;
00089 std::vector<double> myk5;
00090 std::vector<double> myk6;
00091
00092 protected:
00105 void InternalSolve(OdeSolution& rSolution,
00106 AbstractOdeSystem* pAbstractOdeSystem,
00107 std::vector<double>& rCurrentYValues,
00108 std::vector<double>& rWorkingMemory,
00109 double startTime,
00110 double endTime,
00111 double maxTimeStep,
00112 double minTimeStep,
00113 double tolerance,
00114 bool outputSolution);
00115
00127 void CalculateNextYValue(AbstractOdeSystem* pAbstractOdeSystem,
00128 double timeStep,
00129 double time,
00130 std::vector<double>& currentYValues,
00131 std::vector<double>& nextYValues);
00132
00143 void AdjustStepSize(double& rCurrentStepSize, const double& rError, const double& rTolerance,
00144 const double& rMaxTimeStep, const double& rMinTimeStep);
00145
00146 public:
00147
00148 OdeSolution Solve(AbstractOdeSystem* pAbstractOdeSystem,
00149 std::vector<double>& rYValues,
00150 double startTime,
00151 double endTime,
00152 double timeStep,
00153 double ignoredSamplingTime);
00154
00155 void Solve(AbstractOdeSystem* pAbstractOdeSystem,
00156 std::vector<double>& rYValues,
00157 double startTime,
00158 double endTime,
00159 double timeStep);
00160
00161 RungeKuttaFehlbergIvpOdeSolver()
00162 : m1932o2197(1932.0/2197.0),
00163 m7200o2197(7200.0/2197.0),
00164 m7296o2197(7296.0/2197.0),
00165 m12o13(12.0/13.0),
00166 m439o216(439.0/216.0),
00167 m3680o513(3680.0/513.0),
00168 m845o4104(845.0/4104.0),
00169 m8o27(8.0/27.0),
00170 m3544o2565(3544.0/2565.0),
00171 m1859o4104(1859.0/4104.0),
00172 m1o360(1.0/360.0),
00173 m128o4275(128.0/4275.0),
00174 m2197o75240(2197.0/75240.0),
00175 m2o55(2.0/55.0),
00176 m25o216(25.0/216.0),
00177 m1408o2565(1408.0/2565.0),
00178 m2197o4104(2197.0/4104.0)
00179 {
00180 };
00181 };
00182
00183 #endif //_RUNGEKUTTAFEHLBERGIVPODESOLVER_HPP_