100% found this document useful (1 vote)
160 views

The Finite Volume Method For Diffusion Problems: Div U Div Grad S T

This document describes the finite volume method for solving one-dimensional steady-state diffusion problems. It discusses (1) grid generation and discretization of the diffusion equation over control volumes, (2) derivation of the discretized algebraic equation aPφP = aWφW + aEφE + Su for an interior node, and (3) imposing boundary conditions and solving the algebraic equations as a system to obtain the discrete φ values.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
100% found this document useful (1 vote)
160 views

The Finite Volume Method For Diffusion Problems: Div U Div Grad S T

This document describes the finite volume method for solving one-dimensional steady-state diffusion problems. It discusses (1) grid generation and discretization of the diffusion equation over control volumes, (2) derivation of the discretized algebraic equation aPφP = aWφW + aEφE + Su for an interior node, and (3) imposing boundary conditions and solving the algebraic equations as a system to obtain the discrete φ values.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 29

Chapter 4:

The Finite Volume Method for Diffusion


Problems

P f D
Prof. Dr. Ib
Ibrahim
hi SSezaii
Department of Mechanical Engineering
Eastern Mediterranean University

Fall 2010-2011

Introduction

General transport equation is


∂∂(( ρφ )
+ div( ρφ u ) = div(Γgradφ ) + Sφ
∂t
For steady diffusion:
div(Γgradφ ) + Sφ = 0
Control volume integration gives

∫ div(Γgradφ )dV + ∫ Sφ dV = ∫ n ⋅ (Γgradφ )dA + ∫ Sφ dV


CV CV A CV

ME555 : Computational Fluid Dynamics 2 I. Sezai – Eastern Mediterranean University

1
Finite Volume Method for One-dimensional Steady State Diffusion

Steady-state diffusion of a
general property φ in one-
di
dimensional
i lddomaini iis

d dφ
(Γ ) + Sφ = 0
dx dx

S 11: G
Step Grid
id generation:
i

ME555 : Computational Fluid Dynamics 3 I. Sezai – Eastern Mediterranean University

Step 2: Discretisation
Integration of the diffusion equation over the CV gives

d ⎛ dφ ⎞ ⎛ dφ ⎞ ⎛ dφ ⎞
∫ dx ⎜⎝ Γ dx ⎟⎠ dV + ∫ Sφ dV = ⎜⎝ ΓA dx ⎟⎠
ΔV ΔV e
− ⎜ ΓA ⎟ + S ΔV = 0
⎝ dx ⎠ w

To find expressions at the east and west faces, use


Taylor series approximations

⎛ ∂φ ⎞ ⎛ ∂ 2φ ⎞ Δx 2
φ ( x + Δx ) = φ ( x ) + ⎜ ⎟ Δx + ⎜ 2 ⎟ + ⋅⋅⋅
⎝ ∂x ⎠ x ⎝ ∂x ⎠ x 2

ME555 : Computational Fluid Dynamics 4 I. Sezai – Eastern Mediterranean University

2
⎛ ∂φ ⎞ ⎛ ∂ 2φ ⎞ Δx 2
φ ( x + Δx) = φ ( x) + ⎜ ⎟ Δx + ⎜ 2⎟ + ⋅⋅⋅
⎝ ∂x ⎠ x ⎝ ∂x ⎠ x 2

⎛ ∂φ ⎞ ⎛ ∂ 2φ ⎞ Δx 2
φE = φP + ⎜ ⎟ Δx + ⎜ 2 ⎟ + ⋅⋅⋅
⎝ ∂x ⎠ P ⎝ ∂x ⎠ P 2

⎛ ∂φ ⎞ ⎛ ∂ 2φ ⎞ Δx 2
φW = φP − ⎜ ⎟ Δx + ⎜ 2⎟ + ⋅⋅⋅
⎝ ∂x ⎠ P ⎝ ∂x ⎠ P 2
Neglect

⎛ ∂φ ⎞ φE − φW
Adding and subtracting Æ ⎜ ⎟ =
⎝ ∂x ⎠ P 2Δx

⎛ ∂φ ⎞ φE − φP
At the east face Æ ⎜ ⎟ =
⎝ ∂x ⎠e Δx
ME555 : Computational Fluid Dynamics 5 I. Sezai – Eastern Mediterranean University

Rewriting the diffusion equation for an interior point P:


d ⎛ dφ ⎞
∫ dx ⎜⎝ Γ dx ⎟⎠ dV + ∫ Sφ dV = 0
ΔV ΔV

⎛ dφ ⎞ ⎛ dφ ⎞
⎜ ΓA ⎟ − ⎜ ΓA ⎟ + Sφ ΔV = 0
⎝ dx ⎠e ⎝ dx ⎠ w (4.4)
On a uniform grid linear interpolation of Γ is
ΓW + Γ P ΓP + ΓE
Γw = Γe = (4.5)
2 2
Diffusive flux terms are
⎛ dφ ⎞ ⎛ φE − φP ⎞
⎜ ΓA ⎟ = Γ e Ae ⎜ ⎟ (4.6)
⎝ dx ⎠e ⎝ δ xPE ⎠
⎛ dφ ⎞ ⎛ φP − φW ⎞
⎜ ΓA ⎟ = Γ w Aw ⎜ ⎟
(4.7)
⎝ dx ⎠ w ⎝ δ xWP ⎠
ME555 : Computational Fluid Dynamics 6 I. Sezai – Eastern Mediterranean University

3
The source term S may be a function of φ Æ express S in linear form as:
Sφ ΔV = Su + S pφP (4.8)
Substituting (4.6), (4.7) and (4.8) into (4.4)
⎛ φ −φ ⎞ ⎛ φP − φW ⎞
Γ e Ae ⎜ E P ⎟ − Γ w Aw ⎜ ⎟ + ( Su + S pφP ) = 0 (4 9)
(4.9)
⎝ δ xPE ⎠ ⎝ δ xWP ⎠
Rearranging,

⎛ Γe Γ ⎞ ⎛ Γ ⎞ ⎛ Γ ⎞ (4.10)
⎜ Ae + w Aw − S p ⎟ φP = ⎜ w Aw ⎟ φW + ⎜ e Ae ⎟ φE + Su
⎝ δ xPE δ xWP ⎠ ⎝ δ xWP ⎠ ⎝ δ xPE ⎠
or
or, aPφP = aW φW + aEφE + Su (4.11)

where, aW aE aP
Γ w Aw Γ e Ae
aW + aE − S p
δ xWP δ xPE
ME555 : Computational Fluid Dynamics 7 I. Sezai – Eastern Mediterranean University

1 2 3 4 5 6 7
φA W P E φB

δxWP δxP
E
0) boundary values φA ,φB specified.
Special case: no source terms (Sφ = 0), specified
For the point near a west boundary (point 2):
⎛ φ −φ ⎞ ⎛ φP − φ A ⎞
Γ e Ae ⎜ E P ⎟ − Γ w Aw ⎜ ⎟=0
⎝ δ xPE ⎠ ⎝ δ xWP ⎠
⎛ Γe Γ ⎞ ⎛ Γ ⎞ ⎛ Γ ⎞
⎜ Ae + w Aw ⎟ φP = 0.φW + ⎜ e Ae ⎟ φE + ⎜ w Aw ⎟ φ A
⎝ δ xPE δ xWP ⎠ ⎝ δ xPE ⎠ ⎝ δ xWP ⎠
or, aPφP = aW φW + aEφE + Su
aW aE aP SP Su
Γ e Ae Γ A Γ w Aw
0 aW + aE − S p − w w φ
δ xPE δ xWP δ xWP A
ME555 : Computational Fluid Dynamics 8 I. Sezai – Eastern Mediterranean University

