Вы находитесь на странице: 1из 15

Appendix B

Descriptions of Computer Programs and Computer Aids


for Use with This Book

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.

B.I WINDOWS-BASED VISUAL BASIC PROGRAMS


[The Visual Basic programs were written by Dr. Jaeeon Chang, and his help is greatly
appreciated.]
Before using the Visual Basic programs, the following procedure must be followed.
First, locate and click the VBasic Program Folder on the CD-ROM. Then choose
and click one of the five program packages (ChemEq package, Modified UNIFAC
package, Peng-Robinson mixture package, Peng-Robinson package, or Property pack-
age). Note that the folders with the word source contain the source code for each
of these program packages, and are of interest only if the user wishes to modify the
code. Next, click the setup icon. This will install the program, during which proce-
dure you will be asked for the directory and program group in which the program
CDB1
CDB2 Appendix B: Descriptions of Computer Programs and Computer Aids for Use with This Book

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

CP∗ = CPA + CPB · T + CPC · T 2 + CPD · T 3


the heat (enthalpy) and Gibbs energy of formation, the constants in one of the following
vapor pressure equations

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-3 Peng-Robinson Equation of State for Mixtures


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) and the van der Waals
one-fluid mixing rules (Eqs. 9.4-8) and combining rule (Eq. 9.4-9) to compute and plot
the phase behavior and thermodynamic properties of a mixture. The main buttons in
the program window are as follows.
Number of components: The initial default value is 2, though from the dropdown
menu up to 10 components may be chosen.
Comp. id.: This counter is used to set the number for the component whose properties
and groups are to be set.
Name: Clicking in this 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 button. This will load the
compound name, critical property information, and acentric factor into the Peng-
Robinson program.
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 only a single com-
B.I Windows-Based Visual Basic Programs CDB5

position in a binary mixture. However, if calculations are to be done for a bi-


nary mixture over the whole composition range (as described later), this value is
ignored.
Binary interaction parameter: Once all the compounds have been entered, the inter-
action parameters kij for each binary pair can be entered. The default value is zero,
and this is also the value for any like-like interaction (i.e., kii = 0). The values
of some binary interaction parameters can be found in Table 9.4-1; others may be
found in the research literature.
Type of calculation: By choosing the appropriate radio button, the compressibility,
fugacity, bubble point temperature or pressure, and dew point temperature or pres-
sure may be calculated, or an isothermal flash calculation can done (once the
needed state parameters are specified).
Feed state: By choosing the temperature, pressure, and either the vapor or liquid radio
button, and then pressing the Calculate button, a calculation is done. If the com-
pressibility calculation was chosen, the components, their mole fractions, temper-
ature, pressure, and the calculated compressibilities and molar volumes of both
phases appear in the results window. (Note that identical low values of the com-
pressibilities indicate that only the liquid phase is present, while identical larger
values indicate that only the vapor is present.) If the fugacity calculation was cho-
sen, a list of the compounds, their mole fractions, fugacities (in bar), and fugacity
coefficients for only the phase chosen appear in the results window.
If the bubble temperature calculation is chosen, the temperature field is cleared,
and the user can either enter a guess for the bubble point temperature (especially
useful near the mixture critical point) or leave it blank, in which case a program-
generated default guess is used. The calculation is initiated by clicking on the
Calculate button. The results displayed are the calculated bubble point tempera-
ture, the liquid feed composition, the resulting vapor compositions, the K values
(K = y/x), and the compressibilities of each of the phases. The bubble pressure
calculation is similar, except that the temperature is fixed, and either a user-chosen
or program-generated initial guess for the pressure is used. The input for the dew
point temperature calculation is similar to that for the bubble point temperature
calculation, except that the results displayed are the calculated dew point tem-
perature, the vapor feed composition, the resulting liquid compositions, the K
values (K = y/x), and the compressibilities of each of the phases. The input for
the dew point pressure calculation is similar to that for the bubble point pressure
calculation, except that the results displayed are the calculated dew point pres-
sure, the vapor feed composition, the resulting liquid compositions, the K values
(K = y/x), and the compressibilities of each of the phases.
The isothermal flash calculation requires a specification of the feed compo-
sition, temperature, and pressure. The results that appear in the results window
include the compositions of the feed, the resulting liquid and vapor compositions,
and the K = y/x values. Also given are the resulting numbers of moles of liquid
and vapor (based on one mole of feed), and the compressibilities of each of the
phases.
In each of these calculations, if the calculation did not converge, or if the con-
ditions were specified incorrectly, an error message will appear in the message
box at the top right of the program box.
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
CDB6 Appendix B: Descriptions of Computer Programs and Computer Aids for Use with This Book

