421920 Using Templates for Demonstrating Good Programming Practices

Wednesday, November 11, 2015: 1:55 PM
Alpine East (Hilton Salt Lake City Center)
Mordechai Shacham, Ben Gurion University of the Negev, Beer-Sheva, Israel and Michael B. Cutlip, University of Connecticut, Storrs, CT

       Computer based numerical problem solving (CBNPS) is one of the most widespread application of the computers in chemical engineering education and practice (Shacham et al. 2009). Mathematical software packages such as Excel®, MAPLE™, MATHCAD®, MATLAB®, Mathematica®, and POLYMATH™ are currently used routinely for numerical problem solving in engineering education. In order to familiarize engineering educators with the most widely used packages Cutlip et al. 1999 assembled a set of ten benchmark problems that are  characteristic of various core courses in the chemical engineering curriculum. The solutions of this problem set, using the various packages were presented in the ASEE Summer School of for Chemical Engineering Faculty which was held in Snowbird, UT in August of 1997. Shacham and Cutlip, 1999 carried out a comparison of the various software packages using the benchmark problems. The comparison was based on numerical performance, user friendliness and the guidance provided by the program for preparation and documentation of the model and the results, and alteration of the model for parametric studies. Based on the result of this and additional studies (Cutlip et al. 2009), it has been concluded that packages that do not require programming (such as Polymath) can be preferable with respect to user friendliness and the guidance provided by the program for preparation and documentation of the model and the results, however they are usually limited to solution of Single Model-Single Algorithm (SMSA) problems. The use of packages that require programming (such as MATLAB) is essential for solving more complex problems with some combination of Multiple Models and Multiple Algorithms (MMMA).

       In order to provide the required guidance for preparation and documentation of the model and the results when using packages that require programming, we prepared templates that guide the user in these aspects. The templates are implemented using MATLAB. So far templates have been prepared for solving systems of nonlinear algebraic equations, systems of ordinary differential equations (ODE), and polynomial, multiple linear and nonlinear regression. The template requires input of the model, variable names, values and units in a standard  format and display a standard format results report.

       The principles that followed while displaying the results are: 1. Display each result the first time it becomes available in order to help debugging the problem., 2. Display full information (variable name, value and units) for all the variables, 3. Display also information that is not immediately needed, but may be required in the future, and 4. Try to minimize repeated display of the same information.

       For demonstration of the typical contents of the standard report that follows these principles, let us consider a problem of “Simultaneous Multicomponent Diffusion of Gases” (problem 10.8 in Cutlip and Shacham, 2008). This problem includes three ODEs for computation of the concentration of various components: CA, CB and CC, three explicit equations for calculating mole fractions of the components xA, xB and xC, six constants representing the molar fluxes, NA, NB and NC, and the molecular diffusivities,  DAB, DBC and DAC, of the various components.

       . The constant and initial variable values (including variable names and units) are displayed in Table 1. This information is displayed before the solution of the problem starts in order to help with the debugging of the problem.          In Table 2, part of the tabular results, obtained after the integration has been completed, are shown. In the “Results Summary Table” the names, units, minimal, maximal and final values of the state, and explicit variables are displayed. The “Complete Tabular Results” section contains separate tables of the concentrations and the explicit variable values vs. the independent variable according to the number of reporting points requested by the user (only part of this table is displayed).  Observe that the column heading contain variable names and units. A plot of the dependent variables (CA, CB and CC in this case) vs. the independent variable (z) is also presented (Figure 1).

       We believe that the templates we have developed enable better training of the engineers in the aspects of programming that are the most important for them, namely, the preparation and debugging of the model of the problem in hand and presentation of precise,  accurate and complete information regarding the computational results.

       The complete set of templates and the associated explanations and examples are available at ftp://ftp.bgu.ac.il/shacham/templates. Our intention is to develop MATLAB templates for advanced numerical problem solving, including solution of ODE boundary value problems, differential-algebraic system of Equations (DAE), partial differential equations (PDE), parameter estimation in dynamic systems and linear and nonlinear programming

       In the extended abstract and the presentation the complete set of templates that we have developed will be described in more detail and their use in ChE education will be discussed.

           

