11 #include <gsl/gsl_errno.h>
12 #include <gsl/gsl_odeiv.h>
18 "Sends updated state to the MarkovChannel class." );
29 "True if the message has come in to set solver parameters.",
33 "Numerical method to use.",
45 "Another accuracy criterion",
51 "internal timestep to use.",
60 "Initialize solver parameters.",
66 "Handles information regarding the instantaneous rate matrix from "
67 "the MarkovRateTable class.",
71 "Handles process call",
74 "Handles reinit call",
79 static Finfo* procShared[] = {
83 "Shared message for process and reinit",
84 procShared,
sizeof( procShared ) /
sizeof(
const Finfo* )
87 static Finfo* MarkovGslFinfos[] =
100 static string doc[] =
102 "Name",
"MarkovGslSolver",
103 "Author",
"Vishaka Datta S, 2011, NCBS",
104 "Description",
"Solver for Markov Channel."
112 sizeof(MarkovGslFinfos)/
sizeof(
Finfo *),
115 sizeof(doc) /
sizeof(
string)
157 vector< vector< double > >* Q =
static_cast< vector< vector< double >
>* >( params );
158 unsigned int nVars = Q->size();
162 for (
unsigned int i = 0; i < nVars; ++i)
165 for (
unsigned int j = 0; j < nVars; ++j)
166 f[i] += state[j] * ((*Q)[j][i]);
191 if ( method ==
"rk2" ) {
193 }
else if ( method ==
"rk4" ) {
195 }
else if ( method ==
"rk5" ) {
197 }
else if ( method ==
"rkck" ) {
199 }
else if ( method ==
"rk8pd" ) {
201 }
else if ( method ==
"rk2imp" ) {
203 }
else if ( method ==
"rk4imp" ) {
205 }
else if ( method ==
"bsimp" ) {
207 cout <<
"Warning: implicit Bulirsch-Stoer method not yet implemented: needs Jacobian\n";
208 }
else if ( method ==
"gear1" ) {
210 }
else if ( method ==
"gear2" ) {
213 cout <<
"Warning: MarkovGslSolver::innerSetMethod: method '" <<
214 method <<
"' not known, using rk5\n";
255 nVars_ = initialState.size();
265 for (
unsigned int i = 0; i <
nVars_; ++i )
294 gslSys_.params =
static_cast< void *
>( &
Q_ );
306 for (
unsigned int i = 0; i <
nVars_; ++i )
309 while ( t < nextt ) {
310 int status = gsl_odeiv_evolve_apply (
318 for (
unsigned int i = 0; i <
nVars_; i++ )
321 for (
unsigned int i = 0; i <
nVars_; i++ )
324 if ( status != GSL_SUCCESS )
328 for (
unsigned int i = 0; i <
nVars_; ++i )
339 cerr <<
"MarkovGslSolver::reinit : "
340 "Initial state has not been set. Solver has not been initialized."
341 "Call init() before running.\n";
void setInternalDt(double value)
void reinit(const Eref &e, ProcPtr info)
static const Cinfo * MarkovGslSolverCinfo
static int evalSystem(double, const double *, double *, void *)
gsl_odeiv_step * gslStep_
vector< vector< double > > Q_
void setMethod(string method)
gsl_odeiv_evolve * gslEvolve_
double getInternalDt() const
void init(vector< double >)
void process(const Eref &e, ProcPtr info)
static SrcFinfo1< vector< double > > * stateOut()
void setRelativeAccuracy(double value)
const gsl_odeiv_step_type * gslStepType_
double getAbsoluteAccuracy() const
void handleQ(vector< vector< double > >)
bool getIsInitialized() const
void setAbsoluteAccuracy(double value)
vector< vector< T > > resize(vector< vector< T > >table, unsigned int n, T init)
gsl_odeiv_control * gslControl_
static const Cinfo * initCinfo()
static const Cinfo * initCinfo()
vector< double > initialState_
double getRelativeAccuracy() const