Sunteți pe pagina 1din 48

1

I
n
d
i
a
n


I
n
s
t
i
t
u
t
e


o
f


T
e
c
h
n
o
l
o
g
y


M
a
d
r
a
s
C
h
e
n
n
a
i

3
6
Introduction to Finite Difference and Finite Volume
Methods for CFD
By
Prof. B.V.S.S.S Prasad
Thermal Turbo Machines Lab,
Department of Mechanical Engineering,
IIT Madras, Chennai.
2
I
n
d
i
a
n


I
n
s
t
i
t
u
t
e


o
f


T
e
c
h
n
o
l
o
g
y


M
a
d
r
a
s
C
h
e
n
n
a
i

3
6
Pre-Processor
Definition of
geometry/comput
ational domain
Grid generation
Selection of
phenomena to be
modeled and
selecting
governing
equations
Definition of fluid
properties
Specification of
initial/boundary
conditions
Solver
Numerical solution of
governing equations
Approximation of
the unknown
variables by
simple functions
Discretization by
substitution of
the
approximations
into the
governing
equations
Solution of
algebraic
equations
Post-
Processor
Presentation of
results in terms of
Vector plots
Contour plots
Particle tracking
View
manipulations
Printouts
3
I
n
d
i
a
n


I
n
s
t
i
t
u
t
e


o
f


T
e
c
h
n
o
l
o
g
y


M
a
d
r
a
s
C
h
e
n
n
a
i

3
6
Solver
Approximation of
the unknown
variables by simple
functions
Discretization by
substitution of the
approximations into
the governing
equations
Solution of
algebraic equations
Finite Difference Method
Finite Element Method
Spectral Method
Finite Volume Method
Others!
4
I
n
d
i
a
n


I
n
s
t
i
t
u
t
e


o
f


T
e
c
h
n
o
l
o
g
y


M
a
d
r
a
s
C
h
e
n
n
a
i

3
6
Finite Differences
5
I
n
d
i
a
n


I
n
s
t
i
t
u
t
e


o
f


T
e
c
h
n
o
l
o
g
y


M
a
d
r
a
s
C
h
e
n
n
a
i

3
6
6
I
n
d
i
a
n


I
n
s
t
i
t
u
t
e


o
f


T
e
c
h
n
o
l
o
g
y


M
a
d
r
a
s
C
h
e
n
n
a
i

3
6
7
I
n
d
i
a
n


I
n
s
t
i
t
u
t
e


o
f


T
e
c
h
n
o
l
o
g
y


M
a
d
r
a
s
C
h
e
n
n
a
i

3
6
A Typical Finite Difference Grid
8
I
n
d
i
a
n


I
n
s
t
i
t
u
t
e


o
f


T
e
c
h
n
o
l
o
g
y


M
a
d
r
a
s
C
h
e
n
n
a
i

3
6
9
I
n
d
i
a
n


I
n
s
t
i
t
u
t
e


o
f


T
e
c
h
n
o
l
o
g
y


M
a
d
r
a
s
C
h
e
n
n
a
i

3
6
10
I
n
d
i
a
n


I
n
s
t
i
t
u
t
e


o
f


T
e
c
h
n
o
l
o
g
y


M
a
d
r
a
s
C
h
e
n
n
a
i

3
6
11
I
n
d
i
a
n


I
n
s
t
i
t
u
t
e


o
f


T
e
c
h
n
o
l
o
g
y


M
a
d
r
a
s
C
h
e
n
n
a
i

3
6
12
I
n
d
i
a
n


I
n
s
t
i
t
u
t
e


o
f


T
e
c
h
n
o
l
o
g
y


M
a
d
r
a
s
C
h
e
n
n
a
i

3
6
13
I
n
d
i
a
n


I
n
s
t
i
t
u
t
e


o
f


T
e
c
h
n
o
l
o
g
y


M
a
d
r
a
s
C
h
e
n
n
a
i

3
6
14
I
n
d
i
a
n


I
n
s
t
i
t
u
t
e


o
f


T
e
c
h
n
o
l
o
g
y


M
a
d
r
a
s
C
h
e
n
n
a
i

3
6
15
I
n
d
i
a
n


I
n
s
t
i
t
u
t
e


o
f


T
e
c
h
n
o
l
o
g
y


M
a
d
r
a
s
C
h
e
n
n
a
i

3
6
16
I
n
d
i
a
n


I
n
s
t
i
t
u
t
e


o
f


T
e
c
h
n
o
l
o
g
y


