Week4 LectureNotes
Week4 LectureNotes
Problem
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
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
𝑟𝑥 𝑛+12 1
𝑛+2 𝑟𝑥 𝑛+12 𝑛
𝑟𝑦 𝑛
− 𝑇𝑖−1,𝑗 + 1 + 𝑟𝑥 𝑇𝑖,𝑗 − 𝑇𝑖+1,𝑗 = 𝑇𝑖,𝑗 + 𝑇𝑖,𝑗 +1 − 2𝑇𝑖,𝑗𝑛 + 𝑇𝑖,𝑗
𝑛
−1 (1)
2 2 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
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
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
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
𝑛+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
𝑛+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
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
For, 2 ≤ 𝑖 ≤ 𝑖𝑚𝑎𝑥 − 1 j
𝑘 𝑘
𝑎 𝑖𝑚𝑎𝑥 = 0 , 𝑑 𝑖𝑚𝑎𝑥 = + ℎ , 𝑏 𝑖𝑚𝑎𝑥 = −
Δ𝑥 Δ𝑥 i
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
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:
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
Introduction to Finite
Volume Method
k∇2 T + Q = 0 (3.1)
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)
Ω
Typical
control Volume
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.
where,
Δx
β=
Δy
q0
x=0
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
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
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.