4
1 2 3 4 5 6 7
qw
W P E φB

δxWP δxP
No source terms (Sφ = 0),
0) heat flux qw specified at west boundary.
boundary
For the point near a west boundary (point 2):
⎛ φ −φ ⎞
Γ e Ae ⎜ E P ⎟ + qw Aw = 0
⎝ δ xPE ⎠
⎛ Γe ⎞ ⎛ Γ ⎞
⎜ Ae ⎟ φP = 0.φW + ⎜ e Ae ⎟ φE + qw Aw
⎝ δ xPE ⎠ ⎝ δ xPE ⎠
or, aPφP = aW φW + aEφE + Su
aW aE aP SP Su
Γ e Ae
0 aW + aE − S p 0 qw Aw
δ xPE
ME555 : Computational Fluid Dynamics 9 I. Sezai – Eastern Mediterranean University

Summary of Boundary Conditions

For a one-dimensional CV of width Δx near boundary B:


1) Set coefficient aB(i) = 0 (i → P) Δx

qB
2) Add source contributions B P

(a) Fixed value φB:


k B AB
Add: Su = φB
Δx / 2
k A
Sp = − B B
Δx / 2
to the source terms Su and Sp
(b) Fixed flux qB:
Add qBAB in the form of Su + SpφP to the source terms Su and Sp.
ME555 : Computational Fluid Dynamics 10 I. Sezai – Eastern Mediterranean University

5
Step 3: Solution of equations
Discretised equations of the form (4.11)

aPφP = aW φW + aEφE + Su (4-11)

must be set up at each nodal point.


ÆWe obtain a system of linear algebraic equations
Solve the system for φ values
ÆUse any matrix solution method.
e.g. Tri-diagonal matrix algorithm.
ME555 : Computational Fluid Dynamics 11 I. Sezai – Eastern Mediterranean University

Tridiagonal Matrix Algorithm


Consider a system of equations that has a tridiagonal form
d 2φ2 + c2φ3 = b2
a3φ2 + d 3φ3 + c3φ4 = b3
a4φ3 + d 4φ4 + c4φ5 = b4
. . . . . . . .
aiφi −1 + diφi + ciφi +1 = bi
. . . . . .
an − 2φn −3 + d n − 2φn − 2 + cn − 2φn −1 = bn − 2
an −1φn −2 + d n −1φn −1 = bn −1
In matrix form:
⎡d2 c2 ⎤ ⎡ φ2 ⎤ ⎡ b2 ⎤
⎢a d3 c3 ⎥⎢ φ ⎥ ⎢ b ⎥
⎢ 3 ⎥⎢ 3 ⎥ ⎢ 3 ⎥
⎢ a4 d4 c4 ⎥ ⎢ φ4 ⎥ ⎢ b4 ⎥
⎢ ⎥⎢ ⎥ ⎢ ⎥
⎢ ⎥⎢ ⎥=⎢ ⎥
⎢ ai di ci ⎥ ⎢ φi ⎥ ⎢ bi ⎥
⎢ ⎥⎢ ⎥ ⎢ ⎥
⎢ ⎥⎢ ⎥ ⎢ ⎥
⎢ an − 2 d n−2 cn − 2 ⎥ ⎢φn − 2 ⎥ ⎢bn − 2 ⎥
⎢ ⎥⎢ ⎥ ⎢ ⎥
⎢⎣ an −1 d n −1 ⎥⎦ ⎢⎣φn −1 ⎥⎦ ⎢⎣ bn −1 ⎥⎦

ME555 : Computational Fluid Dynamics 12 I. Sezai – Eastern Mediterranean University

6
Subtract (a3/d2) times row 1 from row 2 Æ obtain 0 in a3 position.
⎧ ⎛ a3 ⎞
⎪d3 ← d3 − ⎜ ⎟ c2 Note: c2 is not altered
⎪ ⎝ d2 ⎠

