Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/OrdinaryDiffEqFIRK/Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "OrdinaryDiffEqFIRK"
uuid = "5960d6e9-dd7a-4743-88e7-cf307b64f125"
authors = ["ParamThakkar123 <paramthakkar864@gmail.com>"]
version = "2.8.10"
version = "2.8.11"

[deps]
FastBroadcast = "7034ab61-46d4-4ed7-9d0f-46aef9175898"
Expand Down
98 changes: 39 additions & 59 deletions lib/OrdinaryDiffEqFIRK/src/firk_perform_step.jl
Original file line number Diff line number Diff line change
Expand Up @@ -419,10 +419,8 @@ end

if OrdinaryDiffEqCore.get_EEst(integrator) <= oneunit(OrdinaryDiffEqCore.get_EEst(integrator))
cache.dtprev = dt
if alg.extrapolant != :constant
integrator.k[3] = z1
integrator.k[4] = z2
end
integrator.k[3] = z1
integrator.k[4] = z2
end

integrator.fsallast = f(u, p, t + dt)
Expand Down Expand Up @@ -589,10 +587,8 @@ end

if OrdinaryDiffEqCore.get_EEst(integrator) <= oneunit(OrdinaryDiffEqCore.get_EEst(integrator))
cache.dtprev = dt
if alg.extrapolant != :constant
integrator.k[3] .= z1
integrator.k[4] .= z2
end
integrator.k[3] .= z1
integrator.k[4] .= z2
end

f(fsallast, u, p, t + dt)
Expand Down Expand Up @@ -787,11 +783,9 @@ end

if OrdinaryDiffEqCore.get_EEst(integrator) <= oneunit(OrdinaryDiffEqCore.get_EEst(integrator))
cache.dtprev = dt
if alg.extrapolant != :constant
integrator.k[3] = z1
integrator.k[4] = z2
integrator.k[5] = z3
end
integrator.k[3] = z1
integrator.k[4] = z2
integrator.k[5] = z3
end

integrator.fsallast = f(u, p, t + dt)
Expand Down Expand Up @@ -1055,11 +1049,9 @@ end

if OrdinaryDiffEqCore.get_EEst(integrator) <= oneunit(OrdinaryDiffEqCore.get_EEst(integrator))
cache.dtprev = dt
if alg.extrapolant != :constant
integrator.k[3] .= z1
integrator.k[4] .= z2
integrator.k[5] .= z3
end
integrator.k[3] .= z1
integrator.k[4] .= z2
integrator.k[5] .= z3
end

f(fsallast, u, p, t + dt)
Expand Down Expand Up @@ -1346,13 +1338,11 @@ end

if OrdinaryDiffEqCore.get_EEst(integrator) <= oneunit(OrdinaryDiffEqCore.get_EEst(integrator))
cache.dtprev = dt
if alg.extrapolant != :constant
integrator.k[3] = z1
integrator.k[4] = z2
integrator.k[5] = z3
integrator.k[6] = z4
integrator.k[7] = z5
end
integrator.k[3] = z1
integrator.k[4] = z2
integrator.k[5] = z3
integrator.k[6] = z4
integrator.k[7] = z5
end

integrator.fsallast = f(u, p, t + dt)
Expand Down Expand Up @@ -1739,13 +1729,11 @@ end

if OrdinaryDiffEqCore.get_EEst(integrator) <= oneunit(OrdinaryDiffEqCore.get_EEst(integrator))
cache.dtprev = dt
if alg.extrapolant != :constant
integrator.k[3] .= z1
integrator.k[4] .= z2
integrator.k[5] .= z3
integrator.k[6] .= z4
integrator.k[7] .= z5
end
integrator.k[3] .= z1
integrator.k[4] .= z2
integrator.k[5] .= z3
integrator.k[6] .= z4
integrator.k[7] .= z5
end

