Sie sind auf Seite 1von 79

CHE3001 Computational Methods in

Process Engineering

Instructor: Dr. P. Monash


School of Chemical Engineering (SCHEME)
VIT Vellore
Date: 24 July 2020
Solution of simultaneous linear equations
Direct or non-iterative methods
• Gauss elimination
• Gauss Jordan

Indirect or iterative methods

• Gauss Jacobi
• Gauss Seidel

Dr. Monash Purushothaman CHE3001 Computational Methods in Process Engineering 2


Direct method
• Finds a solution in a finite number of operations by
transforming the system into an equivalent system that is
‘easier’ to solve
• Diagonal, upper or lower triangular systems are easier to
solve
• These direct techniques are useful when the number of
equations involved is not too large (typically of the order of
40 or fewer equations)
• Examples of direct methods: Gauss Elimination, Gauss-
Jordan Elimination and LU Decomposition

Dr. Monash Purushothaman CHE3001 Computational Methods in Process Engineering 3


Indirect method
• These iterative methods are more appropriate when the
number of equations involved is large (typically of the order of
100 or more), or when the matrix is sparse
• They are more economical in memory requirements
• Total number of operations is uncertain, may not converge
• Examples of iterative methods: Gauss-Jacobi method and
Gauss-Seidel iterative methods

Dr. Monash Purushothaman CHE3001 Computational Methods in Process Engineering 4


Solution of simultaneous equations
10 Solutions Graphical method
9
x = 7, y = 6
8 Example 1
7
6
y 5 2x – y = 8  y = 2x - 8
4
3 x–y=1  y=x-1
2
1

-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

-5 The co-ordinates of the point of


-6
intersection of each line give
-7
the solutions to the equations
-8
-9
-10

Dr. Monash Purushothaman CHE3001 Computational Methods in Process Engineering 5


Example- solution of simultaneous equations for three
variables
Use elimination to solve the following system of equations
x – 3y + 6z = 21
3x + 2y – 5z = –30
2x – 5y + 2z = –6

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

–3x + 9y – 18z = –63 –2x + 6y – 12z = –42


3x + 2y – 5z = –30 2x – 5y + 2z = –6
11y – 23z = –93 y – 10z = –48

Dr. Monash Purushothaman CHE3001 Computational Methods in Process Engineering 6


Write the resulting equations in two variables together as a system of equations
11y – 23z = –93
y – 10z = –48 (-11)

11y – 23z = –93


–11y +110z = 528
87z = 435

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

Dr. Monash Purushothaman CHE3001 Computational Methods in Process Engineering 7


Graphical method – used for visualizing properties
of solution

No Solution Infinite Solution

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

• Upper triangular matrix


• Transpose of matrix

• Lower triangular matrix


• Bounded matrix (Tridiagonal
matrix)
Dr. Monash Purushothaman CHE3001 Computational Methods in Process Engineering 9
Matrix Notation
Square matrix i = j or m=n Special type of square Matrices

 a11 a12  a1n  Symmetric matrix aij = aji Identity matrix


aij = aji
a a  a  9 5 2
 21 22 2n    1 0 0 
[A]  [A]   5 7 1   
       2 1 3 [A]   0 1 0 
     0 0 1
 a n1 an 2  ann 
 
Diagonal matrix
Upper triangular matrix
Column Vectors 9 0 0 9 5 2
c1  Element of a Matrix    
[A]   0 7 0  [A]   0 7 1 
  aij or amn  0 0 3  0 0 3
c
 2 
   
Banded matrix
C  c3  Row Vectors 9

2 0 0

Lower triangular 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

The system of equations f (x)  0 can be expressed as f ( x )  Ax  b  0

where,  a11 a12  a1n   x1   b1 


a a  a  x  b 
 21 22 2n   2  2
b 
[A]  x 
       
  bn 
 a n1 an 2  ann   xn 
1 1
The objective is to find the inverse of Matrix A, i.e. A-1 x  [A] b  X=
A
(adjA)B

Dr. Monash Purushothaman CHE3001 Computational Methods in Process Engineering 11


Inverse of a Matrix/Rank of a Matrix

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   

From row 3 we get 3 z  6  z  2 Substituting this into row 2,

2y  6  4  y  1 Substituting this into row 1,

x  1 2  2  x  1
Hence the solution is x = 1, y = -1, z = 2.

Dr. Monash Purushothaman CHE3001 Computational Methods in Process Engineering 12


Gauss Elimination
Linear systems of equations - matrix is triangular are particularly easy to solve

a11 x1  a12 x2  a13 x3    a1n xn  b1  a11 a12 a13 b1 


 
a22 x2  a23 x3    a2 n xn  b2  a21 a22 a 23 b2 
a33 x3    a3 n xn  b3  a31 a32 a33 b3 
Forward
    Elimination
amn xn  bn  a11 a12 a13 b1 
 ' ' 
Step 1  a 22 a 23 b2' 
"
Forward Elimination –  a33 b3" 
To transform the set of equations to
an upper triangular system.

x3  b3" / a33
"

x2  (b2'  a 23
' '
x3 ) / a22 Back
Substitution
x1  (b1  a12 x2  a13 x3 ) / a11

Dr. Monash Purushothaman CHE3001 Computational Methods in Process Engineering 13


Naive Gauss Elimination step by step procedure
o It is called "Naïve" Gauss Elimination because it does not avoid the problem of
division by zero

Forward Elimination: Purpose: to reduce the set of equations to an upper triangular


system

a11 x1  a12 x2  a13 x3  b1 a11 x1  a12 x2  a13 x3  b1


