Book 9
Book 9
ABSTRACT: A new introductory course for modeling and computation, with main em-
phasis on computer-based problem solving has been developed. Advanced features for
enhancing learning effectiveness included in the course are: the use of real life engineering
problems as starting points for learning new material, multistage problems, where the
problem difficulty and the complexity of the computational tool are gradually increased. The
programming assignments involve mainly modification of examples, and self-grading with
immediate feedback ensures mastery level completion of the assignments. The website of the
course is http://www.bgu.ac.il/chem_eng/pages/Courses/shacham%20courses/intoduction.htm.
ß 2005 Wiley Periodicals, Inc. Comput Appl Eng Educ 13: 137 145, 2005; Published online in Wiley
InterScience (www.interscience.wiley.com); DOI 10.1002/cae.20039
137
138 SHACHAM
such an early stage of studying computation that names to cell addresses and changing the definitions
results obtained from the computer should never be of the if statements and some intrinsic functions. The
blindly accepted but must be critically examined for conversion proceeds line by line where the correctness
physical feasibility. of every finished line can be verified by comparing
The example is built up in stages. At first, the the resultant numerical value with the POLYMATH
calculations are carried out for one set of input data: result.
temperature and pressure. In the second step, the The conversion to MATLAB is done first in an
calculations are carried out for about a hundred interactive mode. The ordered equations are copied
different combinations of temperature and pressure, one by one from the POLYMATH solution report and
and in the third step the results of the calculations are pasted into the MATLAB command window, for one
presented in tabular and graphical forms. set of temperature and pressure values. The intrinsic
The mathematical model of the example is first function names and syntax are changed as needed.
set up using the ‘‘Nonlinear Equation Solver’’ pro- This, again, enables line by line verification of the
gram of the POLYMATH package. POLYMATH is the MATLAB model. The finished model can be copied
easiest to use for this purpose because it requires from the command window and pasted into the
minimal modification of the equations and the MATLAB editor to create an m-file. This concludes
variable names. The equations can be entered in the the first part of the example, which includes the
same order as they appear in the problem defini- preparation and verification of the mathematical
tion, even if the calculation order is different, since model of the problem with POLYMATH, Excel, and
POLYMATH reorders the equations in the right calcu- MATLAB.
lation sequence. The program also issues warnings In the second part, the calculations are carried out
for undefined variables, so that common, difficult to for about a hundred different combinations of tem-
detect errors, like using 0 (zero) in the variable name perature and pressure. Only Excel and MATLAB are
in one place and the letter ‘‘o’’ somewhere else, can be used in this part. In Excel the column containing the
easily detected. formulas of the model can be duplicated as many
The POLYMATH model of the problem is solved times as needed while providing the addresses of the
for a few selected values of temperatures and pres- pertinent temperature and pressure values. However,
sures and the results are compared with literature data, the most convenient and effective way to carry out the
in order to verify the correctness of the model. After calculations is by using the ‘‘Two-Input Data Table.’’
that we proceed to convert the model for solution by In MATLAB, several new concepts must be
Excel and MATLAB. learned in order to carry out repetitive calculations
The conversion to Excel involves ‘‘pasting’’ the while changing the parameter values. The m-file con-
POLYMATH model into two adjacent columns of an taining the model of the problem must be converted
Excel worksheet. In the first column the POLYMATH into a user-defined function. A separate main program
model is retained as is, for documentation purposes. (m-file) must be written where the parameters are
On the second column the equations are converted to stored in one-dimensional arrays and the function is
Excel formulas, essentially by changing the variable called repeatedly with different parameter values by
140 SHACHAM
means of for commands. The results are stored in a of the course’s time (12 15 h of lectures and
two-dimensional array and various display and plot recitation sessions) to complete it.
commands are used to display the results in tabular
and graphic forms (linear and logarithmic scales).
In this first chapter, special emphasis is put on ITERATIVE SOLUTION OF A
good engineering and programming practices. The NONLINEAR EQUATION
students are expected to describe all the variables,
including the units used next to the equation in which The objective of this chapter is to introduce the
the variable is calculated and also when displaying its students to the concept of iterative, numerical solution
numerical value in the results. In the graphs prepared, of problems. The contents of this chapter are pre-
the students are expected to mark clearly the axes, to sented in Table 2. The two class examples used in
use scaling appropriate to the order of magnitude of this chapter are the calculation of flow rate in a
the variables, to remove unused graph areas that often pipeline (Cutlip and Shacham [4]) and the calculation
generated by the automatic scaling routines of the of outlet temperatures in a countercurrent flow-heat
software, and to use right proportion between the exchanger. The first example involves the solution of
graph and the letter sizes. In MATLAB, good pro- the Bernoulli equation for the fluid velocity where the
gramming practice requires clearing the workspace pressure drop, the elevation difference, the length, and
and the command window before starting the execu- the diameter of the pipe are specified. The POLY-
tion and explicitly defining the preferred format for MATH nonlinear equation solver is used for setting
printing the results. up the problem and solving the equations for a few
The Redlich Kwong equation of state is used in selected combinations of pipe lengths and diameters.
all the class examples presented. The homework At this point the concept of initial estimate, which is
assignments may include different cubic equations of essential when iterative solution techniques are used,
state (Soave Redlich Kwong or Peng Robinson) is introduced and the selection of a physically sensible
or calculation of the adiabatic flame temperature ([4], initial estimate is emphasized.
this problem can be represented by a cubic equation if After that the model equation are converted to
the heat capacities are correlated with 2nd degree Excel formulas and at first, the ‘‘Goal Seek’’ tool of
polynomials). Excel is used for solving the nonlinear equation. But
This chapter represents, for most of the students, the use of Goal Seek is tedious if the calculation has to
the first introduction to the use of the POLYMATH be repeated many times for different parameter (pipe
package, to computer (MATLAB) programming, and length and diameter, in this case) values. For repetitive
to the use of the three packages for engineering pro- calculations the successive substitution method is
blem solving. Most of the basic material of the course introduced. Using this method requires rewriting the
is included in this chapter and it takes about one third Bernoulli equation so as to generate a converging
sequence of iterations. The attainable accuracy in reasonably fast for all the examples and assignments
iterative solutions is discussed and the concept of the that included in this chapter.
stopping criterion based on an error tolerance is The homework assignments and exams for this
introduced. chapter include solving various equations of state
The new material learned in MATLAB includes (cubic or higher order) for the molar volume, cal-
the global variables, which are used to transfer the culating terminal velocity of falling particles, bubble
current parameter values to the user defined function point, dew point and isothermal flash calculations
and the while statement which is used to stop the for ideal multi-component mixtures, and calculating
iterations when the stopping criterion is satisfied or adiabatic flame temperature in combustion.
the maximum allowed number of iterations exceeded.
The countercurrent heat exchanger problem
involves the calculation of the outlet temperatures MULTIPLE-LINEAR, POLYNOMIAL,
and the heat exchanger duty when the inlet tempera- AND NONLINEAR REGRESSION
tures, fluid properties, and heat transfer area and
coefficients are specified. The problem is converted The contents of this chapter are shown in Table 3. The
into the form of a single nonlinear equation by solving objective of the chapter is to enable the students to use
the cold fluid and hot fluids heat balance equations for POLYMATH, Excel, and MATLAB to fit a straight
the unknown temperatures and the iterations are line, a polynomial, and a linear or a linearizable non-
carried out on the heat duty only. linear regression model to data and to analyze the
The determination of an initial guess for the heat quality of the fit using the variance, the standard
duty represents a special challenge in this case and it deviation, the correlation coefficient, the 95% con-
provides an excellent example of physical and mathe- fidence intervals on the parameters and the residual
matical feasibility of the initial guess. If too high heat plot. This chapter is built around three examples
duty is specified as an initial guess (or reached during ‘‘Fitting a Straight Line to Thermal Conductivity
the iterations) that may lead to higher exit temperature Data,’’ ‘‘Heat Evolved During the Hardening of
of the cold fluid than the inlet temperature of the hot Portland Cement’’ (Daniels and Wood, [11]), and
fluid which is physically impossible. At the same time ‘‘Fitting Polynomials and Correlation Equations to
such temperatures require calculation of the logarithm Vapor Pressure Data’’ (Shacham et al. [12,4]).
of a negative number (in the expression of the logari- Solving the straight-line example by POLY-
thmic mean temperature difference) which is compu- MATH serves as an introduction to the basic concepts:
tationally impossible. model parameters, confidence intervals, the correla-
For most combinations of the input data values tion coefficient, the variance, and the residual plot. All
the successive substitution technique diverges and of those are automatically prepared and displayed by
this provides the opportunity to introduce the secant POLYMATH. In the thermal conductivity example
method. Similarly to successive substitution, this all the indicators show excellent fit (the correlation
method is easy to program and to use and it converges coefficient is 0.9997) however, the residual plot
received in the previous trial. This cycle of self-test, assignments and every student gets a different set of
feedback, and correction can be repeated as many numerical data for the exam. The problems are solved
times as needed, to ensure that the student has full using the software package specified in the problem
understanding of the problem and knows how to solve statement and the student grades his own solution
it correctly. After arriving at the correct solution he using a self-test utility. The feedback provided by the
submits the report on the assignment, including the utility is similar to that of the homework assignments
programs that were used for solving it, electronically, but the student is allowed to take the self-test for a
so that the non-numerical aspects of the report can particular question only twice (if time permits). The
also be checked. report on the solution is submitted electronically and
The homework assignments represent only 20% some of the exams are checked and re-graded manual-
of the total grade of the course, yet most students ly, to ensure that the grade given by the self-test utility
invest considerable effort to get all homework assign- is fair and proper credit is given to the various ques-
ments perfect. tions even if an incorrect numerical value is carried
over to the subsequent answers.
MIDTERM AND FINAL EXAMS
The midterm and the final exams of the course are DISCUSSION AND CONCLUSIONS
held in a computer laboratory, under supervision,
where the students have to present their identity card The particular structure of the introductory course in
to take the exam. The duration of the midterm exam is modeling and computation has evolved over several
2 h and the final exam is 3 h. The questions presented years. One of the latest revisions took place 2 years
in the exams are similar to those of the homework ago when it was decided to extend the course by
BIOGRAPHY