⎪ ⎛ a3 ⎞
⎪b3 ← b3 − ⎜ d ⎟ b2
⎩ ⎝ 2⎠
In general

⎧ ⎛ ai ⎞
⎪di ← di − ⎜ ⎟ ci −1
⎪ ⎝ di −1 ⎠

⎪b ← b − ⎛ ai ⎞ b (3 ≤ i ≤ n − 1)
⎪ i i ⎜ ⎟ i −1
⎩ ⎝ di −1 ⎠
At the end of the forward elimination phase, the form of the system
is as follows:
ME555 : Computational Fluid Dynamics 13 I. Sezai – Eastern Mediterranean University

⎡d2 c2 ⎤ ⎡ φ2 ⎤ ⎡ b2 ⎤
⎢ d3 c3 ⎥⎢ φ ⎥ ⎢ b ⎥
⎢ ⎥⎢ 3 ⎥ ⎢ 3 ⎥
⎢ d4 c4 ⎥ ⎢ φ4 ⎥ ⎢ b4 ⎥
⎢ ⎥⎢ ⎥ ⎢ ⎥
⎢ ⎥⎢ ⎥=⎢ ⎥
⎢ di ci ⎥ ⎢ φi ⎥ ⎢ bi ⎥
⎢ ⎥⎢ ⎥ ⎢ ⎥
⎢ ⎥⎢ ⎥ ⎢ ⎥
⎢ d n−2 cn − 2 ⎥ ⎢φn − 2 ⎥ ⎢bn − 2 ⎥
⎢ ⎥⎢ ⎥ ⎢ ⎥
⎢⎣ d n −1 ⎥⎦ ⎢⎣φn −1 ⎥⎦ ⎢⎣ bn −1 ⎥⎦

Of course, the bi’s and di’s are not as they were at the beginning of this process, but
the ci’s are. The back substitution phase solves for φn–1, φn–2,…, φ2 as follows:
b
φn −1 ← n −1
d n −1
1
φn −2 ← (bn − 2 − cn −2φn −1 )
d n −2
In general
1
φi ← (bi − ciφi +1 ) (i = n − 2, n − 3, ......., 2
di
ME555 : Computational Fluid Dynamics 14 I. Sezai – Eastern Mediterranean University

7
Use single dimensioned arrays Æ (ai), (di), (ci), (bi)
Store the solution in array (φi).
subroutine Tri(n, a, d, c, b, φ)
real array a(n), d(n), c(n), b(n), φ(n)
integer i,
i n
real mult ! (multiplier)
for i = 3 to n–1 do
mult ← ai/di–1
di ← di – (mult)ci–1
bi ← bi – (mult)bi–1
end for
φn–1 ← bn–1/dn–1
for i = n–2 to 2, step –1 do
φi ← (bi – ciφi+1)/di
end for
end subroutine Tri
ME555 : Computational Fluid Dynamics 15 I. Sezai – Eastern Mediterranean University

Worked Examples: 1) One-dimensional steady state diffusion

d ⎛ dT ⎞
Governing equation → ⎜k ⎟+S = 0
dx ⎝ dx ⎠
k → Γ, φ → T, S = heat generation per unit volume
Consider the problem of source-free heat conduction in an insulated
rod whose ends are maintained at constant temperatures of 100 oC and
500 oC respectively. Calculate the steady state temperature in the rod.
Take thermal conductivity k = 1000 W/mK, cross-sectional area A =
10×10–3

In this case, S = 0

ME555 : Computational Fluid Dynamics 16 I. Sezai – Eastern Mediterranean University

8
Solution: Let us divide the rod into 5 equal control volumes (CV’s).
Rules for grid generation:
1) Locations of the CV faces are defined first.
2) Then nodal points are placed at the centers of the CV
CV’ss.
3) Numbering starts from the boundary node at left.
4) All CV’s have a volume of δx.A
5) Inter-nodal distances are equal to δx, (δxWP = δxPE = δx)
6) Near west boundary (node 2), δxWP = δx/2
7) Near
N east bboundary
d ((node
d 6)
6), δx
δ PE = δx/2
δ /2
1 2 3 4 5 6 7
TA TB

δx/2 δx δx δx/2
ME555 : Computational Fluid Dynamics 17 I. Sezai – Eastern Mediterranean University

1 2 3 4 5 6 7
W P E (4.8)
φA φB
Δx

δxPW δxP
For interior nodes ((nodes 3-5):
) E ((4.9))
⎛ φ −φ ⎞ ⎛ φP − φW ⎞
Γ e Ae ⎜ E P ⎟ − Γ w Aw ⎜ ⎟=0
⎝ δ xPE ⎠ ⎝ δ xWP ⎠

⎛ Γe Γ ⎞ ⎛ Γ ⎞ ⎛ Γ ⎞ (4.10)
⎜ Ae + w Aw ⎟ TP = ⎜ w Aw ⎟ TW + ⎜ e Ae ⎟ TE
⎝ δ xPE δ xWP ⎠ ⎝ δ xWP ⎠ ⎝ δ xPE ⎠
or, aPTP = aW TW + aETE (4.11)

where, aW aE aP
Γ w Aw Γ e Ae
aW + aE − S p
δ xWP δ xPE
ME555 : Computational Fluid Dynamics 18 I. Sezai – Eastern Mediterranean University

9
(4-11)

General equation: aPφP = aW φW + aEφE + Su


1 2 3 4 5 6 7
φA W P E φB
Δx

