Computer-Aided Computation for Chemical Engineers
Cheng-Liang Chen
PSE
LABORATORY
Department of Chemical Engineering National TAIWAN University
Chen CL
1
Computer-Aided Computation for Chemical Engineers Course Objectives This course emphasizes the derivation of a variety of numerical methods and their application to the solution of chemical engineering problems. The first objective of of the course is to enable the students to formulate chemical engineering problems as mathematical models belonging to one of the following categories: 1. Complex consecutive calculations, 2. Linear and nonlinear algebraic equations, 3. Ordinary differential equations, 4. Partial differential equations, and 5. Multiple linear and polynomial regressions.
Chen CL
1
Computer-Aided Computation for Chemical Engineers Course Objectives This course emphasizes the derivation of a variety of numerical methods and their application to the solution of chemical engineering problems. The first objective of of the course is to enable the students to formulate chemical engineering problems as mathematical models belonging to one of the following categories: 1. Complex consecutive calculations, 2. Linear and nonlinear algebraic equations, 3. Ordinary differential equations, 4. Partial differential equations, and 5. Multiple linear and polynomial regressions.
Chen CL
2
Computer-Aided Computation for Chemical Engineers Course Objectives Recently, MATLAB has been widely recognized as a high-performance language for technical computing. It integrates computation, visualization, and programming in an easy-to-use environment. The second objective of of this course is to enable students to solve the resultant models using MATLAB and Simulink.
Chen CL
3
Computer-Aided Computation for Chemical Engineers Course Objectives Note: We are not going to train you as a programmer or software engineer . The main learning objectives in this course include:
1. To use computational tool(s) for solving engineering problems effectively; 2. Understand and analyze the problem and formulate the model accurately; 3. Use analytical methods or numerical techniques to find proper solution; 4. Use computer program for solving the problem.
Chen CL
4
Computer-Aided Computation for Chemical Engineers Outline
Simulink and MATLAB Materials
Illustrative Applications Simulink solution of ODEs, some linear
Simulation with Simulink
Computing with MATLAB Plotting tips Programming techniques Problem solving steps
and nonlinear functions Simulink simulation examples: a gas process a stirred-tank heater a batch bioreactor
Some simple engineering problems
Chen CL
5
Computer-Aided Computation for Chemical Engineers Outline
Numerical Solution of Nonlinear Equations Numerical Methods
Illustrative Applications
Types of roots and their approximation Methods of successive substitution Methods of linear interpolation Wegstein method
Solution of the Colebrook Equations Solution of the Soave-Redlich-Kwong Equation
Newton-Raphson method
Solution of nth-Degree Polynomials and Transfer Functions
Newton’s method for simultaneous nonlinear equations
Solution of Nonlinear Equations in Chemical Equilibrium
Chen CL
6
Computer-Aided Computation for Chemical Engineers Outline
Numerical Solution of Simultaneous Linear Algebraic Equations Numerical Methods
Cramer’s rule Gauss elimination method Gauss-Jordan reduction method Gauss-Seidel substitution method Jacobi method
Illustrative Applications
Heat transfer in a pipe Solution of a steam distribution problem Solution of chemical reaction and material balance equations
Chen CL
7
Computer-Aided Computation for Chemical Engineers Outline
Finite Difference Methods and Interpolation Numerical Methods
Illustrative Applications
Finite Differences (FDs): Backward-Forward-Central Difference equations and their solutions Interpolating polynomials Interpolation of equally spaced pts Gregory-Newton method Stirling’s method Interpolation of unequally spaced pts Lagrange polynomials Spline interpolation
Equally spaced data: Gregory-Newton method The Lagrange polynomials and cubic splines
Chen CL
8
Computer-Aided Computation for Chemical Engineers Outline
Numerical Differentiation and Integration Numerical Methods
Differentiation by FDs: Backward-Forward-Central Spline differentiation Newton-Cotes formulas of integration Gauss quadrature Spline integration Multiple integrals
Illustrative Applications
Mass transfer flux from an open vessel Derivative of vectors of equally spaced pts Integration formula: trapezoidal and Simpson’s 1/3 rules Integration formulas: Gauss-Legendre quadrature
Chen CL
9
Computer-Aided Computation for Chemical Engineers Outline
Numerical Solution of Ordinary Differential Equations Numerical Methods
Illustrative Applications
Linear ODEs
Solution of a Chemical reaction system
Nonlinear ODEs: initial-value problems Euler and modified Euler methods Runge-Kutta methods Adams-Moulton methods Simultaneous DEs Nonlinear problems
ODEs:
Solution of non-isothermal plug-flow reactor
boundary-value
The shooting method The finite difference method Collocation methods Step-size control and Stiff DEs
Flow of a non-Newtonian fluid Optimal temperature profile penicilline fermentation
for
Chen CL
10
Computer-Aided Computation for Chemical Engineers Outline
Numerical Solution of Partial Differential Equations Numerical Methods
Solution of differences
PDEs
Elliptic PDEs Parabolic PDEs Hyperbolic PDEs
Illustrative Applications
using
finite
Solution of the Laplace and Poisson equations Solution of parabolic PDEs for diffusion Solution of parabolic PDEs for heat transfer
Chen CL
11
Computer-Aided Computation for Chemical Engineers Outline
Linear and Nonlinear Regression Analysis Numerical Methods
Illustrative Applications
Review of statistical terminologies Linear regression analysis The least squares method Properties of estimated par.s Nonlinear regression analysis The method of steepest descent The Gauss-Newton method Newton’s method The Marquardt method Multiple nonlinear regressions Analysis of variance
Nonlinear regression Marquart method
using
the
Chen CL
12
Computer-Aided Computation for Chemical Engineers Outline
Process Optimization Numerical Methods
Linear programming Nonlinear programming with and without constraints Mixed-integer linear programming Mixed-integer nonlinear programming
Illustrative Applications
Refinery process Synthesis of water networks Synthesis of cooling-water networks Synthesis of heat-exchanger networks
Chen CL
13
Computer-Aided Computation for Chemical Engineers Text Book and References
Constantinides, A. and N. Mostoufi, Numerical Methods for Chemical Engineers with MATLAB Applications, Prentice
Hall, Upper Saddle River, NJ, 1999.
Cutlip, M. B., and M. Shacham, Problem Solving in Chemical Engineering with Numerical Methods, Prentice Hall, Upper Saddle
River, NJ, 2nd Ed., 2007.
William J. Palm III , Introduction to MATLAB 7 for Engineers,
McGraw-Hill, New York, 2005.
Chen CL
14
Some Notes
Computer room: lecture, in-class practice and exercise Tuesday 2 : 10 Thursday 1 : 20
∼
∼
3 : 20 2 : 40
(50%)
Prepare one document file for each exercise:
D93524013 2007 03 08 1.doc
D93524013 2007 03 08
registration no
date
1 . doc
version
doc file
Document file should include problem description , main results and discussion , relevant figures and tables , and m-files for each problem. E-mail your report file immediately to teaching assistant (Ciou Y.J.
[email protected] ) BEFORE you leave computer room You can modify your report and e-mail it again to teaching assistant after the class. However, you have to use another file name: D93524013 2007 03 14 2.doc
Two examinations: mid-term and final
(25% + 25%)
Chen CL
15
Some High-level Programming Languages Language
Key Data
Application Area
Origin of Names
FORTRAN
IBM (1957)
Scientific programming
FORmula TRANslation language
LISP
MIT (1958)
Symbolic computation (AI)
LISp Processing
COBOL
USA (1959)
Business data processing
COmmon Business-Oriented Language
Simple on PC
Beginner’s All Purpose Symbolic Instruction Code
Systems programming
Predecessor language was named B
Symbolic computation (AI)
PROgramming LOGic (Frence)
Real-time distributed systems
Ada Augusta Byron collaborated with nineteenthcentury computer pioneer Charles Babbage
Graphical user interfaces; Objectoriented programming
Objects ”talk” to one another via messages
Supports objects and objectedoriented programming
Incremental modification of C increment operator)
Supports Web programming
Originally named ”Oak”
BASIC C PROLOG Ada Smalltalk
(1965) Bell (1972) (1972) USA (1980) (1980)
C++ JAVA
SUN (1995)
→
Common Lisp Object System
(++ is the C
Chen CL
16
Progress of Programming Languages Progress of Programming Languages 1955
(Machine Language)
(Assembly Language)
1960 1965 1970 r 1975 a e Y
1980 1985 1990 1995 2000
01011010
ADD
Chen CL
17
Progress of Programming Languages Progress of Programming Languages 1955
(Machine Language)
FORTRAN
1960 1965 1970
DO 7, LOOP = 1,5 READ *, X, Y
r 1975 a e Y
1980 1985 1990 1995 2000
AVE=(X+Y)/2.0 PRINT *, X,Y,AVE 7 CONTINUE END
(Assembly Language)
Chen CL
18
Progress of Programming Languages Progress of Programming Languages 1955 1960
(Machine Language)
FORTRAN COBOL
1965 1970
01 EMPLOYEE−RECORD 05 EMPLOYEE−NUMBER PIC 9(5)
r 1975 a e Y
1980
05 EMPLOYEE−NAME 05 BIRTH−DATE 10 BIRTH−MONTH 10 FILLER 10 BIRTH−DAY
1985
1995 2000
PIC 99
PIC X PIC 99
05 DATE−HIRED 10 MONTH−HIRED 10 FILLER
1990
PIC X(30)
10 DAY−HIRED
PIC 99
PIC X PIC 99
(Assembly Language)
Chen CL
19
Progress of Programming Languages Progress of Programming Languages 1955
(Machine Language) LISP
FORTRAN
(Assembly Language)
COBOL
1960 1965 1970
(defun length (x) PROLOG
r 1975 a e Y
(t(+1 (length (cdr x)))))) SCHEME
1990 1995 2000
(length ’(I Love Computers)’) 3
1980 1985
(cond ((null x) 0)
COMMON LISP
CLOS
Chen CL
20
Progress of Programming Languages Progress of Programming Languages 1955
(Machine Language)
LISP
FORTRAN
(Assembly Language)
COBOL
1960
BASIC
1965 1970 PROLOG
r 1975 a e Y
SCHEME
Dim i, sum sum = 0 For i = 1 to 10
1980
sum = sum + 1 Next i
1985 1990
COMMON LISP
CLOS VISUAL
1995 2000
BASIC
Chen CL
21
Progress of Programming Languages Progress of Programming Languages 1955
(Machine Language) LISP
FORTRAN
(Assembly Language)
COBOL
1960
ALGOL60
BASIC
1965 1970
PASCAL
PROLOG
r 1975 a e Y
SCHEME
1980 1985
MODULA−2 COMMON LISP
if (i > 0) then x := 10 else
1990
CLOS
MODULA−3
y := 5 VISUAL
1995 2000
BASIC
Chen CL
22
Progress of Programming Languages Progress of Programming Languages 1955
(Machine Language) LISP
FORTRAN
(Assembly Language)
COBOL
1960
ALGOL60 CPL
BASIC
1965 1970 r 1975 a e Y
PASCAL
C
PROLOG SCHEME
1980 1985
MODULA−2 COMMON LISP
if (i > 0) x = 10; else
1990
CLOS
MODULA−3
y = 5; VISUAL
1995 2000
BASIC
Chen CL
23
Progress of Programming Languages Progress of Programming Languages 1955
(Machine Language)
LISP
FORTRAN
(Assembly Language)
COBOL
1960
ALGOL60 CPL
BASIC
1965 SIMULA
1970 PROLOG
r 1975 a e Y
SCHEME SMALLTALK
1980 1985 1990
PASCAL
C
COMMON LISP
MODULA−2
C++
MODULA−3 CLOS VISUAL
1995
C++
Standard
2000
BASIC
Chen CL
24
Progress of Programming Languages Progress of Programming Languages 1955
(Machine Language)
LISP
FORTRAN
(Assembly Language)
COBOL
1960
ALGOL60 CPL
BASIC
1965 SIMULA
1970 r 1975 a e Y
SCHEME SMALLTALK
1980 1985 1990
PASCAL
C
PROLOG
ADA
C++
COMMON LISP
MODULA−3 CLOS VISUAL
1995 2000
MODULA−2
JAVA
C++
Standard
BASIC
Chen CL
25
Progress of Programming Languages Progress of Programming Languages 1955
(Machine Language)
LISP
FORTRAN
(Assembly Language)
COBOL
1960
ALGOL60 CPL
BASIC
1965 SIMULA
1970 r 1975 a e Y
SCHEME SMALLTALK
1980 1985 1990
PASCAL
C
PROLOG
MATLAB ADA
C++
COMMON LISP
MODULA−3 CLOS VISUAL
1995 2000
MODULA−2
JAVA
C++
Standard
BASIC
Chen CL
26
MATLAB ?
MATrix LABoratory
In 1978, Professor Cleve Moler (New Mexico University, USA) used FORTRAN to write the MATLAB for applications involving matrices , linear algebra , and numerical analysis
In 1984, Jack Little (Stanford University) used C to rewrite and to commercialize the MATLAB software (MathWorks Company)
MATLAB is both a computer programming language and an interactive software environment for using that language
effectively
Chen CL
27
Why MATLAB ? Outstanding Features
Significantly simpler programming
Continuity (no distinction) among integer, real, and complex values (any variable can take any type of number without special declaration)
Extended range of numbers and their accuracy (all in double precision)
Extensive graphic tools including graphic user interface functions
A comprehensive mathematical library
Capability of linking with traditional programming languages
Transportability of MATLAB programs
MATLAB has a number of add-on software modules, called toolboxes, that perform more specialized computations. All toolboxes run under the core MATLAB program
Chen CL
28
Simulink Graphical Dynamic Simulation built on top of
MATrix LABoratory