You are on page 1of 50

fvm

Table of Content
Introduction Why CFD History

C p e xx Chapter
The Finite Volume Method

By Melik Sahraoui

Transport equation Other numerical methods 1D conduction FVM 2D conduction FVM B Boundary d C Conditions diti Solving the discretized equations Checking for accuracy Convergence FVM in polar coordinates (Example) Convection FVM Solving the flow equation (Staggered grid)

M. Sahraoui FVM

M. Sahraoui FVM

Why CFD
CFD (computational fluid dynamics) software is a very important tool to engineers. Shortened product development cycle requires the use of CFD tools to optimize the design early in the design phase.

History
Generally known as Patankars method. Lots of other researchers have p g the method for contributed to improving all kinds of flow problem. These include Spalding, Raithby, etc.

M. Sahraoui FVM

M. Sahraoui FVM

Transport Equations
Transport equations describe the behavior of the different independent transport variables based the conservation principles: Conservation of Mass Momentum equation Balance of Thermal Energy (Conservation of total mechanical energy) Conservation of chemical species Balance of the kinetic energy Two equation turbulence model

Transport Equations
Conservation of species

Cont.

mk ( mk ) + ( ui mk ) = (k ) + Rk t xi xi xi
The conservation of energy equation

(1)

k h ( h) + ( u i h ) = ( ) + Sh t xi xi c xi

The momentum equation

u p ( u j ) + ( ui u j ) = ( j ) + Bj +Vj t xi xi x j xi

M. Sahraoui FVM

M. Sahraoui FVM

Turbulence model
The k-e k e turbulence model is given by:

The general transport equation


Transport equation can then be written in the general form as:

t k ( k ) + ( ui k ) = ( ) + G xi t xi xi
( ) + ( ui ) = ( t ) + (c1G c2 ) t xi xi xi k

( ) + ( u ) = ( ) + S t

Where is kinetic energy, is the rate of dissipation, G is the rate of generation Turbulence, t is the turbulent viscosity, and k, , ,and are empirical constants in the model. 2 1

Diffusion Convective term term Storage/ transient term

Where is the diffusion coefficient, S in the source term and is the dependent variable ( (i.e., , mi,ui,T,,)

Source term

A highly nonlinear problem, due to the interdependence of the different solution fields.

M. Sahraoui FVM

M. Sahraoui FVM

Method of deriving the discretized Equations

FVM- 1D Conduction
The one-dimensional conduction equation is given by

Finite Difference: Using Taylor series expansion Variational formulation g residuals Method of weighted Control Volume Formulation

d dT k +S = 0 dx dx
Where k [W/(m.K] is the thermal conductivity, T is the temperature and S (W/m3) is the rate of heat generation
(x)w
W

(x)E
E

P x

Control Volume (Size: x*1*1)

M. Sahraoui FVM

M. Sahraoui FVM

FVM- 1D Conduction Cont.


d dT dx k dx + S ) dV = 0 V
(x)w
W

FVM- 1D Conduction Cont.


To compute the heat flux at the boundaries of the CV we assume a linear profile for the temperature between the neighboring nodes:
T

With

dy = dz = 1
One Dimensional problem

(x)E
E

P x

d =0 dx k dx + S ) dx
W w P e E

d dT

k + Sdx = 0 d dx
W

dT

dT k E (TE TP ) k = xE dx e
E

dT dT + Sdx = 0 k k dx E dx W W
We assume that S is constant over the contro volume
M. Sahraoui FVM

and

k (T T ) dT k = W P W xW dx W
M. Sahraoui FVM

FVM- 1D Conduction
Cont.

FVM- 1D Conduction
Cont.

k (T T ) dT k = E E P xE dx E

and

k (T T ) dT k = W P W xW dx W

From the previous slide we found that the control volume temperature Tp is then given by:

The discretized 1D conduction equation becomes

a pT p = aW TW + aETE + b
The sourse term S may depend on T. Linearization is necessary, therefore, we assume

k E (TE TP ) kW (TP TW ) + S x = 0 xE xW
Where S is the averaged source term over the control volume. The control volume temperature Tp is then given by:

S = S c + S pTP
The coefficient Ap becomes

a p = aE + aW S P
and

a pT p = aW TW + a ETE + b
Where

b = S c x
aW = kW xW b = S x

aE =

kE xE

a p = aE + aW

M. Sahraoui FVM

M. Sahraoui FVM

Finite-Difference
The one-dimensional conduction equation is given by:

Generalization 1D to 3D Conduction
The 1D discretization Th di ti ti can b be generalized li d t to th the 3D case:

d dT k +S = 0 dx dx
It can be discretized as follows (Using Taylor series expansion)

a pT p = anbTnb + b
Where

dT dT k k dx E dx W +S =0 x k (TE Tp ) k (TP TE ) xw

