[SciPy-user] question about ODE output and time steps

Nils Wagner nwagner@iam.uni-stuttgart...
Thu Apr 26 10:23:29 CDT 2007


Trevis Crane wrote:
>
> Hi all,
>
> I’m new to python and want to start using it as a replacement for the
> too-expensive MATLAB. To that end, I’ve been playing around with the
> ode solver, as it’s a central feature of a simulation I’m working on
> now in MATLAB. I finally got the solver working, but there are some
> things about it that seem cumbersome or not ideal. I’m hoping you can
> help me figure out a better way of implementing it…
>
> First, my test code is attached. It’s a system of three coupled
> equations, an example taken from the MATLAB documentation on their
> ode45 function.
>
> 1) The Y output from ode seems to be of type array. That is, I’m
> solving a system of three coupled equations, so for each iteration the
> solver generates an array of three elements as well as the time at
> that iteration. So, as you can see in my code, I append the output
> from each iteration. This ends up giving me a list of three-element
> arrays. This seems to be a rather cumbersome way of organizing the
> output and makes plotting it rather laborious. The only way I’ve been
> able to plot it is by running a for-loop in which I populate three
> other lists (y1,y2,y3) with the appropriate values from the ode
> solver. Then I can plot it (see attached code). As I said, this seems
> overly-laborious. Any suggestions?
>
> 2) The basic solver scipy.integrate.ode requires you to specify the
> time step. I would prefer a solver with an adaptive time step
> algorithm. What do you suggest I do for this?
>
> Any help is appreciated.
>
> thanks,
>
> trevis
>
> ________________________________________________
>
> Trevis Crane
>
> Postdoctoral Research Assoc.
>
> Department of Physics
>
> University of Ilinois
>
> 1110 W. Green St.
>
> Urbana, IL 61801
>
> p: 217-244-8652
>
> f: 217-244-2278
>
> e: tcrane@uiuc.edu <mailto:tcrane@uiuc.edu>
>
> ________________________________________________
>
> ------------------------------------------------------------------------
>
> _______________________________________________
> SciPy-user mailing list
> SciPy-user@scipy.org
> http://projects.scipy.org/mailman/listinfo/scipy-user
>   
Trevis,

Did you try integrate.odeint ? I have attached a small script for
completeness.

Cheers,

Nils
-------------- next part --------------
A non-text attachment was scrubbed...
Name: test_ode.py
Type: text/x-python
Size: 455 bytes
Desc: not available
Url : http://projects.scipy.org/pipermail/scipy-user/attachments/20070426/0bf0c95b/attachment.py 


More information about the SciPy-user mailing list