201405 matlab applications in chemical engineering_a new book of prof. chyi-tsong chen (陳奇中)

6
Title: MATLAB Applications in Chemical Engineering Author: Chyi-Tsong Chen (陳奇中), Ph.D. Professor of Chemical Engineering Department Feng Chia University, Taichung, Taiwan 台灣逢甲大學化工系; Email: [email protected] Publisher: Tung Hua Book Co., Ltd. (台灣東華書局) ISBN: 978-957-483-769-4

Upload: chyi-tsong-chen

Post on 06-May-2015

391 views

Category:

Education


7 download

TRANSCRIPT

Page 1: 201405 MATLAB Applications in Chemical Engineering_A new book of Prof. Chyi-Tsong Chen (陳奇中)

Title: MATLAB Applications in Chemical Engineering Author: Chyi-Tsong Chen (陳奇中), Ph.D.

Professor of Chemical Engineering Department Feng Chia University, Taichung, Taiwan 台灣逢甲大學化工系; Email: [email protected]

Publisher: Tung Hua Book Co., Ltd. (台灣東華書局) ISBN: 978-957-483-769-4

Page 2: 201405 MATLAB Applications in Chemical Engineering_A new book of Prof. Chyi-Tsong Chen (陳奇中)

Features of the book This book addresses the applications of MATLAB and Simulink in the solution of chemical engineering problems. By classifying the problems into seven different categories, the author organizes this book as follows: Chapter One - Solution of a System of Linear Equations Chapter Two - Solution of Nonlinear Equations Chapter Three - Interpolation,Differentiation and Integration Chapter Four - Numerical Solution of Ordinary Differential

Equations Chapter Five - Numerical Solution of Partial Differential

Equations Chapter Six - Process Optimization Chapter Seven - Parameter Estimation Each chapter is arranged in four major parts. In the first part, the basic problem patterns that can be solved with MATLAB are presented. The second part describes how to apply MATLAB commands to solve the formulated problems in the field of chemical engineering. In the third and the fourth parts, exercises and summary of MATLAB instructions are provided, respectively. The description of the chemical engineering example follows the sequence of problem formulation, model analysis, MATLAB program design, execution results, and discussion. In this way, learners are first aware of the basic problem patterns and the underlying chemical engineering principles, followed by further familiarizing themselves with the relevant MATLAB instructions and programming skills. Readers are encouraged to do exercises to practice their problem-solving skills and deepen the fundamental knowledge of chemical engineering and relevant application problems.

Page 3: 201405 MATLAB Applications in Chemical Engineering_A new book of Prof. Chyi-Tsong Chen (陳奇中)

Contents

Chapter 1: Solution of a System of Linear Equations ......................... 1

1.1 Properties of linear equation systems and the relevant MATLAB commands ................................................................................................ 1 1.1.1 A simple example: the liquid blending problem ..................................... 1 1.1.2 Relevant properties of linear equation systems ....................................... 3 1.1.3 Relevant MATLAB commands .............................................................. 5

1.2 Chemical engineering examples ............................................................. 10 Example 1-2-1 Composition analysis of a distillation column system .......................... 10

Example 1-2-2 Temperature analysis of an insulated stainless steel pipeline .................. 14

Example 1-2-3 Composition analysis of a set of CSTRs .......................................... 17

Example 1-2-4 Independent reactions in a reaction system ...................................... 21

Example 1-2-5 Composition distributions in a distillation column ............................. 23

Example 1-2-6 Steady-state analysis of a batch reaction system .................................... 33

1.3 Exercises ................................................................................................. 40

1.4 Summary of the MATLAB commands related to this chapter ............... 46

Chapter 2: Solution of Nonlinear Equations .......................................... 49

2.1 Relevant MATLAB commands and the Simulink solution interface ..... 49 2.1.1 Nonlinear equation of a single variable ................................................ 49 2.1.2 Solution of a system of nonlinear equations ......................................... 59

2.2 Chemical engineering examples ............................................................. 68 Example 2-2-1 Boiling point of an ideal solution .................................................. 68

Example 2-2-2 Equilibrium concentrations in a reaction system ................................ 71

Example 2-2-3 Analysis of a pipeline network ..................................................... 76

