Scipy.integrate.ode Gives Up On Integration
Solution 1:
"My current suspicion is that the integrator decided that my function is constant after it did not change significantly during the first few integration steps." Your suspicion is correct. ODE solvers typically have an internal step size that is adaptively adjusted based on error estimates computed by the solver. These step sizes are independent of the times for which the output is requested; the output at the requested times is computed using interpolation of the solution at the points computed at the internal steps.
When you start your solver at t = -20
, apparently the input changes so slowly that the solver's internal step size becomes large enough that by the time the solver gets near t = 0
, the solver skips right over the input pulse.
You can limit the internal step size with the option max_step
of the set_integrator
method. If I set max_step
to 2.0 (for example),
r = ode(ode_fun).set_integrator('zvode', method='adams', with_jacobian=False,
max_step=2.0)
I get the output that you expect.
Post a Comment for "Scipy.integrate.ode Gives Up On Integration"