an introduction to computational fluid mechanics by chuen-yen chow

18
An Introduction to Computational Fluid Mechanics By Chuen-Yen Chow

Upload: dinah-scott

Post on 18-Jan-2016

229 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: An Introduction to Computational Fluid Mechanics By Chuen-Yen Chow

An Introduction to

Computational

Fluid

Mechanics

By

Chuen-Yen Chow

Page 2: An Introduction to Computational Fluid Mechanics By Chuen-Yen Chow

Numerical Solution of Ordinary Differential Equations: Initial-Value Problems

Page 3: An Introduction to Computational Fluid Mechanics By Chuen-Yen Chow

Chapter 2

2.2 Numerical Solution of Second-Order ODE Boundary Value Problems

Page 4: An Introduction to Computational Fluid Mechanics By Chuen-Yen Chow
Page 5: An Introduction to Computational Fluid Mechanics By Chuen-Yen Chow

*Linear second order ODE of the form

)()()(2

2

xDfxBdx

dfxA

dx

fd

*The approximation by the difference equation

iiiiiiiii DfBffAh

fffh

11112 2

12

1

*Multiplying the equation by and grouping the terms

2h

2h

iiiiiii DhfAh

fBhfAh 2

12

1 212

21

Page 6: An Introduction to Computational Fluid Mechanics By Chuen-Yen Chow

iiiiiii DhfAh

fBhfAh 2

12

1 212

21

*It can be written in a more convenient form

413211 iiiiiii CfCfCfC

ii

ii

ii

ii

DhC

Ah

C

BhC

Ah

C

24

3

22

1

21

2

21

Page 7: An Introduction to Computational Fluid Mechanics By Chuen-Yen Chow

* The preceding coefficients are known constants at any interior

point in the specified range of x, applied at i=1,2,….,n

* n linear algebraic equations to be solved simultaneously for

n unknown

For i = 1 and n

Since and are known from the boundary conditions and constant

* Therefore are moved to the right

if

14213112011 CfCfCfC

413211 nnnnnnn CfCfCfC

1nf0f

1344

0111414

nnnn fCCC

fCCC

Page 8: An Introduction to Computational Fluid Mechanics By Chuen-Yen Chow

*The coefficient matrix on the left-hand side is called a tridiagonal

matrix

*This matrix can be solved by using the Gaussian elimination

method

Page 9: An Introduction to Computational Fluid Mechanics By Chuen-Yen Chow

*According to Gaussian elimination method, we multiply the

second equation by and the first by and then take the

difference of the two to eliminate

*The resulting equation is

*If we replace the following

1421122431223213211222 CCCCfCCfCCCC

1f21C12C

021

1421122424

122323

1321122222

C

CCCCC

CCC

CCCCC

Page 10: An Introduction to Computational Fluid Mechanics By Chuen-Yen Chow

*The same process is repeated for i = 3, 4, ….., n-1

*The remaining coefficients will be as following

*Where i = 2,3,….,n-1

*The value of can immediately be found by solving

simultaneously the last two equations

01

4,112,144

2,133

3,112,122

i

iiiii

iii

iiiii

C

CCCCC

CCC

CCCCC

nf

3,112,12

4,112,14

nnnn

nnnnn CCCC

CCCCf

Page 11: An Introduction to Computational Fluid Mechanics By Chuen-Yen Chow

*The remaining unknowns can be calculated in a backward order

the following formula

j = n-1, n-2, ……., 2, 1

2

134

j

jjjj C

fCCf

Page 12: An Introduction to Computational Fluid Mechanics By Chuen-Yen Chow

Constants declaration

TMAX = 1.08; DT = 0.002; NM = (TMAX/DT) + 1; NU = 0.000217; DOMAINy = 40.0/1000.0; JM = 41; DY = DOMAINy/(JM-1); U0 = 40.0; D = NU * DT / (DY*DY); U(1) = U0; UO(1) = U0; for J=2:JM % Reset U and UO arrays U(J) = 0.0; UO(J) = 0.0;end

Page 13: An Introduction to Computational Fluid Mechanics By Chuen-Yen Chow

%%Solution using LAASONEN MethodN = JM - 2;JMM1= JM - 1;

for K=1:NM for J=1:JM

UO(J) = U(J); UP(J,K) = U(J);

end

Page 14: An Introduction to Computational Fluid Mechanics By Chuen-Yen Chow

SPECIFY BOUNDARY CONDITIONS AND MODIFY SOME OF THE COEFFICIENTS

for J=1:N C(J,1) = D;

C(J,2) = -(1.0+2.0*D); C(J,3) = D;

C(J,4) = -U(J+1); end

C(1,4) = C(1,4) - C(1,1)*U(1); C(1,1) = 0.0;

C(N,4) = C(N,4) - C(N,3)*U(JM); C(N,3) = 0.0;

% TRIDIGONAL SOLUTION for J = 2:N-1

C(J,2) = C(J,2)*C(J-1,2) - C(J,1)*C(J-1,3); C(J,3) = C(J,3)*C(J-1,2);

C(J,4) = C(J,4)*C(J-1,2) - C(J,1)*C(J-1,4); end

Page 15: An Introduction to Computational Fluid Mechanics By Chuen-Yen Chow

COMPUTE PHI AND U AT INTERIOR POINT

F(N) = ( C(N,4)*C(N-1,2) - C(N,1)*C(N-1,4) ) / ( C(N,2)*C(N-1,2) - C(N,1)*C(N-1,3) );

for K = 1:(N-1) J = N - K; F(J) = ( C(J,4) - C(J,3)*F(J+1) ) / C(J,2); end

for J = 2:JMM1 U(J) = F(J-1); end

Page 16: An Introduction to Computational Fluid Mechanics By Chuen-Yen Chow
Page 17: An Introduction to Computational Fluid Mechanics By Chuen-Yen Chow
Page 18: An Introduction to Computational Fluid Mechanics By Chuen-Yen Chow

END