gustaf s oderlind lund university & e otv os lor and ......example modifying ode45 in matlab to...
TRANSCRIPT
Adaptive Linear Multistep MethodsDesigning Automatic Step Size Control for Multistep Methods
Gustaf SoderlindLund University & Eotvos Lorand University
Contents V1.1
• Classical control of asymptotic errorsAdaptive numerical ODE solvers
Linear multistep methods
• Control theoryTransfer functions and stability
The control design problem
• Dynamic error modelsConstructing a deadbeat controller
Modifying the controller
• Error estimationThe dynamic compensator
Scaling
c© G Soderlind, V1.1 ELTE, 4 April, 2019 Adaptive Linear Multistep Methods
1. Classical control of asymptotic errors
Time-stepping methods for initial value problem y = f (t, y)
Given an approximation yn ≈ y(tn) compute
yn 7→ yn+1
with time step size hn = tn+1 − tn
Work/accuracy trade-off
Put grid points where they matter to accuracy
c© G Soderlind, V1.1 ELTE, 4 April, 2019 Adaptive Linear Multistep Methods
Adaptive methods
Given an error tolerance tol, adaptive methods select thetime step hn to make the local error rn = tol
Static asymptotic step size – error model h→ 0
rn = ϕn hqn
Controller If ϕ is constant, choose hn+1 such that tol = ϕn hqn+1
⇒ hn+1 =
(tol
rn
)1/q
hn
makes rn+1 ≡ tol
c© G Soderlind, V1.1 ELTE, 4 April, 2019 Adaptive Linear Multistep Methods
Classical time-step control
In logarithmic form
log hn+1 − log hn =1
q(log tol− log rn)
Integrating control Summation of control errors
Linear difference equation, log r 7→ log h, where log r = {log rj}∞j=0
c© G Soderlind, V1.1 ELTE, 4 April, 2019 Adaptive Linear Multistep Methods
Example of actual heuristic implementation DASSL
Typical plot of log(hn+1/hn) vs. log(rn/tol)
10−2
10−1
100
101
102
100
Nonlinear, discontinuous and nonsymmetric!
◦
c© G Soderlind, V1.1 ELTE, 4 April, 2019 Adaptive Linear Multistep Methods
How well does it work? Chemakzo problem
10−10
10−8
10−6
10−4
10−10
10−8
10−6
10−4
TOL
achie
ved a
ccura
cy
10−10
10−8
10−6
10−4
102
103
achieved accuracy
# o
f fu
nction c
alls
10−10
10−8
10−6
10−4
101
102
TOL
# o
f ja
cobia
n c
alls
10−10
10−8
10−6
10−4
2
2.5
3
3.5
4
4.5
5
TOL
mean o
rder
Poor computational stability tol variatons have large effects
c© G Soderlind, V1.1 ELTE, 4 April, 2019 Adaptive Linear Multistep Methods
New improved controllers Chemakzo problem
10−10
10−8
10−6
10−4
10−10
10−8
10−6
10−4
TOL
ach
ieve
d a
ccu
racy
10−10
10−8
10−6
10−4
102
103
achieved accuracy
# o
f fu
nctio
n c
alls
10−10
10−8
10−6
10−4
101
102
TOL
# o
f ja
co
bia
n c
alls
10−10
10−8
10−6
10−4
2
2.5
3
3.5
4
4.5
5
TOL
me
an
ord
er
High computational stability Continuous dependence on tol
c© G Soderlind, V1.1 ELTE, 4 April, 2019 Adaptive Linear Multistep Methods
2. Control theory Feedback loop
Control
C (z)
Process
G (z)-log h --⊕
?
logϕ
log tol log r
−1
Static or dynamic asymptotic process model
r = ϕhq ⇒ log r = G (z) · log h + logϕ (G (z) = q)
Control law log h = C (z) · (log tol− log r)
c© G Soderlind, V1.1 ELTE, 4 April, 2019 Adaptive Linear Multistep Methods
Closed loop Controller – process interaction
Solve
log r = G (z) · log h + logϕ
log h = C (z) · (log tol− log r)
for Hϕ(z) : logϕ 7→ log h and Rϕ(z) : logϕ 7→ log r to find
Hϕ(z) = − C (z)
1 + C (z) · G (z)
Rϕ(q) =1
1 + C (z) · G (z)
Control design Low-pass filter for h and high-pass filter for r
c© G Soderlind, V1.1 ELTE, 4 April, 2019 Adaptive Linear Multistep Methods
Control design Choosing C (z)
General control structure
C (z) =P(z)
(z − 1)Q(z)
with degP = degQ corresponding to explicit step size recursion
(z − 1)Q(z) · log h = P(z) · (log r − log tol)
Control on multiplicative form filtering step size ratios ρ
ρn =
(tol
rn
)β1/q (tol
rn−1
)β2/q (tol
rn−2
)β3/q· ρα1
n−1 · ρα2n−2
hn+1 = ρn · hn
c© G Soderlind, V1.1 ELTE, 4 April, 2019 Adaptive Linear Multistep Methods
Control designs Static error model rn = ϕnhqn
Elementary control Q ≡ 1; P ≡ 1/qConvolution filter Q ≡ 1; P ≡ γ < 1/q
I control Q ≡ 1; degP = 0PI control Q ≡ 1; degP = 1
PID control Q ≡ 1; degP = 2FIR filter (z − 1)Q(z) + q · P(z) = zm
Autoregressive (AR) Q has zero(s) at z = 1Moving average (MA) P has zero(s) at z = −1
Noise shaping LP filter of MA type
hn+1 =
(tol
rn
)1/(bq)(tol
rn−1
)1/(bq)
ρ−1/bn−1 · hn
c© G Soderlind, V1.1 ELTE, 4 April, 2019 Adaptive Linear Multistep Methods
What step size properties can be achieved?
0 10 20 30 40 50 60 70 80 90 1000.4
0.5
0.6
0.7
0.8
0 10 20 30 40 50 60 70 80 90 1000.4
0.5
0.6
0.7
0.8
0 10 20 30 40 50 60 70 80 90 1000.4
0.5
0.6
0.7
0.8
Elementary control
FIR filter
Noise shaping filter
c© G Soderlind, V1.1 ELTE, 4 April, 2019 Adaptive Linear Multistep Methods
Example Modifying ode45 in Matlab to ode45dc
Step size sequences in chemotaxis problem
0 2 4 6 8 10 120
0.005
0.01
0.015
0.02
0.025
0.03
Original vs. modified code (PI controller)
c© G Soderlind, V1.1 ELTE, 4 April, 2019 Adaptive Linear Multistep Methods
3. Linear multistep methods
Example Adams–Bashforth two-step method AB2
yn+1 = yn +(
1 +ρn−1
2
)hny′n −
ρn−12
hny′n−1
Step size tn+1 = tn + hnStep ratio ρn−1 = hn/hn−1 = 1 + v , |v | � 1
Asymptotic local error, dynamic model
rn ≈5
12
...y (tn−1) h3n
(2
5+
3
5ρn−1
)≈ ϕn · hqn · ρδn−1
Static error parameter q = 3 and dynamic parameter δ = −3/5
c© G Soderlind, V1.1 ELTE, 4 April, 2019 Adaptive Linear Multistep Methods
Multiplicative approximation
Multinomials in step ratios occur frequently
1− θ +θ
ρ= 1− θ +
θ
1 + v
≈ 1− θ + θ(1− v)
= 1− θv
≈ (1 + v)−θ = ρ−θ
c© G Soderlind, V1.1 ELTE, 4 April, 2019 Adaptive Linear Multistep Methods
Local error structure k-step methods
Asymptotic error model, k = 2
rn = ϕn · hqn · ρδn−1
Static part as in one-step methods or constant step size theory
Dynamic part depends on current and past step sizes
General dynamic asymptotic error model, multiplicative form
rn = ϕn · hqn ·s∏
j=1
ρδjn−j
s = k − 1 for the actual error and s = k for error estimator
c© G Soderlind, V1.1 ELTE, 4 April, 2019 Adaptive Linear Multistep Methods
Process transfer function k = 2
Asymptotic error model, k = 2
rn = ϕn · hqn · ρδn−1 = ϕn · hq+δn h−δn−1
Taking logarithms
log rn = (q + δ) log hn − δ log hn−1 + logϕn
In terms of forward shift/z transform
log r =
(q + δ − δ
z
)log h + logϕ
Transfer function
GAB2(z) = q + δ · z − 1
z=
(q + δ)z − δz
=12z + 3
5z
c© G Soderlind, V1.1 ELTE, 4 April, 2019 Adaptive Linear Multistep Methods
Elementary control
hn+1 =
(tol
rn
)1/q
hn
Taking logarithms
log hn+1 − log hn =1
q(log tol− log rn)
In terms of forward shift/z transform
(z − 1) log h =1
qlog
tol
r
Control transfer function
C0(z) =1
q
1
z − 1
c© G Soderlind, V1.1 ELTE, 4 April, 2019 Adaptive Linear Multistep Methods
Closed loop error transfer function k = 2
Rϕ(z) =1
1 + C0(z) · G2(z)=
(z − 1)z
z2 + δq z −
δq
Deadbeat (FIR)
Static model (δ = 0) has Rϕ(z) = z−1z , a single pole at z = 0
In general (δ 6= 0), poles at
z =−δ ±
√δ2 + 4δq
2q
The closed loop is stable if |z | < 1
c© G Soderlind, V1.1 ELTE, 4 April, 2019 Adaptive Linear Multistep Methods
Closed loop poles for some 2-step methods
AB2 zAB2 =1± i√
19
10; |zAB2| = 1/
√5 ≈ 0.4472
AM2 zAM2 =1± i√
55
28; |zAM2| = 1/
√14 ≈ 0.2673
BDF2 zBDF2 =1± i√
17
9; |zBDF2| =
√2/9 ≈ 0.4714
EMP zEMP =1± i
√23
12; |zEMP| = 1/
√6 ≈ 0.4082
c© G Soderlind, V1.1 ELTE, 4 April, 2019 Adaptive Linear Multistep Methods
Closed loop poles . . .
Even for k = 2 the elementary controller has
• poor stability
• complex conjugate poles
• damped oscillatory homogeneous solutions
Need dedicated controllers compensating dynamics in error model
c© G Soderlind, V1.1 ELTE, 4 April, 2019 Adaptive Linear Multistep Methods
An intuitive controller It’s even worse!
Derive new controller, assuming ϕn+1 ≈ ϕn
tol = ϕn+1 · hq+δn+1 · h−δn
rn = ϕn · hq+δn · h−δn−1
⇒ hn+1 =
(tol
rn
)1/(q+δ)
ρ−δ/(q+δ)n−1 · hn
Closed loop poles z =
{0δ
q+δ
Not deadbeat, and if δ < 0, then a negative root causes overshoot
δAB2 = −35 δAM2 = −2
7 δBDF2 = −23 δEMP = −1
2
c© G Soderlind, V1.1 ELTE, 4 April, 2019 Adaptive Linear Multistep Methods
A general theorem Pole placement
Theorem Assume dynamic asymptotic error model
rn = ϕn hqn ·
s∏j=1
ρδjn−j
combined with step size control law
hn+1 =
(tol
rn
)β/qhn ·
s∏j=1
ραj
n−j
Taking αj = βδj/q implies one pole z = 1− β and s poles z = 0
If in addition β = 1, the controller is deadbeat
c© G Soderlind, V1.1 ELTE, 4 April, 2019 Adaptive Linear Multistep Methods
A general theorem . . .
One parameter family of controllers, with “integral gain” β
hn+1 =
tol
rn·
s∏j=1
ρδjn−j
β/q
hn
• Stable for β ∈ [0, 2]
• Deadbeat at β = 1
• Single positive pole for β ∈ (0, 1)
• Smooth exponential forgetting filter β < 1
• Good performance across methods β = 2/3
• Other controllers can be designed by pole placement
c© G Soderlind, V1.1 ELTE, 4 April, 2019 Adaptive Linear Multistep Methods
A dynamic compensator
Note rn = ϕn hqn ·∏s
j=1 ρδjn−j ⇒ rn ·
∏sj=1 ρ
−δjn−j = ϕn h
qn
hn+1 =
tol
rn·
s∏j=1
ρδjn−j
β/q
hn =
tol
rn ·∏s
j=1 ρ−δjn−j
β/q
hn
Definition Dynamically compensated error rn = rn ·∏s
j=1 ρ−δjn−j
• Satisfies static model rn = ϕn hqn
• Compatible magnitude rn ≈ rn since ρn−j ≈ 1
• Can be controlled using standard static digital filters
c© G Soderlind, V1.1 ELTE, 4 April, 2019 Adaptive Linear Multistep Methods
4. Error estimation
Problem Actual asymptotic local error is not computable
Grid independent methods advance the solution by
• Constructing a polynomial Pn+1(t)
• . . . satisfying characteristic conditions on
• . . . interpolation, collocation and slack
• Defining yn+1 = Pn+1(tn+1)
• Estimating the error by en = ‖Pn+1(tn+1)− Pn(tn+1)‖
Problem Is computable estimate en related to rn?
c© G Soderlind, V1.1 ELTE, 4 April, 2019 Adaptive Linear Multistep Methods
Error estimate
• Pn+1(t) and Pn(t) depend on similar data
• Only differences in y ′n+1, yn and y ′n−k , yn−k
• . . . and in step ratios ρn−1 and ρn−s−1
Computable error estimate
en = c y (q)(tn) · hqn ·s+1∏j=1
ρδjn−j
Actual asymptotic error
rn = c∗y (q)(tn) · hqn ·s∏
j=1
ρδjn−j
c© G Soderlind, V1.1 ELTE, 4 April, 2019 Adaptive Linear Multistep Methods
Error estimate
Error magnitude (due to ρn−j ≈ 1)
rn ≈c∗
c· en
Controller interacts with dynamics of estimator
Proposed control quantity
rn =c∗
c· ‖Pn+1(tn+1)− Pn(tn+1)‖ ·
s+1∏j=1
ρ−δjn−j
to be controlled by standard filters for static models with gain q
Includes magnitude compensator c∗/c and dynamic compensator
c© G Soderlind, V1.1 ELTE, 4 April, 2019 Adaptive Linear Multistep Methods
Error estimate in AB2
Asymptotic dynamic model of computable error estimator
en =23
12
...y (tn) · h3n · ρ
−45/23n−1 ρ
−12/23n−2
Dynamic model of actual asymptotic error
rn =5
12
...y (tn) · h3n · ρ
−3/5n−1
implies control quantity
rn =5
23· ‖Pn+1(tn+1)− Pn(tn+1)‖ · ρ45/23n−1 ρ
12/23n−2
c© G Soderlind, V1.1 ELTE, 4 April, 2019 Adaptive Linear Multistep Methods
A few conclusions
• Multistep methods always have a dynamic error model
• Classical, elementary controller works less well
• A true deadbeat (FIR) controller can be constructed
• A dynamic model for the error estimator is needed
• Compensate error estimator for dynamics and magnitude
• Stable interaction with well-known digital filter controllers
c© G Soderlind, V1.1 ELTE, 4 April, 2019 Adaptive Linear Multistep Methods
Thank you!
c© G Soderlind, V1.1 ELTE, 4 April, 2019 Adaptive Linear Multistep Methods