[SciPy-user] Additional output from scipy.integrate.ode[int]
Tue Mar 3 19:57:16 CST 2009
On Mar 3, 1:54 pm, Pauli Virtanen <p...@iki.fi> wrote:
> Tue, 03 Mar 2009 13:40:11 -0700, gyro wrote:
> > I was wondering if it is possible to specify additional outputs that are
> > calculated in the function specifying the rhs of the odes.
> > As an trivial example (adapting the example in the documentation):
> > def f(t, y, arg1):
> > extra = y*t - y
> > rhs = [1j*arg1*y + y, -arg1*y**2]
> > return (rhs,extra)
> > while r.successful() and r.t < t1:
> > r.integrate(r.t+dt)
> > print r.t, r.y, r.extra
> > I realize that I can calculate the 'extra' after I have the complete
> > solution, but it would be convenient to have the ability to get this
> > information directly from the solver.
> > If this capability is not currently available, is it of interest to have
> > it implemented?
> I'm not sure if there's interest to add this feature, since you can do
> def f(t, y, arg1):
> r.extra = y*t - y
> rhs = [1j*arg1*y + y, -arg1*y**2]
> return rhs
> Note that `r` is available in `f`, since it's in the outer scope.
> Pauli Virtanen
This is a great solution to my problem.
More information about the SciPy-user