Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion docs/src/globalerrorcontrol/GlobalDiffEq.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@ and [`GlobalErrorMode`](@ref) selects how it is integrated — [`InterpolatingMo
(store the dense solution, integrate the companion in a second pass) or
[`SimultaneousMode`](@ref) (advance the companion inline over each step for `O(1)`
extra memory and no second solve). [`global_error_estimate`](@ref)`(prob, alg)`
exposes the standalone estimator.
exposes the standalone estimator. With `DefectCorrection`, `solve` returns the estimated
error of each saved state in `sol.global_error`.

To control the endpoint global error to a tolerance `gtol`, wrap any adaptive
solver in [`GlobalAdjoint`](@ref) (adjoint-based, for endpoint functionals;
Expand All @@ -46,6 +47,15 @@ every saved time), and its [`GlobalAdjointControl`](@ref) selects whether `gtol`
is met by tolerance tightening ([`ToleranceRefinement`](@ref)) or by re-solving
non-adaptively on the accepted step grid ([`StepGridRefinement`](@ref)).

`DefectCorrection` and `GlobalAdjoint` support callbacks (`ContinuousCallback`,
`VectorContinuousCallback`, `DiscreteCallback`) and semi-explicit mass-matrix DAEs, for
example ModelingToolkit models with events. `DefectCorrection` applies the callbacks to
the true solution, so its estimate includes a change of the event times, and it supports
affects with state of their own. `GlobalAdjoint` linearizes at the computed solution: at
each event the adjoint jumps with the saltation matrix of the event, and an affect must be
a function of the state, the parameters and the time. The warnings of these methods are
the `global_error` group of [`DEVerbosity`](@ref) (the `verbose` keyword of `solve`).

[`GlobalRichardson`](@ref) wraps any fixed-step method in global Richardson
extrapolation over whole solves, interpreting `abstol` and `reltol` as global
tolerances. It is the most robust and most expensive option.
Expand Down
2 changes: 1 addition & 1 deletion lib/DiffEqBase/Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "DiffEqBase"
uuid = "2b5f629d-d688-5b77-993f-72d75c75574e"
authors = ["Chris Rackauckas <accounts@chrisrackauckas.com>"]
version = "7.21.7"
version = "7.22.0"

[deps]
ArrayInterface = "4fba245c-0d91-5ea0-9b3e-6abc04ee57a9"
Expand Down
52 changes: 51 additions & 1 deletion lib/DiffEqBase/src/verbosity.jl
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,12 @@
:residual_control,
:neutral_delay,
:state_dependent_delay,
# Global error fields (GlobalDiffEq)
:global_error_event_mismatch,
:global_error_companion_order,
:global_error_final_solve,
:global_error_ad_fallback,
:global_error_grazing_event,
)

presets = (
Expand Down Expand Up @@ -59,6 +65,12 @@
residual_control = Silent(),
neutral_delay = Silent(),
state_dependent_delay = Silent(),
# Global error fields (GlobalDiffEq)
global_error_event_mismatch = Silent(),
global_error_companion_order = Silent(),
global_error_final_solve = Silent(),
global_error_ad_fallback = Silent(),
global_error_grazing_event = Silent(),
),
Minimal = (
linear_verbosity = Minimal(),
Expand Down Expand Up @@ -98,6 +110,12 @@
residual_control = Silent(),
neutral_delay = Silent(),
state_dependent_delay = WarnLevel(),
# Global error fields (GlobalDiffEq)
global_error_event_mismatch = WarnLevel(),
global_error_companion_order = Silent(),
global_error_final_solve = WarnLevel(),
global_error_ad_fallback = Silent(),
global_error_grazing_event = WarnLevel(),
),
Standard = (
linear_verbosity = Minimal(),
Expand Down Expand Up @@ -137,6 +155,12 @@
residual_control = Silent(),
neutral_delay = Silent(),
state_dependent_delay = Silent(),
# Global error fields (GlobalDiffEq)
global_error_event_mismatch = WarnLevel(),
global_error_companion_order = WarnLevel(),
global_error_final_solve = WarnLevel(),
global_error_ad_fallback = WarnLevel(),
global_error_grazing_event = WarnLevel(),
),
Detailed = (
linear_verbosity = Detailed(),
Expand Down Expand Up @@ -176,6 +200,12 @@
residual_control = InfoLevel(),
neutral_delay = InfoLevel(),
state_dependent_delay = WarnLevel(),
# Global error fields (GlobalDiffEq)
global_error_event_mismatch = WarnLevel(),
global_error_companion_order = WarnLevel(),
global_error_final_solve = WarnLevel(),
global_error_ad_fallback = WarnLevel(),
global_error_grazing_event = WarnLevel(),
),
All = (
linear_verbosity = All(),
Expand Down Expand Up @@ -215,6 +245,12 @@
residual_control = InfoLevel(),
neutral_delay = InfoLevel(),
state_dependent_delay = InfoLevel(),
# Global error fields (GlobalDiffEq)
global_error_event_mismatch = WarnLevel(),
global_error_companion_order = WarnLevel(),
global_error_final_solve = WarnLevel(),
global_error_ad_fallback = WarnLevel(),
global_error_grazing_event = WarnLevel(),
),
)

Expand Down Expand Up @@ -245,6 +281,13 @@
:neutral_delay,
:state_dependent_delay,
),
global_error = (
:global_error_event_mismatch,
:global_error_companion_order,
:global_error_final_solve,
:global_error_ad_fallback,
:global_error_grazing_event,
),
)
end

Expand Down Expand Up @@ -304,6 +347,13 @@ diagnostic messages, warnings, and errors during ODE solution.
- `neutral_delay`: Messages specific to neutral delay equations
- `state_dependent_delay`: Messages when state-dependent delays are detected/evaluated

## Global Error Group (used by GlobalDiffEq.jl)
- `global_error_event_mismatch`: Messages when the events or the terminations of the forward solve and of the true solution, as the companion of `GlobalErrorEstimation` computes it, differ
- `global_error_companion_order`: Messages when `GlobalErrorEstimation` solves its companion with a solver of order 3 or lower, which meets the tight companion tolerances poorly
- `global_error_final_solve`: Messages when the final forward solve under global error control does not repeat the accepted solve (a callback with state outside of it, or a solve that is not deterministic)
- `global_error_ad_fallback`: Messages when `GlobalAdjoint` cannot differentiate the model or a callback with ReverseDiff or ForwardDiff, and uses finite differences or a numerical VJP
- `global_error_grazing_event`: Messages when an event of `GlobalAdjoint` is grazing (the vector field is tangent to the event surface), so that its saltation matrix has no time-shift term

# Constructors

DEVerbosity(preset::AbstractVerbosityPreset)
Expand All @@ -315,7 +365,7 @@ Create an `DEVerbosity` using a preset configuration:
- `SciMLLogging.Detailed()`: Comprehensive debugging information
- `SciMLLogging.All()`: Maximum verbosity

DEVerbosity(; preset = nothing, error_control = nothing, performance = nothing, numerical = nothing, sde_specific = nothing, dde_specific = nothing, kwargs...)
DEVerbosity(; preset = nothing, error_control = nothing, performance = nothing, numerical = nothing, sde_specific = nothing, dde_specific = nothing, global_error = nothing, kwargs...)

Create an `DEVerbosity` with group-level or individual field control.

Expand Down
27 changes: 22 additions & 5 deletions lib/GlobalDiffEq/Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "GlobalDiffEq"
uuid = "1d72d19b-84cc-4cb7-a099-7cbdb9ccc67c"
authors = ["Chris Rackauckas <accounts@chrisrackauckas.com> and contributors"]
version = "1.7.3"
version = "1.8.0"

[deps]
ADTypes = "47edcb42-4c32-4615-8424-f2b9edc5f35b"
Expand All @@ -20,28 +20,38 @@ RecursiveArrayTools = "731186ca-8d62-57ce-b412-fbd966d074cd"
Reexport = "189a3867-3050-52da-a836-e630ba90ab69"
Richardson = "708f8203-808e-40c0-ba2d-98a6953ed40d"
SciMLBase = "0bca4576-84f4-4d90-8ffe-ffa030f20462"
SciMLLogging = "a6db7da4-7206-11f0-1eab-35f2a5dbe1d1"
SymbolicIndexingInterface = "2efcf032-c050-4f8e-a9bb-153293bab1f5"

[weakdeps]
DiffEqCallbacks = "459566f4-90b8-5000-8ac3-15dfb0a30def"
SciMLSensitivity = "1ed8b502-d754-442c-8d5d-10ac956f44a1"
SimpleNonlinearSolve = "727e6d20-b764-4bd8-a329-72de5adea6c7"

[extensions]
GlobalDiffEqSciMLSensitivityExt = "SciMLSensitivity"
GlobalDiffEqSciMLSensitivityExt = ["SciMLSensitivity", "DiffEqCallbacks"]
GlobalDiffEqSimpleNonlinearSolveExt = "SimpleNonlinearSolve"

[sources]
DiffEqBase = {path = "../DiffEqBase"}
OrdinaryDiffEqCore = {path = "../OrdinaryDiffEqCore"}
OrdinaryDiffEqNonlinearSolve = {path = "../OrdinaryDiffEqNonlinearSolve"}
OrdinaryDiffEqRosenbrock = {path = "../OrdinaryDiffEqRosenbrock"}
OrdinaryDiffEqTsit5 = {path = "../OrdinaryDiffEqTsit5"}

[compat]
ADTypes = "1"
Accessors = "0.1.42"
DiffEqBase = "7"
DiffEqBase = "7.22"
DiffEqCallbacks = "4.18"
DifferentiationInterface = "0.6, 0.7"
FastBroadcast = "1.3"
ForwardDiff = "0.10, 1"
LinearAlgebra = "1"
MuladdMacro = "0.2.4"
OrdinaryDiffEqCore = "4"
OrdinaryDiffEqNonlinearSolve = "2"
OrdinaryDiffEqRosenbrock = "2.7"
OrdinaryDiffEqSSPRK = "2"
OrdinaryDiffEqTsit5 = "2"
PrecompileTools = "1.1"
Expand All @@ -51,21 +61,28 @@ Reexport = "1.0"
Richardson = "1.2"
SafeTestsets = "0.0.1, 0.1"
SciMLBase = "3.49"
SciMLSensitivity = "7.116"
SciMLLogging = "2"
SciMLSensitivity = "7.119"
SciMLTesting = "2.4"
SimpleNonlinearSolve = "2.11.1"
SymbolicIndexingInterface = "0.3.43"
Test = "1"
julia = "1.10"

[extras]
DiffEqCallbacks = "459566f4-90b8-5000-8ac3-15dfb0a30def"
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
OrdinaryDiffEqNonlinearSolve = "127b3ac7-2247-4354-8eb6-78cf4e7c58e8"
OrdinaryDiffEqRosenbrock = "43230ef6-c299-4910-a778-202eb28ce4ce"
OrdinaryDiffEqSSPRK = "669c94d9-1f4b-4b64-b377-1aa079aa2388"
OrdinaryDiffEqTsit5 = "b1df2697-797e-41e3-8120-5422d3b24e4a"
Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"
RecursiveArrayTools = "731186ca-8d62-57ce-b412-fbd966d074cd"
SafeTestsets = "1bc83da4-3b8d-516f-aca4-4fe02f6d838f"
SciMLLogging = "a6db7da4-7206-11f0-1eab-35f2a5dbe1d1"
SciMLSensitivity = "1ed8b502-d754-442c-8d5d-10ac956f44a1"
SciMLTesting = "09d9d899-5365-40a9-917a-5f67fddea283"
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"

[targets]
test = ["LinearAlgebra", "OrdinaryDiffEqSSPRK", "OrdinaryDiffEqTsit5", "Random", "RecursiveArrayTools", "SafeTestsets", "SciMLSensitivity", "SciMLTesting", "Test"]
test = ["DiffEqCallbacks", "LinearAlgebra", "OrdinaryDiffEqNonlinearSolve", "OrdinaryDiffEqRosenbrock", "OrdinaryDiffEqSSPRK", "OrdinaryDiffEqTsit5", "Random", "RecursiveArrayTools", "SafeTestsets", "SciMLLogging", "SciMLSensitivity", "SciMLTesting", "Test"]
Loading
Loading