[SciPy-user] Additional output from scipy.integrate.ode[int]
Pauli Virtanen
pav at iki.fi
Tue Mar 3 15:54:51 EST 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):
>
[clip]
> def f(t, y, arg1):
> extra = y[0]*t - y[1]
> rhs = [1j*arg1*y[0] + y[1], -arg1*y[1]**2]
> return (rhs,extra)
[clip|
> while r.successful() and r.t < t1:
> r.integrate(r.t+dt)
> print r.t, r.y, r.extra
[clip]
> 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[0]*t - y[1]
rhs = [1j*arg1*y[0] + y[1], -arg1*y[1]**2]
return rhs
Note that `r` is available in `f`, since it's in the outer scope.
--
Pauli Virtanen
More information about the SciPy-User
mailing list