diff --git a/Project.toml b/Project.toml index 842359e..a7294e9 100644 --- a/Project.toml +++ b/Project.toml @@ -12,15 +12,17 @@ LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e" ODEInterface = "54ca160b-1b9f-5127-a996-1867f4bc2a2c" Reexport = "189a3867-3050-52da-a836-e630ba90ab69" SciMLBase = "0bca4576-84f4-4d90-8ffe-ffa030f20462" +SciMLLogging = "a6db7da4-7206-11f0-1eab-35f2a5dbe1d1" [compat] Compat = "2.2, 3.0, 4" DataStructures = "0.18, 0.19" -DiffEqBase = "6.122" +DiffEqBase = "6.217" FunctionWrappers = "1.0" ODEInterface = "0.5" Reexport = "0.2, 1.0" SciMLBase = "1.73, 2, 3.1" +SciMLLogging = "1.9.1" julia = "1.6" [extras] diff --git a/src/ODEInterfaceDiffEq.jl b/src/ODEInterfaceDiffEq.jl index f6b5005..ae590f1 100644 --- a/src/ODEInterfaceDiffEq.jl +++ b/src/ODEInterfaceDiffEq.jl @@ -14,6 +14,8 @@ module ODEInterfaceDiffEq using LinearAlgebra: I using SciMLBase: CallbackSet, ReturnCode, VectorContinuousCallback, check_keywords, warn_compat + using SciMLLogging: SciMLLogging, @SciMLMessage + import DiffEqBase: DEVerbosity import DiffEqBase: solve, initialize!, savevalues! diff --git a/src/solve.jl b/src/solve.jl index 80a721f..c7bd374 100644 --- a/src/solve.jl +++ b/src/solve.jl @@ -15,18 +15,20 @@ function DiffEqBase.__solve( ) where {uType, tuptType, isinplace, AlgType <: ODEInterfaceAlgorithm} tType = eltype(tuptType) + verbose_spec = DiffEqBase._process_verbose_param(verbose) isstiff = alg isa ODEInterfaceImplicitAlgorithm - if verbose - warned = !isempty(kwargs) && check_keywords(alg, kwargs, warnlist) - if !(prob.f isa DiffEqBase.AbstractParameterizedFunction) && isstiff - if DiffEqBase.has_tgrad(prob.f) - @warn("Explicit t-gradient given to this stiff solver is ignored.") - warned = true - end + warned = !isempty(kwargs) && check_keywords(alg, kwargs, warnlist) + if !(prob.f isa DiffEqBase.AbstractParameterizedFunction) && isstiff + if DiffEqBase.has_tgrad(prob.f) + @SciMLMessage( + "Explicit t-gradient given to this stiff solver is ignored.", + verbose_spec, :mismatched_input_output_type + ) + warned = true end - warned && warn_compat() end + warned && warn_compat() callbacks_internal = CallbackSet(callback) @@ -120,7 +122,10 @@ function DiffEqBase.__solve( o[:OUTPUTFCN] = outputfcn if !(callbacks_internal.continuous_callbacks isa Tuple{}) || !isempty(saveat) if alg isa Union{ddeabm, ddebdf} - @warn("saveat and continuous callbacks ignored for ddeabm and ddebdf") + @SciMLMessage( + "saveat and continuous callbacks ignored for ddeabm and ddebdf", + verbose_spec, :dense_output_saveat + ) o[:OUTPUTMODE] = ODEInterface.OUTPUTFCN_WODENSE else o[:OUTPUTMODE] = ODEInterface.OUTPUTFCN_DENSE @@ -238,16 +243,16 @@ function DiffEqBase.__solve( if retcode < 0 if retcode == -1 - verbose && @warn("Input is not consistent.") + @SciMLMessage("Input is not consistent.", verbose_spec, :inconsistent_input) return_retcode = ReturnCode.Failure elseif retcode == -2 - verbose && @warn("Interrupted. Larger maxiters is needed.") + @SciMLMessage("Interrupted. Larger maxiters is needed.", verbose_spec, :max_iters) return_retcode = ReturnCode.MaxIters elseif retcode == -3 - verbose && @warn("Step size went too small.") + @SciMLMessage("Step size went too small.", verbose_spec, :dt_min_unstable) return_retcode = ReturnCode.DtLessThanMin elseif retcode == -4 - verbose && @warn("Interrupted. Problem is probably stiff.") + @SciMLMessage("Interrupted. Problem is probably stiff.", verbose_spec, :stiff_detection) return_retcode = ReturnCode.Unstable end else