Skip to content

Commit e2422a3

Browse files
update for new construction syntax
1 parent ae0c4ac commit e2422a3

File tree

2 files changed

+46
-34
lines changed

2 files changed

+46
-34
lines changed

src/dae_premade_problems.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,4 @@ end
99
u0 = [1.0, 0, 0]
1010
du0 = [-0.04, 0.04, 0.0]
1111
"DAE residual form for the Robertson model"
12-
prob_dae_resrob = DAEProblem(f,u0,du0,(0.0,100000.0))
12+
prob_dae_resrob = DAEProblem(f,du0,u0,(0.0,100000.0))

src/dde_premade_problems.jl

Lines changed: 45 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,8 @@ function f_1delay(::Type{Val{:analytic}}, u₀, p, t)
4747
end
4848

4949
build_prob_dde_1delay(u₀, ::T=u₀) where {T} =
50-
DDEProblem(f_1delay, t->[zero(u₀)], [u₀], (zero(T), T(10)), nothing, [oneunit(T)])
50+
DDEProblem(f_1delay, [u₀], t->[zero(u₀)], (zero(T), T(10)),
51+
constant_lags = [oneunit(T)])
5152

5253
"""
5354
prob_dde_1delay
@@ -86,7 +87,8 @@ f_1delay_notinplace(::Type{Val{:analytic}}, u0, p, t) = f_1delay(Val{:analytic},
8687
#### Vectorized history function
8788

8889
build_prob_dde_1delay_notinplace(u₀, ::T=u₀) where {T} =
89-
DDEProblem(f_1delay_notinplace, t->[zero(u₀)], [u₀], (zero(T), T(10)), nothing, [oneunit(T)])
90+
DDEProblem(f_1delay_notinplace, [u₀], t->[zero(u₀)], (zero(T), T(10)),
91+
constant_lags = [oneunit(T)])
9092

9193
"""
9294
prob_dde_1delay_notinplace
@@ -99,7 +101,8 @@ prob_dde_1delay_notinplace = build_prob_dde_1delay_notinplace(1.0)
99101
#### Scalar history function
100102

101103
build_prob_dde_1delay_scalar_notinplace(u₀, ::T=u₀) where {T} =
102-
DDEProblem(f_1delay_notinplace, t -> zero(u₀), u₀, (zero(T), T(10)), nothing, [oneunit(T)])
104+
DDEProblem(f_1delay_notinplace, u₀, t -> zero(u₀), (zero(T), T(10)),
105+
constant_lags = [oneunit(T)])
103106

104107
"""
105108
prob_dde_1delay_scalar_notinplace
@@ -154,7 +157,8 @@ function f_2delays(::Type{Val{:analytic}}, u₀, p, t)
154157
end
155158

156159
build_prob_dde_2delays(u₀, ::T=u₀) where {T} =
157-
DDEProblem(f_2delays, t -> [zero(u₀)], [u₀], (zero(T), oneunit(T)), nothing, [T(1//3), T(1//5)])
160+
DDEProblem(f_2delays, [u₀], t -> [zero(u₀)], (zero(T), oneunit(T)),
161+
constant_lags = [T(1//3), T(1//5)])
158162

159163
"""
160164
prob_dde_2delays
@@ -194,8 +198,8 @@ f_2delays_notinplace(::Type{Val{:analytic}}, u0, p, t) =
194198
#### Vectorized history function
195199

