Appendix A. Summary of Computer Programs

Several programs are furnished with the text to help you learn the material and to assist in repetitive and/or complex calculations. Programs are available for Microsoft Excel and MATLAB. There is significant duplication of capabilities among the two platforms. The software is updated periodically. Visit the web site listed in the front flap for the latest version of both the software and this appendix.

A.1. Programs for Pure Component Properties

Matlab/3D/PVT.m—3-D PVT for water fluid phases; PHT.m—3-D PHT for water fluid phases.

Matlab/Props/Props.dat—Critical properties, acentric factor, heat capacity constants, and Kamlet-Taft parameters for a variety of substances. Use ‘load Props.dat’ to load to workspace. Props-Browse.m–A quick summary of the compound name and ID number. Many programs load Props.dat.

Matlab/Psat/AntoineGet.m—Returns Antoine constants from database using ID numbers; AntoineTableBrowse.m—Use for a quick overview of ID numbers and temperature limits; AntoineTable.mat—The database, use load AntoineTable.mat to load to workspace for viewing; Tsat.m—Utility program for calculating the saturation temperature. Many programs load AntoineTable.mat.

Excel/Antoine.xlsx—A tabulation of Antoine coefficients for a variety of common chemicals.

Excel/Props.xlsx—Critical properties, acentric factor, heat capacity constants, and Kamlet-Taft parameters for a variety of substances. Use to copy/paste values into other workbooks.

Excel/Steam.xls—Steam property calculator. Same formulation implemented in Harvey, A. P., Peskin, A. P., Klein, S. A., NIST/ASME Steam Properties, Version 2-1, NIST Standard Reference Data Program, December 1997. Another good resource for steam properties for Excel and MATLAB is Xsteam available at www.x-eng.com/ (accessed 11/2011).

Excel/Preos.xls—An Excel workbook for calculating properties using the Peng-Robinson equation. Also calculates departure functions and thermodynamic properties.

Matlab/Chap07/Preos.m—Pure component P-V-T calculations via the Peng-Robinson equation of state. Loads data from Matlab/Props/Props.dat.

Matlab/Chap08-09/PreosPropsMenu.m—A GUI interface for calculating U, H, S, and f using the Peng-Robinson equation of state. Loads data from Matlab/Props/Props.dat.

A.2. Programs for Mixture Phase Equilibria

Matlab/ExamplePlot.m—Plot with multiple data sets, markers, lines, labels, and legend.

Matlab/TextExamples/Ex10_02.m—Raoult’s law adiabatic flash; Ex11_03.m—Fitting 1-parameter Margules; Ex11-07.m—Bubble T for MRL; Gammafit.m—Fitting of activity coefficients, Ex12_04.m—Scatchard-Hildebrand; Ex13_01.m—UNIFAC-VLE; Ex14_03.m—UNIFAC-LLE

Matlab/Chap10/RaoultTxy.m—T-x-y diagram using Raoult’s Law; Flshr.m—Isothermal VLE flash using Raoult’s law.

Matlab/Chap11-13/—See the gammaModels and TextExamples folders for appropriate routines.

Matlab/gammaModels/Marg1P.m—One-parameter Margules; Marg2P.m—Two-parameter Margules; uniquac.m—UNIQUAC equation; vanLaar.m—Van Laar equation; nrtl.m—NRTL equation; unifacVLE/unifacCaller.m—Example of function calls for VLE UNIFAC; unifacLLE/unifacCallerLL.m—Example of function calls for LLE UNIFAC.

Matlab/Chap14/LLEflash.m—Flash using UNIFAC or UNIQUAC.

Matlab/Chap15/Prfug.m—Peng-Robinson fugacities at a given state; Prmix.m—VLE using Peng-Robinson.

Matlab/Chap16/Residue.m – Residue curve calculator programmed to use UNIQUAC.

Excel/Flshr.xls—Two-phase isothermal flash using Raoult’s law. Currently set for a binary system using the short-cut Psat equation.

Excel/Actcoeff.xls—Activity coefficients as a function of composition. These spreadsheets may be modified to calculate excess Gibbs energy, fugacities, and P-x-y diagrams.

1. MARGULES—A spreadsheet to use with the MARGULES activity coefficient model.

2. REGULAR—A spreadsheet to calculate VLE for methanol + benzene using the van Laar and Scatchard-Hildebrand models.

3. NRTL, NRTL5—Binary and multicomponent (up to five components) NRTL activity coefficient models.

4. UNIQUAC, UNIQUAC5—Binary and multicomponent (up to five components) UNIQUAC activity coefficient model. The multicomponent model can be used for LLE.

5. UNIFAC(VLE)—A spreadsheet to use with the UNIFAC activity coefficient model for up to five components to model VLE.

6. UNIFAC(LLE)—Two spreadsheets to use with the UNIFAC activity coefficient model for up to five components to model LLE.

Excel/Gammafit.xls—Fitting activity coefficient parameters.

Excel/Prfug.xlsx—Component fugacities via the Peng-Robinson equation for up to three components. Useful for understanding mixing rules, and for manually following iterative steps for phase equilibria calculations.

Excel/Prmix.xlsx—Peng Robinson phase equilibria.