envelope), temperature versus mass density, or P (on a logarithmic scale) versus


reciprocal temperature scale, depending on the user’s choice. Note that if the cal-
culation did not converge, the “Calculation not converging: one phase region or
poor initial guess” error message will appear. The user should then change the
conditions and/or initial guess and try again.
Summary: Clicking this button results in the components, their critical temperature,
critical pressure, acentric factor, and normal boiling point being displayed in the
results window. The values of all binary interaction parameters are also displayed.
Vary composition: This radio button appears whenever a binary mixture dew point
or bubble point calculation has been selected. Clicking this button results in cal-
culations being done over the complete mole fraction range of compound 1 in
steps of 0.01. The results first appear as a plot of temperature versus liquid and
vapor compositions (for bubble point or dew point temperature calculations) or
of pressure versus liquid and vapor compositions (for bubble point or dew point
pressure calculations). These plots may be pasted into a document as described
in the Property program. After closing the plot, the numerical results that ap-
pear in the results display window are the temperature, pressure, liquid and vapor
mole fractions of compound 1, and the compressibility factors of the liquid and
the vapor. These may be highlighted with the mouse and dragged into an open
document.
Clear results: Clears the results display window but retains all the component infor-
mation for additional calculations.
Save results: Saves all the results in the results display window as a text (.txt) file.
Reset: Clears all the data to start a new calculation with new components.
Exit: Exits the program.

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.

Appendix B.I-5 A Visual Basic Program to Calculate Chemical Equilibrium Constants


as a Function of Temperature: CHEMEQ
This Visual Basic program runs in the Microsoft Windows operating environment and
is used to calculate chemical equilibrium constants as a function of temperature. This
program provides graphs and tables of the results. The main buttons in the program
window are as follows.
No. of reactants: The initial default value is 1, though from the dropdown menu up
to 4 reactants may be chosen. Once the number of reactants has been chosen,
the reaction equation in terms of generic stoichiometric coefficients a, b, etc. and
components A, B, etc. of the reactants will be displayed. How these are changed
into numerical values for the stoichiometric coefficients and actual compounds
will be discussed later.
No. of products: The initial default value is 1, though from the dropdown menu up
to 4 reactants may be chosen. Once the number of products has been chosen, the
reaction equation in terms of generic stoichiometric coefficients and components
will be displayed. How these are changed into numerical values for the stoichio-
metric coefficients and actual compounds will be discussed next.
DB1 DB2: This program contains two radio buttons labeled DB1 and DB2. DB1 is
the limited database that was used in the DOS-based program that accompanied
the third edition of this textbook. It contains data for only 99 chemicals, but it
does include data for solids and some inorganic chemicals that are not present in
DB2. DB2 uses the very extensive database for gases and liquids of the Property
program. The database to be used is chosen by clicking the appropriate radio
button.
Stoichiometric equation: The general stoichiometric equation depending on the num-
ber of reactants and products is displayed. Clicking a stoichiometric coefficient
(lowercase letter) allows the user to replace it with its numeric value. Clicking
the compound (uppercase letter) in the equation results in a pop-up window with
the allowed compounds. Clicking the formula of a compound results in a return
to the main program window, with this formula replacing the generic letter in the
B.II DOS-based Basic Programs CDB9

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.

B.II DOS-BASED BASIC PROGRAMS


Appendix B.II-1 PR1: A Basic Language Program for Thermodynamic Properties
Calculations Using the Peng-Robinson Cubic Equation of State
This appendix briefly describes a Basic language program for the calculation of pure
fluid thermodynamic properties using the Peng-Robinson equation of state. This pro-
gram is available as Basic language code that can be modified by the user (for example,
to use it for the Soave–Redlich-Kwong equation of state) or as a module that can be run
from a DOS window. However, I suggest that the Windows program Peng Robinson be
used instead, though it cannot be modified unless the user has access to a Visual Basic
compiler.
When using this program the user will be asked to supply the critical temperature,
critical pressure, acentric factor, normal boiling point, and ideal gas heat capacity con-
stants in the equation

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.

Appendix B.II-2 VLMU: A Basic Language Program for Multicomponent Vapor-Liquid


