31
ME 747 Introduction to computational fluid dynamics By Chainarong Chaktranond Lecture 5 Introduction to solve engineering problems with finite-difference method

ME747 Lecture 5 - Chainarongchainarong.me.engr.tu.ac.th/documents/ME747 CFD/ME747... · 2009. 8. 14. · Lecture schedule 5. Introduction to solve engineering problems with finite-difference

  • Upload
    others

  • View
    2

  • Download
    0

Embed Size (px)

Citation preview

Page 1: ME747 Lecture 5 - Chainarongchainarong.me.engr.tu.ac.th/documents/ME747 CFD/ME747... · 2009. 8. 14. · Lecture schedule 5. Introduction to solve engineering problems with finite-difference

ME 747 Introduction to computational

fluid dynamics

By Chainarong Chaktranond

Lecture 5Introduction to solve engineering

problems with finite-difference method

Page 2: ME747 Lecture 5 - Chainarongchainarong.me.engr.tu.ac.th/documents/ME747 CFD/ME747... · 2009. 8. 14. · Lecture schedule 5. Introduction to solve engineering problems with finite-difference

2Chainarong Chaktranond, Thammasat University

Lecture schedule

5. Introduction to solve engineering problems with finite-difference method

- Taylor series expansion, Approximation of the second derivative, Initial condition and

Boundary conditions

6 – 7

4. Introduction to numerical methods

- Finite different method, Finite volume method, Finite element method, etc.

5

3. Overviews of governing equations for flow and heat transfer

-Elliptic, Parabolic and Hyperbolic equations

4

2. Introduction to Fortran programming

- Basic commands in Fortran programming

2 - 3

1.Overviews of computational fluid dynamics

- Overviews and importance of heat transfer in real applications1

TopicsSession

Page 3: ME747 Lecture 5 - Chainarongchainarong.me.engr.tu.ac.th/documents/ME747 CFD/ME747... · 2009. 8. 14. · Lecture schedule 5. Introduction to solve engineering problems with finite-difference

3Chainarong Chaktranond, Thammasat University

Contents

Finite difference method

Numerical discretization schemes

Page 4: ME747 Lecture 5 - Chainarongchainarong.me.engr.tu.ac.th/documents/ME747 CFD/ME747... · 2009. 8. 14. · Lecture schedule 5. Introduction to solve engineering problems with finite-difference

4Chainarong Chaktranond, Thammasat University

Solving the fluid dynamic equations

2

2

u ut x

ν∂ ∂=

∂ ∂

Transient –diffusion term

กําหนดให 1ν =

11 1

2

2n n n n ni i i i iu u u u u

t x

+− +− − +

=Δ Δ

จัดรูปสมการไดเปน

11 12 2 21 2n n n n

i i i it t tu u u u

x x x+

− +

Δ Δ Δ⎡ ⎤= + − +⎢ ⎥Δ Δ Δ⎣ ⎦

(1)

(2)

(3)

Explicit Euler method

Page 5: ME747 Lecture 5 - Chainarongchainarong.me.engr.tu.ac.th/documents/ME747 CFD/ME747... · 2009. 8. 14. · Lecture schedule 5. Introduction to solve engineering problems with finite-difference

5Chainarong Chaktranond, Thammasat University

Explicit Euler method

11 12 2 21 2n n n n

i i i it t tu u u u

x x x+

− +

Δ Δ Δ⎡ ⎤= + − +⎢ ⎥Δ Δ Δ⎣ ⎦

กําหนดให ( )0, 5u x =

( ),0 1u t =

( ), 1u t L =0 1 2 m

11 1

n n n ni i i iu au bu cu+

− += + +

1niu −

niu 1

niu +

0 1 2 m

2

taxΔ

=Δ 21 2 tb

xΔ⎡ ⎤= −⎢ ⎥Δ⎣ ⎦ 2

tcxΔ

โดยที่

Page 6: ME747 Lecture 5 - Chainarongchainarong.me.engr.tu.ac.th/documents/ME747 CFD/ME747... · 2009. 8. 14. · Lecture schedule 5. Introduction to solve engineering problems with finite-difference

6Chainarong Chaktranond, Thammasat University

11 1

n n n ni i i iu au bu cu+

− += + +1

niu −

niu 1

niu +

0 1 2 m

( )0, 5u x =Initial condition

กําหนดให Δt = 0.5 และ Δx = 1 ดังนั้น a = 0.5, b = 0, c = 0.5

Explicit Euler method

Boundary condition ( ),0 1u t = ( ), 1u t L =

[ ]{ } { }1n na u u +=

10 0 0 0 0

21 1 1 1 1

32 2 2 2 2

43 3 3 3

54 4 4

0

0

n n

n n

n n

n n

n n

a b c u ua b c u u

a b c u ua b u u

a u u

+

+

+

+

+

⎧ ⎫ ⎧ ⎫⎡ ⎤⎪ ⎪ ⎪ ⎪⎢ ⎥⎪ ⎪ ⎪ ⎪⎢ ⎥ ⎪ ⎪ ⎪ ⎪⎢ ⎥ =⎨ ⎬ ⎨ ⎬