196200
build_prob_dde_2delays_notinplace(u₀, ::T=u₀) where {T} =
197-
DDEProblem(f_2delays_notinplace, t -> [zero(u₀)], [u₀], (zero(T), oneunit(T)),
198-
nothing, [T(1//3), T(1//5)])
201+
DDEProblem(f_2delays_notinplace, [u₀], t -> [zero(u₀)], (zero(T), oneunit(T)),
202+
constant_lags = [T(1//3), T(1//5)])
199203

200204
"""
201205
prob_dde_2delays_notinplace
@@ -208,8 +212,8 @@ prob_dde_2delays_notinplace = build_prob_dde_2delays_notinplace(1.0)
208212
#### Scalar history function
209213

210214
build_prob_dde_2delays_scalar_notinplace(u₀, ::T=u₀) where {T} =
211-
DDEProblem(f_2delays_notinplace, t -> zero(u₀), u₀, (zero(T), oneunit(T)),
212-
nothing, [T(1//3), T(1//5)])
215+
DDEProblem(f_2delays_notinplace, u₀, t -> zero(u₀), (zero(T), oneunit(T)),
216+
constant_lags = [T(1//3), T(1//5)])
213217

214218
"""
215219
prob_dde_2delays_scalar_notinplace
@@ -230,7 +234,8 @@ function f_1delay_long(du, u, h, p, t::T) where T
230234
end
231235

232236
build_prob_dde_1delay_long(u₀, ::T=u₀) where {T} =
233-
DDEProblem(f_1delay_long, t -> [zero(u₀)], [u₀], (zero(T), T(100)), nothing, [T(1//5)])
237+
DDEProblem(f_1delay_long, [u₀], t -> [zero(u₀)], (zero(T), T(100)),
238+
constant_lags = [T(1//5)])
234239

235240
"""
236241
prob_dde_1delay_long
@@ -263,8 +268,8 @@ function f_1delay_long_notinplace(u, h, p, t::T) where T
263268
end
264269

265270
build_prob_dde_1delay_long_notinplace(u₀, ::T=u₀) where {T} =
266-
DDEProblem(f_1delay_long_notinplace, t -> [zero(u₀)], [u₀], (zero(T), T(100)),
267-
nothing, [T(1//5)])
271+
DDEProblem(f_1delay_long_notinplace, [u₀], t -> [zero(u₀)], (zero(T), T(100)),
272+
constant_lags = [T(1//5)])
268273

269274
"""
270275
prob_dde_1delay_long_notinplace
@@ -275,7 +280,8 @@ in-place function.
275280
prob_dde_1delay_long_notinplace = build_prob_dde_1delay_long_notinplace(1.0)
276281

277282
build_prob_dde_1delay_long_scalar_notinplace(u₀, ::T=u₀) where {T} =
278-
DDEProblem(f_1delay_long_notinplace, t -> zero(u₀), u₀, (zero(T), T(100)), nothing, [T(1//5)])
283+
DDEProblem(f_1delay_long_notinplace, u₀, t -> zero(u₀), (zero(T), T(100)),
284+
constant_lags = [T(1//5)])
279285

280286
"""
281287
prob_dde_1delay_long_scalar_notinplace
@@ -294,7 +300,8 @@ function f_2delays_long(du, u, h, p, t::T) where T
294300
end
295301

296302
build_prob_dde_2delays_long(u₀, ::T=u₀) where {T} =
297-
DDEProblem(f_2delays_long, t -> [zero(u₀)], [u₀], (zero(T), T(100)), nothing, [T(1//3), T(1//5)])
303+
DDEProblem(f_2delays_long, [u₀], t -> [zero(u₀)], (zero(T), T(100)),
304+
constant_lags = [T(1//3), T(1//5)])
298305

299306
"""
300307
prob_dde_2delays_long
@@ -329,8 +336,8 @@ end
329336
#### Vectorized history function
330337

331338
build_prob_dde_2delays_long_notinplace(u₀, ::T=u₀) where {T} =
332-
DDEProblem(f_2delays_long_notinplace, t -> [zero(u₀)], [u₀], (zero(T), T(100)),
333-
nothing, [T(1//3), T(1//5)])
339+
DDEProblem(f_2delays_long_notinplace, [u₀], t -> [zero(u₀)], (zero(T), T(100)),
340+
constant_lags = [T(1//3), T(1//5)])
334341

335342
"""
336343
prob_dde_2delays_long_notinplace
@@ -343,8 +350,8 @@ prob_dde_2delays_long_notinplace = build_prob_dde_2delays_long_notinplace(1.0)
343350
#### Scalar history function
344351

345352
build_prob_dde_2delays_long_scalar_notinplace(u₀, ::T=u₀) where {T} =
346-
DDEProblem(f_2delays_long_notinplace, t -> zero(u₀), u₀, (zero(T), T(100)),
347-
nothing, [T(1//3), T(1//5)])
353+
DDEProblem(f_2delays_long_notinplace, u₀, t -> zero(u₀), (zero(T), T(100)),
354+
constant_lags = [T(1//3), T(1//5)])
348355

349356
"""
350357
prob_dde_2delays_long_scalar_notinplace
@@ -370,7 +377,8 @@ end
370377
Model of blood production with constant delay (M. C. Mackey and L. Glass, Oscillation and
371378
chaos in physiological control systems, 1977).
372379
"""
373-
prob_dde_mackey = DDEProblem(f_dde_mackey, t -> [0.5], [0.5], (0.0, 500.0), nothing, [14])
380+
prob_dde_mackey = DDEProblem(f_dde_mackey, [0.5], t -> [0.5], (0.0, 500.0),
381+
constant_lags = [14])
374382

375383
function f_dde_wheldon(du, u, h, p, t)
376384
du[1] = 1.1/(1 + sqrt(10)*(h(t-20)[1])^(5/4)) - 10*u[1]/(1 + 40*u[2])
@@ -384,7 +392,8 @@ u0_wheldon = [1.05767027/3; 1.030713491/3]
384392
Model of chronic granulocytic leukemia with constant delay (T. Wheldon, J. Kirk and
385393
H. Finlay, Cyclical granulopoiesis in chronic granulocytic leukemia: A simulation study, 1974).
386394
"""
387-
prob_dde_wheldon = DDEProblem(f_dde_wheldon, t -> u0_wheldon, u0_wheldon, (0., 100.), [20])
395+
prob_dde_wheldon = DDEProblem(f_dde_wheldon, u0_wheldon, t -> u0_wheldon, (0., 100.),
396+
constant_lags = [20])
388397

389398
function f_dde_neves1(du, u, h, p, t)
390399
du[1] = 1 - h(exp(1-1/t))[1]
@@ -401,8 +410,8 @@ end
401410
DDE with vanishing time dependent delay at ``t = 1`` (K. W. Neves, Automatic integratorion
402411
of functional differential equations: An approach, 1975).
403412
"""
404-
prob_dde_neves_1 = DDEProblem(f_dde_neves1, t -> [log(t)], [log(0.1)], (0.1, 10.), [],
405-
nothing, [(t, u) -> t - exp(1 - 1/t)])
413+
prob_dde_neves_1 = DDEProblem(f_dde_neves1, [log(0.1)], t -> [log(t)], (0.1, 10.),
414+
dependent_lags = [(u,p,t) -> t - exp(1 - 1/t)])
406415

407416
function f_dde_neves_thompson(du, u, h, p, t)
408417
if h(t/2)[1] < 0
@@ -446,8 +455,8 @@ u(t) = 1
446455
447456
for ``t \\leq 0``.
448457
"""
449-
prob_dde_neves_thompson = DDEProblem(f_dde_neves_thompson, t -> [1.], [1.], (0., 2*log(66)),
450-
nothing, [], [(t, u) -> t/2])
458+
prob_dde_neves_thompson = DDEProblem(f_dde_neves_thompson, [1.], t -> [1.], (0., 2*log(66)),
459+
constant_lags = [(u,p,t) -> t/2])
451460

452461
function f_dde_paul1(du, u, h, p, t)
453462
du[1] = - 2*h(t - 1 - abs(u[1]))[1]*(1 - u[1]^2)
@@ -471,8 +480,8 @@ u(t) = 1/2
471480
472481
for ``t \\leq 0``.
473482
"""
474-
prob_dde_paul1 = DDEProblem(f_dde_paul1, t -> [0.5], [0.5], (0., 30.), nothing, [],
475-
[(t, u) -> 1 + abs(u[1])])
483+
prob_dde_paul1 = DDEProblem(f_dde_paul1, [0.5], t -> [0.5], (0., 30.),
484+
dependent_lags = [(u,p,t) -> 1 + abs(u[1])])
476485

477486
function f_dde_paul2(du, u, h, p, t)
478487
h1 = h(t - u[2])[1]
@@ -485,8 +494,8 @@ end
485494
486495
DDE with state dependent delay (C. A. H. Paul, A test set of functional differential equations, 1994).
487496
"""
488-
prob_dde_paul2 = DDEProblem(f_dde_paul2, t -> [1; 0.5], [1; 0.5], (0., 30.), nothing, [],
489-
[(t, u) -> u[2]])
497+
prob_dde_paul2 = DDEProblem(f_dde_paul2, [1; 0.5], t -> [1; 0.5], (0., 30.),
498+
dependent_lags = [(u,p,t) -> u[2]])
490499

491500
function build_prob_dde_mahaffy(tspan, h, σ₀, T₁, γ, Q, k, a, K, r)
492501
function f(du, u, h, p, t)
@@ -495,7 +504,9 @@ function build_prob_dde_mahaffy(tspan, h, σ₀, T₁, γ, Q, k, a, K, r)
495504
du[3] = 1 - Q*exp*u[3])/(σ₀*h(t-T₁-u[3])[2])
496505
end
497506

498-
DDEProblem(f, h, h(0), tspan, nothing, [T₁], [(t, u) -> T₁ + u[3]])
507+
DDEProblem(f, h(0), h, tspan,
508+
constant_lags = [T₁],
509+
dependent_lags = [(u,p,t) -> T₁ + u[3]])
499510
end
500511

501512
function h_mahaffy1(t)
@@ -534,8 +545,8 @@ end
534545
DDE with vanishing state dependent delay at ``t = 1`` (K. W. Neves, Automatic integration
535546
of functional differential equations: An approach, 1975).
536547
"""
537-
prob_dde_neves2 = DDEProblem(f_dde_neves2, t -> [log(t); 1/t], [log(0.1); 10], (0.1, 5.),
538-
nothing, [], [(t, u) -> t - exp(1 - u[2])])
548+
prob_dde_neves2 = DDEProblem(f_dde_neves2, [log(0.1); 10], t -> [log(t); 1/t], (0.1, 5.),
549+
dependent_lags = [(u,p,t) -> t - exp(1 - u[2])])
539550

540551
function build_f_dde_gatica(r₁, r₂, α, δ)
541552
function f_dde_gatica(du, u, h, p, t)
@@ -558,8 +569,9 @@ end
558569
Model of antigen antibody dynamics with fading memory, with vanishing state dependent delay
559570
at ``t = 0`` (J. Gatica and P. Waltman, A threshold model of antigen antibody dynamics with fading memory, 1982).
560571
"""
561-
prob_dde_gatica = DDEProblem(build_f_dde_gatica(0.02, 0.005, 3, 0.01), t -> [5; 0.1; 0; 0],
562-
[5; 0.1; 0; 0], (0., 40.), nothing, [], [(t, u) -> u[4]])
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],
574+
(0., 40.), dependent_lags = [(u,p,t) -> u[4]])
563575

564576
#=
565577
Quorum Sensing model
@@ -611,7 +623,7 @@ function build_prob_dde_qs(u₀, tspan, τ, D, γₛ, Kₘ, nₛ, a, αₐ, β
611623
end
612624
end
613625

614-
DDEProblem(f_dde_qs, t -> u₀, u₀, tspan, nothing, [τ])
626+
DDEProblem(f_dde_qs, u₀, t -> u₀, tspan, constant_lags = [τ])
615627
end
616628

617629
"""

0 commit comments

Comments
 (0)