**numerical python**

numerical python

(Parte **1** de 6)

Numerical Techniques for Chemical and

Biological Engineers

Using MATLAB®

Numerical Techniques for Chemical and

Biological Engineers

Using MATLAB®

A Simple

Bifurcation Approach

Said Elnashaie

Frank Uhlig with the assistance of Chadia Affane

MATLAB® is a trademark of The MathWorks, Inc. and is used with permission. The MathWorks does notwarrant the accuracy of the text or exercises in this book. This book’s use or discussion of MATLAB® software or related products does not constitute endorsement or sponsorship by The MathWorks of a particular pedagogical approach or particular use of the MATLAB® software.

Library of Congress Control Number: 2006930111

ISBN-10: 0-387-34433-0 ISBN-13: 978-0-387-34433-1

© 2007 Springer Science+Business Media, LLC All rights reserved. This work may not be translated or copied in whole or in part without the written permission of the publisher (Springer Science+Business Media, LLC, 233 Spring Street, New York, NY 10013, USA), except for brief excerpts in connection with reviews or scholarly analysis. Use in connection with any form of information storage and retrieval, electronic adaptation, computer software, or by similar or dissimilar methodology now known or hereafter developed is forbidden. The use in this publication of trade names, trademarks, service marks and similar terms, even if they are not identified as such, is not to be taken as an expression of opinion as to whether or not they are subject to proprietary rights.

987654321 springer.com

Professor Said

S.E.H. Elnashaie

Pennsylvania State University at Harrisburg

Room TL 176 Capital College 7 W. Harrisburg Pike Middletown, PA 17057-4898 sse10@psu.edu

Professor Frank Uhlig Department of Mathematics and Statistics

Auburn University 312 Parker Hall Auburn, AL 36849 uhligfd@auburn.edu

Chadia Affane Department of Mathematics and Statistics

Auburn University Auburn, AL 36849 affanac@auburn.edu

Born 1947, Cairo/Egypt; grew up in Egypt; married, two children, three grandchildren.

Chemical Engineering student at Cairo University, University of

Waterloo, and University of Edinburgh.

B. S., Cairo University, 1968; M.S., U of Waterloo, Canada, 1970; Ph.D., U Edinburgh, UK, 1973. Postdoc, University of Toronto and McGill U, 1973 – 1974. Professor, Cairo University, 1974 – 1992; King Saud University, Saudi

Arabia, 1986 – 1996; University of British Columbia, Canada, 1990; University Putra Malaysia, 1996/97; King Fahad University, Saudi Arabia, 1999; Auburn University, 1999 – 2005; Visiting Professor, U British Columbia, Vancouver, 2004; U British Columbia, Vancouver, 2005 –

Vice President, Environmental Energy Systems and Services (ES),

Research Areas: Modeling, Simulation and Optimization of Chemical and Biological Processes, Clean Fuels (Hydrogen, Biodiesel and Ethanol), Fixed and Fluidized Bed Catalytic Reactors, Nonlinear Dynamics, Bifurcation and Chaos, Clean Technology, Utilization of Renewable Materials, Sustainable Engineering. 300+ papers, 3+ books. nashaie@chml.ubc.ca

Born 1945, Magdesprung, Germany; grew up in Mulheim/Ruhr,

Germany; married, two sons.

Mathematics student at University of Cologne, California Institute of Technology.

Ph.D. CalTech 1972; Assistant, University of Wurzburg, RWTH

Two Habilitations (Mathematics), University of Wurzburg 1977,

RWTH Aachen 1978.

Visiting Professor, Oregon State University 1979/1980; Professor of Mathematics, Auburn University 1982 – Two Fulbright Grants; (Co-)organizer of eight research conferences. Research Areas: Linear Algebra, Matrix Theory, Numerical Analysis,

Numerical Algebra, Geometry, Krein Spaces, Graph Theory, Mechanics, Inverse Problems, Mathematical Education, Applied Mathematics, Geometric Computing. 50+ papers, 3+ books.

