0% found this document useful (0 votes)
3 views

Week4 LectureNotes

Material on CFD

Uploaded by

jofred
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views

Week4 LectureNotes

Material on CFD

Uploaded by

jofred
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 23

Application of our Knowledge to a

Problem of Practical Interest and


Setting up an Algorithm

Professor Gautam Biswas


Indian Institute of Technology Kanpur
Application and Setting up an Algorithm

Problem

Consider the metallic square block shown in the figure below.


Application and Setting up an Algorithm

Solution:

i. Considering the vertical symmetry and horizontal symmetry, the top right hand side
quadrant can be considered as the solution domain.
The governing equation is:

𝜕𝑇 𝜕2 𝑇 𝜕2 𝑇
=𝛼 +
𝜕𝑡 𝜕𝑥 2 𝜕𝑦 2

𝑇 is the temperature, 𝛼 is the thermal diffusivity, k is the thermal conductivity and h is


the convective heat transfer coefficient. The initial temperature of the block is 𝑇0 .
It is a cooling problem. 𝑇∞ is the ambient temperature and 𝑇0 > 𝑇∞ .
Application and Setting up an Algorithm

The Part (ii): The ADI discretization of the governing equation :

Step 1
1 1 1 1
𝑛+ 𝑛 𝑛+ 𝑛+ 𝑛+
𝑇𝑖,𝑗 2 − 𝑇𝑖,𝑗 𝑇𝑖+1,𝑗2 − 2𝑇𝑖,𝑗 2 + 𝑇𝑖−1,𝑗2 𝑇𝑖,𝑗𝑛 +1 − 2𝑇𝑖,𝑗𝑛 + 𝑇𝑖,𝑗𝑛 −1
=𝛼 +𝛼
Δ𝑡/2 Δ𝑥 2 Δ𝑦 2

Step 2
1 1 1 1
𝑛+ 𝑛+ 𝑛+ 𝑛+
𝑇𝑖,𝑗𝑛+1 − 𝑇𝑖,𝑗 2 𝑇𝑖+1,𝑗2 − 2𝑇𝑖,𝑗 2 + 𝑇𝑖−1,𝑗2 𝑇𝑖,𝑗𝑛+1 𝑛+1
+1 − 2𝑇𝑖,𝑗
𝑛+1
+ 𝑇𝑖,𝑗 −1
=𝛼 +𝛼
Δ𝑡/2 Δ𝑥 2 Δ𝑦 2

Arranging both the equations in the form where the unknowns are on the left hand
side and knowns on the right hand side.
Application and Setting up an Algorithm

Equation from step 1

𝑟𝑥 𝑛+12 1
𝑛+2 𝑟𝑥 𝑛+12 𝑛
𝑟𝑦 𝑛
− 𝑇𝑖−1,𝑗 + 1 + 𝑟𝑥 𝑇𝑖,𝑗 − 𝑇𝑖+1,𝑗 = 𝑇𝑖,𝑗 + 𝑇𝑖,𝑗 +1 − 2𝑇𝑖,𝑗𝑛 + 𝑇𝑖,𝑗
𝑛
−1 (1)
2 2 2

Equation from step 2

𝑟𝑦 𝑛+1 𝑟𝑦 𝑛+1 1 1 1 1
𝑛+1 𝑛+
2
𝑟𝑥 𝑛+ 𝑛+ 𝑛+
− 𝑇𝑖,𝑗 −1 + 1 + 𝑟𝑦 𝑇𝑖,𝑗 − 𝑇𝑖,𝑗 +1 = 𝑇𝑖,𝑗 + 2 2
𝑇𝑖+1,𝑗 − 2𝑇𝑖,𝑗 + 𝑇𝑖−1,𝑗2 (2)
2 2 2
Application and Setting up an Algorithm

Let us discretize the domain by (imax X jmax) cells,

top boundary 𝜕𝑇 (C)


𝑘 + ℎ𝑇 = ℎ𝑇∞
(2 to imax-1) 𝜕𝑦

