I'm trying to use
scipy in Python to solve an IVP. I specified the
tspan argument of
solve_ivp to be
(0,10), as shown below. However, for some reason, the solutions I get always stop around t=2.5.
from scipy.integrate import solve_ivp import numpy as np import matplotlib.pyplot as plt import scipy.optimize as optim def dudt(t, u): return u*(1-u/12)-4*np.heaviside(-(t-5), 1) ic = [2,4,6,8,10,12,14,16,18,20] sol = solve_ivp(dudt, (0, 10), ic, t_eval=np.linspace(0, 10, 10000)) for solution in sol.y: y = [y for y in solution if y >= 0] t = sol.t[:len(y)] plt.plot(t, y)