163
Computer Aided Process Design and Simulation Supplimentary Course material, to be read along with prescribed text books Dr. B. Nedumaran Associate Professor in Chemical Engineering Adama Science and Technology University, Ethiopia October 2017

Computer Aided Process Design and Simulation · Use the explicit Euler method to predict the behaviour of this reactor up to time equal 100s to four significant figures accuracy

  • Upload
    others

  • View
    1

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Computer Aided Process Design and Simulation · Use the explicit Euler method to predict the behaviour of this reactor up to time equal 100s to four significant figures accuracy

Computer Aided Process Design andSimulation

Supplimentary Course material,to be read along with prescribed text books

Dr. B. NedumaranAssociate Professor in Chemical Engineering

Adama Science and Technology University, Ethiopia

October– 2017

Page 2: Computer Aided Process Design and Simulation · Use the explicit Euler method to predict the behaviour of this reactor up to time equal 100s to four significant figures accuracy

2

© www.yamunacoachingcentre.in

Computer Aided Process Design and Simulation

Supplimentary Course material,to be read along with prescribed text books

Dr. B. Nedumaran

Associate Professor in Chemical Engineering

| $ e

March 2, 2018

Typeset with LATEX

Page 3: Computer Aided Process Design and Simulation · Use the explicit Euler method to predict the behaviour of this reactor up to time equal 100s to four significant figures accuracy

3

Preface

With the advancement of in the field of electronics, communication, informationtechnology and computer science and engineering, it is really impossible to makeany engineering system without computational facility and decision support sys-tems.

This book is intended for the course on Computer Aided Process Design andSimulation aimed at introducing software knowledge on MATLAB, ASPEN-HYSYS,ChemCAD for solving complex mathematical models developed for any real lifeprocess system.

The book is organised in six chapters and an Apendix with chapter 1 introduc-tion of computer Aided Process Engineering followed by numerical methods andprocess modeling in second and third chapters. The fourth chapter deels withpresentation of various software available for the engineers to simulate the entiresystem and the fifth chapter devoted for simulation laboratory exersices usingMATLAB solving linear, non-linear system of ordinary, differential and partialdifferential equations and student exercises. Chapter 6, suggests the topics fora group project with the application of programing skill using simulation soft-ware as well as developing their own routines using programming languages andMATLAB solvers. This will provide an opportunity to the students to select theirsystem and can simulate any kind of process plant including petroleum andpetrochemical sytems.

At the end (not so exhaustive) list of commonly used MATLAB commands areprovided as apendix will definitely help the reader as a ready reference.

Dr. B. NedumaranMarch 2, 2018

Page 4: Computer Aided Process Design and Simulation · Use the explicit Euler method to predict the behaviour of this reactor up to time equal 100s to four significant figures accuracy

4

Page 5: Computer Aided Process Design and Simulation · Use the explicit Euler method to predict the behaviour of this reactor up to time equal 100s to four significant figures accuracy

Contents

1 CAPE- An Introduction 9

2 Numerical methods 11

2.1 Single, first order ordinary differential equation (ODE) . . . . . . . . . 11

2.1.1 Euler Method . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11

2.1.2 Runge-Kutta Methods . . . . . . . . . . . . . . . . . . . . . . . . 14

2.1.3 Implicit Methods . . . . . . . . . . . . . . . . . . . . . . . . . . . 15

2.2 System of coupled first order ODE’s . . . . . . . . . . . . . . . . . . . . 15

2.2.1 Explicit Euler Method . . . . . . . . . . . . . . . . . . . . . . . . 16

2.3 Higher Order Differential equations . . . . . . . . . . . . . . . . . . . . 18

2.4 Partial differential equations, PDE . . . . . . . . . . . . . . . . . . . . . 19

3 Process Modeling 23

3.1 Modeling . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23

3.2 Types of Models . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23

3.2.1 Fundamental Models . . . . . . . . . . . . . . . . . . . . . . . . 23

3.2.2 Empirical Model . . . . . . . . . . . . . . . . . . . . . . . . . . . 24

3.2.3 Steady State Model . . . . . . . . . . . . . . . . . . . . . . . . . . 24

3.2.4 Unsteady State or Dynamic Model . . . . . . . . . . . . . . . . . 24

5

Page 6: Computer Aided Process Design and Simulation · Use the explicit Euler method to predict the behaviour of this reactor up to time equal 100s to four significant figures accuracy

6 CONTENTS

3.2.5 Lumped Parameter Model . . . . . . . . . . . . . . . . . . . . . . 25

3.2.6 Distributed Parameter Model . . . . . . . . . . . . . . . . . . . . 25

3.2.7 Dimensionless Model . . . . . . . . . . . . . . . . . . . . . . . . 25

3.2.8 Dynamics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25

3.2.9 Variables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25

3.3 Uses of Mathematical Models . . . . . . . . . . . . . . . . . . . . . . . 26

3.4 Scope of Coverage . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27

3.4.1 Principles of Formulation . . . . . . . . . . . . . . . . . . . . . 27

3.5 Fundamental Laws . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29

3.5.1 Continuity Equations . . . . . . . . . . . . . . . . . . . . . . . . 29

3.6 Perfectly Mixed Tank . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29

3.7 Flow through pipe . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30

3.7.1 Component Continuity Equations . . . . . . . . . . . . . . . . . 32

3.8 CSTR . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32

3.9 PFR . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34

3.10 Energy Equation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36

3.11CSTR with heater . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36

3.12Models and Solution . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 38

4 Process Simulation 101

4.1 Simulation Packages . . . . . . . . . . . . . . . . . . . . . . . . . . . . 101

4.1.1 Programing Languages and Simulation Software . . . . . . . . 101

4.1.2 Simulation–Definition . . . . . . . . . . . . . . . . . . . . . . . . 107

4.1.3 Need for Simulation software . . . . . . . . . . . . . . . . . . . . 107

4.2 Aspen-HYSYS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 108

4.3 ChemCAD . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 108

Page 7: Computer Aided Process Design and Simulation · Use the explicit Euler method to predict the behaviour of this reactor up to time equal 100s to four significant figures accuracy

CONTENTS 7

4.4 ProSim-II . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 109

4.5 ChemSep . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 110

5 LABORATORY PRACTICE with MATLAB 111

5.1 Student Exercise – 1 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 111

5.2 Student Exercise – 2 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 114

5.3 Student Exercise – 3: Equation of State . . . . . . . . . . . . . . . . . 117

5.3.1 Van der Waal’s EOS . . . . . . . . . . . . . . . . . . . . . . . . . 117

5.3.2 Redlich Kwong EOS . . . . . . . . . . . . . . . . . . . . . . . . . 117

5.3.3 Soave Redlich Kwong EOS . . . . . . . . . . . . . . . . . . . . . 118

5.3.4 Peng Robinson EOS . . . . . . . . . . . . . . . . . . . . . . . . . 118

5.3.5 Peng Robinson Gasem EOS . . . . . . . . . . . . . . . . . . . . . 119

5.3.6 Beattie-Bridgeman EOS . . . . . . . . . . . . . . . . . . . . . . . 120

5.3.7 Benedict-Webb-Rubin EOS . . . . . . . . . . . . . . . . . . . . . 122

5.4 Student Exercise – 4: Differential Equations . . . . . . . . . . . . . . . 124

5.4.1 Solving First Order Differential Equations . . . . . . . . . . . . 124

5.4.2 Solving Second and Higher Order Differential Equations . . . . 125

5.4.3 Solving System of Differental Equations . . . . . . . . . . . . . 126

5.5 Student Exercise – 5 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 129

6 Projects 143

MATLAB COMMANDS 149

Page 8: Computer Aided Process Design and Simulation · Use the explicit Euler method to predict the behaviour of this reactor up to time equal 100s to four significant figures accuracy

8 CONTENTS

Page 9: Computer Aided Process Design and Simulation · Use the explicit Euler method to predict the behaviour of this reactor up to time equal 100s to four significant figures accuracy

Chapter 1

CAPE- An Introduction

With advancement in computational facilities and chemical process industriestend to adapt more quantitative approch to problems in the design and operationof real processes. Design of process plant involves Process synthesis with:

• Reaction Path Selection

• Material Balancing

• Species allocation

• Separation task selection and sequencing

• Auxiliary task assignment and process integration

• Evolutionary improvement of initial flowsheet

• Material and Energy Balances

• Equipment Sizing and Costing

• Economic evaluation

Mathematical models consists of set of linear, nonlinear, ordinary differentialand partial differential equations representing steady state and dynamic systemof real life plant. Obtaining solution for these equations with application of nu-merical methods and manual calculation is a tedious process. With the help of

9

Page 10: Computer Aided Process Design and Simulation · Use the explicit Euler method to predict the behaviour of this reactor up to time equal 100s to four significant figures accuracy

10 CHAPTER 1. CAPE- AN INTRODUCTION

computers and advanced process engineering software it is possible to integrateto get the physico chemical properties, thermodynamic models and computeraided solvers and simulate the plant condition easily before implementing theactual process plant.

Computer aided design does not replace the process engineer completely, butprovide an opportunity to continuously improve the model and development ofnew processes with reduced energy consumotion, higher yield and quality of theproduct. Figure 1.1 indicate the integration of various stages to make a com-prehencive Computer Aided Process Engineering approach.

The course objective is to provide the student with a clear understanding ofwhat is process design, simulation & process optimization and how these canbe employed to solve practical problems commonly encountered in process en-gineering. Use of computer aided tools will play an important role. Studentsare encouraged to use softwares such as MATLAB, ASPEN for solving their ownmodel equations and simulating their ideas in process systems.

Figure 1.1: Structure of CAD Model

Page 11: Computer Aided Process Design and Simulation · Use the explicit Euler method to predict the behaviour of this reactor up to time equal 100s to four significant figures accuracy

Chapter 2

Numerical methods

2.1 Single, first order ordinary differential equation(ODE)

A first order ODE has the following general form:dy

dx= f(x, y)

wherey(x0) = y0

Solution for this type of equation can be solved by Explicit Euler method, Runga-Kutta method and Implicit Euler and Trapezoidal method.

2.1.1 Euler Method

The simplest method to numerically integrate a first order ODE is Euler method.The initial condition (x0, y0) is used to calculate the slope of y(x) at x = x0,

dy

dx

∣∣∣∣x=x0

= f(x0, y0)

Assuming that the slope dy/dx remains constant for a small distance ∆x, thevalue of y(x0 + ∆x) can be estimated as

y(x0 + ∆x) = y(x0) + ∆xf(x0, y0)

11

Page 12: Computer Aided Process Design and Simulation · Use the explicit Euler method to predict the behaviour of this reactor up to time equal 100s to four significant figures accuracy

12 CHAPTER 2. NUMERICAL METHODS

Next, these values of x and y (i.e, x0 + ∆x and y(x0 + ∆x) are used to estimate theslope at the new point.

y(x0 + 2∆x) = y(x0 + ∆x) + ∆xf [x0 + ∆x, y(x0 + ∆x)]

The general recursion relation for the Euler method is

y(xi + ∆x) = y(xi) + ∆xf [xi, y(xi)]

oryi+1 = yi + ∆xf(xi, yi)

Euler’s method also called first order method.

Example:

Using the Euler method, calculate the value of y at x = 1 if

dy

dx= x2y

where y = 1 at x = 0.

Solution:

Chose ∆x = 0.1 for x0 = 0 and y0 = 1,

y1 = 1 + 0.1× 02 × 1 = 1.0000

then for x1 = 0.1 and y1 = 1,

y2 = 1 + 0.1× 0.12 × 1 = 1.0010

theny3 = 1.001 + 0.1× 0.22 × 1.001 = 1.0050

y4 = 1.005 + 0.1× 0.32 × 1.0050 = 1.0140

Table 2.1.1 shows the iterations upto x = 1 for various ∆x. As the step sizedecreases the estimated value is closer to the analytical value.

Example: Semi-batch reactor

Semi batch reactor will have flow into the reactor while no fluid is removedfrom the reactor. Consider the following reaction A(l) k−−→ P(l) occurs in a semibatch reactor and rA = kC2

A.

Page 13: Computer Aided Process Design and Simulation · Use the explicit Euler method to predict the behaviour of this reactor up to time equal 100s to four significant figures accuracy

2.1. SINGLE, FIRST ORDER ORDINARY DIFFERENTIAL EQUATION (ODE) 13

Table 2.1: Results of Euler Example problemx ∆x ∆x ∆x ∆x Analytical

0.1 0.05 0.02 0.01 Value0 1.0000 1.0000 1.0000 1.0000 1.0000

0.1 1.0000 1.0001 1.0002 1.0003 1.00030.2 1.0010 1.0018 1.0023 1.0025 1.00270.3 1.0050 1.0069 1.0081 1.0086 1.00900.4 1.0140 1.0176 1.0199 1.0207 1.02160.5 1.0303 1.0361 1.0400 1.0412 1.04250.6 1.0560 1.0650 1.0707 1.0727 1.07470.7 1.0940 1.1070 1.1154 1.1182 1.12110.8 1.1476 1.1661 1.1718 1.1819 1.18610.9 1.2211 1.2468 1.2635 1.2692 1.27511.0 1.3200 1.3559 1.3792 1.3873 1.3956

Initially the reactor is filled to a volume V0 with an inert liquid. At time equalto zero, a stream of species A at a bconcentration CA0 is fed to the reactor at aflow rate Q0. Performing an unsteady stste mole balance on A results in

dnAdt

= Q0CA0 −kn2

A

VR

Since liquid is added to the reactor, the volumne of the reactor, VR, will increasewith timne. Performing an overall mass balance on the reactor,

d(ρVR)

dt= Q0ρ

Assuming constant density,dVRdt

= Q0

Integrating and using the initial condition yields the following:

VR = Q0t+ V0

∴dnAdt

= Q0CA0 −kn2

A

Q0t+ V0

Page 14: Computer Aided Process Design and Simulation · Use the explicit Euler method to predict the behaviour of this reactor up to time equal 100s to four significant figures accuracy

14 CHAPTER 2. NUMERICAL METHODS

where nA = 0 at t = 0 With the following values for the parameters, CA0 =1 gmol L−1, k = 0.1 L gmol−1 s−1, Q0 = 10 L s−1, V0 = 50 s then, the equation becomes

dnAdt

= 10.0− 0.1n2A

50 + 10t

Use the explicit Euler method to predict the behaviour of this reactor up to timeequal 100 s to four significant figures accuracy.

2.1.2 Runge-Kutta Methods

Runge-Kutta methods provide higher order approximations for the explicit in-tegration of initial valued ODE’s. As a result, they are among the most widelyused methods for the numerical integration of ODE’s. Assuming the ODE of thefollowing form as Euler’s method:

dy

dx= f(x, y)

Expanding the function using Tylor series of function y(x) such that

∆y = ∆x∆y′(x) +∆x2

2y′′(x) +

∆x3

6y′′′(x) + ...

In addition, ∆y is assumed to have the following form:

∆y = ak1 + bk2 + ck3 + dk4

where,k1 = f(x, y)

k2 = f(x+ n∆x, y + nk1∆x)

k3 = f(x+m∆x, y +mk2∆x)

k4 = f(x+ p∆x, y + pk3∆x)

This has been choosen in order to better approximate the slope of y over the inter-val ∆x. By writing Taylor series expansions for k1, k2, k3, and k4 and substitutinginto the above equation and comparing the last two equations and assumingthe values for n = 1/2, m = 1/2, and p = 1, the values of a, b, c, and d can bedetermined.

Page 15: Computer Aided Process Design and Simulation · Use the explicit Euler method to predict the behaviour of this reactor up to time equal 100s to four significant figures accuracy

2.2. SYSTEM OF COUPLED FIRST ORDER ODE’S 15

Hence, for the fourth order method

yi+1 = yi +∆x

6(k1 + 2k2 + 2k3 + k4)

where this equation has a local truncation error with the order of ∆x5 and above.

Solve the examples given in previous subsection using Runge-Kutta method.

2.1.3 Implicit Methods

Implicit methods do not reduce the error significantly, however they show advan-tage over explicit method, its stability.

2.2 System of coupled first order ODE’s

The general problem of set of n-coupled first order ODE’s representing an initialvalue problem (IVP) is given as

dy1

dx= f1(x, y)

dy2

dx= f2(x, y)

...

dyndx

= fn(x, y)

where, y = (y1, y2, ..., yn) and where for a single specified value x, all the values yiare known. Examples for application of coupled first order ODE’s are:

• Non-isothermal plug flow reactor

• Unsteady state batch reactor with multiple reactions

• Transient behaviour of a multi-variable control system

Page 16: Computer Aided Process Design and Simulation · Use the explicit Euler method to predict the behaviour of this reactor up to time equal 100s to four significant figures accuracy

16 CHAPTER 2. NUMERICAL METHODS

2.2.1 Explicit Euler Method

The explicit Euler method presented in the last section can be directly extendedto the solution of a system of n coupleds first order ODE’s. The algorithem is

y1,j+1 = y1,j + ∆f1(xj, yj)

y2,j+1 = y2,j + ∆f2(xj, yj)

...

yn,j+1 = yn,j + ∆fn(xj, yj)

where, yj = (y1,j, y2,j, ..., yn,j). For instance, yi,j is the value of yi at the jth value ofx (i.e., if the initial conditions are specified at x = 0, then the jth value of x wouldbe j∆x).

Example:

Consider adiabatic batch reactor with reaction A k−−→ P

dCAdt

= K1CAexp

(−ERT

)dT

dt= K2CAexp

(−ERT

)where, CA = 1.0 and T = 300 K initially. Determine the concentration and tem-perature after 100 s to three significant figures, if E

R= 300 K, K1 = −0.1 s−1, K2 =

1 K gmol−1 s−1.

Example: Consider the following hypothetical complex reaction scheme for aliquid phase system:

Ak1−−→ 2 B

Ak2−−→←−−K3

C

Bk4−−→ D + C

where, r1 = k1CA = gmol L−1 s−1, r2 = k2C3/2A , r3 = k3C

2C, r4 = k4C

2B, k1 = 1 s−1,

k2 = 0.2√

L/√

gmol/s, k3 = 0.05 L gmol−1 s−1, k4 = 0.4 L gmol−1 s−1

A continuously stirred tank reactor (CSTR) is used for this reaction system.The reactor volum, VR, is 100 L and the volumetric feed to the reactor Q is 50 L s−1

Page 17: Computer Aided Process Design and Simulation · Use the explicit Euler method to predict the behaviour of this reactor up to time equal 100s to four significant figures accuracy

2.2. SYSTEM OF COUPLED FIRST ORDER ODE’S 17

at a concentration of 1 mol L−1 of component A. Assuming steady state operationand isothermal conditions, the mole balance equation are:

F1 = −CA + CA0 + VR(−k1CA − k2C3/2A + k3C

2C)/Q = 0 (2.1)

F2 = −CB + VR(2k1CA − k4C2B)/Q = 0 (2.2)

F3 = −CC + VR(k2C3/2A − k3CC

2 + k4C2B)/Q = 0 (2.3)

F4 = −CD + VR(k4C2B)/Q = 0 (2.4)

The only unknown variables are CA, CB, CC and CD. Solve these variablesusing Newton’s method and verify with MATLAB solver.

The following non-zero partial derivatives for this problem:

∂F1

∂CA=− 1− VR(k1 + 1.5k2C

1/2A )/Q

∂F1

∂CC=VR(2k3CC)/Q

∂F2

∂CA=VR(2k1)/Q

∂F2

∂CB=− 1− VR(2k4CB)/Q

∂F3

∂CA=VR(1.5k2CA1/2)/Q

∂F3

∂CB=VR(2k4CB)/Q

∂F3

∂CC=− 1− VR(2k3CC)/Q

∂F4

∂CB=VR(2k4CB)/Q

∂F4

∂CD=− 1

Assuming the following starting point

CA = CB = CC = CD = 0.3

Page 18: Computer Aided Process Design and Simulation · Use the explicit Euler method to predict the behaviour of this reactor up to time equal 100s to four significant figures accuracy

18 CHAPTER 2. NUMERICAL METHODS

2.3 Higher Order Differential equations

Consider a general problem of nth order ODE,

F

[dny

dxn,dn−1y

dxn−1, . . . ,

dy

dx, y, x

]= 0

where,dn−1

dxn−1 = an−1dn−2

dxn−2 = an−2...

dydx

= a1

y = a0

x = x0

inorder to convert this problem into a set of coupled first order ODE’s, make thefollowing substitutions:

z1 = dydx

z2 = dz1dx

d2ydx2

...zn−1 = dzn−2

dx= dn−1y

dxn−1

The problem can be converted into the following form:

dzn−1

dx= G(zn−1, zn−2, . . . , z1, y, x)

dzn−2

dx= zn−1...

dz1 = z2dydx

= z1

where,zn−1 = an−1

zn−2 = an−2...

z1 = a1

y = a0

x = x0

which is a set of n coupled first order ODE’s of an initial value problem.

Page 19: Computer Aided Process Design and Simulation · Use the explicit Euler method to predict the behaviour of this reactor up to time equal 100s to four significant figures accuracy

2.4. PARTIAL DIFFERENTIAL EQUATIONS, PDE 19

Example:

Consider the third order ODE,

y2 d3y

dx3+ (1− x3)

d2y

dx2+ y

dy

dx= 0

wherey = 1dydx

= 1d2ydx2

= 1

}x = 0

2.4 Partial differential equations, PDE

Initial Value Partial Differential Equations (IV-PDE) describe transient problemsfor which the dependent variable also varies with spatial location (x, y, z). Dy-namic diffusion problems, concentration and temperature profile in a plug flowreactor and unsteady state heat transfer can be represented by IV-PDE. Consid-ering the temperature distribution through a brick wall which forms the wall of abuilding. Initially the wall has a uniform temperature equal to that of the outsideenvironment, T0. Then at some time t, the inside wall temperature is raised to Ti.The energy balance on a differential element inside the brick wall is given as

ρCP∂T

∂t= k

∂2T

∂x2

where ρ is the density, CP is the heat capacity of the brick wall and k is thethermal coductivity of the brick wall. T is the local temperature and x indicatesthe location inside the brick wall. The initial conditions can be written as

t = 0 T = T0 for 0 ≤ x ≤ L

and the boundary conditions are given by

T = T0 at x = 0

T = Ti at x = L

The temperature is a function of time as well as spatial coordinate x. This typeof model is called distributed parameter model. This particular model may betermed as one dimentional heat equation.

Page 20: Computer Aided Process Design and Simulation · Use the explicit Euler method to predict the behaviour of this reactor up to time equal 100s to four significant figures accuracy

20 CHAPTER 2. NUMERICAL METHODS

IV-PDE’s which are linear are a subset of the general classification of linearPDE’s. Linear PDE’s are classified according to the following formula:

A∂2Y

∂x2+B

∂2Y

∂x∂y+ C

∂2Y

∂y2= F

(x, y, Y,

∂Y

∂x;∂Y

∂y

)for

AC −B2 > 0 elliptic PDE

AC −B2 = 0 parabolic PDE

AC −B2 < 0 hyperbolic PDE

∂2Y

∂x2+∂2Y

∂y2= 0

is an elliptic PDE.

There can also be coupled IV-PDE’s. For example

∂T

∂t= f1(z, T, CA)

∂CA∂t

= f2(z, T, CA)

these equations are to be integrated together in order to map the time behaviourof the concentration and temperature profiles. Solve the following initial valuepartial differential equation.

∂Y

∂t= Y

∂2Y

∂x2

withY (x, 0) = 1.0

T (0, t) = 1.0

Y (1, t) = 0.0

Solution:

Let’s use 11 node points. Therefore ∆x = 0.1. Calling the left hand boundaryi = 0, then the ODE’s for i = 2, 8 are

dYidt

= 100Yi[Yi−1 − 2Yi + Yi+1] i = 2, . . . , 8

Page 21: Computer Aided Process Design and Simulation · Use the explicit Euler method to predict the behaviour of this reactor up to time equal 100s to four significant figures accuracy

2.4. PARTIAL DIFFERENTIAL EQUATIONS, PDE 21

For i = 1dY1

dt= 100Yi[1− 2Y1 + Y2]

For i=9dY9

dt= 100Y9[Y8 − 2Y9]

These three couples first order ODE can be solved

Page 22: Computer Aided Process Design and Simulation · Use the explicit Euler method to predict the behaviour of this reactor up to time equal 100s to four significant figures accuracy

22 CHAPTER 2. NUMERICAL METHODS

Page 23: Computer Aided Process Design and Simulation · Use the explicit Euler method to predict the behaviour of this reactor up to time equal 100s to four significant figures accuracy

Chapter 3

Process Modeling

3.1 Modeling

Definitions:

Model is derived from the Latin modus, which means a measure. Used as anoun, it means "a small representation of a planned or existing object"

A mathematical or physical system, obeying certain specified conditions, whosebehavior is used to understand a physical, biological, or social system to whichit is analogous in some way.

A process model is a set of equations (including the necessary input data tosolve the equations) that allows us to predict the behavior of a chemical processsystem.

3.2 Types of Models

3.2.1 Fundamental Models

The emphasis in this text is on the development and use of fundamental or first-principles models. By fundamental, we mean models that are based on knownphysical-chemical relationships. This includes the conservation of mass and con-

23

Page 24: Computer Aided Process Design and Simulation · Use the explicit Euler method to predict the behaviour of this reactor up to time equal 100s to four significant figures accuracy

24 CHAPTER 3. PROCESS MODELING

