[SciPy-user] question about ODE output and time steps
Thu Apr 26 10:50:55 CDT 2007
> -----Original Message-----
> From: email@example.com
> Behalf Of Anne Archibald
> Sent: Thursday, April 26, 2007 10:38 AM
> To: SciPy Users List
> Subject: Re: [SciPy-user] question about ODE output and time steps
> On 26/04/07, Trevis Crane <firstname.lastname@example.org> wrote:
> > 1) The Y output from ode seems to be of type array. That is,
> > solving a system of three coupled equations, so for each iteration
> > solver generates an array of three elements as well as the time at
> > iteration. So, as you can see in my code, I append the output from
> > iteration. This ends up giving me a list of three-element arrays.
> > seems to be a rather cumbersome way of organizing the output and
> > 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)
> > appropriate values from the ode solver. Then I can plot it (see
> > code). As I said, this seems overly-laborious. Any suggestions?
> The plotting functions are a pain, really, I almost always have to do
> something to rearrange my data before I can plot it. The errorbar
> functions are the worst. But the rearrangements can be made less
> I suggest, before plotting, applying array() to your list; then you
> can use slicing to feed the plotting functions:
> A = array(L)
ah, yes, good... thanks
> > 2) The basic solver scipy.integrate.ode requires you to
> > time step. I would prefer a solver with an adaptive time step
> > What do you suggest I do for this?
> In fact it *is* an adaptive algorithm, they both are (odeint is just
> as basic). But they are quite clumsy to use. There is an option which
> will tell odeint to return after just one step of the internal
> If you're doing anything even moderately sophisticated (such as, for
> example, stopping on a particular y value, or obtaining a solution
> object you can treat like a function) I would look at PyDSTool.
I assumed it was fixed since you supply the dt value (or in the case of
odeint, an array of t values). By you statement above, though, I assume
these are simply to tell the solver at what times you want y information
(much like MATLAB's solvers).
What I really want to do, however, requires that I stop the solver at
some iteration step that, a priori, is unknown. I'm simulating a
dynamic system and my condition for stopping the solver is when the
energy of the system stops changing beyond a specified threshold. So
each iteration of the solver I calculated the energy, and if after so
many iterations it stops changing (much), I want the solver to stop.
As for PyDSTool -- I'll check it out.
> Anne M. Archibald
> SciPy-user mailing list
More information about the SciPy-user