|
From: | Tommy Nordgren |
Subject: | Re: [Help-gsl] problem |
Date: | Thu, 25 Aug 2005 21:30:52 +0200 |
particular solution vary, or suffer a disastrous loss of precision.Stiff equations require special methods for stepping, such as Buerlich-Stoer. There is an implementation of it in GSL
Aug 24, 2005 kl. 7:55 PM skrev address@hidden:
Thanks a lot. Attached is my function. Jun Cao Quoting Pau Cervera Badia <address@hidden>:I think it means that gsl_odeiv_evolve_apply is trying to adjust h toobtain the prescribed presicion in the integration of the equations, butthe step-size value seems too large to obtain that precision, so theroutine chooses a smaller step (see [1]). It seems like if one or moreof your variables or derivatives is unboundedly growing, so your solutions are diverging, but I'm not sure if it is the only reason because I don't know you're equations. Maybe you can post your *func* function and we can take a look. [1] http://www.gnu.org/software/gsl/manual/gsl-ref_25.html#SEC384 address@hidden wrote:Hi Pau Cervera Badia:I check h. I found that h is becoming smaller and smaller and finally get to0.0. What does it mean? Does it mean my program is wrong? Thanks again.Jun Cao Quoting Pau Cervera Badia <address@hidden>:Maybe is changing only a little. Can you monitor the h values, something as while (t < t1) { int status = gsl_odeiv_evolve_apply(e,c,s,&sys,&t,t1,&h,y); printf("%.5e %.5e %.5e\n", t, t1, h); if (status != GSL_SUCCESS) break; } will do. If h is becoming smaller and smaller, something wrong ishappening(maybe your ecuations are diverging somewhere). address@hidden wrote:Hi Pau Cervera Badia: Thank you for your response. I check my program again. It stuck int=5.790250,t1=6.467000. After gsl_odeiv_evolve_apply, t always is 5.790250 and doesnotchange. So the program stuck in the "while" loop. I try to change h to1e-2and1e-10. I get the same result. Do you have anoter idea? Thanks again.Jun Cao Quoting Pau Cervera Badia <address@hidden>:gsl_odeiv_evolve_apply(e,c,s,&sys,&t,t1,&h,y) will advance from time t to the next integration time with an optimum step-size, provided that the next time is less than t1. Otherwise it will integrate the system tot1 exactly. So after some iterations the while condition will be false.You can check that gsl_odeiv_evolve_apply is running properly with:while (t < t1) { int status = gsl_odeiv_evolve_apply(e,c,s,&sys,&t,t1,&h,y);printf("%.5e %.5e\n", t, t1); // this should print t less than t1if (status != GSL_SUCCESS) break; } printf("%.5e %.5e\n",t,t1); // this should print t equal to t1 If I'm not missing something, your program should work. Maybe theproblem is that t is always less than t1 for some other reason (maybethe routine couldn't reach the prescribed precision andgsl_odeiv_evolve_apply is trying to reduce the step-size more and more).Maybe you can check the h values. Maybe something will be of any help. address@hidden wrote:Hi:I use ordinary differential equations from GSL. The part of my programislikeexample shown in the document. const gsl_odeiv_step_type * T = gsl_odeiv_step_rk8pd; gsl_odeiv_step * s = gsl_odeiv_step_alloc (T, 9); gsl_odeiv_control * c = gsl_odeiv_control_y_new (1e-6, 0.0); gsl_odeiv_evolve * e = gsl_odeiv_evolve_alloc (9); double mu = 10; gsl_odeiv_system sys = {func, NULL, 9, &mu}; double t = 0.0; double h = 1e-6; for (i = 1; i <no_of_data_points; i++) { t1 = mytable[i]; while (t < t1) { int status = gsl_odeiv_evolve_apply (e, c, s, &sys, &t, t1, &h, y); if (status != GSL_SUCCESS) break; } ... } gsl_odeiv_evolve_free (e); gsl_odeiv_control_free (c); gsl_odeiv_step_free (s);The weird thing is that at some i, the program stuck inside of "while"loopandnever come out. gsl_odeiv_evolve_apply will give t=t, so t is always <t1.Asresult the program never stop. Dose anyone know how to solve thisproblem?Thanks. Jun Cao _______________________________________________ Help-gsl mailing list address@hidden http://lists.gnu.org/mailman/listinfo/help-gsl-- Pau Cervera i Badia (e-mail address@hidden) {Departament de Física Fonamental Martí i Franqués, 1 Universitat de Barcelona Planta 3, despatx 346 bis 08028 Barcelona tel: +34 934 921 155 Spain"To err is human, but to really foul things up requires a computer."}-- Pau Cervera i Badia (e-mail address@hidden) {Departament de Física Fonamental Martí i Franqués, 1 Universitat de Barcelona Planta 3, despatx 346 bis 08028 Barcelona tel: +34 934 921 155 Spain"To err is human, but to really foul things up requires a computer."}-- Pau Cervera i Badia (e-mail address@hidden) {Departament de Física Fonamental Martí i Franqués, 1 Universitat de Barcelona Planta 3, despatx 346 bis 08028 Barcelona tel: +34 934 921 155 Spain"To err is human, but to really foul things up requires a computer."}<ode_fcn.c> _______________________________________________ Help-gsl mailing list address@hidden http://lists.gnu.org/mailman/listinfo/help-gsl
"Home is not where you are born, but where your heart finds peace" - Tommy Nordgren, "The dying old crone"
[Prev in Thread] | Current Thread | [Next in Thread] |