servation of energy, as well as reaction kinetics, transport phenomena, and ther-modynamic (phase equilibrium, etc.) relationships.

3.2.2 Empirical Model

Another common model is the empirical model. An empirical model might be usedif the process is too complex for a fundamental model (either in the fonnulation ofthe model, or the numerical solution of the model), or if the empirical model hassatisfactory predictive capability. An example of an empirical model is a simpleleast squares fit of an equation to experimental data.

Generally, we would prefer to use models based on fundamental knowledge ofchemical-physical relationships. Fundamental models will generally be accurateover a much larger range of conditions than empirical models. Empirical modelsmay be useful for "interpolation" but are generally not useful lilr "extrapolation";that is, an empirical model will only be useful over the range of conditions usedfor the "fit" of the data. It should be noted that it is rare for a single processmodel to exist.

A model is only an approximate representation of an actual process. Thecomplexity of a process model will depend on the final use of the model. If onlyan approximate answer is needed, then a simplified model can often be used.

3.2.3 Steady State Model

Model which describe time independent characteristics of a process is calledsteady state model. The model will predict the output for the given input condi-tions.

3.2.4 Unsteady State or Dynamic Model

This model is capable of predicting the dynamic transient response with timesome time called real time system adapted widely in process control systems.

Page 25: Computer Aided Process Design and Simulation · Use the explicit Euler method to predict the behaviour of this reactor up to time equal 100s to four significant figures accuracy

3.2. TYPES OF MODELS 25

3.2.5 Lumped Parameter Model

A lumped parameter systcm assumes that a variable or interest (temperature,for example) changes only with one independent variable (time, for example, butnot space). A typical example of a lumped parameter system is a perfectly mixed(stirred) tank, where the temperature is uniform throughout the tank.

3.2.6 Distributed Parameter Model

A distributed parameter system has more than one independent variable; forexample, temperature may vary with both spatial position and time.

3.2.7 Dimensionless Model

Model based on dimension less groups are often refered as dimensionless models.Examples are models with dimensionless numbers such as NRe, NNu, NSh etc.

3.2.8 Dynamics

Time-dependent behavior of a process. The behavior with no controllers in thesystem is called the openloop response. The dynamic behavior with feedbackcontrollers included with the process is called the closedloop response.

3.2.9 Variables

Manipulated variables

Typically flow rates of streams entering or leaving a process that we can changein order to control the plant.

Page 26: Computer Aided Process Design and Simulation · Use the explicit Euler method to predict the behaviour of this reactor up to time equal 100s to four significant figures accuracy

26 CHAPTER 3. PROCESS MODELING

Controlled variables

Flow rates, compositions, temperatures, levels, and pressures in the process thatwe will try to control, either trying to hold them as constant as possible or tryingto make them follow some desired time trajectory.

Uncontrolled variables

Variables in the process that are not controlled.

Load disturbances

Flow rates, temperatures, or compositions of streams entering (but sometimesleaving) the process. We are not free to manipulate them. They are set by up-stream or downstream parts of the plant. The control system must be able tokeep the plant under control despite the effects of these disturbances.

3.3 Uses of Mathematical Models

Without doubt, the most important result of developing a mathematical model ofa chemical engineering system is the understanding that is gained of what reallymakes the process “tick.” This insight enables you to strip away from the prob-lem the many extraneous “confusion factors” and to get to the core of the system.You can see more clearly the cause-and-effect relationships between the vari-ables. Mathematical models can be useful in all phases of chemical engineering,from research and development to plant operations, and even in business andeconomic studies.

1. Marketing: If the price of a product is increased, how much will the demanddecrease?

2. Allocation: If we have several sources for raw materials, and several manu-facturing plants, how do we distrihute the raw materials among the plants,and decide what products each plant produces

Page 27: Computer Aided Process Design and Simulation · Use the explicit Euler method to predict the behaviour of this reactor up to time equal 100s to four significant figures accuracy

3.4. SCOPE OF COVERAGE 27

3. Research and development: determining chemical kinetic mechanisms andparameters from laboratory or pilot-plant reaction data; exploring the effectsof different operating conditions for optimization and control studies; aidingin scale-up calculations

4. Design: exploring the sizing and arrangement of processing equipment fordynamic performance; studying the interactions of various parts of the pro-cess, particularly when material recycle or heat integration is used; evalu-ating alternative process and control structures and strategies; simulatingstart-up, shutdown, and emergency situations and procedures

5. Plant operation: troubleshooting control and processing problems; aiding instart-up and operator training; studying the effects of and the requirementsfor expansion (bottleneck-removal) projects; optimizing plant operation. Itis usually much cheaper, safer, and faster to conduct the kinds of studieslisted above on a mathematical model than experimentally on an operatingunit. This is not to say that plant tests are not needed. As we will discusslater, they are a vital part of confirming the validity of the model and ofverifying important ideas and recommendations that evolve from the modelstudies

3.4 Scope of Coverage

We will discuss in this book only deterministic systems that can be described byordinary or partial differential equations. Most of the emphasis will be on lumpedsystems (with one independent variable, time, described by ordinary differentialequations). Both English and SI units will be used. You need to be familiar withboth.

3.4.1 Principles of Formulation

1. Basis: The bases for mathematical models are the fundamental physicaland chemical laws, such as the laws of conservation of mass, energy, andmomentum. To study dynamics we will use them in their general form withtime derivatives included

Page 28: Computer Aided Process Design and Simulation · Use the explicit Euler method to predict the behaviour of this reactor up to time equal 100s to four significant figures accuracy

28 CHAPTER 3. PROCESS MODELING

2. Assumptions: Probably the most vital role that the engineer plays in mod-eling is in exercising his engineering judgment as to what assumptions canbe validly made. Obviously an extremely rigorous model that includes everyphenomenon down to microscopic detail would be so complex that it wouldtake a long time to develop and might be impractical to solve, even on thelatest supercomputers. An engineering compromise between a rigorous de-scription and getting an answer that is good enough is always required. Thishas been called optimum sloppiness. It involves making as many simplifyingassumptions as are reasonable. In practice, this optimum usually corre-sponds to a model which is as complex as the available computing facilitieswill permit. More and more this is a personal computer. The developmentof a model that incorporates the basic phenomena occurring in the processrequires a lot of skill, ingenuity, and practice. It is an area where the cre-ativity and innovativeness of the engineer is a key element in the success ofthe process. The assumptions that are made should be carefully consideredand listed. They impose limitations on the model that should always be keptin mind when evaluating its predicted results

3. Mathematical Consistency of Model: Once all the equations of the mathe-matical model have been written, it is usually a good idea, particularly withbig, complex systems of equations, to make sure that the number of vari-ables equals the number of equations. The so-called degrees of freedom ofthe system must be zero in order to obtain a solution. If this is not true,the system is underspecified or overspecified and something is wrong withthe formulation of the problem. This kind of consistency check may seemtrivial, but I can testify from sad experience that it can save many hours offrustration, confusion, and wasted computer time. Checking to see that theunits of all terms in all equations are consistent is perhaps another trivialand obvious step, but one that is often forgotten. It is essential to be partic-ularly careful of the time units of parameters in dynamic models. Any unitscan be used (seconds, minutes, hours, etc.), but they cannot be mixed. SIunits are prefered in general

4. Solution of Model Equations: The available solution techniques and toolsmust be kept in mind as a mathematical model is developed. An equationwithout any way to solve it is not worth much. MATLAB is used for solvingdifferent model equations in this course

Page 29: Computer Aided Process Design and Simulation · Use the explicit Euler method to predict the behaviour of this reactor up to time equal 100s to four significant figures accuracy

3.5. FUNDAMENTAL LAWS 29

5. Verification: An important but often neglected part of developing a mathe-matical model is proving that the model describes the real-world situation.At the design stage this sometimes cannot be done because the plant hasnot yet been built. However, even in this situation there are usually ei-ther similar existing plants or a pilot plant from which some experimentaldynamic data can be obtained. The design of experiments to test the va-lidity of a dynamic model can sometimes be a real challenge and should becarefully thought out.

3.5 Fundamental Laws

In this section, some fundamental laws of physics and chemistry are reviewed intheir general time-dependent form, and their application to some simple chemicalsystems is illustrated.

3.5.1 Continuity Equations

A. Mass Balance: The principle of the conservation of mass when applied to adynamic system says

The units of this equation are mass per time. Only one total continuity equa-tion can be written for one system. The normal steadystate design equation thatwe are accustomed to using says that ‘’what goes in, comes out.” The dynamicversion of this says the same thing with the addition of the world “eventually.”The right-hand side of Equation will be either a partial derivative ∂

∂tor an ordi-

nary derivative ddt

of the mass inside the system with respect to the independentvariable t.

3.6 Perfectly Mixed Tank

Consider the tank of perfectly mixed liquid shown in Fig. 3.1 into which flows aliquid stream at a volumetric rate of F0, (m3 min−1) and with a density of ρ, (kg m−3).The volumetric holdup of liquid in the tank is V (m3), and its density is ρ. Thevolumetric flow rate from the tank is F , and the density of the outflowing stream

Page 30: Computer Aided Process Design and Simulation · Use the explicit Euler method to predict the behaviour of this reactor up to time equal 100s to four significant figures accuracy

30 CHAPTER 3. PROCESS MODELING

Figure 3.1: Perfectly Mixed Tank

is the same as that of the tank’s contents. The system for which we want towrite a total continuity equation is all the liquid phase in the tank. We call thisa macroscopic system, as opposed to a microscopic system, since it is of definiteand finite size. The mass balance is around the whole tank, not just a small,differential element inside the tank.

F0ρ0 − Fρ = Time rate of change of ρV

Since the liquid is perfectly mixed, the density is the same everywhere in the tank;it does not vary with radial or axial position; i.e., there are no spatial gradients indensity in the tank. This is why we can use a macroscopic system. It also meansthat there is only one independent variable, t. Since ρ and V are functions onlyof t, an ordinary derivative is used in Equation

d(ρV )

dt= F0ρ0 − Fρ

3.7 Flow through pipe

Fluid is flowing through a constant-diameter cylindrical pipe sketched in Fig. 3.2.The flow is turbulent and therefore we can assume plug-flow conditions, i.e.,each slice of liquid flows down the pipe as a unit. There are no radial gradientsin velocity or any other properties. However, axial gradients can exist. Density

Page 31: Computer Aided Process Design and Simulation · Use the explicit Euler method to predict the behaviour of this reactor up to time equal 100s to four significant figures accuracy

3.7. FLOW THROUGH PIPE 31

Figure 3.2: Flow through a pipe

and velocity can change as the fluid flows along the axial or z direction. Thereare now two independent variables: time t and position z. Density and velocityare functions of both t and z: ρ(t,z) and v(t,z).pg..). We want to apply the totalcontinuity equation.

Time rate of change of mass inside system:∂(Aρdz)

∂t

Adz is the volume of the system; ρ is the density. The units of this equation arekg/min.

Mass flowing into system through boundary at z:vAρ

Mass flowing out of the system through boundary atz + dz : vAρ+∂(vAρ)

∂zdz

The above expression for the flow at z + dz may be thought of as a Taylor seriesexpansion of a function f(z), around z. The value of the function at a spot dz awayfrom z is

f(z + dz) = f(z) +

(∂f

∂z

)(z)

dz +

(∂2f

∂z2

)(z)

(dz)2

2!+ ...

If the dz is small, the series can be truncated after the first derivative term.Letting f(z) = vAρ gives above equation. Substituting these terms into Eq. gives

∂(Aρdz)

∂t= vAρ−

[vAρ+

∂(vAρ)

∂zdz

]Canceling out the dz terms and assuming A is constant yield

∂ρ

∂t+∂(vρ)

∂z= 0

Page 32: Computer Aided Process Design and Simulation · Use the explicit Euler method to predict the behaviour of this reactor up to time equal 100s to four significant figures accuracy

32 CHAPTER 3. PROCESS MODELING

3.7.1 Component Continuity Equations

Unlike mass, chemical components are not conserved. If a reaction occurs insidea system, the number of moles of an individual component will increase if it is aproduct of the reaction or decrease if it is a reactant. Therefore the componentcontinuity equation of the jth chemical species of the system says

{ Flow of molesof jth component

into system

}−

{ flow of molesof jth component

out of system

}+

{ rate of formationof moles of jth componentfrom chemical reactions

}=

{ Time rate of changeof moles of jth component

inside system

}

The units of this equation are moles of component j per unit time. The flowsin and out can be both convective (due to bulk flow) and molecular (due to dif-fusion). We can write one component continuity equation for each componentin the system. If there are NC components, there are NC component continuityequations for any one system. However, the one total mass balance and theseNC component balances are not all independent, since the sum of all the molestimes their respective molecular weights equals the total mass. Therefore a givensystem has only NC independent continuity equations. We usually use the totalmass balance and (NC - 1) component balances. For example, in a binary (two-component) system, there would be one total mass balance and one componentbalance.

3.8 CSTR

Consider the same tank of perfectly mixed liquid that we used in previous ex-ample except that a chemical reaction takes place in the liquid in the tank. Thesystem is now a CSTR (continuous stirred-tank reactor) as shown in Fig. 3.3Component A reacts irreversibly and at a specific reaction rate k to form product,component B.

Ak−−→ B

Page 33: Computer Aided Process Design and Simulation · Use the explicit Euler method to predict the behaviour of this reactor up to time equal 100s to four significant figures accuracy

3.8. CSTR 33

Figure 3.3: CSTR

Let the concentration of component A in the inflowing feed stream be CA, (moles ofA per unit volume) and in the reactor CA. Assuming a simple first-order reaction,the rate of consumption of reactant A per unit volume will be directly proportionalto the instantaneous concentration of A in the tank. Filling in the terms in Eq.for a component balance on reactant A, Flow of A into system = F0CA0 Flow of Aout of system = FCA Rate of formation of A from reaction = −V kCA The minussign comes from the fact that A is being consumed, not produced. The units ofall these terms must be the same: moles of A per unit time. Therefore the V kCA,term must have these units. Thus the units of k in this system are min−1.

Time rate of change ofA inside tank =d(V CA)

dt

Combining all of the above gives

d(V CA)

dt= F0CA0 − FCA − V kCA

We have used an ordinary derivative since t is the only independent variable inthis lumped system. The units of this component continuity equation are molesof A per unit time. The left-hand side of the equation is the dynamic term. Thefirst two terms on the right-hand side are the convective terms. The last term isthe generation term. Since the system is binary (components A and B), we couldwrite another component continuity equation for component B. Let CB be theconcentration of B in moles of B per unit volume.

d(V CB)

dt= F0CB0 − FCB + V kCA

Page 34: Computer Aided Process Design and Simulation · Use the explicit Euler method to predict the behaviour of this reactor up to time equal 100s to four significant figures accuracy

34 CHAPTER 3. PROCESS MODELING

Note the plus sign before the generation term since B is being produced by thereaction. Alternatively we could use the total continuity equation since CA, CBand ρ are uniquely related by

MACA +MBCB = ρ

where MA and MB, are the molecular weights of components A and B, respec-tively.

Suppose we have the same macroscopic system as above except that nowconsecutive reactions occur. Reactant A goes to B at a specific reaction rate k1,but B can react at a specific reaction rate k2, to form a third component C.

Ak1−−→ B

k2−−→ C

Assuming first-order reactions, the component continuity equations for compo-nents A, B, and C are

d(V CA)

dt= F0CA0 − FCA − V K1CA

d(V CB)

dt= F0CB0 − FCB + V k1CA − V k2CB

d(V CC)

dt= F0CC0 − FCC + V k2CB

The component concentrations are related to the density

ΣCj=AMjCj = ρ

Three component balances could be used or we could use two of the componentbalances and a total mass balance.

3.9 PFR

Instead of fluid flowing down a pipe as in pipe flow, suppose the pipe is a tubularreactor in which the same reaction A

k1−−→ B of previous example takes place. Asa slice of material moves down the length of the reactor the concentration of reac-tant CA decreases as A is consumed. Density ρ, velocity v, and concentration CA

Page 35: Computer Aided Process Design and Simulation · Use the explicit Euler method to predict the behaviour of this reactor up to time equal 100s to four significant figures accuracy

3.9. PFR 35

can all vary with time and axial position z. We still assume plug-flow conditionsso that there are no radial gradients in velocity, density, or concentration. Theconcentration of A fed to the inlet of the reactor at z = 0 is defined as

CA(t,0) = CA0(t)

The concentration of A in the reactor effluent at z = L is defined as

CA(t,L) = CAL(t)

Figure 3.4: Plug Flow Reactor

We now want to apply the component continuity equation for reactant A to asmall differential slice of width dz, as shown in Fig. 3.4. The inflow terms can besplit into two types: bulk flow and diffusion. Diffusion can occur because of theconcentration gradient in the axial direction. It is usually much less importantthan bulk flow in most practical systems, but we include it here to see what itcontributes to the model. We will say that the diffusive flux of A, NA (moles of Aper unit time per unit area), is given by a Fick’s law type of relationship

NA = −DA∂CA∂z

where DA, is a diffusion coefficient due to both diffusion and turbulence in thefluid flow (eddy diffusivity) DA has units of length per unit time. The terms in thegeneral component continuity equation are:

Molar flow of A into boundary at z (bulk flow and diffusion) = vACA+ANA (moles of A/s)

Molar flow of A leaving system at boundaryz+dz = (vACA+ANA)+∂(vACA + ANA)

∂zdz

Page 36: Computer Aided Process Design and Simulation · Use the explicit Euler method to predict the behaviour of this reactor up to time equal 100s to four significant figures accuracy

36 CHAPTER 3. PROCESS MODELING

Rate of formation of A inside system = −kCAAdz

Time rate of change of A inside system =∂(AdzCA)

∂t

Substituting into Eq. (2.9) gives

∂(AdzCA)

∂t= (vACA + ANA)−

(vACA + ANA +

∂(vACA + ANA)

∂zdz

)− kCAAdz

∂CA∂z

+∂(vCA +NA)

∂z+ kCA = 0

Substituting Eq. (2.16) for NA,

∂CA∂t

+∂(vCA)

∂z+ kCA =

∂z(DA

∂CA∂z

)

The units of the equation are moles A per volume per time.

3.10 Energy Equation

The first law of thermodynamics puts forward the principle of conservation ofenergy. Written for a general open system (where flow of material in and out ofthe system can occur) it is

{Flow of internal, kinetic, and potential energy into system by convection or diffusion}−{flow of internal, kinetic, and potential energy out of system by convection or diffusion}+{heat added to system by conduction, radiation and reaction}−{worh done by system on surroundings (shaft work and PV work)} = {time rate of change of internal, kinetic and potential energy inside system}

3.11 CSTR with heater

The CSTR system will be considered again, this time with a cooling coil inside thetank that can remove the exothermic heat of reaction λ (Btu/lb . mol of A reactedor Cal/g. mol of A reacted). We use the normal convention that λ is negative foran exothermic reaction and positive for an endothermic reaction. The rate of heatgeneration (energy per time) due to reaction is the rate of consumption of A timesλ.

QG = −λV CAk

Page 37: Computer Aided Process Design and Simulation · Use the explicit Euler method to predict the behaviour of this reactor up to time equal 100s to four significant figures accuracy

3.11. CSTR WITH HEATER 37

The rate of heat removal from the reaction mass to the cooling coil is −Q (energyper time). The temperature of the feed stream is T0 and the temperature in thereactor is T (K). Writing for this system,

F0ρ0(U0 + k0 +ψ0)−Fρ(U +K +ψ) + (QG +Q)− (W +FP −F0P0) =d

dt[(U +K +ψ)V ρ]

where U = internal energy (energy per unit mass) K = kinetic energy (energy perunit mass) ψ = potential energy (energy per unit mass) W = shaft work done bysystem (energy per time) P = pressure of system PO = pressure of feed streamNote that all the terms in Eq. must have the same units (energy per time) so theFP terms must use the appropriate conversion factor. In the system shown in

Figure 3.5: CSTR with heat Removal

Fig. 3.5 there is no shaft work, so W = 0. If the inlet and outlet flow velocities arenot very high, the kinetic-energy term is negligible. If the elevations of the inletand outlet flows are about the same, the potential-energy term is small. Thus theEq. reduces to

d(ρV U)

dt= F0ρ0U0−FρU+QG+Q−FρP

ρ+F0ρ0

P0

ρ0

= F0ρ0(U0+P0V0)−Fρ(U+PV )+QG+Q

where V is the specific volume (m3/kg), the reciprocal of the density. Enthalpy,H or h, is defined:

Horh = U + PV

Page 38: Computer Aided Process Design and Simulation · Use the explicit Euler method to predict the behaviour of this reactor up to time equal 100s to four significant figures accuracy

38 CHAPTER 3. PROCESS MODELING

We will use h for the enthalpy of a liquid stream and H for the enthalpy of avapor stream. Thus, for the CSTR, Eq. becomes

d(ρV U)

dt= F0ρ0h0 − Fρh+Q− λV kCA

For liquids the PV term is negligible compared to the U term, and we use thetime rate of change of the enthalpy of the system instead of the internal energyof the system.

d(ρV h)

dt= F0ρ0h0 − Fρh+Q− λV kCA

The enthalpies are functions of composition, temperature, and pressure, butprimarily temperature. From thermodynamics, the heat capacities at constantpressure, Cp and at constant volume, Cvare

Cp =

(∂H

∂T

)P

, Cv =

(∂U

∂T

)v

To illustrate that the energy is primarily influenced by temperature, let us sim-plify the problem by assuming that the liquid enthalpy can be expressed as aproduct of absolute temperature and an average heat capacity CP

h = CPT

We will also assume that the densities of all the liquid streams are constant. Withthese simplifications Eq. becomes

ρCPd(V T )

dt= ρCP (F0T0 − FT ) +Q− λV kCA

3.12 Models and Solution

1. Consider a situation in which the outlet flow rate is a function of the heightof liquid in the tank. Write the modeling equation for tank height assumingtwo different constitutive relationships: (i) F = βh or ii) F = β

√h, where

(β is known as a flow coefficient). You will often see these relationshipsexpressed as F = h/R or F =

√h/R, where R is a flow resistance. List

the state variables, parameters, as well as the input and output variables.

Page 39: Computer Aided Process Design and Simulation · Use the explicit Euler method to predict the behaviour of this reactor up to time equal 100s to four significant figures accuracy

3.12. MODELS AND SOLUTION 39

Give the necessary information to complete the quantitative solution to thisproblem. If the flow rate has units of liters/min and the tank height hasunits of meters, find the units of the flow coefficients and flow resistancesfor (i) and (ii).

Solution:

Let F0 be the inlet volumetric flow rate and F be the volumetric flow rate ofoutlet with liters/min units.

d(V ρ)

dt= F0ρ0 − Fρ

Assuming isothermal conditions and constant density of fluid and constantcross section of tank with area A, the equation becomes

∴dV

dt= F0 − F

Case (i): F = βh

Adh

dt= F0 − β1h = F0 − h/R ∴ R1 =

1

β1

Case (2): F = β√h

Adh

dt= F0 − β2

√h = F0 −

√h/R ∴ R2 =

1

β22

State variable is the rate of change of volume liter/min

Input variables:

• Inlet flow rate,F0, liters/min

• Initial volume of fluid in the tank, V0, m3

Output variables:

• Tank height h, meter

• Outlet flow rate, F , liter/min

• Flow resistance, R1, m.min/liter and R2, m0.5.min/liter

Parameters

Page 40: Computer Aided Process Design and Simulation · Use the explicit Euler method to predict the behaviour of this reactor up to time equal 100s to four significant figures accuracy

40 CHAPTER 3. PROCESS MODELING

• Area of cross section of tank, A, m2

• Total volume of the tank, VT• Total height of the tank, hT , m

• Density of fluid, ρ, kg/m3

• Flow coefficient, β1, liter/m/min and β2, liter/m0.5/min

For getting the solution, we need F0, V0, β.

2. Consider a conical water lank shown below Fig 3.6. Write the dynamicmaterial balance equation if the flow rate out of the tank is a function of’ thesquare root of height of water in the tank (Fo = β

√h). List state variables,

input variables and parameters. (Hint: Use height as a state variable.)

Figure 3.6: Conical Tank

Solution:

Let F0 be the inlet volumetric flow rate and F be the volumetric flow rate ofoutlet with liters/min units.

d(V ρ)

dt= Fiρi − F0ρ0

Assuming isothermal conditions and constant density of fluid and constantcross section of tank with area A, the equation becomes

∴dV

dt= Fi − F0

1

3πr2h = V

Page 41: Computer Aided Process Design and Simulation · Use the explicit Euler method to predict the behaviour of this reactor up to time equal 100s to four significant figures accuracy

3.12. MODELS AND SOLUTION 41

∵r

h=R

H=⇒ r =

R

Hh

∴1

3πR2

H2h3 = V

anddV

dt=

1

3πR2

H23h2dh

dt

F0 = β√h

πR2

H2h2dh

dt= Fi − β

√h

dh

dt=Fi − β

√h

π R2

H2h2

State variable is the rate of change of volume liter/min

Input variables:

• Inlet flow rate,Fi, liters/min

• Initial volume of fluid in the tank, V0, m3

Output variables:

• Tank height h, meter

• Outlet flow rate, F , liter/min

Parameters

• Radius R of tank, m

• Total height of the tank, H, m

• Density of fluid, ρ, kg/m3

• Flow coefficient, β, liter/m0.5/min

For getting the solution, we need Fi, R,H, β.

