I started playing around a bit more with stiff DDEs, and think www.unige.ch/~hairer/radar5-v2.1.tar and accompanying publications contain some nice examples (which should be added to DiffEqProblemLibrary as well, I guess).
However, my first tests show that there are some problems with stiff problems. The first problem is a modified Robertson problem, taken from "The numerical integration of stiff delay differential equations" by Guglielmi; I only changed the integration interval from [0.0, 1e9] to [0.0, 1e5] since otherwise maxiters has to be increased (maybe the number of iterations could be reduced in general by changing some defaults?):
using DelayDiffEq
function f_dde_rober1(du, u, h, p, t)
# compute repeating terms
x = 4e-2 * u[1]
y = 1e4 * u[2] * u[3]
z = 3e7 * (1 - h(p, t - 1; idxs = 2)) * u[2]^2
# compute derivatives
du[1] = y - x
du[2] = x - y - z
du[3] = z
nothing
end
# simplified history function, hence `initial_order` has to be set
h_dde_rober(p, t; idxs = 2) = 0.0
prob_dde_rober1 = DDEProblem(f_dde_rober1, [1.0, 0.0, 0.0], h_dde_rober,
(0.0, 1e5);
constant_lags = [1])
Using Tsit5 integrations is stopped at around t = 627 since the maximal number of iterations is reached, and the solution is wrong as the following plot shows:
sol = solve(prob_dde_rober1, MethodOfSteps(Tsit5()); initial_order = 1)
using Plots
plotly()
plot(sol)

Using Rosenbrock23 a solution is computed on the whole integration interval:
sol = solve(prob_dde_rober1, MethodOfSteps(Rosenbrock23()); initial_order = 1)
plot(sol)

This solution shows the expected dynamics; moreover, it indicates that the stiff solvers work in principle and are quite performant since according to Guglielmi "RADAR5 is the only code able to correctly integrate the above very stiff problem" out of the solvers he considered.
Interestingly, both in Guglielmi and Hairer's "Implementing Radau IIA methods for stiff delay differential equations" and as example problem in the RADAR5 package a different Robertson problem is mentioned (here again on a reduced integration interval):
function f_dde_rober2(du, u, h, p, t)
# compute repeating terms
x = 4e-2 * u[1]
y = 1e4 * h(p, t - 1e-2; idxs = 2) * u[3]
z = 3e7 * u[2] * u[2]
# compute derivatives
du[1] = y - x
du[2] = x - y - z
du[3] = z
nothing
end
prob_dde_rober2 = DDEProblem(f_dde_rober2, [1.0, 0.0, 0.0], h_dde_rober,
(0.0, 1e5);
constant_lags = [1e-2])
For this problem, however, Rosenbrock23 computes a solution only on [0.0, 6.14] since the time steps become too small:
sol = solve(prob_dde_rober2, MethodOfSteps(Rosenbrock23()); initial_order = 1)
plot(sol)

Similar dynamics can be observed with Rodas5, although in this case integration stops because of instability (i.e. NaN values):
sol = solve(prob_dde_rober2, MethodOfSteps(Rodas5()); initial_order = 1)
plot(sol)

Using absolute and relative tolerances that are mentioned in Guglielmi and Hairer's publication I can provoke the same explosions as before at a slightly later time point:
sol = solve(prob_dde_rober2, MethodOfSteps(Rodas5()); initial_order = 1,
reltol = 1e-6, abstol = 1e-10)
plot(sol)

According to Guglielmi and Hairer, with a delay of 3e-2 the second component of this problem oscillates and then explodes at around t = 16.8.
I managed to compile and run RADAR5 and the contained Robertson example on my computer; RADAR5 successfully computed a solution on the interval [0.0, 1e10]. Even though I have no experience with Fortran I studied the implementation of the problem to check whether the implementation corresponds to the stated DDE; hereby I noticed that Guglielmi and Hairer apparently used slightly different default parameters in their implementation (tau = 1e-3, reltol = 1e-9, abstol = 1e-14, and an integration interval of [0.0, 1e11]) but I could still compute a correct solution after changing these values to the ones stated above.
I do not know why DelayDiffEq does not compute a correct solution for the second problem. I'm also surprised that Rodas5 with default settings returns NaN values; I assumed this could (and should) not happen since then the time step should be decreased... I also played around with the number of fixed point iterations; setting force_dtmin = true in the last example resulted in NaN values as well. Are there any settings I could tune? Do you have any ideas why RADAR5 can solve this problem whereas I could not compute a solution with DelayDiffEq?
I started playing around a bit more with stiff DDEs, and think www.unige.ch/~hairer/radar5-v2.1.tar and accompanying publications contain some nice examples (which should be added to DiffEqProblemLibrary as well, I guess).
However, my first tests show that there are some problems with stiff problems. The first problem is a modified Robertson problem, taken from "The numerical integration of stiff delay differential equations" by Guglielmi; I only changed the integration interval from [0.0, 1e9] to [0.0, 1e5] since otherwise
maxitershas to be increased (maybe the number of iterations could be reduced in general by changing some defaults?):Using
Tsit5integrations is stopped at aroundt = 627since the maximal number of iterations is reached, and the solution is wrong as the following plot shows:Using
Rosenbrock23a solution is computed on the whole integration interval:This solution shows the expected dynamics; moreover, it indicates that the stiff solvers work in principle and are quite performant since according to Guglielmi "RADAR5 is the only code able to correctly integrate the above very stiff problem" out of the solvers he considered.
Interestingly, both in Guglielmi and Hairer's "Implementing Radau IIA methods for stiff delay differential equations" and as example problem in the RADAR5 package a different Robertson problem is mentioned (here again on a reduced integration interval):
For this problem, however,
Rosenbrock23computes a solution only on [0.0, 6.14] since the time steps become too small:Similar dynamics can be observed with
Rodas5, although in this case integration stops because of instability (i.e.NaNvalues):Using absolute and relative tolerances that are mentioned in Guglielmi and Hairer's publication I can provoke the same explosions as before at a slightly later time point:
According to Guglielmi and Hairer, with a delay of 3e-2 the second component of this problem oscillates and then explodes at around t = 16.8.
I managed to compile and run RADAR5 and the contained Robertson example on my computer; RADAR5 successfully computed a solution on the interval [0.0, 1e10]. Even though I have no experience with Fortran I studied the implementation of the problem to check whether the implementation corresponds to the stated DDE; hereby I noticed that Guglielmi and Hairer apparently used slightly different default parameters in their implementation (tau = 1e-3, reltol = 1e-9, abstol = 1e-14, and an integration interval of [0.0, 1e11]) but I could still compute a correct solution after changing these values to the ones stated above.
I do not know why DelayDiffEq does not compute a correct solution for the second problem. I'm also surprised that Rodas5 with default settings returns
NaNvalues; I assumed this could (and should) not happen since then the time step should be decreased... I also played around with the number of fixed point iterations; settingforce_dtmin = truein the last example resulted inNaNvalues as well. Are there any settings I could tune? Do you have any ideas why RADAR5 can solve this problem whereas I could not compute a solution with DelayDiffEq?