Skip to content
Merged
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/ImplicitDiscreteSolve/Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "ImplicitDiscreteSolve"
uuid = "3263718b-31ed-49cf-8a0f-35a466e8af96"
authors = ["vyudu <vincent.duyuan@gmail.com>"]
version = "2.1.3"
version = "2.1.4"

[deps]
CommonSolve = "38540f10-b2f7-11e9-35d8-d573e4eb0ff2"
Expand Down
10 changes: 5 additions & 5 deletions lib/ImplicitDiscreteSolve/src/controller.jl
Original file line number Diff line number Diff line change
Expand Up @@ -112,14 +112,14 @@ function OrdinaryDiffEqCore.step_reject_controller!(
return
end

function _accept_kantorovich_step(controller, Θks)
return !controller.strict || all(Θk -> Θk <= controller.Θreject, Θks)
end

function OrdinaryDiffEqCore.accept_step_controller(integrator, cache::KantorovichTypeControllerCache, alg)
(; controller) = cache
(; Θks) = integrator.cache
if controller.strict
return all(controller.Θreject .< Θks)
else
return true
end
return _accept_kantorovich_step(controller, Θks)
end

function OrdinaryDiffEqCore.sync_controllers!(cache1::KantorovichTypeControllerCache, cache2::KantorovichTypeControllerCache)
Expand Down
14 changes: 14 additions & 0 deletions lib/ImplicitDiscreteSolve/test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,20 @@ if TEST_GROUP != "QA"
@test idsol.retcode == ReturnCode.Success
end

@testset "Kantorovich strict acceptance" begin
strict = ImplicitDiscreteSolve.KantorovichTypeController(;
Θmin = 1 // 8, p = 1
)
@test ImplicitDiscreteSolve._accept_kantorovich_step(strict, Float64[])
@test ImplicitDiscreteSolve._accept_kantorovich_step(strict, [0.2, 0.95])
@test !ImplicitDiscreteSolve._accept_kantorovich_step(strict, [0.2, 0.951])

nonstrict = ImplicitDiscreteSolve.KantorovichTypeController(;
Θmin = 1 // 8, p = 1, strict = false
)
@test ImplicitDiscreteSolve._accept_kantorovich_step(nonstrict, [Inf])
end

@testset "Handle nothing in u0" begin
emptyiip(residual, u_next, u, p, t) = nothing
emptyoop(u_next, u, p, t) = nothing
Expand Down
Loading