Skip to content

Commit 7bac46d

Browse files
committed
Add examples OREGONATOR, ROBERTSON, and WALTMAN from RADAR5
1 parent 421926f commit 7bac46d

File tree

2 files changed

+273
-0
lines changed

2 files changed

+273
-0
lines changed

src/dde/dde_premade_problems.jl

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,16 @@ export
2929
# neutral DDEs with vanishing state dependent delays
3030
prob_dde_DDETST_H1, prob_dde_DDETST_H2, prob_dde_DDETST_H3, prob_dde_DDETST_H4
3131

32+
# RADAR5 problems
33+
export prob_dde_RADAR5_oregonator, prob_dde_RADAR5_robertson, prob_dde_RADAR5_waltman
34+
3235
# QS exaple
3336
export prob_dde_qs
3437

3538
include("constant_delays.jl")
3639
include("ddetst.jl")
3740
include("qs.jl")
41+
include("radar5.jl")
3842

3943
# deprecations for problems with constant delays
4044
for p in (:(1delay), :(1delay_long), :(2delays), :(2delays_long))

src/dde/radar5.jl

Lines changed: 269 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,269 @@
1+
#=
2+
The following examples are taken from the source code of the delay differential equation
3+
solver RADAR5 by Nicola Guglielmi and Ernst Hairer:
4+
http://www.unige.ch/~hairer/radar5-v2.1.tar
5+
=#
6+
7+
# OREGONATOR example
8+
@doc raw"""
9+
prob_dde_RADAR5_oregonator
10+
11+
Delay differential equation model from chemical kinetics, given by
12+
13+
```math
14+
\begin{align*}
15+
u_1'(t) &= - k_1 A u_2(t) - k_2 u_1(t) u_2(t - \tau) + k_3 B u_1(t) - 2 k_4 u_1(t)^2, \\
16+
u_2'(t) &= - k_1 A u_2(t) - k_2 u_1(t) u_2(t - \tau) + f k_3 B u_1(t),
17+
\end{align*}
18+
```
19+
20+
for ``t \in [0, 100.5]`` with history function
21+
22+
```math
23+
\begin{align*}
24+
\phi_1(t) &= 1e-10, \\
25+
\phi_2(t) &= 1e-5,
26+
\end{align*}
27+
```
28+
29+
for ``t \leq 0``, where ``k_1 = 1.34``, ``k_2 = 1.6e9``, ``k_3 = 8000``, ``k_4 = 4e7``,
30+
``k_5 = 1``, ``f = 1``, ``A = 0.06``, ``B = 0.06``, and ``\tau = 0.15``.
31+
32+
# References
33+
34+
Epstein, I. and Luo, Y. (1991). Differential delay equations in chemical kinetics. Nonlinear
35+
models, Journal of Chemical Physics (95), pp. 244-254.
36+
"""
37+
const prob_dde_RADAR5_oregonator =
38+
let k₁ = 1.34, k₂ = 1.6e9, k₃ = 8_000, k₄ = 4e7, f = 1, A = 0.06, B = 0.06, τ = 0.15
39+
global function f_dde_RADAR5_oregonator!(du, u, h, p, t)
40+
# past value of the second component
41+
v = h(p, t - τ; idxs = 2)
42+
43+
# precalculations
44+
a = - k₁ * A * u[2] - k₂ * u[1] * v
45+
b = k₃ * B * u[1]
46+
47+
du[1] = a + b - 2 * k₄ * u[1]^2
48+
du[2] = a + f * b
49+
50+
nothing
51+
end
52+
53+
global function h_dde_RADAR5_oregonator(p, t; idxs::Union{Nothing,Int} = nothing)
54+
t 0 || error("history function is only implemented for t ≤ 0")
55+
56+
if idxs === nothing
57+
[1e-10, 1e-5]
58+
elseif idxs == 2
59+
1e-5
60+
else
61+
error("history function is only implemented for the second component")
62+
end
63+
end
64+
65+
DDEProblem(f_dde_RADAR5_oregonator!, h_dde_RADAR5_oregonator, (0.0, 100.5);
66+
constant_lags = [τ])
67+
end
68+
69+
# ROBERTSON example
70+
@doc raw"""
71+
prob_dde_RADAR5_robertson
72+
73+
Delay differential equation model of a chemical reaction with steady state solution, given
74+
by
75+
76+
```math
77+
\begin{align*}
78+
u_1'(t) &= - a u_1(t) + b u_2(t - \tau) u_3(t), \\
79+
u_2'(t) &= a u_1(t) - b u_2(t - \tau) u_3(t) - c u_2(t)^2, \\
80+
u_3'(t) &= c u_2(t)^2,
81+
\end{align*}
82+
```
83+
84+
for ``t \in [0, 10e10]`` with history function ``\phi_1(0) = 1``, ``\phi_2(t) = 0`` for
85+
``t \in [-\tau, 0]``, and ``\phi_3(0) = 0``, where ``a = 0.04``, ``b = 10_000``,
86+
``c = 3e7``, and ``\tau = 0.01``.
87+
88+
# References
89+
90+
Guglielmi, N. and Hairer, E. (2001). Implementing Radau IIA methods for stiff delay
91+
differential equations, Computing (67), pp. 1-12.
92+
"""
93+
const prob_dde_RADAR5_robertson =
94+
let a = 0.04, b = 10_000, c = 3e7, τ = 0.01
95+
global function f_dde_RADAR5_robertson!(du, u, h, p, t)
96+
# past value of the second component
97+
v = h(p, t - τ; idxs = 2)
98+
99+
# precalculations
100+
x = a * u[1] - b * v * u[3]
101+
y = c * u[2]^2
102+
103+
du[1] = - x
104+
du[2] = x - y
105+
du[3] = y
106+
107+
nothing
108+
end
109+
110+
global function h_dde_RADAR5_robertson(p, t; idxs::Union{Nothing,Int} = nothing)
111+
- τ t 0 || error("history function is only implemented for t ∈ [-τ, 0]")
112+
113+
if idxs === nothing
114+
[1.0, 0.0, 0.0]
115+
elseif idxs == 2
116+
0.0
117+
else
118+
error("history function is only implemented for the second component")
119+
end
120+
end
121+
122+
DDEProblem(f_dde_RADAR5_robertson!, h_dde_RADAR5_robertson, (0.0, 1e10);
123+
constant_lags = [τ])
124+
end
125+
126+
# WALTMAN example
127+
@doc raw"""
128+
prob_dde_RADAR5_waltman
129+
130+
Delay differential equation model of antibody production, given by
131+
132+
```math
133+
\begin{align*}
134+
u_1'(t) &= - r u_1(t) u_2(t) - s u_1(t) u_4(t), \\
135+
u_2'(t) &= - r u_1(t) u_2(t) + \alpha r u_1(u_5(t)) u_2(u_5(t)) [t \geq t_0], \\
136+
u_3'(t) &= r u_1(t) u_2(t), \\
137+
u_4'(t) &= - s u_1(t) u_4(t) - \gamma u_4(t) + \beta r u_1(u_6(t)) u_2(u_6(t)) [t > t_1], \\
138+
u_5'(t) &= [t \geq t_0] \frac{u_1(t) u_2(t) + u_3(t)}{u_1(u_5(t)) u_2(u_5(t)) + u_3(u_5(t))}, \\
139+
u_6'(t) &= [t \geq t_1] \frac{1e-12 + u_2(t) + u_3(t)}{1e-12 + u_2(u_6(t)) + u_3(u_6(t))},
140+
\end{align*}
141+
```
142+
143+
for ``t \in [0, 300]`` with history function
144+
145+
```math
146+
\begin{align*}
147+
\phi_1(t) &= \phi_0, \\
148+
\phi_2(t) &= 1e-15, \\
149+
\phi_3(t) &= 0, \\
150+
\phi_4(t) &= 0, \\
151+
\phi_5(t) &= 0, \\
152+
\phi_6(t) &= 0,
153+
\end{align*}
154+
```
155+
156+
for ``t \leq 0``, where ``\alpha = 1.8``, ``\beta = 20``, ``\gamma = 0.002``, ``r = 5e4``,
157+
``s = 1e5``, ``t_0 = 32``, ``t_1 = 119``, and ``\phi_0 = 0.75e-4``.
158+
159+
# References
160+
161+
Waltman, P. (1978). A threshold model of antigen-stimulated antibody production, Theoretical
162+
Immunology (8), pp. 437-453.
163+
"""
164+
prob_dde_RADAR5_waltman
165+
166+
let α = 1.8, β = 20, γ = 0.002, r = 50_000, s = 100_000
167+
global function f_dde_RADAR5_waltman!(du, u, h, p, t)
168+
# time of switches
169+
t₀, t₁ = p.t₀, p.t₁
170+
171+
# precalculations
172+
u₁u₂ = u[1] * u[2]
173+
a = r * u₁u₂
174+
b = s * u[1] * u[4]
175+
176+
du[1] = - a - b
177+
du[3] = a
178+
179+
if t < t₀
180+
du[2] = - a
181+
du[5] = 0
182+
else
183+
v = h(p, u[5])
184+
v₁v₂ = v[1] * v[2]
185+
du[2] = - a + α * r * v₁v₂
186+
du[5] = (u₁u₂ + u[3]) / (v₁v₂ + v[3])
187+
end
188+
189+
if t < t₁
190+
du[4] = - b - γ * u[4]
191+
du[6] = 0
192+
else
193+
w = h(p, u[6])
194+
du[4] = - b - γ * u[4] + β * r * w[1] * w[2]
195+
du[6] = (1e-12 + u[2] + u[3]) / (1e-12 + w[2] + w[3])
196+
end
197+
198+
nothing
199+
end
200+
end
201+
202+
function h_dde_RADAR5_waltman(p, t)
203+
t 0 || error("history function is only implemented for t ≤ 0")
204+
205+
[p.ϕ₀, 1e-15, 0.0, 0.0, 0.0, 0.0]
206+
end
207+
208+
const prob_dde_RADAR5_waltman =
209+
DDEProblem(f_dde_RADAR5_waltman!, (p, t) -> h_dde_RADAR5_waltman(p, 0.0),
210+
h_dde_RADAR5_waltman, (0.0, 300.0), (ϕ₀ = 0.75e-4, t₀ = 32, t₁ = 119);
211+
dependent_lags = ((u, p, t) -> t - u[5], (u, p, t) -> t - u[6]),
212+
order_discontinuity_t0 = 1)
213+
const prob_dde_RADAR5_waltman_1 = prob_dde_RADAR5_waltman
214+
215+
@doc raw"""
216+
prob_dde_RADAR5_waltman_2
217+
218+
Same delay differential equation as [`prob_dde_RADAR5_waltman`] with ``t_0 = 32``,
219+
``t_1 = 111``, and ``\phi_0 = 0.5e-4``.
220+
221+
# References
222+
223+
Waltman, P. (1978). A threshold model of antigen-stimulated antibody production, Theoretical
224+
Immunology (8), pp. 437-453.
225+
"""
226+
const prob_dde_RADAR5_waltman_2 =
227+
remake(prob_dde_RADAR5_waltman; p = (ϕ₀ = 0.5e-4, t₀ = 32, t₁ = 111))
228+
229+
@doc raw"""
230+
prob_dde_RADAR5_waltman_3
231+
232+
Same delay differential equation as [`prob_dde_RADAR5_waltman`] with ``t_0 = 33``,
233+
``t_1 = 145``, and ``\phi_0 = 1e-5``.
234+
235+
# References
236+
237+
Waltman, P. (1978). A threshold model of antigen-stimulated antibody production, Theoretical
238+
Immunology (8), pp. 437-453.
239+
"""
240+
const prob_dde_RADAR5_waltman_3 =
241+
remake(prob_dde_RADAR5_waltman; p = (ϕ₀ = 1e-5, t₀ = 33, t₁ = 145))
242+
243+
@doc raw"""
244+
prob_dde_RADAR5_waltman_4
245+
246+
Same delay differential equation as [`prob_dde_RADAR5_waltman`] with ``t_0 = 34``,
247+
``t_1 = 163``, and ``\phi_0 = 0.75e-5``.
248+
249+
# References
250+
251+
Waltman, P. (1978). A threshold model of antigen-stimulated antibody production, Theoretical
252+
Immunology (8), pp. 437-453.
253+
"""
254+
const prob_dde_RADAR5_waltman_4 =
255+
remake(prob_dde_RADAR5_waltman; p = (ϕ₀ = 0.75e-5, t₀ = 34, t₁ = 163))
256+
257+
@doc raw"""
258+
prob_dde_RADAR5_waltman_5
259+
260+
Same delay differential equation as [`prob_dde_RADAR5_waltman`] with ``t_0 = 35``,
261+
``t_1 = 197``, and ``\phi_0 = 0.5e-4``.
262+
263+
# References
264+
265+
Waltman, P. (1978). A threshold model of antigen-stimulated antibody production, Theoretical
266+
Immunology (8), pp. 437-453.
267+
"""
268+
const prob_dde_RADAR5_waltman_5 =
269+
remake(prob_dde_RADAR5_waltman; p = (ϕ₀ = 0.5e-5, t₀ = 35, t₁ = 197))

0 commit comments

Comments
 (0)