• No results found

Iterative Solvers for Linear Systems

N/A
N/A
Protected

Academic year: 2021

Share "Iterative Solvers for Linear Systems"

Copied!
71
0
0

Loading.... (view fulltext now)

Full text

(1)

9th SimLab Course on Parallel Numerical Simulation, 4.10 – 8.10.2010

Iterative Solvers for Linear Systems

Bernhard Gatzhammer

Chair of Scientific Computing in Computer Science

Technische Universität München

(2)

Outline

• Poisson-Equation: From the Model to an Equation System

• Direct Solvers vs. Iterative Solvers

• Jacobi and Gauss-Seidel Method

• Residual and Smoothness

(3)

Outline

• Poisson-Equation: From the Model to an Equation System

• Direct Solvers vs. Iterative Solvers

• Jacobi and Gauss-Seidel Method

• Residual and Smoothness

(4)

• General:

• 1D:

• 2D:

The Poisson Equation – An Elliptic PDE

-

2

R

d

,

±

-

2

R

d

¡

1

,

u

: -

!

R

¢

u

=

f

in -

(¢ =

r

2

=

r ¢ r

)

@

2

u

@x

2

1

+

@

2

u

@x

2

2

+

: : :

+

@

2

u

@x

2

d

=

f

in

-u

=

g

on

±

--

2

R

,

@

2

u

@x

2

=

f

in

--

2

R

2

,

@

2

u

@x

2

+

@

2

u

@x

2

=

f

in

(5)

-The Laplace operator is part of many important PDEs:

• Heat equation: diffusion of heat

Why the Poisson Equation is of Importance

(6)

The Laplace operator is part of many important PDEs:

• Flow dynamics: friction between molecules

Why the Poisson Equation is of Importance

(7)

The Laplace operator is part of many important PDEs:

• Structural mechanics: displacement of membrane structures

Why the Poisson Equation is of Importance

(8)

The Laplace operator is part of many important PDEs:

• Electrics: electric-, magnetic potentials

Why the Poisson Equation is of Importance

(9)

The Laplace operator is part of many important PDEs:

• Financial mathematics: Diffusive process for option pricing

Why the Poisson Equation is of Importance

(10)

The Laplace operator is part of many important PDEs:

• Heat equation: diffusion of heat

• Flow dynamics: friction between molecules

• Structural mechanics: displacement of membrane structures

• Electrics: electric-, magnetic potentials

• Financial mathematics: Diffusive process for option pricing

• ...

Why the Poisson Equation is of Importance

(11)

Find solution to Poisson equation numerically on a computer:

• Computer has only a finite amount of memory/power

discretization

• Finite Differences as simple discretization

• Idea: Replace derivative by difference

Discretization with Finite Differences I

u

(

x

+

h

)

¡

u

(

x

)

h

h

!

0

¡¡¡!

@u

@x

u

(

x

)

¡

u

(

x

¡

h

)

h

!

0

¡¡¡!

@u

x

x

+

h

(12)

Use forward and backward differences for 2

nd

derivatives:

Discretization with Finite Differences II

@

2

u

@x

2

=

@

@x

@u

@x

¼

@x

@

u

(

x

+

h

h

)

¡

u

(

x

)

¼

u

(

x

+

h

)

¡

u

(

x

)

h

¡

u

(

x

+

h

¡

h

)

¡

u

(

x

¡

h

)

h

h

=

u

(

x

+

h

)

¡

2

u

(

x

) +

u

(

x

¡

h

)

h

2

forward diff.:

backward diff.:

(13)

Regular Cartesian grid: Nodal equation: Stencil:

System matrix:

Grid, Stencil, and Matrix 1D

x

i

=

ih

x

i

x

i

+1

x

i

¡

1

1

¡

2

1

1 2 3 x

h

u

i

¡

1

¡

2

u

i

+

u

i

+1

=

h

2

f

i

A

=

1

h

2

0

@

¡

1

2

¡

1

2

0

1

0

1

¡

2

1

A

(14)

Regular Cartesian grid:

Nodal equation:

Stencil:

Grid, Stencil, and Matrix 2D

h

h

x

i;j

= (

ih; jh

)

u

i

¡

1

;j

+

u

i

+1

;j

+

u

i;j

¡

1

+

u

i;j

+1

¡

4

u