⎢ ⎥ ⎪ ⎪ ⎪ ⎪⎢ ⎥ ⎪ ⎪ ⎪ ⎪⎢ ⎥ ⎪ ⎪ ⎪ ⎪⎣ ⎦ ⎩ ⎭ ⎩ ⎭

Page 7: ME747 Lecture 5 - Chainarongchainarong.me.engr.tu.ac.th/documents/ME747 CFD/ME747... · 2009. 8. 14. · Lecture schedule 5. Introduction to solve engineering problems with finite-difference

7Chainarong Chaktranond, Thammasat University

Explicit Euler method

00 1u =01 5u =02 5u =

At t = 0

At t = t + Δt

( )( ) ( )( ) ( )( )11 0.5 1 0 5 0.5 5 3u = + + =

( )( ) ( )( ) ( )( )0.5 5 0 5 0.5 5 5+ + =12u =

13u = ( )( ) ( )( ) ( )( )0.5 5 0 5 0.5 5 5+ + =

( )( ) ( )( ) ( )( )0.5 5 0 5 0.5 5 5+ + =14u =

11 1

n n n ni i i iu au bu cu+

− += + +

10 1u =

Page 8: ME747 Lecture 5 - Chainarongchainarong.me.engr.tu.ac.th/documents/ME747 CFD/ME747... · 2009. 8. 14. · Lecture schedule 5. Introduction to solve engineering problems with finite-difference

8Chainarong Chaktranond, Thammasat University

At t = t + 2Δt

( )( ) ( )( ) ( )( )21 0.5 1 0 3 0.5 5 3u = + + =

( )( ) ( )( ) ( )( )0.5 3 0 5 0.5 5 4+ + =22u =

23u = ( )( ) ( )( ) ( )( )0.5 5 0 5 0.5 5 5+ + =

( )( ) ( )( ) ( )( )31 0.5 1 0 3 0.5 4 2.5u = + + =

( )( ) ( )( ) ( )( )0.5 3 0 4 0.5 5 4+ + =12u =

13u = ( )( ) ( )( ) ( )( )0.5 4 0 5 0.5 5 4.5+ + =

( )( ) ( )( ) ( )( )0.5 5 0 5 0.5 5 5+ + =14u =

At t = t + 3Δt

20 1u =

30 1u =

Explicit Euler method

Page 9: ME747 Lecture 5 - Chainarongchainarong.me.engr.tu.ac.th/documents/ME747 CFD/ME747... · 2009. 8. 14. · Lecture schedule 5. Introduction to solve engineering problems with finite-difference

9Chainarong Chaktranond, Thammasat University

.000E+00 .100E+01.100E+01.100E+01.100E+01.100E+01.100E+01.100E+01.100E+01.100E+01.100E+01.100E+01

.100E+01 .500E+01.300E+01.300E+01.250E+01.250E+01.225E+01.225E+01.209E+01.209E+01.198E+01.198E+01

.200E+01 .500E+01.500E+01.400E+01.400E+01.350E+01.350E+01.319E+01.319E+01.295E+01.295E+01.276E+01

.300E+01 .500E+01.500E+01.500E+01.450E+01.450E+01.413E+01.413E+01.381E+01.381E+01.354E+01.354E+01

.400E+01 .500E+01.500E+01.500E+01.500E+01.475E+01.475E+01.444E+01.444E+01.413E+01.413E+01.383E+01

.500E+01 .500E+01.500E+01.500E+01.500E+01.500E+01.475E+01.475E+01.444E+01.444E+01.413E+01.413E+01

.600E+01 .500E+01.500E+01.500E+01.500E+01.475E+01.475E+01.444E+01.444E+01.413E+01.413E+01.383E+01

.700E+01 .500E+01.500E+01.500E+01.450E+01.450E+01.413E+01.413E+01.381E+01.381E+01.354E+01.354E+01

.800E+01 .500E+01.500E+01.400E+01.400E+01.350E+01.350E+01.319E+01.319E+01.295E+01.295E+01.276E+01

.900E+01 .500E+01.300E+01.300E+01.250E+01.250E+01.225E+01.225E+01.209E+01.209E+01.198E+01.198E+01

.100E+02 .100E+01.100E+01.100E+01.100E+01.100E+01.100E+01.100E+01.100E+01.100E+01.100E+01.100E+01

x t = 0 1 2 3 4 5 6 7 8 9 10

Explicit Euler method

Page 10: ME747 Lecture 5 - Chainarongchainarong.me.engr.tu.ac.th/documents/ME747 CFD/ME747... · 2009. 8. 14. · Lecture schedule 5. Introduction to solve engineering problems with finite-difference

6

5

4

3

2

1

0

u

1086420x

t = 0 t = 1 t = 2 t = 3 t = 4 t = 5

( )0, 5u x =

( ),0 1u t =

( ), 1u t L =

Initial condition

Boundary condition( )2 2

0.5 0.51

txΔ

= =Δ