M
a
d
r
a
s
C
h
e
n
n
a
i

3
6
17
I
n
d
i
a
n


I
n
s
t
i
t
u
t
e


o
f


T
e
c
h
n
o
l
o
g
y


M
a
d
r
a
s
C
h
e
n
n
a
i

3
6
18
I
n
d
i
a
n


I
n
s
t
i
t
u
t
e


o
f


T
e
c
h
n
o
l
o
g
y


M
a
d
r
a
s
C
h
e
n
n
a
i

3
6
19
I
n
d
i
a
n


I
n
s
t
i
t
u
t
e


o
f


T
e
c
h
n
o
l
o
g
y


M
a
d
r
a
s
C
h
e
n
n
a
i

3
6
20
I
n
d
i
a
n


I
n
s
t
i
t
u
t
e


o
f


T
e
c
h
n
o
l
o
g
y


M
a
d
r
a
s
C
h
e
n
n
a
i

3
6
21
I
n
d
i
a
n


I
n
s
t
i
t
u
t
e


o
f


T
e
c
h
n
o
l
o
g
y


M
a
d
r
a
s
C
h
e
n
n
a
i

3
6
Fundamental of Finite-Difference Methods
22
I
n
d
i
a
n


I
n
s
t
i
t
u
t
e


o
f


T
e
c
h
n
o
l
o
g
y


M
a
d
r
a
s
C
h
e
n
n
a
i

3
6
Difference Representation of Partial Differential Equations
23
I
n
d
i
a
n


I
n
s
t
i
t
u
t
e


o
f


T
e
c
h
n
o
l
o
g
y


M
a
d
r
a
s
C
h
e
n
n
a
i

3
6
24
I
n
d
i
a
n


I
n
s
t
i
t
u
t
e


o
f


T
e
c
h
n
o
l
o
g
y


M
a
d
r
a
s
C
h
e
n
n
a
i

3
6
Simple Theoretical Basis
Consider an ODE L(o)=0
Assume the solution as
Substituting in the above ODE
The residue is (R)=L( )
Ideally, we would like to have this residue to be zero
Based on the principles of calculus of variations, we
propose to minimize the residue such that:
where W is a weighing function and the integrations
performed over the domain of interest.
2 n
0 1 2 n
=a +a x+a x +....+a x o
o
o
W.Rdx 0 =

25
I
n
d
i
a
n


I
n
s
t
i
t
u
t
e


o
f


T
e
c
h
n
o
l
o
g
y


M
a
d
r
a
s
C
h
e
n
n
a
i

3
6
In the approximate (numerical) solution, the number of
weighing functions is equal to the number of unknown
coefficients.
Choices for weighing functions
The residue is forced to be zero at selected points, i.e.,
R(x
1
)=0, R(x
2
)=0 . R (x
n+1
)=0.
(n+1) equations for the (n+1) unknowns
Collocation method
The residue itself is used as weighing function i.e., W=R
R
2
dx=0 Least Squares Method
The function used for approximating the solution is taken as
the weighing function
Galerkin Method
Rdx 0 o =

26
I
n
d
i
a
n


I
n
s
t
i
t
u
t
e


o
f


T
e
c
h
n
o
l
o
g
y


M
a
d
r
a
s
C
h
e
n
n
a
i

3
6
Numerical Algorithm of FVM
Formal Integration of the governing equations of fluid
flow over all the control volumes of the solution
domain.
Discretisation i.e. conversion of integral equations
into a system of algebraic equations.
Solution of algebraic equations by an iterative
method.
27
I
n
d
i
a
n


I
n
s
t
i
t
u
t
e


o
f


T
e
c
h
n
o
l
o
g
y


M
a
d
r
a
s
C
h
e
n
n
a
i

3
6
Simple Theoretical Basis
Consider an ODE L(o)=0
Assume the solution as
Substituting in the above ODE
The residue is (R)=L( )
Ideally, we would like to have this residue to be zero
Based on the principles of calculus of variations, we
propose to minimize the residue such that:
where W is a weighing function and the integrations
performed over the domain of interest.
2 n
0 1 2 n
=a +a x+a x +....+a x o
o
o
W.Rdx 0 =

28
I
n
d
i
a
n


I
n
s
t
i
t
u
t
e


o
f


T
e
c
h
n
o
l
o
g
y


M
a
d
r
a
s
C
h
e
n
n
a
i