(x)w
W

(x)E
E

anb
E

is the coefficient of the neighboring points is the temperature of the neighboring points

P x

Tnb

xe

+S =0

Note: not all scalar quantities are calculated using a linear profile between neighboring points. The source term (S), (S) ke, and kw (conductivity at the interfaces) can be calculated using piece wise function.

kTE kTW k k + +S =( + )TP xe x xw x xe x xw x

M. Sahraoui FVM

M. Sahraoui FVM

The Four Basic Rules

The Four Basic Rules Cont.

1-

Consistency at control volume faces: for two adjacent control volumes, the expression for the flux across the common face must be the same in the discretized equation.
If this not satisfied, the overall balance will not be satisfied. Inconsistent flux may be due to the incorrect profile of temperature in a given cell or using the conductivity of the center-point.

4Some of all coefficients must be equal to the coefficient of the center.


This is a direct result of the fact that if T is a solution than T+C is also a solution. This of course applies to PDE that a source term that is not dependent on T.

2-

All coefficients ( (ap and neighbor g coefficients anb) must be positive.


If this is not true an increase in temperature at the boundary may lead to a decrease in the internal temperature. This may be due to an unrealistic solution.

3-

Negative-slope linearization of the source term

S = S c + S pT p

With

Sp < 0

If Sp is positive it implies that if the source term increases which in turn means that the temperature increases causing further increase in T ..

M. Sahraoui FVM

M. Sahraoui FVM

Griding
xW
W

Griding
xE
E

All discretization formulations tend to give the the same solution as the number of grids is added.
E

P x

Use of non-uniform grid is very beneficial to efficient ffi i t computation t ti and d use of f computing ti resources. Not true that the use of non-uniform grids leads to less accurate results than uniform grids Highest number of grids should be used in regions of highest gradients such as boundary layers and flame fronts (Combustion). Refine grids as needed after initial trials runs.

Two more requirements are necessary even for a coarse grid: Physically realistic behavior Unrealistic Overall balance
Approximate

Unrealistic

Exact

x
M. Sahraoui FVM M. Sahraoui FVM

Conductivity at the interface


Recall that

Conductivity at an interface

k aE = E xE

Solid A
Recall that

Solid B

k A kB

What should we use as kE, conductivity at the interface between 2 CV.

qE =

k E (TE TP ) xE

What should we use as kE (interface between 2 CVs) conductivity It is required that flux conservation is satisfied
(x)e(x)E (x)e+
E

Use thermal resistances in series

Req = Re + Re

xE
keq yz
M. Sahraoui FVM

xe
k P yz

xe+
k E yz
M. Sahraoui FVM

Conductivity at the interface Cont 2


(x)E

Conductivity at the interface Cont 3


For interface, i.e F a centered t d control t l volume l i t f i

xe xe+ keq = k + k P E

(x)e-

(x)e+
E

xe + = xe = xE / 2
k eq = 2k p k E k p + kE
Harmonic mean

This is called the harmonic mean and developed by working out the heat flux between two consecutives nodes This approach guarantees conservation of heat across the interface.

And not

keq = 0.5(k p + k E )= the x =x x / 2 arithmetic mean


e+ e E

Keep in mind d that h using an arithmetic mean leads to incorrect results especially when there an abrupt change in conductivity

k eq = f e k P + (1 f e )k E
fe =

xe+ xe

M. Sahraoui FVM

M. Sahraoui FVM

Non-linearity

Source Term Linearization


As an example take the 1-D conduction equation with a source term given by S = 4 5T 3

Non linearity may come from the fact that conductivity is temperature dependent, or from radiative effects (T4 influence),density variation due to temperature and concentration gradients. In cases where the coefficients in the discretized equations are not constant, iterations for a solution is necessary. For an iteration procedure a convergence criteria is needed to ensure that the iteration process has given the correct solution.

d dT k +S = 0 dx dx
Recall a pT p = aW TW + a ETE + b With and Where

a p = aE + aW S P b = S c x
S = S c + S pTP

We will take 4 possibilities for linearization:

Sc = 4 5Tp*3 and S p = 0

Sc = 4

and

S p = 5Tp*2
M. Sahraoui FVM

M. Sahraoui FVM

Source Term Linearization


ds * ) = 4 5Tp*3 15Tp*2 (Tp Tp* ) S = S + (Tp TP dT S p = 15Tp*2 * and S c = 4 + 10TP *2
* *

Unstedy 1-D conduction


c
T T = k t x x

an

d p

S = 25Tp
* P

Integration over time and the control volume

S c = 4 + 20T

W t

t + t

t + t E T T dtdx = c k dxdt t W x t x

p This may y lead to lower Linerization of 4 is steep. convergence

W t

t + t

T 1 dtdx = cx(TP TP0 ) t

1 S 2

TP0 : Temperature at time t (old values)


1 TP : Temperature at time t+DT (new values)

TP 4
T

M. Sahraoui FVM

M. Sahraoui FVM

Unsteady 1-D conduction


c
T T = k t x x

Unsteady 1-D conduction- cont


1 TP0 ) = cx(TP t + t

ke (TE TP ) kw(TP TW ) dt xe xw

Integration over time and the control volume

How is the LHS calculated (i (i.,e e at which time step)

W t

t + t

t + t E T T dtdx = c dxdt k t W x t x

t + t

1 TP dt = [ fTP + (1 f )Tp0 ]t

Where f is a weighting factor between 0 and 1.

W t

t + t

T 1 dtdx = cx(TP TP0 ) t

TP0

: Temperature at time t (old values)

TP0 : Temperature at time t (old values)


1 TP

1 : Temperature at time t+T (new values) TP

: Temperature p at time t+DT (new ( values) )

M. Sahraoui FVM

M. Sahraoui FVM

Unsteady 1-D conduction- cont


The time discretization depends on the weighting factor f f= 0 Explicit scheme f=0 5 Crank-Nicholson f=0.5 Crank Nicholson scheme f=1 Fully implicit scheme For the fully explicit scheme
0 0 a pTp = aETE0 + aW TW + (a 0 p ae aw )TP

2-D conduction
For the fully implicit scheme (f=1)

T T T = k + k y +S t x x y

CV W y P

The temperature of the CV is given explicitly in terms of the old values. No iterations are needed. Need to keep the explicit scheme positive. Therefore, there a restriction on how big the time step is. For a uniform grid the time step restriction becomes:

c(x) 2 t < 2k
M. Sahraoui FVM

S
M. Sahraoui FVM

Discretization of the 2D equation


a pT p = aW TW + a ETE + a S TS + a N TN + b kW y xW

Discretization of the 3D equation


c
T T T T = k + k + k +S t x x y y z z

aE =
aN =

k E y xE
k N X y N

aW =

When discretized becomes

k y aS = S y S

a0 p =

C Xy
T

apTp = aWTW + aETE + aSTS + aNTN + aTTT + aBTB + b


N W
aE = aN = k E yz xE k N Xz y N kT xy zT

(Top)

0 b = sC xy + a 0 pT p

a P = aE + aW + a N + aS + a 0 p s P xy
xw
N

aW =
aS =

xe
CV

kW yz B (Bottom) S xW

yn
W P y E

k S yz yS
k B xy z B

aT =

aB =

ys
Y

0 b = sC xyz + a 0 pT p

a0 p =

Cxyz
T

x S
M. Sahraoui FVM

a P = aE + aW + a N + aS + aT + a B + aS a 0 p s P xyz
M. Sahraoui FVM

Boundary conditions
Three types of boundary conditions can be used Fixed temperature Fixed flux Convective heat transfer coefficient.

Discretization of the 2D equation


a pT p = aW TW + a ETE + a S TS + a N TN + b kW y xW kS y y S

aE =
aN =

k E y xE
k N X y N

aW =

aS =

a0 p =

C Xy
T

Internal heat generation

T = T0

0 b = sC xy + a 0 pT p

a P = aE + aW + a N + aS + a 0 p s P xy
xw

xe
N CV

T = h(T T ) n

T k = q" n

yn
W P y E

How do we implement these boundary conditions?


Y

ys

x S

M. Sahraoui FVM

M. Sahraoui FVM

Boundary conditions Cont.


The boundary conditions are added to the source term and add it to the source term The boundary condition is discretized as follows Recall that z=1m (2D assumption) The discretized equation becomes

Boundary conditions Cont.


For the adiabatic boundary condition (insulated wall) set t

aw = 0
i.e, the boundary point is not needed for the calculation Also

a pT p = a E TE + a S TS + a N TN + b

Sp = a P = aE + a N + aS + a 0 p S p V

T1, j T 2, j x

y = h(T1, j T )y xe
N

y x ( w + 1 / h) v k y 1 b= T x w v ( + 1 / h) k 1
CV

aw = 0

T1, j = T2, j

For the the fixed heat flux condition set

aw = 0
a pT p = a ETE + a S TS + a N TN + b b = y q"
Recall that z=1m (2D assumption)

yn
W P y E

ys

Boundary nodes Internal nodes

For the adiabatic case or the symmetry condition set

x S

q" = 0

M. Sahraoui FVM

M. Sahraoui FVM

Solving the Algebraic Equations


Generally iterations are need to find a solution to the discretized problem. Direct solution is not feasible for most problems where non-linearity makes the coefficients in the discretized dependent on the variables that we are solving for.

Gauss-Seidel point-by-point method


The discretized 3D equation can be written at every node can be written as:

a pTp = aWTW + aETE + aSTS + aNTN + aTTT + aBTB + b


and generally as:

a pTp = anbTnb + b
Where nb denotes a neighbor point (node)

Tp

a =
*

nb

* Tnb +b

ap

Where Tnb is the guessed value of the neighbor points. The grid points are visited in sequence.

Iteration direction
M. Sahraoui FVM M. Sahraoui FVM

Gauss-Seidel - Convergence

1D solution
Use (TriDiagonal-Matrix U of f TDMA A( i i l i Algorithm).

The Scarborough criterion

a
ap

np

1 < 1

for all equations for at least one point

aiTi = biTi+1 + ciTi1 + di


i denotes successive grid point. Also
position in the array.

The condition is sufficient but not necessary

i = 1,2,3,, M +1
In 1D problems this method allows to find a direct solution when the coefficients do not depend on the field we are solving for.

The convergence of Gauss-Seidel is very slow since information from the boundaries is transmitted at a rate of one grid point per iteration

M. Sahraoui FVM

M. Sahraoui FVM

TDMA SOLUTION 1D SOLUTION

Line by line method


Use for U the th TDMA technique t h i f 2D and d 3D instead i t d of f the Gauss Seidel point by point solution . This makes the solution iterative. Recall that the discritized equation (2D) is

aiTi = biTi+1 + ciTi1 + di


Algorithm
Calculate

for

i = 1,2, ,....., ,N

Use the following recurrence relation to obtain

b1 P = 1 a1

and

d Q1 = 1 a1 di + ciQi1 ai ci P i 1

a pT p = aW TW + a E TE + a S TS + a N TN + b
Apply the TDMA technique in the x-direction, one line at a time. The above equation becomes
* a pT p = aW TW + a ETE + ( aS Ts* + a N TN + b)

P i =
for

bi ai ci Pi1

and

Qi =

i = 2,.....,N 1

Estimated values

Tn = Qn
Back substitution

i = N 1, ,......, , 1

Ti = P iTi +1 + Qi

Chosen line

M. Sahraoui FVM

M. Sahraoui FVM

More on TDMA
Information from one boundary to the other can be transferred with a single iteration on the same line. For faster solution in 2D and 3 D problems, TDMA can be applied alternatively in all directions.

Overrelaxation and Underrelaxation Overrelaxation O l ti is used to speed up the iteration process of linear
problems

Underrelaxation is used to prevent


divergence of the iteration process of

Nonlinear problems These two methods use relaxations factors where the value of the node from the previous time step is used to control the value for the next iteration.
The g general discretized equation q is g given by y
a pT p = anbTnb + b
Tp =

nb nb

T +b

ap

The general discretized equation is given by


M. Sahraoui FVM M. Sahraoui FVM

Overrelaxation and Underrelaxation


The general discretized equation is given by
a pT p = anbTnb + b Tp =

Overrelaxation and Underrelaxation

nb nb

T +b

No relaxation factor is used

Tp =

nb nb

T +b

ap

+ (1 )T p*

ap

Lets introduce the node value from the previous time step T p*
anbTnb + b T p = T p* + T p* ap
T p Produced by the current time step (= 0 for a converged solution)

For a converged solution equation (27) still satisfy the original equation (26)

< 1 Underrelaxation used for nonlinear


problems to control divergence

>1

Overrelaxation used for linear problems to speed up the convergence process. process

Use the relaxation factor on the parenthesis


anbTnb + b T p = T p* + T p* ap
M. Sahraoui FVM M. Sahraoui FVM

Overrelaxation and Underrelaxation


Another technique for relaxation is achieved through inertia

Checking for convergence


How do you make sure that a converged solution is obtained? The best method is to check that the sum of all residuals ( (normalized) ) of all nodes is below a certain value.
Re s = a pT p ( anbTnb + b )

( a p + i )T p = anbTnb + b + iT p*

i>0

Overelaxation used for linear problems

i > 0 Underrelaxation used for nonlinear problems

To compare the value of the nodes between two consecutive iterations may be misleading when a convergence is very slow or not converging (does nor mean diverging)

For a converged solution equation (28) still satisfy the original equation (26)

M. Sahraoui FVM

M. Sahraoui FVM

Testing of the code


For the diffusion p part of the equation q
Run the various 1D simple solution in all directions with different boundary conditions Compare to analytical results

Convection

For testing the flow part compare with the simple analytical solutions first
Poiseuille flow Couette flow Periodic flow

CONVECTION

Compare to experimental measurements


Developing flow Measurement data of the heat transfer coefficient (be care full about the source of the data)

M. Sahraoui FVM

M. Sahraoui FVM

Convection-Diffusion
The flow field must satisfy, satisfy the continuity equation

1D Convection-Diffusion
The flow field must satisfy, satisfy the continuity equation

+ ( u j ) = 0 t x j

(30)

d ( u ) = 0 dx

or

u = C (33)

The g general differential equation q

( ) + ( u j ) = ( )+S t x j x j x j

Where C is constant

(31)

Transport equation

Using the continuity equation (30), eq. (31) becomes

( ) + u j = ( )+S t x j x j x j

d d d ( u ) = ( ) dx dx dx

(34)

(32)
(x)
w

(x)
E

Lets Let s start with the one dimensional case


W

P x

Control Volume (Size: x*1*1)

M. Sahraoui FVM

M. Sahraoui FVM

1D Convection-Diffusion Cont.
Integrate the differential equation (34) over the control volume

Use of linear velocity profile


Assume that the variable between two consecutive nodes vary in linear fashion(same assumption was used in deriving the diffusion equation.

dx (u )dx = dx ( dx )dx
Which becomes

(35)

e = (E + P )

1 2

w = (W + P )

1 2

(37)

d (u ) = d ( dx )
d d ( u )e ( u ) w = dx e dx w
(x)
w

This assume that the control volume face is located in the middle between nodes E & P and W & P. The integrated equation (36) becomes

(36)

(x)
E

1 1 (38) ( u)e (E + P ) ( u) w (W + P ) = 2 2 e (E P ) w (P W ) x x e w
(x)
w

(x)
E

P x

W Control Volume (Size: x*1*1)

P x

M. Sahraoui FVM

Control Volume (Size: x*1*1)

M. Sahraoui FVM

Discretized Equation - velocity profile


First let s define the convection (flow) and diffusion lets symbols

Discretized Equation - velocity profile


The last results which uses a linear profile to calculated the convective flux is the same results as the taylor series expansion. This the the central difference scheme. Due to its simplicity p y it has some inherent stability problems. Negative Coefficients Scarborough criterion not satisfied (divergence with the point-by-point solution

F u

Equation (38) becomes

a p p = aW W + a EE
With the coefficients defined

aE = De a p = De +

Fe 2 Fe F + Dw w 2 2

aW = Dw +

Fw 2
Lets look at an example. (Excel File)

a p = aE + aW + ( Fe Fw )
However the continuity equation ensures that

This scheme fails for flow with high F/D

Fe = Fw

Then

a p = aE + aW

M. Sahraoui FVM

M. Sahraoui FVM

Discretized Equation - Improved


Need to account for the direction of the flow and set e and w accordingly.. Central differencing scheme

Discretized Equation - Improved


The upwind scheme can then be written in the following manner

e = (E + P )

1 2

w = (W + P )

1 2

Fee = P Fe ,0 E Fe ,0
R1 , R2
Denotes the maximum of the two numbers With the coefficients

a p p = aW W + a EE
Upwind scheme

e = P e = E
(x)
E

if if

Fe > 0

a E = De + Fe ,0
aW = Dw + Fw ,0 a P = De + Fe ,0 + Dw + Fw ,0

Fe < 0

(x)
w

a P = a E + aW + ( Fe + Fw )
E

M. Sahraoui FVM

M. Sahraoui FVM

Improving the numerical method

1D Convection-Diffusion Solution

Need to use more accurate schemes for predicting the flux across the control interface. Use the exact solution as a starting position. position

d d d ( u ) = dx dx dx
With the following boundary conditions at at

x=0 x=L
Pe x L

= 0

= L

The exact solution

0 e 1 = L 0 e Pe 1
Where Pe is the peclet number and is given by

Pe =
M. Sahraoui FVM

uL

Ratio of convection to diffusion


M. Sahraoui FVM

1D Convection-Diffusion Solution
The profile of the exact solution is shown below

The Exponential Scheme


The overall flux is given by:

J = u
Exact Solution

d dx

C Conservation ti i imposes (1D problem) bl )

1.2 1 0.8 0.6 0.4 0.2 0 0 0.5 1


Pe=-10 Pe=-1 Pe=0 P 1 Pe=1 Pe=10

dJ =0 dx
Integrating over the control volume

Je Jw = 0
Where Je is given by

Pe

) e Pe 1 J w = Fw (w wPw p ) e 1
M. Sahraoui FVM M. Sahraoui FVM

J e = Fe ( p

p e

The Exponential Scheme


The overall flux is given by:

The hybrid scheme


Find a more efficient calculation of the flux. Use the asymptotic behavior of the exponential scheme For

a p p = aW W + aEE
where

Pe < 2
2 Pe 2

aE = Pe De

aE =

Fe e( Fe / De ) 1
For

Fwe Fw / Dw aw = ( Fw / Dw ) e 1

aE = Pe De aE =0 De

For

Pe > 2
Hybrid VS Exact 6 5

a p = aE + aW + ( Fe Fw )
The exponential scheme is computationally expensive
Ae/De

4 3 2 1 0 -1 -6 -4 -2 0 Pe 2 4 6 Exact Hybrid

M. Sahraoui FVM

M. Sahraoui FVM

The hybrid Scheme Cont.


The discretized equation is given by

The Power Law Scheme


The power law scheme is more efficient than the hybrio scheme in the region of Pe=+2 For

a p p = aW W + aEE
where
a E = Max ( Fe , De Fe ,0) 2 F aW = Max( Fw , Dw + w ,0) 2

Pe < 10

aE = Pe De aE = (1 0,1Pe ) 5 Pe De aE = (1 0,1Pe ) 5 De

For For For

10 Pe < 0
0 Pe 10
Pe > 10

a p = aE + aW + ( Fe Fw )

aE =0 De

M. Sahraoui FVM

M. Sahraoui FVM

The Convective-diffusive Schemes


The overall flux is given by:

The Convective-diffusive Schemes


The overall flux is given by: Scheme Central difference Upwind Hybrid Power Law Exponential (Exact)

a p p = aW W + aEE

where
a E = De f ( Pe ) + Max ( Fe ,0) aW = Dw f ( Pw ) + Max ( Fw ,0)

f (P) 1 0 .5 P

Max(0,1 0.5 P )
Max(0, (1 0.1 P ) 5 ) P e 1
P
Diffusion/Convection Flux

a p = aE + aW + ( Fe Fw )
where f ( P ) is given by Scheme C t l diff Central difference Upwind Hybrid Power Law Exponential (Exact)
f (P)

1.5 1 Central Difference f(P) 0.5 0 0 -0.5 -1 P 2 4 6 8 10 Upwind Hybrid Power Law Exponential

1 0 .5 P

1
Max (0,1 0.5 P )

Max(0, (1 0.1 P ) 5 ) P
e 1
P
M. Sahraoui FVM

M. Sahraoui FVM

2D Convection-Diffusion Discretization
The conservation equation in 2D is given by:

2D Convection-Diffusion Discretization
The conservation equation in 2D is given by:

J ( ) + J x + y = S t x y
Where the fluxes J x and J y are given by J x = u u is the x-direction velocity x v is the y-direction velocity J y = v y Integrating over the two-dimensional CV xw xe
N

(
P

0 0 P )xy P

+ Je Jw + Jn Js =
( SC + S p p )xy

(39)

xw
N

xe
Jn
P CV

yn
W

yn
W P E

CV

Jw
y

Je

ys
Y

ys
x
S
Y

Js
x
S

M. Sahraoui FVM

M. Sahraoui FVM

2D Continuity equation
Along with the transport equation we have the th continuity ti it equation ti u v + + =0 t x y
P
0 P xy + Fe Fw + Fn Fs = 0 t

2D Convection-Diffusion cont.
If we use equation (39) and subtract from it equation by p ti (40) multiplied lti li d b

(40) ( )

xy + ( J e Fe p ) ( J w Fw p ) + t ( J n Fn p ) ( J s Fs p ) = ( SC + S p p )xy (42)

0 p P

0 P

Where Fe, Fw, Fs, Fn are the mass flow rates across the four faces of the control volume given by Fw = (u )w y (41a)

Where

J e Fe p = ae ( p E ) J w Fw p = aw (W p ) J n Fn p = an ( p N ) J s Fs p = as (S p )
Then equation (42) becomes

Fe = (u )e y Fn = (v )n x Fs = (v )s x

(41b) (41c) (41d)

aPP = aEE + aW W + a N N + aSS + b

(43)

M. Sahraoui FVM

M. Sahraoui FVM

2D Convection-Diffusion cont.
The coefficients in equation (43) are given by

Artificial diffusion

aE = De f ( Pe ) + Max( Fe ,0)
aW = Dw f ( Pw ) + Max( Fw ,0)
Hot Hot Cold T Cold T

a N = Dn f ( Pn ) + Max( Fn ,0) aS = Ds f ( Ps ) + Max( Fs ,0)


The mass flux terms (Fe, Fw, Fn, and Fs) are given by Eq. (41a-d)

With diffusion
Excel file

No diffusion (Peclet >>0)

Ratio of convection over diffusion U Velocity scale

Pe =

UL

L: characteristic length

: thermal diffusivity
M. Sahraoui FVM

Pe =

UL

M. Sahraoui FVM

Convection

Solving the momentum equation

The momentum equation is a highly non-linear equation. For three dimensional problems we have to solve for four variables: Three components of velocity Pressure field

Solving the Momentum Equation

Other factors that can complicate the flow solution


Geometry and boundary conditions Compressibility (mainly for gaseous flow) Flow regime (Laminar and turbulent flows)

M. Sahraoui FVM

M. Sahraoui FVM

The momentum equation


Lets start with the momentum equation for the incompressible, constant property flow for a 2-D problem

The momentum equation


In order to avoid the problem of trying to compute the Many effort in numerical h pressure field. fi ld M ff i i l analysis of fluid flow has relied on the stream function vorticity formulation. This approach has many shortcomings Calculating the vorticity at the wall
Not easy for thee-dimensional flow In case the flow is compressible the pressure is needed to calculate the fluid density

u p u u + u + v = + t x y x 2u 2u + 2 + fx 2 y x v v v p + u + v = + t x y y 2v 2v + 2 + fy 2 y x

(45)

(46)

Need to find a way of calculating directly the primitive variables (u,v, and p)

Along with the momentum equation we have to solve the continuity equation (conservation of mass)

u v + =0 x y

(47)

M. Sahraoui FVM

M. Sahraoui FVM

Difficulties in discretization of the momentum equation - 2


Representation of the pressure gradient Take equation (45) we have the pressure gradient in differential form is written as p

Difficulties in discretization of the momentum equation - 3


Since the pressure value at node P is not used we may end with an oscillatory behavior of the pressure field

x
Discretization of this term for the CV given below is

30

10

30

10

30

10

30

10

P PP + PE W +P P p Pw Pe 2 2 = x x x P PE = W 2x
The pressure value at Pp is not used ???
(x)w (x)E (x)w (x)E

Control Volume (Size: x*1*1)

M. Sahraoui FVM

Control Volume (Size: x*1*1)

M. Sahraoui FVM

Difficulties in discretization of the momentum equation - 4


Discretization of the continuity equation given by equation (47). We have

Difficulties in discretization of the momentum equation - 5


Using the single grid for velocity and pressure leads to oscillatory behavior in the pressure and velocity fields. This leads to unrealistic results.

uW + uP uP + uE u uwue 2 2 = x x x u uE = W 2x
This discretized equation uses the velocity at alternating grid points => oscillatory behavior

To solve the problem we use a staggered grid. The velocity components and other variables are not located on the same grid points.

(x)w

(x)E

(x)w

(x)E

Control Volume (Size: x*1*1)

M. Sahraoui FVM

Control Volume (Size: x*1*1)

M. Sahraoui FVM

Staggered Grid

Staggered Grid 2

Staggered location for u This methodology gives significant improvements over the th single i l grid id for f all ll the th variables i bl

u v P T, P, T C C, , k

Control Volume

This methodology is very convenient in writing the momentum equation, energy, species (or mass). This removes the oscillatory behavior of the velocity in the continuity equation and pressure in the momentum equation.
M. Sahraoui FVM M. Sahraoui FVM

Solution of the momentum equations

Pressure correction method.


q From the g generalized discretization equation we can deduce that the discretized equations for the three components of velocity are

aeue = anb unb + b + ( pP pE )Ae (48)X-momentum equation an vn = anb vnb + b + ( p P p N )An (49) Y-momentum equation

at wt = anb wnb + b + ( p P pT )At (50) Z-momentum equation


The p pressure field is needed to solve for the components of velocity PN P
E

u v P T, P, T C C, , k

Control Volume

ue
PP

This methodology is very convenient in writing the momentum, energy, species (or mass) equations.

V control U Control
Volume Volume The control volume for W
M. Sahraoui FVM

This removes the oscillatory behavior of the velocity in the continuity equation and pressure in the momentum equation.
M. Sahraoui FVM

Pressure correction method


When using a guessed pressure field (P ), an (P*) intermediate solution for the velocity components will be obtained. They are denoted by u*, v* and w*.
* ae u e = anbu * + b + ( p* p* )Ae nb P E

Pressure correction method cont.


If subtract Eq (51) from eq eq. (48) we will obtain

aeue' = anbu 'nb + ( p 'P p 'E )Ae

(58)

(51) (52) (53)

The same approach can be used for the other p of velocity y components In equation (54) the term in the summation can be neglcted and (54) becomes

an v * = anb v* + b + ( p* p* )An n nb P N at wt = anb w nb + b + ( p P p T )At


* * * *

L t that Lets th t th the correct t pressure field fi ld p Can be written in this form

p = p * + p' (54)

And in a similar manner the velocity components can be written in this in terms of the guessed velocity components t ( (u*, * v*, * w*) *) fi field ld and d a correction ti f for each h (u, v, and w).

aeue' = ( p 'P p 'E ) Ae or A ' (59) ue = e ( p 'P p 'E ) ae


Then the correct u velocity component can be written as * * u e = ue + u ' = ue + d e * ( p'P p' E ) (60) The same can be written for the two other components of velocity
* * vn = vn + v ' = vn + d n * ( p'P p'N )

u = u * +u ' (55)
v = v * +v'
(56)

(61)

w = w * + w' (57)
M. Sahraoui FVM

wt = wt* + w' = wt* + d t * ( p'P p'T ) (62)


M. Sahraoui FVM

Pressure correction method cont.


y equation q y The continuity is g given by

Pressure correction method cont.


If we use Eq. the di discretized E (56)-(58) (56) (58) into i t th ti d continuity ti it equation (59) we get an equation for the pressure correction equation.

u v w + + + =0 t x y z
The discretized continuity equation is
0 (P P )xyz + [( u ) e ( u ) w ]yz + t [( v) n ( v) s ]xz + [( w) t ( w) b ]yx = 0

aP p'P = aE p'E + aW p 'W + a N p ' N + aS p 'S + aT p'T + aB p 'B +b


Where the coefficients are given by (63) (64)

aE = e d e yz aW = w d w yz a N = n d n xz aS = s d s xz aT = t d t xz aB = b d b xy
And the source term b is given b
0 (P P )xyz + [( u*) w ( u*)e ]yz + b= t [( v*) s ( v*) n ]xz + [( w*) s ( w*)t ]yx

x
N

vn
P

CV

ue

uw

vs
S
X
M. Sahraoui FVM

B is the driving force in the pressure correction equation


M. Sahraoui FVM

Algorithm - Pressure correction


The Method h SIMPLE SI L algorithm l h (Semi-Implicit (S I l h d for f the h Pressure Linked Equations) 1. Guess the pressure field P* 2. Solve the momentum equations Eqs (51)-(53) for u*, v*, and w* 3. Solve the p equation (64) 4. Calculate p Eq. (54) (I.e p=p*+p) 5. Calculate u, v and w from the velocity correction equations Eq. (60)-(62) 6. Solve for any other variable that needs the velocity field 7 Treat the new value of p (from step 4) as the new 7. guessed value (p*) and start from step 2. This process is repeated until convergence is reached. Underrelaxation is needed for the p, u, v, w to keep the solution from diverging.
M. Sahraoui FVM

Algorithm - Pressure correction


There are variation to the h h simple l algorithm l h SIMPLER (SIMPLE Revised) SIMPLEC

M. Sahraoui FVM

Writing and testing code


p of the p g y Decide on the scope program: steady state/transient, variable properties, Cartesian/cylindrical, uniform/nonuniform mesh. Allow for same flexibility to allow future enhancements Testing individual parts first before putting everything together. Make sure that conservation is achieved Solution should be independent of the direction Check for symmetry Dimensionless Numbers Change the variables and check if the behavior in the limit makes sense Compare to exact solution Compare to other published numerical results Compare C t to experimental i t ld data. t

FVM for General Control Volume

M. Sahraoui FVM

M. Sahraoui FVM

FVM for General Control Volume

FVM for General Control Volume


Ti ,nj+1 Ti ,nj T c t dV c t Vabcd Where Vabcd is the volume of the control volume
which is given by the cross product

The unsteady heat 2D equation is given by :

T T c = k t x x

T ( k T ) = .( + k y y

Vabcd = 0.5 xdb yac ydb xac


In cartesian coodinates this reduces to

The integral form of the equation is

c t dV = q.n dS Where q
S

q = k

T T xk y x y

Vabcd = xy n T T T yab dy + k dx k k x y x i +1/ 2, j S

Then the integral form of the heat equation becomes

T T T +k xab k ybc + k xbc y i +1/ 2, j x i , j +1/ 2 y i , j +1/ 2


n

k dy y+k dx = 0 c t dV + x y
S

T T T k ycd + k xcd k yda x i 1/ 2, j y i 1/ 2, j x i , j 1/ 2


n n

Note that:

n dS = xdy ydx
M. Sahraoui FVM

T +k xda y i , j 1/ 2
M. Sahraoui FVM

FVM for General Control Volume


Now we have to evaluate the temperature derivatives at the control volume interfaces:

FVM for General Control Volume


Now we have to evaluate the temperature derivatives at the control volume interface: using the surface abcd Assuming the derivative is constant over the control volume we obtain

i + 1/ 2, j

T x i +1/ 2, 2 j
n

T y i +1/ 2, 2 j

T etc x i , j +1/ 2
n

For this we use the divergence theorem

T T dV Aa 'b ' c ' d ' x x i +1/ 2, j a 'b ' c ' d '


n

(dz = 1)

F dV = F n dS
Let

Then Th

F = Tx T

x dV = T dy
S

(65)

T Aa 'b ' c ' d ' = x i +1/ 2, j


n

T dy
S

And

F = Ty

y dV = T dx
S

(66)

T dy T
S

n i +1, j

ya 'b ' + Tbn yb ' c ' + Ti ,nj yc ' d ' + Tan yd ' a '

Where Tb and Tan are determined as the averages of the four neighboring points

Expressions (65) and (66) provide a way to calculate the derivative at the control volume interface
M. Sahraoui FVM M. Sahraoui FVM

You might also like