Page 11: ME747 Lecture 5 - Chainarongchainarong.me.engr.tu.ac.th/documents/ME747 CFD/ME747... · 2009. 8. 14. · Lecture schedule 5. Introduction to solve engineering problems with finite-difference

program diffusion

parameter (n= 10,m=10)

real u(0:n+1,0:m+1)

open(1000,file='OUT-diffusion',status='unknown')

dt = 0.5

RX = 10.0

dx = RX/real(m)

dtdx = dt/dx/dx

do 10 i = 0,m

u(0,i) = 5.0

u(0,0) = 1.0

u(0,m) = 1.0

10 continue

do 110 j = 1,n

do 100 i = 1,m-1

u(j,0) = 1.0

u(j,m) = 1.0

u(j,i) = dtdx*u(j-1,i-1)+(1.0-2.0*dtdx)*u(j-1,i)+dtdx*u(j-1,i+1)

100 continue

110 continue

do 210 i = 0,m

write(1000,1001) real(i)*dx,(u(j,i),j = 0,n)

1001 format(e8.3,x,11e8.3)

210 continue

stop

end

Page 12: ME747 Lecture 5 - Chainarongchainarong.me.engr.tu.ac.th/documents/ME747 CFD/ME747... · 2009. 8. 14. · Lecture schedule 5. Introduction to solve engineering problems with finite-difference

12Chainarong Chaktranond, Thammasat University

Assignment 2

จงใชวิธี Explicit Euler method คํานวณและวาดกราฟการเปลี่ยนแปลง คา

ความเรว็ u ณ ตําแหนงและเวลาตางๆ เมื่อ Δt = 0.05 และ Δx = 0.1, 0.2, 0.4, 1, 2

2

2

u ut x

ν∂ ∂=

∂ ∂

กําหนดให 1ν =

( )0, 5u x =

( ),0 0u t =

( ), 0u t L =

Initial condition

Boundary condition

Page 13: ME747 Lecture 5 - Chainarongchainarong.me.engr.tu.ac.th/documents/ME747 CFD/ME747... · 2009. 8. 14. · Lecture schedule 5. Introduction to solve engineering problems with finite-difference

13Chainarong Chaktranond, Thammasat University

Implicit Euler method

1 1 1 11 1

2

2n n n n ni i i i iu u u u u

t x

+ + + +− +− − +

=Δ Δ

2

2

u ut x

ν∂ ∂=

∂ ∂กําหนดให 1ν = ( )0, 5u x =

( ),0 1u t =

( ), 1u t L =

1 1 1 11 12 2 22n n n n n

i i i i it t tu u u u u

x x x+ + + +− +

Δ Δ Δ= − + + −

Δ Δ Δ

1 1 1 11 12 2 22n n n n n

i i i i it t tu u u u u

x x x+ + + +

− +

Δ Δ Δ− = − +

Δ Δ Δ

1 1 11 12 2 21 2n n n n

i i i it t tu u u u

x x x+ + +− +

Δ Δ Δ⎛ ⎞= − + + −⎜ ⎟Δ Δ Δ⎝ ⎠

Page 14: ME747 Lecture 5 - Chainarongchainarong.me.engr.tu.ac.th/documents/ME747 CFD/ME747... · 2009. 8. 14. · Lecture schedule 5. Introduction to solve engineering problems with finite-difference

14Chainarong Chaktranond, Thammasat University

Implicit Euler method

1 1 11 1

n n n ni i i iu au bu cu+ + +

− += + +

2

taxΔ

= −Δ 21 2 tb

xΔ⎛ ⎞= +⎜ ⎟Δ⎝ ⎠

1 1 11 12 2 21 2n n n n

i i i it t tu u u u

x x x+ + +− +

Δ Δ Δ⎛ ⎞= − + + −⎜ ⎟Δ Δ Δ⎝ ⎠

2

tcxΔ

= −Δ

To solve this problem, need initial and boundary conditions

Page 15: ME747 Lecture 5 - Chainarongchainarong.me.engr.tu.ac.th/documents/ME747 CFD/ME747... · 2009. 8. 14. · Lecture schedule 5. Introduction to solve engineering problems with finite-difference

15Chainarong Chaktranond, Thammasat University

0 1 1 11 1 1 1 2 1 3u a u b u c u= + + +

0 15 5 5u a u=

1 2 3 54

1 01 1 1 1 1

1 02 2 2 2 2

1 03 3 3 3 3

1 04 4 4 4

1 05 5 5

a b c u ua b c u u

a b c u ua b u u

a u u

⎧ ⎫ ⎧ ⎫⎡ ⎤⎪ ⎪ ⎪ ⎪⎢ ⎥⎪ ⎪ ⎪ ⎪⎢ ⎥ ⎪ ⎪ ⎪ ⎪⎢ ⎥ =⎨ ⎬ ⎨ ⎬

⎢ ⎥ ⎪ ⎪ ⎪ ⎪⎢ ⎥ ⎪ ⎪ ⎪ ⎪⎢ ⎥ ⎪ ⎪ ⎪ ⎪⎣ ⎦ ⎩ ⎭ ⎩ ⎭

[ ]{ } { }1n ni iA u u+ =