3
6
In the approximate (numerical) solution, the number of
weighing functions is equal to the number of unknown
coefficients.
Choices for weighing functions
The residue is forced to be zero at selected points, i.e.,
R(x
1
)=0, R(x
2
)=0 . R (x
n+1
)=0.
(n+1) equations for the (n+1) unknowns
Collocation method
The residue itself is used as weighing function i.e., W=R
R
2
dx=0 Least Squares Method
The function used for approximating the solution is taken as
the weighing function
Galerkin Method
Rdx 0 o =

29
I
n
d
i
a
n


I
n
s
t
i
t
u
t
e


o
f


T
e
c
h
n
o
l
o
g
y


M
a
d
r
a
s
C
h
e
n
n
a
i

3
6
Weighing function W=1 is chosen. The number of
weighted residual equations are obtained by dividing the
computational domain into several sub domains and
setting the weighing function to be unity over one
chosen sub-domain and zero everywhere else.
Finite Volume Method
30
I
n
d
i
a
n


I
n
s
t
i
t
u
t
e


o
f


T
e
c
h
n
o
l
o
g
y


M
a
d
r
a
s
C
h
e
n
n
a
i

3
6
One-Dimensional Steady State Diffusion Equation
The diffusion process is governed by
Step 1: Discretisation of domain (Grid generation)
Property
d d
S 0
dx dx
o
| |
I + =
|
\ .
Control Volume, ( ) vol A x A = A
vol vol
d d
dvol Sdvol 0
dx dx
dvol A dx
A A
o
| |
I + =
|
\ .
=

31
I
n
d
i
a
n


I
n
s
t
i
t
u
t
e


o
f


T
e
c
h
n
o
l
o
g
y


M
a
d
r
a
s
C
h
e
n
n
a
i

3
6
Step 2: Discretization:
(i) Integration of given equation over a control volume
(ii) Obtain discretized equation at the nodal point
Taking W=1 from w to e and zero elsewhere
Equation for one sub-domain (w-e)
32
I
n
d
i
a
n


I
n
s
t
i
t
u
t
e


o
f


T
e
c
h
n
o
l
o
g
y


M
a
d
r
a
s
C
h
e
n
n
a
i

3
6
Considering as the flux
J J S x
e w
+ = A 0
J k
d
dx
=
o
The principal task is to evaluate the fluxes crossing the control
surface
Evaluation of fluxes is done using any finite difference scheme,
Presently using central difference
and
d
dx x
w
P W
w
o o o
o
=
d
dx x
e
E P
e
o o o
o
=

Physically, J
e
diffusion flux of o leaving east face
J
w
diffusion flux of o entering west face
33
I
n
d
i
a
n


I
n
s
t
i
t
u
t
e


o
f


T
e
c
h
n
o
l
o
g
y


M
a
d
r
a
s
C
h
e
n
n
a
i

3
6
K
x
K
x
S x
e
E P
e
w
P W
w
o o
o
o o
o

+ = A 0
K
x
K
x
K
x
K
x
S x
e
e
w
w
P
e
e
E
w
w
W
o o
o
o
o
o
o +
|
\

|
.
| = + + A
a a a b
p P E E W W
o o o = + +
a a b
p P nb nb
o o = +

34
I
n
d
i
a
n


I
n
s
t
i
t
u
t
e


o
f


T
e
c
h
n
o
l
o
g
y


M
a
d
r
a
s
C
h
e
n
n
a
i

3
6
Finite Difference Formulation
2
2
E P W
2
P P E E W W
P P nb nb
d
s 0
dx
2
s 0
x
a a a b
a a b
o
+ =
o o + o
+ =
A
o = o + o +
o = o +

35
I
n
d
i
a
n


I
n
s
t
i
t
u
t
e


o
f


T
e
c
h
n
o
l
o
g
y


M
a
d
r
a
s
C
h
e
n
n
a
i

3
6
In general, the source term S may be non-linear
function of the dependant variable
o
Linearise the source term,
such that
S
p
is negative
( ) a S a S x
p p P nb nb c
+ = +

o o A
The discretisation equation becomes
u p
S S S = + o
36
I
n
d
i
a
n


I
n
s
t
i
t
u
t
e


o
f


T
e
c
h
n
o
l
o
g
y


M
a
d
r
a
s
C
h
e
n
n
a
i

