Case study in Scientific Computing: Optimal control of PDE

Case study in Scientific Computing:
Optimal control of PDE
Iain Smears
University of Oxford
2015
InFoMM CDT
Overview
The purpose of this case study is to learn a range of tools in
modelling and scientific computing:
• modelling and mathematical formulations of optimisation problems
with PDE constraints.
• numerical discretisation methods, such as finite element methods,
and the saddle-point structure of the resulting discrete systems.
• how to solve quickly and efficiently the resulting discrete systems
with preconditioned iterative solvers.
On the practical side, we will learn how to use FENiCS + PETSc to
access a wide range of readily implemented iterative solvers and
preconditioners.
1/10
A short introduction to optimal control of PDE
Consider1 the following Poisson control problem.:
Given β > 0, and an objective function û, find u and f s.t.
1
β
min ku − ûk2L2 (Ω) + kf k2L2 (Ω) ,
2
2
−∆u = f in Ω,
subject to
u = g on ∂Ω.
(1)
(2)
In applications:
• u is the electrostatic/gravitational potential, f is the charge/mass
distribution, and û is a target potential.
1
NB: The notation here differs from many references, esp. u vs f .
2/10
A short introduction to optimal control of PDE
To simplify, assume that the boundary data g = 0, so u = 0 on ∂Ω.
Recall the weak formulation of the elliptic PDE
−∆u = f
in Ω,
(3)
u = 0 on ∂Ω.
Multiply the PDE by a test function v and integrate by parts:
Z
Ω
(−∆u) v dx = −
Z
∂Ω
(∇u · n) v ds +
Z
∇u · ∇v dx .
Ω
3/10
A short introduction to optimal control of PDE
To simplify, assume that the boundary data g = 0, so u = 0 on ∂Ω.
Recall the weak formulation of the elliptic PDE
−∆u = f
in Ω,
(3)
u = 0 on ∂Ω.
Multiply the PDE by a test function v and integrate by parts:
Z
Z
(−∆u) v dx = − (∇u
· n) v ds +
Ω
∂Ω
Z
∇u · ∇v dx .
Ω
Assume v = 0 on ∂Ω, similarly to u.
The weak formulation of (3) is
Z
Ω
∇u · ∇v dx =
Z
f v dx
(4)
Ω
We will use the weak formulation (4) to discretise the problem.
aside: the functions u and v belong to the function space called H01 (Ω).
3/10
A short introduction to optimal control of PDE
Discretisation approach:
1. Define a space of functions that approximate the continuous
solution.
2. Define a discrete constrained minimisation problem on the
approximation space that matches the continuous problem.
3. Use the discrete problem to derive a saddle-point system of linear
equations, that will need to be solved to obtain the approximate
solutions.
This is a discretise-then-optimise approach.
4/10
A short introduction to optimal control of PDE
Choose a mesh Th = {K } on Ω, and define the finite element space
Vh by
Vh = {vh ∈ H01 (Ω) : vh |K ∈ Pk ∀K ∈ Th }.
5/10
A short introduction to optimal control of PDE
Choose a mesh Th = {K } on Ω, and define the finite element space
Vh by
Vh = {vh ∈ H01 (Ω) : vh |K ∈ Pk ∀K ∈ Th }.
Continuous PDE: find u ∈ H01 (Ω) such that
Z
Ω
∇u · ∇v dx =
Z
f v dx ,
Ω
∀v ∈ H01 (Ω)
5/10
A short introduction to optimal control of PDE
Choose a mesh Th = {K } on Ω, and define the finite element space
Vh by
Vh = {vh ∈ H01 (Ω) : vh |K ∈ Pk ∀K ∈ Th }.
Discretised PDE: find uh ∈ Vh such that
Z
Ω
∇uh · ∇vh dx =
Z
Ω
fh vh dx ,
∀vh ∈ Vh .
5/10
A short introduction to optimal control of PDE
Discrete control problem:
1
β
min kuh − ûk2L2 (Ω) + kfh k2L2 (Ω) ,
Z 2
Z2
subject to
Ω
∇uh · ∇vh dx =
Ω
fh vh dx
(5)
∀vh ∈ Vh .
(6)
If {φi }ni=1 denotes a basis of Vh , then uh ⇐⇒ u = (U1 , . . . , Un ).
Mij :=
Z
φi φj dx
Ω
Kij :=
Z
∇φi · ∇φj dx
Ω
zi :=
Z
û φi dx
Ω
So the discrete problem is equivalent to
1
β
1
min u> M u − u> z + kûk2L2 (Ω) + f > M f,
2
2
2
subject to K u − M f = 0.
(7)
(8)
6/10
A short introduction to optimal control of PDE
Discrete control problem:
1
β
min kuh − ûk2L2 (Ω) + kfh k2L2 (Ω) ,
Z 2
Z2
subject to
Ω
∇uh · ∇vh dx =
Ω
fh vh dx
(5)
∀vh ∈ Vh .
(6)
If {φi }ni=1 denotes a basis of Vh , then uh ⇐⇒ u = (U1 , . . . , Un ).
Mij :=
Z
φi φj dx
Ω
Kij :=
Z
∇φi · ∇φj dx
Ω
zi :=
Z
û φi dx
Ω
So the discrete problem is equivalent to
1
1
β
min u> M u − u> z + kûk2L2 (Ω) + f > M f,
2
2
2
subject to K u − M f = 0.
(7)
(8)
6/10
A short introduction to optimal control of PDE
Discrete control problem:
1
β
min kuh − ûk2L2 (Ω) + kfh k2L2 (Ω) ,
Z 2
Z2
subject to
Ω
∇uh · ∇vh dx =
Ω
fh vh dx
(5)
∀vh ∈ Vh .
(6)
If {φi }ni=1 denotes a basis of Vh , then uh ⇐⇒ u = (U1 , . . . , Un ).
Mij :=
Z
φi φj dx
Ω
Kij :=
Z
∇φi · ∇φj dx
Ω
zi :=
Z
û φi dx
Ω
So the discrete problem is equivalent to
1
1
β
min u> M u − u> z + kûk2L2 (Ω) + f > M f,
2
2
2
subject to K u − M f = 0.
(7)
(8)
6/10
A short introduction to optimal control of PDE
Introduce Lagrangian
1
1
β
L := u> M u − u> z + kûk2L2 (Ω) + f > M f + p> (K u − M f)
2
2
2
Then find a critical point:
∂u L = 0 =⇒
M u + K p = z, (adjoint eq.)
∂f L = 0 =⇒
βM f − M p = 0, (gradient eq.)
∂p L = 0 =⇒
(9)
K u − M f = 0. (state eq.)
So, eliminating f = β1 p, we see that (9) is equivalent to the
saddle-point system
"
M
K
K − β1 M
#" #
" #
u
z
=
p
0
(10)
7/10
A short introduction to optimal control of PDE
Saddle-point system:
M
K
K
− β1 M
u
z
=
p
0
(10)
Our goals:
1. Fast and robust iterative solution methods for solving saddle-point
systems: (10).
→ Schur complement, Krylov subspace methods (MINRES),
preconditioners.
2. Mathematical theory of preconditioning saddle-point systems:
→ Spectral equivalence, symmetry of system and preconditioners,
eigenvalues of schur complement preconditioners.
3. Practical computational tools:
→ FEniCS finite element methods + PETSc numerical linear algebra:
access to many finite elements, Krylov subspace methods and
preconditioning algorithms.
8/10
A short introduction to optimal control of PDE
Saddle-point system:
M
K
K
− β1 M
u
z
=
p
0
(10)
Our goals:
1. Fast and robust iterative solution methods for solving saddle-point
systems: (10).
→ Schur complement, Krylov subspace methods (MINRES),
preconditioners.
2. Mathematical theory of preconditioning saddle-point systems:
→ Spectral equivalence, symmetry of system and preconditioners,
eigenvalues of schur complement preconditioners.
3. Practical computational tools:
→ FEniCS finite element methods + PETSc numerical linear algebra:
access to many finite elements, Krylov subspace methods and
preconditioning algorithms.
8/10
A short introduction to optimal control of PDE
Saddle-point system:
M
K
K
− β1 M
u
z
=
p
0
(10)
Our goals:
1. Fast and robust iterative solution methods for solving saddle-point
systems: (10).
→ Schur complement, Krylov subspace methods (MINRES),
preconditioners.
2. Mathematical theory of preconditioning saddle-point systems:
→ Spectral equivalence, symmetry of system and preconditioners,
eigenvalues of schur complement preconditioners.
3. Practical computational tools:
→ FEniCS finite element methods + PETSc numerical linear algebra:
access to many finite elements, Krylov subspace methods and
preconditioning algorithms.
8/10
Case study outline: Plan
Course plan:
1. Basic FEniCS: Importing Dolfin, mesh, function spaces, bilinear forms,
boundary conditions, matrix assembly.
2. Basic PETSc interface: creating PETSc Krylov solvers and preconditioners,
passing options to PETSc, available algorithms.
3. Saddle-point systems: Schur complement, eigenvalues of ideal/approximate
schur-complement preconditioned systems.
4. MINRES: Krylov subspace method for symmetric indefinite systems,
convergence theory.
5. Preconditioning M and K : Chebyshev semi-iteration, multigrid, how to use
these in PETSc.
6. Block preconditioners: extracting sub-matrices/vectors in PETSc, the
PETSC mat shell-preconditioner.
Putting it all together: preconditioned saddle-point system solver!
9/10
Case study outline: Assessment
Assessment is on code + presentation.
Coding goals:
? 3-dimensional Poisson control solver that can handle > 1M DoFs
without running out of memory.
? Flexible code: easy to make changes to the problem, e.g. adding
coefficients, boundary conditions, general meshes.
? Robust code: can handle large range of parameter values, esp. β.
Presentation goals:
? Present the results on a specified problem: convergence analysis,
iteration numbers, computational speed.
? Explain which algorithms were used and why, and which
parameter-choices give best performance.
10/10