Example 2-2-4 A material drying process through heat conduction and forced convection 79

Example 2-2-5 Simulation of a multistage binary distillation .................................... 83

Example 2-2-6 Analysis of a set of three CSTRs in series ........................................ 94

2.3 Exercises ................................................................................................. 97

2.4 Summary of MATLAB commands related to this chapter ................... 115

Chapter 3: Interpolation, Differentiation, and Integration ............. 119

3.1 Interpolation commands in MATLAB .................................................. 119 3.1.1 One-dimensional interpolation ........................................................... 119 3.1.2 Two-dimensional interpolation ........................................................... 122

3.2 Numerical differentiation ..................................................................... 125 3.2.1 The application of the MATLAB diff command in numerical differentiation

............................................................................................................ 126 3.2.2 Polynomial fitting and its application to the calculation of derivatives of a

data set ................................................................................................ 127 3.2.3 Higher-order derivatives of a data set ................................................. 128 3.2.4 The derivatives calculation of a known function ................................ 138 3.2.5 A method for calculating numerical gradients .................................... 143

Page 4: 201405 MATLAB Applications in Chemical Engineering_A new book of Prof. Chyi-Tsong Chen (陳奇中)

3.3 Numerical integration ........................................................................... 144 3.3.1 Integral of numerical data ................................................................... 144 3.3.2 Integral of a known function ............................................................... 145 3.3.3 Double integral ................................................................................... 147

3.4 Chemical engineering examples ........................................................... 149 Example 3-4-1 Preparation of a water solution with a required viscosity ................... 149

Example 3-4-2 Interpolation of diffusivity coefficients ......................................... 151

Example 3-4-3 Reaction rate equation of a batch reactor ...................................... 153

Example 3-4-4 Volume fraction of solid particles in a gas-solid fluidized bed .............. 158

Example 3-4-5 Average residence time calculation based on a tracer response ............ 161

Example 3-4-6 Design of an absorption tower ................................................... 163

Example 3-4-7 Reaction time of an adiabatic batch reactor ................................... 166

Example 3-4-8 Breakthrough time determination for an absorption tower ................. 169

3.5 Exercises ............................................................................................... 173

3.6 Summary of the MATLAB commands related to this chapter ............. 185

Chapter 4: Numerical Solution of Ordinary Differential Equations

............................................................................................................ 187

4.1 Initial value problems for ordinary differential equations .................... 187 4.1.1 The standard problems ........................................................................ 187 4.1.2 The MATLAB ODE solvers ............................................................... 188 4.1.3 Solving ODEs with MATLAB Simulink ............................................ 194 4.1.4 The DEE solution interface ................................................................ 208

4.2 Higher-order ordinary differential equations ........................................ 212

4.3 Stiff differential equations .................................................................... 217

4.4 Differential-algebraic equation system ................................................. 222

4.5 Boundary-valued ordinary differential equations ................................. 226 4.5.1 Problem patterns ................................................................................. 226 4.5.2 MATLAB commands for solving two-point boundary value problems 227 4.5.3 Multipoint BVP .................................................................................. 237

4.6 Chemical engineering examples ........................................................... 242 Example 4-6-1 Temperature and conversion distributions in a catalyzed tubular reactor 242

Example 4-6-2 Temperature and conversion distribution in a plug-flow reactor .......... 248

Example 4-6-3 Biochemical process dynamics in a batch reactor ............................. 252

Example 4-6-4 Temperature distribution on a flat panel with heat conduction and radiation ..

255

Example 4-6-5 Flow dynamics of a non-Newtonian fluid ...................................... 259

Example 4-6-6 Optimal operation temperature for penicillin fermentation ............... 264

4.7 Exercises ............................................................................................... 270

4.8 Summary of the MATLAB commands related to this chapter ............. 293

Chapter 5: Numerical Solution of Partial Differential Equations

............................................................................................................ 295

Page 5: 201405 MATLAB Applications in Chemical Engineering_A new book of Prof. Chyi-Tsong Chen (陳奇中)

5.1 Classifications of PDEs .......................................................................... 295 5.1.1 The order of a PDE ............................................................................. 295 5.1.2 Nonlinearity of a PDE ........................................................................ 296 5.1.3 Categories of initial conditions and boundary conditions ................... 297