uhligfd@auburn.edu w.auburn.edu/~uhligfd

Born 1968, Fes/Morocco; grew up in Morocco; married, two children.

Engineering student at Ecole Superieure de Technologie, E.S.T.,

Chemical engineering student at Texas A&M University, 1997 – 1999;

B.S. Texas A&M University, 1999.

MS in Applied Mathematics, Auburn University, 2003. Ph. D. student, Mathematics, Auburn University, 2004 – Research Areas: Numerical Analysis, Applied Mathematics.

affanac@auburn.edu

Preface

This book has come about by chance.

The ﬁrst author, Said Elnashaie, and his wife, Shadia Elshishini, moved next door to the second author, Frank Uhlig, and his family in 2000. The two families became good neighbors and friends. Their chats covered the usual topics and occasionally included random teaching, departmental, and university matters. One summer day in 2003, Said showed Frank a numerical engineering book that he had been asked to review. Neither of them liked what they saw. Frank eventually brought over his “Numerical Algorithms” book and Said liked it. Then Said brought over his latest Modeling book and Frank liked it, too. And almost immediately this Numerical Chemical and Biological Engineering book project started to take shape.

Said had always felt more mathematically inclined in his work on modeling problems and bifurcation and chaos in chemical/biological engineering; Frank had lately turned more numerical in his perception and eﬀorts as a mathematician.

This book is the outcome of Said’s move to Auburn University and his chance moving in next door to Frank. It was born by a wonderful coincidence!

Said and Frank’s long evening walks through Cary Woods contributed considerably towards most of the new ideas and the educational approach in this book. We have both learned much about numerics, chemical/biological engineering, book writing, and thinking in our eﬀort to present undergraduates with state of the art chemical/biological engineering models and state of the art numerics for modern chemical/biological engineering problems.

Chadia is a chemical engineer who has turned towards applied mathematics in her graduate studies at Auburn University and has helped us bridge the gap between our individual perspectives.

The result is an interdisciplinary, totally modern book, in contents, treatment, and spirit. We hope that the readers and students will enjoy the book and beneﬁt from it.

For help with our computers and computer software issues we are indebted to A. J., to Saad, and to Darrell.

Auburn and Vancouver, 2006 vii

Contents

How to Use this Book | 5 |

Introduction 1

1.1 MATLAB Software and Programming | 12 |

1.1.1 The Basics of MATLAB | 12 |

1.2 Numerical Methods and MATLAB Techniques | 19 |

1.2.1 Solving Scalar Equations | 20 |

Exercises | 3 |

1.2.2 Diﬀerential Equations; the Basic Reduction to First Order Systems | 34 |

1.2.3 Solving Initial Value Problems | 37 |

1.2.4 Solving Boundary Value Problems | 42 |

1.2.5 MATLAB m and Other Files and Built-in MATLAB Functions | 43 |

1 Computations and MATLAB 1

2.1 System Theory and its Applications | 5 |

2.1.1 Systems | 5 |

2.1.2 Steady State, Unsteady State, and Thermodynamic Equilibrium | 57 |

2.2 Basic Principles for Modeling Chemical and Biological Engineering Systems | 58 |

2.3 Classiﬁcation of Chemical and Biological Engineering Systems | 59 |

2.4 Physico-Chemical Sources of Nonlinearity | 61 |

2.5 Sources of Multiplicity and Bifurcation | 65 |

2 Modeling, Simulation, and Design 5

3.1 Continuous Stirred Tank Reactor: The Adiabatic Case | 69 |

Exercises | 89 |

3.2 Continuous Stirred Tank Reactor: The Nonadiabatic Case | 92 |

Exercises | 114 |

3.3 A Biochemical Enzyme Reactor | 115 |

3.4 Scalar Static Equations | 118 |

