From b273aa9460d932bff474ee698402902b1ae1c565 Mon Sep 17 00:00:00 2001 From: ChrisRackauckas-Claude Date: Wed, 23 Sep 2026 08:50:11 -0400 Subject: [PATCH] DDEProblemLibrary: fix sign of k1*A*u2 in RADAR5 Oregonator u1 equation RADAR5-V2.1/OREGONATOR/dr-oregon.f has F(1) = +kM1*A*Y(2) - ..., but prob_dde_RADAR5_oregonator shared `a = -k1*A*u2 - k2*u1*v` between both components, flipping the sign of the first term in du[1]. With the wrong sign u1 decays to zero and the solution stays flat at u2 = 1e-5 instead of oscillating. Fix the RHS and docstring, add a test against the RADAR5 FCN. Co-Authored-By: Chris Rackauckas Co-Authored-By: Claude Opus 5.5 (1M context) Agent-Harness: Claude Code 2.1.280 Agent-Model: claude-opus-5-5[1m] Agent-Session: https://claude.ai/code/session_01Vrsu4PESdABpNaxYiTBVfd Claude-Session: https://claude.ai/code/session_01Vrsu4PESdABpNaxYiTBVfd --- lib/DDEProblemLibrary/Project.toml | 2 +- lib/DDEProblemLibrary/src/radar5.jl | 9 +++++---- lib/DDEProblemLibrary/test/radar5.jl | 17 +++++++++++++++++ lib/DDEProblemLibrary/test/runtests.jl | 1 + 4 files changed, 24 insertions(+), 5 deletions(-) create mode 100644 lib/DDEProblemLibrary/test/radar5.jl diff --git a/lib/DDEProblemLibrary/Project.toml b/lib/DDEProblemLibrary/Project.toml index d83632f..c34849c 100644 --- a/lib/DDEProblemLibrary/Project.toml +++ b/lib/DDEProblemLibrary/Project.toml @@ -1,6 +1,6 @@ name = "DDEProblemLibrary" uuid = "f42792ee-6ffc-4e2a-ae83-8ee2f22de800" -version = "0.1.9" +version = "0.1.10" [deps] DiffEqBase = "2b5f629d-d688-5b77-993f-72d75c75574e" diff --git a/lib/DDEProblemLibrary/src/radar5.jl b/lib/DDEProblemLibrary/src/radar5.jl index 985fff6..4c45c84 100644 --- a/lib/DDEProblemLibrary/src/radar5.jl +++ b/lib/DDEProblemLibrary/src/radar5.jl @@ -54,7 +54,7 @@ Delay differential equation model from chemical kinetics, given by ```math \\begin{align*} - u_1'(t) &= - k_1 A u_2(t) - k_2 u_1(t) u_2(t - τ) + k_3 B u_1(t) - 2 k_4 u_1(t)^2, \\\\ + u_1'(t) &= k_1 A u_2(t) - k_2 u_1(t) u_2(t - τ) + k_3 B u_1(t) - 2 k_4 u_1(t)^2, \\\\ u_2'(t) &= - k_1 A u_2(t) - k_2 u_1(t) u_2(t - τ) + f k_3 B u_1(t), \\end{align*} ``` @@ -84,11 +84,12 @@ const prob_dde_RADAR5_oregonator = let k₁ = 1.34, k₂ = 1.6e9, k₃ = 8_000, v = h(p, t - τ; idxs = 2) # precalculations - a = -k₁ * A * u[2] - k₂ * u[1] * v + a = k₁ * A * u[2] + c = k₂ * u[1] * v b = k₃ * B * u[1] - du[1] = a + b - 2 * k₄ * u[1]^2 - du[2] = a + f * b + du[1] = a - c + b - 2 * k₄ * u[1]^2 + du[2] = -a - c + f * b return nothing end diff --git a/lib/DDEProblemLibrary/test/radar5.jl b/lib/DDEProblemLibrary/test/radar5.jl new file mode 100644 index 0000000..3f8b8e3 --- /dev/null +++ b/lib/DDEProblemLibrary/test/radar5.jl @@ -0,0 +1,17 @@ +using DDEProblemLibrary, Test + +@testset "RADAR5 Oregonator right-hand side" begin + # F(1), F(2) of FCN in RADAR5-V2.1/OREGONATOR/dr-oregon.f + k₁, k₂, k₃, k₄, f, A, B = 1.34, 1.6e9, 8.0e3, 4.0e7, 1.0, 6.0e-2, 6.0e-2 + y2_lag = 3.0e-6 + h(p, t; idxs = nothing) = idxs == 2 ? y2_lag : [0.0, y2_lag] + u = [2.0e-8, 7.0e-6] + expected = [ + k₁ * A * u[2] - k₂ * u[1] * y2_lag + k₃ * B * u[1] - 2 * k₄ * u[1]^2, + -k₁ * A * u[2] - k₂ * u[1] * y2_lag + f * k₃ * B * u[1], + ] + prob = DDEProblemLibrary.prob_dde_RADAR5_oregonator + du = zeros(2) + prob.f(du, u, h, prob.p, 1.0) + @test du ≈ expected rtol = 1.0e-12 +end diff --git a/lib/DDEProblemLibrary/test/runtests.jl b/lib/DDEProblemLibrary/test/runtests.jl index d57e012..47dad9e 100644 --- a/lib/DDEProblemLibrary/test/runtests.jl +++ b/lib/DDEProblemLibrary/test/runtests.jl @@ -15,6 +15,7 @@ if TEST_GROUP == "Core" || TEST_GROUP == "All" @time @testset "Load Tests" begin @test DDEProblemLibrary isa Module end + @time @safetestset "RADAR5" include("radar5.jl") end # Quality assurance: no undefined exports, stale dependencies, etc.