Documente Academic
Documente Profesional
Documente Cultură
All the programs and worksheets discussed in this appendix appear on this CD-ROM,
and on the Web site www.wiley.com/college/sandler. It is my intention to add to and
update these programs on this Web site.
First, some general comments and instructions for these programs and MATHCAD
worksheets. I believe the simplest and most easily understood of the computational aids
offered here are the MATHCAD worksheets, since in this computer algebra package
the equations are written, in general, in the same form as in this book. Consequently,
the MATHCAD worksheets are easily changed to accommodate a different equation
of state or activity coefficient model. However, the MATHCAD package is required
in order to use these worksheets. Included on the CD-ROM is a 120-day evaluation
version of MATHCAD, should the software not otherwise be available to the reader.
Academic group purchases of this software through colleges and universities are avail-
able from MATHSOFT, Inc. The Visual Basic programs are provided in two forms.
One is as stand-alone Windows-based executable programs that can be used without
any additional software, but cannot be modified. The second form is as Visual Basic
code that can be modified, but only if user has access to a Visual Basic compiler. The
DOS Basic programs are also supplied in stand-alone executable and Basic code forms.
The stand-alone versions are run in a DOS window, and have less functionality than the
Visual Basic programs. Also, the DOS Basic UNIFAC program uses an older version
of UNIFAC (as a result of DOS Basic memory limitations). The Basic code programs
can be modified if a Basic or QUICKBASIC compiler is available. There are also three
MATLAB programs available. However, to run these, either MATLAB 7.0 (or higher)
must be installed on the computer or the file MCRInstaller.exe must first be run (as de-
scribed in Appendix B.IV). The MCRInstaller is on the CD-ROM accompanying this
book, or is available from MATHWORKS, Inc.
should appear. Once this process is completed for a program package, the program is
run from the Windows Start menu (lower left-hand corner of the screen) by clicking all
the programs, and choosing sandler (the default program group or the program group
you chose) and then one of the Visual Basic programs you have installed. This installa-
tion procedure needs to be done only once for each of the five program packages. After
that, access to the programs is through the Windows Start menu.
Appendix B.I-1 Property: A Visual Basic Program to Retrieve the Pure Fluid Constants
This Visual Basic program runs in the Microsoft Windows operating environment. It
contains values of the constants of pure fluids adapted from R. C. Reid, J. M. Praus-
nitz, and B. E. Poling, The Properties of Gases and Liquids, 4th ed., McGraw-Hill,
New York, 1986, Appendix A, with corrections and data from other sources. The data
for more than 600 compounds include the chemical formula, common name, molecu-
lar weight, freezing point, normal boiling point, critical temperature, critical pressure,
critical volume, critical compressibility factor Z, acentric factor ω, dipole moment,
constants in the ideal gas molar heat capacity equation
P vap (T ) At + Bt 1.5 + Ct 3 + Dt 6 T
ln = where t = 1 − (A.2-1)
Pc 1−t Tc
B D · P vap
lnP vap = A − + Cln(T ) + (A.2-2)
T T2
or
B
lnP vap = A − (A.2-3)
T +C
the equation number to which the constants apply, the valid temperature range for the
equation, the liquid density, and the temperature for this density. (Note that not all these
data are available for all compounds.)
A portion of the database is visible in a window of the main program window, and
may be searched manually by compound name or formula, or by scrolling with the up
and down arrow keys. A compound is chosen by double-clicking its name, formula, or
ID number. When a compound has been successfully chosen, its name will appear un-
der and at the left of the database display window. Once a compound has been chosen,
clicking the Show Property button will result in the data available for the compound
being displayed in the lower window, including the equations that will be used to cal-
culate the ideal gas constant-pressure heat capacity and the vapor pressure. Also, the
allowable range for the vapor pressure calculations automatically appears under the Cp
and Pvap buttons. This temperature range and the temperature steps for the calculation
of the vapor pressure or heat capacity can be changed. However, the vapor pressure
calculation will not be done if the temperature is below the minimum (Tmin) or above
the maximum (Tmax) allowable.
Clicking the Pvap button results in the appearance of a pop-up window with a graph
of the vapor pressure (in bar) versus temperature (in K). This graph may be copied
to the clipboard by clicking the Copy to clipboard button. It can then be pasted into
B.I Windows-Based Visual Basic Programs CDB3
an open Microsoft Word (or other) document using the Paste Special command from
the drop-down menu list under Edit in Microsoft Word, and then choosing the Device
Independent Bitmap option and clicking OK. The graph can then be resized in the
usual manner. Note that these instructions for copying and pasting graphs also apply to
all other Visual Basic programs described in this appendix.
The pop-up vapor pressure graph is closed by clicking Close in the pop-up window,
and a list of temperature and vapor pressures over the temperature range and interval
chosen is displayed in the data window. All data (and results of later calculations)
that appear in the data window of this program (and the other Visual Basic programs
discussed in this appendix) can be copied into a Microsoft Word (or other) document
by opening the document, highlighting some or all of the data in the data window, and
dragging it into the document. (Note that the data will appear as 8.5 point in the Courier
New font, but can easily be resized and/or reformatted in the document as desired.)
The heat capacity calculation, initiated by clicking the Cp button, is operationally
very similar to the vapor pressure calculation, except that the calculation can be done
over a larger temperature range than is allowed for the vapor pressure calculation.
First, in a pop-up window, a graph of the ideal gas constant-pressure heat capacity
versus temperature appears. This graph may be placed in an open Microsoft Word or
other document as described earlier. When the pop-up window is closed, a list of heat
capacity values as a function of temperature appears in the data window. This list may
be placed in a open document by highlighting and dragging it into the document.
To calculate either the vapor pressure or the heat capacity at only a single tempera-
ture, enter that temperature in both the from and to boxes, but do not set the interval in
the by box to zero, as this will result in an error message. No graph appears in a sin-
gle temperature calculation, and the single value of the vapor pressure or heat capacity
appears in the data window.
Clicking the Reset button clears all the data from the data window and returns the
user to the database window to choose another compound. Clicking the Exit button
closes the program.
Appendix B.I-2 Peng-Robinson Equation of State: A Visual Basic Program for Pure Fluid
Peng-Robinson Equation of State Calculations
This Visual Basic program runs in the Microsoft Windows operating environment and
uses the Peng-Robinson equation of state (Eq. 6.4-2) with the originally proposed tem-
perature dependence of the a(T ) parameter (Eqs. 6.7-6 to 6.7-9) to compute and plot a
variety of thermodynamic properties of a pure fluid.
The main buttons in the program window are as follows.
Find Compound: This button brings up the Property program and allows the user to
select a compound (identified by using the up and down arrow keys, by name, or
by formula) by double-clicking on it and then clicking the Accept button. This
will close the Property program, and in the data window the compound name,
formula, and data used in the equation-of-state calculations will be displayed.
These data have also been imported into the program for use in the equation-of-
state calculations.
Calculate EOS: After choosing the pressure range, step size, temperature, and type
of graph to be generated, pressing this button initiates the calculation. Depend-
ing on the choice made, a pop-up window with either a pressure (y-axis) versus
volume, pressure versus enthalpy, or pressure versus entropy plot will appear. If
the temperature is below the critical temperature and a large pressure range has
CDB4 Appendix B: Descriptions of Computer Programs and Computer Aids for Use with This Book
been chosen, the liquidus line will be shown over the whole pressure range, while
the vapor line will extend from low pressure only up to the vapor pressure of the
substance. If the temperature is above the critical line, only the vapor line will
appear. (Each of these graphs may be copied into an open Word document using
the Copy to clipboard - Paste Special - Device Independent Bitmap sequence
described in detail in the Property program.)
Closing the pop-up graph returns to the data window, which now contains a list
of temperature, pressure, molar volume of the vapor and liquid, enthalpy of the
vapor and liquid, and entropy of the vapor and liquid. The enthalpy and entropy
are with respect to the ideal gas reference state at 298.15 K and 1 bar (by default),
although the user can make other choices. For states in which only a single phase
is present, both the vapor and liquid properties will appear in the list, but will be
identical in value. This property list may be copied into an open document by
highlighting (with the mouse) and dragging it into the document.
Calculate VLE: After choosing a temperature range, interval, and graph type, press-
ing this button will initiate the vapor-liquid phase equilibrium calculation. A pop-
up window will first appear with either the temperature versus volume (phase
envelope), temperature versus mass density, or P (on a logarithmic scale) ver-
sus reciprocal temperature scale, depending on the user’s choice. Note that if the
upper end of the temperature range is near or above the critical temperature, a
“vapor pressure calculation did not converge” error message will appear, and only
the results up to the last converged calculation will be displayed.
Closing the pop-up graph returns to the data window, which now contains a list
of temperature, vapor pressure, vapor and liquid molar volumes, and vapor and
liquid densities.
The graph may be copied into an open Word document using the Copy to clip-
board - Paste Special - Device Independent Bitmap sequence described in de-
tail in the Property program, and the data in the data window can be copied by
highlighting and dragging it into an open document.
Appendix B.I-4 A Visual Basic Program for Activity Coefficient and Vapor-Liquid
Equilibrium Calculations Using the Modified UNIFAC Model
This Visual Basic program runs in the Microsoft Windows operating environment and
uses the Modified UNIFAC model (see Sec. 9.6) to compute and plot a variety of ther-
modynamic properties of a pure fluid. This program can be used with two-component
mixtures and produces graphs and tables, or for multicomponent mixtures to do calcu-
lations at a composition specified by the user. This program uses UNIFAC interaction
parameters (as updated in 2003) supplied by Professor Juergen Gmehling of Oldenberg
University, Germany, courtesy of the UNIFAC Consortium.
The main buttons in the program window are as follows.
No. of components: The initial default value is 2, although from the drop-down menu
up to 10 components may be chosen.
Temperature: The default value is 298.15 K, although the user can specify any tem-
perature below the critical temperature of the most volatile compound. However,
remember that the UNIFAC model is to be used only at low and moderate total
pressures.
Comp. No.: This counter is used to set the identification number for the component
whose properties and groups are to be set.
Name: Clicking in this box or the adjacent Find box brings up a window containing
the database described in the Property program that allows the user to search for
the compound by name or formula, or by using the up and down arrow keys. A
component is chosen by double-clicking on it and then pressing the Accept but-
ton. This will load into the UNIFAC program information about the component,
B.I Windows-Based Visual Basic Programs CDB7
including that necessary to calculate its vapor pressure at the temperature specified
previously. Note that important information about a compound for the UNIFAC
calculation is the frequency of each of its functional groups. This information is
available for some, but not all, components in the database, and when available it
is loaded into the UNIFAC program. The user can change the group assignments
for any component and add group assignments for any component for which they
had not been previously assigned as described below under the heading Group.
This information is added to the database by pressing the Save button.
Mole fraction: Here the user can enter the mole fraction of the component, if the
calculation is to be done for a multicomponent mixture or at a single composition
in a binary mixture. However, if calculations are to be done for a binary mixture
over the whole composition range (as described later), this value is ignored.
Pvap: If the vapor pressure constants are available for the component, the vapor pres-
sure (in bar) will appear in this box. However, the user can override this by en-
tering another value. Also, if the user decides to change the temperature, pressing
the Cal button will result in the calculation of the vapor pressure at the new tem-
perature.
Group: By navigating with the mouse, the user can enter the frequency (that is num-
ber) of each functional group in the compound (blank indicates zero). If the group
frequencies are not in the Property database, these will be blank, and the group
frequencies must be manually entered. Once this is done for a compound, and
the Save button is pressed, the Group data saved message will appear in the top
right of the window; if this compound is chosen for another calculation at some
time in the future, the Group data available? message will appear at the same
location, and the group frequencies will be loaded and appear. However, the user
can override these saved data.
Group summary: Clicking this button will display, for all the compounds, their name,
a list of the identification number of the subgroup, its description, and the fre-
quency with which it occurs in the compound.
Activity coefficient: Clicking this button will result in the calculation of the activity
coefficients for each of the compounds at the temperature and composition spec-
ified, which is displayed in the results window, together with the message “All
interaction parameters are available” if that is the case. However, if some of the
UNIFAC group-group interaction parameters are unavailable, the message “Inter-
action parameters unavailable (and set to zero) for the following pairs of groups,”
followed by the list of unavailable pairs, will appear.
gam vs x: Clicking this button results in the calculation of activity coefficients in a
binary mixture as a function of mole fraction. The activity coefficients versus the
mole fraction of compound 1 appear as a plot in a pop-up window, which may be
copied into an open document as described for earlier programs. When the Close
button is clicked, the results window displays a table of the activity coefficients of
both components and the excess Gibbs energy as a function of the mole fraction of
compound 1 in steps of 0.025. These results can be highlighted (with the mouse)
and dragged into an open document as described in the Property program.
Gex vs x: Clicking this button results in the calculation of activity coefficients and the
excess Gibbs energy in a binary mixture as a function of mole fraction. The excess
Gibbs energy versus mole fraction plot appears in a pop-up window, which may be
copied into an open document as described for earlier programs. When the Close
button is clicked, the results window displays a table of the activity coefficients of
both components and the excess Gibbs energy as a function of the mole fraction of
CDB8 Appendix B: Descriptions of Computer Programs and Computer Aids for Use with This Book
compound 1 in steps of 0.025. These results can be highlighted (with the mouse)
and dragged into an open document as described for the Property program.
P vs xy: Clicking this button results in the calculation of vapor-liquid equilibrium for
a binary mixture. P versus x and P versus y lines are plotted. When the Close
button is clicked, the results window displays the mole fraction of compound 1 in
the liquid phase, the mole fractions of compounds 1 and 2 in the vapor phase, and
the total pressure as a function of the liquid-phase mole fraction of compound 1
in steps of 0.025. These results can be highlighted (with the mouse) and dragged
into an open document as described for the Property program.
Clear results: Clicking this button clears all the results from the results display win-
dow, but keeps all the compound information if, for example, calculations are to
be done at another temperature.
Save results: Clicking this button allows the user to save the contents of the results
display window as a text (.txt) file.
Reset: Clicking this button clears all the information in the program, including the
compounds, their properties, and group frequencies, for a calculation with new
compounds.
Exit: Closes the program.
reaction equation. This procedure should be repeated until the reaction equation
is complete. Note that the program does not check if the stoichiometry is correct,
that is, if there is the same number of each type of atom on each side of the
equation. This is left to the user.
Ka at 298(K) Clicking this button results in the calculation of the chemical equi-
librium constant at 298.15 K. In the data window, the list of compounds in the
reaction, their stoichiometric coefficients (+ for products and − for reactants) is
reported, together with the values of the standard-state Gibbs energy and enthalpy
(heat) of reaction, the equilibrium constant, and the natural and base 10 logarith-
mic values of the equilibrium constant.
Ka in a range of T Clicking this button results in the calculation of the chemical
equilibrium constant over the range of temperatures that the user has specified in
the From T(K)=, To T(K)=, and by step boxes. In the data window, the results
appear in a table of temperature, ln Ka, log Ka, Ka, and the standard-state Gibbs
energy and heat of reaction. This list may be copied into an open document by
highlighting (with the mouse) and dragging into the document.
Graph: log Ka vs 1/T Clicking this button results in the appearance of a pop-up win-
dow containing a graph of log Ka (y-axis) versus the reciprocal of the absolute
temperature. This graph may be copied to the clipboard and pasted into a docu-
ment as described for the programs earlier in this appendix.
Graph: Grxn vs T Clicking this button results in the appearance of a pop-up window
containing a graph of standard-state Gibbs energy versus absolute temperature.
This graph may be copied to the clipboard and pasted into a document as de-
scribed for programs earlier in this appendix.
Graph: Hrxn vs T Clicking this button results in the appearance of a pop-up window
containing a graph of standard-state enthalpy (or heat of reaction) versus abso-
lute temperature. This graph may be copied to the clipboard and pasted into a
document as described for programs earlier in this appendix.
Reset: Clicking this button clears all the information in the program, including the
compounds and their stoichiometric coefficients, for a calculation with new com-
pounds.
Exit: Closes the program.
CP∗ = a + bT + cT 2 + d T 3
CDB10 Appendix B: Descriptions of Computer Programs and Computer Aids for Use with This Book
and a reference temperature and pressure T0 and P0 , respectively.1 (Note all temper-
atures are in K, and pressures are in bar.) The program will then calculate the com-
pressibility, specific volume, enthalpy and entropy departures from ideal gas behavior,
the enthalpy and entropy with respect to the ideal gas reference state at T0 and P0 , and
the fugacity at any state point. The calculations are done using the equations that ap-
pear in Chapter 6. In addition, at temperatures below the critical temperature, the vapor
pressure of the fluid can be computed using the procedure described in Chapter 7.
The data needed to run this program can be entered from the keyboard (and will then
be saved by the program in a user-named data file that can be used again) or read from
a data file. The program output will appear on the screen, and can be printed and/or
saved in a file.
This program is available as Basic source code and as executable module. The code
can be viewed with an text editor or word processor, and is documented with comment
statements so that the user can understand the structure of the program and the calcu-
lations that are being done in various parts of the program. The in-line documentation
also indicates those few parts of the program that would have to be changed to use
another cubic equation of state such as, for example, the Soave version of the Redlich-
Kwong equation. However, if changes to the code are made, the program will have to
be recompiled. Also, after viewing or making changes to the code, the program should
be saved as an ASCII or text file; otherwise it will not be readable by a Basic compiler.
indicates those few parts of the program that would have to be changed to use another
cubic equation of state such as, for example, the Soave version of the Redlich-Kwong
equation. However, if changes to the code are made, the program will have to be re-
compiled. Also, after viewing or making changes to the code, the program should be
saved as an ASCII or text file, otherwise it will not be readable by a compiler.
Appendix B.II-3 UNIFAC: A Basic Program for the Prediction of Activity Coefficients and
Low-Pressure Vapor-Liquid Equilibrium Using the UNIFAC Model
This appendix briefly describes a Basic language program for the prediction of activ-
ity coefficients in binary and multicomponent mixtures using the the original UNIFAC
model. In addition, low-pressure vapor-liquid equilibria (see Sec. 10.2) can be calcu-
lated and plotted for binary mixtures with the assumption that all vapor-phase fugacity
coefficients are unity. The program uses the files UFNRQM.DTA and UNFA44.DTA
that contain the group and interaction parameter data required by the UNIFAC pro-
gram. However, it is recommended that the Windows-based program UNIFAC be used,
as it has a better user interface greater functionality, and uses the more recent modified
UNIFAC model.
When using this UNIFAC program, the user first is asked to supply the number
of groups in each molecule from the menu of UNIFAC groups. Next, the user will
be asked to supply the temperature in degrees K. The activity coefficients can then
be calculated at a composition entered by the user, or for a binary mixture over the
composition range from 0 to 1. If a vapor-liquid equilibrium calculation is performed,
the output is x-y values and an x-y diagram, but the user must first supply either the
pure-component vapor pressures at the temperature of interest, or the constants in the
Antoine vapor pressure equation. The program output will appear on the screen and
can be printed and/or saved in a file.
The Basic language code and data files can be viewed with a text editor or word pro-
cessor. The code is documented with comment statements so that the user can under-
stand the structure of the program and the calculations that are being done in various
parts of the program. If changes are made, the program will have to be recompiled.
Also, after viewing or making changes to either the code or the data files, they should
be saved as an ASCII or text file; otherwise the code will not be readable by a compiler,
and the data files will not be readable by the program.
Appendix B.II-4 CHEMEQ: A Basic Language Program for the Calculation of Chemical
Equilibrium Constants as a Function of Temperature
This appendix briefly describes a Basic language program for the calculation of chem-
ical equilibrium constants, and standard-state heats and Gibbs energies of reaction as a
function of temperature. This program uses the data file REACT.DTA, which contains
species names, f G ◦ and f H ◦ data, and heat capacity constants for 99 compounds.
The user need only supply the stoichiometric coefficients for the species (following the
instructions that will appear on the screen) and the temperature range of interest for the
calculation. The program output will appear on the screen, and can be printed or saved
in a file. However, I suggest that the Windows program of Appendix B.I-6 be used, as
it has greater functionality and is coupled to the PROPERTY database.
The CHEMEQ program is available as Basic language code and as an executable
module that can be run in a DOS window. The code can be viewed with a text editor
or word processor, and is documented with comment statements so that the user can
understand the structure of the program and the calculations being done in the different
CDB12 Appendix B: Descriptions of Computer Programs and Computer Aids for Use with This Book
parts. Users can change the data file, REACT.DTA, to include additional components
of interest to them. However, after viewing or making changes to the code or the data
file, be sure that it is saved as an ASCII or text file. Otherwise, the code will no longer
be readable by a compiler, and the data file will no longer be readable by the program.
tion. The data are entered from a Microsoft Excel spreadsheet as described in the
worksheet.
VLLECALC To calculate vapor-liquid-liquid equilibrium using the simple one-
constant Margules expansion for the liquid phase and an ideal vapor phase.
files, and finally click PRMIX.exe. It will take a few moments to start up, and
ignore any messages that appear in the DOS window. Should the program result in
property values that do not make sense (e.g., imaginary values or negative values)
or lead to an error, the most likely cause is calculation of the properties for a
phase that does not exist at the temperature and pressure chosen, or the initial
guess for temperature or pressure is a poor one. In that case you should change
the conditions or the initial guess and redo the calculations.
PRFLASH.exe This program is very similar to PRMIX program, but is only for
isothermal flash calculations.
UNIFAC.exe This program can be used for up to a 10-component mixture to calcu-
late values of the activity coefficients at a specified composition, or for a binary
mixture to compute the activity coefficients, excess Gibbs energy and vapor-liquid
equilibrium at a specified composition. All calculations are done using the current
(January 2005) UNIFAC model and parameters, and assume an ideal vapor phase.
All property information such as the functional groups and their frequencies of oc-
currence, and the pure-component vapor pressures must be entered manually. To
access the program, open the MATLAB folder, click the UNIFAC folder and then
click UNIFAC.exe. It will take a few moments to start up the program, and ignore
any messages that appear in the DOS window.