3 Some Models with Scalar Equations 69 3.4.1 Simple Examples of Reactions with No Possible Multiple Steady States . 119 3.4.2 Solving Some Static Transcendental and Algebraic Equations from the

Chemical and Biological Engineering Fields | 121 |

Problems for Chapter 3 | 130 |

4.1 A Nonisothermal Distributed System | 135 |

4.1.1 Vapor-Phase Cracking of Acetone | 138 |

4.1.2 Prelude to the Solution of the Problem | 138 |

4.1.3 Material Balance Design Equation in Terms of Volume | 139 |

4.1.4 Heat Balance Design Equation in Terms of Volume | 141 |

4.1.5 Numerical Solution of the Resulting Initial Value Problem | 142 |

Exercises | 154 |

4.2 Anaerobic Digester | 155 |

4.2.1 Process Description and Rate Equations | 155 |

4.2.2 Mathematical Modeling for a Continuous Anaerobic Digester | 156 |

4.2.3 Solution of the Steady-State Equations | 157 |

4.2.4 Steady-State Volume in terms of the Feed Rate | 157 |

4.2.5 Steady-State Conversion in Terms of the Feed Concentration | 159 |

Exercises | 168 |

4.3 Heterogeneous Fluidized Bed Catalytic Reactors | 169 |

4.3.1 Mathematical Modeling and Simulation of Fluidized Beds | 169 |

4.3.2 Analytical Manipulation of the Joint Integrodiﬀerential Equations | 174 |

4.3.4 Dynamic Models and Chemisorption Mechanisms | 177 |

4.3.5 Fluidized Bed Catalytic Reactor with Consecutive Reactions | 181 |

4 Initial Value Problems 135 4.2.6 The Unsteady-State Behavior of the Digester and the Solution of the IVP 165 4.3.3 Bifurcation and Dynamic Behavior of Fluidized Bed Catalytic Reactors . 177 4.3.6 Numerical Treatment of the Steady-State and Dynamical Cases of the

Bubbling Fluidized Bed Catalytic Reactor with Consecutive Reactions | 184 |

Exercises | 221 |

4.4 A Biomedical Example: The Neurocycle Enzyme System | 2 |

4.4.1 Fundamentals | 223 |

4.4.3 Dynamic Model Development | 225 |

4.4.4 Normalized Form of the Model Equations | 229 |

4.4.5 Identiﬁcation of Parameter Values | 231 |

4.4.6 Numerical Considerations | 232 |

Exercises | 249 |

Problems for Chapter 4 | 250 |

4.4.2 The Simpliﬁed Diﬀusion-Reaction Two Enzymes/Two Compartments Model223

5.1 The Axial Dispersion Model | 255 |

5.1.1 Formulation of the Axial Dispersion Model | 257 |

5 Boundary Value Problems 255 5.1.2 Example of an Axial Dispersion Model. Linear and Non-linear Two-point

Boundary Value Problems (BVPs) | 262 |

The Linear Case | 262 |

Analytic Solution of the Linear Case | 265 |

5.1.3 Numerical Solution of Nonlinear BVPs. The Non-Isothermal Case | 277 |

Exercises | 297 |

5.2 The Porous Catalyst Pellet BVP | 298 |

5.2.1 Diﬀusion and Reaction in a Porous Structure | 298 |

5.2.2 Numerical Solution for the Catalytic Pellet BVP | 303 |

The Heat Balance Model | 304 |

The Mass and Heat Balance Model | 314 |

Exercises | 323 |

Problems for Chapter 5 | 324 |

6.1 Heterogeneous Systems | 327 |

6.1.1 Material Balance and Design Equations for Heterogeneous Systems | 328 |

Generalized Mass Balance and Design Equations | 328 |

Overall Heat Balance and Design Equations | 3 |

Two Phase Systems | 335 |

The Co- and Countercurrent Cases | 337 |

The Equilibrium Case | 338 |

