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

Trevis Crane t_crane@mrl.uiuc....
Thu Apr 26 10:06:56 CDT 2007


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

________________________________________________

 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://projects.scipy.org/pipermail/scipy-user/attachments/20070426/1a5ace6d/attachment-0001.html 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: odeTest.py
Type: application/octet-stream
Size: 635 bytes
Desc: odeTest.py
Url : http://projects.scipy.org/pipermail/scipy-user/attachments/20070426/1a5ace6d/attachment-0001.obj 


More information about the SciPy-user mailing list