@@ -33,9 +33,11 @@ many problems/algorithms.
33
33
34
34
Construct an integral (I) step size controller adapting the time step
35
35
based on the formula
36
+
36
37
```
37
38
Δtₙ₊₁ = εₙ₊₁^(1/k) * Δtₙ
38
39
```
40
+
39
41
where `k = get_current_adaptive_order(alg, integrator.cache) + 1` and `εᵢ` is the
40
42
inverse of the error estimate `integrator.EEst` scaled by the tolerance
41
43
(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
46
48
the predicted step size.
47
49
48
50
## 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)
52
55
"""
53
56
struct IController <: AbstractController
54
57
end
@@ -92,9 +95,11 @@ with improved stability properties compared to the [`IController`](@ref).
92
95
This controller is the default for most algorithms in OrdinaryDiffEq.jl.
93
96
94
97
Construct a PI step size controller adapting the time step based on the formula
98
+
95
99
```
96
100
Δtₙ₊₁ = εₙ₊₁^β₁ * εₙ^β₂ * Δtₙ
97
101
```
102
+
98
103
where `εᵢ` are inverses of the error estimates scaled by the tolerance
99
104
(Hairer, Nørsett, Wanner, 2010, Section IV.2).
100
105
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
104
109
the predicted step size.
105
110
106
111
!!! note
112
+
107
113
The coefficients `beta1, beta2` are not scaled by the order of the method,
108
114
in contrast to the [`PIDController`](@ref). For the `PIController`, this
109
115
scaling by the order must be done when the controller is constructed.
110
116
111
117
## 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)
118
125
"""
119
126
mutable struct PIController{QT} <: AbstractController
120
127
beta1:: QT
@@ -174,36 +181,42 @@ The proportional-integral-derivative (PID) controller is a generalization of the
174
181
[`PIController`](@ref) and can have improved stability and efficiency properties.
175
182
176
183
Construct a PID step size controller adapting the time step based on the formula
184
+
177
185
```
178
186
Δtₙ₊₁ = εₙ₊₁^(β₁/k) * εₙ^(β₂/k) * εₙ₋₁^(β₃/ k) * Δtₙ
179
187
```
188
+
180
189
where `k = min(alg_order, alg_adaptive_order) + 1` and `εᵢ` are inverses of
181
190
the error estimates scaled by the tolerance (Söderlind, 2003).
182
191
The step size factor is limited by the `limiter` with default value
192
+
183
193
```
184
194
limiter(x) = one(x) + atan(x - one(x))
185
195
```
196
+
186
197
as proposed by Söderlind and Wang (2006). A step will be accepted whenever the
187
198
predicted step size change is bigger than `accept_safety`. Otherwise, the step
188
199
is rejected and re-tried with the predicted step size.
189
200
190
201
Some standard controller parameters suggested in the literature are
191
202
192
203
| 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` |
200
211
201
212
!!! note
213
+
202
214
In contrast to the [`PIController`](@ref), the coefficients `beta1, beta2, beta3`
203
215
are scaled by the order of the method. Thus, standard controllers such as PI42
204
216
can use the same coefficients `beta1, beta2, beta3` for different algorithms.
205
217
206
218
!!! note
219
+
207
220
In contrast to other controllers, the `PIDController` does not use the keyword
208
221
arguments `qmin, qmax` to limit the step size change or the safety factor `gamma`.
209
222
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
212
225
even if `beta1, beta2` are adapted accordingly and `iszero(beta3)`.
213
226
214
227
## 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)
225
239
"""
226
240
struct PIDController{QT, Limiter} <: AbstractController
227
241
beta:: MVector{3, QT} # controller coefficients
@@ -326,39 +340,47 @@ for algorithms like the (E)SDIRK methods.
326
340
```julia
327
341
gamma = integrator.opts.gamma
328
342
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))
333
349
if q <= integrator.opts.qsteady_max && q >= integrator.opts.qsteady_min
334
- q = one(q)
350
+ q = one(q)
335
351
end
336
352
integrator.qold = q
337
353
q
338
354
```
355
+
339
356
In this case, `niters` is the number of Newton iterations which was required
340
357
in the most recent step of the algorithm. Note that these values are used
341
358
differently depending on acceptance and rejectance. When the step is accepted,
342
359
the following logic is applied:
360
+
343
361
```julia
344
362
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)
349
369
else
350
- qacc = q
370
+ qacc = q
351
371
end
352
372
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
355
375
```
376
+
356
377
When it rejects, it's the same as the [`IController`](@ref):
378
+
357
379
```julia
358
380
if integrator.success_iter == 0
359
- integrator.dt *= 0.1
381
+ integrator.dt *= 0.1
360
382
else
361
- integrator.dt = integrator.dt/ integrator.qold
383
+ integrator.dt = integrator.dt / integrator.qold
362
384
end
363
385
```
364
386
"""
0 commit comments