Stage Eﬃciency | 339 |

Generalized Mass Balance for Two Phase Systems | 339 |

6.1.2 Steady State Models for Isothermal Heterogeneous Lumped Systems | 340 |

Multiple Reactions in Two Phase Systems | 346 |

6.1.4 Nonisothermal Heterogeneous Systems | 348 |

Lumped Systems | 348 |

Heterogeneous Lumped Systems | 349 |

Distributed Systems | 351 |

Exercises | 353 |

6.2 Nonreacting Multistage Isothermal Systems | 353 |

6 Heterogeneous and Multistage Systems 327 6.1.3 Steady State Models for Isothermal Heterogeneous Distributed Systems . 344 6.2.1 Absorption Columns or High Dimensional Lumped, Steady State and

Equilibrium Stages Systems | 353 |

The Case of a Linear Equilibrium Relation | 354 |

Multistage Absorption | 361 |

6.2.2 Nonequilibrium Multistages with Nonlinear Equilibrium Relations | 373 |

Exercises | 381 |

6.3 Isothermal Packed Bed Absorption Towers | 382 |

6.3.1 Model Development | 383 |

6.3.2 Manipulation of the Model Equations | 384 |

Exercises | 399 |

6.4 The Nonisothermal Case: a Battery of CSTRs | 399 |

6.4.1 Model Development | 399 |

6.4.2 Numerical Solutions | 402 |

6.4.3 The Steady State Equations | 419 |

6.3.3 Discussion and Results for both the Simulation and the Design Problem . 384 xi

Problems for Chapter 6 | 422 |

7.1 A Simple Illustrative Example | 426 |

7.1.1 Mass Balance for the Reactor | 427 |

7.1.2 Heat Balance for the Reactor | 428 |

7.1.3 Reactor Model Summary | 429 |

7 Industrial Problems 425 7.1.4 The Catalyst Pellet Design Equations and the Computation of the Eﬀec-

tiveness Factor η | 430 |

7.1.5 Pellet Model Summary | 431 |

7.1.6 Manipulation and Reduction of the Equations | 432 |

Exercises | 436 |

7.2 Industrial Fluid Catalytic Cracking FCC Units | 436 |

7.2.1 Model Development for Industrial FCC Units | 437 |

7.2.2 Static Bifurcation in Industrial FCC Units | 442 |

The Steady State Model | 443 |

Solution of the Steady State Equations | 445 |

Steady State Simulation Results for an Industrial Scale FCC Unit | 446 |

7.2.3 Industrial Veriﬁcation of the Steady State Model and Static Bifurcation

of Industrial Units | 451 |

Simulation Procedure; Veriﬁcation and Cross Veriﬁcation | 453 |

The Dynamic Model | 459 |

Simulation and Bifurcation Results; Discussion for two Industrial FCC Units453 7.2.4 Preliminary Dynamic Modeling and Characteristics of Industrial FCC Units459 Results for the Dynamic Behavior of FCC Units and their Relation to the

Static Bifurcation Characteristics | 461 |

7.2.5 Combined Static and Dynamic Bifurcation Behavior of Industrial FCC

Units | 469 |

The Dynamic Model | 470 |

Exercises | 472 |

7.3 The UNIPOL Process for Polyethylene and Polypropylene Production | 473 |

7.3.1 A Dynamic Mathematical Model | 475 |

General Assumptions | 475 |

Hydrodynamic Relations | 476 |

The Model Equations | 478 |

7.3.2 Numerical Treatment | 482 |

Exercises | 483 |

7.4 Industrial Steam Reformers and Methanators | 484 |

7.4.1 Rate Expressions | 484 |

7.4.2 Model Development for Steam Reformers | 488 |

7.4.3 Modeling of Side-Fired Furnaces | 490 |

7.4.4 Model for a Top-Fired Furnace | 491 |

7.4.5 Modeling of Methanators | 491 |

