00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #ifndef __CTODESOLVER_H__
00021 #define __CTODESOLVER_H__
00022
00023
00024
00025 #include <assert.h>
00026 #include "csphyzik/phyztype.h"
00027
00028 #define ODE_INITIAL_STATE_SIZE 1024
00029
00030
00031 typedef void (*dydt_function)(real t, const real statev[], real delta_statev[] );
00032
00033
00034
00035
00036 class OdeSolver
00037 {
00038 public:
00039
00040 OdeSolver();
00041 virtual ~OdeSolver();
00042
00047 virtual void calc_step (real y0[], real y1[], unsigned int len,
00048 real t0, real t1, dydt_function dydt) = 0;
00049
00050 protected:
00051
00052 virtual void ode_realloc (int new_size);
00053
00055 unsigned int state_size;
00056
00058 real *dy;
00059 real *Iy;
00060 };
00061
00067 class OdeRungaKutta4 : public OdeSolver
00068 {
00069 public:
00070
00071 OdeRungaKutta4 ();
00072 virtual ~OdeRungaKutta4 ();
00073
00074 void calc_step (real y0[], real y1[], unsigned int len,
00075 real t0, real t1, dydt_function dydt);
00076
00077 private:
00078
00079 void ode_realloc (int new_size);
00080
00082 real *k1;
00083 real *k2;
00084 real *k3;
00085 real *k4;
00086 };
00087
00093 class OdeEuler : public OdeSolver
00094 {
00095 public:
00096
00097 OdeEuler ();
00098
00099 void calc_step (real y0[], real y1[], unsigned int len,
00100 real t0, real t1, dydt_function dydt);
00101
00102 };
00103
00104
00111 class OdeMidPoint : public OdeSolver
00112 {
00113 public:
00114
00115 OdeMidPoint();
00116
00117 void calc_step (real y0[], real y1[], unsigned int len,
00118 real t0, real t1, dydt_function dydt);
00119
00120 };
00121
00122 #endif // __CTODESOLVER_H__