δxPW δxP
E
aW aE aP Sp Su
Interior nodes (nodes 3-5):
Γ w Aw Γ e Ae
Su = 0, Sp = 0, Γ = k aW + aE − S p 0 0
δ xWP δ xPE
aW aE aP Sp Su
For boundary node 2: Γ e Ae kA kA
0 aW + aE − S p − TA
δ xPE δ xWP δ xWP
aW aE aP Sp Su
For boundary node 6: Γ w Aw kA kA
0 aW + aE − S p − TB
δ xWP δ xPE δ xPE
ME555 : Computational Fluid Dynamics 19 I. Sezai – Eastern Mediterranean University

The resulting system of equations are

⎡ − aP2 aE2 ⎤ T − Su2 ⎤


⎢ ⎥⎡ 2 ⎤ ⎡
⎢ aW3 − a p3 aE3 ⎢
⎥ T3 ⎥ ⎢ − Su3 ⎥⎥
⎢ ⎥ ⎢ ⎥ ⎢
aW4 −a p4 aE4
⎢ ⎥ ⎢ T4 ⎥ ⎢ − Su4 ⎥
⎢ ⎥⎢ ⎥ ⎢ ⎥
⎢ ⎥ ⎢ ⎥ = ⎢ ⎥
⎢ aWi −a pi aE i ⎢
⎥ i T ⎥ ⎢ − Su i

⎢ ⎥ ⎢ ⎥ ⎢ ⎥
⎢ ⎥⎢ ⎥ ⎢ ⎥
⎢ aWn−2 − a pn−2 ⎢T ⎥
a E n −2 ⎥ ⎢ n − 2 ⎥ ⎢ ⎢ − Su ⎥
⎢ ⎥ ⎢ T ⎥ ⎢ − Su
n−2

⎢⎣ aWn−1 −a pn−1 ⎥⎦ ⎣ n −1 ⎦ ⎣ S n − 1 ⎦⎥

Solve the system of equations using Tri-diagonal matrix algorithm


(TDMA) for T2, T3, …Tn-1 , where (n = 7)
ME555 : Computational Fluid Dynamics 20 I. Sezai – Eastern Mediterranean University

10
The solution is:

⎡ T1 ⎤ ⎡100 ⎤
⎢T ⎥ ⎢140 ⎥
⎢ 2⎥ ⎢ ⎥
⎢T3 ⎥ ⎢ 220 ⎥
⎢ ⎥ ⎢ ⎥
⎢T4 ⎥ = ⎢300 ⎥
⎢T5 ⎥ ⎢380 ⎥
⎢ ⎥ ⎢ ⎥
⎢T6 ⎥ ⎢ 460 ⎥
⎢T ⎥ ⎢500 ⎥
⎣ 7⎦ ⎣ ⎦

Exact solution is:


Comparison of the numerical result with the
analytical solution.
T = 800 x + 100

ME555 : Computational Fluid Dynamics 21 I. Sezai – Eastern Mediterranean University

Homework 1:
Write a computer program in Fortran language to find the
temperature distribution in the problem given in Example 1. Use 5
control volumes.
Use the algorithm given in the “Pseudo
Pseudo program to find the aE
coefficients and source terms in 1-D Diffusion Problems” given in
page 34 of the lecture notes.

ME555 : Computational Fluid Dynamics 22 I. Sezai – Eastern Mediterranean University

11
ME555 : Computational Fluid Dynamics 23 I. Sezai – Eastern Mediterranean University

The governing equation is: d ⎛ dT ⎞


⎜k ⎟ + q& = 0
dx ⎝ dx ⎠

d ⎛ dφ ⎞
The general equation is: ⎜Γ ⎟+S = 0
dx ⎝ dx ⎠

Comparing the above equations, where S ΔV = Su + S pφP

φ = T, Γ = k, Su = qΔV Sp = 0 where, ΔV = AΔx

Take area A = 1 in the y-z plane


1 2 3 4 5 6 7
φA W P E φB
Δx

δxPW δxP
E
Solution is similar to the previous example.
ME555 : Computational Fluid Dynamics 24 I. Sezai – Eastern Mediterranean University

12
(4-11)
General equation: aPφP = aW φW + aEφE + Su
1 2 3 4 5 6 7
φA W P E φB
Δx

δxPW δxP
E

Interior nodes (nodes 3-5): aW aE aP Sp Su


Γ w Aw Γ e Ae
& Δx, Sp = 0, Γ = k
Su = qA aW + aE − S p 0 & Δx
qA
δ xWP δ xPE
aW aE aP Sp Su
For boundary node 2:
Γ e Ae k w Aw k w Aw
0 aW + aE − S p − & Δx +
qA TA
δ xPE δ xWP δ xWP
aW aE aP Sp Su
For boundary node 6: Γ w Aw ke Ae ke Ae
0 aW + aE − S p − & Δx +
qA TB
δ xWP δ xPE δ xPE
ME555 : Computational Fluid Dynamics 25 I. Sezai – Eastern Mediterranean University

Node number 2 3 4 5 6

The solution is:


⎡ T1 ⎤ ⎡100 ⎤
⎢T ⎥ ⎢150 ⎥
⎢ 2⎥ ⎢ ⎥
⎢T3 ⎥ ⎢ 218⎥
⎢ ⎥ ⎢ ⎥
⎢T4 ⎥ = ⎢ 254 ⎥
⎢T5 ⎥ ⎢ 258⎥
⎢ ⎥ ⎢ ⎥
⎢T6 ⎥ ⎢ 230 ⎥
⎢T ⎥ ⎢ 200 ⎥
⎣ 7⎦ ⎣ ⎦
Comparison of the numerical result with the
analytical solution.
⎡T − T q ⎤
Exact solution is: T = ⎢ B A + ( L − x) ⎥ x + TA
⎣ L 2k ⎦
ME555 : Computational Fluid Dynamics 26 I. Sezai – Eastern Mediterranean University

13
ME555 : Computational Fluid Dynamics 27 I. Sezai – Eastern Mediterranean University