Excel/Residue.xlsm—Spreadsheet with macro for calculating residue curves for homogeneous systems using UNIQUAC for up to three components.

Excel/Virialmx.xls—Spreadsheet that calculates the second virial coefficient for a binary mixture using the critical temperature, pressure, and volume.

Excel/Wax.xls—A spreadsheet to calculate wax solubilities.

Excel/Ichemt.xls—A chemical theory spreadsheet for calculating the true mole fractions at a given superficial mole fraction. The equilibrium constants need to be known before using the program.

A.3. Reaction Equilibria

Matlab/TextExamples/Ex17_09.m—Shortcut adiabatic reaction.

Matlab/Chap17-19/Kcalc.m—Equilibrium constant calculator for detailed van’t Hoff; RxnA-dia.m—Adiabatic reaction with full van’t Hoff; Gibbsmin.m—Gibbs minimization; Gprime-Calc.m—Transformed properties for biological systems; IChemTheory.m—Ideal chemical theory.

Excel/Kcalc.xls – Workbook to calculate equilibrium constants as a function of temperature.

Excel/Rxns.xls – Workbook with spreadsheets used for multiple reaction equilibria in the text.

1. RXNADIA-shortcut—Shortcut van’t Hoff for ammonia example.

2. RXNADIA—Detailed van’t Hoff for ammonia example.

3. DUALRXN—Simultaneous reactions.

4. GIBBSMIN—Gibbs minimization.

5. SMPRXN—Simultaneous reactions with phase equilibria.

Excel/CL2H2O.xlsx—Worked electrolyte example.

Excel/GprimeCalc.xlsx—Transformed Gibbs energies for biological systems.

Excel/IdChemTheory.xlsx—Ideal chemical theory.

A.4. Notes on Excel Spreadsheets

*.XLSX Files

These workbooks are a starting point for homework problems. You may need to modify the existing spreadsheet to work a homework problem. The *.XLSX files are provided in “document protected” format so that inadvertent modification will not occur. Only the unlocked cells which appear blue on the screen may be modified without turning the document protection off. (To change the document protection, select “Protection....” from the “Tools” menu. No passwords are used on the distributed spreadsheets. To change the protection status of individual cells, choose “Cell Protection” from the “Format” menu when document protection is turned off.)

While the tabular format of Excel is a benefit, the disadvantage is that it is very difficult to figure out how a pre-programmed sheet works and/or to debug. To find out the interdependencies of cells, first unprotected the sheet, then use the “auditing” tools.

Online Supplements

An online supplement covers topics including naming of variables, importing text files, plotting multiple data sets on the same axes, setting up successive substitution, use of Solver, and array operations. The textbook web site provides links for tutorial videos for the software.

A.5. Notes on MATLAB

MATLAB content is arranged in folders to maximize computing flexibility and power. Files in the folders gammaModels, Props, and Psat should not be moved because other programs call routines in those folders.

When MATLAB first starts, the current directory that holds the code of interest must be selected in the “current directory” drop-down box. Some of the code for this text is organized into subfolders relative to that directory; if a routine cannot be found, this may be the reason. Use the “path” command to see the full search path. Use the “addpath” command or the “genpath” nested into the addpath as shown in the Example files. For example, addpath(../Psat) will permit calling any functions in the Psat folder at the same folder level as any routine that is run in that session. The statement addpath(genpath(../gammaModels)) will add a path to include any routines in the gammaModels or any subfolder of gammaModels for routines that are run at the same folder level as gammaModels. Use additional “../” to move up additional folder levels. Absolute paths can be used in code, but can cause problems if .m files are shared and the recipient does not put the routines in exactly the same folder. The addpath statement must be run once each session unless save-path is used. The convention we use for the text is to embed the addpath statements into the routines that need to access functions in different folders, and we use relative paths.

The display of MATLAB windows can be controlled through the “Desktop” menu; use the menu if a command window, workspace, or other window is not visible. MATLAB files for code for this text are unprotected; create a backup if you need to make changes. An overview of important commands and methods is furnished as an online supplement.

(), [], and {} have special meanings. Do not interchange them or you may get unexpected results. () are used for indicating arithmetic precedence. [] are used to indicate vectors and matrices. {} are used for cell arrays.

*.m and *.dat Files and File Naming

The MATLAB code is contained in .m files which may be scripts or functions. Scripts return the output to the workspace, while functions offer the capability to be called by other functions and return the results to the calling routine. For good programming practice, file names should match the function names, and each should be unique. At the time of this writing, MATLAB does not work well with spaces in file names, and such use leads to confusing error messages.

Online Supplements

Note that a MATLAB supplemental quick reference is available as an online supplement. An additional online supplement covers topics such as importing of text files, plotting, solving routines, minimization and optimizers, and matrix operations.

Note that “element-by-element” processing is powerful. For example, if A, B, and C are vectors with Antoine coefficients for multiple components, Psat = 10^(A – B./(T+C)) will produce a vector of vapor pressures at T. See the online MATLAB supplement for more details.

Matlab/SuppExamples contains files for the examples in the online supplement.

A.6. Disclaimer

The programs provided with this text are for educational use only. They are provided AS IS, without any warranty. They must not be sold under any circumstances.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
100.28.2.72