Page 42: Computer Aided Process Design and Simulation · Use the explicit Euler method to predict the behaviour of this reactor up to time equal 100s to four significant figures accuracy

42 CHAPTER 3. PROCESS MODELING

3. Extend the model developed for isothermal reaction to handle the followingstoichiometric equiation: A+B −−→ 2 P. Assume that the volume is constant,but the change in concentration of component B cannot be neglected.

Solution:

Let F0 be the inlet volumetric flow rate and F be the volumetric flow rate ofoutlet with liters/min units. the reaction scheme is A + B −−→ 2 P

d(V CAρ)

dt= Fiρ0CA0 − FρCA − V k2CACB

alsod(V CBρ)

dt= Fiρ0CB0 − FρCA − V k2CACB

CB = CB0 − (CA0 − CA)

Assuming isothermal conditions and constant density of fluid and constantreaction rate constant k2, the equation becomes

CAdV

dt+ V

dCAdt

= FiCA0 − FCA − V k2CA(CB0 − (CA0 − CA))

Volume of the reactor is constant, hence dVdt

= 0 and Fi = F the rate of changeof concentration of A becomes 0. Then

V k2CACB = FiCA0 − FCA

CA =FiCA0

(V k2CB + F )

Since, CB0 is not constant1

dCBdt

=FiCB0 − FCB

V− k2CA(CB0 − (CA0 − CA))

4. Extend the model developed in problem 3(isothermal with first-order kinet-ics) to handle multiple reactions (assume a constant volume reactor).

A + B −−→ 2 P(reaction1)

1Process industry often face the difficulty in maintaining the quality of final product due tothe presence of contaminant concentration in feed stream (impurity). This exercise may be anexample for control of maintaining the concentration B.

Page 43: Computer Aided Process Design and Simulation · Use the explicit Euler method to predict the behaviour of this reactor up to time equal 100s to four significant figures accuracy

3.12. MODELS AND SOLUTION 43

2 A + P −−→ Q(reaction2)

Assume that no P is fed to the reactor. Assume that the reaction rate (gen-eration) of A per unit volume for reaction 1 is characterized by expression

rA = −k1CACB

where the minus sign indicates that A is consumed in reaction 1. Assumethat the reaction rate (generation) of A per unit volume for reaction 2 ischaracterized by the expression

rA = −k2CACP

If the concentrations are expressed in gmol/liter and the volume in liters,what are the units of the reaction rate constants? If it is desirable to knowthe concentration of component Q, how many equations must be solved? Ifour concern is only with P, how many equations must be solved? Explain.

Solution:

Let F0 be the inlet volumetric flow rate and F be the volumetric flow rateof outlet with liters/min units. the reaction scheme is A + B −−→ 2 P and2 A + P −−→ Q The combined rate of disapperance of A can be expressed as

−rA =dCAdt

= k1CACB + k2CACP

rP =dCPdt

= k1CACB − k2CACP

rQ =dCQdt

= k2CACP

d(V CA)

dt= FiCA0 − FCA − V CA(k1CB + k2CP )

alsod(V CB)

dt= FiCB0 − FCB − V k1CACB

CB = CB0 − (CA0 − CA)

d(V CP )

dt= −FCP − V (k1CACB − k2CACP )

Page 44: Computer Aided Process Design and Simulation · Use the explicit Euler method to predict the behaviour of this reactor up to time equal 100s to four significant figures accuracy

44 CHAPTER 3. PROCESS MODELING

d(V CQ)

dt= −FCQ − V CA(k1CB + k2CP )

Atleast Four equations are necessary to estimate the concentration of Q

Atleast Three equations are necessary to estimate the concentration of Q

5. Model a mixing tank with two feed streams, as shown below Fig 3.7.

Figure 3.7: Mixing Tank

Assume that there are two components, A and B. C represents the con-centration of A. (C1 is the mass concentration of A in stream 1 and C2 isthe mass concentration of A in stream 2). Model the following cases: a.Constant volume, constant density. b. Constant volume, density varies lin-early with concentration. c. Variable volume, density varies linearly withconcentration.

Solution:

As per the problem statement, input and expected output are based oncomponent A only.

Case a:

Constant volume and constant density system

dV

dt= F1 + F2 − F = 0

∴ F = F1 + F2

We can develop a component mass balance as