' '
a21 x1  a22 x2  a23 x3  b2  a 22 x2  a 23 x3  b2'
"
a31 x1  a32 x2  a33 x3  b3 a33 x3  b3"
Step 1: Remove x1 from all equations except the first equation (which serves as
the pivot equation.)
a11 x1  a12 x2  a13 x3  b1 a11 x1  a12 x2  a13 x3  b1
' '
a21 x1  a22 x2  a23 x3  b2  a 22 x2  a23 x3  b2'
' '
a31 x1  a32 x2  a33 x3  b3 a32 x2  a33 x3  b3'
Dr. Monash Purushothaman CHE3001 Computational Methods in Process Engineering 14
Naive Gauss Elimination contd…
o Let's focus on removing x1 from (row 2) first
a11 x1  a12 x2  a13 x3  b1 ( row 1)
a21 x1  a22 x2  a23 x3  b2 ( row 2)
a31 x1  a32 x2  a33 x3  b3 ( row 3)

• If a11 ≠ 0, define m21 = a21 / a11. We can replace (row 2) by {(row 2) – m21 x
(row 1)} to yield

( a 21 x1  a 22 x2  a 23 x3 )  m21 ( a11 x1  a12 x2  a13 x3 )  b2  m21b1


 0  x1  ( a22  m21a12 ) x2  ( a 23  m21a13 ) x3  b2  m21b1
Put

' '
a22  a22  m21a12 a23  a23  m21a13 b2'  b2  m21b1

Dr. Monash Purushothaman CHE3001 Computational Methods in Process Engineering 15


