Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

scipy.integrate.ode.integrate gets stuck if you call it with the initial value #10909

Open
goatchurchprime opened this issue Oct 8, 2019 · 2 comments
Labels
defect A clear bug or issue that prevents SciPy from being installed or used as expected scipy.integrate

Comments

@goatchurchprime
Copy link

This bug has me stumped for a few hours when I was running it in Jupyter. I was setting initial value of the integrator to t0, and then running integrate(t) for t in linspace(t0, t1, N) which meant that I was calling integrate on the initial value and getting zeros.

import scipy.integrate
def f(t, y):
    return t+1
r = scipy.integrate.ode(f).set_integrator('vode', method='bdf', order=15)
r.set_initial_value(t=0, y=0.0)

print(r.integrate(0.0), r.t)  # <---- comment this line out and rerun it
print(r.integrate(0.1), r.t)
print(r.integrate(0.1), r.t)
print(r.integrate(0.2), r.t)

The response to this is:

[0.] 0.0
[0.] 0.0
[0.] 0.0
[0.] 0.0

If you comment out that first integrate line, the response is:

[0.105] 0.1
[0.105] 0.1
[0.22] 0.2

This shows that the duplicate t-value is only a problem for the initial value.

There are no errors shown in Jupyter. However, when I run the same lines on the Python command line, I got:

>>> r = scipy.integrate.ode(f).set_integrator('vode', method='bdf', order=15)
>>> r.set_initial_value(t=0, y=0.0)
<scipy.integrate._ode.ode object at 0x7fc0a8b6def0>
>>> print(r.integrate(0.0), r.t)
[0.] 0.0
>>> print(r.integrate(0.1), r.t)
 DVODE--  ISTATE (=I1) .gt. 1 but DVODE not initialized      
      In above message,  I1 =         2
[0.] 0.0

So there is a nasty error that is not getting reported through for some reason.

Scipy/Numpy/Python version information:

1.2.1 1.15.4 sys.version_info(major=3, minor=6, micro=6, releaselevel='final', serial=0)
@tylerjereddy tylerjereddy added scipy.integrate defect A clear bug or issue that prevents SciPy from being installed or used as expected labels Oct 15, 2019
@tylerjereddy
Copy link
Contributor

I'll tentatively label as a defect until someone more comfortable with integrate comments on the matter. It may also be useful to know if this persists on the latest master branch, and if it wasn't happening for older SciPy versions, but one of us can bisect if we need to & if there's a bug here.

@cesaryuan
Copy link

cesaryuan commented Mar 4, 2021

I also have this problem here, and I don't think it's very friendly to people who use it for the first time.
And thank this issue for letting me solve the problem.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
defect A clear bug or issue that prevents SciPy from being installed or used as expected scipy.integrate
Projects
None yet
Development

No branches or pull requests

3 participants