[SciPy-User] The ode function does not take *args ?

The Helmbolds helmrp@yahoo....
Sat Nov 10 15:18:23 CST 2012


Consider the following ode setup:

t0 = 0
# Order of variables changed from odeint's (w, t) to (t, w).

def f(t, w, params):                    # Note -- no *args !!!
        A, D = params
        x, y = w
        return [-D * y, -A * x]          # Returns a list.
 
def jac(t, w, params):                # Note -- no *args !!!
        A, D = params
        x, y = w
        return [ [0, -D], [-A, 0] ]         # Returns a list of lists.

from scipy.integrate import ode
r = ode(f, jac)
r.set_integrator('vode', method = 'adams', with_jacobian = True)
r.set_initial_value(w0, t0)
r.set_f_params(params)              # Note -- no *args !!!
r.set_jac_params(params)           # Note -- no *args !!!

 
tf = 10
dt = 1

while r.successful() and r.t < tf:
        r.integrate(r.t + dt)
        temp = [r.t, r.y]
        print 'temp = ', temp
 
This produces essentially the same values as when using "odeint".
 
My questions are as follows:
 
    Why the quirky change in the order of the variables?
 
    I'm puzzled by the absence of *args or *params in "ode".
Moreover, if I change any of these to the "*" form, then
"ode" crashes with an error of the general form:
       "ValueError: need more than 0 values to unpack"
 
What am I doing wrong?
 
Running latest SciPy/NumPy with latest Python 2.7.x on Windows 7 64bit.

Bob H    


More information about the SciPy-User mailing list