1 02 2 2 2 2

1 03 3 3 3

1 04 4 4

a b c u ua b u u

a u u

⎧ ⎫ ⎧ ⎫⎡ ⎤⎪ ⎪ ⎪ ⎪⎢ ⎥ =⎨ ⎬ ⎨ ⎬⎢ ⎥⎪ ⎪ ⎪ ⎪⎢ ⎥⎣ ⎦ ⎩ ⎭ ⎩ ⎭

0 1 1 12 2 2 2 3 2 4u a u b u c u= + +

0 1 1 13 3 3 3 4 3 5u a u b u c u= + +

0 1 14 4 4 4 5u a u b u= +

Implicit Euler method

เมื่อตัดคาที่ boundary conditions

สมมติวาพิจารณา 5 grid

Page 16: ME747 Lecture 5 - Chainarongchainarong.me.engr.tu.ac.th/documents/ME747 CFD/ME747... · 2009. 8. 14. · Lecture schedule 5. Introduction to solve engineering problems with finite-difference

16Chainarong Chaktranond, Thammasat University

11 1 1 1 1

12 2 2 2 2

13 3 3 3 3

14 4 4 4 4

15 5 5 5 5

16 6 6 6 6

17 7 7 7 7

18 8 8 8 8

19 9 9

110 10

n n

n n

n n

n n

n n

n n

n n

n n

n

n

a b c u ua b c u u

a b c u ua b c u u

a b c u ua b c u u

a b c u ua b c u u

a b u ua u

+

+

+

+

+

+

+

+

+

+

⎧ ⎫⎡ ⎤⎪ ⎪⎢ ⎥⎪ ⎪⎢ ⎥⎪ ⎪⎢ ⎥⎪ ⎪⎢ ⎥⎪ ⎪⎢ ⎥⎪ ⎪⎢ ⎥ ⎪ ⎪⎢ ⎥ =⎨ ⎬

⎢ ⎥ ⎪ ⎪⎢ ⎥ ⎪ ⎪⎢ ⎥ ⎪ ⎪⎢ ⎥ ⎪ ⎪⎢ ⎥ ⎪ ⎪⎢ ⎥ ⎪ ⎪⎢ ⎥ ⎪ ⎪⎢ ⎥⎣ ⎦ ⎩ ⎭

9

10

n

nu

⎧ ⎫⎪ ⎪⎪ ⎪⎪ ⎪⎪ ⎪⎪ ⎪⎪ ⎪⎪ ⎪⎨ ⎬⎪ ⎪⎪ ⎪⎪ ⎪⎪ ⎪⎪ ⎪⎪ ⎪⎪ ⎪⎩ ⎭

Implicit Euler method

Page 17: ME747 Lecture 5 - Chainarongchainarong.me.engr.tu.ac.th/documents/ME747 CFD/ME747... · 2009. 8. 14. · Lecture schedule 5. Introduction to solve engineering problems with finite-difference

17Chainarong Chaktranond, Thammasat University

Implicit Euler method

Know initial and boundary conditions

12 2 2 2 2

13 3 3 3 3

14 4 4 4 4

15 5 5 5 5

16 6 6 6 6

17 7 7 7 7

18 8 8 8

19 9 9

n n

n n

n n

n n

n n

n n

n n

n n

a b c u ua b c u u

a b c u ua b c u u

a b c u ua b c u u

a b u ua u u

+

+

+

+

+

+

+

+

⎧ ⎫ ⎧ ⎫⎡ ⎤⎪ ⎪ ⎪ ⎪⎢ ⎥⎪ ⎪ ⎪ ⎪⎢ ⎥⎪ ⎪ ⎪ ⎪⎢ ⎥⎪ ⎪ ⎪ ⎪⎢ ⎥⎪ ⎪ ⎪ ⎪⎢ ⎥ =⎨ ⎬ ⎨ ⎬⎢ ⎥ ⎪ ⎪ ⎪ ⎪⎢ ⎥ ⎪ ⎪ ⎪ ⎪⎢ ⎥ ⎪ ⎪ ⎪ ⎪⎢ ⎥ ⎪ ⎪ ⎪ ⎪⎢ ⎥ ⎪ ⎪ ⎪ ⎪⎢ ⎥⎣ ⎦ ⎩ ⎭ ⎩ ⎭

10 1u =( )0, 5u x = 1 1u =

Page 18: ME747 Lecture 5 - Chainarongchainarong.me.engr.tu.ac.th/documents/ME747 CFD/ME747... · 2009. 8. 14. · Lecture schedule 5. Introduction to solve engineering problems with finite-difference

18Chainarong Chaktranond, Thammasat University

tridiagonal matrix algorithm (TDMA)

1 1i i i i i i ia x b x c x d− ++ + =

เมื่อ a1 = cn = 0

1 1 1 1

2 2 2 2 2

3 3 3 3 3

4 4 4

5 5 5

6 6 6

7 7 7

8 8 8 8

0

0

b c x da b c x d

a b c x da b c

a b ca b c

a b ca b x d

