# Download - Numerical Solution of Partial Differential Equations ... · 1 Partial differential equations • Numerical Solution of Partial Differential Equations, K.W. Morton and D.F. Mayers

Transcript

1

Partial differential equations

• Numerical Solution of Partial Differential Equations, K.W. Morton and D.F. Mayers (Cambridge Univ. Press, 1995)

• Numerical Solution of Partial Differential Equations in Science and Engineering, L. Lapidus and G.F. Pinder (Wiley, 1999)

• Finite Difference Schemes and Partial Differential Equations, J.C. Strikwerda (Wadsworth, Belmont, 1989)

= PDE

2

Examples for PDEs

0

00 n

( ), ( )

, ( )

x

x

field depends on

Poisson equation:

Laplace equation:

examples for

scalar

boundary . value

problems

(elliptic eqs.)

Dirichlet boundary condition

von Neuman boundary condition

3

Examples for PDEs

1 0( ( )) ( ) ( )u x u x

example: vectorial boundary value problem

( )u x

is a vector field defined on space

Lamé equation of elasticity(elliptic eq.)

4

Examples for PDEs

)(),(

)(~

),( ,

0

002

2

2

t

tt

xtxct

wave equation

diffusion equation

initial boundary problem

),( tx

5

Examples for PDEs

0 0 0 0

0 0

10( ) ,

( , ) ( ) , ( , ) ( )

( , ) v ( ) , ( , ) p ( )

vv v p v v

t

v x t V x p x t P x

v t t p t t

( , )v x t

vector field in space and time

Navier – Stokes eq. for fluid motion

x x xx y z

y y yx y z

z z zx y z

v v vv v v

x y z

v v vv v v

x y z

v v vv v v

x y z

6

Discretization of space

i,j = (xi ,yj)i,j

xi+1=xi+Δx

yj+1=yj+Δy

Finite

Difference

Method

7

Discretization of derivatives

1

1

21 1

2

small ,

( ) ( )( )

( ) ( ) ( )

( ) ( ) ( )

n

n n

n n

n n

x x n x

x xO x

x xx x

O xx

x xO x

x

first

derivative

in 1d

8

Discretization of derivatives

221 1

2 2

2( ) ( ) ( )( )n n nx x x

O xx x

second derivative in one dimension

242 1 1 2

2 2

16 30 16

12

( ) ( ) ( ) ( ) ( )( )

n n n n nx x x x x

O xx x

or better

9

Discretization of derivatives

)()(6

)(2

)()()( 43

33

3

2

22

2

xOxx

xk

xx

xk

xx

xkxx nnnnkn

1( )

i l

k n ki ik l

a xx x

)( 12

)()( 16)( 30)( 16)( 42

21122

2

xOx

xxxxx

xnnnnn

322 1 1 2

3 3

2 2( ) ( ) ( ) ( )( )n n n xx x x x

O xx x

insert in Taylor expansion:

i = 2

third derivative

10

Derivatives in higher dimension

21 1

1 1 4

( , ) ( , )

( , ) ( , ) ( , )n n n n

n n n n n n

x x y x y

x y x y x y

21

1 1 1

1 1 6

( , , )

( , , ) ( , , ) ( , , )

( , , ) ( , , ) ( , , )

n n n

n n n n n n n n n

n n n n n n n n n

x x y z

x y z x y z x y z

x y z x y z x y z

2 d

3 d

Be Δx = Δy = Δz .

11

Poisson equation

)()( xx

)( nn x

)( 2 211 nnnn xx

bediscretization of the Poisson equation:

discretize one-dimensional space by xn , n = 1,…,N

0 0 1and Nc c Dirichlet boundary conditions:

System of N-1 coupled linear equations

12

Poisson equation in 1d

1 0

2

3

14

2 1 0 0

1 2 1 0 0

0 1 2 1 0

0 0 1 2

c

c

example: chain of N = 5 with ρ = 0

and Dirichlet boundary conditions

15

Poisson equation in 2d

jijijijijiji x ,2

,1,1,,1,1 4

21 1 2 2 4 k k k L k L k kx

two-dimensional discretized equation on grid L L:(Δx = Δy)

replace indices i and j by k = i + ( j -1) (L-2)

System of N = (L-2) 2 coupled linear

equations:bA

16

Laplace equation in 2d

4 1 0 1 0 0 0 0 0

1 4 1 0 1 0 0 0 0

0 1 4 0 0 1 0 0 0

1 0 0 4 1 0 1 0 0

0 1 0 1 4 1 0 1 0

0 0 1 0 1 4 0 0 1

0 0 0 1 0 0 4 1 0

0 0 0 0 1 0 1 4 1

0 0 0 0 0 1 0 1

1

2

3

4

5

6

7

8

9

0

4

21

21

01

212

Example 5 5 lattice with ρ = 0 and m = 0 for all m Γ,

i.e. Dirichlet boundary condition with fixed 0 on Γ.

(L-2)2 (L-2)2 matrix

17

Exact solution

bA

1*

111 1 1

1 1

. .

. . . . .

. . . . .

. .

N N

N NN N N

ba a

a a b

'

'

, ,

ikik

kk

jl jl jk kl

i i ik k

aq

a

a a q a j l k

b b q b

1

1 1

1

*

* *

NN

NN

N

i i jj jj iii

b

a

b aa

solution

Gauss elimination procedure matrix A triangular

for k = 1,..., N once matrix

is triangular

O (N 3) ~ O (L3d)

bA

18

Poisson equation in 2d

Independently of the size of the system

each row or column has only

maximally five non-zero matrix elements

sparse matrix

Use sparse matrix solvers !

Invert with LU decomposition

19

Sparse matrices

example:

Hanwell Subroutine LibraryIain Duff

Store non-zero elements in a

vector and also their coordinates

i and j in vectors.

Yale Sparse Matrix Format

For more details see:www.cise.ufl.edu/research/sparse/codes

20

Sparse matrix solvers

21

Tree data structure where

each node has up to four

children corresponding

That means that each

node can contain several

pointers indexed by two binary variables

representing coordinates i and j.

22

Computational considerations

Computational effort for Gauss elimination N 3.

For a lattice 100 100 = 104 one needs 2 days.

Abandon exact solution and use approximation.

But for that A must be well-conditioned:

example for ill-conditioned situation:

23

Jacobi relaxation method

1 1 1 1

11

4

( ) ( ) ( ) ( ) ( )

( , ) ( , )

ij i j i j ij ij ijt t t t t b

x y b x y

1 1 1 1

1

4 * * * * *ij i j i j ij ij ijb

11

( )

( ) ( ) ( )

A b A D O U

D b O U

t D b O U t

fixed point is the exact solution:

decompose:

general:

24

Error of Jacobi relaxation

11

( ) ( )'( )

( )

t tt

t

Exact solution is only reached for t→∞.

Define required precision ε

and stop when :

1 1 1

1 1 1

1 1

( )

( ) ( ) ( ) ( )

( ) ( ) ( ) ( )

exact solution approximate solution

t

t A b t A b D b O U t

D O U A b t D O U t

real error:

AA-1

25

Error of Jacobi relaxation

11( ) ( ) ( )t t D O U

tct

*)(

with

be λ the largest eigenvalue of Λ

1

1

1

1

( ) ( )

( ) ( )

t t

t t

t t

t t

0 < |λ| < 1

for large t :

26

Error of Jacobi relaxation

1 1 '( ) ( ) ( )t t

2

11

1 1 1

( ) ( )'( )( )

( ) ( ) ( ) ( ) ( )

t ttt

t t t t t

111 1

( ) ( ) ( )'( )

( ) ( ) ( )

t t

tt t c c

tt t t

* ( )( )

( ) ( )t

t ct

t t

real error:

27

Gauss-Seidel relaxation

11

( )

( ) ( ) ( )

A b A D O U

D O b U

t D O b U t

1

1 1

11 1( ) ( ) ( )

N i

i ij j ij j jj i jii

t a t a t ba

and

fixed point is the exact solution

28

Error in Gauss-Seidel

1 1

1 1 1

1

( )

( ) ( ) ( )

( ) ( ) ( ) ( )

exact solutionapproximate solution

t

t A b D O b U t

D O U A b t D O U t

11( ) ( ) ( )t t D O U

with

1

1

( ) ( )( )

( ) ( )

t tt

t

λ largest EV of Λ

29

Partial differential equations (PDF)

bA

Jacobi relaxation

Gauss-Seidel relaxation

30

Gauss-Seidel relaxation

11

( )

( ) ( ) ( )

A b A D O U

D O b U

t D O b U t

1

1 1

11 1( ) ( ) ( )

N i

i ij j ij j jj i jii

t a t a t ba

and

fixed point is the exact solution

31

Overrelaxation

Successive overrelaxation = SOR

11 1( ) ( ) ( ) ( )t D O b D U t

Fixed point is the exact solution.

ω is the overrelaxation parameter.

1 ≤ ω < 2

ω = 1 Gauss-Seidel relaxation Applet

32

Non-linear problem

1 1 1 1 0( ) ( ) ( ) ( )i j ij ij i j ij ij ij ijf U U f U U f U U f U U

Consider a network

of resistors with a

non-linear I-U relation f.

Then Kirchhoff‘s law

takes the form:

Solve with relaxation:

1 1

1 1

1 1

1 1 0

( ( ) ( )) ( ( ) ( ))

( ( ) ( )) ( ( ) ( ))

i j ij ij i j

ij ij ij ij

f U t U t f U t U t

f U t U t f U t U t

33

1 AbbAAAr

Be matrix A positive and symmetric.

The residuum

is a measure for the error.

Minimize the functional:

otherwise 0

if 0 *1

rAr t

error

35

exact solution

Φ(1)

Φ(2)

36

Gradient methods1 1 2( ) ( ) t t tb A A b A b A b A b

i iidα

1 2 2 2 t t t t t ti i i i i i

2i i ii ib A b A d A d A dα αb bα d

2 0

t

t i ii i i t

i ii i

i

d rd A d r

d A dα α

α

Be i the i th approximation.

Minimize along lines:

minimization condition with respect to i:

38

Method of steepest descent

1 1

2

1

1

1

iterate: ,

i i

ii i i t

i i

i i i i

i i i i

d r

r b A

ru Ar

r u

r

r r u

each step N 2, but when matrix A sparse N

39

41

0 if ti jd Ad i j

1 , , i ii i i i i i it

i i

r dr b A α d

1

11

i

i j jj

r b A d

Hestenes and Stiefel (1957)

Choose di conjugate

to each other:

as before:

42

1

1 11

, tij i

i i jtj j j

d Ard r d r d

0 if ti jr Ad i j

one can also show:

Construct conjugate basis using

an orthogonalization procedure:(Gram – Schmidt)

43

1 1 1 1 , r b A d r

1

1

1 1 1 1 1

, ,

,

ti i i i i i i i i

i i i i i i i

c d Ad cd r d

r b A d r cr Ad d

ti ir r

1. initialize:

2. iterate:

3. stop when:Applet

44

If matrix not symmetric then use

and tr b A r b A

Consider two residuals:

This method does not always converge

and can be unstable.

45

1 1 1 1

1 1 1 1

,

, t

r b A d r

r b A d r

1 1

1 1

11

with and

, ,

, ,

t ti i i i i i i i i i

ti i i i i i i i i i i

t ti i i i

r r A d r r A d c r r

d r d d r d c r r

c d Ad c d d

ti ir r

1. initialize:

2. iterate:

3. stop when: 1 n

n i ii

α d

46

Preconditioning

1 1such that P AP

1 1 A bP P

ijiiij

iiijiiij A

PjiA

AP

1

otherwise 0

if 1

Choose a preconditioning matrix

and solve equation:

example: Jacobi preconditioner:

47

Preconditioning

1

1

2

D DP U D O

example: SOR preconditioner:

48

Multigrid procedureAchi Brandt (1970)

Consider coarser

lattices on which

the long-wave

errors are

damped out. h = 2

49

Multigrid procedure

1 , n n n nr b A A r

Strategy: solve the equation for

the error on the coarser lattice.

1. Determine residuum r on the original lattice.

W.L. Briggs, A Multigrid Tutorial

(Soc. For Ind. & Appl. Math, 1991)

Two-level procedure:

50

Multigrid procedure

1

ˆ ˆ ˆn nA r

1 1 ˆ n n

P

3. Then obtain the error on the

coarser lattice solving equation:

4. Then get the error on the

original lattice through an

extension operator P :

2. Define the residuum on

the coarser lattice through

a restriction operator R :

ˆ n nr r

R

51

Multigrid procedure

1 1n n n

5. Get new approximate solution through:

In an m-level procedure one solves the

equation only on the last (coarsest) level.

On each level one can also smoothen the error

using several Gauss-Seidel relaxation steps.

52

Multigrid procedure

2 2

2 1 2 1

2 2 1 1

2 1 2 1 1 1 1 1

1

21

21

4

, ,

, , ,

, , ,

, , , , ,

ˆ

ˆ ˆ

ˆ ˆ ˆ

ˆ ˆ ˆ ˆ

i j i j

i j i j i j

i j i j i j

i j i j i j i j i j

r r

r r r

rr r r

r r r r r

P

Example for extension operator on square lattice:

bilinear interpolation

53

Multigrid procedure

1 1 1 1

1 1 1 1 1 1 1 1

1 1

4 81

16

, , , , , ,

, , , ,

ˆ

i j i j i j i j i j i j

i j i j i j i j

r r r r r rr

r r r r

R

Corresponding restriction operator:

They are adjunct to each other, i.e.

2 ̂̂, ,

ˆ ˆ ˆ ˆ ˆ ˆ ( , ) ( , ) ( , ) ( , )x y x y

v x y u x y h v x y u x yP R

54

Multigrid procedure

One can also vary the protocol

V-cycles, W-cycles, …

55

Solving PDEs

A b discretize system of

coupled linear equations

● Finite difference methods:

Field is discretized on sites: i .

● Finite element methods = FEM:

Field is patched together from a discrete

set of continuous functions.

56

The Fathers of FEM

J. Argyris R.W. Clough O.C. Zienkiewicz

57

Finite Elements at ETH

• Gerald Kress: Strukturanalyse mit FEM

• Christoph Schwab: Numerik der Dgln.

• Peter Arbenz: Introduction to FEM

• Pavel Hora: Grundlagen der nichtlinearen FEM

• Andrei Gusev: FEM in Solids and Structures

• Falk Wittel: Eine kurze Einführung in FEM

• Eleni Chatzi: Method of Finite Elements

58

Literature for FEM

● O.C. Zienkiewicz: „The Finite Element

Method“ (3 Volumes), 6th edition

(Butterworth-Heinemann, 2005)

● K.J. Bathe: „Finite Element Procedures“

(Prentice Hall, 1996)

● H.R. Schwarz: „Finite Element Methods“

59

Finite Elements

Strukturmechanik/Anwendung:[6] J. Altenbach und U. Fischer: Finite-Elemente Praxis,

Fachbuchverlag Leipzig (1991)

[7] P. Fröhlich: FEM-Anwendungspraxis. Einstieg in die

Finite Elemente Analyse, Vieweg Verlag (2005)

[8] B. Klein: FEM, Vieweg-Verlag 6. Aufl. (2005)

[9] K. Knothe and H. Wells: Finite Elemente, Springer-Verlag (1991)

[10] F.U. Mathiak: Die Methode der finiten Elemente (FEM) –

Einführung und Grundlagen (2002).

[11] G. Müller und I. Rehfeld: FEM für Praktiker, Expert-Verlag (1992)

[12] M. Link: Finite Elemente in der Statik und Dynamik,

Teubner-Verlag 3. Aufl. (2002)

[13] H. Tottenham und C. Brebbia: Finite Element Techniques in

Structural Mechanics, Southhamptom.

[14] R. Steinbuch: Finite Elemente - Ein Einstieg, Springer-Verlag (1998)

60

Properties of FEM

• Irregular geometries

• Strongly inhomogeneous fields

• Moving boundaries

• Non-linear equations

Advantage of finite elements over finite differences

Clough (1960)

61

triangulations with different resolution

62

triangulation of a wheel-rim

63

One dimensional example

2

24 0with 0

dx x L

dx

Poisson equation:

1 1

N

i i N i ii i

x a u x x a u x

Expand in terms of localized basis functions ui:

64

One dimensional example

2

20

4 0 1

, , ...,L

j

dx x w x dx j N

dx

baA

2

20 0

4 1 , ,...,

L L

j j

dx w x dx x w x dx j N

dx

Define weight functions wj (x) and get ai from:

wj (x) = uj (x) is called the Galerkin method.

system of linear equations

2

210 0

4 1

, ,...,L LN

ii j j

i

ua x w x dx x w x dx j N

x

2

21 0 0

4 1

, ,...,L LN

ii j j

i

ua x w x dx x w x dx j N

x

65

One dimensional example

0 0

''( ) ( ) '( ) '( ) L L

ij i j i jA u x w x dx u x w x dx

0

4 ( ) ( ) L

j jb x w x dx

baA

with

and

66

One dimensional example

1 1

1 1

( ) / for ,

( ) / for ,

0 otherwise

i i i

i i i i

x x x x x x

u x x x x x x x

Example for basis functions ui(x) are hat functions

centered around xi:

Δx ≡ xi – xi-1

=„element“

xi

ui(x)

xi-1 xi+1

67

One dimensional example

0 10 , L

Boundary conditions are automatically fulfilled

because basis functions were zero at both ends.

0 11

1

N

N i ii

x L x x a u xL

If

then use following decomposition:

68

Non-linear PDEs

2

24

dx x x

dx

2

20

4 0 L

k

dx x x w x dx

dx

,ijk i j k

i j

A a a b 0

'' L

ijk i j kA u x u x w x dx

1d example :

Then solve:

with

i.e. the coupled non-linear system of equations:

69

Picard iteration

21

0 24( ) ( ) ( )

dx x x

dx

21

24( ) ( ) ( )n

n

dx x x

dx

Solve linear equation for Φ1 :

Then iterate:

Émile Picard

70

Finite Elements

1

, ,n

i ii

x y N x y

Decompose in basis functions Ni

0 ( , )x y a b

71

Variational Approach

dsdxdyaE

G

2 b

2

1

2

1 222

G

dsdxdyaE b

G Gds

ndxdydxdy

Minimize the functional: Argyris (1954)

first Green‘s theorem:

= 0

72

Variational Approach

ba

2 21 1

2 2 b

G

E a dxdy

1

2 E A b

0 0 E

A b

a = 0 Poisson equation

b = 0 Helmholtz equationFirst term

of total

energy

can be brought

into the form:

Minimizing

then gives:

2 21 1

2 2

b jG

elements j

E a dxdy

74

Function on Element

1 2 3 ( )r a a x a y

2 21 2 3 4 5 6 ( )r a a x a y a x a xy a y

Higher dimensions

In 2d define function over

one element = triangle of the triangulation

e.g. linearly:

or by a paraboloid:

75

Linear case

76

Standard Form

Transform any element j

into the standard form.

1

1

T

η

ξ

77

Coordinate transformation

yyxxyx

,,

D

xx

yD

yy

xD

xx

yD

yy

x12121313

≡ ≡

78

Coordinate transformation

... ...det jG T

dxdy J d d

yy

xx

J

2 1 3 1 3 1 2 1

detx y x y

J

x x y y x x y y D

Jacobi matrix

79

Coordinate transformation

2 2 2 21 2 32

j Tx yGdxdy c c c d d

Inserting gives for each element

where the

coefficients

are only

calculated

once for

each element.

2 2 2 21 2 32

j T TxG Ty dxdy c d d c d d c d d

80

1 2 3 ( )r a a x a y

2 21 2 3 4 5 6 ( )r a a x a y a x a xy a y

In 2d define function over

one element = triangle of the triangulation

e.g. linearly:

or by a paraboloid:

Basis functions

81

Shape of basis functions

82

Basis functions

6

1

, , ,i ii

N N

1 2

3 4

5 6

1 1 2 2 2 1

2 1 4 1

4 4 1

,

,

,

N N

N N

N N

1 6 1 6, ..., , , ...,N N N

Decompose on standard element in basis functions Ni

83

Shape functions on square lattice

2 2 2 2 2 21 2 3 4 5 6 7 8 9 ( )r c c x c y c x c xy c y c xy c x y c x y

85

Energy Integrals

1

22

1 ,

T T

t t t t

T T

S

I d d N d d

N N d d N N d d

2 2

23 3

t

T

t

T

I d d S

I d d S

Calculate the energy integrals on standard element

defining matrices

S1, S2 and S3 on

standard triangle.

and analogously

6 x 6

86

Rigidity Matrix

2 21 2 32

2

jG

t

T

dxdy

c c c d d S

1 1 2 2 3 32S c S c S c S

defines the rigidity matrix S for any element:

87

Mass Matrix

22

( , )

jj jG T

t t tj j j j j jT

a dxdy a N D d d

a N N D d d M

2 2

j

tj j j jG

elements j elements j

E a dxdy S M

Analogously one defines the mass matrix M:

with and tj j j

jE A A S M

Mj

assembly

88

Assembly of the Matrix

The elements must

be joined such that

the field is continuous.

This is done by identifying

the values of the coefficients

at each vertex for all elements

89

Field term

b b ,

b ,

jj jG T

j j j jT

dxdy N D d d

N D d d b

with jE A b b b

bj

93

0 bA

Solve system

of N linear equations where N is the

number of vertices.

Matrix A and vector b only depend on the

triangulation and on the basis functions and

the unknowns are the coefficients = (φi) .

94

FEM

The connection between the elements gives

off-diagonal terms in the matrix A.

Finally one must also include the boundary

terms, which appear as before on the

right side of the equation.

Applethttp://www.lnm.mw.tum.de/teaching/tmapplets/

95

Stresses in a hinge

96

Stresses in a clip

97

Network of trusses

98

Time dependent PDE‘s

2 1, , ,

Tx t T x t W x t

t C C

Simple example is heat equation:

T is temperature, C is specific heat

ρ is density, κ is thermal conductivity

and W are external sources or sinks.

99

Time dependent PDE‘s

1 12

1 1 4

( , ) ( , ) ( , ) ( , )

( , ) ( , ) ( , ) ( , )

ij ij i j i j

ij ij ij ij

tT x t t T x t T x t T x t

C x

tT x t T x t T x t W x t

C

„line method“ in two dimensions:

2

1

4

t

C x

clearly unstable if

Courant-Friedrichs-Lewy (CFL) condition (1928)

Unstable 1d parabolic PDE

100

101

Crank - Nicolson method

2 2

2

2

( , ) ( , ) ( , ) ( , )

( , ) ( , )

tT x t t T x t T x t T x t t

C

tW x t W x t t

C

21( ) ( , ) , ( ) ( , ) , , ...,n nT t T x t W t W x t n L

implicit algorithm

define

Phyllis

Nicolson

John

Crank(1947)

102

Crank - Nicolson method

1 12

4

O ( , ) ( , ) ( , )

( , ) ( , ) ( , )

n n n

n L n L n

tT x t T x t T x t

C x

T x t T x t T x t

Define operator O

Then Crank – Nicolson becomes:

1

2

2

( , ) ( , ) O ( , ) O ( , )

( , ) ( , )

T x t t T x t T x t T x t t

tW x t W x t t

C

103

Crank - Nicolson method

2 2

O ( ) O ( ) ( ) ( )t

T t t T t W t W t tC

1 1

Then Crank – Nicolson becomes:

where 1 is the unity operator.

2 2( , ) ( , ) O ( , ) O ( , )

( , ) ( , )

T x t t T x t T x t T x t t

tW x t W x t t

C

104

Crank - Nicolson method

Calculate the inverted operator B before:

2

2

-1 O

( ) O ( ) ( ) ( )t

T t t T t W t W t tC

B 1

B 1

105

Crank - Nicolson method

Example: 1d diffusion equation: 2

2

u u

Dt x

1 12

1 1

22

2

i i

i i i

i i i

u t t u t

tD

u t t u t t u t tx

u t u t u t

Crank-Nicholson discretization:

22

D t

x

Courant-Friedrichs-Lewy (CFL) number

1 1

1 1

1 2

1 2

i i i

i i i

u t t u t t u t t

u t u t u t

1 12

1 1

22

2

i i

i i i

i i i

u t t u t

tD

u t t u t t u t tx

u t u t u t tridiagonal problem

106

Tridiagonal matrix problem

equation:

modify coefficients:

solution:

Algorithm goes like O(N) (instead of O(N3) in Gauss elimination).

107

Wave equation2

2 22

with

y kc y ct

2 21 12

2( , ) ( , ) ( , ) ( , )n k n k n k

n k

y x t y x t y x tc y x t

t

21 1

21 1

2 1 2

( , ) ( ) ( , ) ( , )

( , ) ( , ) ( , ) ( , )

n k n k n k

n k n k n L k n L k

y x t y x t y x t

y x t y x t y x t y x t

with = cΔt/Δx < 1/ √ 2

which corresponds to

cut off modes for wave

lengths smaller than .

108

InitializationTo start the iterations one needs to know

the field at two times t and t-Δt.

That means, one needs to know y(xn,0) and 0

,n

yx

tSet 0 0

, , ,n n n

yy x t y x t x

t error O(Δt)

2

2

1 1

1 0 0

0 0 0 04

, , ,

, , , ,

n n n

n n n L n L

yy x t y x t x

t

y x y x y x y x

better

error O(Δt2)

109

Solution of the wave equation

110

velocity field, pressure field

Navier – Stokes equation

10

1

1

2

2

( ) ,

Euler: ( )

Stokes:

vv v p v v

t

vv v p

t

vp v

t

( , ) ( , )v x t p x t

equation of motion for incompressible fluid

viscosity

Solvers for NS equation

• Penalty method with MAC

• Finite Volume Method (FLUENT, OpenFOAM)

• Spectral method

• Discrete methods: DPD, SPH, SRD, LGA,…

• k-ε model for turbulence

CFD = Computational Fluid Dynamics

113

Navier – Stokes equation

211 ( )k k

k k k k

v vp v v v

t

1 0k kv v

2 211 k k

k k k k

v vp v v v

t

Insert incompressibility condition:

Apply on both sides :

114

Navier – Stokes equation

Poisson equation determine pressure pk+1

21 ( ) k k kp v v

To solve it, one needs boundary conditions

for the pressure which one obtains projecting

the NS equation on the boundary.

This must be done numerically.

115

Operator splitting

211

* *

( ) k kk k k k

v v v vp v v v

t

2

11

*

*

( )

kk k k

kk

v vv v v

t

v vp

t

Introduce auxiliary variable field v*

and split

in two

equations: v*

116

Operator splitting

21

*

k

vp

t

11 1

1 * kk k

pn p n v v

n t

11

*k

k

v vp

t

Applying on

one obtains

Projecting on the normal n to the boundary

one obtains:

117

Spatial discretization

MAC = Marker and Cell is a staggered lattice:

Place components of velocity on middle of

edges and pressures in the centers of the cells.

h is the

lattice

spacingy

x

118

Spatial discretization

11 2

1

, ,, , hi j i jx i j

p p p

21 1 1 12

14 , , , , , ,

hi j i j i j i j i j i jp p p p p p

y

x

119

Spatial discretization

1 1 1 1

2 2 2 2

1

* * * * *,

, , , , , , , ,hi j

x i j x i j y i j y i jv v v v v

Poisson equation for the pressure pk+1

is solved on the centers of the cells () .

21

*

k

vp

t

y

x

120

Spatial discretization

x x x y xv v v x v v y v

21 1 ( )k k k k k kv v t p v v v

The equations for the

velocity components

are solved on the edges.

121

Spatial discretization

1 3 11

2 2 22

1

2, , ,,

h

xx x x x

i j i j i ji j

vv v v v

x

1 1 1 11

2 2 2 22

1 1

2 2

1 1

1 1

1

4

1

2

, , , ,,

, ,

h

xy y y y y

i j i j i j i ji j

x x

i j i j

vv v v v v

y

v v

y

x

122

Flow around a vocal chord

123

Sedimentation

comparing experiment and simulation

124

Finite Volume MethodR.J. LeVeque, «Finite Volume Methods for Hyperbolic

Problems» (Cambridge Univ. Press, 2002)

, , ,v x t f v x t g v x t

t

i iG G

vf v dV g v dV

t

Solve conservation law

in integral form

i i iG G G

vdV f v n dS g v dV

t

using Green’s theorem:

125

Finite Volume Method

0

i iG G

vdV f v n dS

t

change of value

in volume i 1

i

i

Gi

vf v n dS

t G

126

Forward-Time Central-Space (FTCS)

2

2

2

2

, , ,

( ) ( ), , ,i i

v vf v x t

t x

v t t v t vf v i t

t x

f is spatially discretized in a central difference scheme

1 12

( ) ( ) ( ( )) ( ( ))i i i i

tv t t v t f v t f v t

x

127

FTCSTime evolution of the inviscid Euler equation

using a forward time central space scheme

128

Kurt Friedrichs

Lax-Friedrichs Scheme

Peter Lax

1 1 1 1 2

1

4

( )

( ) ( ) ( ) ( ) ( )

i

i j i j ij ij nn nnnn

u t t

tu t u t u t u t H t S

x

1 1 1 1

1

2 2

( )

( ) ( ) ( ( )) ( ( ))

i

i i i i

v t t

tv t v t f v t f v t

x

129

Lax-Friedrichs Scheme2d Euler equation with reflecting boundaries

FLUENT

130

FLUENT

131

FLUENT

132

133

Cavity with FLUENT

134

Turbine with FLUENT

135

Airfoil with FLUENT

136

Shock wavesSolutions of

parabolic equations which move with constant velocity

and develop a sharp front.

example: tsunami

typical initial condition:

Riemann problem

137

Shock waves

138

Godunov Scheme

Sergei K. Godunov (1959)

Example

1d inviscid Burgers equation: 0

t x

, ,i i i i i it t t t t t t t t

t

xF F

in-flow out-flow

2

if > 0if 0

if < 0if 02

0 if 0 <

, , ,

L LL

L R R RR

L R

gF g g

with

L R L R

2 L R

139

1d Burgers equationformation of shock wave

140

Spectral MethodsSteve Orszag

(1968)

Finite elements:

basis functions: local smooth functions

Spectral methods:

basis functions: global smooth functions

PDE solver for smooth

Has excellent convergence properties.

141

0 0

with and

( , ) ( ( , ))

( , ) ( , ) ( )B I

Lu x t f u x t

u t u u x u xPDE:

1 1

, ,N

i i N i ii i

u x t a t x u x t a t x

Expand in terms of basis functions ϕi:

Spectral Methods

e.g. ( , ) ( , )Lu x t u x t

t xL differential operator

142

0

0 1 ( , ) ( ( , )) , , ...,L

jLu x t f u x t w x dxdt j N

Define N (orthogonal) test functions wj (x):

wj (x) = ϕj (x) is called the Galerkin method

and wj (x) = δ(x-xj) is called a collocation.

Spectral Methods

143

Spectral Methods

0 0 2

on ( , )

u u

t x

truncated expansion:

2

2

( ) ( , ) ( ) ( )N

Nl l

l N

u x t a t x

144

Spectral Methods

trigonometric basis and test functions:

1

2

and ( ) ( )ilx ikx

l kx e w x e

2 2

20

10

2

( ) N

ilx ikxl

l N

a t e e dxt x

02 2

, , ...,kk

da N Nika k

dt

2

0

2

( )i l k xlke dx

145

Spectral Methods

0 kk

daika

dt

2

0

0

( ) ( ) kxk Ia u x e dx

solve initial condition

with

( ) sin cos( )Iu x xchoose for instance

2

( ) sin ( ) iktk k

ka t J e

Bessel function

146

Spectral Methods

2

( ) sin ( ) iktk k

ka t J e

From asymptotic behaviour of Bessel functions:

0 for : ( ) pkp k a t k

2

2

( ) ( , ) ( ) N

N ikxk

k N

u x t a t econverges faster

than any

power of 1/N.

147

Spectral Methods

Example 2: 1d (full) Burgers equation

t x xxu u u u

2

2

( ) ( , ) ( ) N

N ikxk

k N

u x t a t e

, , ,t x xxu w u u w u w2

0

, ( ) ( )f w f x w x dx

integral or «weak» form,

with

, :w t

2 2 ( ) , , ...,ikx N N

w x e k

Fourier-Galerkian expansion

148

Spectral Methods

, , ,t x xxu w u u w u w

21

2

, ,ikx ikx

t x xu e u u e

2 21 1

2 2 , , ,ikx ikx ikx

t x x xu e u u e u u ike

integrating by parts:

149

Spectral Methods

2

0

2

( ),ilx ikx i l k xlke e e dxuse orthogonality relation

to solve

2

2

2

, ( ) , N

ikx ilx ikxt t l t k

l N

u e a t e e a

2 22

2 2

2

1 1

2 2

22

( )

,

( )

,

, ,

, ,

N Nikx i l m x ilx ikx

x k l ll m N l N

i l m x ikx ilx ikxk l l m l k

l m l l m k

u u ike a a e i l a e ike

ika a e e k l a e e i k a a k a

21

2 , ,ikx ikx

t xu e u u ike

150

Spectral Methods

22 2

t k k l kl m k

a i k a a k a

2

2

( ) ( ) ( ) ( )kk l k

l m k

a ikt a t a t k a t

t

This system of coupled ODE can be solved e.g. with

Runge Kutta using the Fourier transformed initial

condition: 2

0

1 10 0 0

2 2

( ) ( , ), ( , )ikx ikx

ka u x e u x e dx

151

Spectral Methods with other basis functions

Families of orthogonal polynomials on [-1,1] are Legendre and Chebychev polynomials.

Fourier decomposition is good when functions are periodic.

Laguerre polynomials on [0,∞)

Hermite polynomials on (-∞, ∞)

152

Discrete fluid solvers

• Lattice Gas Automata (LGA)

• Lattice Boltzmann Method (LBM)

• Dissipative Particle Dynamics (DPD)

• Smooth Particle Hydrodynamics (SPH)

• Stochastic Rotation Dynamics (SRD)

• Direct Simulation Monte Carlo (DSMC)

153

Lattice gas Automata

• D.H. Rothman and S. Zaleski, „Lattice-Gas Cellular Automata“ (Cambridge Univ. Press, 1997)

• J.-P. Rivet and J.P. Boon, „Lattice Gas Hydrodynamics“ (Cambridge Univ. Press, 2001)

• D.A. Wolf-Gladrow, „Lattice-Gas Cellular Automata and Lattice Boltzmann Models“ (Lecture Notes, Springer, 2000)

154

Lattice gas AutomataParticles move on a triangular lattice and

Momentum is conserved at each collision.

It can be proven (Chapman-Enskog) that

its continuum limit is the Navier Stokes eq.

Lattice gas Automata

157

von Karman street

velocity field of a fluid behind an obstacle

Each vector is an average over time of the

velocities inside a square cell of 25 triangles.

159

Lattice gas Automata

Problem in three dimensions, because there exists

no translationally invariant lattice which is

locally isotropic. One must study the model in 4d

face centered hypercube that has 24 directions

giving 224 = 1677216 possible states. Projecting onto

a 3d hyperplane that already contains 12 directions

adds another six new directions giving 18 in 3d.

160

Discrete fluid solvers

• Lattice Gas Automata (LGA)

• Lattice Boltzmann Method (LBM)

• Dissipative Particle Dynamics (DPD)

• Smooth Particle Hydrodynamics (SPH)

• Stochastic Rotation Dynamics (SRD)

• Direct Simulation Monte Carlo (DSMC)

161

From LGCA to Lattice Boltzmann Models (LBM)

• (Boolean) molecules to (discrete) distributions

ni fi = < ni >

• (Lattice) Boltzmann equations (LBE)

( , 1) ( , )ii i if x c t f x t C f

Lattice Boltzmann

S.Succi, The Lattice Boltzmann equation for fluid dynamics and beyond, Oxford Univ. Press, 2001

ni is the number of particles in a cell going in direction i

162

Boltzmann equation

, ,f x v t x v distribution function

is the number of

particles having at time t velocities

between v and v + Δv in the elementary

volume between x and x + Δx.

, , , , t x vf x x v v t t f x v t t f x f v f

0

, , , ,

lim t x vt

f x x v v t t f x v tf v f a f

t

0

lim

t

va

t

Taylor expansion:

Ludwig Boltzmann

163

Boltzmann equation

Due to collisions between particles in the

volume Δx during the time interval Δt

acquire velocities between v and v+Δv and

some particles do not anymore

have velocities between v and v+Δv , giving the

collision

term:

, ,collf x v t

, ,collf x v t

, , , ,coll coll collf x v t f x v t

164

Boltzmann equation

This gives the Boltzmann equation:

t x v collf v f a f

In thermal equilibrium one expects

the Maxwell-Boltzmann distribution:

22

2

eq kT mn

v u

kTf e

( , )u x t

165

BGK collision term

P.L. BhatnagarBGK model:

P.L. Bhatnagar, E.P. Gross and M. Krook (1954)

eq

coll

f f

where τ is a relaxation time

2

s

m

kT ccs is «sound speed»

μ is viscosity 2 s

kTc

m

166

Averaged quantitiesMoments of the velocity distribution:

, , ,x t m f x v t dv

2

2

( )

, , , ,v u

x t e x t m f x v t dv

, , , ,x t u x t m v f x v t dv

mass density:

momentum density:

energy density:

168

Knudsen numberValidity of the continuum description:

characteristic length of system L must be much larger

than the mean free path l of the molecules

(distance between two subsequent collisions).

K l L

Navier-Stokes equation: 0.01 > K

Boltzmann equation: 0.005 > K

170

Chapman-Enskog expansion0

( )n n

n

f K f

where the small parameter K is the Knudsen number

0 ( ) eqf f

1 1

( )( )

, n n nx x n

n n

K Kt t

Chapman-Enskog

175

1 11

( ) ( )

( ) x xu u u e at

Chapman-Enskog

0 11 1 1 1 2 0 2 0 2

2 1

1

( ) ( )( ) ( ) ( ) ( ) ( ) ( ) ( ) ( ) ( )

( ) ( ) x v x v

f fv f a f v f a f f

t t

0 11 1 1 1 2

2 1

1

( ) ( )( ) ( ) ( ) ( ) ( )

( ) ( ) x v

f fv f a f f

t t

110 1

2

( ) , eq

xy

uv v f f dv

t

Navier Stokes equation:

momentum conservation

176

0

( ) ( ) ( )b n

i iia

g x w x dx w g x

0

( ) , , ...,b n

ki

k ì i ka

x xw w x dx i n

x x

Be g(x) a polynomial of at most degree 2n+1

if for the positive weight function w(x) there exists a

polynomial p(x) of

degree n+1 such that 0 0 ( ) ( ) , , ...,b

k

a

x p x w x dx k n

with

and xi , i = 0,...,n are the zeros of p(x).

177

Lattice Boltzmann

22 2

2

2 2 4 22

2 12 22

eq sd

s s ss

vc vuvu u

fc c cm c

e

2 with ss

u kTc

c m

small parameter:

w(x) p(x)2

0

( )i ii

a H v

2

2

2

2

d

eq kT m

v u

m kT mf e

178

Hermite Polynomials2 3

0 1 2 31 1 3 ( ) , ( ) , ( ) , ( )H x H x x H x x H x x x

2

2

( ) ( ) ! xi j ijH x H x e dx i

179

Lattice Boltzmannone dimensional case:

2

22

2

1

( ) s

s

vcw v

ce

n + 1 = 31 1

03 3

, ,iv

220 1 2

1 1 2 1

6 3 61

, ,

( )!, ,

( ) ( )i

in i

nw

n H v

180

Lattice Boltzmannthree dimensional case:

2 222

2 2 2 22 2 2 2

y zx

s s s s

v vvvc c c ce e e e

0 0 0 0 0 0

0 01 3 0 0 0 1 3 0 0 0 1 3 1 3

01 3 1 3 0 0 1 3 1 3 1 3 0 1 3 1 3 1 3

1 3 1 3 1 3 1 3 1 3 1

8 27

2 27

1 54

( , , )

( / , , ) ( , / , ) ( , , / ) /

( / , / , ) ( , / , / ) ( / , , / ) / /

( / , / , / ) / / /

w w w w

w w w w w w

w w w w w w

w w w w3

1 216

27 discrete velocity vectors

181

Lattice Boltzmann

D2Q9

D3Q15

D3Q19

Lattice Boltzmann

where the equilibrium distribution is defined as:

Define on each site x of a lattice on each outgoing

bond i a velocity distribution function f(x,vi,t)

which is updated as:

2 20

2 4 2

93 31

2 2

i n is s s

vuvu uf w

c c c

011

( , , ) ( , , ) ( ) ( , , ) ( , , )i i i i i i i i n i if x v v t f x v t F v f u T f x v t

183

Lattice Boltzmann

discretization

1

v t

x

CFL number

22

s

t

c

2 2

2

, , , , t tx x v v t t x v t

tf f t v f v f

js is the inverse of a relaxation time.Orthogonal polynomials

Projections of the distribution

Shear viscosity

Bulk viscosity

Chapman-Enskog expansion:

Multi-Relaxation-Time (MRT) LBM

P. Lallemand and L.S. Luo

Phys.Rev.E 61, 6546 (2000)

0

( , ) ( , ) ( )N

j eqj j j

j j j

sf x c t t t f x t m m

i

mj j f

mj (,...,ux,...)

cs2 1

s9,...,13

1

2

59cs2

9

1

s2

1

2

D3Q15

186

Powerflow, EXA

Car design

Lattice Boltzmann

187

Raising of a bubble

188

3d Rayleigh Benard

189

Flow through porous medium in 2d

using a NVidia GTX680

190

Surface Flow with Moving and Deforming Objects

Interfaces and free surfaces

191

192

Discrete fluid solvers

• Lattice Gas Automata (LGA)

• Lattice Boltzmann Method (LBM)

• Dissipative Particle Dynamics (DPD)

• Smooth Particle Hydrodynamics (SPH)

• Stochastic Rotation Dynamics (SRD)

• Direct Simulation Monte Carlo (DSMC)

193

• SPH describes a fluid by replacing its continuum properties with locally (smoothed) quantities at discrete Lagrangian locations meshless

• SPH is based on integral interpolants (Lucy 1977, Gingold & Monaghan 1977, Liu 2003)

(W is the smoothing kernel)

• These can be approximated discretely by a summation interpolant

'd,' ' rrrrr hWAA

j

jN

jjj

mhWAA

1

, rrrr

Smooth Particle Hydrodynamics

194

The kernel (or weighting Function)

1

4

1

2

3, 2

2qq

hhrW

W(r-r’,h)

Compact supportof kernel

WaterParticles

2h

r

| | , barh

rq rr

Smooth Particle Hydrodynamics

195

• Spatial gradients are approximated using a summation containing the gradient of the chosen kernel function

– the characteristics of the method can be changed by using a different kernel

ijijj j

ji WA

mA

ijij

jijii Wm . . uuu

Smooth Particle Hydrodynamics

196

Equations of Motion

• Navier-Stokes equations:

• Recast in particle form as:d

d

jiii j ij

j ij

m Wt

vrv

ijj

ijiji Wm

t vvd

d

iijj

iijj

j

i

ij

i Wpp

mt

Fv

22d

d

v.d

d

t

2d 1

d ipt

v

u F

0

d

d

t

mi

Smooth Particle Hydrodynamics

197

Simulation of free surface

198

Simulation of free surface

199

Simulation of free surface

200

Dwarf Galaxy Formation

201

Discrete fluid solvers

• Lattice Gas Automata (LGA)

• Lattice Boltzmann Method (LBM)

• Dissipative Particle Dynamics (DPD)

• Smooth Particle Hydrodynamics (SPH)

• Stochastic Rotation Dynamics (SRD)

• Direct Simulation Monte Carlo (DSMC)

202

Stochastic Rotation Dynamics

Stochastic Rotation Dynamics (SRD)• introduction of representative fluid particles

• collective interaction by rotation of local particle velocities

• very simple dynamics, but recovers hydrodynamics correctly

• Brownian motion is intrinsic

203

Stochastic Rotation Dynamics

Shift grid to impose

Galilean invariance.

Example of two particles in cell:

204

Shear flow

205

One particle in fluid

particlevv

fluid

e.g. pull sphere through fluid

particlev

Γ

no-slip condition:

create shear in fluid : exchange momentum

movingboundary condition

206

Drag force

jiij ij

j i

vvp

x x

drag force

stress tensor

η = μ is static viscosity

(Bernoulli‘s principle)

207

Homogeneous flow

Re << 1 Stokes law:

FD = 6π η R v(exact for Re = 0)

R

v

Re >> 1 Newton‘s law: FD = 0.22π R2v2

general drag law:

CD is the drag coefficient

22

Re8 DD CF

R is particle radius, v is relative velocity

208

Drag coefficient CD

Reynolds number Re = Dv/μ

Re

209

Inhomogeneous flow

In velocity or pressure gradients: Lift forcesare perpendicular to the direction of the external flow,

important for wings of airplanes.

when particle rotates: Magnus effectimportant for soccer

lift force:

CL is „lift coefficient“

2v

2LL C A

210

Many particles in fluids

•The fluid velocity field followsthe incompressible NavierStokes equations.

• Many industrial processesinvolve the transport of solidparticles suspended in a fluid.The particles can be sand,colloids, polymers, etc.

•The particles are dragged bythe fluid with a force:

simulating particles moving in a sheared fluid

22

Re8 DD CF

211

Stokes limit

hydrodynamic interaction between the particles

ij

jjiiji vrrMv

matrixmobility

)(

for Re = 0 mobility matrix exact

invert a full matrix only a few thousand particles

212

Numerical techniques

Calculate stress tensor directly by evaluating the gradients of the velocity field

through interpolation on the numerical grid,e.g. using Chebychev polynomials .

Method of Fogelson and Peskin:Advect markers that were placed in the particle and then put springs between

their new an their old position.These springs then pull the particle.

1

2

Numerical techniques

2 Method of A.L. Fogelson and C.S. Peskin:

Advect markers that were placed in the

particle and then put springs between

their new an their old position.

These springs then pull the particle.

216

Sedimentation

comparing experiment and simulation

Sedimentation of platelets

Oblate ellipsoids descend

in a fluid under the action

of gravity.

This has applications inbiology (blood), industry(paint) and geology (clay).

Thesis of Frank Fonseca

θ = 0.15 in 3d

228

Oral exams

Jan.22-Feb.02

2017

229

15 relevant questions

• Congruential and lagged-Fibbonacci RN• Definition of percolation• Fractal dimension and sand-box method• Hoshen-Kopelman algorithm• Finite size scaling• Integration with Monte Carlo• Detailed balance and MR2T2

• Ising model

230

15 relevant questions

• Simulate random walk

• Euler method

• 2nd order Runge-Kutta

• 2nd order predictor-corrector

• Jacobi and Gauss-Seidel relaxation

• Strategy of finite elements, finite volumes and spectral methods

231

Next semester402-0810 Computational Quantum Physics

Giuseppe Carleo and Philippe de Forcrand

Tuesday afternoon: V Di 14-16, U Di 16-18

402-0812 Computational Statistical Physics

Mirko Lukovic and Miller Mendoza

Friday morning: V Fr 11-13, U Fr 9-11

327-5102 Molecular Materials Modelling

Daniele Passerone

Friday afternoon: V Fr 14-16, U Fr 16-18

232

Computational Quantum Physics

Giuseppe Carleo and Philippe de Forcrand

Tuesday afternoon: V Di 14-16, U Di 16-18

One particle quantum mechanics:

scattering problem, time evolution

shooting technique

Numerov algorithm

233

Computational Quantum Physics

Many particle systems:

Fock space, etc (≈ 2 weeks theory)

Hartree-Fock approximation

density functional theory and

electron structure (He & H2)

strongly correlated electrons

Hubbard and T-J models

234

Computational Quantum Physics

Lanczos method

Path integral Monte Carlo

Bosonic world lines

QCD, lattice gauge theory

Fermions, QFT

235

Molecular Materials Modelling

Daniele Passerone

Friday afternoon; V Fr 14-16, U Fr 16-18

Empirical potentials and transition rates

Bio-force fields, charges, peptides

Embedded atom models, Wilff‘s theorem

Pair-correlation function with MD

for neutron scattering

236

Melting temperature from phase coexistence

MO-theory, basic SCF, chemical reactions

Density functional theory, pseudopotentials

DFT on realistic systems, hybrids

Linear scaling, GPW

Electronic spectroscopies, STM

Bandstructure, graphene, free energies

Molecular Materials Modelling

237

Computational Statistical Physics

Mirko Lukovic and Miller Mendoza

Friday morning: V Fr 11-13, U Fr 9-11

continuous variables (XY, Heisenberg)

multi-spin coding, bit-manipulation

vectorization, parallelization

histogram methods, multi canonical

238

Computational Statistical Physics

Kawasaki dynamics, heat bath

microcanonical, Creutz algorithm, Q2R

critical slowing down, dynamical scaling

cluster algorithms (Swendsen-Wang, Wolff)

Monte Carlo Renormalization Group

Molecular Dynamics Simulations:

Verlet and leap frog methods

239

Computational Statistical Physics

parallelization, realistic potentials

Ewald sums, reaction field method

Nose-Hoover thermostat, rescaling

constant pressure MD, melting

Discrete Elements, friction, inelasticity

rotation and quaternions

ab- initio calculations, Car Parinello

Top Related