Passing variables to the ODE

Passing variables to the ODE

I would like to do a series of solutions of a ODE while passing varies variables to it for each different solution. I didn't see an easy way to do this in the manual, perhaps I am missing something or a more general trick? My C coding tends to be piecemeal.

Thanks,
Jacob Alldredge

7 posts / 0 new
Last post
For more complete information about compiler optimizations, see our Optimization Notice.

Hi,Could you clarify what kind of variables you want to vary?With best regardsAlexander Kalinkin

Thanks, basically I have a system of ODES that depend on 6 different floats that I wan tto vary as I search for a specific output. I want to use openmp to run a bunch of different parameter sets at once. However right now the only thing I can figure out is to try to store different arrays of parameters gobally and call them from inside each thread, however this seems to not be working.

Thank you for your help.

Hi,You are right, the best way to realize several solvers of ODE on different threads is to distribute them fully between threads. If this approuch doesn't work could you send testcase to us to investigate problem and find out the solution of it?With best regards,Alexander Kalinkin

Thanks, I have something I think works now, at least in serial, using a dummy equation in the series of ode's to pass an index variable to each iteration. I'm still trying to get the OpenMP part working. I'll let you know if I fail.

Thanks for your help.

Jacob,
Thanks for using ODE solver and feel free to ask anything about it!

With best regards,
Alexander Kalinkin

Alexander,

I think that what is needed is to allow the passing of "user parameters" to the user function that computes the derivatives. For example,

dy/dt = f( t , y ; p )

where y and p are arrays of unrelated sizes, and p is a constant during a single integration. However, the user wishes to run a number of integrations with different p. The traditional way of handling this is to allow the user function to have two additional array arguments:

      subroutine (n, t, y, a, ipar, rpar)
      integer n
      double precision t, y(n), a(n,n), rpar(*)
      integer ipar (*)

and the user arrays ipar() and rpar() would be additional, optional, arguments to dodesol and the other solvers. The solver itself would need only to check if these arguments are present and, if so, simply pass them to the user function whenever it needs the derivatives evaluated.

See, for example, the routine odex2.f in Hairer's Web page.

Leave a Comment

Please sign in to add a comment. Not a member? Join today