⎡ ⎤ ⎡ ⎤ ⎡ ⎤⎢ ⎥ ⎢ ⎥ ⎢ ⎥⎢ ⎥ ⎢ ⎥ ⎢ ⎥⎢ ⎥ ⎢ ⎥ ⎢ ⎥⎢ ⎥ ⎢ ⎥ ⎢ ⎥⎢ ⎥ ⎢ ⎥ ⎢ ⎥=⎢ ⎥ ⎢ ⎥ ⎢ ⎥⎢ ⎥ ⎢ ⎥ ⎢ ⎥⎢ ⎥ ⎢ ⎥ ⎢ ⎥⎢ ⎥ ⎢ ⎥ ⎢ ⎥⎢ ⎥ ⎢ ⎥ ⎢ ⎥⎢ ⎥ ⎢ ⎥ ⎢ ⎥⎣ ⎦ ⎣ ⎦ ⎣ ⎦

[ ]{ } { }i iA x d=

Concept

ใช Matrix operation เพื่อทํา

ใหสัมประสิทธิ์แถวทแยงมุม มี

คาเปน 1

Page 19: ME747 Lecture 5 - Chainarongchainarong.me.engr.tu.ac.th/documents/ME747 CFD/ME747... · 2009. 8. 14. · Lecture schedule 5. Introduction to solve engineering problems with finite-difference

19Chainarong Chaktranond, Thammasat University

ขั้นที่ 1 หารเมตริกซแถวแรกดวย b1

tridiagonal matrix algorithm (TDMA)

1 11

1 12

2 2 2 23

3 3 3 3

4 4 4

5 5 5

6 6 6

7 7 78

8 8 8

1 0

0

c dx

b bx

a b c dx

a b c da b c

a b ca b c

a b cx

a b d

⎡ ⎤ ⎡ ⎤⎡ ⎤⎢ ⎥ ⎢ ⎥⎢ ⎥⎢ ⎥ ⎢ ⎥⎢ ⎥⎢ ⎥ ⎢ ⎥⎢ ⎥⎢ ⎥ ⎢ ⎥⎢ ⎥⎢ ⎥ ⎢ ⎥⎢ ⎥⎢ ⎥ ⎢ ⎥=⎢ ⎥⎢ ⎥ ⎢ ⎥⎢ ⎥⎢ ⎥ ⎢ ⎥⎢ ⎥⎢ ⎥ ⎢ ⎥⎢ ⎥⎢ ⎥ ⎢ ⎥⎢ ⎥⎢ ⎥ ⎢ ⎥⎢ ⎥⎢ ⎥ ⎢ ⎥⎣ ⎦⎢ ⎥ ⎢ ⎥⎣ ⎦ ⎣ ⎦

Page 20: ME747 Lecture 5 - Chainarongchainarong.me.engr.tu.ac.th/documents/ME747 CFD/ME747... · 2009. 8. 14. · Lecture schedule 5. Introduction to solve engineering problems with finite-difference

20Chainarong Chaktranond, Thammasat University

ขั้นที่ 2 คูณแถวที่หนึ่งดวย a2 แลวนําไปลบออกจากแถวที่สองและกําหนดให

1 1 1

2 1 2 2 2 2 1 2

3 3 3 3 3

4 4 4

5 5 5

6 6 6

7 7 7

8 8 8 8

1 00

0

c x db c a c x d d a

a b c x da b c

a b ca b c

a b ca b x d

′ ′⎡ ⎤ ⎡ ⎤ ⎡ ⎤⎢ ⎥ ⎢ ⎥ ⎢ ⎥′ ′− −⎢ ⎥ ⎢ ⎥ ⎢ ⎥⎢ ⎥ ⎢ ⎥ ⎢ ⎥⎢ ⎥ ⎢ ⎥ ⎢ ⎥⎢ ⎥ ⎢ ⎥ ⎢ ⎥=⎢ ⎥ ⎢ ⎥ ⎢ ⎥⎢ ⎥ ⎢ ⎥ ⎢ ⎥⎢ ⎥ ⎢ ⎥ ⎢ ⎥⎢ ⎥ ⎢ ⎥ ⎢ ⎥⎢ ⎥ ⎢ ⎥ ⎢ ⎥⎢ ⎥ ⎢ ⎥ ⎢ ⎥⎣ ⎦ ⎣ ⎦ ⎣ ⎦

11

1

ccb

′ =

tridiagonal matrix algorithm (TDMA)

11

1

ddb

′ =และ

Page 21: ME747 Lecture 5 - Chainarongchainarong.me.engr.tu.ac.th/documents/ME747 CFD/ME747... · 2009. 8. 14. · Lecture schedule 5. Introduction to solve engineering problems with finite-difference

ขั้นที่ 3 หารแถวที่สองดวย

1 11

2 2 1 22

2 1 2 2 1 23

3 3 3 3

4 4 4

5 5 5

6 6 6

7 7 78

8 8 8

1 0

0 1

0

c dx

c d d ax

b c a b c ax

a b c da b c

a b ca b c

a b cx

a b d

