You are on page 1of 18

Technische Universitat Munchen

Algorithms of Scientific Computing


Fast Poisson Solvers
Michael Bader
Summer Term 2012

Michael Bader: Algorithms of Scientific Computing


Fast Poisson Solvers, Summer Term 2012 1
Technische Universitat Munchen

Part I

Excursion: Discrete Models for Heat


Transfer and the Poisson Equation
Modelling of Heat Transfer
objective: compute the temperature distribution of some object
under certain prerequisites:
temperature T at object boundaries given
heat sources
material parameters k , . . .
observation from physical experiments:

q k T

heat flow proportional to temperature differences

Michael Bader: Algorithms of Scientific Computing


Fast Poisson Solvers, Summer Term 2012 2
Technische Universitat Munchen

A Wiremesh Model
consider rectangular plate as fine mesh of wires
compute temperature Tij T (xij ) at nodes xij of the mesh

x i,j+1

x i1,j x i,j x i+1,j

x i,j1

hy
hx

Michael Bader: Algorithms of Scientific Computing


Fast Poisson Solvers, Summer Term 2012 3
Technische Universitat Munchen

Wiremesh Model (2)


model assumption:
temperatures in equilibrium at every mesh node
for all temperatures Tij :

1 
Tij = Ti1,j + Ti+1,j + Ti,j1 + Ti,j+1
4
temperature known at (part of) the boundary; for example:

T0,j = 0 Tn,j = 1

task: solve system of linear equations


in standard notation:

Ti1,j Ti+1,j + 4Tij Ti,j1 Ti,j+1 = 0

Michael Bader: Algorithms of Scientific Computing


Fast Poisson Solvers, Summer Term 2012 4
Technische Universitat Munchen

A Finite Volume Model


object: a rectangular metal plate (again)
model as a collection of small connected rectangular cells

hy
hx
examine the heat flow across the cell edges
Michael Bader: Algorithms of Scientific Computing
Fast Poisson Solvers, Summer Term 2012 5
Technische Universitat Munchen

Heat Flow Across the Cell Boundaries


Heat flow across a given edge is proportional to
temperature difference (T1 T0 ) between the adjacent cells
length h of the edge
e.g.: heat flow across the left edge:

(left) 
qij = kx Tij Ti1,j hy

kx depends on material
heat flow across all edges determines change of heat energy:
 
qij = kx Tij Ti1,j hy + kx Tij Ti+1,j hy
 
+ ky Tij Ti,j1 hx + ky Tij Ti,j+1 hx

Michael Bader: Algorithms of Scientific Computing


Fast Poisson Solvers, Summer Term 2012 6
Technische Universitat Munchen

Temperature change due to heat flow


model assumption: conservation of energy, i.e.,
in equilibrium, total heat flow equal to 0 for each cell
or: consider additional source term Fij due to
external heating

radiation

Fij = fij hx hy (fij heat flow per area)
equilibrium with source term requires qij + Fij = 0:

fij hx hy = kx hy 2Tij Ti1,j Ti+1,j

ky hx 2Tij Ti,j1 Ti,j+1

Michael Bader: Algorithms of Scientific Computing


Fast Poisson Solvers, Summer Term 2012 7
Technische Universitat Munchen

Finite Volume Model


divide by hx hy :

kx 
fij = 2Tij Ti1,j Ti+1,j
hx
ky 
2Tij Ti,j1 Ti,j+1
hy

again, system of linear equations


how to treat boundaries?
prescribe temperature in a cell
(e.g. boundary layer of cells)
prescribe heat flow across an edge;
for example insulation at left edge:
(left)
qij =0

Michael Bader: Algorithms of Scientific Computing


Fast Poisson Solvers, Summer Term 2012 8
Technische Universitat Munchen

From Discrete to Continuous


system of equations derived from the discrete model:

kx 
fij = 2Tij Ti1,j Ti+1,j
hx
ky 
2Tij Ti,j1 Ti,j+1
hy

assumption: heat flow across edges is proportional to


temperature difference
(left) 
qij = kx Tij Ti1,j hy

in reality: heat flow proportional to temperature gradient

(left) Tij Ti1,j


qij khy
hx

Michael Bader: Algorithms of Scientific Computing


Fast Poisson Solvers, Summer Term 2012 9
Technische Universitat Munchen

From Discrete to Continuous (2)


replace kx by k/hx , ky by k /hy , and get:

k 
fij = 2
2Tij Ti1,j Ti+1,j
hx
k 
2 2Tij Ti,j1 Ti,j+1
hy

consider arbitrary small cells: hx , hy 0:

2T 2T
   
fij = k k
x 2 ij y 2 ij

leads to partial differential equation (PDE):

2 T (x, y ) 2 T (x, y )
 
k + = f (x, y )
x 2 y 2

Michael Bader: Algorithms of Scientific Computing


Fast Poisson Solvers, Summer Term 2012 10
Technische Universitat Munchen

Part II

Fast Poisson Solvers and the Sine


Transform
situation: solve a system of linear equations

ui1,j ui+1,j + 4uij ui,j1 ui,j+1 = fij i, j