f(fsallast, u, p, t + dt)
Expand Down Expand Up @@ -2004,17 +1992,15 @@ end

if OrdinaryDiffEqCore.get_EEst(integrator) <= oneunit(OrdinaryDiffEqCore.get_EEst(integrator))
cache.dtprev = dt
if alg.extrapolant != :constant
cmax = tabs[end].c
for j in eachindex(cmax)
weight = _stage_weight(c, 1, cmax[j])
kj = @.. weight * z[1]
for i in 2:num_stages
weight = _stage_weight(c, i, cmax[j])
kj = @.. kj + weight * z[i]
end
integrator.k[j + 2] = kj
cmax = tabs[end].c
for j in eachindex(cmax)
weight = _stage_weight(c, 1, cmax[j])
kj = @.. weight * z[1]
for i in 2:num_stages
weight = _stage_weight(c, i, cmax[j])
kj = @.. kj + weight * z[i]
end
integrator.k[j + 2] = kj
end
end

Expand Down Expand Up @@ -2360,15 +2346,13 @@ end

if OrdinaryDiffEqCore.get_EEst(integrator) <= oneunit(OrdinaryDiffEqCore.get_EEst(integrator))
cache.dtprev = dt
if alg.extrapolant != :constant
cmax = tabs[end].c
for j in eachindex(cmax)
weight = _stage_weight(c, 1, cmax[j])
@.. integrator.k[j + 2] = weight * z[1]
for i in 2:num_stages
weight = _stage_weight(c, i, cmax[j])
@.. integrator.k[j + 2] += weight * z[i]
end
cmax = tabs[end].c
for j in eachindex(cmax)
weight = _stage_weight(c, 1, cmax[j])
@.. integrator.k[j + 2] = weight * z[1]
for i in 2:num_stages
weight = _stage_weight(c, i, cmax[j])
@.. integrator.k[j + 2] += weight * z[i]
end
end
end
Expand Down Expand Up @@ -2610,10 +2594,8 @@ end

if OrdinaryDiffEqCore.get_EEst(integrator) <= oneunit(OrdinaryDiffEqCore.get_EEst(integrator))
cache.dtprev = dt
if alg.extrapolant != :constant
for i in 1:num_stages
integrator.k[i + 2] = z[i]
end
for i in 1:num_stages
integrator.k[i + 2] = z[i]
end
end

Expand Down Expand Up @@ -2798,10 +2780,8 @@ end

if OrdinaryDiffEqCore.get_EEst(integrator) <= oneunit(OrdinaryDiffEqCore.get_EEst(integrator))
cache.dtprev = dt
if alg.extrapolant != :constant
for i in 1:num_stages
integrator.k[i + 2] .= z[i]
end
for i in 1:num_stages
integrator.k[i + 2] .= z[i]
end
end

Expand Down
12 changes: 12 additions & 0 deletions lib/OrdinaryDiffEqFIRK/test/ode_firk_tests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -354,3 +354,15 @@ end
)
@test @inferred(OrdinaryDiffEqCore.get_current_adaptive_order(integ.alg.algs[2], integ.cache)) isa Int
end

@testset "Dense output with extrapolant = :constant" begin
f!(du, u, p, t) = (du .= cos(t) .* u; nothing)
f(u, p, t) = cos(t) .* u
exact(t) = exp(sin(t)) .* [1.0, 2.0]
for prob in (ODEProblem(f!, [1.0, 2.0], (0.0, 4.0)), ODEProblem(f, [1.0, 2.0], (0.0, 4.0))),
alg in (RadauIIA3, RadauIIA5, RadauIIA9, AdaptiveRadau, GaussLegendre)

sol = solve(prob, alg(extrapolant = :constant); reltol = 1.0e-8, abstol = 1.0e-10, saveat = 0.01)
@test maximum(maximum(abs.(u .- exact(t))) for (t, u) in zip(sol.t, sol.u)) < 1.0e-5
end
end
Loading