′ ′⎡ ⎤ ⎡ ⎤⎡ ⎤⎢ ⎥ ⎢ ⎥′−⎢ ⎥⎢ ⎥ ⎢ ⎥⎢ ⎥′ ′⎢ ⎥ ⎢ ⎥− −⎢ ⎥⎢ ⎥ ⎢ ⎥⎢ ⎥⎢ ⎥ ⎢ ⎥⎢ ⎥⎢ ⎥ ⎢ ⎥=⎢ ⎥⎢ ⎥ ⎢ ⎥⎢ ⎥⎢ ⎥ ⎢ ⎥⎢ ⎥⎢ ⎥ ⎢ ⎥⎢ ⎥⎢ ⎥ ⎢ ⎥⎢ ⎥⎢ ⎥ ⎢ ⎥⎢ ⎥⎢ ⎥ ⎢ ⎥⎣ ⎦⎢ ⎥ ⎢ ⎥⎣ ⎦ ⎣ ⎦

2 1 2b c a′−

และเริ่มตนทําซ้าํขั้นที่สอง กับแถวอื่นๆ จนถงึแถวที่ n หรือเขยีนไดเปน

1

1

1

; 1

; 2,3, ,i

i

i i i

c ib

cc

i nb c a−

⎧ =⎪⎪′ = ⎨⎪ =⎪ ′−⎩

1

1

1

1

; 1

; 2,3, ,i

i i i

i i i

d ib

dd d a i nb c a

⎧ =⎪⎪′ = ⎨ ′−⎪ =⎪ ′−⎩

2d ′

Page 22: ME747 Lecture 5 - Chainarongchainarong.me.engr.tu.ac.th/documents/ME747 CFD/ME747... · 2009. 8. 14. · Lecture schedule 5. Introduction to solve engineering problems with finite-difference

n nx d ′=

1 ; 1, 2, ,1i i i xx d c x i n n+′ ′= − = − − …

เมื่อคาสัมประสิทธิ์ bn = 1 แลว จะได

ขั้นสุดทายทําการแทนคา xn เพื่อหาคา xn-1, xn-2, …., x1

1

21

2 1 22 1 2

132 1 2

3 2 3 2

34

4 3 4

5

5 4 57 6 7

67 6 7

6 5 6 88

7

7 6 7

1 0

0 1

0 1

0 1

0 1

0 1

0 1

0 1

cc

db c a

d d axc

b c ab c a x

xcb c a

cb c a

d d ac

b c ab c a x

d dc

b c a

′⎡ ⎤⎢ ⎥⎢ ⎥ ′

′⎢ ⎥−′−⎢ ⎥

⎡ ⎤⎢ ⎥ ′−⎢ ⎥⎢ ⎥′− ⎢ ⎥⎢ ⎥⎢ ⎥⎢ ⎥⎢ ⎥⎢ ⎥′− ⎢ ⎥⎢ ⎥ =⎢ ⎥⎢ ⎥⎢ ⎥⎢ ⎥′− ⎢ ⎥⎢ ⎥ ′−⎢ ⎥⎢ ⎥⎢ ⎥ ′−⎢ ⎥′− ⎢ ⎥⎣ ⎦⎢ ⎥ ′−⎢ ⎥

⎢ ⎥′−⎢ ⎥

⎢ ⎥⎢ ⎥⎣ ⎦

7 8

8 7 8

ab c a

⎡ ⎤⎢ ⎥⎢ ⎥⎢ ⎥⎢ ⎥⎢ ⎥⎢ ⎥⎢ ⎥⎢ ⎥⎢ ⎥⎢ ⎥⎢ ⎥⎢ ⎥⎢ ⎥⎢ ⎥⎢ ⎥′−⎢ ⎥⎣ ⎦

nd ′=

Page 23: ME747 Lecture 5 - Chainarongchainarong.me.engr.tu.ac.th/documents/ME747 CFD/ME747... · 2009. 8. 14. · Lecture schedule 5. Introduction to solve engineering problems with finite-difference
Page 24: ME747 Lecture 5 - Chainarongchainarong.me.engr.tu.ac.th/documents/ME747 CFD/ME747... · 2009. 8. 14. · Lecture schedule 5. Introduction to solve engineering problems with finite-difference
Page 25: ME747 Lecture 5 - Chainarongchainarong.me.engr.tu.ac.th/documents/ME747 CFD/ME747... · 2009. 8. 14. · Lecture schedule 5. Introduction to solve engineering problems with finite-difference

12 2 2 2 2

13 3 3 3 3

14 4 4 4 4

15 5 5 5 5

16 6 6 6 6

17 7 7 7 7

18 8 8 8

19 9 9

n n

n n

n n

n n

n n

n n

n n

n n

a b c u ua b c u u

a b c u ua b c u u

a b c u ua b c u u

a b u ua u u

+

+

+

+

+

+

+

+

