[SciPy-User] _dop.error: failed in processing argument list for call-back fcn.

Warren Weckesser warren.weckesser@gmail....
Tue Feb 26 05:16:01 CST 2013


On 2/26/13, SHIHUI GUO <sguo@bournemouth.ac.uk> wrote:
> HI all,
>
> I want to use scipy to implement an oscillator, ie. solving a secod-order
> ordinary differential equation, my code is:
> ===================================
> from scipy.integrate import ode
>
> y0,t0 = [0, 1], 0
>
> def fun(t, y, params):
>     rou = 1
>     omega = 10
>     sigma = 1
>     # convergence rate, ie, lambda
>     conrate = 10
>     temp = -conrate*((y[0]^2+y[1]^2)/rou^2-sigma)
>     dy = temp*y[0] - omega*y[1]
>     ddy = omega*y[0] + temp*y[1]
>     return [dy, ddy]
>
> test = ode(fun).set_integrator('dopri5')
> test.set_initial_value(y0, t0)
> t1 = 10
> dt = 0.1
>
> while test.successful() and test.t<t1:
>     test.integrate(test.t+dt)
>     print test.t, test.yy
> ===================================
>
> ===================================
> The error says:
> _dop.error: failed in processing argument list for call-back fcn.
> File "/home/shepherd/python/research/testode.py", line 23, in <module>
>   test.integrate(test.t+dt)
> File
> "/home/shepherd/epd/epd_free-7.3-2-rh5-x86/lib/python2.7/site-packages/scipy/integrate/_ode.py",
> line 333, in integrate
>   self.f_params, self.jac_params)
> File
> "/home/shepherd/epd/epd_free-7.3-2-rh5-x86/lib/python2.7/site-packages/scipy/integrate/_ode.py",
> line 827, in run
>   tuple(self.call_args) + (f_params,)))
> ===================================
>
> Previously I use the ubuntu default python, and scipy is 0.9.0. Some thread
> says it is a bug and has been fixed in 0.10.0, so I switched to enthought,
> now the scipy is newest version, but the error remains.
>
> Thanks for any help.
>
> Shihui
>


There are a few problems in your code.

You haven't told the `ode` object that your function accepts the extra
argument `params`.  Normally you would do this with
`test.set_f_params(...)`, but since your function doesn't actually use
`params`, it is simpler to just change the function signature to

    def fun(t, y):

Next, in Python, the operator to raise a value to a power is **, not
^, so the formula for `temp` should be:

    temp = -conrate*((y[0]**2+y[1]**2)/rou**2-sigma)

Finally, the attribute for the solution is `y`, not `yy`, so the last
line should be:

    print test.t, test.y


Cheers,

Warren


> --
> *
> ---------------------------------------------------------------------------------------
> *
>
> SHIHUI GUO
> National Center for Computer Animation
> Bournemouth University
> United Kingdom
>
> BU is a Disability Two Ticks Employer and has signed up to the Mindful
> Employer charter. Information about the accessibility of University
> buildings can be found on the BU DisabledGo webpages [
> http://www.disabledgo.com/en/org/bournemouth-university ]
> This email is intended only for the person to whom it is addressed and may
> contain confidential information. If you have received this email in error,
> please notify the sender and delete this email, which must not be copied,
> distributed or disclosed to any other person.
> Any views or opinions presented are solely those of the author and do not
> necessarily represent those of Bournemouth University or its subsidiary
> companies. Nor can any contract be formed on behalf of the University or its
> subsidiary companies via email.
>
>
>


More information about the SciPy-User mailing list