From 9b2890fa070eb9fe46af1d11cc515d90822bb4fd Mon Sep 17 00:00:00 2001 From: Avik Pal Date: Mon, 30 Oct 2023 13:19:31 -0400 Subject: [PATCH] Extend the API a bit more --- Project.toml | 2 +- src/DiffEqBase.jl | 8 ++++++-- src/termination_conditions.jl | 9 +++++++-- 3 files changed, 14 insertions(+), 5 deletions(-) diff --git a/Project.toml b/Project.toml index a41b61377..1a4f33d1a 100644 --- a/Project.toml +++ b/Project.toml @@ -1,7 +1,7 @@ name = "DiffEqBase" uuid = "2b5f629d-d688-5b77-993f-72d75c75574e" authors = ["Chris Rackauckas "] -version = "6.135.0" +version = "6.136.0" [deps] ArrayInterface = "4fba245c-0d91-5ea0-9b3e-6abc04ee57a9" diff --git a/src/DiffEqBase.jl b/src/DiffEqBase.jl index 0ece946cb..c73daadc0 100644 --- a/src/DiffEqBase.jl +++ b/src/DiffEqBase.jl @@ -171,9 +171,13 @@ export initialize!, finalize! export SensitivityADPassThrough +export SteadyStateDiffEqTerminationMode, SimpleNonlinearSolveTerminationMode, + NormTerminationMode, RelTerminationMode, RelNormTerminationMode, AbsTerminationMode, + AbsNormTerminationMode, RelSafeTerminationMode, AbsSafeTerminationMode, + RelSafeBestTerminationMode, AbsSafeBestTerminationMode +# Deprecated API export NLSolveTerminationMode, - NLSolveSafeTerminationOptions, NLSolveTerminationCondition, - NLSolveSafeTerminationResult + NLSolveSafeTerminationOptions, NLSolveTerminationCondition, NLSolveSafeTerminationResult export KeywordArgError, KeywordArgWarn, KeywordArgSilent diff --git a/src/termination_conditions.jl b/src/termination_conditions.jl index a24c1a434..487bb8802 100644 --- a/src/termination_conditions.jl +++ b/src/termination_conditions.jl @@ -55,6 +55,10 @@ mutable struct NonlinearTerminationModeCache{uType, T, nsteps::Int end +get_termination_mode(cache::NonlinearTerminationModeCache) = cache.mode +get_abstol(cache::NonlinearTerminationModeCache) = cache.abstol +get_reltol(cache::NonlinearTerminationModeCache) = cache.reltol + function __update_u!!(cache::NonlinearTerminationModeCache, u) cache.u === nothing && return if ArrayInterface.can_setindex(cache.u) @@ -73,8 +77,9 @@ function _get_tolerance(::Nothing, ::Type{T}) where {T} return _get_tolerance(η, T) end -function SciMLBase.init(u::AbstractArray{T}, mode::AbstractNonlinearTerminationMode; - abstol = nothing, reltol = nothing, kwargs...) where {T} +function SciMLBase.init(u::Union{AbstractArray{T}, T}, + mode::AbstractNonlinearTerminationMode; abstol = nothing, reltol = nothing, + kwargs...) where {T <: Number} abstol = _get_tolerance(abstol, T) reltol = _get_tolerance(reltol, T) best_value = __cvt_real(T, Inf)