Naive Gauss Elimination contd…
We have a11 x1  a12 x2  a13 x3  b1 ( row 1)
' '
a22 x2  a23 x3  b2' ( row 2' )
(row 3') can be obtained in the similar fashion

a11 x1  a12 x2  a13 x3  b1 ( row 1)


' '
After step 1, we have a22 x2  a23 x3  b2' ( row 2' )
' '
a32 x2  a33 x3  b3' ( row 3' )
Step 2: Remove x2 from all equations except the first two equations (row 1) and
(row 2'). That is

a11 x1  a12 x2  a13 x3  b1 a11 x1  a12 x2  a13 x3  b1


' '
a 22 x2  a23 x3  b2'  '
a 22 '
x2  a23 x3  b2'
' '
a32 x2  a33 x3  b3' "
a33 x3  b3"
Basically repeat step 1 on the subsystem

Dr. Monash Purushothaman CHE3001 Computational Methods in Process Engineering 16


Naive Gauss Elimination contd…
After reducing the system of equations into an upper triangular system,
(0) (0) (0) (0)
a11 x1  a12 x 2  a13 x 3    a1n x n  b1(0)

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

Dr. Monash Purushothaman CHE3001 Computational Methods in Process Engineering 17


Case study
Four reactor tanks are connected by pipes as shown in Figure. At steady
state, establish the material balance equation and solve for the
concentrations of the fluid at each tank using Gauss Elimination method.

Q13C1
350 g/s Q33C3
Reactor 1 Reactor 3

Q32C3 Q43C4
Q21C2

Q24C2 150 g/s


Reactor 2 Reactor 4

Volumetric flow rate data is given in the following Table.


Q13 = 75 L/s Q21 = 25 L/s Q24 =20 L/s
Q32 = 45 L/s Q33 = 60 L/s Q43 = 30 L/s
Dr. Monash Purushothaman CHE3001 Computational Methods in Process Engineering 18
solution
Material Balance for Reactor 1: Material Balance for Reactor 2:
350 + Q 21C2 = Q 13C1 Q 32C3 = Q 21C2 + Q 24 C2
75C1 - 25C2 = 350 -------> eq (1) 45C3 = 25C2 + 20C2
45C2 - 45C3 = 0 -------> eq (2)

Material Balance for Reactor 3: Material Balance for Reactor 4:


Q 13C1 + Q 43C 4 = Q 33C3 + Q 32C3 150 + Q 24 C2 = Q 43C 4
75C1 + 30C 4 = 60C3 + 45C3 150 + 20C2 = 30C4
75C1 - 105C3 + 30C 4 = 0 -------> eq (3) 20C2 - 30C3 = -150 -------> eq (4)

75 25 0 0   C1   350 


So we can write the above  0 45 45 0  C2   0 
equation in matrix form as      
75 0 105 30  C3   0 
    
 0 20 0 30  C 4  150 
Dr. Monash Purushothaman CHE3001 Computational Methods in Process Engineering 19
Forward elimination Step 1:
Applying back substitution step:
75 25 0 0 350 
 0 45 45 C4   237.5 / 22.5  10.5555 g / L.
0 0 
  C3 =  -350 -(30  10.5555) /-80 = 8.3333 g/L.
 0 25 105 30 350 
  C2 = 8.3333 g/L.
 0 20 0  30  1 50  C1 = 350 - (-25  8.3333) /75 = 7.4444 g/L.
Forward elimination Step 2:
75 25 0 0 350 
 0 45 45 0 0 
 
0 0 80 30 350  Therefore the concentration of the fluid in
  each reactor is:
 0 0 20  30  1 50 
Concentation in reactor 1 is 7.4444 g/L.
Forward elimination Step 3:
Concentation in reactor 2 is 8.3333 g/L.
75 25 0 0 350  Concentation in reactor 3 is 8.3333 g/L.
 0 45 45 0 0 
  Concentation in reactor 4 is 10.5555 g / L.
0 0 80 30 350 
 
 0 0 0  22.5  237 .5 
Dr. Monash Purushothaman CHE3001 Computational Methods in Process Engineering 20
Case Study
The upward velocity of a rocket is given at three different
times in the following table

Time, t (s) 5 8 12

Velocity, v (m/s) 106.8 177.2 279.2

The velocity data is approximated by a polynomial as


v (t )  at 2  bt  c, 5  t  12

Determine the constants of the polynomial equation using


Gauss Elimination Method.

Dr. Monash Purushothaman CHE3001 Computational Methods in Process Engineering 21


solution
Applying the given conditions, we will get 3 simultaneous
equations.

25a1 + 5a2 + a3 = 106.8


64a1 + 8 a2 + a3 = 177.2
144a1  12a2  a3  279.2

Forward Elimination Step - 1


25 5 1 106.8 
 0 4.8 1.56 96.208 
 
 0 16.8 4.76 335.968 

Dr. Monash Purushothaman CHE3001 Computational Methods in Process Engineering 22


Forward Elimination Step - 2
25 5 1 106.8 
 0 4.8 1.56 96.208 
 
 0 0 0.7 0.76  The constants of
the polynomial
equation is:
Applying back substitution step:
a3  0.76/ 0.7  1.0857
a1 = 0.2905
a2 =  -96.208 -(-1.561.0857) /-4.8 a2 = 19.6905
a2 = 19.6905 a3 = 1.0857
a1 = 106.8 - (11.0857+519.6905) /25
a1 = 0.2905

Dr. Monash Purushothaman CHE3001 Computational Methods in Process Engineering 23


Example – Gauss elimination

Solve
10x1 + 7x2 + 8x3 + 7x4 = 32
7x1 + 5x2 + 6x3 + 5x4 = 23
8x1 + 6x2 + 10x3 + 9x4 = 33
7x1 + 5x2 + 9x3 + 10x4 = 31

10 7 87  x1  32 


7 x  23
5 65    
A  x   2 b 
8 6 10 9   x3  33
   x4   31
7 5 9 10 

Dr. Monash Purushothaman CHE3001 Computational Methods in Process Engineering 24


Getting the Matrix from the user
clc;
clear;
a(i,j) called as array
disp ('Gauss-Elimination
Program')
n=input('Enter the size of
the square matrix\n');
A(1,1)
for i=1:n %This loop is to
get the matrix A and
constant vectors B
for j=1:n
fprintf ('Enter the
value of matrix element A(1,1) A(1,2) A(1,3)
a%d%d:\t',i,j);
a(i,j)=input('');
end
b(i)=input('b=');
end

Dr. Monash Purushothaman CHE3001 Computational Methods in Process Engineering 25


Elimination step
% Gauss Elimination Step Program
for j=1:n-1
for i=j+1:n
fac= a(i,j)/a(j,j);
for k=j:n
a(i,k) = a(i,k) - a(j,k)*fac
end
b(i)=b(i)-b(j)*fac;
end
end
Step 1

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 

Dr. Monash Purushothaman CHE3001 Computational Methods in Process Engineering 26


Step 2
for j=2, i=3, K=2 for j=2, i=3, K=3 for j=2, i=3, 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 0.1000 0.40000 0.1000 
 0 0.1000 0.40000 0. 1000 
 0.1000 0.40000 0.1000   
 
 0 0 3.6000 3.4000   0 0 2.0000 3.4000   0 0 2.0000 3.0000 
     
 0 0.1000 3.4000 5.1000   0 0.1000 3.4000 5.1000   0 0.1000 3.4000 5.1000 

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 

for j=3, i=4, K=3 for j=3, i=4, K=4


10.0000 7.0000 8.0000 7.0000  10.0000 7.0000 8.0000 7.0000 
Step 3  0 0.1000 0.40000 0.1000   0 0.1000 0.40000 0.1000 
  
 0 0 2.0000 3.0000   0 0 2.0000 3.0000 
   
 0 0 0 5 .0000   0 0 0 0.5000 

Dr. Monash Purushothaman CHE3001 Computational Methods in Process Engineering 27


Back substitution step

10.0000 7.0000 8.0000 7.0000 32.0000


 
0 0.1000 0.40000 0. 1000 0. 6000
[A|b]   
 0 0 2.0000 3.0000 5.0000 
 
 0 0 0 0. 5000 0. 5000 
Similarly , back substitution
steps gives the solution of
%Back Substitution Step the given equations
Program
for i=n:-1:1
sum=0;
for j=i+1:n
 x1  1.0000 
 x  1.0000 
sum =sum+a(i,j)*x(j);  2 
end x 
x(i) = (b(i)-sum)/a(i,i);  3x  1 .0000 
end  x4  1.0000 

Dr. Monash Purushothaman CHE3001 Computational Methods in Process Engineering 28


Pitfalls of Elimination Methods
• Division by zero
– When the pivot coefficient is equal to or close to zero

• 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

Dr. Monash Purushothaman CHE3001 Computational Methods in Process Engineering 29


Ill-Conditioned Systems

Solving the above system, you will get x1 = 4 and x2 = 3

However, with the slight change of the coefficient a21 from


1.1 to 1.05, the result is changed dramatically.

you will get x1 = 8 and x2 = 1

Therefore, although x1 = 8 and x2 = 1 is not the true solution


to the original problem, the error check is close enough to
possibly mislead you into believing that your solutions are
adequate.
Dr. Monash Purushothaman CHE3001 Computational Methods in Process Engineering 30
Pivoting Strategies
• Pivoting – making the magnitude of the diagonal elements
(pivots) as large as possible by interchanging equations
• In Gauss Elimination, if pivot coefficient akk(k) = 0 for some k,
the method breaks down

Example However, after the 1st step in the elimination, we get

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

• Partial Pivoting • Complete Pivoting

– Interchange equations (rows) – Interchange both equations


only and unknown elements
(pivots)
– Choose r, the smallest
integer for which – Choose r and s, the smallest
integer for which
– i.e. choose the largest
coefficient in the column to – i.e. choose the largest
become the pivot coefficient coefficient in the sub-matrix
to become the pivot
– interchange rows k and r coefficient.

– interchange rows k and r,


and columns k and s.
Dr. Monash Purushothaman CHE3001 Computational Methods in Process Engineering 32
Pivoting Strategies

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

Dr. Monash Purushothaman CHE3001 Computational Methods in Process Engineering 33


Scaling

2 x1  100, 000 x2  100, 000


Example:
x1  x2  2

Without scaling, forward elimination is applied to give

2 x1  100, 000 x2  100, 000


50, 000 x2  50, 000

x2  1.00
which can be solved by back substitution for
x1  0.00

Dr. Monash Purushothaman CHE3001 Computational Methods in Process Engineering 34


Rescale all coefficients in a row to make the largest coefficient equal to 1
Scaling transforms the original equations to

0.00002 x1  x2  1 x1  x2  2
After pivoting
x1  x2  2 0.00002 x1  x2  1

Forward elimination yields Back substitution yields


x1  x2  2 x1 = x2 = 1.00
x2  1

Forward elimination Back substitution


Solution : Without x1  x2  2 x2 = 1.00, x1 = 1.00
pivoting and scaling (Right)
x2  1
Solution: With partial 2 x1  100,000 x2  100,000 x2 = 1.00, x1 = 0.00
pivoting but no scaling
 50,000 x2  50,000 (Wrong)
With partial pivoting x1  x2  2
and scaling x2 = 1.00, x1 = 1.00
x2  1.00 (Right)
Dr. Monash Purushothaman CHE3001 Computational Methods in Process Engineering 35
Gauss-Jordan Elimination
• Elimination is applied to all equations (excluding the pivot
equation) - Instead of just the subsequent equations as in
Gauss elimination method
• All rows are normalized by dividing them by their pivot
elements
• No back substitution is required

 a11 a12 a13 b1   a11 a12 a13 b1   a11 a13(1) b1(1) 


a  
 21 a22 a 23 b2    (1)
a 22 (1)
a23 b2(1)    (1)
a 22 (1)
a 23 b2(1) 
 a31 a32 a33 b3   (1)
a32 (1)
a33 b3(1)   ( 2)
a33 b3( 2 ) 

 a11 b1( 2 )  1 b1( 2 ) a11  1 c1( 3) 
 (1)   (1)   ( 3) 
 a 22 b2( 2 )    1 b2( 2 ) a22    1 c 2 
 ( 2)
a33 b3( 2 )   1 b ( 2)
b ( 2)   1 c ( 3) 
  3 33   3 

Dr. Monash Purushothaman CHE3001 Computational Methods in Process Engineering 36


Gauss Jordan code to form diagonal matrix
for i = 1 to n
for j =1 to n
if i not equal to j
pivot = a(j,i)/a(i,i);
for k = 1:n+1
a(j,k)=a(j,k)-a(i,k)*pivot;
end
end
end
end

for i = 1 to n
x(i)=a(i,n+1)/a(i,i);
end

Dr. Monash Purushothaman CHE3001 Computational Methods in Process Engineering 37


Pitfalls of Gauss-Jordan method
• Pitfalls: Same as those found in the Gauss elimination
– Division-by-zero, round-off error and ill-conditioned
systems.
• Improvement strategies: Same as those used in the Gauss
elimination
– Use pivoting and scaling to avoid division-by-zero and to
reduce round-off error.
Gauss Elimination Gauss-Jordan Elimination

Elimination Forward Elimination – only needs Needs to eliminate coefficients


Step to eliminate the coefficients below below and above the diagonal
the diagonal. flops= 2 * (2n3/3)
flops = 2n3/3
Substitution Back Substitution No substitution step
Step flops = O(n2)
Total 2n3/3 + O(n2) 4n3/3 (More costly when n is
big)

Dr. Monash Purushothaman CHE3001 Computational Methods in Process Engineering 38


Case study
Four reactor tanks are connected by pipes as shown in Figure. At steady
state, establish the material balance equation and solve for the
concentrations of the fluid at each tank using Gauss Jordan method.

Q13C1
350 g/s Q33C3
Reactor 1 Reactor 3

Q32C3 Q43C4
Q21C2

Q24C2 150 g/s


Reactor 2 Reactor 4

Volumetric flow rate data is given in the following Table.


Q13 = 75 L/s Q21 = 25 L/s Q24 =20 L/s
Q32 = 45 L/s Q33 = 60 L/s Q43 = 30 L/s
Dr. Monash Purushothaman CHE3001 Computational Methods in Process Engineering 39
solution
Material Balance for Reactor 1: Material Balance for Reactor 2:
350 + Q 21C2 = Q 13C1 Q 32C3 = Q 21C2 + Q 24 C2
75C1 - 25C2 = 350 -------> eq (1) 45C3 = 25C2 + 20C2
45C2 - 45C3 = 0 -------> eq (2)

Material Balance for Reactor 3: Material Balance for Reactor 4:


Q 13C1 + Q 43C 4 = Q 33C3 + Q 32C3 150 + Q 24 C2 = Q 43C 4
75C1 + 30C 4 = 60C3 + 45C3 150 + 20C2 = 30C4
75C1 - 105C3 + 30C 4 = 0 -------> eq (3) 20C2 - 30C3 = -150 -------> eq (4)

75 25 0 0   C1   350 


So we can write the above  0 45 45 0  C2   0 
equation in matrix form as      
75 0 105 30  C3   0 
    
 0 20 0 30  C 4  150 
Dr. Monash Purushothaman CHE3001 Computational Methods in Process Engineering 40
Gauss- Jordan elimination Step 1: R2
R2  R2 - pivot ratio *pivot row
75 25 0 0 350 
 0 45 45  a
 0 0  pivot ratio = 21
a11
75 0 105 30 0 
  a 0
 0 20 0  30  150  a21 = a21 - 21 *a11 = 75 - * 75 = 0
a11 75
Gauss- Jordan elimination Step 1: R3 a 0
a22 = a22 - 21 *a12 = 45 - * -25 = 45
a11 75
75 25 0 0 350 
 0 45 45  a 0
0 0 a23 = a23 - 21 *a13 = -45 - * 0 = -45
  a11 75
 0 25 105 30 350 
  a 0
0 20 0  30  150 a24 = a24 - 21 *a14 = 0 - *0= 0
  a11 75
Gauss- Jordan elimination Step 1: R4 a 0
a25 = a25 - 21 *a15 = 0 - * 350 = 0
a11 75
75 25 0 0 350 
 0 45 45 0 0 
 
 0 25 105 30 350  Refer next slide for R3 and R4
 
 0 20 0  30  150  Gauss-Jordan Elimination
Dr. Monash Purushothaman CHE3001 Computational Methods in Process Engineering 41
R3  R3 - pivot ratio *pivot row R4  R4 - pivot ratio *pivot row
a a
pivot ratio = 31 pivot ratio = 41
a11 a11
a 75 a 0
a31 = a31 - 31 *a11 = 75 - * 75 = 0 a41 = a41 - 41 *a14 = 0 - * 75 = 0
a11 75 a11 75
a 75 a 0
a32 = a32 - 31 *a12 = 0 - * -25 = 25 a42 = a42 - 41 *a12 = 20 - * -25 = 20
a11 75 a11 75
a 75 a 0
a33 = a33 - 31 *a13 = -105 - * 0 = -105 a43 = a43 - 41 *a13 = 0 - *0= 0
a11 75 a11 75
a 75 a 0
a34 = a34 - 31 *a14 = 30 - * 0 = 30 a44 = a44 - 41 *a14 = -30 - * 0 = -30
a11 75 a11 75
a 75 a 0
a35 = a35 - 31 *a15 = 0 - * 350 = -350 a45 = a45 - 41 *a15 = -150 - * 350 = -150
a11 75 a11 75

Dr. Monash Purushothaman CHE3001 Computational Methods in Process Engineering 42


Gauss- Jordan elimination Step 2: R1
75 0 25 0 350 
 0 45 45  R1  R1 - pivot ratio *pivot row
 0 0  a
 0 25 105 30 350  pivot ratio = 12 note: i  j
a22
 
 0 20 0  30  150  a 25
a12 = a12 - 12 *a22 = -25 - * 45 = 0
a22 45
Gauss- Jordan elimination Step 2: R3 a 25
a13 = a13 - 12 *a23 = 0 - * -45 = -25
75 0 25 0 350  a22 45
 0 45 45 0 0 
  a 25
a14 = a14 - 12 *a24 = 0 - *0= 0
 0 0 80 30 350  a22 45
  a 25
 0 20 0  30  150  a15 = a15 - 12 *a25 = 350 - * 0 = 350
a22 45
Gauss- Jordan elimination Step 2: R4
75 0 25 0 350 
 0 45 45 0 0 
  Refer next slide for R3 and R4
 0 0 80 30 350 
  Gauss-Jordan Elimination
 0 0 20  30  150 
Dr. Monash Purushothaman CHE3001 Computational Methods in Process Engineering 43
R3  R3 - pivot ratio *pivot row R4  R4 - pivot ratio *pivot row
a32 a
pivot ratio = pivot ratio = 42
a22 a22
a32 25 a 20
a32 = a32 - *a22 = 25 - * 45 = 0 a42 = a42 - 42 *a22 = 20 - * 45 = 0
a22 45 a22 45
a 25 a 20
a33 = a33 - 32 *a23 = -105 - * -45 = -80 a43 = a43 - 42 *a23 = 0 - *-45 = 20
a22 45 a22 45
a 25 a 20
a34 = a34 - 32 *a24 = 30 - * 0 = 30 a44 = a44 - 42 *a24 = -30 - * 0 = -30
a22 45 a22 45
a 25 a 20
a35 = a35 - 32 *a25 = -350 - * 0 = -350 a45 = a45 - 42 *a25 = -150 - * 0 = -150
a22 45 a22 45

Dr. Monash Purushothaman CHE3001 Computational Methods in Process Engineering 44


Gauss- Jordan elimination Step 3: R1 R1  R1 - pivot ratio *pivot row
75 0 0 9.375459.375 a13
 0 45 45  pivot ratio =
 0 0  a33
 0 0 80 30 350  a13 25
  a13 = a13 - *a33 = -25 - * -80 = 0
 0 0 20  3 0  150  a33 80
a13 25
a14 = a14 - *a34 = 0 - * 30 = -9.375
Gauss- Jordan elimination Step 3: R2 a33 80
75 0 0 9.375 459.375 a 25
 0 45 0 16.875196.875  a15 = a15 - 13 *a35 = 350 - * -350
a33 80
 
 0 0 80 30 350  a15 = 459.375
 
 0 0 20  30  150 
Gauss- Jordan elimination Step 3: R4 Refer next slide for R2 and R4
75 0 0 9.375 459.375
 0 45 0 16.875196.875  Gauss-Jordan Elimination
 
 0 0 80 30 350 
 
 0 0 0  22.5  237. 5 
Dr. Monash Purushothaman CHE3001 Computational Methods in Process Engineering 45
R2  R2 - pivot ratio *pivot row R4  R4 - pivot ratio *pivot row
a23 a43
pivot ratio = pivot ratio = note: i  j
a33 a33
a23 45 a43 20
a23 = a23 - *a33 = -45 - * -80 = 0 a43 = a43 - *a33 = 20 - * -80 = 0
a33 80 a33 80
a23 45 a43 20
a24 = a24 - *a34 = 0 - * 30 = -16.875 a44 = a44 - *a34 = -30 - * 30 = -22.5
a33 80 a33 80
a 45 a 20
a25 = a25 - 23 *a35 = 0 - * -350 a45 = a45 - 43 *a35 = -150 - * -350
a33 80 a33 80
a25 = 196.875 a45 = -237.5

Dr. Monash Purushothaman CHE3001 Computational Methods in Process Engineering 46


Gauss- Jordan elimination Step 4: R1 R1  R1 - pivot ratio *pivot row
75 0 0 0 558.3333 a
 0 45 0 16.875 196.875  pivot ratio = 14
a44
 
 0 0 80 30 350  a
a14 = a14 - 14 *a44
  a44
 0 0 0  22.5  237.5 
9.375
= -9.375 - * -22.5 = 0
Gauss- Jordan elimination Step 4: R2 22.5
75 0 0 0 558.3333 a
a15 = a15 - 14 *a45
 0 45 0 a44
0 375 
  9.375
 0 0 80 30 350  = 459.375 - * -237.5
  22.5
 0 0 0  22.5  237.5  = 558.3333
Gauss- Jordan elimination Step 4: R3 Refer next slide for R2 and R3
75 0 0 0 558.3333 
Gauss-Jordan Elimination
 0 45 0 0 375 
 
 0 0 80 0 666.6666 
 
 0 0 0  22.5  237.5 
Dr. Monash Purushothaman CHE3001 Computational Methods in Process Engineering 47
R2  R2 - pivot ratio *pivot row R3  R3 - pivot ratio *pivot row
a24 a34
pivot ratio = pivot ratio =
a44 a44
a24 a
a24 = a24 - *a44 a34 = a34 - 34 *a44
a44 a44
16.875 30
= -16.875 - * -22.5 = 0 = 30 - * -22.5 = 0
22.5 22.5
a a
a25 = a25 - 24 *a45 a35 = a35 - 34 *a45
a44 a44
16.875 30
= 196.875 - * -237.5 =-350 - * -237.5
22.5 22.5
= 375 = -666.6666

Dr. Monash Purushothaman CHE3001 Computational Methods in Process Engineering 48


Gauss- Jordan elimination Step 4:
Since we have 4 unknowns for the given
75 0 0 0 558.3333 
problem, i.e. C1 , C2 , C 3 and C 4 , we have 4  0 45 0 
 0 375 
Gauss- Jordan elimination steps to achieve
 0 0 80 0 666.6666 
diagonal matrix.  
 0 0 0 22.5  237.5 

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 .

Dividing by the diagonal elements, Therefore the concentration of the fluid in


we get each reactor is:
C1 = 558.3333/75 = 7.4444 g/L
Concentation in reactor 1 is 7.4444 g/L.
C2 = 375/45 = 8.3333 g/L
Concentation in reactor 2 is 8.3333 g/L.
C3 = -666.6666/-80 = 8.3333 g/L Concentation in reactor 3 is 8.3333 g/L.
C 4 = -237.5/-22.5 = 10.5555 g/L Concentation in reactor 4 is 10.5555 g / L.

Dr. Monash Purushothaman CHE3001 Computational Methods in Process Engineering 49


Case Study
The upward velocity of a rocket is given at three different
times in the following table

Time, t (s) 5 8 12

Velocity, v (m/s) 106.8 177.2 279.2

The velocity data is approximated by a polynomial as


v (t )  at 2  bt  c, 5  t  12

Determine the constants of the polynomial equation using


Gauss Jordan Method.

Dr. Monash Purushothaman CHE3001 Computational Methods in Process Engineering 50


solution
Applying the given conditions, we will get 3 simultaneous
equations.

25a1 + 5a2 + a3 = 106.8


64a1 + 8 a2 + a3 = 177.2
144a1  12a2  a3  279.2

Step - 1: After normalization and eliminating x1 from


other equations
1 0.2 0.04 4.272 
0 4.8 1.56 96.208 
 
0 16.8 4.76 335.968 
Dr. Monash Purushothaman CHE3001 Computational Methods in Process Engineering 51
Step - 2: After normalization and eliminating x 2 from
other equations
1 0 0.025 0.2633 
 0 1 0.325 20.0433
 
 0 0 0.7 0.76 

Step - 3: After normalization and eliminating x 3 from


other equations
Final solution is:
1 0 0 0.2905  a1 = 0.2905
0 1 0 19.6905
  a2 = 19.6905
0 0 1 1.0857  a3 = 1.0857

Dr. Monash Purushothaman CHE3001 Computational Methods in Process Engineering 52


Case Study
A civil engineer involved in construction requires 4800,
5810 and 5690 m3 of sand, fine gravel, and coarse gravel,
respectively, for a building project. There are three pits from
which these materials can be obtained. The composition of
these pits is given below.

Sand % Fine Gravel % Coarse Gravel %


Pit 1 52 30 18
Pit 2 20 50 30
Pit 3 25 20 55

Determine the cubic meters of sand, fine gravel and coarse


gravel that must be hauled from each pit in order to meet
the engineer’s needs
Dr. Monash Purushothaman CHE3001 Computational Methods in Process Engineering 53
Case study
An electrical engineer supervises the production of three
types of electrical components. Three kinds of material
(metal, plastic, and rubber) are required for production. The
amounts needed to produce each component are given in
the table.
Component Metal, Plastic, Rubber,
g/component g/component g/component
1 15 0.30 1.0
2 17 0.40 1.2
3 19 0.55 1.5
If totals of 3.89, 0.095, and 0.282 kg of metal, plastic, and
rubber, respectively, are available each day, how many
components can be produced per day?
Dr. Monash Purushothaman CHE3001 Computational Methods in Process Engineering 54
Case study
Figure shows three reactors linked by pipes. Develop mass
balance equations for the reactors at steady state and solve
the three simultaneous linear algebraic equations for their
concentrations.

Dr. Monash Purushothaman CHE3001 Computational Methods in Process Engineering 55


Case study
Figure shows five reactors linked by pipes. Develop mass balance
equations for the reactors at steady state and solve the three simultaneous
linear algebraic equations for their concentrations.

Dr. Monash Purushothaman CHE3001 Computational Methods in Process Engineering 56


Case study
An electronics company produces transistors, resistors, and
computer chips. The material requirement for each component
is given in the following Table.

Component Copper Zinc Glass


Transistors 4 1 2
Resistors 3 3 1
Computer chips 2 1 3

Total amounts of materials available in a given week are 960


units of copper, 510 units of zinc, and 610 units of glass. Set up
the system of equations and solve for the number of
transistors, resistors, and computer chips to be manufactured
in this week.
Dr. Monash Purushothaman CHE3001 Computational Methods in Process Engineering 57
Case study
A team of five parachutists is
connected by a weightless cord
while free-falling at a velocity of 9
m/s. Calculate the tension in each
section of cord and the acceleration
of the team.

Dr. Monash Purushothaman CHE3001 Computational Methods in Process Engineering 58


Gauss Elimination/Gauss-Jordan using MS-Excel
inbuilt functions

Dr. Monash Purushothaman CHE3001 Computational Methods in Process Engineering 59


Solutions for the simultaneous equations using
solver (Add-ins present in MS-Excel)

Dr. Monash Purushothaman CHE3001 Computational Methods in Process Engineering 60


Solutions using solver – Contd…

Dr. Monash Purushothaman CHE3001 Computational Methods in Process Engineering 61


Solutions using solver – Contd…

Dr. Monash Purushothaman CHE3001 Computational Methods in Process Engineering 62


Solutions using solver – Contd…
Another Approach
Solution of Simultaneous Equations Using Solver Another
For Approach
Procedure see the week 10 powe
Lecturer: Dr. Monash Purushothaman
Solution using Solver
x1 x2 x3 x4 F(x) =0
B22 10 C22 7 D22 8 E22 7 F2232 1E-06
7 5 6 5 23 -0.03817
8 6 10 9 33 -0.63359
7 5 9 10 31 -0.83206

Solution for the Unknowns


X1= 1.221374 C28
x2= 0.854962 C29
B22*$C$28+C22*$C$29+D22*$C$30+E22*$C$31-F22
x3= 0.977099 C30
x4= 0.854962 C31

Dr. Monash Purushothaman CHE3001 Computational Methods in Process Engineering 63


Gauss Elimination using Ms-Excel
Solution of Simultaneous Equations Using Gauss-Elimination Algorithmn (4 x 4 Matrix ---> 4 Unknowns)
Lecturer: Dr. Monash Purushothaman
Solution using Gauss-Jordan Algorithm

Enter the equation in Augmented Matrix Form


x1 x2 x3 x4 Solution of the Given Simultaneous Equation is
10 7 8 7 32.000000 X1 = 1.000000
7 5 6 5 23.000000 X2 = 1.000000
8 6 10 9 33.000000 X3 = 1.000000
7 5 9 10 31.000000 X4 = 1.000000

Forward Elimination Back Substitution


STEP 1
10 7 8 7 32 X4 = 1
0 0.1 0.4 0.1 0.6 X3 = 1
0 0.4 3.6 3.4 7.4 x2 = 1
0 0.1 3.4 5.1 8.6 x1 = 1

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

Dr. Monash Purushothaman CHE3001 Computational Methods in Process Engineering 64


Gauss-Jordan Using Ms-Excel
Enter the equation in Augmented Matrix Form
x1 x2 x3 x4 Solution of the Given Simultaneous Equation is
10 7 8 7 32.000000 X1 = 1.000000
7 5 6 5 23.000000 X2 = 1.000000
8 6 10 9 33.000000 X3 = 1.000000
7 5 9 10 31.000000 X4 = 1.000000

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

STEP 4 Note: Since the Matrix obtained is


1 0 0 0 1.000000
0 1 0 0 1.000000
an Identity Matrix, back
0 0 1 0 1.000000 substitution step is not required
0 0 0 1 1.000000

Dr. Monash Purushothaman CHE3001 Computational Methods in Process Engineering 65


Iterative Methods to find the solution of
simultaneous equations
• Gauss-Jacobi Method
• Gauss-seidel Method (also called as Liebmann Method or
Successive replacement method)
• Relaxation Method
– Successive relaxation Method (SOR)

• 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 

Dr. Monash Purushothaman CHE3001 Computational Methods in Process Engineering 67


Iterative vs. Direct methods
• Efficient, especially when an approximate solution is known

• May not converge

• Stopping criteria?

• Elimination methods such as Gaussian Elimination and LU


Decomposition are prone to round-off error

• If the nature/physics of the problem is known, a close initial


guess can be made, which decreases the number of
iterations required

Dr. Monash Purushothaman CHE3001 Computational Methods in Process Engineering 68


Convergence of Iterative methods
A simple way to determine the convergence is to inspect the
diagonal elements.

Convergence is guaranteed if the system is diagonally


dominant or symmetric or Positive definite
n
a ii  a
j 1, j  i
ij

Note: The system may still have a chance to converge even


if the matrix A is not diagonally dominant

Good initial guess can greatly improve the chance of


convergence

Convergent rate depends on the properties of the matrix


Dr. Monash Purushothaman CHE3001 Computational Methods in Process Engineering 69
Iterative Method
• Consider a set of n equations and n unknowns:
a11 x1  a12 x2  a13 x3  ...  a1n xn  b1 If, the diagonal elements are non-
a21 x1  a22 x2  a23 x3  ...  a2 n xn  b2 zero

. . . . . . . Rewrite each equation solving for


the corresponding unknown
. . . . . . .
example
. . . . . . .
First equation, solve for x1
. . . . . . .
Second equation, solve for x2
an1 x1  an 2 x2  an3 x3  ...  ann xn  bn

Example: A set of 4 equations and 4unknowns


a 11 x 1  a 12 x 2  a 13 x 3  a 14 x 4  b1  x1  ( b1  a 12 x 2  a 13 x 3  a 14 x 4 ) / a 11
a x  a x  a x  a x  b 
 21 1 22 2 23 3 24 4 2 can be  2
x  ( b2  a 21 x 1  a 23 x 3  a 24 x 4 ) / a 22

a x  a x  a x  a x  b written  x  ( b3  a 31 x 1  a 32 x 2  a 34 x 4 ) / a 33
 31 1 32 2 33 3 34 4 3
as  3
a 41 x 1  a 42 x 2  a 43 x 3  a 44 x 4  b4  x 4  ( b4  a 41 x 1  a 42 x 2  a 43 x 3 ) / a 44

Dr. Monash Purushothaman CHE3001 Computational Methods in Process Engineering 70


Iterative Method
General form of each equation
n
n
b1   a1 j x j b2   a2 j x j
j 1
j 1
j2
x1 
j 1 x2 
a11 a22
n
n
bn   anj x j
b n 1  
j1
a n 1, j x j j 1
j n
x n 1 
j n 1 xn 
a n 1,n 1 ann

n
bi   aij x j
j 1
j i
General form for any row ‘i’ xi  for i  1, 2,, n.
aii

Dr. Monash Purushothaman CHE3001 Computational Methods in Process Engineering 71


Algorithm/Procedure for Iterative Methods
o Start with initial guesses

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

Dr. Monash Purushothaman CHE3001 Computational Methods in Process Engineering 72


Gauss-Seidel Vs. Gauss-Jacobi
The Gauss-Seidel method The Gauss-Jacobi iteration method

Dr. Monash Purushothaman CHE3001 Computational Methods in Process Engineering 73


In-built command in MATLAB

Dr. Monash Purushothaman CHE3001 Computational Methods in Process Engineering 74


Dr. Monash Purushothaman CHE3001 Computational Methods in Process Engineering 75
Case study
Develop a mass balance equations for the continuous
stirred tank reactors under steady state condition and solve
for their concentrations using Gauss elimination method.

Dr. Monash Purushothaman CHE3001 Computational Methods in Process Engineering 76


Case Study
A chemical process consists of 3 reactors linked by pipes. Develop mass
balance equations, at steady state, for the reactors and solve the
equations for the unknown concentrations (C1, C2 and C3) using Gauss-
Seidel method with εs = 5%

30 g/s
14 m3/s (c2) 17 m3/s (c3)
5 m3/s (c2)

200 g/s R3
R2 2 m3/s (c3)

2 m3/s (c2) 3 m3/s (c3) 5 m3/s (c1)


5 m3/s (c1)

R1
500 g/s 7 m3/s (c1)

Dr. Monash Purushothaman CHE3001 Computational Methods in Process Engineering 77


Case study
A civil engineer involved in construction requires 45000,
65000, 52000, 48000 and 70000 m3 of sand, fine gravel,
coarse gravel, cement and water respectively, for a building
project. There are 5 pits from which these materials can be
obtained. The composition of these pits is given below.
Sand Fine Gravel Coarse Gravel Cement Water
% % % % %
Pit 1 55 10 8 10 10
Pit 2 12 65 15 15 12
Pit 3 15 8 52 12 13
Pit 4 13 10 15 58 10
Pit 5 10 7 10 5 55

How many cubic meters must be hauled from each pit in


order to meet the engineer’s needs? Use Gauss Elimination
method to find the solution.
Dr. Monash Purushothaman CHE3001 Computational Methods in Process Engineering 78
End of Module – 2

Thank you

For further clarifications refer text books.

Dr. Monash Purushothaman CHE3001 Computational Methods in Process Engineering 79

Das könnte Ihnen auch gefallen