F (C/(C + CB) = F1(C1/(C1 + C1B) + F2(C2/C2 + C2B)

Page 45: Computer Aided Process Design and Simulation · Use the explicit Euler method to predict the behaviour of this reactor up to time equal 100s to four significant figures accuracy

3.12. MODELS AND SOLUTION 45

C/(C + CB) =F1

F(C1/(C1 + C1B) +

F2

F(C2/C2 + C2B) (3.1)

CB/(C + CB) =F1

F(CB/(C1 + C1B) +

F2

F(CB/(C2 + C2B) (3.2)

Dividing Eq 3.1 by Eq 3.2 we get

C/CB =F1

F(C1/(C1 + C1B)) + F2

F(C2/(C2 + C2B))

F1

F(CB/(C1 + C1B)) + F2

F(CB/(C2 + C2B))

C =F1(C1/(C1 + C1B)) + F2(C2/(C2 + C2B))

F1(1/(C1 + C1B)) + F2(1/(C2 + C2B))

C =F1C1(C2 + C2B) + F2C2(C1 + C1B)

F1(C2 + C2B) + F2(C1 + C1B)(3.3)

Case b:

Constant volume, density varies linearly with concentration. The density ofsolution and concentration of solution can be related as

CS = ρS − ρf

where ρf is the density of solvent.

On substitution of this relation in the equation 3.3 we get

ρS = ρf +F1(ρ1 − ρf )(ρ2 + ρ2B) + F2(ρ2 − ρf )(ρ1 + ρ1B)

F1(ρ2 + ρ2B) + F2(ρ1 + ρ1B)

Case c: Variable volume, density varies linearly with concentration

dV C

dt= F1C1 + F2C2 − FC

CdV

dt+ V

dC

dt= F1

dC1

dt+ C1

dF1

dt+ F2

dC2

dt+ C2

dF2

dt− F dC

dt− CdF

dt

(V + F )dC

dt+

(dV

dt+dF

dt

)C = F1

dC1

dt+ C1

dF1

dt+ F2

dC2

dt+ C2

dF2

dt

Page 46: Computer Aided Process Design and Simulation · Use the explicit Euler method to predict the behaviour of this reactor up to time equal 100s to four significant figures accuracy

46 CHAPTER 3. PROCESS MODELING

6. Consider two tanks in series (Fig 3.8) where the flow out of the first tankenters the second tank. Our objective is to develop a model to describehow the height of liquid in tank 2 changes with time, given the input flowrate F0(t). Assume that the flow out of each tank is a linear function of theheight of liquid in the tank (F1 = β1h1 and F2 = β2h2) and each tank hasa constant cross sectional area. A material balance around the first tank

Figure 3.8: Mixing Tank

yields (assuming constant density and F1 = β1h1)

Solution: Each tank is non-interacting system ie, the flow rate F1, F2 areindependent to each other.

dV1ρ

dt= ρ(F0 − β1h1) ∵ F1 = β1h1

dV2ρ

dt= ρ(β1h1 − β2h2) ∵ F2 = β2h2

Assuming isothermal and constant density system,

∴dh1

dt=

1

A1

(F0 − β1h1)

anddh2

dt=

1

A2

(β2h1 − β1h2)

7. Two liquid surge tanks (with constant cross sectional area) are placed inseries. Write the modeling equations for the height of liquid in the tanks

Page 47: Computer Aided Process Design and Simulation · Use the explicit Euler method to predict the behaviour of this reactor up to time equal 100s to four significant figures accuracy

3.12. MODELS AND SOLUTION 47

assuming that the flowrate from the first tank is a function of the differencein levels of the tanks and the flow rate from the second tank is a functionof the level in the second tank. Consider two cases: (i) the function islinear and (ii) the function is a square root relationship. State all otherassumptions.

Solution:

A1dh1

dt= Fi − F1

A2dh2

dt= F1 − F2

Case (1)

F1 = f(h1 − h2) = β1(h1 − h2)andF2 = f(h2) = β2h2

A1dh1

dt= Fi − f(h1 − h2) = Fi − β1(h1 − h2)

A2dh2

dt= f(h1 − h2)− f(h2) = β1(h1 − h2)− β2h2

Case (2)

F1 = β1

√(h1 − h2)andF2 = β2

√h2

A1dh1

dt= Fi − β1

√(h1 − h2)

A2dh2

dt= β1

√(h1 − h2)− β2

√h2

isothermal constant density system is considered.

8. A gas surge drum has two components (hydrogen and methane) in the feedstream. Let yi and y represent the mole fraction of ethane in the feedstreamand drum, respectively. Find dP/dt and dy/dt if the inlet and outlet flow ratescan vary. Also assume that the inlet concentration can vary. Assume theideal gas law for the effect of pressure and composition on density.

Page 48: Computer Aided Process Design and Simulation · Use the explicit Euler method to predict the behaviour of this reactor up to time equal 100s to four significant figures accuracy

48 CHAPTER 3. PROCESS MODELING

Solution:

Let volume of the surge tank be V , Feed stream molar flow rate Fi andoutlet stream flow rate F The feed stream mole fraction of Methane is yi andHydrogen is (1− yi)The composition of Methane in the tank as well as inh the outlet is y andthat of hydrogen is (1− y)

Assuming ideal gas law for simplicity,

PV = nRT

Pdv

dt+ V

dP

dt= RT

dn

dt(3.4)

n = nCH4 + nH2

dn

dt=dnCH4

dt+dnH2

dt= Fi − F

dnCH4

dt= Fiyi − Fy

dnH2

dt= Fi(1− yi)− F (1− y)

Applying equation 3.4, we get

VdP

dt= RT

(dnCH4

dt+dnH2

dt

)dP

dt=RT

V(Fiyi − Fy + Fi(1− yi)− F (1− y))

dP

dt=RT

V(Fi − F ) (3.5)

y =nCH4

n

dy

dt=ndnCH4

dt− nCH4

dndt

n2

dy

dt=n(Fiyi − Fy)− ny(Fi − F )

n2

dy

dt=

(Fiyi − Fy)− (Fiy − Fy)

n

dy

dt=Fi(yi − y)

n(3.6)

Page 49: Computer Aided Process Design and Simulation · Use the explicit Euler method to predict the behaviour of this reactor up to time equal 100s to four significant figures accuracy

3.12. MODELS AND SOLUTION 49

9. Consider a liquid surge drum that is a sphere. Develop the modeling equa-tion using liquid height as a state variable, assuming variable inlet andoutlet flows.

Solution:

Derivation for Volume of the Sphere Figure for the Derivation of Formula ofSphere by IntegrationThe differential element shown in the figure is cylin-drical with radius x and altitude dy. The volume of cylindrical element is

dV = πx2dy

The sum of the cylindrical elements from 0 to r is a hemisphere, twice thehemisphere will give the volume of the sphere. Thus,

V = 2π

∫ r

0

x2dy

From the equation of the circle x2 + y2 = r2 =⇒ x2 = r2 − y2

V = 2π

∫ r

0

(r2 − y2)dy

V = 2π(r2y − y3

3)

∣∣∣∣h0

dV

dt= F0 − F

The following relationship of height of tank y can be used

π(r2 − y2)dy

dt= F0 − F

asdV

dt= F0 − F =

{π(r2 − h2)dh

dth > 0

−π(r2 − h2)dydt

h < 0

10. A car tire has a slow leak. The flowrate of air out of the tire is proportionalto the pressure of air in the tire (we are using gauge pressure). The initialpressure is 30 psig, and after five days tire pressure is down to 20 psig. Howlong will it take to reach 10 psig?

Page 50: Computer Aided Process Design and Simulation · Use the explicit Euler method to predict the behaviour of this reactor up to time equal 100s to four significant figures accuracy

50 CHAPTER 3. PROCESS MODELING

Figure 3.9: Spherical Tank

Solution:

PV = nRT

Pdv

dt+ V

dP

dt= RT

dn

dt= RT (kP )

For constant Volume, then

dP

dt=RTk

VP = θP ∵ θ =

RTk

V= constant

on integration and applying limits∫ 20

30

dP

P= θ

∫ 5

0

dt

ln(20)− ln(30) = −5θ

∴ θ = 0.08109

while the leakage continues from 20 psig to 10 psig, the time duration t canbe evaluated as

t =ln(20)− ln(10)

θ= 8.545d

Page 51: Computer Aided Process Design and Simulation · Use the explicit Euler method to predict the behaviour of this reactor up to time equal 100s to four significant figures accuracy

3.12. MODELS AND SOLUTION 51

11. A car lire has a slow leak. The flowrate of air out of the tire is proportionalto the square root of the pressure of air in the tire (we are using gaugepressure). the initial pressure is 30 psig, and after 5 days the pressure isdown to 20 psig. How long will it take to reach 10 psig? Compare yourresults with problem 10.

Solution:

PV = nRT

Pdv

dt+ V

dP

dt= RT

dn

dt= RT (k

√P )

For constant Volume, then

dP

dt=RTk

V

√P = θ

√P ∵ θ =

RTk

V= constant

on integration and applying limits∫ 20+14.7

30+14.7

dP

P 0.5= θ

∫ 5

0

dt

P 0.5

−0.5

∣∣∣∣34.7

44.7

= 5θ

∴ θ = 0.3180

while the leakage continues from 20 psig to 10 psig, the time duration t canbe evaluated as

t =(34.70.5 − 24.70.5)/(−0.5)

0.3180= 12.73 d

12. A small room (10 × 10 × 10ft) is perfectly sealed and contains air at 1 atmpressure (absolute). There is a large gas cylinder (100 ft3 ) inside the roomthat contains helium with an initial pressure of 5 atm (absolute), Assumethat the cylinder valve is opened (at t = 0) and the molar flowrate of gasleaving the cylinder is proportional to the difference in pressure betweenthe cylinder and the room. Assume that room air does not diffuse into thecylinder. Write the differential equations that (if solved) would allow youto find how the cylinder pressure, the room pressure and the room molefraction of helium change with time. State all assumptions and show all ofyour work.

Page 52: Computer Aided Process Design and Simulation · Use the explicit Euler method to predict the behaviour of this reactor up to time equal 100s to four significant figures accuracy

52 CHAPTER 3. PROCESS MODELING

Solution:

PrVr = (na + nh)RT

PsVs = nhRT

dprdt

=RT

Vr(dnadt

+dnhdt

)

As the room is sealed one the change in moles of air is zero

dprdt

=RT

Vr

dnhdt

dPsdt

=RT

Vs

dnhdt

From the cylinder side the cange in no of moles of helium is given by

dnhdt

= β(Ps − Pr)

The number of moles released from cylinder is added to the room

∴ yh =nh

na + nh

dyhdt

=(na + nh)

dnh

dt− nh dnh

dt

(na + nh)2∵dnadt

= 0

dyhdt

=na

dnh

dt

(na + nh)2=naβ(Ps − Pr)

(na + nh)2

With Vr = 900, Vs = 100, Pr(0) = 1, Ps(0) = 5, T = 480°R,R = 1.31443, nh(0) = 0and β = 1hr−1 the state space molel becomes

dprdt

=RT

Vrβ(Ps − Pr) (3.7)

dPsdt

= −RTVs

β(Ps − Pr) (3.8)

dnhdt

= β(Ps − Pr) (3.9)

dyhdt

=naβ(Ps − Pr)

(na + β(Ps − Pr))2(3.10)

The solution is obtained by MATLAB ode45 solver as shown in the figure3.10 The script files are shown below:

Page 53: Computer Aided Process Design and Simulation · Use the explicit Euler method to predict the behaviour of this reactor up to time equal 100s to four significant figures accuracy

3.12. MODELS AND SOLUTION 53

function dpy = a12(~, P)%Function file <a12.m> developed by B. Nedumaran for the exercise%problem 12. The ode solver perform the model developed for Helium%leaking from acylinder kept inside an insulated room and the%profile of pressure inside room and cylinder as well as the%number of moles of Helium leaked from cylinder and fraction of%Helium inside the roomvr0=900;vs0=100;R=1.31443;T=293;Pr0=1;Ps0=5;na=Pr0*vr0/R/T;dpy=[R*T/vr0*(P(2)-P(1))];-R*T/vs0*(P(2)-P(1));P(2)-P(1);na*(P(2)-P(1))/(na+P(3)).^2];end\vspace%Script file As12.m will produce the solution in the form of plottspan=[0 3];nh0=5*100/1.31443/480p0=[1 5 nh0,0][t P]=ode45(@a12,tspan,P0);plot(t,P)

13. A balloon expands or contracts in volume so that the pressure inside theballoon is approximately the atmospheric pressure.

(a) Develop the mathematical model (write the differential equation) for thevolume of a balloon that has a slow leak. Let V represent the volumeof the balloon and q represent the molar flowrate of air leaking fromthe balloon. State all assumptions. List state variables, inputs, andparameters.

(b) The following experimental data have been obtained for a leaking bal-loon. Predict when the radius of the balloon will reach 5 cm using twodifferent assumptions for the molar rate of air leaving the balloon:

Page 54: Computer Aided Process Design and Simulation · Use the explicit Euler method to predict the behaviour of this reactor up to time equal 100s to four significant figures accuracy

54 CHAPTER 3. PROCESS MODELING

Figure 3.10: Pressure and concentration Profile inside the room and cylinder

i. the molar rate is constantii. the molar rate is proportional to the surface area of the balloon

Reminder: The volume of a sphere is (4/3)πr3 and the area of a sphereis 4πr2.

Solution:

(a)

The pressure inside the balloon is nearly at atmospheric pressure and as-sumed constant. Taking the ideal gas law into consideration

PV = nRT

Page 55: Computer Aided Process Design and Simulation · Use the explicit Euler method to predict the behaviour of this reactor up to time equal 100s to four significant figures accuracy

3.12. MODELS AND SOLUTION 55

t,min r, cm0 105 7.5

PdV

dt= RT

dn

dt

dn

dt= −q

∴dV

dt= −RTq

P= C ∵ R, T, P and q are constant

on integration we get ∫ V

V0

dV = C

∫ t

0

dt

V − V0 = Ct

(b.i)

expressing volume of sphere in terms of radius

4

3πr3

0 −4

3πr3 = Ct

4

3π1000− 4

3π(7.5)3 = 5C

∴ C = 484.083

and time taken for the radius of balloon becomes 5 cm for constant molarflow rate of leakage is

t =43π(1000− 125)

484.083= 7.56min

(b.ii)

q = c(4πr2)

∴dV

dt= 4πr2dr

dt= −4πcRTr2

P

dr

dt=cRT

P= C

Page 56: Computer Aided Process Design and Simulation · Use the explicit Euler method to predict the behaviour of this reactor up to time equal 100s to four significant figures accuracy

56 CHAPTER 3. PROCESS MODELING

on integration

10− r = Ct =⇒ C =2.5

5= 0.5

time for the radius becomes 5 cm is

t =10− 5

0.5= 10min

14. Often liquid surge tanks (particularly those containing hydrocarbons) willhave a gas "blanket" of nitrogen or carbon dioxide to prevent the accumula-tion of explosive vapors above the liquid, as depicted below. Fig 3.11

Figure 3.11: Hydrocarbon storage Tank

Develop the modeling equations with gas pressure and liquid volume as thestate variable. Let qf and q reprecent the inlet and outlet gas molar flowrates,Ff and F the liquid volumetric flowrates, V the constant (total) volume, Vlthe liquid volume, and P the gas pressure. Assume the ideal gas law. Showthat lhe modeling equations are:

dVldt

= Ff − F

dP

dt=

P

V − Vl(Ff − F ) +

RT

V − Vl(qf − q)

and state any other assumptions.

Solution:

For the liquid region, the mass balance equation

Volumetric flow rate, in−Volumetric flow rate, out = Rate of change of volume

Ff − F =dVldt

Page 57: Computer Aided Process Design and Simulation · Use the explicit Euler method to predict the behaviour of this reactor up to time equal 100s to four significant figures accuracy

3.12. MODELS AND SOLUTION 57

Vg = V − Vl =⇒ dVgdt

= −dVldt

For gas space follows Ideal gas law

PVg = nRT

PdVgdt

+ VgdP

dt= RT

dn

dt

dn

dt= qf − q

On substitution

−P (Ff − F ) + (V − Vl)dp

dt= RT (qf − q)

dP

dt=

P

V − Vl(Ff − F ) +

RT

V − Vl(qf − q)

The above expression is true for

• The fugasity of liquid doesn’t change the volume of the liquid

• No effect of change in pressure of gas space due to diffusion of liquidmolecules into gas stream

• No appreciable change in temperature due to compression or expansionof gas space

• No heat loss

15. Most chemical process plants have a natural gas header that circulatesthrough the process plant. A simplified version of such a header is shownbelow (Fig. 3.12).

Here, the natural gas enters the process plant from a source (the naturalgas pipeline) through a control valve. It flows through the plant piping,which we have represented as a perfectly mixed drum for simplicity. An-other valve connects the plant piping to the gas drum for a boilerhouse unit.Gas passes through another valve to the boilerhouse furnaces. Write mod-eling equations assuming that the pressures in drums 1 and 2 are the statevariables. Let the input variables be h1 (valve position 1), h2 (valve position2), and Pi(source pressure).

Solution:

Page 58: Computer Aided Process Design and Simulation · Use the explicit Euler method to predict the behaviour of this reactor up to time equal 100s to four significant figures accuracy

58 CHAPTER 3. PROCESS MODELING

Figure 3.12: Pipeline header

Assuming Ideal Gas LawP1V1 = n1RT

P2V2 = n2RT

and the state space variables become

dP1

dt=RT

V1

dn1

dt

dP2

dt=RT

V2

dn2

dt

Assuming that the molar flow rate through the valves is proprtional to itsposition and ∆P

dn1

dt= βihi(Pi − P1)− β1h1(P1 − P2)

dn2

dt= β1h1(P1 − P2)− β2h2(P2 − P3)

∴dP1

dt=RT

V1

βihi(Pi − P1)− β1h1(P1 − P2)

dP2

dt=RT

V2

β1h1(P1 − P2)− β2h2(P2 − P3)

16. The Lotka-Volterra equations were developed to mode! the behavior of preda-torprey systems, making certain assumptions about the birth and death

Page 59: Computer Aided Process Design and Simulation · Use the explicit Euler method to predict the behaviour of this reactor up to time equal 100s to four significant figures accuracy

3.12. MODELS AND SOLUTION 59

rates of each species. Consider a system composed of sheep (prey) and coy-otes (predator). In the following Lotka- Volterr 1 equations x1 represents thenumber of sheep and x2 the number of coyotes in the system.

dx1

dt= αx1 − γx1x2

dx2

dt= εγx1x2 − βx2

Discuss the meaning of the parameters α, β, γ and ε and the assumptionsmade in the model.

Solution:

x1 represents number of sheeps and x2 represents number of coyotes (red-dish fox like wild animal from north America).dx1dt

and dx2dt

represents the rate of change in number of sheeps and coyotesrespectively.

The rate of change is mainly due to their respective birth rates and deathrates.

dx1

dt= αx1 − γx1x2 (3.11)

dx2

dt= εγx1x2 − βx2 (3.12)

Hence

(a) α - represents the birth rate of sheeps

(b) γ- represents the death rate of sheep due to their competence with thepresence of number of coyotes, x2

(c) ε- represents the conducive birth rate of coyotes due to their availabilityof pray the sheeps, x1

(d) β- represents the death rate of coyotes

17. Consider a perfectly mixed stirred-tank heater, with a single liquid feedstream and a single liquid product stream, as shown below (Fig. 3.13).

Develop the material and energy balance equations that describe this pro-cess. Fi is the volumetric flow rate into the tank, F is the volumetric flowrate out of the tank, T is the temperature of the fluid entering the tank, T is

Page 60: Computer Aided Process Design and Simulation · Use the explicit Euler method to predict the behaviour of this reactor up to time equal 100s to four significant figures accuracy

60 CHAPTER 3. PROCESS MODELING

Figure 3.13: CSTR with heater

the temperature of the fluid in the tank, h is the height of liquid in the tank,and Q is the rate of energy added to the tank. State assumptions (such asconstant density, etc.). Assume that the volume can vary with time and thatF is proportional to

√h. How many differential equations does it take to

model this system? What are the state variables? What are the parameters?What are the inputs? List the information necessary to solve this problem.

Solution:

Mass Balance equation can be expressed as

Aρdh

dt= Fiρi − Fρ

for a constant density system the equation become

Adh

dt= Fi − F = Fi − β

√h

Energy Balance: Consider Tr as reference temperature or room temperaturein Kelvin

heat inflow−heat Outflow+Heat added = Rate of Change of Heat in holdup

FiρCp(Ti − Tr)− FρCp(T − Tr) +dQ

dt+dWs

dt= Aρ

d(hCp(T − Tr))dt

FiρCp(Ti−Tr)−β√hρCp(T−Tr)+

dQ

dt+dWs

dt= Aρ

((Cp(T − Tr))

dh

dt+ h

d(Cp(T − Tr))dt

)ρ = g(T )

Cp = f(T )

where, Ws the heat input through the rotating shaft can be considered asconstant.

Page 61: Computer Aided Process Design and Simulation · Use the explicit Euler method to predict the behaviour of this reactor up to time equal 100s to four significant figures accuracy

3.12. MODELS AND SOLUTION 61

18. Consider a gas surge drum with variable inlet and outlet molar flowrates,qf and q, respectively. Assume that heat is being added to the tank at arate, Q. Write the modeling equations that describe how the temperature, Tand pressure, P , vary with time. Do not neglect the PV term in the energybalance.

Solution:

PV = nRT

Energy balance:

qfCP (Tf−Tr)−qCP (T−Tr)+Q =d(nCp(T − Tr))

dt= (qf−q)CP (T−Tr)+n

d(CP (T − Tr))dt

Mass Balance:

VdP

dt= R(qf − q)T +

PV

RT

dT

dt

19. Derive the reaction diffusion equation

∂CA∂t

= −rA∂CA∂z

+DAB∂2CA∂z2

− kCA

using the same method to derive the tubular reactor model in Section 2.6.Assume that a chemical species enters a volume element via convection(bulk flow) and a concentration gradient (diffusion):∣∣∣∣(FCA − ADAZ

dCAdZ

)∣∣∣∣V

leaves by convection and a concentration gradient:∣∣∣∣(FCA − ADAZdCAdZ

)∣∣∣∣V+∆V

and also leaves by a first-order reaction.

Solution:

Refer derivation in section 3.9 PFR

Page 62: Computer Aided Process Design and Simulation · Use the explicit Euler method to predict the behaviour of this reactor up to time equal 100s to four significant figures accuracy

62 CHAPTER 3. PROCESS MODELING

20. Consider the nonlinear tank height model

dh

dt=FiA− β

A

√h

and define the dimensionless variables u = Fi/Fs and x = h/hs. Where Fsand hs are the steady-state flowrate and height respectively (Fs = β

√hs).

Define the dimensionless time, τ , that will yield the following dimensionlessequation:

dx

dτ= −√x+ u

Solution:

Given:dh

dt=FiA− β

A

√h

u =FiFs

=⇒ Fi = Fsu

x =h

hs=⇒ h = hsx

dh = hsdx

Fs = β√hs

Let τ = tts

tsdτ = dt

∴dh

dτ=dh

dt

dt

dτ=

(Fsu

A− β

A

√xhs

)ts

dh

dτ= hs

dx

dx

dτ=

1

hs

(Fsu

A− β

A

√xhs

)ts

dx

dτ= u−

√x

comparing the coefficients of u and√x, we get

tsFsAhs

= 1 andtsβ

A√hs

= 1

Page 63: Computer Aided Process Design and Simulation · Use the explicit Euler method to predict the behaviour of this reactor up to time equal 100s to four significant figures accuracy

3.12. MODELS AND SOLUTION 63

ts =AhsFs

∴tsβ

A√hs

=AhsFsβ

A√hs

= 1

21. Derive the constitutive relationship F = β√h by considering a steady-state

energy balance around a tank with a constant flowrate. Use P = P0 + ρgh forthe pressure at the bottom of the tank, where P0 is the atmospheric pressure(pressure at the top surface), h is the height of liquid in the tank, ρ is thedensity of fluid. Assume that the cross-sectional area at the surface is muchlarger than the cross-sectional area of the exit pipe.

22. Consider the isothermal CSTR model with first-order kinetics:

dCAdt

=F

V(CAf − CA)− kACA

Use τ = kt as the dimensionless time. Develop the dimensionless equationfor the two cases: (i) x = CA

CAfand (ii) x = 1 − CA

CAf. Compare and contrast the

resulting equations with the example in Section 2.7.

Solution:

Consider the isothermal CSTR model with first-order kinetics:

dCAdt

=F

V(CAf − CA)− kCA

Useing τ = kt as the dimensionless time

dt= k

dCAdτ

=dCAdt

dt

The dimensionless model can be expressed as follows:

Case (i):

Page 64: Computer Aided Process Design and Simulation · Use the explicit Euler method to predict the behaviour of this reactor up to time equal 100s to four significant figures accuracy

64 CHAPTER 3. PROCESS MODELING

x =CACAf

dx

dt=

1

C2Af

(CAf

dCAdt− CA

dCAfdt

)dCAdt

= CAfdx

dt+ x

dCAfdt

CAfdx

dt+ x

dCAfdt

=F

V(CAf − CA)− kCA

= CAf

[F

V(1− x)− kx

]CAfk

dx

dτ+ xk

dCAfdτ

= CAf

[F

V(1− x)− kx

]for constant feed rate, feed concentration and volume, the dimensionlessmodel become

kCAfdx

dτ= kCAf

[F

kV(1− x)− x

]dx

dτ=

F

V k(1− x)− x

Case (ii):

x = 1− CACAf

dx

dt= − 1

CAf

dCAdt

dx

dτ= − 1

CAf

(F

V(CAf − CA)− kCA

)dτ

dt

dx

dτ= − 1

CAf

(F

V(CAf − CA)− kCA

)k

dx

dτ=

(−FVx+ k(1− x)

)k

23. Semibatch reactors are operated as a cross between batch and continuousreactors. A semibatch reactor is initially charged with a volume of material,

Page 65: Computer Aided Process Design and Simulation · Use the explicit Euler method to predict the behaviour of this reactor up to time equal 100s to four significant figures accuracy

3.12. MODELS AND SOLUTION 65

and a continous feed of reactant is started. There is, however, no outletstream. Develop the modeling equations for a single first-order reaction.The state variables should be volume and concentration of reactant A.

Solution:

Semibatch Reactor Equations in Terms of Concentrations - with constantmolar feed.

A schematic diagram of this semibatch reactor is shown in Figure 3.14.We shall consider the elementary liquid-phase reaction A+B −−→ C in whichreactant B is slowly added to a well-mixed vat containing reactant A. A molebalance on species A yields

Figure 3.14: Semi Batch Reactor

[rate in]− [rate out]− [rate of generation] = [rate of accumulation] (3.13)

0− 0− rAV (t) =dNA

dt

Three variables can be used to formulate and solve semibatch reactor prob-lems: the concentrations, Cj, the number of moles, N , and the conversion,X. Recalling that the number of moles of A, NA, is just the product of con-centration of A, CA, and the volume, V we can rewrite Equation 3.13 as

−rA =dV CAdt

= VdCAdt

+ CAdV

dt

Page 66: Computer Aided Process Design and Simulation · Use the explicit Euler method to predict the behaviour of this reactor up to time equal 100s to four significant figures accuracy

66 CHAPTER 3. PROCESS MODELING

We note that since the reactor is being filled, the volume, V varies with time.The reactor volume at any time t can be found from an overall mass balanceof all species:

ρ0v0 + 0 + 0 =d(ρV )

dt

For a constant-density system, ρ0 = ρ, and dVdt

= v0 with the initial conditionV = V0 at t = 0, integrating for the case of constant volumetric flow rate v0

yieldsV = V0 + v0t

−v0CA + V rA = VdCAdt

The balance on A can be rewritten as

dCAdt

= −rA −v0

VCA

A mole balance on B that is fed to the reactor at a rate FB0 is

In + Out + Generation = Accumulation

RearrangingdNB

dt= rBV + FB0

dV CBdt

= VdCBdt

+ CBdV

dt= FB0 + rBV

Substituting in terms of V and differentiating, the mole balance on B be-comes

dCBdt

= rB +v0(CB0 − CB)

V

At time t = 0, the initial concentration of B in the vat is zero, CBi = 0.The concecentration of B in the feed is CB0. If the reaction order is otherthan zero- or first-order or if the reaction is nonisothermal, we must usenumerical techniques to determine the conversion as a function of time,usually with ode solver.

24. Pharmacokinetics is the study of how drugs infused to the body are dis-tributed to other parts of the body. The concept of a compartmental modelis often used, where it is assumed that the drug is injected into compartment1. Some of the drug is eliminated (reacted) in compartment 1, and some of

Page 67: Computer Aided Process Design and Simulation · Use the explicit Euler method to predict the behaviour of this reactor up to time equal 100s to four significant figures accuracy

3.12. MODELS AND SOLUTION 67

it diffuses into compartment 2 (the rest accumulates in compartment 1).Similarly, some of the drug that diffuses into compartment 2 diffuses backinto compartment 1, while some is eliminated by reaction and the rest accu-mulates in compartment 2. Assume that the rates of diffusion and reactionare directly proportional to the concentration of drug in the compartmentof interest Show that the following balance equations arise, and discuss themeaning of each parameter (kij, units of min−1)

dx1

dt= −(k10 + k12)x1 + k21x2 + u

dx2

dt= k12x1 − (k20 + k21)x2

where x1 and x2 =drug concentrations in compartments 1 and 2 (µg/ml), andu = rate of drug input to compartment 1 (scaled by the volumc of compart-ment 1, µg/ml.min).

25. A simple bioreactor model (assuming steady state operation) is

0 =

(µmaxx2

km + x2 + k1x22

−D)x1

0 = (sf − x2)D −(x1

c

)( µmaxx2

km + x2 + k1x22

)Where µmax = 0.53, km = 0.12, k1 = 0.4545, c = 0.4, sf = 4. If x1 is the biomassconcentration (mass of cells) and x2 is the substrate concentration (foodsource for the cells). Find the steady-state values for x1 and x2 if D = 0.3(There are three solutions).

Use fsolve and several initial guesses for the solution vector.

26. For the dimensionless CSTR problem (module 9 in Section V), use the MAT-LAB routine fsolve to find the solutions. Show the initial guesses and thesolutions that fsolve converges to. Show your function routine as well asthe calls to MATLAB.

f1(x1, x2) = −φx1κ(x2) + (1− x1) = 0

f2(x1, x2) = βφx1κ(x2)− (1 + δ)x2 = 0

where κ(x2) = exp(

x21+x2/γ

)and the following parameters are used β = 8,

φ = 0.072, γ = 20 and δ = 0.3

Page 68: Computer Aided Process Design and Simulation · Use the explicit Euler method to predict the behaviour of this reactor up to time equal 100s to four significant figures accuracy

68 CHAPTER 3. PROCESS MODELING

Solution

The function file q26.m is given below:

function F=q26(x)%UNTITLED2 Summary of this function goes here% Detailed explanation goes herephi=0.072;beta=8;gamma=20;delta=0.3F=[-0.phi*x(1)*exp(x(2)/(1+x(2)/gamma))+(1-x(1)); beta*phi* x(1)

*exp(x(2)/(1+x(2)/gamma))-(1+delta)*x(2)];end

The solution is obtained by Matlab command fsolve

>> x=fsolve(@q26,[0.1 0.1])

Equation solved.

fsolve completed because the vector of function values is near zeroas measured by the default value of the function tolerance, andthe problem appears regular as measured by the gradient.

<stopping criteria details>

x =

0.8560 0.8860

27. Consider the scaled predator-prey equations.

dy1

dt= α(1− y2)y1

dy2

dt= −β(1− y1)y2

Page 69: Computer Aided Process Design and Simulation · Use the explicit Euler method to predict the behaviour of this reactor up to time equal 100s to four significant figures accuracy

3.12. MODELS AND SOLUTION 69

The parameters are α = β = 1.0 and the initial conditions are y1(0) = 1.5 andy2(0) = 0.75. The time unit is days.

Solve these equations using the MATLAB integration routine ode45. In ad-dition to transient responses (t vs y1 and y2), also plot "phase-plane" plots (y1

vs y2).

Solution

The function file q27.m and the solution (Fig 3.15) is given below:

function F=q27(~,x)% q27.malpha=1;beta=1;F=[alpha*(1-x(2))*x(1); -beta*(1-x(1))*x(2)];end

The solution is obtained by Matlab command ode45

>> [t x]=ode45(@q27,[0 2],[1.5 0.75]);>> plot(t,x)>>plot(x(1),x(2))

The phase plan curve is given as Fig 3.16

28. Consider a CSTR with a second-order reaction. Assume that the rate of re-action (per unit volume) is proportional to the square of the concentration ofthe reacting component. Assuming constant volume and constant density,show that the modeling equation is:

dC

dt=F

VCi −

F

VC − k2C

2

Use the following parameters: FV

= 5 min, k2 = 0.32 ft3lbmol−1min−1 and asteady-state inlet concentration of Cis = 1.25 lbmol ft−3 Calculate the steady-state concentration of Cs = 0.625 lbmol ft−3 Assume that a step change inthe inlet concentration occurs at t = 0. That is, Ci changes from 1.25 to1.75 lbmol ft−3 Use ode45 to simulate how the outlet concentration changesas a function of time.

Page 70: Computer Aided Process Design and Simulation · Use the explicit Euler method to predict the behaviour of this reactor up to time equal 100s to four significant figures accuracy

70 CHAPTER 3. PROCESS MODELING

Figure 3.15: Solution to system of ODEs

29. A gas surge drum has two components (hydrogen and methane) in the feedstream. Let yi and y represent the mole fraction of methane in the feedstream and drum, respectively. Find dP/dt and dy/dt if the inlet and out-let flowrates can vary. Also assume that the inlet concentration can vary.Assume the ideal gas law for the effect of pressure and composition on den-sity. Assume that the gas drum volume is 100 liters. The temperature ofthe drum is 31.5 deg C (304.65 K). At steady-state the drum pressure is 5atm, the molar flow rate in and out is 2 gmol/min and the concentration is25% methane, 75% hydrogen. Use ode45 to solve the following problems.You are initially at steady-state.

Page 71: Computer Aided Process Design and Simulation · Use the explicit Euler method to predict the behaviour of this reactor up to time equal 100s to four significant figures accuracy

3.12. MODELS AND SOLUTION 71

Figure 3.16: Phase plan Curve

(a) Assume that the molar flowrates remain constant, but the inlet methaneconcentration is changed to 50%. Find how pressure and compositionchange with time.

(b) Assume that the molar flowrate out of the drum is proportional to thedifference in pressure between the drum and the outlet header, whichis at 2 atm pressure. Perform a step change in inlet concentration to50% methane, simultaneously with a step change in inlet flowrate to 3gmol/min.

(c) Assume that the MASS flowrate out of the drum is proportional to thesquare root of the difference in pressure between the drum and the out-

Page 72: Computer Aided Process Design and Simulation · Use the explicit Euler method to predict the behaviour of this reactor up to time equal 100s to four significant figures accuracy

72 CHAPTER 3. PROCESS MODELING

let header (which is at 2 atm pressure). Again, perform a step change ininlet concentration to 50% methane, simultaneously with a step changein inlet flowrate to 3 gmol/min,

(d) Assume that the MASS flowrates in and out are proportional to thesquare root of the pressure drops. Assume that the steady-state inletgas header is at 5 atm. Perform a step change in inlet concentration to50% methane, simultaneously with a step change in inlet pressure to 6atm.

30. Pharmacokinetics is the study of how drugs infused to the hody are dis-tributed to other parts of the body. The concept of a compartmental modelis often used, where it is assumed that the drug is injected into compart-ment i. Some of the drug is eliminated (reacted) in compartment 1, and someof it diffuses into compartment 2 (the rest accumulates in compartment 1).Similarly, some of the drug that diffuses into compartment 2 diffuses backinto compartment 1, while some is eliminated by reaction and the rest accu-mulates in compartment 2. The rates of diffusion and reaction are directlyproportional to the concentration of drug in the compartment of interest.The following balance equations describe the rate of change of drug concen-tration in each compartment.

dx1

dt= −(k10 + k12)x1 + k21x2 + u

dx2

dt= k12x1 − (k20 + k21)x2

where x1 and x2 = drug concentrations in compartments 1 and 2 (µg/kg ofpatient weight), and u = rate of drug input to compartment 1 (scaled bythe patient weight. µg/kgmin). Experimental studies (of the response ofthe compartment 1 concentration to various drug infusions) have led to thefollowing parameter values:

(k10 + k12) = 0.26 min−1

(k20 + k21) = 0.096 min−1

k12k21 = 0.015 min−1

for the drug atracurium, which is a muscle relaxant. Notice that the param-eters have not been independently determined. Show (through numerical

Page 73: Computer Aided Process Design and Simulation · Use the explicit Euler method to predict the behaviour of this reactor up to time equal 100s to four significant figures accuracy

3.12. MODELS AND SOLUTION 73

simulation) that all of the following values lead to the same results for thebehavior of x1, while the results for x2 are different. Let the initial concentra-tion be 0 for each compartment and assume a constant drug infusion rateof 5.2 µg/kgmin

(a). k12 = k21 (b). k12 = 2k21 (c). k12 = 0.5k21

Discuss how the concentration of compartment 2 (if measurable) could beused to determine the actual values of k12 and k21 . Use the MATLAB functionode45 for your simulations.

31. A stream contains a waste chemical, W, with a concentration of 1 mol/liter.To meet EPA and state standards, at least 90% of the chemical must beremoved by rcaction. The chemical decomposes by a second-order reactionwith a rate constant of 1.5 liter/(mol hr). The stream flowrate is 100 liter/hrand two available reactors (400 and 2000 liters) have been placed in series(the smaller reactor is placed before the larger one).

(a) Write the modeling equations for the concentration of the waste chemi-cal. Assume constant volume and constant density. LetCw1 = concentration in reactor 1, mol/literCw2 = concentration in reactor 2, mol/literF = Volumetric flow rate, liter/htV1 = liquid volume in reactor 1, literV2 = liquid volume in reactor 2, literk = second - order rate constant, liter/(mol hr)

(b) Show that the steady-state concentrations are 0.33333 mol/liter (re-actor 1) and 0.09005 mol/liter (reactor 2), so the specification is met.(Hint: You need to solve quadratic equations to obtain the concentra-tions.)

(c) The system is not initially at steady-state. Write a function file and useode45 for the following: (i). If Cw1 = 0.3833 and Cw2 = 0.09005, find howhow the concentrations change with time.(ii). If Cw1 = 0.3333 and Cw2 = 0.14005, find how how the concentrationschange with time.

32. Consider a batch reactor with a series reaction where component A reactsto form the desired component B reversibly. Component B can also react

Page 74: Computer Aided Process Design and Simulation · Use the explicit Euler method to predict the behaviour of this reactor up to time equal 100s to four significant figures accuracy

74 CHAPTER 3. PROCESS MODELING

to form the undesired component C. The process objective is to maximizethe yield of component B. A mathematical model is used to predict the timerequired to achieve the maximum yield of B. The reaction scheme can becharacterized by

Ak1f←−→k1r

Bk2−−→ C

Here k1f and k1r represent the kinetic rate constants for the forward andreverse reactions for the conversion of A to B, while k2 represents the rateconstant for the conversion of B to C. Assuming that each of the reactionsis first-order, the reactor operates at constant volume, and there are no feedor product streams, the modeling equations are:

dCAdt

= −k1fCA + k1rCB

dCBdt

= k1fCA − k1rCB − k2CB

dCCdt

= k2CB

where CA, CB and CC represent the concentrations (mol/volume) of compo-nents A, B, and C, respectively.

(a) For k1f = 2, k1r = 1, and k2 = 1.25, use ode45 to solve for the concen-trations as a function of time. Assume an initial concentration of A ofCA0 = 1mol/liter. Then plot the concentrations as a function of time. Forwhat time is the concentration of B maximized?

(b) Usually there is some uncertainty in the rate constants. If the real valueof k2 is 1.5 hr−1 find how the concentrations vary with time and comparewith part a.

33. As a process development engineer you arc working on a process with threecontinuous-stirred-tank reactors (CSTRs) in series (Fig 3.17). A constantvolumetric flow rate (flowrate does not vary with time) is maintained through-out the system, however the volume in each reactor is different (but con-stant). Since the temperature varies from reactor to reactor (but is constantin an individual reactor) the reaction rate parameter is different for eachreactor. The molar concentration of the inlet stream varies. Assume thatthe density of the streams remains constant (independent of concentration).The reaction is a first-order (irreversible) decomposition (A −−→ B). Molarrate of decomposition of A (per unit volume) = kCA

Page 75: Computer Aided Process Design and Simulation · Use the explicit Euler method to predict the behaviour of this reactor up to time equal 100s to four significant figures accuracy

3.12. MODELS AND SOLUTION 75

Figure 3.17: CSTR in series

(a) Write the 3 dynamic model equations.

(b) Write the state-space model o(x) = Ax+Bu

(c) The values of the parameters and variables areF = 1 ft3/min, C0 = 1lbmol/ft3, V1 = 10ft3, V2 = 8ft3, V3 = 5ft3, k1 =0.0333 min−1, k2 = 0.2 min−1, k3 = 0.55 min−1

i. Find the steady-state concentrations in each reactorii. Evaluate the A matrix (Jacobian) and find the eigenvalues

34. Consider a chemical reactor with bypass as shown below. Assume thatthe reaction rate (per unit volume) is first-order (r = kC1) and C1 is theconcentration in the reactor (the reactor is perfectly mixed). Assume thatthe volume in the reactor (V ) and the feed flowrate (F ) remain constant. Thefraction of feed bypassing the reactor is (1−a)F and that entering the reactoris aF . Assume that the fraction bypassing the reactor does not change. Theinlet concentration (Cin) is the input variable and the mixed outlet streamcomposition (C2) is the output variable. Write this model in state-space form(this model is inherently linear, so deviation variahles are not needed).

o(x) = Ax+Bu

y = Cx+Du

35. Consider the following set of series and parallel reactions

Ak1−−→ B

k2−−→ C

A + Ak3−−→ D

Page 76: Computer Aided Process Design and Simulation · Use the explicit Euler method to predict the behaviour of this reactor up to time equal 100s to four significant figures accuracy

76 CHAPTER 3. PROCESS MODELING

Material balances on components A and B yield the following two equations

dCAdt

=F

V(CAf − CA)− k2CA − k3C

2A

dCBdt

=F

V(−CB) + (K1CA − k2CB)

wherek1 =

5

6min−1, k2 =

5

3min−1, k3 =

1

6

liter

mol.min

CAf = 10mol

liter, CAs = 3

mol

liter

(a) Find the steady-state dilution rate (F/V ) and concentration of B (showall units)

(b) Linearize and put in state-space form (find the numerical values of theA, B and C matrices), assuming that the manipulated variable is dilu-tion rate (F/V ), and the output variable is CB

(c) Find the eigenvalues (show units)

(d) Find perturbations in initial conditions that are in the fastest and slow-est directions.

36. A chemical reactor that has a single second-order reaction and an outletflowrate that is a linear function of height has the following model:

dV C

dt= FinCin − FC − kV C2

dV

dt= Fin − F

where the outlet flowrate is linearly related to the volume of liquid in thereactor (F = βV ). The parameters, variables and their steady-state valuesare shown below.

Fin = inlet flowrate (1 liter/min)

Cin = inlet concentration (1 gmol/liter)

C = tank concentration (0.5 gmol/liter)

V = tank volume (1 liter)

k = reaction rate constant (2 liter/(gmol min))

Page 77: Computer Aided Process Design and Simulation · Use the explicit Euler method to predict the behaviour of this reactor up to time equal 100s to four significant figures accuracy

3.12. MODELS AND SOLUTION 77

β = 1 min−1

Differential equations can be written in physical state variable form as

dC

dt=FinV

(Cin − C)− kC2

dV

dt= Fin − βV

(a) List the states, outputs, inputs and parameters for the nonlinear equa-tions mentioned above.

(b) Linearize the differential equations and write the state space model (findthe numerical values for the A, B, and C matrices), assuming that theinlet flowrate is the input variable and that both states are output vari-ables. Define the deviation variables for states, inputs, and outputs.

37. Find the "fast" and "slow" initial conditions for the following model

x1 = −x1

x2 = −4x2

Solution:

x1 = −x1

x2 = −4x2

can be written in state space model

x = Ax =

[−1 00 −4

]x

Eigen vector is[

0 11 0

]and Eigen values are λ1 = −4 and λ2 = −1

∵ x(t) = V eλtV −1x(0)

x(t) =

[0 11 0

] [e−4t 0

0 e−t

] [0 11 0

] [01

]

Page 78: Computer Aided Process Design and Simulation · Use the explicit Euler method to predict the behaviour of this reactor up to time equal 100s to four significant figures accuracy

78 CHAPTER 3. PROCESS MODELING

x(t) =

[0e−4t

]The response curve is shown in figure 3.18 for both fast and slow response.

similarly

x(t) =

[0 110

] [e−4t 0

0 et

] [0 11 0

] [10

]x(t) =

[e−t

0

]x(2) = e−4t, x(1) = 0 is fast response and x(1) = e−t, x(2) = 0 is slow response.

38. Find the stable and unstable subspaces for the following system of equations

x1 = −x1

x2 = 4x2

Plot the transient responses for initial conditions in both the stable andunstable subspaces. Show that a small perturbation from the stable initialcondition will lead to an unstable solution.

Solution:

x1 = −x1

x2 = 4x2

can be written in state space model

x = Ax =

[−1 00 4

]x

Eigen vector is[

1 00 1

]and Eigen values are λ1 = −1 and λ2 = 4

∵ x(t) = V eλtV −1x(0)

x(t) =

[1 00 1

] [e−t 00 e4t

] [1 00 1

] [10

]

Page 79: Computer Aided Process Design and Simulation · Use the explicit Euler method to predict the behaviour of this reactor up to time equal 100s to four significant figures accuracy

3.12. MODELS AND SOLUTION 79

Figure 3.18: Transient response for initial conditions in slow and fast subspaces

x(t) =

[e−t

0

]The response curve is shown in figure 3.19 for both fast and slow response.

similarly

x(t) =

[1 00 1

] [e−t 00 e4t

] [1 00 1

] [01

]

x(t) =

[0e4t

]

Page 80: Computer Aided Process Design and Simulation · Use the explicit Euler method to predict the behaviour of this reactor up to time equal 100s to four significant figures accuracy

80 CHAPTER 3. PROCESS MODELING

x(2) = e4t, x(1) = 0 is Unstable response and x(1) = e−t, x(2) = 0 is stablecondition response.

Figure 3.19: Transient response for initial conditions for Stable and Unstableconditions

39. The noninteracting tank model is[h1

h2

]=

[− β1A1

0β1A2

−β2A2

] [h1

h2

]+

[1A1

0

]F0

Consider a system where the steady state flowrates are 5 ft3/min, and thefollowing cross-sectional areas and steady-state heights:

A1 = 2 ft2, A2 = 10 ft2

Page 81: Computer Aided Process Design and Simulation · Use the explicit Euler method to predict the behaviour of this reactor up to time equal 100s to four significant figures accuracy

3.12. MODELS AND SOLUTION 81

h1 = 2.5 ft, h2 = 5 ft

We find (from F1 = β1h1 and F2 = β2h2), then, that:

β1 = 2ft2

min, andβ2 = 1

ft2

min

and the state-space model (in physical variables) becomes:[h1

h2

]=

[−1 00.2 −0.1

] [h1

h2

]+

[0.50

]F0

h1

h2

F2

F0

=

1 00 10 10 0

[ h1

h2

]+

0001

F0

(a) Work in deviation variable form and find the fast and slow subspaces.Use initial to simulate the unforced deviation variable system (inputdeviation remainsconstant at 0), from initial conditions in both the fastand slow subspaces.

(b) Use the results from above part, and convert to the actual physicalvariables.

(c) Work in physical variable form. Use initial to simulate the unforced de-viation variable system (input remains constant), from initial conditionsin both the fast and slow subspaces. Show that the results obtained arethe same as those in part b.

Solution:

>> A=[-1 0;0.2 -0.1]

A =-1.0000 00.2000 -0.1000

>> B=[0.5;0]

B =

Page 82: Computer Aided Process Design and Simulation · Use the explicit Euler method to predict the behaviour of this reactor up to time equal 100s to four significant figures accuracy

82 CHAPTER 3. PROCESS MODELING

0.50000

>> u=[5]

u =

5

>> C=[1 0;0 1;0 1;0 0]

C =

1 00 10 10 0

>> D=[0;0;0;1]

D =

0001

>> sys=ss(A,B,C,D)

a =x1 x2

x1 -1 0x2 0.2 -0.1

b =u1

x1 0.5x2 0

Page 83: Computer Aided Process Design and Simulation · Use the explicit Euler method to predict the behaviour of this reactor up to time equal 100s to four significant figures accuracy

3.12. MODELS AND SOLUTION 83

c =x1 x2

y1 1 0y2 0 1y3 0 1y4 0 0

d =u1

y1 0y2 0y3 0y4 1

Continuous-time model.>> initial(sys,[2.5 5])>>

The sequence of command executed at MATLAB Command prompt result inthe response of initial conditions. Fig. 3.20

40. As a chemical engineer in the pharmaceutical industry you are responsiblefor a process that uses a bacteria to produce an antibiotic. The reactorhas been contaminated with a protozoan that consumes the bacteria. Thepredator-prey equations are used to model the system (b =bacteria (prey),p =protozoa (predator)). The time unit is days.

db

dt= αb− γbp

dp

dt= εγbp− βp

(a) Show that the steady-state values are

bs =β

εγ, ps =

α

γ

(b) Use the scaled variables, w and z, to find the following scaled modelingequations

w =b

bs, z =

p

ps

Page 84: Computer Aided Process Design and Simulation · Use the explicit Euler method to predict the behaviour of this reactor up to time equal 100s to four significant figures accuracy

84 CHAPTER 3. PROCESS MODELING

Figure 3.20: Initial response curves

dw

dt= α(1− z)w

dz

dt= −β(1− w)z

(c) Find the eigenvalues of the Jacobian matrix for the scaled equations,evaluated at ws and zs. Realize that ws and zs are 1.0 by definition. Findthe eigenvalues in terms of α and β

(d) The parameters are α = β = 1.0 and the initial conditions are w(0) = 1.5and z(0) = 0.75

i. Linearize and write the state-space form (let the state variables be

Page 85: Computer Aided Process Design and Simulation · Use the explicit Euler method to predict the behaviour of this reactor up to time equal 100s to four significant figures accuracy

3.12. MODELS AND SOLUTION 85

x1 = w − ws and x2 = z − Zs). Find the initial condition vector x0 =[x1(0)x2(0)

], to use with initial.

ii. Solve the state space model from (i) using lsim and plot the transientresponse of x1 and x2 as a function of time (plot these curves on thesame graph), simulating to at least t = 20

iii. Show a phase-plane plot, placing x1 on the x−axis and x2 on they−axis.

iv. What is the "peak-to-peak" time for the bacteria? By how much timedoes the protozoan "lag" the bacteria?

Solution (i):

db

dt= αb− γbp (3.14)

dp

dt= εγbp− βp (3.15)

at steady state, p = ps and b = bs

db

dt= αb− γbp = 0 =⇒ ps =

α

γ(3.16)

dp

dt= εγbp− βp = 0 =⇒ bs =

β

εγ(3.17)

Solution (ii):

w =b

bsz =

p

ps

dw

dt=

1

bs

db

dt

=1

bs(αb− γbp)

=1

bs(αwbs − γwbszps)

=1

bs(αwbs − γwbsz

α

γ)

= wα(1− z)

Page 86: Computer Aided Process Design and Simulation · Use the explicit Euler method to predict the behaviour of this reactor up to time equal 100s to four significant figures accuracy

86 CHAPTER 3. PROCESS MODELING

dz

dt=

1

ps

dp

dt

=1

ps(εγbp− βp)

=1

ps(εγw

β

ε.γzps − βzps)

= −βz(1− w)

solution (iii):

41. Consider the state-space model[x1

x2

]=

[−1.0 0.04.0 −5.0

] [x1

x2

]Find the "fast" and "slow" initial condition directions.

Solution:

>> A=[-1 0;4 -5]

A =

-1 04 -5

>> [v d]=eig(A)

v =

0 0.70711.0000 0.7071

d =

-5 00 -1

Page 87: Computer Aided Process Design and Simulation · Use the explicit Euler method to predict the behaviour of this reactor up to time equal 100s to four significant figures accuracy

3.12. MODELS AND SOLUTION 87

>> inv(v)

ans =

-1.0000 1.00001.4142 0

x(t) = v

[−e−5t 04e−5t −5e−t

]v−1

[−50

]and

x(t) = v

[−e−5t 04e−5t −5e−t

]v−1

[0−1

]with these relations we find x1 is approaching fast in both initial condi-

tions.(Fig 3.21) x2 is approaching fast with initial condition[

0−1

]but rela-

tively slow for the other initial condition[−50

]42. Consider the following system of two reactors (Fig 3.22) Assume a first order

decomposition of A −−→ B. Assume that all flowrate are constant (volumesare constant).

(a) Write the modeling equations for concentration of A, using either theinstantaneous or integral method

(b) Write these in state-space form:

x = Ax+Bu

(c) Given the following constants. calculate the steady-state concentra-tions:

F0 = 1.25m3

hr, FR = 1.75

m3

hr

C0 = 1.5kgmol

m3, k1 = 0.10833hr−1, k2 = 0.3333hr−1

V1 = 15m3, V2 = 9m3

Page 88: Computer Aided Process Design and Simulation · Use the explicit Euler method to predict the behaviour of this reactor up to time equal 100s to four significant figures accuracy

88 CHAPTER 3. PROCESS MODELING

Figure 3.21: Fast and Slow Response

(d) Find the eigenvalues of the A matrix. Discuss the stability of this Sys-tem.

(e) The inlet concentration. C0, is changed from 1.5 to 1.75 at t = 0. Usestep to simulate the behaviour of this system.

Solution (a):

Let the initial concentration of fresh feed to the reactor 1 is C0 and therecycle concentration be CA2. The concentration of the mixed feed enteringthr reactor 1 is CA0 as given by

Page 89: Computer Aided Process Design and Simulation · Use the explicit Euler method to predict the behaviour of this reactor up to time equal 100s to four significant figures accuracy

3.12. MODELS AND SOLUTION 89

Figure 3.22: CSTR in series

CA0 =F0C0 + FRCA2

F0 + FR

τ1 =V1

F0 + FRand τ2 =

V2

F0 + FR

dCA1

dt=

1

τ1

(CA0 − CA1)

−k1CA1

anddCA2

dt=

1

τ2

(CA1 − CA2)

−k2CA2

(b);

The system of equations can be expressed as state space model

x = Ax+Bu

where, [dCA1

dtdCA2

dt

]=

[ CA0

k1τ10

0 CA1

k2τ2

] [ 1CA1

1CA2

]−[ 1

k1τ11

k2τ2

][1]

y = Cx+Du

CA0 =

[0 00 FR

F0+FR

] [CA1

CA2

]+

[0F0

F0+FR

][C0]

(c) With given inputs,

F0 = 1.25m3

hr, FR = 1.75

m3

hr

Page 90: Computer Aided Process Design and Simulation · Use the explicit Euler method to predict the behaviour of this reactor up to time equal 100s to four significant figures accuracy

90 CHAPTER 3. PROCESS MODELING

C0 = 1.5kgmol

m3, k1 = 0.10833hr−1, k2 = 0.3333hr−1

V1 = 15m3, V2 = 9m3

43. A stirred tank heater is used to supply a chemical process with a fluid at aconstant temperature. The heater receives fluid from an upstream processunit which may cause the flowrate or temperature to change. Consider thediagram of the stirred tank heater shown below (Fig 3.23) Where the tankinlet stream is received from another process unit. A heat transfer fluid iscirculated through a jacket to heat the fluid in the tank, Assume that nochange of phase occurs in either the tank liquid or the jacket liquid.

Figure 3.23: CSTR with heater

(a) Write the dynamic modeling equations to find the tank and jacket tem-peratures. Do not use any numerical values - leave these equations interms of the process parameters and variables. State any additionalassumptions needed to solve the problem. Assume:

• Constant level• Perfect mixing in both the tank and jacket• The tank inlet flowrate, jacket flowrate, tank inlet temperature, and

jacket inlet temperature may change• The rate of heat transfer from the jacket to the tank is governed by

the equation Q = UA(Tj − T ), where U is the overall heat transfercoefficient and A is the area for heat exchange.

(b) State the major objective of this process

(c) What do you consider the most important measured variable?

Page 91: Computer Aided Process Design and Simulation · Use the explicit Euler method to predict the behaviour of this reactor up to time equal 100s to four significant figures accuracy

3.12. MODELS AND SOLUTION 91

(d) What is a likely input variable, variable that you would use to maintaina desired tank temperature?Assume that both the tank fluid and the jacket fluid are water. Thesteady-state values of this system variables and some parameters are:

F = 1ft3

minpCp = 61.3

BTU

°Fft3, pjCpj = 61.3

BTU

°Fft3

Ti = 50°F T = 125°F V = 10ft3

Tjin = 200°F Tj = 150°F Vj = 1ft3

(e) Find Fj and UA (show units) at steady-state.

(f) Linearize the set of two nonlinear ODEs obtained in problem a, to obtainthe state space form:

x = Ax+Bu

y = Cx

where

x =

[T − TsTj − Tjs

]= state variables

u =

Fj − FjsF − FsTi − TisTjin − Tjins

= input variables

y =

[T − TsTj − Tjs

]= output variables

Determine the A, B, and C matrices (symbolically and numerically)

(g) Find the eigenvalues of A.

(h) Simulate the system of state-space equations for a step change in thejacket flowrate from Fj = 1.5ft3/min to Fj = 1.75ft3/min, F at time = 5minutes (work in deviation variables, but remember to convert back tophysical variables before plotting). What is the final value of the states,in the physical variables (T and Tj)? Plot the response.

(i) Perform some simulations with step changes on some of the other inputvariables. Comment on any different behavior that you may observe.

Page 92: Computer Aided Process Design and Simulation · Use the explicit Euler method to predict the behaviour of this reactor up to time equal 100s to four significant figures accuracy

92 CHAPTER 3. PROCESS MODELING

44. Consider the following model of 2-stage absorption column:

dw

dt= −

(L+ V a

M

)w +

(V a

M

)z

dz

dt=

(L

M

)w −

(L+ V a

M

)z +

V

Mzf

where w and z are the liquid concentrations on stage 1 and stage 2, re-spectively. L and V are the liquid and vapor molar flow rates. zf is theconcentration of the vapor stream entering the column. The steady-state in-put values are L = 80 gmol inert liquid/ min and V = 100 gmol inert vapour/min. The parameter values are M = 20 gmol inert liquid, a = 0.5, and zf = 0.1gmol solute /gmol inert vapor.

(a) Find the steady-state values of w and z.

(b) Linearize and find the state space model, assuming that L and V arethe inputs.

(c) Find the eigen values and eigen vectors of A (Jacobian).

(d) Find the expected "slowest" and "fastest" initial conditions (perturba-tions from steady-state).

Solution:

(a):

At steady state, w and z becomes constant and its derivatives becomes zero,hence

dw

dt= −

(L+ V a

M

)w +

(V a

M

)z = 0

dz

dt=

(L

M

)w −

(L+ V a

M

)z +

V

Mzf = 0

Substituting the values for L = 80, V = 100, M = 20, a = 0.5 and zf = 0.1

−6.5w + 2.5z = 0

4w +−6.5z = −0.5

which can be represented by[−6.5 2.5

4 −6.5

] [wz

]=

[0−0.5

]

Page 93: Computer Aided Process Design and Simulation · Use the explicit Euler method to predict the behaviour of this reactor up to time equal 100s to four significant figures accuracy

3.12. MODELS AND SOLUTION 93

the steady state solution for the above system of equations become ws =0.0388 gmol and zs = 0.1008gmol

(b):

There are two state variables w and z, two input variables L and M and twooutput variable w − ws and z − zs.

[W]

=

[wszs

][X]

=

[wz

]=

[w − wsz − zs

]

u =

[LV

]The elements of A (Jacobian) matrics are

A11 =∂f1

∂w|ws,f1s =

(L+ V a

M

)= 6.5

A12 =∂f1

∂z|zs,f1s =

(V a

M

)= 2.5

A21 =∂f2

∂w|ws,f2s =

(L+ V a

M

)= 6.5

A22 =∂f1

∂w|ws,f1s =

(L+ V a

M

)= 6.5

B11 =∂f1

∂L= − w

M

B12 =∂f1

∂V= −aw

M+az

M

B21 =∂f2

∂L=

w

M− z

M

B22 =∂f2

∂V= −az

M+zfM

(c):

With A matrics, the eigen values and eigen vectors are given by matrics aregiven by d and v as follows:

Page 94: Computer Aided Process Design and Simulation · Use the explicit Euler method to predict the behaviour of this reactor up to time equal 100s to four significant figures accuracy

94 CHAPTER 3. PROCESS MODELING

>> A=[6.5 2.5; 6.5 6.5]

A =

6.5000 2.50006.5000 6.5000

>> [v d]=eig(A)

v =

0.5270 -0.52700.8498 0.8498

d =

10.5311 00 2.4689

>> inv(v)

ans =

0.9487 0.5883-0.9487 0.5883

(d)

x(t) = v

[6.5e10.5311t 2.56.5e10.5311t 6.5e2.4689t

]v−1

[10.5311

0

]45. Most chemical process plants have a natural gas header that circulates

through the process plant. A simplified version of such a header is shownbelow. Here, the natural gas enters the process plant from a source (thenatural gas pipeline) through a control valve. It flows through the plantpiping, which we have represented as a perfectly mixed drum for simplicity.Another valve connects the plant piping to the gas drum for a boiler houseunit. Gas passes through another valve to the boiler house furnaces. The

Page 95: Computer Aided Process Design and Simulation · Use the explicit Euler method to predict the behaviour of this reactor up to time equal 100s to four significant figures accuracy

3.12. MODELS AND SOLUTION 95

Figure 3.24: Pipe line header

objective of this problem is to develop a linear model that relates changes invalve position to changes in drum pressures.

(a) Write modeling equations assuming that the pressures in drums 1 and2 are the state variables. Let the input variables- be (1) valve position1, (2) valve position 2, and (3) source pressure.

(b) Solve for the steady-state conditions and write the modeling equationsin linear, deviation variable form.

x = Ax+Bu

y = Cx

x =

[P1 − PsP2− P2s

]= State variables

u =

h1 − h1s

h2 − h2s

P1 − P1s

=

Valve position 1Valve position 2

Change in source pressure

= input variables

y =

[P1 − P1s

P2 − P2s

]= output variables

(c) Study the effect of step changes in each input on each tank pressure.HINTS: For simplicity, assume that the following equations can be usedfor the flow through the valves:

qi = αihi(pi − p1) = flow through valve i

q1 = α1h1(p1 − p2) = flow through valve 1

q2 = α2h2(p2 − p3) = flow through valve 2

Page 96: Computer Aided Process Design and Simulation · Use the explicit Euler method to predict the behaviour of this reactor up to time equal 100s to four significant figures accuracy

96 CHAPTER 3. PROCESS MODELING

where the flowrate is in Ibmol/min, h is the fraction that a valve is open(varies between 0 and 1), and α is a valve coefficient. STEADY STATEDATA: gas flowratc = 1000 std ft3/min

P − is = 250psig, P1s = 50psig, P2s = 30psig, P3s = 5psig

assume that each valve is 1/2 open under these conditions (his = h1s =h2s = 0.5) CONSTANTS:

V1 = 1135 ft3, V2 = 329 fdt3,Temp = 32°F

R = 10.73psia.ft3

lbmol.°RMAGNITUDE OF STEP CHANGES: Make separate step changes of 0.1(10%) in the valve openings, and 10 psia in the inlet pressure. Simulateforto t = 15 minute

46. A stream contains a waste chemical, W , with a concentration of 1 mol/liter.To meet EPA and shale standards, at least 90% of the chemical must beremoved by reaction. The chemical decomposes by a second-order reactionwith a rate constant of 1.5 liter/(mol hr). The stream flow rate is 100 liter/hrand two available reactors (400 and 2000 liters) have been placed in series(the smaller reactor is placed before the larger one).

(a) Write the modeling equations for the concentration of the waste chemi-cal. Assume constant volume and constant density.Let Cw1 =concentration in reactor 1, mol/liter Cw2 =concentration inreactor 2, mol/liter F =volumetric flowrate, liter/hr V1 =liquid volumein reactor 1, liters V2 =liquid volume in reactor 2, liters k =second-orderrate constant, liter/(mol hr)

(b) Show that the steady-stale concentrations are 0.33333 mol/liter (re-actor 1) and 0.09005 mol/liter (reactor 2), so the specification is met.(Hint: You need to solve quadratic equations to obtain the concentra-tions.)

(c) Linearize at steady-state and develop the state space model (analytical),of the form:

x = Ax+Bu

where:

x =

[Cw1 − Cw1s

Cw2 − Cw2s

]u =

[F − Fs

Cwin − Cwins

]

Page 97: Computer Aided Process Design and Simulation · Use the explicit Euler method to predict the behaviour of this reactor up to time equal 100s to four significant figures accuracy

3.12. MODELS AND SOLUTION 97

(d) Show that the A and B matrices are:

A =

[−1.25 00.05 −0.32015

]B =

[0.001667 0.250.0001216 0

](also, show the units associated with each coefficient)

(e) Find the eigenvalues and eigenvectors using the MATLAB eig function.

(f) The system is not initially at steady-state. Solve the following for thelinearized model, using the MATLAB function initial (first, convert thephysical variables to deviation variables)

i. If Cw1(0) = 0.3833 and Cw2(0) = 0.09005, find how the concentrationschange with time.

ii. If Cw1(0) = 0.3333 and Cw2(0) = 0.14005, find how the concentra-tions change with time. Relate these responses to the eigenval-ues/eigenvector analysis of e. Discuss the differences in speedsof response (you should find that a perturbation in the first reactorconcentration responds more rapidly and a perturbation in the sec-ond reactor concentration). The MATLAB initial function needs youto create the following matrices before using it:

C =

[1 00 1

], D =

[0 00 0

](g) Solve f for the nonlinear equations, using ode45. Compare the linear

and nonlinear variables on the same plots (make certain you convertfrom deviation to physical variables for the linear results).

(h) Now, consider a step change in the flowrate from 100 liters/hour to110 liters/hour. Assume the initial concentrations are the steady-statevalues (0.3333 and 0.09005). Compare the linear and nonlinear re-sponses of the reactor concentrations. Is the removal specification stillobtained?

(i) Would better steady-state removal of W be obtained if the order of thereaction vessels was reversed? Why or why not? (Show your calcula-tions.)

47. Solution of NaCl in water is called Brine solution whose density is measuredin Baume scale denoted by Be°. In order to get brine with maximum sat-uration normally between 26-28% by weight, a concrete tank of volume VT

Page 98: Computer Aided Process Design and Simulation · Use the explicit Euler method to predict the behaviour of this reactor up to time equal 100s to four significant figures accuracy

98 CHAPTER 3. PROCESS MODELING

is filled with impure crystals of NaCl with 30 % sand particles imprignatedalong with salt having initial bed porocity ε. Water is feed with the volumet-ric flow rate of Fi m3 s−1. The rate of dissolution of NaCl in water is assumedto be constant 1× 10−9 kg m−3 min−1 of water. The tank is filled with satu-rated solution of brine at CS kg m−3 of solution. Assuming the level of liquidis maintained constant and equal to the level of raw salt initially, develop amodel to simulate the outlet concentration of brine in Baume scale, and rateof change of NaCl and the rate of change of contaminant sand in terms ofits mass with respect to time. Suitably assume all missing variables if any.Note: Be° = 145− 145

ρsolρsolvent, and Csol = ρsol − ρwater Solution:

Total volume of Tank = VT Porosity of bulk solid = ε

Volume of initial liquid hold up = εVT volume of Sand and Salt = (1 − ε)VTVolume of Salt = V0,Salt = 0.7(1 − ε)VT Mass of Salt = M0,Salt = 0.7(1 − ε)VTρsMass of Sand = M0,Sand = 0.3(1− ε)VTρsSince only salt is dissolving into solution and sand is relatively insoluble therate of change of mass of sand is zero

∴dMsand

dt= 0 (3.18)

constant rate of dissolution of salt,

dMSalt

dt= −1× 10−9εVT (3.19)

dVSaltdt

=−1× 10−9εVT

ρs

Looking at the mass balance on liquid,

dVsoldt

=1× 10−9εVT

ρs∵ operating at steady state wrt volumetric flow rate

d(VsolCsol)

dt= FiCsalt,0 − FiCsol + (1× 10−9)εVT

CsoldVsoldt

+ VsoldCsoldt

= −FiCsol + (1× 10−9)εVT

dCsoldt

=−FiCsol + (1× 10−9)εVT − Csol dVsoldt

Vsol

Page 99: Computer Aided Process Design and Simulation · Use the explicit Euler method to predict the behaviour of this reactor up to time equal 100s to four significant figures accuracy

3.12. MODELS AND SOLUTION 99

dCsoldt

=−FiCsol + (1× 10−9)εVT − −1×10−9CsolεVT

ρs

Vsol(3.20)

Be° = 145− 145ρsol

ρsolvent =⇒ ρsol = 145ρwater(145−Be°) , and Csol = ρsol − ρwater

dCsoldt

=dρsoldt

∵ ρwater = Constant

dρsoldt

=dBe°dt

145ρwater(145−Be°)2

∴dρsoldt

=−Fi(ρsol − ρwater) + (1× 10−9)εVT − −1×10−9(ρsol−ρwater)εVT

ρs

Vsol(3.21)

and

∴dBe°dt

=(145−Be°)2

145ρwater

[−Fi(ρsol − ρwater) + (1× 10−9)εVT + 1×10−9(ρsol−ρwater)εVT

ρs

Vsol

](3.22)

substituting ρsol − ρwater = −ρwaterBe°145−Be , we get,

∴dBe°dt

=(145−Be°)2

145ρwaterVsol

[−Fi(−

ρwaterBe°(145−Be°)

) + (1× 10−9)εVT +1× 10−9(− ρwaterBe°

(145−Be°))εVT

ρs

](3.23)

∴dBe°dt

=(145−Be°)145ρwaterVsol

[Fi(ρwaterBe°) + (1× 10−9)εVT (145−Be°)− 1× 10−9(ρwaterBe°)εVT

ρs

]

∴dBe°dt

=(145−Be°)

145Vsol

[FiBe° +

(1× 10−9)εVT (145−Be°)ρwater

− 1× 10−9Be°εVTρs

](3.24)

Modeling of Reactors with multiple reactions and VLE and distillation referclass instructions

Page 100: Computer Aided Process Design and Simulation · Use the explicit Euler method to predict the behaviour of this reactor up to time equal 100s to four significant figures accuracy

100 CHAPTER 3. PROCESS MODELING

Page 101: Computer Aided Process Design and Simulation · Use the explicit Euler method to predict the behaviour of this reactor up to time equal 100s to four significant figures accuracy

Chapter 4

Process Simulation

4.1 Simulation Packages

4.1.1 Programing Languages and Simulation Software

1. Advanced Simulation Library - open-source hardware accelerated multi-physics simulation software.

2. ASCEND - open-source equation-based modelling environment.

3. DWSIM - an open-source CAPE-OPEN compliant chemical process simula-tor.

4. Elmer - an open-source multiphysical simulation software for Windows/Mac/ Linux.

5. Facsimile - a free, open-source discrete-event simulation library.

6. Freemat - a free environment for rapid engineering, scientific prototypingand data processing using the same language as Matlab and GNU Octave.

7. Galatea - a multi-agent, multi-programming language, simulation platform.

8. GNU Octave - an open-source mathematical modeling and simulation soft-ware very similar to using the same language as Matlab and Freemat.

101

Page 102: Computer Aided Process Design and Simulation · Use the explicit Euler method to predict the behaviour of this reactor up to time equal 100s to four significant figures accuracy

102 CHAPTER 4. PROCESS SIMULATION

9. Minsky (economic simulator) - an open-source visual computer program fordynamic simulation of economic models.

10. Modelica - an open standard for modeling software.

11. Mobility Testbed - an open-source multi-agent simulation testbed for trans-port coordination algorithms.

12. NetLogo - an open-source multi-agent simulation software

13. ns-3 - an open-source network simulator.

14. OpenFOAM - open-source software used for computational fluid dynamics(or CFD)

15. OpenEaagles - multi-platform simulation framework to prototype and buildsimulation applications.

16. Open Source Physics - an open-source Java software project for teachingand studying physics.

17. OpenSim - an open-source software system for biomechanical modeling.

18. Physics Abstraction Layer - an open-source physics simulation package.

19. Project Chrono - an open-source multi-physics simulation framework.

20. OpenEaagles - multi-platform simulation framework to prototype and buildsimulation applications.

21. Open Source Physics - an open-source Java software project for teachingand studying physics.

22. OpenSim - an open-source software system for biomechanical modeling.

23. Physics Abstraction Layer - an open-source physics simulation package.

24. Project Chrono - an open-source multi-physics simulation framework.

25. SageMath - a system for algebra and geometry experimentation via Python.

26. Scilab - free open-source software for numerical computation and simula-tion similar to Matlab/Simulink.

Page 103: Computer Aided Process Design and Simulation · Use the explicit Euler method to predict the behaviour of this reactor up to time equal 100s to four significant figures accuracy

4.1. SIMULATION PACKAGES 103

27. SimPy - an open-source discrete-event simulation package based on Python.

28. SOFA - an open-source framework for multi-physics simulation with an em-phasis on medical simulation.

29. Stanford University Unstructured - an open-source framework for compu-tational fluid dynamics simulation and optimal shape design.

30. Step - an open-source two-dimensional physics simulation engine (KDE).

31. Tortuga - an open-source software framework for discrete-event simulationin Java

32. 20-sim - bond graph-based multi-domain simulation software.

33. Actran - finite element-based simulation software to analyze the acousticbehavior of mechanical systems and parts.

34. ACSL and acslX - an advanced continuous simulation language.

35. AMESim - a platform to analyze multi-domain, intelligent systems and pre-dict and optimize multi-disciplinary performance. Developed by SiemensPLM Software.

36. AnyLogic - a multi-method simulation modeling tool for business and sci-ence. Developed by The AnyLogic Company.

37. ASPEN Plus âAS a Process simulation package by ASPEN Tech

38. APMonitor - a tool for dynamic simulation, validation, and optimization ofmulti-domain systems with interfaces to Python and MATLAB.

39. Arena - simulation and automation software developed by Rockwell Automa-tion.

40. AutoCAST - metal casting design and simulation software developed by Ad-vanced Reasoning Technologies.

41. Automation Studio - a fluid power, electrical and control systems design andsimulation software developed by Famic Technologies Inc.

42. Chemical WorkBench - a chemical kinetics simulation software tool devel-oped by Kintech Lab.

Page 104: Computer Aided Process Design and Simulation · Use the explicit Euler method to predict the behaviour of this reactor up to time equal 100s to four significant figures accuracy

104 CHAPTER 4. PROCESS SIMULATION

43. CircuitLogix - an electronics simulation software developed by Logic DesignInc

44. Chemical WorkBench - a chemical kinetics simulation software tool devel-oped by Kintech Lab.

45. ChemCAD âASProcess Simulation software

46. CircuitLogix - an electronics simulation software developed by Logic DesignInc.

47. COMSOL Multiphysics (formerly FEMLAB) - a finite element analysis, solverand simulation software package for various physics and engineering appli-cations, especially coupled phenomena, or multi-physics.

48. DX Studio - a suite of tools for simulation and visualization.

49. Dymola - modeling and simulation software based on the Modelica language.

50. Ecolego - a simulation software tool for creating dynamic models and per-forming deterministic and probabilisticsimulations.

51. EcosimPro - continuous and discrete modelling and simulation software.

52. Enterprise Architect - a tool for simulation of UML behavioral modeling,coupled with Win32 user interface interaction.

53. Enterprise Dynamics - a simulation software platform developed by INCON-TROL Simulation Solutions.

54. ExtendSim - simulation software for discrete event, continuous, discreterate and agent-based simulation.

55. Flexsim - discrete event simulation software.

56. Fluent, Inc. - simulation software for fluid flow, turbulence, heat transfer,and reactions for industrial applications.

57. GoldSim - simulation software for system dynamics and discrete event sim-ulation, embedded in a Monte Carlo framework.

58. HyperWorks - multi-discipline simulation software

Page 105: Computer Aided Process Design and Simulation · Use the explicit Euler method to predict the behaviour of this reactor up to time equal 100s to four significant figures accuracy

4.1. SIMULATION PACKAGES 105

59. Isaac dynamics - dynamic process simulation software for conventional andrenewable power plants.

60. Khimera - a chemical kinetics simulation software tool developed by KintechLab.

61. Lanner WITNESS - a discrete event simulation platform for modelling pro-cesses and experimentation.

62. Lanner L-SIM Server - Java-based simulation engine for simulating BPMN2.0based process models.

63. Maple - a general-purpose computer algebra system developed and soldcommercially by Waterloo Maple Inc.

64. MapleSim - a multi domain modeling and simulation tool developed by Wa-terloo Maple Inc.

65. MATLAB - a programming, modeling and simulation tool developed by Math-Works.

66. Mathematica - a computational software program based on symbolic math-ematics, developed by Wolfram Research.

67. ModelCenter - a framework for integration of third-party modeling and sim-ulation tools/scripts, workflow automation, and multidisciplinary designanalysis and optimization from Phoenix Integration.

68. NEi Nastran - software for engineering simulation of stress, dynamics, andheat transfer in structures

69. NetSim - network simulation software for defense applications, network de-sign validation and network research and development.

70. NI Multisim - an electronic schematic capture and simulation program.

71. Plant Simulation - plant, line and process simulation and optimization soft-ware, developed by Siemens PLM Software.

72. PLECS - a tool for system-level simulations of electrical circuits. Developedby Plexim.

Page 106: Computer Aided Process Design and Simulation · Use the explicit Euler method to predict the behaviour of this reactor up to time equal 100s to four significant figures accuracy

106 CHAPTER 4. PROCESS SIMULATION

73. PRO/II - software for steady state chemical process simulation and exten-sively used by oil and gas refineries.

74. Promodel - a discrete event simulation software

75. Project Team Builder - a project management simulator used for trainingand education.

76. PSF Lab - calculates the point spread function of an optical microscopeunder various imaging conditions based on a rigorous vectorial model.

77. RoboLogix - robotics simulation software developed by Logic Design Inc.

78. Ship Simulator - a vehicle simulation computer game by VSTEP which sim-ulates maneuvering various ships in different environments.

79. Simcad Pro - dynamic discrete and continuous simulation software.

80. SimEvents - a part of MathWorks which adds discrete event simulation tothe MATLAB/Simulink environment.

81. Simio - an object-oriented discrete event and agent based simulation soft-ware developed by Simio LLC.

82. SimScale - a web-based simulation platform, with CFD, FEA, and thermo-dynamics capabilities.

83. SIMUL8 - software for discrete event or process based simulation.

84. Simulations Plus - modeling and simulation software for pharmaceuticalresearch

85. SimulationX - modeling and simulation software based on the Modelica lan-guage.

86. Simulink - a tool for block diagrams, electrical mechanical systems andmachines from MathWorks.

87. TRNSYS - software for dynamic simulation of renewable energy systems,HVAC systems, building energy use and both passive and active solar sys-tems.

88. Vensim - system dynamics and continuous simulation software for businessand public policy applications.

Page 107: Computer Aided Process Design and Simulation · Use the explicit Euler method to predict the behaviour of this reactor up to time equal 100s to four significant figures accuracy

4.1. SIMULATION PACKAGES 107

89. VisSim - system simulation and optional C-code generation of electrical,process, control, bio-medical, mechanical and UML State chart systems

90. Vortex (software) - a high-fidelity, realtime physics engine that simulatesrigid body dynamics, collision detection, contact determination, and dy-namic reactions.

91. Wolfram SystemModeler âAS modeling and simulation software based onthe Modelica language.

92. Working Model âAS a dynamic simulator with connections to SolidWorks.

93. VisualSim Architect âAS an electronic system-level software for modelingand simulation of electronic systems, embedded software and semiconduc-tors.

4.1.2 Simulation–Definition

Simulation is the act of representing some aspects of the real world by numbersor symbols which may be manipulated to facilitate their study

4.1.3 Need for Simulation software

Simulation software has had an enormous impact on the petroleum, petrochem-ical and chemical process industries. Process Simulation is almost universallyused to guide the design of new processes, evaluates alternate plate configura-tions, troubleshoots and debottlenecks plant process. Process Simulation pro-grams perform rigorous mass and energy balances for a wide range of chemicalprocesses. Process Engineering tools have been developed for heat transfer sim-ulation, plant gross error detection, piping network simulation, safety systemmodeling

Dynamic simulation software has also been developed to model plant controlsystems for detailed engineering studies and operator training. Simulations arebased on rigorous first-principle models and the actual plant controls can beused to troubleshoot process and control problems that occur in the actual plantand perform what-if and debottlenecking studies. High fidelity plant simulatorsare used to train operators in a non-destructive environment.

Page 108: Computer Aided Process Design and Simulation · Use the explicit Euler method to predict the behaviour of this reactor up to time equal 100s to four significant figures accuracy

108 CHAPTER 4. PROCESS SIMULATION

On-line optimization has been practiced in the hydrocarbon processing indus-try for over 40 years. On-line optimization answers the question of how should agiven unit, or groups of units, can be operated to maximize economic given con-straints of the operating and economic environment. Optimizations are typicallybased on a mathematical model ranging from a unit to a complete manufactur-ing complex based on observed plant performance to rigorous first principles ofheat, mass and momentum balances. Most recent implementations of on-lineoptimization utilize first principles models to take advantage of their superioraccuracy, rigor, range, and maintainability.

4.2 Aspen-HYSYS

It is possible to manage with software developers to manage to solve a model ofa simple chemical process with small number of equations and variables. As thecomplexity of the integrated plant with solving large set of linear, non linear andstate space equations becomes a challenge. ASPEN (Advanced System for ProcessEngineering) is one of the most widely used software for process simulation since1984. Developed to design nonlinear simulation software that could aid in the de-velopment of synthetic fuels. The sophisticated Aspen software tool can simulatelarge processes with a high degree of accuracy. It has the model library that in-cludes mixers, splitters, phase separators, heat exchangers, distillationcolumns,reactors, pressure changers and manipulators. By interconnecting several unitoperations, it is possible to develop a process flow diagram (PFD) for a completeplant. ASPEN software basically built with FORTRAN codes also provide opportu-nity to agument user developed model libraries to solve any specific application.ASPEN has acquired HYSYS later with the new brand ASPEN-HYSYS1

4.3 ChemCAD

ChemCAD is Chemstations’ intutive suite of chemical process simulator that im-prove and enhance the capability of process engineers and vis-a-vis increases theproductivity by superior support for engineering decisions while addressing the

1Er. MOHD. KAMARUDDIN ABD. HAMID, HYSYS®: An Introduction to Chemical EngineeringSimulation For UTM Degree++ Program, http://www.fkkksa.utm.my/staff/kamaruddi

Page 109: Computer Aided Process Design and Simulation · Use the explicit Euler method to predict the behaviour of this reactor up to time equal 100s to four significant figures accuracy

4.4. PROSIM-II 109

toughest chemical process model and trouble shooting day to day problems. Awindow based user friendly software bundle with addition of Chemical propertydatabase is similar to ASPEN-HYSYS package of Chemstation Inc, Houstan, TX,USA.

4.4 ProSim-II

Over view of PRO II

1. PRO/II is the flagship offering in SimSci -Esscor’s Process Engineering Suite(PES).

2. This steady-state simulator performs rigorous mass and energy balances fora wide range of processes. From oil and gas separation to reactive distilla-tion, PRO/II combines the data resources of a large chemical

3. component library and extensive thermodynamic property prediction meth-ods with the most advanced and flexible unit operations techniques.

4. Process engineers benefit from computational facilities to perform all massand energy balance calculations needed to model most steady-state pro-cesses within the chemical, petroleum, natural gas, solids processing, andpolymer industries.

5. PRO/II runs in an interactive WindowsÂo-based GUI environment.

Simulation with PRO-II

1. Build Process Flow Diagram

2. Check the input measure

3. Define components

4. Select the Thermodynamic method

5. Supply process stream data

6. Supply process unit data

Page 110: Computer Aided Process Design and Simulation · Use the explicit Euler method to predict the behaviour of this reactor up to time equal 100s to four significant figures accuracy

110 CHAPTER 4. PROCESS SIMULATION

7. Run the simulation and view the results

PRO-II Simulation Manual provides detailed guideline and examples

4.5 ChemSep

ChemSep lite is a open source program can be downloaded and installed in anyPCs. It provide various configurations of Distillation columns simulation.

Follow the class room demostration on ChemSep.

Page 111: Computer Aided Process Design and Simulation · Use the explicit Euler method to predict the behaviour of this reactor up to time equal 100s to four significant figures accuracy

Chapter 5

LABORATORY PRACTICE withMATLAB

5.1 Student Exercise – 1

Note: Common to all groups

1. Plot the following three curves On (i) a single plot and (ii) multiple plots(using the subplot command): 2 cos(t), sin(t) and cos(t)+sin(t). Use a timeperiod such that two or three peaks occur for cach curve. Use solid, dashed,and ’+’ symbols for the different curves. Use roughly 25-50 points for eachcurve.

2. Calculate the rank, deteminant and matrix inverse of the following matrices(use help rank, help det, and help inv):

A =

1 2 1−1 −2 −12 4 2

B =

1 2 1−1 4 −12 4 2

111

Page 112: Computer Aided Process Design and Simulation · Use the explicit Euler method to predict the behaviour of this reactor up to time equal 100s to four significant figures accuracy

112 CHAPTER 5. LABORATORY PRACTICE WITH MATLAB

C =

1 2 1−1 4 −12 4 5

3. Find CC−1, where:

C =

1 2 1−1 −2 −12 4 5

4. CalculateXTX, and XXT where:

X =

1234

5. Find the eigenvalues of thc matrix:

D =

−1 0 0 21 −2 0 61 3 −1 80 0 0 −2

6. Consider the expression:

−KA− ATK −Q−KBR−1BTK = 0

with

A =

[0 32 −1

]

B =

[14

]

Q =

[−11.896 −20.328−17.192 −18.856

]

K =

[7 35 2

]Solve for R

Page 113: Computer Aided Process Design and Simulation · Use the explicit Euler method to predict the behaviour of this reactor up to time equal 100s to four significant figures accuracy

5.1. STUDENT EXERCISE – 1 113

7. Find the solutions to the equationf(x) = 3x3 + x2 + 5x− 6 = 0. Use roots andfzero commands.

8. Integrate the following equations from t = 0 to t = 5:

dX1

dt= −X1 +X2

dX2

dt= −X2

with the initial conditions, X1(0) = X2(0) = 1. Use ode45 and plot yourresults.

9. Write your own function file for the following equation:

k(T ) = a e(b−CT−ln dT−eT+fT 2)

fora = 3.33, b = 13, 148, c = 5639.5, d = 1.077, e = 5.44 × 10−4, f = 1.125 × 10−7

and T is in units of Kelvin. Plot k as a function of T for temperatures from373 to 600 K. (we suggest 50 points)

10. Find V ( cm3

gmole)for the following equation of state:

P =RT

V − b− a

T 0.5V (V + b)

forP = 13.76 bar, b = 44.891cm3/gmol, T = 333 K, a = 1.56414×108 cm6bar/gmol2K0.5,R is ideal gas constant in appropriate units.

Reference:

B. W. Bequette, Process Dynamics, Modeling, Analysis and Simulation, Print-ice Hall, New Jersey, 1998, pp432–434.

Page 114: Computer Aided Process Design and Simulation · Use the explicit Euler method to predict the behaviour of this reactor up to time equal 100s to four significant figures accuracy

114 CHAPTER 5. LABORATORY PRACTICE WITH MATLAB

5.2 Student Exercise – 2

Note: Common to all groups

1. Note that a different solution for the best fit of a line is obtained if it isassumed that b is known; this becomes a single parameter estimation prob-lem. Derive the following result for the estimate of a if it is assumed that bis known.

a =

(ΣNi=1yixi

)− bNx

(ΣNi=1x

2i )

2. Use the matrix algebra approach to solve for the slope of a line, if the inter-cept b is known. You should obtain the same result as problem 1 above.

3. The Arrhenius rate expression is used to find reaction rate constants as afunction of temperature:

k = A exp (−E/RT )

Taking the natural log (ln) of each side of the Arrhenius rate expression, wefind:

ln k = lnA− (E/R)(1/T )

where R is the ideal gas constant (1.987 cal/gmol K). Linear regressionanalysis can be used to find A and E. Rate constants as a function oftemperature for a first-order decomposition of benzene diazonium chlorideare shown below1: Find A and E using least squares analysis (show units).

k,min−1 0.026 0.062 0.108 0.213 0.43T,K 313 319 323 328 333

Show that polyfit and the matrix algebra approach (M3.24) yield the sameresults. Compare model and experiment by (i) plotting ln k versus 1/T and(ii)k versus T

4. The Arrhenius rate expression is used to find rate constants as a functionof temperature:

k = A exp (−E/RT )

1This data is from Example 3.1 in Fogler, I-LS. (1992). Elements of Chemical Reaction Engi-neering, 2nd ed. Englewood Cliffs, NJ: Prentice Hall.

Page 115: Computer Aided Process Design and Simulation · Use the explicit Euler method to predict the behaviour of this reactor up to time equal 100s to four significant figures accuracy

5.2. STUDENT EXERCISE – 2 115

Taking the natural log (ln) of each side of the Arrhenius rate expression, wefind:

ln k = lnA− (E/R)(1/T )

Linear regression analysis call be used to find A and E. Rate constants as afunction of temperature for a first-order reaction arc shown below:

k,min−1 0.0014 0.026 0.0047 0.0083 0.014 0.023 0.038 0.059 0.090T,K 300 310 320 330 340 350 360 370 380

Find A andE using least squares analysis (show units). Show that polyfitand the matrix algebra approach (M3.24) yield the same results. Comparemodel and experimental by (i) plotting ln k versus 1/T and (ii)k versus T .

5. The growth rate expression for a biochemical reaction, using a Monod model,is:

µ =µmaxx

km + x

where µ is the specific growth rate,µmax and km are parameters, and x is thesubstrate concentration. The growth rate relationship can be rearranged to:

(1/µ) = (1/µmax) + (km/µmax)(1/x)

Data for a particular reactor are shown below: Use linear regression to solve

µ, h−1 0.25 0.31 0.36 0.43 0.45 0.47 0.50 0.52x, g L−1 0.1 0.15 0.25 0.50 0.75 1.00 1.50 3.00

for the parameters (µmax and km). Show that polyfit and the matrix algebraapproach (M3.24) yield the same reslts.

6. The growth rate expression for a biochemical reaction, using a substrateinhibition model, is

µ =µmaxx

km + x+ k1x2

where µ is the specific growth rate, µmax and km are parameters, and x is thesubstrate concentration. The growth rate relationship can he rearranged to

(1/µ) = (k1/µmax)x+ (km/µmax)(1/x) + (1/µmax)

Page 116: Computer Aided Process Design and Simulation · Use the explicit Euler method to predict the behaviour of this reactor up to time equal 100s to four significant figures accuracy

116 CHAPTER 5. LABORATORY PRACTICE WITH MATLAB

µ, h−1 0.24 0.27 0.34 0.35 0.35 0.34 0.33 0.22x, g L−1 0.1 0.15 0.25 0.50 0.75 1.00 1.50 3.00

Data for a particular reactor are shown below.

Use linear regression (M3.24) to solve for the parameters (µmax, km and k1).

Note that:

Y =

1/µ(1)1/µ(2)

...1/µ(8)

Φ =

x(1) 1/x(1) 1x(2) 1/x(2) 1

......

...x(8) 1/x(8) 1

θ =

k1/µmaxkm/µmax1/µmax

and the solution is

θ = (ΦTΦ)−1ΦTY

Compare the model and experimental by plotting µ versus x

Reference:

B. W. Bequette, Process Dynamics, Modeling, Analysis and Simulation, Print-ice Hall, New Jersey, 1998, pp 461 – 464.

Page 117: Computer Aided Process Design and Simulation · Use the explicit Euler method to predict the behaviour of this reactor up to time equal 100s to four significant figures accuracy

5.3. STUDENT EXERCISE – 3: EQUATION OF STATE 117

5.3 Student Exercise – 3: Equation of State

Note: Group wise assignment

5.3.1 Van der Waal’s EOS

Van der Waals equation (1873)

p =RT

V − b− a

V 2

where

a =27R2T 2

c

64Pc

and

b =RTc8Pc

This was the first equation of state to describe the properties of fluids over awide pressure range. It predicts the existence of a critical point, and also thatliquids exist. While it is an improvement on the Ideal Gas law, it is still notparticularly accurate.

5.3.2 Redlich Kwong EOS

Redlich-Kwong equation (1949)

P =RT

V − b− a

T 0.5V (V + b)

where

a = 0.42748R2T 2.5

c

Pc

and

b = 0.08664RTcPc

Page 118: Computer Aided Process Design and Simulation · Use the explicit Euler method to predict the behaviour of this reactor up to time equal 100s to four significant figures accuracy

118 CHAPTER 5. LABORATORY PRACTICE WITH MATLAB

In this equation of state, the parameter a in the van der Waals equation wasgiven a square root of T dependence, and the denominator of the second termwas given a small b dependence. The result is an equation of state that is quiteaccurate for predicting molar volumes of pure substances. However, calculationsof the properties of mixtures and predictions of vapour-liquid equilibrium usingthis model are not particularly accurate

5.3.3 Soave Redlich Kwong EOS

Soave-Redlich-Kwong equation (1972)

P =RT

V − b− a

V (V + b)

where

a = 0.42748R2TcPc

[1 + (0.480 + 1.574ω − 0.176ω2)

([1−

√T

Tc

)]2

andb = 0.08664

RTcPc

Soave proposed a modification to the Redlich-Kwong equation of state to over-come some of its limitations. Essentially, the parameter a is given a more compli-cated temperature dependence than that assumed in the Redlich-Kwong equa-tion. The parameters giving the dependence of a on ω were found by fitting ex-perimental data on a variety of compounds to the equation.

This equation is still frequently used for predicting the properties of pure sub-stances, mixtures and vapour-liquid equilibrum. It is not expected to be accuratefor highly polar species or molecules that exhibit hydrogen bonding

5.3.4 Peng Robinson EOS

Peng-Robinson equation (1976)

P =RT

V − b− a

V (V + b) + b(V − b)

Page 119: Computer Aided Process Design and Simulation · Use the explicit Euler method to predict the behaviour of this reactor up to time equal 100s to four significant figures accuracy

5.3. STUDENT EXERCISE – 3: EQUATION OF STATE 119

a = 0.45724R2TcPC

[1 + (0.37464 + 1.5422ω − 0.2699ω2)

(1−

√T

Tc

)]2

b = 0.07780RTcPc

This equation of state is fairly similar to the Soave-Redlich-Kwong equation,but with a slightly different denominator for the second term. Again, the parame-ter a has a temperature dependence, and the parameters giving its dependence ωhave been found by comparing the predictions of the equation with experimentalboiling points.

The Peng-Robinson equation is particularly accurate for predicting the prop-erties of hydrocarbons, including the behaviour of mixtures and vapour-liquidequilibrium. It is not expected to be accurate when predicting properties of highlypolar molecules, particularly those that are capable of hydrogen bonding.

5.3.5 Peng Robinson Gasem EOS

Peng-Robinson-Gasem equation (2001)

There have been many suggested improvements to the temperature depen-dence function of the parameter a in the Peng-Robinson equation (e.g. those ofMathias, Mathias-Copeman, and Twu and co-workers). The version included inthis program is the temperature dependence of Gasem, Gao, Pan & Robinsondescribed in Fluid Phase Equilibria, 181, 113-125 (2001). The function is:

P =RT

V − b− a

V (V + b) + b(V − b)

where

a = 0.45724R2T 2

c

Pcexp

[{2.00 + 0.836

T

Tc

}{1−

(T

Tc

)0.134+0.508ω−0.046ω2}]

andb = 0.07780

RTcPc

This equation is one of the best equations of state that require just three inputparameters (Tc, Pc, and ω). It is more accurate for heavy hydrocarbons and works

Page 120: Computer Aided Process Design and Simulation · Use the explicit Euler method to predict the behaviour of this reactor up to time equal 100s to four significant figures accuracy

120 CHAPTER 5. LABORATORY PRACTICE WITH MATLAB

better at temperatures above the critical point than the normal Peng-Robinsonequation. Note, though, that it isn’t necessarily better than the SRK or PR equa-tion for light hydrocarbons, and may even perform worse than them in somecases. Also, it is still not expected to be particularly accurate when predictingproperties of highly polar molecules, particularly those that are capable of hydro-gen bonding.

More sophisticated equations of state may be required for good predictions ofthe properties of polar molecules over a wide range of conditions (e.g. those ofPatel & Teja or Stryjek & Vera). These equations, however, normally require morethan three input parameters in their formulation.

5.3.6 Beattie-Bridgeman EOS

The Bettie-Bridgeman equation of state is expressed as

PV =

(RT +

β

V+

γ

V 2+

δ

V 3

)where β = RTB0 − A0 −RC/T 2

γ = −RTB0b+ aA0 −RB0C/T2

δ = RB0bc/T2

R is gas constant (0.082 06 atm L K−1 gmol−1)

T = temperature K

P = pressure atm

V = volume L

The constants A0, B0, a, b, c are available from physical property table 2 for anumber of common gases. For isobutane the values are A0 = 16.6037, B0 = 0.2354,a = 0.11171, b = 0.07697, c = 300× 104

For particular values of temperature T and pressure P the value of the spe-cific volume V cannot be obtained explicitly from this equation, it would requireiterations to converge on the correct solution.

2E. J. Henley and E. M. Rosen, Material and Energy Balance computation, 1969, Wiley, NY

Page 121: Computer Aided Process Design and Simulation · Use the explicit Euler method to predict the behaviour of this reactor up to time equal 100s to four significant figures accuracy

5.3. STUDENT EXERCISE – 3: EQUATION OF STATE 121

Rearrange the equation and use fsolve command in MATLAB.

Problem:

Estimate the fugacity of N2 at 25 ◦C and 800atm pressure using Bettie-Bridgemanequation of state.

Solution: For a pure component, the fugacity f is given by

ln

(f

P

)=

∫ P

0

(z − 1)

PdP

where z is the compressibility factor (P v/RT ), P is the pressure, R is the gasconstant, T is the absolute temperature, and v is the specific volume.

Another form of Battie-Bridgeman equation of state, i.e.,

P =RT (1− ε)

v2(v +B)− A

v2

where

A = A0(1− a/v)

B = B0(1− b/v)

ε = c/vT 3

and for N2the constants are A0 = 136.2315, a =0.02617, B0 =0.05046, b =-0.00691, c = 4.2× 104. In order to evaluate fugacity coefficient, we must evaluatethe integral of constant temperatureof

z − 1

P

where z = P v/RT . Rearranging the equation of state yields

z =(1− ε)v

(v +B)− A

RT v

using fsolve command we can find v and then estimate z.

Page 122: Computer Aided Process Design and Simulation · Use the explicit Euler method to predict the behaviour of this reactor up to time equal 100s to four significant figures accuracy

122 CHAPTER 5. LABORATORY PRACTICE WITH MATLAB

5.3.7 Benedict-Webb-Rubin EOS

The Benedict-Webb-Rubin equation of state is expressed as

Pv = RT +β

v+σ

v2+

ζ

v4+ω

v5

where β = RTB0 − A0 − C0/T2

σ = RTb− a2 + (c/T 2)e−y/v2

ζ = cye−y/v2/T 2

ω = aα

R is gas constant 0.082 06 atm L K−1 gmol−1

T = temperature K

P = pressure atm

V = volume L

The constants A0, B0, C0, a, b, c, α, γ are available from physical propertytable for a number of common gases. For isobutane the values are A0 = 10.2326,B0 = 0.137544, C0 = 0.84994, a = 1.9376, b = 0.042435, c = 0.286× 106, α = 1.0741× 10−3,γ = 3.4× 10−2

For particular values of temperature T and pressure P the value of the spe-cific volume V cannot be obtained explicitly from this equation, it would requireiterations to converge on the correct solution.

Rearrange the equation and use fsolve command in MATLAB.

ASSIGNMENT:

1. Group (Food Stream): Each batch of students will develop a Matlab programto plot isotherms with one EOS for CO2, O2 and N2

2. Group (Environment Stream): Each batch of students will develop a Matlabprogram to plot isotherms with one EOS for ETHANOL, PROPANOL andISOPROPANOL

3. Group 1 (Process): Each batch of students will develop a Matlab program toplot isotherms with one EOS for METHANE, ETHANE and PROPANE

Page 123: Computer Aided Process Design and Simulation · Use the explicit Euler method to predict the behaviour of this reactor up to time equal 100s to four significant figures accuracy

5.3. STUDENT EXERCISE – 3: EQUATION OF STATE 123

4. Group 2 (Process): Each batch of students will develop a Matlab program toplot isotherms with one EOS for n-BUTANE, ISOBUTANE and n-PENTANE

Reference:

[1] Reid,R.C., Prausnitz,J.M., and Sherwood, T.K., API Technical Data Book(extant 1988), The Properties of Liquids and Gases , 3rd Edition,Mcgraw-Hill,New York (1977)

[2] Perry’s Chemical Engineering Handbook, McGraw Hills, NY

[3] Zakia Nasri and Housam Binous, Applications of the Peng-Robinson Equa-tion of State using MATLAB, Chemical Engineering Education, Vol. 43, No. 2,Spring 2009.

[4] Roger G. E. Franks, Modeling and Simulation in Chemical Engineering,Wiley-Interscience, Wiley & Sons, Inc, NY, 1972.

[5] James B. Riggs, An Introduction to Numerical Methods for Chemical Engi-neers, Texas Tech University Press, 1988.

Page 124: Computer Aided Process Design and Simulation · Use the explicit Euler method to predict the behaviour of this reactor up to time equal 100s to four significant figures accuracy

124 CHAPTER 5. LABORATORY PRACTICE WITH MATLAB

5.4 Student Exercise – 4: Differential Equations

Note: Group wise assignment

5.4.1 Solving First Order Differential Equations

Though MATLAB is primarily a numerics package, it can certainly solve straight-forward differential equations symbolically. Suppose, for example, that we wantto solve the first order differential equation

y′(x) = xy

We can use MATLAB’s built-in dsolve(). The input and output for solving thisproblem in MATLAB is given below.

� y = dsolve(′Dy = y ∗ x′,′ x′)

y = C1 ∗ exp(1/2 ∗ x2)

Notice in particular that MATLAB uses capital D to indicate the derivative andrequires that the entire equation appear in single quotes. MATLAB takes t to bethe independent variable by default, so here x must be explicitly specified as theindependent variable. Alternatively, if you are going to use the same equation anumber of times, you might choose to define it as a variable, say, eqn1.

� eqn1 =′ Dy = y ∗ x′

eqn1 = Dy = y ∗ x

� y = dsolve(eqn1,′ x′)

y = C1 ∗ exp(1/2 ∗ x2)

To solve an initial value problem, with y(1) = 1, use

� y = dsolve(eqn1,′ y(1) = 1′,′ x′)

y = 1/exp(1/2) ∗ exp(1/2 ∗ x2)

or� inits =′ y(1) = 1′; � y = dsolve(eqn1, inits,′ x′)

Page 125: Computer Aided Process Design and Simulation · Use the explicit Euler method to predict the behaviour of this reactor up to time equal 100s to four significant figures accuracy

5.4. STUDENT EXERCISE – 4: DIFFERENTIAL EQUATIONS 125

y = 1/exp(1/2) ∗ exp(1/2 ∗ x2)

Now that we have solved the ODE, suppose we want to plot the solution to get arough idea of its behavior. We run immediately into two minor difficulties: (1) ourexpression for y(x) isn’t suited for array operations (.*, ./, .), and (2) y, as MATLABreturns it, is actually a symbol (a symbolic object). The first of these obstaclesis straightforward to fix, using vectorize(). For the second, we employ the usefulcommand eval(), which evaluates or executes text strings that constitute validMATLAB commands. Hence, we can use

� x = linspace(0, 1, 20);

z = eval(vectorize(y));

� plot(x, z)

You may notice a subtle point here, that eval() evaluates strings (character ar-rays), and y, as we have defined it, is a symbolic object. However, vectorizeconverts symbolic objects into strings.

5.4.2 Solving Second and Higher Order Differential Equations

Suppose we want to solve and plot the solution to the second order equation

y′′(x) + 8y′(x) + 2y(x) = cos(x) ; y(0) = 0, y′(0) = 1

The following (more or less self-explanatory) MATLAB code suffices:

� eqn2 =′ D2y + 8 ∗Dy + 2 ∗ y = cos(x)′;

� inits2 =′ y(0) = 0, Dy(0) = 1′;

� y = dsolve(eqn2, inits2,′ x′)

y = 1/65∗cos(x)+8/65∗sin(x)+(−1/130+53/1820∗14(1/2))∗exp((−4+14(1/2))∗x)−1/1820∗(53+14(1/2))∗14(1/2)∗exp(−(4+14(1/2))∗x)

� z = eval(vectorize(y));

� plot(x, z)

Page 126: Computer Aided Process Design and Simulation · Use the explicit Euler method to predict the behaviour of this reactor up to time equal 100s to four significant figures accuracy

126 CHAPTER 5. LABORATORY PRACTICE WITH MATLAB

>>eqn2 = ’D2y + 8*Dy + 2*y = cos(x)’;>>inits2 = ’y(0)=0, Dy(0)=1’;>>y=dsolve(eqn2,inits2,’x’)y =1/65*cos(x)+8/65*sin(x)+(-1/130+53/1820*14^(1/2))

*exp((-4+14^(1/2))*x)-1/1820*(53+14^(1/2))*14^(1/2)

*exp(-(4+14^(1/2))*x)>>z = eval(vectorize(y));>>plot(x,z)

5.4.3 Solving System of Differental Equations

Suppose we want to solve and plot solutions to the system of three ordinarydifferential equations

x′(t) = x(t) + 2y(t)z(t)

y′(t) = x(t) + z(t)

z′(t) = 4x(t)− 4y(t) + 5z(t)

First, to find a general solution, we proceed as in Section, except with each equa-tion now braced in its own pair of (single) quotation marks:

>>[x,y,z]=dsolve(’Dx=x+2*y-z’,’Dy=x+z’,’Dz=4*x-4*y+5*z’)x =2*C1*exp(2*t)-2*C1*exp(t)C2*exp(3*t)+2*C2

*exp(2*t)-1/2*C3*exp(3*t)+1/2*C3*exp(t)y =2*C1*exp(t)-C1*exp(2*t)+C2*exp(3*t)-C2*exp(2*t)+1/2*C3*exp(3*t)-1/2*C3*exp(t)z =-4*C1*exp(2*t)+4*C1*exp(t)+4*C2*exp(3*t)-4*C2*exp(2*t)-C3*exp(t)+2*C3*exp(3*t)

(If you use MATLAB to check your work, keep in mind that its choice of constantsC1, C2, and C3 probably won’t correspond with your own. For example, youmight haveC = 2C1 + 1/2C3, so that the coefficients of exp(t) in the expressionfor x are combined. Fortunately, there is no such ambiguity when initial values

Page 127: Computer Aided Process Design and Simulation · Use the explicit Euler method to predict the behaviour of this reactor up to time equal 100s to four significant figures accuracy

5.4. STUDENT EXERCISE – 4: DIFFERENTIAL EQUATIONS 127

are assigned.) Notice that since no independent variable was specified, MATLABused its default, t. For an example in which the independent variable is specified.To solve an initial value problem, we simply define a set of initial values and addthem at the end of our dsolve() command. Suppose we have x(0) = 1, y(0) = 2,and z(0) = 3. We have, then,

>>inits=’x(0)=1,y(0)=2,z(0)=3’;>>[x,y,z]=dsolve(’Dx=x+2*y-z’,’Dy=x+z’,’Dz=4*x-4*y+5*z’,inits)x =6*exp(2*t)-5/2*exp(t)-5/2*exp(3*t)y =5/2*exp(t)-3*exp(2*t)+5/2*exp(3*t)z =-12*exp(2*t)+5*exp(t)+10*exp(3*t)

Finally, plotting this solution can be accomplished as,

>>t=linspace(0,.5,25);>>xx=eval(vectorize(x));>>yy=eval(vectorize(y));>>zz=eval(vectorize(z));>>plot(t, xx, t, yy, t, zz)

The figure resulting from these commands is included as Figure

ASSIGNMENT:

Solve the following set of differential equations:

1.dy1

dx= −0.04y1 + y2y3

dy2

dx= 0.04y1 − y2y3 − 3y2

2

dy3

dx= 3y2

2

Where,y1 = 1, y2 = y3 = 0, at x = 0

Integrate this system of ODE’s to x = 10 using MATLAB Commands 3

3James B. Riggs, An Introduction to Numerical Methods for Chemical Engineers, Texas TechUniversity Press, 1988

Page 128: Computer Aided Process Design and Simulation · Use the explicit Euler method to predict the behaviour of this reactor up to time equal 100s to four significant figures accuracy

128 CHAPTER 5. LABORATORY PRACTICE WITH MATLAB

2.dy1

dx= −0.04y1 + 104y2y3

dy2

dx= 0.04y1 − 104y2y3 − 3× 107y2

2

dy3

dx= 3× 107y2

2

Where,y1 = 1, y2 = y3 = 0, at x = 0

Integrate this system of ODE’s to x = 10 using MATLAB Commands

3. Group (Food Stream): Each batch of students will develop a Matlab programto solve the ode of First order, Second order and Higher order using thecommand dsolve and generate necessary plots and submit on the same day

4. Group (Environment Stream): Each batch of students will develop a Matlabprogram to solve the ode of First order, Second order and Higher order usingthe command dsolve and generate necessary plots and submit on the sameday

5. Group 1 (Process): Each batch of students will develop a Matlab programto solve the ode of First order, Second order and Higher order using thecommand dsolve and generate necessary plots and submit on the same day

6. Group 2 (Process): Each batch of students will develop a Matlab programto solve the ode of First order, Second order and Higher order using thecommand dsolve and generate necessary plots and submit on the same day

Page 129: Computer Aided Process Design and Simulation · Use the explicit Euler method to predict the behaviour of this reactor up to time equal 100s to four significant figures accuracy

5.5. STUDENT EXERCISE – 5 129

5.5 Student Exercise – 5

1. Solve the following three equations :

3x1 − 2x2 + x3 = 32x1 + 4x2 − 2x3 = 24x1 − 2x2 − 3x3 = −12

2. Solve the following three equations :

2x2 − x3 = 32x1 − 3x2 + x3 = 13x1 − 2x2 + 5x3 = 10

3. Solve the following three equations :

3x1 − x2 + 3x3 = 25x1 + 3x2 + x3 = 6x1 − 2x2 − x3 = 2

4. Solve the following three equations :

x1 − x2 = 12x1 + x2 − 3x3 = 1

3x2 − 4x3 + 2x4 = 3x3 − 5x4 = 3

5. Solve with initial guess value for x = 1,

f(x) = x2ex − 1 = 0

6. Solve with initial guess value for x = 4,

f(x) = xex + x− 5ex − 5 = 0

7. Solve with initial guess value for x = 1,

f(x) =x2(6.76− 0.5x)

62.4× 106(1− 0.5x)(2− x)− 1 = 0

Page 130: Computer Aided Process Design and Simulation · Use the explicit Euler method to predict the behaviour of this reactor up to time equal 100s to four significant figures accuracy

130 CHAPTER 5. LABORATORY PRACTICE WITH MATLAB

8. Solvef(x) = x tanx− 1, if 0 < x < π/2

9. Solvef(x) = x3 − x− 4 = 0

10. Solve

161− 26018

v+ 4.249v7/4 + 1.5v2 = 0

11. Solve the ODE for y(0.3)

dy

dx= y exp (3x), y(0) = 1

12. Solve for y(0.5) the equation

dy

dx= xey, y(0) = 0

13. Solve for y(0.2) the following ODE

dy

dx=√xey, y(0) = 1

14. Solve the following function

dy

dx= −100x y(0) = 0

15. Determine y1 and y2 at x = 1 for the following set of first order ODE’s:

dy1

dx=

10y1y2 exp (y1/100)

1 + x2

dy2

dx=−y1y2 exp (y1/100)

1 + x2

where y1 = y2 = 1 at x = 0

Page 131: Computer Aided Process Design and Simulation · Use the explicit Euler method to predict the behaviour of this reactor up to time equal 100s to four significant figures accuracy

5.5. STUDENT EXERCISE – 5 131

16. Determine y1, y2 and y3 at x = 0.3 for the system of equations given below:

dy1

dx=xy1y2

y3

dy2

dx= x2 + y2

1 + y22 + y2

3

dy3

dx= (y1y2 + y2y3 + y1y3)x

where, y1 = y2 = y3 = 1, at x = 0.

17. Find the function y1 = f(x) and y2 = f(x) for the following equations

dy1

dx= y1y2 + 1

dy2

dx= y1y2 − 1

where, y1 = y2 = 0, at x = 0.

18. Solve the following equations

dy1

dx= −100000y1 + 0.1y2

dy2

dx= −0.1y1 − 0.1y2

where, y1 = y2 = 1 at x = 0

19. Solve the following simultaneous set of equations when t = 0, Y (0) = 1 andZ(0) = 1,

dY

dt= X2 − Y 2 + 3Z

dZ

dt= Y − 2Z +X

X = 5Z2 − Y + 6

20. Solve the set of non-linear equations, assuming suitable initial guess for x1

and x2,f1(x) = x2 + x2

2 − 36 = 0

f2(x) = x21 − 3x2 − 16 = 0

Page 132: Computer Aided Process Design and Simulation · Use the explicit Euler method to predict the behaviour of this reactor up to time equal 100s to four significant figures accuracy

132 CHAPTER 5. LABORATORY PRACTICE WITH MATLAB

21. Solve the following system of non-linear equations with inital guess x = (1, 1)

f(x) = 2x21 + 3x2

2 − 50

f(x) = 2x21 − x2 − 9 = 0

22. Solve the following system of non-linear equations with inital guess x = (0, 0)

f(x) = 5(x2 − x21)4 = 0

f(x) = (1− x1)2 = 0

23. Solve the following system of non-linear equations with inital guess x =(0, 0, 0)

x31 − ex2 + sinhx3 = 3.62882

x21x3 + (x2

2 − x3)2 = 4.0

x1x2x3 − x3 + x1x2 = 5

24. Using x = 1 as starting point find a root of the equation

f(x) = x2ex − 1 = 0

25. Using x = 4 as the initial guess, find the solution of equation

f(x) = xex + x− 5ex − 5

26. Solve the equationf(x) = xx − 2 = 0

27. Solve the equationf(x) = x2 − ex = 0, x(0) = 1

28. Find the specific volume of ammonia using Van der Waals equation of state(P +

a

V 2

)(V − b

)= RT

where P = 10atm T = 250 K R = 0.082 L atm gmol−1 K−1 a = 4.19 atm L2 gmol−2

b = 37.2× 10−3 L gmol−1

Page 133: Computer Aided Process Design and Simulation · Use the explicit Euler method to predict the behaviour of this reactor up to time equal 100s to four significant figures accuracy

5.5. STUDENT EXERCISE – 5 133

29. Consider an isothermal constant pressure batch reactor in which the fol-lowing reaction occurs:

A(g)k−−→ 2 P(g)

where −rA = 0.1C2A = gmol L−1 s−1. Initially, the reactor contains 0.01gmol of A

and 0.01gmol of an inert gas in a volume of 0.5 L. Derermine the volume ofreactor after 25 s of reacton. The prformance of this reactor is defined by anunsteady state mole balance of component A for the reactor, yielding

dnAdt

= V (−rA) = −0.1n2A

V

Assuming ideal gas law,

V = V0

(nTnT0

)= 0.5

(0.01 + nA + 2(0.01− nA)

0.02

)= 0.75− 25nA L

then,dnAdt

=−0.1n2

A

0.075− 25nA

where nA = 0.01 at t = 0. Integrate this equation to determine nA at t = 25 s.then deremine the volume of reactor.

30. The following reaction takes place in an isothermal reactor:

A + Bk1−−→←−−k2

C + D

C + Bk3−−→ E + F

Starting with 0.5 gmol L−1 of A and 0.7 gmol L−1 of B in a solvent, determinethe time required to achieve 80% conversion given

k1 = 15 600 L gmol−1 min−1

k2 = 5.2× 106 L gmol−1 min−1

k3 = 1.2 L gmol−1 min−1

Assume the rate expressions correspond to the stoichiometric relationships.

31. Consider the following equilibrium reactions

CH4 (g) + H2O (g)←−→ CO (g) + 3 H2 (g)

Page 134: Computer Aided Process Design and Simulation · Use the explicit Euler method to predict the behaviour of this reactor up to time equal 100s to four significant figures accuracy

134 CHAPTER 5. LABORATORY PRACTICE WITH MATLAB

CO (g) + H2O (g)←−→ CO2 (g) + H2 (g)

At 2000 K the equilibrium constants for these reactions are 1.930× 10−4 and5.528 respectively. Initially, a gas containing 20% CH4 (g) and 80% H2O (g) ispresent at 2000 K and 1atm pressure. Coose a basis of 10 mol of gas and lete1 equal the degree of reaction for the first reaction and e2 be the degree ofreaction for the second reaction. The equilibrium constants can be writtenas

K1 =YCOY

3H2P

YCH4YH2O

and K2 =YCO2YH2

YCOYH2O

The equilibrium mole fractions can be written as

YCO =e1 − e2

10 + 2e1

YH2 =3e1 + e2

10 + 2e1

YH2O =8− e1 − e2

10 + e1

YCO2 =e2

10 + 2e1

YCH4 =2− e1

10 + 2e1

On substituting these relationships into equilibrium constant expressions

(e1 − e2)(3e1 + e2)3

(2− e1)(8− e1 − e2)(10 + 2e1)2= 1.930× 10−4

e2(e3e1 + e2)

(e1 − e2)(8− e1 − e2)= 5.528

Solve the equilibrium gas composition for this system.

32. Consider the semi-batch reactor with the following reaction scheme:

Ak1←−→k2

Bk3−−→ C

r1 = k1C2A, k1 = 0.1

r2 = k2CB, k2 = 0.5

Page 135: Computer Aided Process Design and Simulation · Use the explicit Euler method to predict the behaviour of this reactor up to time equal 100s to four significant figures accuracy

5.5. STUDENT EXERCISE – 5 135

r3 = k3C2B, k3 = 0.05

Concentration is in gmol L−1. Determine the reaction time necessary to at-tain the maximum concentration of of the intermediate product B. Use thefollowing equations:

dnAdt

= Q0CA0 + VR(−r1 + r2)

dnBdt

= VR(r1 − r2 − r3)

dnCdt

= VR(r3)

∵ Ci =niVR

and VR = Q0t+ V0

the above equations become

dnAdt

= 10− 0.1n2A

50 + 10t+ 0.5nB

dnBdt

=0.1n2

A − 0.05n2B

50 + 10t− 0.05nB

dnCdt

=0.05n2

B

50 + 10t

where, nA = nB = nC = 0 at t = 0

33. Consider the following IV-PDE:

∂Y

∂t=∂2Y

∂x2+∂Y

∂x

whereY (x, 0) = 1, Y (0, t) = 1, Y (1, t) = 2

Determine Y (x, 0.1) using MATLAB pde solver

1. Solve the following three equations :

3x1 − 2x2 + x3 = 32x1 + 4x2 − 2x3 = 24x1 − 2x2 − 3x3 = −12

Page 136: Computer Aided Process Design and Simulation · Use the explicit Euler method to predict the behaviour of this reactor up to time equal 100s to four significant figures accuracy

136 CHAPTER 5. LABORATORY PRACTICE WITH MATLAB

2. Solve the following three equations :

2x2 − x3 = 32x1 − 3x2 + x3 = 13x1 − 2x2 + 5x3 = 10

3. Solve the following three equations :

3x1 − x2 + 3x3 = 25x1 + 3x2 + x3 = 6x1 − 2x2 − x3 = 2

4. Solve the following three equations :

x1 − x2 = 12x1 + x2 − 3x3 = 1

3x2 − 4x3 + 2x4 = 3x3 − 5x4 = 3

5. Solve with initial guess value for x = 1,

f(x) = x2ex − 1 = 0

6. Solve with initial guess value for x = 4,

f(x) = xex + x− 5ex − 5 = 0

7. Solve with initial guess value for x = 1,

f(x) =x2(6.76− 0.5x)

62.4× 106(1− 0.5x)(2− x)− 1 = 0

8. Solvef(x) = x tanx− 1, if 0 < x < π/2

9. Solvef(x) = x3 − x− 4 = 0

Page 137: Computer Aided Process Design and Simulation · Use the explicit Euler method to predict the behaviour of this reactor up to time equal 100s to four significant figures accuracy

5.5. STUDENT EXERCISE – 5 137

10. Solve161− 26018

v+ 4.249v7/4 + 1.5v2 = 0

11. Solve the ODE for y(0.3)

dy

dx= y exp (3x), y(0) = 1

12. Solve for y(0.5) the equation

dy

dx= xey, y(0) = 0

13. Solve for y(0.2) the following ODE

dy

dx=√xey, y(0) = 1

14. Solve the following function

dy

dx= −100x y(0) = 0

15. Determine y1 and y2 at x = 1 for the following set of first order ODE’s:

dy1

dx=

10y1y2 exp (y1/100)

1 + x2

dy2

dx=−y1y2 exp (y1/100)

1 + x2

where y1 = y2 = 1 at x = 0

16. Determine y1, y2 and y3 at x = 0.3 for the system of equations given below:

dy1

dx=xy1y2

y3

dy2

dx= x2 + y2

1 + y22 + y2

3

dy3

dx= (y1y2 + y2y3 + y1y3)x

where, y1 = y2 = y3 = 1, at x = 0.

Page 138: Computer Aided Process Design and Simulation · Use the explicit Euler method to predict the behaviour of this reactor up to time equal 100s to four significant figures accuracy

138 CHAPTER 5. LABORATORY PRACTICE WITH MATLAB

17. Find the function y1 = f(x) and y2 = f(x) for the following equations

dy1

dx= y1y2 + 1

dy2

dx= y1y2 − 1

where, y1 = y2 = 0, at x = 0.

18. Solve the following equations

dy1

dx= −100000y1 + 0.1y2

dy2

dx= −0.1y1 − 0.1y2

where, y1 = y2 = 1 at x = 0

19. Solve the following simultaneous set of equations when t = 0, Y (0) = 1 andZ(0) = 1,

dY

dt= X2 − Y 2 + 3Z

dZ

dt= Y − 2Z +X

X = 5Z2 − Y + 6

20. Solve the set of non-linear equations, assuming suitable initial guess for x1

and x2,f1(x) = x2 + x2

2 − 36 = 0

f2(x) = x21 − 3x2 − 16 = 0

21. Solve the following system of non-linear equations with inital guess x = (1, 1)

f(x) = 2x21 + 3x2

2 − 50

f(x) = 2x21 − x2 − 9 = 0

22. Solve the following system of non-linear equations with inital guess x = (0, 0)

f(x) = 5(x2 − x21)4 = 0

f(x) = (1− x1)2 = 0

Page 139: Computer Aided Process Design and Simulation · Use the explicit Euler method to predict the behaviour of this reactor up to time equal 100s to four significant figures accuracy

5.5. STUDENT EXERCISE – 5 139

23. Solve the following system of non-linear equations with inital guess x =(0, 0, 0)

x31 − ex2 + sinhx3 = 3.62882

x21x3 + (x2

2 − x3)2 = 4.0

x1x2x3 − x3 + x1x2 = 5

24. Using x = 1 as starting point find a root of the equation

f(x) = x2ex − 1 = 0

25. Using x = 4 as the initial guess, find the solution of equation

f(x) = xex + x− 5ex − 5

26. Solve the equationf(x) = xx − 2 = 0

27. Solve the equationf(x) = x2 − ex = 0, x(0) = 1

28. Find the specific volume of ammonia using Van der Waals equation of state(P +

a

V 2

)(V − b

)= RT

where P = 10atm T = 250 K R = 0.082 L atm gmol−1 K−1 a = 4.19 atm L2 gmol−2

b = 37.2× 10−3 L gmol−1

29. Consider an isothermal constant pressure batch reactor in which the fol-lowing reaction occurs:

A(g)k−−→ 2 P(g)

where −rA = 0.1C2A = gmol L−1 s−1. Initially, the reactor contains 0.01gmol of A

and 0.01gmol of an inert gas in a volume of 0.5 L. Derermine the volume ofreactor after 25 s of reacton. The prformance of this reactor is defined by anunsteady state mole balance of component A for the reactor, yielding

dnAdt

= V (−rA) = −0.1n2A

V

Page 140: Computer Aided Process Design and Simulation · Use the explicit Euler method to predict the behaviour of this reactor up to time equal 100s to four significant figures accuracy

140 CHAPTER 5. LABORATORY PRACTICE WITH MATLAB

Assuming ideal gas law,

V = V0

(nTnT0

)= 0.5

(0.01 + nA + 2(0.01− nA)

0.02

)= 0.75− 25nA L

then,dnAdt

=−0.1n2

A

0.075− 25nA

where nA = 0.01 at t = 0. Integrate this equation to determine nA at t = 25 s.then deremine the volume of reactor.

30. The following reaction takes place in an isothermal reactor:

A + Bk1−−→←−−k2

C + D

C + Bk3−−→ E + F

Starting with 0.5 gmol L−1 of A and 0.7 gmol L−1 of B in a solvent, determinethe time required to achieve 80% conversion given

k1 = 15 600 L gmol−1 min−1

k2 = 5.2× 106 L gmol−1 min−1

k3 = 1.2 L gmol−1 min−1

Assume the rate expressions correspond to the stoichiometric relationships.

31. Consider the following equilibrium reactions

CH4 (g) + H2O (g)←−→ CO (g) + 3 H2 (g)

CO (g) + H2O (g)←−→ CO2 (g) + H2 (g)

At 2000 K the equilibrium constants for these reactions are 1.930× 10−4 and5.528 respectively. Initially, a gas containing 20% CH4 (g) and 80% H2O (g) ispresent at 2000 K and 1atm pressure. Coose a basis of 10 mol of gas and lete1 equal the degree of reaction for the first reaction and e2 be the degree ofreaction for the second reaction. The equilibrium constants can be writtenas

K1 =YCOY

3H2P

YCH4YH2O

and K2 =YCO2YH2

YCOYH2O

Page 141: Computer Aided Process Design and Simulation · Use the explicit Euler method to predict the behaviour of this reactor up to time equal 100s to four significant figures accuracy

5.5. STUDENT EXERCISE – 5 141

The equilibrium mole fractions can be written as

YCO =e1 − e2

10 + 2e1

YH2 =3e1 + e2

10 + 2e1

YH2O =8− e1 − e2

10 + e1

YCO2 =e2

10 + 2e1

YCH4 =2− e1

10 + 2e1

On substituting these relationships into equilibrium constant expressions

(e1 − e2)(3e1 + e2)3

(2− e1)(8− e1 − e2)(10 + 2e1)2= 1.930× 10−4

e2(e3e1 + e2)

(e1 − e2)(8− e1 − e2)= 5.528

Solve the equilibrium gas composition for this system.

32. Consider the semi-batch reactor with the following reaction scheme:

Ak1←−→k2

Bk3−−→ C

r1 = k1C2A, k1 = 0.1

r2 = k2CB, k2 = 0.5

r3 = k3C2B, k3 = 0.05

Concentration is in gmol L−1. Determine the reaction time necessary to at-tain the maximum concentration of of the intermediate product B. Use thefollowing equations:

dnAdt

= Q0CA0 + VR(−r1 + r2)

dnBdt

= VR(r1 − r2 − r3)

Page 142: Computer Aided Process Design and Simulation · Use the explicit Euler method to predict the behaviour of this reactor up to time equal 100s to four significant figures accuracy

142 CHAPTER 5. LABORATORY PRACTICE WITH MATLAB

dnCdt

= VR(r3)

∵ Ci =niVR

and VR = Q0t+ V0

the above equations become

dnAdt

= 10− 0.1n2A

50 + 10t+ 0.5nB

dnBdt

=0.1n2

A − 0.05n2B

50 + 10t− 0.05nB

dnCdt

=0.05n2

B

50 + 10t

where, nA = nB = nC = 0 at t = 0

33. Consider the following IV-PDE:

∂Y

∂t=∂2Y

∂x2+∂Y

∂x

whereY (x, 0) = 1, Y (0, t) = 1, Y (1, t) = 2

Determine Y (x, 0.1) using MATLAB pde solver

Page 143: Computer Aided Process Design and Simulation · Use the explicit Euler method to predict the behaviour of this reactor up to time equal 100s to four significant figures accuracy

Chapter 6

Projects

Each team of 5-in-1 learning will identify/ chose a process engineering projectbased on the following:

1. Process simulation using simulation software such as ChemSep, ChemCAD,ASPEN

2. Develop MATLAB codes for simulation as mentioned above - students cantry to rewrite codes developed on other programing languages

3. Develop Progam on process equipment design using MATLAB

Choose the title of project and proceed with the structure as:

• Project Title

• Statement of Problem

• Literature resources

• Software Selection

• Details of input, output and other process variables

• Phisco chemical data used

• Program Code or the simulation flow sheet

143

Page 144: Computer Aided Process Design and Simulation · Use the explicit Euler method to predict the behaviour of this reactor up to time equal 100s to four significant figures accuracy

144 CHAPTER 6. PROJECTS

• Presentation of output as table, graph

• Conclusion

• reference

Tentative Project Titles

1. Gravity flow tank simulation

2. Multiple CSTR in series simulation

3. Non isothermal CSTR Simulation

4. Binary Distillation column simulation Program

5. Ternary Batch distillation with holdup

6. Multicomponent Dynamic simulation

7. Variable pressure column simulation

8. Simulation of Batch Reactor

9. Simulation of columns for Multicomponent distillation simulation using Chem-Sep software

10. Simulation of process plant with major unit operations using ASPEN simu-lation software

• Grinding and size separation

• Reactors and separators

• Multicomponent distillation

• Crystellaizers and centrifuge

• Adsorption columns

• Simulation of Benzene Production Process

• Simulation Toluene Production

• Simulation of Xylene Plant

• Simulation of Ethylbenzene Process

Page 145: Computer Aided Process Design and Simulation · Use the explicit Euler method to predict the behaviour of this reactor up to time equal 100s to four significant figures accuracy

145

• Simulation of Styrene Process

• Simulation of polymerization Process: Polystyrene Plant

• Simulation of Cumene Manufacturing Plant

• Simulation of Phenol Synthesis

• Simulation of Acetone Manufacture

• Simulation of Bisphenol A Production process

• Simulation of Terephthalic acid (TPA)

• Simulation of Dimethyl terephthalate (DMT)

• Simulation Pththalic anhydride Reactor

• Simulation of Cyclohexane Plant

• Simulation of Caprolactam and Nylons

• Simulation of Azeotropic Distillation of Ethanol-Water system UsingTernary component

• Simulation of Separation of Isomers

• Simulation of Packed Bed Distillation

Page 146: Computer Aided Process Design and Simulation · Use the explicit Euler method to predict the behaviour of this reactor up to time equal 100s to four significant figures accuracy

146 CHAPTER 6. PROJECTS

Page 147: Computer Aided Process Design and Simulation · Use the explicit Euler method to predict the behaviour of this reactor up to time equal 100s to four significant figures accuracy

Appendices

147

Page 148: Computer Aided Process Design and Simulation · Use the explicit Euler method to predict the behaviour of this reactor up to time equal 100s to four significant figures accuracy
Page 149: Computer Aided Process Design and Simulation · Use the explicit Euler method to predict the behaviour of this reactor up to time equal 100s to four significant figures accuracy

149

Appendix MATLAB COMMANDS

Table 6.1: Commands for Managing a SessionCommand Actionclc Clears Command window.clear Removes variables from memory.exist Checks for existence of file or variable.global Declares variables to be global.help Searches for a help topic.lookfor Searches help entries for a keyword.quit Stops MATLAB.who Lists current variables.whos Lists current variables (long display).

Page 150: Computer Aided Process Design and Simulation · Use the explicit Euler method to predict the behaviour of this reactor up to time equal 100s to four significant figures accuracy

150

Table 6.2: Operators and Special Characters+ Plus addition operator- Minus subtraction operator* Scalar and matrix multiplication op-

erator.* Array multiplication operatorˆ Scalar and matrix exponentiation op-

erator: Colon generates regularly spaced elements

and represents an entire row or col-umn

( ) Parentheses; encloses function argu-ments and array indices; overridesprecedence

Brackets enclosures array elements. Decimal point. . . Ellipsis; line-continuation operator, Comma separates statements and elements

in a row; Semicolon separates columns and suppresses

display% Percent sign designates a comment and specifies

formatting= Assignment (replacement) operator

Table 6.3: Special Variables and Constantsans Most recent answereps Accuracy of floating-point precisioni,j The imaginary unit -1Inf InfinityNaN Undefined numerical result (not a number)pi The number π

Page 151: Computer Aided Process Design and Simulation · Use the explicit Euler method to predict the behaviour of this reactor up to time equal 100s to four significant figures accuracy

151

Table 6.4: System and File Commandscd Changes current directorydate Displays current datedelete Deletes a filediary Switches on/off diary file recordingdir Lists all files in current directoryload Loads workspace variables from a filepath Displays search pathpwd Displays current directorysave Saves workspace variables in a filetype Displays contents of a filewhat Lists all MATLAB files in the current directorywklread Reads .wk1 spreadsheet file

Page 152: Computer Aided Process Design and Simulation · Use the explicit Euler method to predict the behaviour of this reactor up to time equal 100s to four significant figures accuracy

152

Table 6.5: Input/Output and Formatting CommandsInput/Output Commands

disp Displays contents of an array or stringfscanf Read formatted data from a fileformat Controls screen-display formatfprintf Performs formatted writes to screen or fileinput Displays prompts and waits for input; Suppresses screen printing

Format Codes for fprintf and fscanf%s Format as a string%d Format as an integer%f Format as a floating point value%e Format as a floating point value in scientific notation%g Format in the most compact form: %f or %en Insert a new line in the output stringt Insert a tab in the output string

Numeric Display Formatsformat short Four decimal digits (default)format long 16 decimal digitsformat short e Five digits plus exponentformat long e 16 digits plus exponentsformat bank Two decimal digitsformat + Positive, negative, or zeroformat rat Rational approximationformat compact Suppresses some line feedsformat loose Resets to less compact display mode

Page 153: Computer Aided Process Design and Simulation · Use the explicit Euler method to predict the behaviour of this reactor up to time equal 100s to four significant figures accuracy

153

Table 6.6: Vector, Matrix and Array CommandsArray Commands

cat Concatenates arraysfind Finds indices of nonzero elementslength Computers number of elementslinspace Creates regularly spaced vectorlogspace Creates logarithmically spaced vectormax Returns largest elementmin Returns smallest elementprod Product of each columnreshape Change sizesize Computes array sizesort Sorts each columnsum Sums each column

Special Matriceseye Creates an identity matrixones Creates an array of oneszeros Creates an array of zeros

Matrix Arithmeticcross Computes cross productsdot Computes dot products

Matrix Commands for Solving Linear Equationsdet Computes determinant of an arrayinv Computes inverse of a matrixpinv Computes pseudoinverse of a matrixrank Computes rank of a matrixrref Computes reduced row echelon form

Cell Array Functionscell Creates cell arraycelldisp Displays cell arraycellplot Displays graphical representation of cell arraynum2cell Converts numeric array to cell arraydeal Matches input and output listsiscell Identifies cell array

Page 154: Computer Aided Process Design and Simulation · Use the explicit Euler method to predict the behaviour of this reactor up to time equal 100s to four significant figures accuracy

154

Table 6.7: Structure Functionsfieldnames Returns field names in a structure arraygetfield Returns field contents of a structure arrayisfield Identifies a structure array fieldisstruct Identifies a structure arrayrmfield Removes a field from a structure arraysetfield Sets contents of fieldstruct Creates structure array

Table 6.8: Colors, Symbols and Line TypesColor Symbol Line

y– yellow .– point -– solidm– magenta o–circle :– dotted

c– cyan x– x-mark -.– dash dottedr– red +– plus –– dashed

g– green *–star -b– blue d– diamond -

w– white v triangle (down) -black–black ˆ triangle (up) -

< triangle (left)> triangle (right)p– pentagramh– hexagram

Page 155: Computer Aided Process Design and Simulation · Use the explicit Euler method to predict the behaviour of this reactor up to time equal 100s to four significant figures accuracy

155

Table 6.9: Plotting CommandsBasic xy Plotting Commands

axis Sets axis limitsfplot Intelligent plotting of functionsgrid Displays gridlinesplot Generates xy plotprint Prints plot or saves plot to a filetitle Puts text at top of plotxlabel Adds text label to x-axisylabel Adds text label to y-axis

Plot Enhancement Commandsaxes Creates axes objectsclose Closes the current plotclose all Closes all plotsfigure Opens a new figure windowgtext Enables label placement by mousehold Freezes current plotlegend Legend placement by mouserefresh Redraws current figure windowset Specifies properties of objects such as axessubplot Creates plots in subwindowstext Places string in figure

Specialized Plot Commandsbar Creates bar chartloglog Creates log-log plotpolar Creates polar plotsemilogx Creates semilog plot (logarithmic abscissa)semilogy Creates semilog plot (logarithmic ordinate)stairs Creates stairs potstem Creates stem plot

Page 156: Computer Aided Process Design and Simulation · Use the explicit Euler method to predict the behaviour of this reactor up to time equal 100s to four significant figures accuracy

156

Table 6.10: Three-Dimensional Plotting Commandscontour Creates contour plotmesh Creates three-dimensional mesh surface plotmeshc Same as mesh with contour plot underneathmeshz Same as mesh with vertical lines underneathplot3 Creates three-dimensional plots from lines and pointssurf Creates shaded three-dimensional mesh surface plotsurfc Same as surf with contour plot underneathmeshgrid Creates rectangular gridwaterfall Same as mesh with mesh lines in one directionzlabel Adds text label to z-axis

Histogram Functionsbar Creates a bar charthist Aggregates the data into equally spaced binshistc Aggregates the data into unequally spaced bins

Page 157: Computer Aided Process Design and Simulation · Use the explicit Euler method to predict the behaviour of this reactor up to time equal 100s to four significant figures accuracy

157

Table 6.11: Programming

Logical and Relational Operators== Relational operator: equal to= Relational operator: not equal to< Relational operator: less than<= Relational operator: less than or equal to> Relational operator: greater than>= Relational operator: greater than or equal to& Logical operator: AND| Logical operator: OR

Logical operator: NOTxor Logical operator: EXCLUSIVE OR

Program Flow Controlbreak Terminates execution of a loopcase Provides alternate execution paths within switch structureelse Delineates alternate block of statementselseif Conditionally executes statementsend Terminates for, while, and if statementserror Display error messagesfor Repeats statements a specific number of timesif Executes statements conditionallyotherwise Default part of switch statementreturn Return to the invoking functionswitch Directs program execution by comparing point with case expressionswarning Display a warning messagewhile Repeats statements an indefinite number of times

Page 158: Computer Aided Process Design and Simulation · Use the explicit Euler method to predict the behaviour of this reactor up to time equal 100s to four significant figures accuracy

158

Table 6.12: Logical Functionsany True if any elements are nonzeroall True if all elements are nonzerofind Finds indices of nonzero elementsfinite True if elements are finiteisnan True if elements are undefinedisinf True if elements are infiniteisempty True if matrix is emptyisreal True if all elements are real

Table 6.13: M-Fileseval Interpret strings containing Matlab expressionsfeval Function evaluationfunction Creates a user-defined function M-fileglobal Define global variablesnargin Number of function input argumentsnargout Number of function output argumentsscript Script M-files

Table 6.14: Timingcputime CPU time in secondsclock Current date and time as date vectortic, toc Start, stop a stopwatch timer

Page 159: Computer Aided Process Design and Simulation · Use the explicit Euler method to predict the behaviour of this reactor up to time equal 100s to four significant figures accuracy

159

Table 6.15: Mathematical FunctionsExponential and Logarithmic Functions

exp(x) Exponential; exp(x)log(x) Natural logarithm; ln(x)log10(x) Common (base 10) logarithm;log(x) = log10(x)sqrt(x) Square root;

√x

Trigonometric Functionsacos(x) Inverse cosine; arccos(x)acot(x) Inverse cotangent; cot−1(x)acsc(x) Inverse cosecant; csc−1(x)asec(x) Inverse secant; sec−1(x)asin(x) Inverse sine; arcsin(x)atan(x) Inverse tangent; arctan(x)atan2(y,x) Four-quadrant inverse tangentcos(x) Cosine; cos(x)cot(x) Cotangent; cot(x)csc(x) Cosecant; csc(x)sec(x) Secant; sec(x)sin(x) Sine;sin(x)tan(x) Tangent; tan(x)

Hyperbolic Functionsacosh(x) Inverse hyperbolic cosine; cosh−1(x)acoth(x) Inverse hyperbolic cotangent; coth−1(x)acsch(x) Inverse hyperbolic cosecant; −1(x)asech(x) Inverse hyperbolic secant; −1(x)asinh(x) Inverse hyperbolic sine; sinh−1(x).atanh(x) Inverse hyperbolic tangent; tanh−1(x)cosh(x) Hyperbolic cosine;cosh(x)coth(x) Hyperbolic cotangent; cosh(x)/ sinh(x)csch(x) Hyperbolic cosecant; 1/ sinh(x)sech(x) Hyperbolic secant; 1/ cosh(x)sinh(x) Hyperbolic sine;sinh(x)tanh(x) Hyperbolic tangent; sinh(x)/ cosh(x)

Page 160: Computer Aided Process Design and Simulation · Use the explicit Euler method to predict the behaviour of this reactor up to time equal 100s to four significant figures accuracy

160

Table 6.16: Complex Functionsabs(x) Absolute value; xangle(x) Angle of a complex number xconj(x) Complex conjugate of ximag(x) Imaginary part of a complex number xreal(x) Real part of a complex number x

Table 6.17: Statistical Functionserf(x) Computes the error function (x)mean Calculates the averagemedian Calculates the medianstd Calculates the standard deviation

Table 6.18: Random Number Functionsrand Generates uniformly distributed random numbers between 0 and 1randn Generates normally distributed random numbers

Table 6.19: Numeric Functionsceil Rounds to the nearest integer toward .fix Rounds to the nearest integer toward zerofloor Rounds to the nearest integer toward .round Rounds towards the nearest integersign Signum function

Table 6.20: String Functionsfindstr Finds occurrences of a stringstrcmp Compares stringschar Creates character string array

Page 161: Computer Aided Process Design and Simulation · Use the explicit Euler method to predict the behaviour of this reactor up to time equal 100s to four significant figures accuracy

161

Table 6.21: Numerical MethodsPolynomial and Regression Functions

conv Computes product of two polynomialsdeconv Computes ratio of polynomialseig Computes the eigenvalues of a matrixpoly Computes polynomial from rootspolyfit Fits a polynomial to datapolyval Evaluates polynomial and generates error estimatesroots Computes polynomial roots

Interpolation Functionsinterp1 Linear and cubic-spline interpolations of a function of one variableinterp2 Linear interpolation of a function of two variablesspline Cubic-spline interpolationunmkpp Computes the coefficients of cubic-spine polynomials

Table 6.22: Root Finding and Minimizationfmin Finds minimum of single-variable functionfmins Finds minimum of multivariable functionfzero Finds zero of single-variable function

Table 6.23: Numerical Integration Functionsquad Numerical integration with adaptive Simpson’s rulequadl Numerical integration with adaptive Lobatto quadraturetrapz Numerical integration with the trapezoidal rule

Table 6.24: Numerical Differentiation Functions

diff(x) Computes the difference between adjacent elements in the vector xpolyder Differentiates a polynomial, a polynomial product, or a polynomial quotient

Page 162: Computer Aided Process Design and Simulation · Use the explicit Euler method to predict the behaviour of this reactor up to time equal 100s to four significant figures accuracy

162

Table 6.25: ODE Solversode23 Nonstiff, low-order solverode45 Nonstiff, medium-order solverode113 Nonstiff, variable-order solverode23s Stiff, low-orderode23t Moderately stiff, trapezoidal rule solverode23b Stiff, low-order solverode15s Stiff, variable-order solverodeset Creates integrator options structure for ODE solvers

Table 6.26: Predefined Input Functionsgensig Generates a periodic sine, square, or pulse inputsawtooth Generates a periodic sawtooth inputsquare Generates a square wave inputstepfun Generates a step function input

Table 6.27: Linear Algebra Functionsdet Returns the determinant of a matrixeig Returns the eigenvalues (characteristic roots) of a matrixinv Returns the inverse of a matrixpoly Returns the characteristic polynomial of a matrix

Page 163: Computer Aided Process Design and Simulation · Use the explicit Euler method to predict the behaviour of this reactor up to time equal 100s to four significant figures accuracy

163

Table 6.28: Symbolic Math Toolbox

Functions for Creating and Evaluating Symbolic Expressionsclass Returns the class of an expressiondigits Sets the number of decimal digits used to do variable precision arithmeticdouble Converts an expression to numeric formezplot Generates a plot of a symbolic expressionfindsym Finds the symbolic variables in a symbolic expressionnumden Returns the numerator and denominator of an expressionsym Creates a symbolic variablesyms Creates one or more symbolic variablesvpa Sets the number of digits used to evaluate expressions

Functions for Manipulating Symbolic Expressionscollect Collects coefficients of like powers in an expressionexpand Expands an expression by carrying out jpowersfactor Factors an expressionpoly2sym Converts a polynomial coefficient vector to a symbolic polynomialpretty Displays an expression in a form that resembles typeset mathematicssimple Searches for the shortest form of an expressionsimplify Simplifies an expression using Maple’s simplification rulessubs Substitutes variables or expressionssym2poly Converts an expression to a polynomial coefficient vector

Symbolic Calculus Functionsdiff Returns the derivative of an expressionDirac Dirac delta function (unit impulse)Heaviside Heaviside function (unit step)int Returns the integral of an expressionlimit Returns the limit of an expressionsymsum Returns the symbolic summation of an expressiontaylor Returns the Taylor series of a function

Symbolic Solution of Algebraic and Transcendental Equationssolve Solves symbolic equations

Symbolic Solution of Differential Equationsdsolve Returns a symbolic solution of a differential equation or set of equations

Laplace Transform Functionsilaplace Returns the inverse Laplace transformlaplace Returns the Laplace transform