The governing d ⎛ dT ⎞ d ⎛ dT ⎞ 2
⎜ kA ⎟ − hP(T − T∞ ) = 0 or ⎜ ⎟ − n (T − T∞ ) = 0
equation is: dx ⎝ dx ⎠ dx ⎝ dx ⎠
hP
d dφ where n2 =
The ggeneral equation
q is: (Γ ) + Sφ = 0 kA
d
dx dx
d S ΔV = Su + S pφP
Comparing the above equations, ΔV = AΔx

φ = T, Γ = 1, Su = n2T∞ΔV Sp = –n2ΔV
1 2 3 4 5 6 7
TB W P E
Δx q=0
δxPW δxP
E
Solution is similar to the previous example. Find coefficients of
aPφP = aW φW + aEφE + Su
ME555 : Computational Fluid Dynamics 28 I. Sezai – Eastern Mediterranean University

14
(4-11)

General equation: aPφP = aW φW + aEφE + Su


1 2 3 4 5 6 7
TB W P E
Δx q=0
δxPW δxP
E
Interior nodes (nodes 3-5): aW aE aP Sp Su
Su = n2ΔVT∞, Sp = –n2ΔV, Γ w Aw Γ e Ae
aW + aE − S p − n 2 ΔV n 2 ΔVT∞
Γ=k δ xWP δ xPE

aW aE aP Sp Su
For boundary
b d Γ e Ae Γ w Aw Γ w Aw
0 aW + aE − S p − n 2 ΔV − n 2 ΔVT∞ + TB
node 2: δ xPE Δx / 2 Δx / 2
aW aE aP Sp Su
For boundary node 6: Γ w Aw
0 aW + aE − S p −n 2 ΔV n 2 ΔVT∞
δ xWP
ME555 : Computational Fluid Dynamics 29 I. Sezai – Eastern Mediterranean University

The solution is

⎡ T1 ⎤ ⎡ 100 ⎤
⎢ ⎥ ⎢ 64 22 ⎥
⎢T2 ⎥ ⎢ 64.22 ⎥
⎢T3 ⎥ ⎢ 36.91⎥
⎢ ⎥ ⎢ ⎥
⎢T4 ⎥ = ⎢ 26.50 ⎥
⎢T5 ⎥ ⎢ 22.60 ⎥
⎢ ⎥ ⎢ ⎥
⎢T6 ⎥ ⎢ 21.30 ⎥
⎢ ⎥ ⎢ 21 30 ⎥
⎣T7 ⎦ ⎣ 21.30 ⎦

ME555 : Computational Fluid Dynamics 30 I. Sezai – Eastern Mediterranean University

15
Comparison with the analytical solution

Node

2
3
4
5
6

Maximum error: 6.27%


The numerical solution can be improved by employing a
finer grid.
Consider the same problem, but use 10 control volumes.
Comparison of the results is given as follows
ME555 : Computational Fluid Dynamics 31 I. Sezai – Eastern Mediterranean University

Maximum
error: 2.08%

ME555 : Computational Fluid Dynamics 32 I. Sezai – Eastern Mediterranean University

16
Homework 2:
Write a Fortran program to find the temperature distribution in the
rod in example 4.3. Compare the results obtained using 10 and 50
points on a graph. Use the algorithm given in the pseudo program
appearing in the following slide.

The geometry of example 4.3.

ME555 : Computational Fluid Dynamics 33 I. Sezai – Eastern Mediterranean University

Pseudo Program to Find aE Coefficients and Source Terms in 1-D Diffusion Problems

Main program
call grids
call internal_coefficients
call boundary_coefficients
call app_coefficient
call tdma
end program
subroutine grids
for i = 2 to N–1
Find δxw(i), δxe(i)
end for
end subroutine grids
subroutine internal_coefficients
for i = 2 to N–1
ΓAw ΓAe
aW (i ) = ; aE (i ) = ; S p (i ) = − n 2 ΔV , Su (i ) = n 2 ΔVT∞
δ xw (i ) δ xe (i )
end for
end subroutine internal_coefficients)
ME555 : Computational Fluid Dynamics 34 I. Sezai – Eastern Mediterranean University

17
subroutine boundary_coefficients (overwrite on near-boundary coefficients)
for i = 2 (west boundary)
Su (i ) = Su (i ) + aw (i )TB
Sp(i ) = Sp(i) − aw (i )
aw(i) = 0
end for
for i = N–1 (east boundary)
no corrections are needed for Su and Sp since qe = 0 ( Su (i) = Su (i) + qe Ae )
ae(i) = 0
end for
end subroutine boundary
boundary_coefficients
coefficients
subroutine a_p coefficient
for i = 2 to N–1
ap(i) = aw(i) + ae(i) –Sp(i)
end for
end subroutine a_p coefficient
ME555 : Computational Fluid Dynamics 35 I. Sezai – Eastern Mediterranean University

Finite Volume Method for Two-dimensional Diffusion Problems

Consider the two-dimensional steady state diffusion equation


∂ ⎛ ∂φ ⎞ ∂ ⎛ ∂φ ⎞
⎜Γ ⎟ + ⎜Γ ⎟ + S = 0
∂x ⎝ ∂x ⎠ ∂y ⎝ ∂y ⎠

Integrating the above equation over the CV,


ME555 : Computational Fluid Dynamics 36 I. Sezai – Eastern Mediterranean University

18
∂ ⎛ ∂φ ⎞ ∂ ⎛ ∂φ ⎞
∫ ∂x ⎜⎝ Γ ∂x ⎟⎠ dx ⋅ dy + ∫ ∂y ⎜⎝ Γ ∂y dx ⋅ dy ⎟⎠ + ∫ Sφ dV = 0
ΔV ΔV ΔV

Noting that Ae = Aw = Δy and An = As = Δx, we obtain:

