Skip to content

Commit

Permalink
Merge branch 'SciML:master' into SharpFineRKN6
Browse files Browse the repository at this point in the history
  • Loading branch information
HenryLangner authored Nov 14, 2023
2 parents 270cbe8 + 66317a8 commit 912e9d3
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 5 deletions.
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "OrdinaryDiffEq"
uuid = "1dea7af3-3e70-54e6-95c3-0bf5283fa5ed"
authors = ["Chris Rackauckas <[email protected]>", "Yingbo Ma <[email protected]>"]
version = "6.59.0"
version = "6.59.1"

[deps]
ADTypes = "47edcb42-4c32-4615-8424-f2b9edc5f35b"
Expand Down
14 changes: 10 additions & 4 deletions src/dense/stiff_addsteps.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -644,15 +644,15 @@ 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

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

Expand Down Expand Up @@ -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
Expand All @@ -857,7 +860,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

Expand Down Expand Up @@ -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]
Expand Down
10 changes: 10 additions & 0 deletions test/integrators/event_detection_tests.jl
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using StaticArrays
using OrdinaryDiffEq
using DiffEqDevTools
using Test

@inbounds @inline function ż(z, p, t)
Expand Down Expand Up @@ -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 (Rodas4(),Rodas4P(),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
Expand Down

0 comments on commit 912e9d3

Please sign in to comment.