3
6
Example Problem
A fin has a base temperature of 100C (T
B
) and the end
insulated. It is exposed to an ambient temperature of 20 C.
One dimensional heat transfer in this situation is governed by
where h is the convective heat transfer coefficient, P is the
perimeter, k the thermal conductivity of the material and the
ambient temperature. Calculate the temperature distribution
along the fin and compare the results with the analytical
solution given by
where n
2
=hP/(kA), L is the length of the fin and x the distance
along the fin. Data L=1m, hP/(kA)=25m
-2
( ) 0
d dT
kA hP T T
dx dx
| |
|
\ .
=

( )
( )
cosh[ ( )]
cosh( )
T T
n L x
nL
T T
B


37
I
n
d
i
a
n


I
n
s
t
i
t
u
t
e


o
f


T
e
c
h
n
o
l
o
g
y


M
a
d
r
a
s
C
h
e
n
n
a
i

3
6
Solution:
The governing equation in the example contains a sink term, the
convective heat loss, which is a function of the local temperature T. The
first step in solving the problem by the finite volume method is to set up a
grid. We assume a uniform grid and divide the length into five control
volumes so that ox=0.2m.
( ) hP T T

38
I
n
d
i
a
n


I
n
s
t
i
t
u
t
e


o
f


T
e
c
h
n
o
l
o
g
y


M
a
d
r
a
s
C
h
e
n
n
a
i

3
6
When kA=constant, the governing equation can be written as
where n
2
=hp/(kA)
Integration of the above equation over a control volume gives
The second integral due to the source term in the equation is evaluated
by assuming that the integral is locally constant within each control
volume.
First we develop a formula valid for nodal points 2,3 and 4 by
introducing the usual linear approximations for the temperature
gradient. Subsequent division by cross sectional area A gives
This can be rearranged as
2
( ) 0
d dT
n T T
dx dx
| |
|
\ .
=

2
( ) 0
V V
d dT
dV n T T dV
dx dx

A A
| |
=
|
\ .

2
[ ( ) ] 0
P
e w
dT dT
A A n T T A x
dx dx
o


| | | |
=
| |
\ . \ .

2
[ ( ) ] 0
P w E P
P
T T T T
n T T x
x x
o
o o

| | | |
=
| |
\ . \ .

2 2
1 1 1 1
P w E P
T T T n xT n xT
x x x x
o o
o o o o

| | | | | |
+ = + +
| | |
\ . \ . \ .
39
I
n
d
i
a
n


I
n
s
t
i
t
u
t
e


o
f


T
e
c
h
n
o
l
o
g
y


M
a
d
r
a
s
C
h
e
n
n
a
i

3
6
For interior nodal points 2,3 and 4 we write
with
Next we apply the boundary conditions at node points 1 and 5. At node 1 the
west control volume boundary is kept at a specified temperature.
The coefficients of the discretised equation at boundary node 1 are
At node 5 the flux across the east boundary is zero since the east side of the
control volume is an insulated boundary.
P P W W E E u
a T a T a T S = + +
a
W
a
E
a
P
S
p
S
u
1/(ox) 1/(ox) a
W
+a
E
-Sp -n
2
ox n
2
oxT

2
[ ( ) ] 0
/ 2
E P P B
P
T T T T
n T T x
x x
o
o o

| | | |
=
| |
\ . \ .
a
W
a
E
a
P
S
p
S
u
0 1/(ox) a
W
+a
E
-Sp -n
2
ox-2/ox n
2
oxT

+2/oxT
B
( )
2
0 0
P W
P
T T
n T T x
x
o
o


| |
| |
=
| |

\ .
\ .

40
I
n
d
i
a
n


I
n
s
t
i
t
u
t
e


o
f


T
e
c
h
n
o
l
o
g
y


M
a
d
r
a
s
C
h
e
n
n
a
i

3
6
Hence the east coefficient is set to zero. There are no additional
source terms associated with the zero flux boundary conditions. The
coefficients at the boundary node 5 are given by
Substituting numerical values gives the coefficients
a
W
a
E
a
P
S
p
S
u
1/(ox) 0 a
W
+a
E
-Sp -n
2
ox n
2
oxT

Node a
W
a
E
Su S
P
aP=a
W
+a
E
-Sp
1 0 5 100+10T
B
-15 20
2 5 5 100 -5 15
3 5 5 100 -5 15
4 5 5 100 -5 15
5 5 0 100 -5 10
41
I
n
d
i
a
n


I
n
s
t
i
t
u
t
e


o
f


T
e
c
h
n
o
l
o
g
y


M
a
d
r
a
s
C
h
e
n
n
a
i

3
6
The matrix form of the equations set is
The solution to the above system is
Comparison with the analytical solution:
The maximum percentage error ((analytical solution-finite volume
solution)/analytical solution) is around 6%. Given the coarseness of the grid
used in the calculation the numerical solution is reasonably close to the
exact solution
42
I
n
d
i
a
n