5.2 The MATLAB PDE toolbox ................................................................. 300 5.2.1 The MATLAB PDE solver ................................................................. 300 5.2.2 The PDE graphical interface toolbox .................................................. 314 5.2.2.1 The solvable PDE problem patterns ....................................................... 316

5.2.2.2 Solution of PDE problems with the pdetool interface .................................. 318

5.3 Chemical engineering examples ........................................................... 325 Example 5-3-1 Temperature and reaction rate distributions in a catalyzed reactor ........ 325

Example 5-3-2 Concentration distribution in a diffusive reaction system ................... 333

Example 5-3-3 Rapid cooling of a hot solid object .............................................. 339

Example 5-3-4 Two-dimensional heat transfer ................................................... 344

Example 5-3-5 The permeation of gaseous solute into a liquid film ......................... 355

Example 5-3-6 Concentration distribution of ethanol in a tube .............................. 360

Example 5-3-7 Heat conduction of a long rod ................................................... 362

Example 5-3-8 Unsteady-state heat conduction in a flat panel ................................ 366

5.4 Exercises ............................................................................................... 370

5.5 Summary of the MATLAB commands related to this chapter ............. 378

Chapter 6: Process Optimization ............................................................... 381

6.1 The optimization problem and the relevant MATLAB commands ...... 381 6.1.1 Optimization problems of a single decision variable .......................... 381 6.1.2 Multivariate optimization problems without constraints .................... 383 6.1.3 Linear programming problems ........................................................... 386 6.1.4 Quadratic programming problem ........................................................ 388 6.1.5 The constrained nonlinear optimization problems .............................. 391 6.1.6 The multi-objective goal attainment problem ..................................... 395 6.1.7 Semi-infinitely constrained optimization problem ............................. 399 6.1.8 The minimax problem ......................................................................... 408 6.1.9 Binary integer programming problem ................................................ 411 6.1.10 A real-coded genetic algorithm for optimization ................................ 413 6.1.10.1 Fundamental principles of the real-coded genetic algorithm ......................... 413

6.1.10.2 Application of the real-coded genetic algorithm to solve optimization problems . 417

6.2 Chemical engineering examples ........................................................... 427 Example 6-2-1 Maximizing the profit of a production system ................................ 427

Example 6-2-2 The optimal photoresist film thickness in a wafer production process ... 431

Example 6-2-3 Minimal energy of a chemical equilibrium system ........................... 432

Example 6-2-4 Maximal profit of an alkylation process ........................................ 435

Example 6-2-5 Maximum separation efficiency in a single-effect distillatory .............. 441

Example 6-2-6 Dynamic optimization of an ammonia synthesis process .................... 445

Example 6-2-7 Optimal operating temperature for a tubular reactor ....................... 451

6.3 Exercises ............................................................................................... 456

6.4 Summary of the MATLAB commands related to this chapter ............. 477

Page 6: 201405 MATLAB Applications in Chemical Engineering_A new book of Prof. Chyi-Tsong Chen (陳奇中)

Chapter 7: Parameter Estimation ............................................................. 479

7.1 Parameter estimation using the least-squares method .......................... 479 7.1.1 Linear least-squares method ............................................................... 480 7.1.2 Nonlinear least-squares methods ........................................................ 486 7.1.3 The confidence interval of parameter estimation ................................ 490

7.2 Chemical engineering examples ........................................................... 493 Example 7-2-1 The solubility model of sulfur dioxide ........................................... 493

Example 7-2-2 The rate equation of a catalyzed reaction system ............................. 495

Example 7-2-3 Isothermal adsorption model for activated carbon ........................... 499

Example 7-2-4 Transfer function of a heating process .......................................... 502

Example 7-2-5 Estimation of the reaction rate constants for a fermentation process ..... 506

Example 7-2-6 Parameter estimation for a packed bed reactor described by a partial

differential equation model ...................................................... 510

Example 7-2-7 Parameter estimation using D-optimal experimental design method ..... 518

7.3 Exercises ............................................................................................... 522

7.4 Summary of the MATLAB commands related to this chapter ............. 533

References ................................................................................................................ 535

Index ........................................................................................................................... 541