⎡ ⎛ ∂φ ⎞ ⎛ ∂φ ⎞ ⎤ ⎡ ⎛ ∂φ ⎞ ⎛ ∂φ ⎞ ⎤
⎢Γ e Ae ⎜ ⎟ − Γ w Aw ⎜ ⎟ ⎥ + ⎢Γ n An ⎜ ⎟ − Γ s As ⎜ ⎟ ⎥ + S ΔV = 0
⎣ ⎝ ∂x ⎠e ⎝ ∂x ⎠ w ⎦ ⎣ ⎝ ∂y ⎠ n ⎝ ∂y ⎠ s ⎦ (4.53)
Equation (4.53) represents a balance of the generation of φ in a CV and the fluxes
through its cell faces
∂φ φP − φW
Flux across the west face = Γ w Aw = Γ w Aw
∂x w δ xWP
∂φ φ −φ
Flux across the east face = Γ e Ae = Γ e Ae E P
∂x e δ xPE
∂φ φ −φ
Flux across the south face = Γ s As = Γ s As P S
∂y s δ ySP
∂φ φ − φP
Flux across the north face = Γ n An = Γ n An N
∂y n δ yPN
ME555 : Computational Fluid Dynamics 37 I. Sezai – Eastern Mediterranean University

By substitution of the above expressions into eqn. (4.53) we obtain


φ E − φP φ −φ φ − φP φ −φ
Γ e Ae − Γ w Aw P W + Γ n An N − Γ s As P S + S ΔV = 0
δ xPE δ xWP δ yPN δ ySP
Substituting the linearised form of the source term S ΔV = Su + S PφP

⎛ Γ w Aw Γ e Ae Γ s As Γ n An ⎞
⎜ + + + − S p ⎟ φP
⎝ δ xWP δ xPE δ ySP δ yPN ⎠
⎛Γ A ⎞ ⎛Γ A ⎞ ⎛Γ A ⎞ ⎛Γ A ⎞
= ⎜ w w ⎟ φW + ⎜ e e ⎟ φE + ⎜ s s ⎟ φS + ⎜ n n ⎟ φN + Su
⎝ δ xWP ⎠ ⎝ δ xPE ⎠ ⎝ δ ySP ⎠ ⎝ δ yPN ⎠

This eqn can be written in the form:

aPφP = aW φW + aEφE + aSφS + aN φN + Su


where
aW aE aS aN aP
Aw = Ae = Δy Γ w Aw Γ e Ae Γ s As Γ n An
aW + aE + aS + aN − S p
As = An = Δx δ xWP δ xPE δ ySP δ yPN
ME555 : Computational Fluid Dynamics 38 I. Sezai – Eastern Mediterranean University

19
Finite Volume Method for Three-dimensional Diffusion Problems
Steady state diffusion in a 3D situation is governed by
∂ ⎛ ∂φ ⎞ ∂ ⎛ ∂φ ⎞ ∂ ⎛ ∂φ ⎞
⎜Γ ⎟ + ⎜Γ ⎟ + ⎜Γ ⎟ + S = 0 (4.58)
∂x ⎝ ∂x ⎠ ∂y ⎝ ∂y ⎠ ∂z ⎝ ∂z ⎠
A typical
i l controll volume
l is
i shown
h below.
b l

ME555 : Computational Fluid Dynamics 39 I. Sezai – Eastern Mediterranean University

Integration of eqn (4.58) over the control volume gives


⎡ ⎛ ∂φ ⎞ ⎛ ∂φ ⎞ ⎤ ⎡ ⎛ ∂φ ⎞ ⎛ ∂φ ⎞ ⎤
⎢Γ e Ae ⎜ ⎟ − Γ w Aw ⎜ ⎟ ⎥ + ⎢Γ n An ⎜ ⎟ − Γ s As ⎜ ⎟ ⎥
⎣ ⎝ ∂x ⎠e ⎝ ∂x ⎠ w ⎦ ⎣ ⎝ ∂y ⎠n ⎝ ∂x ⎠ s ⎦
⎡ ⎛ ∂φ ⎞ ⎛ ∂φ ⎞ ⎤
+ ⎢Γt At ⎜ ⎟ − Γb Ab ⎜ ⎟ ⎥ + S ΔV = 0
⎣ ⎝ ∂z ⎠t ⎝ ∂z ⎠b ⎦
which can be discretized as
φ E − φP φ −φ φ − φP φ −φ
Γ e Ae − Γ w Aw P W + Γ n An N − Γ s As P S
δ xPE δ xWP δ yPN δ ySP
φ − φP φ −φ
+Γ t At T − Γ b Ab P B + ( Su + S p )φP = 0
δ z PT δ z BP
R
Rearranging
i aPφP = aW φW + aEφE + aSφS + aN φN + aBφB + aT φT + Su

aW aE aS aN aB aT aP
Γ w Aw Γ e Ae Γ s As Γ n An Γ b Ab Γ t At aW + aE + aS + aN
δ xWP δ xPE δ ySP δ yPN δ zBP δ yPT + aB + aT − S p
ME555 : Computational Fluid Dynamics 40 I. Sezai – Eastern Mediterranean University

20
Summary of Discretized Equations for Diffusion Problems

aPφP = ∑ anbφnb + Su
aP = ∑ anb − S p
source terms: S ΔV = Su + S pφP

aW aE aS aN aB aT aP
Γ w Aw Γ e Ae
1D aW + aE − S p
δ xWP δ xPE
Γ w Aw Γ e Ae Γ s As Γ n An aW + aE + aS + aN
2D
δ xWP δ xPE δ ySP δ yPN −S p
Γ w Aw Γ e Ae Γ s As Γ n An Γ b Ab Γ t At aW + aE + aS + aN
3D
δ xWP δ xPE δ ySP δ yPN δ z BP δ yPT + aB + aT − S p

