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.9"
version = "2.8.10"

[deps]
FastBroadcast = "7034ab61-46d4-4ed7-9d0f-46aef9175898"
Expand Down
8 changes: 4 additions & 4 deletions lib/OrdinaryDiffEqFIRK/src/algorithms.jl
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ function RadauIIA3(;
concrete_jac = nothing,
linsolve = nothing,
extrapolant = :dense, fast_convergence_cutoff = 1 // 5,
new_W_γdt_cutoff = 1 // 5,
new_W_γdt_cutoff = 0 // 1,
κ = nothing, maxiters = 10,
step_limiter! = trivial_limiter!
)
Expand Down Expand Up @@ -99,7 +99,7 @@ function RadauIIA5(;
concrete_jac = nothing,
linsolve = nothing,
extrapolant = :dense, fast_convergence_cutoff = 1 // 5,
new_W_γdt_cutoff = 1 // 5,
new_W_γdt_cutoff = 0 // 1,
κ = nothing, maxiters = 10, smooth_est = true,
step_limiter! = trivial_limiter!
)
Expand Down Expand Up @@ -148,7 +148,7 @@ function RadauIIA9(;
concrete_jac = nothing,
linsolve = nothing,
extrapolant = :dense, fast_convergence_cutoff = 1 // 5,
new_W_γdt_cutoff = 1 // 5,
new_W_γdt_cutoff = 0 // 1,
κ = nothing, maxiters = 10, smooth_est = true,
step_limiter! = trivial_limiter!
)
Expand Down Expand Up @@ -200,7 +200,7 @@ function AdaptiveRadau(;
min_order = 5, max_order = 13, threading = false,
linsolve = nothing,
extrapolant = :dense, fast_convergence_cutoff = 1 // 5,
new_W_γdt_cutoff = 1 // 5,
new_W_γdt_cutoff = 0 // 1,
κ = nothing, maxiters = 10, smooth_est = true,
step_limiter! = trivial_limiter!
)
Expand Down
4 changes: 4 additions & 0 deletions lib/OrdinaryDiffEqFIRK/src/firk_perform_step.jl
Original file line number Diff line number Diff line change
Expand Up @@ -447,6 +447,7 @@ end
(new_jac = do_newJ(integrator, alg, cache, repeat_step)) &&
(firk_new_J!(J, W1, integrator, cache); cache.W_γdt = dt)
new_W = do_newW(integrator, alg, new_jac, cache.W_γdt)
new_W && (cache.W_γdt = dt)
if is_lazy_W(W1)
set_W_gamma!(W1, αdt + βdt * im)
integrator.stats.nw += 1
Expand Down Expand Up @@ -825,6 +826,7 @@ end
(new_jac = do_newJ(integrator, alg, cache, repeat_step)) &&
(firk_new_J!(J, W1, integrator, cache, W2); cache.W_γdt = dt)
new_W = do_newW(integrator, alg, new_jac, cache.W_γdt)
new_W && (cache.W_γdt = dt)
if is_lazy_W(W1)
set_W_gamma!(W1, γdt)
set_W_gamma!(W2, αdt + βdt * im)
Expand Down Expand Up @@ -1403,6 +1405,7 @@ end
(new_jac = do_newJ(integrator, alg, cache, repeat_step)) &&
(firk_new_J!(J, W1, integrator, cache, W2, W3); cache.W_γdt = dt)
new_W = do_newW(integrator, alg, new_jac, cache.W_γdt)
new_W && (cache.W_γdt = dt)
if is_lazy_W(W1)
set_W_gamma!(W1, γdt)
set_W_gamma!(W2, α1dt + β1dt * im)
Expand Down Expand Up @@ -2052,6 +2055,7 @@ end
(new_jac = do_newJ(integrator, alg, cache, repeat_step)) &&
(firk_new_J!(J, W1, integrator, cache, W2); cache.W_γdt = dt)
new_W = do_newW(integrator, alg, new_jac, cache.W_γdt)
new_W && (cache.W_γdt = dt)
if is_lazy_W(W1)
set_W_gamma!(W1, γdt)
for i in 1:((num_stages - 1) ÷ 2)
Expand Down
13 changes: 13 additions & 0 deletions lib/OrdinaryDiffEqFIRK/test/ode_firk_tests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -339,3 +339,16 @@ end
)
@test @inferred(OrdinaryDiffEqCore.get_current_adaptive_order(integ.alg.algs[2], integ.cache)) isa Int
end

@testset "In-place FIRK stays accurate after a callback" begin
f!(du, u, p, t) = (du[1] = -3u[1] + 1; nothing)
exact(t) = (1 - exp(-3t)) / 3
callback = DiscreteCallback((u, t, integrator) -> t == 0.5, integrator -> nothing)
for alg in (RadauIIA5(), RadauIIA9(), AdaptiveRadau())
sol = solve(
ODEProblem(f!, [0.0], (0.0, 1.0)), alg; reltol = 1.0e-8, abstol = 1.0e-11,
callback, tstops = [0.5]
)
@test maximum(abs(u[1] - exact(t)) for (t, u) in zip(sol.t, sol.u)) < 1.0e-8
end
end
Loading