7.4.6 Dusty Gas Model for Catalyst Pellets in Steam Reformers and Methanators492 xii

7.4.8 Some Computed Simulation Results for Steam Reformers | 494 |

7.4.9 Simulation Results for Methanators | 498 |

Exercises | 501 |

7.5 Production of Styrene | 502 |

7.5.1 The Pseudohomogeneous Model | 503 |

The Rate Equations | 503 |

Model Equations | 506 |

Numerical Solution of the Model Equations | 508 |

7.4.7 Numerical Considerations ... ........ ....... ........ . 493 Simulation of an Industrial Reactor Using the Pseudohomogeneous Model 508 7.5.2 Simulation of Industrial Units Using the more Rigorous Heterogeneous

Model | 509 |

The Catalyst Pellet Equations | 509 |

Model Equations of the Reactor | 511 |

Extracting Intrinsic Rate Constants | 512 |

Exercises | 515 |

7.6 Production of Bioethanol | 515 |

7.6.1 Model Development | 515 |

7.6.2 Discussion of the Model and Numerical Solution | 519 |

7.6.3 Graphical Presentation | 520 |

Exercises | 530 |

Problems for Chapter 7 | 531 |

(A) Basic Notions of Linear Algebra | 535 |

(B) Row Reduction and Systems of Linear Equations | 537 |

(C) Subspaces, Linear (In)dependence, Matrix Inverse and Bases | 538 |

(D) Basis Change and Matrix Similarity | 539 |

(E) Eigenvalues and Eigenvectors, Diagonalizable Matrices | 541 |

(F) Orthonormal Bases, Normal Matrices and the Schur Normal Form | 542 |

(G) The Singular Value Decomposition and Least Squares Problems | 543 |

(H) Linear Diﬀerential Equations | 544 |

Appendix 1: Linear Algebra and Matrices 533

Appendix 2:

1. Sources of Multiplicity | 549 |

1.1 Isothermal or Concentration Multiplicity | 549 |

1.2 Thermal Multiplicity | 550 |

1.3 Multiplicity due to Reactor Conﬁguration | 551 |

2. Simple Quantitative Explanation of the Multiplicity Phenomenon | 551 |

3. Bifurcation and Stability | 553 |

3.1 Steady State Analysis | 553 |

3.2 Dynamic Analysis | 559 |

3.3 Chaotic Behavior | 564 |

Bifurcation, Instability, and Chaos in Chemical and Biological Systems 547 xiii

Appendix 3: Contents of the CD and How to Use it 571 Resources 573 Epilogue 579 Index 581 List of Photographs 590 xiv

The question mark The question mark

Introduction

This book is interdisciplinary, involving two relatively new ﬁelds of human endeavor. The two ﬁelds are: Chemical/Biological1 Engineering and Numerical Mathematics.

How do these two disciplines meet? They meet through mathematical modeling.

Mathematical modeling is the science or art of transforming any macro-scale or microscale problem to mathematical equations. Mathematical modeling of chemical and biological systems and processes is based on chemistry, biochemistry, microbiology, mass diﬀusion, heat transfer, chemical, biochemical and biomedical catalytic or biocatalytic reactions, as well as noncatalytic reactions, material and energy balances, etc.

As soon as the chemical and biological processes are turned into equations, these equations must be solved eﬃciently in order to have practical value. Equations are usually solved numerically with the help of computers and suitable software.

Almost all problems faced by chemical and biological engineers are nonlinear. Most if not all of the models have no known closed form solutions. Thus the model equations generally require numerical techniques to solve them. One central task of chemical/biological engineers is to identify the chemical/biological processes that take place within the boundaries of a system and to put them intelligently into the form of equations by utilizing justiﬁable assumptions and physico-chemical and biological laws. The best and most modern classiﬁcation of diﬀerent processes is through system theory. The models can be formed of steady-state design equations used in the design (mainly sizing and optimization), or unsteady-state (dynamic) equations used in start-up, shutdown, and the design of control systems. Dynamic equations are also useful to investigate the bifurcation and stability characteristics of the processes.

