SlideShare a Scribd company logo
INTRODUCTION TO
NUMERICAL
METHODS IN
CHEMICAL
ENGINEERING
Pradeep Ahuja
dCj
dx
= 0, j = A,B,C,D
C – Ci i – 1dCi
dx
u = u
Dx
dCj
dx
uC = uC – Dj,in j
A+B C
k1
B+C D
k2
2
d CA
2
dx
D – u C CA B– k = 01
dCA
dx
2
d CB
2
dx
D – u C CA B– k – k C C = 01 2 B C
dCB
dx
2
d CC
2
dx
D – u + C CA Bk – k C C = 01 2 B C
dCC
dx
2
d CD
2
dx
D – u + k C C = 02 B C
dCD
dx
C – 2C + Ci + 1 i i – 1
2
d Ci
2
dx
D = D 2
Dx
u
x
Introductionto
Numerical Methods in Chemical Engineering
Introductionto
Numerical Methods in
Chemical Engineering
PRADEEP AHUJA
Associate Professor
Department of Chemical Engineering and Technology
Institute of Technology, Banaras Hindu University
Varanasi
New Delhi-110001
2010
Rs. 275.00
INTRODUCTION TO NUMERICAL METHODS IN CHEMICAL ENGINEERING
Pradeep Ahuja
© 2010 by PHI Learning Private Limited, New Delhi. All rights reserved. No part of this book may
be reproduced in any form, by mimeograph or any other means, without permission in writing from
the publisher.
ISBN-978-81-203-4018-3
The export rights of this book are vested solely with the publisher.
Published by Asoke K. Ghosh, PHI Learning Private Limited, M-97, Connaught Circus,
New Delhi-110001 and Printed by Jay Print Pack Private Limited, New Delhi-110015.
To
my Mother
Kamla Ahuja
and
All my Students
Contents
vii
Preface ix
1. Linear Algebraic Equations 1–16
1.1 Tridiagonal Matrix Algorithm (TDMA) 1
1.2 Gauss Elimination Method 5
1.3 Gauss–Seidel Method 10
Exercises 12
2. Nonlinear Algebraic Equations 17–30
2.1 Newton’s Method 17
2.2 Pressure Drop in Pipe 20
2.3 Minimum Fluidization Velocity 21
2.4 Terminal Velocity 23
2.5 System of Nonlinear Equations 25
Exercises 29
3. Chemical Engineering Thermodynamics 31–52
3.1 Solution of Cubic Equations of State 31
3.2 Bubble Point and Dew Point Temperature Calculations
Using Raoult’s Law 33
3.2.1 Bubble Point Temperature Calculation 33
3.2.2 Dew Point Temperature Calculation 34
3.3 Flash Calculations Using Raoult’s Law 35
3.4 Bubble Point and Dew Point Temperature Calculations Using Modified
Raoult’s Law 37
3.5 Flash Calculations Using Modified Raoult’s Law 40
3.6 Vapour Pressure Using Cubic Equation of State 42
3.7 P-x-y Diagram Using Gamma–Phi Approach 43
3.8 P-x-y Diagram Using Cubic Equation of State 44
3.9 Chemical Reaction Equilibrium—Two Simultaneous Reactions 47
3.10 Adiabatic Flame Temperature 49
Exercises 50
viii Contents
4. Initial Value Problems 53–84
4.1 Solution of Single Ordinary Differential Equation 53
4.2 Double Pipe Heat Exchanger 55
4.3 Stirred Tank with Coil Heater 57
4.4 Pneumatic Conveying 60
4.5 Solution of Simultaneous Ordinary Differential Equations 63
4.6 Series of Stirred Tanks with Coil Heater 66
4.7 Initial Value Problems in Chemical Reaction Engineering 68
4.8 Batch and Stirred Tank Reactors 69
4.9 Plug Flow Reactor 74
4.10 Nonisothermal Plug Flow Reactor 76
Exercises 80
5. Boundary Value Problems 85–104
5.1 Discretization in One-Dimensional Space 85
5.2 One-Dimensional Steady Heat Conduction 93
5.3 Chemical Reaction and Diffusion in Pore 97
Exercises 99
6. Convection–Diffusion Problems 105–118
6.1 Upwind Schemes 105
6.1.1 First Order Upwind Scheme 105
6.1.2 Second Order Upwind Scheme 106
6.2 Comparison of CDS and UDS 113
Exercises 114
7. Tubular Reactor with Axial Dispersion 119–154
7.1 Boundary Value Problems in Chemical Reaction Engineering 119
7.2 First Order Reaction 120
7.3 Second Order Reaction 129
7.4 Multiple Reactions 131
Exercises 153
8. Chemical Reaction and Diffusion in a Spherical Catalyst Pellet 155–170
8.1 First Order Reaction 155
8.2 Second Order Reaction 158
8.3 Non isothermal Conditions 161
Exercises 169
9. One-Dimensional Transient Heat Conduction 171–191
9.1 Classification of Partial Differential Equations 171
9.2 Explicit and Implicit Discretization 172
9.3 Crank–Nicolson Discretization 173
9.4 Von Neumann Stability Analysis 174
9.5 Transient Conduction in Rectangular Slab 176
9.6 Transient Conduction in Cylinder 181
9.7 Transient Conduction in Sphere 183
9.8 Transient Diffusion in Sphere 186
Exercises 188
Contents ix
10. Two-Dimensional Steady and Transient Heat Conduction 192–223
10.1 Discretization in Two-Dimensional Space 192
10.2 Gauss–Seidel Method 194
10.3 Relaxation Parameter 194
10.4 Red–Black Gauss–Seidel Method 195
10.5 ADI Method for Steady Heat Conduction 208
10.6 ADI Method for Transient Heat Conduction 214
Exercises 220
Appendix: Programs in C++ 225–283
Bibliography 285–286
Index 287–289
This book entitled Introduction to Numerical Methods in Chemical Engineering is designed for
a course on Numerical Methods in Chemical Engineering and the associated Computer
Applications Laboratory course offered as part of undergraduate programmes in chemical
engineering. Also, for the courses on Chemical Engineering Mathematics or Applied
Mathematics in Chemical Engineering, this book can be used for the numerical solution aspects
of chemical engineering problems.
The computer programs are listed in C++. The author assumes that the students are at
least moderately familiar with the C++ language. In addition to the computer examples, there
are several much shorter examples appearing throughout the text. These shorter examples
usually illustrate a particular point by means of hand calculations. 33 sample programs in C++,
arranged by chapter, are presented in the Appendix and about 148 exercises (including chapter-
end exercises with answers) are solved. The numerical solutions of algebraic (linear and
nonlinear) and differential (ordinary and partial) equations encountered in subjects such as
General Chemical Engineering, Chemical Engineering Thermodynamics, Chemical Reaction
Engineering, and Heat Transfer are discussed using introductory but efficient numerical
methods. The students can also use the programs and build up their own programs to solve
specific Design Project problems in chemical engineering. The author feels that before using
chemical engineering software (which use advanced numerical methods), the students should
have some hands-on experience on small programs and introductory numerical methods as well
as their usage in chemical engineering. The experience gained from using these programs helps
in the development of basic understanding of numerical methods and confidence in handling
numerical techniques. Some problems whose analytical solutions are available are also solved
and the numerical and analytical results are compared. By changing various parameters the
student can find out the conditions under which correct results are obtained as well as those
under which correct results are not obtained.
For the solution of linear algebraic equations, the tridiagonal matrix algorithm (TDMA),
Gauss elimination, and Gauss–Seidel methods are discussed. For the solution of nonlinear
equation(s), Newton’s method is discussed and for initial value problems in ordinary
differential equations the Runge–Kutta fourth order method is discussed. For the solution of
boundary value problems the Finite Difference method is used. The Finite Difference method
is a simple yet very powerful tool for the solution of boundary value problems, but requires
a structured grid. It is the basis for the Advanced Finite Volume and Finite Element methods.
In this book the following Finite Difference methods are discussed: Central Difference Scheme
(CDS) for discretization of diffusion terms, Upwind Difference Scheme (UDS) for
Preface
xi
discretization of convection terms, Forward in Time and Central in Space (FTCS) difference
scheme for discretization of the one-dimensional transient conduction/diffusion equation
adopting the Explicit, Implicit and Crank–Nicolson methods, and the Alternating Direction
Implicit (ADI) method for the numerical solution of two-dimensional steady and transient heat
conduction.
Chapter 1 contains an introduction to the numerical solution of a system of linear
algebraic equations. The numerical solution of a single as well as two (simultaneous) nonlinear
algebraic equation(s) and the calculation of pressure drop in a pipe under nonlaminar
conditions, minimum fluidization velocity and terminal velocity are all discussed in Chapter
2. The numerical solution of computer-oriented problems in Chemical Engineering
Thermodynamics is discussed in Chapter 3. Various problems in vapour–liquid and chemical
reaction equilibria are discussed. Vapour–liquid equilibrium calculations are done for systems
following Raoult’s law, modified Raoult’s law, Gamma–Phi approach and Phi–Phi approach.
The numerical solution of initial value problems in ordinary differential equations, along with
the initial value problems in double pipe heat exchanger and stirred tanks with coil heater, and
in batch, stirred and plug flow reactors are discussed in Chapter 4. The numerical solution of
boundary value problems in ordinary differential equations and convection–diffusion problems
are discussed in Chapters 5 and 6 respectively. The numerical solution of tubular reactors with
axial dispersion and simultaneous chemical reaction and diffusion in spherical catalyst pellets
are discussed in Chapters 7 and 8 respectively. The numerical solution of one-dimensional
transient heat conduction/diffusion is discussed in Chapter 9, and that of two-dimensional
steady and transient heat conduction is discussed in Chapter 10. The Finite Difference method
is used for the solution of boundary value problems in Chapters 5–10.
The books referred to by the author for the preparation of class notes, on which the
contents of this book are principally based, is given in the Bibliography. The author expresses
his thanks to all those authors, too numerous to acknowledge individually. The author is
indebted to all his colleagues for many positive interactions and discussions and also to all his
friends for their constant appreciation, invaluable advice and encouragement. The author
would like to thank the Department of Science and Technology, New Delhi, for providing
partial financial support and Prof. S.N. Upadhyay, Director, Institute of Technology, Banaras
Hindu University, Varanasi, for providing the major part of the funds for the purchase of
Fluent 25 Users Perpetual License software in the Department of Chemical Engineering and
Technology, which proved immensely useful in the process of writing this book.
The author is also thankful to all his B.Tech. Chemical Engineering students who have
taken up the Computer Laboratory course and various computational and other chemical
engineering courses so enthusiastically and helped in many ways in developing this work.
Their inquisitive questions and enthusiasm towards the numerical solution of algebraic and
differential equations in chemical engineering inspired the author to create a work of this kind,
in which the numerical solution of various equations in chemical engineering is provided under
one cover. Feedback from students has critically guided the development and evolution of the
book, taking it from a handwritten collection of notes to the present form. The book is thus
dedicated to all his students. The author is grateful to Mr. Sudarshan Das, Mr. Abhjit Baroi
and Mr. Pankaj Manohar of PHI Learning for their cooperation.
xii Preface
The author is indebted and extremely thankful to his mother Kamla Ahuja, to his father
A.D. Ahuja, and his wife Preeti Bala Ahuja, for their care, help and understanding, as without
their support this work could never have been completed.
In spite of all efforts to the contrary, some errors might have crept into the book. The
author would be rather grateful if such errors are pointed out. He would also very much
appreciate any criticism or suggestion for improvement of the contents of the book from the
readers.
Pradeep Ahuja
Preface xiii
1
Chapter 1
Linear Algebraic Equations
A system of linear algebraic equations can be solved by direct or iterative methods. The direct
methods discussed in this chapter are the TriDiagonal Matrix Algorithm (TDMA) and Gauss
Elimination methods, and the iterative method discussed is the Gauss-Seidel method.
A tridiagonal or block tridiagonal set of linear algebraic equations is formed during the
discretization of ordinary and partial differential equations. The discretization of differential
equations using the finite difference method is discussed in Chapters 5 to 10. All types of linear
algebraic equations can be solved using the Gauss Elimination method, but if the equations are
of tridiagonal type, then TDMA is very fast as compared to the Gauss Elimination method. The
Gauss–Seidel method is used for the solution of two-dimensional steady heat transfer, which
is discussed in Chapter 10.
1.1 Tridiagonal Matrix Algorithm (TDMA)
TDMA is a direct method. Consider the following tridiagonal set of linear algebraic equations:
   
    
    
    
    
    
    
    
0 0 0 0 0
0 0 0 0
D E Z F
C D E Z F
C D E Z F
C D E Z F
C D E Z F
C D Z F
    
ª º ª º ª º
« » « » « »
« » « » « »
« » « » « »
« » « » « »
« » « » « »
« » « » « »
« » « » « »
« » « » « »
« » « » « »
« » « » « »
« » « » « »
« » « » «
« » « » «¬ ¼ ¬ ¼ ¬ ¼
»
»
(1.1)
N linear algebraic equations can be written in the form Ax = d. The matrix A contains elements
on the diagonal (bi, i = 1 to N), sub-diagonal (ai, i = 2 to N), and super-diagonal (ci, i = 1 to
N – 1), and thus is called a tridiagonal matrix. The algorithm for the solution of this sort of
linear algebraic equation is called the TriDiagonal Matrix Algorithm or the Thomas algorithm.
2 Introduction to Numerical Methods in Chemical Engineering
The equations are of the type
 K K K K K K K
C Z D Z E Z F   where a1 = 0, cN = 0 (1.2)
Let us write the solution at xi in terms of xi+1 as
K K
K K
K
E Z
Z H
C

 (1.3a)
Then we can also write

 

K K
K K
K
E Z
Z H
C

 

 (1.3b)
where bi and gi are obtained by substituting Eq. (1.3b) into Eq. (1.2). Thus we get

 

K K
K K K K K K K
K
E Z
C D Z E Z FH
C

 

§ ·
  ¨ ¸
© ¹
The above equation can be written as

 

K K
K K K K K K K
K
C E
D Z F C E ZH
C

 

§ ·
  ¨ ¸
© ¹
Thus


 
 
K K K K
K K
K K K K
K K
K K
F C E
Z Z
C E C E
D D
H
C C


 
 


§ · § ·
 ¨ ¸ ¨ ¸
© ¹ © ¹
Comparing with Eq. (1.3a), we get


K K
K K
K
C E
DC
C


 (1.4)
 


K K K K K K
K
KK K
K
K
F C F C
C E
D
H H
H
C
C
 


 
§ ·
¨ ¸
© ¹
(1.5)
a1 = 0; therefore
b1 = b1 (1.6)
and



F
D
H (1.7)
The algorithm for the solution of a tridiagonal set of linear algebraic equations is given below:
(i) Calculate bi and gi for i = 1 to N.
(ii) Calculate 0 0
0 0
0
E Z
Z H
C

 . Since cN = 0, therefore xN = gN.
(iii) Calculate
K K
K K
K
E Z
Z H
C

 for i = N – 1, N – 2, …, 3, 2, 1.
Linear Algebraic Equations 3
EXAMPLE 1.1 Solve the following set of linear algebraic equations using TDMA







  
   
   
   
   
   
  
Z
Z
Z
Z
Z
Z
Z
 ª ºª º ª º
« »« » « » « »« » « »
« »« » « » 
« »« » « »
 « »« » « »
« »« » « » 
« »« » « »
 « »« » « »
« »« » « » « » « »« »¬ ¼ ¬ ¼¬ ¼
Solution We have
C  D 
H 





F
D


 
 

 

 
C E
DC
C
   

H
H
C
  


    
  
 
F C   u 
 
C
C
 
 

 

 

C E
D    

H
H
C
  




 


F C
 


C
C
 
 

 

 

C E
D    

H
H
C
  


 



F C  

C
C
 
 

 

 

C E
D
4 Introduction to Numerical Methods in Chemical Engineering
H
H
C
  


  
 

F C  

C
C
 
 

 

 

C E
D    

H
H
C
  





 

F C
 


C
C
 
 

 

 

C E
D    

H
H
C
  





 

F C
 


Now let us compute the solution starting with x7.
H 



Z
H
C
 
 

  

  
E Z
Z   u
H
C
 
 

  

 
E Z
Z
u
 
H
C
 
 

 
 

E Z
Z
u
 
H
C
 
 

 
 

E Z
Z
u
 
H
C
 
 

 

 
E Z
Z  
H
C
 
 


 

E Z
Z
Linear Algebraic Equations 5
Program 1.1 uses the above method for solving the tridiagonal system of linear algebraic
equations and is given in the Appendix.
1.2 Gauss Elimination Method
Gauss Elimination is a direct method. The Gauss Elimination method reduces the system of
equations to an upper triangular system which can then be solved by back substitution.
Consider the following system of three linear algebraic equations:
      C Z C Z C Z F 
      C Z C Z C Z F 
      C Z C Z C Z F 
The augmented matrix is
   
   
   
C C C F
C C C F
C C C F
ª º
« »
« »
« »
¬ ¼
(1.8)
Take the element a11 as the pivot. Multiply the first equation by 

C
C
 and then add it to the
second equation, which then becomes
   
     
  
C CC C C
C Z C Z F F
C C C
§ · § ·
   ¨ ¸ ¨ ¸
© ¹ © ¹
Thus x1 is eliminated from the second equation. Similarly, eliminate x1 from the third
equation by multiplying the first equation by


C
C
 and then adding it to the third equation.
At the end of the first stage the augmented matrix becomes
   
  
  


C C C F
C C F
C C F
ª º
« »
c c c« »
« »c c c¬ ¼
(1.9)
Now take the element a¢22 as the new pivot. Multiply the second equation by


C
C
c

c
and then
add it to the third equation. Thus x2 is eliminated from the third equation. At the end of the
second stage the augmented matrix becomes
   
  
 

 
C C C F
C C F
C F
ª º
« »
c c c« »
« »cc cc¬ ¼
(1.10)
The values of x1, x2, and x3 can be obtained by back substitution. The pivots should be chosen
in such a way that they are nonzero. Rows can be exchanged so that the pivot is nonzero. This
procedure is called partial pivoting.
6 Introduction to Numerical Methods in Chemical Engineering
EXAMPLE 1.2 Solve the following set of three linear algebraic equations in three variables
using the Gauss Elimination method:
    Z Z Z 
    Z Z Z 
    Z Z Z 
Solution The augmented matrix is
   
   
   
ª º
« »
« »
« »
¬ ¼
Multiply the first equation by


 and then add it to the second equation. We get
   
   
   
ª º
« »
« »
« »
¬ ¼
Multiply the first equation by


 and then add it to the third equation. We get
   
   
   
ª º
« »
« »
« »
¬ ¼
This completes the first stage. Multiply the second equation by


 and then add it to the
third equation. We get
   
   
   
ª º
« »
« »
« »
¬ ¼
From the previous equation we get
9.68367x3 = 48.418367
Solving, we get x3 = 5.
From the second equation we get
9.8x2 + 0.6x3 = 42.2
Thus 
  


Z
 u
From the first equation we get
10x1 + x2 + 2x3 = 44
Linear Algebraic Equations 7
Thus 
   


Z
  u
.
Program 1.2 uses the Gauss elimination method for solving a system of linear algebraic
equations and is given in the Appendix.
EXAMPLE 1.3 Solve the following set of three linear algebraic equations in three variables
using the Gauss Elimination method:
    Z Z Z 
    Z Z Z   
   Z Z Z 
Solution The augmented matrix is
   
   
   
ª º
« »
  « »
« »¬ ¼
Multiply the first equation by


and then add it to the second equation. We get
   
   
   
ª º
« »
 « »
« »¬ ¼
Multiply the first equation by


 and then add it to the third equation. We get
   
   
   
ª º
« »
 « »
« » ¬ ¼
Multiply the second equation by 0.3076923 and then add it to the third equation. We get
   
   
   
ª º
« »
 « »
« »¬ ¼
From the previous equation, we get
3.5384x3 = –3.5384
Solving, we get x3 = –1.
8 Introduction to Numerical Methods in Chemical Engineering
From the second equation, we get
4.3333x2 – 3.6667x3 = –5
Thus 
 


Z
 
 .
From the first equation, we get
3x1 + x2 – 2x3 = 9
Thus 
  


Z
 
.
EXAMPLE 1.4 Benzene (1), toluene (2), styrene (3), and xylene (4) are to be separated in
the sequence of distillation columns shown in Fig. 1.1. Determine molar flow rates of streams
D1, B1, D2, and B2. The composition of the feed stream and the streams D1, B1, D2, and B2 is
shown in the figure. Also, determine the molar flow rates and compositions of streams B and
D. The molar flow rate of the feed stream is 70 mol/min.
Fig. 1.1 Schematic diagram for Example 1.4.
Solution The material balance equations for benzene (1), toluene (2), styrene (3), and xylene
(4) are given below.
x1 = 0.35
x2 = 0.54
x3 = 0.04
x4 = 0.07
x1 = 0.16
x2 = 0.42
x3 = 0.24
x4 = 0.18
x1 = 0.21
x2 = 0.54
x3 = 0.10
x4 = 0.15
x1 = 0.01
x2 = 0.10
x3 = 0.65
x4 = 0.24
x1 = 0.20
x2 = 0.40
x3 = 0.25
x4 = 0.15
70 mol/min
D1
D
B1
D2
B
B2
Linear Algebraic Equations 9
         $  $u   
         $  $u   
         $  $u   
         $  $u   
The above equations can be written as




    
    
    
    

$

$
ª ºª º ª º
« »« » « »
« »« » « »
« »« » « »
« »« » « »
« » « »« »¬ ¼ ¬ ¼¬ ¼
Solving by using the Gauss Elimination method, we get
D1 = 26.25 mol/min
B1 = 17.5 mol/min
D2 = 8.75 mol/min
B2 = 17.5 mol/min.
B = D2 + B2 = 26.25 mol/min.
The composition of stream B is given by
 

 
$
 $
Z
$

 

 
$
 $
Z
$

 

 
$
 $
Z
$

 

 
$
 $
Z
$

D = D1 + B1 = 43.75 mol/min.
The composition of stream D is given by
 

 

 $
Z


 

 

 $
Z
10 Introduction to Numerical Methods in Chemical Engineering
 

 

 $
Z


 

 

 $
Z


Now, let us check the solution obtained. B + D is 70 mol/min, which is correct. Now, let us
back-calculate the feed composition.
 


 $Z $Z
 


 $Z $Z
 


 $Z $Z
 


 $Z $Z
1.3 Gauss–Seidel Method
Gauss–Seidel is an iterative method. Consider a system of N linear algebraic equations in N
variables. The first equation can be written with variable x1 on the left hand side and the rest
of the terms on the right hand side. Similarly, the second equation can be written with variable
x2 on the left hand side and the rest of the terms on the right hand side, and so on. Now we
can assume some values of the variables, and compute the new value of x1 from the first
equation and the new value of x2 from the second equation, and so on. In the Gauss–Seidel
method, when the new value of x2 is computed from the second equation then on the right hand
side for the variable x1 the updated value calculated from the first equation, is used. Similarly,
when the new value of x3 is calculated from the third equation, then on the right hand side for
the variables x1 and x2 the updated values calculated from the first and second equations are
used. By doing this a higher convergence rate is obtained. So the latest values of the variables
are always used.
In the above explanation it is assumed that in the first equation the coefficient of x1 is
the highest among the coefficients of the other variables, and in the second equation the
coefficient of x2 is the highest among the coefficients of the other variables. All the equations
have many variables in them. A survey of the given system of linear algebraic equations is
made and that variable which has the highest coefficient is kept on the left hand side. The
variable whose coefficient is the largest is used to express that variable in terms of the others.
The Gauss–Seidel method has the disadvantage of not always converging to a solution
and of sometimes converging very slowly. However, this method will always converge to a
solution when the magnitude of the coefficient on the left hand side is sufficiently dominant
with respect to the magnitudes of the other coefficients in that equation.
Linear Algebraic Equations 11
EXAMPLE 1.5 Solve the following set of three linear algebraic equations in three variables
using the Gauss–Seidel method:
10x1 + x2 + 2x3 = 44
2x1 + 10x2 + x3 = 51
x1 + 2x2 + 10x3 = 61
Solution It can be seen that the coefficient of x1 is dominant in the first equation, and the
coefficient of x2 and x3 are dominant in the second and third equations, respectively. Thus
  

 

P P
P Z Z
Z   

  

 

P P
P Z Z
Z

  
 
  

 

P P
P Z Z
Z
 
  
Let us assume x2 = 0, x3 = 0. The initial values used will not affect the converged solution, but
will affect the number of iterations required for convergence.
First Iteration:

  


Z
 

   


Z
 u 

   


Z
– 
Second Iteration:

   


Z
  u

   


Z
 u 

   


Z
  u
The final converged solution is 1x = 3, 2x = 4, 3x = 5.
Program 1.3 uses the Gauss–Seidel method for solving a system of linear algebraic equations
and is given in the Appendix.
EXAMPLE 1.6 Solve the following set of three linear algebraic equations in three variables
using the Gauss–Seidel method:
    Z Z Z 
    Z Z Z   
   Z Z Z
12 Introduction to Numerical Methods in Chemical Engineering
Solution Let us write the first, second and third equations in the form
  

 

P P
P Z Z
Z   

  

 

P P
P Z Z
Z

   
 
  



P P
P Z Z
Z
 
  
Let us assume x2 = 0, x3 = 0.
First Iteration:

  


Z
 

  


Z
  


  


Z
 

Second Iteration:

   


Z
  u

   


Z
   u


  


Z
 

The final converged solution is x1 = 3, x2 = –2, x3 = –1.
Exercises
1.1 Solve the following using TDMA:








  
   
   
   
   
   
   
  
Z
Z
Z
Z
Z
Z
Z
Z
 ª ºª º ª º
« »« » « »  « »« » « »
« »« » « » 
« »« » « »
  « »« » « »
« »« » « » 
« »« » « »
  « »« » « »
« »« » « » 
« »« » « »
 « »« » « »¬ ¼ ¬ ¼¬ ¼
(Ans: x1 = 111.11, x2 = 122.22, x3 = 133.33, x4 = 144.44, x5 = 155.55,
x6 = 166.66, x7 = 177.77, x8 = 188.88)
Linear Algebraic Equations 13
1.2 Solve the following linear algebraic equations using the Gauss elimination method:
2x1 – x2 = 100
– x1 + 2x2 – x3 = 0
– x2 + 2x3 – x4 = 0
– x3 + 2x4 – x5 = 0
– x4 + 2x5 – x6 = 0
– x5 + 2x6 – x7 = 0
– x6 + 2x7 – x8 = 0
– x7 + 2x8 = 200
Note that the augmented matrix for this problem is
        
        
        
        
        
        
        
        
ª º
« »
 « »
« » 
« »
 « »
« » 
« »
 « »
« » « »
« »¬ ¼
(Ans: x1 = 111.11, x2 = 122.22, x3 = 133.33, x4 = 144.44, x5 = 155.55,
x6 = 166.66, x7 = 177.77, x8 = 188.88)
1.3 Solve the equations in Problem 1.2 using the Gauss–Seidel method.
Note that the equations are expressed in the form
 



P
P Z
Z  

  


P P
P Z Z
Z

 

  


P P
P Z Z
Z

 

  


P P
P Z Z
Z

 

  


P P
P Z Z
Z
14 Introduction to Numerical Methods in Chemical Engineering

  


P P
P Z Z
Z

 

  


P P
P Z Z
Z

 

 



P
P Z
Z

 
(Ans: x1 = 111.11, x2 = 122.22, x3 = 133.33, x4 = 144.44, x5 = 155.55,
x6 = 166.66, x7 = 177.77, x8 = 188.88)
1.4 Solve the following linear algebraic equations using the Gauss elimination method:
4x1 + 2x2 + x3 = 11
–x1 + 2x2 = 3
2x1 + x2 + 4x3 = 16
Note that the augmented matrix is
   
   
   
ª º
« »
« »
« »
¬ ¼
(Ans: x1 = 1, x2 = 2, x3 = 3)
1.5 Solve the linear algebraic equations of Problem 1.4 using the Gauss–Seidel method:
Note that for Gauss–Seidel to converge the equations are expressed in the form
  

 

P P
P Z Z
Z   

 



P
P Z
Z

 
 
  

 

P P
P Z Z
Z
 
  
(Ans: x1 = 1, x2 = 2, x3 = 3)
1.6 Solve the following linear algebraic equations using the Gauss elimination method:
     Z Z Z 
   Z Z Z 
     Z Z Z 
(Ans: x1 = 1.2857, x2 = 1.9286, x3 = 2.8571)
Linear Algebraic Equations 15
1.7 Solve the linear algebraic equations of Problem 1.6 using the Gauss-Seidel method:
Note that for Gauss–Seidel to converge the equations are expressed in the form
  

  

P P
P Z Z
Z   

  



P P
P Z Z
Z

  
 
  

  

P P
P Z Z
Z
 
  
(Ans: x1 = 1.2857, x2 = 1.9286, x3 = 2.8571)
1.8 Solve the following linear algebraic equations using the Gauss elimination method:









         
         
         
         
        
        
        
        
        
6
6
6
6
6
6
6
6
6
ª º ª º
« »« » « »« »
« »« » 
« »« »
 « »« »
« »« »
« »« »
 « »« »
« »« »
« »« »
« »« »
« »« »
« » « »¬ ¼ ¬ ¼





ª º
« »
« »
« »
« »
« »
« »
« »
« »
« »
« »
« »
« »
« »¬ ¼
Note that for using the Gauss elimination method the equations have to expressed
in the form of augmented matrix as
         
         
         
         
         
         
         
         
         
ª º 
« »
 « »
« » 
« »
 « »
« »
« »
 « »
« » « »
« » 
« »
 « »¬ ¼
(Ans: T1,1 = 47.14, T1,2 = 91.25, T1,3 = 182.86, T2,1 = 57.32, T2,2 = 115.00,
T2,3 = 220.18, T3,1 = 47.14, T3,2 = 91.25, T3,3 = 182.86)
16 Introduction to Numerical Methods in Chemical Engineering
1.9 Solve the following linear algebraic equations using the Gauss–Seidel method:
  
   
  
   
    
   
  
   
  
 
 
 
 
 
 
 
 

6 6 6
6 6 6 6
6 6 6
6 6 6 6
6 6 6 6 6
6 6 6 6
6 6 6
6 6 6 6
6 6 6
   
   
  
   
   
   
  
   
  
Note that for Gauss–Seidel to converge the equations are to be expressed in the
form
 



P P
P 6 6
6   

  



P P P
P 6 6 6
6

   

 



P P
P 6 6
6

  

  



P P P
P 6 6 6
6

   
 
   


P P P P
P 6 6 6 6
6
 
   
 
  



P P P
P 6 6 6
6
 
   

 



P P
P 6 6
6

  
 
  



P P P
P 6 6 6
6
 
   
 
 



P P
P 6 6
6
 
  
(Ans: T1,1 = 47.14, T1,2 = 91.25, T1,3 = 182.86, T2,1 = 57.32, T2,2 = 115.00,
T2,3 = 220.18, T3,1 = 47.14, T3,2 = 91.25, T3,3 = 182.86)
17
Chapter 2
Nonlinear Algebraic Equations
Newton’s (or Newton–Raphson) method for the numerical solution of a nonlinear algebraic
equation is described first in this chapter. Examples discussed include the calculation of
pressure drop in a pipe in nonlaminar range, and the calculation of minimum fluidization
velocity and terminal velocity. Thereafter the solution of two simultaneous nonlinear algebraic
equations is discussed using Newton’s method.
2.1 Newton's Method
The function f is formulated in such a way that the polynomial or the expression whose root
is to be determined is of the form f (x) = 0. Newton’s method is given by
P P H
Z Z
H


c (2.1)
where xn
is the value of x at the start of the iteration and xn+1
is the updated value after the
iteration. First an initial value of x is assumed, and the function value and its derivative are
determined at this assumed value. The assumed value is updated by using Newton’s formula,
and again the function value and its derivative are determined at this new value of x (see
Fig. 2.1). The value of x is again updated and the procedure is repeated till there is no change
in the previous and updated values of x. By taking different starting (old) values, different roots
can be obtained, if more than one real root occurs. Note that when the root is obtained, there
is no change in the value of x. That is, xn+1
= xn
, which implies f = 0, which is the required
condition, that function value should become zero at the root. Note that Newton’s method
works only if, at f = 0, the derivative of the function is not zero. In Fig. 2.1, the function value
becomes zero at the root xs. In this case the starting value is taken to be x1.
The algorithm of Newton’s method is:
(i) Take an initial value of xn
,
(ii) Calculate f and
FH
H
FZ
c at the value of xn
,
(iii) Calculate the new value of x, using P P H
Z Z
H


c
,
(iv) Check if F
P P
Z Z
  ; if yes, stop, else
18 Introduction to Numerical Methods in Chemical Engineering
(v) Make xn
= xn+1
and go to Step (ii) and repeat the procedure till the condition stated
in (iv) is satisfied. e is the convergence criterion and may be of the order of 10–6
.
Fig. 2.1 Concept of Newton’s method.
The derivation of Newton’s formula is presented below. Let a nonlinear algebraic equation be
represented as f (x) = 0. Let us start with an initial guess x0
of the solution and let us assume
that it is close to the actual solution xs. We make a Taylor series to approximate f(x) in the
vicinity of x0
as follows:
 introduction-to-numerical-methods-in-chemical-engineering
 introduction-to-numerical-methods-in-chemical-engineering
 introduction-to-numerical-methods-in-chemical-engineering
Z Z
FH F H
H Z H Z Z Z Z Z
FZ FZ
    
At the solution, 
 5H Z = 0 and the Taylor series yields
 introduction-to-numerical-methods-in-chemical-engineering
 introduction-to-numerical-methods-in-chemical-engineering
5 5
Z Z
FH F H
H Z Z Z Z Z
FZ FZ
    
If x0
is sufficiently close to xs, then
  
   
5 5 5Z Z Z Z Z Z  
In this case, as long as the first derivative is nonzero at x0
, we obtain a reasonable
approximation of the solution, x1
, from the rule
 introduction-to-numerical-methods-in-chemical-engineering
Z
FH
H Z Z Z
FZ
  (2.2)
Successive application of this rule yields Newton’s method for solving a single nonlinear
algebraic equation in the form
 introduction-to-numerical-methods-in-chemical-engineering
P
P P
P
H Z
Z Z
H Z


c
f
f1
f2
f3
0 x1 x2 x3
x
xs
Nonlinear Algebraic Equations 19
where f ¢ denotes the derivative of the function with respect to x. The iterations are stopped
when the previous and updated values of x are less than eabs, that is
F

CDU
P P
Z Z
  (2.3)
or

TGN
P P
P
Z Z
Z
F



 (2.4)
Consider that the real roots of the equation x3
– 2x2
– x + 2 = 0 have to be determined.
Different roots are obtained by taking different starting values of x. Newton’s method
discussed here determines only the real roots. For the above equation the starting values taken
and the corresponding roots are listed in Table 2.1.
Table 2.1 Different roots obtained by taking different starting values in Newton’s method
Starting value Real root of x3
– 2x2
– x + 2 = 0 by Newton’s method
4.0 2.0
1.5 –1.0
0.5 1.0
0.25 1.0
0.0 2.0
–1.0 –1.0
–2.0 –1.0
–4.0 –1.0
–100.0 –1.0
100.0 2.0
Thus the three roots on which the solution converges are (2, 1, –1). Various iterations in
Newton’s method to determine the real root of the equation x3
– 2x2
– x + 2 = 0 with starting
value x = 4 are listed in Table 2.2.
Table 2.2 Various iterations in Newton’s method for starting value of 4x
Iteration number Starting point f f ¢
P P H
Z Z
H


c
1 4.0 30.0 28.0 2.92857
2 2.92857 7.03533 13.01529 2.38803
3 2.38803 1.82478 6.55594 2.10969
4 2.10969 0.37852 3.91362 2.01297
5 2.01297 0.03959 3.10426 2.00022
6 2.00022 0.00066 3.00176 2.00000
7 2.00000 0.00000 3.00000 2.00000
In Table 2.2, f = x3
– 2x2
– x + 2, and f ¢ = 3x2
– 4x – 1 .
20 Introduction to Numerical Methods in Chemical Engineering
EXAMPLE 2.1 Apply Newton’s method to determine a real root of the equation
f (x) = x3
– 5x + 1 = 0
Take the initial approximation as x0 = 0.5.
Solution With an initial value of 0.5, it can be checked that the solution is 0.201640.
2.2 Pressure Drop in Pipe
The pressure drop in a pipe of length L is given by the relation
S
'


H.8
2

(2.5)
where 8 is the average velocity in the pipe of internal diameter D and the fluid density is r.
When the pressure drop is given by Eq. (2.5), the friction factor under laminar flow conditions
is given by

4G
H (2.6)
where
S
N
4G
8
. For the entire nonlaminar range the friction factor is given by the Colebrook
relation
F  
 NQI
 4G

H H
§ ·
 ¨ ¸¨ ¸
© ¹
(2.7)
For the laminar conditions the friction factor can be easily determined. But for nonlaminar
conditions the Colebrook equation has to be solved using Newton’s method as described in the
example below.
EXAMPLE 2.2 Air at 25°C and 1 atm flows through a 4 mm diameter tube with an average
velocity of 50 m/s. The roughness is e = 0.0015 mm. Calculate the friction factor using the
Colebrook equation
F  
 NQI
 4G

H H
§ ·
 ¨ ¸¨ ¸
© ¹
Determine the pressure drop in a 1 m section of the tube using the relation
S
'


H.8
2

Density of air at 25°C and 1 atm is 1.23 kg/m3
and viscosity is 1.79 ´ 10–5
kg/m-s.
Solution We have
F
Nonlinear Algebraic Equations 21
S
N


   
4G 
 
8 

u u u
u
Thus
  
NQI
 H H
§ ·
 ¨ ¸¨ ¸
© ¹
or

  
 NQI  
H H


§ ·u
 u ¨ ¸¨ ¸
© ¹
Let us define a function, F, as

  
 NQI  (
H H


§ ·u
 u ¨ ¸¨ ¸
© ¹
The derivative of the function with respect to the friction factor is given by
H
( H
H
 

  
u u u 
c  
u  u
Using Newton’s method, we get f = 0.0291. Under these conditions the pressure drop in a 1 m
section of the pipe is given by
'

   

 
2
u u u
u
N/m2
= 11.19 kPa
Program 2.1 for calculating the pressure drop in a pipe under nonlaminar conditions is given
in the Appendix.
2.3 Minimum Fluidization Velocity
Ergun proposed the following general equation applicable for low, medium and high Reynolds
number for pressure drop across a packed bed:
 introduction-to-numerical-methods-in-chemical-engineering
F FN S
GG F F
' '
'
 
   
  
U RU R
X . X .
2
FF
 
 (2.8)
where n is the superficial velocity of the fluid, dp is the particle diameter, fs is the sphericity
of the particle, e is the voidage in the packed bed, and DP is the pressure drop across the
packed bed of length DL . r and m are respectively the density and viscosity of the fluid. At
the point of incipient fluidization the force obtained from the pressure drop across the fluidized
bed (DP ´ A) is equal to the gravitational force exerted by the mass of the particles minus the
buoyancy force. If Lmf is the height of the packed bed at the point of minimum fluidization
22 Introduction to Numerical Methods in Chemical Engineering
and emf is the voidage of the packed bed at minimum fluidization, then the total volume of the
bed at minimum fluidization is Lmf ´ A and thus the volume of solids at minimum fluidization
is Lmf A(1 – emf). The gravitational force of the particles minus the buoyancy force is given
by volume of the solid particles ´ (rp – r)g. Thus at minimum fluidization conditions
 introduction-to-numerical-methods-in-chemical-engineering
F S S' OH OH R2 # . # Iu   (2.9)
or
 introduction-to-numerical-methods-in-chemical-engineering
F S S
'
OH
OH
 R
2
I
.
  (2.10)
Substituting this value in the Ergun equation for packed bed, we get
 introduction-to-numerical-methods-in-chemical-engineering
 introduction-to-numerical-methods-in-chemical-engineering
 introduction-to-numerical-methods-in-chemical-engineering
F FS N
F S S
G F G F

OH OH
OH OH OH   
OH OH
  
 R
U R U R
X X I
F F
ª ºª º 
« »   « »
« »« »¬ ¼ ¬ ¼
(2.11)
The real roots of the minimum fluidization velocity can be obtained using Newton’s
method.
EXAMPLE 2.3 Solid particles having a diameter of 0.12 mm, shape factor fs = 0.88, and
a density of 1000 kg/m3
are to be fluidized using air at 2.0 atm and 25o
C. The
voidage at minimum fluidization is 0.42. The viscosity of air under these conditions is
1.845 ´ 10–5
kg/m-s. The molecular weight of air is 28.97.
Solution The density of air at 2.0 atm and 25°C is given by
S

   

 
2/
46

u u u
u
kg/m3
The diameter of the particle is pd = 1.2*10-4
m. The function is
 introduction-to-numerical-methods-in-chemical-engineering
 introduction-to-numerical-methods-in-chemical-engineering
 introduction-to-numerical-methods-in-chemical-engineering
F FS N
F S S
G F G F

OH OH
OH OH OH   
OH OH
  
 R
U R U R
H X X I
F F
ª ºª º 
« »   « »
« »« »¬ ¼ ¬ ¼
and the derivative of the function with respect to nmf is
 introduction-to-numerical-methods-in-chemical-engineering
F FS N
G F G F

OH OH
OH   
OH OH
  

U R U R
H X
F F
ª º 
c « »
« »¬ ¼
Starting with an initial value of nmf = 0.1 m/s, the converged value is nmf = 0.0046 m/s.
Program 2.2 for calculating the minimum fluidization velocity is given in the Appendix.
Nonlinear Algebraic Equations 23
2.4 Terminal Velocity
Consider a particle of mass m kg falling at velocity of v m/s (see Fig. 2.2). The momentum
balance equation is given by
R
I D 
FX
O ( ( (
FV
  (2.12)
Gravitational force minus the buoyancy force on the particle is given by
 introduction-to-numerical-methods-in-chemical-engineering
S S S S
SI D R R R
R
O
( ( 8 I I   (2.13)
where VP is the volume of the particle and m is the mass of the particle.
Fig. 2.2 Various forces acting on particle falling in stationary fluid.
The terminal velocity or free settling velocity is a constant velocity fall and is given when

RFX
FV
; thus
I D ( ( ( (2.14)
CD is given by
S 



 R

V
( #
%
X
. Thus Eq. (2.14) becomes
S S S
S


R R  V
R
O
I # % X (2.15)
where Ap is the projected area of the particle on a plane at right angles to the direction of
motion and nt is the terminal velocity of the falling particle. As the velocity of particle rises
the drag force also increases till the drag force balances the (gravitational – buoyancy) force.
Thus,
S S
S S
 R
V
R R 
I O
X
# %

FD
Fg – Fb = (rp – r)Vpg
24 Introduction to Numerical Methods in Chemical Engineering
For spherical particles,
Q
Q S S 
 
R R R RO T F
and the projected area is given by
Q
Q



R
R R
F
# T
Thus for spherical particles the expression for terminal velocity becomes
S S
S


R R
V

IF
X
%

(2.16)
For laminar flow (Rep  1), that is, in the Stokes law region

4G

R
% (2.17)
where Rep is the particle Reynold’s number and is given by
S
N
4G
R
R
XF
. We get the
following expression for terminal settling velocity in the laminar flow regime
S S
N


R R
V
IF
X

(2.18)
For turbulent flow, CD = 0.44 (Rep  1000 to 2 ´ 105
). But for intermediate values of the
particle Reynolds number, there are many correlations. The Schiller and Nauman correlation
is applicable for Rep  800 and is given by
4G
4G
 R
R
%  (2.19)
The terminal velocity for the case of intermediate values of particle Reynolds number is
determined using the following steps:
(i) A value of terminal velocity is assumed.
(ii) At the assumed value the particle Reynolds number is calculated and thereafter CD
is determined.
(iii) The terminal velocity is recalculated using
S S
S


R R
V

IF
X
%

.
If the assumed value and recalculated values are different, the new calculated value becomes
the starting value for the next iteration. The procedure is repeated till the absolute value of the
difference between the new value and the previous value of the terminal velocity in an iteration
is negligible.
Nonlinear Algebraic Equations 25
EXAMPLE 2.4 Oil droplets of diameter 2 mm are to be settled from air at 25°C and 1 atm.
The density of oil is 900 kg/m3
. Calculate the terminal settling velocity of the particles. For
air at these conditions, m = 1.85 ´ 10–5
kg/m-s. CD is given by
4G
4G
 R
R
% 
Solution The following data are given: dp = 2 ´ 10–3
m, m = 1.85 ´ 10–5
kg/m-s. The density
of air under the given conditions is given by
S

  

 
2/
46

u u
u
kg/m3
The particle Reynolds number is given by
S
N


  
4G 
 
I V R V
R V
X F X
X


u u u
u
The calculations are presented in Table 2.3.
Table 2.3 Calculations in Example 2.6
Assumed nt Rep CD nt
0.03 3.83 8.63 1.5
1.5 191.35 0.82 4.9
4.9 625.0 0.52 6.2
6.2 790.0 0.47 6.47
6.47 825.38 0.47 6.52
The terminal velocity obtained is 6.5285 m/s.
Program 2.3 for calculating the terminal velocity is given in the Appendix.
2.5 System of Nonlinear Equations
We now extend Newton’s method to solve a set of N simultaneous nonlinear algebraic
equations for N unknowns.
 introduction-to-numerical-methods-in-chemical-engineering
 introduction-to-numerical-methods-in-chemical-engineering
 introduction-to-numerical-methods-in-chemical-engineering
!
!
!

!
   
   
   
  
    
    
    
    
0
0
0
0 0
H Z Z Z Z
H Z Z Z Z
H Z Z Z Z
H Z Z Z Z
We define the vector of unknowns
26 Introduction to Numerical Methods in Chemical Engineering
 @  
6
0Z Z Z Z Z
and write the system of equations as
f (x) = 0
We use a Taylor series expansion to obtain Newton’s method, representing the ith function in
the vicinity of the current estimate xn
as
 introduction-to-numerical-methods-in-chemical-engineering
 introduction-to-numerical-methods-in-chemical-engineering
 introduction-to-numerical-methods-in-chemical-engineering
 introduction-to-numerical-methods-in-chemical-engineering
P P
0 0 0
P P P PK K
K K O O O O R R
O O RO O RZ Z
H H
H Z H Z Z Z Z Z Z Z
Z Z Z
˜ ˜
    
˜ ˜ ˜Ç Ç Ç 
Assuming that xn
is sufficiently close to the true solution xS, we can drop the quadratic and
higher order terms
 introduction-to-numerical-methods-in-chemical-engineering
P
0
P PK
K 5 O O
OO Z
H
H Z Z Z
Z
˜
  
˜Ç
For convenience we collect the first partial derivatives into the N ´ N Jacobian matrix
P
K
KO
O Z
H
,
Z
˜
˜ (2.20)
The truncated Taylor series expansion then becomes
 introduction-to-numerical-methods-in-chemical-engineering
0
P P P P
K KO O O
O
H Z , Z Z
|  ¦
or
0
P P P
KO O K
O
, Z H Z' 
¦ (2.21)
where the update vector is given by
 P P P
Z Z Z'  
 (2.22)
The terms on the left hand side of Eq. (2.21) are the ith component of a matrix–vector
product. The linear system is
P P P
, Z H Z' 
(2.23)
Iterations are performed till there is no change in Nxxxx ,...,,, 321 , that is
F F F F' ' ' '!   
 CDU  CDU  CDU CDU   P P P P
0Z Z Z Z   
    (2.24)
Let us consider two nonlinear equations f1(x1, x2) and f2(x1, x2). To start the iteration, some
initial values of x1 and x2 have to be assumed. The change in the values of x1 and x2 are
determined using Eq. (2.23).
 
 
 
 
 
 
H H
Z Z
H H
Z Z
Z H
Z H
˜ ˜
˜ ˜
˜ ˜
˜ ˜
Ë Û
'Ë Û Ë ÛÌ Ü Ì Ü Ì ÜÌ Ü 'Í Ý Í ÝÌ ÜÍ Ý
(2.25)
Nonlinear Algebraic Equations 27
Now we have to find the inverse of the Jacobian matrix. The inverse of a nonsingular
2 ´ 2 matrix  
 
C C
#
C C
Ë Û
Ì Ü
Í Ý
is given by
 
 

FGV
C C
#
C C#
Ë Û
Ì ÜÍ Ý
. Thus Eq. (2.25) can be
written as
 
  
  
 

H H
Z ZZ H
Z HH H
Z Z
˜ ˜Ë Û
Ì Ü˜ ˜'Ë Û Ë Û
Ì ÜÌ Ü Ì Ü' ˜ ˜Ì ÜÍ Ý Í ÝÌ Ü˜ ˜Í Ý
(2.26)
where
   
   
H H H H

Z Z Z Z
˜ ˜ ˜ ˜

˜ ˜ ˜ ˜
(2.27)
Thus
 
 
 

H H
H H
Z Z
Z

˜ ˜

˜ ˜
' (2.28)
and
 
 
 

H H
H H
Z Z
Z

˜ ˜

˜ ˜
' (2.29)
The algorithm for solution of two simultaneous nonlinear algebraic equations is given below:
(i) Assume x1 and x2,
(ii) Calculate f1, f2, 

H
Z
˜
˜
, 

H
Z
˜
˜
, 

H
Z
˜
˜
, and 

H
Z
˜
˜
,
(iii) Calculate Dx1 and Dx2, and
(iv) Calculate new values of x1 and x2.
Go to (ii) till F

 
P P
Z Z
  and F

 
P P
Z Z
  .
EXAMPLE 2.5 Obtain the values of x and y that satisfy the following two nonlinear algebraic
equations:
 introduction-to-numerical-methods-in-chemical-engineering
UKP  
Z
H Z [ G Z[
I Z [ Z[ Z [
 
  
Solution The partial derivatives of function f are given by
ZH
G [
Z
H
Z
[
˜

˜
˜
˜
28 Introduction to Numerical Methods in Chemical Engineering
The partial derivatives of function g are given by
EQU 
EQU 
I
[ Z[
Z
I
Z Z[
[
˜

˜
˜

˜
Let us assume x = 0.1 and y = 0.5.
 introduction-to-numerical-methods-in-chemical-engineering
UKP  


EQU  
EQU  

   


Z
Z
H Z [ G Z[
I Z [ Z[ Z [
H
G [
Z
H
Z
[
I
[ Z[
Z
I
Z Z[
[
H I H I

Z [ [ Z
H I
I H
[ [
Z

I H
H I
Z[
 
   
˜

˜
˜
˜
˜

˜
˜

˜
˜ ˜ ˜ ˜

˜ ˜ ˜ ˜
˜ ˜

 –  –˜ ˜
' 
˜ ˜

˜'
   


Z

–  –˜
New x = 0.1 – 0.13036 = –0.03036
New y = 0.5 + 0.5406 = 1.0406
The iterations are summarized in Table 2.4.
Table 2.4 Summary of iterations in Example 2.5
x y f g
H
Z
˜
˜
H
[
˜
˜
I
Z
˜
˜
I
[
˜
˜
D Dx Dy
0.1 0.5 0.1552 –0.3991 1.6052 0.1 1.5 1.1 1.6157 –0.13036 0.5406
–0.03036 1.0406 –0.0615 0.0097 2.0107 –0.03036 2.0406 0.9696 2.0115 0.0295 –0.0721
–0.00086 0.9685 –0.0017 –0.0324 1.9676 –0.00086 1.9685 0.99914 1.9676 0.00088 0.0307
0 0.9992 0.0000 –0.0008 1.9992 0 1.9992 1 1.9992 0 0.0008
0 1 0 0 2 0 2 1 2 0 0
Nonlinear Algebraic Equations 29
The solution of the given nonlinear algebraic equations is x = 0 and y = 1. Note that when
f = 0 and g = 0 the solution is obtained.
Program 2.4 for the solution of the above two simultaneous nonlinear equations is given in the
Appendix.
EXAMPLE 2.6 Modify Program 2.4 to solve the following system of two nonlinear algebraic
equations:
 introduction-to-numerical-methods-in-chemical-engineering
H Z Z Z Z
H Z Z Z Z
 
 
Solution For the given nonlinear equations
    
   
   
   CPF 
H H H H
Z Z Z Z
Z Z Z Z
˜ ˜ ˜ ˜

˜ ˜ ˜ ˜
Program 2.4 can be modified to obtain the following solution: x1 = 3 and x2 = 4.
Exercises
2.1 Determine the root of the equation
 
    Z Z Z  
which is close to 2.5.
(Ans: 2.5034)
2.2 Air at 25°C and 1 atm flows through a 4 mm diameter tube with an average velocity
of 25 m/s. The roughness is e = 0.0015 mm. The friction factor is given by
F  
 NQI
 4G

H H
§ ·
 ¨ ¸¨ ¸
© ¹
Determine the pressure drop in a 1 m section of the tube using the relation
S
'


H.8
2

The density of air at 25°C and 1 atm is 1.23 kg/m3
and the viscosity is
1.79 ´ 10–5
kg/m-s.
(Ans: f = 0.03467, DP = 3.33 kPa)
2.3 Solid particles having a diameter of 0.05 mm, shape factor fs = 0.88, and density
of 1000 kg/m3
are to be fluidized using air at 2.0 atm and 25°C. The voidage
at minimum fluidization is 0.39. The viscosity of air under these conditions is
1.845 ´ 10-5
kg/m-s. The molecular weight of air is 28.97.
(Ans: 0.000611 m/s)
30 Introduction to Numerical Methods in Chemical Engineering
2.4 Solve Exercise 2.3 for solid particles having a diameter of 0.25 mm. The voidage
at minimum fluidization is 0.48.
(Ans: 0.0327 m/s)
2.5 Oil droplets of diameter 0.2 mm are to be settled from air at 25°C and 1 atm. The
density of oil is 900 kg/m3
. Calculate the terminal settling velocity of the particles.
Viscosity of air under these conditions is 1.85 ´ 10–5
kg/m-s. CD is given by
4G
4G
 R
R
% 
(Ans: 0.6462 m/s)
2.6 Solve Exercise 2.5 for oil droplets of diameter 0.02 mm.
(Ans: 0.0105 m/s)
31
Chapter 3
Chemical Engineering
Thermodynamics
The calculation of molar volume using the van der Waals, Redlich–Kwong, and Peng–
Robinson cubic equations of state at the given temperature and pressure is discussed first in
this chapter. After this, bubble point, dew point, and flash calculations using Raoult’s and
modified Raoult’s law are discussed. The determination of vapour pressure at the given
temperature for a pure substance following a cubic equation of state is thereafter discussed.
The determination of system pressure and vapour phase composition at the given temperature
and liquid phase composition is discussed using the gamma–phi
G HK K K K K
[ 2 Z H and phi–phi
G G8 .
K K K K[ 2 Z 2 approaches. The solution of two simultaneous chemical reactions in
equilibrium in the homogeneous phase and the calculation of adiabatic flame temperature are
also discussed in this chapter.
3.1 Solution of Cubic Equations of State
The molar volume of both the saturated vapour and saturated liquid can be calculated using
cubic equations of state. The cubic equations of state can have three real roots or one real root
and two complex roots. When there is only one real root, then only one phase exists—liquid
or vapour—and when three real roots exist, then there are two phases. The smallest root is the
molar volume of saturated liquid and the largest root is the molar volume of saturated vapour.
The intermediate root is of the no physical significance. To determine the molar volume of the
liquid phase, the starting value taken is V = b, and to determine the molar volume of the vapour
phase, the starting value taken is
46
8
2
.
The van der Waals equation of state is

46 C
2
8 D 8

 (3.1)
The cubic form of the van der Waals cubic equation of state is given by
 

46 C CD
8 D 8 8
2 2 2
§ ·
   ¨ ¸
© ¹
(3.2)
where
 


E
E
4 6
C
2
and

E
E
46
D
2
32 Introduction to Numerical Methods in Chemical Engineering
Let us define the function as  46 C CD
H 8 D 8 8
2 2 2
§ ·
   ¨ ¸
© ¹
. At the given temperature and
pressure and given critical properties of the substance, the only unknown in this equation is
the molar volume V. The derivative of the function f with respect to the molar volume is given
by

 
46 C
H 8 D 8
2 2
§ ·
c   ¨ ¸
© ¹
(3.3)
A value of molar volume is assumed. At the assumed molar volume the value of the
function f and its derivative f¢ are determined and the new molar volume is determined using
Newton’s method [see Eq. (2.1)]
P P H
8 8
H


c (2.1)
Thereafter, the new molar volume becomes the old molar volume, and f and ’f are determined
again at this molar volume. The procedure is repeated till there is a very meagre change
between the new and old molar volumes, that is,  
P P
8 8 
  .
The Redlich-Kwong equation of state is
46 C
2
8 D 6 8 8 D

  (3.4)
The cubic form of the Redlich-Kwong cubic equation of state is given by
  

46 D46 C CD
8 8 D 8
2 2 62 62
§ ·
    ¨ ¸
© ¹
(3.5)
where
 
 E
E
4 6
C
2
and
 E
E
46
D
2
.
Let us define the function as   46 D46 C CD
H 8 8 D 8
2 2 62 62
§ ·
    ¨ ¸
© ¹
. At the given
temperature and pressure and given the critical properties of the substance, the only unknown
in this equation is the molar volume, V. The derivative of the function f with respect to the
molar volume is given by
 
 
46 D46 C
H 8 8 D
2 2 62
È Ø
   „ É ÙÊ Ú
(3.6)
The Peng–Robinson equation of state is
 

46 C
2
8 D 8 D8 D

  
(3.7)
The cubic form of the Peng–Robinson cubic equation of state is given by
    
 
46 46D C 46 CD
8 D 8 D 8 D D
2 2 2 2 2
§ · § ·
       ¨ ¸ ¨ ¸
© ¹ © ¹
(3.8)
Chemical Engineering Thermodynamics 33
B
B
X X



 
  

E
E
E
E
E
46
C
2
6
O
6
O
46
D
2
§ ·
 ¨ ¸¨ ¸
© ¹
 
Let us define the function as
    

46 46D C 46 CD
H 8 D 8 D 8 D D
2 2 2 2 2
§ · § ·
       ¨ ¸ ¨ ¸
© ¹ © ¹
At the given temperature and pressure and given critical properties of the substance the only
unknown in this equation is the molar volume V. The derivative of the function f with respect
to the molar volume is given by
  
  
46 46D C
H 8 D 8 D
2 2 2
§ · § ·
c     ¨ ¸ ¨ ¸
© ¹ © ¹
(3.9)
EXAMPLE 3.1 Calculate the molar volume of saturated liquid water and saturated water
vapor at 100°C and 101.325 kPa using van der Waals, Redlich–Kwong and Peng–Robinson
cubic equations of state. For water: TC = 647.1 K, PC = 220.55 bar, and w = 0.345.
Solution Program 3.1 for calculating the molar volume at the given temperature and pressure
using various cubic equations of state is given in the Appendix. The result obtained from the
program is given below.
Saturated liquid volume using Peng–Robinson equation of state = 2.25 ´ 10–5
m3
/mol
Saturated vapour volume using Peng–Robinson equation of state = 0.030352 m3
/mol
Saturated liquid volume using Redlich–Kwong equation of state = 2.64 ´ 10–5
m3
/mol
Saturated vapour volume using Redlich–Kwong equation of state = 0.030400 m3
/mol
Saturated liquid volume using van der Waals equation of state = 3.90 ´ 10–5
m3
/mol
Saturated vapour volume using van der Waals equation of state = 0.030469 m3
/mol.
3.2 Bubble Point and Dew Point Temperature Calculations
Using Raoult's Law
3.2.1 Bubble Point Temperature Calculation
When the liquid phase composition is given, the governing equation is UCV UCV
   2 Z 2 Z 2 . In
this problem, along with the liquid phase composition the system pressure is given and the
bubble point temperature and the vapour composition have to be determined. Newton’s method
34 Introduction to Numerical Methods in Chemical Engineering
is used to determine the temperature which satisfies the equation UCV UCV
   2 Z 2 Z 2 . Let us
formulate a function f.
UCV UCV
   H 2 Z 2 Z 2  (3.10)
Using Antoine equation
UCV
NP
$
2 #
6 %

 (3.11)
we get
 
   
 
GZR GZR
$ $
H 2 Z # Z #
6 % 6 %
§ · § ·
   ¨ ¸ ¨ ¸
 © ¹ © ¹
(3.12)
In the above equation the Antoine parameters, system pressure and liquid composition are
given. The only unknown is the temperature. The derivative of the function f with respect to
temperature is given by
 introduction-to-numerical-methods-in-chemical-engineering
UCV UCV
     
 
 
Z 2 $ Z 2 $
H
6 % 6 %
c  
 
(3.13)
A value of temperature is assumed. At the assumed temperature the value of function f and its
derivative f ¢ are determined and the new temperature is determined using [see Eq. (2.1)]
P P H
6 6
H


c (2.1)
Thereafter the new temperature becomes the old temperature and again at this temperature, f
and f ¢ are determined. The procedure is repeated till there is a very meagre change between
the new and old temperatures, that is,  
P P
6 6 
  . This equation can also be written as




P P
P
6 6
6




 .
The assumed temperature is calculated from the relation UCVP
K K6 Z 6¦ . The saturation
temperatures UCV
6 and UCV
6 are calculated for the given pressure using the Antoine equation
UCV
NP
$
6 %
# 2

 (3.14)
Once the temperature that satisfies the equation UCV UCV
   2 Z 2 Z 2 is determined, the vapour
phase composition can be determined using
UCV
 

Z 2
[
2
and
UCV
 

Z 2
[
2
.
3.2.2 Dew Point Temperature Calculation
When the vapour phase composition is given, use is made of  
UCV UCV
 
 [ [
2 2 2
 . In this problem
system pressure is given along with vapour phase composition and dew point temperature and
liquid phase composition have to be determined. Newton’s method is used to determine the
temperature which satisfies the equation  
UCV UCV
 
 [ [
2 2 2
 . Let us formulate a function f .
Chemical Engineering Thermodynamics 35
 
UCV UCV
 
 [ [
H
2 2 2
  (3.15)
Using the Antoine equation UCV
NP
$
2 #
6 %


, we get
 
   
 

GZR GZR
$ $
H [ # [ #
2 6 % 6 %
§ · § ·
     ¨ ¸ ¨ ¸
 © ¹ © ¹
(3.16)
Here in this equation the Antoine parameters, system pressure and vapour composition are
given. The only unknown is the temperature. The derivative of the function f with respect to
temperature is given by
 introduction-to-numerical-methods-in-chemical-engineering
UCV UCV
   
[ $ [ $
H
2 6 % 2 6 %
c 
  (3.17)
A value of temperature is assumed. At the assumed temperature the value of the function f and
its derivative H c are determined and the new temperature is determined using
P P H
6 6
H


c
Thereafter, the new temperature becomes the old temperature and f and H c are determined
again at this temperature. The procedure is repeated till there is a very meagre change between
the new and old temperatures, that is,  
P P
6 6 
  . This equation can also be written as




P P
P
6 6
6




 . The assumed temperature is calculated from the relation UCVP
K K
6 [ 6¦ .
Once the temperature that satisfies the equation  
UCV UCV
 
 [ [
2 2 2
 is determined, the liquid
phase composition can be determined using

 UCV

[ 2
Z
2
and 
 UCV

[ 2
Z
2
.
EXAMPLE 3.2 Calculate the bubble point and dew point temperatures for the acetone (1) –
water (2) system at 101.325 kPa for feed composition z1 = 0.5. Assume the system to follow
Raoult’s law.
Solution Program 3.2 for calculating the bubble and dew point temperatures for a system
following Raoult’s law is given in the Appendix. The result obtained from the program is
bubble point temperature = 71.81°C, dew point temperature = 87.08°C.
3.3 Flash Calculations Using Raoult's Law
The aim here is to calculate the compositions of the vapour and liquid phases at the given
temperature and pressure under flash conditions, assuming Raoult’s law to be true. For a
mixture at the given pressure, if the temperature lies between the bubble point and dew point
36 Introduction to Numerical Methods in Chemical Engineering
temperatures or at the given temperature, if the pressure lies between the dew point and bubble
point pressure, both liquid and vapour exist. In this section we shall determine the equilibrium
liquid and vapour phase compositions if the temperature, system pressure and feed composition
are given. The overall composition is denoted by zi and L and V denote the amount of moles
in the liquid and vapour phases respectively. Let the initial total number of moles before
flashing be 1. The distribution coefficient (Ki) for a species is defined as its composition in the
vapour phase divided by its composition in the liquid phase. We can write for a particular
species that
K
K
K
[
-
Z
(3.18)
For a system following Raoult’s law,
UCV
K
K
2
-
2
; therefore, if the temperature and the pressure
of the system are given, then the K values of all the components can be calculated. The
composition of the vapour in terms of Ki and feed composition is given by

K K
K
K
- 
[
8 8- 
(3.19)
and the composition of the liquid phase is given by

K
K
K

Z
8 8- 
(3.20)
Finally we should have


K K
K
K
- 
[
8 8- ¦ ¦ (3.21)
where the summation is over all the components, and also


K
K
K

Z
8 8- ¦ ¦ 3.22)
Therefore let us define a function
K K
K K
K
- 
H [ Z
8 8-


 ¦ ¦ ¦ (3.23)
The function has to be formulated in such a way that its required value is zero. In this equation
the only unknown is V, which is the number of moles in the vapour phase per unit mol fed
to the system. The derivative of the function with respect to V is given by
 introduction-to-numerical-methods-in-chemical-engineering
K K
K
- 
H
8 8-

c 
 
¦ (3.24)
A value of V is assumed. At the assumed V the value of the function f and its derivative f ¢
are determined and the new V is determined using
P P H
8 8
H


c
Chemical Engineering Thermodynamics 37
Thereafter, the new V becomes the old V and again at this V the function f and its derivative
f ¢ are determined. The procedure is repeated till there is a very meagre change between the
new and old values of V, that is,  
P P
8 8 
  . Once V is determined, the vapour and
liquid phase composition can be determined.
EXAMPLE 3.3 Calculate the compositions of the liquid and vapour phases for the acetone
(1)–acetonitrile (2)–nitromethane (3) system. The feed composition is z1 = 0.3, z2 = 0.3 and z3
= 0.4. At the given temperature, UCV
2 195.75 kPa, UCV
2 97.84 kPa, and UCV
2 50.32 kPa.
The pressure of the system is 100 kPa. Assume the system to follow Raoult’s law.
Solution Program 3.3 for calculating the composition of the liquid and vapour phases under
flash conditions for a system following Raoult’s law is given in the Appendix. The result
obtained from the program is given below: x1 = 0.25057, y1 = 0.490491, x2 = 0.301341,
y2 = 0.294832, x3 = 0.44561, y3 = 0.224231. The number of moles in vapour phase is 0.206026.
3.4 Bubble Point and Dew Point Temperature Calculations
Using Modified Raoult's Law
The modified Raoult’s law is given by
UCV
  [ 2 Z 2H 
(3.25)
UCV
   [ 2 Z 2H (3.26)
The activity coefficients can be determined using various models. In the present case the
Wilson model is used, because for a given system the activity coefficients can be determined
as a function of the temperature and the liquid composition. The Wilson parameters are given
by
 


GZR
8 C
8 46
È Ø
/ É ÙÊ Ú (3.27)
 


GZR
8 C
8 46
È Ø
/ É ÙÊ Ú (3.28)
The activity coefficients are given by
 
   
     
NP NP
 Z Z Z
Z Z Z Z
H 
Ë Û/ /
  /  Ì Ü
 /  /Í Ý
(3.29)
 
    
     
NP NP
 Z Z Z
Z Z Z Z
H
Ë Û/ /
  /  Ì Ü
 /  /Í Ý
(3.30)
Calculation of bubble point pressure
(i) Enter the temperature and the liquid composition.
38 Introduction to Numerical Methods in Chemical Engineering
(ii) Calculate the vapour pressure of the components at the given temperature.
(iii) Calculate the activity coefficients at the given temperature and liquid composition.
(iv) Calculate the bubble point pressure using the relation UCV UCV
     2 Z 2 Z 2H H
Calculation of bubble point temperature
(i) Enter the pressure and the liquid composition
(ii) At the given pressure, calculate the saturation temperature of the components and the
assumed temperature using UCVP
K K
6 Z 66 .
(iii) At the assumed temperature, calculate the vapour pressure of the components and the
activity coefficients.
(iv) Update the vapour pressure of Component 1 using the relation
UCV
 UCV

   UCV

2
2
2
Z Z
2
H H 
(v) From the updated value of UCV
2 , calculate the temperature using

UCV
 NP
$
6 %
# 2


(vi) Go to Step (iii) and repeat the procedure till convergence in temperature is obtained.
Calculation of dew point pressure
(i) Enter the temperature and the vapour composition.
(ii) Calculate the vapour pressure of the components at the given temperature.
(iii) Initially assume the activity coefficients to be one and calculate the system pressure
using
 
UCV UCV
 

2
[ [
2 2H H 

(iv) Calculate the liquid composition using 
 UCV

[ 2
Z
2H 
and

 UCV
 
[ 2
Z
2H
.
(v) Update the liquid composition using
21
1
1
xx
x
x

and 12 1 xx  .
(vi) At the liquid composition, calculate the activity coefficients.
(vii) Go to Step (iv) and repeat the procedure till convergence in activity coefficients is
obtained.
(viii) Calculate the system pressure using
Chemical Engineering Thermodynamics 39
 
UCV UCV
 

2
[ [
2 2H H 

(ix) Go to Step (iv) and repeat the procedure till convergence in the pressure is obtained.
Calculation of dew point temperature
(i) Enter the pressure and the vapour composition.
(ii) At the given pressure, calculate the saturation temperature of the components and the
assumed temperature using UCVP
K K
6 [ 66 . Initially take g1 = g2 = 1.
(iii) At the assumed temperature, calculate the vapour pressure of the components.
(iv) Calculate the liquid composition using 
 UCV

[ 2
Z
2H 
and 
 UCV
 
[ 2
Z
2H
.
(v) Update the liquid composition using 

 
Z
Z
Z Z
and x2 = 1 – x1.
(vi) At the liquid composition, calculate the activity coefficients.
(vii) Go to Step (iv) and repeat the procedure till convergence in activity coefficients is
obtained.
(viii) Update the vapour pressure of Component 1 using the relation
UCV
UCV   
 UCV

[ [ 2
2 2
2H H 
È Ø
É Ù
Ê Ú
(ix) From the updated value of UCV
2 , calculate the temperature using 
UCV
 NP
$
6 %
# 2


(x) Go to Step (iii) and repeat the procedure till convergence in temperature is obtained:
EXAMPLE 3.4 Consider a binary vapour–liquid equilibrium system. The Antoine equations
of the components are given by
UCV


NP 

2
6


UCV


NP 

2
6


where the temperature is in °C and the vapour pressure in kPa. The parameters in the Wilson
equation are: a12 = 437.98 cal/mol and a21 = 1238 cal/mol. The molar volume of the
components is V1 = 76.92 cm3
/mol and V2 = 18.07 cm3
/mol. Assume the system to follow the
modified Raoult’s law.
(i) Calculate the bubble point pressure at 100°C and x1 = 0.5.
(ii) Calculate the bubble point temperature at 101.325 kPa and x1 = 0.5.
40 Introduction to Numerical Methods in Chemical Engineering
(iii) Calculate the the dew point pressure at 100°C and y1 = 0.5.
(iv) Calculate the dew point temperature at 101.325 kPa and y1 = 0.5.
Solution Program 3.4 for the bubble point and dew point calculations for a system following
the modified Raoult’s law is given in the Appendix. The result obtained from the program is
given below: (i) 204.264 kPa, (ii) 80.93°C, (iii) 184.10 kPa, and (iv) 83.82°C.
3.5 Flash Calculations Using Modified Raoult's Law
In flash the vapour and liquid phases coexist at the given temperature and pressure. The feed
composition is given and the compositions of the liquid and vapour phases are to be
determined using the modified Raoult’s law. For the given temperature and feed composition,
first the bubble point and dew point pressures are determined. Then a pressure is chosen
between the bubble point and dew point pressures.
(i) Enter the temperature.
(ii) At the given temperature calculate the vapour pressure of components.
(iii) Calculate the activity coefficients by assuming the total feed as liquid.
(iv) Calculate the bubble point pressure using the relation UCV UCV
     2 Z 2 Z 2H H
(v) Record the bubble point pressure (Pbubble) and the activity coefficients (g 1b and g 2b).
(vi) For the calculation of the dew point pressure (total feed as vapour), first assume the
activity coefficients to be1.
(vii) Calculate the pressure using
 
UCV UCV
   

2
[ [
2 2H H

.
(viii) Calculate the liquid phase compositions using 
 UCV
 
[ 2
Z
2H
and 
 UCV
 
[ 2
Z
2H
.
(ix) Update the liquid composition using 

 
Z
Z
Z Z
and x2 = 1 – x1.
(x) At the liquid composition, calculate the activity coefficients.
(xi) Go to step (viii) and repeat the procedure till convergence in activity coefficients is
obtained.
(xii) Calculate the system pressure using
 
UCV UCV
   

2
[ [
2 2H H

.
(xiii) Go to step (viii) and repeat the procedure till convergence in pressure is obtained.
(xiv) Store the dew point pressure (Pdew) and the activity coefficients (g 1d and g 2d).
Chemical Engineering Thermodynamics 41
(xv) Enter the pressure between the bubble point and dew point pressures.
(xvi) The assumed number moles in vapour phase is calculated using DWDDNG
DWDDNG FGY
2 2
8
2 2


.
(xvii) The assumed value of g 1 is calculated using
 introduction-to-numerical-methods-in-chemical-engineering
 introduction-to-numerical-methods-in-chemical-engineering
FGY  
 
DWDDNG FGY
D F
F
2 2
2 2
H H
H H
 


.
(xviii) The assumed value of g2 is calculated using
 introduction-to-numerical-methods-in-chemical-engineering
 introduction-to-numerical-methods-in-chemical-engineering
FGY  
 
DWDDNG FGY
D F
F
2 2
2 2
H H
H H
 


.
(xix) Calculate
UCV
 

2
-
2
H
and
UCV
 

2
-
2
H
.
(xx) Calculate
 


- 
[
8 8- 
and
 


- 
[
8 8- 
.
(xxi) Calculate 


[
Z
-
and 


[
Z
-
.
(xxii) Define a function    H [ Z [ Z   .
(xxiii)
 introduction-to-numerical-methods-in-chemical-engineering
K K
K
- 
H
8 8-

c 
 
¦ .
(xxiv) P P H
8 8
H


c
.
(xxv) Go to Step (xx) and repeat the procedure till convergence in V is obtained.
(xxvi) Calculate g1 and g2.
(xxvii) Go to Step (xix) and repeat the procedure till convergence in activity coefficients is
obtained.
EXAMPLE 3.5 Calculate the composition of the liquid and vapour phases for the system
acetone (1)–water (2) at 100o
C and 200 kPa. The feed composition is z1 = 0.3. The Antoine
equations of the components are given by
UCV


NP 

2
6


UCV


NP 

2
6


where the temperature is in °C and the vapour pressure in kPa. The parameters in the Wilson
equation are: a12 = 292.66 cal/mol and a21 = 1445.26 cal/mol. The molar volume of the
components is V1 = 74.05 cm3
/mol and V2 = 18.07 cm3
/mol. Assume the system to follow the
modified Raoult’s law.
42 Introduction to Numerical Methods in Chemical Engineering
Solution Program 3.5 for calculating the composition of the liquid and vapour phases under
flash conditions for a system following the modified Raoult’s law is given in the Appendix.
The result obtained from the program is: bubble point pressure = 310.47 kPa, dew point
pressure = 142.80 kPa. The system pressure chosen is 200 kPa and after convergence the
number of moles in the vapour phase is 0.546235. x1 = 0.045019 and y1 = 0.511817.
3.6 Vapour Pressure Using Cubic Equation of State
The cubic equations of state are applicable for both the liquid and vapour phases. At a given
temperature, a cubic equation of state can be used to determine the vapour pressure of a pure
substance. A pressure is assumed and the fugacities in the liquid and vapour phases are
determined. If at the assumed pressure the fugacities are not identical, then another pressure
is assumed and the pressure at which the fugacities are the same (f L
= f V
) is the vapour
pressure. The algorithm for calculation of vapour pressure is given below.
(i) Assume a pressure.
(ii) At the given temperature and the assumed pressure, calculate VV
and VL
as described
in Program 3.1.
(iii) Calculate f L
and f V
using cubic equation of state.
(iv) If 
. 8
8
H H
H

 , stop.
(v) Calculate the new pressure using, PGY QNF
.
8
H
2 2
H
, and go back to Step (ii) and repeat
the procedure till Condition (iv) is satisfied.
For the Peng–Robinson cubic equation of state, the fugacity of a pure substance is given by
 introduction-to-numerical-methods-in-chemical-engineering
NP  NP NP
   
8 DH 2D C
 
2 46 D46 8 D
 § ·
   ¨ ¸
© ¹  
(3.31)
The fugacity of the liquid phase is given by
 introduction-to-numerical-methods-in-chemical-engineering
NP  NP NP
   
..
. .
.
8 DH 2D C
 
2 46 D46 8 D
 § ·
   ¨ ¸
© ¹  
(3.31a)
where
.
. 28

46
Chemical Engineering Thermodynamics 43
and the fugacity of the vapour phase is given by
 introduction-to-numerical-methods-in-chemical-engineering
NP  NP NP
   
88
8 8
8
8 DH 2D C
 
2 46 D46 8 D
 § ·
   ¨ ¸
© ¹  
(3.31b)
where
8
8 28

46
EXAMPLE 3.6 Calculate the vapour pressure of water at 100°C using the Peng–Robinson
cubic equation of state. For water: TC = 647.1 K, PC = 220.55 bar, and w = 0.345.
Solution Program 3.6 for calculating the vapour pressure using the cubic equation of state
is given in the Appendix. The vapour pressure of water at 100°C as obtained from the program
is 96071.375 Pa.
3.7 P–x–y Diagram Using Gamma–Phi Approach
In the Gamma–Phi approach, the vapour–liquid equilibrium is described using the equation
    
8
[ 2 Z HG H (3.32)
    
8
[ 2 Z HG H (3.33)
At the given temperature and liquid phase composition, the equilibrium pressure and the
vapour composition are determined. Then again at the same temperature and at a different
liquid phase composition, the equilibrium pressure and vapour composition are determined.
This is used to generate the P–x–y diagram at the given temperature.
The algorithm is given below.
(i) Read T, x1, Tc1, Pc1, Tc2, Pc2, w1, w2, ZC1, ZC2, UCV
2 , UCV
2 .
(ii) x2 = 1 – x1.
(iii) At the given temperature and liquid phase composition, calculate the activity
coefficients g1 and g2.
(iv) At the given temperature, calculate B11, B22, B12 and d12.
(v) Calculate the initial value of the total pressure using UCV UCV
     2 Z 2 Z 2H H (only to
start the solution do we assume the modified Raoult’s law to be true) and the
composition in vapour phase using the relation
UCV
  

Z 2
[
2
H
and
UCV
  

Z 2
[
2
H
.
(vi) At the total pressure, calculate the fugacity of the pure liquid species 1(f1) and 2(f2)
at the given temperature and calculated pressure, using the relation
UCV
UCV
UCV
GZR GZR
.
K K
KK K
K K
8 2 2$ 2
H 2
46 46
ª º§ ·
« »¨ ¸¨ ¸ « »© ¹ ¬ ¼
44 Introduction to Numerical Methods in Chemical Engineering
(vii) Calculate the fugacity coefficient of the species 1( G ) and 2( G ) in the vapour phase.
(viii) Calculate  


H
-
2
H
G
and  


H
-
2
H
G
.
(ix) Calculate    5 - Z - Zu  u .
(x) Calculate  

- Z
[
5
u
and  

- Z
[
5
u
. Go to Step (vii) and repeat the procedure
till dS  e. (This is because the composition of the vapour phase has changed and
therefore the fugacity coefficients of the species in the vapour phase get changed.)
(xi) Calculate the new pressure using      
 
Z H Z H
2
H H
G G
 and calculate the new
compositions in the vapour phase using   


Z H
[
2
H
G
and   


Z H
[
2
H
G
. Go to Step
(vi) and repeat the procedure till dP  e.
EXAMPLE 3.7 Consider the methanol (1) – water (2) system in vapour–liquid equilibrium.
The temperature of the system is 100°C and the liquid phase composition is x1 = 0.958.
Determine the system pressure and the vapour phase composition. Use the Gamma–Phi
approach. The Antoine equations of the components are given by
UCV


NP 

2
6


UCV


NP 

2
6


where temperature is in °C and vapour pressure in kPa. The parameters in the Wilson equation
are: a12 = 107.38 cal/mol and a21 = 469.55 cal/mol. The molar volume of the components is
V1 = 40.73 cm3
/mol and V2 = 18.07 cm3
/mol. Tc1 = 512.6 K, Pc1 = 80.97 bar, w1 = 0.564,
Zc1 = 0.224, Tc2 = 647.1 K, Pc2 = 220.55 bar, w2 = 0.345, Zc2 = 0.229.
Solution Program 3.7 for P–x–y calculations using the Gamma–Phi approach is given
in the Appendix. The result obtained from the program is given below: pressure = 344930.59
Pa and y1 = 0.980694.
3.8 P-x-y Diagram Using Cubic Equation of State
For the Peng–Robinson equation of state the fugacity coefficient of component 1 in the liquid
phase is given by
NP  NP
.
. . .
.
D 2D
 
46D
G
§ ·
  ¨ ¸¨ ¸
© ¹
Chemical Engineering Thermodynamics 45
 introduction-to-numerical-methods-in-chemical-engineering
 introduction-to-numerical-methods-in-chemical-engineering
NP
 
 
.
.
.
. . ..
.
2D
Z C Z C DC 46
C D 2DD 46

46
 ª º
 « »
¬ ¼  
(3.34)
and the fugacity coefficient of component 1 in the vapour phase is given by
NP  NP
8
8 8 8
8
D 2D
 
46D
G
§ ·
  ¨ ¸¨ ¸
© ¹
 introduction-to-numerical-methods-in-chemical-engineering
 introduction-to-numerical-methods-in-chemical-engineering
NP
 
 
8
8
8
8 8 88
8
2D
[ C [ C DC 46
C D 2DD 46

46
 ª º
 « »
¬ ¼  
(3.35)
The fugacity coefficient of component 2 in the liquid phase is given by
NP  NP
.
. . .
.
D 2D
 
46D
G
§ ·
  ¨ ¸¨ ¸
© ¹
 introduction-to-numerical-methods-in-chemical-engineering
 introduction-to-numerical-methods-in-chemical-engineering
NP
 
 
.
.
.
. . ..
.
2D
Z C Z C DC 46
C D 2DD 46

46
 ª º
 « »
¬ ¼  
(3.36)
and the fugacity coefficient of component 2 in the vapour phase is given by
NP  NP
8
8 8 8
8
D 2D
 
46D
G
§ ·
  ¨ ¸¨ ¸
© ¹
 introduction-to-numerical-methods-in-chemical-engineering
 introduction-to-numerical-methods-in-chemical-engineering
NP
 
 
8
8
8
8 8 88
8
2D
[ C [ C DC 46
C D 2DD 46

46
 ª º
 « »
¬ ¼  
(3.37)
where
 
      .
C Z C Z C Z Z C  (3.38)
   
.
D Z D Z D (3.39)
 
      8
C [ C [ C [ [ C  (3.40)
   
8
D [ D [ D (3.41)
.
. 28

46
(3.42)
46 Introduction to Numerical Methods in Chemical Engineering
8
8 28

46
(3.43)
For a binary VLE mixture the phase equilibrium equations are
   
8 .
[ 2 Z 2G G (3.44)
   
8 .
[ 2 Z 2G G (3.45)
and variables are T, P, x1, and y1. Thus, if any two variables (T or P, x1 or y1) are specified
the other two can be determined.
Since the compositions of the liquid and vapour phases are different, a and b for each
phase are different. Calculate a and b for the liquid phase and then ZL
and VL
(the smallest
root), and a and b for the vapour phase and then ZV
and VV
(the largest root). The molar volume
is calculated by solving the cubic form of the Peng–Robinson equation of state. The algorithm
for the calculation of the bubble point pressure and the vapour phase composition at the given
temperature and the liquid phase composition for a binary mixture using the cubic equations
of state is given below.
(i) Read T, x1, Tc1, Pc1, Tc2, Pc2, w1, w2
(ii) Calculate x2 = 1 – x1
(iii) Calculate a11, a22, 221112 aaa , b1, b2
(iv) Calculate for liquid phase:
 
      .
C Z C Z C Z Z C  and    
.
D Z D Z D .
(v) Assume some pressure (P) and composition in the vapour phase y1 (assume y1 greater
than x1 if component 1 is the more volatile component).
(vi) Using Newton’s technique, calculate VL
using aL
, bL
, x1, x2. Take Vold = bL
because
the liquid phase molar volume is to be calculated. From VL
, calculate
.
. 28

46
(compressibility factor in the liquid phase).
(vii) Calculate the fugacity coefficient of the components 
.
G and 
.
G in the liquid
mixture.
(viii) Calculate for the vapour phase:
 
      8
C [ C [ C [ [ C  and    
8
D [ D [ D .
(ix) Using Newton’s technique, calculate VV
using aV
, bV
, y1, y2. Take QNF
46
8
2
because
the vapour phase molar volume is to be calculated. From VV
, calculate
8
8 28

46
(compressibility factor in the vapour phase).
(x) Calculate the fugacity coefficient of the components 
8
G and 
8
G in the vapour phase
mixture.
(xi) Calculate 


.
8-
G
G
and 


.
8-
G
G
.
(xii) Calculate     5WO - Z - Zu  u
Chemical Engineering Thermodynamics 47
(xiii) Calculate  

- Z
[
5WO
u
and  

- Z
[
5WO
u
. Go to Step (viii) and repeat the procedure
till 
 5WOE F . This is because the composition of the vapour phase has changed;
therefore aV
and bV
get changed.
(xiv) Calculate the new pressure using PGY QNF2 2 5WOu . Go to Step (vi) and repeat the
procedure till 2E F .
EXAMPLE 3.8 Consider the CO2 (1) – n-pentane (2) system in vapour–liquid equilibrium.
The temperature of the system is 377.65 K and the liquid phase composition is x1 = 0.5.
Determine the system pressure and the vapour phase composition using the Peng–Robinson
cubic equation of state. Tc1 = 304.2 K, Pc1 = 73.83 bar, w1 = 0.224, Tc2 = 469.7 K, Pc2 = 33.70
bar, and w2 = 0.252.
Solution Program 3.8 for P–x–y calculations using the Peng–Robinson cubic equation of
state is given in the Appendix. The result obtained from the program is given below: Pressure
= 6524432 Pa and y1 = 0.81127.
3.9 Chemical Reaction Equilibrium—Two Simultaneous
Reactions
The solution of two simultaneous nonlinear algebraic equations is described in Section 2.5. The
application in chemical reaction equilibrium in the homogeneous phase is described in the
example below.
EXAMPLE 3.9 In the production of synthesis gas the following two independent reactions
take place
CH4 + H2O ® CO + 3H2
CO + H2O ® CO2 + H2
Starting with 5 moles of steam and 1 mole of methane, calculate the equilibrium composition
of the resulting mixture at 600°C and 1 atm. At this temperature the equilibrium constants for
the first and second reaction are 0.574 and 2.21 respectively. Assume the gas mixture to follow
ideal gas behaviour.
Solution Let X1 be the reaction coordinate for the first reaction and X2 for the second. The
number of moles of components at equilibrium is as follows:
CH4: 1 – X1
H2O: 5 – X1 – X2
CO: X1 – X2
H2: 3X1 + X2
CO2: X2
Total: 6 + 2X1
48 Introduction to Numerical Methods in Chemical Engineering
Since the pressure is 1 atm, therefore K = KPKy = Ky.
 introduction-to-numerical-methods-in-chemical-engineering
: : : :
: : : :
: : :
: : : :

  
The two nonlinear algebraic equations are
 introduction-to-numerical-methods-in-chemical-engineering
 introduction-to-numerical-methods-in-chemical-engineering
 introduction-to-numerical-methods-in-chemical-engineering
 introduction-to-numerical-methods-in-chemical-engineering
: : : :
H
: : : :
 introduction-to-numerical-methods-in-chemical-engineering
 introduction-to-numerical-methods-in-chemical-engineering
: : :
H
: : : :


  
and their derivatives are
 introduction-to-numerical-methods-in-chemical-engineering
 introduction-to-numerical-methods-in-chemical-engineering
 introduction-to-numerical-methods-in-chemical-engineering
 introduction-to-numerical-methods-in-chemical-engineering
: : : :H
: : : : :
 ˜

˜
 introduction-to-numerical-methods-in-chemical-engineering
 introduction-to-numerical-methods-in-chemical-engineering
 introduction-to-numerical-methods-in-chemical-engineering
 introduction-to-numerical-methods-in-chemical-engineering
 introduction-to-numerical-methods-in-chemical-engineering
: : : : : : : : :
: : : :
 introduction-to-numerical-methods-in-chemical-engineering
 introduction-to-numerical-methods-in-chemical-engineering
 introduction-to-numerical-methods-in-chemical-engineering
 introduction-to-numerical-methods-in-chemical-engineering
 introduction-to-numerical-methods-in-chemical-engineering
 introduction-to-numerical-methods-in-chemical-engineering
 introduction-to-numerical-methods-in-chemical-engineering
 introduction-to-numerical-methods-in-chemical-engineering
 introduction-to-numerical-methods-in-chemical-engineering
 introduction-to-numerical-methods-in-chemical-engineering
: : : : : :H
: : : : :
: : : :
: : : :
   ˜

˜
 introduction-to-numerical-methods-in-chemical-engineering
 introduction-to-numerical-methods-in-chemical-engineering
 introduction-to-numerical-methods-in-chemical-engineering
 introduction-to-numerical-methods-in-chemical-engineering
 introduction-to-numerical-methods-in-chemical-engineering
: : : :H :
: : : : : : : : :
 ˜

˜
 introduction-to-numerical-methods-in-chemical-engineering
 introduction-to-numerical-methods-in-chemical-engineering
 introduction-to-numerical-methods-in-chemical-engineering
 introduction-to-numerical-methods-in-chemical-engineering
 introduction-to-numerical-methods-in-chemical-engineering
: : : :H : :
: : : : : : : : :
 ˜ 

˜      
The algorithm is described in Section 2.5. Program 3.9 for solution of two chemical reaction
equilibrium equations is given in the Appendix. The solution is X1 = 0.912 and
X2 = 0.633. Thus at equilibrium: moles of CH4 = 0.09 mol, moles of H2O = 3.465 mol, moles
of CO = 0.285 mol, moles of H2 = 3.355 mol, moles of CO2 = 0.625 mol, and total number
of moles = 7.82 mol.
Chemical Engineering Thermodynamics 49
3.10 Adiabatic Flame Temperature
First the inlet species are laised from inlet temperature (T1) to adiabatic flame temperature (T)
and then the reaction at temperature T is carried out. The total enthalpy change is zero as there
is no heat and work exchange with the surroundings. The algorithm for the calculation of
adiabatic flame temperature is described below.
(i) Read the various constants of molar heat capacity at constant pressure for various species.
(ii) Read the various stoichiometric coefficients (ni) and moles of each species (ni) entering.
(iii) Read the standard enthalpy of formation for various species and calculate the
standard enthalpy change of reaction. Read the standard temperature (T0) and inlet
temperature (T1).
(iv) Calculate sa, sb, sc, sd using the relations
       UC P C P C P C P C          UD P D P D P D P D  
       UE P E P E P E P E          UF P F P F P F P F  
(v) Calculate the heat required to raise the inlet species from the inlet temperature (T1)
to the adiabatic flame temperature (T) using
 introduction-to-numerical-methods-in-chemical-engineering
 introduction-to-numerical-methods-in-chemical-engineering
 introduction-to-numerical-methods-in-chemical-engineering
UD UE UF
UC 6 6 6 6 6 6 6 6      
Note that this formula is valid for the molar heat capacity given by the equation
 
2% C D6 E6 F6  
(vi) Calculate
       C C C C CO O O O'           D D D D DO O O O'   
       E E E E EO O O O'           F F F F FO O O O'   
(vii) Calculate the standard enthalpy change of reaction at the adiabatic flame temperature
(T) with respect to the standard enthalpy change of reaction at temperature (T0)
 introduction-to-numerical-methods-in-chemical-engineering
 introduction-to-numerical-methods-in-chemical-engineering
 introduction-to-numerical-methods-in-chemical-engineering
6
D E F
* C 6 6 6 6 6 6 6 6
' ' '
' '       
(viii) Assume an adiabatic flame temperature and at that temperature calculate the value of
the function
 introduction-to-numerical-methods-in-chemical-engineering
 introduction-to-numerical-methods-in-chemical-engineering
 introduction-to-numerical-methods-in-chemical-engineering
UD UE UF
H UC 6 6 6 6 6 6 6 6      
+
 introduction-to-numerical-methods-in-chemical-engineering
 introduction-to-numerical-methods-in-chemical-engineering
 introduction-to-numerical-methods-in-chemical-engineering
6
D E F
* C 6 6 6 6 6 6 6 6
' ' '
' '       
and its derivative
   
H UC UD 6 UE 6 UF 6 C D 6 E 6 F 6' ' ' 'c  u  u  u   u  u  u
(ix) Calculate new temperature using Newton’s formula P P H
6 6
H


c
, take this as the
old temperature and go to Step (n) and repeat the procedure till there is no significant
change in temperature (dT  e).
50 Introduction to Numerical Methods in Chemical Engineering
EXAMPLE 3.10 Calculate the adiabatic flame temperature of a gas initially at 25o
C
containing 1 mol C2H6 (1), 4 mol O2 (2), 10 mol CO2 (3) and 0 mol of H2O (4). The ethane
is completely burned. The standard heat capacity is given by   
2% C D6 E6 F6   , where
T is in K and 
2% in cal/mol-K.
Species a b ´ 102
c ´ 105
d ´ 109
C2H6 1.648 4.124 –1.530 1.740
O2 6.085 0.3631 –0.1709 0.3133
CO2 5.316 1.4285 –0.8362 1.784
H2O(g) 7.700 0.04594 0.2521 –0.8587
The standard enthalpy of formation at 298.15 K is: 

Â7I H
*' kcal/mol,


ÂB Is H
*' kcal/mol,  

% * H
*' kcal/mol.
Solution The reaction with stoichiometric amount of oxygen is
    

% * 1 %1 * 1

 o 
and the reaction with 4 mol of O2 and 10 mol CO2 is
      % * 1 %1 %1 * 1 1  o  
Program 3.10 for the calculation of adiabatic flame temperature (AFT) is given in the
Appendix. The result obtained from the computer program is AFT = 2090.39 K.
Exercises
3.1 Calculate the molar volume of saturated liquid water and saturated water vapour at
180°C and 1.0 MPa using the van der Waals, Redlich–Kwong and Peng–Robinson
cubic equations of state. For water: TC = 647.1 K, PC = 220.55 bar, and w = 0.345.
(Ans: VL
using the Peng–Robinson equation of state = 2.47 ´ 10–5
m3
/mol, VV
using
the Peng–Robinson equation of state = 0.003570 m3
/mol, VL
using the Redlich–
Kwong equation of state = 2.95 ´ 10–5
m3
/mol, VV
using the Redlich–Kwong
equation of state = 0.003605 m3
/mol, VL
using the van der Waals equation of state
= 4.31 ´ 10–5
m3
/mol, VV
using the van der Waals equation of state = 0.003647 m3
/mol)
3.2 Calculate the bubble point and dew point temperatures for the acetone (1)–water
(2) system at 101.325 kPa for feed composition z1 = 0.9. Assume the system to
follow Raoult’s law.
(Ans: Bubble point temperature = 58.58°C, dew point temperature = 66.93°C)
3.3 Calculate the composition of the liquid and vapour phases for the acetone
(1)– acetonitrile (2)–nitromethane (3)–system. The feed composition is z1 = 0.25,
z2 = 0.5 and z3 = 0.25. At the given temperature: UCV
2 195.75 kPa, UCV
2 97.84
kPa, and UCV
2 50.32 kPa. The pressure of the system is 100 kPa. Assume the
system to follow Raoult’s law.
(Ans: x1 = 0.175384, y1 = 0.343313, x2 = 0.504845, y2 = 0.493941, x3 =
0.320819, y3 = 0.161436. The number of moles in the vapour phase is 0.444331.)
Chemical Engineering Thermodynamics 51
3.4 Consider a binary vapour–liquid equilibrium system. The Antoine equations of the
components are given by
UCV


NP 

2
6


UCV


NP 

2
6


where the temperature is in °C and the vapour pressure in kPa. The parameters in
the Wilson equation are: a12 = 437.98 cal/mol and a21 = 1238 cal/mol. The molar
volumes of the components are V1 = 76.92 cm3
/mol and V2 = 18.07 cm3
/mol.
Assume the system to follow the modified Raoult’s law.
(i) Calculate the bubble point pressure at 100°C and x1 = 0.3.
(ii) Calculate the bubble point temperature at 101.325 kPa and x1 = 0.3.
(iii) Calculate the dew point pressure at 100°C and y1 = 0.3.
(iv) Calculate the dew point temperature at 101.325 kPa and y1 = 0.3.
[Ans: (i) 193.78 kPa, (ii) 82.18°C, (iii) 140.78 kPa, and (iv) 91.00°C]
3.5 Calculate the composition of the liquid and vapour phases for the acetone (1)–
water (2) system at 100°C and 200 kPa. The feed composition is z1 = 0.5. The
Antoine equations of the components are given by
UCV


NP 

2
6


UCV


NP 

2
6


where the temperature is in °C and the vapour pressure in kPa. The parameters in
the Wilson equation are: a12 = 292.66 cal/mol and a21 = 1445.26 cal/mol. The molar
volume of the components is V1 = 74.05 cm3
/mol and V2 = 18.07 cm3
/mol. Assume
the system to follow the modified Raoult’s law.
[Ans: Bubble point pressure = 334.97 kPa, dew point pressure = 195.68 kPa,
number of moles in vapour phase = 0.974685, x1 = 0.045018, y1 = 0.511817]
3.6 Calculate the vapour pressure of water at 120°C using the Peng–Robinson cubic
equation of state. For water: TC = 647.1 K, PC = 220.55 bar, and w = 0.345.
(Ans: 191689.125 Pa)
3.7 Consider the methanol (1) – water (2) system in vapour–liquid equilibrium. The
temperature of the system is 100°C and the liquid phase composition is x1 = 0.5.
Determine the system pressure and the vapour phase composition. Use the Gamma-
Phi approach. The Antoine equations of the components are given by
UCV


NP 

2
6
52 Introduction to Numerical Methods in Chemical Engineering
UCV


NP 

2
6


where the temperature is in °C and the vapour pressure in kPa. The parameters in
the Wilson equation are: a12 = 107.38 cal/mol and a21 = 469.55 cal/mol. The molar
volumes of the components are V1 = 40.73 cm3
/mol and V2 = 18.07 cm3
/mol.
TC1 = 512.6 K, PC1 = 80.97 bar, w1 = 0.564, ZC1 = 0.224, TC2 = 647.1 K,
PC2 = 220.55 bar, w2 = 0.345, ZC2 = 0.229.
(Ans: Pressure = 253786 Pa, 1y 0.757692)
3.8 Consider the CO2 (1) – n-pentane (2) system in vapour–liquid equilibrium. The
temperature of the system is 377.65 K and the liquid phase composition is x1 = 0.35.
Determine the system pressure and the vapour phase composition using the Peng–
Robinson cubic equation of state. TC1 = 304.2 K, PC1 = 73.83 bar, w1 = 0.224,
TC2 = 469.7 K, PC2 = 33.70 bar, w2 = 0.252.
(Ans: Pressure = 4572206 Pa, 1y 0.782462)
3.9 Calculate the adiabatic flame temperature of a gas initially at 25°C containing 1 mol
C2H6 (1), 5 mol O2 (2), 10 mol CO2 (3) and 0 mol of H2O (4). The ethane is
completely burned. The standard heat capacity is given by C0
P = a + bT + cT2
+ dT3
where T is in K and C0
P in cal/mol-K.
Species a b ´ 102
c ´ 105
d ´ 109
C2H6 1.648 4.124 –1.530 1.740
O2 6.085 0.3631 –0.1709 0.3133
CO2 5.316 1.4285 –0.8362 1.784
H2O(g) 7.700 0.04594 0.2521 –0.8587
The standard enthalpy of formation at 298.15 K is: 

Â7I a H
*' kcal/mol,


ÂB Is H
*' kcal/mol, and  

% * H
*' kcal/mol.
(Ans: AFT = 2024.45 K)
53
Chapter 4
Initial Value Problems
Consider two simultaneous differential equations
F[

FZ
and
F
[
FZ
 . The analytical solution
of the differential equations is y = A sin(x + a) and z = A cos(x + a). There are two constants
of integration A and a. In general, a system of N first order equations has N constants of
integration. If the values of the dependent variables y and z are specified for a value of x, then
the problem of determining the values of y and z at some future x is called an initial value
problem. Alternatively, the values of some of the dependent variables may be specified at a
number of different values of x, then the problem is called a boundary value problem. The
most common form is a two-point boundary value problem where the function values are given
for two values of x. Boundary value problems are discussed in Chapters 5–10.
The examples discussed here include the calculation of temperature profile in a double
pipe heat exchanger, of a single stirred tank with coil heater and also of a series of stirred tanks
with coil heater. The velocity profile of a solid particle in a pneumatic conveyor, and the
calculation of the concentration profile in the batch, stirred and plug flow reactors is also
discussed in this chapter.
4.1 Solution of Single Ordinary Differential Equation
Consider an ordinary differential equation
F[
H Z [
FZ
(4.1)
with the initial condition: at x = x0, y = y0. The ordinary differential equation has to be
integrated to determine the value of y at some x. A step size, h, is chosen in the independent
variable. At the initial condition both x and y are known and after a step size in independent
variable, i.e. at x = x0 + h the value of y is computed. Then this becomes the starting point
for the next value of independent variable, x = x0 + 2h at which the value of dependent variable
is determined. This procedure is repeated till the value of x at which the y-value is to be
determined is reached. For each problem there exists an optimum step size. The step size
should not be high, otherwise the truncation errors will be high, and if the step size is very
small, then round-off errors are high. At the optimum step size the total error (truncation error
+ round-off error) is the least, and thus the numerical results are accurate.
54 Introduction to Numerical Methods in Chemical Engineering
In the numerical formulation of the problem some terms are left out; those errors are
called truncation errors. When the step size is small, these errors are less. If the step size is
very low, then the truncation errors are less but the round-off errors are high. Consider a step
size of 10–6
m; then to go from 1 to 10 m, the number of iterations required is 107
, which is
huge. Whenever the new concentration is computed, the number is not completely stored, it
is stored up to some decimal places only, depending on the compiler used. So to avoid round-
off errors the step size should not be very small and to avoid truncation errors it should not
be very large. So there is an optimum step size and it varies with the problem. To determine
the optimum step size, at a particular value of independent variable x the value of the
dependent variable y is determined using various step sizes. When for two consecutive step
sizes the value of y is the same, then the higher of the two is the optimum step size.
In the Runge–Kutta fourth order method the following are computed:
M J H Z [u (4.2)
   
 

 
M J H Z J [ M
§ ·
u  ¨ ¸
© ¹
(4.3)
   
 

 
M J H Z J [ M
§ ·
u  ¨ ¸
© ¹
(4.4)
M J H Z J [ Mu   (4.5)
[ [ M M M M    (4.6)
From the initial condition (x0, y0) we have determined the value of y at x0 + h. Now again the
above calculations are carried out to determine the value of y at x0 + 2h. But before carrying
out the next calculation the following statements, due to which the value of y1 becomes y0 and
x0 + h becomes x0, are executed:
x0 = x0 + h (4.7)
y0 = y1 (4.8)
EXAMPLE 4.1 Integrate the ordinary differential equation
F[
Z [
FZ

using the Runge–Kutta fourth order method. The initial condition is: at x = 0, y = 0. Determine
the value of y at x = 0.2. The analytical solution is given by y = ex
– x – 1.
Solution Let us take step size of h = Dx = 0.1. The function is
F[
H Z [
FZ
 . To compute
y at x = 0.1 the starting point is x0 = 0 and y0 = 0. The calculations are given below.
f(0,0) = 0; therefore k1 = 0.1 ´ f(0,0) = 0;
f(0.05,0) = 0.05; therefore k2 = 0.1 ´ 0.05 = 0.005;
f(0.05,0.0025) = 0.0525; therefore k3 = 0.00525;
f(0.1,0.00525) = 0.10525; therefore k4 = 0.010525.
Initial Value Problems 55
Thus
[ [ M M M M    at x = 0.1
Now let us compute the value of y at x = 0.2. For this computation the starting point is
x0 = 0.1 and y0 = 0.0051708. The calculations are given below.
f(0.1, 0.0051708) = 0.1051708; therefore k1 = 0.01051708;
f(0.15, 0.01042934) = 0.16042934; therefore k2 = 0.0160429;
f(0.15, 0.01319225) = 0.16319225; therefore k3 = 0.016319225;
f(0.2, 0.02149) = 0.22149; therefore k4 = 0.022149.
Thus
[   u  u 
Thus the value of y (at x = 0.2) = 0.0214025.
The analytical solution at x = 0.2 is y = e0.2
– 0.2 – 1 = 0.0214028, which is close to the
numerical solution.
EXAMPLE 4.2 Solve the following ordinary differential equation:
x
y
dx
dy


1
with the initial condition y(0) = 2. Determine y at x = 2.5 using the fourth-order Runge–Kutta
method.
Solution The initial condition is: at x = 0: y = 2. We have to determine y at x = 2.5. The result
from Program 4.1 (given in the Appendix) at step size of 0.01 is: at x = 2.5, y = 0.57.
4.2 Double Pipe Heat Exchanger
The schematic diagram of the inner pipe of the double pipe heat exchanger is shown in Fig. 4.1.
The outer pipe contains steam at temperature TS and the fluid in the inner pipe is heated.
Heat entering through whole
circumference = U(2pRDz)(TS – T)
Fig. 4.1 Schematic diagram of double pipe heat exchanger.
TGH

 2 O% 6 6 TGH

 2  O% 6 6'
56 Introduction to Numerical Methods in Chemical Engineering
Consider a differential section of the inner pipe. Through the circumference of the inner pipe
heat enters from steam in the outer pipe. Under steady conditions (Input – Output = 0)
 introduction-to-numerical-methods-in-chemical-engineering
 introduction-to-numerical-methods-in-chemical-engineering
TGH TGH
2  2   5O% 6 6 O% 6 6 7   6 6Q' '    
Dividing by Dz, we get
2 5
6 6
O% 7  6 6

Q'
'
 § ·
  ¨ ¸
© ¹
As Dz ® 0, we get
2 5
F6
O% 7  6 6
F
Q   (4.9)
where T is the temperature of the fluid in the inner pipe and is a function of length, TS is the
temperature of steam in the outer pipe and is constant, and O is the mass flow rate of fluid in
inner pipe. The analysis of the double pipe heat exchanger is described in the example below.
EXAMPLE 4.3 On one side of a double pipe heat exchanger is saturated steam and water
is flowing in the inner tube. The temperature of entering water is 20°C and the velocity of
water is 1 m/s. The inner diameter of the inner pipe is 2.4 cm. Under steady conditions,
determine the temperature of water at the length of 5 and 10 m from the inlet. The total length
of the heat exchanger is 10 m. Assume that the temperature does not change along the radius
of the pipe. The density of water is 1000 kg/m3
and the specific heat capacity is 4184 J/kg-
K. The overall heat transfer coefficient based on the inside area of the inner pipe is 200 W/
m2
-K and the temperature of saturated steam is 250°C.
Solution The mass flow rate of water is


  

O X#S Q
§ ·
u u ¨ ¸
© ¹
kg/s
Eq. (4.9) becomes
F6
6
F
 u  u u u
F6
6
F

u 
The initial condition is: at z = 0, T = 20. The temperature is to be determined at z = 5 and
z = 10. The differential equation is integrated using the Runge–Kutta fourth order method.
Program 4.1 can be modified, and with step size of 0.01 m, we get at z = 5 m, T = 28.97°C
and at z = 10 m, T = 37.60°C.
Let us now check the answer. The exit temperature of water at z = 10 m is 37.60°C. The
heat taken up by water is equal to UADTlmtd, and from the energy balance equation we get
NOVF  

 27 . 6 O% 6 6Q '
Initial Value Problems 57
where T1 is the temperature of the inlet water, T2 is the temperature of the exit water, and
L = 10 m. The temperatures in the double pipe heat exchanger are shown in Fig. 4.2.
Fig. 4.2 Diagram for Example 4.3.
The log mean temperature difference is given by
NOVF
 


NP

6'

§ ·
¨ ¸
© ¹
Substituting the values in the energy balance equation, we get
 
NOVF

    

  
2O% 6 6
7
. 6Q Q'
 u u
u u u
W/m2
-K
which is close to the given value. In this problem the overall heat transfer coefficient is given
and temperature of water is determined. Usually in heat transfer laboratory experiments, the
exit temperature of water is known and the overall heat transfer coefficient is determined.
4.3 Stirred Tank with Coil Heater
The schematic diagram of a stirred tank with coil heater is shown in Fig. 4.3.
Fig. 4.3 Schematic diagram of stirred tank with coil heater.
37.60°C
Steam temperature
Water temperature
20°C
250°C250°C
M = Mass
of fluid
in tank
T
TS
O O
58 Introduction to Numerical Methods in Chemical Engineering
The energy balance equation is given by Accumulation = Input – Output. The input is due to
energy input by the entering stream and the heat input from the steam, and the output is energy
carried away by the exit stream. From the energy balance equation, we get
2 2
F6
/% O% 6 6 3
FV
  (4.10)
where T1 is the temperature of the entering stream and T is the temperature of exit stream and
is equal to temperature of water in the stirred tank. The heat transfer between the steam in the
coil and the fluid is given by Q = UADTlmtd = UA(TS – T). The temperature throughout the coil
is TS as the steam is saturated, and outside the whole coil, that is inside the tank uniform
temperature, T exists as the vessel is stirred; therefore DTlmtd = TS – T. Note that though the
temperature in the tank is uniform, it varies with time.
EXAMPLE 4.4 Consider a stirred tank heater. It is a square tank 0.5 m on its sides and 2
m high and is filled with water at 20°C. Water is fed to the tank at a flow rate of 1L/s and
exits out at the same flow rate from the top of the tank. The temperature of inlet water is 20°C.
At time t = 0 s, water in the tank is heated by a coil containing steam whose overall heat
transfer coefficient based on the outside area of the coil is 200 W/m2
-K. The outside area of
the coil through which heat exchange takes place is 1 m2
. The temperature of the steam is
250°C. The specific heat capacity of water is 4184 J/kg-K. After how much time is the
temperature of exit water 28°C? What is the maximum temperature that can be reached in the
tank?
Solution Volume of tank = 0.5 ´ 0.5 ´ 2 = 0.5 m3
. Since the density of water is 1000 kg/m3
,
therefore the mass of water in the tank is 500 kg. Thus M = 500 kg, CP = 4184 J/kg-K,
3 = UA(TS – T) = 200(TS – T), and m = 1 kg/s, and Eq. (4.10) becomes
 introduction-to-numerical-methods-in-chemical-engineering
F6
6 6
FV
u u u   u 
Simplifying, we get
 
F6
6
FV

The initial condition is: at t = 0, T = 20°C. We have to determine t at T = 28°C. Program 4.1 can
be modified, and with step size of 0.1 we get T = 28°C at t = 700 s. The variation of
temperature of the fluid in the tank with time is shown in Table 4.1.
Table 4.1 Variation of fluid temperature in tank with time in Example 4.4
Time (s) Temperature (°C)
500 26.81
750 28.31
1000 29.19
3000 30.46
5000 30.48
Initial Value Problems 59
The steady state temperature is obtained when in the differential equation 
F6
FV
; thus
the steady state temperature is given by 0.064 – 0.0021 T = 0 or T = 30.48°C. The same is
also obtained from the numerical solution. Note the temperature at 5000 s in Table 4.1.
EXAMPLE 4.5 Consider a stirred vessel which initially contains 760 kg of solvent at 25°C.
12 kg/min of solvent flows into the stirred vessel at 25°C and exits out also at the same rate.
At t = 0 the flow of steam is started in a coil in the stirred vessel. The heat supplied by steam
to the solvent is given by 3 = UA(TS – T), where UA is the overall heat transfer coefficient
multiplied by coil area through which heat exchange takes place and TS is the temperature of
steam and is 150°C. UA = 11.5 kJ/min-K. The specific heat of the solvent is Cp = 2.3 kJ/kg-
K. Show that
Q

 %U  
F6
6
FV

Determine the solvent temperature after 50 min. Also determine the maximum temperature that
can be reached in the tank.
Solution From the energy balance equation we know: Accumulation = Input – Output. Here
input energy is due to incoming fluid and steam and output is due to outgoing fluid.
Substituting the values in Eq. (4.10), we get
 introduction-to-numerical-methods-in-chemical-engineering
F6
6 6
FV
u u   
Note that DTlmtd = TS – T, where T is the temperature of the fluid in the stirred tank. In the
coil throughout the temperature is TS and the fluid temperature is T. Simplifying the above
equation, we get
 
F6
6
FV

The initial condition is: at t = 0, T = 25°C. We have to determine T at t = 3000 s.
Program 4.1 can be modified, and with step size of 0.01 we get: at t = 3000 s, T = 49.69°C.
The variation of temperature of the fluid in the tank with time is shown in Table 4.2.
Table 4.2 Variation of fluid temperature in tank with time in Example 4.5
Time (s) Temperature (o
C)
1000 36.41
2000 44.27
3000 49.69
5000 55.98
7500 59.43
10000 60.78
15000 61.53
20000 61.64
25000 61.66
60 Introduction to Numerical Methods in Chemical Engineering
The steady state temperature is obtained when in the differential equation, 
F6
FV
, thus the
steady state temperature is given by 0.023 – 0.000373T = 0 or T = 61.66°C. The same is also
obtained from the numerical solution. Note the temperature at 25000 s in Table 4.2.
4.4 Pneumatic Conveying
Consider a pneumatic conveyor in which solids are inserted from the bottom along with the
flowing gas. The forces acting on the particle are: drag force acting upwards, buoyancy force
acting upwards and gravitational force acting downwards. The momentum balance equation
becomes [see Eq. (2.15)]
R  D I
R
R
FX ( ( (
FV 8
S
 
where rp is the density of the particle, vp is the upward velocity of the particle, FD is the drag
force acting on the particle, Fb is the buoyancy force acting on the particle, Fg is the
gravitational force acting on the particle, and Vp is the volume of the particle. The drag force
is given by
R

I I R
( #
%
X XS  (4.11)
where rg is the density of the gas, Ap is the projected area of the particle on a plane at right
angles to the direction of motion, and vg – vp is the relative velocity. The gravitational force
minus the buoyancy force on the particle is given by [see Eq. (2.17)]
I D R R I( ( 8 IS S 
The various forces acting are shown in Figure 4.4.
Fig. 4.4 Various forces (divided by volume of particle) acting on particle during pneumatic
conveying.
(rp – rg)g


 

R
I  I R I R
R
#
% X X X X
8
S  
vg
Initial Value Problems 61
Thus the momentum balance equation becomes
 introduction-to-numerical-methods-in-chemical-engineering
R R
R  I I R I R
R
FX #
% X X I
FV 8
S S S S   (4.12)
Note that the terms have units of force acting on the particle divided by the volume of the
particle. Dividing both sides of the equation by rp, we get
R I R I
 I R
R R R
FX #
% X X I
FV 8
S S
S S
§ ·
  ¨ ¸¨ ¸
© ¹
The derivative
R R
R
FX FX
X
FV F
where z is the direction along the length of the pneumatic conveyor. Thus the momentum
balance equation can be written as
R I R I
R  I R
R R R
FX #
X % X X I
F 8
S S
S S
§ ·
  ¨ ¸¨ ¸
© ¹
(4.13)
Program 4.2 uses the Runge–Kutta fourth order method for integrating the above ordinary
differential equation and is given in the Appendix.
EXAMPLE 4.6 Determine the velocity of the solid particles of diameter 3 ´ 10–4
m along
the length of the pneumatic conveyor. The initial velocity of the particle is zero and superficial
velocity of air is 12 m/s. The density of the particle is 900 kg/m3
. Air is fed at 25°C and 1
atm and the viscosity of air under these conditions is 1.8 ´ 10–5
kg/m-s. Neglect wall effects.
Use the following relation to determine CD:
4G
4G
 R
R
% 
where Rep is the particle Reynolds number based on relative velocity and is given by
4G
I I R R
R
X X FS
N

Solution The following data are given:
dp = 3 ´ 10–4
m
vg = 12 m/s
m = 1.8 ´ 10–5
kg/m-s.
The density of air under the given conditions is given by

  

 
I
2/
46
S

u u
u
kg/m3
62 Introduction to Numerical Methods in Chemical Engineering
The projected area of the particle divided by the volume of the particle is given by



  

  

R R
R R R
R
# T
8 T F
T
Q
Q

u
m–1
The particle Reynolds number is
 introduction-to-numerical-methods-in-chemical-engineering
 introduction-to-numerical-methods-in-chemical-engineering
4G  
 
I I R R R
R R
X X F X
X
S
N


 u  u u

u
The momentum balance equation is
R I R I
R  I R
R R R
FX #
X % X X I
F 8
S S
S S
§ ·
  ¨ ¸¨ ¸
© ¹
R
R  R
FX
X % X
F
§ ·
  ¨ ¸
© ¹
R
 R
FX
% X
F
 
Let 
R[ X ; thus
F[
% [
F
 
where
4G  R [ and
4G
4G
 R
R
%  . The initial condition is at
z = 0, y = 0. The problem can be solved using the Runge–Kutta fourth order method. The
velocity of the particle along the length of the pneumatic conveyor as obtained from
Program 4.2 is presented in Table 4.3. The step size of 0.01 m is taken.
Table 4.3 Velocity of particle as obtained from Program 4.2
z (m) vp (m/s)
0.0 0.00
0.1 5.84
0.2 7.24
0.3 8.06
0.5 9.01
1.0 10.06
2.0 10.67
3.0 10.83
5.0 10.90
10.0 10.90
Initial Value Problems 63
4.5 Solution of Simultaneous Ordinary Differential Equations
Consider a system of two ordinary differential equations
F[
H Z [ 
FZ
(4.14)
F
H Z [ 
FZ
(4.15)
with the initial condition: at x = x0, y = y0 and z = z0. The ordinary differential equations have
to be integrated to determine the value of y and z at some x. A step size, h, is chosen in the
independent variable and after a step size in independent variable, i.e., at x = x0 + h the value
of y and z are to be computed. In the Runge–Kutta fourth order method the following are
computed:
M J H Z [ u (4.16)
N J H Z [ u (4.17)
      
  
 
  
M J H Z J [ M  N
§ ·
u   ¨ ¸
© ¹
(4.18)
      
  
 
  
N J H Z J [ M  N
§ ·
u   ¨ ¸
© ¹
(4.19)
      
  
 
  
M J H Z J [ M  N
§ ·
u   ¨ ¸
© ¹
(4.20)
      
  
 
  
N J H Z J [ M  N
§ ·
u   ¨ ¸
© ¹
(4.21)
M J H Z J [ M  Nu    (4.22)
N J H Z J [ M  Nu    (4.23)
[ [ M M M M    (4.24)
N N N N    (4.25)
From the initial condition (x0, y0, z0), we have determined the value of y and z at x0 + h. Now
again, the above calculations are carried out to determine the value of y and z at x0 + 2h. But
before carrying out the next calculation the following statements are executed, due to which
the value of y1 becomes y0, z1 becomes z0 and x0 + h becomes x0:
x0 = x0 + h
y0 = y1
z0 = z1
64 Introduction to Numerical Methods in Chemical Engineering
EXAMPLE 4.7 Integrate the ordinary differential equations
yx
dt
dx
2
yx
dt
dy
23 
using the Runge–Kutta fourth order method. The initial condition is: at t = 0, x = 6, y = 4.
Determine the values of x and y at t = 0.2. The analytical solution is given by x = 4e4t
+ 2e–t
and y = 6e4t
– 2e–t
.
Solution Take step size of h = Dt = 0.1. The functions are  
FZ
H Z [
FV
and
  
F[
H Z [
FV
. To compute the value at t = 0.1 the starting point is t0 = 0, x0 = 6 and y0
= 4. The calculations are given below.
f1(0, 6, 4) = 14; therefore k1 = 1.4;
f2(0, 6, 4) = 26; therefore l1 = 2.6;
f1(0.05, 6.7, 5.3) = 17.3; therefore k2 = 1.73;
f2(0.05, 6.7, 5.3) = 30.7; therefore l1 = 3.07;
f1(0.05, 6.865, 5.535) = 17.935; therefore k3 = 1.7935;
f2(0.05, 6.865, 5.535) = 31.665; therefore l3 = 3.1665;
f1(0.1, 7.7935, 7.1665) = 22.1265; therefore k4 = 2.21265;
f2(0.1, 7.7935, 7.1665) = 37.7135; therefore l4 = 3.77135.
Thus
Z Z M M M M (at t = 0.1)
[ [ N N N N (at t = 0.1)
Now let us compute the value of y and z at t = 0.2. For this computation the starting point is
t0 = 0.1, x0 = 7.7766, and y0 = 7.140725. The calculations are given below.
f1(0.1, 7.7766, 7.140725) = 22.05805; therefore k1 = 2.205805;
f2(0.1, 7.7766, 7.140725) = 37.61125; therefore l1 = 3.761125;
f1(0.15, 8.8795, 9.0212875) = 26.922075; therefore k2 = 2.6922075;
f2(0.15, 8.8795, 9.0212875) = 44.681075; therefore l2 = 4.4681075;
f1(0.15, 9.12270375, 9.37477875) = 27.87226; therefore k3 = 2.787226;
f2(0.15, 9.12270375, 9.37477875) = 46.1176687; therefore l3 = 4.61176687;
f1(0.2, 10.563826, 11.75249187) = 34.06881; therefore k4 = 3.406881;
f2(0.2, 10.563826, 11.75249187) = 55.19646; therefore l4 = 5.519646.
Initial Value Problems 65
Thus at t = 0.2
u  u 

       

Z
u  u 

       

[
From the analytical solution at t = 0.2: x = 10.5396, y = 11.7158, which is close to the
numerical solution.
EXAMPLE 4.8 Solve the following ordinary differential equations:
F[

FZ

F
[
FZ
with the initial condition y(0) = 2, z(0) = 1. Determine the value of y and z at x = 3. Compare
the numerical solution with the analytical solution. The analytical solution of the given
differential equations is y = Asin(x + a) and z = Acos(x + a).
Solution The two simultaneous ordinary differential equations can be written as

F[
H 
FZ

F
H [
FZ
The initial condition is: at x = 0, y = 2, z = 1. We have to determine y and z at x = 3. The
result from Program 4.3 at step size of 0.01 is: at x = 3: y = –1.84, z = –1.27. Now let us check
the numerical result with the analytical solution. First let us determine the constants A and a.
At x = 0: y = 2, z = 1, and thus
2 = A sin(0 + a)
1 = A cos(0 + a)
Thus tan a = 2 or a = 63.435° and thus A = 2.236. From the conversion of radians to degrees
we know that 3.1416 radians = 180°. Thus x = 3 = 171.887°. At x = 3 the following is obtained:
y = 2.236 sin(171.887 + 63.435) = –1.84
z = 2.236 cos(171.887 + 63.435) = –1.27
which is the same as numerical solution.
EXAMPLE 4.9 Solve the following ordinary differential equation:



F [
[Z
FZ
with the initial conditions y(0) = 2, y¢(0) = 1. Determine the value of y at x = 3.
66 Introduction to Numerical Methods in Chemical Engineering
Solution Let us take
F[

FZ
Then the given differential equation can be written as

F
[Z
FZ
The two simultaneous differential equations can be written as

F[
H 
FZ

F
H [Z
FZ
The initial condition is at x = 0, y = 2, z = 1. We have to determine y at x = 3. Program 4.3
can be modified (only the functions func1 and func2 have to be changed) and with step size
of 0.01 we get at x = 3: y = –1.90, z = –1.15.
4.6 Series of Stirred Tanks with Coil Heater
The schematic diagram of a series of stirred tanks with coil heater is shown in Fig. 4.5. The mass
in each tank shall be assumed constant as the tank volume and density of oil are assumed
constant. The energy balance of tank 1 (accumulation = Input – Output) gives
 introduction-to-numerical-methods-in-chemical-engineering
2 2 5
F6
/% O% 6 6 7# 6 6
FV
where M is the mass of oil in the tank and O is the flow rate of oil. T0 is the inlet temperature
T3
T3
T2T1
T1 T2
O kg/s
T0
Fig. 4.5 Schematic diagram of series of stirred tanks with coil heater.
Initial Value Problems 67
of the oil. T1, T2, and T3 are the temperatures of the first, second and third tank respectively.
TS is the temperature of steam. The energy balance of tank 2 gives
 introduction-to-numerical-methods-in-chemical-engineering
2 2 5
F6
/% O% 6 6 7# 6 6
FV
The energy balance of tank 3 gives
 introduction-to-numerical-methods-in-chemical-engineering
2 2 5
F6
/% O% 6 6 7# 6 6
FV
The analysis is described in the example below.
EXAMPLE 4.10 Three tanks in series are used to heat oil (see Fig. 4.5). Each tank is initially
filled with 1000 kg of oil at 20°C. Saturated steam at 250°C condenses within the coils
immersed in each tank. Oil is fed into the first tank at a rate of 2 kg/s and overflows into the
second and third tanks at the same flow rate. The temperature of the oil fed to the first tank
is 20°C. The tanks are well mixed so that the temperature inside the tanks is uniform and the
outlet stream temperature is the temperature within the tank. Cp of oil = 2000 J/kg-K. The rate
of heat transferred to the oil from the steam is given by 3 = UA(TS – T), where A is the outside
area of the coil in one tank, A = 1 m2
and the overall heat transfer coefficient is based on the
outside area of the coil, U = 200 W/m2
-K. Determine the steady state temperature in all the
three tanks. What time interval is required for T3 to reach 99% of this steady state value?
Solution UA = 200 W/K. From the first differential equation we get
 introduction-to-numerical-methods-in-chemical-engineering
u u   


 


      
 
F6
6 6
FV
F6
6
FV
From the second differential equation we get
 introduction-to-numerical-methods-in-chemical-engineering
u u   
 

  

 
     
  
F6
6 6 6
FV
F6
6 6
FV
From the third differential equation we get
 introduction-to-numerical-methods-in-chemical-engineering
u u   
 

  

 
     
  
F6
6 6 6
FV
F6
6 6
FV
The initial condition is: at t = 0: T1 = T2 = T3 = 20°C. Program 4.4 for the solution of above

More Related Content

PDF
PPTX
Gas Absorption & Stripping in Chemical Engineering (Part 3/4)
PPT
8. fm 9 flow in pipes major loses co 3 copy
PDF
Sedimentation
PPTX
reboiler in process industry.
PPTX
Saponification in a batch reactor
PPTX
Fluid mechanics in our daily life
Gas Absorption & Stripping in Chemical Engineering (Part 3/4)
8. fm 9 flow in pipes major loses co 3 copy
Sedimentation
reboiler in process industry.
Saponification in a batch reactor
Fluid mechanics in our daily life

What's hot (20)

PPTX
Thermosyphon Reboiler & its type with operational parameter.
PPTX
Compressible flows in fluid mechanics in chemical engineering
PPTX
Reflux ratio
PDF
Pump Cavitation & Net Positive Suction Head
PDF
Two-Phase Flow Patterns and Flow-Pattern Maps
PPTX
Heat transfer in packed bed
PPTX
Benzene manufacturing
PPTX
Unit Operations of chemical Engineering.
PDF
Aspen HYSYS - Your very first HYSYS Simulation (1).pdf
PPTX
Bernoulli’s equation and its significance
PPTX
Lewis-Randall Rule ,Excess property,Excess Gibbs Energy &Activity Coefficient
PPTX
Water demineralization process
PPTX
Forced convection
PDF
Design of thermosyphon reboiler
PPTX
Difference between batch,mixed flow & plug-flow reactor
PPTX
Fluid mechanics
PDF
Fluid Mechanics Chapter 2 Part II. Fluids in rigid-body motion
Thermosyphon Reboiler & its type with operational parameter.
Compressible flows in fluid mechanics in chemical engineering
Reflux ratio
Pump Cavitation & Net Positive Suction Head
Two-Phase Flow Patterns and Flow-Pattern Maps
Heat transfer in packed bed
Benzene manufacturing
Unit Operations of chemical Engineering.
Aspen HYSYS - Your very first HYSYS Simulation (1).pdf
Bernoulli’s equation and its significance
Lewis-Randall Rule ,Excess property,Excess Gibbs Energy &Activity Coefficient
Water demineralization process
Forced convection
Design of thermosyphon reboiler
Difference between batch,mixed flow & plug-flow reactor
Fluid mechanics
Fluid Mechanics Chapter 2 Part II. Fluids in rigid-body motion
Ad

Viewers also liked (18)

PDF
Types of chemical reactions document
PDF
Thermodynamics & Chemistry: Howard Devoe
PDF
Sách new cutting edge - pre intermediate -Book
PDF
Benny and the biscuits
PDF
Calculo earl swokowski subido JHS
PDF
Como puedo desarrollar mis talentos
PDF
Book of IQ Tests
PPTX
PMI-ACP Exam Study Flashcards sample
PDF
Oxford dictionary earth science
PDF
Total english -_elementary
PPTX
Persuasive Project Proposal Writing for Effective Fundraising
PDF
Cracking sin secretos
PDF
13986149 c-pgming-for-embedded-systems
PPTX
Business process mapping
PDF
A critical review of academic institutions and quality in higher education
PDF
Fireside Alphabet Picture Book
PDF
Handbook of mechanical engineering calculations
PDF
Curso microcontroladores pic no mp lab 8
Types of chemical reactions document
Thermodynamics & Chemistry: Howard Devoe
Sách new cutting edge - pre intermediate -Book
Benny and the biscuits
Calculo earl swokowski subido JHS
Como puedo desarrollar mis talentos
Book of IQ Tests
PMI-ACP Exam Study Flashcards sample
Oxford dictionary earth science
Total english -_elementary
Persuasive Project Proposal Writing for Effective Fundraising
Cracking sin secretos
13986149 c-pgming-for-embedded-systems
Business process mapping
A critical review of academic institutions and quality in higher education
Fireside Alphabet Picture Book
Handbook of mechanical engineering calculations
Curso microcontroladores pic no mp lab 8
Ad

Similar to introduction-to-numerical-methods-in-chemical-engineering (20)

PDF
Introduction to numerical methods in chemical engineering.pdf
PDF
Mathematical models for a chemical reactor
PDF
Computational Chemical Engineering
PDF
[E-book at Google Play Books] MATLAB Applications in Chemical Engineering (20...
DOC
Cf dfinal1 (may11)
PDF
Introduction to numerical methods in chemical engineering p. ahuja
PDF
An algorithm for simulation of achemical transport equation in an aquifer fin...
DOCX
PDF
Numerical Methods For Chemical Engineering Applications In Matlab Beers
PDF
ANSYS Project
PDF
Lecture notes.pdfhdhdhshsgdjshsjssjsjsgihhs
PDF
Sedat Biringen, Chuen-Yen Chow - An Introduction to Computational Fluid Mecha...
PDF
Advanced Data Analysis and Modelling in Chemical Engineering.pdf
PPT
6주차
PDF
(E book) thermodynamics fundamentals for applications - j. o'connell, j. ha...
PDF
Assignment 1 - Application of Numerical Analysis.pdf
PDF
AOFW CHG433_Part I_wip_Nov2023.pdf presentation
PPTX
Scilab Chemical Engineering application.pptx
PDF
A simple finite element solver for thermo-mechanical problems - margonari eng...
PDF
Charles-G.-Hill-Jr-An-Introduction-To-Chemical-Engineering-Kinetics-Reactor-D...
Introduction to numerical methods in chemical engineering.pdf
Mathematical models for a chemical reactor
Computational Chemical Engineering
[E-book at Google Play Books] MATLAB Applications in Chemical Engineering (20...
Cf dfinal1 (may11)
Introduction to numerical methods in chemical engineering p. ahuja
An algorithm for simulation of achemical transport equation in an aquifer fin...
Numerical Methods For Chemical Engineering Applications In Matlab Beers
ANSYS Project
Lecture notes.pdfhdhdhshsgdjshsjssjsjsgihhs
Sedat Biringen, Chuen-Yen Chow - An Introduction to Computational Fluid Mecha...
Advanced Data Analysis and Modelling in Chemical Engineering.pdf
6주차
(E book) thermodynamics fundamentals for applications - j. o'connell, j. ha...
Assignment 1 - Application of Numerical Analysis.pdf
AOFW CHG433_Part I_wip_Nov2023.pdf presentation
Scilab Chemical Engineering application.pptx
A simple finite element solver for thermo-mechanical problems - margonari eng...
Charles-G.-Hill-Jr-An-Introduction-To-Chemical-Engineering-Kinetics-Reactor-D...

Recently uploaded (20)

PPTX
CYBER-CRIMES AND SECURITY A guide to understanding
PDF
Mohammad Mahdi Farshadian CV - Prospective PhD Student 2026
PDF
Unit I ESSENTIAL OF DIGITAL MARKETING.pdf
PDF
The CXO Playbook 2025 – Future-Ready Strategies for C-Suite Leaders Cerebrai...
PDF
Automation-in-Manufacturing-Chapter-Introduction.pdf
PPTX
M Tech Sem 1 Civil Engineering Environmental Sciences.pptx
PPTX
FINAL REVIEW FOR COPD DIANOSIS FOR PULMONARY DISEASE.pptx
PDF
737-MAX_SRG.pdf student reference guides
PDF
Operating System & Kernel Study Guide-1 - converted.pdf
PPTX
UNIT-1 - COAL BASED THERMAL POWER PLANTS
PPTX
CH1 Production IntroductoryConcepts.pptx
PPTX
Current and future trends in Computer Vision.pptx
PDF
PPT on Performance Review to get promotions
PDF
BIO-INSPIRED HORMONAL MODULATION AND ADAPTIVE ORCHESTRATION IN S-AI-GPT
PPTX
Safety Seminar civil to be ensured for safe working.
PPTX
Geodesy 1.pptx...............................................
PPTX
Construction Project Organization Group 2.pptx
PPTX
Infosys Presentation by1.Riyan Bagwan 2.Samadhan Naiknavare 3.Gaurav Shinde 4...
PPTX
OOP with Java - Java Introduction (Basics)
DOCX
573137875-Attendance-Management-System-original
CYBER-CRIMES AND SECURITY A guide to understanding
Mohammad Mahdi Farshadian CV - Prospective PhD Student 2026
Unit I ESSENTIAL OF DIGITAL MARKETING.pdf
The CXO Playbook 2025 – Future-Ready Strategies for C-Suite Leaders Cerebrai...
Automation-in-Manufacturing-Chapter-Introduction.pdf
M Tech Sem 1 Civil Engineering Environmental Sciences.pptx
FINAL REVIEW FOR COPD DIANOSIS FOR PULMONARY DISEASE.pptx
737-MAX_SRG.pdf student reference guides
Operating System & Kernel Study Guide-1 - converted.pdf
UNIT-1 - COAL BASED THERMAL POWER PLANTS
CH1 Production IntroductoryConcepts.pptx
Current and future trends in Computer Vision.pptx
PPT on Performance Review to get promotions
BIO-INSPIRED HORMONAL MODULATION AND ADAPTIVE ORCHESTRATION IN S-AI-GPT
Safety Seminar civil to be ensured for safe working.
Geodesy 1.pptx...............................................
Construction Project Organization Group 2.pptx
Infosys Presentation by1.Riyan Bagwan 2.Samadhan Naiknavare 3.Gaurav Shinde 4...
OOP with Java - Java Introduction (Basics)
573137875-Attendance-Management-System-original

introduction-to-numerical-methods-in-chemical-engineering

  • 1. INTRODUCTION TO NUMERICAL METHODS IN CHEMICAL ENGINEERING Pradeep Ahuja dCj dx = 0, j = A,B,C,D C – Ci i – 1dCi dx u = u Dx dCj dx uC = uC – Dj,in j A+B C k1 B+C D k2 2 d CA 2 dx D – u C CA B– k = 01 dCA dx 2 d CB 2 dx D – u C CA B– k – k C C = 01 2 B C dCB dx 2 d CC 2 dx D – u + C CA Bk – k C C = 01 2 B C dCC dx 2 d CD 2 dx D – u + k C C = 02 B C dCD dx C – 2C + Ci + 1 i i – 1 2 d Ci 2 dx D = D 2 Dx u x
  • 2. Introductionto Numerical Methods in Chemical Engineering
  • 3. Introductionto Numerical Methods in Chemical Engineering PRADEEP AHUJA Associate Professor Department of Chemical Engineering and Technology Institute of Technology, Banaras Hindu University Varanasi New Delhi-110001 2010
  • 4. Rs. 275.00 INTRODUCTION TO NUMERICAL METHODS IN CHEMICAL ENGINEERING Pradeep Ahuja © 2010 by PHI Learning Private Limited, New Delhi. All rights reserved. No part of this book may be reproduced in any form, by mimeograph or any other means, without permission in writing from the publisher. ISBN-978-81-203-4018-3 The export rights of this book are vested solely with the publisher. Published by Asoke K. Ghosh, PHI Learning Private Limited, M-97, Connaught Circus, New Delhi-110001 and Printed by Jay Print Pack Private Limited, New Delhi-110015.
  • 6. Contents vii Preface ix 1. Linear Algebraic Equations 1–16 1.1 Tridiagonal Matrix Algorithm (TDMA) 1 1.2 Gauss Elimination Method 5 1.3 Gauss–Seidel Method 10 Exercises 12 2. Nonlinear Algebraic Equations 17–30 2.1 Newton’s Method 17 2.2 Pressure Drop in Pipe 20 2.3 Minimum Fluidization Velocity 21 2.4 Terminal Velocity 23 2.5 System of Nonlinear Equations 25 Exercises 29 3. Chemical Engineering Thermodynamics 31–52 3.1 Solution of Cubic Equations of State 31 3.2 Bubble Point and Dew Point Temperature Calculations Using Raoult’s Law 33 3.2.1 Bubble Point Temperature Calculation 33 3.2.2 Dew Point Temperature Calculation 34 3.3 Flash Calculations Using Raoult’s Law 35 3.4 Bubble Point and Dew Point Temperature Calculations Using Modified Raoult’s Law 37 3.5 Flash Calculations Using Modified Raoult’s Law 40 3.6 Vapour Pressure Using Cubic Equation of State 42 3.7 P-x-y Diagram Using Gamma–Phi Approach 43 3.8 P-x-y Diagram Using Cubic Equation of State 44 3.9 Chemical Reaction Equilibrium—Two Simultaneous Reactions 47 3.10 Adiabatic Flame Temperature 49 Exercises 50
  • 7. viii Contents 4. Initial Value Problems 53–84 4.1 Solution of Single Ordinary Differential Equation 53 4.2 Double Pipe Heat Exchanger 55 4.3 Stirred Tank with Coil Heater 57 4.4 Pneumatic Conveying 60 4.5 Solution of Simultaneous Ordinary Differential Equations 63 4.6 Series of Stirred Tanks with Coil Heater 66 4.7 Initial Value Problems in Chemical Reaction Engineering 68 4.8 Batch and Stirred Tank Reactors 69 4.9 Plug Flow Reactor 74 4.10 Nonisothermal Plug Flow Reactor 76 Exercises 80 5. Boundary Value Problems 85–104 5.1 Discretization in One-Dimensional Space 85 5.2 One-Dimensional Steady Heat Conduction 93 5.3 Chemical Reaction and Diffusion in Pore 97 Exercises 99 6. Convection–Diffusion Problems 105–118 6.1 Upwind Schemes 105 6.1.1 First Order Upwind Scheme 105 6.1.2 Second Order Upwind Scheme 106 6.2 Comparison of CDS and UDS 113 Exercises 114 7. Tubular Reactor with Axial Dispersion 119–154 7.1 Boundary Value Problems in Chemical Reaction Engineering 119 7.2 First Order Reaction 120 7.3 Second Order Reaction 129 7.4 Multiple Reactions 131 Exercises 153 8. Chemical Reaction and Diffusion in a Spherical Catalyst Pellet 155–170 8.1 First Order Reaction 155 8.2 Second Order Reaction 158 8.3 Non isothermal Conditions 161 Exercises 169 9. One-Dimensional Transient Heat Conduction 171–191 9.1 Classification of Partial Differential Equations 171 9.2 Explicit and Implicit Discretization 172 9.3 Crank–Nicolson Discretization 173 9.4 Von Neumann Stability Analysis 174 9.5 Transient Conduction in Rectangular Slab 176 9.6 Transient Conduction in Cylinder 181 9.7 Transient Conduction in Sphere 183 9.8 Transient Diffusion in Sphere 186 Exercises 188
  • 8. Contents ix 10. Two-Dimensional Steady and Transient Heat Conduction 192–223 10.1 Discretization in Two-Dimensional Space 192 10.2 Gauss–Seidel Method 194 10.3 Relaxation Parameter 194 10.4 Red–Black Gauss–Seidel Method 195 10.5 ADI Method for Steady Heat Conduction 208 10.6 ADI Method for Transient Heat Conduction 214 Exercises 220 Appendix: Programs in C++ 225–283 Bibliography 285–286 Index 287–289
  • 9. This book entitled Introduction to Numerical Methods in Chemical Engineering is designed for a course on Numerical Methods in Chemical Engineering and the associated Computer Applications Laboratory course offered as part of undergraduate programmes in chemical engineering. Also, for the courses on Chemical Engineering Mathematics or Applied Mathematics in Chemical Engineering, this book can be used for the numerical solution aspects of chemical engineering problems. The computer programs are listed in C++. The author assumes that the students are at least moderately familiar with the C++ language. In addition to the computer examples, there are several much shorter examples appearing throughout the text. These shorter examples usually illustrate a particular point by means of hand calculations. 33 sample programs in C++, arranged by chapter, are presented in the Appendix and about 148 exercises (including chapter- end exercises with answers) are solved. The numerical solutions of algebraic (linear and nonlinear) and differential (ordinary and partial) equations encountered in subjects such as General Chemical Engineering, Chemical Engineering Thermodynamics, Chemical Reaction Engineering, and Heat Transfer are discussed using introductory but efficient numerical methods. The students can also use the programs and build up their own programs to solve specific Design Project problems in chemical engineering. The author feels that before using chemical engineering software (which use advanced numerical methods), the students should have some hands-on experience on small programs and introductory numerical methods as well as their usage in chemical engineering. The experience gained from using these programs helps in the development of basic understanding of numerical methods and confidence in handling numerical techniques. Some problems whose analytical solutions are available are also solved and the numerical and analytical results are compared. By changing various parameters the student can find out the conditions under which correct results are obtained as well as those under which correct results are not obtained. For the solution of linear algebraic equations, the tridiagonal matrix algorithm (TDMA), Gauss elimination, and Gauss–Seidel methods are discussed. For the solution of nonlinear equation(s), Newton’s method is discussed and for initial value problems in ordinary differential equations the Runge–Kutta fourth order method is discussed. For the solution of boundary value problems the Finite Difference method is used. The Finite Difference method is a simple yet very powerful tool for the solution of boundary value problems, but requires a structured grid. It is the basis for the Advanced Finite Volume and Finite Element methods. In this book the following Finite Difference methods are discussed: Central Difference Scheme (CDS) for discretization of diffusion terms, Upwind Difference Scheme (UDS) for Preface xi
  • 10. discretization of convection terms, Forward in Time and Central in Space (FTCS) difference scheme for discretization of the one-dimensional transient conduction/diffusion equation adopting the Explicit, Implicit and Crank–Nicolson methods, and the Alternating Direction Implicit (ADI) method for the numerical solution of two-dimensional steady and transient heat conduction. Chapter 1 contains an introduction to the numerical solution of a system of linear algebraic equations. The numerical solution of a single as well as two (simultaneous) nonlinear algebraic equation(s) and the calculation of pressure drop in a pipe under nonlaminar conditions, minimum fluidization velocity and terminal velocity are all discussed in Chapter 2. The numerical solution of computer-oriented problems in Chemical Engineering Thermodynamics is discussed in Chapter 3. Various problems in vapour–liquid and chemical reaction equilibria are discussed. Vapour–liquid equilibrium calculations are done for systems following Raoult’s law, modified Raoult’s law, Gamma–Phi approach and Phi–Phi approach. The numerical solution of initial value problems in ordinary differential equations, along with the initial value problems in double pipe heat exchanger and stirred tanks with coil heater, and in batch, stirred and plug flow reactors are discussed in Chapter 4. The numerical solution of boundary value problems in ordinary differential equations and convection–diffusion problems are discussed in Chapters 5 and 6 respectively. The numerical solution of tubular reactors with axial dispersion and simultaneous chemical reaction and diffusion in spherical catalyst pellets are discussed in Chapters 7 and 8 respectively. The numerical solution of one-dimensional transient heat conduction/diffusion is discussed in Chapter 9, and that of two-dimensional steady and transient heat conduction is discussed in Chapter 10. The Finite Difference method is used for the solution of boundary value problems in Chapters 5–10. The books referred to by the author for the preparation of class notes, on which the contents of this book are principally based, is given in the Bibliography. The author expresses his thanks to all those authors, too numerous to acknowledge individually. The author is indebted to all his colleagues for many positive interactions and discussions and also to all his friends for their constant appreciation, invaluable advice and encouragement. The author would like to thank the Department of Science and Technology, New Delhi, for providing partial financial support and Prof. S.N. Upadhyay, Director, Institute of Technology, Banaras Hindu University, Varanasi, for providing the major part of the funds for the purchase of Fluent 25 Users Perpetual License software in the Department of Chemical Engineering and Technology, which proved immensely useful in the process of writing this book. The author is also thankful to all his B.Tech. Chemical Engineering students who have taken up the Computer Laboratory course and various computational and other chemical engineering courses so enthusiastically and helped in many ways in developing this work. Their inquisitive questions and enthusiasm towards the numerical solution of algebraic and differential equations in chemical engineering inspired the author to create a work of this kind, in which the numerical solution of various equations in chemical engineering is provided under one cover. Feedback from students has critically guided the development and evolution of the book, taking it from a handwritten collection of notes to the present form. The book is thus dedicated to all his students. The author is grateful to Mr. Sudarshan Das, Mr. Abhjit Baroi and Mr. Pankaj Manohar of PHI Learning for their cooperation. xii Preface
  • 11. The author is indebted and extremely thankful to his mother Kamla Ahuja, to his father A.D. Ahuja, and his wife Preeti Bala Ahuja, for their care, help and understanding, as without their support this work could never have been completed. In spite of all efforts to the contrary, some errors might have crept into the book. The author would be rather grateful if such errors are pointed out. He would also very much appreciate any criticism or suggestion for improvement of the contents of the book from the readers. Pradeep Ahuja Preface xiii
  • 12. 1 Chapter 1 Linear Algebraic Equations A system of linear algebraic equations can be solved by direct or iterative methods. The direct methods discussed in this chapter are the TriDiagonal Matrix Algorithm (TDMA) and Gauss Elimination methods, and the iterative method discussed is the Gauss-Seidel method. A tridiagonal or block tridiagonal set of linear algebraic equations is formed during the discretization of ordinary and partial differential equations. The discretization of differential equations using the finite difference method is discussed in Chapters 5 to 10. All types of linear algebraic equations can be solved using the Gauss Elimination method, but if the equations are of tridiagonal type, then TDMA is very fast as compared to the Gauss Elimination method. The Gauss–Seidel method is used for the solution of two-dimensional steady heat transfer, which is discussed in Chapter 10. 1.1 Tridiagonal Matrix Algorithm (TDMA) TDMA is a direct method. Consider the following tridiagonal set of linear algebraic equations: 0 0 0 0 0 0 0 0 0 D E Z F C D E Z F C D E Z F C D E Z F C D E Z F C D Z F ª º ª º ª º « » « » « » « » « » « » « » « » « » « » « » « » « » « » « » « » « » « » « » « » « » « » « » « » « » « » « » « » « » « » « » « » « » « » « » « « » « » «¬ ¼ ¬ ¼ ¬ ¼ » » (1.1) N linear algebraic equations can be written in the form Ax = d. The matrix A contains elements on the diagonal (bi, i = 1 to N), sub-diagonal (ai, i = 2 to N), and super-diagonal (ci, i = 1 to N – 1), and thus is called a tridiagonal matrix. The algorithm for the solution of this sort of linear algebraic equation is called the TriDiagonal Matrix Algorithm or the Thomas algorithm.
  • 13. 2 Introduction to Numerical Methods in Chemical Engineering The equations are of the type K K K K K K K C Z D Z E Z F where a1 = 0, cN = 0 (1.2) Let us write the solution at xi in terms of xi+1 as K K K K K E Z Z H C (1.3a) Then we can also write K K K K K E Z Z H C (1.3b) where bi and gi are obtained by substituting Eq. (1.3b) into Eq. (1.2). Thus we get K K K K K K K K K K E Z C D Z E Z FH C § · ¨ ¸ © ¹ The above equation can be written as K K K K K K K K K K C E D Z F C E ZH C § · ¨ ¸ © ¹ Thus K K K K K K K K K K K K K K F C E Z Z C E C E D D H C C § · § · ¨ ¸ ¨ ¸ © ¹ © ¹ Comparing with Eq. (1.3a), we get K K K K K C E DC C (1.4) K K K K K K K KK K K K F C F C C E D H H H C C § · ¨ ¸ © ¹ (1.5) a1 = 0; therefore b1 = b1 (1.6) and F D H (1.7) The algorithm for the solution of a tridiagonal set of linear algebraic equations is given below: (i) Calculate bi and gi for i = 1 to N. (ii) Calculate 0 0 0 0 0 E Z Z H C . Since cN = 0, therefore xN = gN. (iii) Calculate K K K K K E Z Z H C for i = N – 1, N – 2, …, 3, 2, 1.
  • 14. Linear Algebraic Equations 3 EXAMPLE 1.1 Solve the following set of linear algebraic equations using TDMA Z Z Z Z Z Z Z ª ºª º ª º « »« » « » « »« » « » « »« » « » « »« » « » « »« » « » « »« » « » « »« » « » « »« » « » « »« » « » « » « »« »¬ ¼ ¬ ¼¬ ¼ Solution We have C D H F D C E DC C H H C F C u C C C E D H H C F C C C C E D H H C F C C C C E D
  • 15. 4 Introduction to Numerical Methods in Chemical Engineering H H C F C C C C E D H H C F C C C C E D H H C F C Now let us compute the solution starting with x7. H Z H C E Z Z u H C E Z Z u H C E Z Z u H C E Z Z u H C E Z Z H C E Z Z
  • 16. Linear Algebraic Equations 5 Program 1.1 uses the above method for solving the tridiagonal system of linear algebraic equations and is given in the Appendix. 1.2 Gauss Elimination Method Gauss Elimination is a direct method. The Gauss Elimination method reduces the system of equations to an upper triangular system which can then be solved by back substitution. Consider the following system of three linear algebraic equations: C Z C Z C Z F C Z C Z C Z F C Z C Z C Z F The augmented matrix is C C C F C C C F C C C F ª º « » « » « » ¬ ¼ (1.8) Take the element a11 as the pivot. Multiply the first equation by C C and then add it to the second equation, which then becomes C CC C C C Z C Z F F C C C § · § · ¨ ¸ ¨ ¸ © ¹ © ¹ Thus x1 is eliminated from the second equation. Similarly, eliminate x1 from the third equation by multiplying the first equation by C C and then adding it to the third equation. At the end of the first stage the augmented matrix becomes C C C F C C F C C F ª º « » c c c« » « »c c c¬ ¼ (1.9) Now take the element a¢22 as the new pivot. Multiply the second equation by C C c c and then add it to the third equation. Thus x2 is eliminated from the third equation. At the end of the second stage the augmented matrix becomes C C C F C C F C F ª º « » c c c« » « »cc cc¬ ¼ (1.10) The values of x1, x2, and x3 can be obtained by back substitution. The pivots should be chosen in such a way that they are nonzero. Rows can be exchanged so that the pivot is nonzero. This procedure is called partial pivoting.
  • 17. 6 Introduction to Numerical Methods in Chemical Engineering EXAMPLE 1.2 Solve the following set of three linear algebraic equations in three variables using the Gauss Elimination method: Z Z Z Z Z Z Z Z Z Solution The augmented matrix is ª º « » « » « » ¬ ¼ Multiply the first equation by and then add it to the second equation. We get ª º « » « » « » ¬ ¼ Multiply the first equation by and then add it to the third equation. We get ª º « » « » « » ¬ ¼ This completes the first stage. Multiply the second equation by and then add it to the third equation. We get ª º « » « » « » ¬ ¼ From the previous equation we get 9.68367x3 = 48.418367 Solving, we get x3 = 5. From the second equation we get 9.8x2 + 0.6x3 = 42.2 Thus Z u From the first equation we get 10x1 + x2 + 2x3 = 44
  • 18. Linear Algebraic Equations 7 Thus Z u . Program 1.2 uses the Gauss elimination method for solving a system of linear algebraic equations and is given in the Appendix. EXAMPLE 1.3 Solve the following set of three linear algebraic equations in three variables using the Gauss Elimination method: Z Z Z Z Z Z Z Z Z Solution The augmented matrix is ª º « » « » « »¬ ¼ Multiply the first equation by and then add it to the second equation. We get ª º « » « » « »¬ ¼ Multiply the first equation by and then add it to the third equation. We get ª º « » « » « » ¬ ¼ Multiply the second equation by 0.3076923 and then add it to the third equation. We get ª º « » « » « »¬ ¼ From the previous equation, we get 3.5384x3 = –3.5384 Solving, we get x3 = –1.
  • 19. 8 Introduction to Numerical Methods in Chemical Engineering From the second equation, we get 4.3333x2 – 3.6667x3 = –5 Thus Z . From the first equation, we get 3x1 + x2 – 2x3 = 9 Thus Z . EXAMPLE 1.4 Benzene (1), toluene (2), styrene (3), and xylene (4) are to be separated in the sequence of distillation columns shown in Fig. 1.1. Determine molar flow rates of streams D1, B1, D2, and B2. The composition of the feed stream and the streams D1, B1, D2, and B2 is shown in the figure. Also, determine the molar flow rates and compositions of streams B and D. The molar flow rate of the feed stream is 70 mol/min. Fig. 1.1 Schematic diagram for Example 1.4. Solution The material balance equations for benzene (1), toluene (2), styrene (3), and xylene (4) are given below. x1 = 0.35 x2 = 0.54 x3 = 0.04 x4 = 0.07 x1 = 0.16 x2 = 0.42 x3 = 0.24 x4 = 0.18 x1 = 0.21 x2 = 0.54 x3 = 0.10 x4 = 0.15 x1 = 0.01 x2 = 0.10 x3 = 0.65 x4 = 0.24 x1 = 0.20 x2 = 0.40 x3 = 0.25 x4 = 0.15 70 mol/min D1 D B1 D2 B B2
  • 20. Linear Algebraic Equations 9 $ $u $ $u $ $u $ $u The above equations can be written as $ $ ª ºª º ª º « »« » « » « »« » « » « »« » « » « »« » « » « » « »« »¬ ¼ ¬ ¼¬ ¼ Solving by using the Gauss Elimination method, we get D1 = 26.25 mol/min B1 = 17.5 mol/min D2 = 8.75 mol/min B2 = 17.5 mol/min. B = D2 + B2 = 26.25 mol/min. The composition of stream B is given by $ $ Z $ $ $ Z $ $ $ Z $ $ $ Z $ D = D1 + B1 = 43.75 mol/min. The composition of stream D is given by $ Z $ Z
  • 21. 10 Introduction to Numerical Methods in Chemical Engineering $ Z $ Z Now, let us check the solution obtained. B + D is 70 mol/min, which is correct. Now, let us back-calculate the feed composition. $Z $Z $Z $Z $Z $Z $Z $Z 1.3 Gauss–Seidel Method Gauss–Seidel is an iterative method. Consider a system of N linear algebraic equations in N variables. The first equation can be written with variable x1 on the left hand side and the rest of the terms on the right hand side. Similarly, the second equation can be written with variable x2 on the left hand side and the rest of the terms on the right hand side, and so on. Now we can assume some values of the variables, and compute the new value of x1 from the first equation and the new value of x2 from the second equation, and so on. In the Gauss–Seidel method, when the new value of x2 is computed from the second equation then on the right hand side for the variable x1 the updated value calculated from the first equation, is used. Similarly, when the new value of x3 is calculated from the third equation, then on the right hand side for the variables x1 and x2 the updated values calculated from the first and second equations are used. By doing this a higher convergence rate is obtained. So the latest values of the variables are always used. In the above explanation it is assumed that in the first equation the coefficient of x1 is the highest among the coefficients of the other variables, and in the second equation the coefficient of x2 is the highest among the coefficients of the other variables. All the equations have many variables in them. A survey of the given system of linear algebraic equations is made and that variable which has the highest coefficient is kept on the left hand side. The variable whose coefficient is the largest is used to express that variable in terms of the others. The Gauss–Seidel method has the disadvantage of not always converging to a solution and of sometimes converging very slowly. However, this method will always converge to a solution when the magnitude of the coefficient on the left hand side is sufficiently dominant with respect to the magnitudes of the other coefficients in that equation.
  • 22. Linear Algebraic Equations 11 EXAMPLE 1.5 Solve the following set of three linear algebraic equations in three variables using the Gauss–Seidel method: 10x1 + x2 + 2x3 = 44 2x1 + 10x2 + x3 = 51 x1 + 2x2 + 10x3 = 61 Solution It can be seen that the coefficient of x1 is dominant in the first equation, and the coefficient of x2 and x3 are dominant in the second and third equations, respectively. Thus P P P Z Z Z P P P Z Z Z P P P Z Z Z Let us assume x2 = 0, x3 = 0. The initial values used will not affect the converged solution, but will affect the number of iterations required for convergence. First Iteration: Z Z u Z – Second Iteration: Z u Z u Z u The final converged solution is 1x = 3, 2x = 4, 3x = 5. Program 1.3 uses the Gauss–Seidel method for solving a system of linear algebraic equations and is given in the Appendix. EXAMPLE 1.6 Solve the following set of three linear algebraic equations in three variables using the Gauss–Seidel method: Z Z Z Z Z Z Z Z Z
  • 23. 12 Introduction to Numerical Methods in Chemical Engineering Solution Let us write the first, second and third equations in the form P P P Z Z Z P P P Z Z Z P P P Z Z Z Let us assume x2 = 0, x3 = 0. First Iteration: Z Z Z Second Iteration: Z u Z u Z The final converged solution is x1 = 3, x2 = –2, x3 = –1. Exercises 1.1 Solve the following using TDMA: Z Z Z Z Z Z Z Z ª ºª º ª º « »« » « » « »« » « » « »« » « » « »« » « » « »« » « » « »« » « » « »« » « » « »« » « » « »« » « » « »« » « » « »« » « »¬ ¼ ¬ ¼¬ ¼ (Ans: x1 = 111.11, x2 = 122.22, x3 = 133.33, x4 = 144.44, x5 = 155.55, x6 = 166.66, x7 = 177.77, x8 = 188.88)
  • 24. Linear Algebraic Equations 13 1.2 Solve the following linear algebraic equations using the Gauss elimination method: 2x1 – x2 = 100 – x1 + 2x2 – x3 = 0 – x2 + 2x3 – x4 = 0 – x3 + 2x4 – x5 = 0 – x4 + 2x5 – x6 = 0 – x5 + 2x6 – x7 = 0 – x6 + 2x7 – x8 = 0 – x7 + 2x8 = 200 Note that the augmented matrix for this problem is ª º « » « » « » « » « » « » « » « » « » « » « »¬ ¼ (Ans: x1 = 111.11, x2 = 122.22, x3 = 133.33, x4 = 144.44, x5 = 155.55, x6 = 166.66, x7 = 177.77, x8 = 188.88) 1.3 Solve the equations in Problem 1.2 using the Gauss–Seidel method. Note that the equations are expressed in the form P P Z Z P P P Z Z Z P P P Z Z Z P P P Z Z Z P P P Z Z Z
  • 25. 14 Introduction to Numerical Methods in Chemical Engineering P P P Z Z Z P P P Z Z Z P P Z Z (Ans: x1 = 111.11, x2 = 122.22, x3 = 133.33, x4 = 144.44, x5 = 155.55, x6 = 166.66, x7 = 177.77, x8 = 188.88) 1.4 Solve the following linear algebraic equations using the Gauss elimination method: 4x1 + 2x2 + x3 = 11 –x1 + 2x2 = 3 2x1 + x2 + 4x3 = 16 Note that the augmented matrix is ª º « » « » « » ¬ ¼ (Ans: x1 = 1, x2 = 2, x3 = 3) 1.5 Solve the linear algebraic equations of Problem 1.4 using the Gauss–Seidel method: Note that for Gauss–Seidel to converge the equations are expressed in the form P P P Z Z Z P P Z Z P P P Z Z Z (Ans: x1 = 1, x2 = 2, x3 = 3) 1.6 Solve the following linear algebraic equations using the Gauss elimination method: Z Z Z Z Z Z Z Z Z (Ans: x1 = 1.2857, x2 = 1.9286, x3 = 2.8571)
  • 26. Linear Algebraic Equations 15 1.7 Solve the linear algebraic equations of Problem 1.6 using the Gauss-Seidel method: Note that for Gauss–Seidel to converge the equations are expressed in the form P P P Z Z Z P P P Z Z Z P P P Z Z Z (Ans: x1 = 1.2857, x2 = 1.9286, x3 = 2.8571) 1.8 Solve the following linear algebraic equations using the Gauss elimination method: 6 6 6 6 6 6 6 6 6 ª º ª º « »« » « »« » « »« » « »« » « »« » « »« » « »« » « »« » « »« » « »« » « »« » « »« » « » « »¬ ¼ ¬ ¼ ª º « » « » « » « » « » « » « » « » « » « » « » « » « »¬ ¼ Note that for using the Gauss elimination method the equations have to expressed in the form of augmented matrix as ª º « » « » « » « » « » « » « » « » « » « » « » « » « »¬ ¼ (Ans: T1,1 = 47.14, T1,2 = 91.25, T1,3 = 182.86, T2,1 = 57.32, T2,2 = 115.00, T2,3 = 220.18, T3,1 = 47.14, T3,2 = 91.25, T3,3 = 182.86)
  • 27. 16 Introduction to Numerical Methods in Chemical Engineering 1.9 Solve the following linear algebraic equations using the Gauss–Seidel method: 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 Note that for Gauss–Seidel to converge the equations are to be expressed in the form P P P 6 6 6 P P P P 6 6 6 6 P P P 6 6 6 P P P P 6 6 6 6 P P P P P 6 6 6 6 6 P P P P 6 6 6 6 P P P 6 6 6 P P P P 6 6 6 6 P P P 6 6 6 (Ans: T1,1 = 47.14, T1,2 = 91.25, T1,3 = 182.86, T2,1 = 57.32, T2,2 = 115.00, T2,3 = 220.18, T3,1 = 47.14, T3,2 = 91.25, T3,3 = 182.86)
  • 28. 17 Chapter 2 Nonlinear Algebraic Equations Newton’s (or Newton–Raphson) method for the numerical solution of a nonlinear algebraic equation is described first in this chapter. Examples discussed include the calculation of pressure drop in a pipe in nonlaminar range, and the calculation of minimum fluidization velocity and terminal velocity. Thereafter the solution of two simultaneous nonlinear algebraic equations is discussed using Newton’s method. 2.1 Newton's Method The function f is formulated in such a way that the polynomial or the expression whose root is to be determined is of the form f (x) = 0. Newton’s method is given by P P H Z Z H c (2.1) where xn is the value of x at the start of the iteration and xn+1 is the updated value after the iteration. First an initial value of x is assumed, and the function value and its derivative are determined at this assumed value. The assumed value is updated by using Newton’s formula, and again the function value and its derivative are determined at this new value of x (see Fig. 2.1). The value of x is again updated and the procedure is repeated till there is no change in the previous and updated values of x. By taking different starting (old) values, different roots can be obtained, if more than one real root occurs. Note that when the root is obtained, there is no change in the value of x. That is, xn+1 = xn , which implies f = 0, which is the required condition, that function value should become zero at the root. Note that Newton’s method works only if, at f = 0, the derivative of the function is not zero. In Fig. 2.1, the function value becomes zero at the root xs. In this case the starting value is taken to be x1. The algorithm of Newton’s method is: (i) Take an initial value of xn , (ii) Calculate f and FH H FZ c at the value of xn , (iii) Calculate the new value of x, using P P H Z Z H c , (iv) Check if F P P Z Z ; if yes, stop, else
  • 29. 18 Introduction to Numerical Methods in Chemical Engineering (v) Make xn = xn+1 and go to Step (ii) and repeat the procedure till the condition stated in (iv) is satisfied. e is the convergence criterion and may be of the order of 10–6 . Fig. 2.1 Concept of Newton’s method. The derivation of Newton’s formula is presented below. Let a nonlinear algebraic equation be represented as f (x) = 0. Let us start with an initial guess x0 of the solution and let us assume that it is close to the actual solution xs. We make a Taylor series to approximate f(x) in the vicinity of x0 as follows:
  • 33. Z Z FH F H H Z H Z Z Z Z Z FZ FZ At the solution, 5H Z = 0 and the Taylor series yields
  • 36. 5 5 Z Z FH F H H Z Z Z Z Z FZ FZ If x0 is sufficiently close to xs, then 5 5 5Z Z Z Z Z Z In this case, as long as the first derivative is nonzero at x0 , we obtain a reasonable approximation of the solution, x1 , from the rule
  • 38. Z FH H Z Z Z FZ (2.2) Successive application of this rule yields Newton’s method for solving a single nonlinear algebraic equation in the form
  • 40. P P P P H Z Z Z H Z c f f1 f2 f3 0 x1 x2 x3 x xs
  • 41. Nonlinear Algebraic Equations 19 where f ¢ denotes the derivative of the function with respect to x. The iterations are stopped when the previous and updated values of x are less than eabs, that is F CDU P P Z Z (2.3) or TGN P P P Z Z Z F (2.4) Consider that the real roots of the equation x3 – 2x2 – x + 2 = 0 have to be determined. Different roots are obtained by taking different starting values of x. Newton’s method discussed here determines only the real roots. For the above equation the starting values taken and the corresponding roots are listed in Table 2.1. Table 2.1 Different roots obtained by taking different starting values in Newton’s method Starting value Real root of x3 – 2x2 – x + 2 = 0 by Newton’s method 4.0 2.0 1.5 –1.0 0.5 1.0 0.25 1.0 0.0 2.0 –1.0 –1.0 –2.0 –1.0 –4.0 –1.0 –100.0 –1.0 100.0 2.0 Thus the three roots on which the solution converges are (2, 1, –1). Various iterations in Newton’s method to determine the real root of the equation x3 – 2x2 – x + 2 = 0 with starting value x = 4 are listed in Table 2.2. Table 2.2 Various iterations in Newton’s method for starting value of 4x Iteration number Starting point f f ¢ P P H Z Z H c 1 4.0 30.0 28.0 2.92857 2 2.92857 7.03533 13.01529 2.38803 3 2.38803 1.82478 6.55594 2.10969 4 2.10969 0.37852 3.91362 2.01297 5 2.01297 0.03959 3.10426 2.00022 6 2.00022 0.00066 3.00176 2.00000 7 2.00000 0.00000 3.00000 2.00000 In Table 2.2, f = x3 – 2x2 – x + 2, and f ¢ = 3x2 – 4x – 1 .
  • 42. 20 Introduction to Numerical Methods in Chemical Engineering EXAMPLE 2.1 Apply Newton’s method to determine a real root of the equation f (x) = x3 – 5x + 1 = 0 Take the initial approximation as x0 = 0.5. Solution With an initial value of 0.5, it can be checked that the solution is 0.201640. 2.2 Pressure Drop in Pipe The pressure drop in a pipe of length L is given by the relation S ' H.8 2 (2.5) where 8 is the average velocity in the pipe of internal diameter D and the fluid density is r. When the pressure drop is given by Eq. (2.5), the friction factor under laminar flow conditions is given by 4G H (2.6) where S N 4G 8 . For the entire nonlaminar range the friction factor is given by the Colebrook relation F NQI 4G H H § · ¨ ¸¨ ¸ © ¹ (2.7) For the laminar conditions the friction factor can be easily determined. But for nonlaminar conditions the Colebrook equation has to be solved using Newton’s method as described in the example below. EXAMPLE 2.2 Air at 25°C and 1 atm flows through a 4 mm diameter tube with an average velocity of 50 m/s. The roughness is e = 0.0015 mm. Calculate the friction factor using the Colebrook equation F NQI 4G H H § · ¨ ¸¨ ¸ © ¹ Determine the pressure drop in a 1 m section of the tube using the relation S ' H.8 2 Density of air at 25°C and 1 atm is 1.23 kg/m3 and viscosity is 1.79 ´ 10–5 kg/m-s. Solution We have F
  • 43. Nonlinear Algebraic Equations 21 S N 4G 8 u u u u Thus NQI H H § · ¨ ¸¨ ¸ © ¹ or NQI H H § ·u u ¨ ¸¨ ¸ © ¹ Let us define a function, F, as NQI ( H H § ·u u ¨ ¸¨ ¸ © ¹ The derivative of the function with respect to the friction factor is given by
  • 44. H ( H H u u u c u u Using Newton’s method, we get f = 0.0291. Under these conditions the pressure drop in a 1 m section of the pipe is given by ' 2 u u u u N/m2 = 11.19 kPa Program 2.1 for calculating the pressure drop in a pipe under nonlaminar conditions is given in the Appendix. 2.3 Minimum Fluidization Velocity Ergun proposed the following general equation applicable for low, medium and high Reynolds number for pressure drop across a packed bed:
  • 46. F FN S GG F F ' ' ' U RU R X . X . 2 FF (2.8) where n is the superficial velocity of the fluid, dp is the particle diameter, fs is the sphericity of the particle, e is the voidage in the packed bed, and DP is the pressure drop across the packed bed of length DL . r and m are respectively the density and viscosity of the fluid. At the point of incipient fluidization the force obtained from the pressure drop across the fluidized bed (DP ´ A) is equal to the gravitational force exerted by the mass of the particles minus the buoyancy force. If Lmf is the height of the packed bed at the point of minimum fluidization
  • 47. 22 Introduction to Numerical Methods in Chemical Engineering and emf is the voidage of the packed bed at minimum fluidization, then the total volume of the bed at minimum fluidization is Lmf ´ A and thus the volume of solids at minimum fluidization is Lmf A(1 – emf). The gravitational force of the particles minus the buoyancy force is given by volume of the solid particles ´ (rp – r)g. Thus at minimum fluidization conditions
  • 49. F S S' OH OH R2 # . # Iu (2.9) or
  • 51. F S S ' OH OH R 2 I . (2.10) Substituting this value in the Ergun equation for packed bed, we get
  • 55. F FS N F S S G F G F OH OH OH OH OH OH OH R U R U R X X I F F ª ºª º « » « » « »« »¬ ¼ ¬ ¼ (2.11) The real roots of the minimum fluidization velocity can be obtained using Newton’s method. EXAMPLE 2.3 Solid particles having a diameter of 0.12 mm, shape factor fs = 0.88, and a density of 1000 kg/m3 are to be fluidized using air at 2.0 atm and 25o C. The voidage at minimum fluidization is 0.42. The viscosity of air under these conditions is 1.845 ´ 10–5 kg/m-s. The molecular weight of air is 28.97. Solution The density of air at 2.0 atm and 25°C is given by S 2/ 46 u u u u kg/m3 The diameter of the particle is pd = 1.2*10-4 m. The function is
  • 59. F FS N F S S G F G F OH OH OH OH OH OH OH R U R U R H X X I F F ª ºª º « » « » « »« »¬ ¼ ¬ ¼ and the derivative of the function with respect to nmf is
  • 61. F FS N G F G F OH OH OH OH OH U R U R H X F F ª º c « » « »¬ ¼ Starting with an initial value of nmf = 0.1 m/s, the converged value is nmf = 0.0046 m/s. Program 2.2 for calculating the minimum fluidization velocity is given in the Appendix.
  • 62. Nonlinear Algebraic Equations 23 2.4 Terminal Velocity Consider a particle of mass m kg falling at velocity of v m/s (see Fig. 2.2). The momentum balance equation is given by R I D FX O ( ( ( FV (2.12) Gravitational force minus the buoyancy force on the particle is given by
  • 64. S S S S SI D R R R R O ( ( 8 I I (2.13) where VP is the volume of the particle and m is the mass of the particle. Fig. 2.2 Various forces acting on particle falling in stationary fluid. The terminal velocity or free settling velocity is a constant velocity fall and is given when RFX FV ; thus I D ( ( ( (2.14) CD is given by S R V ( # % X . Thus Eq. (2.14) becomes
  • 65. S S S S R R V R O I # % X (2.15) where Ap is the projected area of the particle on a plane at right angles to the direction of motion and nt is the terminal velocity of the falling particle. As the velocity of particle rises the drag force also increases till the drag force balances the (gravitational – buoyancy) force. Thus,
  • 66. S S S S R V R R I O X # % FD Fg – Fb = (rp – r)Vpg
  • 67. 24 Introduction to Numerical Methods in Chemical Engineering For spherical particles, Q Q S S R R R RO T F and the projected area is given by Q Q R R R F # T Thus for spherical particles the expression for terminal velocity becomes
  • 68. S S S R R V IF X % (2.16) For laminar flow (Rep 1), that is, in the Stokes law region 4G R % (2.17) where Rep is the particle Reynold’s number and is given by S N 4G R R XF . We get the following expression for terminal settling velocity in the laminar flow regime
  • 69. S S N R R V IF X (2.18) For turbulent flow, CD = 0.44 (Rep 1000 to 2 ´ 105 ). But for intermediate values of the particle Reynolds number, there are many correlations. The Schiller and Nauman correlation is applicable for Rep 800 and is given by
  • 70. 4G 4G R R % (2.19) The terminal velocity for the case of intermediate values of particle Reynolds number is determined using the following steps: (i) A value of terminal velocity is assumed. (ii) At the assumed value the particle Reynolds number is calculated and thereafter CD is determined. (iii) The terminal velocity is recalculated using
  • 71. S S S R R V IF X % . If the assumed value and recalculated values are different, the new calculated value becomes the starting value for the next iteration. The procedure is repeated till the absolute value of the difference between the new value and the previous value of the terminal velocity in an iteration is negligible.
  • 72. Nonlinear Algebraic Equations 25 EXAMPLE 2.4 Oil droplets of diameter 2 mm are to be settled from air at 25°C and 1 atm. The density of oil is 900 kg/m3 . Calculate the terminal settling velocity of the particles. For air at these conditions, m = 1.85 ´ 10–5 kg/m-s. CD is given by
  • 73. 4G 4G R R % Solution The following data are given: dp = 2 ´ 10–3 m, m = 1.85 ´ 10–5 kg/m-s. The density of air under the given conditions is given by S 2/ 46 u u u kg/m3 The particle Reynolds number is given by S N 4G I V R V R V X F X X u u u u The calculations are presented in Table 2.3. Table 2.3 Calculations in Example 2.6 Assumed nt Rep CD nt 0.03 3.83 8.63 1.5 1.5 191.35 0.82 4.9 4.9 625.0 0.52 6.2 6.2 790.0 0.47 6.47 6.47 825.38 0.47 6.52 The terminal velocity obtained is 6.5285 m/s. Program 2.3 for calculating the terminal velocity is given in the Appendix. 2.5 System of Nonlinear Equations We now extend Newton’s method to solve a set of N simultaneous nonlinear algebraic equations for N unknowns.
  • 77. ! ! ! ! 0 0 0 0 0 H Z Z Z Z H Z Z Z Z H Z Z Z Z H Z Z Z Z We define the vector of unknowns
  • 78. 26 Introduction to Numerical Methods in Chemical Engineering @ 6 0Z Z Z Z Z and write the system of equations as f (x) = 0 We use a Taylor series expansion to obtain Newton’s method, representing the ith function in the vicinity of the current estimate xn as
  • 83. P P 0 0 0 P P P PK K K K O O O O R R O O RO O RZ Z H H H Z H Z Z Z Z Z Z Z Z Z Z ˜ ˜ ˜ ˜ ˜Ç Ç Ç Assuming that xn is sufficiently close to the true solution xS, we can drop the quadratic and higher order terms
  • 85. P 0 P PK K 5 O O OO Z H H Z Z Z Z ˜  ˜Ç For convenience we collect the first partial derivatives into the N ´ N Jacobian matrix P K KO O Z H , Z ˜ ˜ (2.20) The truncated Taylor series expansion then becomes
  • 87. 0 P P P P K KO O O O H Z , Z Z | ¦ or
  • 88. 0 P P P KO O K O , Z H Z' ¦ (2.21) where the update vector is given by P P P Z Z Z' (2.22) The terms on the left hand side of Eq. (2.21) are the ith component of a matrix–vector product. The linear system is
  • 89. P P P , Z H Z' (2.23) Iterations are performed till there is no change in Nxxxx ,...,,, 321 , that is F F F F' ' ' '! CDU CDU CDU CDU P P P P 0Z Z Z Z (2.24) Let us consider two nonlinear equations f1(x1, x2) and f2(x1, x2). To start the iteration, some initial values of x1 and x2 have to be assumed. The change in the values of x1 and x2 are determined using Eq. (2.23). H H Z Z H H Z Z Z H Z H ˜ ˜ ˜ ˜ ˜ ˜ ˜ ˜ Ë Û 'Ë Û Ë ÛÌ Ü Ì Ü Ì ÜÌ Ü 'Í Ý Í ÝÌ ÜÍ Ý (2.25)
  • 90. Nonlinear Algebraic Equations 27 Now we have to find the inverse of the Jacobian matrix. The inverse of a nonsingular 2 ´ 2 matrix C C # C C Ë Û Ì Ü Í Ý is given by FGV C C # C C# Ë Û Ì ÜÍ Ý . Thus Eq. (2.25) can be written as H H Z ZZ H Z HH H Z Z ˜ ˜Ë Û Ì Ü˜ ˜'Ë Û Ë Û Ì ÜÌ Ü Ì Ü' ˜ ˜Ì ÜÍ Ý Í ÝÌ Ü˜ ˜Í Ý (2.26) where H H H H Z Z Z Z ˜ ˜ ˜ ˜ ˜ ˜ ˜ ˜ (2.27) Thus H H H H Z Z Z ˜ ˜ ˜ ˜ ' (2.28) and H H H H Z Z Z ˜ ˜ ˜ ˜ ' (2.29) The algorithm for solution of two simultaneous nonlinear algebraic equations is given below: (i) Assume x1 and x2, (ii) Calculate f1, f2, H Z ˜ ˜ , H Z ˜ ˜ , H Z ˜ ˜ , and H Z ˜ ˜ , (iii) Calculate Dx1 and Dx2, and (iv) Calculate new values of x1 and x2. Go to (ii) till F P P Z Z and F P P Z Z . EXAMPLE 2.5 Obtain the values of x and y that satisfy the following two nonlinear algebraic equations:
  • 92. UKP Z H Z [ G Z[ I Z [ Z[ Z [ Solution The partial derivatives of function f are given by ZH G [ Z H Z [ ˜ ˜ ˜ ˜
  • 93. 28 Introduction to Numerical Methods in Chemical Engineering The partial derivatives of function g are given by EQU EQU I [ Z[ Z I Z Z[ [ ˜ ˜ ˜ ˜ Let us assume x = 0.1 and y = 0.5.
  • 95. UKP EQU EQU Z Z H Z [ G Z[ I Z [ Z[ Z [ H G [ Z H Z [ I [ Z[ Z I Z Z[ [ H I H I Z [ [ Z H I I H [ [ Z I H H I Z[ ˜ ˜ ˜ ˜ ˜ ˜ ˜ ˜ ˜ ˜ ˜ ˜ ˜ ˜ ˜ ˜ ˜ ˜ – –˜ ˜ ' ˜ ˜ ˜' Z – –˜ New x = 0.1 – 0.13036 = –0.03036 New y = 0.5 + 0.5406 = 1.0406 The iterations are summarized in Table 2.4. Table 2.4 Summary of iterations in Example 2.5 x y f g H Z ˜ ˜ H [ ˜ ˜ I Z ˜ ˜ I [ ˜ ˜ D Dx Dy 0.1 0.5 0.1552 –0.3991 1.6052 0.1 1.5 1.1 1.6157 –0.13036 0.5406 –0.03036 1.0406 –0.0615 0.0097 2.0107 –0.03036 2.0406 0.9696 2.0115 0.0295 –0.0721 –0.00086 0.9685 –0.0017 –0.0324 1.9676 –0.00086 1.9685 0.99914 1.9676 0.00088 0.0307 0 0.9992 0.0000 –0.0008 1.9992 0 1.9992 1 1.9992 0 0.0008 0 1 0 0 2 0 2 1 2 0 0
  • 96. Nonlinear Algebraic Equations 29 The solution of the given nonlinear algebraic equations is x = 0 and y = 1. Note that when f = 0 and g = 0 the solution is obtained. Program 2.4 for the solution of the above two simultaneous nonlinear equations is given in the Appendix. EXAMPLE 2.6 Modify Program 2.4 to solve the following system of two nonlinear algebraic equations:
  • 98. H Z Z Z Z H Z Z Z Z Solution For the given nonlinear equations CPF H H H H Z Z Z Z Z Z Z Z ˜ ˜ ˜ ˜ ˜ ˜ ˜ ˜ Program 2.4 can be modified to obtain the following solution: x1 = 3 and x2 = 4. Exercises 2.1 Determine the root of the equation Z Z Z which is close to 2.5. (Ans: 2.5034) 2.2 Air at 25°C and 1 atm flows through a 4 mm diameter tube with an average velocity of 25 m/s. The roughness is e = 0.0015 mm. The friction factor is given by F NQI 4G H H § · ¨ ¸¨ ¸ © ¹ Determine the pressure drop in a 1 m section of the tube using the relation S ' H.8 2 The density of air at 25°C and 1 atm is 1.23 kg/m3 and the viscosity is 1.79 ´ 10–5 kg/m-s. (Ans: f = 0.03467, DP = 3.33 kPa) 2.3 Solid particles having a diameter of 0.05 mm, shape factor fs = 0.88, and density of 1000 kg/m3 are to be fluidized using air at 2.0 atm and 25°C. The voidage at minimum fluidization is 0.39. The viscosity of air under these conditions is 1.845 ´ 10-5 kg/m-s. The molecular weight of air is 28.97. (Ans: 0.000611 m/s)
  • 99. 30 Introduction to Numerical Methods in Chemical Engineering 2.4 Solve Exercise 2.3 for solid particles having a diameter of 0.25 mm. The voidage at minimum fluidization is 0.48. (Ans: 0.0327 m/s) 2.5 Oil droplets of diameter 0.2 mm are to be settled from air at 25°C and 1 atm. The density of oil is 900 kg/m3 . Calculate the terminal settling velocity of the particles. Viscosity of air under these conditions is 1.85 ´ 10–5 kg/m-s. CD is given by
  • 100. 4G 4G R R % (Ans: 0.6462 m/s) 2.6 Solve Exercise 2.5 for oil droplets of diameter 0.02 mm. (Ans: 0.0105 m/s)
  • 101. 31 Chapter 3 Chemical Engineering Thermodynamics The calculation of molar volume using the van der Waals, Redlich–Kwong, and Peng– Robinson cubic equations of state at the given temperature and pressure is discussed first in this chapter. After this, bubble point, dew point, and flash calculations using Raoult’s and modified Raoult’s law are discussed. The determination of vapour pressure at the given temperature for a pure substance following a cubic equation of state is thereafter discussed. The determination of system pressure and vapour phase composition at the given temperature and liquid phase composition is discussed using the gamma–phi
  • 102. G HK K K K K [ 2 Z H and phi–phi
  • 103. G G8 . K K K K[ 2 Z 2 approaches. The solution of two simultaneous chemical reactions in equilibrium in the homogeneous phase and the calculation of adiabatic flame temperature are also discussed in this chapter. 3.1 Solution of Cubic Equations of State The molar volume of both the saturated vapour and saturated liquid can be calculated using cubic equations of state. The cubic equations of state can have three real roots or one real root and two complex roots. When there is only one real root, then only one phase exists—liquid or vapour—and when three real roots exist, then there are two phases. The smallest root is the molar volume of saturated liquid and the largest root is the molar volume of saturated vapour. The intermediate root is of the no physical significance. To determine the molar volume of the liquid phase, the starting value taken is V = b, and to determine the molar volume of the vapour phase, the starting value taken is 46 8 2 . The van der Waals equation of state is 46 C 2 8 D 8 (3.1) The cubic form of the van der Waals cubic equation of state is given by 46 C CD 8 D 8 8 2 2 2 § · ¨ ¸ © ¹ (3.2) where E E 4 6 C 2 and E E 46 D 2
  • 104. 32 Introduction to Numerical Methods in Chemical Engineering Let us define the function as 46 C CD H 8 D 8 8 2 2 2 § · ¨ ¸ © ¹ . At the given temperature and pressure and given critical properties of the substance, the only unknown in this equation is the molar volume V. The derivative of the function f with respect to the molar volume is given by 46 C H 8 D 8 2 2 § · c ¨ ¸ © ¹ (3.3) A value of molar volume is assumed. At the assumed molar volume the value of the function f and its derivative f¢ are determined and the new molar volume is determined using Newton’s method [see Eq. (2.1)] P P H 8 8 H c (2.1) Thereafter, the new molar volume becomes the old molar volume, and f and ’f are determined again at this molar volume. The procedure is repeated till there is a very meagre change between the new and old molar volumes, that is, P P 8 8 . The Redlich-Kwong equation of state is
  • 105. 46 C 2 8 D 6 8 8 D (3.4) The cubic form of the Redlich-Kwong cubic equation of state is given by 46 D46 C CD 8 8 D 8 2 2 62 62 § · ¨ ¸ © ¹ (3.5) where E E 4 6 C 2 and E E 46 D 2 . Let us define the function as 46 D46 C CD H 8 8 D 8 2 2 62 62 § · ¨ ¸ © ¹ . At the given temperature and pressure and given the critical properties of the substance, the only unknown in this equation is the molar volume, V. The derivative of the function f with respect to the molar volume is given by 46 D46 C H 8 8 D 2 2 62 È Ø „ É ÙÊ Ú (3.6) The Peng–Robinson equation of state is 46 C 2 8 D 8 D8 D (3.7) The cubic form of the Peng–Robinson cubic equation of state is given by 46 46D C 46 CD 8 D 8 D 8 D D 2 2 2 2 2 § · § · ¨ ¸ ¨ ¸ © ¹ © ¹ (3.8)
  • 107. B B X X E E E E E 46 C 2 6 O 6 O 46 D 2 § · ¨ ¸¨ ¸ © ¹ Let us define the function as 46 46D C 46 CD H 8 D 8 D 8 D D 2 2 2 2 2 § · § · ¨ ¸ ¨ ¸ © ¹ © ¹ At the given temperature and pressure and given critical properties of the substance the only unknown in this equation is the molar volume V. The derivative of the function f with respect to the molar volume is given by 46 46D C H 8 D 8 D 2 2 2 § · § · c ¨ ¸ ¨ ¸ © ¹ © ¹ (3.9) EXAMPLE 3.1 Calculate the molar volume of saturated liquid water and saturated water vapor at 100°C and 101.325 kPa using van der Waals, Redlich–Kwong and Peng–Robinson cubic equations of state. For water: TC = 647.1 K, PC = 220.55 bar, and w = 0.345. Solution Program 3.1 for calculating the molar volume at the given temperature and pressure using various cubic equations of state is given in the Appendix. The result obtained from the program is given below. Saturated liquid volume using Peng–Robinson equation of state = 2.25 ´ 10–5 m3 /mol Saturated vapour volume using Peng–Robinson equation of state = 0.030352 m3 /mol Saturated liquid volume using Redlich–Kwong equation of state = 2.64 ´ 10–5 m3 /mol Saturated vapour volume using Redlich–Kwong equation of state = 0.030400 m3 /mol Saturated liquid volume using van der Waals equation of state = 3.90 ´ 10–5 m3 /mol Saturated vapour volume using van der Waals equation of state = 0.030469 m3 /mol. 3.2 Bubble Point and Dew Point Temperature Calculations Using Raoult's Law 3.2.1 Bubble Point Temperature Calculation When the liquid phase composition is given, the governing equation is UCV UCV 2 Z 2 Z 2 . In this problem, along with the liquid phase composition the system pressure is given and the bubble point temperature and the vapour composition have to be determined. Newton’s method
  • 108. 34 Introduction to Numerical Methods in Chemical Engineering is used to determine the temperature which satisfies the equation UCV UCV 2 Z 2 Z 2 . Let us formulate a function f. UCV UCV H 2 Z 2 Z 2 (3.10) Using Antoine equation UCV NP $ 2 # 6 % (3.11) we get GZR GZR $ $ H 2 Z # Z # 6 % 6 % § · § · ¨ ¸ ¨ ¸ © ¹ © ¹ (3.12) In the above equation the Antoine parameters, system pressure and liquid composition are given. The only unknown is the temperature. The derivative of the function f with respect to temperature is given by
  • 110. UCV UCV Z 2 $ Z 2 $ H 6 % 6 % c (3.13) A value of temperature is assumed. At the assumed temperature the value of function f and its derivative f ¢ are determined and the new temperature is determined using [see Eq. (2.1)] P P H 6 6 H c (2.1) Thereafter the new temperature becomes the old temperature and again at this temperature, f and f ¢ are determined. The procedure is repeated till there is a very meagre change between the new and old temperatures, that is, P P 6 6 . This equation can also be written as P P P 6 6 6 . The assumed temperature is calculated from the relation UCVP K K6 Z 6¦ . The saturation temperatures UCV 6 and UCV 6 are calculated for the given pressure using the Antoine equation UCV NP $ 6 % # 2 (3.14) Once the temperature that satisfies the equation UCV UCV 2 Z 2 Z 2 is determined, the vapour phase composition can be determined using UCV Z 2 [ 2 and UCV Z 2 [ 2 . 3.2.2 Dew Point Temperature Calculation When the vapour phase composition is given, use is made of UCV UCV [ [ 2 2 2 . In this problem system pressure is given along with vapour phase composition and dew point temperature and liquid phase composition have to be determined. Newton’s method is used to determine the temperature which satisfies the equation UCV UCV [ [ 2 2 2 . Let us formulate a function f .
  • 111. Chemical Engineering Thermodynamics 35 UCV UCV [ [ H 2 2 2 (3.15) Using the Antoine equation UCV NP $ 2 # 6 % , we get GZR GZR $ $ H [ # [ # 2 6 % 6 % § · § · ¨ ¸ ¨ ¸ © ¹ © ¹ (3.16) Here in this equation the Antoine parameters, system pressure and vapour composition are given. The only unknown is the temperature. The derivative of the function f with respect to temperature is given by
  • 113. UCV UCV [ $ [ $ H 2 6 % 2 6 % c (3.17) A value of temperature is assumed. At the assumed temperature the value of the function f and its derivative H c are determined and the new temperature is determined using P P H 6 6 H c Thereafter, the new temperature becomes the old temperature and f and H c are determined again at this temperature. The procedure is repeated till there is a very meagre change between the new and old temperatures, that is, P P 6 6 . This equation can also be written as P P P 6 6 6 . The assumed temperature is calculated from the relation UCVP K K 6 [ 6¦ . Once the temperature that satisfies the equation UCV UCV [ [ 2 2 2 is determined, the liquid phase composition can be determined using UCV [ 2 Z 2 and UCV [ 2 Z 2 . EXAMPLE 3.2 Calculate the bubble point and dew point temperatures for the acetone (1) – water (2) system at 101.325 kPa for feed composition z1 = 0.5. Assume the system to follow Raoult’s law. Solution Program 3.2 for calculating the bubble and dew point temperatures for a system following Raoult’s law is given in the Appendix. The result obtained from the program is bubble point temperature = 71.81°C, dew point temperature = 87.08°C. 3.3 Flash Calculations Using Raoult's Law The aim here is to calculate the compositions of the vapour and liquid phases at the given temperature and pressure under flash conditions, assuming Raoult’s law to be true. For a mixture at the given pressure, if the temperature lies between the bubble point and dew point
  • 114. 36 Introduction to Numerical Methods in Chemical Engineering temperatures or at the given temperature, if the pressure lies between the dew point and bubble point pressure, both liquid and vapour exist. In this section we shall determine the equilibrium liquid and vapour phase compositions if the temperature, system pressure and feed composition are given. The overall composition is denoted by zi and L and V denote the amount of moles in the liquid and vapour phases respectively. Let the initial total number of moles before flashing be 1. The distribution coefficient (Ki) for a species is defined as its composition in the vapour phase divided by its composition in the liquid phase. We can write for a particular species that K K K [ - Z (3.18) For a system following Raoult’s law, UCV K K 2 - 2 ; therefore, if the temperature and the pressure of the system are given, then the K values of all the components can be calculated. The composition of the vapour in terms of Ki and feed composition is given by K K K K - [ 8 8- (3.19) and the composition of the liquid phase is given by K K K Z 8 8- (3.20) Finally we should have K K K K - [ 8 8- ¦ ¦ (3.21) where the summation is over all the components, and also K K K Z 8 8- ¦ ¦ 3.22) Therefore let us define a function
  • 115. K K K K K - H [ Z 8 8- ¦ ¦ ¦ (3.23) The function has to be formulated in such a way that its required value is zero. In this equation the only unknown is V, which is the number of moles in the vapour phase per unit mol fed to the system. The derivative of the function with respect to V is given by
  • 117. K K K - H 8 8- c ¦ (3.24) A value of V is assumed. At the assumed V the value of the function f and its derivative f ¢ are determined and the new V is determined using P P H 8 8 H c
  • 118. Chemical Engineering Thermodynamics 37 Thereafter, the new V becomes the old V and again at this V the function f and its derivative f ¢ are determined. The procedure is repeated till there is a very meagre change between the new and old values of V, that is, P P 8 8 . Once V is determined, the vapour and liquid phase composition can be determined. EXAMPLE 3.3 Calculate the compositions of the liquid and vapour phases for the acetone (1)–acetonitrile (2)–nitromethane (3) system. The feed composition is z1 = 0.3, z2 = 0.3 and z3 = 0.4. At the given temperature, UCV 2 195.75 kPa, UCV 2 97.84 kPa, and UCV 2 50.32 kPa. The pressure of the system is 100 kPa. Assume the system to follow Raoult’s law. Solution Program 3.3 for calculating the composition of the liquid and vapour phases under flash conditions for a system following Raoult’s law is given in the Appendix. The result obtained from the program is given below: x1 = 0.25057, y1 = 0.490491, x2 = 0.301341, y2 = 0.294832, x3 = 0.44561, y3 = 0.224231. The number of moles in vapour phase is 0.206026. 3.4 Bubble Point and Dew Point Temperature Calculations Using Modified Raoult's Law The modified Raoult’s law is given by UCV [ 2 Z 2H (3.25) UCV [ 2 Z 2H (3.26) The activity coefficients can be determined using various models. In the present case the Wilson model is used, because for a given system the activity coefficients can be determined as a function of the temperature and the liquid composition. The Wilson parameters are given by GZR 8 C 8 46 È Ø / É ÙÊ Ú (3.27) GZR 8 C 8 46 È Ø / É ÙÊ Ú (3.28) The activity coefficients are given by NP NP Z Z Z Z Z Z Z H Ë Û/ / / Ì Ü / /Í Ý (3.29) NP NP Z Z Z Z Z Z Z H Ë Û/ / / Ì Ü / /Í Ý (3.30) Calculation of bubble point pressure (i) Enter the temperature and the liquid composition.
  • 119. 38 Introduction to Numerical Methods in Chemical Engineering (ii) Calculate the vapour pressure of the components at the given temperature. (iii) Calculate the activity coefficients at the given temperature and liquid composition. (iv) Calculate the bubble point pressure using the relation UCV UCV 2 Z 2 Z 2H H Calculation of bubble point temperature (i) Enter the pressure and the liquid composition (ii) At the given pressure, calculate the saturation temperature of the components and the assumed temperature using UCVP K K 6 Z 66 . (iii) At the assumed temperature, calculate the vapour pressure of the components and the activity coefficients. (iv) Update the vapour pressure of Component 1 using the relation UCV UCV UCV 2 2 2 Z Z 2 H H (v) From the updated value of UCV 2 , calculate the temperature using UCV NP $ 6 % # 2 (vi) Go to Step (iii) and repeat the procedure till convergence in temperature is obtained. Calculation of dew point pressure (i) Enter the temperature and the vapour composition. (ii) Calculate the vapour pressure of the components at the given temperature. (iii) Initially assume the activity coefficients to be one and calculate the system pressure using UCV UCV 2 [ [ 2 2H H (iv) Calculate the liquid composition using UCV [ 2 Z 2H and UCV [ 2 Z 2H . (v) Update the liquid composition using 21 1 1 xx x x and 12 1 xx . (vi) At the liquid composition, calculate the activity coefficients. (vii) Go to Step (iv) and repeat the procedure till convergence in activity coefficients is obtained. (viii) Calculate the system pressure using
  • 120. Chemical Engineering Thermodynamics 39 UCV UCV 2 [ [ 2 2H H (ix) Go to Step (iv) and repeat the procedure till convergence in the pressure is obtained. Calculation of dew point temperature (i) Enter the pressure and the vapour composition. (ii) At the given pressure, calculate the saturation temperature of the components and the assumed temperature using UCVP K K 6 [ 66 . Initially take g1 = g2 = 1. (iii) At the assumed temperature, calculate the vapour pressure of the components. (iv) Calculate the liquid composition using UCV [ 2 Z 2H and UCV [ 2 Z 2H . (v) Update the liquid composition using Z Z Z Z and x2 = 1 – x1. (vi) At the liquid composition, calculate the activity coefficients. (vii) Go to Step (iv) and repeat the procedure till convergence in activity coefficients is obtained. (viii) Update the vapour pressure of Component 1 using the relation UCV UCV UCV [ [ 2 2 2 2H H È Ø É Ù Ê Ú (ix) From the updated value of UCV 2 , calculate the temperature using UCV NP $ 6 % # 2 (x) Go to Step (iii) and repeat the procedure till convergence in temperature is obtained: EXAMPLE 3.4 Consider a binary vapour–liquid equilibrium system. The Antoine equations of the components are given by UCV NP 2 6 UCV NP 2 6 where the temperature is in °C and the vapour pressure in kPa. The parameters in the Wilson equation are: a12 = 437.98 cal/mol and a21 = 1238 cal/mol. The molar volume of the components is V1 = 76.92 cm3 /mol and V2 = 18.07 cm3 /mol. Assume the system to follow the modified Raoult’s law. (i) Calculate the bubble point pressure at 100°C and x1 = 0.5. (ii) Calculate the bubble point temperature at 101.325 kPa and x1 = 0.5.
  • 121. 40 Introduction to Numerical Methods in Chemical Engineering (iii) Calculate the the dew point pressure at 100°C and y1 = 0.5. (iv) Calculate the dew point temperature at 101.325 kPa and y1 = 0.5. Solution Program 3.4 for the bubble point and dew point calculations for a system following the modified Raoult’s law is given in the Appendix. The result obtained from the program is given below: (i) 204.264 kPa, (ii) 80.93°C, (iii) 184.10 kPa, and (iv) 83.82°C. 3.5 Flash Calculations Using Modified Raoult's Law In flash the vapour and liquid phases coexist at the given temperature and pressure. The feed composition is given and the compositions of the liquid and vapour phases are to be determined using the modified Raoult’s law. For the given temperature and feed composition, first the bubble point and dew point pressures are determined. Then a pressure is chosen between the bubble point and dew point pressures. (i) Enter the temperature. (ii) At the given temperature calculate the vapour pressure of components. (iii) Calculate the activity coefficients by assuming the total feed as liquid. (iv) Calculate the bubble point pressure using the relation UCV UCV 2 Z 2 Z 2H H (v) Record the bubble point pressure (Pbubble) and the activity coefficients (g 1b and g 2b). (vi) For the calculation of the dew point pressure (total feed as vapour), first assume the activity coefficients to be1. (vii) Calculate the pressure using UCV UCV 2 [ [ 2 2H H . (viii) Calculate the liquid phase compositions using UCV [ 2 Z 2H and UCV [ 2 Z 2H . (ix) Update the liquid composition using Z Z Z Z and x2 = 1 – x1. (x) At the liquid composition, calculate the activity coefficients. (xi) Go to step (viii) and repeat the procedure till convergence in activity coefficients is obtained. (xii) Calculate the system pressure using UCV UCV 2 [ [ 2 2H H . (xiii) Go to step (viii) and repeat the procedure till convergence in pressure is obtained. (xiv) Store the dew point pressure (Pdew) and the activity coefficients (g 1d and g 2d).
  • 122. Chemical Engineering Thermodynamics 41 (xv) Enter the pressure between the bubble point and dew point pressures. (xvi) The assumed number moles in vapour phase is calculated using DWDDNG DWDDNG FGY 2 2 8 2 2 . (xvii) The assumed value of g 1 is calculated using
  • 125. FGY DWDDNG FGY D F F 2 2 2 2 H H H H . (xviii) The assumed value of g2 is calculated using
  • 128. FGY DWDDNG FGY D F F 2 2 2 2 H H H H . (xix) Calculate UCV 2 - 2 H and UCV 2 - 2 H . (xx) Calculate - [ 8 8- and - [ 8 8- . (xxi) Calculate [ Z - and [ Z - . (xxii) Define a function H [ Z [ Z . (xxiii)
  • 130. K K K - H 8 8- c ¦ . (xxiv) P P H 8 8 H c . (xxv) Go to Step (xx) and repeat the procedure till convergence in V is obtained. (xxvi) Calculate g1 and g2. (xxvii) Go to Step (xix) and repeat the procedure till convergence in activity coefficients is obtained. EXAMPLE 3.5 Calculate the composition of the liquid and vapour phases for the system acetone (1)–water (2) at 100o C and 200 kPa. The feed composition is z1 = 0.3. The Antoine equations of the components are given by UCV NP 2 6 UCV NP 2 6 where the temperature is in °C and the vapour pressure in kPa. The parameters in the Wilson equation are: a12 = 292.66 cal/mol and a21 = 1445.26 cal/mol. The molar volume of the components is V1 = 74.05 cm3 /mol and V2 = 18.07 cm3 /mol. Assume the system to follow the modified Raoult’s law.
  • 131. 42 Introduction to Numerical Methods in Chemical Engineering Solution Program 3.5 for calculating the composition of the liquid and vapour phases under flash conditions for a system following the modified Raoult’s law is given in the Appendix. The result obtained from the program is: bubble point pressure = 310.47 kPa, dew point pressure = 142.80 kPa. The system pressure chosen is 200 kPa and after convergence the number of moles in the vapour phase is 0.546235. x1 = 0.045019 and y1 = 0.511817. 3.6 Vapour Pressure Using Cubic Equation of State The cubic equations of state are applicable for both the liquid and vapour phases. At a given temperature, a cubic equation of state can be used to determine the vapour pressure of a pure substance. A pressure is assumed and the fugacities in the liquid and vapour phases are determined. If at the assumed pressure the fugacities are not identical, then another pressure is assumed and the pressure at which the fugacities are the same (f L = f V ) is the vapour pressure. The algorithm for calculation of vapour pressure is given below. (i) Assume a pressure. (ii) At the given temperature and the assumed pressure, calculate VV and VL as described in Program 3.1. (iii) Calculate f L and f V using cubic equation of state. (iv) If . 8 8 H H H , stop. (v) Calculate the new pressure using, PGY QNF . 8 H 2 2 H , and go back to Step (ii) and repeat the procedure till Condition (iv) is satisfied. For the Peng–Robinson cubic equation of state, the fugacity of a pure substance is given by
  • 133. NP NP NP 8 DH 2D C 2 46 D46 8 D § · ¨ ¸ © ¹ (3.31) The fugacity of the liquid phase is given by
  • 135. NP NP NP .. . . . 8 DH 2D C 2 46 D46 8 D § · ¨ ¸ © ¹ (3.31a) where . . 28 46
  • 136. Chemical Engineering Thermodynamics 43 and the fugacity of the vapour phase is given by
  • 138. NP NP NP 88 8 8 8 8 DH 2D C 2 46 D46 8 D § · ¨ ¸ © ¹ (3.31b) where 8 8 28 46 EXAMPLE 3.6 Calculate the vapour pressure of water at 100°C using the Peng–Robinson cubic equation of state. For water: TC = 647.1 K, PC = 220.55 bar, and w = 0.345. Solution Program 3.6 for calculating the vapour pressure using the cubic equation of state is given in the Appendix. The vapour pressure of water at 100°C as obtained from the program is 96071.375 Pa. 3.7 P–x–y Diagram Using Gamma–Phi Approach In the Gamma–Phi approach, the vapour–liquid equilibrium is described using the equation 8 [ 2 Z HG H (3.32) 8 [ 2 Z HG H (3.33) At the given temperature and liquid phase composition, the equilibrium pressure and the vapour composition are determined. Then again at the same temperature and at a different liquid phase composition, the equilibrium pressure and vapour composition are determined. This is used to generate the P–x–y diagram at the given temperature. The algorithm is given below. (i) Read T, x1, Tc1, Pc1, Tc2, Pc2, w1, w2, ZC1, ZC2, UCV 2 , UCV 2 . (ii) x2 = 1 – x1. (iii) At the given temperature and liquid phase composition, calculate the activity coefficients g1 and g2. (iv) At the given temperature, calculate B11, B22, B12 and d12. (v) Calculate the initial value of the total pressure using UCV UCV 2 Z 2 Z 2H H (only to start the solution do we assume the modified Raoult’s law to be true) and the composition in vapour phase using the relation UCV Z 2 [ 2 H and UCV Z 2 [ 2 H . (vi) At the total pressure, calculate the fugacity of the pure liquid species 1(f1) and 2(f2) at the given temperature and calculated pressure, using the relation
  • 139. UCV UCV UCV GZR GZR . K K KK K K K 8 2 2$ 2 H 2 46 46 ª º§ · « »¨ ¸¨ ¸ « »© ¹ ¬ ¼
  • 140. 44 Introduction to Numerical Methods in Chemical Engineering (vii) Calculate the fugacity coefficient of the species 1( G ) and 2( G ) in the vapour phase. (viii) Calculate H - 2 H G and H - 2 H G . (ix) Calculate 5 - Z - Zu u . (x) Calculate - Z [ 5 u and - Z [ 5 u . Go to Step (vii) and repeat the procedure till dS e. (This is because the composition of the vapour phase has changed and therefore the fugacity coefficients of the species in the vapour phase get changed.) (xi) Calculate the new pressure using Z H Z H 2 H H G G and calculate the new compositions in the vapour phase using Z H [ 2 H G and Z H [ 2 H G . Go to Step (vi) and repeat the procedure till dP e. EXAMPLE 3.7 Consider the methanol (1) – water (2) system in vapour–liquid equilibrium. The temperature of the system is 100°C and the liquid phase composition is x1 = 0.958. Determine the system pressure and the vapour phase composition. Use the Gamma–Phi approach. The Antoine equations of the components are given by UCV NP 2 6 UCV NP 2 6 where temperature is in °C and vapour pressure in kPa. The parameters in the Wilson equation are: a12 = 107.38 cal/mol and a21 = 469.55 cal/mol. The molar volume of the components is V1 = 40.73 cm3 /mol and V2 = 18.07 cm3 /mol. Tc1 = 512.6 K, Pc1 = 80.97 bar, w1 = 0.564, Zc1 = 0.224, Tc2 = 647.1 K, Pc2 = 220.55 bar, w2 = 0.345, Zc2 = 0.229. Solution Program 3.7 for P–x–y calculations using the Gamma–Phi approach is given in the Appendix. The result obtained from the program is given below: pressure = 344930.59 Pa and y1 = 0.980694. 3.8 P-x-y Diagram Using Cubic Equation of State For the Peng–Robinson equation of state the fugacity coefficient of component 1 in the liquid phase is given by
  • 141. NP NP . . . . . D 2D 46D G § · ¨ ¸¨ ¸ © ¹
  • 145. NP . . . . . .. . 2D Z C Z C DC 46 C D 2DD 46 46 ª º « » ¬ ¼ (3.34) and the fugacity coefficient of component 1 in the vapour phase is given by
  • 146. NP NP 8 8 8 8 8 D 2D 46D G § · ¨ ¸¨ ¸ © ¹
  • 149. NP 8 8 8 8 8 88 8 2D [ C [ C DC 46 C D 2DD 46 46 ª º « » ¬ ¼ (3.35) The fugacity coefficient of component 2 in the liquid phase is given by
  • 150. NP NP . . . . . D 2D 46D G § · ¨ ¸¨ ¸ © ¹
  • 153. NP . . . . . .. . 2D Z C Z C DC 46 C D 2DD 46 46 ª º « » ¬ ¼ (3.36) and the fugacity coefficient of component 2 in the vapour phase is given by
  • 154. NP NP 8 8 8 8 8 D 2D 46D G § · ¨ ¸¨ ¸ © ¹
  • 157. NP 8 8 8 8 8 88 8 2D [ C [ C DC 46 C D 2DD 46 46 ª º « » ¬ ¼ (3.37) where . C Z C Z C Z Z C (3.38) . D Z D Z D (3.39) 8 C [ C [ C [ [ C (3.40) 8 D [ D [ D (3.41) . . 28 46 (3.42)
  • 158. 46 Introduction to Numerical Methods in Chemical Engineering 8 8 28 46 (3.43) For a binary VLE mixture the phase equilibrium equations are 8 . [ 2 Z 2G G (3.44) 8 . [ 2 Z 2G G (3.45) and variables are T, P, x1, and y1. Thus, if any two variables (T or P, x1 or y1) are specified the other two can be determined. Since the compositions of the liquid and vapour phases are different, a and b for each phase are different. Calculate a and b for the liquid phase and then ZL and VL (the smallest root), and a and b for the vapour phase and then ZV and VV (the largest root). The molar volume is calculated by solving the cubic form of the Peng–Robinson equation of state. The algorithm for the calculation of the bubble point pressure and the vapour phase composition at the given temperature and the liquid phase composition for a binary mixture using the cubic equations of state is given below. (i) Read T, x1, Tc1, Pc1, Tc2, Pc2, w1, w2 (ii) Calculate x2 = 1 – x1 (iii) Calculate a11, a22, 221112 aaa , b1, b2 (iv) Calculate for liquid phase: . C Z C Z C Z Z C and . D Z D Z D . (v) Assume some pressure (P) and composition in the vapour phase y1 (assume y1 greater than x1 if component 1 is the more volatile component). (vi) Using Newton’s technique, calculate VL using aL , bL , x1, x2. Take Vold = bL because the liquid phase molar volume is to be calculated. From VL , calculate . . 28 46 (compressibility factor in the liquid phase). (vii) Calculate the fugacity coefficient of the components . G and . G in the liquid mixture. (viii) Calculate for the vapour phase: 8 C [ C [ C [ [ C and 8 D [ D [ D . (ix) Using Newton’s technique, calculate VV using aV , bV , y1, y2. Take QNF 46 8 2 because the vapour phase molar volume is to be calculated. From VV , calculate 8 8 28 46 (compressibility factor in the vapour phase). (x) Calculate the fugacity coefficient of the components 8 G and 8 G in the vapour phase mixture. (xi) Calculate . 8- G G and . 8- G G . (xii) Calculate 5WO - Z - Zu u
  • 159. Chemical Engineering Thermodynamics 47 (xiii) Calculate - Z [ 5WO u and - Z [ 5WO u . Go to Step (viii) and repeat the procedure till 5WOE F . This is because the composition of the vapour phase has changed; therefore aV and bV get changed. (xiv) Calculate the new pressure using PGY QNF2 2 5WOu . Go to Step (vi) and repeat the procedure till 2E F . EXAMPLE 3.8 Consider the CO2 (1) – n-pentane (2) system in vapour–liquid equilibrium. The temperature of the system is 377.65 K and the liquid phase composition is x1 = 0.5. Determine the system pressure and the vapour phase composition using the Peng–Robinson cubic equation of state. Tc1 = 304.2 K, Pc1 = 73.83 bar, w1 = 0.224, Tc2 = 469.7 K, Pc2 = 33.70 bar, and w2 = 0.252. Solution Program 3.8 for P–x–y calculations using the Peng–Robinson cubic equation of state is given in the Appendix. The result obtained from the program is given below: Pressure = 6524432 Pa and y1 = 0.81127. 3.9 Chemical Reaction Equilibrium—Two Simultaneous Reactions The solution of two simultaneous nonlinear algebraic equations is described in Section 2.5. The application in chemical reaction equilibrium in the homogeneous phase is described in the example below. EXAMPLE 3.9 In the production of synthesis gas the following two independent reactions take place CH4 + H2O ® CO + 3H2 CO + H2O ® CO2 + H2 Starting with 5 moles of steam and 1 mole of methane, calculate the equilibrium composition of the resulting mixture at 600°C and 1 atm. At this temperature the equilibrium constants for the first and second reaction are 0.574 and 2.21 respectively. Assume the gas mixture to follow ideal gas behaviour. Solution Let X1 be the reaction coordinate for the first reaction and X2 for the second. The number of moles of components at equilibrium is as follows: CH4: 1 – X1 H2O: 5 – X1 – X2 CO: X1 – X2 H2: 3X1 + X2 CO2: X2 Total: 6 + 2X1
  • 160. 48 Introduction to Numerical Methods in Chemical Engineering Since the pressure is 1 atm, therefore K = KPKy = Ky.
  • 162. : : : : : : : :
  • 163. : : : : : : : The two nonlinear algebraic equations are
  • 168. : : : : H : : : :
  • 171. : : : H : : : : and their derivatives are
  • 176. : : : :H : : : : : ˜ ˜
  • 182. : : : : : : : : : : : : :
  • 193. : : : : : :H : : : : : : : : : : : : : ˜ ˜
  • 199. : : : :H : : : : : : : : : : ˜ ˜
  • 205. : : : :H : : : : : : : : : : : ˜ ˜ The algorithm is described in Section 2.5. Program 3.9 for solution of two chemical reaction equilibrium equations is given in the Appendix. The solution is X1 = 0.912 and X2 = 0.633. Thus at equilibrium: moles of CH4 = 0.09 mol, moles of H2O = 3.465 mol, moles of CO = 0.285 mol, moles of H2 = 3.355 mol, moles of CO2 = 0.625 mol, and total number of moles = 7.82 mol.
  • 206. Chemical Engineering Thermodynamics 49 3.10 Adiabatic Flame Temperature First the inlet species are laised from inlet temperature (T1) to adiabatic flame temperature (T) and then the reaction at temperature T is carried out. The total enthalpy change is zero as there is no heat and work exchange with the surroundings. The algorithm for the calculation of adiabatic flame temperature is described below. (i) Read the various constants of molar heat capacity at constant pressure for various species. (ii) Read the various stoichiometric coefficients (ni) and moles of each species (ni) entering. (iii) Read the standard enthalpy of formation for various species and calculate the standard enthalpy change of reaction. Read the standard temperature (T0) and inlet temperature (T1). (iv) Calculate sa, sb, sc, sd using the relations UC P C P C P C P C UD P D P D P D P D UE P E P E P E P E UF P F P F P F P F (v) Calculate the heat required to raise the inlet species from the inlet temperature (T1) to the adiabatic flame temperature (T) using
  • 210. UD UE UF UC 6 6 6 6 6 6 6 6 Note that this formula is valid for the molar heat capacity given by the equation 2% C D6 E6 F6 (vi) Calculate C C C C CO O O O' D D D D DO O O O' E E E E EO O O O' F F F F FO O O O' (vii) Calculate the standard enthalpy change of reaction at the adiabatic flame temperature (T) with respect to the standard enthalpy change of reaction at temperature (T0)
  • 214. 6 D E F * C 6 6 6 6 6 6 6 6 ' ' ' ' ' (viii) Assume an adiabatic flame temperature and at that temperature calculate the value of the function
  • 218. UD UE UF H UC 6 6 6 6 6 6 6 6 +
  • 222. 6 D E F * C 6 6 6 6 6 6 6 6 ' ' ' ' ' and its derivative H UC UD 6 UE 6 UF 6 C D 6 E 6 F 6' ' ' 'c u u u u u u (ix) Calculate new temperature using Newton’s formula P P H 6 6 H c , take this as the old temperature and go to Step (n) and repeat the procedure till there is no significant change in temperature (dT e).
  • 223. 50 Introduction to Numerical Methods in Chemical Engineering EXAMPLE 3.10 Calculate the adiabatic flame temperature of a gas initially at 25o C containing 1 mol C2H6 (1), 4 mol O2 (2), 10 mol CO2 (3) and 0 mol of H2O (4). The ethane is completely burned. The standard heat capacity is given by 2% C D6 E6 F6 , where T is in K and 2% in cal/mol-K. Species a b ´ 102 c ´ 105 d ´ 109 C2H6 1.648 4.124 –1.530 1.740 O2 6.085 0.3631 –0.1709 0.3133 CO2 5.316 1.4285 –0.8362 1.784 H2O(g) 7.700 0.04594 0.2521 –0.8587 The standard enthalpy of formation at 298.15 K is: Â7I H *' kcal/mol, ÂB Is H *' kcal/mol, % * H *' kcal/mol. Solution The reaction with stoichiometric amount of oxygen is % * 1 %1 * 1 o and the reaction with 4 mol of O2 and 10 mol CO2 is % * 1 %1 %1 * 1 1 o Program 3.10 for the calculation of adiabatic flame temperature (AFT) is given in the Appendix. The result obtained from the computer program is AFT = 2090.39 K. Exercises 3.1 Calculate the molar volume of saturated liquid water and saturated water vapour at 180°C and 1.0 MPa using the van der Waals, Redlich–Kwong and Peng–Robinson cubic equations of state. For water: TC = 647.1 K, PC = 220.55 bar, and w = 0.345. (Ans: VL using the Peng–Robinson equation of state = 2.47 ´ 10–5 m3 /mol, VV using the Peng–Robinson equation of state = 0.003570 m3 /mol, VL using the Redlich– Kwong equation of state = 2.95 ´ 10–5 m3 /mol, VV using the Redlich–Kwong equation of state = 0.003605 m3 /mol, VL using the van der Waals equation of state = 4.31 ´ 10–5 m3 /mol, VV using the van der Waals equation of state = 0.003647 m3 /mol) 3.2 Calculate the bubble point and dew point temperatures for the acetone (1)–water (2) system at 101.325 kPa for feed composition z1 = 0.9. Assume the system to follow Raoult’s law. (Ans: Bubble point temperature = 58.58°C, dew point temperature = 66.93°C) 3.3 Calculate the composition of the liquid and vapour phases for the acetone (1)– acetonitrile (2)–nitromethane (3)–system. The feed composition is z1 = 0.25, z2 = 0.5 and z3 = 0.25. At the given temperature: UCV 2 195.75 kPa, UCV 2 97.84 kPa, and UCV 2 50.32 kPa. The pressure of the system is 100 kPa. Assume the system to follow Raoult’s law. (Ans: x1 = 0.175384, y1 = 0.343313, x2 = 0.504845, y2 = 0.493941, x3 = 0.320819, y3 = 0.161436. The number of moles in the vapour phase is 0.444331.)
  • 224. Chemical Engineering Thermodynamics 51 3.4 Consider a binary vapour–liquid equilibrium system. The Antoine equations of the components are given by UCV NP 2 6 UCV NP 2 6 where the temperature is in °C and the vapour pressure in kPa. The parameters in the Wilson equation are: a12 = 437.98 cal/mol and a21 = 1238 cal/mol. The molar volumes of the components are V1 = 76.92 cm3 /mol and V2 = 18.07 cm3 /mol. Assume the system to follow the modified Raoult’s law. (i) Calculate the bubble point pressure at 100°C and x1 = 0.3. (ii) Calculate the bubble point temperature at 101.325 kPa and x1 = 0.3. (iii) Calculate the dew point pressure at 100°C and y1 = 0.3. (iv) Calculate the dew point temperature at 101.325 kPa and y1 = 0.3. [Ans: (i) 193.78 kPa, (ii) 82.18°C, (iii) 140.78 kPa, and (iv) 91.00°C] 3.5 Calculate the composition of the liquid and vapour phases for the acetone (1)– water (2) system at 100°C and 200 kPa. The feed composition is z1 = 0.5. The Antoine equations of the components are given by UCV NP 2 6 UCV NP 2 6 where the temperature is in °C and the vapour pressure in kPa. The parameters in the Wilson equation are: a12 = 292.66 cal/mol and a21 = 1445.26 cal/mol. The molar volume of the components is V1 = 74.05 cm3 /mol and V2 = 18.07 cm3 /mol. Assume the system to follow the modified Raoult’s law. [Ans: Bubble point pressure = 334.97 kPa, dew point pressure = 195.68 kPa, number of moles in vapour phase = 0.974685, x1 = 0.045018, y1 = 0.511817] 3.6 Calculate the vapour pressure of water at 120°C using the Peng–Robinson cubic equation of state. For water: TC = 647.1 K, PC = 220.55 bar, and w = 0.345. (Ans: 191689.125 Pa) 3.7 Consider the methanol (1) – water (2) system in vapour–liquid equilibrium. The temperature of the system is 100°C and the liquid phase composition is x1 = 0.5. Determine the system pressure and the vapour phase composition. Use the Gamma- Phi approach. The Antoine equations of the components are given by UCV NP 2 6
  • 225. 52 Introduction to Numerical Methods in Chemical Engineering UCV NP 2 6 where the temperature is in °C and the vapour pressure in kPa. The parameters in the Wilson equation are: a12 = 107.38 cal/mol and a21 = 469.55 cal/mol. The molar volumes of the components are V1 = 40.73 cm3 /mol and V2 = 18.07 cm3 /mol. TC1 = 512.6 K, PC1 = 80.97 bar, w1 = 0.564, ZC1 = 0.224, TC2 = 647.1 K, PC2 = 220.55 bar, w2 = 0.345, ZC2 = 0.229. (Ans: Pressure = 253786 Pa, 1y 0.757692) 3.8 Consider the CO2 (1) – n-pentane (2) system in vapour–liquid equilibrium. The temperature of the system is 377.65 K and the liquid phase composition is x1 = 0.35. Determine the system pressure and the vapour phase composition using the Peng– Robinson cubic equation of state. TC1 = 304.2 K, PC1 = 73.83 bar, w1 = 0.224, TC2 = 469.7 K, PC2 = 33.70 bar, w2 = 0.252. (Ans: Pressure = 4572206 Pa, 1y 0.782462) 3.9 Calculate the adiabatic flame temperature of a gas initially at 25°C containing 1 mol C2H6 (1), 5 mol O2 (2), 10 mol CO2 (3) and 0 mol of H2O (4). The ethane is completely burned. The standard heat capacity is given by C0 P = a + bT + cT2 + dT3 where T is in K and C0 P in cal/mol-K. Species a b ´ 102 c ´ 105 d ´ 109 C2H6 1.648 4.124 –1.530 1.740 O2 6.085 0.3631 –0.1709 0.3133 CO2 5.316 1.4285 –0.8362 1.784 H2O(g) 7.700 0.04594 0.2521 –0.8587 The standard enthalpy of formation at 298.15 K is: Â7I a H *' kcal/mol, ÂB Is H *' kcal/mol, and % * H *' kcal/mol. (Ans: AFT = 2024.45 K)
  • 226. 53 Chapter 4 Initial Value Problems Consider two simultaneous differential equations F[ FZ and F [ FZ . The analytical solution of the differential equations is y = A sin(x + a) and z = A cos(x + a). There are two constants of integration A and a. In general, a system of N first order equations has N constants of integration. If the values of the dependent variables y and z are specified for a value of x, then the problem of determining the values of y and z at some future x is called an initial value problem. Alternatively, the values of some of the dependent variables may be specified at a number of different values of x, then the problem is called a boundary value problem. The most common form is a two-point boundary value problem where the function values are given for two values of x. Boundary value problems are discussed in Chapters 5–10. The examples discussed here include the calculation of temperature profile in a double pipe heat exchanger, of a single stirred tank with coil heater and also of a series of stirred tanks with coil heater. The velocity profile of a solid particle in a pneumatic conveyor, and the calculation of the concentration profile in the batch, stirred and plug flow reactors is also discussed in this chapter. 4.1 Solution of Single Ordinary Differential Equation Consider an ordinary differential equation
  • 227. F[ H Z [ FZ (4.1) with the initial condition: at x = x0, y = y0. The ordinary differential equation has to be integrated to determine the value of y at some x. A step size, h, is chosen in the independent variable. At the initial condition both x and y are known and after a step size in independent variable, i.e. at x = x0 + h the value of y is computed. Then this becomes the starting point for the next value of independent variable, x = x0 + 2h at which the value of dependent variable is determined. This procedure is repeated till the value of x at which the y-value is to be determined is reached. For each problem there exists an optimum step size. The step size should not be high, otherwise the truncation errors will be high, and if the step size is very small, then round-off errors are high. At the optimum step size the total error (truncation error + round-off error) is the least, and thus the numerical results are accurate.
  • 228. 54 Introduction to Numerical Methods in Chemical Engineering In the numerical formulation of the problem some terms are left out; those errors are called truncation errors. When the step size is small, these errors are less. If the step size is very low, then the truncation errors are less but the round-off errors are high. Consider a step size of 10–6 m; then to go from 1 to 10 m, the number of iterations required is 107 , which is huge. Whenever the new concentration is computed, the number is not completely stored, it is stored up to some decimal places only, depending on the compiler used. So to avoid round- off errors the step size should not be very small and to avoid truncation errors it should not be very large. So there is an optimum step size and it varies with the problem. To determine the optimum step size, at a particular value of independent variable x the value of the dependent variable y is determined using various step sizes. When for two consecutive step sizes the value of y is the same, then the higher of the two is the optimum step size. In the Runge–Kutta fourth order method the following are computed:
  • 229. M J H Z [u (4.2) M J H Z J [ M § · u ¨ ¸ © ¹ (4.3) M J H Z J [ M § · u ¨ ¸ © ¹ (4.4)
  • 230. M J H Z J [ Mu (4.5)
  • 231. [ [ M M M M (4.6) From the initial condition (x0, y0) we have determined the value of y at x0 + h. Now again the above calculations are carried out to determine the value of y at x0 + 2h. But before carrying out the next calculation the following statements, due to which the value of y1 becomes y0 and x0 + h becomes x0, are executed: x0 = x0 + h (4.7) y0 = y1 (4.8) EXAMPLE 4.1 Integrate the ordinary differential equation F[ Z [ FZ using the Runge–Kutta fourth order method. The initial condition is: at x = 0, y = 0. Determine the value of y at x = 0.2. The analytical solution is given by y = ex – x – 1. Solution Let us take step size of h = Dx = 0.1. The function is F[ H Z [ FZ . To compute y at x = 0.1 the starting point is x0 = 0 and y0 = 0. The calculations are given below. f(0,0) = 0; therefore k1 = 0.1 ´ f(0,0) = 0; f(0.05,0) = 0.05; therefore k2 = 0.1 ´ 0.05 = 0.005; f(0.05,0.0025) = 0.0525; therefore k3 = 0.00525; f(0.1,0.00525) = 0.10525; therefore k4 = 0.010525.
  • 233. [ [ M M M M at x = 0.1 Now let us compute the value of y at x = 0.2. For this computation the starting point is x0 = 0.1 and y0 = 0.0051708. The calculations are given below. f(0.1, 0.0051708) = 0.1051708; therefore k1 = 0.01051708; f(0.15, 0.01042934) = 0.16042934; therefore k2 = 0.0160429; f(0.15, 0.01319225) = 0.16319225; therefore k3 = 0.016319225; f(0.2, 0.02149) = 0.22149; therefore k4 = 0.022149. Thus
  • 234. [ u u Thus the value of y (at x = 0.2) = 0.0214025. The analytical solution at x = 0.2 is y = e0.2 – 0.2 – 1 = 0.0214028, which is close to the numerical solution. EXAMPLE 4.2 Solve the following ordinary differential equation: x y dx dy 1 with the initial condition y(0) = 2. Determine y at x = 2.5 using the fourth-order Runge–Kutta method. Solution The initial condition is: at x = 0: y = 2. We have to determine y at x = 2.5. The result from Program 4.1 (given in the Appendix) at step size of 0.01 is: at x = 2.5, y = 0.57. 4.2 Double Pipe Heat Exchanger The schematic diagram of the inner pipe of the double pipe heat exchanger is shown in Fig. 4.1. The outer pipe contains steam at temperature TS and the fluid in the inner pipe is heated. Heat entering through whole circumference = U(2pRDz)(TS – T) Fig. 4.1 Schematic diagram of double pipe heat exchanger. TGH 2 O% 6 6 TGH 2 O% 6 6'
  • 235. 56 Introduction to Numerical Methods in Chemical Engineering Consider a differential section of the inner pipe. Through the circumference of the inner pipe heat enters from steam in the outer pipe. Under steady conditions (Input – Output = 0)
  • 238. TGH TGH 2 2 5O% 6 6 O% 6 6 7 6 6Q' ' Dividing by Dz, we get
  • 239. 2 5 6 6 O% 7 6 6 Q' ' § · ¨ ¸ © ¹ As Dz ® 0, we get
  • 240. 2 5 F6 O% 7 6 6 F Q (4.9) where T is the temperature of the fluid in the inner pipe and is a function of length, TS is the temperature of steam in the outer pipe and is constant, and O is the mass flow rate of fluid in inner pipe. The analysis of the double pipe heat exchanger is described in the example below. EXAMPLE 4.3 On one side of a double pipe heat exchanger is saturated steam and water is flowing in the inner tube. The temperature of entering water is 20°C and the velocity of water is 1 m/s. The inner diameter of the inner pipe is 2.4 cm. Under steady conditions, determine the temperature of water at the length of 5 and 10 m from the inlet. The total length of the heat exchanger is 10 m. Assume that the temperature does not change along the radius of the pipe. The density of water is 1000 kg/m3 and the specific heat capacity is 4184 J/kg- K. The overall heat transfer coefficient based on the inside area of the inner pipe is 200 W/ m2 -K and the temperature of saturated steam is 250°C. Solution The mass flow rate of water is O X#S Q § · u u ¨ ¸ © ¹ kg/s Eq. (4.9) becomes
  • 241. F6 6 F u u u u
  • 242. F6 6 F u The initial condition is: at z = 0, T = 20. The temperature is to be determined at z = 5 and z = 10. The differential equation is integrated using the Runge–Kutta fourth order method. Program 4.1 can be modified, and with step size of 0.01 m, we get at z = 5 m, T = 28.97°C and at z = 10 m, T = 37.60°C. Let us now check the answer. The exit temperature of water at z = 10 m is 37.60°C. The heat taken up by water is equal to UADTlmtd, and from the energy balance equation we get NOVF 27 . 6 O% 6 6Q '
  • 243. Initial Value Problems 57 where T1 is the temperature of the inlet water, T2 is the temperature of the exit water, and L = 10 m. The temperatures in the double pipe heat exchanger are shown in Fig. 4.2. Fig. 4.2 Diagram for Example 4.3. The log mean temperature difference is given by NOVF NP 6' § · ¨ ¸ © ¹ Substituting the values in the energy balance equation, we get NOVF 2O% 6 6 7 . 6Q Q' u u u u u W/m2 -K which is close to the given value. In this problem the overall heat transfer coefficient is given and temperature of water is determined. Usually in heat transfer laboratory experiments, the exit temperature of water is known and the overall heat transfer coefficient is determined. 4.3 Stirred Tank with Coil Heater The schematic diagram of a stirred tank with coil heater is shown in Fig. 4.3. Fig. 4.3 Schematic diagram of stirred tank with coil heater. 37.60°C Steam temperature Water temperature 20°C 250°C250°C M = Mass of fluid in tank T TS O O
  • 244. 58 Introduction to Numerical Methods in Chemical Engineering The energy balance equation is given by Accumulation = Input – Output. The input is due to energy input by the entering stream and the heat input from the steam, and the output is energy carried away by the exit stream. From the energy balance equation, we get
  • 245. 2 2 F6 /% O% 6 6 3 FV (4.10) where T1 is the temperature of the entering stream and T is the temperature of exit stream and is equal to temperature of water in the stirred tank. The heat transfer between the steam in the coil and the fluid is given by Q = UADTlmtd = UA(TS – T). The temperature throughout the coil is TS as the steam is saturated, and outside the whole coil, that is inside the tank uniform temperature, T exists as the vessel is stirred; therefore DTlmtd = TS – T. Note that though the temperature in the tank is uniform, it varies with time. EXAMPLE 4.4 Consider a stirred tank heater. It is a square tank 0.5 m on its sides and 2 m high and is filled with water at 20°C. Water is fed to the tank at a flow rate of 1L/s and exits out at the same flow rate from the top of the tank. The temperature of inlet water is 20°C. At time t = 0 s, water in the tank is heated by a coil containing steam whose overall heat transfer coefficient based on the outside area of the coil is 200 W/m2 -K. The outside area of the coil through which heat exchange takes place is 1 m2 . The temperature of the steam is 250°C. The specific heat capacity of water is 4184 J/kg-K. After how much time is the temperature of exit water 28°C? What is the maximum temperature that can be reached in the tank? Solution Volume of tank = 0.5 ´ 0.5 ´ 2 = 0.5 m3 . Since the density of water is 1000 kg/m3 , therefore the mass of water in the tank is 500 kg. Thus M = 500 kg, CP = 4184 J/kg-K, 3 = UA(TS – T) = 200(TS – T), and m = 1 kg/s, and Eq. (4.10) becomes
  • 247. F6 6 6 FV u u u u Simplifying, we get F6 6 FV The initial condition is: at t = 0, T = 20°C. We have to determine t at T = 28°C. Program 4.1 can be modified, and with step size of 0.1 we get T = 28°C at t = 700 s. The variation of temperature of the fluid in the tank with time is shown in Table 4.1. Table 4.1 Variation of fluid temperature in tank with time in Example 4.4 Time (s) Temperature (°C) 500 26.81 750 28.31 1000 29.19 3000 30.46 5000 30.48
  • 248. Initial Value Problems 59 The steady state temperature is obtained when in the differential equation F6 FV ; thus the steady state temperature is given by 0.064 – 0.0021 T = 0 or T = 30.48°C. The same is also obtained from the numerical solution. Note the temperature at 5000 s in Table 4.1. EXAMPLE 4.5 Consider a stirred vessel which initially contains 760 kg of solvent at 25°C. 12 kg/min of solvent flows into the stirred vessel at 25°C and exits out also at the same rate. At t = 0 the flow of steam is started in a coil in the stirred vessel. The heat supplied by steam to the solvent is given by 3 = UA(TS – T), where UA is the overall heat transfer coefficient multiplied by coil area through which heat exchange takes place and TS is the temperature of steam and is 150°C. UA = 11.5 kJ/min-K. The specific heat of the solvent is Cp = 2.3 kJ/kg- K. Show that Q %U F6 6 FV Determine the solvent temperature after 50 min. Also determine the maximum temperature that can be reached in the tank. Solution From the energy balance equation we know: Accumulation = Input – Output. Here input energy is due to incoming fluid and steam and output is due to outgoing fluid. Substituting the values in Eq. (4.10), we get
  • 250. F6 6 6 FV u u Note that DTlmtd = TS – T, where T is the temperature of the fluid in the stirred tank. In the coil throughout the temperature is TS and the fluid temperature is T. Simplifying the above equation, we get F6 6 FV The initial condition is: at t = 0, T = 25°C. We have to determine T at t = 3000 s. Program 4.1 can be modified, and with step size of 0.01 we get: at t = 3000 s, T = 49.69°C. The variation of temperature of the fluid in the tank with time is shown in Table 4.2. Table 4.2 Variation of fluid temperature in tank with time in Example 4.5 Time (s) Temperature (o C) 1000 36.41 2000 44.27 3000 49.69 5000 55.98 7500 59.43 10000 60.78 15000 61.53 20000 61.64 25000 61.66
  • 251. 60 Introduction to Numerical Methods in Chemical Engineering The steady state temperature is obtained when in the differential equation, F6 FV , thus the steady state temperature is given by 0.023 – 0.000373T = 0 or T = 61.66°C. The same is also obtained from the numerical solution. Note the temperature at 25000 s in Table 4.2. 4.4 Pneumatic Conveying Consider a pneumatic conveyor in which solids are inserted from the bottom along with the flowing gas. The forces acting on the particle are: drag force acting upwards, buoyancy force acting upwards and gravitational force acting downwards. The momentum balance equation becomes [see Eq. (2.15)] R D I R R FX ( ( ( FV 8 S where rp is the density of the particle, vp is the upward velocity of the particle, FD is the drag force acting on the particle, Fb is the buoyancy force acting on the particle, Fg is the gravitational force acting on the particle, and Vp is the volume of the particle. The drag force is given by
  • 252. R I I R ( # % X XS (4.11) where rg is the density of the gas, Ap is the projected area of the particle on a plane at right angles to the direction of motion, and vg – vp is the relative velocity. The gravitational force minus the buoyancy force on the particle is given by [see Eq. (2.17)]
  • 253. I D R R I( ( 8 IS S The various forces acting are shown in Figure 4.4. Fig. 4.4 Various forces (divided by volume of particle) acting on particle during pneumatic conveying. (rp – rg)g R I I R I R R # % X X X X 8 S vg
  • 254. Initial Value Problems 61 Thus the momentum balance equation becomes
  • 256. R R R I I R I R R FX # % X X I FV 8 S S S S (4.12) Note that the terms have units of force acting on the particle divided by the volume of the particle. Dividing both sides of the equation by rp, we get
  • 257. R I R I I R R R R FX # % X X I FV 8 S S S S § · ¨ ¸¨ ¸ © ¹ The derivative R R R FX FX X FV F where z is the direction along the length of the pneumatic conveyor. Thus the momentum balance equation can be written as
  • 258. R I R I R I R R R R FX # X % X X I F 8 S S S S § · ¨ ¸¨ ¸ © ¹ (4.13) Program 4.2 uses the Runge–Kutta fourth order method for integrating the above ordinary differential equation and is given in the Appendix. EXAMPLE 4.6 Determine the velocity of the solid particles of diameter 3 ´ 10–4 m along the length of the pneumatic conveyor. The initial velocity of the particle is zero and superficial velocity of air is 12 m/s. The density of the particle is 900 kg/m3 . Air is fed at 25°C and 1 atm and the viscosity of air under these conditions is 1.8 ´ 10–5 kg/m-s. Neglect wall effects. Use the following relation to determine CD:
  • 259. 4G 4G R R % where Rep is the particle Reynolds number based on relative velocity and is given by
  • 260. 4G I I R R R X X FS N Solution The following data are given: dp = 3 ´ 10–4 m vg = 12 m/s m = 1.8 ´ 10–5 kg/m-s. The density of air under the given conditions is given by I 2/ 46 S u u u kg/m3
  • 261. 62 Introduction to Numerical Methods in Chemical Engineering The projected area of the particle divided by the volume of the particle is given by R R R R R R # T 8 T F T Q Q u m–1 The particle Reynolds number is
  • 264. 4G I I R R R R R X X F X X S N u u u u The momentum balance equation is
  • 265. R I R I R I R R R R FX # X % X X I F 8 S S S S § · ¨ ¸¨ ¸ © ¹
  • 266. R R R FX X % X F § · ¨ ¸ © ¹
  • 267. R R FX % X F Let R[ X ; thus
  • 269. 4G R [ and
  • 270. 4G 4G R R % . The initial condition is at z = 0, y = 0. The problem can be solved using the Runge–Kutta fourth order method. The velocity of the particle along the length of the pneumatic conveyor as obtained from Program 4.2 is presented in Table 4.3. The step size of 0.01 m is taken. Table 4.3 Velocity of particle as obtained from Program 4.2 z (m) vp (m/s) 0.0 0.00 0.1 5.84 0.2 7.24 0.3 8.06 0.5 9.01 1.0 10.06 2.0 10.67 3.0 10.83 5.0 10.90 10.0 10.90
  • 271. Initial Value Problems 63 4.5 Solution of Simultaneous Ordinary Differential Equations Consider a system of two ordinary differential equations
  • 272. F[ H Z [ FZ (4.14)
  • 273. F H Z [ FZ (4.15) with the initial condition: at x = x0, y = y0 and z = z0. The ordinary differential equations have to be integrated to determine the value of y and z at some x. A step size, h, is chosen in the independent variable and after a step size in independent variable, i.e., at x = x0 + h the value of y and z are to be computed. In the Runge–Kutta fourth order method the following are computed:
  • 274. M J H Z [ u (4.16)
  • 275. N J H Z [ u (4.17) M J H Z J [ M N § · u ¨ ¸ © ¹ (4.18) N J H Z J [ M N § · u ¨ ¸ © ¹ (4.19) M J H Z J [ M N § · u ¨ ¸ © ¹ (4.20) N J H Z J [ M N § · u ¨ ¸ © ¹ (4.21)
  • 276. M J H Z J [ M Nu (4.22)
  • 277. N J H Z J [ M Nu (4.23)
  • 278. [ [ M M M M (4.24)
  • 279. N N N N (4.25) From the initial condition (x0, y0, z0), we have determined the value of y and z at x0 + h. Now again, the above calculations are carried out to determine the value of y and z at x0 + 2h. But before carrying out the next calculation the following statements are executed, due to which the value of y1 becomes y0, z1 becomes z0 and x0 + h becomes x0: x0 = x0 + h y0 = y1 z0 = z1
  • 280. 64 Introduction to Numerical Methods in Chemical Engineering EXAMPLE 4.7 Integrate the ordinary differential equations yx dt dx 2 yx dt dy 23 using the Runge–Kutta fourth order method. The initial condition is: at t = 0, x = 6, y = 4. Determine the values of x and y at t = 0.2. The analytical solution is given by x = 4e4t + 2e–t and y = 6e4t – 2e–t . Solution Take step size of h = Dt = 0.1. The functions are FZ H Z [ FV and F[ H Z [ FV . To compute the value at t = 0.1 the starting point is t0 = 0, x0 = 6 and y0 = 4. The calculations are given below. f1(0, 6, 4) = 14; therefore k1 = 1.4; f2(0, 6, 4) = 26; therefore l1 = 2.6; f1(0.05, 6.7, 5.3) = 17.3; therefore k2 = 1.73; f2(0.05, 6.7, 5.3) = 30.7; therefore l1 = 3.07; f1(0.05, 6.865, 5.535) = 17.935; therefore k3 = 1.7935; f2(0.05, 6.865, 5.535) = 31.665; therefore l3 = 3.1665; f1(0.1, 7.7935, 7.1665) = 22.1265; therefore k4 = 2.21265; f2(0.1, 7.7935, 7.1665) = 37.7135; therefore l4 = 3.77135. Thus
  • 281. Z Z M M M M (at t = 0.1)
  • 282. [ [ N N N N (at t = 0.1) Now let us compute the value of y and z at t = 0.2. For this computation the starting point is t0 = 0.1, x0 = 7.7766, and y0 = 7.140725. The calculations are given below. f1(0.1, 7.7766, 7.140725) = 22.05805; therefore k1 = 2.205805; f2(0.1, 7.7766, 7.140725) = 37.61125; therefore l1 = 3.761125; f1(0.15, 8.8795, 9.0212875) = 26.922075; therefore k2 = 2.6922075; f2(0.15, 8.8795, 9.0212875) = 44.681075; therefore l2 = 4.4681075; f1(0.15, 9.12270375, 9.37477875) = 27.87226; therefore k3 = 2.787226; f2(0.15, 9.12270375, 9.37477875) = 46.1176687; therefore l3 = 4.61176687; f1(0.2, 10.563826, 11.75249187) = 34.06881; therefore k4 = 3.406881; f2(0.2, 10.563826, 11.75249187) = 55.19646; therefore l4 = 5.519646.
  • 283. Initial Value Problems 65 Thus at t = 0.2
  • 284. u u Z
  • 285. u u [ From the analytical solution at t = 0.2: x = 10.5396, y = 11.7158, which is close to the numerical solution. EXAMPLE 4.8 Solve the following ordinary differential equations: F[ FZ F [ FZ with the initial condition y(0) = 2, z(0) = 1. Determine the value of y and z at x = 3. Compare the numerical solution with the analytical solution. The analytical solution of the given differential equations is y = Asin(x + a) and z = Acos(x + a). Solution The two simultaneous ordinary differential equations can be written as F[ H FZ F H [ FZ The initial condition is: at x = 0, y = 2, z = 1. We have to determine y and z at x = 3. The result from Program 4.3 at step size of 0.01 is: at x = 3: y = –1.84, z = –1.27. Now let us check the numerical result with the analytical solution. First let us determine the constants A and a. At x = 0: y = 2, z = 1, and thus 2 = A sin(0 + a) 1 = A cos(0 + a) Thus tan a = 2 or a = 63.435° and thus A = 2.236. From the conversion of radians to degrees we know that 3.1416 radians = 180°. Thus x = 3 = 171.887°. At x = 3 the following is obtained: y = 2.236 sin(171.887 + 63.435) = –1.84 z = 2.236 cos(171.887 + 63.435) = –1.27 which is the same as numerical solution. EXAMPLE 4.9 Solve the following ordinary differential equation: F [ [Z FZ with the initial conditions y(0) = 2, y¢(0) = 1. Determine the value of y at x = 3.
  • 286. 66 Introduction to Numerical Methods in Chemical Engineering Solution Let us take F[ FZ Then the given differential equation can be written as F [Z FZ The two simultaneous differential equations can be written as F[ H FZ F H [Z FZ The initial condition is at x = 0, y = 2, z = 1. We have to determine y at x = 3. Program 4.3 can be modified (only the functions func1 and func2 have to be changed) and with step size of 0.01 we get at x = 3: y = –1.90, z = –1.15. 4.6 Series of Stirred Tanks with Coil Heater The schematic diagram of a series of stirred tanks with coil heater is shown in Fig. 4.5. The mass in each tank shall be assumed constant as the tank volume and density of oil are assumed constant. The energy balance of tank 1 (accumulation = Input – Output) gives
  • 288. 2 2 5 F6 /% O% 6 6 7# 6 6 FV where M is the mass of oil in the tank and O is the flow rate of oil. T0 is the inlet temperature T3 T3 T2T1 T1 T2 O kg/s T0 Fig. 4.5 Schematic diagram of series of stirred tanks with coil heater.
  • 289. Initial Value Problems 67 of the oil. T1, T2, and T3 are the temperatures of the first, second and third tank respectively. TS is the temperature of steam. The energy balance of tank 2 gives
  • 291. 2 2 5 F6 /% O% 6 6 7# 6 6 FV The energy balance of tank 3 gives
  • 293. 2 2 5 F6 /% O% 6 6 7# 6 6 FV The analysis is described in the example below. EXAMPLE 4.10 Three tanks in series are used to heat oil (see Fig. 4.5). Each tank is initially filled with 1000 kg of oil at 20°C. Saturated steam at 250°C condenses within the coils immersed in each tank. Oil is fed into the first tank at a rate of 2 kg/s and overflows into the second and third tanks at the same flow rate. The temperature of the oil fed to the first tank is 20°C. The tanks are well mixed so that the temperature inside the tanks is uniform and the outlet stream temperature is the temperature within the tank. Cp of oil = 2000 J/kg-K. The rate of heat transferred to the oil from the steam is given by 3 = UA(TS – T), where A is the outside area of the coil in one tank, A = 1 m2 and the overall heat transfer coefficient is based on the outside area of the coil, U = 200 W/m2 -K. Determine the steady state temperature in all the three tanks. What time interval is required for T3 to reach 99% of this steady state value? Solution UA = 200 W/K. From the first differential equation we get
  • 295. u u F6 6 6 FV F6 6 FV From the second differential equation we get
  • 297. u u F6 6 6 6 FV F6 6 6 FV From the third differential equation we get
  • 299. u u F6 6 6 6 FV F6 6 6 FV The initial condition is: at t = 0: T1 = T2 = T3 = 20°C. Program 4.4 for the solution of above
  • 300. 68 Introduction to Numerical Methods in Chemical Engineering three ordinary differential equations by the Runge–Kutta fourth order method is given in the Appendix. The results at step size of 0.1 is shown in Table 4.4. Table 4.4 Results in Example 4.10. Time (s) T1 (o C) T2 (o C) T3 (o C) 1000 29.61 36.08 39.56 2500 30.89 40.98 49.87 7500 30.95 41.38 51.31 15000 30.95 41.38 51.31 The steady state temperature is obtained when in the differential equation F6 FV ; thus the steady state temperatures are given by 6 °C u 6 °C u 6 °C The same steady state temperatures are also obtained from the numerical solution. Note the temperature at 7500 s in Table 4.4. We are required to determine the time required for temperature in tank 3 to reach 0.99 ´ 51.31 = 50.80°C. From Program 4.4 this time is 3150 s. 4.7 Initial Value Problems in Chemical Reaction Engineering Batch and plug flow reactors are initial value problems. The initial conditions and ordinary differential equations for batch and plug flow reactors are shown in Table 4.5. Table 4.5 Initial conditions and ODEs for batch and plug flow reactors Initial ODE’s for Batch Reactor Initial ODEs for Plug Flow Condition for Condition for Reactor Batch Reactor Plug Flow Reactor oM # $ #V # $ V % % # # $ # F% M % FV F% M % FV #V # $ Z % % # # $ # F% W M % FZ F% W M % FZ
  • 301. Initial Value Problems 69 Table 4.5 (Cont.) o o M M # $ % #V # $ % V % % % # # $ # $ % $ F% M % FV F% M % M % FV F% M % FV #V # $ % Z % % % # # $ # $ % $ F% W M % FZ F% W M % M % FZ F% W M % FZ o o M M # $ % $ % #V # $ % V % % % % # # $ $ # $ $ % % # $ $ % $ % F% M % % FV F% M % % M % % FV F% M % % M % % FV F% M % % FV #V # $ % Z % % % % # # $ $ # $ $ % % # $ $ % $ % F% W M % % FZ F% W M % % M % % FZ F% W M % % M % % FZ F% W M % % FZ 4.8 Batch and Stirred Tank Reactors The solution of initial value problems in batch and stirred tank reactors is described with the examples given below. EXAMPLE 4.11 Consider a reaction A ® B carried out in a batch reactor. The differential equation for species A is # # F% M% FV The initial condition is: at t = 0, CA = 1 mol/m3 . The rate constant of the reaction is 1 s–1 . Using the Runge–Kutta fourth order method, determine the concentration of A at 3 s. Solution The differential equation is written in the form f = –kCA. Thereafter the following are computed:
  • 302. u M J H V % § · u ¨ ¸ © ¹ M J H V J % M § · u ¨ ¸ © ¹ M J H V J % M
  • 303. 70 Introduction to Numerical Methods in Chemical Engineering
  • 304. u M J H V J % M
  • 305. % % M M M M V V J % % Program 4.1 can be modified and the results for step size of 0.01 s are presented in Table 4.6. Table 4.6 Results in Example 4.11 t (s) CA (mol/m3 ) CA (mol/m3 ) = e–t Numerical solution Analytical solution 0.0 1.000000 1.000000 1.0 0.367880 0.367879 2.0 0.135335 0.135335 3.0 0.049787 0.049787 5.0 0.006738 0.006738 10.0 0.000045 0.000045 EXAMPLE 4.12 A liquid phase reaction A ® B is carried out in a stirred vessel reactor. Feed enters the reactor at a rate of F = 1 L/s and exits out also at the same flow rate. Both the reactant and product have the same density. The concentration of reactant in the feed is CA0 = 1 mol/m3 . The volume of the tank is V = 10 L and the concentration of A of the solution in the tank is 1 mol/m3 . The vessel may be considered perfectly mixed, so that the concentration of A in the product stream equals that inside the tank. The rate of consumption of A equals kCA, where k = 1 s–1 . Determine the concentration of A at various time periods from 0 to 10 s. Solution Mole balance on component A is given by Accumulation = Input – Output – Consumption Moles of A in the reactor = VCA Accumulation =
  • 306. #F 8% FV Input = FCA0 Output = FCA Thus from the mole balance of component A, we get
  • 307. # # # # F 8% (% (% M% 8 FV Substituting the values we get
  • 308. # # # F % % % FV # # F% % FV
  • 309. Initial Value Problems 71 The initial condition is: at t = 0, CA = 1 mol/m3 . Program 4.1 can be modified and at step size of 0.01 the concentration of component A in the tank with time is shown in Table 4.7. Table 4.7 Results in Example 4.12 Time (s) CA (mol/m3 ) 0.10 0.9053 0.25 0.7891 0.50 0.6212 1.0 0.3969 2.0 0.1927 3.0 0.1248 5.0 0.0947 10.0 0.0909 At steady state, #F% FV ; thus #% mol/m3 . The same is also obtained from numerical solution. Note the concentration at 10 s in the Table 4.7. EXAMPLE 4.13 Consider reaction o o M M # $ % carried out in a batch reactor. The differential equation for component A is # # F% M % FV for component B $ # $ F% M % M % FV for component C % $ F% M % FV The initial condition is: at t = 0, CA = 1 mol/m3 , CB = 0 mol/m3 , and CC = 0 mol/m3 . The rate constants are k1 = 1 s–1 and k2 = 1 s–1 . Using the Runge–Kutta fourth order method, determine the concentration of A, B, and C up to 10 s. Solution The differential equations are written in the form of functions H M # H M # M $ H M $ where A, B and C are the concentrations of the components A, B, and C, respectively. The initial condition is at time t = t0, A = A0, B = B0, C = C0. Thereafter the concentrations are computed at time t = t0 + h.
  • 310. 72 Introduction to Numerical Methods in Chemical Engineering
  • 313. u u u M J H V # $ % N J H V # $ % O J H V # $ % § · u ¨ ¸ © ¹ § · u ¨ ¸ © ¹ § · u ¨ ¸ © ¹ § · u ¨ ¸ © ¹ u M J H V J # M $ N % O N J H V J # M $ N % O O J H V J # M $ N % O M J H V J # M $ N % O N J H V J # M $ N § · ¨ ¸ © ¹ § · u ¨ ¸ © ¹ % O O J H V J # M $ N % O
  • 316. u u u M J H V J # M $ N % O N J H V J # M $ N % O O J H V J # M $ N % O
  • 317. # # M M M M
  • 318. $ $ N N N N
  • 319. % % O O O O t0 = t0 + h A0 = A1 B0 = B1 C0 = C1 Program 4.5 for the solution of the above three simultaneous ordinary differential equations by the Runge–Kutta fourth order method is given in the Appendix. The results for step size of 0.01 s are presented in Table 4.8.
  • 320. Initial Value Problems 73 Table 4.8 Results in Example 4.13 t (s) CA (mol/m3 ) CB (mol/m3 ) CC (mol/m3 ) 0.0 1.000000 0.000000 0.000000 1.0 0.367880 0.367879 0.264241 2.0 0.135335 0.270671 0.593994 3.0 0.049787 0.149361 0.800852 4.0 0.018316 0.073263 0.908422 5.0 0.006738 0.033690 0.959573 10.0 0.000045 0.000454 0.999503 EXAMPLE 4.14 Consider the following two reactions taking place in a batch reactor: oM # $ % oM $ % The concentration of various species with time are given by the following differential equations: for component A # # $ F% M % % FV for component B $ # $ $ % F% M % % M % % FV for component C % # $ $ % F% M % % M % % FV for component D $ % F% M % % FV The initial conditions are: at t = 0, CA = 1 mol/m3 , CB = 1 mol/m3 , CC = 0 mol/m3 , and CD = 0 mol/m3 . The rate constant of the reactions are k1 = k2 = 1 m3 /mol-s. Using the Runge–Kutta fourth order method determine the concentration of species A, B, C, and D up to 10 s. Solution Program 4.6 for solution of the above four simultaneous ordinary differential equations by the Runge–Kutta fourth order method is given in the Appendix. The results for step size of 0.01 s are presented in Table 4.9.
  • 321. 74 Introduction to Numerical Methods in Chemical Engineering Table 4.9 Results in Example 4.14 t (s) CA (mol/m3 ) CB (mol/m3 ) CC (mol/m3 ) CD (mol/m3 ) 0.0 1.000000 1.000000 0.000000 0.000000 1.0 0.528875 0.394646 0.336895 0.134230 2.0 0.404510 0.175134 0.366113 0.229376 3.0 0.357692 0.083121 0.367737 0.274571 4.0 0.337090 0.040733 0.366553 0.296357 5.0 0.327357 0.020275 0.365561 0.307082 10.0 0.318152 0.000659 0.364356 0.317492 4.9 Plug Flow Reactor The solution of initial value problems in plug flow reactor is described with examples given below. EXAMPLE 4.15 Consider a reaction A ® B carried out in a plug flow reactor. The differential equation for species A along the length of the plug flow reactor of length 10 m is # # F% W M% FZ The initial condition is: at x = 0 (inlet), CA = 1 mol/m3 . A fluid medium comprising initially only A flows through the reactor with a mean axial velocity u = 1 m/s. The rate constant of the reaction is 1 s–1 . Using the Runge–Kutta fourth order method, determine the concentration of A along the length of the plug flow reactor up to 10 m. Solution Program 4.1 can be modified and the results for step size of 0.01 m are presented in Table 4.10. Table 4.10 Results in Example 4.15 x (m) CA (mol/m3 ) 0.0 1.000000 1.0 0.367880 2.0 0.135335 3.0 0.049787 5.0 0.006738 10.0 0.000045 EXAMPLE 4.16 Consider a reaction o o M M # $ % carried out in a plug flow reactor. The differential equation for component A is # # F% W M % FZ
  • 322. Initial Value Problems 75 for component B $ # $ F% W M % M % FZ for component C % $ F% W M % FZ The initial condition is: at x = 0 (inlet), CA = 1 mol/m3 , CB = 0 mol/m3 , and CC = 0 mol/m3 . A fluid medium comprising initially only A flows through the reactor with a mean axial velocity u = 1 m/s. The rate constants are: k1 = 1 s–1 and k2 = 1 s–1 . Using the Runge–Kutta fourth order method, determine the concentration of A, B, and C along the length of the plug flow reactor up to 10 m. Solution Program 4.5 can be modified (time replaced by distance along the length of the tubular reactor) and the results for step size of 0.01 m are presented in Table 4.11. Table 4.11 Results in Example 4.16 x (m) CA (mol/m3 ) CB (mol/m3 ) CC (mol/m3 ) 0.0 1.000000 0.000000 0.000000 1.0 0.371577 0.367861 0.260562 2.0 0.136695 0.272024 0.591281 3.0 0.050287 0.150359 0.799353 4.0 0.018500 0.073814 0.907686 5.0 0.006806 0.033960 0.959234 10.0 0.000046 0.000458 0.999496 EXAMPLE 4.17 Consider the following two reactions taking place in a plug flow reactor: oM # $ % oM $ % The concentration of various species with the length of the reactor are given by the following differential equations: for component A # # $ F% W M % % FZ for component B $ # $ $ % F% W M % % M % % FZ for component C % # $ $ % F% W M % % M % % FZ for component D $ % F% W M % % FZ
  • 323. 76 Introduction to Numerical Methods in Chemical Engineering The initial conditions are: at x = 0 (inlet), CA = 1 mol/m3 , CB = 1 mol/m3 , CC = 0 mol/m3 , and CD = 0 mol/m3 . The length of the plug flow reactor is 10 m. A fluid medium comprising initially only A and B flows through the reactor with a mean axial velocity u = 1 m/s. The rate constant of the reactions are k1 = k2 = 1 m3 /mol-s. Using the Runge–Kutta fourth order method, determine the concentration of species A, B, C, and D along the length of the plug flow reactor up to 10 m. Solution Substituting k1 = k2 = 1 m3 /mol-s and u = 1 m/s in the above ordinary differential equations, we get # # $ F% % % FZ $ # $ $ % F% % % % % FZ % # $ $ % F% % % % % FZ $ % F% % % FZ Program 4.6 can be modified (time replaced by distance along the length of the tubular reactor) and the results for step size of 0.01 m are presented in Table 4.12. Table 4.12 Results in Example 4.17 x (m) CA (mol/m3 ) CB (mol/m3 ) CC (mol/m3 ) CD (mol/m3 ) 0.0 1.000000 1.000000 0.000000 0.000000 1.0 0.528875 0.394646 0.336895 0.134230 2.0 0.404510 0.175134 0.366113 0.229376 3.0 0.357692 0.083121 0.367737 0.274571 4.0 0.337090 0.040733 0.366553 0.296357 5.0 0.327357 0.020275 0.365561 0.307082 10.0 0.318152 0.000659 0.364356 0.317492 4.10 Nonisothermal Plug Flow Reactor EXAMPLE 4.18 Consider the reaction A ® B carried out in a steam heated heat exchanger reactor. Reactant A is fed at the rate of 1.26 kg/s per tube. The feed consisting of pure A enters the reactor at a temperature of 21°C. It is desired to determine the height of reactor required for 90% conversion of A. The internal diameter of the reactor tubes may be taken as 2.54 cm. Steam at 388.71 K is available for heating purposes. The rate constant of the first order
  • 324. Initial Value Problems 77 reaction is given by § · ¨ ¸ © ¹ GZRM Z 46 , where T is in Kelvin. Take the following parameters: R = 8.314 J/mol-K, r = 980.9 kg/m3 , molecular weight of reacting stream, M = 200 g/mol, heat transfer coefficient based on inside area of reactor tube, U = 1900 W/ m2 -K, Cp = 15.7 J/kg-K, TZP*' = 92.9 kJ/mol. Assume the heat of reaction to be independent of temperature. Solution Since the reaction is first order,
  • 325. # # # MP MP M% : ( ( , where F is the volumetric flow rate of reactant A and #P is the inlet molar flow rate of A. The rate constant of the reaction can be written as ª º§ · « »¨ ¸ © ¹¬ ¼ GZR M M D G where ' D 46 , 6 6 G and
  • 326. u GZRM D . T1 is a reference temperature and is taken to be the temperature of steam. # # # # FP PF: F: T P F8 F8 # F
  • 327. ª º§ · « »¨ ¸ © ¹¬ ¼ GZR # # M D : TF: F8 (P G From energy balance on reactants we get TZP 2 # F6 O% T # * S F ' where q = Ua(TS – T) and a is the total area of heat transfer per unit length; thus a = pD (for one tube). A is the cross-sectional area of the tube based on inside diameter. Thus the above equation becomes
  • 328. TZP 2 5 # F6 7 O% 6 6 T * F8 ' MI O O U MI U ( u u ' D 46
  • 330. u u GZR GZR M D S–1
  • 331. 78 Introduction to Numerical Methods in Chemical Engineering
  • 332. ª º§ · « »¨ ¸ © ¹¬ ¼ GZR #M : F: F ( G § · ¨ ¸ u© ¹ #M ( Q m–1 Thus
  • 333. ª º§ · « »¨ ¸ © ¹¬ ¼ GZR 6F: : F 6 MI MI 2 , 9 O% U - - a, A and U are all based on the internal diameter of tubes. The inlet molar flow rate of A is given by MI OQN OQN U MI U #P
  • 334. TZP 2 5 # F6 7 O% 6 6 T * #F '
  • 336. u TZP 5 # F6 6 6 T * FQ '
  • 338. ª º§ · ª º§ · u « »¨ ¸ ¨ ¸« » © ¹ © ¹¬ ¼ ¬ ¼ u GZR GZR # # 6 M P D : : 6 T ( G
  • 339. ª º§ · « »¨ ¸ © ¹¬ ¼ GZR # 6 T : 6
  • 340. ª º§ · u « »¨ ¸ © ¹¬ ¼ TZP GZR # 6 T * : 6 '
  • 341. ª º§ · u « »¨ ¸ © ¹¬ ¼ TZP GZR # 6 T * : 6 ' Thus the energy balance equation becomes
  • 343. ª º§ · u « »¨ ¸ © ¹¬ ¼ GZR 5 6F6 6 6 : F 6
  • 344. Initial Value Problems 79 Thus the two simultaneous ordinary differential equations are
  • 345. ª º§ · ¨ ¸« » © ¹¬ ¼ GZR F: : F 6
  • 347. ª º§ · ¨ ¸« » © ¹¬ ¼ GZR F6 6 : F 6 The initial condition is: at z = 0, X = 0 and T = 294.15 K. Program 4.7 for the solution of the above two simultaneous ordinary differential equations by Runge-Kutta fourth order method is given in the Appendix. The results for step size of 0.1 m are presented in Table 4.13. Table 4.13 Results in Example 4.18 z (m) X T 0.1 0.000026 343.87 0.2 0.000363 359.29 0.3 0.00094 361.51 0.4 0.0015 362.69 0.5 0.0015 362.69 1.0 0.005 364.87 2.0 0.011 365.35 3.0 0.017 365.40 5.0 0.029 365.49 10 0.059 365.71 15 0.088 365.93 20 0.118 366.16 25 0.147 366.40 30 0.176 366.64 35 0.204 366.89 40 0.232 367.14 45 0.260 367.39 50 0.287 367.66 100 0.542 370.65 150 0.752 374.56 200 0.903 379.76 250 0.980 385.59 300 0.998 388.33 350 0.999 388.68 Thus 90% conversion is achieved at a height of 200 m.
  • 348. 80 Introduction to Numerical Methods in Chemical Engineering Exercises 4.1 Integrate the following ODEs using the Runge–Kutta fourth order method: FZ Z [ FV F[ Z [ Z FV F Z[ FV Initial condition at t = 0: x = y = z = 5. Determine x(20), y(20), z(20). (Ans: x(20) = 6.76, y(20) = 12.61, z(20) = 10.96) 4.2 Consider the second order ordinary differential equation F Z FZ Z FVFV with the initial conditions x(0) = 3 and
  • 349. FZ FV . Compute x(5). Hint: Take FZ [ FV and thus the given ODE becomes F[ Z [ FV . The two simultaneous differential equations can be solved using the Runge-Kutta fourth order method by taking the following functions. FZ H [ FV F[ H Z [ FV Initial condition at t = 0: x = 3 and y = –5. Note that since the ordinary differential equation is second order, therefore two conditions have to be given to completely define the problem. (Ans: x(5) = –4.9 ´ 10–6 ) 4.3 Consider the second order ordinary differential equation F [ F[ Z [ FZFZ with the initial conditions y(0) = 1 and
  • 350. F[ FZ . Compute y(1). Hint: Take F[ FZ and thus the given ODE becomes F Z [ FZ . The two simultaneous differential equations can be solved using the Runge–Kutta fourth order method by taking the following functions:
  • 351. Initial Value Problems 81 F[ H FZ F Z [ H FZ Initial condition at x = 0: y = 1 and z = 0. ( Ans: y(1) = 0.8785) 4.4 Determine the velocity of the solid particles of diameter 0.0003 m in a pneumatic conveyor at length of 10 m. The initial velocity of the particle is zero and superficial velocity of air is 10 m/s. The density of the particle is 900 kg/m3 . Air is fed at 25°C and 1 atm and the viscosity of air under these conditions is 1.8 ´ 10–5 kg/ m-s. Neglect the wall effects. Use the following relation to determine CD:
  • 352. 4G 4G R R % where pRe is the particle Reynolds number based on relative velocity and is given by
  • 353. 4G I I R R R X X FS N . (Ans: 8.9044 m/s) 4.5 Consider a reaction A ® B carried out in a batch reactor. The differential equation for species A is # # F% M% FV The initial condition is: at t = 0, CA = 1 mol/m3 . The rate constant of the reaction is 0.1 s–1 . Using the Runge–Kutta fourth order method, determine the concentration of A at 10 s. (Ans: 0.36788 mol/m3 ) 4.6 Solve Exercise 4.5 for rate constant of the reaction of 0.01 s–1 . (Ans: 0.904838 mol/m3 ) 4.7 Consider a reaction A ® B carried out in a plug flow reactor. The differential equation for species A is # # F% W M% F The initial condition is: at z = 0, CA = 1 mol/m3 . The rate constant of the reaction is 0.1 s–1 . Using Runge–Kutta fourth order method, determine the concentration of A at 5 m from entrance. Take u = 1 m/s. (Ans: 0.606531 mol/m3 ) 4.8 Solve Exercise 4.7 for rate constant of the reaction of 0.01 s–1 . (Ans: 0.95123 mol/m3 )
  • 354. 82 Introduction to Numerical Methods in Chemical Engineering 4.9 Consider reaction o o M M # $ % carried out in a batch reactor. The differential equation for component A is # # F% M % FV for component B $ # $ F% M % M % FV for component C % $ F% M % FV The initial condition is: at t = 0, CA = 1 mol/m3 , CB = 0 mol/m3 , and CC = 0 mol/m3 . The rate constants are: k1 = 1 s–1 and k2 = 0.1 s–1 . Using the Runge–Kutta fourth order method, determine the concentration of A, B, and C at 10 s. (Ans: CA = 4.54 ´ 10–5 mol/m3 , CB = 0.408704 mol/m3 , CC = 0.59125 mol/m3 ) 4.10 Solve Exercise 4.9 for the following rate constants: k1 = 0.1 s–1 and k2 = 1 s–1 . (Ans: CA = 0.3679 mol/m3 , CB = 0.0409 mol/m3 , CC = 0.5912 mol/m3 ) 4.11 Consider reaction o o M M # $ % carried out in a plug flow reactor. The differential equation for component A is # # F% W M % FZ for component B $ # $ F% W M % M % FZ for component C % $ F% W M % FZ The initial condition is: at x = 0, CA = 1 mol/m3 , CB = 0 mol/m3 , and CC = 0 mol/ m3 . The rate constants are: k1 = 1 s–1 and k2 = 0.1 s–1 . Using the Runge–Kutta fourth order method, determine the concentration of A, B, and C at 5 m from entrance. (Ans: CA = 0.006738 mol/m3 , CB = 0.6664 mol/m3 , CC = 0.3268 mol/m3 ) 4.12 Solve Exercise 4.11 for the following rate constants: k1 = 0.1 s–1 and k2 = 1 s–1 . (Ans: CA = 0.6065 mol/m3 , CB = 0.0666 mol/m3 , CC = 0.3268 mol/m3 ) 4.13 Consider the following two reactions taking place in a batch reactor: oM # $ % oM $ %
  • 355. Initial Value Problems 83 The concentration of various species with time are given by the following differential equations: for component A # # $ F% M % % FV for component B $ # $ $ % F% M % % M % % FV for component C % # $ $ % F% M % % M % % FV for component D $ % F% M % % FV The initial conditions are: at t = 0, CA = 1 mol/m3 , CB = 1 mol/m3 , CC = 0 mol/m3 , and CD = 0 mol/m3 . The rate constant of the reactions are k1 = 1 m3 /mol-s and k2 = 0.1 m3 /mol-s. Using the Runge–Kutta fourth order method, determine the concentration of species A, B, C, and D at 10 s. (Ans: CA = 0.1392 mol/m3 , CB = 0.0361 mol/m3 , CC = 0.7576 mol/m3 , CD = 0.1032 mol/m3 ) 4.14 Solve Exercise 4.13 for the following rate constants: k1 = 0.1 m3 /mol-s and k2 = 1 m3 /mol-s. (Ans: CA = 0.5899 mol/m3 , CB = 0.2447 mol/m3 , CC = 0.0650 mol/m3 , CD = 0.3452 mol/m3 ) 4.15 Consider the following two reactions taking place in a plug flow reactor: oM # $ % oM $ % The concentration of various species are given by the following differential equations: for component A # # $ F% W M % % FZ for component B $ # $ $ % F% W M % % M % % FZ for component C % # $ $ % F% W M % % M % % FZ
  • 356. 84 Introduction to Numerical Methods in Chemical Engineering for component D $ % F% W M % % FZ The initial conditions are: at x = 0 (inlet), CA = 1 mol/m3 , CB = 1 mol/m3 , CC = 0 mol/m3 , and CD = 0 mol/m3 . The rate constant of the reactions are k1 = 1 m3 /mol-s and k2 = 0.1 m3 /mol-s. Using the Runge–Kutta fourth order method, determine the concentration of species A, B, C, and D at 5 m from the entrance. (Ans: CA = 0.1949 mol/m3 , CB = 0.1168 mol/m3 , CC = 0.7269 mol/m3 , CD = 0.0781 mol/m3 ) 4.16 Solve Exercise 4.15 for the following rate constants: k1 = 0.1 m3 /mol-s and k2 = 1 m3 /mol-s. (Ans: CA = 0.7009 mol/m3 , CB = 0.4764 mol/m3 , CC = 0.0747 mol/m3 , CD = 0.2244 mol/m3 )
  • 357. 85 Chapter 5 Boundary Value Problems The application of finite difference method for the numerical solution of boundary value problems in ordinary differential equations is discussed in this chapter with various examples. One-dimensional steady heat conduction, steady heat conduction in a fin, and chemical reaction and diffusion in a pore are also discussed in this chapter. The discretization of the convection term is discussed in the next chapter. 5.1 Discretization in One-Dimensional Space The basic idea of finite difference methods is that the derivatives in differential equations are written in terms of discrete quantities of dependent and independent variables, resulting in simultaneous algebraic equations with all unknowns prescribed at discrete nodal points. Consider a function y(x) and its derivatives at point x. y(x + Dx) can be expanded in Taylor series about y(x) as follows:
  • 359. Z Z Z F[ Z F [ Z F [ [ Z Z [ Z Z FZ FZ FZ ' ' ' ' (5.1) Simplifying, we get
  • 361. Z Z [ Z Z [ Z F[ Z F [ Z FZ FZ ' ' ' Thus
  • 364. Z [ Z Z [ ZF[ 1 Z FZ Z ' ' ' The derivative Z F[ FZ is of first order in Dx, indicating that the truncation error O(Dx) goes to zero like the first power in Dx. That is why we write the derivative at point x as
  • 366. o NKO Z Z [ Z Z [ ZF[ FZ Z' ' ' Consider a one-dimensional body as shown in Fig. 5.1.
  • 367. 86 Introduction to Numerical Methods in Chemical Engineering Fig. 5.1 One-dimensional body. We may write y in Taylor series at i + 1 and i – 1 as K K K K K K F[ Z F [ Z F [ Z F [ [ [ Z FZ FZ FZ FZ ' ' ' ' (5.2a) K K K K K K F[ Z F [ Z F [ Z F [ [ [ Z FZ FZ FZ FZ ' ' ' ' (5.2b) From Eq. (5.2a), we get the forward difference approximation of F[ FZ at node i as
  • 368. K K K [ [F[ 1 Z FZ Z ' ' (5.3) and from Eq. (5.2b) we get the backward difference approximation of F[ FZ at node i as
  • 369. K K K [ [F[ 1 Z FZ Z ' ' (5.4) Subtracting Eq. (5.2b) from Eq. (5.2a), we get the central difference approximation of F[ FZ at node i as
  • 370. K K K [ [F[ 1 Z FZ Z ' ' (5.5) It is seen that the truncation errors for the forward difference and backward differences are first order, whereas the central difference yields a second order truncation error. Adding the two equations, we get the central difference approximation of F [ FZ at node i
  • 371. K K K K [ [ [F [ 1 Z FZ Z ' ' (5.6) It should be noted that these finite difference approximations are only valid to some order of Dx. The error in the approximations is called the truncation error. It is possible to get approximations which are valid to higher order by using more grid points in the approximations. But for our purposes the approximations given above will be sufficient. A numerical scheme is called consistent if the finite difference approximations have a truncation error that approaches zero in the limit that Dx ® 0, Dt ® 0. Even if the numerical scheme is consistent, we are still not guaranteed that iterating the numerical scheme will give a good approximation to the true solution of the differential equation. A numerical scheme is called convergent if the solution of the discretized equations approaches the exact solution of the differential equation in the limit that Dx ® 0, Dt ® 0. i – 2 i – 1 i i + 1 i + 2
  • 372. Boundary Value Problems 87 For linear equations the issue of convergence is intimately related to the issue of stability of the numerical scheme. A scheme is called stable if it does not magnify errors that arise in the course of the calculation. As Dx and Dt are made smaller, the truncation error of approximating the derivatives by finite differences decreases. However, for smaller sizes, more computations need to be done to get solutions for the same domain and total time, which leads to increased round-off errors. The total error as a function of these sizes is shown in Fig. 5.2. Here it is assumed that the solution is calculated on the same domain and for the same total time. Fig. 5.2 Errors as function of grid size for finite difference calculation. For a second order differential equation, two boundary conditions have to be specified and thus the problem is called the two-point boundary value problem. There are three types of boundary conditions: Dirichlet, Neumann and mixed. Dirichlet boundary condition is the one in which the variable is defined such as y = 0 and Neumann boundary condition is the one in which the gradient of the variable is defined perpendicular to the surface such as F[ FP . Mixed boundary condition is the one which is a combination of Dirichlet and Neumann, such as
  • 373. f F6 M J 6 6 FZ . A well-posed problem is the one which has a unique solution. EXAMPLE 5.1 Using finite difference method, solve the second order one dimensional linear differential equation F [ FZ (0 x 1) with the Dirichlet boundary conditions at x = 0: 0y at x = 1: 0y Truncation error Total error Round-off error Error Grid size
  • 374. 88 Introduction to Numerical Methods in Chemical Engineering Compute the value of y at x = 0.5. Make two parts (see Fig. 5.3). The exact solution is y = x2 – x. Fig. 5.3 Example 5.1. Solution The central difference in space gives K K K [ [ [ Z' Substituting i = 2, we get [ [ [ Z' Since two parts are made, therefore Dx = 0.5. It is given that y1 = 0 and y3 = 0 and we get [ , which is the same as the exact solution. EXAMPLE 5.2 Using the finite difference method, solve the second order one dimensional linear differential equation F [ FZ (0 x 1) with the following boundary conditions: At x = 0: 0y Dirichlet boundary condition At x = 1: F[ FZ Neumann boundary condition Compute the value of y at x = 0.5. Make two parts (see Fig. 5.4). Fig. 5.4 Example 5.2. Solution The central difference in space gives K K K [ [ [ Z' At node 2 [ [ [ Z' 1 2 3 1 2 3 4
  • 375. Boundary Value Problems 89 Since y1 = 0, we get [ [ Z' At node 3 [ [ [ Z' where node 4 is a hypothetical node. From the boundary condition at node 3, we get [ [ Z' thus y4 = y2 + 2Dx. Therefore Z [ [ Z ' ' Thus Z [ [ Z ' ' Solving the equations for nodes 2 and 3, we get [ and y3 = 0. EXAMPLE 5.3 Using finite difference method, solve the differential equation with the source term f(x)
  • 376. F [ [ H Z FZ (0 x 1) f(x) = 4x2 – 2x – 4 with the Dirichlet boundary conditions At x = 0: 0y At x = 1: 1y The total length is 1 m. Make 3 parts (see Fig. 5.5). The exact solution is y = –2x2 + x. Fig. 5.5 Example 5.3. Solution The central difference in space gives K K K K K [ [ [ [ H Z' At node 2 [ [ [ [ H Z' 1 2 3 4
  • 377. 90 Introduction to Numerical Methods in Chemical Engineering [ [ [ § · ¨ ¸ © ¹
  • 378. [ [ [ At node 3 [ [ [ [ § · § · ¨ ¸ ¨ ¸ © ¹ © ¹§ · ¨ ¸ © ¹
  • 379. [ [ [ Solving the equations for nodes 2 and 3, we get y2 = 0.111 and y3 = –0.222. EXAMPLE 5.4 Using finite difference method, solve the differential equation with the source term f(x)
  • 380. F [ [ H Z FZ (0 x 1)
  • 381. H Z Z Z subject to the boundary conditions At x = 0: y = 0 At x = 1: F[ FZ The total length is 1 m. Make 3 parts (see Fig. 5.6). The exact solution is y = –2x2 + x. Fig. 5.6 Example 5.4. Solution The central difference in space gives K K K K K [ [ [ [ H Z' At node 2 [ [ [ [ H Z' [ [ [ § · ¨ ¸ © ¹ 1 2 3 4 5
  • 383. [ [ [ At node 3 [ [ [ [ § · § · ¨ ¸ ¨ ¸ © ¹ © ¹§ · ¨ ¸ © ¹
  • 384. [ [ [ [ At node 4 [ [ [ [ § · ¨ ¸ © ¹
  • 385. [ [ [ [ where node 5 is a hypothetical node. From the boundary condition at node 4, we get [ [ Z' , therefore 235 yy and the equation for node 4 becomes
  • 386. [ [ [ Thus the equation of node 2 is [ [ Thus the equation of node 3 is [ [ [ Thus the equation of node 4 is [ [ The equation can be written as [ [ [ ª º ª º ª º « » « » « » « » « » « » « » « » « »¬ ¼ ¬ ¼ ¬ ¼ Solving using TDMA, we get [ , [ , y4 = –1. EXAMPLE 5.5 Solve the boundary value problem F [ [ FZ
  • 387. F[ FZ and y(1) = 1. Take Dx = 0.1 m. Compare the results with the analytical solution EQUJ EQUJ Z [
  • 388. 92 Introduction to Numerical Methods in Chemical Engineering Solution The schematic diagram is shown in Fig. 5.7. Fig. 5.7 Example 5.5. Discretizing the given differential equation at nodei using the central difference scheme, we get K K K K [ [ [ [ Z'
  • 389. K K K [ Z [ [' Since Dx = 0.1, therefore Dx2 = 0.01 and the above equation becomes K K K [ [ [ At node 1 [ [ [ Also at node 1, F[ FZ , thus [ [ Z' , thus y0 = y2 and we get at node 1 –2.01y1 + 2y2 = 0 At node 2 y1 – 2.01y2 + y3 = 0 At node 10 y9 – 2.01y10 + y11 = 0 Since y11 = 1, the above equation becomes y9 – 2.01y10 = –1 Thus the unknowns are y1 to y10. The tridiagonal set of 10 equations becomes [ [ [ [ ª ºª º ª º « »« » « » « »« » « » « »« » « » « »« » « » « »« » « » « »« » « » ¬ ¼ ¬ ¼¬ ¼ F[ FZ y = 1 1 6 11
  • 390. Boundary Value Problems 93 The solution can be obtained by modifying the parameters ai (i = 2 to N), bi (i = 1 to N) and ci (i = 1 to N – 1) in Program 1.1 given in the Appendix. The numerical and analytical solution at nodes 1 to 10 are shown in Table 5.1. Table 5.1 Numerical and analytical solutions at nodes 1 to 10 for Example 5.5 Node x (m) Numerical y Analytical y 1 0.0 0.6482 0.6481 2 0.1 0.6515 0.6513 3 0.2 0.6612 0.6611 4 0.3 0.6776 0.6774 6 0.5 0.7309 0.7308 9 0.8 0.8668 0.8667 10 0.9 0.9287 0.9287 5.2 One-Dimensional Steady Heat Conduction The steady heat conduction in one dimension is described with examples given below. EXAMPLE 5.6 Consider 1-dimensional steady state conduction without heat generation taking place in a rectangular slab. The temperature of the left side of the slab is 100°C and of the right side is 200°C. The length of the slab is 10 cm and the thermal conductivity of the slab is 120 W/cm-K. Make nine uniform divisions. The governing equation is F 6 M FZ Solution Let us make nine uniform divisions as shown in Fig. 5.8. Fig. 5.8 Example 5.6. Dx = 1.111, T1 = 100°C, T10 = 200°C. Using the central difference scheme, we get K K K 6 6 6 M Z' K K K 6 6 6 The equation for node 2 is 2T2 – T3 = 100 Similar equations can be written for all the nodes and the following set of eight linear algebraic equations is obtained. The equations can be written in tridiagonal form as 1 2 3 4 5 6 7 8 9 10
  • 391. 94 Introduction to Numerical Methods in Chemical Engineering 6 6 6 6 6 6 6 6 ª ºª º ª º « »« » « » « »« » « » « »« » « » « »« » « » « »« » « » « »« » « » « »« » « » « »« » « » « »« » « » « »« » « » « »« » « »¬ ¼ ¬ ¼¬ ¼ The solution can be obtained by modifying the parameters ai (i = 2 to N), bi (i = 1 to N) and ci (i = 1 to N – 1) in Program 1.1 given in the Appendix. Using TDMA the following solution is obtained: 6 6 6 6 6 6 6 6 ª º ª º « » « » « » « » « » « » « » « » « » « » « » « » « » « » « » « » « » « » « » « » « » « »¬ ¼¬ ¼ EXAMPLE 5.7 A fin of diameter 0.02 m and length 0.05 m is attached to a wall. The temperature of the wall is 320°C. Determine the temperature of the fin at x = 0.0125, 0.025, 0.0375 and 0.05 m using the finite difference technique taking four parts. The thermal conductivity of the rod is 50 W/m-K and the convective heat transfer coefficient from the rod to the surroundings is 100 W/m2 -K. The temperature of the surroundings is 20°C. The governing differential equation is F J2 M#FZ R R , where q = T – Tsurr and the boundary condition at x = 0.05 m is F J FZ M R R . Solution The schematic diagram of the fin is shown in Fig. 5.9. Fig. 5.9 Steady state heat transfer in fin. x = 0 0.0125 0.025 0.0375 x = 0.05 m 0 1 2 3 4 Wallat320°C q0 = 300
  • 392. Boundary Value Problems 95 Let J2 O M# . From the discretization of the differential equation F J2 M#FZ R R , we get K K K K O Z R R R R ' § · ¨ ¸ © ¹ Simplifying, we get
  • 393. K K K O ZR R R' ª º ¬ ¼ (for i = 1, 2, 3, 4) Let D = 2 + (mDx)2 . Therefore the above equation becomes –qi–1 + Dqi – qi+1 = 0 Applying the above equation to node 1, we get –q0 + Dq1 – q2 = 0 Since q0 = 300 the above equation becomes Dq1 – q2 = 300. Applying the above equation to node 2, we get –q1 + Dq2 – q3 = 0 Applying the above equation to node 3, we get –q2 + Dq3 – q4 = 0 Applying the above equation to node 4, we get –q3 + Dq4 – q5 = 0 where q5 is a hypothetical node to the right of node 4. At x = L (node 4), the equation F J FZ M R R is applicable and the difference equation becomes J Z M R R R ' From this expression we can determine 5T in terms of 3T and 4T . J Z M R R R ' Substituting this in the equation for node 4, we get J Z M R R '§ · ¨ ¸ © ¹
  • 394. 96 Introduction to Numerical Methods in Chemical Engineering Thus the four difference equations are Dq1 – q2 = 300 – q1 + Dq2 – q3 = 0 – q2 + Dq3 – q4 = 0 J Z M R R '§ · ¨ ¸ © ¹
  • 395. J FJ2 J O M# MFF M Q Q u u§ · ¨ ¸ © ¹
  • 396. O Z' u u Thus the four difference equations are 2.0625q1 – q2 = 300 – q1 + 2.0625q2 – q3 = 0 – q2 + 2.0625q3 – q4 = 0 – 2q3 + 2.1125q4 = 0 The set of simultaneous linear algebraic equations can be written in tridiagonal form as R R R R ª ºª º ª º « »« » « » « »« » « » « »« » « » « »« » « » « » « »« »¬ ¼ ¬ ¼¬ ¼ The solution can be obtained by modifying the parameters ai (i = 2 to N), bi (i = 1 to N) and ci (i = 1 to N – 1) in Program 1.1 given in the Appendix. The comparison of numerical and analytical results is presented in Table 5.2. Table 5.2 Numerical and analytical results for Example 5.7 x (m) q (numerical solution q (analytical for 4 parts) solution) 0.0125 248.95 248.75 0.025 213.47 213.13 0.0375 191.32 190.90 0.05 181.13 180.66 Even when 4 parts are made the difference between the numerical and analytical solution is meagre. The numerical solution can exactly match with the analytical solution if a greater number of parts is made.
  • 397. Boundary Value Problems 97 5.3 Chemical Reaction and Diffusion in Pore The differential equation for diffusion and reaction in a pore is given by F % M % FZ (5.7) Let us define M O (5.8) Thus the differential equation can be written as F % O % FZ (5.9) The boundary conditions are at x = 0 C = CS (5.10a) and at x = L F% FZ (5.10b) where CS is the concentration at the surface of the pore. EXAMPLE 5.8 Diffusion and reaction take place in a pore of 1mm in length. The rate constant of the reaction, k = 10–3 s–1 and effective diffusivity of species, D = 10–9 m2 /s. Make 100 parts of the pore and determine the concentration at x = 0.5 mm. The concentration at the surface of the mouth of the pore is 1 mol/m3 . Solution We have M O m–1 The pore length is 1 mm = 10-3 m and 100 parts are made, thus Z' m. The schematic diagram of the pore is shown in Fig. 5.10. The first node is labelled 0 and therefore the last node is the 100th node as 100 parts are made. Fig. 5.10 Diffusion and reaction in pore. The boundary conditions are At x = 0: C = 1 At x = 10–3 m: F% FZ F% FZ 100 x = 1 mm 0 x = 0 C = 1
  • 398. 98 Introduction to Numerical Methods in Chemical Engineering Discretizing the differential equation at node i, we get K K K K % % % % Z' At node 1 % % % % Z' It is given that C0 = 1, therefore % % % Z' Substituting the value of Dx = 10–5 m, we get % % % u Simplifying, we get % % At node 2 % % % % Z' C3 + C1 – 2C2 – 10–4 C2 = 0 C1 – 2.0001C2 + C3 = 0 At node 99 % % % % Z' C100 + C98 – 2C99 – 10–4 C99 = 0 C98 – 2.0001C99 + C100 = 0 At node 100 % % % % Z' % % % % But F% FZ ; thus % % Z' and therefore C101 = C99. Substituting C101 = C99 in the previous equation, we get 2C99 – 2.0001C100 = 0 The 100 equations can be written in tridiagonal form as
  • 399. Boundary Value Problems 99 % % % % % % ª ºª º ª º « »« » « » « »« » « » « »« » « « »« » « « »« » « « »« » « « »« » « « »« » « « »« » « « »« » « « »« » « « »« » « « » «« »¬ ¼ ¬ ¼¬ ¼ » » » » » » » » » » » The solution can be obtained by modifying the parameters ai (i = 2 to N), bi (i = 1 to N) and ci (i = 1 to N – 1) and di (i = 1 to N) in Program 1.1 given in the Appendix. From the results, we get C = 0.73 at x = 0.5 mm (50th node). Exercises 5.1 Consider the two-point boundary value problem 012 2 y dx yd with the boundary conditions y(0) = y(1) = 0. List the tridiagonal set of equations and determine y at various values of x. Take Dx = 0.1. (Ans: The tridiagonal set of equations are [ [ [ [ ª ºª º ª º « »« » « » « »« » « » « »« » « » « »« » « » « »« » « » « »« » « » ¬ ¼ ¬ ¼¬ ¼ y1 = y(0.1) = 0.041253 y2 = y(0.2) = 0.072919 y3 = y(0.3) = 0.095313 y4 = y(0.4) = 0.108661 y5 = y(0.5) = 0.113096 y6 = y(0.6) = 0.108661 y7 = y(0.7) = 0.095313 y8 = y(0.8) = 0.072919 y9 = y(0.9) = 0.041253 5.2 Consider the two-point boundary value problem F [ F[ [ Z FZFZ with the boundary conditions y(0) = 5 and y(20) = 8. List the tridiagonal set of equations and determine y at x = 10. Take Dx = 1.
  • 400. 100 Introduction to Numerical Methods in Chemical Engineering (Ans: The tridiagonal set of equations are [ [ [ [ ª ºª º ª º « »« » « » « »« » « » « »« » « » « »« » « » « »« » « » « »« » « » ¬ ¼ ¬ ¼¬ ¼ y10 = y(10) = 8.514381. 5.3 Consider the ordinary differential equation y dx yd 2 2 with the boundary conditions y(1) = 1.175 and y(3) = 10.018. Take Dx = 0.5. List the tridiagonal set of equations and determine y at various x. (Ans: The tridiagonal set of equations are [ [ [ ª º ª º ª º « » « » « »« » « » « » « » « » « » ¬ ¼ ¬ ¼ ¬ ¼ y1 = y(1.5) = 2.146603 y2 = y(2.0) = 3.654857 y3 = y(2.5) = 6.076825. 5.4 Consider the ordinary differential equation F [ [ FZ with the boundary conditions:
  • 402. F[ FZ . Take Dx = 0.5. List the tridiagonal set of equations and determine y at various x. (Ans: The tridiagonal set of equations are [ [ [ [ [ ª ºª º ª º « »« » « » « »« » « » « »« » « » « »« » « » « »« » « » « »« » « » ¬ ¼ ¬ ¼¬ ¼ y1 = y(1.0) = 1.552429 y2 = y(1.5) = 2.333983 y3 = y(2.0) = 3.699032 y4 = y(2.5) = 5.988840 y5 = y(3.0) = 9.775857
  • 403. Boundary Value Problems 101 5.5 Consider 1-D steady state conduction without heat generation taking place in a rectangular slab. The temperature of the left side of the slab is 100°C and of the right side is 50°C. The length of the slab is 1 m and the thermal conductivity of the slab is 120 W/cm-K. Take Dx = 0.1 m. Determine the temperature distribution in the slab and list the tridiagonal set of equations. The governing equation is F 6 FZ . (Ans: The tridiagonal set of equations are 6 6 6 6 ª ºª º ª º « »« » « » « »« » « » « »« » « » « »« » « » « »« » « » « »« » « » ¬ ¼ ¬ ¼¬ ¼ T1 = T(0.1) = 95.0 T2 = T(0.2) = 90.0 T3 = T(0.3) = 85.0 T4 = T(0.4) = 80.0 T5 = T(0.5) = 75.0 T6 = T(0.6) = 70.0 T7 = T(0.7) = 65.0 T8 = T(0.8) = 60.0 T9 = T(0.9) = 55.0 5.6 A fin of diameter 0.02 m and length 0.08 m is attached to a wall (see Fig. 5.11). The temperature of the wall is 200°C. List the tridiagonal set of equations and determine the temperature of the fin at x = 0.02, 0.04, 0.06 and 0.08 m, using the finite difference technique taking four parts. The thermal conductivity of rod is 25 W/m-K and convective heat transfer coefficient from rod to surroundings is 40 W/m2 -K. The temperature of surroundings is 25°C. The governing differential equation is F J2 M#FZ R R , where q = T – Tsurr and boundary condition at x = 0.08 m is F J FZ M R R . Fig. 5.11 Exercise 5.6. x = 0 0.02 0.04 0.06 x = 0.08 m 0 1 2 3 4 Wallat200°C
  • 404. 102 Introduction to Numerical Methods in Chemical Engineering (Ans: The tridiagonal set of equations are R R R R ª ºª º ª º « »« » « » « »« » « » « »« » « » « »« » « » « » « »« »¬ ¼ ¬ ¼¬ ¼ q1 = q(0.02) = 128.49 q2 = q(0.04) = 98.44 q3 = q(0.06) = 80.98 q4 = q(0.08) = 73.88 5.7 Diffusion and reaction take place in a pore of 1mm in length. The rate constant of the reaction, k = 2.5 ´ 10–4 s–1 and effective diffusivity of species, D = 10–9 m2 /s. Make 10 parts of the pore. List the tridiagonal set of equations and determine the concentration along x. The concentration at the surface of the mouth of the pore is 1 mol/m3 and at pore end F% FZ . (Ans: The tridiagonal set of equations are % % % % ª ºª º ª º « »« » « » « »« » « » « »« » « » « »« » « » « »« » « » « »« » « »¬ ¼ ¬ ¼¬ ¼ C1 = C(0.1) = 0.978139 C2 = C(0.2) = 0.958723 C3 = C(0.3) = 0.941703 C4 = C(0.4) = 0.927039 C5 = C(0.5) = 0.914691 C6 = C(0.6) = 0.904631 C7 = C(0.7) = 0.896832 C8 = C(0.8) = 0.891275 C9 = C(0.9) = 0.887947 C10 = C(1.0) = 0.886838 Distance (in mm) is measured from the pore mouth. 5.8 Diffusion and reaction take place in a pore of 1 mm in length. The rate constant of the reaction, k = 0.1 s–1 and effective diffusivity of species, D = 10–9 m2 /s. Make 10 parts of the pore. List the tridiagonal set of equations and determine the concentration along x. The concentration at the surface of the mouth of the pore is 1 mol/m3 and at pore end F% FZ . (Ans: The tridiagonal set of equations are % % % % ª ºª º ª º « »« » « » « »« » « » « »« » « » « »« » « » « »« » « » « »« » « »¬ ¼ ¬ ¼¬ ¼
  • 405. Boundary Value Problems 103 C1 = C(0.1) = 0.381966 C2 = C(0.2) = 0.145898 C3 = C(0.3) = 0.055728 C4 = C(0.4) = 0.021286 C5 = C(0.5) = 0.008131 C6 = C(0.6) = 0.003107 C7 = C(0.7) = 0.001190 C8 = C(0.8) = 0.000463 C9 = C(0.9) = 0.000198 C10 = C(1.0) = 0.000132 Distance (in mm) is measured from the pore mouth. 5.9 Water flows between the two fixed parallel plates as shown in Fig. 5.12. Fluid moves in the x-direction parallel to the plates and there is no velocity in the y direction. The spacing between the plates is 0.02 m and pressure gradient is – 100 Pa/m. The viscosity of water under the flow conditions is 0.001 kg/m-s. Using the finite difference method, solve the velocity profile equation R W Z [ N w w w w Fig. 5.12 Illustration for Exercise 5.9. Determine the velocity at various nodes between the symmetry line and the wall. Make 10 parts. Compare the numerical solution with the analytical solution
  • 406. R W [ J ZN ˜È Ø É ÙÊ Ú˜ . (Ans: The tridiagonal set of equations are W W W W ª ºª º ª º « »« » « » « »« » « » « »« » « » « »« » « » « »« » « » « »« » « » ¬ ¼ ¬ ¼¬ ¼ and the results are presented in Table 5.3. y x u h h
  • 407. 104 Introduction to Numerical Methods in Chemical Engineering Table 5.3 Results in Exercise 5.9 x (m) Node u, Numerical (m/s) u, Analytical (m/s) 0.000 1 5.00 5.00 0.001 2 4.95 4.95 0.002 3 4.80 4.80 0.003 4 4.55 4.55 0.004 5 4.20 4.20 0.005 6 3.75 3.75 0.006 7 3.20 3.20 0.007 8 2.55 2.55 0.008 9 1.80 1.80 0.009 10 0.95 0.95 Distance (in m) is measured from the symmetry line.
  • 408. 105 Chapter 6 Convection–Diffusion Problems The convection-diffusion equation for the transport of a component of concentration C is given by F% F % W FZ FZ In the above equation, F% W FZ is the convection term and F % FZ is the diffusion term. The central difference scheme (CDS) or the upwind difference scheme (UDS) can be used for the discretization of the convection term, whereas CDS is used for the discretization of the diffusion term. The comparison of the central difference and upwind difference schemes for the discretization of convection term is also discussed here. 6.1 Upwind Schemes The upwind scheme is used for the discretization of the convection term. The first order and second order upwind schemes are described below. 6.1.1 First Order Upwind Scheme When the fluid is flowing from left to right properties at grid point i depend only on the properties at grid point i – 1 and when the fluid is flowing from right to left properties at grid point i depend only on the properties at grid point i + 1. This is nothing more than obeying the physics of the flow. For information propagated from left to right discretization of convection term at node i is given by K K % %F% FZ Z' (® x, ® u) (6.1) and for information propagated from right to left discretization of convection term at node i is given by K K % %F% FZ Z' (® x, ¬ u) (6.2) This is shown in Fig. 6.1.
  • 409. 106 Introduction to Numerical Methods in Chemical Engineering 6.1.2 Second Order Upwind Scheme For information propagated from left to right, discretization of convection term at node i is given by K K K % % %F% FZ Z' (® x, ® u) (6.3) and for information propagated from right to left, discretization of convection term at node i is given by K K K % % %F% FZ Z' (® x, ¬u) (6.4) Fig. 6.1 Discretization of convection term using first order upwind method: (a) Direction of flow and space identical; (b) Direction of flow opposite to direction of space. Let us now derive the formula for second order upwind scheme. Since upwind scheme is one- sided, we shall consider nodes near to a boundary (see Fig. 6.2). Assume that C can be expressed near the boundary by the polynomial C = a + bx + cx2 Direction of flow The information has passed through node i – 1 and then comes to node i Direction of flow The information has passed through node i + 1 and then comes to node i (a) i – 2 i – 1 i i + 1 i + 2 i + 3 i – 2 i – 1 i i + 1 i + 2 i + 3 (b) K K F% % % FZ Z' K K F% % % FZ Z'
  • 410. Convection–Diffusion Problems 107 Fig. 6.2 Nodes near boundary. At point 1 (x = 0) C1 = a At point 2 (x = Dx) C2 = a + bDx + cDx2 At point 3 (x = 2Dx) C3 = a + 2bDx + 4cDx2 Solving the above equations for b, we get % % % D Z' We find b because it is equal to F% FZ at the wall (at node 1). This is because F% D EZ FZ and at x = 0, F% FZ = b. Therefore at point 1 % % %F% FZ Z' This is a one-sided finite difference expression for the derivative at the boundary. This becomes the basis for second order upwind scheme K K K K % % %% Z Z ˜È Ø É ÙÊ Ú˜ ' Here information is propagated in the opposite direction as compared to the direction of x. If information is propagated in the direction of x, then K K K K % % %% Z Z ˜È Ø É ÙÊ Ú˜ ' Oscillations do not take place when first order upwind scheme is used for discretization of convection term. u 3 2 1 Dx Dx x Boundary
  • 411. 108 Introduction to Numerical Methods in Chemical Engineering EXAMPLE 6.1 A component C is transported by means of convection and diffusion through a one-dimensional space shown in Fig. 6.3. Fig. 6.3 One-dimensional space. Discretize the convection–diffusion equation F% F % W FZ FZ The boundary conditions are: at x = 0 m, C = 0 and at x = 1 m, C = 1. Discretize the equation using (i) central difference scheme for both diffusion and convection terms and (ii) central difference scheme for diffusion term and first order upwind scheme for convection term. Make 50 parts between x = 0 and x = 1 m. Calculate the distribution of C as a function of x for x = 0.84 to 1.0. Compare the numerical results with the analytical solution. For the boundary conditions, at x = 0: C = C0 and at x = L: C = CL, the analytical solution for 0 £ x £ L is
  • 414. Z 2G . .2G G % Z % % % G where Pe is the Peclet number, the ratio of strength of convection by strength of diffusion, and is given by W. 2G . Take 50Pe . Solution We have (i) Central difference scheme for both diffusion and convection terms Using central difference scheme (CDS) at node i, we get K K K K K % % % % % W Z Z' ' § · § · ¨ ¸ ¨ ¸ © ¹ © ¹ Multiplying by Z ' , we get
  • 415. K K K K K W Z % % % % % ' The local Peclet number is given by NQE W Z 2G ' u x = 1x = 0
  • 416. Convection–Diffusion Problems 109 Thus the discretized equation at nodei becomes
  • 418. NQE NQE K K K 2G % % 2G % Let NQE 2GB and NQE 2GC Thus K K K % % %C B Let the total length be 1 m and let us make 50 parts of the length; therefore 02.0'x m. The schematic diagram is shown in Fig. 6.4. 0 10 20 30 40 50 x = 0 x = 1 C = C0 C = C50 Fig. 6.4 Schematic diagram. At node 0, C = C0. At node 1 % % %C B Since the value of C0 is known; therefore the equation at node 1 becomes % % %B C At node 2 % % %C B At node 3 % % %C B At node 48 % % %C B At node 49 % % %C B At node 50 the value of C50 is known; therefore the equation for node 49 becomes % % %C B Thus the set of equations for value of C at node 1 to 49 using central difference scheme for both the diffusion and convection terms becomes
  • 419. 110 Introduction to Numerical Methods in Chemical Engineering % % % % % % % % % % CB C B C B C B C B C B C B BC ª ºª º « »« » « »« » « »« » « »« » « »« » « »« » « »« » « »« » « »« » « »« » « »« » « »« » « »« » « »« » « »« » « »« » « »« » « » « »¬ ¼ ¬ ¼ ª º « » « » « » « » « » « » « » « » « » « » « » « » « » « » « » « » « »« »¬ ¼ For Pe = 50, W and the local Peclet number becomes NQE W Z 2G ' u . Thus aÿ= Peloc – 2 = –1 and bÿ= Peloc + 2 = 3. The solution can be obtained by modifying the parameters ai (i = 2 to N), bi (i = 1 to N) and ci (i = 1 to N – 1) in Program 1.1 given in the Appendix. The numerical and analytical results are shown in Table 6.1. (ii) Central difference scheme for diffusion term and upwind difference scheme for convection term Using the upwind difference scheme (UDS) for the convection term and the central difference scheme for the diffusion term at node i, we get K K K K K % % % % % W Z Z' ' § · § · ¨ ¸ ¨ ¸ © ¹ © ¹ On multiplying by Z ' , the discretized equation at nodei becomes
  • 421. NQE NQE K K K 2G % 2G % % Let b = Peloc + 2 and g = Peloc + 1 Thus K K K % % %H C Let the total length be 1 m and let us make 50 parts of the length; therefore Dx = 0.02 m. At node 0, C = C0. At node 1 % % %H C Since the value of C0 is known, therefore the equation at node 1 becomes % % %C H At node 2 % % %H C
  • 422. Convection–Diffusion Problems 111 At node 3 % % %H C At node 48 % % %H C At node 49 % % %H C At node 50 the value of C50 is known; therefore the equation for node 49 becomes % % %H C Thus the set of equations for value of C at node 1 to 49 using the central difference scheme for the diffusion term and the first order upwind scheme for the convection term becomes % % % % % % % % % HC H C H C H C H C H C H C H C ª ºª º « »« » « »« » « »« » « »« » « »« » « »« » « »« » « »« » « »« » « »« » « »« » « »« » « »« » « »« » « »« » « »« » « »« »« » « »¬ ¼ ¬ ¼ % ª º « » « » « » « » « » « » « » « » « » « » « » « » « » « » « » « » « »« »¬ ¼ For Pe = 50, W and the local Peclet number becomes NQE W Z 2G ' u . Thus b = Peloc + 2 = 3 and g = Peloc + 1 = 2. The solution can be obtained by modifying the parameters ai (i = 2 to N), bi (i = 1 to N) and ci (i = 1 to N – 1) in Program 1.1 given in the Appendix. The numerical and analytical results are shown in Table 6.1. Table 6.1 Numerical and analytical results for Example 6.1 Node number x (m) C (CDS) C (CDS/UDS) Z G % G (Analytical) 42 0.84 0.000152 0.003906 0.000335 43 0.86 0.000457 0.007813 0.000912 44 0.88 0.001372 0.015625 0.002479 45 0.90 0.004115 0.031250 0.006738 46 0.92 0.012346 0.062500 0.018316 47 0.94 0.037037 0.125000 0.049787 48 0.96 0.111111 0.250000 0.135335 49 0.98 0.333333 0.500000 0.367879
  • 423. 112 Introduction to Numerical Methods in Chemical Engineering The central difference scheme is a second order scheme and is therefore more accurate, whereas upwind scheme used is first order and is therefore less accurate. But if more parts are made, then more accurate results are obtained. The importance of first order upwind scheme is shown in the next example. EXAMPLE 6.2 Solve the previous problem for Pe = 500. Solution We have (i) Central difference scheme for both diffusion and convection terms For Pe = 500, W and the local Peclet number becomes NQE W Z 2G ' u . Thus a = Peloc – 2 = 8 and b = Peloc + 2 = 12. The solution can be obtained by modifying the parameters ai (i = 2 to N), bi (i = 1 to N) and ci (i =1 to N – 1) in Program 1.1 given in the Appendix. The numerical results are shown in Table 6.2. (ii) Central difference scheme for diffusion term and upwind difference scheme for convection term For Pe = 500, W and the local Peclet number becomes NQE W Z 2G ' u . Thus b = Peloc + 2 = 12 and g = Peloc + 1 = 11. The solution can be obtained by modifying the parameters ai (i = 2 to N), bi (i = 1 to N) and ci (i = 1 to N – 1) in Program 1.1 given in the Appendix. The numerical results are shown in Table 6.2. Table 6.2 Numerical results for Example 6.2 Node number x (m) C (CDS) C (CDS/UDS) 42 0.84 0.039018 0.000000 43 0.86 –0.058528 0.000000 44 0.88 0.087791 0.000000 45 0.90 –0.131687 0.000006 46 0.92 0.197531 0.000060 47 0.94 –0.296296 0.000751 48 0.96 0.444444 0.008264 49 0.98 –0.666667 0.090909 When the local Peclet number is much below 1, then diffusion is dominant and when the local Peclet number is much above 1, then convection is dominant. When the central difference scheme is used for the discretization of both the diffusion and convection terms, then for all local Peclet number greater than zero, b 0 but a changes sign at Peloc = 2. The subdiagonal elements are negative, diagonals are positive and superdiagonals are negative for Peloc 2, whereas for Peloc 2 the subdiagonals elements are negative, diagonals are positive and superdiagonals are positive. It is seen that when Peloc 2, oscillations occur in the solution of CDS, whereas, when UDS is used for discretization of the convection term, then for all values
  • 424. Convection–Diffusion Problems 113 of Peloc the subdiagonal elements are negative, diagonals are positive and superdiagonals are negative. When first order method (UDS) is used, oscillations do not occur. Note that the sign of subdiagonal, diagonal and superdiagonal elements in UDS match that of CDS for Peloc 2. Thus if oscillations occur when CDS is used, then a larger number of parts can be made so that Dx becomes less and thus Peloc becomes less than 2, or UDS can be used to avoid oscillations. 6.2 Comparison of CDS and UDS The upwind difference scheme at node i is given by [see Eq. (6.1)] 75 K K % %F% FZ Z' (6.1) The right hand side can be written as K K K K K K K K % % % % % % % % Z Z Z Z' ' ' ' § · ¨ ¸ © ¹ (6.5) Thus 75 %5 K K K K % % % %F% F% FZ FZ Z Z' ' § · ¨ ¸ © ¹ (6.6) 75 %5 K K K K % % % %F% F% FZ FZ Z Z' ' § · ¨ ¸ © ¹ (6.7) 75 %5 K K K K % % % %F% F% FZ FZ Z' § · ¨ ¸ © ¹ (6.8) 75 %5 K K K % % %F% F% FZ FZ Z' § · ¨ ¸ © ¹ (6.9) 75 %5 K K K % % %F% F% Z FZ FZ Z ' ' § · ¨ ¸ © ¹ (6.10) 75 %5 F% F% Z F % FZ FZ FZ ' (6.11) Now consider the discretization of the convection–diffusion equation F% F % W FZ FZ Using the UDS for the discretization of the convection term, we get 75 F% F % W FZ FZ (6.12)
  • 425. 114 Introduction to Numerical Methods in Chemical Engineering Substituting Eq. (6.11) in Eq. (6.12), we get %5 F% Z F % F % W FZ FZ FZ '§ · ¨ ¸ ¨ ¸ © ¹ %5 F% W Z F % F % W FZ FZ FZ ' (6.13) Thus UDS is equivalent to adding the additional numerical diffusion (or artificial diffusion) term to the CDS. The effective diffusion coefficient is GHH W Z ' (6.14) and the effective local Peclet number is NQEGHH GHH NQE W Z W Z 2G W Z W Z 2G ' ' ' ' (6.15) Thus due to the addition of the numerical diffusion term, the effective local Peclet number is always less than 2, whatever the value of the local Peclet number and thus oscillations do not occur when first order UDS is used. Exercises 6.1 A component of concentration C is transported by means of convection and diffusion through a one-dimensional space F% F % W FZ FZ The boundary conditions are: at at x = 0 m, C = 1 and at x = 1 m, C = 0. Discretize the convection-diffusion equation using the central difference scheme for both diffusion and convection terms. Calculate the distribution of C as a function of x. Make 10 parts between x = 0 and x = 1 m. Take W m–1 . Compare the numerical result with the analytical solution
  • 426. Z G % Z G § · ¨ ¸ © ¹ . (Ans: The tridiagonal set of equations are % % % % ª ºª º ª º « »« » « » « »« » « » « »« » « » « »« » « » « »« » « » « »« » « »¬ ¼ ¬ ¼¬ ¼
  • 427. Convection–Diffusion Problems 115 and the results are shown in Table 6.3. Table 6.3 Results of Exercise 6.1 x (m) C (numerical – CDS) C (analytical) 0.1 0.999966 0.999922 0.2 0.999865 0.999710 0.3 0.999560 0.999133 0.4 0.998645 0.997567 0.5 0.995902 0.993307 0.6 0.987671 0.981729 0.7 0.962979 0.950256 0.8 0.888904 0.864704 0.9 0.666678 0.632149 6.2 A component of concentration C is transported by means of convection and diffusion through a one-dimensional space F% F % W FZ FZ The boundary conditions are: At x = 0 m, C = 1 and at x = 1 m, C = 0. Discretize the convection-diffusion equation using the central difference scheme for the diffusion term and the first order upwind difference scheme for the convection term. Calculate the distribution of C as a function of x. Make 10 parts between x = 0 and x = 1 m. Take W m–1 . Compare the numerical result with the analytical solution
  • 428. Z G % Z G § · ¨ ¸ © ¹ . (Ans: The tridiagonal set of equations are % % % % ª ºª º ª º « »« » « » « »« » « » « »« » « » « »« » « » « »« » « » « »« » « »¬ ¼ ¬ ¼¬ ¼ and the results are shown in Table 6.4. Table 6.4 Results of Exercise 6.2 x (m) C (numerical – CDS/UDS) C (analytical) 0.1 0.999023 0.999922 0.2 0.997068 0.999710 0.3 0.993157 0.999133 0.4 0.985337 0.997567 0.5 0.969697 0.993307 0.6 0.938417 0.981729 0.7 0.875855 0.950256 0.8 0.750733 0.864704 0.9 0.500489 0.632149
  • 429. 116 Introduction to Numerical Methods in Chemical Engineering Since the first order upwind is used for the discretization of the convection term, therefore more parts are a must for a better answer as the first order method is O(Dx). 6.3 Solve Exercise 6.1 for W m–1 . Compare the numerical result with the analytical solution
  • 430. Z G % Z G § · ¨ ¸ © ¹ . (Ans: The tridiagonal set of equations are % % % % ª ºª º ª º « »« » « » « »« » « » « »« » « » « »« » « » « »« » « » « »« » « »¬ ¼ ¬ ¼¬ ¼ and the results are shown in Table 6.5. Table 6.5 Results of Exercise 6.3 x (m) C (numerical – CDS) C (analytical) 0.1 1.000000 0.999999 0.2 1.000000 0.999999 0.3 1.000000 0.999999 0.4 1.000000 0.999994 0.5 1.000000 0.999955 0.6 1.000000 0.999665 0.7 1.000000 0.997521 0.8 1.000000 0.981684 0.9 1.000000 0.864665 In this problem the local Peclet number is 2.0; therefore central difference gives a wrong answer. 6.4 Solve Exercise 6.2 for W m–1 . Compare the numerical result with the analytical solution
  • 431. Z G % Z G § · ¨ ¸ © ¹ . (Ans: The tridiagonal set of equations are % % % % ª ºª º ª º « »« » « » « »« » « » « »« » « » « »« » « » « »« » « » « »« » « »¬ ¼ ¬ ¼¬ ¼
  • 432. Convection–Diffusion Problems 117 and the results are shown in Table 6.6. Table 6.6 Results of Exercise 6.4 x (m) C (numerical – CDS/UDS) C (analytical) 0.1 0.999966 0.999999 0.2 0.999865 0.999999 0.3 0.999560 0.999999 0.4 0.998645 0.999994 0.5 0.995902 0.999955 0.6 0.987671 0.999665 0.7 0.962979 0.997521 0.8 0.888904 0.981684 0.9 0.666678 0.864665 Since the first order upwind method is used for the discretization of the convection term, therefore more parts are a must for a better answer as the first order method is O(Dx). 6.5 Solve Exercise 6.1 for W m–1 . Compare the numerical result with the analytical solution
  • 433. Z G % Z G § · ¨ ¸ © ¹ . (Ans: The tridiagonal set of equations are % % % % ª ºª º ª º « »« » « » « »« » « » « »« » « » « »« » « » « »« » « » « »« » « »¬ ¼ ¬ ¼¬ ¼ and the results are shown in Table 6.7. Table 6.7 Results of Exercise 6.5 x (m) C (numerical – CDS) C (analytical) 0.1 1.000697 1.000000 0.2 0.999071 1.000000 0.3 1.002865 1.000000 0.4 0.994011 1.000000 0.5 1.014670 1.000000 0.6 0.966466 0.999999 0.7 1.078942 0.999999 0.8 0.816497 0.999955 0.9 1.428870 0.993262
  • 434. 118 Introduction to Numerical Methods in Chemical Engineering In this problem the local Peclet number is greater than 2.0; therefore central difference gives oscillations. 6.6 Solve Exercise 6.2 for W m–1 . Compare the numerical result with the analytical solution
  • 435. Z G % Z G § · ¨ ¸ © ¹ . (Ans: The tridiagonal set of equations are % % % % ª ºª º ª º « »« » « » « »« » « » « »« » « » « »« » « » « »« » « » « »« » « »¬ ¼ ¬ ¼¬ ¼ and the results are shown in Table 6.8. Table 6.8 Results of Exercise 6.6 x (m) C (numerical – CDS/UDS) C (analytical) 0.1 1.000000 1.000000 0.2 1.000000 1.000000 0.3 0.999997 1.000000 0.4 0.999979 1.000000 0.5 0.999872 1.000000 0.6 0.999229 0.999999 0.7 0.995371 0.999999 0.8 0.972223 0.999955 0.9 0.833334 0.993262 Since the first order upwind method is used for the discretization of convection term, therefore more parts are a must for a better answer as the first order method is O(Dx)).
  • 436. 119 Chapter 7 Tubular Reactor with Axial Dispersion Plug flow reactors were discussed in Chapter 4. When axial dispersion takes place in a tubular reactor, then the problem becomes a boundary value problem and the differential equation becomes second order due to the addition of a diffusion term. Thus two conditions are required to completely define the problem. Danckwerts boundary conditions are considered here. One boundary condition is specified at the inlet and one at the exit of the tubular reactor, for each species. The solution of various single, series and parallel reactions are discussed using the finite difference method in this chapter. 7.1 Boundary Value Problems in Chemical Reaction Engineering In tubular reactor with axial dispersion the boundary conditions are specified. The boundary conditions and ordinary differential equations for the tubular reactor with axial dispersion are shown in Table 7.1. Table 7.1 Boundary conditions and ODEs for tubular reactor with axial dispersion Boundary condition Boundary condition ODEs for plug at x = 0 at x = L flow reactor M # $o # # KP # $ $ KP $ F% W% W% FZ F% W% W% FZ # $ F% FZ F% FZ # # # $ $ # F % F% W M % FZ FZ F % F% W M % FZ FZ M M # $ %o o # # KP # $ $ KP $ % % KP % F% W% W% FZ F% W% W% FZ F% W% W% FZ # $ % F% FZ F% FZ F% FZ # # # $ $ # $ % % $ F % F% W M % FZ FZ F % F% W M % M % FZ FZ F % F% W M % FZ FZ M M # $ % $ % o o
  • 437. 120 Introduction to Numerical Methods in Chemical Engineering KP KP KP KP # # # $ $ $ % % % F% W% W% FZ F% W% W% FZ F% W% W% FZ F% W% W% FZ # $ % F% FZ F% FZ F% FZ F% FZ # # # $ $ $ # $ $ % % % # $ $ % $ % F % F% W M % % FZFZ F % F% W M % % M % % FZFZ F % F% W M % % M % % FZFZ F % F% W M % % FZFZ 7.2 First Order Reaction Consider a tubular vessel in which axial dispersion occurs along with convection. The velocity of the fluid is u, the axial dispersion coefficient is D, the concentration of species is C and A is the cross-sectional area. Consider a differential section in this vessel (see Fig. 7.1). Fig. 7.1 Tubular reactor and differential section. In this differential section the material entering through convection = uCA (7.1) that entering through dispersion = F% # FZ (7.2) that leaving through convection = F% W % FZ # FZ § · ¨ ¸ © ¹ (7.3) and that leaving through dispersion = F% F F% FZ # FZ FZ FZ ª º§ · ¨ ¸« » © ¹¬ ¼ (7.4) Accumulation = F% #FZ FV (7.5) dx Table 7.1 (Cont.)
  • 438. Tubular Reactor with Axial Dispersion 121 We know that Input – Output = Accumulation. Thus F% F% F% F% F F% #FZ W%# # W % FZ # FZ # FV FZ FZ FZ FZ FZ ª º§ · § · ˜ ¨ ¸ ¨ ¸« » © ¹ © ¹¬ ¼ (7.6) F% F% F F% FZ W FZ FZ FV FZ FZ FZ § · ¨ ¸ © ¹ (7.7) F% F % F% W FV FZFZ (7.8) At steady state and if reaction also occurs in the tubular vessel, we get
  • 439. F % F% W T FZFZ (7.9) C now refers to the concentration of the reactant or product. –r is a net positive quantity if C refers to a reactant and negative if C refers to a product. Use of a dispersion model changes the reactor analysis from an initial value problem to a boundary value problem. The boundary conditions proposed by Danckwerts are At inlet: KP F% W% W% FZ (7.10) At exit: F% FZ (7.11) At the reactor inlet, the flux entering is uCin but once inside the reactor and in the presence of dispersion, the flux is F% W% FZ Balancing these two fluxes at x = 0 yields the inlet boundary condition KP F% W% W% FZ If the reaction stops once the stream leaves the reactor, the concentration profile becomes uniform, and the outlet boundary condition becomes F% FZ . EXAMPLE 7.1 Consider a reaction A ® B carried out in a tubular reactor. The differential equation for species A along the length of the tubular reactor of length 10 m is # # # F % F% W M% FZFZ
  • 440. 122 Introduction to Numerical Methods in Chemical Engineering The boundary conditions are At x = 0 (inlet): KP # # # F% W% W% FZ At x = 10 m (exit): #F% FZ A fluid medium comprising initially only A flows through the reactor with a mean axial velocity u = 1 m/s. The axial dispersion coefficient, D = 10–4 m2 /s and rate constant of the reaction is 1 s–1 . The inlet concentration, CA,in = 1 mol/m3 . Make 50, 20, and 10 parts of the reactor and determine the concentration of A at various nodes along the length of the tubular reactor. Solution We have Concentration profile for 50 parts 50 parts of the reactor are made as shown in Fig. 7.2. ZÂ1Â ZÂ1Â Fig. 7.2 Example 7.1. Z' m We solve the differential equation using upwind difference scheme for convection term. Discretizing the differential equation at node i, we get #K #K #K #K #K #K % % % % % W M % ZZ '' § · § · ¨ ¸ ¨ ¸ © ¹ © ¹ At node 1 # # # # # # % % % % % W M % ZZ '' § · § · ¨ ¸ ¨ ¸ © ¹ © ¹ # # # W W % M % % Z ZZ Z Z' '' ' ' § · § · ¨ ¸ ¨ ¸ © ¹ © ¹ From the boundary condition at node 1, we get KP # # # # % % W% W% Z' § · ¨ ¸ © ¹
  • 441. Tubular Reactor with Axial Dispersion 123 Solving for CA0 we get
  • 442. KP # # # # W Z % % % % ' Substituting for CA0 in the equation for node 1, we get
  • 443. KP # # # # # W W W Z % M % % % % Z Z Z Z Z ' ' '' ' ' § · § ·ª º ¨ ¸ ¨ ¸« » © ¹ © ¹¬ ¼ KP # # # W W W W W M % % % Z Z ZZ Z' ' '' ' § · § ·§ · ¨ ¸ ¨ ¸¨ ¸¨ ¸ ¨ ¸© ¹© ¹ © ¹ At node 2 # # # W W % M % % Z ZZ Z Z' '' ' ' § · § · ¨ ¸ ¨ ¸ © ¹ © ¹ At node 3 # # # W W % M % % Z ZZ Z Z' '' ' ' § · § · ¨ ¸ ¨ ¸ © ¹ © ¹ At node 51 # # # W W % M % % Z ZZ Z Z' '' ' ' § · § · ¨ ¸ ¨ ¸ © ¹ © ¹ From the boundary condition at node 51, we get # #% % Z' § · ¨ ¸ © ¹ thus CA52 = CA50 Substituting for CA52 in the equation for node 51, we get # # W W % M % Z ZZ Z' '' ' § · § · ¨ ¸ ¨ ¸ © ¹ © ¹ The coefficients of equation 1 (at node 1) are Coefficient of # W W % M Z Z '' u Coefficient of # W % ZZ '' u Right hand side of equation 1 = KP # W W % Z' § · ¨ ¸¨ ¸ © ¹
  • 444. 124 Introduction to Numerical Methods in Chemical Engineering The coefficients of equation 2 (at node 2) are Coefficient of # W % ZZ '' Coefficient of # W % M ZZ '' u Coefficient of # % Z' Right hand side of equation 2 = 0. The coefficients of equation 3 (at node 3) are Coefficient of # W % ZZ '' Coefficient of # W % M ZZ '' u Coefficient of # % Z' Right hand side of equation 3 = 0. The coefficients of equation 51 (at node 51) are Coefficient of # W % ZZ '' u Coefficient of # W % M ZZ '' u Right hand side of equation 51 = 0. The above equations can be written in tridiagonal form as given below. The solution can be obtained by modifying the parameters ai (i = 2 to N), bi (i = 1 to N) and ci (i = 1 to N – 1) in Program 1.1 given in the Appendix. # # # # % % % % ª ºª º ª º « »« » « » « »« » « » « »« » « » « »« » « » « »« » « » « »« » « »¬ ¼ ¬ ¼¬ ¼
  • 445. Tubular Reactor with Axial Dispersion 125 The solution using TDMA is presented in Table 7.2. Table 7.2 Results for concentration profile for 50 parts Node number x (m) CA 1 0.0 0.999908 2 0.2 0.833268 3 0.4 0.694400 4 0.6 0.578675 5 0.8 0.482236 6 1.0 0.401869 7 1.2 0.334895 8 1.4 0.279083 9 1.6 0.232573 10 1.8 0.193813 11 2.0 0.161513 12 2.2 0.134596 13 2.4 0.112165 14 2.6 0.093472 15 2.8 0.077895 16 3.0 0.064913 17 3.2 0.054095 18 3.4 0.045080 19 3.6 0.037567 20 3.8 0.031306 21 4.0 0.026089 22 4.2 0.021741 23 4.4 0.018118 51 10.0 0.000110 More conversion would have occurred if the reactor is assumed to be ideal plug flow. Concentration profile for 20 parts If 20 parts of the reactor are made, then Z' m. The coefficients of the 21 equations at 21 nodes are as given below. The coefficients of equation 1 (at node 1) are Coefficient of # W W % M Z Z '' u Coefficient of # W % ZZ '' u Right hand side of equation 1 = KP # W W % Z' § · ¨ ¸¨ ¸ © ¹
  • 446. 126 Introduction to Numerical Methods in Chemical Engineering The coefficients of equation 2 (at node 2) are Coefficient of # W % ZZ '' Coefficient of # W % M ZZ '' u Coefficient of # % Z' Right hand side of equation 2 = 0. The coefficients of equation 3 (at node 3) are Coefficient of # W % ZZ '' Coefficient of # W % M ZZ '' u Coefficient of # % Z' Right hand side of equation 3 = 0. The coefficients of equation 21 (at node 21) are Coefficient of # W % ZZ '' u Coefficient of # W % M ZZ '' u Right hand side of equation 21 = 0. The above equations can be written in tridiagonal form as given below: # # # # % % % % ª ºª º ª º « »« » « » « »« » « » « »« » « » « »« » « » « »« » « » « »« » « »¬ ¼ ¬ ¼¬ ¼ The solution can be obtained by modifying the parameters ai (i = 2 to N), bi (i = 1 to N) and ci (i = 1 to N – 1) in Program 1.1 given in the Appendix. The results are presented in Table 7.3.
  • 447. Tubular Reactor with Axial Dispersion 127 Table 7.3 Results for concentration profile for 20 parts Node number x (m) CA 1 0.0 0.999917 3 1.0 0.444400 5 2.0 0.197500 7 3.0 0.087800 9 4.0 0.039000 11 5.0 0.017300 13 6.0 0.007700 15 7.0 0.003400 17 8.0 0.001500 19 9.0 0.000677 21 10.0 0.000301 Concentration profile for 10 parts If 10 parts of the reactor are made, then Z' m. The coefficients of the 11 equations at 11 nodes are as given below. The coefficients of equation 1 (at node 1) are Coefficient of # W W % M Z Z '' u Coefficient of # W % ZZ '' u Right hand side of equation 1 = KP # W W % Z' § · ¨ ¸¨ ¸ © ¹ The coefficients of equation 2 (at node 2) are Coefficient of # W % ZZ '' Coefficient of # W % M ZZ '' u Coefficient of # % Z' Right hand side of equation 2 = 0. The coefficients of equation 3 (at node 3) are Coefficient of # W % ZZ ''
  • 448. 128 Introduction to Numerical Methods in Chemical Engineering Coefficient of # W % M ZZ '' u Coefficient of # % Z' Right hand side of equation 3 = 0. The coefficients of equation 11 (at node 11) are Coefficient of # W % ZZ '' u Coefficient of # W % M ZZ '' u Right hand side of equation 11 = 0. The above equations can be written in tridiagonal form as given below. # # # # % % % % ª ºª º ª º « »« » « » « »« » « » « »« » « » « »« » « » « »« » « » « »« » « »¬ ¼ ¬ ¼¬ ¼ The solution can be obtained by modifying the parameters ai (i = 2 to N), bi (i = 1 to N) and ci (i = 1 to N – 1) in Program 1.1 given in the Appendix. The results are presented in Table 7.4. Table 7.4 Results for concentration profile for 10 parts Node number x (m) CA 1 0.0 0.999925 2 1.0 0.499975 3 2.0 0.249994 4 3.0 0.125000 5 4.0 0.062502 6 5.0 0.031252 7 6.0 0.015626 8 7.0 0.007813 9 8.0 0.003907 10 9.0 0.001953 11 10.0 0.000977
  • 449. Tubular Reactor with Axial Dispersion 129 7.3 Second Order Reaction Consider a tubular reactor with axial dispersion in which second order reaction takes place. The analysis is described with an example. EXAMPLE 7.2 Consider a reaction A ® B carried out in a tubular reactor. The differential equation for species A along the length of the tubular reactor of length 10 m is # # # F % F% W M% FZFZ The boundary conditions are At x = 0 (inlet): KP # # # F% W% W% FZ At x = 10 m (exit): #F% FZ A fluid medium comprising initially only A flows through the reactor with a mean axial velocity u = 1 m/s. The axial dispersion coefficient, D = 10–4 m2 /s and rate constant of the reaction is 1 m3 /mol-s. The inlet concentration CA,in =1 mol/m3 . Make 20 parts of the reactor and determine the concentration of A at various nodes along the length of the tubular reactor. Solution Since 20 parts of the reactor are made, Z' m. The coefficients of the 21 equations at 21 nodes are as given below. The coefficients of equation 1 (at node 1) are Coefficient of # # # # W W % M % Z Z % % '' u Coefficient of # W % ZZ '' u Right hand side of equation 1 = KP # W W % Z' § · ¨ ¸¨ ¸ © ¹ The coefficients of equation 2 (at node 2) are Coefficient of # W % ZZ ''
  • 450. 130 Introduction to Numerical Methods in Chemical Engineering Coefficient of # # # # W % M % % % ZZ '' u Coefficient of # % Z' Right hand side of equation 2 = 0. The coefficients of equation 3 (at node 3) are Coefficient of # W % ZZ '' Coefficient of # # # # W % M % % % ZZ '' u Coefficient of # % Z' Right hand side of equation 3 = 0. The coefficients of equation 21 (at node 21) are Coefficient of # W % ZZ '' u Coefficient of # # # # W % M % % % ZZ '' u Right hand side of equation 21 = 0. The above equations can be written in tridiagonal form as given below. % %# # % %# # % %# # % %# # ª º ª º ª º « » « » « » « » « » « » « » « » « » « » « » « » « » « » « » « » « » « »¬ ¼¬ ¼ ¬ ¼ Program 7.1 for the solution of the above problem is given in the Appendix. In the program the initial values of concentration of A at nodes 1 to 21 is assumed and then the TDMA is used to determine new values of concentration of A at nodes 1 to 21. Again, these values are used to determine the coefficients in the matrix, and after the coefficients are determined the TDMA is used to determine new values of concentration of A at nodes 1 to 21. The procedure is repeated till there is no change in the concentration at each node. The results are presented in Table 7.5.
  • 451. Tubular Reactor with Axial Dispersion 131 Table 7.5 Results in Example 7.2 Node number x (m) CA 1 0.0 0.999923 3 1.0 0.569732 5 2.0 0.387587 7 3.0 0.290241 9 4.0 0.230588 11 5.0 0.190624 13 6.0 0.162124 15 7.0 0.140841 17 8.0 0.124379 19 9.0 0.111286 21 10.0 0.100638 7.4 Multiple Reactions Consider a tubular reactor with axial dispersion in which multiple reactions takes place. The analysis is described with an example. EXAMPLE 7.3 Consider the following two reactions taking place in a tubular reactor with axial dispersion: M # $ % o M $ % o Assuming the axial dispersion coefficient to be the same for all the species, the concentration of various species along the length of the reactor are given by the following differential equations: for component A # # # $ F % F% W M % % FZFZ for component B $ $ # $ $ % F % F% W M % % M % % FZFZ for component C % % # $ $ % F % F% W M % % M % % FZFZ for component D $ % F % F% W M % % FZFZ
  • 452. 132 Introduction to Numerical Methods in Chemical Engineering The boundary conditions are KP # # # F% W% W% FZ KP $ $ $ F% W% W% FZ At inlet: KP % % % F% W% W% FZ KP F% W% W% FZ At exit: CPF %# $ F%F% F% F% FZ FZ FZ FZ Make 20 parts of the reactor of length 10 m. A fluid medium comprising initially only A and B flows through the reactor with a mean axial velocity u = 1 m/s. The axial dispersion coefficient is the same for all the species, D = 10–4 m2 /s, and the rate constants of the reactions are k1 = k2 = 1 m3 /mol-s. The inlet concentrations of A and B are CA,in = CB,in = 1 mol/m3 . Compute the concentration of various species along the length of the reactor. Solution We have Z' m We solve the differential equation using the upwind difference scheme for the convection term. Discretizing the differential equation at node i, we get for species A #K #K #K #K #K #K $K % % % % % W M % % ZZ '' § · § · ¨ ¸ ¨ ¸ © ¹ © ¹ for species B $K $K $K $K $K #K $K $K %K % % % % % W M % % M % % ZZ '' § · § · ¨ ¸ ¨ ¸ © ¹ © ¹ for species C %K %K %K %K %K #K $K $K %K % % % % % W M % % M % % ZZ '' § · § · ¨ ¸ ¨ ¸ © ¹ © ¹ for species D K K K K K $K %K % % % % % W M % % ZZ '' § · § · ¨ ¸ ¨ ¸ © ¹ © ¹
  • 453. Tubular Reactor with Axial Dispersion 133 At node 1 the discretized equation for the component A is # # # # # # $ % % % % % W M % % ZZ '' § · § · ¨ ¸ ¨ ¸ © ¹ © ¹ # $ # # W W % M % % % Z ZZ Z Z' '' ' ' § · § · ¨ ¸ ¨ ¸ © ¹ © ¹ From the boundary condition at node 1, we get KP # # # # % % W% W% Z' § · ¨ ¸ © ¹ Solving for CA0, we get
  • 454. KP # # # # W Z % % % % ' Substituting for CA0 in the equation for node 1, we get
  • 455. KP # $ # # # # W W W Z % M % % % % % Z Z Z Z Z ' ' '' ' ' § · § ·ª º ¨ ¸ ¨ ¸« » © ¹ © ¹¬ ¼ KP $ # # # W W W W W M % % % % Z Z ZZ Z' ' '' ' § · § ·§ · ¨ ¸ ¨ ¸¨ ¸¨ ¸ ¨ ¸© ¹© ¹ © ¹ At node 1 the discretized equation for component B is $ $ $ $ $ # $ $ % % % % % % W M % % M % % ZZ '' § · § · ¨ ¸ ¨ ¸ © ¹ © ¹ $ # % $ $ W W % M % M % % % Z ZZ Z Z' '' ' ' § · § · ¨ ¸ ¨ ¸ © ¹ © ¹ From the boundary condition at node 1, we get KP $ $ $ $ % % W% W% Z' § · ¨ ¸ © ¹ Solving for CB0, we get
  • 456. KP $ $ $ $ W Z % % % % ' Substituting for CB0 in the equation for node 1, we get
  • 457. KP $ # % $ $ $ $ W W W Z % M % M % % % % % Z Z Z Z Z ' ' '' ' ' § · § · ª º ¨ ¸ ¨ ¸ « » © ¹ © ¹ ¬ ¼ KP # % $ $ $ W W W W W M % M % % % % Z Z ZZ Z' ' '' ' § · § ·§ · ¨ ¸ ¨ ¸¨ ¸¨ ¸ ¨ ¸© ¹© ¹ © ¹
  • 458. 134 Introduction to Numerical Methods in Chemical Engineering At node 1 the discretized equation for component C is % % % % % # $ $ % % % % % % W M % % M % % ZZ '' § · § · ¨ ¸ ¨ ¸ © ¹ © ¹ % $ % % # $ W W % M % % % M % % Z ZZ Z Z' '' ' ' § · § · ¨ ¸ ¨ ¸ © ¹ © ¹ From the boundary condition at node 1, we get % % % % % W% Z' § · ¨ ¸ © ¹ Solving for CC0, we get % % % W Z% % % ' Substituting for CC0, in the equation for node 1, we get % % $ % % # $ W Z% W W % M % % % M % % Z Z Z Z Z ' ' '' ' ' § ·§ · § · ¨ ¸ ¨ ¸¨ ¸ © ¹ © ¹© ¹ $ % % # $ W W W M % % % M % % Z ZZ Z' '' ' § · § · ¨ ¸ ¨ ¸¨ ¸ © ¹© ¹ At node 1 the discretized equation for component D is $ % % % % % % W M % % ZZ '' § · § · ¨ ¸ ¨ ¸ © ¹ © ¹ $ % W W % % % M % % Z ZZ Z Z' '' ' ' § · § · ¨ ¸ ¨ ¸ © ¹ © ¹ From the boundary condition at node 1, we get % % W% Z' § · ¨ ¸ © ¹ Solving for CD0, we get W Z% % % ' Substituting for CD0, in the equation for node 1, we get $ % W Z% W W % % % M % % Z Z Z Z Z ' ' '' ' ' § ·§ · § · ¨ ¸ ¨ ¸¨ ¸ © ¹ © ¹© ¹ $ % W W W % % M % % Z ZZ Z' '' ' § · § · ¨ ¸ ¨ ¸¨ ¸ © ¹© ¹
  • 459. Tubular Reactor with Axial Dispersion 135 At node 2 the discretized equations for various components are # $ # # W W % M % % % Z ZZ Z Z' '' ' ' § · § · ¨ ¸ ¨ ¸ © ¹ © ¹ $ # % $ $ W W % M % M % % % Z ZZ Z Z' '' ' ' § · § · ¨ ¸ ¨ ¸ © ¹ © ¹ % $ % % # $ W W % M % % % M % % Z ZZ Z Z' '' ' ' § · § · ¨ ¸ ¨ ¸ © ¹ © ¹ $ % W W % % % M % % Z ZZ Z Z' '' ' ' § · § · ¨ ¸ ¨ ¸ © ¹ © ¹ At node 21 the discretized equation for component A is # $ # # W W % M % % % Z ZZ Z Z' '' ' ' § · § · ¨ ¸ ¨ ¸ © ¹ © ¹ From the boundary condition at node 21, we get # #% % Z' § · ¨ ¸ © ¹ thus CA22 = CA20 Substituting for CA22 in the equation for node 21, we get # $ # W W % M % % Z ZZ Z' '' ' § · § · ¨ ¸ ¨ ¸ © ¹ © ¹ At node 21 the discretized equation for component B is $ # % $ $ W W % M % M % % % Z ZZ Z Z' '' ' ' § · § · ¨ ¸ ¨ ¸ © ¹ © ¹ From the boundary condition at node 21, we get $ $% % Z' § · ¨ ¸ © ¹ thus CB22 = CB20 Substituting for CB22 in the equation for node 21, we get $ # % $ W W % M % M % % Z ZZ Z' '' ' § · § · ¨ ¸ ¨ ¸ © ¹ © ¹ At node 21 the discretized equation for component C is % $ % % # $ W W % M % % % M % % Z ZZ Z Z' '' ' ' § · § · ¨ ¸ ¨ ¸ © ¹ © ¹ From the boundary condition at node 21, we get % %% % Z' § · ¨ ¸ © ¹ thus CC22 = CC20
  • 460. 136 Introduction to Numerical Methods in Chemical Engineering Substituting for CC22 in the equation for node 21, we get % $ % # $ W W % M % % M % % Z ZZ Z' '' ' § · § · ¨ ¸ ¨ ¸ © ¹ © ¹ At node 21 the discretized equation for component D is $ % W W % % % M % % Z ZZ Z Z' '' ' ' § · § · ¨ ¸ ¨ ¸ © ¹ © ¹ From the boundary condition at node 21, we get % % Z' § · ¨ ¸ © ¹ thus CD22 = CD20 Substituting for 22DC in the equation for node 21, we get $ % W W % % M % % Z ZZ Z' '' ' § · § · ¨ ¸ ¨ ¸ © ¹ © ¹ The coefficients of equation 1 (node 1, species A) are Coefficient of # $ $% % % u Coefficient of CB1 = 0 Coefficient of CC1 = 0 Coefficient of CD1 = 0 Coefficient of #% u Coefficient of CB2 = 0 Coefficient of CC2 = 0 Coefficient of CD2 = 0 Right hand side of equation 1 = KP # W W % Z' § · ¨ ¸¨ ¸ © ¹ The coefficients of equation 2 (node 1, species B) are Coefficient of CA1 = 0 Coefficient of CB1 = # % # %% % % % u Coefficient of CC1 = 0 Coefficient of CD1 = 0 Coefficient of CA2 = 0
  • 461. Tubular Reactor with Axial Dispersion 137 Coefficient of $% u Coefficient of CC2 = 0 Coefficient of CD2 = 0 Right hand side of equation 2 = KP $ W W % Z' § · ¨ ¸¨ ¸ © ¹ The coefficients of equation 3 (node 1, species C) are: Coefficient of CA1 = 0 Coefficient of CB1 = 0 Coefficient of CC1 = $ $% % u Coefficient of CD1 = 0 Coefficient of CA2 = 0 Coefficient of CB2 = 0 Coefficient of CC2 = u Coefficient of CD2 = 0 Right hand side of equation 3 = –CA1CB1. The coefficients of equation 4 (node 1, species D) are: Coefficient of CA1 = 0 Coefficient of CB1 = 0 Coefficient of CC1 = 0 Coefficient of % u Coefficient of CA2 = 0 Coefficient of CB2 = 0 Coefficient of CC2 = 0 Coefficient of % u Right hand side of equation 4 = –CB1CC1. The coefficients of equation 5 (node 2, species A) are: Coefficient of #%
  • 462. 138 Introduction to Numerical Methods in Chemical Engineering Coefficient of CB1 = 0 Coefficient of CC1 = 0 Coefficient of CD1 = 0 Coefficient of # $ $% % % u Coefficient of CB2 = 0 Coefficient of CC2 = 0 Coefficient of CD2 = 0 Coefficient of #% Coefficient of CB3 = 0 Coefficient of CC3 = 0 Coefficient of CD3 = 0 Right hand side of equation 5 = 0. The coefficients of equation 6 (node 2, species B) are: Coefficient of CA1 = 0 Coefficient of $% Coefficient of CC1 = 0 Coefficient of CD1 = 0 Coefficient of CA2 = 0 Coefficient of $ # % # %% % % % % u Coefficient of CC2 = 0 Coefficient of CD2 = 0 Coefficient of CA3 = 0 Coefficient of $% Coefficient of CC3 = 0 Coefficient of CD3 = 0 Right hand side of equation 6 = 0. The coefficients of equation 7 (node 2, species C) are: Coefficient of CA1 = 0 Coefficient of CB1 = 0 Coefficient of %%
  • 463. Tubular Reactor with Axial Dispersion 139 Coefficient of CD1 = 0 Coefficient of CA2 = 0 Coefficient of CB2 = 0 Coefficient of % $ $% % % u Coefficient of CD2 = 0 Coefficient of CA3 = 0 Coefficient of CB3 = 0 Coefficient of %% Coefficient of CD3 = 0 Right hand side of equation 7 = –CA2CB2 The coefficients of equation 8 (node 2, species D) are: Coefficient of CA1 = 0 Coefficient of CB1 = 0 Coefficient of CC1 = 0 Coefficient of % Coefficient of CA2 = 0 Coefficient of CB2 = 0 Coefficient of CC2 = 0 Coefficient of % u Coefficient of CA3 = 0 Coefficient of CB3 = 0 Coefficient of CC3 = 0 Coefficient of % Right hand side of equation 8 = –CB2CC2. The coefficients of equation 81 (node 21, species A) are: Coefficient of #% u Coefficient of CB20 = 0 Coefficient of CC20 = 0 Coefficient of CD20 = 0
  • 464. 140 Introduction to Numerical Methods in Chemical Engineering Coefficient of # $ $% % % u Coefficient of CB21 = 0 Coefficient of CC21 = 0 Coefficient of CD21 = 0 Right hand side of equation 81 = 0. The coefficients of equation 82 (node 21, species B) are: Coefficient of CA20 = 0 Coefficient of $% u Coefficient of CC20 = 0 Coefficient of CD20 = 0 Coefficient of CA21 = 0 Coefficient of $ # % # %% % % % % u Coefficient of CC21 = 0 Coefficient of CD21 = 0 Right hand side of equation 82 = 0. The coefficients of equation 83 (node 21, species C) are: Coefficient of CA20 = 0 Coefficient of CB20 = 0 Coefficient of %% u Coefficient of CD20 = 0 Coefficient of CA21 = 0 Coefficient of CB21 = 0 Coefficient of % $ $% % % u Coefficient of CD21 = 0 Right hand side of equation 83 = –CA21CB21. The coefficients of equation 84 (node 21, species D) are: Coefficient of CA20 = 0 Coefficient of CB20 = 0 Coefficient of CC20 = 0
  • 465. Tubular Reactor with Axial Dispersion 141 Coefficient of % u Coefficient of CA21 = 0 Coefficient of CB21 = 0 Coefficient of CC21 = 0 Coefficient of % u Right hand side of equation 84 = –CB21CC21. Thus the set of equations for concentration of species A, B, C, and D at nodes 1 to 21 can be written in the block tridiagonal form as $ % : # $ % : # $ % : # $ % : # $ % : # $ % : # $ % : # $ : ª º ª º « » « » « » « » « » « » « » « » « » « » « » « » « » « » « » « » « » « » « » « » « » « » « » « » « » « » « » « » « » « » « » « » « » « »« » « »¬ ¼ ¬ ¼ ª º « » « » « » « » « » « » « » « » « » « » « » « » « » « » « » « » « »« »¬ ¼ where # $ % % % : % % ª º « » « » « » « » « »¬ ¼ # $ % % % : % % ª º « » « » « » « » « »¬ ¼ # $ % % % : % % ª º « » « » « » « » « »¬ ¼ For node 1 $ # % $ % % % $ % ª º « » « » « » « » « »¬ ¼
  • 466. 142 Introduction to Numerical Methods in Chemical Engineering % ª º « » « » « » « » « »¬ ¼ # $ $ % % % % % ª º « »« » « » « » « »¬ ¼ For node 2 # ª º « » « » « » « » « »¬ ¼ $ # % $ % % % $ % ª º « » « » « » « » « »¬ ¼ % ª º « » « » « » « » « »¬ ¼ # $ $ % % % % % ª º « » « » « » « » « »¬ ¼ For node 3 # ª º « » « » « » « » « »¬ ¼ $ # % $ % % % $ % ª º « » « » « » « » « »¬ ¼
  • 467. Tubular Reactor with Axial Dispersion 143 % ª º « » « » « » « » « »¬ ¼ # $ $ % % % % % ª º « » « » « » « » « »¬ ¼ For node 21 # ª º « » « » « » « » « »¬ ¼ $ # % $ % % % $ % ª º « » « » « » « » « »¬ ¼ # $ $ % % % % % ª º « » « » « » « » « »¬ ¼ The 84 linear algebraic equations can be written in the form Ax = d, where A is a 84 ´ 84 matrix, x is the vector of size 84 ´ 1 containing the variables to be determined, and d is also a vector of size 84 ´ 1. The variables can be written as @ 6 # $ % # $ % Z % % % % % % % % The Gauss elimination method can be used to solve these 84 linear algebraic equations. The non-zero elements of the matrix A are A(1,1) = –20005.9992–CB1, A(1,5) = 2.0008, A(2,2) = –20005.9992–CA1–CC1, A(2,6) = 2.0008 A(3,3) = –20005.9992–CB1, A(3,7) = 2.0008, A(4,4) = –20005.9992, A(4,8) = 2.0008, A(5,1) = 2.0004, A(5,5) = –2.0008–CB2, A(5,9) = 0.0004, A(6,2) = 2.0004, A(6,6) = –2.0008–CA2–CC2, A(6,10) = 0.0004, A(7,3) = 2.0004, A(7,7) = –2.0008–CB2, A(7,11) = 0.0004, A(8,4) = 2.0004, A(8,8) = –2.0008, A(8,12) = 0.0004, A(9,5) = 2.0004, A(9,9) = –2.0008–CB3, A(9,13) = 0.0004, A(10,6) = 2.0004, A(10,10) = –2.0008–CA3–CC3, A(10,14) = 0.0004, A(11,7) = 2.0004, A(11,11) = –2.0008–CB3, A(11,15) = 0.0004, A(12,8) = 2.0004, A(12,12) = –2.0008, A(12,16) = 0.0004, A(13,9) = 2.0004, A(13,13) = –2.0008–CB4, A(13,17) = 0.0004, A(14,10) = 2.0004, A(14,14) = –2.0008–CA4–CC4, A(14,18) = 0.0004, A(15,11) = 2.0004, A(15,15) = –2.0008–CB4, A(15,19) = 0.0004, A(16,12) = 2.0004, A(16,16) = –2.0008, A(16,20) = 0.0004, A(17,13) =
  • 468. 144 Introduction to Numerical Methods in Chemical Engineering 2.0004, A(17,17) = –2.0008–CB5, A(17,21) = 0.0004, A(18,14) = 2.0004, A(18,18) = –2.0008– CA5–CC5, A(18,22) = 0.0004, A(19,15) = 2.0004, A(19,19) = –2.0008–CB5, A(19,23) = 0.0004, A(20,16) = 2.0004, A(20,20) = –2.0008, A(20,24) = 0.0004, A(21,17) = 2.0004, A(21,21) = –2.0008–CB6, A(21,25) = 0.0004, A(22,18) = 2.0004, A(22,22) = –2.0008–CA6–CC6, A(22,26) = 0.0004, A(23,19) = 2.0004, A(23,23) = –2.0008–CB6, A(23,27) = 0.0004, A(24,20) = 2.0004, A(24,24) = –2.0008, A(24,28) = 0.0004, A(25,21) = 2.0004, A(25,25) = –2.0008–CB7, A(25,29) = 0.0004, A(26,22) = 2.0004, A(26,26) = –2.0008–CA7–CC7, A(26,30) = 0.0004, A(27,23) = 2.0004, A(27,27) = –2.0008–CB7, A(27,31) = 0.0004, A(28,24) = 2.0004, A(28,28) = –2.0008, A(28,32) = 0.0004, A(29,25) = 2.0004, A(29,29) = –2.0008–CB8, A(29,33) = 0.0004, A(30,26) = 2.0004, A(30,30) = –2.0008–CA8–CC8, A(30,34) = 0.0004, A(31,27) = 2.0004, A(31,31) = –2.0008–CB8, A(31,35) = 0.0004, A(32,28) = 2.0004, A(32,32) = –2.0008, A(32,36) = 0.0004, A(33,29) = 2.0004, A(33,33) = –2.0008–CB9, A(33,37) = 0.0004, A(34,30) = 2.0004, A(34,34) = –2.0008–CA9–CC9, A(34,38) = 0.0004, A(35,31) = 2.0004, A(35,35) = –2.0008–CB9, A(35,39) = 0.0004, A(36,32) = 2.0004, A(36,36) = –2.0008, A(36,40) = 0.0004, A(37,33) = 2.0004, A(37,37) = –2.0008–CB10, A(37,41) = 0.0004, A(38,34) = 2.0004, A(38,38) = –2.0008–CA10– CC10, A(38,42) = 0.0004, A(39,35) = 2.0004, A(39,39) = –2.0008–CB10, A(39,43) = 0.0004, A(40,36) = 2.0004, A(40,40) = –2.0008, A(40,44) = 0.0004, A(41,37) = 2.0004, A(41,41) = –2.0008–CB11, A(41,45) = 0.0004, A(42,38) = 2.0004, A(42,42) = –2.0008–CA11–CC11, A(42,46) = 0.0004, A(43,39) = 2.0004, A(43,43) = –2.0008–CB11, A(43,47) = 0.0004, A(44,40) = 2.0004, A(44,44) = –2.0008, A(44,48) = 0.0004, A(45,41) = 2.0004, A(45,45) = –2.0008–CB12, A(45,49) = 0.0004, A(46,42) = 2.0004, A(46,46) = –2.0008–CA12–CC12, A(46,50) = 0.0004, A(47,43) = 2.0004, A(47,47) = –2.0008–CB12, A(47,51) = 0.0004, A(48,44) = 2.0004, A(48,48) = –2.0008, A(48,52) = 0.0004, A(49,45) = 2.0004, A(49,49) = –2.0008–CB13, A(49,53) = 0.0004, A(50,46) = 2.0004, A(50,50) = –2.0008–CA13–CC13, A(50,54) = 0.0004, A(51,47) = 2.0004, A(51,51) = –2.0008–CB13, A(51,55) = 0.0004, A(52,48) = 2.0004, A(52,52) = –2.0008, A(52,56) = 0.0004, A(53,49) = 2.0004, A(53,53) = –2.0008–CB14, A(53,57) = 0.0004, A(54,50) = 2.0004, A(54,54) = –2.0008–CA14–CC14, A(54,58) = 0.0004, A(55,51) = 2.0004, A(55,55) = –2.0008–CB14, A(55,59) = 0.0004, A(56,52) = 2.0004, A(56,56) = –2.0008, A(56,60) = 0.0004, A(57,53) = 2.0004, A(57,57) = –2.0008–CB15, A(57,61) = 0.0004, A(58,54) = 2.0004, A(58,58) = –2.0008– CA15–CC15, A(58,62) = 0.0004, A(59,55) = 2.0004, A(59,59) = –2.0008–CB15, A(59,63) = 0.0004, A(60,56) = 2.0004, A(60,60) = –2.0008, A(60,64) = 0.0004, A(61,57) = 2.0004, A(61,61) = –2.0008–CB16, A(61,65) = 0.0004, A(62,58) = 2.0004, A(62,62) = –2.0008–CA16– CC16, A(62,66) = 0.0004, A(63,59) = 2.0004, A(63,63) = –2.0008–CB16, A(63,67) = 0.0004, A(64,60) = 2.0004, A(64,64) = –2.0008, A(64,68) = 0.0004, A(65,61) = 2.0004, A(65,65) = –2.0008–CB17, A(65,69) = 0.0004, A(66,62) = 2.0004, A(66,66) = –2.0008–CA17–CC17, A(66,70) = 0.0004, A(67,63) = 2.0004, A(67,67) = –2.0008–CB17, A(67,71) = 0.0004, A(68,64) = 2.0004, A(68,68) = –2.0008, A(68,72) = 0.0004, A(69,65) = 2.0004, A(69,69) = –2.0008–CB18, A(69,73) = 0.0004, A(70,66) = 2.0004, A(70,70) = –2.0008–CA18–CC18, A(70,74) = 0.0004, A(71,67) = 2.0004, A(71,71) = –2.0008–CB18, A(71,75) = 0.0004, A(72,68) = 2.0004, A(72,72) = –2.0008, A(72,76) = 0.0004, A(73,69) = 2.0004, A(73,73) = –2.0008–CB19, A(73,77) = 0.0004, A(74,70) = 2.0004, A(74,74) = –2.0008–CA19–CC19, A(74,78) = 0.0004, A(75,71) = 2.0004, A(75,75) = –2.0008–CB19, A(75,79) = 0.0004, A(76,72) = 2.0004, A(76,76) = –2.0008, A(76,80) = 0.0004, A(77,73) = 2.0004, A(77,77) = –2.0008–CB20, A(77,81) = 0.0004, A(78,74) = 2.0004, A(78,78) = –2.0008–CA20–CC20, A(78,82) = 0.0004, A(79,75) = 2.0004, A(79,79) = –2.0008–CB20, A(79,83) = 0.0004, A(80,76) = 2.0004, A(80,80) = –2.0008, A(80,84) = 0.0004, A(81,77) =
  • 469. Tubular Reactor with Axial Dispersion 145 2.0008, A(81,81) = –2.0008–CB21, A(82,78) = 2.0008, A(82,82) = –2.0008–CA21–CC21, A(83,79) = 2.0008, A(83,83) = –2.0008–CB21, A(84,80) = 2.0008, A(84,84) = –2.0008 The nonzero right hand side terms are given in augmented matrix A form as A(1,85) = –20004, A(2,85) = –20004, A(3,85) = –CA1CB1, A(4,85) = –CB1CC1, A(7,85) = –CA2CB2, A(8,85) = –CB2CC2, A(11,85) = –CA3CB3, A(12,85) = –CB3CC3, A(15,85) = –CA4CB4, A(16,85) = –CB4CC4, A(19,85) = –CA5CB5, A(20,85) = –CB5CC5, A(23,85) = –CA6CB6, A(24,85) = –CB6CC6, A(27,85) = –CA7CB7, A(28,85) = –CB7CC7, A(31,85) = –CA8CB8, A(32,85) = –CB8CC8, A(35,85) = –CA9CB9, A(36,85) = –CB9CC9, A(39,85) = –CA10CB10, A(40,85) = –CB10CC10, A(43,85) = –CA11CB11, A(44,85) = –CB11CC11, A(47,85) = –CA12CB12, A(48,85) = –CB12CC12, A(51,85) = –CA13CB13, A(52,85) = –CB13CC13, A(55,85) = –CA14CB14, A(56,85) = –CB14CC14, A(59,85) = –CA15CB15, A(60,85) = –CB15CC15, A(63,85) = –CA16CB16, A(64,85) = –CB16CC16, A(67,85) = –CA17CB17, A(68,85) = –CB17CC17, A(71,85) = –CA18CB18, A(72,85) = –CB18CC18, A(75,85) = –CA19CB19, A(76,85) = –CB19CC19, A(79,85) = –CA20CB20, A(80,85) = –CB20CC20, A(83,85) = –CA21CB21, A(84,85) = –CB21CC21 Program 7.2 for the solution of the above problem is given in the Appendix. The concentration of various species along the length of the reactor is obtained using the Gauss elimination method. The results are shown in Table 7.6. Table 7.6 Results in Example 7.3 Node number x (m) CA CB CC CD 1 0.0 0.999925 0.999918 0.000060 0.000006 2 0.5 0.745869 0.681292 0.189554 0.064577 3 1.0 0.602852 0.474505 0.268800 0.129276 4 1.5 0.516040 0.336482 0.304402 0.181438 5 2.0 0.460355 0.241939 0.321230 0.221265 6 2.5 0.423163 0.175791 0.329465 0.251137 7 3.0 0.397574 0.128732 0.333583 0.273464 8 3.5 0.379579 0.094823 0.335665 0.290175 9 4.0 0.366717 0.070151 0.336717 0.302718 10 4.5 0.357413 0.052067 0.337242 0.312168 11 5.0 0.350622 0.038739 0.337497 0.319310 12 5.5 0.345632 0.028875 0.337612 0.324724 13 6.0 0.341947 0.021552 0.337659 0.328835 14 6.5 0.339216 0.016103 0.337671 0.331960 15 7.0 0.337186 0.012040 0.337668 0.334332 16 7.5 0.335674 0.009008 0.337659 0.336124 17 8.0 0.334547 0.006742 0.337649 0.337466 18 8.5 0.333705 0.005048 0.337639 0.338454 19 9.0 0.333075 0.003780 0.337630 0.339160 20 9.5 0.332604 0.002831 0.337623 0.339638 21 10.0 0.332252 0.002121 0.337617 0.339996 EXAMPLE 7.4 Solve Example 7.3 by making 3 parts of the reactor of length 3 m. Solution Since three parts are made, therefore the total number of nodes is 4. The coefficients of equation 1 (node 1, species A) are:
  • 470. 146 Introduction to Numerical Methods in Chemical Engineering Coefficient of # $ $% % % – Coefficient of CB1 = 0 Coefficient of CC1 = 0 Coefficient of CD1 = 0 Coefficient of #% – Coefficient of CB2 = 0 Coefficient of CC2 = 0 Coefficient of CD2 = 0 Right hand side of equation 1 = KP # W W % Z' § · ¨ ¸¨ ¸ © ¹ The coefficients of equation 2 (node 1, species B) are: Coefficient of CA1 = 0 Coefficient of $ # % # %% % % % % – Coefficient of CC1 = 0 Coefficient of CD1 = 0 Coefficient of CA2 = 0 Coefficient of $% – Coefficient of CC2 = 0 Coefficient of CD2 = 0 Right hand side of equation 2 = KP $ W W % Z' § · ¨ ¸¨ ¸ © ¹ The coefficients of equation 3 (node 1, species C) are: Coefficient of CA1 = 0 Coefficient of CB1 = 0 Coefficient of % $ $% % % – Coefficient of CD1 = 0 Coefficient of CA2 = 0 Coefficient of CB2 = 0
  • 471. Tubular Reactor with Axial Dispersion 147 Coefficient of %% – Coefficient of CD2 = 0 Right hand side of equation 3 = –CA1CB1 The coefficients of equation 4 (node 1, species D) are: Coefficient of CA1 = 0 Coefficient of CB1 = 0 Coefficient of CC1 = 0 Coefficient of % – Coefficient of CA2 = 0 Coefficient of CB2 = 0 Coefficient of CC2 = 0 Coefficient of % – Right hand side of equation 4 = –CB1CC1 The coefficients of equation 5 (node 2, species A) are: Coefficient of #% Coefficient of CB1 = 0 Coefficient of CC1 = 0 Coefficient of CD1 = 0 Coefficient of # $ $% % % – Coefficient of CB2 = 0 Coefficient of CC2 = 0 Coefficient of CD2 = 0 Coefficient of #% Coefficient of CB3 = 0 Coefficient of CC3 = 0 Coefficient of CD3 = 0 Right hand side of equation 5 = 0. The coefficients of equation 6 (node 2, species B) are: Coefficient of CA1 = 0
  • 472. 148 Introduction to Numerical Methods in Chemical Engineering Coefficient of $% Coefficient of CC1 = 0 Coefficient of CD1 = 0 Coefficient of CA2 = 0 Coefficient of $ # % # %% % % % % – Coefficient of CC2 = 0 Coefficient of CD2 = 0 Coefficient of CA3 = 0 Coefficient of $% Coefficient of CC3 = 0 Coefficient of CD3 = 0 Right hand side of equation 6 = 0. The coefficients of equation 7 (node 2, species C) are: Coefficient of CA1 = 0 Coefficient of CB1 = 0 Coefficient of %% Coefficient of CD1 = 0 Coefficient of CA2 = 0 Coefficient of CB2 = 0 Coefficient of % $ $% % % – Coefficient of CD2 = 0 Coefficient of CA3 = 0 Coefficient of CB3 = 0 Coefficient of %% Coefficient of CD3 = 0 Right hand side of equation 7 = –CA2CB2. The coefficients of equation 8 (node 2, species D) are: Coefficient of CA1 = 0
  • 473. Tubular Reactor with Axial Dispersion 149 Coefficient of CB1 = 0 Coefficient of CC1 = 0 Coefficient of % Coefficient of CA2 = 0 Coefficient of CB2 = 0 Coefficient of CC2 = 0 Coefficient of % – Coefficient of CA3 = 0 Coefficient of CB3 = 0 Coefficient of CC3 = 0 Coefficient of % Right hand side of equation 8 = –CB2CC2 The coefficients of equation 13 (node 4, species A) are: Coefficient of #% – Coefficient of CB3 = 0 Coefficient of CC3 = 0 Coefficient of CD3 = 0 Coefficient of # $ $% % % – Coefficient of CB4 = 0 Coefficient of CC4 = 0 Coefficient of CD4 = 0 Right hand side of equation 13 = 0. The coefficients of equation 14 (node 4, species B) are: Coefficient of CA3 = 0 Coefficient of $% – Coefficient of CC3 = 0 Coefficient of CD3 = 0 Coefficient of CA4 = 0 Coefficient of $ # % # %% % % % % –
  • 474. 150 Introduction to Numerical Methods in Chemical Engineering Coefficient of CC4 = 0 Coefficient of CD4 = 0 Right hand side of equation 14 = 0 The coefficients of equation 15 (node 4, species C) are: Coefficient of CA3 = 0 Coefficient of CB3 = 0 Coefficient of %% – Coefficient of CD3 = 0 Coefficient of CA4 = 0 Coefficient of CB4 = 0 Coefficient of % $ $% % % – Coefficient of CD4 = 0 Right hand side of equation 15 = –CA4CB4. The coefficients of equation 16 (node 4, species D) are: Coefficient of CA3 = 0 Coefficient of CB3 = 0 Coefficient of CC3 = 0 Coefficient of % – Coefficient of CA4 = 0 Coefficient of CB4 = 0 Coefficient of CC4 = 0 Coefficient of % – Right hand side of equation 16 = –CB4CC4. Thus the set of equations for concentration of species A, B, C, and D at nodes 1 to 4 can be written in the block tridiagonal form as $ % : # $ % : # $ % : # $ : ª º ª º ª º « » « » « » « » « » « » « » « » « » « » « » « » « » « » « »¬ ¼ ¬ ¼ ¬ ¼
  • 475. Tubular Reactor with Axial Dispersion 151 where # # # $ $ $ % % % % % % % % % : : : % % % % % % ª º ª º ª º « » « » « » « » « » « » « » « » « » « » « » « » « » « » « »¬ ¼ ¬ ¼ ¬ ¼ For node 1 $ # % $ % % % $ % ª º « » « » « » « » « »¬ ¼ % ª º « » « » « » « » « »¬ ¼ # $ $ % % % % % ª º « »« » « » « » « »¬ ¼ For node 2 # ª º « » « » « » « » « »¬ ¼ $ # % $ % % % $ % ª º « » « » « » « » « »¬ ¼ % ª º « » « » « » « » « »¬ ¼
  • 476. 152 Introduction to Numerical Methods in Chemical Engineering # $ $ % % % % % ª º « » « » « » « » « »¬ ¼ For node 3 # ª º « » « » « » « » « »¬ ¼ $ # % $ % % % $ % ª º « » « » « » « » « »¬ ¼ % ª º « » « » « » « » « »¬ ¼ # $ $ % % % % % ª º « » « » « » « » « »¬ ¼ For node 4 # ª º « » « » « » « » « »¬ ¼ $ # % $ % % % $ % ª º « » « » « » « » « »¬ ¼
  • 477. Tubular Reactor with Axial Dispersion 153 # $ $ % % % % % ª º « » « » « » « » « »¬ ¼ The 16 linear algebraic equations can be written in the form Ax = d, where A is a 16 ´ 16 matrix, x is the vector of size 16 ´ 1 containing the variables to be determined, and d is also a vector of size 16 ´ 1. The variables can be written as @ 6 # $ % # $ % Z % % % % % % % % The Gauss elimination method can be used to solve these 16 linear algebraic equations (see Program 1.2 given in the Appendix). The results are given in Table 7.7. Table 7.7 Results in Example 7.4 Node number x (m) CA CB CC CD 1 0 0.999933 0.999927 0.000060 0.000006 2 1 0.652683 0.532064 0.226697 0.120620 3 2 0.503350 0.296694 0.289994 0.206656 4 3 0.430048 0.170485 0.310390 0.259562 Exercises 7.1 Consider a reaction A ® B carried out in a tubular reactor. The differential equation for species A along the length of the tubular reactor of length 10 m is # # # F % F% W M% FZFZ The boundary conditions are At x = 0 (inlet) KP # # # F% W% W% FZ At x = 10 m (exit) #F% FZ A fluid medium comprising initially only A flows through the reactor with a mean axial velocity u = 1 m/s. The axial dispersion coefficient, D = 10–4 m2 /s and the rate constant of the reaction is 0.1 s–1 . The inlet concentration CA,in =1 mol/m3 . Make 10 parts of the reactor. List the tridiagonal set of equations and determine the concentration of A at various positions along the length of the tubular reactor. (Ans: The tridiagonal set of equations are
  • 478. 154 Introduction to Numerical Methods in Chemical Engineering # # # # % % % % ª ºª º ª º « »« » « » « »« » « » « »« » « » « »« » « » « »« » « » « »« » « »¬ ¼ ¬ ¼¬ ¼ CA1 = CA(0.0) = 0.999991 CA2 = CA(1.0) = 0.909083 CA3 = CA(2.0) = 0.826440 CA4 = CA(3.0) = 0.751310 CA5 = CA(4.0) = 0.683009 CA6 = CA(5.0) = 0.620918 CA7 = CA(6.0) = 0.564471 CA8 = CA(7.0) = 0.513156 CA9 = CA(8.0) = 0.466506 CA10 = CA(9.0) = 0.424097 CA11 = CA(10.0) = 0.385549 7.2 Consider a reaction A ® B carried out in a tubular reactor. The differential equation for species A along the length of the tubular reactor of length 10 m is # # # F % F% W M% FZFZ The boundary conditions are At x = 0 (inlet): # # KP # F% W% W% FZ At x = 10 m (exit): #F% FZ A fluid medium comprising initially only A flows through the reactor with a mean axial velocity u = 1 m/s. The axial dispersion coefficient, D = 10–4 m2 /s and rate constant of the reaction is 0.1 m3 /mol-s. The inlet concentration CA,in = 1 mol/m3 . Make 10 parts of the reactor. List the tridiagonal set of equations and determine the concentration of A at various positions along the length of the tubular reactor. (Ans: The tridiagonal set of equations are % %# # % %# # % %# # % %# # ª º ª º ª º « » « » « » « » « » « » « » « » « » « » « » « » « » « » « » « » « » « » « »« » « » ¬ ¼¬ ¼ ¬ ¼ CA1 = CA(0.0) = 0.999991 CA2 = CA(1.0) = 0.916073 CA3 = CA(2.0) = 0.844719 CA4 = CA(3.0) = 0.783356 CA5 = CA(4.0) = 0.730059 CA6 = CA(5.0) = 0.683363 CA7 = CA(6.0) = 0.642133 CA8 = CA(7.0) = 0.605478 CA9 = CA(8.0) = 0.572688 CA10 = CA(9.0) = 0.543192 CA11 = CA(10.0) = 0.516529
  • 479. 155 Chapter 8 Chemical Reaction and Diffusion in Spherical Catalyst Pellet Chemical reaction and diffusion in a spherical catalyst pellet is a boundary value problem, because at the surface of the pellet the concentration of the species is known and at the centre of the pellet the gradient of concentration is zero. The finite difference method is used for the numerical solution of the first and second order reactions along with the diffusion term in a spherical catalyst pellet. The numerical solution under nonisothermal conditions is also discussed in this chapter. 8.1 First Order Reaction The differential equation for diffusion and reaction in a spherical catalyst pellet is given by F % F% M% T FTFT § · ¨ ¸¨ ¸ © ¹ (8.1) It is assumed that the pellet is isothermal and therefore the rate constant is also fixed. D is the effective binary diffusivity of A within the catalyst pellet. The boundary conditions are at r = R C = CS (8.1b) and at r = 0 0 dr dC (8.1b) where CS is the concentration at the surface of the spherical catalyst pellet. EXAMPLE 8.1 The chemical reaction and diffusion in a spherical catalyst pellet is given by # # # F % F% M% T FTFT where D is the effective binary diffusivity of A within the catalyst pellet. The pellet is isothermal. The concentration at the surface of the spherical catalyst pellet is 1 mol/m3 , thus the boundary conditions are
  • 480. 156 Introduction to Numerical Methods in Chemical Engineering at r = R CA = 1 at r = 0 #F% FT The radius of the catalyst pellet is 1.0 cm. Make 100 parts of the radius. Take the rate constant, k = 10-3 s–1 and D = 10–9 m2 /s. Determine the concentration of species A at various nodes along the radius of the catalyst pellet. Solution The differential equation for diffusion and reaction in a spherical catalyst pellet is F % F% M % T FT FT It is given that M m–2 . The radius is 1 cm = 10–2 m and 100 parts are made, thus T' m. The schematic diagram of the spherical catalyst pellet is shown in Fig. 8.1. The first node is labelled 0 and therefore the last node is the 100th node as 100 parts are made. Fig. 8.1 Diffusion and reaction in spherical catalyst pellet. The boundary conditions are: at r = 1 cm C = 1 r = 0 F% FT 100 r = R C100 = 1 0 r = 0
  • 481. Chemical Reaction and Diffusion in Spherical Catalyst Pellet 157 Discretizing the differential equation at node i, we get K K K K K K % % % % % % O T TT ' '' § · ¨ ¸ © ¹
  • 482. K K K K K K % % % % % T % O '
  • 483. K K K K K K % % % % % % O K K K % % % O O § · § · ¨ ¸ ¨ ¸ © ¹ © ¹ At node 0 (centre of spherical catalyst pellet) the differential equation becomes F % % FT Discretizing, we get % % % % T' § · ¨ ¸ © ¹
  • 484. % % % T %'
  • 485. % % % % At node 0, F% FT ; thus % % T' , and therefore C–1 = C1. Therefore the above equation becomes
  • 486. % % % % % At node 1 (m = 1) K K K % % % O O § · § · ¨ ¸ ¨ ¸ © ¹ © ¹ % % § · ¨ ¸ © ¹ At node 2 (m = 2) % % % § · § · ¨ ¸ ¨ ¸ © ¹ © ¹ At node 3 (m = 3) % % % § · § · ¨ ¸ ¨ ¸ © ¹ © ¹
  • 487. 158 Introduction to Numerical Methods in Chemical Engineering At node 99 (m = 99) % % % § · § · ¨ ¸ ¨ ¸ © ¹ © ¹ Since C100 = 1, we get % % § · § · ¨ ¸ ¨ ¸ © ¹ © ¹ % % § · ¨ ¸ © ¹ The 100 equations can be written in tridiagonal form as % % % % % % % ª º ª º« » « »« » « »« » « »« » « »« » « »« » « »« » « »« » « »« » « » « » « »« » « » « » « »« » « »¬ ¼ « »¬ ¼ ª º « » « » « » « » « » « » « » « » « » « » « » « » « »¬ ¼ The solution can be obtained by modifying the parameters ai (i = 2 to N), bi (i = 1 to N) and ci (i = 1 to N – 1) in Program 1.1 given in the Appendix. The results for nodes 77 to 99 are presented in Table 8.1 given in the next section. 8.2 Second Order Reaction The differential equation for diffusion and second order reaction in a spherical catalyst pellet is given by F % F% M% T FTFT § · ¨ ¸¨ ¸ © ¹ (8.2) It is assumed that the pellet is isothermal and therefore the rate constant is also fixed. D is the effective binary diffusivity of A within the catalyst pellet. The boundary conditions are At r = R: C = CS At r = 0: F% FT where CS is the concentration at the surface of the spherical catalyst pellet.
  • 488. Chemical Reaction and Diffusion in Spherical Catalyst Pellet 159 EXAMPLE 8.2 The chemical reaction and diffusion in a spherical catalyst pellet is given by # # # F % F% M% T FTFT where D is the effective binary diffusivity of A within the catalyst pellet. The pellet is isothermal. The concentration at the surface of the spherical catalyst pellet is 1 mol/m3 ; thus the boundary conditions are At r = R: CA = 1 At r = 0: #F% FT The radius of the catalyst pellet is 1.0 cm. Make 100 parts of the radius. Take the rate constant, k = 10–3 m3 /mol-s and D = 10–9 m2 /s. Determine the concentration of species A at various nodes along the radius of the catalyst pellet. Solution The differential equation for diffusion and reaction in a spherical catalyst pellet is F % F% M % T FT FT It is given that M . The radius is 1 cm = 10–2 m and 100 parts are made, thus T' m. The schematic diagram of the spherical catalyst pellet is given in Fig. 8.1. The first node is labelled 0 and therefore the last node is the 100th node as 100 parts are made. Discretizing the differential equation at node i, we get K K K K K K % % % % % % O T TT ' '' § · ¨ ¸ © ¹
  • 489. K K K K K K % % % % % T % O '
  • 490. K K K K K K % % % % % % O
  • 491. K K K K % % % % O O § · § · ¨ ¸ ¨ ¸ © ¹ © ¹ At node 0 (centre of spherical catalyst pellet) the differential equation becomes F % % FT
  • 492. 160 Introduction to Numerical Methods in Chemical Engineering Discretizing, we get % % % % T' § · ¨ ¸ © ¹
  • 493. % % % T %'
  • 494. % % % % At node 0, F% FT ; thus % % T' , and therefore C–1 = C1. Therefore the above equation becomes
  • 495. % % %
  • 496. % % % At node 1 (m = 1)
  • 497. K K K K % % % % O O § · § · ¨ ¸ ¨ ¸ © ¹ © ¹
  • 498. % % % § · ¨ ¸ © ¹ At node 2 (m = 2)
  • 499. % % % % § · § · ¨ ¸ ¨ ¸ © ¹ © ¹ At node 3 (m = 3)
  • 500. % % % % § · § · ¨ ¸ ¨ ¸ © ¹ © ¹ At node 99 (m = 99)
  • 501. % % % % § · § · ¨ ¸ ¨ ¸ © ¹ © ¹ Since C100 = 1, we get
  • 502. % % % § · § · ¨ ¸ ¨ ¸ © ¹ © ¹
  • 503. % % % § · ¨ ¸ © ¹ The 100 equations can be written in tridiagonal form as % % % % % % % % ª º ª º« » ª º « » « » « » « »« » « » « »« » « » « »« » « » « » « » « » « »« » « » ¬ ¼ « »« » ¬ ¼ « »¬ ¼
  • 504. Chemical Reaction and Diffusion in Spherical Catalyst Pellet 161 It is seen that the coefficient matrix also depends on the concentrations. Therefore, to start the program the concentrations are assumed, the coefficients are calculated and TDMA is used to determine the new concentrations. At these concentrations the coefficients are re-calculated and TDMA is used to determine the new concentrations. The procedure is repeated till there is no change in the concentration profile. Program 8.1 for the solution of the above problem is given in the Appendix. The results for nodes 77 to 99 are presented in Table 8.1. Table 8.1 Concentration of reactants in spherical catalyst pellet for first and second order reactions under isothermal condition Node number r (cm) C (first order reaction) C (second order reaction) 99 0.99 0.914015 0.930360 98 0.98 0.835509 0.868043 97 0.97 0.763826 0.812053 96 0.96 0.698366 0.761560 95 0.95 0.638586 0.715865 94 0.94 0.583988 0.674377 93 0.93 0.534119 0.636593 92 0.92 0.488564 0.602084 91 0.91 0.446948 0.570482 90 0.90 0.408925 0.541468 89 0.89 0.374184 0.514766 88 0.88 0.342438 0.490138 87 0.87 0.313425 0.467374 86 0.86 0.286908 0.446290 85 0.85 0.262670 0.426724 84 0.84 0.240513 0.408536 83 0.83 0.220257 0.391599 82 0.82 0.201735 0.375800 81 0.81 0.184799 0.361041 80 0.80 0.169310 0.347233 79 0.79 0.155144 0.334296 78 0.78 0.142186 0.322160 77 0.77 0.130331 0.310759 8.3 Nonisothermal Conditions The differential equation for diffusion and reaction in a spherical catalyst pellet is given by
  • 505. F % F% M 6 % T FTFT § · ¨ ¸¨ ¸ © ¹ (8.3) where the rate constant is a function of the temperature, or
  • 507. GZR 5 5 5 6' M 6 M 6 46 6 ª º§ · « »¨ ¸ © ¹¬ ¼ (8.4)
  • 508. 162 Introduction to Numerical Methods in Chemical Engineering Consider the case of a non-isothermal first order reaction A ® B occurring in the interior of a spherical catalyst pellet. We wish to compute the effect of internal heat and mass transfer resistance upon the reaction rate and the concentration and temperature profiles within the pellet. The concentration profile CA(r) is governed by the mole balance
  • 509. # # # F%F T T M 6 % FT FT § · ¨ ¸ © ¹ (8.5) where DA is the effective binary diffusivity of A within the pellet. If k is the effective thermal conductivity of the pellet, the temperature profile T(r) is governed by the energy balance
  • 511. TZP # F F6 T M T * M 6 % FT FT ' § · ª º ¨ ¸ ¬ ¼ © ¹ (8.6) Neglecting external heat and mass transfer resistance, we have known values of the concentration and temperature at the surface, r = R: CA(R) = CAS and T(R) = TS. Also, at the centre of the pellet, r = 0: # T F% FT and T F6 FT . The temperature dependence of the rate constant is
  • 513. GZR 5 5 5 6' M 6 M 6 46 6 ª º§ · « »¨ ¸ © ¹¬ ¼ (8.7) If we assume constant DA, k and TZP*' the problem reduces to a single ordinary differential equation. Dividing the energy balance equation by TZP*' and adding to the mole balance equation, we get
  • 514. TZP # # F%F F M F6 T T FT FT FT FT*' § · § · ¨ ¸¨ ¸ ¨ ¸© ¹ © ¹ (8.8) Integrating, we get
  • 515. TZP # # F% M F6 T % FT FT*' ª º « » « » ¬ ¼ (8.9) where C1 is the constant of integration. Dividing by r2 gives
  • 516. TZP # # %F M % 6 FT T*' ª º « » « » ¬ ¼ (8.10) From the symmetry boundary condition C1 = 0 and a second integration
  • 517. TZP # # M % 6 % *' (8.11) where C2 is the constant of integration. At the surface, we get the value of constant C2 as
  • 518. TZP # #5 5 M % % 6 *' (8.12)
  • 519. Chemical Reaction and Diffusion in Spherical Catalyst Pellet 163 Comparing Eqs. (8.11) and (8.12), we get
  • 521. TZP TZP # # # #5 5 M M % 6 % 6 * *' ' (8.13) Thus there exists the following linear relation between CA(r) and T(r):
  • 523. TZP# 5 # #5 * 6 T 6 % T % M ' ª º ¬ ¼ (8.14) Thus only the mole balance equation has to be solved. Thus, if we assume constant DA, k and TZP*' , we can show that at any point along the radius the temperature and concentration of the reactant are related by Eq. (8.14). A parameter is defined as
  • 524. TZP 5 5 * % M6 C ' (8.15) From Eq. (8.14), we get
  • 525. TZP 5 5 5 *6 % % 6 M6 ' Therefore
  • 526. TZP 5 5 5 6 6 * % % M6 ' Subtracting one from both the sides, we get
  • 528. TZP TZP 5 5 5 5 5 * % % 6 M6 6 * % % M6 ' ' (8.16) Let us define a parameter as 5 ' 46 H (8.17) If CS = 1, then
  • 529. TZP 5 * M6 C ' and the expression for rate constant given in Eq. (8.7) becomes
  • 533. GZR 5 5 5 % % M 6 M 6 % % HC C ª º « » « »¬ ¼ (8.18)
  • 534. 164 Introduction to Numerical Methods in Chemical Engineering EXAMPLE 8.3 Diffusion and reaction take place in a non-isothermal spherical catalyst pellet of radius 1 cm. The rate constant of the reaction k(TS) = 10–3 s–1 and effective diffusivity of species, D = 10–9 m2 /s. Make 100 parts of the radius and determine the concentration within the catalyst pellet. The concentration at the surface of the spherical catalyst pellet CS = 1 mol/ m3 . Take b = 1 and gÿ= 1. Solution The differential equation for diffusion and reaction in a non-isothermal spherical catalyst pellet is F % F% M % T FT FT where
  • 538. GZR 5 5 5 % % M 6 M 6 % % HC C ª º « » « »¬ ¼ Thus the differential equation becomes
  • 541. GZR 5 5 5 M 6 % %F % F% % T FT % %FT HC C ª º§ · « »¨ ¸¨ ¸ « »© ¹¬ ¼ It is given that
  • 542. 5M 6 m–2 . The radius is 1 cm = 10–2 m and 100 parts are made; thus T' m. The schematic diagram of the spherical catalyst pellet is given in Fig. 8.1. The boundary conditions are At r = 1 cm: C = 1 At r = 0: F% FT Since b = 1, gÿ= 1, and CS = 1 mol/m3 , the differential equation becomes GZR F % F% % % T FT %FT ª º§ · « »¨ ¸ © ¹¬ ¼ Discretizing the differential equation at node i, we get GZR K K K K K K K K % % % % % % % O T T %T ' '' ª º§ · § · « »¨ ¸¨ ¸ © ¹ « »© ¹¬ ¼
  • 543. GZR K K K K K K K K % % % % % % % O % ª º§ · « »¨ ¸ « »© ¹¬ ¼
  • 544. Chemical Reaction and Diffusion in Spherical Catalyst Pellet 165 GZR K K K K K % % % % O % O ª º§ ·§ · § · « »¨ ¸¨ ¸ ¨ ¸© ¹ © ¹« »© ¹¬ ¼ At node 0 (centre of spherical catalyst pellet), the differential equation becomes GZR F % % % %FT ª º§ · « »¨ ¸ © ¹¬ ¼ Discretizing, we get GZR % % % % % %T' ª º§ · § · « »¨ ¸¨ ¸ © ¹ « »© ¹¬ ¼
  • 545. GZR % % % % % % ª º§ · « »¨ ¸ « »© ¹¬ ¼ At node 0, F% FT ; thus % % T' , and therefore C–1 = C1. Therefore the above equation becomes
  • 546. GZR % % % % % ª º§ · « »¨ ¸ « »© ¹¬ ¼ GZR % % % % ª º§ · « »¨ ¸ « »© ¹¬ ¼ At node 1 (m = 1) GZR K K K K K % % % % O % O ª º§ ·§ · § · « »¨ ¸¨ ¸ ¨ ¸© ¹ © ¹« »© ¹¬ ¼ GZR % % % % ª º§ · § · « »¨ ¸ ¨ ¸ © ¹© ¹¬ ¼ At node 2 (m = 2) GZR % % % % % ª º§ ·§ · § · « »¨ ¸¨ ¸ ¨ ¸ © ¹ © ¹© ¹¬ ¼ At node 3 (m = 3) GZR % % % % % ª º§ ·§ · § · « »¨ ¸¨ ¸ ¨ ¸© ¹ © ¹« »© ¹¬ ¼ At node 99 (m = 99) GZR % % % % % ª º§ ·§ · § · « »¨ ¸¨ ¸ ¨ ¸© ¹ © ¹« »© ¹¬ ¼
  • 547. 166 Introduction to Numerical Methods in Chemical Engineering Since C100 = 1, we get GZR % % % % ª º§ ·§ · « »¨ ¸¨ ¸ © ¹ « »© ¹¬ ¼ The 100 equations can be written in tridiagonal form as GZR GZR GZR GZR % % % % % % %% %% % % ª º§ · « »¨ ¸ © ¹« » « » § · ª º« » ¨ ¸ « »« »© ¹ « »« » « »« » « »« » § · « »« » ¨ ¸ « » « » ¬ ¼© ¹ « » § ·« » ¨ ¸« » « »© ¹¬ ¼ ª º « » « » « » « » « » « » « » « »¬ ¼ It is seen that the coefficient matrix also depends on the concentrations. Therefore, to start the program the concentrations are assumed, the coefficients are calculated and TDMA is used to determine the new concentrations. At these concentrations the coefficients are re-calculated and TDMA is used to determine the new concentrations. The procedure is repeated till there is no change in the concentration profile. Program 8.2 for the solution of the above problem is given in the Appendix. The results for nodes 77 to 100 are presented in Table 8.2. EXAMPLE 8.4 Solve Example 8.3 for b = 10 and gÿ= 1. Solution Since b = 10, gÿ= 1, and CS = 1 mol/m3 , the differential equation becomes GZR F % F% % % T FT %FT ª º§ · « »¨ ¸ © ¹¬ ¼ Discretizing the differential equation at node i, we get GZR K K K K K K K K % % % % % % % O T T %T ' '' ª º§ · § · « »¨ ¸¨ ¸ © ¹ « »© ¹¬ ¼
  • 548. GZR K K K K K K K K % % % % % % % O % ª º§ · « »¨ ¸ « »© ¹¬ ¼ GZR K K K K K % % % % O % O ª º§ ·§ · § · « »¨ ¸¨ ¸ ¨ ¸© ¹ © ¹« »© ¹¬ ¼ At node 0 (centre of spherical catalyst pellet), the differential equation becomes GZR F % % % %FT ª º§ · « »¨ ¸ © ¹¬ ¼
  • 549. Chemical Reaction and Diffusion in Spherical Catalyst Pellet 167 Discretizing, we get GZR % % % % % %T' ª º§ · § · « »¨ ¸¨ ¸ © ¹ « »© ¹¬ ¼
  • 550. GZR % % % % % % ª º§ · « »¨ ¸ « »© ¹¬ ¼ At node 0, F% FT ; thus % % T' , and therefore C–1 = C1. Therefore the above equation becomes
  • 551. GZR % % % % % ª º§ · « »¨ ¸ « »© ¹¬ ¼ GZR % % % % ª º§ · « »¨ ¸ « »© ¹¬ ¼ At node 1 (m = 1) GZR K K K K K % % % % O % O ª º§ ·§ · § · « »¨ ¸¨ ¸ ¨ ¸© ¹ © ¹« »© ¹¬ ¼ GZR % % % % ª º§ · § · « »¨ ¸ ¨ ¸ © ¹© ¹¬ ¼ At node 2 (m = 2) GZR % % % % % ª º§ ·§ · § · « »¨ ¸¨ ¸ ¨ ¸© ¹ © ¹© ¹¬ ¼ At node 3 (m = 3) GZR % % % % % ª º§ ·§ · § · « »¨ ¸¨ ¸ ¨ ¸© ¹ © ¹« »© ¹¬ ¼ At node 99 (m = 99) GZR % % % % % ª º§ ·§ · § · « »¨ ¸¨ ¸ ¨ ¸© ¹ © ¹« »© ¹¬ ¼ Since C100 = 1, we get GZR % % % % ª º§ ·§ · « »¨ ¸¨ ¸ © ¹ « »© ¹¬ ¼
  • 552. 168 Introduction to Numerical Methods in Chemical Engineering The 100 equations can be written in tridiagonal form as GZR GZR GZR GZR % % % % % % %% %% % % ª º§ · « »¨ ¸ © ¹« » « » § · ª« » ¨ ¸ «« »© ¹ «« » « » « » § · « » ¨ ¸ « » ¬© ¹ « » § ·« » ¨ ¸« » « »© ¹¬ ¼ ª º º « » » « » » « » « » « » « » « » « » « » « » « »¼ « »¬ ¼ It is seen that the coefficient matrix also depends on the concentrations. Therefore, to start the program the concentrations are assumed, the coefficients are calculated and TDMA is used to determine the new concentrations. At these concentrations the coefficients are re-calculated and TDMA is used to determine the new concentrations. The procedure is repeated till there is no change in the concentration profile. Program 8.2 can be modified to solve this problem. The results for nodes 77 to 100 are presented in Table 8.2. Table 8.2 Concentration of reactant in spherical catalyst pellet under non-isothermal conditions for first order reaction for b = 1 and b = 10 Node number r (cm) C (b = 1) C (b = 10) 100 1.00 1.000000 1.000000 99 0.99 0.901657 0.873620 98 0.98 0.803074 0.752422 97 0.97 0.713959 0.646573 96 0.96 0.633761 0.554827 95 0.95 0.561849 0.475639 94 0.94 0.497557 0.407470 93 0.93 0.440217 0.348888 92 0.92 0.389179 0.298610 91 0.91 0.343828 0.255496 90 0.90 0.303586 0.218553 89 0.89 0.267922 0.186914 88 0.88 0.236345 0.159829 87 0.87 0.208414 0.136650 86 0.86 0.183724 0.116820 85 0.85 0.161913 0.099585 84 0.84 0.142658 0.085352 83 0.83 0.125665 0.072949 82 0.82 0.110677 0.062345 81 0.81 0.097460 0.053280 80 0.80 0.085810 0.045531 79 0.79 0.075543 0.038908 78 0.78 0.066497 0.033247 77 0.77 0.058529 0.028409
  • 553. Chemical Reaction and Diffusion in Spherical Catalyst Pellet 169 Exercises 8.1 The chemical reaction and diffusion in a spherical catalyst pellet is given by # # # F % F% M% T FTFT where D is the effective binary diffusivity of A within the catalyst pellet. The pellet is isothermal. The concentration at the surface of the spherical catalyst pellet is 1 mol/m3 thus the boundary conditions are: At r = R: CA = 1 At r = 0: #F% FT The radius of the catalyst pellet is 1.0 cm. Make 10 parts of the radius. Take the rate constant, k = 0.1 s–1 and D = 10–9 m2 /s. Determine the concentration of species A at various positions along the radius of the catalyst pellet. (Ans: The tridiagonal set of equations are # # # # % % % % ª º ª ºª º « » « »« » « » « »« » « » « »« » « » « »« » « » « »« » « » « »« » ¬ ¼ ¬ ¼« »¬ ¼ CA0 = CA(0.0) = 0.000000 CA1 = CA(0.1) = 0.000000 CA2 = CA(0.2) = 0.000000 CA3 = CA(0.3) = 0.000000 CA4 = CA(0.4) = 0.000000 CA5 = CA(0.5) = 0.000000 CA6 = CA(0.6) = 0.000000 CA7 = CA(0.7) = 0.000001 CA8 = CA(0.8) = 0.000120 CA9 = CA(0.9) = 0.010894 Distance (in cm) is measured from the centre of the spherical pellet. 8.2 The chemical reaction and diffusion in a spherical catalyst pellet is given by # # # F % F% M% T FTFT where D is the effective binary diffusivity of A within the catalyst pellet. The pellet is isothermal. The concentration at the surface of the spherical catalyst pellet is 1 mol/m3 , thus the boundary conditions are At r = R: CA = 1 At r = 0: #F% FT
  • 554. 170 Introduction to Numerical Methods in Chemical Engineering The radius of the catalyst pellet is 1.0 cm. Make 10 parts of the radius. Take the rate constant, k = 0.1 m3 /mol-s and D = 10–9 m2 /s. Determine the concentration of species A at various positions along the radius of the catalyst pellet. (Ans: The tridiagonal set of equations are # # # # # # # # % % % % % % % % ª º ª º« » ª º « » « » « » « »« » « » « »« » « » « »« » « » « » « » « » « »« » « » ¬ ¼ « »« » ¬ ¼ « »¬ ¼ CA0 = CA(0.0) = 0.001837 CA1 = CA(0.1) = 0.001894 CA2 = CA(0.2) = 0.002073 CA3 = CA(0.3) = 0.002419 CA4 = CA(0.4) = 0.003030 CA5 = CA(0.5) = 0.004131 CA6 = CA(0.6) = 0.006286 CA7 = CA(0.7) = 0.011211 CA8 = CA(0.8) = 0.025902 CA9 = CA(0.9) = 0.096965 Distance (in cm) is measured from the centre of the spherical pellet. 8.3 Diffusion and reaction take place in a non-isothermal spherical catalyst pellet of radius 1 cm. The rate constant of the reaction k(TS) = 0.1 s–1 and effective diffusivity of species, D = 10–9 m2 /s. Make 10 parts of the radius and determine the concentration within the catalyst pellet. The concentration at the surface of the spherical catalyst pellet, CS = 1 mol/m3 . Take b = 1 and g = 1. (Ans: The tridiagonal set of equations are GZR GZR GZR GZR % % % % % % %% %% % % ª º§ · « »¨ ¸ © ¹« » « » ª º § · ª º« » « » ¨ ¸ « »« » « »© ¹ « »« » « « »« » « « »« » « § · « »« » « ¨ ¸ « » « » « ¬ ¼© ¹ «¬ ¼« » § ·« » ¨ ¸« » « »© ¹¬ ¼ » » » » » » CA0 = CA(0.0) = 0.000000 CA1 = CA(0.1) = 0.000000 CA2 = CA(0.2) = 0.000000 CA3 = CA(0.3) = 0.000000 CA4 = CA(0.4) = 0.000000 CA5 = CA(0.5) = 0.000000 CA6 = CA(0.6) = 0.000000 CA7 = CA(0.7) = 0.000000 CA8 = CA(0.8) = 0.000045 CA9 = CA(0.9) = 0.006659 Distance (in cm) is measured from the centre of the spherical pellet.
  • 555. 171 Chapter 9 One-Dimensional Transient Heat Conduction The numerical solution of one-dimensional transient heat conduction in a rectangular slab, cylinder, and sphere is discussed in this chapter using the finite difference method. The one- dimensional transient heat conduction in a rectangular slab is given by 6 6 V Z B ˜ ˜ ˜ ˜ (9.1) In a cylinder it is given by 6 6 6 V T TT B È Ø˜ ˜ ˜ É Ù˜ ˜˜Ê Ú (9.2) and in a sphere it is given by 6 6 6 V T TT B È Ø˜ ˜ ˜ É Ù˜ ˜˜Ê Ú (9.3) where 2 M % B S . Discretization is carried out using the forward in time and central in space (FTCS) difference scheme. The explicit, implicit and Crank–Nicolson discretizations are discussed. An example of one-dimensional transient diffusion is also discussed. Von Neumann stability analysis, which is used to determine the criteria under which the explicit scheme is stable, is also discussed. 9.1 Classification of Partial Differential Equations Consider the two-dimensional partial differential equation (PDE) H H H H H # $ % ' (H ) Z [ Z [Z [ ˜ ˜ ˜ ˜ ˜ ˜ ˜ ˜ ˜˜ ˜ (9.4) When B2 – 4AC 0, characteristics do not exist and it is elliptic PDE. When B2 – 4AC = 0, one set of characteristics exists and it is parabolic PDE. When B2 – 4AC 0, two sets of characteristics exist and it is hyperbolic PDE. A summary of the above result with examples is presented in Table 9.1.
  • 556. 172 Introduction to Numerical Methods in Chemical Engineering Table 9.1 Classification of partial differential equations PDE Parameters Classification of PDE 6 6 Z [ ˜ ˜ ˜ ˜ A = 1 B2 – 4AC = –4 0 B = 0 Elliptic C = 1 6 6 V Z B ˜ ˜ ˜ ˜ (a 0) A = –a B2 – 4AC = 0 B = 0 Parabolic C = 0 1-D wave equation A = 1 B2 – 4AC = 4a2 0 (a 0) (9.5) B = 0 Hyperbolic C = –a2 The coefficients in the 1D wave equation are determined using the following. Differentiating Eq. (9.5) with respect to x, we get W W C V Z Z ˜ ˜ ˜ ˜ ˜ Differentiating Eq. (9.5) with respect to t, we get W W C V ZV ˜ ˜ ˜ ˜˜ Combining the above two equations, we get W W C V Z ˜ ˜ ˜ ˜ A linear PDE is one in which A, B, C, D, E, F, and G are functions of x and y only. 9.2 Explicit and Implicit Discretization Consider conduction in a one-dimensional rectangular slab. The partial differential equation is [see Eq. (9.1)] 6 6 V Z B ˜ ˜ ˜ ˜ Using the forward in time and central in space explicit difference scheme, we get
  • 557. P P P P P K K K K K6 6 6 6 6 V Z B ' ' (9.6) W W C V Z ˜ ˜ ˜ ˜
  • 558. One-Dimensional Transient Heat Conduction 173 If the solution is known at time n, then it is very easy to determine the solution at time n + 1 using the explicit method.
  • 559. P P P P P K K K K K6 / 6 6 6 6 (9.7) where
  • 560. V / Z B' ' . Thus if the temperature at all the nodes is known at time t, the temperature at time t + Dt can be computed and from this temperature at time t + Dt, the temperature at time t + 2Dt can be computed. Thus the temperature at any required time can be computed. Thus the values of all the nodes can be updated to compute the temperature profile at the required time. But there is a disadvantage, which is that explicit discretization is not stable for all values of Dt and Dx. It is stable only when
  • 561. V Z B ' ' d (9.8) Thus the choice of Dt and Dx is not independent. If the condition
  • 562. V Z B ' ' d is not satisfied, then convergence shall not be obtained and the solution shall start diverging. The implicit method is an unconditionally stable method and the implicit discretization of Eq. (9.1) is given by
  • 563. P P P P P K K K K K6 6 6 6 6 V Z B ' ' (9.9) When the temperature at time t is known, then to calculate the temperature at time t + Dt the tridiagonal set of linear algebraic equations is solved. Thus P K6 are known and P K6 are calculated. Thus marching in time can be carried out to obtain the temperature at various nodes at the next time step for the parabolic PDE. 9.3 Crank-Nicolson Discretization Consider conduction in a rectangular slab. The partial differential equation is [see Eq. (9.1)] 6 6 V Z B ˜ ˜ ˜ ˜ Crank–Nicolson discretization is given by
  • 565. P P P P P P P P K K K K K K K K6 6 6 6 6 6 6 6 V Z Z B Ë Û Ì Ü ' Ì Ü' 'Í Ý (9.10) In the Crank–Nicolson method the discretization of space term is carried out using the central difference scheme at time n and at time n + 1 and taking the mean of the two. It is an
  • 566. 174 Introduction to Numerical Methods in Chemical Engineering unconditionally stable method. It is an more accurate than the implicit method. The accuracy of the implicit method is O(Dt,Dx2 ), whereas that of Crank–Nicolson is O(Dt2 ,Dx2 ). The central difference scheme is not used in time because it would require high storage, as there would be terms of three types—Tn+1 , Tn , Tn–1 . 9.4 Von Neumann Stability Analysis Von Neumann stability analysis is also called the Fourier method. The method shall be described for the one-dimensional transient heat conduction [see Eq. (9.1)] 6 6 V Z B ˜ ˜ ˜ ˜ Discretizing using the FTCS explicit scheme, we get at node i [see Eq. (9.6)]
  • 567. P P P P P K K K K K V 6 6 6 6 6 Z B ' ' Let the exact solution of this equation be D. This is the solution that would be obtained using a computer with infinite accuracy (infinite storage of each variable). Let the numerical solution on a real machine with finite accuracy be N. Then, round-off error = N – D = e. Thus, N = D + e and the above equation becomes P P P P P P P P P P K K K K K K K K K K V Z F F F F F B È Ø É Ù' 'Ê Ú (9.11) Since the exact solution D must satisfy the difference equation, the same is true of the error, that is P P P P P K K K K K V Z F F F F F B È Ø É Ù' 'Ê Ú (9.12) Thus the exact solution D and the error e must both satisfy the same difference equation. Consider a distribution of errors at any time. The error e(x, t) can be written as a series of the form
  • 568. OKM ZCV O Z V G GF Ç (9.13) where O O M . Q m = 0, 1, 2, …, M¢ (9.14) M¢ is the number of intervals (Dx units long) contained in length L. Since the difference equation is linear, superposition may be used and we may examine the behaviour of a single term of the series. Thus, when the finite difference equation (FDE) is linear, it is sufficient to
  • 569. One-Dimensional Transient Heat Conduction 175 investigate only one component of the Fourier series. The error is in the form of Fourier series. Consider the term
  • 570. OKM ZCV O Z V G GF (9.15) where km is real but a may be complex. Substituting
  • 571. OKM ZCV O Z V G GF into Eq. (9.12), we get
  • 575. O OO O OC V V KM Z Z KM Z ZKM Z KM Z KM ZCV CV CV CV G G G G / G G G G G G ' ' ' (9.16) where V / Z B' ' . If we divide by OKM ZCV G G , we get
  • 576. O OKM Z KM ZC V G / G G' '' and if we utilize the relation EQU K K G GC C C (9.17) we get
  • 577. EQU C V G / C' (9.18) where OM ZC ' (9.19) We know EQU UKP C C (9.20) Thus UKP C V G / C' (9.21) Since P C V P K KGF F ' for each frequency present in the solution for the error, it is clear that if C V G ' is less than or equal to one, a general component of the error will not grow from one time step to the next. Stability means that error should not grow. This requires that UKP / C d (9.22) The factor UKP / C (representing P K P K F F ) is called the amplification factor. If the sign on the left hand side of Eq. (9.22) is either positive or negative, two conditions result. For positive sign UKP / C ! (9.23) For negative sign UKP / C d (9.24) Since M is positive, the first condition is always satisfied. The second inequality is satisfied
  • 578. 176 Introduction to Numerical Methods in Chemical Engineering only if / d , which is the stability requirement. Thus for the explicit finite difference equation
  • 579. P P P P P K K K K K V 6 6 6 6 6 Z B' ' to be stable V Z B' ' d (9.25) The two-dimensional transient heat conduction equation is 6 6 6 V Z [ B È Ø˜ ˜ ˜ É Ù˜ ˜ ˜Ê Ú (9.26) Discretizing at node (i, j) using the FTCS explicit scheme, we get
  • 581. P P P P P P P P K L K L K L K L K L K L K L K L V V 6 6 6 6 6 6 6 6 Z [ B B ' ' ' ' (9.27) From the von Neumann stability analysis, we get the explicit FTCS discretization to be stable when V V Z [ B B' ' … ' ' (9.28) When Dx = Dy = D, the discretized form of Eq. (9.26) becomes
  • 582. P P P P P P P K L K L K L K L K L K L K L V 6 6 6 6 6 6 6 B ' ' (9.29) and the stability criterion for explicit discretization becomes VB' … ' (9.30) 9.5 Transient Conduction in Rectangular Slab One-dimensional transient heat conduction in a rectangular slab using the implicit method is described in the example below. EXAMPLE 9.1 Consider transient heat conduction in a rectangular slab. The partial differential equation is 6 6 V Z B ˜ ˜ ˜ ˜ The total width of the rectangular slab is 0.8 cm. Initially the temperature is uniform at 20°C. The temperature of the end faces of the rectangular slab is made 300°C at t = 0 s. Use implicit discretization and take Dx = 0.1 cm, Dt = 0.1 s, and a = 10–5 m2 /s. List the tridiagonal system
  • 583. One-Dimensional Transient Heat Conduction 177 of equations and determine the temperature at the centre and the intermediate points of the slab up to 3.1 s. Solution The schematic diagram of the rectangular slab is shown in Fig. 9.1. Fig. 9.1 Transient heat conduction in rectangular slab. Using forward in time and central in space implicit difference scheme, we get
  • 584. P P P P P K K K K K6 6 6 6 6 V Z B ' '
  • 585. P P P P P K K K K K6 6 / 6 6 6 where
  • 589. P P P P K K K K/ 6 / 6 / 6 6 At node 2
  • 592. P P P P / 6 / 6 / 6 6 At node 3
  • 595. P P P P / 6 / 6 / 6 6 At node 4
  • 598. P P P P / 6 / 6 / 6 6 where T5 = 300°C. At node 1 the finite difference equation is
  • 601. P P P P / 6 / 6 / 6 6 2 3 41 Symmetry Wall at 300°C 5
  • 602. 178 Introduction to Numerical Methods in Chemical Engineering where 0 is a hypothetical node to the left of node 1. Since at x = 0 (node 1) the symmetry condition is satisfied, we get 6 Z ˜ ˜ ; thus P P 6 6 Z ' and so 1 2 1 0 nn TT . Thus at i = 1, we get
  • 604. P P P / 6 / 6 6 The following tridiagonal set of linear algebraic equations is obtained: P P P P P P P P 6/ 6/ 6 6/ / / 6/ / / 6 6/ / 6 / Ë Û Ë ÛË Û Ì ÜÌ ÜÌ Ü Ì ÜÌ ÜÌ Ü Ì Ü Ì ÜÌ Ü Ì ÜÌ ÜÌ Ü Ì ÜÌ ÜÌ Ü Ì ÜÌ Ü Ì ÜÍ ÝÍ Ý Ì ÜÍ Ý where the old values are at time n and the computed values are at time n + 1. Here a = 10–5 m2 /s, Dt = 0.1 s, Dx = 0.1 cm, P P P P 6 6 6 6 °C, T5 = 300°C. Thus
  • 606. V / Z B ' – ' – P P P P P P P P 6 6 6 6 6 6 6 6 Ë Û Ë ÛË Û Ì Ü Ì ÜÌ Ü Ì Ü Ì ÜÌ Ü Ì Ü Ì ÜÌ Ü Ì Ü Ì ÜÌ Ü Ì Ü Ì ÜÌ ÜÍ Ý Ì Ü Ì ÜÍ Ý Í Ý At time t = 0, P P P P 6 6 6 6 °C and the solution by TDMA is obtained at time t = 0.1s. These become the old values for solution by TDMA at t = 0.2 s and so on. Note that in this sort of discretization a tridiagonal matrix is bound to get formed because, for discretization at node i, use is made of the values at nodes i – 1, i + 1, and i. Program 9.1 for the solution of the above problem is given in the Appendix. The coefficient matrix parameters are constant, but the right hand side of the linear algebraic equations each time is updated. The results of Program 9.1 are presented in Table 9.2.
  • 607. One-Dimensional Transient Heat Conduction 179 Table 9.2 Results of Program 9.1 Time (s) T1 T2 T3 T4 0.1 31.91 37.87 61.70 127.23 0.2 53.21 63.86 100.49 175.91 0.3 78.59 91.28 131.40 202.44 0.4 104.35 117.22 156.04 219.49 0.5 128.55 140.66 176.20 231.90 0.6 150.45 161.40 193.09 241.66 0.7 169.87 179.57 207.45 249.71 0.8 186.90 195.42 219.79 256.50 0.9 201.78 209.21 230.44 262.31 1.0 214.72 221.20 239.65 267.32 1.1 225.98 231.60 247.64 271.65 1.2 235.75 240.64 254.56 275.40 1.3 244.24 248.48 260.57 278.66 1.4 251.60 255.29 265.78 281.48 1.5 258.00 261.19 270.30 283.93 1.6 263.55 266.32 274.22 286.05 1.7 268.36 270.77 277.63 287.89 1.8 272.54 274.63 280.58 289.49 1.9 276.17 277.98 283.15 290.88 2.0 279.32 280.89 285.38 292.09 2.1 282.05 283.42 287.31 293.13 2.2 284.42 285.61 288.99 294.04 2.3 286.48 287.51 290.44 294.83 2.4 288.27 289.16 291.70 295.51 2.5 289.82 290.59 292.80 296.10 2.6 291.16 291.84 293.75 296.62 2.7 292.33 292.91 294.58 297.07 2.8 293.34 293.85 295.29 297.45 2.9 294.22 294.66 295.92 297.79 3.0 294.99 295.37 296.46 298.08 3.1 295.65 295.98 296.92 298.33 EXAMPLE 9.2 A brick wall with a thickness of 0.5 m is initially at a uniform temperature of 300 K. At time t = 0 the left surface is maintained at 425 K and right at 600 K. Determine the time required for its centre temperature to reach 425 K. Use implicit discretization and take Dx = 0.05 m, a = 10–5 m2 /s, and Dt = 1.0 s. Solution The schematic diagram is shown in Fig. 9.2. Fig. 9.2 Example 9.2. 1 6 11 600425 Initial temperature = 300
  • 608. 180 Introduction to Numerical Methods in Chemical Engineering In a rectangular slab 6 6 V Z B ˜ ˜ ˜ ˜ Discretizing using implicit FTCS at node i, we get P P P P P K K K K K 6 6 6 6 6 V Z B È Ø É Ù' 'Ê Ú Dx = 0.05 m and Dt = 1.0 s; thus V Z B ' –' . Therefore
  • 609. P P P P P K K K K K6 6 6 6 6 P P P P K K K K 6 6 6 6 At node 2 P P P P 6 6 6 6 Since T1 = 425, we get P P P 6 6 6 – At node 3 P P P P 6 6 6 6 At node 9 P P P P 6 6 6 6 At node 10 P P P P 6 6 6 6 Since T11 = 600, we get P P P 6 6 6 – Thus the unknowns are T2 to T10. The tridiagonal set of 9 linear algebraic equations is P P P P P P P P 6 6 6 6 6 6 6 6 Ë Û Ë ÛË Û Ì Ü Ì ÜÌ Ü Ì Ü Ì ÜÌ Ü Ì Ü Ì ÜÌ Ü Ì Ü Ì ÜÌ ÜÌ Ü Ì Ü Ì Ü Ì Ü Ì ÜÌ ÜÍ ÝÌ Ü Ì ÜÍ Ý Í Ý Initially P P P P P P P P P 6 6 6 6 6 6 6 6 6 . After every iteration the time is incremented by 1 s. We have to determine the time when T6 = 425. Program 9.1 can
  • 610. One-Dimensional Transient Heat Conduction 181 be modified by changing the coefficients and the following solution is obtained at 2865 s: T2 = 415.87, T3 = 409.24, T4 = 407.40, T5 = 412.24, T6 = 425.06, T7 = 446.44, T8 = 476.11, T9 = 512.95, and T10 = 555.07. 9.6 Transient Conduction in Cylinder One-dimensional transient heat conduction in a cylinder using the implicit method is described in the example below. EXAMPLE 9.3 Consider a cylinder of radius 0.4 cm. Initially the temperature is uniform at 20°C. The temperature of the cylinder surface is made 300°C at t = 0 s. Use implicit discretization and take Dr = 0.1 cm, Dt = 0.1 s, and a = 10–5 m2 /s. List the tridiagonal system of equations and determine the temperature at the centre and the intermediate points of the cylinder up to 2.1 s. Solution The partial differential equation is 6 6 6 V T TT B È Ø˜ ˜ ˜ É Ù˜ ˜˜Ê Ú Using the forward in time and central in space implicit difference scheme, we get
  • 611. P P P P P P P K K K K K K K6 6 6 6 6 6 6 V O T TT B Ë ÛÈ Ø Ì Ü É Ù' ' 'Ì ÜÊ Ú'Í Ý
  • 612. P P P P P P P K K K K K K K 6 6 / 6 6 6 6 6 O Ë Û Ì Ü Í Ý where
  • 613. V / T B' ' . P P P P P K K K K K / / 6 6 6 / 6 / /6 O O È Ø È Ø É Ù É ÙÊ Ú Ê Ú
  • 614. P P P P K K K K / / / 6 / 6 / 6 6 O O È Ø È Ø É Ù É ÙÊ Ú Ê Ú At node 2 (m = 1)
  • 615. P P P P/ / / 6 / 6 / 6 6 È Ø È Ø É Ù É ÙÊ Ú Ê Ú At node 3 (m = 2)
  • 616. P P P P/ / / 6 / 6 / 6 6 È Ø È Ø É Ù É ÙÊ Ú Ê Ú
  • 617. 182 Introduction to Numerical Methods in Chemical Engineering At node 4 (m = 3)
  • 618. P P P P/ / / 6 / 6 / 6 6 È Ø È Ø É Ù É ÙÊ Ú Ê Ú where T5 = 300°C. On using L’Hospital’s rule at node 1, the PDE becomes 6 6 V T ˜ ˜ ˜ ˜ . Using implicit FTCS to discretize, we get
  • 620. P P PP P K K KK K 6 6 66 6 V T ' '
  • 621. P P P P P K K K K K6 6 / 6 6 6
  • 624. P P P P K K K K / 6 / 6 / 6 6 At i = 1, we get
  • 627. P P P P / 6 / 6 / 6 6 where 0 is a hypothetical node to the left of node 1. Since at r = 0, 6 T ˜ ˜ , P P 6 6 T ' ; thus P P 6 6 . Thus at i = 1, we get
  • 629. P P P / 6 / 6 6 The following tridiagonal set of linear algebraic equations is obtained. PP PP PP PP / / 66// / 66 / / 6/ 6 /66/ / Ë Û Ë ÛÌ ÜË Û Ì ÜÌ ÜÌ Ü Ì ÜÌ ÜÌ Ü Ì ÜÌ ÜÌ Ü Ì Ü Ì ÜÌ Ü Ì ÜÌ ÜÌ Ü –Ì Ü Ì ÜÍ ÝÌ Ü Í Ý Ì ÜÍ Ý where the old values are at time n and the computed values are at time n + 1. Here a = 10–5 m2 /s, Dt = 0.1 s, Dr = 0.1 cm, P P P P 6 6 6 6 °C, T5 = 300°C. Thus
  • 631. V / T B ' – ' – P P P P P P P P 6 6 6 6 6 6 6 6 Ë Û Ë ÛË Û Ì Ü Ì ÜÌ Ü Ì Ü Ì ÜÌ Ü Ì Ü Ì ÜÌ Ü Ì Ü Ì ÜÌ Ü Ì Ü Ì ÜÌ ÜÍ Ý Ì Ü Ì ÜÍ Ý Í Ý
  • 632. One-Dimensional Transient Heat Conduction 183 At time t = 0, P P P P 6 6 6 6 °C, and the solution by TDMA is obtained at time t = 0.1 s. These become the old values for solution by TDMA at t = 0.2 s and so on. Program 9.1 can be modified to solve this problem and the results are given in Table 9.3. Table 9.3 Results in Example 9.3 Time (s) T1 T2 T3 T4 0.1 48.29 55.37 81.30 145.91 0.2 91.65 102.48 137.51 203.48 0.3 135.90 146.97 180.31 234.56 0.4 174.33 183.93 211.78 253.66 0.5 205.21 212.93 234.84 266.43 0.6 229.08 235.05 251.79 275.39 0.7 247.17 251.69 264.29 281.85 0.8 260.72 264.11 273.53 286.56 0.9 270.83 273.36 280.36 290.04 1.0 278.34 280.22 285.43 292.60 1.1 283.92 285.32 289.18 294.49 1.2 288.06 289.09 291.96 295.90 1.3 291.13 291.89 294.02 296.94 1.4 293.40 293.97 295.54 297.71 1.5 295.09 295.51 296.67 298.28 1.6 296.34 296.65 297.51 298.70 1.7 297.26 297.49 298.13 299.02 1.8 297.95 298.12 298.60 299.25 1.9 298.46 298.58 298.94 299.42 2.0 298.83 298.93 299.19 299.55 2.1 299.11 299.18 299.38 299.64 The number of parts can be increased to obtain a better solution. 9.7 Transient Conduction in Sphere One-dimensional transient heat conduction in a sphere using the implicit method is described in the example below. EXAMPLE 9.4 Consider a sphere of radius 0.4 cm. Initially the temperature is uniform at 20°C. The temperature of the sphere surface is made 300°C at t = 0 s. Use implicit discretization and take Dr = 0.1 cm, Dt = 0.1 s, and a = 10–5 m2 /s. List the tridiagonal system of equations and determine the temperature at the centre and the intermediate points of the sphere up to 1.4 s. Solution The partial differential equation is 6 6 6 V T TT B È Ø˜ ˜ ˜ É Ù˜ ˜˜Ê Ú
  • 633. 184 Introduction to Numerical Methods in Chemical Engineering Using the forward in time and central in space implicit difference scheme, we get
  • 634. P P P P P P P K K K K K K K6 6 6 6 6 6 6 V O T TT B Ë ÛÈ Ø Ì Ü É Ù' ' 'Ì ÜÊ Ú'Í Ý
  • 635. P P P P P P P K K K K K K K 6 6 / 6 6 6 6 6 O Ë Û Ì Ü Í Ý where
  • 636. V / T B' ' . P P P P P K K K K K / / 6 6 6 / 6 / /6 O O È Ø È Ø É Ù É ÙÊ Ú Ê Ú
  • 637. P P P P K K K K / / 6 / 6 / 6 / 6 O O È Ø È Ø É Ù É ÙÊ Ú Ê Ú At node 2 (m = 1)
  • 640. P P P P 6 / / 6 6 / 6 At node 3 (m = 2)
  • 641. P P P P/ / 6 / 6 / 6 / 6 È Ø È Ø É Ù É ÙÊ Ú Ê Ú At node 4 (m = 3)
  • 642. P P P P/ / 6 / 6 / 6 / 6 È Ø È Ø É Ù É ÙÊ Ú Ê Ú where T5 = 300°C At node 1 the PDE becomes 6 6 V T ˜ ˜ ˜ ˜ . Again, using the implicit FTCS, we get
  • 644. P P PP P K K K K K 6 6 66 6 V T ' '
  • 645. P P P P P K K K K K6 6 / 6 6 6
  • 648. P P P P K K K K 6 / 6 / 6 / 6 At i =1, we get
  • 651. P P P P 6 / 6 / 6 / 6 where 0 is a hypothetical node to the left of node 1. At r = 0, 6 T ˜ ˜ ; thus P P 6 6 T ' and so P P 6 6 .
  • 652. One-Dimensional Transient Heat Conduction 185 Thus at i = 1, we get
  • 654. P P P 6 / 6 / 6 The following tridiagonal set of linear algebraic equations is obtained: PP PP PP PP / / 66 / / 66 // / 66 // 6/ 6 Ë Û Ë ÛË Û Ì Ü Ì ÜÌ Ü Ì Ü Ì ÜÌ Ü Ì Ü Ì ÜÌ Ü Ì Ü Ì ÜÌ Ü Ì Ü Ì ÜÌ Ü –Ì Ü Ì Ü Ì ÜÍ Ý Í ÝÍ Ý where the old values are at time n and the computed values are at time n + 1. Here a = 10–5 m2 /s, Dt = 0.1 s, Dr = 0.1 cm, P P P P 6 6 6 6 °C, T5 = 300°C. Thus
  • 656. V / T B ' – ' – P P P P P P P P 6 6 6 6 6 6 6 6 Ë Û Ë ÛË Û Ì Ü Ì ÜÌ Ü Ì Ü Ì ÜÌ Ü Ì Ü Ì ÜÌ Ü Ì Ü Ì ÜÌ Ü Ì Ü Ì ÜÌ ÜÍ Ý Ì Ü Ì ÜÍ Ý Í Ý At time t = 0, P P P P 6 6 6 6 °C and the solution by TDMA is obtained at time t = 0.1 s. These become the old values for solution by TDMA at t = 0.2 s and so on. Program 9.1 can be modified to solve this problem and the results are given in Table 9.4. Table 9.4 Results in Example 9.4 Time (s) T1 T2 T3 T4 0.1 65.71 73.33 100.00 162.22 0.2 126.67 136.83 168.57 224.87 0.3 180.57 189.55 215.92 256.27 0.4 220.93 227.66 246.71 273.58 0.5 248.79 253.44 266.33 283.71 0.6 267.24 270.32 278.75 289.85 0.7 279.18 281.17 286.60 293.64 0.8 286.82 288.09 291.55 296.00 0.9 291.67 292.48 294.67 297.48 1.0 294.74 295.25 296.64 298.41 1.1 296.68 297.00 297.88 299.00 1.2 297.91 298.11 298.66 299.37 1.3 298.68 298.81 299.16 299.60 1.4 299.17 299.25 299.47 299.75
  • 657. 186 Introduction to Numerical Methods in Chemical Engineering 9.8 Transient Diffusion in Sphere One-dimensional transient diffusion in a sphere using the implicit method is described in the example below. EXAMPLE 9.5 Consider a 6.52 mm diameter bead which contains 10 mg of a certain drug in gel matrix. The diffusion coefficient of drug in gel matrix is 3.0 ´ 10–7 cm2 /s. The drug is immediately swept away once it reaches the bulk solution, that is, CS = 0. The transient diffusion of the drug is given by % % % V T TT È Ø˜ ˜ ˜ É Ù˜ ˜˜Ê Ú The boundary conditions are At r = 0: % T ˜ ˜ t ³ 0 At r = R: C = CS = 0 t 0 The initial condition is At t = 0: C = C0 0 £ r £ R Determine the concentration of the drug in the centre of the bead after 3, 12, 24, and 48 h. Make 10 parts of the radius from r = 0 to r = R. Take Dt = 1.0 s. Solution The radius of the bead is 0.326 cm and the initial concentration of the drug in the bead is = OI 4Q mg/cm3 . The schematic diagram of the bead from r = 0 to r = R with 10 parts is shown in Fig. 9.3. Fig. 9.3 Example 9.5. In a sphere % % % V T TT È Ø˜ ˜ ˜ É Ù˜ ˜˜Ê Ú 0 5 10 r = R C = 0 Initial concentration = 68.9 mg/cm3 T F% FT
  • 658. One-Dimensional Transient Heat Conduction 187 Discretizing using FTCS at node i, we get P P P P P P P K K K K K K K % % % % % % % V O T TT' ' '' § · ¨ ¸¨ ¸ © ¹
  • 659. P P P P P P P K K K K K K K V % % % % % % % OT ' ' ª º « » ¬ ¼ Dr = 0.0326 cm and Dt = 1.0 s. Thus V T ' – – –' Thus at node i
  • 660. P P P P P P P K K K K K K K % % % % % % % O – ª º « » ¬ ¼ P P P P K K K K % % % % O O § · § · ¨ ¸ ¨ ¸ © ¹ © ¹ Using L’Hospital’s rule, the PDE at node 0 becomes % % V T ˜ ˜ ˜ ˜ Discretizing the above equation at node 0, we get
  • 661. P P P P P% % % % % V T ' '
  • 663. P P P P P % % % % % At node 0, % T ˜ ˜ ; thus % % T ' , and therefore C1 = C–1. Thus the above equation becomes
  • 665. P P P P % % % %
  • 666. P P P P % % % % Thus the equation at node 0 is P P P % % % At node 1 P P P P % % % % È Ø È Ø É Ù É ÙÊ Ú Ê Ú
  • 667. 188 Introduction to Numerical Methods in Chemical Engineering At node 2 P P P P % % % % È Ø È Ø É Ù É ÙÊ Ú Ê Ú At node 8 P P P P % % % % È Ø È Ø É Ù É ÙÊ Ú Ê Ú At node 9 P P P P % % % % È Ø È Ø É Ù É ÙÊ Ú Ê Ú Since C10 = 0, the equation for node 9 becomes P P P % % % È Ø É ÙÊ Ú The above set of 10 equations (at nodes 0 to 9) can be written in tridiagonal form as
  • 672. P P P P P P P P % % % % % % % % Ë Û Ì ÜË Û Ë Û Ì Ü Ì Ü Ì Ü Ì ÜÌ Ü Ì Ü Ì ÜÌ Ü Ì Ü Ì ÜÌ Ü Ì Ü Ì ÜÌ Ü Ì Ü Ì ÜÌ Ü Ì Ü Ì ÜÌ Ü Ì ÜÍ Ý Í Ý Ì Ü Ì ÜÍ Ý Initially P P P P P P P P P P % % % % % % % % % % mg/cm3 . At the comple- tion of an iteration, time is incremented by 1 s. Program 9.2 for the solution of the above problem is given in the Appendix. The following concentration of drug at the centre of the bead is obtained from Program 9.2: after 3 h the concentration is 62.39 mg/cm3 ; after 12 h the concentration is 26.36 mg/cm3 , after 24 h the concentration is 7.99 mg/cm3 ; and after 48 h the concentration is 0.73 mg/cm3 . Exercises 9.1 Consider transient heat conduction in a rectangular slab. The total width of the rectangular slab is 1 cm. Initially the temperature is uniform at 25°C. The temperature of the end-faces of the rectangular slab is made 300°C at t = 0 s. Use implicit discretization and take Dx = 0.1 cm, Dt = 0.1 s, and a = 10–5 m2 /s. List the tridiagonal system of equations and determine the temperature at the centre and the intermediate points of the slab after 5 s. (Ans: The tridiagonal set of equations is
  • 673. One-Dimensional Transient Heat Conduction 189 P P P P P P P P P P 6 6 6 6 6 6 6 6 6 6 Ë Û Ë ÛË ÛÌ Ü Ì Ü Ì Ü Ì Ü Ì ÜÌ ÜÌ Ü Ì Ü Ì Ü Ì Ü Ì Ü Ì ÜÌ Ü Ì Ü Ì ÜÌ Ü Ì Ü Ì Ü Ì Ü Ì ÜÍ Ý Í Ý Í Ý T1 = T(0.0) = 87.43 T2 = T(0.1) = 96.08 T3 = T(0.2) = 122.44 T4 = T(0.3) = 166.98 T5 = T(0.4) = 228.16. Distance (in cm) is measured from the centre. 9.2 Consider a cylinder of radius 0.5 cm. Initially the temperature is uniform at 25°C. The temperature of the cylinder surface is made 300°C at t = 0 s. Use implicit discretization and take Dr = 0.1 cm, Dt = 0.1 s, and a = 10–5 m2 /s. List the tridiagonal system of equations and determine the temperature at the centre and the intermediate points of the cylinder after 5 s. (Ans: The tridiagonal set of equations is PP PP PP PP PP 66 66 66 66 66 Ë Û Ë ÛË Û Ì Ü Ì ÜÌ Ü Ì Ü Ì ÜÌ Ü Ì Ü Ì Ü Ì Ü Ì Ü Ì ÜÌ Ü Ì Ü Ì Ü Ì Ü Ì Ü Ì ÜÌ Ü Ì Ü Ì ÜÌ Ü Í ÝÌ Ü Ì ÜÍ ÝÍ Ý T1 = T(0.0) = 150.81 T2 = T(0.1) = 158.06 T3 = T(0.2) = 179.46 T4 = T(0.3) = 213.45 T5 = T(0.4) = 256.06 Distance (in cm) is measured from the centre. 9.3 Consider a sphere of radius 0.5 cm. Initially the temperature is uniform at 25°C. The temperature of the sphere surface is made 300°C at t = 0 s. Use implicit discretization and take Dr = 0.1 cm, Dt = 0.1 s, and a = 10–5 m2 /s. List the tridiagonal system of equations and determine the temperature at the centre and the intermediate points of the sphere after 5 s. (Ans: The tridiagonal set of equations is PP PP PP PP PP 66 66 66 66 66 Ë ÛË ÛË Û Ì ÜÌ ÜÌ Ü Ì ÜÌ ÜÌ Ü Ì ÜÌ ÜÌ Ü Ì ÜÌ ÜÌ Ü Ì ÜÌ ÜÌ Ü Ì ÜÌ ÜÌ Ü Ì ÜÌ ÜÌ Ü Í ÝÍ Ý Ì ÜÍ Ý
  • 674. 190 Introduction to Numerical Methods in Chemical Engineering T1 = T(0.0) = 200.21 T2 = T(0.1) = 205.72 T3 = T(0.2) = 221.68 T4 = T(0.3) = 245.88 T5 = T(0.4) = 274.07 Distance (in cm) is measured from the centre. 9.4 Consider a concrete wall 0.5 m thick. Initially the temperature is uniform at 20°C. The temperature of one surface of the wall x = 0 is suddenly raised to 80°C and the right surface at x = 0.5 m remains always at 20°C. Use implicit discretization and take Dx = 0.1 m, Dt = 10 s, and a = 1.25 ´ 10–5 m2 /s. List the tridiagonal system of equations and determine the temperature distribution throughout the slab after 1 h. (Ans: The tridiagonal set of equations are P P P P P P P P 6 6 6 6 6 6 6 6 Ë Û Ë Û Ë Û Ì Ü Ì ÜÌ Ü Ì Ü Ì ÜÌ ÜÌ Ü Ì ÜÌ Ü Ì Ü Ì ÜÌ Ü Ì Ü Ì ÜÌ ÜÍ Ý Ì Ü Ì ÜÍ Ý Í Ý T2 = T(0.1) = 64.06 T3 = T(0.2) = 49.66 T4 = T(0.3) = 37.70 T5 = T(0.4) = 28.13 Distance (in m) is measured from surface at 80°C. 9.5 A large flat slab of clay is to be dried. The slab is dried from both sides, is 4 cm thick and has an initial uniform water concentration of 0.5 g of water per cm3 . The movement of water within the clay occurs by diffusion. It is known that, with the proposed drying conditions, the drying will occur in the constant rate period at a rate of 0.1 g/cm2 -h of water as long as the surface moisture concentration remains above 0.2257 g of water per cm3 . Use implicit discretization and take Dx = 0.2 cm, Dt = 0.01 h, and D = 0.25 cm2 /h. List the tridiagonal system of equations and determine the duration of the constant rate period and the distribution of water within the clay at the end of the constant rate period. The partial differential equation is % % V Z ˜ ˜ ˜ ˜ and the boundary conditions are: at x = 0 (centre), % Z ˜ ˜ and at x = 2 cm, % Z ˜ ˜ (Ans: The solution of the problem is obtained by calculating the time required for the surface concentration to fall to 0.2257 g/cm3 . This concentration is obtained at 1.5 h. The tridiagonal set of equations is
  • 675. One-Dimensional Transient Heat Conduction 191 P P P P P P P P % % % % % % % % Ë Û Ë ÛË Û Ì Ü Ì ÜÌ Ü Ì Ü Ì ÜÌ Ü Ì Ü Ì ÜÌ Ü Ì Ü Ì ÜÌ Ü Ì Ü Ì Ü Ì Ü Ì Ü Ì ÜÌ ÜÍ ÝÌ Ü Ì Ü Í Ý Í Ý At t = 1.5 h: C1 = C(0.0) = 0.4947 C2 = C(0.2) = 0.4937 C3 = C(0.4) = 0.4904 C4 = C(0.6) = 0.4841 C5 = C(0.8) = 0.4738 C6 = C(1.0) = 0.4578 C7 = C(1.2) = 0.4342 C8 = C(1.4) = 0.4011 C9 = C(1.6) = 0.3563 C10 = C(1.8) = 0.2983 C11 = C(2.0) = 0.2257 Distance (in cm) is measured from the centre.
  • 676. 192 Chapter 10 Two-Dimensional Steady and Transient Heat Conduction Two-dimensional steady heat conduction is given by 6 6 Z [ ˜ ˜ ˜ ˜ (10.1) This is an elliptic partial differential equation and the temperature T(x, y) must satisfy this equation as well as the boundary conditions along the entire boundary of the plate. Two- dimensional transient heat conduction is given by [see Eq. (9.26)] 6 6 6 V Z [ B È Ø˜ ˜ ˜ É Ù˜ ˜ ˜Ê Ú This is a parabolic partial differential equation. Relaxation techniques are used for the numerical solution of elliptic equations, whereas marching in time is used for parabolic equations. The numerical solution of two-dimensional steady heat conduction is carried out by the Gauss–Seidel, Red–Black Gauss–Seidel, and Alternating Direction Implicit (ADI) methods. The boundary conditions like convection, exterior corner with convection, interior corner with convection and insulation are discussed in this chapter. The numerical solution of two-dimensional transient heat conduction is discussed using ADI method, which is an implicit method and is therefore unconditionally stable. It is also called line-by-line TDMA. 10.1 Discretization in Two-Dimensional Space Consider a two-dimensional body as shown in Fig. 10.1. Around each node a control volume is made. If there is no net accumulation of mass in the body, then the mass balance equation at a node can be interpreted as indicating that the net mass entering through all the four sides of the control volume is zero. The depth of the body in the z-direction may be taken to be unity. The temperature in the control volume is uniform and under steady conditions the heat input through all the sides of the control volume is zero. The heat inputs are given by terms like 6 M# Z ˜ ˜ and 6 M# [ ˜ ˜ . Therefore the derivatives 6 Z ˜ ˜ and 6 [ ˜ ˜ have to be evaluated at the control volume boundaries. The temperature gradients around the control volume (i, j) may be written as
  • 677. Two-Dimensional Steady and Transient Heat Conduction 193 K L K L K L 6 66 Z Z ˜  ˜ ' (10.2) K L K L K L 6 66 Z Z ˜  ˜ ' (10.3) K L K L K L 6 66 [ [ ˜  ˜ ' (10.4) K L K L K L 6 66 [ [ ˜  ˜ ' (10.5) Fig. 10.1 Control volume around node. The second derivatives may be written as
  • 678. K L K L K L K L K L K L K L K L K L K L K K 6 6 Z Z 6 6 6 6 6 6 66 Z ZZ Z Z ˜ ˜ ˜ ˜ ˜  ˜ ' ' (10.6)
  • 679. K L K L K L K L K L K L K L K L K L K L L L 6 6 [ [ 6 6 6 6 6 6 66 [ [[ [ [ ˜ ˜ ˜ ˜ ˜  ˜ ' ' (10.7) Dy i + 1, j i, j + 1 i – 1, j i, j – 1 Dx i, j K L K L K L K L
  • 680. 194 Introduction to Numerical Methods in Chemical Engineering Discretizing the equation 6 6 Z [ ˜ ˜ ˜ ˜ for any interior node in which the source term is zero, we get K L K L K L K L K L K L 6 6 6 6 6 6 Z [' ' (10.8) For Dx = Dy, we get K L K L K L K L K L K L 6 6 6 6 6 6 or K L K L K L K L K L 6 6 6 6 6 (10.9) 10.2 Gauss-Seidel Method In calculating Ti,j the values of the temperatures on the right hand side of Eq. (10.9) consist initially of estimated values or known boundary values. However, as soon as an appropriate temperature at a node is calculated, this calculated value supersedes the estimated value and is used as the temperature at that point until it is, in turn, superseded by a new calculated value. Thus the latest calculated values of the temperatures are always used in calculating newer and better values. Consider nodes in a two-dimensional space, with the bottom left node being (0,0) and the top right node being (10,10). Suppose that node (0,0) is updated first followed by node (1,0), (2,0),…, (10,0), (0,1), (1,1),…, (10,1), (0,2), (1,2),…, (10,2),…, (0,10), (1,10),…, (10,10). Then, by the time the value of Ti,j is updated, the values Ti–1,j and Ti,j–1 have already been updated. On using the Gauss–Seidel method, Eq. (10.9) becomes P P P P K L K L K L K LP K L 6 6 6 6 6 (10.10) 10.3 Relaxation Parameter The temperature taken at the beginning of an iteration is Tn and the new temperature computed during the iteration is Tn+1 . Now, for the next iteration the temperature can be taken to be either Tn+1 , between Tn and Tn+1 , or more than Tn+1 , and is given by P P P 6 6 6X' (10.11) The parameter w is known as the relaxation parameter. The various cases are described in Table 10.1.
  • 681. Two-Dimensional Steady and Transient Heat Conduction 195 Table 10.1 Relaxation parameter values Temperature New Temperature Relaxation Type of taken at the temperature taken at the parameter Relaxation beginning of computed beginning of iteration during iteration next iteration 100 110 110 1 Gauss–Seidel 100 110 105 0.5 Underrelaxation 100 110 115 1.5 Overrelaxation The method is convergent only for 0 w 2. For overrelaxation the relaxation parameter lies between 1 and 2 and for underrelaxation between 0 and 1. When w = 1, it becomes the Gauss– Seidel method. The optimum value of w is different for each problem. It has to be determined by hit and trial. 10.4 Red–Black Gauss–Seidel Method When the Gauss–Seidel method is used, the nodes are processed down the rows (or columns) or the mesh is divided into black and red nodes as shown in Fig. 10.2. This method for solution of elliptic PDE is Red–Black Gauss–Seidel. Both Gauss–Seidel and Red–Black Gauss–Seidel are pointwise methods. The Alternating Direction Implicit (ADI) method described in the next section is a line-by-line method. R B R B R B R B R B R B R B R B B R B R B R B R B R B R B R B R R B R B R B R B R B R B R B R B B R B R B R B R B R B R B R B R R B R B R B R B R B R B R B R B B R B R B R B R B R B R B R B R R B R B R B R B R B R B R B R B B R B R B R B R B R B R B R B R Fig. 10.2 Red–black nodes in two-dimensional space. The nodes surrounding the black node are all red and the nodes surrounding the red node are all black. The surrounding nodes are those nodes which are to the east, west, north and south of a node. The other four nodes are called the corner nodes of node (i, j). Consider again the finite difference equation (10.9): K L K L K L K L K L 6 6 6 6 6 Red points depend only on the black points and black points depend only on the red points. Thus we can carry out one half-sweep updating the red points and then another half-sweep
  • 682. 196 Introduction to Numerical Methods in Chemical Engineering updating the black points with the new red values. Thus, the Red–Black Gauss–Seidel method is the one in which the red nodes are updated using black nodes and then the black nodes are updated using the updated red nodes. This procedure is repeated till the following convergence criterion is satisfied: P P K L K L6 6 F . EXAMPLE 10.1 Determine the temperature at various nodes shown in Fig. 10.3. The two- dimensional heat transfer is given by the equation 6 6 Z [ ˜ ˜ ˜ ˜ . The boundary conditions are shown in Fig. 10.3. The size of the slab is 2 m ´ 2 m and Dx = Dy = 0.5 m. Use the Gauss– Seidel method. Fig. 10.3 Example 10.1 Solution Since all the nodes are interior nodes, therefore the discretized equation at node (i, j) is given by K L K L K L K L K L 6 6 6 6 6 Thus P P P 6 6 6 P P P P 6 6 6 6 P P P 6 6 6 P P P P 6 6 6 6 P P P P P 6 6 6 6 6 400°C 20°C 20°C20°C T1,3 T2,3 T3,3 T1,2 T2,2 T3,2 T1,1 T2,1 T3,1
  • 683. Two-Dimensional Steady and Transient Heat Conduction 197 P P P P 6 6 6 6 P P P 6 6 6 P P P P 6 6 6 6 P P P 6 6 6 Note that the coefficient of the term on the left hand side is the highest among all the other coefficients in the linear algebraic equation. That is why convergence is obtained when the Gauss–Seidel method is used for solving the above set of linear algebraic equations. To start the iteration, some initial values of all the nine variables are assumed and thereafter their latest values are used to update the solution. The iterations are performed till there is no change in the value of temperature P P K L K L6 6 F . Program 10.1 for the solution of the above problem is given in the Appendix. The converged solution is T1,1 = 47.14 T2,1 = 57.32 T3,1 = 47.14 T1,2 = 91.25 T2,2 = 115.00 T3,2 = 91.25 T1,3 = 182.86 T2,3 = 220.18 T3,3 = 182.86 EXAMPLE 10.2 Consider the following body in which the inner face is at 200°C and the outer face is at 100°C. The body is very long so that heat transfer takes place in two dimensions only. The thermal conductivity of the body is 1.21 W/m-K. The dimensions of the body are shown in Fig. 10.4. Take Z [' ' m. Fig. 10.4 Example 10.2. 3 m 1 m 3 m 1 m 1 2 345 100°C 200°C
  • 684. 198 Introduction to Numerical Methods in Chemical Engineering Using the Gauss–Seidel method, solve for the temperatures at nodes 1 to 5. Solution Since there is no source term, we get P P 6 6 P P P 6 6 6 P P P 6 6 6 P P P 6 6 6 P P 6 6 On modifying the Program 10.1, the following solution is obtained: T1 = 145.83°C, T2 = 141.67°C, T3 = 120.83°C, T4 = 141.67°C, T5 = 145.83°C. EXAMPLE 10.3 Determine the temperature at various nodes shown in Fig. 10.5. The heat transfer is given by the equation 6 6 Z [ ˜ ˜ ˜ ˜ . The boundary conditions are shown in the figure. The size of the slab is 2 m ´ 2 m and Dx = Dy = 0.5 m. Use the Red–Black Gauss– Seidel method. Fig. 10.5 Example 10.3. Solution Before starting the iterations the following initial values of temperatures at the black nodes are assumed: B1 = 55, B2 = 90, B3 = 90, B4 = 220°C. Now we compute values at the red nodes using the assumed values at the black nodes. % 4 q 400°C 20°C 20°C20°C R4 B4 R5 B2 R3 B3 R1 B1 R2
  • 685. Two-Dimensional Steady and Transient Heat Conduction 199 % 4 q % 4 q % 4 q % 4 q Now let us update the black node values using the updated values at the red nodes. % $ q % $ q % $ q % $ q Updating the red nodes using the updated black node values, we get: R1 = 46.80, R2 = 46.80, R3 = 114.375, R4 = 182.578, R5 = 182.578°C. Updating the black nodes using updated red node values, we get: B1 = 56.994, B2 = 90.938, B3 = 90.938, B4 = 219.88°C. Note that even after two iterations the temperatures are close to the converged values obtained using the Gauss–Seidel method in Example 10.1. The iterations are performed till there is no change in the value of temperature, P P K L K L6 6 F . EXAMPLE 10.4 Discretize the equation 6 6 Z [ ˜ ˜ ˜ ˜ at node (i, j) of a convection boundary as shown in Fig. 10.6. Fig. 10.6 Convection boundary condition. Dy Dx i – 1, j i, j – 1 Convection boundary i, j + 1 i, j dq2 dq4 dq1 dq3 Dx 2 T¥ h
  • 686. 200 Introduction to Numerical Methods in Chemical Engineering Solution The given differential equation is at steady state and therefore in the control volume around node (i, j), the summation of S entering the control volume from all the four sides is zero. From the left and right sides, FS 6 M# FV Z ˜ ˜ , and from top and bottom, FS 6 M# FV [ ˜ ˜ . To determine the area for heat transfer into the control volume, the depth is taken to be unity. The various energy inputs into the control volume around node (i, j) are K L K L 6 6FS Z M FV [ È Ø' É Ù'Ê Ú K L K L 6 6FS M [ FV Z È Ø ' É Ù'Ê Ú K L K L 6 6FS Z M FV [ È Ø' É Ù'Ê Ú
  • 687. K L FS J [ 6 6 FV ‡' Thus, from the energy balance at node
  • 688. ji, , we get FSFS FS FS FV FV FV FV Thus
  • 689. K L K L K L K L K L K L K L 6 6 6 6 6 6Z Z M M [ M J [ 6 6 [ Z [ ' ' ' ' ' ' ' f § · § · § · ¨ ¸ ¨ ¸ ¨ ¸ © ¹ © ¹ © ¹ where T¥ is the free stream temperature of the surrounding fluid and h is the convective heat transfer coefficient between the convection boundary surface and fluid. If Dx = Dy, the equation becomes
  • 693. K L K L K L K L K L K L K L M M 6 6 M 6 6 6 6 J Z 6 6' f Collecting the terms of Ti,j on one side and the rest of the terms on the other side, we get
  • 694. K L K L K L K L 6 6 6 $K6 6 $K f where the Biot number is given by J Z $K M ' An equation of this type is applicable for each node along the convection boundary surface.
  • 695. Two-Dimensional Steady and Transient Heat Conduction 201 EXAMPLE 10.5 Discretize the equation 6 6 Z [ ˜ ˜ ˜ ˜ at node (i, j) of an exterior corner with convection boundary condition as shown in Fig. 10.7. Fig. 10.7 Exterior corner with convection boundary condition. Solution From the energy balance at node (i, j), we get
  • 697. K L K L K L K L K L K L 6 6 6 6[ Z Z [ M M J 6 6 J 6 6 Z [ ' ' ' ' ' ' f f § · § · ¨ ¸ ¨ ¸ © ¹ © ¹ where T¥ is the free stream temperature of the surrounding fluid and h is the convective heat transfer coefficient between the convection boundary surface and the fluid. If Dx = Dy, the equation becomes
  • 700. K L K L K L K L K L M M 6 6 6 6 J Z 6 6' f Collecting the terms of Ti, j on one side and the rest of the terms on the other side, we get
  • 701. K L K L K L 6 6 $K6 6 $K f EXAMPLE 10.6 Discretize the equation 6 6 Z [ ˜ ˜ ˜ ˜ at node (i, j) of an interior corner with the convection boundary condition as shown in Fig. 10.8. Dy Dx i – 1, j i, j – 1 Dx T¥ h T¥ h i, j 2 i – 1, j – 1
  • 702. 202 Introduction to Numerical Methods in Chemical Engineering Fig. 10.8 Interior corner with convection boundary condition. Solution From the energy balance at node (i, j), we get K L K L K L K L K L K L K L K L 6 6 6 6 6 6 6 6[ Z M M Z M [ M Z [ Z [ ' ' ' ' ' ' ' ' § · § · § · § · ¨ ¸ ¨ ¸ ¨ ¸ ¨ ¸ © ¹ © ¹ © ¹ © ¹
  • 704. K L K L Z [ J 6 6 J 6 6 ' ' f f where T¥ is the free stream temperature of the surrounding fluid and h is the convective heat transfer coefficient between the convection boundary surface and the fluid. Taking Dx = Dy and dividing by k, we get
  • 707. K L K L K L K L K L K L K L K L K L 6 6 6 6 6 6 6 6 $K 6 6 f Collecting the terms of Ti, j on one side and the rest of the terms on the other side, we get
  • 708. K L K L K L K L K L 6 6 6 6 $K6 6 $K f EXAMPLE 10.7 Discretize the equation 6 6 Z [ ˜ ˜ ˜ ˜ at node (i, j) of an insulation boundary as shown in Fig. 10.9. Dy Dx i – 1, j i, j + 1 Dx i, j 2 i + 1, j T¥ h i, j – 1
  • 709. Two-Dimensional Steady and Transient Heat Conduction 203 Fig. 10.9 Insulation boundary condition. Solution The given differential equation is at steady state and therefore in the control volume around node (i, j) the summation of S entering the control volume from all the three sides is zero. There is no heat flux across the insulation boundary. From the energy balance at node (i, j), we get K L K L K L K L K L K L 6 6 6 6 6 6Z Z M M [ M [ Z [ È Ø È Ø È Ø' ' ' É Ù É Ù É Ù' ' 'Ê Ú Ê Ú Ê Ú If Dx = Dy, the equation becomes
  • 711. K L K L K L K L K L K L 6 6 6 6 6 6 Collecting the terms of Ti, j on one side and the rest of the terms on the other side, we get K L K L K L K L 6 6 6 6 Note that the insulation boundary equation is obtained by setting h = 0 in the equation for convection boundary. EXAMPLE 10.8 Determine the temperature at various nodes shown in Fig. 10.10. The steady heat transfer is given by the equation 6 6 Z [ ˜ ˜ ˜ ˜ . The left face is maintained at Dy Dx i – 1, j i, j + 1 i, j Dx 2 Insulation boundary
  • 712. 204 Introduction to Numerical Methods in Chemical Engineering 100o C and the top face at 500°C, while the other two faces are exposed to an environment at 100o C. The convective heat transfer coefficient between the right and bottom walls to the surrounding fluid is 10 W/m2 -K. The block is 1 m ´ 1 m. Use the Gauss–Seidel method. Fig. 10.10 Example 10.8. Solution Z [' ' m. At the interior nodes the discretized equation is K L K L K L K L K L 6 6 6 6 6 At nodes T1,1, T2,1, T3,2, and T3,3 the convection boundary condition exists, and at node T3,1 the exterior corner convection boundary condition exists. These convection boundary conditions have been described in previous examples. Thus the following nodal equations are obtained:
  • 713. P P P 6 6 6 P P P P 6 6 6 6 P P P 6 6 6
  • 714. P P P P 6 6 6 6 P P P P P 6 6 6 6 6 P P P P 6 6 6 6 500°C 100°C T1,3 T2,3 T3,3 T1,2 T2,2 T3,2 T1,1 T2,1 T3,1 h = 10 W/m2 -K T¥ = 100°C T¥ = 100°C h = 10 W/m2 -K
  • 715. Two-Dimensional Steady and Transient Heat Conduction 205
  • 717. P P P P 6 6 6 6
  • 718. P P P 6 6 6 Note that the coefficient of the term on the left hand side is the highest among all the other coefficients in the linear algebraic equation and that is why convergence is obtained when the Gauss–Seidel method is used. To start the iteration, some initial values of all the nine variables are assumed and thereafter their latest values are used to update the solution. The iterations are performed till there is no change in the value of the temperature at the given node, that is, P P K L K L6 6 F . Program 10.1 can be modified for the solution of this problem. The converged solution is (all T in °C) T1,1 = 157.68 T2,1 = 184.51 T3,1 = 175.32 T1,2 = 192.34 T2,2 = 231.03 T3,2 = 217.01 T1,3 = 280.65 T2,3 = 330.25 T3,3 = 309.32 EXAMPLE 10.9 For the L-shaped body shown in Fig. 10.11, determine the temperatures at nodes 1 to 9. Steady heat conduction takes place in the body, 6 6 Z [ ˜ ˜ ˜ ˜ . The left surface is insulated and the bottom surface is at a uniform temperature of 90°C. The entire top surface is subjected to convection to ambient air at 25°C. The heat transfer coefficient between the top surface and the ambient air is 75 W/m2 -K. The right surface is subjected to uniform heat flux of 4500 W/m2 . Dx = Dy = 1 cm. The thermal conductivity of the body, k = 15 W/m-K. Fig. 10.11 Example 10.9. Heat flux 4500 W/m2 Surface at 90°C Insulated Dx = 1 cm Dy = 1 cm h = 75 W/m2 -K T¥ = 25°C 1 2 3 654 7 8 9
  • 719. 206 Introduction to Numerical Methods in Chemical Engineering Solution Equation for node 1:
  • 720. 6 6 6 6Z [ Z M M J 6 6 [ Z ' ' ' ' ' f § · § · ¨ ¸ ¨ ¸ © ¹© ¹
  • 723. M 6 6 M 6 6 J Z 6 6' f
  • 724. J Z 6 6 6 6 6 6 M ' f where J Z M ' – . Thus the equation for node 1 becomes
  • 725. 6 6 6 6f The coefficient of T1 is the highest; therefore 6 6 6 Equation for node 2:
  • 726. 6 6 6 66 6[ [ M M M Z J Z 6 6 Z Z [ ' ' ' ' ' ' ' f § · § ·§ · ¨ ¸¨ ¸ ¨ ¸ © ¹ © ¹ © ¹
  • 730. J Z 6 6 6 6 6 6 6 6 M ' f
  • 731. 6 6 6 6 Equation for node 3:
  • 733. 6 6 6 6[ Z Z [ M M J 6 6 J 6 6 Z [ ' ' ' ' ' ' f f § ·§ · ¨ ¸¨ ¸ © ¹ © ¹
  • 734. 6 6 6 6 J Z 6 6 M ' f
  • 735. 6 6 6 Equation for node 4: 6 66 6 6Z Z M M M [ [ [ Z ' ' ' ' ' ' § · § · § · ¨ ¸ ¨ ¸ ¨ ¸ © ¹© ¹ © ¹ 6 6 6 6 6 6 6 6
  • 736. Two-Dimensional Steady and Transient Heat Conduction 207 Equation for node 5: 6 6 6 6 6 6 6 6 M [ M [ M Z M Z Z Z [ [ ' ' ' ' ' ' ' ' § · § ·§ · § · ¨ ¸ ¨ ¸¨ ¸ ¨ ¸ © ¹ © ¹ © ¹ © ¹ 6 6 6 6 Equation for node 6: 6 6 6 6 6 6 6 6Z [ M M [ M Z M [ Z [ Z ' ' ' ' ' ' ' ' § · § ·§ · § · ¨ ¸ ¨ ¸¨ ¸ ¨ ¸ © ¹ © ¹© ¹ © ¹
  • 738. Z [ J 6 6 J 6 6 ' ' f f
  • 739. 6 6 6 6 J Z 6 6 6 6 6 6 M ' f
  • 740. 6 6 6 6 Equation for node 7:
  • 741. 6 6 6 6 6[ [ M M M Z J Z 6 6 Z Z [ ' ' ' ' ' ' ' f § ·§ · § · ¨ ¸¨ ¸ ¨ ¸ © ¹ © ¹ © ¹
  • 745. J Z 6 6 6 6 6 6 6 M ' f
  • 746. 6 6 6 Equation for node 8:
  • 747. 6 6 6 6 6[ [ M M M Z J Z 6 6 Z Z [ ' ' ' ' ' ' ' f § ·§ · § · ¨ ¸¨ ¸ ¨ ¸ © ¹ © ¹ © ¹
  • 751. J Z 6 6 6 6 6 6 6 M ' f
  • 752. 6 6 6 Equation for node 9:
  • 753. 6 6 6[ Z [ Z M M J 6 6 Z [ ' ' ' ' ' ' f § ·§ · ¨ ¸¨ ¸ © ¹ © ¹
  • 756. [ J Z 6 6 6 6 6 M ' ' f 6 6
  • 757. 208 Introduction to Numerical Methods in Chemical Engineering Program 10.1 can be modified for the solution of this problem. The converged solution is: T1 = 83.19, T2 = 82.86, T3 = 81.49, T4 = 86.43, T5 = 86.27, T6 = 85.78, T7 = 86.72, T8 = 87.26, and T9 = 88.54°C. 10.5 ADI Method for Steady Heat Conduction The Alternating Direction Implicit (ADI) method can also be applied for the solution of the two-dimensional steady heat conduction equation (10.1) 6 6 Z [ ˜ ˜ ˜ ˜ Using the central difference scheme, we get K L K L K L K L K L K L 6 6 6 6 6 6 Z [ ' ' [see Eq. (10.8)] This equation can be split into the following two half-steps: P P P P P P K L K L K L K L K L K L 6 6 6 6 6 6 Z [ È Ø É Ù ' 'Ê Ú (10.12) P P P P P P K L K L K L K L K L K L 6 6 66 6 6 [ Z È Ø É Ù É Ù ' 'É Ù Ê Ú (10.13) The first half-step is executed on all the nodes. This is followed by computation of the second half- step on all the nodes (see Fig. 10.12). The ADI method is also called the line-by-line Fig. 10.12 First half-step and second half-step in ADI iteration. (a) First half-step of iteration (b) Second half-step of iteration i + 1i j + 1 j Sweep direction Sweepdirection
  • 758. Two-Dimensional Steady and Transient Heat Conduction 209 TDMA, as in each line of nodes taken a tridiagonal set of linear algebraic equations is formed. TDMA can be used to solve them, and thus the values of nodes along a line are updated. Initially, Eq. (10.12) is considered for the first half of iteration, in which the sweep direction is along the x-axis and each line of nodes along the x-axis is updated. Then Eq. (10.13) is considered for the second half of iteration, in which the sweep direction is along the y-axis and each line of nodes along the y-axis is updated. The iterations are performed till convergence in temperature is achieved, P P K L K L6 6 F . ADI is a line-by-line method, whereas Gauss– Seidel is a pointwise method. EXAMPLE 10.10 Determine the temperature at various nodes shown in Fig. 10.13. The heat transfer is given by the equation 6 6 Z [ ˜ ˜ ˜ ˜ . The boundary conditions are shown in Fig. 10.13. The size of the slab is 2 m ´ 2 m and Dx = Dy = 0.5 m. Use the ADI method. Fig. 10.13 Example 10.10. Solution The first half iteration is performed (scanning various i nodes for given j) using the discretized equation P P P P P P K L K L K L K L K L K L 6 6 6 6 6 6 Z [ ' ' Since Dx = Dy, the discretized equation becomes P P P P P K L K LK L K L K L 6 6 6 6 6 At node 1,1 P P P P P 6 6 6 6 6 20°C20°C 400°C 20°C T0,3 T0,2 T0,1 T1,3 T1,2 T1,1 T2,3 T2,2 T2,1 T3,3 T3,2 T3,1 T4,3 T4,2 T4,1 T1,4 T2,4 T3,4 T1,0 T2,0 T3,0
  • 759. 210 Introduction to Numerical Methods in Chemical Engineering Let us assume the following initial temperatures: T1,2 = 90, T2,2 = 110, T3,2 = 90. Since T0,1 is always at 20°C, the above equation becomes P P P P P 6 6 6 6 6 At node 2,1 P P P P P 6 6 6 6 6 P P P P P 6 6 6 6 6 At node 3,1 P P P P P 6 6 6 6 6 P P P P P 6 6 6 6 6 Since T4,1 is always at 20°C, the above equation becomes P P P P P 6 6 6 6 6 The following tridiagonal set of linear algebraic equations is obtained for various i nodes at j = 1 P P P 6 6 6 Ë Û Ë Û Ë ÛÌ Ü Ì Ü Ì ÜÌ Ü Ì Ü Ì ÜÌ Ü Ì Ü Ì Ü Í Ý Í ÝÌ Ü Í Ý The solution by TDMA is P 6 = 46.43, P 6 = 55.71, P 6 = 46.43°C. Now let us write the equations for various i nodes at j = 2. At node 1,2 P P P P P 6 6 6 6 6 Let us assume the following initial temperatures: T1,3 = 180, T2,3 = 220, T3,3 = 180. Since T0,2 is always at 20°C, the above equation becomes P P P P P 6 6 6 6 6 At node 2,2 P P P P P 6 6 6 6 6 P P P P P 6 6 6 6 6
  • 760. Two-Dimensional Steady and Transient Heat Conduction 211 At node 3,2 P P P P P 6 6 6 6 6 P P P P P 6 6 6 6 6 Since T4,2 is always at 20o C, the above equation becomes P P P P P 6 6 6 6 6 The following tridiagonal set of linear algebraic equations is obtained for variousi nodes at j = 2: P P P 6 6 6 Ë Û Ë Û Ë ÛÌ Ü Ì Ü Ì ÜÌ Ü Ì Ü Ì ÜÌ Ü Ì Ü Ì Ü Í Ý Í ÝÌ Ü Í Ý The solution by TDMA is: P 6 = 90.10, P 6 = 113.98, P 6 = 90.10°C. Now let us write the equations for various i nodes at j = 3. At node 1,3 P P P P P 6 6 6 6 6 Since T0,3 is always at 20°C, the above equation becomes P P P P P 6 6 6 6 6 At node 2,3 P P P P P 6 6 6 6 6 P P P P P 6 6 6 6 6 At node 3,3 P P P P P 6 6 6 6 6 P P P P P 6 6 6 6 6 Since T4,3 is always at 20°C, the above equation becomes P P P P P 6 6 6 6 6
  • 761. 212 Introduction to Numerical Methods in Chemical Engineering The following tridiagonal set of linear algebraic equations is obtained for various i nodes at j = 3: P P P 6 6 6 Ë Û Ë Û Ë ÛÌ Ü Ì Ü Ì ÜÌ Ü Ì Ü Ì ÜÌ Ü Ì Ü Ì Ü Í Ý Í ÝÌ Ü Í Ý The solution by TDMA is: P 6 = 182.46, P 6 = 219.72, P 6 = 182.46°C. The second half iteration (scanning various j nodes for given i) is performed using the discretized equation P P P P P P K L K L K L K L K L K L 6 6 6 6 6 6 Z [ ' ' Since Dx = Dy, the discretized equation becomes P P P P P K L K L K L K L K L 6 6 6 6 6 At node 1,1 P P P P P 6 6 6 6 6 P P P P P 6 6 6 6 6 Since T1,0 is always at 20°C, the above equation becomes P P P P P 6 6 6 6 6 At node 1,2 P P P P P 6 6 6 6 6 P P P 6 6 6 At node 1,3 P P P P P 6 6 6 6 6 Since T1,4 is always at 400°C, the above equation becomes P P 6 6 The following tridiagonal set of linear algebraic equations is obtained for various j nodes at i = 1: P P P 6 6 6 Ë Û Ë Û Ë Û Ì ÜÌ Ü Ì Ü Ì ÜÌ Ü Ì Ü Ì ÜÌ Ü Ì Ü Í Ý Í ÝÌ ÜÍ Ý
  • 762. Two-Dimensional Steady and Transient Heat Conduction 213 The solution by TDMA is: P 6 = 46.63, P 6 = 90.81, P 6 = 182.63°C. At node 2,1 P P P P P 6 6 6 6 6 P P P P P 6 6 6 6 6 Since T2,0 is always at 20°C, the above equation becomes P P P P P 6 6 6 6 6 At node 2,2 P P P P P 6 6 6 6 6 P P P 6 6 6 At node 2,3 P P P P P 6 6 6 6 6 Since T2,4 is always at 400°C, the above equation becomes P P 6 6 The following tridiagonal set of linear algebraic equations is obtained for various j nodes at i = 2: P P P 6 6 6 Ë Û Ë Û Ë Û Ì ÜÌ Ü Ì Ü Ì ÜÌ Ü Ì Ü Ì ÜÌ Ü Ì Ü Í Ý Í ÝÌ ÜÍ Ý The solution by TDMA is: P 6 = 56.87, P 6 = 114.41, P 6 = 219.88°C. At node 3,1 P P P P P 6 6 6 6 6 P P P P P 6 6 6 6 6 Since T3,0 is always at 20°C, the above equation becomes P P P P P 6 6 6 6 6 At node 3,2 P P P P P 6 6 6 6 6 P P P 6 6 6
  • 763. 214 Introduction to Numerical Methods in Chemical Engineering At node 3,3 P P P P P 6 6 6 6 6 Since T3,4 is always at 400°C, the above equation becomes P P 6 6 The following tridiagonal set of linear algebraic equations is obtained for various j nodes at i = 3: P P P 6 6 6 Ë Û Ë Û Ë Û Ì ÜÌ Ü Ì Ü Ì ÜÌ Ü Ì Ü Ì ÜÌ Ü Ì Ü Í Ý Í ÝÌ ÜÍ Ý The solution by TDMA is: P 6 = 46.97, P 6 = 91.03, P 6 = 182.73°C. Program 10.2 for the solution of the above problem is given in the Appendix. After 25 iterations when convergence is obtained, the results from the computer program are: T1,1 = 47.14, T1,2 = 91.25, T1,3 = 182.86, T2,1 = 57.32, T2,2 = 115.00, T2,3 =220.16, T3,1 = 47.14, T3,2 = 91.25, T3,3 = 182.86°C. Similar results are obtained in Example 10.1 in which the problem was solved using the Gauss–Seidel method. 10.6 ADI Method for Transient Heat Conduction The ADI method can be extended for the solution of two-dimensional transient heat conduction. The explicit schemes are stable only with some constraints on Dx and Dt, whereas implicit schemes are not associated with these constraints. Therefore the ADI method, which is an implicit method shall be used. Transient heat conduction in two-dimensional space is given by [see Eq. (9.26)] 6 6 6 V Z [ B È Ø˜ ˜ ˜ É Ù˜ ˜ ˜Ê Ú Taking the first half-step in time, we get P P P P P P P P K LK L K L K L K L K L K L K L 6 6 6 6 6 6 6 6 V Z [ B È Ø É Ù É Ù' ' 'É Ù Ê Ú (10.14) Letting D = Dx = Dy and V / B' ' , we get
  • 764. Two-Dimensional Steady and Transient Heat Conduction 215 P P P P P P P P K L K L K L K LK L K L K L K L / 6 6 6 6 6 6 6 6 È Ø É Ù É ÙÊ Ú (10.15) Multiplying both sides by / , we get P P P P P P P P K L K L K L K LK L K L K L K L 6 6 6 6 6 6 6 6 / È Ø É Ù É ÙÊ Ú (10.16) P P P P P P K L K L K LK L K L K L 6 6 6 6 6 6 / / È Ø È Ø É Ù É ÙÊ Ú Ê Ú (10.17) Now let us carry out the second half of the iteration P P P P P P P P K L K L K L K L K L K L K L K L 6 6 6 6 6 6 6 6 V Z [ B È Ø É Ù É Ù' ' 'É Ù Ê Ú (10.18) P P P P P P P P K L K L K L K LK L K L K L K L / 6 6 6 6 6 6 6 6 È Ø É Ù É ÙÊ Ú (10.19) Multiplying both sides by / , we get P P P P P P P P K L K L K L K LK L K L K L K L6 6 6 6 6 6 6 6 / È Ø É Ù É ÙÊ Ú (10.20) P P P P P P K L K L K L K L K L K L 6 6 6 6 6 6 / / È Ø È Ø É Ù É ÙÊ Ú Ê Ú (10.21) ADI is an implicit method and is therefore unconditionally stable; moreover, because it is a line-by-line method, TDMA can be used to update the temperature for nodes in a line. Initially Eq. (10.17) is considered for the first half of the iteration. In this equation, Tn is the temperature at time t and P 6 are the updated temperatures computed in this first half of iteration. Sweeping of each line along the x-axis is carried out from bottom to top. Then Eq. (10.21) is considered for the second half of the iteration. In this equation, P 6 are known and P 6 are computed. The sweeping of each line along the y-axis is carried out from left to right and the temperature profile at time t + Dt is computed. This temperature profile at t + Dt can be used to obtain the temperature profile at t + 2Dt by again carrying out the first half and the second half of the iteration. Thus marching in time is carried out for this parabolic PDE.
  • 765. 216 Introduction to Numerical Methods in Chemical Engineering EXAMPLE 10.11 A slab of size 2 m ´ 2 m is initially at 0°C, and at t = 0 all the four sides of the slab are made at 400o C. Take D = Dx = Dy = 0.1 m and a = 1 m2 /s. Determine the temperature of the slab at various nodes at t = 0.5 s. Take Dt = 0.05 s and for computing consider the upper quadrant of the slab. Solution The upper quadrant of the slab is shown in Fig. 10.14. The size of the quadrant is 1 m ´ 1 m and 10 parts along an axis are made; therefore D = Dx = Dy = 0.1 m. Let us take 't 0.05 s; therefore V / B' ' . Thus / and / . Fig. 10.14 Upper quadrant of slab in Example 10.11. First half of iteration Equations for node (1,1) to node (10,1) At node (1,1), using Eq. (10.17) and from symmetry P P 6 6 and P P 6 6 , we get P P P P 6 6 6 6 At node (2,1), using Eq. (10.17) and from symmetry P P 6 6 , we get P P P P P 6 6 6 6 6 At node (3,1), using Eq. (10.17) and from symmetry P P 6 6 , we get P P P P P 6 6 6 6 6 (11,11)(1,11) (11,1)(1,1) 400°C 400°C 6 Z ˜ ˜ 6 [ ˜ ˜
  • 766. Two-Dimensional Steady and Transient Heat Conduction 217 At node (10,1), using Eq. (10.17) and from symmetry P P 6 6 , we get P P P P P 6 6 6 6 6 In the above equation on the right hand side, T11,1 = 400. The above set of 10 equations constitute a tridiagonal matrix and can be solved using TDMA. Equations for node (1,2) to node (10,2) At node (1,2), using Eq. (10.17) and from symmetry P P 6 6 , we get P P P P P 6 6 6 6 6 At node (2,2), using Eq. (10.17), we get P P P P P P 6 6 6 6 6 6 At node (3,2), using Eq. (10.17), we get P P P P P P 6 6 6 6 6 6 At node (10,2), using Eq. (10.17), we get P P P P P P 6 6 6 6 6 6 In the above equation on the right hand side, T11,2 = 400. The above set of 10 equations constitute a tridiagonal matrix and can be solved using TDMA. Equations for node (1,10) to node (10,10) At node (1,10), using Eq. (10.17), and from symmetry P P 6 6 , we get P P P P P 6 6 6 6 6 At node (2,10), using Eq. (10.17), we get P P P P P P 6 6 6 6 6 6 At node (3,10), using Eq. (10.17), we get P P P P P P 6 6 6 6 6 6 At node (10,10) using Eq. (10.17) we get P P P P P P 6 6 6 6 6 6
  • 767. 218 Introduction to Numerical Methods in Chemical Engineering In the above set of equations on the right hand side, Ti,11 = 400 and T11,10 = 400. The above set of 10 equations constitute a tri-diagonal matrix and can be solved using TDMA. Second half of iteration Equations for node (1,1) to node (1,10) At node (1,1), using Eq. (10.21) and from symmetries P P 6 6 and P P 6 6 , we get P P P P 6 6 6 6 At node (1,2), using Eq. (10.21) and from symmetry P P 6 6 , we get P P P P P 6 6 6 6 6 At node (1,3), using Eq. (10.21) and from symmetry P P 6 6 , we get P P P P P 6 6 6 6 6 At node (1,10), using Eq. (10.21) and from symmetry P P 6 6 , we get P P P P P 6 6 6 6 6 In the above equation on the right hand side, T1,11 = 400. The above set of 10 equations constitute a tridiagonal matrix and can be solved using TDMA. Equations for node (2,1) to node (2,10) At node (2,1), using Eq. (10.21) and from symmetry P P 6 6 , we get P P P P P 6 6 6 6 6 At node (2,2), using Eq. (10.21), we get P P P P P P 6 6 6 6 6 6 At node (2,3), using Eq. (10.21), we get P P P P P P 6 6 6 6 6 6 At node (2,10), using Eq. (10.21), we get P P P P P P 6 6 6 6 6 6
  • 768. Two-Dimensional Steady and Transient Heat Conduction 219 In the above equation on the right hand side, T2,11 = 400. The above set of 10 equations constitute a tridiagonal matrix and can be solved using TDMA. Equations for node (10,1) to node (10,10) At node (2,1), using Eq. (10.21) and from symmetry P P 6 6 , we get P P P P P 6 6 6 6 6 At node (2,2), using Eq. (10.21), we get P P P P P P 6 6 6 6 6 6 At node (2,3), using Eq. (10.21), we get P P P P P P 6 6 6 6 6 6 At node (2,10), using Eq. (10.21), we get P P P P P P 6 6 6 6 6 6 In the above set of equations on the right hand side, T11,i = 400 and T10,11 = 400. The above set of 10 equations constitute a tridiagonal matrix and can be solved using TDMA. Note that for both the first-half and second-half iterations the tridiagonal matrix that is formed has the following coefficients: C C C C C C C C C D D D D D D D D D D E E E E E E E E E Program 10.3 for the solution of the above problem is given in the Appendix. The temperatures (in °C) at t = 0.5 s are presented in Table 10.2. Table 10.2 Temperatures in Example 10.11 T1,1 = 329.77 T2,1 = 331.09 T3,1 = 334.21 T4.1 = 339.01 T5,1 = 345.20 T1,2 = 329.83 T2,2 = 331.70 T3,2 = 334.86 T4,2 = 339.65 T5,2 = 345.80 T1,3 = 330.02 T2,3 = 333.54 T3,3 = 336.81 T4,3 = 341.58 T5,3 = 347.61 T1,4 = 330.42 T2,4 = 336.68 T3,4 = 340.10 T4,4 = 344.82 T5,4 = 350.64 T1,5 = 331.19 T2,5 = 341.22 T3,5 = 344.80 T4,5 = 349.39 T5,5 = 354.86 T1,6 = 332.64 T2,6 = 347.31 T3,6 = 350.96 T4,6 = 355.29 T5,6 = 360.25 T1,7 = 335.34 T2,7 = 355.10 T3,7 = 358.61 T4,7 = 362.43 T5,7 = 366.68 T1,8 = 340.39 T2,8 = 364.85 T3,8 = 367.76 T4,8 = 370.77 T5,8 = 374.10 T1,9 = 349.80 T2,9 = 376.94 T3,9 = 378.59 T4,9 = 380.49 T5,9 = 382.71 T1,10 = 367.33 T2,10 = 389.30 T3,10 = 388.85 T4,10 = 389.60 T5,10 = 390.70
  • 769. 220 Introduction to Numerical Methods in Chemical Engineering T6,1 = 352.52 T7,1 = 360.60 T8,1 = 369.54 T9,1 = 381.09 T10,1 = 388.03 T6,2 = 353.06 T7,2 = 361.06 T8,2 = 369.90 T9,2 = 381.31 T10,2 = 388.17 T6,3 = 354.67 T7,3 = 362.42 T8,3 = 370.96 T9,3 = 381.98 T10,3 = 388.60 T6,4 = 357.35 T7,4 = 364.68 T8,4 = 372.73 T9,4 = 383.07 T10,4 = 389.30 T6,5 = 361.08 T7,5 = 367.81 T8,5 = 375.16 T9,5 = 384.59 T10,5 = 390.27 T6,6 = 365.79 T7,6 = 371.75 T8,6 = 378.22 T9,6 = 386.49 T10,6 = 391.47 T6,7 = 371.37 T7,7 = 376.38 T8,7 = 381.80 T9,7 = 388.71 T10,7 = 392.88 T6,8 = 377.76 T7,8 = 381.65 T8,8 = 385.87 T9,8 = 391.25 T10,8 = 394.47 T6,9 = 385.18 T7,9 = 387.81 T8,9 = 390.63 T9,9 = 394.16 T10,9 = 396.38 T6,10 = 391.98 T7,10 = 393.37 T8,10 = 394.88 T9,10 = 396.86 T10,10 = 397.96 Exercises 10.1 Using the Gauss-Seidel method, determine the temperatures at positions 1, 2, 3 and 4 shown in Fig. 10.15. Fig. 10.15 Exercise 10.1. (Ans: T1 = 487.5, T2 = 437.5, T3 = 362.5, T4 = 412.5°C) 10.2 Using the Gauss-Seidel method, determine the temperature of the heated plate shown in Fig. 10.16. The dimension of the plate is 40 cm ´ 40 cm and is made of aluminium. The thermal conductivity of aluminium is 0.5 W/m-K. Fig. 10.16 Exercise 10.2. 700°C 500°C 400°C100°C 4 1 3 2 100°C 0°C 50°C75°C T1,3 T2,3 T2,3 T1,2 T2,2 T3,2 T1,1 T2,1 T3,1
  • 770. Two-Dimensional Steady and Transient Heat Conduction 221 (Ans: T1,1 = 42.86, T1,2 = 63.17, T1,3 = 78.57, T2,1 = 33.26, T2,2 = 56.25, T2,3 = 76.12, T3,1 = 33.93, T3,2 = 52.46, T3,3 = 69.64°C) 10.3 Using the Gauss-Seidel method, determine the steady state temperatures for nodes 1 to 6 shown in Fig. 10.17. The thermal conductivity of the body is 1.5 W/m-K. Dx = Dy = 25 cm. Fig. 10.17 Exercise 10.3. (Ans: T1 = 27.6, T2 = 27.6, T3 = 41.6, T4 = 41.6, T5 = 47.2, T6 = 47.2°C) 10.4 Calculate the steady state temperatures for nodes 1 to 16 shown in Fig. 10.18. Take Dx = Dy = 20 cm and k = 2.3 W/m-K. Fig. 10.18 Exercise 10.4. (Ans: T1 = 35.28, T2 = 35.89, T3 = 38.49, T4 = 48.36, T5 = 55.24, T6 = 56.66, T7 = 61.84, T8 = 74.20, T9 = 72.37, T10 = 73.67, T11 = 78.01, T12 = 86.58, T13 = 86.91, T14 = 87.63, T15 = 89.94, T16 = 94.13o C) 10.5 A slab of size 2 m ´ 2 m shown in Fig. 10.19 is initially at 0°C. At t = 0 s, all the four sides of the slab are made at 600°C. Take Dx = Dy = 0.1 m. Take a = 1 m2 /s. Determine the temperature of the slab at various nodes at t = 0.25 s. Take Dt = 0.05 s, and for computing, consider the upper quadrant of the slab as shown in Fig. 10.19. 1 2 3 4 5 6 50°C50°C 50°C 100°C 100°C h = 23 W/m2 -K, T¥ = 25°C Insulation h = 12 W/m2 -K, T¥ = 15°C1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
  • 771. 222 Introduction to Numerical Methods in Chemical Engineering Fig. 10.19 Exercise 10.5. (Ans: Program 10.3 can be modified and the temperatures (in °C) at t = 0.25 s are presented in Table 10.3. Table 10.3 Temperatures in Exercise 10.5 T1,1 = 290.10 T2,1 = 294.61 T3,1 = 308.63 T4.1 = 329.39 T5,1 = 356.77 T1,2 = 290.34 T2,2 = 297.26 T3,2 = 311.43 T4.2 = 332.19 T5,2 = 359.39 T1,3 = 291.18 T2,3 = 305.32 T3,3 = 319.95 T4.3 = 340.64 T5,3 = 367.31 T1,4 = 292.95 T2,4 = 319.18 T3,4 = 334.48 T4.4 = 354.95 T5,4 = 380.66 T1,5 = 296.35 T2,5 = 339.47 T3,5 = 355.48 T4.5 = 375.40 T5,5 = 399.59 T1,6 = 302.74 T2,6 = 366.94 T3,6 = 383.30 T4.6 = 402.10 T5,6 = 424.03 T1,7 = 314.69 T2,7 = 401.84 T3,7 = 417.53 T4.7 = 434.20 T5,7 = 452.99 T1,8 = 336.96 T2,8 = 443.29 T3,8 = 456.10 T4.8 = 469.16 T5,8 = 483.88 T1,9 = 378.48 T2,9 = 491.07 T3,9 = 497.67 T4.9 = 505.61 T5,9 = 515.51 T1,10 = 455.84 T2,10 = 563.32 T3,10 = 562.67 T4.10 = 566.37 T5,10 = 571.09 T6,1 = 390.11 T7,1 = 427.17 T8,1 = 462.90 T9,1 = 496.07 T10,1 = 576.63 T6,2 = 392.45 T7,2 = 429.12 T8,2 = 464.48 T9,2 = 497.27 T10,2 = 576.89 T6,3 = 399.47 T7,3 = 435.00 T8,3 = 469.20 T9,3 = 500.88 T10,3 = 577.69 T6,4 = 411.25 T7,4 = 444.85 T8,4 = 477.09 T9,4 = 506.92 T10,4 = 579.01 T6,5 = 427.88 T7,5 = 458.70 T8,5 = 488.17 T9,5 = 515.38 T10,5 = 580.87 T6,6 = 449.20 T7,6 = 476.39 T8,6 = 502.28 T9,6 = 526.13 T10,6 = 583.23 T6,7 = 474.24 T7,7 = 497.03 T8,7 = 518.67 T9,7 = 538.58 T10,7 = 586.01 T6,8 = 500.60 T7,8 = 518.57 T8,8 = 535.63 T9,8 = 551.33 T10,8 = 589.01 T6,9 = 527.28 T7,9 = 540.20 T8,9 = 552.54 T9,9 = 563.91 T10,9 = 592.14 T6,10 = 576.02 T7,10 = 580.89 T8,10 = 585.36 T9,10 = 589.41 T10,10 = 596.94 600°C 600°C (1,11) (11,11) (1,1) (11,1) 6 Z ˜ ˜ 6 [ ˜ ˜
  • 772. Two-Dimensional Steady and Transient Heat Conduction 223 10.6 Solve Exercise 10.5 to determine the temperature profile at 0.5 s. (Ans: Program 10.3 can be modified and the temperatures (in °C) at t = 0.5 s are presented in Table 10.4. Table 10.4 Temperatures in Exercise 10.6 T1,1 = 494.66 T2,1 = 496.64 T3,1 = 501.32 T4,1 = 508.51 T5,1 = 517.80 T1,2 = 494.74 T2,2 = 497.55 T3,2 = 502.29 T4,2 = 509.48 T5,2 = 518.71 T1,3 = 495.03 T2,3 = 500.31 T3,3 = 505.21 T4,3 = 512.37 T5,3 = 521.42 T1,4 = 495.63 T2,4 = 505.01 T3,4 = 510.15 T4,4 = 517.23 T5,4 = 525.95 T1,5 = 496.78 T2,5 = 511.83 T3,5 = 517.20 T4,5 = 524.09 T5,5 = 532.29 T1,6 = 498.96 T2,6 = 520.96 T3,6 = 526.45 T4,6 = 532.93 T5,6 = 540.37 T1,7 = 503.02 T2,7 = 532.65 T3,7 = 537.91 T4,7 = 543.65 T5,7 = 550.03 T1,8 = 510.59 T2,8 = 547.27 T3,8 = 551.64 T4,8 = 556.16 T5,8 = 561.14 T1,9 = 524.71 T2,9 = 565.42 T3,9 = 567.89 T4,9 = 570.73 T5,9 = 574.06 T1,10 = 551.00 T2,10 = 583.95 T3,10 = 583.27 T4,10 = 584.40 T5,10 = 586.05 T6,1 = 528.78 T7,1 = 540.91 T8,1 = 554.31 T9,1 = 571.64 T10,1 = 582.04 T6,2 = 529.59 T7,2 = 541.59 T8,2 = 554.84 T9,2 = 571.97 T10,2 = 582.26 T6,3 = 532.01 T7,3 = 543.63 T8,3 = 556.44 T9,3 = 572.97 T10,3 = 582.90 T6,4 = 536.03 T7,4 = 547.02 T8,4 = 559.09 T9,4 = 574.61 T10,4 = 583.95 T6,5 = 541.62 T7,5 = 551.72 T8,5 = 562.75 T9,5 = 576.89 T10,5 = 585.40 T6,6 = 548.69 T7,6 = 557.62 T8,6 = 567.33 T9,6 = 579.73 T10,6 = 587.21 T6,7 = 557.06 T7,7 = 564.57 T8,7 = 572.70 T9,7 = 583.08 T10,7 = 589.32 T6,8 = 566.64 T7,8 = 572.48 T8,8 = 578.81 T9,8 = 586.87 T10,8 = 591.71 T6,9 = 577.77 T7,9 = 581.71 T8,9 = 585.94 T9,9 = 591.24 T10,9 = 594.56 T6,10 = 587.97 T7,10 = 590.05 T8,10 = 592.32 T9,10 = 595.29 T10,10 = 596.94
  • 773. 225 Appendix Programs in C++ Program Title 1.1 Program for the solution of tridiagonal equations 1.2 Program for the solution of linear algebraic equations by the Gauss Elimination method 1.3 Program for the solution of linear algebraic equations by the Gauss–Seidel method 2.1 Program to solve for pressure drop in a pipe (nonlaminar case) 2.2 Program to solve for minimum fluidization velocity 2.3 Program to solve for terminal velocity 2.4 Program for the solution of two simultaneous nonlinear equations 3.1 Program to calculate the molar volume in the liquid and vapour phases at the given temperature and pressure 3.2 Program to calculate the bubble point temperature and the dew point temperature of a mixture of given composition, assuming Raoult’s law to be true 3.3 Program to calculate the compositions of the vapour and liquid phases at the given temperature and pressure under flash conditions, assuming Raoult’s law to be true 3.4 Program to calculate the bubble point pressure, bubble point temperature, dew point pressure and dew point temperature of a mixture of given composition, assuming the modified Raoult’s law to be true 3.5 Program to calculate the compositions of the vapour and liquid phases at the given temperature and pressure under flash conditions, assuming the modified Raoult’s law to be true 3.6 Program to calculate the vapour pressure at the given temperature using the Peng– Robinson equation of state by comparing the fugacities of the liquid and vapour phases 3.7 Program to calculate the bubble point pressure using the gamma–phi approach 3.8 Program to calculate the bubble point pressure using the Peng–Robinson equation of state 3.9 Program for the solution of two simultaneous chemical reactions in chemical equilibrium 3.10 Program to calculate the adiabatic flame temperature (AFT) for a fuel 4.1 Program to solve an ordinary differential equation by the Runge–Kutta method 4.2 Program to determine the velocity of a particle in a pneumatic conveyor
  • 774. 226 Appendix: Programs in C++ 4.3 Program to solve two simultaneous ordinary differential equations by the Runge– Kutta method 4.4 Program to solve three simultaneous ordinary differential equations by the Runge– Kutta method 4.5 Program to solve three simultaneous ordinary differential equations for the reaction A ® B ® C by the Runge–Kutta fourth order method 4.6 Program to solve four simultaneous ordinary differential equations for the reactions A + B ® C and B + C ® D by the Runge–Kutta method 4.7 Program to solve ordinary differential equations in a non-isothermal tubular reactor by the Runge–Kutta method 7.1 Program to calculate the concentration profile in a tubular reactor with axial dispersion (second order reaction) 7.2 Program to calculate the concentration profile in a tubular reactor with axial dispersion in which two parallel reactions take place 8.1 Program to calculate the concentration profile along the radius for reaction– diffusion in a spherical catalyst pellet (second order isothermal reaction) 8.2 Program to calculate the concentration profile along the radius for reaction- diffusion in a spherical catalyst pellet (non-isothermal, beta = 1) 9.1 Program to calculate the temperature profile in a rectangular slab during transient heat conduction 9.2 Program to calculate the concentration profile in a sphere during transient diffusion of drug from spherical pellet 10.1 Program to calculate the temperature profile in a two-dimensional body during steady heat conduction using the Gauss-Seidel method 10.2 Program to calculate the temperature profile in a two-dimensional body during steady heat conduction using the ADI method 10.3 Program to calculate the temperature profile in a two-dimensional body during transient heat conduction using the ADI method PROGRAM 1.1 //PROGRAM 1.1 //program for the solution of tridiagonal equations #includeiostream.h #includeconio.h #includemath.h void main() { clrscr(); int i,j,n,i1,n1,k; float a[21],b[21],c[21],d[21],x[21],beta[21],gamma[21]; //a is subdiagonal, b is diagonal and c is superdiagonal for(i=2;i=7;++i) {
  • 775. Appendix: Programs in C++ 227 a[i]=1.0; } for(i=1;i=7;++i) { b[i]=-2.0; } for(i=1;i=6;++i) { c[i]=1.0; } d[1]=-240.0; for(i=2;i=6;++i) { d[i]=-40.0; } d[7]=-60.0; i=1; n=7; beta[i]=b[i]; gamma[i]=d[i]/beta[i]; i1=i+1; for(j=i1;j=n;++j) { beta[j]=b[j]-a[j]*c[j-1]/beta[j-1]; gamma[j]=(d[j]-a[j]*gamma[j-1])/beta[j]; } x[n]=gamma[n]; n1=n-i; for(k=1;k=n1;++k) { j=n-k; x[j]=gamma[j]-c[j]*x[j+1]/beta[j]; } cout“ttt THE SOLUTION BY TDMA”endl; for(i=1;i=7;++i) { coutx[i]endl; } getch(); } PROGRAM 1.2 //PROGRAM 1.2 //program for the solution of linear algebraic equations //by the Gauss Elimination method #includeiostream.h
  • 776. 228 Appendix: Programs in C++ #includeconio.h #includemath.h void main() { clrscr(); int n,m,l,i,j,k,jj,kp1,nn,ip1; float a[10][11],x[10],sum,big,ab,quot,t; n=4; coutnendl; m=n+1; l=n-1; cout“Input the elements of A rowwise and elements of B”endl; for(i=1;i=n;i++) { for(j=1;j=m;j++) { cina[i][j]; } } for(i=1;i=n;i++) { for(j=1;j=m;j++) { couta[i][j]endl; } } for(k=1;k=l;k++) { big=fabs(a[k][k]); jj=k; kp1=k+1; for(i=kp1;i=n;i++) { ab=fabs(a[i][k]); if((big-ab)0.0) { big=ab; jj=i; } } if((jj-k)0) { for(j=k;j=m;j++) { t=a[jj][j]; a[jj][j]=a[k][j];
  • 777. Appendix: Programs in C++ 229 a[k][j]=t; } } for(i=kp1;i=n;i++) { quot=a[i][k]/a[k][k]; for(j=kp1;j=m;j++) { a[i][j]=a[i][j]-quot*a[k][j]; } } for(i=kp1;i=n;i++) { a[i][k]=0.0; } } x[n]=a[n][m]/a[n][n]; for(nn=1;nn=l;nn++) { sum=0.0; i=n-nn; ip1=i+1; for(j=ip1;j=n;j++) { sum=sum+a[i][j]*x[j]; } x[i]=(a[i][m]-sum)/a[i][i]; } for(i=1;i=n;i++) {coutx[i]endl;} getch(); } PROGRAM 1.3 //PROGRAM 1.3 //program for the solution of linear algebraic equations //by the Gauss-Seidel method #includeiostream.h #includeconio.h #includemath.h void main() { clrscr(); float x1old,x2old,x3old,x1new,x2new,x3new; x1new=2.0;
  • 778. 230 Appendix: Programs in C++ x2new=3.0; x3new=4.0; do { x1old=x1new; x2old=x2new; x3old=x3new; x1new=(44.0-x2old-2*x3old)/10.0; x2new=(51.0-2*x1new-x3old)/10.0; x3new=(61.0-x1new-2*x2new)/10.0; }while(fabs(x1new-x1old)1e-6fabs(x2new-x2old)1e-6fabs(x3new- x3old)1e-6); coutx1new“ “x2new“ “x3newendl; getch(); } PROGRAM 2.1 //PROGRAM 2.1 //program to solve for pressure drop in a pipe (nonlaminar case) #includeiostream.h #includeconio.h #includemath.h void main() { clrscr(); float fricf,epsilon,d,mu,rho,v,fricfnew,f,fdash,Re,deltap,length,a1,a2,a3; int n; d=0.004,v=50.0,rho=1.23,mu=1.79e-5,epsilon=0.0015e-3,length=1.0; cout“ttt OUTPUT”endl; cout“nEnter the initial value of fricfact”; cinfricf; a1=epsilon/d; Re=rho*v*d/mu; a2=2.51/Re; n=0; fricfnew=0.01; do { fricf=fricfnew; f=(1.0/sqrt(fricf))+2.0*log10((a1/3.7)+(a2/sqrt(fricf))); a3=-0.5*pow(fricf,-1.5); fdash=a3+2.0*a2*a3/((a1/3.7)+(a2/sqrt(fricf))); fricfnew=fricf-f/fdash; n=n+1;
  • 779. Appendix: Programs in C++ 231 }while(fabs(fricfnew-fricf)1e-6); deltap=fricfnew*length*v*v*rho/(2.0*d); cout“t Friction factor is “fricfnewendl; cout“Pressure drop is “deltapendl; cout“Number of iterations performed “nendl; getch(); } PROGRAM 2.2 //PROGRAM 2.2 //program to solve for minimum fluidization velocity #includeiostream.h #includeconio.h #includemath.h void main() { clrscr(); float epsilon,mu,vmf,phis,dp,rhop,rhog,a1,a2,a3,v,vnew,f,fdash; const g=9.81; int n; dp=0.00012, phis=0.88, rhog=2.374, rhop=1000.0, mu=1.845e-5, epsilon=0.42; cout“ttt OUTPUT”endl; cout“nEnter the initial value of vmf in m/s “; cinvmf; a1=1.75*rhog*(1.0-epsilon)/(phis*dp*pow(epsilon,3.0)); a2=150.0*mu*(1.0-epsilon)*(1.0-epsilon)/(phis*phis*dp*dp*pow(epsilon,3)); a3=(1.0-epsilon)*(rhop-rhog)*g; n=0; vnew=0.01; do { v=vnew; f=a1*v*v+a2*v-a3; fdash=2.0*a1*v+a2; vnew=v-f/fdash; n=n+1; }while(fabs(vnew-v)1e-6); cout“t Velocity at minimum fluidization is “vnew “ m/s “endl; cout“Number of iterations performed were “nendl; getch(); }
  • 780. 232 Appendix: Programs in C++ PROGRAM 2.3 //PROGRAM 2.3 //program to solve for terminal velocity #includeiostream.h #includeconio.h #includemath.h void main() { clrscr(); float vt,vtnew,rhop,rhog,dp,cd,rep,mu,a1; float g=9.81; int n; rhog=1.18,rhop=900.0,dp=0.002,mu=1.85e-5; cout“nEnter the value of initial value of terminal velocity in m/ s “; cinvtnew; do { vt=vtnew; rep=rhog*vt*dp/mu; cd=24.0*(1.0+0.15*pow(rep,0.687))/rep; a1=4.0*(rhop-rhog)*g*dp/(3.0*cd*rhog); vtnew=sqrt(a1); n=n+1; }while(fabs(vtnew-vt)1e-6); cout“t Value of terminal velocity is “vtnewendl; cout“number of iterations performed is “nendl; getch(); } PROGRAM 2.4 //PROGRAM 2.4 //program for the solution of two simultaneous nonlinear equations #includeiostream.h #includeconio.h #includemath.h void main() { clrscr(); float x1,x2,x1new,x2new,f1,f2,df1dx1,df1dx2,df2dx1,df2dx2; float d,deltax1,deltax2; int n; x1new=0.1;
  • 781. Appendix: Programs in C++ 233 x2new=0.5; n=0; do { x1=x1new; x2=x2new; f1=pow(2.71828,x1)+x1*x2-1.0; f2=sin(x1*x2)+x1+x2-1.0; df1dx1=pow(2.71828,x1)+x2; df1dx2=x1; df2dx1=x2*cos(x1*x2)+1.0; df2dx2=x1*cos(x1*x2)+1.0; d=df1dx1*df2dx2-df1dx2*df2dx1; deltax1=(f2*df1dx2-f1*df2dx2)/d; deltax2=(f1*df2dx1-f2*df1dx1)/d; x1new=x1+deltax1; x2new=x2+deltax2; n=n+1; }while(fabs(x1new-x1)1e-6fabs(x2new-x2)1e-6); cout“The number of iterations performed is “nendl; coutx1new“ “x2newendl; getch(); } PROGRAM 3.1 //PROGRAM 3.1 //program to calculate the molar volume in the liquid and vapour phases at the //given temperature and pressure #includeiostream.h #includeconio.h #includemath.h void main() { clrscr(); float w,s,t,tc,k,a,b,r=8.314,lpha,sol[2],vold,vnew,B,tr,b0,b1; float p,pc,f,f1; cout“Enter the value of temperature in deg K and pressure in Pa”; cintp; cout“Enter the value of critical temperature in deg K and critical pressure in Pa”; cintcpc; cout“Enter the value of acentric factor”; cinw; // //VIRIAL GAS EQUATION OF STATE Z(T,P) //
  • 782. 234 Appendix: Programs in C++ tr=t/tc; b0=.083-0.422*pow(tr,-1.6); b1=.139-0.172*pow(tr,-4.2); B=(b0+w*b1)*r*tc/pc; vnew=r*t/p+B; cout“Volume of vapour by virial eos Z(T,P) “vnew“m3/mol”endl; // //VIRIAL GAS EQUATION OF STATE Z(T,V) // vnew=r*t/p; do { vold=vnew; f=p*vold/(r*t)-1-B/vold; f1=p/(r*t)+B/(vold*vold); vnew=vold-f/f1; } while(fabs(vnew-vold)1e-6); cout“Volume of vapour by virial eos Z(T,V) “vnew“m3/mol”endl; // //PENG–ROBINSON CUBIC EQUATION OF STATE // int i=0; k=.37464+1.54226*w-.26992*w*w; s=1+k*(1-pow(t/tc,.5)); lpha=pow(s,2); a=.45724*r*r*tc*tc*lpha/pc; b=.07780*r*tc/pc; vnew=b; for(i=0;i=1;++i) { do { vold=vnew; f=pow(vold,3)*p+vold*vold*(p*b-r*t)-vold*(3*p*b*b+2*b*r*t-a); f=f+(p*b*b*b+b*b*r*t-a*b); f1=pow(vold,2)*3*p+vold*2*(b*p-t*r)+(a-3*b*b*p-2*r*t*b); vnew=vold-f/f1; } while(fabs(vnew-vold)1e-6); sol[i]=vnew; vnew=r*t/p; } cout“Volume of saturated liquid by Peng-Robinson “sol[0]“m3/ mol”endl
  • 783. Appendix: Programs in C++ 235 “Volume of saturated vapour by Peng-Robinson “sol[1]“m3/moln”; // //REDLICH–KWONG CUBIC EQUATION OF STATE // i=0; a=.42748*r*r*pow(tc,2.5)/pc; b=.08664*r*tc/pc; vnew=b; for(i=0;i=1;++i) { do { vold=vnew; f=pow(vold,3)*p-r*t*vold*vold-vold*(p*b*b+b*r*t-a/sqrt(t))-a*b/ sqrt(t); f1=pow(vold,2)*3*p-vold*2*r*t-(p*b*b+b*r*t-a/sqrt(t)); vnew=vold-f/f1; } while(fabs(vnew-vold)1e-6); sol[i]=vnew; vnew=r*t/p; } cout“Volume of saturated liquid by Redlich–Kwong “sol[0]“m3/ mol”endl “Volume of saturated vapour by Redlich–Kwong “sol[1]“m3/moln”; // //VAN DER WAALS CUBIC EQUATION OF STATE // i=0; a=27*r*r*tc*tc/(64*pc); b=r*tc/(8*pc); vnew=b; for(i=0;i=1;++i) { do { vold=vnew; f=pow(vold,3)*p-vold*vold*(p*b+r*t)+a*vold-a*b; f1=pow(vold,2)*3*p-vold*2*(b*p+t*r)+a; vnew=vold-f/f1; } while(fabs(vnew-vold)1e-6); sol[i]=vnew; vnew=r*t/p; }
  • 784. 236 Appendix: Programs in C++ cout“Volume of saturated liquid by van der Waals “sol[0]“m3/ mol”endl “Volume of saturated vapour by van der Waals “sol[1]“m3/moln”; getch(); } PROGRAM 3.2 //PROGRAM 3.2 //program to calculate the BPT and DPT //of a mixture of given composition, assuming Raoult’s law to be true //BPT is calculated by taking the given composition to be in liquid phase //DPT is calculated by taking the given composition to be in vapour phase #includeiostream.h #includeconio.h #includemath.h void main() { clrscr(); float p,p1sat,p2sat,p1satn,t1sat,t2sat; float told,tnew,x1,x2,y1,y2,z1,a1,b1,c1,a2,b2,c2; float f,f1; cout“nEnter the mole fraction of component 1”; cinz1; cout“nEnter the pressure in kPa”; cinp; // the Antoine constants are for acetone (1) and water (2). For use of // these constants temperature is in deg C and pressure in kPa. a1=14.39155; b1=2795.317; c1=230.002; a2=16.26205; b2=3799.887; c2=226.346; //CALCULATION OF BUBBLE POINT TEMPERATURE x1=z1; x2=1-z1; t1sat=b1/(a1-log(p))-c1; t2sat=b2/(a2-log(p))-c2; tnew=x1*t1sat+x2*t2sat; do { told=tnew; p1sat=exp(a1-b1/(told+c1));
  • 785. Appendix: Programs in C++ 237 p2sat=exp(a2-b2/(told+c2)); f=p-x1*p1sat-x2*p2sat; f1=-x1*p1sat*b1/((told+c1)*(told+c1))-x2*p2sat*b2/ ((told+c2)*(told+c2)); tnew=told-f/f1; }while(fabs(tnew-told)1e-6); cout“nThe bubble point temperature is:”tnew; //CALCULATION OF DEW POINT TEMPERATURE y1=z1; y2=1-z1; t1sat=b1/(a1-log(p))-c1; t2sat=b2/(a2-log(p))-c2; tnew=y1*t1sat+y2*t2sat; do { told=tnew; p1sat=exp(a1-b1/(told+c1)); p2sat=exp(a2-b2/(told+c2)); f=(1/p)-(y1/p1sat)-(y2/p2sat); f1=(y1*b1/((told+c1)*(told+c1)))/(p1sat)+(y2*b2/ ((told+c2)*(told+c2)))/(p2sat); tnew=told-f/f1; }while(fabs(tnew-told)1e-6); cout“nThe dew point temperature is ”tnew; getch(); } PROGRAM 3.3 //PROGRAM 3.3 //program to calculate the compositions of the vapour and liquid phases //at the given //temperature and pressure under flash conditions, assuming Raoult’s law //to be true #includeiostream.h #includeconio.h #includemath.h void main() { clrscr(); int i; float psat[4],k[4],z[4],x[4],y[4],dpp,bpp,V,p,Vo,f,f1; // dpp is the dew point pressure, bpp is bubble point pressure and // V is the number of moles in the vapour phase. psat[1]=195.75,psat[2]=97.84,psat[3]=50.32;
  • 786. 238 Appendix: Programs in C++ cout“Enter the composition of acetone (1), acetonitrile (2), nitromethane (3)”; cinz[1]z[2]z[3]; bpp=z[1]*psat[1]+z[2]*psat[2]+z[3]*psat[3]; dpp=1/(z[1]/psat[1]+z[2]/psat[2]+z[3]/psat[3]); cout“Bubble point pressure of the mixture is “bpp“ kPa”endl; cout“Dew point pressure of the mixture is “dpp“ kPa”endl; cout“nEnter the pressure in kPa in between DPP and BPP n”; cinp; for(i=1;i4;i++) { k[i]=psat[i]/p; } cout“n Enter an assumed value for the vapour fraction V”; cinV; f = f1 = 0.0; do { Vo=V; for(i=1;i4;i++) { f=f+z[i]*(k[i]-1)/(1-Vo+Vo*k[i]); f1=f1-z[i]*(k[i]-1)*(k[i]-1)/pow((1-Vo+Vo*k[i]),2); } V=Vo-f/f1; } while(fabs(V-Vo)1e-6); for(i=1;i4;i++) { x[i]=z[i]/(1-V+V*k[i]); y[i]=x[i]*k[i]; } cout“Mole fraction of acetone in the liquid phase is “x[1]endl; cout“Mole fraction of acetone in the vapour phase is “y[1]endl; cout“Mole fraction of acetonitrile in the liquid phase is “x[2]endl; cout“Mole fraction of acetonitrile in the vapour phase is “y[2]endl; cout“Mole fraction of nitromethane in liquid phase is “x[3]endl; cout“Mole fraction of nitromethane in vapour phase is “y[3]endl; cout“Number of moles in vapour phase is “Vendl; cout“x[1]+x[2]+x[3]=”x[1]+x[2]+x[3]endl; cout“y[1]+y[2]+y[3]=”y[1]+y[2]+y[3]endl; getch(); }
  • 787. Appendix: Programs in C++ 239 PROGRAM 3.4 //PROGRAM 3.4 //program to calculate the bubble point pressure, bubble point temperature, //dew point pressure and dew point temperature, assuming the modified //Raoult’s law to be true #includeiostream.h #includeconio.h #includemath.h void main() { clrscr(); float p,t,a1,b1,c1,a2,b2,c2,p1sat,p2sat,r=8.314,pold,pnew,g11,g22,t1sat,t2sat; float tnew,told,x1,x2,y1,y2,h12,h21,g1,g2,m,a12=437.98*4.186,a21=1238*4.186; float V1=76.92,V2=18.07; a1=16.678; b1=3640.2; c1=219.61; a2=16.2887; b2=3816.44; c2=227.02; //the component 1 is acetone and 2 is water. The pressure in Antoine equation //is in kPa and temperature in deg C. a12 and a21 are in cal/mol. // //CALCULATION OF BPP (temperature and liquid phase composition are given) cout“Calculation of BPP”endl; cout“Enter the value of temperature in deg C and mole fraction x1”; cintx1; x2=1-x1; p1sat=exp(a1-b1/(c1+t)); p2sat=exp(a2-b2/(c2+t)); h12=V2*exp(-a12/(r*(t+273.15)))/V1; h21=V1*exp(-a21/(r*(t+273.15)))/V2; m=h12/(x1+x2*h12)-h21/(x2+x1*h21); g1=exp(-log(x1+x2*h12)+x2*m); g2=exp(-log(x2+x1*h21)-x1*m); p=x1*g1*p1sat+x2*g2*p2sat; cout“BPP=”p“kPan”; // //CALCULATION OF BPT (pressure and liquid phase composition are given) cout“Calculation of BPT”endl; cout“Enter the value of pressure in kPa and x1n”; cinpx1; x2=1-x1; t1sat=b1/(a1-log(p))-c1; t2sat=b2/(a2-log(p))-c2;
  • 788. 240 Appendix: Programs in C++ tnew=x1*t1sat+x2*t2sat; do { told=tnew; p1sat=exp(a1-b1/(c1+told)); p2sat=exp(a2-b2/(c2+told)); h12=V2*exp(-a12/(r*(told+273.15)))/V1; h21=V1*exp(-a21/(r*(told+273.15)))/V2; m=h12/(x1+x2*h12)-h21/(x2+x1*h21); g1=exp(-log(x1+x2*h12)+x2*m); g2=exp(-log(x2+x1*h21)-x1*m); p1sat=p/(g1*x1+g2*x2*(p2sat/p1sat)); tnew=b1/(a1-log(p1sat))-c1; } while(fabs(tnew-told).0001); cout“BPT=”tnew“deg Cn”; // //CALCULATION OF DPP (temperature and vapour phase composition are given) cout“Calculation of DPP”endl; cout“Enter the temperature in deg C and y1n”; cinty1; y2=1-y1; p1sat=exp(a1-b1/(c1+t)); p2sat=exp(a2-b2/(c2+t)); g1=g2=1; g11=g22=1; pnew=1/(y1/(g1*p1sat)+y2/(g2*p2sat)); do { pold=pnew; do { g1=g11; g2=g22; x1=y1*pold/(g1*p1sat); x2=y2*pold/(g2*p2sat); x1=x1/(x1+x2); x2=1-x1; h12=V2*exp(-a12/(r*(t+273.15)))/V1; h21=V1*exp(-a21/(r*(t+273.15)))/V2; m=h12/(x1+x2*h12)-h21/(x2+x1*h21); g11=exp(-log(x1+x2*h12)+x2*m); g22=exp(-log(x2+x1*h21)-x1*m); } while((fabs(g11-g1).001)(fabs(g22-g2).001)); pnew=1/(y1/(g1*p1sat)+y2/(g2*p2sat)); }
  • 789. Appendix: Programs in C++ 241 while(fabs(pnew-pold).0001); cout“DPP=”pnew“kPan”; // //CALCULATION OF DPT (pressure and vapour phase composition are given) cout“Calculation of DPT”endl; cout“Enter the pressure in kPa and y1n”; cinpy1; y2=1-y1; t1sat=b1/(a1-log(p))-c1; t2sat=b2/(a2-log(p))-c2; tnew=y1*t1sat+y2*t2sat; g11=g22=1; do { told=tnew; p1sat=exp(a1-b1/(c1+told)); p2sat=exp(a2-b2/(c2+told)); do { g1=g11; g2=g22; x1=y1*p/(g1*p1sat); x2=y2*p/(g2*p2sat); x1=x1/(x1+x2); x2=1-x1; h12=V2*exp(-a12/(r*(told+273.15)))/V1; h21=V1*exp(-a21/(r*(told+273.15)))/V2; m=h12/(x1+x2*h12)-h21/(x2+x1*h21); g11=exp(-log(x1+x2*h12)+x2*m); g22=exp(-log(x2+x1*h21)-x1*m); } while((fabs(g11-g1).0001)(fabs(g22-g2).0001)); p1sat=p*(y1/g1+y2*p1sat/(g2*p2sat)); tnew=b1/(a1-log(p1sat))-c1; } while(fabs(tnew-told).0001); cout“DPT=”tnew“deg Cn”; getch(); } PROGRAM 3.5 //PROGRAM 3.5 //program to calculate the compositions of the liquid and vapour phases under //flash conditions, assuming the modified Raoult’s law to be true #includeiostream.h
  • 790. 242 Appendix: Programs in C++ #includeconio.h #includemath.h void main() { clrscr(); // the component 1 is acetone and 2 is water. The pressure in Antoine equation // is in kPa and temperature in deg C. a12 and a21 are in cal/mol. float t,p,z1,z2,a12=292.66,a21=1445.26,V1=74.05,V2=18.07,h12,h21; float r=1.987,m,g1,g2,g1n,g2n,gb1,gb2,gd1,gd2; float p1sat,p2sat,k1,k2,V,Vnew,bpp,dpp,pnew,pold; float A1,A2,B1,B2,C1,C2; float x1,x2,y1,y2,f,f1; cout“Enter the temperature in deg C”; cint; cout“Enter the overall composition of species 1”; cinz1; z2=1-z1; //Listing the values of the Antoine parameters A1=14.39155; A2=16.26205; B1=2795.817; B2=3799.887; C1=230.002; C2=226.346; //Calculation of BPP x1=z1; x2=z2; p1sat=exp(A1-(B1/(t+C1))); p2sat=exp(A2-(B2/(t+C2))); h12=V2*exp(-a12/(r*(t+273.15)))/V1; h21=V1*exp(-a21/(r*(t+273.15)))/V2; m=(h12/(x1+x2*h12))-(h21/(x2+x1*h21)); g1=exp(-log(x1+x2*h12)+x2*m); g2=exp(-log(x2+x1*h21)-x1*m); p=x1*g1*p1sat+x2*g2*p2sat; cout“BPP=”p“kPan”; bpp=p; gb1=g1; gb2=g2; //Calculation of DPP y1=z1; y2=z2; p1sat=exp(A1-(B1/(t+C1))); p2sat=exp(A2-(B2/(t+C2))); g1=g2=1; pnew=1/(y1/(g1*p1sat)+y2/(g2*p2sat));
  • 791. Appendix: Programs in C++ 243 g1n=g1;g2n=g2; do { pold=pnew; do { g1=g1n; g2=g2n; x1=y1*pold/(g1*p1sat); x2=y2*pold/(g2*p2sat); x1=x1/(x1+x2); x2=1-x1; h12=V2*exp(-a12/(r*(t+273.15)))/V1; h21=V1*exp(-a21/(r*(t+273.15)))/V2; m=(h12/(x1+x2*h12))-(h21/(x2+x1*h21)); g1n=exp(-log(x1+x2*h12)+x2*m); g2n=exp(-log(x2+x1*h21)-x1*m); } while(fabs(g1n-g1).0001fabs(g2n-g2).0001); pnew=1/(y1/(g1n*p1sat)+y2/(g2n*p2sat)); } while(fabs(pnew-pold).0001); cout“DPP=”pnew“n”; dpp=pnew; gd1=g1n; gd2=g2n; cout“Enter a pressure between “dpp“ and “bpp“n”; cinp; V=(bpp-p)/(bpp-dpp); g1=((p-dpp)*(gb1-gd1))/(bpp-dpp)+gd1; g2=((p-dpp)*(gb2-gd2))/(bpp-dpp)+gd2; //Calculation of distribution coefficients do { g1n=g1; g2n=g2; k1=g1n*p1sat/p; k2=g2n*p2sat/p; do { V=Vnew; y1=(k1*z1)/(1-V+V*k1); y2=(k2*z2)/(1-V+V*k2); x1=y1/k1; x2=y2/k2; f=y1-x1+y2-x2;
  • 792. 244 Appendix: Programs in C++ f1=-(z1*(k1-1)*(k1-1)/((1-V+V*k1)*(1-V+V*k1))+ z2*(k2-1)*(k2-1)/((1-V+V*k2)*(1-V+V*k2))); Vnew=V-f/f1; } while(fabs(Vnew-V).00001); h12=V2*exp(-a12/(r*(t+273.15)))/V1; h21=V1*exp(-a21/(r*(t+273.15)))/V2; m=(h12/(x1+x2*h12))-(h21/(x2+x1*h21)); g1=exp(-log(x1+x2*h12)+x2*m); g2=exp(-log(x2+x1*h21)-x1*m); } while(fabs(g1-g1n).0001fabs(g2-g2n).0001); cout“The number of moles in vapour phase is”Vnew“n”; cout“x1+x2=”(x1+x2)“n”; cout“y1+y2=”(y1+y2)“n”; cout“x1=”x1“n”; cout“y1=”y1“n”; getch(); } PROGRAM 3.6 //PROGRAM 3.6 //program to calculate the vapour pressure at the given //temperature using the Peng–Robinson eos by comparing the fugacities of the //liquid and vapour phases #includeiostream.h #includeconio.h #includemath.h void main() { clrscr(); float w,s,t,tc,k,a,b,r=8.314,lpha,vold,vnew; float vliq,vvap,zliq,zvap,c,d,fl,fv,pnew,p,pc,f,f1; cout“Enter the temperature in deg K and assumed pressure in Pa”; cintpnew; cout“Enter the value of the critical temperature in deg K and the critical pressure in Pa”; cintcpc; cout“Enter the value of the acentric factor”; cinw; k=.37464+1.54226*w-.26992*w*w; s=1+k*(1-pow(t/tc,.5)); lpha=pow(s,2); a=.45724*r*r*tc*tc*lpha/pc; b=.07780*r*tc/pc;
  • 793. Appendix: Programs in C++ 245 do { p=pnew; vnew=b; do { vold=vnew; f=pow(vold,3.0)*p+vold*vold*(p*b-r*t)-vold*(3.0*p*b*b+2.0*b*r*t-a); f=f+(p*b*b*b+b*b*r*t-a*b); f1=pow(vold,2.0)*3.0*p+vold*2.0*(b*p-t*r)+(a-3.0*b*b*p-2.0*r*t*b); vnew=vold-f/f1; } while(fabs(vnew-vold)1e-6); vliq=vnew; zliq=p*vliq/(r*t); c=(a/(2.0*sqrt(2.0)*b*r*t))*(log((zliq+(1.0+sqrt(2.0))*b*p/(r*t))/ (zliq+(1.0-sqrt(2.0))*b*p/(r*t)))); fl=p*exp(zliq-1-log(zliq-p*b/(r*t))-c); vnew=r*t/p; do { vold=vnew; f=pow(vold,3.0)*p+vold*vold*(p*b-r*t)-vold*(3.0*p*b*b+2.0*b*r*t-a); f=f+(p*b*b*b+b*b*r*t-a*b); f1=pow(vold,2.0)*3.0*p+vold*2.0*(b*p-t*r)+(a-3.0*b*b*p-2.0*r*t*b); vnew=vold-f/f1; } while(fabs(vnew-vold)1e-6); vvap=vnew; zvap=p*vvap/(r*t); d=(a/(2.0*sqrt(2.0)*b*r*t))*(log((zvap+(1.0+sqrt(2.0))*b*p/(r*t))/ (zvap+(1.0-sqrt(2.0))*b*p/(r*t)))); fv=p*exp(zvap-1.0-log(zvap-b)-d); pnew=p*fl/fv; } while(fabs(pnew-p)1e-6); cout“The saturated vapour pressure at “t“ deg K is “pnew“ Pa”endl; getch(); } PROGRAM 3.7 //PROGRAM 3.7 //program to calculate the bubble point pressure using the gamma–phi approach #includeiostream.h
  • 794. 246 Appendix: Programs in C++ #includeconio.h #includemath.h void main() { clrscr(); float p,t,p1sat,p2sat,r=8.314,pnew,vc1,vc2,x1,x2,y1,y2,h12,h21,b11; float b22,b12,vc12,pc1,pc2,pc12,w1,w2,w12,tc1,tc2,tc12,zc1,zc2,zc12; float fc1,fc2,snew=0.0,g1,g2,f1,f2,b0,b1,tr1,tr2,tr12,k1,k2,sold,v1; float v2,a12,a21,z,d12,A1,A2,B1,B2,C1,C2; // read the values of tc1,tc2,pc1,pc2,w1,w2,zc1,zc2 // the data given are for the methanol (1) - water (2) system // A1, B1, C1, A2, B2, C2 denote the Antoine constants in this program a12=107.38*4.186;a21=469.55*4.186; tc1=512.6;tc2=647.1;pc1=80.97*pow(10,5);pc2=220.55*pow(10,5); w1=0.564;w2=0.345;zc1=0.224;zc2=0.229;v1=40.73*pow(10,-6); v2=18.07*pow(10,-6); //feed the temperature in degree C t=100.0;x1=0.958;x2=1-x1; A1=16.5938; A2=16.2620; B1=3644.3; B2=3799.89; C1=239.76; C2=226.35; p1sat=exp(A1-B1/(C1+t)); p2sat=exp(A2-B2/(C2+t)); p1sat=p1sat*1000; // converting kPa to Pa p2sat=p2sat*1000; t=t+273.15; h12=(v2/v1)*exp(-a12/(r*t)); h21=(v1/v2)*exp(-a21/(r*t)); z=h12/(x1+x2*h12)-h21/(x2+x1*h21); g1=exp(-log(x1+x2*h12)+x2*z); g2=exp(-log(x2+x1*h21)-x1*z); tr1=t/tc1; b0=.083-0.422*pow(tr1,-1.6); b1=.139-0.172*pow(tr1,-4.2); b11=(r*tc1/pc1)*(b0+w1*b1); tr2=t/tc2; b0=.083-0.422*pow(tr2,-1.6); b1=.139-0.172*pow(tr2,-4.2); b22=(r*tc2/pc2)*(b0+w2*b1); w12=(w1+w2)*0.5; tc12=pow((tc1*tc2),0.5); zc12=(zc1+zc2)*0.5; vc1=zc1*r*tc1/pc1;vc2=zc2*r*tc2/pc2;
  • 795. Appendix: Programs in C++ 247 vc12=pow((pow(vc1,0.333333)+pow(vc2,0.33333))*0.5,3); pc12=zc12*r*tc12/vc12; tr12=t/tc12; b0=.083-0.422*pow(tr12,-1.6); b1=.139-0.172*pow(tr12,-4.2); b12=(r*tc12/pc12)*(b0+w12*b1); d12=2*b12-b11-b22; p=x1*g1*p1sat+x2*g2*p2sat; y1=x1*g1*p1sat/p;y2=x2*g2*p2sat/p; pnew = p; do { p=pnew; f1=p1sat*(exp(b11*p1sat/(r*t)))*(exp((v1*(p-p1sat)/(r*t)))); f2=p2sat*(exp(b22*p2sat/(r*t)))*(exp((v2*(p-p2sat)/(r*t)))); do { sold=snew; fc1=exp((p/(r*t))*(b11+y2*y2*d12)); fc2=exp((p/(r*t))*(b22+y1*y1*d12)); k1=g1*f1/(fc1*p); k2=g2*f2/(fc2*p); snew=x1*k1+x2*k2; y1=x1*k1/snew; y2=x2*k2/snew; } while(fabs(snew-sold)1e-6); pnew=(x1*g1*f1/fc1)+(x2*g2*f2/fc2); y1=x1*g1*f1/(fc1*pnew);y2=x2*g2*f2/(fc2*pnew); } while(fabs(pnew-p)1e-6); cout“fc1=”fc1endl“fc2=”fc2endl; cout“g1=”g1endl“g2=”g2endl; cout“k1=”k1endl“k2=”k2endl; cout“p=”pendl“y1=”y1endl; getch(); } PROGRAM 3.8 //PROGRAM 3.8 //program to calculate the bubble point pressure using the Peng–Robinson eos #includeiostream.h #includeconio.h #includemath.h void main() {
  • 796. 248 Appendix: Programs in C++ float t,x1,x2,y1,y2,tc1,tc2,v,vnew,pnew,p,zliq,zvap,avap,bvap; float fc1l,fc2l,fc1v,fc2v,y1n,y2n; float k1,k2,w1,w2,f,f1,lpha1,lpha2,r,snew,sold,pc1,pc2; float aliq,bliq,b1,b2,a11,a22,a12,m1,m2; clrscr(); //the data are for the CO2 (1) – n-pentane (2) system t=377.65;x1=0.5; cout“The value of x1=”x1endl; cout“Enter an assumed value of y1 greater than x1 n”; ciny1; tc1=304.2;tc2=469.7;pc1=73.83e5;pc2=33.70e5;w1=0.224;w2=0.252; r=8.314;x2=1-x1;y2=1-y1; k1=0.37464+1.54226*w1-0.26992*w1*w1; k2=0.37464+1.54226*w2-0.26992*w2*w2; m1=1+k1*(1-pow(t/tc1,0.5)); m2=1+k2*(1-pow(t/tc2,0.5)); lpha1=m1*m1; lpha2=m2*m2; a11=0.455724*r*r*tc1*tc1*lpha1/pc1; a22=0.455724*r*r*tc2*tc2*lpha2/pc2; a12=(pow(a11*a22,0.5)); b1=0.07780*r*tc1/pc1; b2=0.07780*r*tc2/pc2; aliq=(x1*x1*a11+x2*x2*a22+2*x1*x2*a12); bliq=x1*b1+x2*b2; pnew=50e5; // assumed value for pressure in Pa snew=0.0; do { p=pnew; vnew=bliq; do { v=vnew; f=pow(v,3)*p+v*v*(p*bliq-r*t)-v*(3*p*bliq*bliq+2*bliq*r*t-aliq); f=f+(p*bliq*bliq*bliq+bliq*bliq*r*t-aliq*bliq); f1=pow(v,2)*3*p+v*2*(bliq*p-r*t)+(aliq-3*bliq*bliq*p-2*r*t*bliq); vnew=v-(f/f1); } while(fabs(vnew-v)1e-6); zliq=p*vnew/(r*t); fc1l=exp((b1/bliq)*(zliq-1)-log(zliq-bliq*p/(r*t))-(aliq/ (2*sqrt(2)*r*t*bliq))* ((2*(x1*a11+x2*a12)/aliq)-(b1/bliq))*log((zliq+(2.414*bliq*p/ (r*t)))/(zliq- (.414*bliq*p/(r*t)))));
  • 797. Appendix: Programs in C++ 249 fc2l=exp((b2/bliq)*(zliq-1)-log(zliq-bliq*p/(r*t))-(aliq/ (2*sqrt(2)*r*t*bliq))* ((2*(x1*a12+x2*a22)/aliq)-(b2/bliq))*log((zliq+(2.414*bliq*p/ (r*t)))/(zliq- (.414*bliq*p/(r*t))))); do { sold=snew; avap=(y1*y1*a11+y2*y2*a22+2*y1*y2*a12); bvap=y1*b1+y2*b2; vnew=r*t/p; do { v=vnew; f=pow(v,3)*p+v*v*(p*bvap-r*t)-v*(3*p*bvap*bvap+2*bvap*r*t-avap); f=f+(p*bvap*bvap*bvap+bvap*bvap*r*t-avap*bvap); f1=pow(v,2)*3*p+v*2*(bvap*p-r*t)+(avap-3*bvap*bvap*p-2*r*t*bvap); vnew=v-(f/f1); } while(fabs(vnew-v)1e-6); zvap=p*vnew/(r*t); fc1v=exp((b1/bvap)*(zvap-1)-log(zvap-bvap*p/(r*t))-(avap/ (2*sqrt(2)*r*t*bvap))* ((2*(y1*a11+y2*a12)/avap)-(b1/bvap))*log((zvap+(2.414*bvap*p/ (r*t)))/(zvap- (.414*bvap*p/(r*t))))); fc2v=exp((b2/bvap)*(zvap-1)-log(zvap-bvap*p/(r*t))-(avap/ (2*sqrt(2)*r*t*bvap))* ((2*(y1*a12+y2*a22)/avap)-(b2/bvap))*log((zvap+(2.414*bvap*p/ (r*t)))/(zvap- (.414*bvap*p/(r*t))))); k1=fc1l/fc1v;k2=fc2l/fc2v;cout“k1=”k1endl“k2=”k2endl; snew=k1*x1+k2*x2; y1=k1*x1/snew; y2=k2*x2/snew; } while(fabs(snew-sold)1e-6); pnew=p*snew; } while(fabs(pnew-p)1e-6); cout“k1=”k1endl“k2=”k2endl“bpp=”pnewendl“y1=”y1endl; getch(); }
  • 798. 250 Appendix: Programs in C++ PROGRAM 3.9 //PROGRAM 3.9 //program for the solution of two simultaneous chemical reactions #includeiostream.h #includeconio.h #includemath.h void main() { clrscr(); float x1,x2,x1new,x2new,f1,f2,df1dx1,df1dx2,df2dx1,df2dx2; float d1,d2,d3,d4,d5,d6,d7,d8,d9,d10,d11,d,deltax1,deltax2; int n; x1new=0.9; x2new=0.5; n=0; do { x1=x1new; x2=x2new; d1=(x1-x2)*pow((3*x1+x2),3); d2=(1-x1)*(5-x1-x2)*pow((6+2*x1),2); f1=(d1/d2)-0.575; f2=(x2*(3*x1+x2)/((x1-x2)*(5-x1-x2)))-2.21; d3=pow((3*x1+x2),2)*(12.0*x1-8.0*x2)/((1-x1)*(5-x1 x2) *(6+2*x1)*(6+2*x1)); d4=pow((3*x1+x2),3)*(x1-x2)*(8*x1*x1+6*x1*x2-24*x1+2*x2-16); d5=pow((1-x1),2)*pow((5-x1-x2),2)*pow((6+2*x1),3); df1dx1=d3-(d4/d5); d6=3*(x1-x2)*(3*x1+x2)*(3*x1+x2)-pow((3*x1+x2),3); d7=(1-x1)*(5-x1-x2)*(6+2*x1)*(6+2*x1); d8=((x1-x2)*(pow((3*x1+x2),3)))/((1-x1)*(5-x1-x2)*(5-x1-x2) *(6+2*x1)*(6+2*x1)); df1dx2=(d6/d7)+d8; d9=(x1-x2)*(x1-x2)*(5-x1-x2)*(5-x1-x2); df2dx1=3*x2/((x1-x2)*(5-x1-x2))-(x2*(3*x1+x2)*(5-2*x1))/d9; d10=(3*x1+2*x2)/((x1-x2)*(5-x1-x2)); d11=x2*(3*x1+x2)*(2*x2-5)/((pow((x1-x2),2))*pow((5-x1-x2),2)); df2dx2=d10-d11; d=df1dx1*df2dx2-df1dx2*df2dx1; deltax1=(f2*df1dx2-f1*df2dx2)/d; deltax2=(f1*df2dx1-f2*df1dx1)/d; x1new=x1+deltax1; x2new=x2+deltax2; n=n+1;
  • 799. Appendix: Programs in C++ 251 }while(fabs(x1new-x1)1e-6fabs(x2new-x2)1e-6); cout“The number of iterations performed is “nendl; coutx1new“ “x2newendl; getch(); } PROGRAM 3.10 //PROGRAM 3.10 //program to calculate the adiabatic flame temperature (AFT) for a fuel //case of complete conversion #includeiostream.h #includeconio.h #includemath.h void main() { clrscr(); float sa,sb,sc,sd,da,db,dc,dd,t,tnew,t0=298.15,t1,n1,n2,n3,n4,f,f1,h0; float u1=1,u2=3.5,u3=2,u4=3; // n1, n2, n3, n4 are the number of moles entering of species // 1, 2, 3, 4 respectively and u1, u2, u3, and u4 are their stoichiometric // coefficients. The data is given for the reaction // C2H6 + 3.5O2 = 2CO2 + 3H2O // C2H6 is 1, O2 is 2, CO2 is 3 and H2O is 4 float a1=1.648,a2=6.085,a3=5.316,a4=7.700; float b1=4.124e-2,b2=.3631e-2,b3=1.4285e-2,b4=.04594e-2; float c1=-1.530e-5,c2=-.1709e-5,c3=-.8362e-5,c4=.2521e-5; float d1=1.740e-9,d2=.3133e-9,d3=1.784e-9,d4=-.8587e-9; cout“Enter the value of n1,n2,n3,n4n”; cinn1n2n3n4; cout“nEnter the inlet temperature in deg C”; cint1; t1=t1+273.15; sa=n1*a1+n2*a2+n3*a3+n4*a4; sb=n1*b1+n2*b2+n3*b3+n4*b4; sc=n1*c1+n2*c2+n3*c3+n4*c4; sd=n1*d1+n2*d2+n3*d3+n4*d4; da=u4*a4+u3*a3-u2*a2-u1*a1; db=u4*b4+u3*b3-u2*b2-u1*b1; dc=u4*c4+u3*c3-u2*c2-u1*c1; dd=u4*d4+u3*d3-u2*d2-u1*d1; h0=(u4*(-57.7979)+u3*(-94.052)-u2*0-u1*(-20.236))*1000; tnew=1000; //for various old values of tnew the final answer is the same do {
  • 800. 252 Appendix: Programs in C++ t=tnew; f=sa*(t-t1)+(sb/2)*(t*t-t1*t1)+(sc/3)*(t*t*t-t1*t1*t1)+(sd/4) *(t*t*t*t-t1*t1*t1*t1); f=f+h0+da*(t-t0)+(db/2)*(t*t-t0*t0)+(dc/3)*(t*t*t-t0*t0*t0)+(dd/4) *(t*t*t*t-t0*t0*t0*t0); f1=sa+sb*t+sc*t*t+sd*t*t*t+da+db*t+dc*t*t+dd*t*t*t; tnew=t-f/f1; }while(fabs((tnew-t)/tnew)1e-6); cout“AFT=”tnew; getch(); } PROGRAM 4.1 //PROGRAM 4.1 //program to solve an ordinary differential equation by the Runge–Kutta method #includeiostream.h #includeconio.h #includemath.h void main() { clrscr(); float h,x0,xf,y,k1,k2,k3,k4; int n; x0=0.00000,y=2.00000; float func(float,float); cout“ttt OUTPUT”endl; cout“nEnter the value of x at which y is required: “; cinxf; cout“tEnter the value of step length (h): “; cinh; n=(xf-x0)/h; for(int i=0;i=n-1;i++) { k1=h*func(x0,y); k2=h*func(x0+0.5*h,y+0.5*k1); k3=h*func(x0+0.5*h,y+0.5*k2); k4=h*func(x0+h,y+k3); y=y+((k1+2.0*k2+2.0*k3+k4)/6.0); x0=x0+h; } cout“t Value found by Runge-Kutta method at given x: “y; coutendl; getch(); } float func(float x, float y) {
  • 801. Appendix: Programs in C++ 253 float f=-y/(1.0+x); return(f); } PROGRAM 4.2 //PROGRAM 4.2 //program to determine the velocity of a particle in a pneumatic conveyor #includeiostream.h #includeconio.h #includemath.h void main() { clrscr(); float h,z0,z,zf,y0,y,vp,k1,k2,k3,k4; int n; z0=0.00000,y0=0.00000; float func(float,float); cout“ttt OUTPUT”endl; cout“nEnter the value of z in m at which vp is required: “; cinzf; cout“tEnter the value of step length (h): “; cinh; n=(zf-z0)/h; for(int i=0;i=n-1;i++) { k1=h*func(z0,y0); k2=h*func(z0+0.5*h,y0+0.5*k1); k3=h*func(z0+0.5*h,y0+0.5*k2); k4=h*func(z0+h,y0+k3); y=y0+((k1+2.0*k2+2.0*k3+k4)/6.0); z0=z0+h; y0=y; vp=sqrt(y); cout“t Value found at z = “z0 “ = “vpendl; } cout“t Value found by Runge-Kutta method at given z: “vp; coutendl; getch(); } float func(float a, float b) { float rep=19.648*(12.0-sqrt(b)); float cd=24.0*(1.0+0.15*pow(rep,0.687))/rep; float f=6.55*cd*(12.0-sqrt(b))*(12.0-sqrt(b))-19.594; return(f); }
  • 802. 254 Appendix: Programs in C++ PROGRAM 4.3 //PROGRAM 4.3 //program to solve two simultaneous ordinary differential equations //by Runge-Kutta method #includeiostream.h #includeconio.h #includemath.h void main() { clrscr(); float h,x0,xf,y,z,k1,k2,k3,k4,l1,l2,l3,l4; int n; x0=0.00000,y=2.00000,z=1.00000; float func1(float,float,float); float func2(float,float,float); cout“ttt OUTPUT”endl; cout“nEnter the value of x at which y and z are required: “; cinxf; cout“tEnter the value of step length (h): “; cinh; n=(xf-x0)/h; for(int i=0;i=n-1;i++) { k1=h*func1(x0,y,z); l1=h*func2(x0,y,z); k2=h*func1(x0+0.5*h,y+0.5*k1,z+0.5*l1); l2=h*func2(x0+0.5*h,y+0.5*k1,z+0.5*l1); k3=h*func1(x0+0.5*h,y+0.5*k2,z+0.5*l2); l3=h*func2(x0+0.5*h,y+0.5*k2,z+0.5*l2); k4=h*func1(x0+h,y+k3,z+l3); l4=h*func2(x0+h,y+k3,z+l3); y=y+((k1+2.0*k2+2.0*k3+k4)/6.0); z=z+((l1+2.0*l2+2.0*l3+l4)/6.0); x0=x0+h; } cout“t Value at given x: “y“ “z; coutendl; getch(); } float func1(float x, float y, float z) { float f=z; return(f); } float func2(float x, float y, float z) {
  • 803. Appendix: Programs in C++ 255 float f=-y; return(f); } PROGRAM 4.4 //PROGRAM 4.4 //program to solve three simultaneous ordinary differential equations //by the Runge-Kutta method #includeiostream.h #includeconio.h #includemath.h void main() { clrscr(); double h,t0,tf,temp1,temp2,temp3,k1,k2,k3,k4; double l1,l2,l3,l4,m1,m2,m3,m4; long n; t0=0.00000,temp1=20.00000,temp2=20.00000,temp3=20.00000; double func1(double,double,double,double); double func2(double,double,double,double); double func3(double,double,double,double); cout“ttt OUTPUT”endl; cout“nEnter the value of t in sec at which temperatures are required: “; cintf; cout“tEnter the value of the step length (h): “; cinh; n=(tf-t0)/h; cout“The number n is = “nendl; for(long i=0;i=n-1;i++) { k1=h*func1(t0,temp1,temp2,temp3); l1=h*func2(t0,temp1,temp2,temp3); m1=h*func3(t0,temp1,temp2,temp3); k2=h*func1(t0+0.5*h,temp1+0.5*k1,temp2+0.5*l1,temp3+0.5*m1); l2=h*func2(t0+0.5*h,temp1+0.5*k1,temp2+0.5*l1,temp3+0.5*m1); m2=h*func3(t0+0.5*h,temp1+0.5*k1,temp2+0.5*l1,temp3+0.5*m1); k3=h*func1(t0+0.5*h,temp1+0.5*k2,temp2+0.5*l2,temp3+0.5*m2); l3=h*func2(t0+0.5*h,temp1+0.5*k2,temp2+0.5*l2,temp3+0.5*m2); m3=h*func3(t0+0.5*h,temp1+0.5*k2,temp2+0.5*l2,temp3+0.5*m2); k4=h*func1(t0+h,temp1+k3,temp2+l3,temp3+m3); l4=h*func2(t0+h,temp1+k3,temp2+l3,temp3+m3); m4=h*func3(t0+h,temp1+k3,temp2+l3,temp3+m3); temp1=temp1+((k1+2.0*k2+2.0*k3+k4)/6.0); temp2=temp2+((l1+2.0*l2+2.0*l3+l4)/6.0); temp3=temp3+((m1+2.0*m2+2.0*m3+m4)/6.0);
  • 804. 256 Appendix: Programs in C++ t0=t0+h; } cout“t Value at given t: “temp1“ “temp2“ “temp3; coutendl; getch(); } double func1(double t, double temp1, double temp2, double temp3) { double f=0.065-0.0021*temp1; return(f); } double func2(double t, double temp1, double temp2, double temp3) { double f=0.002*temp1-0.0021*temp2+0.025; return(f); } double func3(double t, double temp1, double temp2, double temp3) { double f=0.002*temp2-0.0021*temp3+0.025; return(f); } PROGRAM 4.5 //PROGRAM 4.5 //program to solve three simultaneous ordinary differential equations //for the reaction a - b - c by the Runge-Kutta fourth order method #includeiostream.h #includeconio.h #includemath.h void main() { clrscr(); float h,t0,tf,a,b,c,k1,k2,k3,k4; float l1,l2,l3,l4,m1,m2,m3,m4; int n; t0=0.00000,a=1.00000,b=0.00000,c=0.00000; float func1(float,float,float,float); float func2(float,float,float,float); float func3(float,float,float,float); cout“ttt OUTPUT”endl; cout“nEnter the value of t in sec at which concentrations are required: “; cintf; cout“tEnter the value of step length (h): “; cinh; n=(tf-t0)/h;
  • 805. Appendix: Programs in C++ 257 cout“The number n is “nendl; for(int i=0;i=n-1;i++) { k1=h*func1(t0,a,b,c); l1=h*func2(t0,a,b,c); m1=h*func3(t0,a,b,c); k2=h*func1(t0+0.5*h,a+0.5*k1,b+0.5*l1,c+0.5*m1); l2=h*func2(t0+0.5*h,a+0.5*k1,b+0.5*l1,c+0.5*m1); m2=h*func3(t0+0.5*h,a+0.5*k1,b+0.5*l1,c+0.5*m1); k3=h*func1(t0+0.5*h,a+0.5*k2,b+0.5*l2,c+0.5*m2); l3=h*func2(t0+0.5*h,a+0.5*k2,b+0.5*l2,c+0.5*m2); m3=h*func3(t0+0.5*h,a+0.5*k2,b+0.5*l2,c+0.5*m2); k4=h*func1(t0+h,a+k3,b+l3,c+m3); l4=h*func2(t0+h,a+k3,b+l3,c+m3); m4=h*func3(t0+h,a+k3,b+l3,c+m3); a=a+((k1+2.0*k2+2.0*k3+k4)/6.0); b=b+((l1+2.0*l2+2.0*l3+l4)/6.0); c=c+((m1+2.0*m2+2.0*m3+m4)/6.0); t0=t0+h; } cout“t Value at given t: “a“ “b“ “cendl; getch(); } float func1(float t, float a, float b, float c) { float f=-a; return(f); } float func2(float t, float a, float b, float c) { float f=a-b; return(f); } float func3(float t, float a, float b, float c) { float f=b; return(f); } PROGRAM 4.6 //PROGRAM 4.6 //program to solve four simultaneous ordinary differential equations //for the reactions a + b - c and b + c - d by the Runge-Kutta method #includeiostream.h #includeconio.h
  • 806. 258 Appendix: Programs in C++ #includemath.h void main() { clrscr(); double h,t0,tf,a,b,c,d,k1,k2,k3,k4; double l1,l2,l3,l4,m1,m2,m3,m4,n1,n2,n3,n4; long n; t0=0.00000,a=1.00000,b=1.00000,c=0.00000,d=0.00000; double func1(double,double,double,double,double); double func2(double,double,double,double,double); double func3(double,double,double,double,double); double func4(double,double,double,double,double); cout“ttt OUTPUT”endl; cout“nEnter the value of t in sec at which concentrations are required: “; cintf; cout“tEnter the value of step length (h): “; cinh; n=(tf-t0)/h; cout“The number n is = “nendl; for(long i=0;i=n-1;i++) { k1=h*func1(t0,a,b,c,d); l1=h*func2(t0,a,b,c,d); m1=h*func3(t0,a,b,c,d); n1=h*func4(t0,a,b,c,d); k2=h*func1(t0+0.5*h,a+0.5*k1,b+0.5*l1,c+0.5*m1,d+0.5*n1); l2=h*func2(t0+0.5*h,a+0.5*k1,b+0.5*l1,c+0.5*m1,d+0.5*n1); m2=h*func3(t0+0.5*h,a+0.5*k1,b+0.5*l1,c+0.5*m1,d+0.5*n1); n2=h*func4(t0+0.5*h,a+0.5*k1,b+0.5*l1,c+0.5*m1,d+0.5*n1); k3=h*func1(t0+0.5*h,a+0.5*k2,b+0.5*l2,c+0.5*m2,d+0.5*n2); l3=h*func2(t0+0.5*h,a+0.5*k2,b+0.5*l2,c+0.5*m2,d+0.5*n2); m3=h*func3(t0+0.5*h,a+0.5*k2,b+0.5*l2,c+0.5*m2,d+0.5*n2); n3=h*func4(t0+0.5*h,a+0.5*k2,b+0.5*l2,c+0.5*m2,d+0.5*n2); k4=h*func1(t0+h,a+k3,b+l3,c+m3,d+n3); l4=h*func2(t0+h,a+k3,b+l3,c+m3,d+n3); m4=h*func3(t0+h,a+k3,b+l3,c+m3,d+n3); n4=h*func4(t0+h,a+k3,b+l3,c+m3,d+n3); a=a+((k1+2.0*k2+2.0*k3+k4)/6.0); b=b+((l1+2.0*l2+2.0*l3+l4)/6.0); c=c+((m1+2.0*m2+2.0*m3+m4)/6.0); d=d+((n1+2.0*n2+2.0*n3+n4)/6.0); t0=t0+h; } cout“t Value at given t: “a“ “b“ “c“ “dendl; getch(); }
  • 807. Appendix: Programs in C++ 259 double func1(double t, double a, double b, double c, double d) { double f=-a*b; return(f); } double func2(double t, double a, double b, double c, double d) { double f=-a*b-b*c; return(f); } double func3(double t, double a, double b, double c, double d) { double f=a*b-b*c; return(f); } double func4(double t, double a, double b, double c, double d) { double f=b*c; return(f); } PROGRAM 4.7 //PROGRAM 4.7 //program to solve ordinary differential equations in a non-isothermal //tubular reactor by the Runge-Kutta method #includeiostream.h #includeconio.h #includemath.h void main() { clrscr(); float h,z0,zf,x,t,k1,k2,k3,k4,l1,l2,l3,l4; int n; z0=0.00000,x=0.00000,t=294.15; float func1(float,float,float); float func2(float,float,float); cout“ttt OUTPUT”endl; cout“nEnter the value of z in m at which x and t are required: “; cinzf; cout“tEnter the value of step length (h): “; cinh; n=(zf-z0)/h; for(int i=0;i=n-1;i++) {
  • 808. 260 Appendix: Programs in C++ k1=h*func1(z0,x,t); l1=h*func2(z0,x,t); k2=h*func1(z0+0.5*h,x+0.5*k1,t+0.5*l1); l2=h*func2(z0+0.5*h,x+0.5*k1,t+0.5*l1); k3=h*func1(z0+0.5*h,x+0.5*k2,t+0.5*l2); l3=h*func2(z0+0.5*h,x+0.5*k2,t+0.5*l2); k4=h*func1(z0+h,x+k3,t+l3); l4=h*func2(z0+h,x+k3,t+l3); x=x+((k1+2.0*k2+2.0*k3+k4)/6.0); t=t+((l1+2.0*l2+2.0*l3+l4)/6.0); z0=z0+h; } cout“t Value at given z: “x“ “tendl; coutendl; getch(); } float func1(float z, float x, float t) { float f=0.0527*(1-x)*exp(33.68*(1-388.71/t)); return(f); } float func2(float z, float x, float t) { float f=7.665*(388.71-t)-29554.1*0.0527*(1-x)*exp(33.68*(1-388.71/t)); return(f); } PROGRAM 7.1 //PROGRAM 7.1 //program to calculate the concentration profile in a //tubular reactor with axial dispersion (second order reaction) #includeiostream.h #includeconio.h #includemath.h void main() { clrscr(); int i,j,n,i1,n1,k,iter; float a[101],b[101],c[101],d[101],x[101],x1[101],beta[101],gamma[101]; for(i=2;i=20;++i) {a[i]=2.0004; } a[21]=2.0008; c[1]=2.0008; for(i=2;i=20;++i)
  • 809. Appendix: Programs in C++ 261 {c[i]=0.0004; } d[1]=-20004.0; for(i=2;i=21;++i) {d[i]=0.0; } for(i=1;i=21;++i) {x[i]=0.0; } iter=0; do { iter=iter+1; for(i=1;i=21;++i) {x1[i]=x[i];} b[1]=-20005.9992-x1[1]; for(i=2;i=21;++i) {b[i]=-2.0008-x1[i]; } i=1; n=21; beta[i]=b[i]; gamma[i]=d[i]/beta[i]; i1=i+1; for(j=i1;j=n;++j) { beta[j]=b[j]-a[j]*c[j-1]/beta[j-1]; gamma[j]=(d[j]-a[j]*gamma[j-1])/beta[j]; } x[n]=gamma[n]; n1=n-i; for(k=1;k=n1;++k) { j=n-k; x[j]=gamma[j]-c[j]*x[j+1]/beta[j]; } }while(fabs(x[12]-x1[12])1e-6fabs(x[18]-x1[18])1e-6); cout“ttt THE SOLUTION BY TDMA”endl; for(i=1;i=21;++i) { cout“x[“i“] = “x[i]endl; } cout“Number of iterations is “iter; getch(); }
  • 810. 262 Appendix: Programs in C++ PROGRAM 7.2 //PROGRAM 7.2 //program to calculate the concentration profile in a tubular reactor //with axial dispersion in which two parallel reactions take place #includeiostream.h #includeconio.h #includemath.h void main() { clrscr(); int n,m,l,i,j,k,jj,kp1,nn,ip1; float a[90][91],x[90],x1[90],sum,big,ab,quot,t; n=84; coutnendl; m=n+1; l=n-1; for(i=1;i=n;i++) { for(j=1;j=m;j++) { a[i][j]=0.0; } } for(i=1;i=84;i++) {x[i]=0.01;} do { for(i=1;i=84;i++) {x1[i]=x[i];} a[1][1]=-20005.9992-x1[2]; a[1][5]=2.0008; a[2][2]=-20005.9992-x1[1]-x1[3]; a[2][6]=2.0008; a[3][3]=-20005.9992-x1[2]; a[3][7]=2.0008; a[4][4]=-20005.9992; a[4][8]=2.0008; a[5][1]=2.0004; a[5][5]=-2.0008-x1[6]; a[5][9]=0.0004; a[6][2]=2.0004; a[6][6]=-2.0008-x1[5]-x1[7]; a[6][10]=0.0004; a[7][3]=2.0004; a[7][7]=-2.0008-x1[6];
  • 811. Appendix: Programs in C++ 263 a[7][11]=0.0004; a[8][4]=2.0004; a[8][8]=-2.0008; a[8][12]=0.0004; a[9][5]=2.0004; a[9][9]=-2.0008-x1[10]; a[9][13]=0.0004; a[10][6]=2.0004; a[10][10]=-2.0008-x1[9]-x1[11]; a[10][14]=0.0004; a[11][7]=2.0004; a[11][11]=-2.0008-x1[10]; a[11][15]=0.0004; a[12][8]=2.0004; a[12][12]=-2.0008; a[12][16]=0.0004; a[13][9]=2.0004; a[13][13]=-2.0008-x1[14]; a[13][17]=0.0004; a[14][10]=2.0004; a[14][14]=-2.0008-x1[13]-x1[15]; a[14][18]=0.0004; a[15][11]=2.0004; a[15][15]=-2.0008-x1[14]; a[15][19]=0.0004; a[16][12]=2.0004; a[16][16]=-2.0008; a[16][20]=0.0004; a[17][13]=2.0004; a[17][17]=-2.0008-x1[18]; a[17][21]=0.0004; a[18][14]=2.0004; a[18][18]=-2.0008-x1[17]-x1[19]; a[18][22]=0.0004; a[19][15]=2.0004; a[19][19]=-2.0008-x1[18]; a[19][23]=0.0004; a[20][16]=2.0004; a[20][20]=-2.0008; a[20][24]=0.0004; a[21][17]=2.0004; a[21][21]=-2.0008-x1[22]; a[21][25]=0.0004; a[22][18]=2.0004; a[22][22]=-2.0008-x1[21]-x1[23]; a[22][26]=0.0004;
  • 812. 264 Appendix: Programs in C++ a[23][19]=2.0004; a[23][23]=-2.0008-x1[22]; a[23][27]=0.0004; a[24][20]=2.0004; a[24][24]=-2.0008; a[24][28]=0.0004; a[25][21]=2.0004; a[25][25]=-2.0008-x1[26]; a[25][29]=0.0004; a[26][22]=2.0004; a[26][26]=-2.0008-x1[25]-x1[27]; a[26][30]=0.0004; a[27][23]=2.0004; a[27][27]=-2.0008-x1[26]; a[27][31]=0.0004; a[28][24]=2.0004; a[28][28]=-2.0008; a[28][32]=0.0004; a[29][25]=2.0004; a[29][29]=-2.0008-x1[30]; a[29][33]=0.0004; a[30][26]=2.0004; a[30][30]=-2.0008-x1[29]-x1[31]; a[30][34]=0.0004; a[31][27]=2.0004; a[31][31]=-2.0008-x1[30]; a[31][35]=0.0004; a[32][28]=2.0004; a[32][32]=-2.0008; a[32][36]=0.0004; a[33][29]=2.0004; a[33][33]=-2.0008-x1[34]; a[33][37]=0.0004; a[34][30]=2.0004; a[34][34]=-2.0008-x1[33]-x1[35]; a[34][38]=0.0004; a[35][31]=2.0004; a[35][35]=-2.0008-x1[34]; a[35][39]=0.0004; a[36][32]=2.0004; a[36][36]=-2.0008; a[36][40]=0.0004; a[37][33]=2.0004; a[37][37]=-2.0008-x1[38]; a[37][41]=0.0004; a[38][34]=2.0004;
  • 813. Appendix: Programs in C++ 265 a[38][38]=-2.0008-x1[37]-x1[39]; a[38][42]=0.0004; a[39][35]=2.0004; a[39][39]=-2.0008-x1[38]; a[39][43]=0.0004; a[40][36]=2.0004; a[40][40]=-2.0008; a[40][44]=0.0004; a[41][37]=2.0004; a[41][41]=-2.0008-x1[42]; a[41][45]=0.0004; a[42][38]=2.0004; a[42][42]=-2.0008-x1[41]-x1[43]; a[42][46]=0.0004; a[43][39]=2.0004; a[43][43]=-2.0008-x1[42]; a[43][47]=0.0004; a[44][40]=2.0004; a[44][44]=-2.0008; a[44][48]=0.0004; a[45][41]=2.0004; a[45][45]=-2.0008-x1[46]; a[45][49]=0.0004; a[46][42]=2.0004; a[46][46]=-2.0008-x1[45]-x1[47]; a[46][50]=0.0004; a[47][43]=2.0004; a[47][47]=-2.0008-x1[46]; a[47][51]=0.0004; a[48][44]=2.0004; a[48][48]=-2.0008; a[48][52]=0.0004; a[49][45]=2.0004; a[49][49]=-2.0008-x1[50]; a[49][53]=0.0004; a[50][46]=2.0004; a[50][50]=-2.0008-x1[49]-x1[51]; a[50][54]=0.0004; a[51][47]=2.0004; a[51][51]=-2.0008-x1[50]; a[51][55]=0.0004; a[52][48]=2.0004; a[52][52]=-2.0008; a[52][56]=0.0004; a[53][49]=2.0004; a[53][53]=-2.0008-x1[54];
  • 814. 266 Appendix: Programs in C++ a[53][57]=0.0004; a[54][50]=2.0004; a[54][54]=-2.0008-x1[53]-x1[55]; a[54][58]=0.0004; a[55][51]=2.0004; a[55][55]=-2.0008-x1[54]; a[55][59]=0.0004; a[56][52]=2.0004; a[56][56]=-2.0008; a[56][60]=0.0004; a[57][53]=2.0004; a[57][57]=-2.0008-x1[58]; a[57][61]=0.0004; a[58][54]=2.0004; a[58][58]=-2.0008-x1[57]-x1[59]; a[58][62]=0.0004; a[59][55]=2.0004; a[59][59]=-2.0008-x1[58]; a[59][63]=0.0004; a[60][56]=2.0004; a[60][60]=-2.0008; a[60][64]=0.0004; a[61][57]=2.0004; a[61][61]=-2.0008-x1[62]; a[61][65]=0.0004; a[62][58]=2.0004; a[62][62]=-2.0008-x1[61]-x1[63]; a[62][66]=0.0004; a[63][59]=2.0004; a[63][63]=-2.0008-x1[62]; a[63][67]=0.0004; a[64][60]=2.0004; a[64][64]=-2.0008; a[64][68]=0.0004; a[65][61]=2.0004; a[65][65]=-2.0008-x1[66]; a[65][69]=0.0004; a[66][62]=2.0004; a[66][66]=-2.0008-x1[65]-x1[67]; a[66][70]=0.0004; a[67][63]=2.0004; a[67][67]=-2.0008-x1[66]; a[67][71]=0.0004; a[68][64]=2.0004; a[68][68]=-2.0008; a[68][72]=0.0004;
  • 815. Appendix: Programs in C++ 267 a[69][65]=2.0004; a[69][69]=-2.0008-x1[70]; a[69][73]=0.0004; a[70][66]=2.0004; a[70][70]=-2.0008-x1[69]-x1[71]; a[70][74]=0.0004; a[71][67]=2.0004; a[71][71]=-2.0008-x1[70]; a[71][75]=0.0004; a[72][68]=2.0004; a[72][72]=-2.0008; a[72][76]=0.0004; a[73][69]=2.0004; a[73][73]=-2.0008-x1[74]; a[73][77]=0.0004; a[74][70]=2.0004; a[74][74]=-2.0008-x1[73]-x1[75]; a[74][78]=0.0004; a[75][71]=2.0004; a[75][75]=-2.0008-x1[74]; a[75][79]=0.0004; a[76][72]=2.0004; a[76][76]=-2.0008; a[76][80]=0.0004; a[77][73]=2.0004; a[77][77]=-2.0008-x1[78]; a[77][81]=0.0004; a[78][74]=2.0004; a[78][78]=-2.0008-x1[77]-x1[79]; a[78][82]=0.0004; a[79][75]=2.0004; a[79][79]=-2.0008-x1[78]; a[79][83]=0.0004; a[80][76]=2.0004; a[80][80]=-2.0008; a[80][84]=0.0004; a[81][77]=2.0008; a[81][81]=-2.0008-x1[82]; a[82][78]=2.0008; a[82][82]=-2.0008-x1[81]-x1[83]; a[83][79]=2.0008; a[83][83]=-2.0008-x1[82]; a[84][80]=2.0008; a[84][84]=-2.0008; a[1][85]=-20004.0; a[2][85]=-20004.0;
  • 816. 268 Appendix: Programs in C++ a[3][85]=-x1[1]*x1[2]; a[4][85]=-x1[2]*x1[3]; a[5][85]=0.0; a[6][85]=0.0; a[7][85]=-x1[5]*x1[6]; a[8][85]=-x1[6]*x1[7]; a[9][85]=0.0; a[10][85]=0.0; a[11][85]=-x1[9]*x1[10]; a[12][85]=-x1[10]*x1[11]; a[13][85]=0.0; a[14][85]=0.0; a[15][85]=-x1[13]*x1[14]; a[16][85]=-x1[14]*x1[15]; a[17][85]=0.0; a[18][85]=0.0; a[19][85]=-x1[17]*x1[18]; a[20][85]=-x1[18]*x1[19]; a[21][85]=0.0; a[22][85]=0.0; a[23][85]=-x1[21]*x1[22]; a[24][85]=-x1[22]*x1[23]; a[25][85]=0.0; a[26][85]=0.0; a[27][85]=-x1[25]*x1[26]; a[28][85]=-x1[26]*x1[27]; a[29][85]=0.0; a[30][85]=0.0; a[31][85]=-x1[29]*x1[30]; a[32][85]=-x1[30]*x1[31]; a[33][85]=0.0; a[34][85]=0.0; a[35][85]=-x1[33]*x1[34]; a[36][85]=-x1[34]*x1[35]; a[37][85]=0.0; a[38][85]=0.0; a[39][85]=-x1[37]*x1[38]; a[40][85]=-x1[38]*x1[39]; a[41][85]=0.0; a[42][85]=0.0; a[43][85]=-x1[41]*x1[42]; a[44][85]=-x1[42]*x1[43]; a[45][85]=0.0; a[46][85]=0.0; a[47][85]=-x1[45]*x1[46]; a[48][85]=-x1[46]*x1[47];
  • 817. Appendix: Programs in C++ 269 a[49][85]=0.0; a[50][85]=0.0; a[51][85]=-x1[49]*x1[50]; a[52][85]=-x1[50]*x1[51]; a[53][85]=0.0; a[54][85]=0.0; a[55][85]=-x1[53]*x1[54]; a[56][85]=-x1[54]*x1[55]; a[57][85]=0.0; a[58][85]=0.0; a[59][85]=-x1[57]*x1[58]; a[60][85]=-x1[58]*x1[59]; a[61][85]=0.0; a[62][85]=0.0; a[63][85]=-x1[61]*x1[62]; a[64][85]=-x1[62]*x1[63]; a[65][85]=0.0; a[66][85]=0.0; a[67][85]=-x1[65]*x1[66]; a[68][85]=-x1[66]*x1[67]; a[69][85]=0.0; a[70][85]=0.0; a[71][85]=-x1[69]*x1[70]; a[72][85]=-x1[70]*x1[71]; a[73][85]=0.0; a[74][85]=0.0; a[75][85]=-x1[73]*x1[74]; a[76][85]=-x1[74]*x1[75]; a[77][85]=0.0; a[78][85]=0.0; a[79][85]=-x1[77]*x1[78]; a[80][85]=-x1[78]*x1[79]; a[81][85]=0.0; a[82][85]=0.0; a[83][85]=-x1[81]*x1[82]; a[84][85]=-x1[82]*x1[83]; for(k=1;k=l;k++) { big=fabs(a[k][k]); jj=k; kp1=k+1; for(i=kp1;i=n;i++) { ab=fabs(a[i][k]); if((big-ab)0.0) {
  • 818. 270 Appendix: Programs in C++ big=ab; jj=i; } } if((jj-k)0) { for(j=k;j=m;j++) { t=a[jj][j]; a[jj][j]=a[k][j]; a[k][j]=t; } } for(i=kp1;i=n;i++) { quot=a[i][k]/a[k][k]; for(j=kp1;j=m;j++) { a[i][j]=a[i][j]-quot*a[k][j]; } } for(i=kp1;i=n;i++) { a[i][k]=0.0; } } x[n]=a[n][m]/a[n][n]; for(nn=1;nn=l;nn++) { sum=0.0; i=n-nn; ip1=i+1; for(j=ip1;j=n;j++) { sum=sum+a[i][j]*x[j]; } x[i]=(a[i][m]-sum)/a[i][i]; } }while(fabs(x[21]-x1[21])1e-6fabs(x[84]-x1[84])1e-6); for(i=1;i=n;i++) {coutx[i]endl;} getch(); }
  • 819. Appendix: Programs in C++ 271 PROGRAM 8.1 //PROGRAM 8.1 //program to calculate the concentration profile along the radius for //reaction-diffusion in a spherical catalyst pellet (second order //isothermal reaction) #includeiostream.h #includeconio.h #includemath.h void main() { clrscr(); int i,j,n,i1,n1,k,iter; float a[105],b[105],x1[105],c[105],d[105],x[105],beta[105],gamma[105]; for(i=1;i=100;++i) {x[i]=0.0; } //loop starts from here iter=0; do { iter=iter+1; for(i=1;i=100;++i) {x1[i]=x[i]; } for(i=2;i=100;++i) {a[i]=1.0-(1.0/(i-1.0)); } b[1]=-6.0-0.01*x1[1]; for(i=2;i=100;++i) {b[i]=-2.0-0.01*x1[i]; } c[1]=6.0; for(i=2;i=99;++i) {c[i]=1.0+(1.0/(i-1.0));; } for(i=1;i=99;++i) {d[i]=0.0; } d[100]=-100.0/99.0; i=1; n=100; beta[i]=b[i]; gamma[i]=d[i]/beta[i]; i1=i+1; for(j=i1;j=n;++j) {
  • 820. 272 Appendix: Programs in C++ beta[j]=b[j]-a[j]*c[j-1]/beta[j-1]; gamma[j]=(d[j]-a[j]*gamma[j-1])/beta[j]; } x[n]=gamma[n]; n1=n-i; for(k=1;k=n1;++k) { j=n-k; x[j]=gamma[j]-c[j]*x[j+1]/beta[j]; } }while(fabs(x[1]-x1[1])1e-6fabs(x[100]-x1[100])1e-6); cout“ttt THE SOLUTION BY TDMA”endl; for(i=1;i=100;++i) { cout“x[“i“] = “x[i]endl; } cout“Number of iterations is “iter; getch(); } PROGRAM 8.2 //PROGRAM 8.2 //program to calculate the concentration profile along the radius for //reaction-diffusion in a spherical catalyst pellet (non-isothermal, beta=1) #includeiostream.h #includeconio.h #includemath.h void main() { clrscr(); int i,j,n,i1,n1,k,iter; float a[105],b[105],x1[105],c[105],d[105],x[105],beta[105],gamma[105]; for(i=1;i=100;++i) {x[i]=0.0; } iter=0; //loop starts from here do { iter=iter+1; for(i=1;i=100;++i) {x1[i]=x[i]; } for(i=2;i=100;++i)
  • 821. Appendix: Programs in C++ 273 {a[i]=1.0-(1.0/(i-1.0)); } b[1]=-6.0-0.01*exp((1.0-x1[1])/(2.0-x1[1])); for(i=2;i=100;++i) {b[i]=-2.0-0.01*exp((1.0-x1[i])/(2.0-x1[i])); } c[1]=6.0; for(i=2;i=99;++i) {c[i]=1.0+(1.0/(i-1.0));; } for(i=1;i=99;++i) {d[i]=0.0; } d[100]=-100.0/99.0; i=1; n=100; beta[i]=b[i]; gamma[i]=d[i]/beta[i]; i1=i+1; for(j=i1;j=n;++j) { beta[j]=b[j]-a[j]*c[j-1]/beta[j-1]; gamma[j]=(d[j]-a[j]*gamma[j-1])/beta[j]; } x[n]=gamma[n]; n1=n-i; for(k=1;k=n1;++k) { j=n-k; x[j]=gamma[j]-c[j]*x[j+1]/beta[j]; } }while(fabs(x[1]-x1[1])1e-6fabs(x[100]-x1[100])1e-6); cout“ttt THE SOLUTION BY TDMA”endl; for(i=1;i=100;++i) { cout“x[“i“] = “x[i]endl; } cout“Number of iterations is “iter; getch(); } PROGRAM 9.1 //PROGRAM 9.1 //program to calculate the temperature profile in a rectangular //slab during transient heat conduction
  • 822. 274 Appendix: Programs in C++ #includeiostream.h #includeconio.h #includemath.h void main() { clrscr(); int i,j,n,i1,n1,k; float a[21],b[21],c[21],d[21],x[21],beta[21],gamma[21]; float x1old,x2old,x3old,x4old,time,timef; x[1]=20.0; x[2]=20.0; x[3]=20.0; x[4]=20.0; time=0.0; timef=3.0; //a is subdiagonal, b is diagonal and c is superdiagonal a[2]=1.0; a[3]=1.0; a[4]=1.0; b[1]=-1.5; b[2]=-3.0; b[3]=-3.0; b[4]=-3.0; c[1]=1.0; c[2]=1.0; c[3]=1.0; for(time=0.1;timetimef;time=time+0.1) { x1old=x[1]; x2old=x[2]; x3old=x[3]; x4old=x[4]; d[1]=-0.5*x1old; d[2]=-x2old; d[3]=-x3old; d[4]=-x4old-300.0; i=1; n=4; beta[i]=b[i]; gamma[i]=d[i]/beta[i]; i1=i+1; for(j=i1;j=n;++j) { beta[j]=b[j]-a[j]*c[j-1]/beta[j-1]; gamma[j]=(d[j]-a[j]*gamma[j-1])/beta[j]; }
  • 823. Appendix: Programs in C++ 275 x[n]=gamma[n]; n1=n-i; for(k=1;k=n1;++k) { j=n-k; x[j]=gamma[j]-c[j]*x[j+1]/beta[j]; } cout“ttt THE SOLUTION BY TDMA AT TIME = “time“ seconds”endl; coutx[1]“ “x[2]“ “x[3]“ “x[4]endl; } getch(); } PROGRAM 9.2 //PROGRAM 9.2 //program to calculate the concentration profile in a sphere //during transient diffusion of drug from spherical pellet #includeiostream.h #includeconio.h #includemath.h void main() { clrscr(); int i,j,n,i1,n1,k; float a[21],b[21],c[21],d[21],x[21],beta[21],gamma[21]; float x1old,x2old,x3old,x4old,x5old,x6old,x7old,x8old,x9old,x10old,time,timef; for(i=1;i=10;++i) { x[i]=68.9; } time=0.0; timef=10800.0; //a is subdiagonal, b is diagonal and c is superdiagonal for(i=2;i=10;++i) { a[i]=-(1.0-1.0/(i-1.0)); } for(i=2;i=10;++i) { b[i]=3544.5; } b[1]=591.4; for(i=2;i=9;++i) {
  • 824. 276 Appendix: Programs in C++ c[i]=-(1.0+1.0/(i-1.0)); } c[1]=-1.0; for(time=0.0;timetimef;time=time+1.0) { x1old=x[1]; x2old=x[2]; x3old=x[3]; x4old=x[4]; x5old=x[5]; x6old=x[6]; x7old=x[7]; x8old=x[8]; x9old=x[9]; x10old=x[10]; d[1]=x1old*590.4; d[2]=x2old*3542.5; d[3]=x3old*3542.5; d[4]=x4old*3542.5; d[5]=x5old*3542.5; d[6]=x6old*3542.5; d[7]=x7old*3542.5; d[8]=x8old*3542.5; d[9]=x9old*3542.5; d[10]=x10old*3542.5; i=1; n=10; beta[i]=b[i]; gamma[i]=d[i]/beta[i]; i1=i+1; for(j=i1;j=n;++j) { beta[j]=b[j]-a[j]*c[j-1]/beta[j-1]; gamma[j]=(d[j]-a[j]*gamma[j-1])/beta[j]; } x[n]=gamma[n]; n1=n-i; for(k=1;k=n1;++k) { j=n-k; x[j]=gamma[j]-c[j]*x[j+1]/beta[j]; } } cout“ttt THE SOLUTION BY TDMA AT TIME = “time“ seconds”endl; for(i=1;i=10;++i)
  • 825. Appendix: Programs in C++ 277 { coutx[i]endl; } getch(); } PROGRAM 10.1 //PROGRAM 10.1 //program to calculate the temperature profile in a 2-D body //during steady heat conduction using the Gauss–Seidel method #includeiostream.h #includeconio.h #includemath.h void main() { clrscr(); float t11old,t12old,t13old,t11new,t12new,t13new; float t21old,t22old,t23old,t21new,t22new,t23new; float t31old,t32old,t33old,t31new,t32new,t33new; t11new=t12new=t13new=101.0; t21new=t22new=t23new=101.0; t31new=t32new=t33new=101.0; do { t11old=t11new; t12old=t12new; t13old=t13new; t21old=t21new; t22old=t22new; t23old=t23new; t31old=t31new; t32old=t32new; t33old=t33new; t11new=(t12old+50+0.5*t21old+100.0/3.0)*3/7; t12new=(t11new+t13old+t22old+100)/4.0; t13new=(t12new+t23old+600)/4; t21new=(t22old+0.5*t11new+0.5*t31old+100/3)*3/7; t22new=(t12new+t32old+t23old+t21new)/4; t23new=(t13new+t22new+t33old+500)/4; t31new=(0.5*t21new+0.5*t32old+100/3)*3/4; t32new=(t22new+0.5*t31new+0.5*t33old+100/3)*3/7; t33new=(t23new+250+0.5*t32new+100/3)*3/7; } w h i l e ( f a b s ( t 1 1 n e w - t 1 1 o l d ) 1 e - 6 f a b s ( t 1 2 n e w - t 1 2 o l d ) 1 e - 6fabs(t13new-t13old)1e-6
  • 826. 278 Appendix: Programs in C++ fabs(t21new-t21old)1e-6fabs(t22new-t22old)1e-6fabs(t23new- t23old)1e-6 fabs(t31new-t31old)1e-6fabs(t32new-t32old)1e-6fabs(t33new- t33old)1e-6); coutt11new“ “t12new“ “t13newendl; coutt21new“ “t22new“ “t23newendl; coutt31new“ “t32new“ “t33newendl; getch(); } PROGRAM 10.2 //PROGRAM 10.2 //program to calculate the temperature profile in a 2–D body //during steady heat conduction using the ADI method #includeiostream.h #includeconio.h #includemath.h void main() { clrscr(); int i,j,ii,jj,n,nn,nmax,i1,n1,k; float a[21],b[21],c[21],d[21],x[21],beta[21],gamma[21], t[21][21]; float tstar[21][21]; a[2]=1.0; a[3]=1.0; b[1]=-4.0; b[2]=-4.0; b[3]=-4.0; c[1]=1.0; c[2]=1.0; cout“Enter the maximum number of iterations “; cinnmax; t[0][1]=tstar[0][1]=20.0; t[0][2]=tstar[0][2]=20.0; t[0][3]=tstar[0][3]=20.0; t[1][0]=tstar[1][0]=20.0; t[2][0]=tstar[2][0]=20.0; t[3][0]=tstar[3][0]=20.0; t[4][1]=tstar[4][1]=20.0; t[4][2]=tstar[4][2]=20.0; t[4][3]=tstar[4][3]=20.0; t[1][4]=tstar[1][4]=400.0; t[2][4]=tstar[2][4]=400.0; t[3][4]=tstar[3][4]=400.0;
  • 827. Appendix: Programs in C++ 279 for(i=1;i=3;i++) { for(j=1;j=3;j++) { t[i][j]=20.0; } } for(nn=1;nn=nmax;nn++) { for(jj=1;jj=3;jj++) { d[1]=-t[0][jj]-t[1][jj+1]-tstar[1][jj-1]; d[2]=-t[2][jj+1]-tstar[2][jj-1]; d[3]=-t[4][jj]-t[3][jj+1]-tstar[3][jj-1]; i=1; n=3; beta[i]=b[i]; gamma[i]=d[i]/beta[i]; i1=i+1; for(j=i1;j=n;++j) { beta[j]=b[j]-a[j]*c[j-1]/beta[j-1]; gamma[j]=(d[j]-a[j]*gamma[j-1])/beta[j]; } x[n]=gamma[n]; n1=n-i; for(k=1;k=n1;++k) { j=n-k; x[j]=gamma[j]-c[j]*x[j+1]/beta[j]; } tstar[1][jj]=x[1]; tstar[2][jj]=x[2]; tstar[3][jj]=x[3]; } for(ii=1;ii=3;ii++) { d[1]=-t[ii][0]-tstar[ii+1][1]-tstar[ii-1][1]; d[2]=-tstar[ii+1][2]-tstar[ii-1][2]; d[3]=-t[ii][4]-tstar[ii+1][3]-tstar[ii-1][3]; i=1; n=3; beta[i]=b[i]; gamma[i]=d[i]/beta[i]; i1=i+1;
  • 828. 280 Appendix: Programs in C++ for(j=i1;j=n;++j) { beta[j]=b[j]-a[j]*c[j-1]/beta[j-1]; gamma[j]=(d[j]-a[j]*gamma[j-1])/beta[j]; } x[n]=gamma[n]; n1=n-i; for(k=1;k=n1;++k) { j=n-k; x[j]=gamma[j]-c[j]*x[j+1]/beta[j]; } t[ii][1]=x[1]; t[ii][2]=x[2]; t[ii][3]=x[3]; } } cout“ttt THE SOLUTION BY ADI”endl; coutt[1][1]“ “t[1][2]“ “t[1][3]endl; coutt[2][1]“ “t[2][2]“ “t[2][3]endl; coutt[3][1]“ “t[3][2]“ “t[3][3]endl; getch(); } PROGRAM 10.3 //PROGRAM 10.3 //program to calculate the temperature profile in a 2–D body //during transient heat conduction using the ADI method #includeiostream.h #includeconio.h #includemath.h void main() { clrscr(); int i,j,ii,jj,n,nn,nmax,i1,n1,k,kk,count; float a[21],b[21],c[21],d[21],x[21],beta[21],gamma[21],t[21][21]; float tstar[21][21],time,timef; timef=0.5; for(k=1;k=10;k++) { a[k]=-1.0; b[k]=2.4; c[k]=-1.0; }
  • 829. Appendix: Programs in C++ 281 c[1]=-2.0; for(k=1;k=11;k++) { t[11][k]=400.0; tstar[11][k]=400.0; t[k][11]=400.0; tstar[k][11]=400.0; } for(i=1;i=10;i++) { for(j=1;j=10;j++) { t[i][j]=0.0; tstar[i][j]=0.0; } } for(time=0.0;time=timef;time=time+0.05) { for(jj=1;jj=10;jj++) { if(jj==1) { for(ii=1;ii=10;ii++) { d[ii]=2*t[ii][2]-1.6*t[ii][1]; } d[10]=d[10]+400.0; } else { for(ii=1;ii=10;ii++) { d[ii]=t[ii][jj+1]+t[ii][jj-1]-1.6*t[ii][jj]; } d[10]=d[10]+400.0; } i=1; n=10; beta[i]=b[i]; gamma[i]=d[i]/beta[i]; i1=i+1; for(j=i1;j=n;++j) { beta[j]=b[j]-a[j]*c[j-1]/beta[j-1]; gamma[j]=(d[j]-a[j]*gamma[j-1])/beta[j]; }
  • 830. 282 Appendix: Programs in C++ x[n]=gamma[n]; n1=n-i; for(k=1;k=n1;++k) { j=n-k; x[j]=gamma[j]-c[j]*x[j+1]/beta[j]; } for(count=1;count=10;count=count+1) { tstar[count][jj]=x[count]; } } for(ii=1;ii=10;ii++) { if(ii==1) { for(jj=1;jj=10;jj++) { d[jj]=2*tstar[ii+1][1]-1.6*tstar[ii][1]; } d[10]=d[10]+400.0; } else { for(jj=1;jj=10;jj++) { d[jj]=tstar[ii-1][jj]+tstar[ii+1][jj]-1.6*tstar[ii][jj]; } d[10]=d[10]+400.0; } i=1; n=10; beta[i]=b[i]; gamma[i]=d[i]/beta[i]; i1=i+1; for(j=i1;j=n;++j) { beta[j]=b[j]-a[j]*c[j-1]/beta[j-1]; gamma[j]=(d[j]-a[j]*gamma[j-1])/beta[j]; } x[n]=gamma[n]; n1=n-i; for(k=1;k=n1;++k) {
  • 831. Appendix: Programs in C++ 283 j=n-k; x[j]=gamma[j]-c[j]*x[j+1]/beta[j]; } for(count=1;count=10;count=count+1) { t[ii][count]=x[count]; } } } cout“ttt THE SOLUTION BY ADI AT TIME = “time“ s”endl; for(i=1;i=10;i++) { for(j=1;j=10;j++) { cout“t[“i“][“j“] = “t[i][j]“t”; } } getch(); }
  • 832. 285 Bibliography Ahuja, P., Chemical Engineering Thermodynamics, PHI Learning, New Delhi, 2009. Anderson, J.D., Computational Fluid Dynamics: The Basics with Applications, McGraw-Hill, New York, 1995. Beers, K.J., Numerical Methods for Chemical Engineering: Applications in MATLAB, Cambridge University Press, Cambridge, UK, 2007 Bird, R.B., Stewart, W.E., and Lightfoot, E.N., Transport Phenomena, 2nd ed., John Wiley, New York, 2002. Butt, J.B., Reaction Kinetics and Reactor Design, Prentice Hall, Englewood Cliffs, New Jersey, 1980. Carnahan, B., Luther, H.A., and Wilkes, J.O., Applied Numerical Methods, John Wiley, New York, 1969 Cengel, Y.A., Heat Transfer: A Practical Approach, 2nd ed., Tata McGraw-Hill, New Delhi, 2003 Chapra, S.C. and Canale, R.P., Numerical Methods for Engineers, 3rd ed., Tata McGraw-Hill, New Delhi, 1998. Chung, T.J., Computational Fluid Dynamics, Cambridge University Press, New York, 2002. Cooper, A.R. and Jeffreys, G.V., Chemical Kinetics and Reactor Design, Oliver and Boyd, Edinburgh, 1971 Felder, R.M. and Rousseau, R.W., Elementary Principles of Chemical Processes, John Wiley, New York, 2000. Finlayson, B.A., Nonlinear Analysis in Chemical Engineering, McGraw-Hill, New York, 1980. Finlayson, B.A., Introduction to Chemical Engineering Computing, John Wiley, New York, 2006. Fogler, H.S., Elements of Chemical Reaction Engineering, 4th ed., Pearson Education/Prentice Hall, Upper Saddle River, New Jersey, 2006.
  • 833. 286 Bibliography Fox, R.W., and McDonald, A.T., Introduction to Fluid Mechanics, 5th ed., John Wiley, New York, 2004. Gear, C.W., Numerical Initial Value Problems in Ordinary Differential Equations, Prentice Hall, Englewood Cliffs, New Jersey, 1971. Gupta, S.K., Numerical Methods for Engineers, Wiley Eastern, New Delhi, 1995. Hill, C.G., Jr., Introduction to Chemical Kinetics and Reactor Design, John Wiley, New York, 1977. Holland, C.D. and Anthony, R.G., Fundamentals of Chemical Reaction Engineering, Prentice Hall, Englewood Cliffs, New Jersey, 1979 Holman, J.P., Heat Transfer, 8th ed., McGraw-Hill, New York, 1997. Jain, M.K., Iyengar, S.R.K., and Jain, R.K., Numerical Methods for Scientific and Engineering Computation, 5th ed., New Age International, New Delhi, 2007. Jenson, V.G. and Jeffreys, G.V., Mathematical Methods in Chemical Engineering, 2nd ed., Academic Press, New York, 1977. Kreyszig, E., Advanced Engineering Mathematics, 8th ed., John Wiley, New York, 1999. Levenspiel, O., Chemical Reaction Engineering, 3rd ed., John Wiley, New York, 2001. Mickley, H.S., Sherwood, T.K., and Reed, C.E., Applied Mathematics in Chemical Engineering, 2nd ed., McGraw-Hill, New York, 1957. Munson, B.R., Young, D.F., and Osiishi, T.H., Fundamentals of Fluid Mechanics, 5th ed., John Wiley, New York, 2006. Press, W.H., Teukolsky, S.A., Vetterling, W.T., and Flannery, B.P., Numerical Recipes: The Art of Scientific Computing, 3rd ed., Cambridge University Press, Cambridge, UK, 2007. Sandler, S.I., Chemical, Biochemical, and Engineering Thermodynamics, 4th ed., Wiley India Edition, New Delhi, 2006. Sastry, S.S., Introductory Methods of Numerical Analysis, 3rd ed., Prentice-Hall of India, New Delhi, 1998. Smith, J.M., van Ness, H.C., and Abbott, M.M., Introduction to Chemical Engineering Thermodynamics, 6th ed., McGraw-Hill, New York, 2001. Tannehill, J.C., Anderson, D.A., and Pletcher, R.H., Computational Fluid Mechanics and Heat Transfer, 2nd ed., Taylor and Francis, Washington, D.C., 1997. Versteeg, H.K. and Malalasekera, W., An Introduction to Computational Fluid Dynamics— The Finite Volume Method, Prentice Hall, New York, 1995. Welty, J.R., Wicks, C.E., Wilson, R.E., and Rorrer, G.L., Fundamentals of Momentum, Heat, and Mass Transfer, 4th ed., John Wiley, New York, 2001.
  • 834. 287 Index Activity coefficient, 37 Adiabatic flame temperature, 49–50 Alternating direction implicit (ADI) method, 208–220 for steady heat conduction, 208–214 for transient heat conduction, 214–220 Antoine equation, 34 Axial dispersion, 119 Backward difference scheme, 86 Batch reactor, 69–74 Block tridiagonal matrix, 150 Boundary conditions, 87 Dirichlet, 87 mixed, 87 Neumann, 87 Boundary value problem (BVP), 85 Bubble point temperature, 33–34, 38 using modified Raoult’s law, 38 using Raoult’s law, 33–34 Central difference scheme, 86, 113 Chemical reaction and diffusion first order reaction, 155–158 non-isothermal conditions, 161–168 in a pore, 97 second order reaction, 158–161 in a spherical catalyst pellet, 155–168 Chemical reaction engineering, 68–79, 119–170 boundary value problems, 119–170 initial value problems, 68–79 Chemical reaction equilibrium—two simultan- eous reactions, 47–48 Classification of partial differential equations, 171 elliptic, 171 hyperbolic, 171 parabolic, 171 Colebrook equation, 20 Comparison of central and upwind difference schemes, 113–114 Control volume, 193 Convection–diffusion problems, 105 Crank-Nicolson method, 173 Cubic equations of state, 31–33 Peng-Robinson, 33 Redlich-Kwong, 32 van der Waals, 31 Danckwert’s boundary conditions, 121 Dew point temperature, 34–35, 39–40 using modified Raoult’s law, 39–40 using Raoult’s law, 34–35 Diffusion, 97–99, 105, 155, 186–188 of drug from a spherical gel matrix, 186–188 Dirichlet boundary condition, 87 Discretization in one-dimensional space, 86, 172 in two-dimensional space, 192–194 of differential equations, 86, 172, 192–194 Double pipe heat exchanger, 55–56 Drag coefficient, 23, 60 Effective diffusion coefficient, 114 Elliptic partial differential equation, 171
  • 835. 288 Index Ergun equation for packed beds, 21 Explicit method, 172 Fin, 94 Finite difference schemes, 86, 105–107, 172–173 backward difference, 86 central difference, 86 forward difference, 86 FTCS Crank-Nicolson scheme, 173 FTCS explicit scheme, 172 FTCS implicit scheme, 173 upwind difference, 105–107 Flash calculations, 35–37, 40–42 using modified Raoult’s law, 40–42 using Raoult’s law, 35–37 Forward difference scheme, 86 Forward in time and central in space (FTCS) difference scheme, 172–173 Fourier stability analysis, 174–176 Friction factor, 20–21 Gamma-phi approach, 43–44 Gauss-Seidel method, 10 Gaussian elimination method, 5 Heat conduction, 93, 176, 195, 208, 214 one-dimensional steady, 93 one-dimensional transient, 176 two-dimensional steady, 195, 208 two-dimensional transient, 214 Implicit method, 172 Initial value problems (IVP), 53–79 batch reactor, 69 in chemical reaction engineering, 68–79 nonisothermal plug flow reactor, 76 plug flow reactor, 74 stirred tank reactor, 69 L’ Hospitals rule, 182, 187 Line-by-line TDMA (see ADI method) Linear algebraic equations, 1–12 Log mean temperature difference, 56 Minimum fluidization velocity, 21 Neumann boundary conditions, 87 Newton’s method, 17 Newton-Raphson method (see Newton’s method) Nonlinear algebraic equations, 17–29 Numerical diffusion term, 114 One-dimensional steady heat conduction, 93 transient diffusion in a sphere, 186–188 transient heat conduction, 176–185 in a cylinder, 181–183 in a rectangular slab, 176–181 in a sphere, 183–185 Optimum step size, 53 Ordinary differential equation, 53, 87, 105, 155 Overall heat transfer coefficient, 56 P-x-y diagram, 43–47 using cubic equation of state, 44–47 using gamma-phi approach, 43–44 Partial differential equation (PDE), 171 parabolic, 176–185, 214–220 Particle Reynold’s number, 24 Peclet number, 108–114 local, 109 effective, 114 Plug flow reactor, 74 Pneumatic conveying, 60 Pressure drop in a pipe under nonlaminar conditions, 20 Raoult’s law, 33–37 Rate constant, 69, 120, 129, 155, 158 first order reaction, 69, 120, 155 second order reaction, 129, 158 Red-black Gauss-Seidel method, 195 Relaxation parameter, 194 technique, 194–195 Gauss-Seidel, 194 overrelaxation, 195 underrelaxation, 195
  • 836. Index 289 Reynold’s number, 20 Round-off error, 53, 87 Runge-Kutta fourth order method, 54 Stability, 87, 174–176 Standard enthalpy change of reaction, 49 Step size, 53 Stirred tank with coil heater, 57 series of, 66 System of linear algebraic equations, 1–12 of nonlinear algebraic equations, 25 of ordinary differential equations, 63, 131 boundary value problem, 131 initial value problem, 63 Taylor series expansion, 85 Terminal velocity, 23 Thomas algorithm (see Tridiagonal matrix algorithm) Tridiagonal matrix, 1 algorithm (TDMA), 2 diagonal elements, 1 sub-diagonal elements, 1 super-diagonal elements, 1 Tridiagonal set of linear algebraic equations, 1, 94, 96, 99, 110, 111, 124, 126, 128, 130, 158, 160, 166, 168, 178, 180, 182, 185, 188, 210–214, 217–219 Truncation error, 53, 87 Tubular reactor with axial dispersion, 119–153 first order reaction, 120–128 multiple reactions, 131–153 second order reaction, 129–131 Two-dimensional steady heat conduction, 192–214 using ADI method, 208 using Gauss-Seidel method, 194 using red-black Gauss-Seidel method, 195 transient heat conduction, 214–220 using ADI method, 214–220 Upwind difference schemes, 105–108 first-order, 105 second-order, 106–108 Vapour–liquid equilibrium calculations, 33–47 using Gamma-Phi approach, 43–44 using modified Raoult’s law, 37–42 using Phi-Phi approach, 44–47 using Raoult’s law, 33–37 Vapour pressure using cubic equation of state, 42–43 Von Neumann stability analysis, 174–176
  • 837. Rs. 275.00 www.phindia.com 9 7 8 8 1 2 0 3 4 0 1 8 3 ISBN:978-81-203-4018-3 INTRODUCTION TO NUMERICAL METHODS IN CHEMICAL ENGINEERING Pradeep Ahuja his book is an exhaustive presentation of the numerical methods used in chemical engineering. Intended primarily as a textbook for BE/BTech students of chemicalTengineering, the book will also be useful to research and development/process professionals in the fields of chemical, biochemical, mechanical and biomedical engineering. The initial chapters discuss the linear and nonlinear algebraic equations. The ensuing chapters cover the problems in chemical engineering thermodynamics as well as initial value problems, boundary value problems and convection–diffusion problems. Topics related to chemical reaction, dispersion and diffusion as well as steady and transient heat conduction are treated in the final chapters. The book covers a large number of numerical methods including tridiagonal matrix algorithm (TDMA) method, Newton’s method, Runge–Kutta fourth-order method, Upwind Difference Scheme (UDS) method and Alternating Direction Implicit (ADI) method. Strong emphasis is given on applications and uses of numerical analysis specifically required at the undergraduate level. The book contains numerous worked-out examples and chapter-end exercises. The answers to all chapter-end exercises are provided. The Appendix contains a total of 33 programs in C++ related to the various numerical methods explained in the book. THE AUTHOR PRADEEP AHUJA, Ph.D., is Reader in the Department of Chemical Engineering and Technology, Institute of Technology, Banaras Hindu University, Varanasi. He has more than a decade’s experience in teaching chemical engineering at the BE/BTech level. He has published several research papers in national and international journals. Dr. Ahuja is a recipient of the AICTE Career Award for Young Teachers and a life member of the Indian Institute of Chemical Engineers (IIChE). Our other useful books Chemical Engineering Thermodynamics, Pradeep Ahuja Process Control: Concepts, Dynamics and Applications, S.K. Singh Heat Transfer: Principles and Applications, Binay K. Dutta Principles of Mass Transfer and Separation Processes, Binay K. Dutta Colloid and Interface Science, Pallab Ghosh ™Process Simulation and Control Using ASPEN , Amiya K. Jana