• Tidak ada hasil yang ditemukan

FINITE DIFFERENCE AND PDE. Haryo Tomo

N/A
N/A
Protected

Academic year: 2021

Membagikan "FINITE DIFFERENCE AND PDE. Haryo Tomo"

Copied!
44
0
0

Teks penuh

(1)

FINITE DIFFERENCE

AND PDE

(2)

Finite differences

Finite volumes

- time-dependent PDEs

-> robust, simple concept, easy to

parallelize, regular grids, explicit method

Finite elements - -> implicit approach, matrix inversion, well founded, static and time-dependent PDEs

irregular grids, more complex algorithms, engineering problems

- time-dependent PDEs

-> robust, simple concept, irregular grids, explicit method

(3)

Particle-based methods

Pseudospectral

methods

- lattice gas methods

- molecular dynamics - granular problems - fluid flow

- earthquake simulations

-> very heterogeneous problems, nonlinear problems

Boundary element methods

- problems with boundaries (rupture)

- based on analytical solutions - only discretization of planes

-> good for problems with special boundary conditions (rupture, cracks, etc)

- orthogonal basis functions, special case of FD

- spectral accuracy of space derivatives

- wave propagation, ground penetrating radar -> regular grids, explicit method, problems with strongly heterogeneous media

(4)

What is a finite difference?

Common definitions of the derivative of f(x):

dx

x

f

dx

x

f

f

dx x

)

(

)

(

lim

0

dx

dx

x

f

x

f

f

dx x

)

(

)

(

lim

0

dx

dx

x

f

dx

x

f

f

dx x

2

)

(

)

(

lim

0

These are all correct definitions in the limit dx->0. But we want dx to remain FINITE

(5)

What is a finite difference?

The equivalent approximations of the derivatives are:

dx

x

f

dx

x

f

f

x

)

(

)

(

dx

dx

x

f

x

f

f

x

)

(

)

(

dx

dx

x

f

dx

x

f

f

x

2

)

(

)

(

forward difference backward difference centered difference

(6)

The

big

question:

How good are the FD approximations?



(7)

Taylor Series

Taylor series are expansions of a function f(x) for some finite distance dx to f(x+dx)

What happens, if we use this expression for

dx

x

f

dx

x

f

f

x

)

(

)

