Hi All, Attached is a patch which adds two new ODE solvers to the scipy.integrate.ode module. The solvers are dopri5 and dop853, which are explicit Runge-Kutta pairs originally developed by Dormand and Prince. The fortran code was downloaded from: http://www.unige.ch/~hairer/software.html The license is clearly BSD and SciPy compatible. These are excellent solvers, described in detail in the authors book: Solving Ordinary Differential Equations. Nonstiff Problems. 2nd edition. Springer Series in Comput. Math., vol. 8. The dopri5 code is what Matlab's ode45 is based on. I think they would be a good addition to SciPy and I have used them often (in Fortran). The attached patch tries to follow the (somewhat strange to me) coding practices of the current ode module. I have added them to the test suite, but note that there are not many tests! (I might add some if I get time). I have also tested them with my own code which uses the ode module. If I get the go ahead from some regular SciPy contributers then I'll go ahead and commit this patch. I think I still have SVN access, but I wanted this pacth to be reviewed first as it has been a long time since I did anything with SciPy. Cheers, John -- Telephone: (+44) (0) 7739 105209
On Sun, Feb 22, 2009 at 17:56, John Travers <jtravs@gmail.com> wrote:
Hi All,
Attached is a patch which adds two new ODE solvers to the scipy.integrate.ode module. The solvers are dopri5 and dop853, which are explicit Runge-Kutta pairs originally developed by Dormand and Prince. The fortran code was downloaded from:
http://www.unige.ch/~hairer/software.html
The license is clearly BSD and SciPy compatible.
These are excellent solvers, described in detail in the authors book:
Solving Ordinary Differential Equations. Nonstiff Problems. 2nd edition. Springer Series in Comput. Math., vol. 8.
The dopri5 code is what Matlab's ode45 is based on.
I think they would be a good addition to SciPy and I have used them often (in Fortran). The attached patch tries to follow the (somewhat strange to me) coding practices of the current ode module. I have added them to the test suite, but note that there are not many tests! (I might add some if I get time). I have also tested them with my own code which uses the ode module.
If I get the go ahead from some regular SciPy contributers then I'll go ahead and commit this patch. I think I still have SVN access, but I wanted this pacth to be reviewed first as it has been a long time since I did anything with SciPy.
* Typo: "first 0rder" * You're missing dop.pyf * I don't like the conditional imports inside the classes. * Don't print things. Use warnings.warn() if you must. But otherwise, +1. -- Robert Kern "I have come to believe that the whole world is an enigma, a harmless enigma that is made terrible by our own mad attempt to interpret it as though it had an underlying truth." -- Umberto Eco
at 12:21 AM, Robert Kern <robert.kern@gmail.com> wrote:
* Typo: "first 0rder"
Fixed. This was also in the original fortran code.
* You're missing dop.pyf
Fixed in the attached patch.
* I don't like the conditional imports inside the classes.
Neither do I, but as I said, I followed the coding style already in ode.py
* Don't print things. Use warnings.warn() if you must.
Same as above. I might get round to cleaing this if I find time, but generally I don't like to change others code.
But otherwise, +1.
Thanks.
On Sun, Feb 22, 2009 at 18:36, John Travers <jtravs@gmail.com> wrote:
at 12:21 AM, Robert Kern <robert.kern@gmail.com> wrote:
* Typo: "first 0rder"
Fixed. This was also in the original fortran code.
* You're missing dop.pyf
Fixed in the attached patch.
* I don't like the conditional imports inside the classes.
Neither do I, but as I said, I followed the coding style already in ode.py
* Don't print things. Use warnings.warn() if you must.
Same as above. I might get round to cleaing this if I find time, but generally I don't like to change others code.
Well, it looks like some smartass went in and made those changes to the old code .... And that smartass will be happy to fix up yours when you check it in, if you like. -- Robert Kern "I have come to believe that the whole world is an enigma, a harmless enigma that is made terrible by our own mad attempt to interpret it as though it had an underlying truth." -- Umberto Eco
John Travers wrote:
If I get the go ahead from some regular SciPy contributers then I'll go ahead and commit this patch. I think I still have SVN access, but I wanted this pacth to be reviewed first as it has been a long time since I did anything with SciPy.
+1 -Travis -- Travis Oliphant Enthought, Inc. (512) 536-1057 (office) (512) 536-1059 (fax) http://www.enthought.com oliphant@enthought.com
Sun, 22 Feb 2009 23:56:55 +0000, John Travers wrote:
Attached is a patch which adds two new ODE solvers to the scipy.integrate.ode module. [clip]
I think this is a good point to discuss some API design decisions on scipy.integrate.ode. There are currently two main interfaces to ODE integration: - vode: a class, requires people to repeatedly call .integrate() to get values at separated points. Parameters set via method calls to the object. Uses DVODE/ZVODE. - odeint: a function, computes values at points given as arguments. Parameters set via (keyword) arguments to the function. Uses LSODA. Clearly, here we have one interface too many, and it's a bit of a mess. Either both LSODA and DVODE should be available only via one way (or both ways, as we decided to go with scipy.interpolate). Which to deprecate? Also, how to specify the integrator to use: choose the correct function, or specify the name of the integrator as a string? I'd perhaps like to see: - All integrators moved to classes (with CamelCase names). If you want to use eg. the ZVODE solver, you'd instantiate 'Zvode' class. - The 'integrate' method would support getting multiple time points at once. - There'd also be thin wrapper functions (with lowercase names), e.g. 'zvode' that would allow all solvers to have a simple odeint-type interface. - Both of the current 'ode' and 'odeint' interfaces would be dropped in Scipy 1.0, and deprecated before that. How would this sound? -- Pauli Virtanen
OK the new solvers were commited in revision 5589. On the api re-design I have some notes below: On Mon, Feb 23, 2009 at 9:03 AM, Pauli Virtanen <pav@iki.fi> wrote:
I'd perhaps like to see: - All integrators moved to classes (with CamelCase names). If you want to use eg. the ZVODE solver, you'd instantiate 'Zvode' class.
+1
- The 'integrate' method would support getting multiple time points at once. - There'd also be thin wrapper functions (with lowercase names), e.g. 'zvode' that would allow all solvers to have a simple odeint-type interface. - Both of the current 'ode' and 'odeint' interfaces would be dropped in Scipy 1.0, and deprecated before that.
+1, I too thought the api could be much cleaner. One extra convenience 'feature' would be to have wrappers to use the real data solvers with complex input. For my stuff at least I find vode or dopri5, with the problem split into real and imaginary parts, with the translatation occuring at each step (with more then 2**15 points), considerably faster than the full system under zvode. It would be easy to supply wrappers which converted the data to/from the rhs function and input data.
On Mon, Feb 23, 2009 at 09:03:50AM +0000, Pauli Virtanen wrote:
How would this sound?
In general good, but keep a simple odeint interface, with maybe a keyword argument to specify which integrator to use (it could even take an integrator instance). I was trying to help my little sister doing her homework with SciPy this week end, and grokking ODEs and integrators is hard-enough without thinking of objects and classes. Gaël
On Mon, 23 Feb 2009 12:16:16 +0100 Gael Varoquaux <gael.varoquaux@normalesup.org> wrote:
On Mon, Feb 23, 2009 at 09:03:50AM +0000, Pauli Virtanen wrote:
How would this sound?
In general good, but keep a simple odeint interface, with maybe a keyword argument to specify which integrator to use (it could even take an integrator instance).
+1 Nils
Hi John,
Attached is a patch which adds two new ODE solvers to the scipy.integrate.ode module. The solvers are dopri5 and dop853, which are explicit Runge-Kutta pairs originally developed by Dormand and Prince. The fortran code was downloaded from:
This is good news, and the scipy module certainly needs an updated API. I hope that previous discussions on this list about API changes will be looked up as there were some good suggestions then. I wonder how much extra work it would be to include H&W's stiff and delayed ODE and DAE solvers such as Radau, Retard, and Hem? Those would be of great value to Scipy users, I think, as there's little high-level language support available for those AFAIK (Radau is in PyDSTool but not the others). Thanks, Rob
I would just like to note here I added a scikit: odes, with two extra ode solver, actually dae solvers, so the api called had to be different (they are based on a residual, not on a lhs). See: http://cage.ugent.be/~bm/progs.html However the API changes, it would be nice if this type of dae solvers is considered. Benny 2009/2/23 Rob Clewley <rob.clewley@gmail.com>
Hi John,
Attached is a patch which adds two new ODE solvers to the scipy.integrate.ode module. The solvers are dopri5 and dop853, which are explicit Runge-Kutta pairs originally developed by Dormand and Prince. The fortran code was downloaded from:
http://www.unige.ch/~hairer/software.html<http://www.unige.ch/%7Ehairer/software.html>
This is good news, and the scipy module certainly needs an updated API. I hope that previous discussions on this list about API changes will be looked up as there were some good suggestions then.
I wonder how much extra work it would be to include H&W's stiff and delayed ODE and DAE solvers such as Radau, Retard, and Hem? Those would be of great value to Scipy users, I think, as there's little high-level language support available for those AFAIK (Radau is in PyDSTool but not the others).
Thanks, Rob _______________________________________________ Scipy-dev mailing list Scipy-dev@scipy.org http://projects.scipy.org/mailman/listinfo/scipy-dev
participants (8)
-
Benny Malengier
-
Gael Varoquaux
-
John Travers
-
Nils Wagner
-
Pauli Virtanen
-
Rob Clewley
-
Robert Kern
-
Travis E. Oliphant