ME555 : Computational Fluid Dynamics 41 I. Sezai – Eastern Mediterranean University

Application of TDMA to Two-dimensional Problems

Line by line application of TDMA method


ME555 : Computational Fluid Dynamics 42 I. Sezai – Eastern Mediterranean University

21
For a point P: aPφP = aW φW + aEφE + aSφS + aN φN + b

a) Sweep direction: n-s


Rearranging aSφS − aPφP + aN φN = − aW φW − aEφE − b φW and φE are known
from previous
iteration
This is similar
to the TDMA a jφ j −1 + d jφ j + c jφ j +1 = b j
equation
Procedure:
1) Solve along n-s direction along the line for j = 2, 3,…, n-1
using TDMA
2) Move to the next n-s line
3) Repeat step 1-2.
ME555 : Computational Fluid Dynamics 43 I. Sezai – Eastern Mediterranean University

b) Sweep direction: e-w

For a point P: aPφP = aW φW + aEφE + aSφS + aN φN + b

Rearranging aW φW − aPφP + aEφE = − aSφS − aN φN − b φS and φN are known


from previous iteration

This is similar
to the TDMA aiφi −1 + diφi + ciφ j +1 = bi
equation
Procedure:
1)) Solve alongg e-w direction alongg the line for i = 2, 3,…, n–1
using TDMA
2) Move to the next e-w line
3) Repeat step 1-2.

ME555 : Computational Fluid Dynamics 44 I. Sezai – Eastern Mediterranean University

22
Application of the TDMA method to three-dimensional problems
For 3-D problems the TDMA method is applied line by line on a selected plane and
then the calculation is moved to the next plane.

To solve along n-s direction: aSφS − aPφP + aN φN = − aW φW − aEφE − aBφB − aT φT − b

To solve along e-w direction: aW φW − aPφP + aEφE = − aSφS − aN φN − aBφB − aT φT − b


ME555 : Computational Fluid Dynamics 45 I. Sezai – Eastern Mediterranean University

Example:
Consider a 2D plate
Thickness = 1cm, k = 1000W/m/K
Calculate the temperature distribution

T = 100 oC

0.4 m
qw =500
insulated
kW/m2

0.3 m

insulated
ME555 : Computational Fluid Dynamics 46 I. Sezai – Eastern Mediterranean University

23
T = 100 oC

(1, 6) (2, 6) (3, 6) (4, 6) (5, 6)


(M=6) j = 6

j=5 Δy(5)

δyn(4)

j=4 Δy(4)
δxw(3) δxe(3)
qw = 500kW/m2 insulated
δys(4)
j=3 Δy(3)
Δx(2) Δx(3) Δx(4)

(1, 2) (2, 2) (3, 2) (4, 2) (5, 2)


j=2 Δy(2)
(1, 1) (2, 1) (3, 1) (4, 1) (5, 1)
j=1
i=1 i=2i=3 i = 4 i = 5 (N=5)
insulated
First draw control volumes, with equal spacings
Then, place nodes at the center of the control volumes.
Δx = Lx/N – 2 = 0.3/(5 – 2 ) = 0.1, Δy = Ly/M – 2 = 0.4/(6 – 2 ) = 0.1
ME555 : Computational Fluid Dynamics 47 I. Sezai – Eastern Mediterranean University

The governing equation is


∂ ⎛ ∂T ⎞ ∂ ⎛ ∂T ⎞
⎜Γ ⎟ + ⎜Γ ⎟=0 (Γ = k )
∂x ⎝ ∂x ⎠ ∂y ⎝ ∂y ⎠
which can be discretised as
aPTP = aW TW + aETE + aS TS + aN TN + Su

This equation is written for each node (i, j) in the domain


aP (i, j )T (i, j ) = aW (i, j )T (i − 1, j ) + aE (i, j )T (i + 1, j )
+ aS (i, j )T (i, j − 1) + aN (i, j )T (i, j + 1) + Su (i, j )

For interior points: (i = 2 – 4, j = 2 – 6)

ΓAw ΓAe ΓAs ΓAn δyn


aW = ; aE = ; aS = ; aN =
δ xw δ xe δ xs δ xn δxw δxe
Δy
aP = aW + aE + aS + aN − S p S p = 0, Su = 0
δys

Δx
ME555 : Computational Fluid Dynamics 48 I. Sezai – Eastern Mediterranean University

24
After finding aP, aE,aW,aN,aS coefficients follow the following steps
1) Solve the general equation using TDMA along j = 2 line (nodes
(2, 2, (3, 2), and (4, 2))
aW TW − aPTP + aETE = − aS TS − aN TN − Su
unknowns Initially unknown, but set
them to zero
Æ Temperatures along j = 2 are solved (Horizontal sweep)
2) Use TDMA along j = 3 line (nodes (2, 3), (3, 3) and (4, 3))
aW TW − aPTP + aETE = −aS TS − aN TN − Su
Known from Initially was set to
3) Repeat until j = 5 line previous iteration zero
4) Use TDMA along i = 2 line
Vertical sweep
5) Repeat until i =4 line
6) Go to step 1
ME555 : Computational Fluid Dynamics 49 I. Sezai – Eastern Mediterranean University

7) Repeat steps 1-6 until scaled residual norm becomes R ≤ ε where ε


= tolerance (use ε = 1.E–6)
r
R=
∑∑ aP (i, j )TP (i, j )
j i

where r is the residual norm defined as

r = ∑∑ r (i, j ) (Note the absolute value sign)


j i

and
r (i, j ) = aW (i, j )T (i − 1, j ) + aE (i, j )T (i + 1, j )
+ aS (i, j )T (i, j − 1) + aN (i, j )T (i, j + 1)
+ Su (i, j ) − aP (i, j )T (i, j )
ME555 : Computational Fluid Dynamics 50 I. Sezai – Eastern Mediterranean University

