# (263f) Combining Various Software Tools for Enhancing Programming and Numerical Problem Solving Capabilities

#### AIChE Annual Meeting

#### 2019

#### 2019 AIChE Annual Meeting

#### Education Division

#### Computing for ChEs: Teaching Programming and Simulation Software

#### Tuesday, November 12, 2019 - 9:30am to 9:48am

At the Ben-Gurion University, first year students are required to take the introductory â€œModelling and Computationâ€ course where the mathematical software packages: POLYMATH (http://www.polymath-software.com) and MATLAB (http://www.mathworks.com) the Excel spreadsheet and the DIPPR (https://dippr.aiche.org) physical property database that is typically provided with POLYMATH are taught. The â€œModeling and Computation Courseâ€ is described in detail by Shacham (2005). In a more advanced â€œProcess Simulationâ€ course, MATLAB and DIPPR are used for modeling individual unit operations. UniSim (https://www.honeywellprocess.com) process simulation program is used for simulation of complete processes. This course is described in more detail by Shacham (2011).

The use of the different software packages will be demonstrated here by calculating the â€œAdiabatic Flame Temperature (AFT)â€ for Ethane and Methane natural gas mixtures (presented as problem 2.13 in Cutlip and Shacham, 2007, a copy of the problem definition is available at the ftp site: ftp://ftp.bgu.ac.il/shacham/AIChE_19/Appendix_A.pdf ) . Physical property data (heats of combustion and heat capacity equations and values) are typically available from classical thermodynamic books. The solution of most problems usually start using POLYMATH whose desirable properties are mentioned, for example, by Mahecha-Botero et al. (2011) who advise that the program is appropriate â€œfor solving systems of algebraic and ordinary differential equations because it requires minimal computer programming skills and is extremely simple to use.â€

**Exercise 1 (1 ^{st} year CHEG students) **

In this exercise the students are required to formulate the POLYMATH program for calculating AFT for one particular value of *x* (th air-to-fuel ratio) and a value of *y* (inlet ethane concentration). The POLYMATH program, which is self-explanatory, is shown in Figure B-1. (Note: the Figures and Tables wonâ€™t be included here in this paper, but they are available at the FTP site ftp://ftp.bgu.ac.il/shacham/AIChE_19/Appendix_B.pdf ). The solution for AFT involves solution of a nonlinear algebraic equation (NLE) which can be easily solved by pressing the pink arrow when the problem coding from Figure Bâ€“1 has been entered. Solutions obtained are, for example, AFT = 2198.0 K, for air-to fuel ratio of x=0.5 and 2503.3 K, for *x* = 1.

**Exercise 2 (1 ^{st}year CHEG students) **

The next exercise is to obtain and plot AFT values for various air to fuel ratios and natural gas compositions. MATLAB and Excel are more suitable for such an assignment, consequently the POLYMATH options of exporting the problem statement to MATLAB and Excel are used.

A typical MATLAB function (as generated by POLYMATH) for this Exercise is shown in Figure B-2. The students are required to prepare a main program that calls the MATLAB function and carries out the calculations for large sets of x and y values. The requested MATLAB program is shown in Figure B-3 and the resulting plot of AFT vs air-to- fuel ratio, generated by this program, is shown in Figure B-4. Students find that learning MATLAB programming by modifying an existing, working program is much easier than starting from scratch.

In solving Exercise 2 with Excel, an error-prone and difficult task is to replace the POLYMATH variable names in the data base equations by appropriate cell addresses. This can be expedited by exporting the POLYMATH code to Excel as shown in Figure B-5. In column â€œBâ€ of the Excel spreadsheet the original variable names are shown and in column â€œDâ€ the original equations. The modified equations, in which the variable names were replaced by their addresses, are inserted in column â€œCâ€. The solution for AFT is obtained by using the â€œSolverâ€ or â€œGoal Seekâ€ tools to minimize the contents of cell â€œC19â€ by changing the value that appears in cell C18. Starting with a correct spreadsheet representation of the problem definition, it is necessary to generate tabular and graphical representations of the AFT results for different parameter values.

**Exercise 3 (3 ^{rd} year CHEG students)**

The accuracy of the physical property data (heat of combustion and heat capacity correlations) included in the problem statement can be compared with the AFT obtained using the â€œConversion Reactorâ€ unit of the UniSim commercial process simulation program. The results of the UniSim calculations are shown in Figure B-6, for the parameter values x =. 1 and y = 0.75. The exit temperature from the conversion reactor is 2044 Â°C = 2317 K. The AFT temperature calculated, using the POLYMATH program for the same conditions is: 2503 K. Thus there is 8.03 % difference between the two solutions.

It is assumed that the significant difference between the AFT calculated by UniSim and the Excel model is caused by the difference in the precision of the physical property data used. This assumption can be checked by replacing the heat of combustion data and the heat capacity correlations in the POLYMATH model are replaced with up-to-date data from the DIPPR Physical Property Database. Note that a subset of 113 components from the DIPPR database are accessible from POLYMATH. This subset includes the six compounds included in the exercises.

The POLYMATH program, in which the heat of combustion data and the heat capacity correlations were replaced with the data and correlations from the DIPPR database, is shown in Figure B-7. The reported uncertainty for the heat of combustion data of CH_{4} and C_{2}H_{6} is: < 0.2 %. The uncertainty for the ideal gas heat capacity correlations for all the compounds is reported as < 1 %. The AFT calculated, using the program shown in Figure B-7 for the parameter values *x* = 0. 1 and *y* = 0.75, was AFT = 2313 K, thus the difference from the value obtained by UniSim is only 1.12%. Thus, using more accurate physical property data brings the solution much closer to the value obtained with UniSim.

**Conclusions**

The problem solving of the Adiabatic Flame Temperature (AFT) for Ethane and Methane Mixtures in Air provides a real system for a host of calculations that can be conducted with a variety of commonly used PC software packages and process simulators. Use of POLYMATH, Excel, MATLAB, DIPPR Database and the UniSim Process Simulator are integrated into a progression of problem solving of increasing complexity that can be introduced progressively within the Chemical Engineering curriculum. Students enjoy this relatively gradual approach that builds up their capabilities and understanding of both the problem and the required problem solver that is being used. The POLYMATH export to MATLAB and Excel considerably speeds up the learning of these software packages. The good results of the comparison with a Process Simulatorâ€™s results (with its internal data base) increases the studentâ€™s| confidence in the correctness of the problem solutions and helps to verify the results.

**References**

- 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, 2007. - Mahecha-Botero, A., Reaume, S., Grace, J.R., Ellis, N., â€œIndependent research as a teaching tool in graduate chemical reaction engineering. Case study: modelling isomerization of unsaturated fatty acids with catalyst deactivationâ€. Educ. Chem. Eng. 6 (1), e1â€“e9 (2011).
- Shacham, M., â€œAn Introductory Course of Modeling and Computation for Chemical Engineersâ€. Comput. Appl. Eng. Educ. 13, 137-145(2005)
- Shacham, M., â€œUse of Advanced Educational Technologies in a Process Simulation Courseâ€. Computer Aided Chemical Engineering, 29, 1135-1139(2011).