i;j

=

h

2

f

i;j

1

¡

4

1

1

1

x

i;j

x

i

+1

;j

x

i

¡

1

;j

x

i;j

¡

1

x

i;j

+1

(15)

System matrix:

Grid, Stencil, and Matrix 2D

A

=

1

h

2

0

B

B

B

B

B

B

B

B

B

B

B

B

@

¡

4

1

¢

1

¢

¢

¢

¢

¢

1

¡

4

1

¢

1

¢

¢

¢

¢

¢

1

¡

4

¢

¢

1

¢

¢

¢

1

¢

¢

¡

4

1

¢

1

¢

¢

¢

1

¢

1

¡

4

1

¢

1

¢

¢

¢

1

¢

1

¡

4

¢

¢

1

¢

¢

¢

1

¢

¢

¡

4

1

¢

¢

¢

¢

¢

1

¢

1

¡

4

1

¢

¢

¢

¢

¢

1

¢

1

¡

4

1

C

C

C

C

C

C

C

C

C

C

C

C

A

1

¡

4

1

1

h

h

(16)

We obtain a system of equations to be solved:

is the number of grid unknowns, i.e. equations

contains sink/source terms and boundary influences

• We want to obtain

Discretized Poisson Equation

Au

=

f

,

A

2

R

N

£

N

,

u; f

2

R

N

N

f

(17)

Outline

• Poisson-Equation: From the Model to an Equation System

• Direct Solvers vs. Iterative Solvers

• Jacobi and Gauss-Seidel Method

• Residual and Smoothness

(18)

Popular direct solvers for :

• Gaussian elimination

• LU decomposition

• Cholesky factorization

compute directly up to numerical accuracy

computational complexity of GEM in 2D: , in 3D:

GEM optimized for band-structure: in 2D: , in 3D:

Direct Solvers of Systems of Linear Equations

u

=

A

¡

1

f

A

=

LU

,

LUu

=

f

,

Uu

=

L

¡

1

f

A

=

U

T

U

T

N

¢

:::

¢

T

2

¢

Au

=

T

N

¢

:::

¢

T

2

¢

f

,

Uu

=

f

0

Au

=

f

O

(

h

6

)

¢

=

U

O

(

h

9

)

O

(

h

4

)

O

(

h

7

)

(19)

h

N

runtime (33 TFlop/s)

2

-8

65.536

0.5 sec

2

-9

262.144

8.3 sec

2

-10

1.048.576

2 min 23 sec

2

-11

4.194.304

35 min 32 sec

2

-12

16.777.216

9 h 28 min 38 sec

2

-13

67.108.864

6 d 7 h 28 min 10 sec

Runtime of GEM for Solving Poisson 2D

(20)

Runtime of GEM for Solving Poisson 3D

h

N

runtime (33 TFlop/s)

2

-6

262.144

8 min 53 sec

2

-7

2.097.152

18 h 57 min 26 sec

2

-8

16.777.216

100 d 26 h 10 min 53 sec

2

-9

134.217.728

35 a 156 d 57 h 53 min 04 sec

x 128

(21)

Iterative Solvers of Systems of Linear Equations

In contrast to direct solvers, iterative solvers

• Compute approximate solutions

• Improve the approximation in an iterative process

• One iteration is cheap to compute, in 2D , in 3D

• Fixpoint iteration:

• Types of methods:

Splitting methods, Krylov-subspace methods, Multigrid methods

u

k

¼

A

¡

1

f

u

k

+1

=

F

(

u

k

)

¡¡¡¡!

k

!1

u

=

F

(

u

)

(22)

Outline

• Poisson-Equation: From the Model to an Equation System

• Direct Solvers vs. Iterative Solvers

• Jacobi and Gauss-Seidel Method

• Residual and Smoothness

• Multigrid Solver

(23)

Splitting Methods

Split up matrix :

Update rule:

Matrix has to be of simple form to to get

Au

=

f

(

S

+

T

)

u

=

f

Su

k

+1

=

f

¡

T u

k

u

k

+1

=

S

¡

1

(

f

¡

T u

k

)

u

k

+1

=

F

(

u

k

)

S

u

k

+1

A

(24)

The Jacobi Method

• Choose:

• Splitting:

• Update rule:

S

=

diag

(

A

) :=

D

A

A

=

S

