diff --git a/lib/OrdinaryDiffEqSDIRK/src/kencarp_kvaerno_caches.jl b/lib/OrdinaryDiffEqSDIRK/src/kencarp_kvaerno_caches.jl index a122c5fee0..f680e0bdbe 100644 --- a/lib/OrdinaryDiffEqSDIRK/src/kencarp_kvaerno_caches.jl +++ b/lib/OrdinaryDiffEqSDIRK/src/kencarp_kvaerno_caches.jl @@ -77,10 +77,7 @@ end z₂::uType z₃::uType z₄::uType - k1::kType - k2::kType - k3::kType - k4::kType + ks::Vector{kType} atmp::uNoUnitsType nlsolver::N tab::Tab @@ -98,15 +95,9 @@ function alg_cache(alg::KenCarp3, u, rate_prototype, ::Type{uEltypeNoUnits}, fsalfirst = zero(rate_prototype) if f isa SplitFunction - k1 = zero(u) - k2 = zero(u) - k3 = zero(u) - k4 = zero(u) + ks = [zero(u) for _ in 1:4] else - k1 = nothing - k2 = nothing - k3 = nothing - k4 = nothing + ks = [nothing for _ in 1:4] uf = UJacobianWrapper(f, t, p) end @@ -117,8 +108,7 @@ function alg_cache(alg::KenCarp3, u, rate_prototype, ::Type{uEltypeNoUnits}, atmp = similar(u, uEltypeNoUnits) recursivefill!(atmp, false) - KenCarp3Cache(u, uprev, fsalfirst, z₁, z₂, z₃, z₄, k1, k2, - k3, k4, atmp, nlsolver, tab, alg.step_limiter!) + KenCarp3Cache(u, uprev, fsalfirst, z₁, z₂, z₃, z₄, ks, atmp, nlsolver, tab, alg.step_limiter!) end @cache mutable struct CFNLIRK3ConstantCache{N, Tab} <: SDIRKConstantCache @@ -147,10 +137,7 @@ end z₂::uType z₃::uType z₄::uType - k1::kType - k2::kType - k3::kType - k4::kType + ks::Vector{kType} atmp::uNoUnitsType nlsolver::N tab::Tab @@ -166,10 +153,7 @@ function alg_cache(alg::CFNLIRK3, u, rate_prototype, ::Type{uEltypeNoUnits}, uBottomEltypeNoUnits, tTypeNoUnits, γ, c, Val(true)) fsalfirst = zero(rate_prototype) - k1 = zero(u) - k2 = zero(u) - k3 = zero(u) - k4 = zero(u) + ks = [zero(u) for _ in 1:4] z₁ = zero(u) z₂ = zero(u) @@ -178,7 +162,7 @@ function alg_cache(alg::CFNLIRK3, u, rate_prototype, ::Type{uEltypeNoUnits}, atmp = similar(u, uEltypeNoUnits) recursivefill!(atmp, false) - CFNLIRK3Cache(u, uprev, fsalfirst, z₁, z₂, z₃, z₄, k1, k2, k3, k4, atmp, nlsolver, tab) + CFNLIRK3Cache(u, uprev, fsalfirst, z₁, z₂, z₃, z₄, ks, atmp, nlsolver, tab) end @cache mutable struct Kvaerno4ConstantCache{N, Tab} <: SDIRKConstantCache @@ -263,12 +247,7 @@ end z₄::uType z₅::uType z₆::uType - k1::kType - k2::kType - k3::kType - k4::kType - k5::kType - k6::kType + ks::Vector{kType} atmp::uNoUnitsType nlsolver::N tab::Tab @@ -288,19 +267,9 @@ function alg_cache(alg::KenCarp4, u, rate_prototype, ::Type{uEltypeNoUnits}, fsalfirst = zero(rate_prototype) if f isa SplitFunction - k1 = zero(u) - k2 = zero(u) - k3 = zero(u) - k4 = zero(u) - k5 = zero(u) - k6 = zero(u) + ks = [zero(u) for _ in 1:6] else - k1 = nothing - k2 = nothing - k3 = nothing - k4 = nothing - k5 = nothing - k6 = nothing + ks = [nothing for _ in 1:6] uf = UJacobianWrapper(f, t, p) end @@ -314,7 +283,7 @@ function alg_cache(alg::KenCarp4, u, rate_prototype, ::Type{uEltypeNoUnits}, recursivefill!(atmp, false) KenCarp4Cache( - u, uprev, fsalfirst, z₁, z₂, z₃, z₄, z₅, z₆, k1, k2, k3, k4, k5, k6, atmp, + u, uprev, fsalfirst, z₁, z₂, z₃, z₄, z₅, z₆, ks, atmp, nlsolver, tab, alg.step_limiter!) end @@ -408,14 +377,7 @@ end z₆::uType z₇::uType z₈::uType - k1::kType - k2::kType - k3::kType - k4::kType - k5::kType - k6::kType - k7::kType - k8::kType + ks::Vector{kType} atmp::uNoUnitsType nlsolver::N tab::Tab @@ -433,23 +395,9 @@ function alg_cache(alg::KenCarp5, u, rate_prototype, ::Type{uEltypeNoUnits}, fsalfirst = zero(rate_prototype) if f isa SplitFunction - k1 = zero(u) - k2 = zero(u) - k3 = zero(u) - k4 = zero(u) - k5 = zero(u) - k6 = zero(u) - k7 = zero(u) - k8 = zero(u) + ks = [zero(u) for _ in 1:8] else - k1 = nothing - k2 = nothing - k3 = nothing - k4 = nothing - k5 = nothing - k6 = nothing - k7 = nothing - k8 = nothing + ks = [nothing for _ in 1:8] end z₁ = zero(u) @@ -464,7 +412,7 @@ function alg_cache(alg::KenCarp5, u, rate_prototype, ::Type{uEltypeNoUnits}, recursivefill!(atmp, false) KenCarp5Cache(u, uprev, fsalfirst, z₁, z₂, z₃, z₄, z₅, z₆, z₇, z₈, - k1, k2, k3, k4, k5, k6, k7, k8, atmp, nlsolver, tab, alg.step_limiter!) + ks, atmp, nlsolver, tab, alg.step_limiter!) end @cache mutable struct KenCarp47ConstantCache{N, Tab} <: SDIRKConstantCache @@ -496,13 +444,7 @@ end z₅::uType z₆::uType z₇::uType - k1::kType - k2::kType - k3::kType - k4::kType - k5::kType - k6::kType - k7::kType + ks::Vector{kType} atmp::uNoUnitsType nlsolver::N tab::Tab @@ -520,21 +462,9 @@ function alg_cache(alg::KenCarp47, u, rate_prototype, ::Type{uEltypeNoUnits}, fsalfirst = zero(rate_prototype) if f isa SplitFunction - k1 = zero(u) - k2 = zero(u) - k3 = zero(u) - k4 = zero(u) - k5 = zero(u) - k6 = zero(u) - k7 = zero(u) + ks = [zero(u) for _ in 1:7] else - k1 = nothing - k2 = nothing - k3 = nothing - k4 = nothing - k5 = nothing - k6 = nothing - k7 = nothing + ks = [nothing for _ in 1:7] end z₁ = zero(u) @@ -548,7 +478,7 @@ function alg_cache(alg::KenCarp47, u, rate_prototype, ::Type{uEltypeNoUnits}, recursivefill!(atmp, false) KenCarp47Cache(u, uprev, fsalfirst, z₁, z₂, z₃, z₄, z₅, z₆, z₇, - k1, k2, k3, k4, k5, k6, k7, atmp, nlsolver, tab) + ks, atmp, nlsolver, tab) end @cache mutable struct KenCarp58ConstantCache{N, Tab} <: SDIRKConstantCache @@ -581,14 +511,7 @@ end z₆::uType z₇::uType z₈::uType - k1::kType - k2::kType - k3::kType - k4::kType - k5::kType - k6::kType - k7::kType - k8::kType + ks::Vector{kType} atmp::uNoUnitsType nlsolver::N tab::Tab @@ -607,23 +530,9 @@ function alg_cache(alg::KenCarp58, u, rate_prototype, ::Type{uEltypeNoUnits}, fsalfirst = zero(rate_prototype) if f isa SplitFunction - k1 = zero(u) - k2 = zero(u) - k3 = zero(u) - k4 = zero(u) - k5 = zero(u) - k6 = zero(u) - k7 = zero(u) - k8 = zero(u) + ks = [zero(u) for _ in 1:8] else - k1 = nothing - k2 = nothing - k3 = nothing - k4 = nothing - k5 = nothing - k6 = nothing - k7 = nothing - k8 = nothing + ks = [nothing for _ in 1:8] end z₁ = zero(u) @@ -638,5 +547,5 @@ function alg_cache(alg::KenCarp58, u, rate_prototype, ::Type{uEltypeNoUnits}, recursivefill!(atmp, false) KenCarp58Cache(u, uprev, fsalfirst, z₁, z₂, z₃, z₄, z₅, z₆, z₇, z₈, - k1, k2, k3, k4, k5, k6, k7, k8, atmp, nlsolver, tab) + ks, atmp, nlsolver, tab) end diff --git a/lib/OrdinaryDiffEqSDIRK/src/kencarp_kvaerno_perform_step.jl b/lib/OrdinaryDiffEqSDIRK/src/kencarp_kvaerno_perform_step.jl index 20d497abff..1aca2a9067 100644 --- a/lib/OrdinaryDiffEqSDIRK/src/kencarp_kvaerno_perform_step.jl +++ b/lib/OrdinaryDiffEqSDIRK/src/kencarp_kvaerno_perform_step.jl @@ -269,7 +269,7 @@ end @muladd function perform_step!(integrator, cache::KenCarp3Cache, repeat_step = false) @unpack t, dt, uprev, u, p = integrator - @unpack z₁, z₂, z₃, z₄, k1, k2, k3, k4, atmp, nlsolver, step_limiter! = cache + @unpack z₁, z₂, z₃, z₄, ks, atmp, nlsolver, step_limiter! = cache @unpack tmp = nlsolver @unpack γ, a31, a32, a41, a42, a43, btilde1, btilde2, btilde3, btilde4, c3, α31, α32 = cache.tab @unpack ea21, ea31, ea32, ea41, ea42, ea43, eb1, eb2, eb3, eb4 = cache.tab @@ -308,8 +308,8 @@ end if integrator.f isa SplitFunction # This assumes the implicit part is cheaper than the explicit part - @.. broadcast=false k1=dt * integrator.fsalfirst - z₁ - @.. broadcast=false tmp+=ea21 * k1 + @.. broadcast=false ks[1]=dt * integrator.fsalfirst - z₁ + @.. broadcast=false tmp+=ea21 * ks[1] end nlsolver.c = 2γ @@ -322,10 +322,10 @@ end if integrator.f isa SplitFunction z₃ .= z₂ @.. broadcast=false u=tmp + γ * z₂ - f2(k2, u, p, t + 2γdt) - k2 .*= dt + f2(ks[2], u, p, t + 2γdt) + ks[2] .*= dt integrator.stats.nf2 += 1 - @.. broadcast=false tmp=uprev + a31 * z₁ + a32 * z₂ + ea31 * k1 + ea32 * k2 + @.. broadcast=false tmp=uprev + a31 * z₁ + a32 * z₂ + ea31 * ks[1] + ea32 * ks[2] else # Guess is from Hermite derivative on z₁ and z₂ @.. broadcast=false z₃=α31 * z₁ + α32 * z₂ @@ -342,11 +342,11 @@ end if integrator.f isa SplitFunction z₄ .= z₂ @.. broadcast=false u=tmp + γ * z₃ - f2(k3, u, p, t + c3 * dt) - k3 .*= dt + f2(ks[3], u, p, t + c3 * dt) + ks[3] .*= dt integrator.stats.nf2 += 1 - @.. broadcast=false tmp=uprev + a41 * z₁ + a42 * z₂ + a43 * z₃ + ea41 * k1 + - ea42 * k2 + ea43 * k3 + @.. broadcast=false tmp=uprev + a41 * z₁ + a42 * z₂ + a43 * z₃ + ea41 * ks[1] + + ea42 * ks[2] + ea43 * ks[3] else @unpack α41, α42 = cache.tab @.. broadcast=false z₄=α41 * z₁ + α42 * z₂ @@ -360,11 +360,11 @@ end @.. broadcast=false u=tmp + γ * z₄ if integrator.f isa SplitFunction - f2(k4, u, p, t + dt) - k4 .*= dt + f2(ks[4], u, p, t + dt) + ks[4] .*= dt integrator.stats.nf2 += 1 - @.. broadcast=false u=uprev + a41 * z₁ + a42 * z₂ + a43 * z₃ + γ * z₄ + eb1 * k1 + - eb2 * k2 + eb3 * k3 + eb4 * k4 + @.. broadcast=false u=uprev + a41 * z₁ + a42 * z₂ + a43 * z₃ + γ * z₄ + eb1 * ks[1] + + eb2 * ks[2] + eb3 * ks[3] + eb4 * ks[4] end step_limiter!(u, integrator, p, t + dt) @@ -374,8 +374,8 @@ end if integrator.opts.adaptive if integrator.f isa SplitFunction @.. broadcast=false tmp=btilde1 * z₁ + btilde2 * z₂ + btilde3 * z₃ + - btilde4 * z₄ + ebtilde1 * k1 + ebtilde2 * k2 + - ebtilde3 * k3 + ebtilde4 * k4 + btilde4 * z₄ + ebtilde1 * ks[1] + ebtilde2 * ks[2] + + ebtilde3 * ks[3] + ebtilde4 * ks[4] else @.. broadcast=false tmp=btilde1 * z₁ + btilde2 * z₂ + btilde3 * z₃ + btilde4 * z₄ @@ -510,7 +510,7 @@ end @muladd function perform_step!(integrator, cache::CFNLIRK3Cache, repeat_step = false) @unpack t, dt, uprev, u, p = integrator - @unpack z₁, z₂, z₃, z₄, k1, k2, k3, k4, atmp, nlsolver = cache + @unpack z₁, z₂, z₃, z₄, ks, atmp, nlsolver = cache @unpack tmp = nlsolver @unpack γ, a31, a32, a41, a42, a43, c2, c3 = cache.tab @unpack ea21, ea31, ea32, ea41, ea42, ea43, eb1, eb2, eb3, eb4 = cache.tab @@ -547,8 +547,8 @@ end if integrator.f isa SplitFunction # This assumes the implicit part is cheaper than the explicit part - @.. broadcast=false k1=dt * integrator.fsalfirst - z₁ - @.. broadcast=false tmp+=ea21 * k1 + @.. broadcast=false ks[1]=dt * integrator.fsalfirst - z₁ + @.. broadcast=false tmp+=ea21 * ks[1] end nlsolver.c = c2 @@ -561,10 +561,10 @@ end if integrator.f isa SplitFunction z₃ .= z₂ @.. broadcast=false u=tmp + γ * z₂ - f2(k2, u, p, t + c2 * dt) - k2 .*= dt + f2(ks[2], u, p, t + c2 * dt) + ks[2] .*= dt integrator.stats.nf2 += 1 - @.. broadcast=false tmp=uprev + a31 * z₁ + a32 * z₂ + ea31 * k1 + ea32 * k2 + @.. broadcast=false tmp=uprev + a31 * z₁ + a32 * z₂ + ea31 * ks[1] + ea32 * ks[2] else @.. broadcast=false z₃=z₂ @.. broadcast=false tmp=uprev + a31 * z₁ + a32 * z₂ @@ -580,11 +580,11 @@ end if integrator.f isa SplitFunction z₄ .= z₂ @.. broadcast=false u=tmp + γ * z₃ - f2(k3, u, p, t + c3 * dt) - k3 .*= dt + f2(ks[3], u, p, t + c3 * dt) + ks[3] .*= dt integrator.stats.nf2 += 1 - @.. broadcast=false tmp=uprev + a41 * z₁ + a42 * z₂ + a43 * z₃ + ea41 * k1 + - ea42 * k2 + ea43 * k3 + @.. broadcast=false tmp=uprev + a41 * z₁ + a42 * z₂ + a43 * z₃ + ea41 * ks[1] + + ea42 * ks[2] + ea43 * ks[3] else @.. broadcast=false z₄=z₂ @.. broadcast=false tmp=uprev + a41 * z₁ + a42 * z₂ + a43 * z₃ @@ -597,11 +597,11 @@ end @.. broadcast=false u=tmp + γ * z₄ if integrator.f isa SplitFunction - f2(k4, u, p, t + dt) - k4 .*= dt + f2(ks[4], u, p, t + dt) + ks[4] .*= dt integrator.stats.nf2 += 1 - @.. broadcast=false u=uprev + a41 * z₁ + a42 * z₂ + a43 * z₃ + γ * z₄ + eb1 * k1 + - eb2 * k2 + eb3 * k3 + eb4 * k4 + @.. broadcast=false u=uprev + a41 * z₁ + a42 * z₂ + a43 * z₃ + γ * z₄ + eb1 * ks[1] + + eb2 * ks[2] + eb3 * ks[3] + eb4 * ks[4] end if integrator.f isa SplitFunction @@ -957,7 +957,7 @@ end @unpack t, dt, uprev, u, p = integrator @unpack z₁, z₂, z₃, z₄, z₅, z₆, atmp, nlsolver, step_limiter! = cache @unpack tmp = nlsolver - @unpack k1, k2, k3, k4, k5, k6 = cache + @unpack ks = cache @unpack γ, a31, a32, a41, a42, a43, a51, a52, a53, a54, a61, a63, a64, a65, c3, c4, c5 = cache.tab @unpack α31, α32, α41, α42, α51, α52, α53, α54, α61, α62, α63, α64, α65 = cache.tab @unpack btilde1, btilde3, btilde4, btilde5, btilde6 = cache.tab @@ -1000,8 +1000,8 @@ end if integrator.f isa SplitFunction # This assumes the implicit part is cheaper than the explicit part - @.. broadcast=false k1=dt * integrator.fsalfirst - z₁ - @.. broadcast=false tmp+=ea21 * k1 + @.. broadcast=false ks[1]=dt * integrator.fsalfirst - z₁ + @.. broadcast=false tmp+=ea21 * ks[1] end nlsolver.c = 2γ @@ -1015,10 +1015,10 @@ end if integrator.f isa SplitFunction z₃ .= z₂ @.. broadcast=false u=tmp + γ * z₂ - f2(k2, u, p, t + 2γdt) - k2 .*= dt + f2(ks[2], u, p, t + 2γdt) + ks[2] .*= dt integrator.stats.nf2 += 1 - @.. broadcast=false tmp=uprev + a31 * z₁ + a32 * z₂ + ea31 * k1 + ea32 * k2 + @.. broadcast=false tmp=uprev + a31 * z₁ + a32 * z₂ + ea31 * ks[1] + ea32 * ks[2] else # Guess is from Hermite derivative on z₁ and z₂ @.. broadcast=false z₃=α31 * z₁ + α32 * z₂ @@ -1035,11 +1035,11 @@ end if integrator.f isa SplitFunction z₄ .= z₂ @.. broadcast=false u=tmp + γ * z₃ - f2(k3, u, p, t + c3 * dt) - k3 .*= dt + f2(ks[3], u, p, t + c3 * dt) + ks[3] .*= dt integrator.stats.nf2 += 1 - @.. broadcast=false tmp=uprev + a41 * z₁ + a42 * z₂ + a43 * z₃ + ea41 * k1 + - ea42 * k2 + ea43 * k3 + @.. broadcast=false tmp=uprev + a41 * z₁ + a42 * z₂ + a43 * z₃ + ea41 * ks[1] + + ea42 * ks[2] + ea43 * ks[3] else @.. broadcast=false z₄=α41 * z₁ + α42 * z₂ @.. broadcast=false tmp=uprev + a41 * z₁ + a42 * z₂ + a43 * z₃ @@ -1055,11 +1055,11 @@ end if integrator.f isa SplitFunction z₅ .= z₄ @.. broadcast=false u=tmp + γ * z₄ - f2(k4, u, p, t + c4 * dt) - k4 .*= dt + f2(ks[4], u, p, t + c4 * dt) + ks[4] .*= dt integrator.stats.nf2 += 1 @.. broadcast=false tmp=uprev + a51 * z₁ + a52 * z₂ + a53 * z₃ + a54 * z₄ + - ea51 * k1 + ea52 * k2 + ea53 * k3 + ea54 * k4 + ea51 * ks[1] + ea52 * ks[2] + ea53 * ks[3] + ea54 * ks[4] else @.. broadcast=false z₅=α51 * z₁ + α52 * z₂ + α53 * z₃ + α54 * z₄ @.. broadcast=false tmp=uprev + a51 * z₁ + a52 * z₂ + a53 * z₃ + a54 * z₄ @@ -1075,11 +1075,11 @@ end if integrator.f isa SplitFunction z₆ .= z₅ @.. broadcast=false u=tmp + γ * z₅ - f2(k5, u, p, t + c5 * dt) - k5 .*= dt + f2(ks[5], u, p, t + c5 * dt) + ks[5] .*= dt integrator.stats.nf2 += 1 @.. broadcast=false tmp=uprev + a61 * z₁ + a63 * z₃ + a64 * z₄ + a65 * z₅ + - ea61 * k1 + ea62 * k2 + ea63 * k3 + ea64 * k4 + ea65 * k5 + ea61 * ks[1] + ea62 * ks[2] + ea63 * ks[3] + ea64 * ks[4] + ea65 * ks[5] else @.. broadcast=false z₆=α61 * z₁ + α62 * z₂ + α63 * z₃ + α64 * z₄ + α65 * z₅ @.. broadcast=false tmp=uprev + a61 * z₁ + a63 * z₃ + a64 * z₄ + a65 * z₅ @@ -1092,11 +1092,11 @@ end @.. broadcast=false u=tmp + γ * z₆ if integrator.f isa SplitFunction - f2(k6, u, p, t + dt) - k6 .*= dt + f2(ks[6], u, p, t + dt) + ks[6] .*= dt integrator.stats.nf2 += 1 @.. broadcast=false u=uprev + a61 * z₁ + a63 * z₃ + a64 * z₄ + a65 * z₅ + γ * z₆ + - eb1 * k1 + eb3 * k3 + eb4 * k4 + eb5 * k5 + eb6 * k6 + eb1 * ks[1] + eb3 * ks[3] + eb4 * ks[4] + eb5 * ks[5] + eb6 * ks[6] end step_limiter!(u, integrator, p, t + dt) @@ -1105,9 +1105,9 @@ end if integrator.opts.adaptive if integrator.f isa SplitFunction @.. broadcast=false tmp=btilde1 * z₁ + btilde3 * z₃ + btilde4 * z₄ + - btilde5 * z₅ + btilde6 * z₆ + ebtilde1 * k1 + - ebtilde3 * k3 + ebtilde4 * k4 + ebtilde5 * k5 + - ebtilde6 * k6 + btilde5 * z₅ + btilde6 * z₆ + ebtilde1 * ks[1] + + ebtilde3 * ks[3] + ebtilde4 * ks[4] + ebtilde5 * ks[5] + + ebtilde6 * ks[6] else @.. broadcast=false tmp=btilde1 * z₁ + btilde3 * z₃ + btilde4 * z₄ + btilde5 * z₅ + btilde6 * z₆ @@ -1560,7 +1560,7 @@ end @muladd function perform_step!(integrator, cache::KenCarp5Cache, repeat_step = false) @unpack t, dt, uprev, u, p = integrator @unpack z₁, z₂, z₃, z₄, z₅, z₆, z₇, z₈, atmp, nlsolver, step_limiter! = cache - @unpack k1, k2, k3, k4, k5, k6, k7, k8 = cache + @unpack ks = cache @unpack tmp = nlsolver @unpack γ, a31, a32, a41, a43, a51, a53, a54, a61, a63, a64, a65, a71, a73, a74, a75, a76, a81, a84, a85, a86, a87, c3, c4, c5, c6, c7 = cache.tab @unpack α31, α32, α41, α42, α51, α52, α61, α62, α71, α72, α73, α74, α75, α81, α82, α83, α84, α85 = cache.tab @@ -1605,8 +1605,8 @@ end if integrator.f isa SplitFunction # This assumes the implicit part is cheaper than the explicit part - @.. broadcast=false k1=dt * integrator.fsalfirst - z₁ - @.. broadcast=false tmp+=ea21 * k1 + @.. broadcast=false ks[1]=dt * integrator.fsalfirst - z₁ + @.. broadcast=false tmp+=ea21 * ks[1] end nlsolver.c = 2γ @@ -1619,10 +1619,10 @@ end if integrator.f isa SplitFunction z₃ .= z₂ @.. broadcast=false u=tmp + γ * z₂ - f2(k2, u, p, t + 2γdt) - k2 .*= dt + f2(ks[2], u, p, t + 2γdt) + ks[2] .*= dt integrator.stats.nf2 += 1 - @.. broadcast=false tmp=uprev + a31 * z₁ + a32 * z₂ + ea31 * k1 + ea32 * k2 + @.. broadcast=false tmp=uprev + a31 * z₁ + a32 * z₂ + ea31 * ks[1] + ea32 * ks[2] else # Guess is from Hermite derivative on z₁ and z₂ @.. broadcast=false z₃=a31 * z₁ + α32 * z₂ @@ -1639,10 +1639,10 @@ end if integrator.f isa SplitFunction z₄ .= z₃ @.. broadcast=false u=tmp + γ * z₃ - f2(k3, u, p, t + c3 * dt) - k3 .*= dt + f2(ks[3], u, p, t + c3 * dt) + ks[3] .*= dt integrator.stats.nf2 += 1 - @.. broadcast=false tmp=uprev + a41 * z₁ + a43 * z₃ + ea41 * k1 + ea43 * k3 + @.. broadcast=false tmp=uprev + a41 * z₁ + a43 * z₃ + ea41 * ks[1] + ea43 * ks[3] else @.. broadcast=false z₄=α41 * z₁ + α42 * z₂ @.. broadcast=false tmp=uprev + a41 * z₁ + a43 * z₃ @@ -1658,11 +1658,11 @@ end if integrator.f isa SplitFunction z₅ .= z₂ @.. broadcast=false u=tmp + γ * z₄ - f2(k4, u, p, t + c4 * dt) - k4 .*= dt + f2(ks[4], u, p, t + c4 * dt) + ks[4] .*= dt integrator.stats.nf2 += 1 - @.. broadcast=false tmp=uprev + a51 * z₁ + a53 * z₃ + a54 * z₄ + ea51 * k1 + - ea53 * k3 + ea54 * k4 + @.. broadcast=false tmp=uprev + a51 * z₁ + a53 * z₃ + a54 * z₄ + ea51 * ks[1] + + ea53 * ks[3] + ea54 * ks[4] else @.. broadcast=false z₅=α51 * z₁ + α52 * z₂ @.. broadcast=false tmp=uprev + a51 * z₁ + a53 * z₃ + a54 * z₄ @@ -1678,11 +1678,11 @@ end if integrator.f isa SplitFunction z₆ .= z₃ @.. broadcast=false u=tmp + γ * z₅ - f2(k5, u, p, t + c5 * dt) - k5 .*= dt + f2(ks[5], u, p, t + c5 * dt) + ks[5] .*= dt integrator.stats.nf2 += 1 @.. broadcast=false tmp=uprev + a61 * z₁ + a63 * z₃ + a64 * z₄ + a65 * z₅ + - ea61 * k1 + ea63 * k3 + ea64 * k4 + ea65 * k5 + ea61 * ks[1] + ea63 * ks[3] + ea64 * ks[4] + ea65 * ks[5] else @.. broadcast=false z₆=α61 * z₁ + α62 * z₂ @.. broadcast=false tmp=uprev + a61 * z₁ + a63 * z₃ + a64 * z₄ + a65 * z₅ @@ -1698,12 +1698,12 @@ end if integrator.f isa SplitFunction z₇ .= z₂ @.. broadcast=false u=tmp + γ * z₆ - f2(k6, u, p, t + c6 * dt) - k6 .*= dt + f2(ks[6], u, p, t + c6 * dt) + ks[6] .*= dt integrator.stats.nf2 += 1 @.. broadcast=false tmp=uprev + a71 * z₁ + a73 * z₃ + a74 * z₄ + a75 * z₅ + - a76 * z₆ + ea71 * k1 + ea73 * k3 + ea74 * k4 + ea75 * k5 + - ea76 * k6 + a76 * z₆ + ea71 * ks[1] + ea73 * ks[3] + ea74 * ks[4] + ea75 * ks[5] + + ea76 * ks[6] else @.. broadcast=false z₇=α71 * z₁ + α72 * z₂ + α73 * z₃ + α74 * z₄ + α75 * z₅ @.. broadcast=false tmp=uprev + a71 * z₁ + a73 * z₃ + a74 * z₄ + a75 * z₅ + a76 * z₆ @@ -1719,12 +1719,12 @@ end if integrator.f isa SplitFunction z₈ .= z₅ @.. broadcast=false u=tmp + γ * z₇ - f2(k7, u, p, t + c7 * dt) - k7 .*= dt + f2(ks[7], u, p, t + c7 * dt) + ks[7] .*= dt integrator.stats.nf2 += 1 @.. broadcast=false tmp=uprev + a81 * z₁ + a84 * z₄ + a85 * z₅ + a86 * z₆ + - a87 * z₇ + ea81 * k1 + ea83 * k3 + ea84 * k4 + ea85 * k5 + - ea86 * k6 + ea87 * k7 + a87 * z₇ + ea81 * ks[1] + ea83 * ks[3] + ea84 * ks[4] + ea85 * ks[5] + + ea86 * ks[6] + ea87 * ks[7] else @.. broadcast=false z₈=α81 * z₁ + α82 * z₂ + α83 * z₃ + α84 * z₄ + α85 * z₅ @.. broadcast=false tmp=uprev + a81 * z₁ + a84 * z₄ + a85 * z₅ + a86 * z₆ + a87 * z₇ @@ -1737,12 +1737,12 @@ end @.. broadcast=false u=tmp + γ * z₈ if integrator.f isa SplitFunction - f2(k8, u, p, t + dt) - k8 .*= dt + f2(ks[8], u, p, t + dt) + ks[8] .*= dt OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) @.. broadcast=false u=uprev + a81 * z₁ + a84 * z₄ + a85 * z₅ + a86 * z₆ + a87 * z₇ + - γ * z₈ + eb1 * k1 + eb4 * k4 + eb5 * k5 + eb6 * k6 + - eb7 * k7 + eb8 * k8 + γ * z₈ + eb1 * ks[1] + eb4 * ks[4] + eb5 * ks[5] + eb6 * ks[6] + + eb7 * ks[7] + eb8 * ks[8] end step_limiter!(u, integrator, p, t + dt) @@ -1752,8 +1752,8 @@ end if integrator.f isa SplitFunction @.. broadcast=false tmp=btilde1 * z₁ + btilde4 * z₄ + btilde5 * z₅ + btilde6 * z₆ + btilde7 * z₇ + btilde8 * z₈ + - ebtilde1 * k1 + ebtilde4 * k4 + ebtilde5 * k5 + - ebtilde6 * k6 + ebtilde7 * k7 + ebtilde8 * k8 + ebtilde1 * ks[1] + ebtilde4 * ks[4] + ebtilde5 * ks[5] + + ebtilde6 * ks[6] + ebtilde7 * ks[7] + ebtilde8 * ks[8] else @.. broadcast=false tmp=btilde1 * z₁ + btilde4 * z₄ + btilde5 * z₅ + btilde6 * z₆ + btilde7 * z₇ + btilde8 * z₈ @@ -1977,7 +1977,7 @@ end @muladd function perform_step!(integrator, cache::KenCarp47Cache, repeat_step = false) @unpack t, dt, uprev, u, p = integrator @unpack z₁, z₂, z₃, z₄, z₅, z₆, z₇, atmp, nlsolver = cache - @unpack k1, k2, k3, k4, k5, k6, k7 = cache + @unpack ks = cache @unpack tmp = nlsolver @unpack γ, a31, a32, a41, a42, a43, a51, a52, a53, a54, a61, a62, a63, a64, a65, a73, a74, a75, a76, c3, c4, c5, c6 = cache.tab @unpack α31, α32, α41, α42, α43, α51, α52, α61, α62, α63, α71, α72, α73, α74, α75, α76 = cache.tab @@ -2021,8 +2021,8 @@ end if integrator.f isa SplitFunction # This assumes the implicit part is cheaper than the explicit part - @.. broadcast=false k1=dt * integrator.fsalfirst - z₁ - @.. broadcast=false tmp+=ea21 * k1 + @.. broadcast=false ks[1]=dt * integrator.fsalfirst - z₁ + @.. broadcast=false tmp+=ea21 * ks[1] end nlsolver.c = 2γ @@ -2035,10 +2035,10 @@ end if integrator.f isa SplitFunction z₃ .= z₂ @.. broadcast=false u=tmp + γ * z₂ - f2(k2, u, p, t + 2γdt) - k2 .*= dt + f2(ks[2], u, p, t + 2γdt) + ks[2] .*= dt integrator.stats.nf2 += 1 - @.. broadcast=false tmp=uprev + a31 * z₁ + a32 * z₂ + ea31 * k1 + ea32 * k2 + @.. broadcast=false tmp=uprev + a31 * z₁ + a32 * z₂ + ea31 * ks[1] + ea32 * ks[2] else #Guess is from Hermite derivative on z₁ and z₂ @.. broadcast=false z₃=a31 * z₁ + α32 * z₂ @@ -2055,11 +2055,11 @@ end if integrator.f isa SplitFunction z₄ .= z₃ @.. broadcast=false u=tmp + γ * z₃ - f2(k3, u, p, t + c3 * dt) - k3 .*= dt + f2(ks[3], u, p, t + c3 * dt) + ks[3] .*= dt integrator.stats.nf2 += 1 - @.. broadcast=false tmp=uprev + a41 * z₁ + a42 * z₂ + a43 * z₃ + ea41 * k1 + - ea42 * k2 + ea43 * k3 + @.. broadcast=false tmp=uprev + a41 * z₁ + a42 * z₂ + a43 * z₃ + ea41 * ks[1] + + ea42 * ks[2] + ea43 * ks[3] else @.. broadcast=false z₄=α41 * z₁ + α42 * z₂ + α43 * z₃ @.. broadcast=false tmp=uprev + a41 * z₁ + a42 * z₂ + a43 * z₃ @@ -2075,11 +2075,11 @@ end if integrator.f isa SplitFunction z₅ .= z₁ @.. broadcast=false u=tmp + γ * z₄ - f2(k4, u, p, t + c4 * dt) - k4 .*= dt + f2(ks[4], u, p, t + c4 * dt) + ks[4] .*= dt integrator.stats.nf2 += 1 @.. broadcast=false tmp=uprev + a51 * z₁ + a52 * z₂ + a53 * z₃ + a54 * z₄ + - ea51 * k1 + ea52 * k2 + ea53 * k3 + ea54 * k4 + ea51 * ks[1] + ea52 * ks[2] + ea53 * ks[3] + ea54 * ks[4] else @.. broadcast=false z₅=α51 * z₁ + α52 * z₂ @.. broadcast=false tmp=uprev + a51 * z₁ + a52 * z₂ + a53 * z₃ + a54 * z₄ @@ -2095,12 +2095,12 @@ end if integrator.f isa SplitFunction z₆ .= z₃ @.. broadcast=false u=tmp + γ * z₅ - f2(k5, u, p, t + c5 * dt) - k5 .*= dt + f2(ks[5], u, p, t + c5 * dt) + ks[5] .*= dt integrator.stats.nf2 += 1 @.. broadcast=false tmp=uprev + a61 * z₁ + a62 * z₂ + a63 * z₃ + a64 * z₄ + - a65 * z₅ + ea61 * k1 + ea62 * k2 + ea63 * k3 + ea64 * k4 + - ea65 * k5 + a65 * z₅ + ea61 * ks[1] + ea62 * ks[2] + ea63 * ks[3] + ea64 * ks[4] + + ea65 * ks[5] else @.. broadcast=false z₆=α61 * z₁ + α62 * z₂ + α63 * z₃ @.. broadcast=false tmp=uprev + a61 * z₁ + a62 * z₂ + a63 * z₃ + a64 * z₄ + a65 * z₅ @@ -2116,12 +2116,12 @@ end if integrator.f isa SplitFunction z₇ .= z₆ @.. broadcast=false u=tmp + γ * z₆ - f2(k6, u, p, t + c6 * dt) - k6 .*= dt + f2(ks[6], u, p, t + c6 * dt) + ks[6] .*= dt integrator.stats.nf2 += 1 @.. broadcast=false tmp=uprev + a73 * z₃ + a74 * z₄ + a75 * z₅ + a76 * z₆ + - ea71 * k1 + ea72 * k2 + ea73 * k3 + ea74 * k4 + ea75 * k5 + - ea76 * k6 + ea71 * ks[1] + ea72 * ks[2] + ea73 * ks[3] + ea74 * ks[4] + ea75 * ks[5] + + ea76 * ks[6] else @.. broadcast=false z₇=α71 * z₁ + α72 * z₂ + α73 * z₃ + α74 * z₄ + α75 * z₅ + α76 * z₆ @@ -2135,11 +2135,11 @@ end @.. broadcast=false u=tmp + γ * z₇ if integrator.f isa SplitFunction - f2(k7, u, p, t + dt) - k7 .*= dt + f2(ks[7], u, p, t + dt) + ks[7] .*= dt OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) @.. broadcast=false u=uprev + a73 * z₃ + a74 * z₄ + a75 * z₅ + a76 * z₆ + γ * z₇ + - eb3 * k3 + eb4 * k4 + eb5 * k5 + eb6 * k6 + eb7 * k7 + eb3 * ks[3] + eb4 * ks[4] + eb5 * ks[5] + eb6 * ks[6] + eb7 * ks[7] end ################################### Finalize @@ -2147,9 +2147,9 @@ end if integrator.opts.adaptive if integrator.f isa SplitFunction @.. broadcast=false tmp=btilde3 * z₃ + btilde4 * z₄ + btilde5 * z₅ + - btilde6 * z₆ + btilde7 * z₇ + ebtilde3 * k3 + - ebtilde4 * k4 + ebtilde5 * k5 + ebtilde6 * k6 + - ebtilde7 * k7 + btilde6 * z₆ + btilde7 * z₇ + ebtilde3 * ks[3] + + ebtilde4 * ks[4] + ebtilde5 * ks[5] + ebtilde6 * ks[6] + + ebtilde7 * ks[7] else @.. broadcast=false tmp=btilde3 * z₃ + btilde4 * z₄ + btilde5 * z₅ + btilde6 * z₆ + btilde7 * z₇ @@ -2397,7 +2397,7 @@ end @muladd function perform_step!(integrator, cache::KenCarp58Cache, repeat_step = false) @unpack t, dt, uprev, u, p = integrator @unpack z₁, z₂, z₃, z₄, z₅, z₆, z₇, z₈, atmp, nlsolver = cache - @unpack k1, k2, k3, k4, k5, k6, k7, k8 = cache + @unpack ks = cache @unpack tmp = nlsolver @unpack γ, a31, a32, a41, a42, a43, a51, a52, a53, a54, a61, a62, a63, a64, a65, a71, a72, a73, a74, a75, a76, a83, a84, a85, a86, a87, c3, c4, c5, c6, c7 = cache.tab @unpack α31, α32, α41, α42, α51, α52, α61, α62, α63, α71, α72, α73, α81, α82, α83, α84, α85, α86, α87 = cache.tab @@ -2442,8 +2442,8 @@ end if integrator.f isa SplitFunction # This assumes the implicit part is cheaper than the explicit part - @.. broadcast=false k1=dt * integrator.fsalfirst - z₁ - @.. broadcast=false tmp+=ea21 * k1 + @.. broadcast=false ks[1]=dt * integrator.fsalfirst - z₁ + @.. broadcast=false tmp+=ea21 * ks[1] end nlsolver.c = 2γ @@ -2456,10 +2456,10 @@ end if integrator.f isa SplitFunction z₃ .= z₂ @.. broadcast=false u=tmp + γ * z₂ - f2(k2, u, p, t + 2γdt) - k2 .*= dt + f2(ks[2], u, p, t + 2γdt) + ks[2] .*= dt integrator.stats.nf2 += 1 - @.. broadcast=false tmp=uprev + a31 * z₁ + a32 * z₂ + ea31 * k1 + ea32 * k2 + @.. broadcast=false tmp=uprev + a31 * z₁ + a32 * z₂ + ea31 * ks[1] + ea32 * ks[2] else # Guess is from Hermite derivative on z₁ and z₂ @.. broadcast=false z₃=α31 * z₁ + α32 * z₂ @@ -2476,11 +2476,11 @@ end if integrator.f isa SplitFunction z₄ .= z₁ @.. broadcast=false u=tmp + γ * z₃ - f2(k3, u, p, t + c3 * dt) - k3 .*= dt + f2(ks[3], u, p, t + c3 * dt) + ks[3] .*= dt integrator.stats.nf2 += 1 - @.. broadcast=false tmp=uprev + a41 * z₁ + a42 * z₂ + a43 * z₃ + ea41 * k1 + - ea42 * k2 + ea43 * k3 + @.. broadcast=false tmp=uprev + a41 * z₁ + a42 * z₂ + a43 * z₃ + ea41 * ks[1] + + ea42 * ks[2] + ea43 * ks[3] else @.. broadcast=false z₄=α41 * z₁ + α42 * z₂ @.. broadcast=false tmp=uprev + a41 * z₁ + a42 * z₂ + a43 * z₃ @@ -2496,11 +2496,11 @@ end if integrator.f isa SplitFunction z₅ .= z₂ @.. broadcast=false u=tmp + γ * z₄ - f2(k4, u, p, t + c4 * dt) - k4 .*= dt + f2(ks[4], u, p, t + c4 * dt) + ks[4] .*= dt integrator.stats.nf2 += 1 @.. broadcast=false tmp=uprev + a51 * z₁ + a52 * z₂ + a53 * z₃ + a54 * z₄ + - ea51 * k1 + ea52 * k2 + ea53 * k3 + ea54 * k4 + ea51 * ks[1] + ea52 * ks[2] + ea53 * ks[3] + ea54 * ks[4] else @.. broadcast=false z₅=α51 * z₁ + α52 * z₂ @.. broadcast=false tmp=uprev + a51 * z₁ + a52 * z₂ + a53 * z₃ + a54 * z₄ @@ -2516,12 +2516,12 @@ end if integrator.f isa SplitFunction z₆ .= z₃ @.. broadcast=false u=tmp + γ * z₅ - f2(k5, u, p, t + c5 * dt) - k5 .*= dt + f2(ks[5], u, p, t + c5 * dt) + ks[5] .*= dt integrator.stats.nf2 += 1 @.. broadcast=false tmp=uprev + a61 * z₁ + a62 * z₂ + a63 * z₃ + a64 * z₄ + - a65 * z₅ + ea61 * k1 + ea62 * k2 + ea63 * k3 + ea64 * k4 + - ea65 * k5 + a65 * z₅ + ea61 * ks[1] + ea62 * ks[2] + ea63 * ks[3] + ea64 * ks[4] + + ea65 * ks[5] else @.. broadcast=false z₆=α61 * z₁ + α62 * z₂ + α63 * z₃ @.. broadcast=false tmp=uprev + a61 * z₁ + a62 * z₂ + a63 * z₃ + a64 * z₄ + a65 * z₅ @@ -2537,12 +2537,12 @@ end if integrator.f isa SplitFunction z₇ .= z₃ @.. broadcast=false u=tmp + γ * z₆ - f2(k6, u, p, t + c6 * dt) - k6 .*= dt + f2(ks[6], u, p, t + c6 * dt) + ks[6] .*= dt integrator.stats.nf2 += 1 @.. broadcast=false tmp=uprev + a71 * z₁ + a72 * z₂ + a73 * z₃ + a74 * z₄ + - a75 * z₅ + a76 * z₆ + ea71 * k1 + ea72 * k2 + ea73 * k3 + - ea74 * k4 + ea75 * k5 + ea76 * k6 + a75 * z₅ + a76 * z₆ + ea71 * ks[1] + ea72 * ks[2] + ea73 * ks[3] + + ea74 * ks[4] + ea75 * ks[5] + ea76 * ks[6] else @.. broadcast=false z₇=α71 * z₁ + α72 * z₂ + α73 * z₃ @.. broadcast=false tmp=uprev + a71 * z₁ + a72 * z₂ + a73 * z₃ + a74 * z₄ + @@ -2559,12 +2559,12 @@ end if integrator.f isa SplitFunction z₈ .= z₇ @.. broadcast=false u=tmp + γ * z₇ - f2(k7, u, p, t + c7 * dt) - k7 .*= dt + f2(ks[7], u, p, t + c7 * dt) + ks[7] .*= dt integrator.stats.nf2 += 1 @.. broadcast=false tmp=uprev + a83 * z₃ + a84 * z₄ + a85 * z₅ + a86 * z₆ + - a87 * z₇ + ea81 * k1 + ea82 * k2 + ea83 * k3 + ea84 * k4 + - ea85 * k5 + ea86 * k6 + ea87 * k7 + a87 * z₇ + ea81 * ks[1] + ea82 * ks[2] + ea83 * ks[3] + ea84 * ks[4] + + ea85 * ks[5] + ea86 * ks[6] + ea87 * ks[7] else @.. broadcast=false z₈=α81 * z₁ + α82 * z₂ + α83 * z₃ + α84 * z₄ + α85 * z₅ + α86 * z₆ + α87 * z₇ @@ -2578,12 +2578,12 @@ end @.. broadcast=false u=tmp + γ * z₈ if integrator.f isa SplitFunction - f2(k8, u, p, t + dt) - k8 .*= dt + f2(ks[8], u, p, t + dt) + ks[8] .*= dt OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) @.. broadcast=false u=uprev + a83 * z₃ + a84 * z₄ + a85 * z₅ + a86 * z₆ + a87 * z₇ + - γ * z₈ + eb3 * k3 + eb4 * k4 + eb5 * k5 + eb6 * k6 + - eb7 * k7 + eb8 * k8 + γ * z₈ + eb3 * ks[3] + eb4 * ks[4] + eb5 * ks[5] + eb6 * ks[6] + + eb7 * ks[7] + eb8 * ks[8] end ################################### Finalize @@ -2592,8 +2592,8 @@ end if integrator.f isa SplitFunction @.. broadcast=false tmp=btilde3 * z₃ + btilde4 * z₄ + btilde5 * z₅ + btilde6 * z₆ + btilde7 * z₇ + btilde8 * z₈ + - ebtilde3 * k3 + ebtilde4 * k4 + ebtilde5 * k5 + - ebtilde6 * k6 + ebtilde7 * k7 + ebtilde8 * k8 + ebtilde3 * ks[3] + ebtilde4 * ks[4] + ebtilde5 * ks[5] + + ebtilde6 * ks[6] + ebtilde7 * ks[7] + ebtilde8 * ks[8] else @.. broadcast=false tmp=btilde3 * z₃ + btilde4 * z₄ + btilde5 * z₅ + btilde6 * z₆ + btilde7 * z₇ + btilde8 * z₈ @@ -2619,4 +2619,4 @@ end else @.. broadcast=false integrator.fsallast=z₈ / dt end -end +end \ No newline at end of file diff --git a/lib/OrdinaryDiffEqSDIRK/src/sdirk_perform_step.jl b/lib/OrdinaryDiffEqSDIRK/src/sdirk_perform_step.jl index a0f33020dc..bd9bfb4aac 100644 --- a/lib/OrdinaryDiffEqSDIRK/src/sdirk_perform_step.jl +++ b/lib/OrdinaryDiffEqSDIRK/src/sdirk_perform_step.jl @@ -336,7 +336,7 @@ end @muladd function perform_step!(integrator, cache::TRBDF2ConstantCache, repeat_step = false) @unpack t, dt, uprev, u, f, p = integrator - @unpack γ, d, ω, btilde1, btilde2, btilde3, α1, α2 = cache.tab + @unpack γ, d, ω, btilde, α = cache.tab nlsolver = cache.nlsolver alg = unwrap_alg(integrator, true) markfirststage!(nlsolver) @@ -358,7 +358,7 @@ end ################################## Solve BDF2 Step ### Initial Guess From Shampine - z = α1 * zprev + α2 * zᵧ + z = α[1] * zprev + α[2] * zᵧ nlsolver.z = z nlsolver.c = 1 @@ -371,7 +371,7 @@ end ################################### Finalize if integrator.opts.adaptive - tmp = btilde1 * zprev + btilde2 * zᵧ + btilde3 * z + tmp = btilde[1] * zprev + btilde[2] * zᵧ + btilde[3] * z if isnewton(nlsolver) && alg.smooth_est # From Shampine integrator.stats.nsolve += 1 est = _reshape(get_W(nlsolver) \ _vec(tmp), axes(tmp)) @@ -395,7 +395,7 @@ end @unpack z, tmp = nlsolver W = isnewton(nlsolver) ? get_W(nlsolver) : nothing b = nlsolver.ztmp - @unpack γ, d, ω, btilde1, btilde2, btilde3, α1, α2 = cache.tab + @unpack γ, d, ω, btilde, α = cache.tab alg = unwrap_alg(integrator, true) # FSAL @@ -415,7 +415,7 @@ end ################################## Solve BDF2 Step ### Initial Guess From Shampine - @.. broadcast=false z=α1 * zprev + α2 * zᵧ + @.. broadcast=false z=α[1] * zprev + α[2] * zᵧ @.. broadcast=false tmp=uprev + ω * zprev + ω * zᵧ nlsolver.c = 1 isnewton(nlsolver) && set_new_W!(nlsolver, false) @@ -429,7 +429,7 @@ end ################################### Finalize if integrator.opts.adaptive - @.. broadcast=false tmp=btilde1 * zprev + btilde2 * zᵧ + btilde3 * z + @.. broadcast=false tmp=btilde[1] * zprev + btilde[2] * zᵧ + btilde[3] * z if alg.smooth_est && isnewton(nlsolver) # From Shampine est = nlsolver.cache.dz linres = dolinsolve(integrator, nlsolver.cache.linsolve; b = _vec(tmp), @@ -453,7 +453,7 @@ end @unpack z, tmp = nlsolver W = isnewton(nlsolver) ? get_W(nlsolver) : nothing b = nlsolver.ztmp - @unpack γ, d, ω, btilde1, btilde2, btilde3, α1, α2 = cache.tab + @unpack γ, d, ω, btilde, α = cache.tab alg = unwrap_alg(integrator, true) # FSAL @@ -478,7 +478,7 @@ end ### Initial Guess From Shampine @inbounds @simd ivdep for i in eachindex(u) - z[i] = α1 * zprev[i] + α2 * zᵧ[i] + z[i] = α[1] * zprev[i] + α[2] * zᵧ[i] end @inbounds @simd ivdep for i in eachindex(u) tmp[i] = uprev[i] + ω * zprev[i] + ω * zᵧ[i] @@ -498,7 +498,7 @@ end if integrator.opts.adaptive @inbounds @simd ivdep for i in eachindex(u) - tmp[i] = btilde1 * zprev[i] + btilde2 * zᵧ[i] + btilde3 * z[i] + tmp[i] = btilde[1] * zprev[i] + btilde[2] * zᵧ[i] + btilde[3] * z[i] end if alg.smooth_est && isnewton(nlsolver) # From Shampine est = nlsolver.cache.dz diff --git a/lib/OrdinaryDiffEqSDIRK/src/sdirk_tableaus.jl b/lib/OrdinaryDiffEqSDIRK/src/sdirk_tableaus.jl index ed95cef957..be940530d1 100644 --- a/lib/OrdinaryDiffEqSDIRK/src/sdirk_tableaus.jl +++ b/lib/OrdinaryDiffEqSDIRK/src/sdirk_tableaus.jl @@ -2,11 +2,8 @@ struct TRBDF2Tableau{T, T2} γ::T2 d::T ω::T - btilde1::T - btilde2::T - btilde3::T - α1::T - α2::T + btilde::Vector{T} + α::Vector{T} end #= @@ -36,12 +33,9 @@ function TRBDF2Tableau(T, T2) γ = convert(T2, 2 - sqrt(2)) d = convert(T, 1 - sqrt(2) / 2) ω = convert(T, sqrt(2) / 4) - btilde1 = convert(T, (1 - sqrt(2)) / 3) - btilde2 = convert(T, 1 // 3) - btilde3 = convert(T, (sqrt(2) - 2) / 3) - α1 = convert(T, -sqrt(2) / 2) - α2 = convert(T, 1 + sqrt(2) / 2) - TRBDF2Tableau(γ, d, ω, btilde1, btilde2, btilde3, α1, α2) + btilde = convert.(T, [(1 - sqrt(2)) / 3, 1 // 3, (sqrt(2) - 2) / 3]) + α = convert.(T, [-sqrt(2) / 2, 1 + sqrt(2) / 2]) + TRBDF2Tableau(γ, d, ω, btilde, α) end struct ESDIRK4Tableau{T, T2}