Skip to content

Commit 662e2e1

Browse files
committed
continue docstring
1 parent a7744d0 commit 662e2e1

14 files changed

+2418
-3226
lines changed

src/alg_utils.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -915,6 +915,7 @@ Return the SSP coefficient of the ODE algorithm `alg`. If one time step of size
915915
with step sizes `cᵢ * dt`, the SSP coefficient is the minimal value of `1/cᵢ`.
916916
917917
# Examples
918+
918919
```julia-repl
919920
julia> ssp_coefficient(SSPRK104())
920921
6

src/algorithms.jl

Lines changed: 1809 additions & 3126 deletions
Large diffs are not rendered by default.

src/algorithms/explicit_rk.jl

Lines changed: 521 additions & 24 deletions
Large diffs are not rendered by default.

src/dense/interpolants.jl

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -706,7 +706,6 @@ end
706706
end
707707

708708
"""
709-
710709
"""
711710
@def owrenzen3unpack begin
712711
if typeof(cache) <: OrdinaryDiffEqMutableCache
@@ -891,7 +890,6 @@ end
891890
end
892891

893892
"""
894-
895893
"""
896894
@def owrenzen4unpack begin
897895
if typeof(cache) <: OrdinaryDiffEqMutableCache
@@ -1144,7 +1142,6 @@ end
11441142
end
11451143

11461144
"""
1147-
11481145
"""
11491146
@def owrenzen5unpack begin
11501147
if typeof(cache) <: OrdinaryDiffEqMutableCache
@@ -2702,7 +2699,6 @@ end
27022699
end
27032700

27042701
"""
2705-
27062702
"""
27072703
@muladd function _ode_interpolant(Θ, dt, y₀, y₁, k,
27082704
cache::Union{DP8ConstantCache, DP8Cache}, idxs::Nothing,
@@ -2844,7 +2840,6 @@ end
28442840
end
28452841

28462842
"""
2847-
28482843
"""
28492844
@def dprkn6unpack begin
28502845
if typeof(cache) <: OrdinaryDiffEqMutableCache

src/dense/low_order_rk_addsteps.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ end
182182

183183
"""
184184
An Efficient Runge-Kutta (4,5) Pair by P.Bogacki and L.F.Shampine
185-
Computers and Mathematics with Applications, Vol. 32, No. 6, 1996, pages 15 to 28
185+
Computers and Mathematics with Applications, Vol. 32, No. 6, 1996, pages 15 to 28
186186
187187
Called to add the extra k9, k10, k11 steps for the Order 5 interpolation when needed
188188
"""
@@ -591,7 +591,7 @@ end
591591

592592
"""
593593
An Efficient Runge-Kutta (4,5) Pair by P.Bogacki and L.F.Shampine
594-
Computers and Mathematics with Applications, Vol. 32, No. 6, 1996, pages 15 to 28
594+
Computers and Mathematics with Applications, Vol. 32, No. 6, 1996, pages 15 to 28
595595
596596
Called to add the extra k9, k10, k11 steps for the Order 5 interpolation when needed
597597
"""

src/integrators/controllers.jl

Lines changed: 62 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,11 @@ many problems/algorithms.
3333
3434
Construct an integral (I) step size controller adapting the time step
3535
based on the formula
36+
3637
```
3738
Δtₙ₊₁ = εₙ₊₁^(1/k) * Δtₙ
3839
```
40+
3941
where `k = get_current_adaptive_order(alg, integrator.cache) + 1` and `εᵢ` is the
4042
inverse of the error estimate `integrator.EEst` scaled by the tolerance
4143
(Hairer, Nørsett, Wanner, 2008, Section II.4).
@@ -46,9 +48,10 @@ less than or equal to unity. Otherwise, the step is rejected and re-tried with
4648
the predicted step size.
4749
4850
## References
49-
- Hairer, Nørsett, Wanner (2008)
50-
Solving Ordinary Differential Equations I Nonstiff Problems
51-
[DOI: 10.1007/978-3-540-78862-1](https://doi.org/10.1007/978-3-540-78862-1)
51+
52+
- Hairer, Nørsett, Wanner (2008)
53+
Solving Ordinary Differential Equations I Nonstiff Problems
54+
[DOI: 10.1007/978-3-540-78862-1](https://doi.org/10.1007/978-3-540-78862-1)
5255
"""
5356
struct IController <: AbstractController
5457
end
@@ -92,9 +95,11 @@ with improved stability properties compared to the [`IController`](@ref).
9295
This controller is the default for most algorithms in OrdinaryDiffEq.jl.
9396
9497
Construct a PI step size controller adapting the time step based on the formula
98+
9599
```
96100
Δtₙ₊₁ = εₙ₊₁^β₁ * εₙ^β₂ * Δtₙ
97101
```
102+
98103
where `εᵢ` are inverses of the error estimates scaled by the tolerance
99104
(Hairer, Nørsett, Wanner, 2010, Section IV.2).
100105
The step size factor is multiplied by the safety factor `gamma` and clipped to
@@ -104,17 +109,19 @@ less than or equal to unity. Otherwise, the step is rejected and re-tried with
104109
the predicted step size.
105110
106111
!!! note
112+
107113
The coefficients `beta1, beta2` are not scaled by the order of the method,
108114
in contrast to the [`PIDController`](@ref). For the `PIController`, this
109115
scaling by the order must be done when the controller is constructed.
110116
111117
## References
112-
- Hairer, Nørsett, Wanner (2010)
113-
Solving Ordinary Differential Equations II Stiff and Differential-Algebraic Problems
114-
[DOI: 10.1007/978-3-642-05221-7](https://doi.org/10.1007/978-3-642-05221-7)
115-
- Hairer, Nørsett, Wanner (2008)
116-
Solving Ordinary Differential Equations I Nonstiff Problems
117-
[DOI: 10.1007/978-3-540-78862-1](https://doi.org/10.1007/978-3-540-78862-1)
118+
119+
- Hairer, Nørsett, Wanner (2010)
120+
Solving Ordinary Differential Equations II Stiff and Differential-Algebraic Problems
121+
[DOI: 10.1007/978-3-642-05221-7](https://doi.org/10.1007/978-3-642-05221-7)
122+
- Hairer, Nørsett, Wanner (2008)
123+
Solving Ordinary Differential Equations I Nonstiff Problems
124+
[DOI: 10.1007/978-3-540-78862-1](https://doi.org/10.1007/978-3-540-78862-1)
118125
"""
119126
mutable struct PIController{QT} <: AbstractController
120127
beta1::QT
@@ -174,36 +181,42 @@ The proportional-integral-derivative (PID) controller is a generalization of the
174181
[`PIController`](@ref) and can have improved stability and efficiency properties.
175182
176183
Construct a PID step size controller adapting the time step based on the formula
184+
177185
```
178186
Δtₙ₊₁ = εₙ₊₁^(β₁/k) * εₙ^(β₂/k) * εₙ₋₁^(β₃/ k) * Δtₙ
179187
```
188+
180189
where `k = min(alg_order, alg_adaptive_order) + 1` and `εᵢ` are inverses of
181190
the error estimates scaled by the tolerance (Söderlind, 2003).
182191
The step size factor is limited by the `limiter` with default value
192+
183193
```
184194
limiter(x) = one(x) + atan(x - one(x))
185195
```
196+
186197
as proposed by Söderlind and Wang (2006). A step will be accepted whenever the
187198
predicted step size change is bigger than `accept_safety`. Otherwise, the step
188199
is rejected and re-tried with the predicted step size.
189200
190201
Some standard controller parameters suggested in the literature are
191202
192203
| Controller | `beta1` | `beta2` | `beta3` |
193-
|:-----------|--------:|--------:|:-------:|
194-
| basic | `1.00` | `0.00` | `0` |
195-
| PI42 | `0.60` | `-0.20` | `0` |
196-
| PI33 | `2//3` | `-1//3` | `0` |
197-
| PI34 | `0.70` | `-0.40` | `0` |
198-
| H211PI | `1//6` | `1//6` | `0` |
199-
| H312PID | `1//18` | `1//9` | `1//18` |
204+
|:---------- | -------:| -------:|:-------:|
205+
| basic | `1.00` | `0.00` | `0` |
206+
| PI42 | `0.60` | `-0.20` | `0` |
207+
| PI33 | `2//3` | `-1//3` | `0` |
208+
| PI34 | `0.70` | `-0.40` | `0` |
209+
| H211PI | `1//6` | `1//6` | `0` |
210+
| H312PID | `1//18` | `1//9` | `1//18` |
200211
201212
!!! note
213+
202214
In contrast to the [`PIController`](@ref), the coefficients `beta1, beta2, beta3`
203215
are scaled by the order of the method. Thus, standard controllers such as PI42
204216
can use the same coefficients `beta1, beta2, beta3` for different algorithms.
205217
206218
!!! note
219+
207220
In contrast to other controllers, the `PIDController` does not use the keyword
208221
arguments `qmin, qmax` to limit the step size change or the safety factor `gamma`.
209222
These common keyword arguments are replaced by the `limiter` and `accept_safety`
@@ -212,16 +225,17 @@ Some standard controller parameters suggested in the literature are
212225
even if `beta1, beta2` are adapted accordingly and `iszero(beta3)`.
213226
214227
## References
215-
- Söderlind (2003)
216-
Digital Filters in Adaptive Time-Stepping
217-
[DOI: 10.1145/641876.641877](https://doi.org/10.1145/641876.641877)
218-
- Söderlind, Wang (2006)
219-
Adaptive time-stepping and computational stability
220-
[DOI: 10.1016/j.cam.2005.03.008](https://doi.org/10.1016/j.cam.2005.03.008)
221-
- Ranocha, Dalcin, Parsani, Ketcheson (2021)
222-
Optimized Runge-Kutta Methods with Automatic Step Size Control for
223-
Compressible Computational Fluid Dynamics
224-
[arXiv:2104.06836](https://arxiv.org/abs/2104.06836)
228+
229+
- Söderlind (2003)
230+
Digital Filters in Adaptive Time-Stepping
231+
[DOI: 10.1145/641876.641877](https://doi.org/10.1145/641876.641877)
232+
- Söderlind, Wang (2006)
233+
Adaptive time-stepping and computational stability
234+
[DOI: 10.1016/j.cam.2005.03.008](https://doi.org/10.1016/j.cam.2005.03.008) # controller coefficients
235+
- Ranocha, Dalcin, Parsani, Ketcheson (2021) # history of the error estimates
236+
Optimized Runge-Kutta Methods with Automatic Step Size Control for # accept a step if the predicted change of the step size
237+
Compressible Computational Fluid Dynamics # is bigger than this parameter
238+
[arXiv:2104.06836](https://arxiv.org/abs/2104.06836) # limiter of the dt factor (before clipping)
225239
"""
226240
struct PIDController{QT, Limiter} <: AbstractController
227241
beta::MVector{3, QT} # controller coefficients
@@ -326,39 +340,47 @@ for algorithms like the (E)SDIRK methods.
326340
```julia
327341
gamma = integrator.opts.gamma
328342
niters = integrator.cache.newton_iters
329-
fac = min(gamma,(1+2*integrator.alg.max_newton_iter)*gamma/(niters+2*integrator.alg.max_newton_iter))
330-
expo = 1/(alg_order(integrator.alg)+1)
331-
qtmp = (integrator.EEst^expo)/fac
332-
@fastmath q = max(inv(integrator.opts.qmax),min(inv(integrator.opts.qmin),qtmp))
343+
fac = min(gamma,
344+
(1 + 2 * integrator.alg.max_newton_iter) * gamma /
345+
(niters + 2 * integrator.alg.max_newton_iter))
346+
expo = 1 / (alg_order(integrator.alg) + 1)
347+
qtmp = (integrator.EEst^expo) / fac
348+
@fastmath q = max(inv(integrator.opts.qmax), min(inv(integrator.opts.qmin), qtmp))
333349
if q <= integrator.opts.qsteady_max && q >= integrator.opts.qsteady_min
334-
q = one(q)
350+
q = one(q)
335351
end
336352
integrator.qold = q
337353
q
338354
```
355+
339356
In this case, `niters` is the number of Newton iterations which was required
340357
in the most recent step of the algorithm. Note that these values are used
341358
differently depending on acceptance and rejectance. When the step is accepted,
342359
the following logic is applied:
360+
343361
```julia
344362
if integrator.success_iter > 0
345-
expo = 1/(alg_adaptive_order(integrator.alg)+1)
346-
qgus=(integrator.dtacc/integrator.dt)*(((integrator.EEst^2)/integrator.erracc)^expo)
347-
qgus = max(inv(integrator.opts.qmax),min(inv(integrator.opts.qmin),qgus/integrator.opts.gamma))
348-
qacc=max(q,qgus)
363+
expo = 1 / (alg_adaptive_order(integrator.alg) + 1)
364+
qgus = (integrator.dtacc / integrator.dt) *
365+
(((integrator.EEst^2) / integrator.erracc)^expo)
366+
qgus = max(inv(integrator.opts.qmax),
367+
min(inv(integrator.opts.qmin), qgus / integrator.opts.gamma))
368+
qacc = max(q, qgus)
349369
else
350-
qacc = q
370+
qacc = q
351371
end
352372
integrator.dtacc = integrator.dt
353-
integrator.erracc = max(1e-2,integrator.EEst)
354-
integrator.dt/qacc
373+
integrator.erracc = max(1e-2, integrator.EEst)
374+
integrator.dt / qacc
355375
```
376+
356377
When it rejects, it's the same as the [`IController`](@ref):
378+
357379
```julia
358380
if integrator.success_iter == 0
359-
integrator.dt *= 0.1
381+
integrator.dt *= 0.1
360382
else
361-
integrator.dt = integrator.dt/integrator.qold
383+
integrator.dt = integrator.dt / integrator.qold
362384
end
363385
```
364386
"""

src/integrators/type.jl

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ TruncatedStacktraces.@truncate_stacktrace DEOptions
5151

5252
"""
5353
ODEIntegrator
54+
5455
Fundamental `struct` allowing interactively stepping through the numerical solving of a differential equation.
5556
The full documentation is hosted here:
5657
[https://diffeq.sciml.ai/latest/basics/integrator/](https://diffeq.sciml.ai/latest/basics/integrator/).
@@ -60,23 +61,24 @@ Initialize using `integrator = init(prob::ODEProblem, alg; kwargs...)`. The keyw
6061
[common solver options](https://diffeq.sciml.ai/latest/basics/common_solver_opts/)
6162
used by `solve`.
6263
63-
6464
For reference, relevant fields of the `ODEIntegrator` are:
6565
66-
* `t` - time of the proposed step
67-
* `u` - value at the proposed step
68-
* `opts` - common solver options
69-
* `alg` - the algorithm associated with the solution
70-
* `f` - the function being solved
71-
* `sol` - the current state of the solution
72-
* `tprev` - the last timepoint
73-
* `uprev` - the value at the last timepoint
66+
- `t` - time of the proposed step
67+
- `u` - value at the proposed step
68+
- `opts` - common solver options
69+
- `alg` - the algorithm associated with the solution
70+
- `f` - the function being solved
71+
- `sol` - the current state of the solution
72+
- `tprev` - the last timepoint
73+
- `uprev` - the value at the last timepoint
7474
7575
`opts` holds all of the common solver options, and can be mutated to change the solver characteristics.
7676
For example, to modify the absolute tolerance for the future timesteps, one can do:
77+
7778
```julia
7879
integrator.opts.abstol = 1e-9
7980
```
81+
8082
For more info see the linked documentation page.
8183
"""
8284
mutable struct ODEIntegrator{algType <: Union{OrdinaryDiffEqAlgorithm, DAEAlgorithm}, IIP,

src/nlsolve/functional.jl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,11 @@ end
2929
compute_step!(nlsolver::NLSolver{<:Union{NLFunctional,NLAnderson}}, integrator)
3030
3131
Compute the next step of the fixed-point iteration
32+
3233
```math
3334
g(z) = dt⋅f(tmp + γ⋅z, p, t + c⋅dt),
3435
```
36+
3537
and return the norm of ``g(z) - z``.
3638
3739
# References

src/nlsolve/nlsolve.jl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,11 @@
44
nlsolve!(nlsolver::AbstractNLSolver, integrator)
55
66
Solve
7+
78
```math
89
dt⋅f(innertmp + γ⋅z, p, t + c⋅dt) + outertmp = z
910
```
11+
1012
where `dt` is the step size and `γ` and `c` are constants, and return the solution `z`.
1113
"""
1214
function nlsolve!(nlsolver::AbstractNLSolver, integrator::DiffEqBase.DEIntegrator,

src/rkc_utils.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,7 @@ and `cache.start` (the start index of recurrence parameters for that
208208
degree), where `recf` are the `μ,κ` pairs
209209
for the `mdeg` degree method. The `κ` for `stage-1` for every degree
210210
is 0 therefore it's not included in `recf`
211-
"""
211+
"""
212212
function choosedeg!(cache::T) where {T}
213213
isconst = T <: OrdinaryDiffEqConstantCache
214214
isconst || (cache = cache.constantcache)

src/tableaus/feagin_tableaus.jl

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,6 @@ end
123123

124124
"""
125125
constructFeagin10
126-
127126
"""
128127
function Feagin10ConstantCache(T::Type{<:CompiledFloats}, T2::Type{<:CompiledFloats})
129128
adaptiveConst = convert(T, 0.002777777777777778)
@@ -279,7 +278,6 @@ end
279278

280279
"""
281280
constructFeagin10
282-
283281
"""
284282
function Feagin10ConstantCache(T::Type, T2::Type)
285283
adaptiveConst = convert(T, 1 // 360)
@@ -669,7 +667,6 @@ end
669667

670668
"""
671669
constructFeagin12
672-
673670
"""
674671
function Feagin12ConstantCache(T::Type{<:CompiledFloats}, T2::Type{<:CompiledFloats})
675672
adaptiveConst = convert(T, 49 // 640)
@@ -944,7 +941,6 @@ end
944941

945942
"""
946943
constructFeagin12
947-
948944
"""
949945
function Feagin12ConstantCache(T::Type, T2::Type)
950946
adaptiveConst = convert(T, 49 // 640)
@@ -1648,7 +1644,6 @@ end
16481644

16491645
"""
16501646
constructFeagin14
1651-
16521647
"""
16531648
function Feagin14ConstantCache(T::Type{<:CompiledFloats}, T2::Type{<:CompiledFloats})
16541649
adaptiveConst = convert(T, 1 // 1000)
@@ -2126,7 +2121,6 @@ end
21262121

21272122
"""
21282123
constructFeagin14
2129-
21302124
"""
21312125
function Feagin14ConstantCache(T::Type, T2::Type)
21322126
adaptiveConst = convert(T, 1 // 1000)

0 commit comments

Comments
 (0)