I
n
s
t
i
t
u
t
e


o
f


T
e
c
h
n
o
l
o
g
y


M
a
d
r
a
s
C
h
e
n
n
a
i

3
6
The numerical solution can be improved by employing a finer grid. Let
us consider the same problem with the rod length subdivided into 10
control volumes. The derivation of the discretized equations is the
same as before, but the numerical values of the coefficients and source
terms are different owing to the smaller grid spacing of ox=0.1m. The
comparison of results of the second calculation with the analytical
solution is given. The second numerical results show better agreement
with the analytical solution with maximum deviation of 2% only.
43
I
n
d
i
a
n


I
n
s
t
i
t
u
t
e


o
f


T
e
c
h
n
o
l
o
g
y


M
a
d
r
a
s
C
h
e
n
n
a
i

3
6
44
I
n
d
i
a
n


I
n
s
t
i
t
u
t
e


o
f


T
e
c
h
n
o
l
o
g
y


M
a
d
r
a
s
C
h
e
n
n
a
i

3
6
Finite Volume Method for
Two-dimensional diffusion problems
S 0
x x y y
| | c co c co
| |
I + I + =
| |
c c c c
\ .
\ .
Two-dimensional steady state diffusion equation
Step 1 : Discretization using 2 D grid
vol vol vol
dx dy dx dy S dvol 0
x x y y
o
A A A
| | c co c co
| |
I + I + =
| |
c c c c
\ .
\ .

45
I
n
d
i
a
n


I
n
s
t
i
t
u
t
e


o
f


T
e
c
h
n
o
l
o
g
y


M
a
d
r
a
s
C
h
e
n
n
a
i

3
6
Integrating over a control volume and then obtaining the
discretized equation
A
e
=A
w
= y and A
n
=A
s
= x
[J
e
-J
w
]+[J
n
-J
s
]+
Where
Generalized discretized equation form for interior nodes
a
P
o
P
= a
P
o
P
+a
P
o
P
+ a
P
o
P
+ a
P
o
P
+S
u
a
W
+a
E
+a
S
+a
N
-S
p
a
P
a
N
a
S
a
E
a
W
w w
WP
A
x
I
o
e e
PE
A
x
I
o
s s
SP
A
y
I
o
n n
PN
A
y
I
o
A A
S V 0 A =
( )
W W P W
w
WP
A
J
x
I o o
=
o
( )
E E W P
e
PE
A
J
x
I o o
=
o
( )
N N P N
n
NP
A
J
x
I o o
=
o
( )
S S S P
s
SP
A
J
x
I o o
=
o
46
I
n
d
i
a
n


I
n
s
t
i
t
u
t
e


o
f


T
e
c
h
n
o
l
o
g
y


M
a
d
r
a
s
C
h
e
n
n
a
i

3
6
Three-dimensional steady state diffusion equation
Finite Volume Method for
Three-dimensional diffusion problems
Typical Control
Volume is
S 0
x x y y z z
| | c co c co c co
| | | |
I + I + I + =
| | |
c c c c c c
\ . \ .
\ .
47
I
n
d
i
a
n


I
n
s
t
i
t
u
t
e


o
f


T
e
c
h
n
o
l
o
g
y


M
a
d
r
a
s
C
h
e
n
n
a
i

3
6
a
N
a
S
a
E a
W
w w
WP
A
x
I
o
e e
PE
A
x
I
o
s s
SP
A
y
I
o
n n
PN
A
y
I
o
a
B
a
T
a
P
a
W
+a
E
+a
S
+a
N
+a
B
+
a
T
-S
P
b b
BP
A
z
I
o
t t
Pt
A
z
I
o
a
P
o
P
= a
P
o
P
+a
P
o
P
+ a
P
o
P
+ a
P
o
P
+S
u
The discretized equation for interior nodes is
where
48
I
n
d
i
a
n


I
n
s
t
i
t
u
t
e


o
f


T
e
c
h
n
o
l
o
g
y


M
a
d
r
a
s
C
h
e
n
n
a
i

3
6
SUMMARY
1. CFD overview
2. Basics of important CFD solvers FDM,FVM and FEM
3. Finite Volume Method for 1D diffusion problems
importance of fluxes
4. Example problem of heat conduction in a fin importance
of grid size
5. Extensions to 2D and 3D diffusion problems

S-ar putea să vă placă și