rtol = 1e-5 tspan = [t0, tf] delays = [tau] def h(t): return [(-1)**(np.floor(-5 * t))] jumps = sorted([-k * (1 / 5) for k in range(1, 6)]) tspan = [t0, tf] sol = solve_dde(fun, tspan, delays, y0, h, method='RK23', jumps=jumps, atol=atol, rtol=rtol) sol45 = solve_dde(fun, tspan, delays, y0, h, method='RK45', jumps=jumps, atol=atol, rtol=rtol) t = sol.t
tf = 10.0 atol = 1e-10 rtol = 1e-5 tspan = [t0, tf] delays = [tau] def h(t): return [1] sol = solve_dde(fun, tspan, delays, y0, h, method='RK23', tracked_stages=None, atol=atol, rtol=rtol) t = sol.t y = sol.y[0, :] yp = sol.yp[0, :] #jit cdde f = [-y_jit(0, t_jit - tau)] DDE = jitcdde(f) DDE.set_integration_parameters(atol=atol, rtol=rtol) DDE.constant_past(y0) DDE.step_on_discontinuities() data = []
tf = 40 tau1 = 1. tau10 = 10. y0 = [5., .1, 1.0] delays = [tau1, tau10] tspan = [t0, tf] zeros = [zero_y0, zero_y1, zero_y2] atol = 1e-10 rtol = 1e-5 sol23 = solve_dde(fun, tspan, delays, y0, y0, method='RK23', events=zeros, atol=atol, rtol=rtol) t = sol23.t y0 = sol23.y[0, :] y1 = sol23.y[1, :] y2 = sol23.y[2, :] y0_e = sol23.y_events[0][:, 0] y1_e = sol23.y_events[1][:, 1] y2_e = sol23.y_events[2][:, 2] import scipy.io as spio
beta = 0.25 gamma = 0.1 args = (beta, gamma) atol = 1e-10 rtol = 1e-5 tspan = [t0, tf] delays = [tau] y0 = [1.0] def h(t): return [1.] sol23 = solve_dde(fun, tspan, delays, y0, h, method='RK23', args=args, atol=atol, rtol=rtol) t = sol23.t y = sol23.y[0,:] yp = sol23.yp[0,:] sol45 = solve_dde(fun, tspan, delays, y0, h, method='RK45', args=args, atol=atol, rtol=rtol) t45 = sol45.t y45 = sol45.y[0,:] yp45 = sol45.yp[0,:] # jitcdde f = [ beta * y_jit(0,t_jit-tau) / (1 + y_jit(0,t_jit-tau)**n) - gamma*y_jit(0) ] DDE = jitcdde(f) DDE.set_integration_parameters(atol=atol, rtol=rtol) DDE.constant_past([1.0]) DDE.step_on_discontinuities()
def ev(t, y, Z): return y[0] ev.terminal = True ev.direction = -1 delays = [] sol = solve_dde(fun, tspan, delays, y0, y0, method='RK23', events=ev, dense_output=True, atol=atol, rtol=rtol) t = sol.t y_0 = sol.y[0, :] y_1 = sol.y[1, :] t_ = np.linspace(0, t[-1]) y1_interp = sol.sol(t_)[1, :] y0_interp = sol.sol(t_)[0, :] plt.figure() plt.plot(t_ivp, y_1_ivp, 'o', label='solve_ivp y1') plt.plot(t, y_1, 'k', label='solve_dde y1') plt.plot(t_ivp, y_0_ivp, 'o', label='solve_ivp y0')
tau = 0.74 y0 = [19.001] h = [19.0] t0 = 0.0 tf = 40.0 atol = 1e-8 rtol = 1e-8 tspan = [t0, tf] delays = [tau] sol = solve_dde(fun, tspan, delays, y0, h, method='RK23', atol=atol, rtol=rtol, dense_output=True) t = sol.t y = sol.y[0, :] yp = sol.yp[0, :] t_m = 5.5 y0_ = sol.sol(t_m) sol_re = solve_dde(fun, [t_m, tf], delays, y0_, sol, method='RK23',
finalEvent.terminal = True def hitGround(t, y, Z): return y[0] hitGround.direction = 0 # % All events have to be reported hitGround.terminal = True events = [finalEvent, hitGround] sol23 = solve_dde(fun, tspan, delays, y0, y0, method='RK23', atol=atol, rtol=rtol, events=events) print( "\nKind of Event: solve_dde dde23 reference DDE_SOLVER" ) # ref values of matlab dde23 example script ref = [4.516757065, 9.751053145, 11.670393497] # computed values from matlab dde23 with same atol & rtol mat = [4.5167708185, 9.7511043904, 11.6703836720] # from DDE_SOLVER fortran routine example : Example 4.4.5: Events and Change Routine f90 = [4.5167570861630821, 9.7510847727976273, 11.670385883524640] e = 0
return [-10.0] y0 = 1.0 jumps = [1.] tf = 2.0 tspan = [0.0, tf] delays = [] rtol = 1e-5 atol = 1e-10 sol23 = solve_dde(fun, tspan, delays, [y0], [y0], method='RK23', atol=atol, rtol=rtol) sol23_j = solve_dde( fun, tspan, delays, [y0], [y0], #tracked_stages=0, method='RK23', jumps=jumps, atol=atol, rtol=rtol) print('nfev of f without jumps option : %s' % (sol23.nfev)) print('nfev of f wit jumps option : %s' % (sol23_j.nfev))
args = (tau, N_D, delta, P) atol = 1e-10 rtol = 1e-5 tspan = [t0, tf] delays = [tau] y0 = [100] jumps = [tau] sol = solve_dde(fun, tspan, delays, y0, y0, method='RK23', args=args, jumps=jumps, atol=atol, rtol=rtol) t = sol.t y = sol.y[0, :] yp = sol.yp[0, :] plt.figure() plt.plot(y, yp, label='solve_dde') plt.xlabel('y') plt.ylabel('yp') plt.legend() plt.savefig('figures/gurney/phase')