ES440/ES911: CFD Chapter 5. Solution of Linear Equation Systems Dr Yongmann M. Chung http://www.eng.warwick.ac.uk/staff/ymc/es440.html Y.M.Chung@warwick.ac.uk School of Engineering & Centre for Scientific Computing University of Warwick 1
Chapter 5 Solution of Linear Equation Systems 2
Algebraic Equation System for FVM u 0 2u 1 + u 2 = f 1, u 1 2u 2 + u 3 = f 2,. u i 1 2u i + u i+1 = f i,. u NX 2 2u NX 1 + u NX = f NX 1, u NX 1 2u NX + u NX+1 = f NX. Here, NX is the number of Control Volume and we have NX number of equations for u 1, u 2,... u i,..., u NX 1, u NX. u 0 and u NX+1 are boundary values. 3
Matrix Equations for 1D FDM The result of discretisation is a system of linear algebraic equations: 2 1 1 2 1 1 2 1 1 2 1 1 2 u 1 u 2 u i u NX 1 u NX = f 1 u 0 f 2 f i f NX 1 f NX u NX+1. 4
Matrix Equations - Cont d Algebraic Equation: Aφ = Q. (3.43 F&P ) 5
Matrix Equations - Cont d Algebraic Equation: Aφ = Q. (3.43 F&P ) A = 2 1 1 2 1 1 2 1 1 2 1 1 2, 5
Matrix Equations - Cont d Algebraic Equation: Aφ = Q. (3.43 F&P ) A = 2 1 1 2 1 1 2 1 1 2 1 1 2,Q = f 1 u 0 f 2 f i f NX 1 f NX u NX+1, 5
Matrix Equations - Cont d Algebraic Equation: Aφ = Q. (3.43 F&P ) A = 2 1 1 2 1 1 2 1 1 2 1 1 2,Q = f 1 u 0 f 2 f i f NX 1 f NX u NX+1, and φ = (u 1, u 2,..., u i,... u NX 1, u NX ) T. 5
Tri-Diagonal Matrix A = AX = B b 1 c 1 a 2 b 2 c 2 a 3 b 3 c 3 a NX 1 b NX 1 c NX 1,B = f 1 f 2 f 3 f NX 1, a NX X = (u 1, u 2, u 3, u NX 1, u NX ) T. b NX f NX 6
5.2.3 TDMA: Thomas Algorithm An upper triangular form of the tridiagonal matrix may be obtained by computing the new b i by b i = b i and the new f i by f i = f i a i b i 1 c i 1, a i b i 1 f i 1, i = 2,3,..., NX, i = 2,3,..., NX, then computing the unknowns from back substitution according to u NX = f NX /b NX and then u k = f k c k u k+1 b k, k = NX 1, NX 2,...,2,1. 7
One-Dimensional FDM Governing Equation: 1D Navier-Stokes Equation. 2 u y 2 = dp dx. (1) 8
One-Dimensional FDM Governing Equation: 1D Navier-Stokes Equation. 2 u y 2 = dp dx. (3) Second-Order Central Difference Method for u x : 2 u x 2 = u i+1 2u i + u i 1 x 2, 2 u y 2 = u j+1 2u j + u j 1 y 2. (3.30 FP ) 8
One-Dimensional FDM Governing Equation: 1D Navier-Stokes Equation. 2 u y 2 = dp dx. (5) Second-Order Central Difference Method for u x : Finite Difference Equation is: 2 u x 2 = u i+1 2u i + u i 1 x 2, 2 u y 2 = u j+1 2u j + u j 1 y 2. (3.30 FP ) u j+1 2u j + u j 1 y 2 = dp dx. (6) 8
One-Dimensional FDM Finite Difference Equation is: u j+1 2u j + u j 1 y 2 = dp dx. (7) 9
One-Dimensional FDM Finite Difference Equation is: u j+1 2u j + u j 1 y 2 = dp dx. (10) Rearranging gives or 1 y 2u j 1 2 y 2u j + 1 y 2u j+1 = dp dx, (11) u j 1 2u j + u j+1 = dp dx y2. (12) 9
One-Dimensional FDM Finite Difference Equation is: u j+1 2u j + u j 1 y 2 = dp dx. (13) Rearranging gives or Let s f j = dp dx y2. 1 y 2u j 1 2 y 2u j + 1 y 2u j+1 = dp dx, (14) u j 1 2u j + u j+1 = dp dx y2. (15) 9
One-Dimensional FDM 2 u x 2 = dp dx. Divide the computational domain into NX steps (control volumes). x 1 2 i i+1 NX NX+1 u j 1 2u j + u j+1 = f j. 10
One-Dimensional FDM 2 u x 2 = dp dx. Divide the computational domain into NX steps (control volumes). Apply the FDE to the interior points x 1 2 i i+1 NX NX+1 x 2, x 3,..., x i,..., x N. x 1 & x N+1 are boundary points. u j 1 2u j + u j+1 = f j. 10
One-Dimensional FDM 2 u x 2 = dp dx. Divide the computational domain into NX steps (control volumes). Apply the FDE to the interior points x 1 2 i i+1 NX NX+1 x 2, x 3,..., x i,..., x N. x 1 & x N+1 are boundary points. Domain size L = 2, N = 4 & x = 0.5 u j 1 2u j + u j+1 = f j. x 1, x 2, x 3, x 4, x 5. x 1 & x 5 are boundary. 10
Algebraic Equation System Finite Difference Equation is: u j 1 2u j + u j+1 = dp dx y2. With x = 0.5 & dp dx = 2: 11
Algebraic Equation System Finite Difference Equation is: With x = 0.5 & dp dx = 2: f j = dp dx y2 = 0.5 u j 1 2u j + u j+1 = dp dx y2. u 1 2u 2 + u 3 = 0.5, u 2 2u 3 + u 4 = 0.5, u 3 2u 4 + u 5 = 0.5. Here, N = 4 is the number of x and we have 3 number of equations for u 2, u 3 & u 4. 11
Algebraic Equation System Finite Difference Equation is: 1 y 2u j 1 2 y 2u j + 1 y 2u j+1 = dp dx, With x = 0.5 & dp dx = 2: 12
Algebraic Equation System Finite Difference Equation is: 1 y 2u j 1 2 y 2u j + 1 y 2u j+1 = dp dx, With x = 0.5 & dp dx = 2: 1 y 2 = 4 4u 1 8u 2 + 4u 3 = 2, 4u 2 8u 3 + 4u 4 = 2, 4u 3 8u 4 + 4u 5 = 2. u 1 and u 5 are boundary values. 12
Matrix Equations for 1D FDM The result of discretisation is a system of linear algebraic equations: 2 1 1 2 1 1 2 u 2 u 3 u 4 0.5 u 1 = 0.5. 0.5 u 5 13
Matrix Equations for 1D FDM The result of discretisation is a system of linear algebraic equations: 2 1 1 2 1 1 2 u 2 u 3 u 4 0.5 u 1 = 0.5. 0.5 u 5 At walls, due to no-slip boundary condition, u 1 = 0 & u 5 = 0. 2 1 u 2 0.5 1 2 1 u 3 = 0.5. 1 2 0.5 u 4 13
Matrix Equations for 1D FDM Finite Difference Equation is: u j 1 2u j + u j+1 = dp dx y2. 14
Matrix Equations for 1D FDM Finite Difference Equation is: u j 1 2u j + u j+1 = dp dx y2. The result of discretisation is a system of linear algebraic equations: 2 1 1 2 1 1 2 u 2 u 3 u 4 = 0.5 0.5 0.5. 14
Matrix Equations for 1D FDM Finite Difference Equation is: 1 y 2u j 1 2 y 2u j + 1 y 2u j+1 = dp dx, 15
Matrix Equations for 1D FDM Finite Difference Equation is: 1 y 2u j 1 2 y 2u j + 1 y 2u j+1 = dp dx, The result of discretisation is a system of linear algebraic equations: 8 4 4 8 4 4 8 u 2 u 3 u 4 = 2 2 2. 15
1D FDM Solution 1 y/h 0 N=4 N=10 N=50 N=100-1 0 0.5 1 1.5 U/U m 16
Two-Dimensional FDM Divide the computational domain into NX steps in x direction, y NY steps in y direction. y x x 17
Two-Dimensional FDM Divide the computational domain into NX steps in x direction, y NY steps in y direction. y NX NY control volumes. x x 17
Two-Dimensional FDM Divide the computational domain into NX steps in x direction, y NY steps in y direction. y NX NY control volumes. x x Resulting Finite Difference Equations (FDE) are u i+1,j 2u i,j + u i 1,j x 2 + u i,j+1 2u i,j + u i,j 1 y 2 = f i,j. 17
Two-Dimensional FDM 2D Finite Difference Equations are 1 x 2u i+1,j 2 x 2u i,j + 1 x 2u i 1,j + 1 y 2u i,j+1 2 y 2u i,j + 1 y 2u i,j 1 = f i,j, 1 x 2u i+1,j + 1 x 2u i 1,j + 1 y 2u i,j+1 + 1 y 2u i,j 1 1 2( x 2 + 1 y 2)u i,j = f i,j, 18
Two-Dimensional FDM 2D Finite Difference Equations are 1 x 2u i+1,j 2 x 2u i,j + 1 x 2u i 1,j + 1 y 2u i,j+1 2 y 2u i,j + 1 y 2u i,j 1 = f i,j, 1 x 2u i+1,j + 1 x 2u i 1,j + 1 y 2u i,j+1 + 1 y 2u i,j 1 1 2( x 2 + 1 y 2)u i,j = f i,j, Rearrange the equation using α = 1 x 2 & β = 1 y 2 αu i 1,j + αu i+1,j + βu i,j 1 + βu i,j+1 2(α + β)u i,j = f i,j. 18
Matrix Equations for 2D FDM The result of discretisation is a system of linear algebraic equations: A P φ P + l A l φ l = Q P. (3.42 F&P ) 19
Solution to 1D Matrix Equations The result of discretisation is a system of linear algebraic equations: A P φ P = Q P l A l φ l. 20
Solution to 1D Matrix Equations The result of discretisation is a system of linear algebraic equations: A P φ P = Q P l A l φ l. 1D FDM au i 1 + bu i }{{} +cu i+1 = f i. bu i = f i (au i 1 + cu i+1 ), u i = f i (au i 1 + cu i+1 ). b 20
Solution to 2D Matrix Equations The result of discretisation is a system of linear algebraic equations: A P φ P = Q P l A l φ l. 21
Solution to 2D Matrix Equations The result of discretisation is a system of linear algebraic equations: A P φ P = Q P l A l φ l. 2D FDM αu i 1,j + αu i+1,j + βu i,j 1 + βu i,j+1 2(α + β) u i,j }{{} = f i,j. 2(α + β)u i,j = αu i 1,j + αu i+1,j + βu i,j 1 + βu i,j+1 f i,j, u i,j = αu i 1,j + αu i+1,j + βu i,j 1 + βu i,j+1 f i,j 2(α + β). 21
Solution to 2D Matrix Equations 1D FDM in the x-direction αu i 1,j + αu i+1,j + βu i,j 1 + βu i,j+1 2(α + β)u i,j = f i,j. }{{} OLD αu i 1,j 2(α + β)u i,j + αu i+1,j = f i,j βu i,j 1 + βu i,j+1. }{{} OLD 22
Solution to 2D Matrix Equations 1D FDM in the x-direction αu i 1,j + αu i+1,j + βu i,j 1 + βu i,j+1 2(α + β)u i,j = f i,j. }{{} OLD αu i 1,j 2(α + β)u i,j + αu i+1,j = f i,j βu i,j 1 + βu i,j+1. }{{} OLD 1D FDM in the y-direction αu i 1,j + αu i+1,j +βu i,j 1 + βu i,j+1 2(α + β)u i,j = f i,j. }{{} OLD βu i,j 1 2(α + β)u i,j + βu i,j+1 = f i,j αu i 1,j + αu i+1,j. }{{} OLD 22
Solution to 2D Matrix Equations 2D Finite Difference Equations are αu i+1,j + αu i 1,j + βu i,j+1 + βu i,j 1 2(α + β)u i,j = f i,j. 23
Solution to 2D Matrix Equations 2D Finite Difference Equations are αu i+1,j + αu i 1,j + βu i,j+1 + βu i,j 1 2(α + β)u i,j = f i,j. No direct solver - Iterative solver. 23
Solution to 2D Matrix Equations 2D Finite Difference Equations are αu i+1,j + αu i 1,j + βu i,j+1 + βu i,j 1 2(α + β)u i,j = f i,j. No direct solver - Iterative solver. Using Tri-Diagonal Matrix Algorithm in each direction. αu i+1,j + αu i 1,j 2 (α + β)u i,j = f i,j βu i,j+1 βu i,j 1, βu i,j+1 + βu i,j 1 2 (α + β)u i,j = f i,j αu i+1,j αu i 1,j. Repeat until solution converges. 23
Solution to 2D Matrix Equations 2D Finite Difference Equations are αu i+1,j + αu i 1,j + βu i,j+1 + βu i,j 1 2(α + β)u i,j = f i,j. No direct solver - Iterative solver. Using Tri-Diagonal Matrix Algorithm in each direction. αu i+1,j + αu i 1,j 2 (α + β)u i,j = f i,j βu i,j+1 βu i,j 1, βu i,j+1 + βu i,j 1 2 (α + β)u i,j = f i,j αu i+1,j αu i 1,j. Repeat until solution converges. More details on Martix Computation. 23
2D FDM Solution 1 y/h 0 ITER=1 ITER=2 ITER=3 ITER=4 ITER=5 ITER=10 ITER=15 ITER=100-1 0 0.2 0.4 0.6 0.8 1 U/U max 24
Convergency U(y=0) 1 N=4 N=8 N=16 0.8 N=32 N=64 N=128 0.6 N=256 0.4 0.2 0 0 20 40 60 80 100 iteration number 25
Convergency - Cont d U(y=0) 1 N=4 N=8 N=16 0.8 N=32 N=64 N=128 0.6 N=256 0.4 0.2 0 10 0 10 1 10 2 10 3 10 4 iteration number 26
Convergency - Cont d 0.1 0.08 0.06 error 0.04 0.02 N=4 N=8 N=16 N=32 N=64 N=128 N=256 0 0 20 40 60 80 100 iteration number 27
Convergency - Cont d 10 0 10-2 10-4 error 10-6 10-8 10-10 10-12 N=4 N=8 N=16 N=32 N=64 N=128 N=256 10-14 0 1000 2000 3000 4000 5000 iteration number 28