Module - 2 Updated On 29 July 2020-1 PDF
Module - 2 Updated On 29 July 2020-1 PDF
Process Engineering
• Gauss Jacobi
• Gauss Seidel
-10 -9 -8 - -6 -5 -4 -3 -2 -1 0 1 2 3 4 5 6 7 8 9 10
7 -1 x Convert to equations of the form
-2
-3 y = mx + c
-4
Rewrite the system as two smaller systems, each containing two of the three equations
x – 3y + 6z = 21 x – 3y + 6z = 21
3x + 2y – 5z = –30 2x – 5y + 2z = –6
Eliminate one variable (same variable., Let us take x) in each of the two smaller
systems
(x – 3y + 6z = 21) (-3) (x – 3y + 6z = 21) (-2)
3x + 2y – 5z = –30 2x – 5y + 2z = –6
z=5
y – 10(5) = –48
y – 50 = –48
y=2
Substitute the values of the variables in one of the original equations having three
variables
x – 3(2) + 6(5) = 21
x + 24 = 21
The solution is (–3, 2, 5)
x = –3
Unique Solution
Ill-conditioned systems
Dr. Monash Purushothaman CHE3001 Computational Methods in Process Engineering 8
Matrix Notations and Terminology
• Matrix: square matrix,
• Matrix addition
diagonal matrix
• Row vectors
• Matrix subtraction
• Column vectors
• Matrix multiplication
• Symmetric matric
• Determinant of Matrix
• Diagonal matrix
• Inverse of Matrix
• Identity matrix
• Augment of Matrix
c 5 7 8 0 9 0 0
[A]
4 [B] b1 b2 b3 0 1 3 7 [A] 5 7 0
c5
0
0 3 6
2 1 3
16 Oct 2012
Dr. Monash Purushothaman 10
CHE3001 Computational Methods in Process EngineeringKKEK1142 Numerical Methods for Engineering
10I
Simultaneous Linear Algebraic Equations
a11 x1 a12 x2 a13 x3 b1
a21 x1 a22 x2 a23 x3 b2
a31 x1 a32 x2 a33 x3 b3
Objective is to determine the values of x1 ,x2 and x3
x + y+z=2
Rank of a Matrix 4x+2y+z=4 Upper triangular matrix
x - y +z=4
1 1 1 2 1 1 1 2 1 1 1 2
R1 R1 0 2 3 4
4 2 1 4 R2-4R1 0 2 3 4 -R2
1 1 1 4 R3-R1 0 2 0 R3-R2 0 0 3 6
2
x 1 2 2 x 1
Hence the solution is x = 1, y = -1, z = 2.
x2 (b2' a 23
' '
x3 ) / a22 Back
Substitution
x1 (b1 a12 x2 a13 x3 ) / a11
• If a11 ≠ 0, define m21 = a21 / a11. We can replace (row 2) by {(row 2) – m21 x
(row 1)} to yield
' '
a22 a22 m21a12 a23 a23 m21a13 b2' b2 m21b1
a (1)
22 2x a (1)
23 3x a (1)
2n nx b (1)
2
2) (n 2) (n 2)
a (n x
n 1,n 1 n 1 a n 1,n nx b n 1
1) (n 1)
a (n
nn x n b n
we can start solving for x's in backward manner
n
b ( n 1) bi( i 1) j i 1 aij( i 1) x j
n
xn ( n 1)
xi ( i 1)
for i n 1,n 2 ,1
a nn a ii
Back Substitution
Q13C1
350 g/s Q33C3
Reactor 1 Reactor 3
Q32C3 Q43C4
Q21C2
Time, t (s) 5 8 12
Solve
10x1 + 7x2 + 8x3 + 7x4 = 32
7x1 + 5x2 + 6x3 + 5x4 = 23
8x1 + 6x2 + 10x3 + 9x4 = 33
7x1 + 5x2 + 9x3 + 10x4 = 31
for j=1, i=2, K=1 for j=1, i=2, K=2 for j=1, i=2, K=3
10.0000 7.0000 8.0000
7.0000 10.0000 7.0000 8.0000
7.0000 10.0000 7.0000 8.00007.0000
0 0.1000 6.0000 5.0000 0 0.1000 6.0000 5.0000 0 0.1000 0.4000 5.0000
8.0000 6.0000 10.0000 9.0000 8.0000 6.0000 10.0000 9.0000 8.0000 6.0000 10.0000 9.0000
7.0000 5.0000 9.0000 10.000 7.0000 5.0000 9.0000 10.000 7.0000 5.0000 9.0000 10.000
for j=2, i=4, K=2 for j=2, i=4, K=3 for j=2, i=4, K=4
10.0000 7.0000 8.0000 7.0000 10.0000 7.0000 8.0000 7.0000 10.0000 7.0000 8.0000 7.0000
0 0.1000 0.40000 0.1000 0 0.1000 0.40000 0. 10 00 0 0.1000 0.40000 0.1000
0 0 2.0000 3.0000 0 0 2.0000 3.0000 0 0 2.0000 3.0000
0 0 3.4000 5.1000 0 0 3.0000 5.1000 0 0 3.0000 5.0000
• Round-off error
– Round-off error propagates significantly when we
calculate the solution of a large number of equations.
• Ill-conditioned system
– When the determinant is close to zero
x1 x2 x3 1 x1 + x2 + x3 = 1
x1 x2 2 x3 2 x3 = 1 Note that a22 = 0,
x1 2 x2 2 x3 1 x2 + x3 = 0
By interchanging Row 2 and Row 3, we get
x1 + x2 + x3 = 1
This system is non-singular
Upper Triangular
and has a unique solution x2 + x3 = 0 Matrix
x1 x2 x3 1
x3 = 1
Dr. Monash Purushothaman CHE3001 Computational Methods in Process Engineering 31
Pivoting Strategies
• Avoid division by zero • Minimize the effect of rounding error
1 2 5 1 7 1 1 2 5 1 7 1
0 0 33 2 15 2 0 8 5 0 10 5
0 4 5 6 1 3 0 4 5 6 1 3
0 6 25 99 2 4 0 6 25 99 2 4
0 8 5 0 10 5 0 0 33 2 15 2
Complete Pivoting
1 2 99 1 7 1 1 1 99 2 7 1
0 0 33 2 15 2 0 88 25 6 2 4
0 4 5 6 1 3 0 6 5 4 1 3
0 6 25 88 2 4 0 2 33 0 15 2
0 8 5 0 10 5 0 0 5 8 10 5
x2 1.00
which can be solved by back substitution for
x1 0.00
0.00002 x1 x2 1 x1 x2 2
After pivoting
x1 x2 2 0.00002 x1 x2 1
for i = 1 to n
x(i)=a(i,n+1)/a(i,i);
end
Q13C1
350 g/s Q33C3
Reactor 1 Reactor 3
Q32C3 Q43C4
Q21C2
Now we divide the right hand side vector with the diagonal value, we will get the
Identity matrix, which provides the solution for the unknowns i.e. C1 , C2 , C3 and C 4 .
Time, t (s) 5 8 12
STEP 2
10 7 8 7 32
0 0.1 0.4 0.1 0.6
0 0 2 3 5
0 0 3 5 8
Note: (N-1) Steps are required to
STEP 3 achieve upper triangular matrix
10 7 8 7 32.000000
0 0.1 0.4 0.1 0.6
0 0 2 3 5
0 0 0 0.5 0.5
STEP 1
1 0.7 0.8 0.7 3.200000
0 0.1 0.4 0.1 0.600000
0 0.4 3.6 3.4 7.400000
0 0.1 3.4 5.1 8.600000
STEP 2
1 0 -2 0 -1.000000
0 1 4 1 6.000000
0 0 2 3 5.000000
0 0 3 5 8.000000
STEP 3
1 0 0 3 4.000000
0 1 0 -5 -4.000000
0 0 1 1.5 2.500000
0 0 0 0.5 0.500000
• Newton’s Method
Iterative Methods are appropriate, when
• the number of equations involved is large (typically of the
order of 100 or more)
• the matrix is sparse (less memory requirements)
Dr. Monash Purushothaman CHE3001 Computational Methods in Process Engineering 66
Sparse Matrix
For systems that have coefficient matrices with the
appropriate structure – especially large, sparse systems
(many coefficients whose value is zero) – iterative
techniques may be preferable
4 1 0 0 1 0 0 0 0 0 0 0 0 0 0 0 u1 0 . 08
1 u
4 1 0 0 1 0 0 0 0 0 0 0 0 0 0 2
0 . 16
0 1 4 1 0 0 1 0 0 0 0 0 0 0 0 0 u3 0 . 36
0 0 1 4 0 0 0 1 0 0 0 0 0 0 0 0 u4 1 . 64
1 0 0 0 4 1 0 0 1 0 0 0 0 0 0 0 u5 0 . 16
0 1 0 0 1 4 1 0 0 1 0 0 0 0 0 0 u6 0 .0
0 0 1 0 0 1 4 1 0 0 1 0 0 0 0 0 u 0 .0
7
0 0 0 1 0 0 1 4 0 0 0 1 0 0 0 0 u 1 .0
8
0 0 0 0 1 0 0 0 4 1 0 0 1 0 0 0 u9 0 . 36
0 0 0 0 0 1 0 0 1 4 1 0 0 1 0 0 u 10 0
0 0 0 0 0 0 1 0 0 1 4 1 0 0 1 0 u 11 0
0 0 0 0 0 0 0 1 0 0 1 4 0 0 0 1 u 1 .0
12
0 0 0 0 0 0 0 0 1 0 0 0 4 1 0 0 u 13 1 . 64
0 0 0 0 0 0 0 0 0 1 0 0 1 4 1 0 u 1 .0
14
0 0 0 0 0 0 0 0 0 0 1 0 0 1 4 1 u 15 1 .0
0 0 0 0 0 0 0 0 0 0 0 1 0 0 1 4 u 16 2 .0
• Stopping criteria?
n
bi aij x j
j 1
j i
General form for any row ‘i’ xi for i 1, 2,, n.
aii
o If you have “n” number of equations you have to guess “n” number of initial
guesses for the unknowns
Note
• It is not necessary all the unknowns have same initial guess values
• In general, the initial values of the initial guesses is assumed to be “0”
• If the Physical nature of the problem is known, one can assume initial guess
close to the approximate solution (to reduce the number of iterations)
x inew x iold
o Calculate the Absolute Relative Approximate Error a i
new
100
xi
o Stop the iteration, when the absolute relative approximate error is less than a
pre-specified tolerance for all unknowns
30 g/s
14 m3/s (c2) 17 m3/s (c3)
5 m3/s (c2)
200 g/s R3
R2 2 m3/s (c3)
R1
500 g/s 7 m3/s (c1)
Thank you