⎧ ⎫ ⎧ ⎫⎡ ⎤⎪ ⎪ ⎪ ⎪⎢ ⎥⎪ ⎪ ⎪ ⎪⎢ ⎥⎪ ⎪ ⎪ ⎪⎢ ⎥⎪ ⎪ ⎪ ⎪⎢ ⎥⎪ ⎪ ⎪ ⎪⎢ ⎥ =⎨ ⎬ ⎨ ⎬⎢ ⎥ ⎪ ⎪ ⎪ ⎪⎢ ⎥ ⎪ ⎪ ⎪ ⎪⎢ ⎥ ⎪ ⎪ ⎪ ⎪⎢ ⎥ ⎪ ⎪ ⎪ ⎪⎢ ⎥ ⎪ ⎪ ⎪ ⎪⎢ ⎥⎣ ⎦ ⎩ ⎭ ⎩ ⎭

จากตัวอยาง Implicit Euler method

Page 26: ME747 Lecture 5 - Chainarongchainarong.me.engr.tu.ac.th/documents/ME747 CFD/ME747... · 2009. 8. 14. · Lecture schedule 5. Introduction to solve engineering problems with finite-difference

2 2 212

2 2 213

3 3 3 314

4 4 4 415

5 5 5 516

6 6 6 617

7 7 7 718

8 8 819

9 9

1n

n

nn

nn

nn

nn

nn

nn

nn

b c uua a au

a b c uu

a b c uu

a b c uu

a b c uu

a b c uu

a b uu

a u

+

+

+

+

+

+

+

+

⎧ ⎫⎡ ⎤⎧ ⎫ ⎪ ⎪⎢ ⎥⎪ ⎪ ⎪ ⎪⎢ ⎥⎪ ⎪ ⎪ ⎪⎢ ⎥⎪ ⎪ ⎪ ⎪⎢ ⎥⎪ ⎪ ⎪ ⎪⎢ ⎥ ⎪ ⎪ ⎪ ⎪⎢ ⎥ =⎨ ⎬ ⎨ ⎬⎢ ⎥ ⎪ ⎪ ⎪ ⎪⎢ ⎥ ⎪ ⎪ ⎪ ⎪⎢ ⎥ ⎪ ⎪ ⎪ ⎪⎢ ⎥ ⎪ ⎪ ⎪ ⎪⎢ ⎥ ⎪ ⎪ ⎪ ⎪⎢ ⎥ ⎩ ⎭ ⎪ ⎪⎢ ⎥⎣ ⎦ ⎩ ⎭

หารแถวแรกดวย a2

22

2

b ba

′= 22

2

c ca

′= 22

2

nnu u

a′=

แลวกําหนดให

Page 27: ME747 Lecture 5 - Chainarongchainarong.me.engr.tu.ac.th/documents/ME747 CFD/ME747... · 2009. 8. 14. · Lecture schedule 5. Introduction to solve engineering problems with finite-difference

2 2 212

3 2 2 3 1 3 23

3 2 3 2 3 214

4 4 4 1 45

5 5 5 1 56

6 6 6 1 67

7 7 7 1 78

8 8 1 89

9 9

1

1

nn

n nn

nn

nn

nn

nn

nn

nn

b c uu

b c b c u uua b a b a bu

a b c uu

a b c uu

a b c uu

a b c uu

a b uu

a u

′+

′+

+

+

+

+

+

+

′ ′ ⎧⎡ ⎤⎧ ⎫ ⎪⎢ ⎥′ ′− −⎪ ⎪ ⎪⎢ ⎥⎪ ⎪ ⎪′ ′⎢ ⎥− − ′−⎪ ⎪ ⎪⎢ ⎥⎪ ⎪⎢ ⎥ ⎪ ⎪⎢ ⎥ =⎨ ⎬ ⎨⎢ ⎥ ⎪ ⎪⎢ ⎥ ⎪ ⎪⎢ ⎥ ⎪ ⎪⎢ ⎥ ⎪ ⎪⎢ ⎥ ⎪ ⎪⎢ ⎥ ⎩ ⎭⎢ ⎥⎣ ⎦

⎫⎪⎪⎪⎪

⎪ ⎪⎪ ⎪

⎬⎪ ⎪⎪ ⎪⎪ ⎪⎪ ⎪⎪ ⎪⎪ ⎪⎩ ⎭

นําแถวที่สองลบออกดวยแถวที่หนึ่งและหารดวย 3 2a b′−

3nu ′

Page 28: ME747 Lecture 5 - Chainarongchainarong.me.engr.tu.ac.th/documents/ME747 CFD/ME747... · 2009. 8. 14. · Lecture schedule 5. Introduction to solve engineering problems with finite-difference

2 2

3 2 2 3

3 2 3 21

4 3 3 4 21

4 3 4 3 3

5 4 4 5

5 4 5 4

6 5 5 6

6 5 6 5

7 6 6 7

7 6 7 6

8 7 7

8 7

1

1

1

1

1

1

1

1

n

n

b cb c b ca b a b

b c b c ua b a b u

b c b ca b a b

b c b ca b a b

b c b ca b a b

b c ba b

+

+

′ ′⎡ ⎤⎢ ⎥′ ′−⎢ ⎥

′ ′⎢ ⎥− −⎢ ⎥′ ′−⎢ ⎥⎢ ⎥′ ′− −⎢ ⎥