The complexity of the mathematical model depends upon the degree of accuracy required and on the complexity of the interaction between the diﬀerent processes taking place within the boundaries of the system and on the interaction between the system and its surrounding. It is an important art for chemical/biological engineers to reach an optimal degree of sophistication (complexity) for the system model. By “optimal degree of sophistication” we mean ﬁnding a model for the process, which is as simple as possible without sacriﬁcing the required accuracy as dictated by the speciﬁc practical application

1Biological engineering comprises both biochemical and biomedical engineering

2 Introduction of the model.

After the chemical/biological engineer has developed a suitable mathematical model with an optimal degree of “sophistication” for the process, he/she is then faced with the problem of solving its equations numerically. This is where stable and eﬃcient numerical methods become essential.

The classiﬁcation of numerical solution techniques lends itself excellently to the system theory classiﬁcation as well. A large number of chemical/biological processes will be presented, modeled, and eﬃ- cient numerical techniques will be developed and programmed using MATLAB R 2.T his is a sophisticated numerical software package. MATLAB is powerful numerically through its built-in functions and it allows us to easily develop and evaluate complicated numerical codes that fulﬁl very specialized tasks. Our solution techniques wil be developed and discussed from both the chemical/biological point of view and the numerical point of view.

Hence the ﬂow of each chapter of this book will lead from a description of speciﬁc chemical/biological processes and systems to the identiﬁcation of the main state variables and processes occurring within the boundaries of the system, as well as the interaction between the system and its surrounding environment. The necessary system processes and interactions are then expressed mathematically in terms of state variables and parameters in the form of equations. These equations may most simply be algebraic or transcendental, or they may involve functional, diﬀerential, or matrix equations in ﬁnitely many variables.

The mathematical model speciﬁes a set of equations that reﬂects the characteristics and behavior of the underlying chemical/biological system. The parameters of the model can be obtained from data in the literature or through well-designed experimentation. Any model solution should be checked ﬁrst against known experimental and industrial data before relying on its numerical solution for new data. To use a model in the design and control of a system generally requires eﬃcient solution methods for the model equations.

Some of the models are very simple and easy to solve, even by hand, but most require medium to high-powered numerical techniques.

From chapter to chapter, we introduce increasingly more complex chemical/biological processes and describe methods and develop MATLAB codes for their numerical solution. The problem of validating a solution and comparing between diﬀerent algorithms can be tackled by testing diﬀerent numerical techniques on the same problem and verifying and comparing their output against known experimental and industrial data.

In this interdisciplinary text we assume that the reader has a basic knowledge of the laws governing the rates of diﬀerent chemical, biological and physical processes, as well as of material and energy balances. Junior and senior undergraduates majoring in chemical/biological engineering and graduate students in these areas should be able to follow the engineering related portions of the text, as well as its notations and scientiﬁc deductions easily. Regarding mathematics, students should be familiar with calculus, linear algebra and matrices, as well as diﬀerential equations, all on the ﬁrst and second

2MATLAB is a registered trade mark of The MathWorks, Inc., 3 Apple Hill Drive, Natick, MA 01760; http://www.mathworks.com .

Introduction 3 year elementary undergraduate level. Having had a one semester course in numerical analysis is not required, but will deﬁnitely be helpful. We include an appendix on linear algebra and matrices at the end of the book since linear lgebra is often not required in chemical/biological engineering curricula.

In order to solve chemical/biological problems of diﬀering levels we rely throughout on well tested numerical procedures for which we include MATLAB codes and test ﬁles. Moreover, a large part of this book is dedicated to explain the workings of our algorithms on an intuitive level and thereby we give a valuable introduction to the world of scientiﬁc computation and numerical analysis.

(Parte **1** de 6)