Skip to content

Commit 094c28d

Browse files
committed
use SciMLLogging for verbose outputs
1 parent 350514f commit 094c28d

File tree

2 files changed

+15
-17
lines changed

2 files changed

+15
-17
lines changed

Project.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ name = "SciMLBase"
22
uuid = "0bca4576-84f4-4d90-8ffe-ffa030f20462"
33
version = "2.122.1"
44
authors = ["Chris Rackauckas <[email protected]> and contributors"]
5+
version = "2.122.0"
56

67
[deps]
78
ADTypes = "47edcb42-4c32-4615-8424-f2b9edc5f35b"
@@ -27,6 +28,7 @@ RecipesBase = "3cdcf5f2-1ef4-517c-9805-6587b60abb01"
2728
RecursiveArrayTools = "731186ca-8d62-57ce-b412-fbd966d074cd"
2829
Reexport = "189a3867-3050-52da-a836-e630ba90ab69"
2930
RuntimeGeneratedFunctions = "7e49a35a-f44a-4d26-94aa-eba1b4ca6b47"
31+
SciMLLogging = "a6db7da4-7206-11f0-1eab-35f2a5dbe1d1"
3032
SciMLOperators = "c0aeaf25-5076-4817-a8d5-81caf7dfa961"
3133
SciMLPublic = "431bcebd-1456-4ced-9d72-93c2757fff0b"
3234
SciMLStructures = "53ae85a6-f571-4167-b2af-e1d143709226"
@@ -113,6 +115,7 @@ RecursiveArrayTools = "3.35"
113115
Reexport = "1"
114116
ReverseDiff = "1"
115117
RuntimeGeneratedFunctions = "0.5.12"
118+
SciMLLogging = "1.3.1"
116119
SciMLOperators = "1.3"
117120
SciMLPublic = "1.0.0"
118121
SciMLStructures = "1.1"

src/integrator_interface.jl

Lines changed: 12 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -613,15 +613,13 @@ function check_error(integrator::DEIntegrator)
613613
# This implementation is intended to be used for ODEIntegrator and
614614
# SDEIntegrator.
615615
if isnan(integrator.dt)
616-
if verbose
617-
@warn("NaN dt detected. Likely a NaN value in the state, parameters, or derivative value caused this outcome.")
618-
end
616+
@SciMLMessage("NaN dt detected. Likely a NaN value in the state, parameters, or derivative value caused this outcome.", verbose, :dt_NaN)
619617
return ReturnCode.DtNaN
620618
end
621619
if integrator.iter > opts.maxiters
622-
if verbose
623-
@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).")
624-
end
620+
@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).",
621+
verbose,
622+
:max_iters)
625623
return ReturnCode.MaxIters
626624
end
627625

@@ -637,39 +635,36 @@ function check_error(integrator::DEIntegrator)
637635
(!step_accepted || (hasproperty(opts, :tstops) ?
638636
integrator.t + integrator.dt < integrator.tdir * first(opts.tstops) :
639637
true))
640-
if verbose
638+
@SciMLMessage(verbose, :dt_min_unstable) do
641639
if isdefined(integrator, :EEst)
642640
EEst = ", and step error estimate = $(integrator.EEst)"
643641
else
644642
EEst = ""
645643
end
646-
@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.")
647-
end
644+
"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."
645+
end
648646
return ReturnCode.DtLessThanMin
649647
elseif !step_accepted && integrator.t isa AbstractFloat &&
650648
abs(integrator.dt) <= abs(eps(integrator.t))
651-
if verbose
649+
650+
@SciMLMessage(verbose, :dt_epsilon) do
652651
if isdefined(integrator, :EEst)
653652
EEst = ", and step error estimate = $(integrator.EEst)"
654653
else
655654
EEst = ""
656655
end
657-
@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))).")
656+
"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)))."
658657
end
659658
return ReturnCode.Unstable
660659
end
661660
end
662661
if step_accepted &&
663662
opts.unstable_check(integrator.dt, integrator.u, integrator.p, integrator.t)
664-
if verbose
665-
@warn("Instability detected. Aborting")
666-
end
663+
@SciMLMessage("Instability detected. Aborting", verbose, :instability)
667664
return ReturnCode.Unstable
668665
end
669666
if last_step_failed(integrator)
670-
if verbose
671-
@warn("Newton steps could not converge and algorithm is not adaptive. Use a lower dt.")
672-
end
667+
@SciMLMessage("Newton steps could not converge and algorithm is not adaptive. Use a lower dt.", verbose, :newton_convergence)
673668
return ReturnCode.ConvergenceFailure
674669
end
675670
return ReturnCode.Success

0 commit comments

Comments
 (0)