′ ′−⎢ ⎥⎢ ⎥′ ′− −⎢ ⎥

′ ′−⎢ ⎥⎢ ⎥′ ′− −⎢ ⎥⎢ ′ ′ ⎥−⎢ ⎥′ ′− −⎢ ⎥⎢ ⎥′ ′−⎢ ⎥

′−⎢ ⎥⎢ ⎥⎢ ⎥⎣ ⎦

2

3 2

3 2

4 3

4 3

5 414

5 415

1 6 56

1 6 57

1 7 68

1 7 69

8 7

8 7

9 8

9 8

n

n n

n n

n nn

nn n

n

nn n

n

n

n n

n n

uu ua bu ua bu u

ua b

uu uua b

uu uua buu ua bu ua b

′+

+′

+

+

′+

+

⎧ ⎫⎪ ⎪

−⎪ ⎪⎪ ⎪′−⎪ ⎪⎪ ⎪−

⎧ ⎫ ⎪ ⎪′−⎪ ⎪ ⎪ ⎪⎪ ⎪ ⎪ ⎪−⎪ ⎪ ⎪ ⎪

′−⎪ ⎪ ⎪ ⎪⎪ ⎪ ⎪ ⎪⎪ ⎪= −⎨ ⎬ ⎨ ⎬⎪ ⎪ ⎪ ′−⎪ ⎪ ⎪⎪ ⎪ ⎪ −⎪ ⎪ ⎪

′−⎪ ⎪ ⎪⎩ ⎭ ⎪ −⎪

′⎪ −⎪

−⎪⎪ ′−⎪⎩

⎪⎪⎪⎪⎪⎪⎪⎪⎪⎪⎪⎪⎭

ทําดงัขัน้ตอนทีผ่านมาจนกระทั่งคาสัมประสิทธิ์แถวทแยงมมุทุกตัวมีคาเปน 1

1 8 79 9

8 7

n nn nu u

u ua b

′′+ −

= =′−

จะไดวา 1 8 7 7

8 9 88 7

n n nb c bu u u

a b′ ′+ ′ ′−

= −′−

1 ; 1, 2, ,1i i i xx d c x i n n+′ ′= − = − − …

8 7 7

8 7

b c ba b

′ ′−′−

8 7

8 7

n nu ua b

′−′−

นําไปแทนคา

Page 29: ME747 Lecture 5 - Chainarongchainarong.me.engr.tu.ac.th/documents/ME747 CFD/ME747... · 2009. 8. 14. · Lecture schedule 5. Introduction to solve engineering problems with finite-difference

29Chainarong Chaktranond, Thammasat University

Other methods

1 11 1

2

22

n n n n ni i i i iu u u u u

t x

+ −− +⎡ ⎤− − +

= ⎢ ⎥Δ Δ⎣ ⎦

Richardson method

DuFort-Frankel method

1 1 1 11 1

22

n n n n n ni i i i i iu u u u u u

t x

+ − + −− +⎡ ⎤− − − +

= ⎢ ⎥Δ Δ⎣ ⎦

แทนเทอม diffusion ดวย 1 1

2

n ni iu u+ −+

Truncation error ( ) ( ) ( )2 2 2, , /O t x t x⎡ ⎤Δ Δ Δ Δ⎣ ⎦

Page 30: ME747 Lecture 5 - Chainarongchainarong.me.engr.tu.ac.th/documents/ME747 CFD/ME747... · 2009. 8. 14. · Lecture schedule 5. Introduction to solve engineering problems with finite-difference

30Chainarong Chaktranond, Thammasat University

Other methods

1 1 1 11 1

2

2n n n n ni i i i iu u u u u

t x

+ + + +− +⎡ ⎤− − +

= ⎢ ⎥Δ Δ⎣ ⎦

Lassonen method (Euler implicit method)

Crank-Nicolson method

1 1 1 11 1 1 1

2 2

2 21 12 2

n n n n n n n ni i i i i i i iu u u u u u u u

t x x

+ + + +− + − +⎡ ⎤ ⎡ ⎤− − + − +

= +⎢ ⎥ ⎢ ⎥Δ Δ Δ⎣ ⎦ ⎣ ⎦

Truncation error ( ) ( ),O t xΔ Δ⎡ ⎤⎣ ⎦

Page 31: ME747 Lecture 5 - Chainarongchainarong.me.engr.tu.ac.th/documents/ME747 CFD/ME747... · 2009. 8. 14. · Lecture schedule 5. Introduction to solve engineering problems with finite-difference

31Chainarong Chaktranond, Thammasat University

Assignment 3

จงใชวิธี Implicit Euler method คํานวณและวาดกราฟการเปลี่ยนแปลง คา

ความเรว็ u ณ ตําแหนงและเวลาตางๆ เมื่อ Δt = 0.05 และ Δx = 0.1, 0.2, 0.4, 1, 2

2

2

u ut x

ν∂ ∂=

∂ ∂

กําหนดให 1ν =

( )0, 5u x =

( ),0 0u t =

( ), 0u t L =

Initial condition

Boundary condition