55# ## In-place function
66
77function f_1delay (du, u, h, p, t)
8- du[1 ] = - h (t - oneunit (t))[1 ] / oneunit (t)
8+ du[1 ] = - h (p, t - oneunit (t))[1 ] / oneunit (t)
99end
1010
1111function f_1delay (:: Type{Val{:analytic}} , u₀, p, t)
@@ -47,7 +47,7 @@ function f_1delay(::Type{Val{:analytic}}, u₀, p, t)
4747end
4848
4949build_prob_dde_1delay (u₀, :: T = u₀) where {T} =
50- DDEProblem (f_1delay, [u₀], t -> [zero (u₀)], (zero (T), T (10 )),
50+ DDEProblem (f_1delay, [u₀], (p, t) -> [zero (u₀)], (zero (T), T (10 )),
5151 constant_lags = [oneunit (T)])
5252
5353"""
@@ -79,15 +79,15 @@ prob_dde_1delay = build_prob_dde_1delay(1.0)
7979# ## Not in-place function
8080
8181function f_1delay_notinplace (u, h, p, t)
82- - h (t - oneunit (t)) ./ oneunit (t)
82+ - h (p, t - oneunit (t)) ./ oneunit (t)
8383end
8484
8585f_1delay_notinplace (:: Type{Val{:analytic}} , u0, p, t) = f_1delay (Val{:analytic }, u0, p, t)
8686
8787# ### Vectorized history function
8888
8989build_prob_dde_1delay_notinplace (u₀, :: T = u₀) where {T} =
90- DDEProblem (f_1delay_notinplace, [u₀], t -> [zero (u₀)], (zero (T), T (10 )),
90+ DDEProblem (f_1delay_notinplace, [u₀], (p, t) -> [zero (u₀)], (zero (T), T (10 )),
9191 constant_lags = [oneunit (T)])
9292
9393"""
@@ -101,8 +101,8 @@ prob_dde_1delay_notinplace = build_prob_dde_1delay_notinplace(1.0)
101101# ### Scalar history function
102102
103103build_prob_dde_1delay_scalar_notinplace (u₀, :: T = u₀) where {T} =
104- DDEProblem (f_1delay_notinplace, u₀, t -> zero (u₀), (zero (T), T (10 )),
105- constant_lags = [oneunit (T)])
104+ DDEProblem (f_1delay_notinplace, u₀, (p, t) -> zero (u₀), (zero (T), T (10 )),
105+ constant_lags = [oneunit (T)])
106106
107107"""
108108 prob_dde_1delay_scalar_notinplace
@@ -117,7 +117,7 @@ prob_dde_1delay_scalar_notinplace = build_prob_dde_1delay_scalar_notinplace(1.0)
117117# ## In-place function
118118
119119function f_2delays (du, u, h, p, t:: T ) where T
120- du[1 ] = (- h (t - T (1 // 3 ))[1 ] - h (t - T (1 // 5 ))[1 ]) / oneunit (t)
120+ du[1 ] = (- h (p, t - T (1 // 3 ))[1 ] - h (p, t - T (1 // 5 ))[1 ]) / oneunit (t)
121121end
122122
123123function f_2delays (:: Type{Val{:analytic}} , u₀, p, t)
@@ -157,7 +157,7 @@ function f_2delays(::Type{Val{:analytic}}, u₀, p, t)
157157end
158158
159159build_prob_dde_2delays (u₀, :: T = u₀) where {T} =
160- DDEProblem (f_2delays, [u₀], t -> [zero (u₀)], (zero (T), oneunit (T)),
160+ DDEProblem (f_2delays, [u₀], (p, t) -> [zero (u₀)], (zero (T), oneunit (T)),
161161 constant_lags = [T (1 // 3 ), T (1 // 5 )])
162162
163163"""
@@ -189,7 +189,7 @@ prob_dde_2delays = build_prob_dde_2delays(1.0)
189189# ## Not in-place function
190190
191191function f_2delays_notinplace (u, h, p, t:: T ) where T
192- (- h (t - T (1 // 3 )) .- h (t - T (1 // 5 ))) ./ oneunit (t)
192+ (- h (p, t - T (1 // 3 )) .- h (p, t - T (1 // 5 ))) ./ oneunit (t)
193193end
194194
195195f_2delays_notinplace (:: Type{Val{:analytic}} , u0, p, t) =
@@ -198,7 +198,7 @@ f_2delays_notinplace(::Type{Val{:analytic}}, u0, p, t) =
198198# ### Vectorized history function
199199
200200build_prob_dde_2delays_notinplace (u₀, :: T = u₀) where {T} =
201- DDEProblem (f_2delays_notinplace, [u₀], t -> [zero (u₀)], (zero (T), oneunit (T)),
201+ DDEProblem (f_2delays_notinplace, [u₀], (p, t) -> [zero (u₀)], (zero (T), oneunit (T)),
202202 constant_lags = [T (1 // 3 ), T (1 // 5 )])
203203
204204"""
@@ -212,7 +212,7 @@ prob_dde_2delays_notinplace = build_prob_dde_2delays_notinplace(1.0)
212212# ### Scalar history function
213213
214214build_prob_dde_2delays_scalar_notinplace (u₀, :: T = u₀) where {T} =
215- DDEProblem (f_2delays_notinplace, u₀, t -> zero (u₀), (zero (T), oneunit (T)),
215+ DDEProblem (f_2delays_notinplace, u₀, (p, t) -> zero (u₀), (zero (T), oneunit (T)),
216216 constant_lags = [T (1 // 3 ), T (1 // 5 )])
217217
218218"""
@@ -230,11 +230,11 @@ prob_dde_2delays_scalar_notinplace = build_prob_dde_2delays_scalar_notinplace(1.
230230# ## In-place function
231231
232232function f_1delay_long (du, u, h, p, t:: T ) where T
233- du[1 ] = (- h (t - T (1 // 5 ))[1 ] + u[1 ]) / oneunit (t)
233+ du[1 ] = (- h (p, t - T (1 // 5 ))[1 ] + u[1 ]) / oneunit (t)
234234end
235235
236236build_prob_dde_1delay_long (u₀, :: T = u₀) where {T} =
237- DDEProblem (f_1delay_long, [u₀], t -> [zero (u₀)], (zero (T), T (100 )),
237+ DDEProblem (f_1delay_long, [u₀], (p, t) -> [zero (u₀)], (zero (T), T (100 )),
238238 constant_lags = [T (1 // 5 )])
239239
240240"""
@@ -264,11 +264,11 @@ prob_dde_1delay_long = build_prob_dde_1delay_long(1.0)
264264# ## Not in-place function
265265
266266function f_1delay_long_notinplace (u, h, p, t:: T ) where T
267- (- h (t - T (1 // 5 )) .+ u ) ./ oneunit (t)
267+ (- h (p, t - T (1 // 5 )) .+ u ) ./ oneunit (t)
268268end
269269
270270build_prob_dde_1delay_long_notinplace (u₀, :: T = u₀) where {T} =
271- DDEProblem (f_1delay_long_notinplace, [u₀], t -> [zero (u₀)], (zero (T), T (100 )),
271+ DDEProblem (f_1delay_long_notinplace, [u₀], (p, t) -> [zero (u₀)], (zero (T), T (100 )),
272272 constant_lags = [T (1 // 5 )])
273273
274274"""
@@ -280,7 +280,7 @@ in-place function.
280280prob_dde_1delay_long_notinplace = build_prob_dde_1delay_long_notinplace (1.0 )
281281
282282build_prob_dde_1delay_long_scalar_notinplace (u₀, :: T = u₀) where {T} =
283- DDEProblem (f_1delay_long_notinplace, u₀, t -> zero (u₀), (zero (T), T (100 )),
283+ DDEProblem (f_1delay_long_notinplace, u₀, (p, t) -> zero (u₀), (zero (T), T (100 )),
284284 constant_lags = [T (1 // 5 )])
285285
286286"""
@@ -296,12 +296,12 @@ prob_dde_1delay_long_scalar_notinplace = build_prob_dde_1delay_long_scalar_notin
296296# ## In-place function
297297
298298function f_2delays_long (du, u, h, p, t:: T ) where T
299- du[1 ] = (- h (t - T (1 // 3 ))[1 ] - h (t - T (1 // 5 ))[1 ]) / oneunit (t)
299+ du[1 ] = (- h (p, t - T (1 // 3 ))[1 ] - h (p, t - T (1 // 5 ))[1 ]) / oneunit (t)
300300end
301301
302302build_prob_dde_2delays_long (u₀, :: T = u₀) where {T} =
303- DDEProblem (f_2delays_long, [u₀], t -> [zero (u₀)], (zero (T), T (100 )),
304- constant_lags = [T (1 // 3 ), T (1 // 5 )])
303+ DDEProblem (f_2delays_long, [u₀], (p, t) -> [zero (u₀)], (zero (T), T (100 )),
304+ constant_lags = [T (1 // 3 ), T (1 // 5 )])
305305
306306"""
307307 prob_dde_2delays_long
@@ -330,13 +330,13 @@ prob_dde_2delays_long = build_prob_dde_2delays_long(1.0)
330330# ## Not in-place function
331331
332332function f_2delays_long_notinplace (u, h, p, t:: T ) where T
333- (- h (t - T (1 // 3 )) .- h (t - T (1 // 5 ))) ./ oneunit (t)
333+ (- h (p, t - T (1 // 3 )) .- h (p, t - T (1 // 5 ))) ./ oneunit (t)
334334end
335335
336336# ### Vectorized history function
337337
338338build_prob_dde_2delays_long_notinplace (u₀, :: T = u₀) where {T} =
339- DDEProblem (f_2delays_long_notinplace, [u₀], t -> [zero (u₀)], (zero (T), T (100 )),
339+ DDEProblem (f_2delays_long_notinplace, [u₀], (p, t) -> [zero (u₀)], (zero (T), T (100 )),
340340 constant_lags = [T (1 // 3 ), T (1 // 5 )])
341341
342342"""
@@ -350,7 +350,7 @@ prob_dde_2delays_long_notinplace = build_prob_dde_2delays_long_notinplace(1.0)
350350# ### Scalar history function
351351
352352build_prob_dde_2delays_long_scalar_notinplace (u₀, :: T = u₀) where {T} =
353- DDEProblem (f_2delays_long_notinplace, u₀, t -> zero (u₀), (zero (T), T (100 )),
353+ DDEProblem (f_2delays_long_notinplace, u₀, (p, t) -> zero (u₀), (zero (T), T (100 )),
354354 constant_lags = [T (1 // 3 ), T (1 // 5 )])
355355
356356"""
@@ -368,7 +368,7 @@ differential equations.
368368=#
369369
370370function f_dde_mackey (du, u, h, p, t)
371- du[1 ] = 0.2 * h (t- 14 )[1 ]/ (1 + h (t- 14 )[1 ]^ 10 ) - 0.1 * u[1 ]
371+ du[1 ] = 0.2 * h (p, t- 14 )[1 ]/ (1 + h (p, t- 14 )[1 ]^ 10 ) - 0.1 * u[1 ]
372372end
373373
374374"""
@@ -377,11 +377,11 @@ end
377377Model of blood production with constant delay (M. C. Mackey and L. Glass, Oscillation and
378378chaos in physiological control systems, 1977).
379379"""
380- prob_dde_mackey = DDEProblem (f_dde_mackey, [0.5 ], t -> [0.5 ], (0.0 , 500.0 ),
380+ prob_dde_mackey = DDEProblem (f_dde_mackey, [0.5 ], (p, t) -> [0.5 ], (0.0 , 500.0 ),
381381 constant_lags = [14 ])
382382
383383function f_dde_wheldon (du, u, h, p, t)
384- du[1 ] = 1.1 / (1 + sqrt (10 )* (h (t- 20 )[1 ])^ (5 / 4 )) - 10 * u[1 ]/ (1 + 40 * u[2 ])
384+ du[1 ] = 1.1 / (1 + sqrt (10 )* (h (p, t- 20 )[1 ])^ (5 / 4 )) - 10 * u[1 ]/ (1 + 40 * u[2 ])
385385 du[2 ] = 100 * u[1 ]/ (1 + 40 * u[2 ]) - 2.43 * u[2 ]
386386end
387387u0_wheldon = [1.05767027 / 3 ; 1.030713491 / 3 ]
@@ -392,11 +392,11 @@ u0_wheldon = [1.05767027/3; 1.030713491/3]
392392Model of chronic granulocytic leukemia with constant delay (T. Wheldon, J. Kirk and
393393H. Finlay, Cyclical granulopoiesis in chronic granulocytic leukemia: A simulation study, 1974).
394394"""
395- prob_dde_wheldon = DDEProblem (f_dde_wheldon, u0_wheldon, t -> u0_wheldon, (0. , 100. ),
395+ prob_dde_wheldon = DDEProblem (f_dde_wheldon, u0_wheldon, (p, t) -> u0_wheldon, (0. , 100. ),
396396 constant_lags = [20 ])
397397
398398function f_dde_neves1 (du, u, h, p, t)
399- du[1 ] = 1 - h (exp (1 - 1 / t))[1 ]
399+ du[1 ] = 1 - h (p, exp (1 - 1 / t))[1 ]
400400end
401401# only valid for specific history function
402402function f_dde_neves1 (:: Type{Val{:analytic}} , u₀, p, t )
@@ -410,11 +410,11 @@ end
410410DDE with vanishing time dependent delay at ``t = 1`` (K. W. Neves, Automatic integratorion
411411of functional differential equations: An approach, 1975).
412412"""
413- prob_dde_neves_1 = DDEProblem (f_dde_neves1, [log (0.1 )], t -> [log (t)], (0.1 , 10. ),
413+ prob_dde_neves_1 = DDEProblem (f_dde_neves1, [log (0.1 )], (p, t) -> [log (t)], (0.1 , 10. ),
414414 dependent_lags = [(u,p,t) -> t - exp (1 - 1 / t)])
415415
416416function f_dde_neves_thompson (du, u, h, p, t)
417- if h (t/ 2 )[1 ] < 0
417+ if h (p, t/ 2 )[1 ] < 0
418418 du[1 ] = 1 - u[1 ]
419419 else
420420 du[1 ] = - 1 - u[1 ]
@@ -455,11 +455,11 @@ u(t) = 1
455455
456456for ``t \\ leq 0``.
457457"""
458- prob_dde_neves_thompson = DDEProblem (f_dde_neves_thompson, [1. ], t -> [1. ], (0. , 2 * log (66 )),
458+ prob_dde_neves_thompson = DDEProblem (f_dde_neves_thompson, [1. ], (p, t) -> [1. ], (0. , 2 * log (66 )),
459459 constant_lags = [(u,p,t) -> t/ 2 ])
460460
461461function f_dde_paul1 (du, u, h, p, t)
462- du[1 ] = - 2 * h (t - 1 - abs (u[1 ]))[1 ]* (1 - u[1 ]^ 2 )
462+ du[1 ] = - 2 * h (p, t - 1 - abs (u[1 ]))[1 ]* (1 - u[1 ]^ 2 )
463463end
464464
465465"""
@@ -480,11 +480,11 @@ u(t) = 1/2
480480
481481for ``t \\ leq 0``.
482482"""
483- prob_dde_paul1 = DDEProblem (f_dde_paul1, [0.5 ], t -> [0.5 ], (0. , 30. ),
483+ prob_dde_paul1 = DDEProblem (f_dde_paul1, [0.5 ], (p, t) -> [0.5 ], (0. , 30. ),
484484 dependent_lags = [(u,p,t) -> 1 + abs (u[1 ])])
485485
486486function f_dde_paul2 (du, u, h, p, t)
487- h1 = h (t - u[2 ])[1 ]
487+ h1 = h (p, t - u[2 ])[1 ]
488488 du[1 ] = - 2 * h1
489489 du[2 ] = (abs (h1) - abs (u[1 ]))/ (1 + abs (h1))
490490end
@@ -494,22 +494,22 @@ end
494494
495495DDE with state dependent delay (C. A. H. Paul, A test set of functional differential equations, 1994).
496496"""
497- prob_dde_paul2 = DDEProblem (f_dde_paul2, [1 ; 0.5 ], t -> [1 ; 0.5 ], (0. , 30. ),
497+ prob_dde_paul2 = DDEProblem (f_dde_paul2, [1 ; 0.5 ], (p, t) -> [1 ; 0.5 ], (0. , 30. ),
498498 dependent_lags = [(u,p,t) -> u[2 ]])
499499
500500function build_prob_dde_mahaffy (tspan, h, σ₀, T₁, γ, Q, k, a, K, r)
501501 function f (du, u, h, p, t)
502- du[1 ] = σ₀* h (t- T₁)[2 ] - γ* u[1 ] - Q
502+ du[1 ] = σ₀* h (p, t- T₁)[2 ] - γ* u[1 ] - Q
503503 du[2 ] = a/ (1 + K* u[1 ]^ r) - k* u[2 ]
504- du[3 ] = 1 - Q* exp (γ* u[3 ])/ (σ₀* h (t- T₁- u[3 ])[2 ])
504+ du[3 ] = 1 - Q* exp (γ* u[3 ])/ (σ₀* h (p, t- T₁- u[3 ])[2 ])
505505 end
506506
507- DDEProblem (f, h (0 ), h, tspan,
507+ DDEProblem (f, h (nothing , 0 ), h, tspan,
508508 constant_lags = [T₁],
509509 dependent_lags = [(u,p,t) -> T₁ + u[3 ]])
510510end
511511
512- function h_mahaffy1 (t)
512+ function h_mahaffy1 (p, t)
513513 if t < - 6
514514 return [3.325 ; 9.5 ; 120 ]
515515 else
519519prob_dde_mahaffy1 = build_prob_dde_mahaffy ((0. , 300. ), h_mahaffy1, 0.0031 , 6 , 0.001 , 0.0275 ,
520520 2.8 , 6570 , 0.0382 , 6.96 )
521521
522- prob_dde_mahaffy2 = build_prob_dde_mahaffy ((0. , 100. ), t -> [3.5 ; 10 ; 50 ], 0.00372 , 3 , 0.1 ,
522+ prob_dde_mahaffy2 = build_prob_dde_mahaffy ((0. , 100. ), (p, t) -> [3.5 ; 10 ; 50 ], 0.00372 , 3 , 0.1 ,
523523 0.00178 , 6.65 , 15600 , 0.0382 , 6.96 )
524524
525525"""
@@ -531,7 +531,7 @@ prob_dde_mahaffy1, prob_dde_mahaffy2
531531function f_dde_neves2 (du, u, h, p, t)
532532 t2 = exp (1 - u[2 ])
533533 du[1 ] = u[2 ]
534- du[2 ] = - h (t2)[2 ]* u[2 ]^ 2 * t2
534+ du[2 ] = - h (p, t2)[2 ]* u[2 ]^ 2 * t2
535535end
536536# only valid for specific history function
537537function f_dde_neves2 (:: Type{Val{:analytic}} , u₀, p, t )
@@ -545,15 +545,15 @@ end
545545DDE with vanishing state dependent delay at ``t = 1`` (K. W. Neves, Automatic integration
546546of functional differential equations: An approach, 1975).
547547"""
548- prob_dde_neves2 = DDEProblem (f_dde_neves2, [log (0.1 ); 10 ], t -> [log (t); 1 / t], (0.1 , 5. ),
548+ prob_dde_neves2 = DDEProblem (f_dde_neves2, [log (0.1 ); 10 ], (p, t) -> [log (t); 1 / t], (0.1 , 5. ),
549549 dependent_lags = [(u,p,t) -> t - exp (1 - u[2 ])])
550550
551551function build_f_dde_gatica (r₁, r₂, α, δ)
552552 function f_dde_gatica (du, u, h, p, t)
553553 u₁u₂ = u[1 ]* u[2 ]
554554 r₁u₁u₂ = r₁* u₁u₂
555555 r₂u₃ = r₂* u[3 ]
556- uₕ = h (t - u[4 ])
556+ uₕ = h (p, t - u[4 ])
557557 uₕ₁₂ = uₕ[1 ]* uₕ[2 ]
558558
559559 du[1 ] = - r₁u₁u₂ + r₂u₃
@@ -570,7 +570,7 @@ Model of antigen antibody dynamics with fading memory, with vanishing state depe
570570at ``t = 0`` (J. Gatica and P. Waltman, A threshold model of antigen antibody dynamics with fading memory, 1982).
571571"""
572572prob_dde_gatica = DDEProblem (build_f_dde_gatica (0.02 , 0.005 , 3 , 0.01 ),
573- [5 ; 0.1 ; 0 ; 0 ], t -> [5 ; 0.1 ; 0 ; 0 ],
573+ [5 ; 0.1 ; 0 ; 0 ], (p, t) -> [5 ; 0.1 ; 0 ; 0 ],
574574 (0. , 40. ), dependent_lags = [(u,p,t) -> u[4 ]])
575575
576576#=
@@ -614,7 +614,7 @@ function build_prob_dde_qs(u₀, tspan, τ, D, γₛ, Kₘ, nₛ, a, αₐ, β
614614 du[4 ] = αC * (R - u[4 ]) * u[3 ] - γ₃ * u[4 ]
615615 end
616616
617- Cₜ = h (t - τ)[4 ]
617+ Cₜ = h (p, t - τ)[4 ]
618618 if Cₜ < 0
619619 # eq. 5 not defined for Cₜ < 0
620620 du[5 ] = 0
@@ -623,7 +623,7 @@ function build_prob_dde_qs(u₀, tspan, τ, D, γₛ, Kₘ, nₛ, a, αₐ, β
623623 end
624624 end
625625
626- DDEProblem (f_dde_qs, u₀, t -> u₀, tspan, constant_lags = [τ])
626+ DDEProblem (f_dde_qs, u₀, (p, t) -> u₀, tspan, constant_lags = [τ])
627627end
628628
629629"""
0 commit comments