[SciPy-user] Additional output from scipy.integrate.ode[int]
Tue Mar 3 14:54:51 CST 2009
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:
> 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]
Note that `r` is available in `f`, since it's in the outer scope.
More information about the SciPy-user