diff --git a/lib/OrdinaryDiffEqCore/src/OrdinaryDiffEqCore.jl b/lib/OrdinaryDiffEqCore/src/OrdinaryDiffEqCore.jl index 3a262c420d..37ba3daaaf 100644 --- a/lib/OrdinaryDiffEqCore/src/OrdinaryDiffEqCore.jl +++ b/lib/OrdinaryDiffEqCore/src/OrdinaryDiffEqCore.jl @@ -61,7 +61,7 @@ using DiffEqBase: check_error!, @def, _vec, _reshape using FastBroadcast: @.., True, False using SciMLBase: NoInit, CheckInit, OverrideInit, AbstractDEProblem, _unwrap_val, - ODEAliasSpecifier + ODEAliasSpecifier, @SciMLMessage, ODEVerbosity, Verbosity import SciMLBase: AbstractNonlinearProblem, alg_order, LinearAliasSpecifier diff --git a/lib/OrdinaryDiffEqCore/src/composite_algs.jl b/lib/OrdinaryDiffEqCore/src/composite_algs.jl index 6beec535d5..16e3ebe710 100644 --- a/lib/OrdinaryDiffEqCore/src/composite_algs.jl +++ b/lib/OrdinaryDiffEqCore/src/composite_algs.jl @@ -52,8 +52,12 @@ function (AS::AutoSwitchCache)(integrator) if (!AS.is_stiffalg && AS.count > AS.maxstiffstep) integrator.dt = dt * AS.dtfac AS.is_stiffalg = true + SciMLBase.@SciMLMessage("Algorithm was switched to $(nameof(typeof(integrator.alg.algs[Int(AS.current) + 1]))) at t = $(integrator.t).", + integrator.opts.verbose, :alg_switch, :performance) elseif (AS.is_stiffalg && AS.count < -AS.maxnonstiffstep) integrator.dt = dt / AS.dtfac + SciMLBase.@SciMLMessage("Algorithm was switched to $(nameof(typeof(integrator.alg.algs[1]))) at t = $(integrator.t).", + integrator.opts.verbose, :alg_switch, :performance) AS.is_stiffalg = false end AS.current = Int(AS.is_stiffalg) + 1 diff --git a/lib/OrdinaryDiffEqCore/src/initdt.jl b/lib/OrdinaryDiffEqCore/src/initdt.jl index ee223b75ec..59bd5d6403 100644 --- a/lib/OrdinaryDiffEqCore/src/initdt.jl +++ b/lib/OrdinaryDiffEqCore/src/initdt.jl @@ -128,9 +128,8 @@ # because it also checks if partials are NaN # https://discourse.julialang.org/t/incorporating-forcing-functions-in-the-ode-model/70133/26 if isnan(d₁) - if integrator.opts.verbose - @warn("First function call produced NaNs. Exiting. Double check that none of the initial conditions, parameters, or timespan values are NaN.") - end + @SciMLMessage("First function call produced NaNs. Exiting. Double check that none of the initial conditions, parameters, or timespan values are NaN.", + integrator.opts.verbose, :init_NaN, :error_control) return tdir * dtmin end @@ -249,8 +248,10 @@ end d₀ = internalnorm(u0 ./ sk, t) f₀ = f(u0, p, t) - if integrator.opts.verbose && any(x -> any(isnan, x), f₀) - @warn("First function call produced NaNs. Exiting. Double check that none of the initial conditions, parameters, or timespan values are NaN.") + + if any(x -> any(isnan, x), f₀) + @SciMLMessage("First function call produced NaNs. Exiting. Double check that none of the initial conditions, parameters, or timespan values are NaN.", + integrator.opts.verbose, :init_NaN, :error_control) end inferredtype = Base.promote_op(/, typeof(u0), typeof(oneunit(t))) diff --git a/lib/OrdinaryDiffEqCore/src/integrators/type.jl b/lib/OrdinaryDiffEqCore/src/integrators/type.jl index 1f9bef031d..4311cdfafc 100644 --- a/lib/OrdinaryDiffEqCore/src/integrators/type.jl +++ b/lib/OrdinaryDiffEqCore/src/integrators/type.jl @@ -41,7 +41,7 @@ mutable struct DEOptions{absType, relType, QT, tType, Controller, F1, F2, F3, F4 callback::F4 isoutofdomain::F5 unstable_check::F7 - verbose::Bool + verbose::ODEVerbosity calck::Bool force_dtmin::Bool advance_to_tstop::Bool diff --git a/lib/OrdinaryDiffEqCore/src/solve.jl b/lib/OrdinaryDiffEqCore/src/solve.jl index 570fbbd8d2..e0f7605065 100644 --- a/lib/OrdinaryDiffEqCore/src/solve.jl +++ b/lib/OrdinaryDiffEqCore/src/solve.jl @@ -54,7 +54,7 @@ function DiffEqBase.__init( internalopnorm = LinearAlgebra.opnorm, isoutofdomain = ODE_DEFAULT_ISOUTOFDOMAIN, unstable_check = ODE_DEFAULT_UNSTABLE_CHECK, - verbose = true, + verbose = ODEVerbosity(Verbosity.Default()), timeseries_errors = true, dense_errors = false, advance_to_tstop = false, @@ -102,8 +102,9 @@ function DiffEqBase.__init( prob.f.mass_matrix isa AbstractMatrix && all(isequal(0), prob.f.mass_matrix) # technically this should also warn for zero operators but those are hard to check for - if (dense || !isempty(saveat)) && verbose - @warn("Rosenbrock methods on equations without differential states do not bound the error on interpolations.") + if (dense || !isempty(saveat)) + @SciMLMessage("Rosenbrock methods on equations without differential states do not bound the error on interpolations.", + verbose, :rosenbrock_no_differential_states, :error_control) end end @@ -114,7 +115,8 @@ function DiffEqBase.__init( end if !isempty(saveat) && dense - @warn("Dense output is incompatible with saveat. Please use the SavingCallback from the Callback Library to mix the two behaviors.") + @SciMLMessage("Dense output is incompatible with saveat. Please use the SavingCallback from the Callback Library to mix the two behaviors.", + verbose, :dense_output_saveat, :error_control) end progress && @logmsg(LogLevel(-1), progress_name, _id=progress_id, progress=0) @@ -650,9 +652,8 @@ function handle_dt!(integrator) error("Automatic dt setting has the wrong sign. Exiting. Please report this error.") end if isnan(integrator.dt) - if integrator.opts.verbose - @warn("Automatic dt set the starting dt as NaN, causing instability. Exiting.") - end + @SciMLMessage("Automatic dt set the starting dt as NaN, causing instability. Exiting.", + integrator.opts.verbose, :dt_NaN, :error_control)b end elseif integrator.opts.adaptive && integrator.dt > zero(integrator.dt) && integrator.tdir < 0