or, simpler, for a 1D problem:

un1 + 2un un+1 = fn for n = 1, . . . , N 1

with u0 = uN = 0
consider very fine meshes, for example with 1000 1000
unknowns (in 2D)
actually simple to solve in 1D (tri-diagonal system),
but hard to solve in 2D (and even harder in 3D)
Michael Bader: Algorithms of Scientific Computing
Fast Poisson Solvers, Summer Term 2012 11
Technische Universitat Munchen

Applying the Sine Transform


Idea: apply discrete sine transfrom on un and fn
N1 N1
X nk X nk
un = 2 Uk sin , fn = 2 Fk sin (1)
N N
k=1 k =1

into the system of equations

un1 + 2un un+1 = fn for n = 1, . . . , N 1

Why should that help?


corresponding continuous problem is u 00 (x) = f (x)
is solved by u(x) = sin(x), if f (x) = sin(x)
(with u(x) = 0 at both boundaries)
sine modes are eigenvectors of the system matrix, and
eigenmodes of the continuous solution

Michael Bader: Algorithms of Scientific Computing


Fast Poisson Solvers, Summer Term 2012 12
Technische Universitat Munchen

Applying the Sine Transform (2)


We insert the transformations
N1 N1
X nk X nk
un = 2 Uk sin and fn = 2 Fk sin
N N
k=1 k=1

into the system of linear equations


un+1 + 2un un1 = fn for n = 1, . . . , N 1
u0 = uN = 0,
and get, for n = 1, . . . , N 1:
N1 N1 N1
X (n + 1)k X nk X (n 1)k
2 Uk sin +4 Uk sin 2 Uk sin
N N N
k=1 k=1 k=1
N1
X nk
=2 Fk sin
N
k=1

Michael Bader: Algorithms of Scientific Computing


Fast Poisson Solvers, Summer Term 2012 13
Technische Universitat Munchen

Applying the Sine Transform (3)


Use theorems of addition
sin(A + B) = sin(A) cos(B) + cos(A) sin(B) and
sin(A B) = sin(A) cos(B) cos(A) sin(B)
applied to:
   
(n + 1)k nk k
sin = sin + and
N N N
   
(n 1)k nk k
sin = sin
N N N
We have the situation
sin(A + B) + sin(A B) = 2 sin(A) cos(B)
or, particularly:
       
(n + 1)k (n 1)k nk k
sin + sin = 2 sin cos
N N N N
Michael Bader: Algorithms of Scientific Computing
Fast Poisson Solvers, Summer Term 2012 14
Technische Universitat Munchen

Applying the Sine Transform (4)


Use theorems of addition in the left-hand side:
N1
X  N1
(n + 1)k (n 1)k X nk
2 Uk sin + Uk sin +4 Uk sin
N N N
k=1 k=1
N1 N1
X nk k X nk
4 Uk sin cos +4 Uk sin
N N N
k =1 k=1

and obtain simplified system of equations:


N1 N1 N1
X nk k X nk X nk
4 Uk sin cos +4 Uk sin =2 Fk sin
N N N N
k=1 k=1 k=1
N1   N1
X nk k X nk
2 Uk sin 1 cos = Fk sin
N N N
k =1 k =1

Michael Bader: Algorithms of Scientific Computing


Fast Poisson Solvers, Summer Term 2012 15
Technische Universitat Munchen

Solution of the System of Equations


We transformed the system of equations into
N1   N1
X nk k X nk
2 Uk sin 1 cos = Fk sin
N N N
k=1 k=1

All equations are satisfied, if


 
k
2Uk 1 cos = Fk for all k = 1, . . . , N 1
N

This is true, if we set


Fk
Uk = for all k = 1, . . . , N 1.
2 2 cos k
N

Michael Bader: Algorithms of Scientific Computing


Fast Poisson Solvers, Summer Term 2012 16
Technische Universitat Munchen

Fast Poisson Solver Algorithm


1. Compute the coefficients Fk by a Fast Sine Transform:
N1
1 X nk
Fk = fn sin
N N
n=1

2. Compute all coefficients Uk from the Fk as

Fk
Uk = for all k = 1, . . . , N 1.
2 2 cos k
N

3. Compute the un from the Uk by means of an Inverse


Fast Sine Transform:
N1
X nk
un = 2 Uk sin ,
N
k=1

Michael Bader: Algorithms of Scientific Computing


Fast Poisson Solvers, Summer Term 2012 17
Technische Universitat Munchen

Fast Poisson Solver Algorithm (2)


Computational Costs:
the two Fast Sine Transforms require O(N log N) operations
step 2 needs only O(N) operations
total computational effort is O(N log N)
thus: slower than solving the tridiagonal system of equations
directly, which has effort O(N)
however: pays off in 2D and higher-dimensional settings!

When can the Algorithm be applied:


boundary conditions need to be u0 = uN = 0
(otherwise: different transform required)
requires rectangular/cuboid domain and Cartesian mesh
requires uniform material parameters k

Michael Bader: Algorithms of Scientific Computing


Fast Poisson Solvers, Summer Term 2012 18

You might also like