gsl_ode_solver.h

Go to the documentation of this file.
00001 
00002 
00003 //
00008 //
00009 //--------------------------------------------------------------------------
00010 //--------------------------------------------------------------------------
00011 //  
00012 //  libMoM Library - a library for stochastic simulations in engineering.
00013 // 
00014 //  Copyright (C) 2010 Rochan R. Upadhyay
00015 // 
00016 //  This library is free software; you can redistribute it and/or
00017 //  modify it under the terms of the Version 2.1 GNU Lesser General
00018 //  Public License as published by the Free Software Foundation.
00019 // 
00020 //  This library is distributed in the hope that it will be useful,
00021 //  but WITHOUT ANY WARRANTY; without even the implied warranty of
00022 //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
00023 //  Lesser General Public License for more details.
00024 // 
00025 //  You should have received a copy of the GNU Lesser General Public
00026 //  License along with this library; if not, write to the Free Software
00027 //  Foundation, Inc. 51 Franklin Street, Fifth Floor, 
00028 //  Boston, MA  02110-1301  USA
00029 // 
00030 //--------------------------------------------------------------------------
00031 
00032 
00033 #ifndef _GSL_ODE_SOLVER_H
00034 #define _GSL_ODE_SOLVER_H
00035 
00036 #include <gsl/gsl_odeiv.h>
00037 #include "gsl_vector_double.h"
00038 
00039 typedef unsigned int uint;
00040 
00041 class ode_function
00042 {
00043     public:
00044 
00046 //
00048 //    
00049     
00050     virtual vector operator()(double t, const vector& x);       
00051     
00053 //
00058 //    
00059     
00060     static int func(double t, const double y[], double f[], void *p);
00061 
00063 //
00065 //    
00066     
00067     void set_params(const vector &vpass);
00068 
00070 //
00071 
00072     double *params; 
00073 
00075 //
00077 //
00078 
00079     void set_dimension(uint dim);
00080 
00082 //
00083 
00084     uint dim;
00085     
00086 };
00087 
00089 //
00090 
00091 class ode_solver 
00092 {
00093 
00094     public:
00095 
00097 //
00105     
00106     
00107     ode_solver(uint _dim, double _etol_abs, double _etol_rel,
00108                         const gsl_odeiv_step_type* type=gsl_odeiv_step_gear2);
00109 
00111 //
00113 //
00114     
00115     ~ode_solver();
00116     
00118 //
00120 //
00121     
00122     void set(ode_function& function);
00123     
00125 //
00130 //
00131 
00132     int evolve(double& t, double t1, double& step_size, vector& solution_y);
00133     
00134     private:
00135     
00137 //
00138 
00139     void assert_set();
00140     
00142 //    
00143     
00144     uint dim;
00145     
00147 //    
00148 
00149         double etol_abs;
00150 
00152 //
00153 
00154         double etol_rel;
00155         
00157 //      
00158 
00159         bool isSet;
00160         
00162 //      
00163         
00164         bool isConverged;
00165         
00167 //
00168     
00169     gsl_odeiv_step * s;
00170 
00172 //
00173 
00174     gsl_odeiv_control * c;
00175 
00177 //
00178 
00179     gsl_odeiv_evolve * e;
00180 
00182 //
00183     gsl_odeiv_system sys; 
00184     
00185 };
00186 
00187 #endif // _GSL_ODE_SOLVERER_H
00188 
All Classes Files Functions Variables Typedefs Friends Defines