left right
boundary boundary
(B) 𝜕𝑇 𝜕𝑇 (D)
=0 𝑘 + ℎ𝑇 = ℎ𝑇∞
𝜕𝑥 𝜕𝑥
(j=1 to jmax) (2 to jmax)

bottom 𝜕𝑇
=0
𝜕𝑦 (A)
(i=1 to imax)
Application and Setting up an Algorithm

B.C. for step 1


1 1 1 1
𝑛+ 𝑛+ 𝑛+ 𝑛+
From (A) 𝑇𝑖,2 2 − 𝑇𝑖,1 2 From (B) 𝑇2,𝑗 2 − 𝑇1,𝑗 2
=0 (3) =0
Δ𝑦 Δ𝑥 (4)

1 1
𝑛+2 𝑛+2
From (C) 𝑘 𝑇𝑖,𝑗𝑚𝑎𝑥 − 𝑇𝑖,𝑗𝑚𝑎𝑥 −1 1
𝑛+
+ 2
ℎ𝑇𝑖,𝑗𝑚𝑎𝑥 = ℎ𝑇∞ (5)
Δ𝑦

1 1
𝑛+ 𝑛+
𝑘 𝑇𝑖𝑚𝑎𝑥2 ,𝑗 − 𝑇𝑖𝑚𝑎𝑥2 −1,𝑗 1
From (D) 𝑛+
+ ℎ𝑇𝑖𝑚𝑎𝑥2 ,𝑗 = ℎ𝑇∞ (6)
Δ𝑥
Application and Setting up an Algorithm

Let us discretize the domain by (imax X jmax) cells,

top boundary 𝜕𝑇 (C)


𝑘 + ℎ𝑇 = ℎ𝑇∞
(2 to imax-1) 𝜕𝑦

left right
boundary boundary
(B) 𝜕𝑇 𝜕𝑇 (D)
=0 𝑘 + ℎ𝑇 = ℎ𝑇∞
𝜕𝑥 𝜕𝑥
(j=1 to jmax) (2 to jmax)

bottom 𝜕𝑇
=0
𝜕𝑦 (A)
(i=1 to imax)
Application and Setting up an Algorithm

B.C. for step 2


𝑛+1 𝑛+1 𝑛+1 𝑛+1
𝑇𝑖,2 − 𝑇𝑖,1 𝑇2,𝑗 − 𝑇1,𝑗
From (A) =0 From (B)
Δ𝑦 =0
Δ𝑥
(7) (8)

𝑛+1 𝑛+1
From (C) 𝑘 𝑇𝑖,𝑗𝑚𝑎𝑥 − 𝑇𝑖,𝑗𝑚𝑎𝑥 −1 𝑛+1
+ ℎ𝑇𝑖,𝑗𝑚𝑎𝑥 = ℎ𝑇∞ (9)
Δ𝑦

𝑛+1 𝑛+1
From (D)
𝑘 𝑇𝑖𝑚𝑎𝑥 ,𝑗 − 𝑇𝑖𝑚𝑎𝑥 −1,𝑗 𝑛+1
+ ℎ𝑇𝑗𝑚𝑎𝑥 = ℎ𝑇∞ (10)
Δ𝑥
Application and Setting up an Algorithm

Solve the equations (1) and (2) together with the B.C. using Tri-diagonal
matrix formulation.
Step 1 : Now for each j we can have TDM by varying i=2 to imax-1.
Use equation (1) for interior points and equations (4) and (6) for boundary
points. For each j solve all i through TDMA.
1 1
𝑛+ 𝑛+
𝑇2,𝑗 2 − 𝑇1,𝑗 2
=0
Δ𝑥
1 1 j
𝑛+ 𝑛+
𝑘 𝑇𝑖𝑚𝑎𝑥2 ,𝑗 − 𝑇𝑖𝑚𝑎𝑥2 −1,𝑗 1 sweep TDMA
𝑛+
+ ℎ𝑇𝑖𝑚𝑎𝑥2 ,𝑗 = ℎ𝑇∞ system
Δ𝑥
i
−1 1 0 ⋯ ⋯ ⋯ 0 0 1
𝑟𝑥 𝑟𝑥 𝑛+2 0