+

T

=

D

A

+ (

A

¡

D

A

)

Au

=

f

(

D

A

+ (

A

¡

D

A

))

u

=

f

D

A

u

k

+1

= (

f

¡

(

A

¡

D

A

)

u

k

)

u

k

+1

=

D

A

¡

1

(

f

¡

(

A

¡

D

A

)

u

k

)

u

k

i

+1

=

1

a

ii

(

f

i

¡

N

X

j

=1

j

6

=

i

a

ij

u

k

j

)

(25)

Jacobi Method Example – 1D Heat Equation

• Stationary heat equation with as temperature:

• Boundaries have zero temperature, no sources:

• Solution is known:

f

= 0

u

u

= 0

@

2

u

@x

2

=

f

in

-u

k

i

+1

=

1

a

ii

(

f

i

¡

N

X

j

=1

j

6

=

i

a

ij

u

j

)

=

)

u

k

i

+1

=

1

2

(

u

k

i

¡

1

+

u

k

i

+1

)

(26)

Jacobi Method Example – 1D Heat Equation

Unit domain:

0

1

x

- := [0

;

1]

;

h

=

1

8

;

N

= 7

A

=

0

B

B

B

B

B

B

B

B

@

¡

2

1

1

¡

2

1

1

¡

2

1

1

¡

2

1

1

¡

2

1

1

¡

2

1

1

¡

2

1

C

C

C

C

C

C

C

C

A

(27)

Jacobi Method Example – 1D Heat Equation

0

1

x

(28)

Jacobi Method Example – 1D Heat Equation

0

1

x

k

= 0

u

k

i

+1

=

1

2

(

u

k

i

¡

1

+

u

k

i

+1

)

(29)

Jacobi Method Example – 1D Heat Equation

0

1

x

(30)

Jacobi Method Example – 1D Heat Equation

0

1

x

(31)

Jacobi Method Example – 1D Heat Equation

0

1

x

(32)

Jacobi Method Example – 1D Heat Equation

0

1

x

(33)

Jacobi Method Example – 1D Heat Equation

0

1

x

(34)

Jacobi Method Example – 1D Heat Equation

0

1

x

(35)

Jacobi Method Example – 1D Heat Equation

0

1

x

(36)

Jacobi Method Example – 1D Heat Equation

0

1

x

(37)

Jacobi Method Example – 1D Heat Equation

0

1

x

k

= 8

(38)

The Gauss-Seidel Method

• Choose:

• Splitting:

• Update rule:

S

=

L

(

A

) :=

L

A

A

=

S

+

T

=

L

A

+ (

A

¡

L

A

)

Au

=

f

(

L

A

+ (

A

¡

L

A

))

u

=

f

L

A

u

k

+1

= (

f

¡

(

A

¡

L

A

)

u

k

)

u

k

+1

=

L

¡

A

1

(

f

¡

(

A

¡

L

A

)

u

k

)

u

k

i

+1

=

1

a

ii

(

f

i

¡

i

¡

1

X

j

=1

a

ij

u

k

j

+1

¡

N

X

j

=

i

+1

a

ij

u

k

j

)

(39)

Gauss-Seidel Method Example – 1D Heat Equation

• Stationary heat equation with as temperature:

• Boundaries have zero temperature, no sources:

• Solution is known:

f

= 0

u

u

= 0

@

2

u

@x

2

=

f

in

-u

k

i

+1

=

1

a

ii

(

f

i

¡

i

¡

1

X

j

=1

a

ij

u

k

j

+1

¡

N

X

j

=

i

+1

a

ij

u

k

j

)

=

)

u

k

i

+1

=

1

2

(

u

k

+1

i

¡

1

+

u

k

i

+1

)

(40)

Gauss-Seidel Method Example – 1D Heat Equation

0

1

x

(41)

Gauss-Seidel Method Example – 1D Heat Equation

0

1

x

(42)

Gauss-Seidel Method Example – 1D Heat Equation

0

1

x

(43)

Gauss-Seidel Method Example – 1D Heat Equation

0

1

x

(44)

Gauss-Seidel Method Example – 1D Heat Equation

0

1

x

(45)

Gauss-Seidel Method Example – 1D Heat Equation

0

1

x

(46)

Gauss-Seidel Method Example – 1D Heat Equation

0

1

x