25
Fast Iterative Solvers for Linear Systems of Equations

Apart from TDMA, there are other iterative methods for solving the
system of equations. Unlike TDMA, which solves the problem line
by line, these iterative methods solves all equations simultaneously.
As a result these methods are faster than TDMA. Some of the fast
iterative methods are
1) SIP (strongly implicit procedure)
2) MSIP (modified SIP)
3) CG (Conjugate gradient method)
4) BiCGSTAB (bi-conjugate gradient stabilized method)
CG method is used for solving linear systems of equations which
have a symmetric coefficient matrix. All other methods mentioned
above are used for systems of equations involving non-symmetric
coefficient matrices.
ME555 : Computational Fluid Dynamics 51 I. Sezai – Eastern Mediterranean University

Homework 3:
Write a computer program in Fortran language to find the
temperature distribution in the 2-D plate problem given in the
previous example. Use the algorithm given in the pseudo program
on the next page. (a) Use 5x6 grids (b) 51x51 grids and plot the
temperature countours.
Thickness = 1cm, k = 1000W/m/K
T = 100 oC

qw =500 04m
0.4
insulated
kW/m2

0.3 m
insulated
ME555 : Computational Fluid Dynamics 52 I. Sezai – Eastern Mediterranean University

26
Pseudo Program to Solve the 2D Plate Problem
Main program
call grids
call internal_coefficients
call boundary_coefficients
call
ll boundary_values
b d l
call ap_coefficient
for iter = 1 to itermax
call solver
call boundary_values
call residual
(check if residual is below a desired value)
end for
call print
end program

ME555 : Computational Fluid Dynamics 53 I. Sezai – Eastern Mediterranean University

subroutine grids
for i = 2 to N–1
Find δxw(i), δxe(i), δx(i)
end for
for j = 2 to M–1
Find δys(j), δyn(j), δy(j)
end for
Update near boundary values of δxw(i), δxe(i), δys(j), δyn(j)
end subroutine grids
subroutine internal_coefficients
for i = 2 to N–1 and j = 2 to M–1
ΓAw ΓAe ΓAs ΓAn
aW (i, j ) = ; aE = ; aS = ; aN =
δ xw (i ) δ xe (i ) δ xs ( j ) δ xn ( j )
S p (i, j ) = 0, Su (i, j ) = 0
end for
end subroutine internal_coefficients

ME555 : Computational Fluid Dynamics 54 I. Sezai – Eastern Mediterranean University

27
subroutine boundary_coefficients (overwrite on near-boundary coefficients)
for i = 2 and j = 2 to M–1 (!west boundary)
Su (i, j ) = Su (i, j ) + qw Aw
aw(i, j) = 0
end for
for i = N–1 and j = 2 to M–1 (!east boundary)
ae(i, j) = 0
end for

for i = 2, N–1 and j = 2 (!south boundary)


as(i, j) = 0
end for
for i = 2, N–1 and j = M–1 (!north boundary)
Su(i, j) = Su(i, j) +an(i, j)*Tnorth
Sp(i, j) = Sp(i, j) – an(i, j)
an(i, j) = 0
end for
end subroutine boundary coefficients
ME555 : Computational Fluid Dynamics 55 I. Sezai – Eastern Mediterranean University

subroutine ap_coefficient
for i = 2 to N–1 and j = 2 to M–1
ap(i, j) = aw(i, j) + ae(i, j) + as(i, j) + an(i, j) – sp(i, j)
end for
end subroutine ap_coefficient

Subroutine solver
Call horizontal_sweep
Call vertical_sweep
End subroutine solver

Subroutine horizontal_sweep
for j = 2 to M–1
Calculate a(i), d(i), c(i), b(i) for TDMA for solving x(i) values along a
horizontal line for i = 2 to N–1
call TDMA(a,d,c,b,x,N)
transfer values of x(i) to T(i, j) along a horizontal line for i = 2 to N–1
end for
end subroutine horizontal_sweep
ME555 : Computational Fluid Dynamics 56 I. Sezai – Eastern Mediterranean University

28
Subroutine vertical_sweep
for i = 2 to N-1
calculate a(j), d(j), c(j), b(j) for TDMA for solving x(j) values along a vertical line for j
= 2 to M-1
call TDMA(a,d,c,b,x,M)
transfer values of x(j) to T(i, j) along a horizontal line for j = 2 to M-1
end for
end subroutine vertical_sweep
SUBROUTINE PRINT !For contour plot of temperature using TECPLOT
OPEN (UNIT=15,FILE="txy.dat")
WRITE(15,*)'TITLE = "T data on XY plane,',N,',',M,' " '
WRITE(15,*)'VARIABLES = "X", "Y", "T" '
WRITE(15,*)'ZONE I=',N,' J=',M,' F=POINT'
DO J=1,M
DO I=1,N
I 1N
WRITE (15,*) XCOOR(I,J),YCOOR(I,J),T(I,J)
END DO
END DO
CLOSE (15)
END SUBROUTINE PRINT
ME555 : Computational Fluid Dynamics 57 I. Sezai – Eastern Mediterranean University

SUBROUTINE BOUNDARY_VALUES
! top
J=M
DO I=1,N
T(I,J)=100
END DO
! left
I=1
DO J=1,M-1
T(I,J)=Q*DXW(I+1)/COND+T(I+1,J)
END DO
! RIGHT
I=N
DO J=1,M-1
T(I,J)=T(I-1,J)
END DO
! BOTTOM
J 1
J=1
DO I=1,N
T(I,J)=T(I,J+1)
END DO
END SUBROUTINE BOUNDARY_VALUES

ME555 : Computational Fluid Dynamics 58 I. Sezai – Eastern Mediterranean University

29

You might also like