From 11a1a20846a4a1e44ad4ade521f35c5b64766a29 Mon Sep 17 00:00:00 2001 From: Christopher Rackauckas Date: Sat, 11 Nov 2023 16:56:36 -0500 Subject: [PATCH 1/4] Fix up Rodas5(p) addsteps! --- src/dense/stiff_addsteps.jl | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/dense/stiff_addsteps.jl b/src/dense/stiff_addsteps.jl index f61d0d2d75..87d1da4f35 100644 --- a/src/dense/stiff_addsteps.jl +++ b/src/dense/stiff_addsteps.jl @@ -522,7 +522,7 @@ end function _ode_addsteps!(k, t, uprev, u, dt, f, p, cache::Rosenbrock5ConstantCache, always_calc_begin = false, allow_calc_end = true, force_calc_end = false) - if length(k) < 2 || always_calc_begin + if length(k) < 3 || always_calc_begin @unpack tf, uf = cache @unpack a21, a31, a32, a41, a42, a43, a51, a52, a53, a54, a61, a62, a63, a64, a65, C21, C31, C32, C41, C42, C43, C51, C52, C53, C54, C61, C62, C63, C64, C65, C71, C72, C73, C74, C75, C76, C81, C82, C83, C84, C85, C86, C87, gamma, d1, d2, d3, d4, d5, c2, c3, c4, c5 = cache.tab @@ -644,7 +644,7 @@ function _ode_addsteps!(k, t, uprev, u, dt, f, p, cache::Rosenbrock5ConstantCach h48 * k8 copyat_or_push!(k, 1, k₁) copyat_or_push!(k, 2, k₂) - copyat_or_push!(k, 2, k₃) + copyat_or_push!(k, 3, k₃) end nothing end @@ -652,7 +652,7 @@ end function _ode_addsteps!(k, t, uprev, u, dt, f, p, cache::Rosenbrock5Cache, always_calc_begin = false, allow_calc_end = true, force_calc_end = false) - if length(k) < 2 || always_calc_begin + if length(k) < 3 || always_calc_begin @unpack du, du1, du2, tmp, k1, k2, k3, k4, k5, k6, k7, k8, dT, J, W, uf, tf, linsolve_tmp, jac_config, fsalfirst, weight = cache @unpack a21, a31, a32, a41, a42, a43, a51, a52, a53, a54, a61, a62, a63, a64, a65, C21, C31, C32, C41, C42, C43, C51, C52, C53, C54, C61, C62, C63, C64, C65, C71, C72, C73, C74, C75, C76, C81, C82, C83, C84, C85, C86, C87, gamma, d1, d2, d3, d4, d5, c2, c3, c4, c5 = cache.tab @@ -857,7 +857,7 @@ end function _ode_addsteps!(k, t, uprev, u, dt, f, p, cache::Rosenbrock5Cache{<:Array}, always_calc_begin = false, allow_calc_end = true, force_calc_end = false) - if length(k) < 2 || always_calc_begin + if length(k) < 3 || always_calc_begin @unpack du, du1, du2, k1, k2, k3, k4, k5, k6, k7, k8, dT, J, W, uf, tf, linsolve_tmp, jac_config, fsalfirst = cache @unpack a21, a31, a32, a41, a42, a43, a51, a52, a53, a54, a61, a62, a63, a64, a65, C21, C31, C32, C41, C42, C43, C51, C52, C53, C54, C61, C62, C63, C64, C65, C71, C72, C73, C74, C75, C76, C81, C82, C83, C84, C85, C86, C87, gamma, d1, d2, d3, d4, d5, c2, c3, c4, c5 = cache.tab From 16764b1d9c5f411be11bd37d611fa588d89af631 Mon Sep 17 00:00:00 2001 From: David Widmann Date: Mon, 13 Nov 2023 17:35:56 +0100 Subject: [PATCH 2/4] Fix Rodas5 and Rodas5P --- src/dense/stiff_addsteps.jl | 6 ++++++ test/integrators/event_detection_tests.jl | 10 ++++++++++ 2 files changed, 16 insertions(+) diff --git a/src/dense/stiff_addsteps.jl b/src/dense/stiff_addsteps.jl index 87d1da4f35..2dfbe9ba2f 100644 --- a/src/dense/stiff_addsteps.jl +++ b/src/dense/stiff_addsteps.jl @@ -838,6 +838,9 @@ function _ode_addsteps!(k, t, uprev, u, dt, f, p, cache::Rosenbrock5Cache, veck8 = _vec(k8) @.. broadcast=false veck8=-vecu + # https://github.com/SciML/OrdinaryDiffEq.jl/issues/2055 + tmp = linsolve_tmp + @unpack h21, h22, h23, h24, h25, h26, h27, h28, h31, h32, h33, h34, h35, h36, h37, h38, h41, h42, h43, h44, h45, h46, h47, h48 = cache.tab @.. broadcast=false tmp=h21 * k1 + h22 * k2 + h23 * k3 + h24 * k4 + h25 * k5 + h26 * k6 + h27 * k7 + h28 * k8 @@ -1092,6 +1095,9 @@ function _ode_addsteps!(k, t, uprev, u, dt, f, p, cache::Rosenbrock5Cache{<:Arra @unpack h21, h22, h23, h24, h25, h26, h27, h28, h31, h32, h33, h34, h35, h36, h37, h38, h41, h42, h43, h44, h45, h46, h47, h48 = cache.tab + # https://github.com/SciML/OrdinaryDiffEq.jl/issues/2055 + tmp = linsolve_tmp + @inbounds @simd ivdep for i in eachindex(u) tmp[i] = h21 * k1[i] + h22 * k2[i] + h23 * k3[i] + h24 * k4[i] + h25 * k5[i] + h26 * k6[i] + h27 * k7[i] + h28 * k8[i] diff --git a/test/integrators/event_detection_tests.jl b/test/integrators/event_detection_tests.jl index 9caddeacda..307baf7759 100644 --- a/test/integrators/event_detection_tests.jl +++ b/test/integrators/event_detection_tests.jl @@ -1,5 +1,6 @@ using StaticArrays using OrdinaryDiffEq +using DiffEqDevTools using Test @inbounds @inline function ż(z, p, t) @@ -60,6 +61,15 @@ prob = ODEProblem(f, u0, tspan, p) sol = solve(prob, Tsit5(), callback = cb2) @test minimum(Array(sol)) > -40 +# https://github.com/SciML/OrdinaryDiffEq.jl/issues/2055 +for alg in (Rodas5(), Rodas5P()) + sol2 = solve(prob, alg; callback = cb2) + sol3 = appxtrue(sol, sol2) + @test sol3.errors[:L2] < 1e-5 + @test sol3.errors[:L∞] < 5e-5 + @test sol3.errors[:final] < 1e-5 +end + function fball(du, u, p, t) du[1] = u[2] du[2] = -p From 0765f08bfd3ab9de5a27da5094e2e7c89abd14f1 Mon Sep 17 00:00:00 2001 From: Christopher Rackauckas Date: Tue, 14 Nov 2023 01:33:50 -0500 Subject: [PATCH 3/4] Update test/integrators/event_detection_tests.jl --- test/integrators/event_detection_tests.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/integrators/event_detection_tests.jl b/test/integrators/event_detection_tests.jl index 307baf7759..97885568e0 100644 --- a/test/integrators/event_detection_tests.jl +++ b/test/integrators/event_detection_tests.jl @@ -62,7 +62,7 @@ sol = solve(prob, Tsit5(), callback = cb2) @test minimum(Array(sol)) > -40 # https://github.com/SciML/OrdinaryDiffEq.jl/issues/2055 -for alg in (Rodas5(), Rodas5P()) +for alg in (Rodas4(),Rodas4P(),Rodas5(), Rodas5P()) sol2 = solve(prob, alg; callback = cb2) sol3 = appxtrue(sol, sol2) @test sol3.errors[:L2] < 1e-5 From 66317a8d1d2f23570a89e27ca63e923714524599 Mon Sep 17 00:00:00 2001 From: Christopher Rackauckas Date: Tue, 14 Nov 2023 04:34:53 -0500 Subject: [PATCH 4/4] Update Project.toml --- Project.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Project.toml b/Project.toml index 8132810a05..13af420651 100644 --- a/Project.toml +++ b/Project.toml @@ -1,7 +1,7 @@ name = "OrdinaryDiffEq" uuid = "1dea7af3-3e70-54e6-95c3-0bf5283fa5ed" authors = ["Chris Rackauckas ", "Yingbo Ma "] -version = "6.59.0" +version = "6.59.1" [deps] ADTypes = "47edcb42-4c32-4615-8424-f2b9edc5f35b"