(

?

... ) ( ! 4 ) ( ! 3 ) ( ! 2 ) ( dx ) ( ) ( '''' 4 '' ' 3 '' 2 '        dx f x f x dx f x dx f x dx f x x f

(8)

Taylor Series

... that leads to :

The error of the first derivative using the forward formulation is of order dx.

Is this the case for other formulations of the derivative? Let’s check! ) ( ) ( ... ) ( ! 3 ) ( ! 2 ) ( dx 1 ) ( ) ( ' '' ' 3 '' 2 ' dx O x f x f dx x f dx x f dx dx x f dx x f              

(9)

... with the centered formulation we get:

The error of the first derivative using the centered approximation is of order dx2.

This is an important results: it DOES matter which formulation we use. The centered scheme is more accurate!

Taylor Series

) ( ) ( ... ) ( ! 3 ) ( dx 1 ) 2 / ( ) 2 / ( 2 ' '' ' 3 ' dx O x f x f dx x f dx dx dx x f dx x f              

(10)

' ' ' ! 3 ) 2 ( ' ' ! 2 ) 2 ( ' ) 2 ( ) 2 ( 3 2 f dx f dx f dx f dx x f      *a | *b | *c | *d |

... again we are looking for the coefficients a,b,c,d with which the function values at x±(2)dx have to be multiplied in order to obtain the interpolated value or the first (or second) derivative!

... Let us add up all these equations like in the previous case ...

' ' ' ! 3 ) ( ' ' ! 2 ) ( ' ) ( ) ( 3 2 f dx f dx f dx f dx x f      ' ' ' ! 3 ) ( ' ' ! 2 ) ( ' ) ( ) ( 3 2 f dx f dx f dx f dx x f      ' ' ' ! 3 ) 2 ( ' ' ! 2 ) 2 ( ' ) 2 ( ) 2 ( 3 2 f dx f dx f dx f dx x f     

(11)

Problems: Stability

2 2 2 2 ) ( ) ( 2 ) ( ) ( 2 ) ( ) ( sdt dt t p t p dx x p x p dx x p dx dt c dt t p          

1

dx

dt

c

Stability: Careful analysis using harmonic functions shows that a stable numerical calculation is subject to special conditions (conditional stability). This holds for many numerical problems. (Derivation on the board).

(12)

Problems: Dispersion

2 2 2 2 ) ( ) ( 2 ) ( ) ( 2 ) ( ) ( sdt dt t p t p dx x p x p dx x p dx dt c dt t p          

Dispersion: The numerical approximation has

artificial dispersion,

in other words, the wave speed becomes frequency dependent (Derivation in the board).

You have to find a frequency bandwidth

where this effect is small. The solution is to use a sufficient number of grid points per wavelength.

(13)

Finite Differences - Summary

 Conceptually the most simple of the numerical methods and can be learned quite quickly

 Depending on the physical problem FD methods are

conditionally stable (relation between time and space increment)

 FD methods have difficulties concerning the accurate

implementation of boundary conditions (e.g. free surfaces, absorbing boundaries)

 FD methods are usually explicit and therefore very easy to implement and efficient on parallel computers

(14)

Partial Differential Equations

by Lale Yurttas, Texas A&M

(15)

PERSAMAAN DIFERENSIAL PARSIAL

• Persamaan Umum

• Menyatakan bagaimana variabel tak bebas Ø berubah

terhadap variabel bebas x,y. Disini a,b,c,d,e,f, dan g mungkin merupakan fungsi dari Ø

0

2 2 2 2 2

g

f

y

e

x

d

y

c

y

x

b

x

a

(16)

Jenis2 PDP

• Ditentukan oleh harga b2-4ac

< 0, eliptic = 0, parabolic > 0, hyperbolic • Adveksi… • Difusi…. • Gelombang…

(17)

JENIS-JENIS

(18)

by Lale Yurttas, Texas A&M

(19)

The Laplacian Difference Equations/

0 4 0 2 2 2 2 0 , 1 , 1 , , 1 , 1 2 1 , , 1 , 2 , 1 , , 1 2 1 , , 1 , 2 2 2 , 1 , , 1 2 2 2 2 2 2                                               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 i j i j i j i j i T T T T T y x y T T T x T T T y T T T y T x T T T x T y T x T

by Lale Yurttas, Texas A&M

University Chapter 29

Laplacian difference equation.

Holds for all interior points

Laplace Equation

O[(x)2]

(20)

by Lale Yurttas, Texas A&M

(21)

• In addition, boundary conditions along the edges must be specified to obtain a unique solution.

• The simplest case is where the temperature at the boundary is set at a fixed value, Dirichlet boundary condition.

• A balance for node (1,1) is:

• Similar equations can be developed for other interior points to result a set of simultaneous equations.

0

4

0

75

0

4

21 12 11 10 01 11 10 12 01 21

T

T

T

T

T

T

T

T

T

T

by Lale Yurttas, Texas A&M

(22)

150 4 100 4 175 4 50 4 0 4 75 4 50 4 0 4 75 4 33 23 32 33 23 13 22 23 13 12 33 32 22 31 23 32 22 12 21 13 22 12 11 32 31 21 22 13 21 11 12 21 11                                          T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T

• The result is a set of nine simultaneous equations with nine unknowns:

(23)

x

Diffusion

Equation

Diffusion

2 2

x

h

D

t

h

h

(24)

x

d

h

u

D

x

 

x

x

d

u

d d

u

u

x

x

h

d

u

h

x

x t

x

   

 

(25)

d

u

h

x

x t

x

   

 

d

h

u

D

x

 

d

u

h

t

x

 

0

t

 

2 2

h

h

D

t

x

Diffusion Equation

(26)

Numerical Solution of Diffusion Eq.

( )

h i

(

1)

h i

(

1)

h i

1

( )

(

1)

h

h i

h i

x

x

 

x

h

2

(

1)

( )

h

h i

h i

x

x

 

 

2 2 2 1

1

h

h

h

x

x

x

x

(27)

x

t

xt  1 2 ・・・・・ i-1 i i+1 ・・・・ N 1 2 ・・ j-1 j j+ J

)

,

( j

i

h

)

1

,

1

(

i

j

h

(28)

t

j

i

h

j

i

h

t

h

(

,

1

)

(

,

)

2 2 2

(

1, )

( , )

( , )

(

1, )

(

1, ) 2 ( , )

(

1, )

h

D

h i

j

h i j

h i j

h i

j

D

x

x

x

x

h i

j

h i j

h i

j

D

x

2

( ,

1)

( , )

{ (

1, ) 2 ( , )

(

1, )}

h i j

h i j

D t

h i

j

h i j

h i

j

x

 

Unknown Known

(29)

Numerical Solution of Diffusion Equation

x

t

xt  1 2 ・・・・・ i-1 i i+1 ・・・・ N 1 2 ・・ j-1 j j+ J Initial Condition (Given)

(30)

2

2

( )

( )

(

1) 2

( )

(

1)

2

( )

( )

new old old old old

new old

do

,N-1

end do

do

,N-1

end do

i

t

h

i

h

i

h

i

h

i

h

i

D

x

i

h

i

h

i

 

2

( ,

1)

( , )

D t

{ (

1, ) 2 ( , )

(

1, )}

h i j

h i j

h i

j

h i j

h i

j

x

 

(31)

Contoh

• Cari solusinya dengan step size 0,2

• Jumlah titik solusi n=((2-1)/0,2)-1=4

• Kita dapatkan 4 persamaan, satu untuk tiap titik yang dicari.

6

)

2

(

,

1

)

1

(

,

4

2

3

2 2 2

y

x

y

y

dx

dy

dx

y

d

(32)

Penyelesaian dengan Beda Hingga

Persamaannya:

Buat persamaan untuk semua titik, mulai dari i=1, hingga i=4 x0=a x1 x2 x3 x4 x5=b 2 1 1 2 1 1

4

2

2

3

2

i i i i i i i

x

y

h

y

y

h

y

y

y

(33)

Domain Solusi

y5=6

y0=1

(34)

Penyelesaian dg Finite Diff.

• Dengan h = 0,2

• Buat persamaan untuk semua titik, mulai dari i=1,

hingga i=4

• Masukkan nilai-nilai x1=1,2 hingga x4 =1,8 dan kondisi

batas y0 = 1 dan y5 = 6

2

1

1

48

17

,

5

4

5

,

32

y

i

y

i

y

i

x

i

(35)

Kondisi batas

• Dirichlet atau fixed boundary, misal C(0) = Co

• Neuman atau natural boundary,

misal dC/dx = 0

• Robin/ Cauchy boundary condition,

misal dC/dx + C = 0

• Penerapan dalam finite difference dengan menambahkan

(36)

penyelesaian

persamaan

parabolik

dengan

skema

eksplisit

(37)

persamaan diferensial,

ditulis dalam bentuk metode beda hingga,

(38)

penyelesaian

persamaan

eliptik

laplace

….equation

(39)

Stabilitas skema eksplisit

k

(40)
(41)
(42)

penyelesaian

persamaan

parabolik

dengan

skema

implisit

(43)
(44)

Referensi

Dokumen terkait