[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Help-gsl] solving ODE in a loop

From: Lado Samushia
Subject: [Help-gsl] solving ODE in a loop
Date: Tue, 9 Sep 2008 12:04:34 -0500

I am trying to solve am ode system in a double loop (for different values of
This is how my code looks like schematically:
int func (double t, const double y[], double f[], void *params){

int jac (double t, const double y[], double *dfdy, double dfdt[], void

int main ( ) {
  double t;
  double h = 1e-6;
  double y[3];
  gsl_odeiv_evolve * e = gsl_odeiv_evolve_alloc (3);
  gsl_odeiv_step * s = gsl_odeiv_step_alloc (T, 3);
  gsl_odeiv_control * c = gsl_odeiv_control_y_new (1e-6, 0.0);

  for ( ) {
    for ( ) {
      t = 1e-6;
      //initialize parameters
      //initialize y[]
      gsl_odeiv_system sys = {func, jac, 3, parameters};
      while ( )
        int status = gsl_odeiv_evolve_apply (e, c, s, &sys, &t, t1, &h, y);
  gsl_odeiv_evolve_free (e);
  gsl_odeiv_control_free (c);
  gsl_odeiv_step_free (s);

  return 0;
It works fine for the first time, but brakes down on second (and consequent)
loop executions (gives "nan" for function values and jumps trough interval
in one step).
Can you tell me how I can fix this problem?
Thank you in advance.

reply via email to

[Prev in Thread] Current Thread [Next in Thread]