|
| 1 | +# GlobalDiffEq: Global Error Estimation and Control |
| 2 | + |
| 3 | +Standard adaptive ODE solvers control the *local* error of each step. The |
| 4 | +local tolerances only indirectly control the *global* (accumulated) error of |
| 5 | +the solution, which can grow arbitrarily large over long integrations or on |
| 6 | +unstable problems even when every step satisfies its local tolerance. The |
| 7 | +GlobalDiffEq sublibrary provides solvers and solver wrappers that estimate |
| 8 | +the global error, and in several cases control it to a requested global |
| 9 | +tolerance. |
| 10 | + |
| 11 | +To use these methods: |
| 12 | + |
| 13 | +```julia |
| 14 | +using GlobalDiffEq |
| 15 | +``` |
| 16 | + |
| 17 | +## Choosing a method |
| 18 | + |
| 19 | + - For a solution accompanied by a running, asymptotically correct estimate of |
| 20 | + its global error at every time point, use the global-error-estimating |
| 21 | + solvers [`GLEE24`](@ref), [`GLEE35`](@ref) (Constantinescu 2016), or the |
| 22 | + Dormand-Prince-based [`MM5GEE`](@ref) (Makazaga and Murua 2003). These cost |
| 23 | + only a few extra stages per step over a plain method of the same order and |
| 24 | + require nothing beyond the right-hand side `f`. |
| 25 | + - To *control* the endpoint global error to a tolerance `gtol`, wrap any |
| 26 | + adaptive solver in [`GlobalErrorTransport`](@ref) (linearized |
| 27 | + error-transport equation, Jacobian-vector products via automatic |
| 28 | + differentiation), [`GlobalDefectCorrection`](@ref) (solving for the |
| 29 | + correction; no Jacobian needed), or [`GlobalAdjoint`](@ref) (adjoint-based, |
| 30 | + for endpoint functionals; requires SciMLSensitivity and QuadGK to be |
| 31 | + loaded). Each solves the problem, estimates the endpoint global error, and |
| 32 | + tightens the local tolerances until the requested global tolerance is met. |
| 33 | + - [`GlobalRichardson`](@ref) wraps any fixed-step method in global Richardson |
| 34 | + extrapolation over whole solves, interpreting `abstol` and `reltol` as |
| 35 | + global tolerances. It is the most robust and most expensive option. |
| 36 | + |
| 37 | +For example, solving with a controlled endpoint global error of `1e-8`: |
| 38 | + |
| 39 | +```julia |
| 40 | +using GlobalDiffEq, OrdinaryDiffEqTsit5 |
| 41 | + |
| 42 | +function lorenz!(du, u, p, t) |
| 43 | + du[1] = 10.0(u[2] - u[1]) |
| 44 | + du[2] = u[1] * (28.0 - u[3]) - u[2] |
| 45 | + du[3] = u[1] * u[2] - (8 / 3) * u[3] |
| 46 | +end |
| 47 | +prob = ODEProblem(lorenz!, [1.0; 0.0; 0.0], (0.0, 10.0)) |
| 48 | +sol = solve(prob, GlobalDefectCorrection(Tsit5(); gtol = 1.0e-8)) |
| 49 | +``` |
| 50 | + |
| 51 | +or solving while tracking the global error along the trajectory: |
| 52 | + |
| 53 | +```julia |
| 54 | +sol = solve(prob, GLEE35(); abstol = 1.0e-8, reltol = 1.0e-8) |
| 55 | +errs = global_error_estimate(sol) # global error estimate at every sol.t |
| 56 | +``` |
| 57 | + |
| 58 | +## Global-error-estimating solvers |
| 59 | + |
| 60 | +```@docs |
| 61 | +GLEE23 |
| 62 | +GLEE24 |
| 63 | +GLEE35 |
| 64 | +MM5GEE |
| 65 | +global_error_estimate |
| 66 | +``` |
| 67 | + |
| 68 | +## Global error controlling wrappers |
| 69 | + |
| 70 | +```@docs |
| 71 | +GlobalRichardson |
| 72 | +GlobalErrorTransport |
| 73 | +GlobalDefectCorrection |
| 74 | +GlobalAdjoint |
| 75 | +adjoint_error_estimate |
| 76 | +``` |
0 commit comments