2
1 + 𝑟𝑥 −
2
0 ⋯ ⋯ ⋯ 0 𝑇1𝑖,𝑗 𝑟𝑦
𝑛 𝑛 𝑛 𝑛
𝑟𝑥 𝑟𝑥 1 𝑇𝑖,𝑗 + 𝑇𝑖,𝑗 +1 − 2𝑇𝑖,𝑗 + 𝑇𝑖,𝑗 −1
0 −
2
1 + 𝑟𝑥 −
2
⋯ ⋯ ⋯ ⋮ 𝑛+2 2
⋮ ⋱ ⋱ ⋱ ⋯ ⋯ ⋯ ⋮ 𝑇2,𝑗 ⋮
=
⋮ ⋯ ⋱ ⋱ ⋱ ⋯ ⋯ ⋮
⋮ ⋯ ⋯ ⋱ ⋱ ⋱ ⋯ ⋮
⋮ 𝑖 = 2 𝑡𝑜 𝑖𝑚𝑎𝑥 − 1
⋮ ⋯ ⋯ ⋯ ⋱ ⋱ ⋱ −
𝑟𝑥 ⋮ ⋮
2 1
𝑘 𝑘
𝑛+
𝑇𝑖𝑚𝑎𝑥2 ,𝑗 ℎ𝑇∞
0 ⋯ ⋯ ⋯ ⋯ 0 − +ℎ
Δ𝑥 Δ𝑥

(11)
Application and Setting up an Algorithm

Step 2 : For each “ i “ we can have TDM by varying j=2 to jmax.


Use equation (2) for interior points equations and (7) and (9) for boundary points.
For each i solve for all j through TDMA.
𝑛+1 𝑛+1
𝑇𝑖,2 − 𝑇𝑖,1
=0
Δ𝑦
TDMA j
system

𝑛+1 𝑛+1
𝑘 𝑇𝑖,𝑗𝑚𝑎𝑥 − 𝑇𝑖,𝑗𝑚𝑎𝑥 −1 𝑛+1
+ ℎ𝑇𝑖,𝑗𝑚𝑎𝑥 = ℎ𝑇∞
Δ𝑦 i
sweep

−1 1 0 ⋯ ⋯ ⋯ 0 0 𝑛+1 0

𝑟𝑦
1 + 𝑟𝑦 −
𝑟𝑦
0 ⋯ ⋯ ⋯ 0 𝑇𝑖,1 1 1 1 1
2 2 𝑛+ 𝑟𝑥 𝑛+ 𝑛+ 𝑛+
𝑟𝑦 𝑟𝑦 𝑛+1 𝑇𝑖,𝑗 2 + 𝑇𝑖+1,𝑗2 − 2𝑇𝑖,𝑗 2 + 𝑇𝑖+1,𝑗2
0 −
2
1 + 𝑟𝑦 −
2
⋯ ⋯ ⋯ ⋮ 𝑇𝑖,2 2
⋮ ⋱ ⋱ ⋱ ⋯ ⋯ ⋯ ⋮
⋮ ⋯ ⋱ ⋱ ⋱ ⋯ ⋯ ⋮ ⋮ = ⋮
⋮ ⋯ ⋯ ⋱ ⋱ ⋱ ⋯ ⋮ 𝑗 = 2 𝑡𝑜 𝑗𝑚𝑎𝑥 − 1
⋮ ⋯ ⋯ ⋯ ⋱ ⋱ ⋱ −
𝑟𝑦
2
⋮ ⋮
𝑛+1
0 ⋯ ⋯ ⋯ ⋯ 0 −
𝑘
Δ𝑦
𝑘
Δ𝑦
+ℎ 𝑇𝑖,𝑗𝑚𝑎𝑥 ℎ𝑇∞

(12)
Thomas Algorithm steps

The tridiagonal system

LU decomposition can be viewed as the matrix form of Gaussian elimination


Application and Setting up an Algorithm

Algorithm:

