Sunteți pe pagina 1din 30

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 rst objective 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 dierential equations,
4. Partial dierential 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 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
eectively;
2. Understand and analyze the problem and formulate the model
accurately;
3. Use analytical methods or numerical techniques to nd 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
Simulation with Simulink
Simulink solution of ODEs, some linear
and nonlinear functions
Simulink simulation examples:
a gas process
a stirred-tank heater
a batch bioreactor
Computing with MATLAB
Plotting tips
Programming techniques
Problem solving steps
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
Newton-Raphson method
Solution of the Colebrook Equations
Solution of the Soave-Redlich-Kwong
Equation
Solution of n
th
-Degree Polynomials and
Transfer Functions
Newtons 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 Illustrative Applications
Cramers rule
Gauss elimination method
Gauss-Jordan reduction method
Gauss-Seidel substitution method
Jacobi method
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 Dierence Methods and Interpolation
Numerical Methods Illustrative Applications
Finite Dierences (FDs):
Backward-Forward-Central
Dierence equations and their solutions
Interpolating polynomials
Interpolation of equally spaced pts
Gregory-Newton method
Stirlings 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 Dierentiation and Integration
Numerical Methods Illustrative Applications
Dierentiation by FDs:
Backward-Forward-Central
Spline dierentiation
Mass transfer ux from an open vessel
Derivative of vectors of equally spaced
pts
Newton-Cotes formulas of integration
Gauss quadrature
Spline integration
Multiple integrals
Integration formula:
trapezoidal and Simpsons 1/3 rules
Integration formulas:
Gauss-Legendre quadrature
Chen CL 9
Computer-Aided Computation
for Chemical Engineers
Outline
Numerical Solution of Ordinary Dierential Equations
Numerical Methods Illustrative Applications
Linear ODEs Solution of a Chemical reaction system
Nonlinear ODEs: initial-value problems
Euler and modied Euler methods
Runge-Kutta methods
Adams-Moulton methods
Simultaneous DEs
Solution of non-isothermal plug-ow
reactor
Nonlinear ODEs: boundary-value
problems
The shooting method
The nite dierence method
Collocation methods
Flow of a non-Newtonian uid
Optimal temperature prole for
penicilline fermentation
Step-size control and Sti DEs
Chen CL 10
Computer-Aided Computation
for Chemical Engineers
Outline
Numerical Solution of Partial Dierential Equations
Numerical Methods Illustrative Applications
Solution of PDEs using nite
dierences
Elliptic PDEs
Parabolic PDEs
Hyperbolic PDEs
Solution of the Laplace and Poisson
equations
Solution of parabolic PDEs for diusion
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
Newtons method
The Marquardt method
Multiple nonlinear regressions
Analysis of variance
Nonlinear regression using the
Marquart method
Chen CL 12
Computer-Aided Computation
for Chemical Engineers
Outline
Process Optimization
Numerical Methods Illustrative Applications
Linear programming
Nonlinear programming with and
without constraints
Mixed-integer linear programming
Mixed-integer nonlinear programming
Renery 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. Mostou, 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 3 : 20
Thursday 1 : 20 2 : 40 (50%)
Prepare one document le for each exercise:
D93524013 2007 03 08 1.doc
D93524013

registration no
2007 03 08

date
1

version
. doc

doc le
Document le should include problem description, main results and
discussion, relevant gures and tables, and m-les for each problem.
E-mail your report le immediately to teaching assistant (Ciou Y.J.
d93524013@ntu.edu.tw) 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 le name:
D93524013 2007 03 14 2.doc
Two examinations: mid-term and nal (25% + 25%)
Chen CL 15
Some High-level Programming Languages
Language Key Data Application Area Origin of Names
FORTRAN IBM (1957) Scientic programming FORmula TRANslation language
LISP MIT (1958) Symbolic computation (AI) LISp Processing Common Lisp Object System
COBOL USA (1959) Business data processing COmmon Business-Oriented Language
BASIC (1965) Simple on PC Beginners All Purpose Symbolic Instruction Code
C Bell (1972) Systems programming Predecessor language was named B
PROLOG (1972) Symbolic computation (AI) PROgramming LOGic (Frence)
Ada USA (1980) Real-time distributed systems Ada Augusta Byron collaborated with nineteenth-
century computer pioneer Charles Babbage
Smalltalk (1980) Graphical user interfaces; Object-
oriented programming
Objects talk to one another via messages
C++ Supports objects and objected-
oriented programming
Incremental modication of C (++ is the C
increment operator)
JAVA SUN (1995) Supports Web programming Originally named Oak
Chen CL 16
Progress of Programming Languages
1955
1960
1965
1970
1975
1980
1985
1990
1995
2000