References

1.     Cutlip, M., J.J. Hwalek, H.E. Nuttall, M. Shacham, J. Brule, J. Widman, T. Han, B. Finlayson, E.M. Rosen, and R. Taylor, “A Collection of 10 Numerical Problems in Chemical Engineering Solved by Various Mathematical Software Packages,” Computer Applications in Engineering Education, 6, 169 (1998)

2.     Cutlip, M. B. and Shacham, M.  Problem Solving In Chemical and Biochemical Engineering with Polymath, Excel and MATLAB. Prentice-Hall, Upper Saddle River, New-Jersey, 2008.

3.     Cutlip, M. B.,  Brauner, N. and M. Shacham, " Biokinetic Modeling of Imperfect Mixing in a Chemostat – an Example of Multiscale Modeling", Chemical Engineering Education , Vol. 43. No. 3, 243-248 (2009)

4.     Shacham, M. and M. B. Cutlip, “Selecting the Appropriate Numerical Software for a Chemical Engineering Course”, Computers chem. Engng., 23(suppl.), S645-S649(1999)

5.     Shacham, M., Cutlip, M. B. and N. Brauner, "From Numerical Problem Solving to Model Based Experimentation – Incorporationg Computer Based Tools of Various Scales into the ChE Curriculum", Chemical Engineering Education, Vol. 43. No. 4, 315- 321 (2009)

Table 1.  Display of the initial values for the example problem

Prob. 10.8 - Simultaneous Multicomponent Diffusion of Gases

 

Constants

NA = 2.115e-005   (kg-mol/m^2-s)

NB = -0.0004143   (kg-mol/m^2-s)

NC = 0   (kg-mol/m^2-s)

DAB = 0.000147   (m^2/s)

DBC = 0.0001245   (m^2/s)

DAC = 0.0001075   (m^2/s)

CT = 0.0074309   (kg-mol/m^3)

 

 Variable values at the initial point

z = 0   (m)

CA = 0.0002229   (kg-mol/m^3)

CB = 0   (kg-mol/m^3)

CC = 0.007208   (kg-mol/m^3)

 Explicit variables 

xA = 0.029996   (-)

xB = 0   (-)

xC = 0.97001   (-)

Figure 1.  Plot of the dependent variables vs. the independent variable  for the example problem

Table 2.  Display of the solution for the example problem

       Results Summary Table

Variable

Minimal

Maximal

Final

Units

z

0

0.001

0.001

(m)

CA

4.79E-08

0.0002229

4.79E-08

(kg-mol/m^3)

CB

0

0.0027013

0.0027013

(kg-mol/m^3)

CC

0.0047296

0.007208

0.0047296

(kg-mol/m^3)

xA

6.45E-06

0.029996

6.45E-06

(-)

xB

0

0.36352

0.36352

(-)

xC

0.63648

0.97001

0.63648

(-)

       Complete Tabular Results

z

CA

CB

CC

(m)

(kg-mol/m^3)

(kg-mol/m^3)

(kg-mol/m^3)

0

0.0002229

0

0.007208

2.50E-05

0.00021605

8.24E-05

0.0071325

5.00E-05

0.00020928

0.0001639

0.0070577

7.50E-05

0.00020258

0.0002445

0.0069838

0.0001

0.00019596

0.0003243

0.0069106

              •

              •

              •

0.0009

1.81E-05

0.0024796

0.0049332

0.000925

1.35E-05

0.0025359

0.0048815

0.00095

8.96E-06

0.0025916

0.0048303

0.000975

4.45E-06

0.0026467

0.0047797

0.001

4.79E-08

0.0027013

0.0047296

      


Extended Abstract: File Uploaded
See more of this Session: Best Practices for Teaching Computational Tools and Assessment
See more of this Group/Topical: Education Division