Equilibrium Calculations Using the Peng-Robinson Cubic Equation of State
This appendix briefly describes a Basic language program for the calculation of species
fugacities and multicomponent vapor-liquid equilibrium calculations using the Peng-
Robinson equation of state with generalized parameters (Eqs. 6.7-1 to 6.7-4) and the
van der Waals one-fluid mixing rules (Eqs. 9.4-8 and 9.4-9). I suggest that the Windows
program of Appendix B.I-4 be used. However, user cannot modify that program unless
a Visual Basic compiler is available.
When using the PR1 program the user will be asked to supply the critical tempera-
ture, critical pressure, acentric factor, and normal boiling point of each species, and the
binary interaction parameter for each pair of species in the mixture.2 (Note all temper-
atures are in K, and pressures are in bar.) The program can then be used to calculate
the fugacity of each species, the bubble point temperature or pressure, the dew point
temperature or pressure, or an isothermal flash calculation. The calculations are done
using the equations that appear in Chapters 9 and 10.
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 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 cal-
culations that are being done in various parts of the program. The documentation also
1 The heat capacity parameters can be found in Appendix II and the critical properties in Table 6.6-1. However,
the parameters for a much more extensive list of substances can be found in the Windows-based program Property
of Appendix B.I-1.
2 The heat capacity parameters can be found in Appendix II and the critical properties in Table 6.6-1. However,
the parameters for a much more extensive list of substances can be found in the Windows-based program Property
of Appendix B.I-1. Some binary interaction parameters appear in Table 9.4-1.
B.II DOS-based Basic Programs CDB11

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.

B.III MATHCAD WORKSHEETS


Included on this CD-ROM is a collection of MATHCAD worksheets that can be used
for a variety of thermodynamic calculations. As a MATHCAD worksheet is largely
self-explanatory, these worksheets contain only simple documentation and/or explana-
tions. The MATHCAD worksheets are organized in five folders, the contents of which
are described below.
The P-R EOS folder contains a number of worksheets for Peng-Robinson equation-
of-state calculations for both pure components and mixtures. In the phase equilibrium
calculations, both phases are described by the Peng-Robinson equation of state. The
van der Waals one-fluid mixing rules are used in the mixture calculations. These work-
sheets are as follows.
PRVAPT To calculate the vapor pressure of a pure fluid at a given value of T .
PRVAPP To calculate the temperature at which the vapor pressure of a pure fluid will
have the value of P.
PRPROP To calculate the thermodynamic properties of a pure fluid at specified values
of T and P.
PRMIXPRP To calculate the thermodynamic properties of a mixture at specified val-
ues of composition, T , and P.
PRDEWT To calculate the dew point temperature and equilibrium liquid composi-
tions for a vapor mixture of specified composition and pressure P.
PRBUBT To calculate the bubble point temperature and equilibrium vapor composi-
tions for a liquid mixture of specified composition and pressure P.
PRDEWP To calculate the dew point pressure and equilibrium liquid compositions
for a vapor mixture of specified composition and temperature T .
PRBUBP To calculate the bubble point pressure and equilibrium vapor compositions
for a liquid mixture of specified composition and temperature T .
ISOTFLASH To calculate the equilibrium vapor and liquid compositions and ther-
modynamic properties of a mixture of specified feed composition and temperature
that is subjected to an isothermal flash (decrease in pressure).
ISOHFLASH To calculate the equilibrium vapor and liquid compositions and ther-
modynamic properties of a mixture of specified feed composition and initial tem-
perature and pressure that is subjected to an isenthalpic flash (for example, a
Joule-Thomson expansion).
ISOSFLASH To calculate the equilibrium vapor and liquid compositions and thermo-
dynamic properties of a mixture of specified feed composition and initial temper-
ature and pressure that is subjected to an isentropic flash (for example, expansion
through a well-designed nozzle).
∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗
The SRK EOS folder contains, for illustrative purposes, two worksheets for Soave–
Redlich-Kwong equation-of-state calculations for a pure fluid:
SRKPROP To calculate the properties of a fluid described by the Soave–Redlich-
Kwong equation of state at a specified T and P.
B.III MATHCAD Worksheets CDB13

SRKVAPP To calculate the vapor pressure of a fluid described by the Soave–Redlich-