Y
e
a
r
Progress of Programming Languages
(Machine Language) (Assembly Language)
01011010 ADD
Chen CL 17
Progress of Programming Languages
1955
1960
1965
1970
1975
1980
1985
1990
1995
2000

Y
e
a
r
Progress of Programming Languages
(Machine Language) (Assembly Language)
FORTRAN
DO 7, LOOP = 1,5
READ *, X, Y
AVE=(X+Y)/2.0
PRINT *, X,Y,AVE
7 CONTINUE
END
Chen CL 18
Progress of Programming Languages
1955
1960
1965
1970
1975
1980
1985
1990
1995
2000

Y
e
a
r
Progress of Programming Languages
(Machine Language) (Assembly Language)
FORTRAN
COBOL
01 EMPLOYEERECORD
05 EMPLOYEENUMBER PIC 9(5)
05 EMPLOYEENAME PIC X(30)
05 BIRTHDATE
10 BIRTHMONTH PIC 99
10 FILLER PIC X
10 BIRTHDAY PIC 99
05 DATEHIRED
10 MONTHHIRED PIC 99
10 FILLER PIC X
10 DAYHIRED PIC 99
Chen CL 19
Progress of Programming Languages
1955
1960
1965
1970
1975
1980
1985
1990
1995
2000

Y
e
a
r
Progress of Programming Languages
(Machine Language) (Assembly Language)
FORTRAN
COBOL
LISP
SCHEME
COMMON
LISP
CLOS
PROLOG
(defun length (x)
(cond ((null x) 0)
(t(+1 (length (cdr x))))))
(length (I Love Computers))
3
Chen CL 20
Progress of Programming Languages
1955
1960
1965
1970
1975
1980
1985
1990
1995
2000

Y
e
a
r
Progress of Programming Languages
(Machine Language) (Assembly Language)
FORTRAN
COBOL
LISP
SCHEME
COMMON
LISP
CLOS
PROLOG
BASIC
VISUAL
BASIC
Dim i, sum

sum = 0
For i = 1 to 10
sum = sum + 1
Next i
Chen CL 21
Progress of Programming Languages
1955
1960
1965
1970
1975
1980
1985
1990
1995
2000

Y
e
a
r
Progress of Programming Languages
(Machine Language) (Assembly Language)
FORTRAN
COBOL
LISP
SCHEME
COMMON
LISP
CLOS
PROLOG
BASIC
VISUAL
BASIC
ALGOL60
PASCAL
MODULA2
MODULA3
if (i > 0) then
x := 10
else
y := 5
Chen CL 22
Progress of Programming Languages
1955
1960
1965
1970
1975
1980
1985
1990
1995
2000

Y
e
a
r
Progress of Programming Languages
(Machine Language) (Assembly Language)
FORTRAN
COBOL
LISP
SCHEME
COMMON
LISP
CLOS
PROLOG
BASIC
VISUAL
BASIC
ALGOL60
PASCAL
MODULA2
MODULA3
CPL
C
if (i > 0)
x = 10;
else
y = 5;
Chen CL 23
Progress of Programming Languages
1955
1960
1965
1970
1975
1980
1985
1990
1995
2000

Y
e
a
r
Progress of Programming Languages
(Machine Language) (Assembly Language)
FORTRAN
COBOL
LISP
SCHEME
COMMON
LISP
CLOS
PROLOG
BASIC
VISUAL
BASIC
ALGOL60
PASCAL
MODULA2
MODULA3
CPL
C
SIMULA
SMALLTALK
C++
C++
Standard
Chen CL 24
Progress of Programming Languages
1955
1960
1965
1970
1975
1980
1985
1990
1995
2000

Y
e
a
r
Progress of Programming Languages
(Machine Language) (Assembly Language)
FORTRAN
COBOL
LISP
SCHEME
COMMON
LISP
CLOS
PROLOG
BASIC
VISUAL
BASIC
ALGOL60
PASCAL
MODULA2
MODULA3
CPL
C
SIMULA
SMALLTALK
C++
C++
Standard
ADA
JAVA
Chen CL 25
Progress of Programming Languages
1955
1960
1965
1970
1975
1980
1985
1990
1995
2000

Y
e
a
r
Progress of Programming Languages
(Machine Language) (Assembly Language)
FORTRAN
COBOL
LISP
SCHEME
COMMON
LISP
CLOS
PROLOG
BASIC
VISUAL
BASIC
ALGOL60
PASCAL
MODULA2
MODULA3
CPL
C
SIMULA
SMALLTALK
C++
C++
Standard
ADA
JAVA
MATLAB
Chen CL 26
MATLAB ?
MATrixLABoratory
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
eectively
Chen CL 27
Why MATLAB ?
Outstanding Features
Signicantly 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
MATrixLABoratory
Chen CL 29
Thank You for Your Attention
Questions Are Welcome

S-ar putea să vă placă și