(47)

Gauss-Seidel Method Example – 1D Heat Equation

0

1

x

(48)

Gauss-Seidel Method Example – 1D Heat Equation

0

1

x

(49)

Gauss-Seidel Method Example – 1D Heat Equation

0

1

x

(50)

Gauss-Seidel Method Example – 1D Heat Equation

0

1

x

(51)

Gauss-Seidel Method Example – 1D Heat Equation

0

1

x

(52)

Gauss-Seidel Method Example – 1D Heat Equation

0

1

x

(53)

Gauss-Seidel Method Example – 1D Heat Equation

0

1

x

(54)

Gauss-Seidel Method Example – 1D Heat Equation

0

1

x

(55)

Gauss-Seidel Method Example – 1D Heat Equation

0

1

x

(56)

Gauss-Seidel Method Example – 1D Heat Equation

0

1

x

k

= 8

(57)

Gauss-Seidel Method Example – 1D Heat Equation

0

1

x

k

= 8

(58)

Outline

• Poisson-Equation: From the Model to an Equation System

• Direct Solvers vs. Iterative Solvers

• Jacobi and Gauss-Seidel Method

• Residual and Smoothness

(59)

Residual

• Residual:

• Splitting:

Au

= (

S

+

T

)

u

=

f

u

k

+1

=

S

¡

1

(

f

¡

T u

k

)

Au

=

f

Au

k

6

=

f

f

¡

Au

k

=

res

k

u

k

+1

=

S

¡

1

(

f

¡

(

A

¡

S

)

u

k

)

u

k

+1

=

S

¡

1

(

f

¡

Au

k

) +

u

k

u

k

+1

=

u

k

+

S

¡

1

res

k

(60)

• Local influences form residual:

• GS : high residual

oscillatory error/fct values

• GS : low residual

smooth error/fct values

Residual for 1D Heat Equation Example

u

i

¡

1

¡

2

u

i

+

u

i

+1

= 0

u

k

i

¡

1

¡

2

u

i

k

+

u

k

i

+1

=

res

k

i

0

1

x

0

1

x

k

= 0

k

= 8

(61)

Smoothnes depends on grid resolution :

:

:

:

Smoothness Observation

h

h

=

1

8

h

=

1

4

0

1

x

0

1

x

0

1

x

h

=

1

2

0

1

x

0

1

x

0

1

x

k

!

k

+ 1

Error reduction

(62)

Outline

• Poisson-Equation: From the Model to an Equation System

• Direct Solvers vs. Iterative Solvers

• Jacobi and Gauss-Seidel Method

• Residual and Smoothness

(63)

Geometric Multigrid Idea

• Only high error frequencies are removed effectively

• Frequencies depend on grid resolution

• Idea:

• Use several grid levels

(64)

Multigrid Example – 1D Heat Equation

0

1

x

(65)

Multigrid Example – 1D Heat Equation

0

1

x

(66)

Multigrid Example – 1D Heat Equation

0

1

x

(67)

Multigrid Example – 1D Heat Equation

0

1

x

(68)

Multigrid Example – 1D Heat Equation

0

1

x

(69)

Multigrid Example – 1D Heat Equation

0

1

x

(70)

Multigrid Example – 1D Heat Equation

0

1

x

(71)

References

Related documents

Throughout our science curriculum you'll see that science skills and knowledge are important but it’s the application of these ideas that lead onto the great discoveries.. Let’s get

We have constructed the new efficient integral mean value method (IMVM) for solving linear and nonlinear Fredholm integral of the second kind and the systems included such equations

The college has developed web-based systems to assist faculty: initial verification /attendance, enrollment changes during the term for unofficial withdrawals, and end of term

b) when a worker has no regular employment, WCB will fix a reasonable rate of earnings on which to base compensation, keeping in mind current earnings of workers employed in

Other authors suggest that kava hepatotoxicity can also be observed after the intake of traditional aqueous kava preparation and therefore it should not be linked to acetonic

From  the  workers’  perspective,  poor  lighting  at  work 

Contractor shall provide all schedules used for the contract to the Project Manager on a monthly basis, in accordance with the schedule updating requirements in Section 7.7

The simple expression reflects the fact that for an arbitrary, smooth surface, the curvature at any point is defined by assigning radii of curvature, R1 and R2, in two planes,