5
5
# ## In-place function
6
6
7
7
function 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)
9
9
end
10
10
11
11
function f_1delay (:: Type{Val{:analytic}} , u₀, p, t)
@@ -47,7 +47,7 @@ function f_1delay(::Type{Val{:analytic}}, u₀, p, t)
47
47
end
48
48
49
49
build_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 )),
51
51
constant_lags = [oneunit (T)])
52
52
53
53
"""
@@ -79,15 +79,15 @@ prob_dde_1delay = build_prob_dde_1delay(1.0)
79
79
# ## Not in-place function
80
80
81
81
function f_1delay_notinplace (u, h, p, t)
82
- - h (t - oneunit (t)) ./ oneunit (t)
82
+ - h (p, t - oneunit (t)) ./ oneunit (t)
83
83
end
84
84
85
85
f_1delay_notinplace (:: Type{Val{:analytic}} , u0, p, t) = f_1delay (Val{:analytic }, u0, p, t)
86
86
87
87
# ### Vectorized history function
88
88
89
89
build_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 )),
91
91
constant_lags = [oneunit (T)])
92
92
93
93
"""
@@ -101,8 +101,8 @@ prob_dde_1delay_notinplace = build_prob_dde_1delay_notinplace(1.0)
101
101
# ### Scalar history function
102
102
103
103
build_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)])
106
106
107
107
"""
108
108
prob_dde_1delay_scalar_notinplace
@@ -117,7 +117,7 @@ prob_dde_1delay_scalar_notinplace = build_prob_dde_1delay_scalar_notinplace(1.0)
117
117
# ## In-place function
118
118
119
119
function 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)
121
121
end
122
122
123
123
function f_2delays (:: Type{Val{:analytic}} , u₀, p, t)
@@ -157,7 +157,7 @@ function f_2delays(::Type{Val{:analytic}}, u₀, p, t)
157
157
end
158
158
159
159
build_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)),
161
161
constant_lags = [T (1 // 3 ), T (1 // 5 )])
162
162
163
163
"""
@@ -189,7 +189,7 @@ prob_dde_2delays = build_prob_dde_2delays(1.0)
189
189
# ## Not in-place function
190
190
191
191
function 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)
193
193
end
194
194
195
195
f_2delays_notinplace (:: Type{Val{:analytic}} , u0, p, t) =
@@ -198,7 +198,7 @@ f_2delays_notinplace(::Type{Val{:analytic}}, u0, p, t) =
198
198
# ### Vectorized history function
199
199
200
200
build_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)),
202
202
constant_lags = [T (1 // 3 ), T (1 // 5 )])
203
203
204
204
"""
@@ -212,7 +212,7 @@ prob_dde_2delays_notinplace = build_prob_dde_2delays_notinplace(1.0)
212
212
# ### Scalar history function
213
213
214
214
build_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)),
216
216
constant_lags = [T (1 // 3 ), T (1 // 5 )])
217
217
218
218
"""
@@ -230,11 +230,11 @@ prob_dde_2delays_scalar_notinplace = build_prob_dde_2delays_scalar_notinplace(1.
230
230
# ## In-place function
231
231
232
232
function 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)
234
234
end
235
235
236
236
build_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 )),
238
238
constant_lags = [T (1 // 5 )])
239
239
240
240
"""
@@ -264,11 +264,11 @@ prob_dde_1delay_long = build_prob_dde_1delay_long(1.0)
264
264
# ## Not in-place function
265
265
266
266
function 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)
268
268
end
269
269
270
270
build_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 )),
272
272
constant_lags = [T (1 // 5 )])
273
273
274
274
"""
@@ -280,7 +280,7 @@ in-place function.
280
280
prob_dde_1delay_long_notinplace = build_prob_dde_1delay_long_notinplace (1.0 )
281
281
282
282
build_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 )),
284
284
constant_lags = [T (1 // 5 )])
285
285
286
286
"""
@@ -296,12 +296,12 @@ prob_dde_1delay_long_scalar_notinplace = build_prob_dde_1delay_long_scalar_notin
296
296
# ## In-place function
297
297
298
298
function 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)
300
300
end
301
301
302
302
build_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 )])
305
305
306
306
"""
307
307
prob_dde_2delays_long
@@ -330,13 +330,13 @@ prob_dde_2delays_long = build_prob_dde_2delays_long(1.0)
330
330
# ## Not in-place function
331
331
332
332
function 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)
334
334
end
335
335
336
336
# ### Vectorized history function
337
337
338
338
build_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 )),
340
340
constant_lags = [T (1 // 3 ), T (1 // 5 )])
341
341
342
342
"""
@@ -350,7 +350,7 @@ prob_dde_2delays_long_notinplace = build_prob_dde_2delays_long_notinplace(1.0)
350
350
# ### Scalar history function
351
351
352
352
build_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 )),
354
354
constant_lags = [T (1 // 3 ), T (1 // 5 )])
355
355
356
356
"""
@@ -368,7 +368,7 @@ differential equations.
368
368
=#
369
369
370
370
function 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 ]
372
372
end
373
373
374
374
"""
@@ -377,11 +377,11 @@ end
377
377
Model of blood production with constant delay (M. C. Mackey and L. Glass, Oscillation and
378
378
chaos in physiological control systems, 1977).
379
379
"""
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 ),
381
381
constant_lags = [14 ])
382
382
383
383
function 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 ])
385
385
du[2 ] = 100 * u[1 ]/ (1 + 40 * u[2 ]) - 2.43 * u[2 ]
386
386
end
387
387
u0_wheldon = [1.05767027 / 3 ; 1.030713491 / 3 ]
@@ -392,11 +392,11 @@ u0_wheldon = [1.05767027/3; 1.030713491/3]
392
392
Model of chronic granulocytic leukemia with constant delay (T. Wheldon, J. Kirk and
393
393
H. Finlay, Cyclical granulopoiesis in chronic granulocytic leukemia: A simulation study, 1974).
394
394
"""
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. ),
396
396
constant_lags = [20 ])
397
397
398
398
function 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 ]
400
400
end
401
401
# only valid for specific history function
402
402
function f_dde_neves1 (:: Type{Val{:analytic}} , u₀, p, t )
@@ -410,11 +410,11 @@ end
410
410
DDE with vanishing time dependent delay at ``t = 1`` (K. W. Neves, Automatic integratorion
411
411
of functional differential equations: An approach, 1975).
412
412
"""
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. ),
414
414
dependent_lags = [(u,p,t) -> t - exp (1 - 1 / t)])
415
415
416
416
function f_dde_neves_thompson (du, u, h, p, t)
417
- if h (t/ 2 )[1 ] < 0
417
+ if h (p, t/ 2 )[1 ] < 0
418
418
du[1 ] = 1 - u[1 ]
419
419
else
420
420
du[1 ] = - 1 - u[1 ]
@@ -455,11 +455,11 @@ u(t) = 1
455
455
456
456
for ``t \\ leq 0``.
457
457
"""
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 )),
459
459
constant_lags = [(u,p,t) -> t/ 2 ])
460
460
461
461
function 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 )
463
463
end
464
464
465
465
"""
@@ -480,11 +480,11 @@ u(t) = 1/2
480
480
481
481
for ``t \\ leq 0``.
482
482
"""
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. ),
484
484
dependent_lags = [(u,p,t) -> 1 + abs (u[1 ])])
485
485
486
486
function f_dde_paul2 (du, u, h, p, t)
487
- h1 = h (t - u[2 ])[1 ]
487
+ h1 = h (p, t - u[2 ])[1 ]
488
488
du[1 ] = - 2 * h1
489
489
du[2 ] = (abs (h1) - abs (u[1 ]))/ (1 + abs (h1))
490
490
end
@@ -494,22 +494,22 @@ end
494
494
495
495
DDE with state dependent delay (C. A. H. Paul, A test set of functional differential equations, 1994).
496
496
"""
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. ),
498
498
dependent_lags = [(u,p,t) -> u[2 ]])
499
499
500
500
function build_prob_dde_mahaffy (tspan, h, σ₀, T₁, γ, Q, k, a, K, r)
501
501
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
503
503
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 ])
505
505
end
506
506
507
- DDEProblem (f, h (0 ), h, tspan,
507
+ DDEProblem (f, h (nothing , 0 ), h, tspan,
508
508
constant_lags = [T₁],
509
509
dependent_lags = [(u,p,t) -> T₁ + u[3 ]])
510
510
end
511
511
512
- function h_mahaffy1 (t)
512
+ function h_mahaffy1 (p, t)
513
513
if t < - 6
514
514
return [3.325 ; 9.5 ; 120 ]
515
515
else
519
519
prob_dde_mahaffy1 = build_prob_dde_mahaffy ((0. , 300. ), h_mahaffy1, 0.0031 , 6 , 0.001 , 0.0275 ,
520
520
2.8 , 6570 , 0.0382 , 6.96 )
521
521
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 ,
523
523
0.00178 , 6.65 , 15600 , 0.0382 , 6.96 )
524
524
525
525
"""
@@ -531,7 +531,7 @@ prob_dde_mahaffy1, prob_dde_mahaffy2
531
531
function f_dde_neves2 (du, u, h, p, t)
532
532
t2 = exp (1 - u[2 ])
533
533
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
535
535
end
536
536
# only valid for specific history function
537
537
function f_dde_neves2 (:: Type{Val{:analytic}} , u₀, p, t )
@@ -545,15 +545,15 @@ end
545
545
DDE with vanishing state dependent delay at ``t = 1`` (K. W. Neves, Automatic integration
546
546
of functional differential equations: An approach, 1975).
547
547
"""
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. ),
549
549
dependent_lags = [(u,p,t) -> t - exp (1 - u[2 ])])
550
550
551
551
function build_f_dde_gatica (r₁, r₂, α, δ)
552
552
function f_dde_gatica (du, u, h, p, t)
553
553
u₁u₂ = u[1 ]* u[2 ]
554
554
r₁u₁u₂ = r₁* u₁u₂
555
555
r₂u₃ = r₂* u[3 ]
556
- uₕ = h (t - u[4 ])
556
+ uₕ = h (p, t - u[4 ])
557
557
uₕ₁₂ = uₕ[1 ]* uₕ[2 ]
558
558
559
559
du[1 ] = - r₁u₁u₂ + r₂u₃
@@ -570,7 +570,7 @@ Model of antigen antibody dynamics with fading memory, with vanishing state depe
570
570
at ``t = 0`` (J. Gatica and P. Waltman, A threshold model of antigen antibody dynamics with fading memory, 1982).
571
571
"""
572
572
prob_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 ],
574
574
(0. , 40. ), dependent_lags = [(u,p,t) -> u[4 ]])
575
575
576
576
#=
@@ -614,7 +614,7 @@ function build_prob_dde_qs(u₀, tspan, τ, D, γₛ, Kₘ, nₛ, a, αₐ, β
614
614
du[4 ] = αC * (R - u[4 ]) * u[3 ] - γ₃ * u[4 ]
615
615
end
616
616
617
- Cₜ = h (t - τ)[4 ]
617
+ Cₜ = h (p, t - τ)[4 ]
618
618
if Cₜ < 0
619
619
# eq. 5 not defined for Cₜ < 0
620
620
du[5 ] = 0
@@ -623,7 +623,7 @@ function build_prob_dde_qs(u₀, tspan, τ, D, γₛ, Kₘ, nₛ, a, αₐ, β
623
623
end
624
624
end
625
625
626
- DDEProblem (f_dde_qs, u₀, t -> u₀, tspan, constant_lags = [τ])
626
+ DDEProblem (f_dde_qs, u₀, (p, t) -> u₀, tspan, constant_lags = [τ])
627
627
end
628
628
629
629
"""
0 commit comments