Blame doc/examples/ode-initval-low-level.c
|
Packit |
67cb25 |
int
|
|
Packit |
67cb25 |
main (void)
|
|
Packit |
67cb25 |
{
|
|
Packit |
67cb25 |
const gsl_odeiv2_step_type * T
|
|
Packit |
67cb25 |
= gsl_odeiv2_step_rk8pd;
|
|
Packit |
67cb25 |
|
|
Packit |
67cb25 |
gsl_odeiv2_step * s
|
|
Packit |
67cb25 |
= gsl_odeiv2_step_alloc (T, 2);
|
|
Packit |
67cb25 |
gsl_odeiv2_control * c
|
|
Packit |
67cb25 |
= gsl_odeiv2_control_y_new (1e-6, 0.0);
|
|
Packit |
67cb25 |
gsl_odeiv2_evolve * e
|
|
Packit |
67cb25 |
= gsl_odeiv2_evolve_alloc (2);
|
|
Packit |
67cb25 |
|
|
Packit |
67cb25 |
double mu = 10;
|
|
Packit |
67cb25 |
gsl_odeiv2_system sys = {func, jac, 2, &mu};
|
|
Packit |
67cb25 |
|
|
Packit |
67cb25 |
double t = 0.0, t1 = 100.0;
|
|
Packit |
67cb25 |
double h = 1e-6;
|
|
Packit |
67cb25 |
double y[2] = { 1.0, 0.0 };
|
|
Packit |
67cb25 |
|
|
Packit |
67cb25 |
while (t < t1)
|
|
Packit |
67cb25 |
{
|
|
Packit |
67cb25 |
int status = gsl_odeiv2_evolve_apply (e, c, s,
|
|
Packit |
67cb25 |
&sys,
|
|
Packit |
67cb25 |
&t, t1,
|
|
Packit |
67cb25 |
&h, y);
|
|
Packit |
67cb25 |
|
|
Packit |
67cb25 |
if (status != GSL_SUCCESS)
|
|
Packit |
67cb25 |
break;
|
|
Packit |
67cb25 |
|
|
Packit |
67cb25 |
printf ("%.5e %.5e %.5e\n", t, y[0], y[1]);
|
|
Packit |
67cb25 |
}
|
|
Packit |
67cb25 |
|
|
Packit |
67cb25 |
gsl_odeiv2_evolve_free (e);
|
|
Packit |
67cb25 |
gsl_odeiv2_control_free (c);
|
|
Packit |
67cb25 |
gsl_odeiv2_step_free (s);
|
|
Packit |
67cb25 |
return 0;
|
|
Packit |
67cb25 |
}
|