Solution of Linear Algebraic Equations: These Equations Could Also Be Written As
Solution of Linear Algebraic Equations: These Equations Could Also Be Written As
𝒂𝑷 𝑻𝑷 = 𝒂𝑬 𝑻𝑬 + 𝒂𝑾 𝑻𝑾 + 𝒃
These equations could also be written as
𝐴 𝑇 = 𝐷
where
[A]: Coefficient matrix
[T]: Unknown matrix
[D]: Constant matrix
i=1 2 3 4 5 6
w e i
A B
W i P E
i-1 i+1 (Dx)B
Dx
𝑎1 − 𝑏1
0 0 0 0 0 𝑇1 𝑑1
−𝑐2 𝑎2
−𝑏2 0 0 0 0 𝑇2 𝑑2
0 −𝑐3𝑎3 −𝑏2 0 0 0 𝑇3 𝑑3
……… … …
………… ….. = …..
………….. … …
………… …. ….
0 0 0 0 −𝑐𝑁−1 𝑎𝑁−1 −𝑏𝑁−1 𝑇𝑁−1 𝑑𝑁−1
0 0 0 0 0 −𝑐𝑁 𝑎𝑁 𝑇𝑁 𝑑𝑁
NOTE:
1) Number of equations is the same as the number of grid points.
2) Grids 1 and N are boundary grids.
3) In equations for boundary grids, there two unknowns.
4) In equations for inner grids, there are three unknowns.
5) Coefficient matrix is a tri-diagonal matrix, i.e., only three entries around
the diagonal are non-zero, all other entries are zero.
There are two families of solution methods for linear algebraic equations:
The number of operations for the solution of the system of N equations with N
unknowns is finite and it is known beforehand. Examples for direct solution methods
are
- Cramer’s rule
- Matrix inversion method
- Gaussian elimination method
- Gauss –Jordan Elimination method (Tri-Diagonal Matrix Algorithm, TDMA)
Iterative Methods
Jacobi and Gauss-Seidel iterative methods are easy to implement in simple computer
programs, but they can be slow to converge when the system of equations is large.
Hence, they are not considered suitable for general CFD procedure.
i=1 2 3 4 5 i=N=6
w e i
A B
W i P E
i-1 i+1
Consider a system of equations obtained for N grids given above.
𝑎1 − 𝑏1 0 0 0 0 0 𝑇1 𝑑1
−𝑐2 𝑎2 −𝑏2 0 0 0 0 𝑇2 𝑑2
0 −𝑐3 𝑎3 −𝑏2 0 0 0 𝑇3 𝑑3
……… … …
………… ….. = …..
………….. … …
………… …. ….
0 0 0 0 −𝑐𝑁−1 𝑎𝑁−1 −𝑏𝑁−1 𝑇𝑁−1 𝑑𝑁−1
0 0 0 0 0 −𝑐𝑁 𝑎𝑁 𝑇𝑁 𝑑𝑁
Using TDMA, solution of the above set of equations are obtained in two operations:
1. Forward elimination
Starting from equation i=2, unknown Ti is solved in terms of Ti+1 and substituted into
equation i+1. As a result, one unknown is eliminated from each equation for i = 2, 3,
….. N.
2. Backward substitution
As a result of the forward elimination, one of the unknowns from each equation is
eliminated. Since there were only two unknowns in the last equation, after forward
elimination, only one unknown, TN remains . Then, TN is solved from the last equation,
then by back substitution, all other unknowns TN-1, TN-2, ……… T1 are solved.
𝒃𝟏 𝒅𝟏
For i = 1, c1 = 0 hence, 𝑷𝟏 = 𝑸𝟏 = (6)
𝒂𝟏
𝒂𝟏
𝒅𝑵 +𝒄𝑵 𝑸𝑵−𝟏
For i = N, bN = 0 hence, 𝑷𝑵 = 𝟎 𝑸𝑵 = and TN = QN (7)
𝒂𝑵 −𝒄𝑵 𝑷𝑵−𝟏
Backward Substitution
In the backward substitution, starting from i = N-1, using Eq. (2), we solve TN-1, TN-2,
TN-3, ……….. T2 and T1.
1) From Eq. (6), P1 and Q1 are calculated for i = 1 (left boundary node)
𝒃𝟏 𝒅𝟏
For i = 1, c1 = 0 hence, 𝑷𝟏 = 𝑸𝟏 = (6)
𝒂𝟏
𝒂𝟏
1) From Eq. (5), Pi and Qi are calculated for i = 2, 3, ….. N-1 (For inner nodes)
𝒃𝒊 𝒅𝒊 +𝒄𝒊 𝑸𝒊−𝟏
𝑷𝒊 = 𝑸𝒊 = (5)
𝒂𝒊 − 𝒄𝒊 𝑷𝒊−𝟏 𝒂𝒊 −𝒄𝒊 𝑷𝒊−𝟏
2) From Eq. (7), PN and QN are calculated for i = N and TN=QN is obtained (right
boundary)
𝒅𝑵 +𝒄𝑵 𝑸𝑵−𝟏
For i = N, bN = 0 hence, 𝑷𝑵 = 𝟎 𝑸𝑵 = and TN = QN (7)
𝒂𝑵 −𝒄𝑵 𝑷𝑵−𝟏
3) From Eq. (2), starting from i=N-1, TN-1, TN-2, ……. T2 and T1 are calculated.
Ti = PiTi+1 + Qi (2)
i=1 2 3 4 5 i=N=6
w e i
A B
W i P E
i-1 i+1
A
TA=200 B
x
Step 1: Mathematical formulation
𝑑 𝑑𝑇
Basic equation: 𝑘 =0
𝑑𝑥 𝑑𝑥
Boundary conditions: At x=0, T=TA=200 oC and at x=L, -kdt/dx=qB
Equally spaced 4 grid points (except the boundary points) are considered as the
computational mesh, as below.
(dx)
i=1 2 3 4 5 6
w e i
A B
W i P E
i-1 i+1 (Dx)B
Dx
Step 3: Discretization
1 0 0 0 0 0 𝑇1 200
−1 2 − 1 0 0 0 𝑇2 0
NOTE: Both
0 −1 2 −1 0 0 𝑇3 0 sides of
0 0 −1 2 −1 0 𝑇4 0 equations for
0 0 0 −1 2 −1 𝑇5 = 0 inner nodes
… … divided by
…. …. 1000.
0 0 0 0 −1 1 𝑇6 −0.100
Step 4: Solution of algebraic equations: Solve the algebraic equations using TDMA
𝒃𝟏 𝟎 𝒅𝟏 𝟐𝟎𝟎
For i = 1, c1 = 0 hence, 𝑷𝟏 = = =𝟎 𝑸𝟏 =
𝒂𝟏
= 𝟏 =200 (6)
𝒂𝟏 𝟏
𝑏2 1 1
For i=2 𝑃2 = = =
𝑎2 −𝑐2 𝑃2−1 2−(1)(0) 2
𝑏4 1
For i=4 𝑃4 = = = 0.8
𝑎4 −𝑐4 𝑃4−1 2−(1)(0.75)
𝑏5 1
For i = 5 𝑃5 = = = 0.833
𝑎5 −𝑐5 𝑃5−1 2−(1)(0.8)
T5 =P5T6+Q5= 191.66
T4 =P4T5+Q4= 193.33
T3 = 195
T2 = 196.66
T1 = 200 oC (BC)
1) An initial value is assumed for all unknows at all grid points. (Generally, initial
values are assumed as zero.)
2) From each equation, one unknown which has the highest coefficient is solved
using the values for other variables from the previous iteration (or the initial
values).
3) Repeat (iterate) the calculations using the updated values of the unknowns.
4) When the difference between the values of all unknowns in two subsequent
iterations is smaller than the convergence criteria assumed, iteration is
terminated.
Example:
4x1 – x2 + x3 = 4
x1 + 6x2 + x3 = 4 x1 = ?, x2 = ?, x3 = ?
- x1 + 2x2 + 5x3 = 4
Step 1: Assume initial values as zero for all unknowns.
Iteration 2:
1 1 1
𝑥1 = 4 + 1.33 − 0.73 = 1.15 𝑥2 = 6 9 − 1.15 − 0.73 = 1.19 𝑥3 = 5 4 + 1.15 − 1.19 = 0.79
4
Step 4: Check the convergence: Calculate the difference between values obtained in
two following iterations and compare them with the convergence criteria e chosen.
1) Consider 1-dimensional steady heat conduction in a rod. Total length of the rod
is 3 units. Everywhere in the rod thermal conductivity is k=1 and there is a heat
generation of S=2. At left end of the rod (at x=0) T=1 and at the right end of the
rod (at x=3), dT/dx =5 are given as the boundary conditions.
a) Consider grid points are located at x=0, 1, 2 and 3, derive the discretization
equations using both finite difference and control volume approaches.
b) Solve the discretization equation sets using both TDMA and Gauss-Seidel
iteration methods. (NOTE: Do not use a program.)
c) Compare the numerically obtained results with the analytical solution and
interpret.
2. Consider 1-dimensional steady heat conduction in a rod. Total length of the rod is
1 unit. Everywhere in the rod thermal conductivity is k=1 and there is a heat
generation of S=2. At left end of the rod (x=0) T=0 and at the right end of the rod
(x=1), dT/dx =1 are given as the boundary conditions. Using control volume
approach, derive the discretization equations considering 3, 5, 15 and 20 equal
control volumes. Solve the set of algebraic equations for all four grid systems and
compare the results with each other and with analytical solution. Show the results
on a graph and analyze the results and interpret the effect of the grid size on the
numerical results.