1. Initialize ∆x, ∆y, h, k, ∆t, Told [imax, jmax], Tnew [imax, jmax].
2. Apply initial condition Told [imax, jmax] = T0 for interior and boundary points.
3. Two stages of time stepping:
(a.) Sweep for each j (except for j = 1 and j = jmax)

Sweep initially in the y-direction for each j (all interior points), i.e. except for j = 1 and
j = jmax, call the Tri-diagonal subroutine.
Tri(a, b, c, d, rx), where the array variables namely a, b, c, d, rx are obtained from
equation (11).

𝑛
𝑟𝑦 𝑛 𝑛 𝑛
𝑐 1 = 0 , 𝑐 𝑖𝑚𝑎𝑥 = 𝑇∞ 𝑎𝑛𝑑 𝑐 𝑖 = 𝑇𝑖,𝑗 + 𝑇𝑖,𝑗 +1 − 2𝑇𝑖,𝑗 + 𝑇𝑖,𝑗 −1
2
𝑓𝑜𝑟 2 ≤ 𝑖 ≤ 𝑖𝑚𝑎𝑥 − 1

𝑎 1 = 1 , 𝑑 1 = −1 , 𝑏 1 = 0
𝑟𝑥 , 𝑟
𝑎 𝑖 =− 𝑑 𝑖 = 1 + 𝑟𝑥 , 𝑏 𝑖 = − 𝑥
2 2
Application and Setting up an Algorithm

We are calculating for each j, j = 2 to jmax - 1.

For, 2 ≤ 𝑖 ≤ 𝑖𝑚𝑎𝑥 − 1 j

𝑘 𝑘
𝑎 𝑖𝑚𝑎𝑥 = 0 , 𝑑 𝑖𝑚𝑎𝑥 = + ℎ , 𝑏 𝑖𝑚𝑎𝑥 = −
Δ𝑥 Δ𝑥 i

The Tri-diagonal system returns the x(i) array.


• Store the Tnew [i, j] = x(i).
• Apply B.C. for j = 1 and j = jmax from equations (3) and (5).
• Substitute Told [i, j] by Tnew [i, j].

(b.) Sweep for each i (except for i = 1 and i = imax)

Here the 2nd Tri-diagonal sweep has to be done. For all i except i=1
and i=imax, call the subroutine Tri(a, b, c, d, ry), where the array
variables namely a, b, c, d, ry takes the values from equation (12),
which again returns x(i).
• Update Tnew [i, j] = X(i).
• Apply B.C. for i = 1 and i = imax from equations (8) and (10).
Application and Setting up an Algorithm

4. If it is required to predict the temperature field at a specified time


level, then divide the total time duration by four/ five equal divisions
and each division is counted as the time step, ∆t. Use step 3 to
complete the calculation for each time step. Having calculated the
temperature field after each time step, initialize the temperature field
by the most recent value and progress. If the desired time level is
reached, go to step 6.

5. If you are required to reach the steady state temperature, then take a
time step that is reasonable and calculate the temperature field
iteratively using step 3. At the end of each time step, compare the
temperature values at each location between two time steps. Check
if the maximum discrepancy at any (i, j) location falls below a
specified small value, say ε, effectively, max(disi,j) < ε, then go to step
6. Else go to step 3 and repeat.

6. Stop.
Application and Setting up an Algorithm

Final Task:

Consider a chrome-steel block (z direction infinitely long)


with side walls of 8 cm. The α = 1.6 * 10-5 m2/s and
k = 61 W/mK. The block is initially at a uniform
temperature T0 = 100⁰C. It is suddenly exposed to a cool
stream at 25⁰C . The heat transfer coefficient between
the air and the surface is h = 400 W/m2K. By using a
(10 X 10) grid mesh, find the temperature distribution
after 60 seconds.
Application and Setting up an Algorithm

Pseudo Code1:

do i= 2,n
r = b (i)/ d (i-1)
d (i) = d (i) –r *a(i-1)
c(i) = c(i)-r* c (i-1)
end do

Pseudo code-2 Back Substitution:

x(n) = c(n)/ d (n)


