This is the mail archive of the
gsl-discuss@sources.redhat.com
mailing list for the GSL project.
RE: Setting multiple ODE parameters
- From: "Elie Allouis" <E dot Allouis at eim dot surrey dot ac dot uk>
- To: "Robert G. Brown" <rgb at phy dot duke dot edu>
- Cc: <gsl-discuss at sources dot redhat dot com>
- Date: Tue, 17 Aug 2004 23:55:40 +0100
- Subject: RE: Setting multiple ODE parameters
I appreciate all the answers I have received. I want to thanks particularly Mr Roger Brown for his rather complete analysis of my query. I think it has clarified the topic.
I am posting below one of the answer I received that has not been posted on the list, in case it can be useful to somebody in the future. This will provides an other practical example of Mr Brown analysis.
Thank you very much,
Rgds,
Elie Allouis
--------------------------------------------
Elie Allouis
U.5
Surrey Space Centre
Guildford, UK
--------------------------------------------
<<<- Edited--->>>
I define a structure as:
struct ODE_params
{
double Q, drive_freq, r;
};
In the code I define a variable of type structure like
struct ODE_params rod_param={ 1.2577, // Quality factor "Q"
1.17731, // Drive frequency "a"
1.088 }; // Radii ratio "r"
I pass the pointer to rod_param to the ODE integrator as
gsl_odeiv_system sys = {func, jac, ODE_DIM, &rod_param};
Functions 'func' and 'jac' may use some of the parameters. At the beginning of
each function I add these several lines to recast void pointer into pointer
to the structure and assign elements of the structure to local variables
inside the function.
int
func (double t, const double y[], double f[],
void *params)
{
struct ODE_params *p
= (struct ODE_params *) params;
double Q = p->Q;
double a = p->drive_freq;
double r = p->r;
(...)
Hope this helps. Also, have a look in gsl documentation under multiroot
solvers. In the examples there they use the same trick.
<<<----End--->>>>