SPREADSHEETING WITH EXCEL
II. GOALSEEKING, SOLVING, AND GRAPHING
R.M. Felder
Department of Chemical Engineering
North Carolina State University
November, 1994
(Revised by E. M. Wilcox, August, 1998)
Statement of the problem.
Given below are five equations relating seven variables: x, T, pa*, pb*, pa, pb, and y.
We wish to create an EXCEL spreadsheet that will take as input several values of x, and for each one, find T for which (pa + pb = 760). (This is a sixth equation).
The procedure will be as follows:
The calculation will involve generation of the spreadsheet shown in Table 1.
TABLE 1. EXCEL SPREADSHEET FOR EXAMPLE PROBLEM
For example, when x = 0.900, a value of T = 82.2 substituted into Eqs. (1) and (2) yields pa* = 809.6 and pa* = 313.7,
respectively. These values substituted into Eqs. (3) and (4) in turn lead
to values of pa and pb that add up to the target value of 760.0. The corresponding value of y from Eq. (5) is then 0.959.
After this spreadsheet is generated, it will be sorted: Rows 12-22
will be rearranged in order of increasing values of x in Column A. EXCEL
will then create plots of T vs. x and T vs. y that will appear as shown in Figure 1.
In the tutorial exercise that follows, we will give instructions for
running the modern version of EXCEL (which runs on Windows NT and Windows 95)
and the old version (which runs on SPARCstations under a Windows 3.1 emulator
like SoftWindows or WABI). We strongly suggest that you use a machine that
runs the new version, however--the old one is very slow and generally
inferior.
EXERCISE
The spreadsheet is now stored under the name "mod2.xls", and that name should
appear in the title bar at the top of the EXCEL window.
You should see P(mm Hg) = in Cell [A3] and 760 in Cell [B3].
Antoine equation coefficients [downarrow] Compound [rightarrow]
A [rightarrow] B [rightarrow] C [CR]
Row 7: Benzene [rightarrow] 6.90565 [rightarrow] 1211.033 [rightarrow]
220.790
Row 8: Toluene [rightarrow] 6.95334 [rightarrow] 1343.943 [rightarrow]
219.377
Save the spreadsheet with the Ctrl-s command. Hold down
the "Ctrl" key and type s. (Alternatively, click the "floppy disk"
icon on the EXCEL tool bar.)
Beginning in Cell [A10], type
x [rightarrow] T [rightarrow] pa* [rightarrow] pb* [rightarrow] pa+pb
[rightarrow] y [CR]
Then right-justify each entry by selecting [A10:F10] and clicking
the "right justify" icon.
Beginning in Cell [A12] (two cells below the x, type
0 [downarrow] 1 [downarrow] .1 [downarrow] .2 [downarrow] .3
[downarrow] .4 [downarrow] .5 [downarrow] .6 [downarrow] .7 [downarrow] .8
[downarrow] .9 [CR]
(Don't use a formula to enter these values, and don't bother typing the
trailing zeros, like the trailing 00 in 0.100.)
Save the spreadsheet.
= 10 ^ ($B$7 - $C$7 / (B12 + $D$7))
[CR]
We anticipate copying this formula into the rest of Column C.
When we do so, as we move down the column we will want the cell address [B12]
in the formula to change to [B13], [B14], etc., which it will since we used
the relative cell address. However, we do not want cell address [B7] in the
formula (which contains the Antoine coefficient A for benzene) to change to
[B8], [B9], etc., and so we use the absolute address [$B$7].
A very large number should appear in [D12]. (The formula is not yet
correct.)
The formula should now read = 10^($B$8-$C$8/(B12+$D$8)),
and the
value in the cell should be 556.3212. Verify that this is the correct formula
(Eq. 2) for calculating pb* at 100°C.
= A12*C12 + (1-A12)*D12 [CR] = A12*C12/E12 [CR] Save the spreadsheet.
Goalseeking
After a little activity, a message box will open labeled Goal Seek
Status, informing you that the search was successful and the final value in
Cell [E12] is 760.0000018. (You won't always get this close to the target
value.) Move the message box if necessary to see Row 12 of the worksheet.
You should see a value 110.6253 in Cell [B12], which is the desired
value of T.
-- Click on Cell [E13]. Choose the Tools menu and select Goal Seek. You will see a blur in Row 13 as the search proceeds. Click OK on the message box once it appears. For x=1, EXCEL calculates T=80.09999 and y=1.
None of the format codes at the window on the right matches what we want (three
decimal places), so we create our own code.
All the values in the selected range should now have the desired appearance.
Your worksheet should now look exactly like the one shown at the beginning of
this tutorial.
Sorting
At this point, you could enter another column in the Then By box to
be used as the basis for ordering the rows if two elements in Column A have the
same value. (This will not occur in this example, so we won't bother to enter
a secondary key.)
Note: If you sort a worksheet based on a column containing
text entries, the sorting is in alphabetical order of those entries.
Click on Windows 3.1 if you are working on a
SPARCStation or another computer running an old version of EXCEL.
A dialogue window labeled "Chart Wizard" will appear, which will take you
step by step through much of the graph generation process.
In the "Data range" entry box, type A12:B22 , and click to indicate that your data series are in Columns . A plot of T vs. x will appear in the dialogue window. Don't click on "Next>."
Still in the Step 2 box, click on the "Series" tab. In the "Name" entry box, type
Click on Next>.
Click on the Titles tab of the Step 3 window if it is not already selected. Make the following entries in the appropriate boxes (click in each new box rather than hitting [CR]).
-- Title the chart TXY DIAGRAM FOR BENZENE/TOLUENE AT 760 MM HG A small ugly graph will appear somewhere on your worksheet.
In what follows, "graph window" refers to the large white box containing
the graph, title, axis labels, and legend, and "plot area" refers to the
interior shaded box that contains the curve. We will now modify the graph to
get the desired appearance (shown in the beginning of this tutorial).
To resize the graph only vertically you would use the bottom middle dot,
and to resize it only horizontally you would use the right middle dot.
-- Under "Patterns," select major tick marks inside, no minor tick marks. Repeat this procedure for the vertical axis, first double-clicking on the axis to bring up the "Format Axis" window.
-- Under "Patterns" put major tick marks inside.
-- Under the "Border" options, click None.
-- Click on the "Add" button near the bottom left of the window. The second graph should now be on the chart.
-- Double-click on the grey area of the graph to bring up the "Format Plot Area" window. The graph is now complete.
Click on Physical basis of the tutorial to see a description of the vapor-liquid equilibrium problem that this spreadsheet was designed to solve. Otherwise, you may exit from the tutorial.
A dialogue window labeled "Chart Wizard" will appear, which will take you
step by step through much of the graph generation process. It will first ask
if the range you selected is the range you actually want (A12:B22). Click
Next> .
-- Under "Data series in:" click on Columns
In the Step 5 window,
-- Click on Yes under "Add a legend." (We will later
change it from "Series 1.")
-- Title the Category(X) axis Benzene fraction The graph will appear in the specified location on the worksheet. If
necessary, scroll down so that you can see the entire graph window.
In what follows, "graph window" refers to the large white box containing
the graph, title, axis labels, and legend, and "plot area" refers to the
interior shaded box that contains the curve. We will now modify the graph to
get the desired appearance (shown in the beginning of this tutorial).
Under the Insert menu, select
Gridlines. If you clicked in the appropriate boxes on the dialogue window that comes up, you could get vertical or horizontal gridlines at major and minor tickmarks on the graph. (Don't do it now.) Click Cancel.
-- Under "Patterns," select major tick marks inside, no minor tick marks. Repeat this procedure for the vertical axis. Double-click on the axis to bring up the "Format Axis" window.
-- Under "Patterns" put major tick marks inside. Still pointing directly at the curve, double-click. A "Format Data Series" window should come up. Under the "Name and Values" tab in the "Name:" entry box, change "Series 1" to Liquid: T vs. x . Click on OK.
-- Under the "Border" options, click None.
-- Select the T column including the heading (Press and hold on Cell [B10], drag down to Cell [B22], and release).
-- Highlight the rectangular range [F12:G22]. A "Paste Special" window will appear. Place check marks as follows:
-- Add cells as New Series Currently the two plots are shown as two solid lines of different colors. We want to change the "Vapor" line to be a dashed black line. (Different colors cannot be distinguished on a black-and-white printout.) We also want to change the legend to "Vapor: T vs. y."
-- Activate the graph by double-clicking on it. The graph should now look like the one at the beginning of this tutorial.
-- Double-click on the gray area of the graph to bring up the "Format Plot Area" window.
The worksheet and the graph should come out on your default printer. If you wish to print only the graph, click on the graph and then print. EXCEL will automatically scale up your graph to fit on one full page.
APPENDIX: PHYSICAL BASIS OF THE TUTORIAL PROBLEM
The vapor pressure of a substance, p* , can be expressed
as a function of temperature, T, by the Antoine equation:
The Antoine constants (A, B, and C) for benzene and toluene are given
below for T in degrees Celsius (°C) and p* in millimeters
of mercury (mm Hg):
and so
Another way of stating
this result is that at a pressure of 1350.5 mm Hg, the boiling point
of pure liquid benzene is 100°C.
Suppose we have a liquid mixture of benzene and toluene, with
x being the fraction of benzene (technically x is the mole
fraction of benzene in the liquid mixture, but if this means nothing to
you it doesn't matter). That is, if x=0.30, the mixture contains 30%
benzene and 70% toluene. Further suppose that the mixture is heated in an
open flask on a day when the barometric pressure is Patm = 760 mm Hg.
(Under normal atmospheric conditions, Patm varies in the range 750-770
mm Hg.) As the liquid temperature increases, the vapor pressure of benzene
(pa*) and that of toluene (pb*) both increase, following the Antoine equation. According to Raoult's Law, the liquid in the flask will boil when the temperature reaches a point such that
where the partial pressures of benzene and toluene in the vapor bubbles
are calculated as
and (pa*) and (pb*) are given by the Antoine equation. Moreover, the fraction of benzene in the vapor bubbles that form when the liquid boils is
The problem we wish to solve is, given a value of Patm
(=760 mm Hg), calculate the boiling point temperature, T, and the fraction of benzene in the vapor bubbles, y, for a series of benzene fractions in the liquid, x. The procedure is the trial-and error calculation outlined at the beginning of the tutorial.
If we perform this calculation for a number of values of x between zero and one, we can generate the TXY diagram created in this tutorial. Once we have it, vapor-liquid equilibrium calculations become easy.
For example, if we heat a 50% liquid mixture of benzene and toluene
(x=0.50) at a pressure of 1 atm (760 mm Hg), the mixture will boil
at 92°C (obtained by going straight up from x=0.5 to the
liquid curve and reading the temperature), and the vapor bubbles will
contain about 71% benzene and 29% toluene (obtained by going across
at 82°C to the vapor curve and reading the fraction on the
horizontal axis).
A B C D E
F 1
TXY DIAGRAM FOR BENZENE
AND TOLUENE 2 3
P(mm Hg) =
760
4
5 Antoine equation coefficients
6 Compound A B C 7
Benzene
6.90565
1211.033
220.790
8 Toluene
6.95334 1343.943 219.377 9 10 x T pa* pb* (pa+pb) y
11
12 0.000 110.6 1784.5 760.0 760.0 0.000
13 1.000 80.1 760.0 292.2 760.0 1.000
14 0.100 106.1 1589.8 667.8 760.0 0.209
15 0.200 102.1 1429.1 592.7 760.0 0.376
16 0.300 98.5 1294.9 530.8 760.0 0.511
17 0.400 95.1 1181.5 479.0 760.0 0.622
18 0.500 92.1 1084.7 435.3 760.0 0.714
19 0.600 89.3 1001.3 398.0 760.0 0.791
20 0.700 86.8 928.9 365.9 760.0 0.856
21 0.800 84.4 865.5 338.0 760.0 0.911
22 0.900 82.2 809.6 313.7 760.0 0.959
If Column A is too narrow for the contents of [A3] (including the equal sign) to
show, click on the column label (A) to highlight the entire column; point to the
location right between Columns A and B (the pointer symbol should change to a
vertical bar); hold down the left mouse button, and
drag the pointer to the right to make Column A wider.
Click the "right justify" icon on the EXCEL tool bar.
Row 6 should now contain Compound A B C, with each label at the right
of its cell.
-- Move the dialog window if necessary so you can see Rows 12-22 of the worksheet.
-- Click on the To Value box and type 760.
-- Click on the By Changing Cell box and type B13 [CR].
Reformatting the Spreadsheet
Plotting: Windows 95 & Windows NT
-- Title the Category(X) axis Benzene fraction
-- Title the Value(Y) axis Temperature (Deg. C). Don't click on "Next>."
-- Under "Scale," make the axis run from 0 to 1, with major tick marks at
intervals of 0.1.
-- Under "Font," select "Font style:" = Arial, Regular.
-- Under "Number," select Category = Number, Decimal places = <3>.
-- Under "Alignment," move the pointer on the semicircle to the top (12
o'clock) position.
-- Click on OK.
-- Under "Scale" have the axis run from 80 to 112,
with the x axis crossing at 80.
-- Under "Font" select Arial, regular.
-- Under "Number" select Number, 0 decimal places.
-- Under "Alignment," leave the pointer at the horizontal (3 o'clock) position.
-- Click on OK.
-- Under the "Area" options, click on white (lower right box).
-- Click on OK.
-- Save.
-- Type Vapor: T vs. y in the "Name:" box.
-- Type =Sheet1!F12:F22 in the "X Values:" box.
-- Type =Sheet1!B12:B22 in the "Y Values:" box.
-- Click on Finish.
-- Save.
-- Under the "Area" section, select white. Click on OK.
-- Save.
A description follows of the vapor-liquid equilibrium problem that this spreadsheet is designed to solve. If you don't wish to read it now, you may exit from the tutorial.
-- Enter that you want to use the first 1 column for X
data
-- Enter that you want to use the first 0 row for legend
text
-- Click on Next>
-- Title the chart
-- Title the Value(Y) axis Temperature (Deg. C)
-- Click on Finish.
-- Save.
-- Under "Scale," make the axis run from 0 to 1, with major tick marks at
intervals of 0.1.
-- Under "Font," select "Font style:" = Regular.
-- Under "Number," select Category = Number, Decimal places = <3>.
-- Under "Alignment," select the middle vertical option (text going from bottom
to top)
-- Click on OK.
-- Under "Scale" have the axis run from 80 to 112,
with the x axis crossing at 80.
-- Under "Font" select Arial, regular.
-- Under "Number" select Number, 0 decimal places.
-- Under "Alignment," designate the horizontal text position.
-- Click on OK.
-- Save.
-- Under the "Area" options, click on white (lower right box).
-- Click on OK.
-- Save.
-- Move the pointer to the right edge of the highlighted area. The pointer should become an arrow.
-- Press and hold the right mouse button, drag the area to Column G (Row 10 through Row 22), and release.
-- Save.
-- Move the pointer to the right edge of the higlighted area. The pointer should become an arrow.
-- Press and hold the right mouse button, drag the area into the graph, and release.
-- Y values in Columns
-- Categories (X values) in first column
-- Click on OK. The second plot will now appear in the graph.
-- Save.
-- Click on the top (vapor) curve on the graph to bring up the boxes along the length of the curve.
-- Still pointing directly at the curve, double-click to bring up the "Format Data Series" window.
-- Under the "Name and Values" tab in the "Name:" entry box, change "Series 2" to Vapor: T vs. y .
-- Under the "Patterns" tab, "Line" options, click on the arrow to the right of "Style:" and select a dashed line.
-- Still under the "Patterns" tab, "Line" options, click on the arrow to the right of "Color:" and select black.
-- Click on OK.
-- Save.
-- Under the "Area" section, click on the white box. Click on OK.
Compound A
B
C
Benzene 6.90565 1211.033
220.790
Toluene 6.95334 1343.943
219.377