00001 #ifndef INDII_ML_ODE_DIFFERENTIALMODEL_HPP 00002 #define INDII_ML_ODE_DIFFERENTIALMODEL_HPP 00003 00004 #include "boost/serialization/serialization.hpp" 00005 00006 namespace indii { 00007 namespace ml { 00008 namespace ode { 00009 00010 /** 00011 * AdaptiveRungeKutta compatible model. 00012 * 00013 * @author Lawrence Murray <lawrence@indii.org> 00014 * @version $Rev: 542 $ 00015 * @date $Date: 2008-08-31 14:44:14 +0100 (Sun, 31 Aug 2008) $ 00016 */ 00017 class DifferentialModel { 00018 public: 00019 /** 00020 * Default constructor for restoring from serialization. 00021 */ 00022 DifferentialModel(); 00023 00024 /** 00025 * Constructor. 00026 * 00027 * @param dimensions Number of state variables in the system. 00028 */ 00029 DifferentialModel(const unsigned int dimensions); 00030 00031 /** 00032 * Destructor. 00033 */ 00034 virtual ~DifferentialModel(); 00035 00036 /** 00037 * Calculate derivatives of the system at a given time. 00038 * 00039 * @param t \f$t\f$; the time. 00040 * @param y \f$\mathbf{y}(t)\f$; the values of all state variables 00041 * at time \f$t\f$. 00042 00043 * @param dydt Array into which to write the calculated derivatives 00044 * \f$\frac{d}{dt}y_i(t)\f$ for state variables at time \f$t\f$. 00045 * 00046 * @see indii::ml::aux::arrayToVector and 00047 * indii::ml::aux::vectorToArray for convenient methods for 00048 * converting between C/C++ arrays and indii::ml::aux::vector. 00049 * 00050 * @see gsl_odeiv_system data type and gsl_odeiv_evolve_apply() 00051 * function of the @ref GSL "GSL". 00052 */ 00053 virtual void calculateDerivatives(double t, const double y[], 00054 double dydt[]) = 0; 00055 00056 /* 00057 * Compute Jacobian of the system of differential equations. 00058 * 00059 * @param t The time. 00060 * @param y The value of all state variables \f$y_i\f$ at time t. 00061 * @param dfdy Row-ordered array in which to write the Jacobian 00062 * matrix of derivatives \f$\frac{d^2y_i}{dt dy_j}\f$ for each pair 00063 * of state variables \f$y_i\f$ and \f$y_j\f$. 00064 * @param dfdt Array in which to write the calculated derivative 00065 * \f$\frac{d^2y_i}{dt^2}\f$ for each state variable \f$y_i\f$. 00066 * 00067 * @see gsl_odeiv_system data type and gsl_odeiv_evolve_apply() 00068 * function of the @ref GSL for more information. 00069 */ 00070 //virtual void calculateJacobian(double t, const double y[], double *dfdy, 00071 // double *dfdt) = 0; 00072 00073 /** 00074 * Number of state variables in the system. 00075 * 00076 * @return Number of state variables in the system. 00077 */ 00078 unsigned int getDimensions(); 00079 00080 private: 00081 /** 00082 * Number of state variables in the system. 00083 */ 00084 unsigned int dimensions; 00085 00086 /** 00087 * Serialize, or restore from serialization. 00088 */ 00089 template<class Archive> 00090 void serialize(Archive& ar, const unsigned int version); 00091 00092 /* 00093 * Boost.Serialization requirements. 00094 */ 00095 friend class boost::serialization::access; 00096 00097 }; 00098 00099 } 00100 } 00101 } 00102 00103 template<class Archive> 00104 void indii::ml::ode::DifferentialModel::serialize(Archive& ar, 00105 const unsigned int version) { 00106 ar & dimensions; 00107 } 00108 00109 #endif
1.5.3