Skip to content

Commit f32e100

Browse files
Fix strict Kantorovich step acceptance
Co-Authored-By: Chris Rackauckas <accounts@chrisrackauckas.com>
1 parent d96863b commit f32e100

3 files changed

Lines changed: 20 additions & 6 deletions

File tree

lib/ImplicitDiscreteSolve/Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name = "ImplicitDiscreteSolve"
22
uuid = "3263718b-31ed-49cf-8a0f-35a466e8af96"
33
authors = ["vyudu <vincent.duyuan@gmail.com>"]
4-
version = "2.1.3"
4+
version = "2.1.4"
55

66
[deps]
77
CommonSolve = "38540f10-b2f7-11e9-35d8-d573e4eb0ff2"

lib/ImplicitDiscreteSolve/src/controller.jl

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -112,14 +112,14 @@ function OrdinaryDiffEqCore.step_reject_controller!(
112112
return
113113
end
114114

115+
function _accept_kantorovich_step(controller, Θks)
116+
return !controller.strict || all(Θk -> Θk <= controller.Θreject, Θks)
117+
end
118+
115119
function OrdinaryDiffEqCore.accept_step_controller(integrator, cache::KantorovichTypeControllerCache, alg)
116120
(; controller) = cache
117121
(; Θks) = integrator.cache
118-
if controller.strict
119-
return all(controller.Θreject .< Θks)
120-
else
121-
return true
122-
end
122+
return _accept_kantorovich_step(controller, Θks)
123123
end
124124

125125
function OrdinaryDiffEqCore.sync_controllers!(cache1::KantorovichTypeControllerCache, cache2::KantorovichTypeControllerCache)

lib/ImplicitDiscreteSolve/test/runtests.jl

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,20 @@ if TEST_GROUP != "QA"
9292
@test idsol.retcode == ReturnCode.Success
9393
end
9494

95+
@testset "Kantorovich strict acceptance" begin
96+
strict = ImplicitDiscreteSolve.KantorovichTypeController(;
97+
Θmin = 1 // 8, p = 1
98+
)
99+
@test ImplicitDiscreteSolve._accept_kantorovich_step(strict, Float64[])
100+
@test ImplicitDiscreteSolve._accept_kantorovich_step(strict, [0.2, 0.95])
101+
@test !ImplicitDiscreteSolve._accept_kantorovich_step(strict, [0.2, 0.951])
102+
103+
nonstrict = ImplicitDiscreteSolve.KantorovichTypeController(;
104+
Θmin = 1 // 8, p = 1, strict = false
105+
)
106+
@test ImplicitDiscreteSolve._accept_kantorovich_step(nonstrict, [Inf])
107+
end
108+
95109
@testset "Handle nothing in u0" begin
96110
emptyiip(residual, u_next, u, p, t) = nothing
97111
emptyoop(u_next, u, p, t) = nothing

0 commit comments

Comments
 (0)