do i = 2,n
j=n-i+1
x(j)=(c(j)-a(j)*c(j+1))/ d(j)
end do
Chapter 3

Introduction to Finite
Volume Method

3.1 The Basic Technique


In Chapter 2, the finite difference method was introduced. In the context of the
methods of weighted residuals, it can be said that the Finite Difference proce-
dure is a collocation method with piecewise definition of the field variable in the
neighbourhood of chosen grid points (or collocation points). In a similar fashion
the Finite Volume Method is a subdomain method with piecewise definition of
the field variable in the neighbourhood of chosen control volumes. The total
solution domain is divided into many small control volumes which are usually
rectangular (or arbitrary quadrilateral) in shape. Nodal points are used within
these control volumes for interpolating the field variable and usually, a single
node at the centre of the control volume is used for each control volume. This
method was developed by Patankar and Spalding (1972) and they proposed the
use of the physical approach (where possible) for deriving the nodal equations.
We shall illustrate the technique with the help of the 2-D heat conduction prob-
lem in rectangular geometry.

Consider 2-D, steady heat conduction in rectangular geometry (Figure 3.1).


The 2-D heat conduction equation is

k∇2 T + Q = 0 (3.1)

where T (x, y) is the temperature field, k is the thermal conductivity and Q is


the heat generation per unit volume.
At present we shall not consider any specific set of boundary conditions for
the problem, but we shall discuss the handling of various types of boundary
conditions in due course. The two alternative ways of setting up the nodal
equations are the weighted residual approach and the physical approach.

1
3.2 Computational Fluid Dynamics

Using the weighted residual approach, the 2-D heat conduction equation can be
approximately satisfied by:
 
Wi (k∇2 T + Q) dx dy = 0 (3.2)
Ω

where the weight

Typical
control Volume

Figure 3.1: Grid Arrangement for the Finite Volume Method.

Wi = 1 within the ith control volume.


Wi = 0 outside the ith control volume.
Thus, we get, for each i = 1, ...n
 
(k∇2 T + Q) dx dy = 0 (3.3)
Ωi

Integrating equation (3.3) by parts, we get:


 
(∇ · k∇T + Q) dx dy
Ωi
  
∂T
= k dl + Q dx dy = 0
ci ∂n Ωi

where the Gauss divergence theorem has been used to convert the volume inte-
gral to a surface integral.
  
∂T
Q dx dy = −k dl (3.4)
Ωi ci ∂n
 
The meaning of Eqn. (3.4) is that the net heat generation rate (= Q dx dy)
in the control volume is equal to the net sum of the rate of heat energy going out
Introduction to Finite Volume Method 3.3


∂T
of the control volume Ωi (= − k dl, where ci is the boundary of the con-
∂n
trol volume Ωi ). Equation (3.4) can be taken as an energy balance equation for
the ith control volume. This balance equation can also be obtained physically,
considering the balance of heat flux in Figure 3.2. For a typical node P with
neighbours E, N, W, S (standing for east, north, west and south etc.) and cor-
responding control volume boundaries in those directions denoted by e, n, w, s
etc., the heat balance for the control volume can be written as follows (for unit
depth in z-direction):
qe · Δy · 1 − qw · Δy · 1 + qn · Δx · 1 − qs · Δx · 1 = Q · 1 · Δx Δy
where qe is the heat flux (per unit area) on the east face, etc., and the faces
are taken to be one unit deep perpendicular to the plane of the figure. Thus,
qe · Δy · 1 is the total heat flux through the east face. The fluxes are taken to
be positive in the directions indicated by the arrows.

Physically, the above equation is equivalent to saying


Net rate of heat diffusing out the control volume through the boundary
= Rate of heat generation within the control volume (CV) at steady state
Thus, 
q · ds = QΔx Δy
 (3.5)
which is the same statement as equation (3.4). In the implementation of the
FVM procedure, the heat fluxes are expressed in terms of the nodal temper-
atures (TE , etc. at the CV centers) using piecewise interpolation around the
control volume for the field variable (temperature in this case). Thus, assuming
temperature to have linear variation between points E and P , the heat flux qe
can be evaluated as follows:

