Using Adaptive Time Step For Scipy.integrate.ode When Solving Ode Systems
I have to just read Using adaptive step sizes with scipy.integrate.ode and the accepted solution to that problem, and have even reproduced the results by copy-and-paste in my Pytho
Solution 1:
In the line
y_solutions.append(y)
you think that you are appending the current vector. What actally happens is that you are appending the object reference to y
. Since apparently the integrator reuses the vector y
during the integration loop, you are always appending the same object reference. Thus at the end, each position of the list is filled by the same reference pointing to the vector of the last state of y
.
Long story short: replace with
y_solutions.append(y.copy())
and everything is fine.
Post a Comment for "Using Adaptive Time Step For Scipy.integrate.ode When Solving Ode Systems"