Kwong equation of state at a specified temperature.
∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗
The ACT COEFF folder contains several worksheets for use in fitting activity coeffi-
cient data to some of the different models discussed in this textbook:
ACTCOEF A general worksheet that uses excess Gibbs energy data as a function of
composition to calculate parameters in activity coefficient models. The the van
Laar, two- and three-parameter NRTL, Redlich-Kister, and Wilson models can
be used. These models are accessed by double-clicking in the ACTCOEF work-
sheet that branches the user to the appropriate worksheet. This worksheet uses the
vanlaar1.mcd, vanlaar2.mcd, Redkis.mac, Nrtl2.mcd, Nrtl3.mcd, and Wilson.mcd
worksheets. The data for use by this program are entered into a Microsoft Excel
spreadsheet in two columns. The first column contains the mole fractions of com-
ponent 1, with the first entry being a value of 0 and the last a value of 1. The
second column contains the excess Gibbs energies at each of these mole frac-
tions, which is zero for the first and last entries. (Some care must be used that the
called worksheets and the Excel spreadsheet are in the appropriate directory, as
described in the documentation for the ACTCOEF worksheet.)
gam inf to gam van laar Used to calculate the parameters in the van Laar model from
values of the two infinite-dilution activity coefficients. The excess Gibbs energy
is then calculated over the whole composition range.
Redlich-Kister A stand-alone worksheet that uses excess Gibbs energy data as a func-
tion of composition to calculate the values of the parameters in the two-parameter
Redlich-Kister expansion.
Redlich-Kister2 A stand-alone worksheet that uses excess Gibbs energy data as a
function of composition to calculate the values of the parameters in the two-
parameter Redlich-Kister expansion. Fitting is done differently than in the pre-
ceding worksheet.
van Laar A stand-alone worksheet that uses excess Gibbs energy data as a function of
composition to calculate the values of the two parameters in the van Laar model.
∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗
The Chem EQ folder contains two worksheets for chemical equilibrium calculations.
CHEMEQ To calculate the values of a chemical equilibrium constant as a function of
temperature. The user must supply the standard-state enthalpies and Gibbs ener-
gies of formation of all components, and the constants in the equations for their
heat capacities. (Note that using the Visual Basic version of the program, those
data are automatically imported from the PROPERTY program.)
ADIABATIC FLAME To calculate the adiabatic flame temperature of a single flam-
mable component (the worksheet is set up for methane) in the presence of a user-
specified amount of air and initial temperature and pressure.
∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗
The MISC folder contains, for illustrative purposes, three worksheets:
VAPPRESFIT Requires as input vapor pressures as a function of temperature, and
then fits these data to a three-constant Antoine equation. The data are entered
from a Microsoft Excel spreadsheet as described in the worksheet.
PRTLMOLR Requires as input mixing data (for example, heat of mixing) as a func-
tion of composition, fits these data using the Redlich-Kister expansion, and then
calculates the partial molar property of each component as a function of composi-
CDB14 Appendix B: Descriptions of Computer Programs and Computer Aids for Use with This Book

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.

B.IV MATLAB PROGRAMS


[MATLAB programs were written by Mr. Zhuoyang Lian, and his help is greatly ap-
preciated.]
To run any of the MATLAB programs one needs to have MATLAB 7.0 (or higher)
installed on the computer, or to have installed the file MCRInstaller.exe on this CD-
ROM (and available from MATHWORKS, Inc.) Running MCRInstaller.exe will take
several minutes, and then will allow the three MATLAB programs on the CD-ROM
to run. However, to change the programs, one will need the complete MATLAB soft-
ware. [Note that running the MCRInstaller program will create new programs in the
directory.]
Once the MCRInstaller program has finished (if you did not have MATLAB on
your computer and had to install it), click on one of the three program folders, Peng
Robinson Pure, Peng Robinson Mix, or UNIFAC. Next, click on the program to be
run. The first time this is done for one of the programs, it will take several minutes for
the program to be inflated before it can be used. Some error messages may appear in
the command window that is opened during the installation process. These should be
ignored. The MATLAB window will open, and the program can be used as described
below.
To run a MATLAB program again at some later time, the MCRInstaller is not used.
One need only find the MATLAB folder, click the program folder, and then click on
the program. This time both the command window (perhaps with some error messages,
which are to be ignored) and the MATLAB window (the command window) will ap-
pear rapidly.
The Peng Robinson Mix folder contains the PRMIX and PRFLASH programs; the
Peng Robinson Pure folder contains the PRPURE program and the UNIFAC folder
containing the modified UNIFAC program.
PRPURE.exe This program can be used to do Peng-Robinson equation-of-state cal-
culations for a pure fluid. All property information such as the critical properties,
acentric factor, normal boiling point, and ideal heat capacity constants must be
entered manually. To access the program, open the MATLAB folder, click the
Peng-Robinson EOS programs folder, click GUI folder, then click exe files, and
finally click PRPURE.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. In that case you should
change the conditions and redo the calculations.
PRMIX.exe This program can be used to do a variety of Peng-Robinson equation-of-
state calculations for a binary mixture, including the properties of a single phase,
dew point pressure, dew point temperature, bubble point pressure, and bubble
point temperature calculations. All property information such as the critical prop-
erties, acentric factor, normal boiling point, and the binary interaction parameter
must be entered manually. To access the program, open the MATLAB folder,
click the Peng-Robinson EOS programs folder, click GUI folder, then click exe
B.IV MATLAB Programs CDB15

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.

Оценить