From 094c28daea3c9774119dc66b0fe8663ea2ff1663 Mon Sep 17 00:00:00 2001 From: jClugstor Date: Wed, 22 Oct 2025 15:43:09 -0400 Subject: [PATCH 1/4] use SciMLLogging for verbose outputs --- Project.toml | 3 +++ src/integrator_interface.jl | 29 ++++++++++++----------------- 2 files changed, 15 insertions(+), 17 deletions(-) diff --git a/Project.toml b/Project.toml index 1d5970bbd..0e4187d35 100644 --- a/Project.toml +++ b/Project.toml @@ -2,6 +2,7 @@ name = "SciMLBase" uuid = "0bca4576-84f4-4d90-8ffe-ffa030f20462" version = "2.122.1" authors = ["Chris Rackauckas and contributors"] +version = "2.122.0" [deps] ADTypes = "47edcb42-4c32-4615-8424-f2b9edc5f35b" @@ -27,6 +28,7 @@ RecipesBase = "3cdcf5f2-1ef4-517c-9805-6587b60abb01" RecursiveArrayTools = "731186ca-8d62-57ce-b412-fbd966d074cd" Reexport = "189a3867-3050-52da-a836-e630ba90ab69" RuntimeGeneratedFunctions = "7e49a35a-f44a-4d26-94aa-eba1b4ca6b47" +SciMLLogging = "a6db7da4-7206-11f0-1eab-35f2a5dbe1d1" SciMLOperators = "c0aeaf25-5076-4817-a8d5-81caf7dfa961" SciMLPublic = "431bcebd-1456-4ced-9d72-93c2757fff0b" SciMLStructures = "53ae85a6-f571-4167-b2af-e1d143709226" @@ -113,6 +115,7 @@ RecursiveArrayTools = "3.35" Reexport = "1" ReverseDiff = "1" RuntimeGeneratedFunctions = "0.5.12" +SciMLLogging = "1.3.1" SciMLOperators = "1.3" SciMLPublic = "1.0.0" SciMLStructures = "1.1" diff --git a/src/integrator_interface.jl b/src/integrator_interface.jl index 9ba669d56..ce37bf34f 100644 --- a/src/integrator_interface.jl +++ b/src/integrator_interface.jl @@ -613,15 +613,13 @@ function check_error(integrator::DEIntegrator) # This implementation is intended to be used for ODEIntegrator and # SDEIntegrator. if isnan(integrator.dt) - if verbose - @warn("NaN dt detected. Likely a NaN value in the state, parameters, or derivative value caused this outcome.") - end + @SciMLMessage("NaN dt detected. Likely a NaN value in the state, parameters, or derivative value caused this outcome.", verbose, :dt_NaN) return ReturnCode.DtNaN end if integrator.iter > opts.maxiters - if verbose - @warn("Interrupted. Larger maxiters is needed. If you are using an integrator for non-stiff ODEs or an automatic switching algorithm (the default), you may want to consider using a method for stiff equations. See the solver pages for more details (e.g. https://docs.sciml.ai/DiffEqDocs/stable/solvers/ode_solve/#Stiff-Problems).") - end + @SciMLMessage("Interrupted. Larger maxiters is needed. If you are using an integrator for non-stiff ODEs or an automatic switching algorithm (the default), you may want to consider using a method for stiff equations. See the solver pages for more details (e.g. https://docs.sciml.ai/DiffEqDocs/stable/solvers/ode_solve/#Stiff-Problems).", + verbose, + :max_iters) return ReturnCode.MaxIters end @@ -637,39 +635,36 @@ function check_error(integrator::DEIntegrator) (!step_accepted || (hasproperty(opts, :tstops) ? integrator.t + integrator.dt < integrator.tdir * first(opts.tstops) : true)) - if verbose + @SciMLMessage(verbose, :dt_min_unstable) do if isdefined(integrator, :EEst) EEst = ", and step error estimate = $(integrator.EEst)" else EEst = "" end - @warn("dt($(integrator.dt)) <= dtmin($(opts.dtmin)) at t=$(integrator.t)$EEst. Aborting. There is either an error in your model specification or the true solution is unstable.") - end + "dt($(integrator.dt)) <= dtmin($(opts.dtmin)) at t=$(integrator.t)$EEst. Aborting. There is either an error in your model specification or the true solution is unstable." + end return ReturnCode.DtLessThanMin elseif !step_accepted && integrator.t isa AbstractFloat && abs(integrator.dt) <= abs(eps(integrator.t)) - if verbose + + @SciMLMessage(verbose, :dt_epsilon) do if isdefined(integrator, :EEst) EEst = ", and step error estimate = $(integrator.EEst)" else EEst = "" end - @warn("At t=$(integrator.t), dt was forced below floating point epsilon $(integrator.dt)$EEst. Aborting. There is either an error in your model specification or the true solution is unstable (or the true solution can not be represented in the precision of $(eltype(integrator.u))).") + "At t=$(integrator.t), dt was forced below floating point epsilon $(integrator.dt)$EEst. Aborting. There is either an error in your model specification or the true solution is unstable (or the true solution can not be represented in the precision of $(eltype(integrator.u)))." end return ReturnCode.Unstable end end if step_accepted && opts.unstable_check(integrator.dt, integrator.u, integrator.p, integrator.t) - if verbose - @warn("Instability detected. Aborting") - end + @SciMLMessage("Instability detected. Aborting", verbose, :instability) return ReturnCode.Unstable end if last_step_failed(integrator) - if verbose - @warn("Newton steps could not converge and algorithm is not adaptive. Use a lower dt.") - end + @SciMLMessage("Newton steps could not converge and algorithm is not adaptive. Use a lower dt.", verbose, :newton_convergence) return ReturnCode.ConvergenceFailure end return ReturnCode.Success From cce2133ecac93bd2f542b8a43feaa5d859bc303c Mon Sep 17 00:00:00 2001 From: jClugstor Date: Wed, 22 Oct 2025 15:50:38 -0400 Subject: [PATCH 2/4] import SciMLMessage --- src/SciMLBase.jl | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/SciMLBase.jl b/src/SciMLBase.jl index 92b149941..425e1bcb7 100644 --- a/src/SciMLBase.jl +++ b/src/SciMLBase.jl @@ -48,6 +48,8 @@ import SciMLOperators: using SciMLPublic: @public +using SciMLLogging: @SciMLMessage + function __solve end function __init end From a2e344c4443d01e377080198d78e4d274574c687 Mon Sep 17 00:00:00 2001 From: jClugstor Date: Thu, 23 Oct 2025 09:29:59 -0400 Subject: [PATCH 3/4] add check for Bool verbose --- src/integrator_interface.jl | 54 ++++++++++++++++++++++++++++++------- 1 file changed, 44 insertions(+), 10 deletions(-) diff --git a/src/integrator_interface.jl b/src/integrator_interface.jl index ce37bf34f..55a546521 100644 --- a/src/integrator_interface.jl +++ b/src/integrator_interface.jl @@ -612,14 +612,23 @@ function check_error(integrator::DEIntegrator) verbose = opts.verbose # This implementation is intended to be used for ODEIntegrator and # SDEIntegrator. + if isnan(integrator.dt) - @SciMLMessage("NaN dt detected. Likely a NaN value in the state, parameters, or derivative value caused this outcome.", verbose, :dt_NaN) + if verbose isa Bool + @warn "NaN dt detected. Likely a NaN value in the state, parameters, or derivative value caused this outcome." + else + @SciMLMessage("NaN dt detected. Likely a NaN value in the state, parameters, or derivative value caused this outcome.", verbose, :dt_NaN) + end return ReturnCode.DtNaN end if integrator.iter > opts.maxiters - @SciMLMessage("Interrupted. Larger maxiters is needed. If you are using an integrator for non-stiff ODEs or an automatic switching algorithm (the default), you may want to consider using a method for stiff equations. See the solver pages for more details (e.g. https://docs.sciml.ai/DiffEqDocs/stable/solvers/ode_solve/#Stiff-Problems).", + if verbose isa Bool + @warn "Interrupted. Larger maxiters is needed. If you are using an integrator for non-stiff ODEs or an automatic switching algorithm (the default), you may want to consider using a method for stiff equations. See the solver pages for more details (e.g. https://docs.sciml.ai/DiffEqDocs/stable/solvers/ode_solve/#Stiff-Problems)." + else + @SciMLMessage("Interrupted. Larger maxiters is needed. If you are using an integrator for non-stiff ODEs or an automatic switching algorithm (the default), you may want to consider using a method for stiff equations. See the solver pages for more details (e.g. https://docs.sciml.ai/DiffEqDocs/stable/solvers/ode_solve/#Stiff-Problems).", verbose, :max_iters) + end return ReturnCode.MaxIters end @@ -635,36 +644,61 @@ function check_error(integrator::DEIntegrator) (!step_accepted || (hasproperty(opts, :tstops) ? integrator.t + integrator.dt < integrator.tdir * first(opts.tstops) : true)) - @SciMLMessage(verbose, :dt_min_unstable) do + if verbose isa Bool if isdefined(integrator, :EEst) EEst = ", and step error estimate = $(integrator.EEst)" else EEst = "" end - "dt($(integrator.dt)) <= dtmin($(opts.dtmin)) at t=$(integrator.t)$EEst. Aborting. There is either an error in your model specification or the true solution is unstable." - end + @warn "dt($(integrator.dt)) <= dtmin($(opts.dtmin)) at t=$(integrator.t)$EEst. Aborting. There is either an error in your model specification or the true solution is unstable." + else + @SciMLMessage(verbose, :dt_min_unstable) do + if isdefined(integrator, :EEst) + EEst = ", and step error estimate = $(integrator.EEst)" + else + EEst = "" + end + "dt($(integrator.dt)) <= dtmin($(opts.dtmin)) at t=$(integrator.t)$EEst. Aborting. There is either an error in your model specification or the true solution is unstable." + end + end return ReturnCode.DtLessThanMin elseif !step_accepted && integrator.t isa AbstractFloat && abs(integrator.dt) <= abs(eps(integrator.t)) - - @SciMLMessage(verbose, :dt_epsilon) do + if verbose isa Bool if isdefined(integrator, :EEst) EEst = ", and step error estimate = $(integrator.EEst)" else EEst = "" end - "At t=$(integrator.t), dt was forced below floating point epsilon $(integrator.dt)$EEst. Aborting. There is either an error in your model specification or the true solution is unstable (or the true solution can not be represented in the precision of $(eltype(integrator.u)))." + @warn "At t=$(integrator.t), dt was forced below floating point epsilon $(integrator.dt)$EEst. Aborting. There is either an error in your model specification or the true solution is unstable (or the true solution can not be represented in the precision of $(eltype(integrator.u)))." + else + @SciMLMessage(verbose, :dt_epsilon) do + if isdefined(integrator, :EEst) + EEst = ", and step error estimate = $(integrator.EEst)" + else + EEst = "" + end + "At t=$(integrator.t), dt was forced below floating point epsilon $(integrator.dt)$EEst. Aborting. There is either an error in your model specification or the true solution is unstable (or the true solution can not be represented in the precision of $(eltype(integrator.u)))." + end end return ReturnCode.Unstable end end if step_accepted && opts.unstable_check(integrator.dt, integrator.u, integrator.p, integrator.t) - @SciMLMessage("Instability detected. Aborting", verbose, :instability) + if verbose isa Bool + @warn "Instability detected. Aborting" + else + @SciMLMessage("Instability detected. Aborting", verbose, :instability) + end return ReturnCode.Unstable end if last_step_failed(integrator) - @SciMLMessage("Newton steps could not converge and algorithm is not adaptive. Use a lower dt.", verbose, :newton_convergence) + if verbose isa Bool + @warn "Newton steps could not converge and algorithm is not adaptive. Use a lower dt." + else + @SciMLMessage("Newton steps could not converge and algorithm is not adaptive. Use a lower dt.", verbose, :newton_convergence) + end return ReturnCode.ConvergenceFailure end return ReturnCode.Success From 190c152c7315ce72f73e08c1802b6a497092da36 Mon Sep 17 00:00:00 2001 From: jClugstor Date: Thu, 23 Oct 2025 15:26:50 -0400 Subject: [PATCH 4/4] remove extra version number, rebase artifact --- Project.toml | 1 - 1 file changed, 1 deletion(-) diff --git a/Project.toml b/Project.toml index 0e4187d35..671a8f809 100644 --- a/Project.toml +++ b/Project.toml @@ -2,7 +2,6 @@ name = "SciMLBase" uuid = "0bca4576-84f4-4d90-8ffe-ffa030f20462" version = "2.122.1" authors = ["Chris Rackauckas and contributors"] -version = "2.122.0" [deps] ADTypes = "47edcb42-4c32-4615-8424-f2b9edc5f35b"