∂T  k {TE − TP }
qe = − k =− (3.6)
∂x e Δx
while deriving equation (3.6) it has been assumed that the cell size is, constant
in x-direction (equal to Δx). Similarly, qw is given by

∂T  k {TP − TW }
qw = − k  =− (3.7)
∂x w Δx
Using similar expressions for qn and qs also, the nodal equation for point P
becomes:
k Δy k Δy k Δx
+ {−TE + TP } + {TP − TW } + {TP − TN }
Δx Δx Δy
k Δx
+ {TP − TS } = Q Δx Δy (3.8)
Δy
This equation can be rewritten in the familiar form used in finite difference as:
  Q Δx2
TP 2 + 2β 2 − TE − TW − β 2 TN − β 2 TS = (3.9)
k
3.4 Computational Fluid Dynamics

Figure 3.2: Balance of Heat Flux in a Control Volume.

where,

Δx
β=
Δy

During numerical implementation, the subscripts E, W, etc. will be changed to


numerical indices of i, j and solved in the some way (using point-by-point or
line-by-line procedure etc.) as mentioned in Chapter-2.

The boundary conditions of a typical heat transfer problem can be handled


in the following way. When the heat flux at the boundary is prescribed, say
∂T
−k = q0 at x = 0, the corresponding heat flux term in the balance Equation
∂x
(3.5) is set equal to the applied heat flux. For instance, for the control volumes
adjacent to the x = 0 boundary as shown in Fig. 3.3, the term qw will be
Introduction to Finite Volume Method 3.5

q0

x=0

Figure 3.3: Prescribed Heat Flux at the Boundary.

substituted by q0 in equation (3.5). Thus,

qe Δy − (+q0 ) Δy + qn Δx − qs Δx
k {TE − TP } k {TN − TP }
= − Δy − q0 Δy − Δx
Δx Δy
k {TP − TS }
+ Δx = Q Δx Δy (3.10)
Δy

Equation (3.10) will be the nodal equation for such nodes.

When the boundary temperature is specified, the control volume shapes near
the boundary can be changed to facilitate the implementation of the boundary
conditions. For instance, consider the condition T = TL on the x = L boundary
(see Fig. 3.4). For the nodes on the boundary, an imaginary extension of the
control volumes outside the actual domain can be considered in line with the
finite difference methodology described earlier. The physical boundary is taken
to be at the center of ”boundary cells” of width Δx/2 (see Figure 3.4), while
3
the widths of the adjacent cells are thus reduced to Δx. Consider a typical
4
control volume i near the x = L boundary as shown in Fig. 3.4.

The boundary cells will need no nodal equation as the T = TL will be ap-
plied. The nodal equation for the adjacent cell P will be written considering a
3.6 Computational Fluid Dynamics

N i

E
W P

TL
S

x=L

Figure 3.4: Boundary Condition, at x = L, T = TL .

shortened control volume:

qe · Δy − qw · Δy + qn Δx1 − qs Δx1
(TL − TP ) (TP − TW ) (TN − TP )
= −k Δy + k Δy − k Δx1
(Δx/2) Δx Δy
(TP − TS )
+ k Δx1 = Q Δx1 Δy (3.11)
Δy
3
where Δx1 = Δx.
4
Note that TL has been substituted instead of TE in the above equation, so the
boundary condition is being directly applied. In this fashion, by adjusting the
control volume spacing and the placement of nodes, nodal equations can be
obtained at all nodes and these can be solved simultaneously by the matrix
inversion technique, line-by-line technique or point-by-point technique as dis-
cussed earlier. Having done the above exercise, we may like to look at a more
generalized description of the finite volume method.

3.2 A Generalized Approach


As it has been observed, the Finite Volume method uses an integral form of
the equations to be solved. The computational domain is divided into ele-
mentary volumes and the integration is performed within the these elementary
volumes. The method enables one to handle complex geometry without having
the equation written in curvilinear coordinates. The method also preserves the

You might also like