INTRODUCTION - Rose

advertisement
EES Lab Activities
Learning to Use Engineering Equation Solver (EES)
Example 1 — Exploring a simple problem.
1. Start the EES program.
2. Equations Window — Now open an Equations Window (if one does not appear go to the
Windows Menu and click Equation) and type in the two formulas shown below using standard programming notation for mathematical operations :
x ln  x   y 3
1
z
y
If you have problems with notation go to the Help Menu and select Help Index or go to the
Options Menu and select Function Info.
x
3. Checking Equations — Check your equations by pressing the Check/Format Button (button with the red check mark) or go to the Calculate Menu and select Check/Format. This
will examine your equations for format errors and determine the number of variables and
equations. You should find that there are no format errors but you have 3 variables and 2
equations. (This is not necessarily a problem depending on what you do with these equations.)
4. Solving — Now solve the equations by pressing the Solve Button (button with a calculator)
or go to the Calculate Menu and select Solve. As you might expect, you will get an error
message indicating that the problem is underspecified and asking if you want to see the Debug Window. Press Yes. This information is especially useful when you have many equations. Variables that only show up in a single equation are suspect and often indicate a typing
mistake. By clicking on the variable z you will be transferred to the appropriate line in the
Equations Window. Delete “+ z” from the second equation and solve the equations.
You should now see a Calculations Completed Box giving some details of the solution.
Press Continue and you will see the Solutions Window. Double clicking on either of the
variables will bring up a Format Selected Variable Box that will allow you to assign units
and change the appearance and number of significant figures of the answer. (Selecting Key
Variable will place the answer in a separately tabbed section of the Solutions Window.)
5. Residuals Window — Now go to the Windows Menu and select Residuals. The Residuals
Window gives you information about the equation blocks and the solution convergence. Unlike MAPLE, EES cannot do symbolic solutions and solves equations numerically. The main
solution algorithm uses a variation of Newton’s method and iteratively solves a set of nonlinear algebraic equations.
For our two equations, the program would rewrite them in terms of their residuals R1 and
R2 as follows:
1
R1  y 3  x ln  x 
and
R2   x
y
The exact solution is the one that makes both residuals exactly zero; however, this is never
possible with a numerical solution procedure. The accuracy of the solutions is determined by
the values of the residuals. The absolute residual is the value of either R1 or R2 when the
computations stopped. The relative residual is the value of the absolute residual divided by
the left-hand side of the original equation, e.g. R1/(xln(x)) for equation 1. Computations stop
when the values of the relative residual, absolute residual, or number of iterations satisfy the
106752575
Page 1 of 6
EES Lab Activities
limits established for the program. (To see these go to Options Menu, select Options and
then select the Stop Criteria tab.)
You will also notice that there is only one block of equations. One of the strengths of
EES is its ability to group the equations into blocks that are solved sequentially. For example,
a problem with 20 variables and 20 equations might have 4 blocks. The EES solution algorithm groups the equations into the blocks, orders the solution of the blocks, and then solves
each block using the iterative algorithm described above. (If you find this interesting and
want more details, you should consult the EES Manual.)
6. Variables Information Window — Now go to the Options Menu and select Variables. The
Variable Information Window gives you information about every variable in the problem.
Particularly notice the initial guess and the lower/upper values. This information may be critical in some problems. In this window, you may also add units and change the number of
digits reported for any variable by clicking in the appropriate column.
For our two equations, this window indicates that the program assumed initial guess of
one for every variable. It then searched over – ∞ < x < + ∞ and – ∞ < y < + ∞. The computations stopped when the residuals satisfied the convergence criteria or the number of iterations
exceeded the pre-defined limit.
Convergence is often a problem with any numerical solver like EES. When a solution
fails to converge it is often the result of the initial guess or upper/lower limits being unreasonable or incorrect. [What would have happened if the initial guess for x had been –1 or the
upper limit for variable x was 0? Try it out.] If the equations describe a physical system, you
can often determine physically reasonable values for the limits and initial guesses. When
running EES you need not always change the default guesses. However, if a problem fails to
converge consider the physical limits of any variable, e.g. if you are using absolute temperatures, degrees Kelvin or Rankine, then the lower limit for any temperature is zero.
7. Formatted Equations — Before leaving this problem go to the Windows Menu and select
Formatted Equations. This window shows you the equations written in more realistic mathematical notation.
8. Leaving EES — There are several options for leaving an EES program. Unlike many programs, there is no Close option. If you go to the File Menu, you will find the following options:
Exit – exit the EES program. If you have not saved your file, a window will appear and
ask you if you want to save the changes.
Open – open an existing EES file. When you select Open, a window will appear and ask
you to save the current file before you search for the existing file. Then a browser will
appear and you can find the existing EES file you wish to open.
New – open a new EES file. When you select New, a window will appear and ask you to
save the current file before opening a new EES file.
If you have made no changes in the current file since it was last saved, the window asking
you to save the program will not appear.
Select New option, save the file if you want, and begin the next example.
106752575
Page 2 of 6
EES Lab Activities
Example 2 — Thermodynamics without tables (sometimes)!
The real value of EES becomes apparent when you start making use of its built in thermophysical properties. To explore this capability consider the following problem:
A fire occurred in a parked car on a hot summer day. One of the potential sources of fuel was
a butane cigarette lighter left laying on the dash of the car. The lighter was one of those inexpensive lighters with a transparent plastic case you can buy at the checkout counter. Experts
have said that if the lighter fluid was almost entirely liquid then the expansion of the fluid
could have burst the plastic case.
Under normal conditions, the lighter temperature is approximately 70oF, and contains an
equilibrium liquid-vapor mixture of butane (actually n-butane). Someone has estimated that
the maximum possible lighter temperature could have been 250oF under direct sunlight.
Determine (a) the initial pressure inside the lighter at 70oF for a range of mixture qualities,
and (b) the final lighter pressure at 250oF if the lighter fluid was initially at the conditions of
Part (a).
Given:
State 1: T1  70 F
o
0  x1  1.0
1  2: Constant volume heating
State 2:
70o F  T2  250o F
Solution:
Part (a): Using the state principle, P1 = P(T1, x1)
Part (b): Using the process information that the
mass and volume are constant gives υ2 = υ1. Now
using the state principle gives P2 = P(T2, υ2) where
υ2 = υ1= υ(T1, x1).
1. Unit System — Open a new Equation Window. Before we begin typing anything, we need
to check the unit system used in EES. In the first example, units made no difference to us because the equations were pure numbers; however, if you use any of the built-in property
functions the unit system is critical.
Go to Options Menu and select Unit System. Now select English, Mass basis, Fahrenheit, psia , and degrees. These selections tell EES how to interpret any numerical value used
as an argument of a built-in thermophysical or trigonometric function.
2. Now we can begin typing our equations in the Equation Window:
-- Text in quotes are comments. Text can also be
placed in curly brackets {}; however this text will
T1 = 70 [F]
“initial temperature”
not appear in the Formatted Equation Window.
x1 = 0.5
“initial quality”
Comment your code liberally as it helps in underFluid$='n-Butane'
standing and documenting your solution.
P1 = PRESSURE(Fluid$,x=x1,T=T1)
-- Constants can be assigned units by placing the
v1 = VOLUME(Fluid$,x=x1,T=T1)
symbol in square brackets []. These will be used if
v2 = v1
the check units options is turned on and will be
shown in the solutions window.
T2 = 250 [F]
P2 = PRESSURE(Fluid$,v=v2,T=T2)
-- Fluid$ is a text variable. Using this symbol for
the fluid name allows us to change the fluid with
minimal typing. ‘n-Butane’ is a text string.
-- All thermodynamic functions require two independent variables and the name of the substance. The only exception are ideal gas properties
u and h. For a complete list of the possible thermodynamic functions, go to the Options
“Butane lighter example”
106752575
Page 3 of 6
EES Lab Activities
Menu and select Function Info. Then hit the radio button for Fluid Properties. The list of
functions is on the left and the list of available substances is on the right. You can paste a
function into the Equation Window by selecting the function from the left column and the
fluid from the right column and then hitting Paste. For additional information about the function or substances hit [? Function Info] or [? Fluid Info]. Note that any two variables are
possible: P, T, h, u, s, v, x.
-- Line spacing and capitalization are not important to EES and should be used to clarify your
code.
3. Check the equations using the Check/Format Button or just Solve. Your results for P1 and
P2 should be P1=31.27 [psia] and P2=83.09 [psia].
Notice how all of the other variables also have units associated with them. Units are assigned by EES based on the Unit System choice you made earlier. If you check the Residuals Window, you will find that there is only one block and the residuals are exactly equal to
zero because this solution did not require any iteration.
4. To see how problem formulation impacts EES, rewrite the equation for P2 as follows:
Replace
P2 = PRESSURE(Fluid$,v=v2,T=T2)
with T2 = TEMPERATURE(Fluid$, v=v2, P=P2)
In the new formulation, the pressure at 2 is one of the arguments of the Temperature Function and can only be solved for iteratively. In the original formulation, the pressure at 2 was
an explicit function of the specific volume and temperature at 2 and could be solved for directly.
Now hit Solve and check the answers. They should be the same as before. However, note
that P2 does not have units associated with it because it was not the output of a function. You
could assign units by going to the Variables Information Window if desired.
Now check the Residuals Window. Notice how there is still only one block of equations
but EES had to iterate to find P2 since it was not on the left-hand side of the equation as in
the original formulation. This is one of the major strengths of EES – equations can be
written in any order. Convergence can often be improved by rewriting an equation to isolate the unknown on the left-hand side of the equation; but in most cases EES can solve the
equations you give it.
Before beginning the next step, change the equations back to the original formulation:
Replace T2 = TEMPERATURE(Fluid$, v=v2, P=P2) with P2 = PRESSURE(Fluid$,v=v2,T=T2).
Failure to do this will cause convergence problems in the next section.
5. Parametric Tables — Now let us investigate another feature of EES, the Parametric Table.
This feature allows you to easily investigate how changing the value of one variable affects
your solution.
Go to the Table Menu and select New Parametric Table. In the New Parametric Table Window, increase the number of runs from 10 to 11. Now move x1 and P2 from the variables-in-equations list to the variables-in-table list using the Add Button. Once this is done
hit Continue. You will now see the Table 1 in the Parametric Table Window. By filling in
any values in this table, EES will solve for the rest.
Fill in the quality, x, column with values from 0 to 1 by tenths. You can do this by hand
or right-click the top of the x column, select Alter Values, and fill in the numbers.
Now go to the Calculate Menu and select Solve Table. The Solve Table Window will
appear and you will need to increase the run number from 10 to 11. Hit OK. At this point,
you should get an Error Window telling you that the value of x1 is already set in the Equations Window.
106752575
Page 4 of 6
EES Lab Activities
To remedy this situation, hit OK and return to the Equations Window. Find the equation
x1 = 0.5. Now double click the equation to select the entire line, right-click the line, and
comment the line with { }. This is a quick way to take a line of code out of the way without
erasing it. You can also just add “ “ or { } around the equation or just delete it. It is usually
better to comment the line of code out of the equations in case you need it later. This is a
VERY common occurrence when you use a Parametric Table. Typically you will build the
model for a single set of values, get the model working correctly, and then look at the parametric behavior. Variables cannot have values set in two different places.
Now Solve Table again. You should get a Parametric Table showing x1 and P2. What do
you think about the claim that if the mixture is mostly liquid, the lighter could have burst?
What happens when the contents are mostly vapor? [If you elect to explore the Solutions
Window, Variable Information Window, or Residuals Window after solving a table, you will
only find the values for the last entry in the table, i.e. the values for x1 = 1.]
6. Plotting Results — Now we can plot the results. Go to the Plots Menu and select New Plot.
This should bring up New Plot Setup where you select the variables on the plot. Highlight
x1 for the x-axis and P2 for the y-axis. Other options are Spline Fit, Automatic Update, and
Add Legend. Spline Fit smooths out the curve between the data points. Automatic Update
will automatically update the plot when you change any of the values in the Parametric Table. Add Legend will add a legend item for the curve. Do not click any of the options. Then
click OK.
To improve the appearance of your plot double-click one of the numbers on the y-axis.
This will bring up Modify Axis for Plot 1. Click the Log option and the Automatic Scaling
option. The press OK. This will give you a Semi-log plot of the same data.
7. Overlaying Data on a Plot — It is possible to plot many different sets of data on a single
plot using the overlay feature. Since we did not click the Automatic Update feature when we
set up Plot 1, we can go back and recalculate the data points and Plot 1 will not change. Go
back to the Equations Window and change T2 to 100. Now Solve Table. You will get a new
set of values for P2.
Go to the Plots Menu and select Overlay Plot. You will see a screen that is similar to the
New Plot Setup screen. Notice in the upper right-hand side, you can select the table you want
the data to come from. This should be the Parametric Table you just ran. Select x1 for the xaxis and P2 for the y-axis as before. Notice that you can also select a different y-axis scale if
you want, but do not do so for this problem. Now click OK. You should now have two data
sets on your graph --- one for T2 = 250oF and 100oF. IF we had selected the Automatic Update option for our original Plot 1 data then when we recalculated the results for T2=100oF
the data would have also changed. The updated plot might have required us to change the
scale of the axis but otherwise should have been usable.
8. Prepare for a new example by going to the File Menu and selecting New and then saving the
Butane Lighter File under an appropriate name. You may want this file for future reference.
106752575
Page 5 of 6
EES Lab Activities
Example 3 — Performance of a Turbine and Condenser
Problem: Consider a steady-state system consisting of a steam turbine connected to a condenser
as shown in the figure:
1: P1 = 1000 kPa; T1 = 500 oC
Turbine
1
12: Adiabatic, steady-state turbine
with ηturb = 100%
wturb
2: P2 = 10 kPa
2
3
qcond
23: Isobaric, steady-state heat exchanger.
3: Saturated Liquid (x3 = 0)
Condenser
(a) Solve for T2, x2, qcond,out, and wturb,out for the given operating conditions.
(b) Prepare a parametric table showing how the above variables change for P2 = 10 to 100 kPa.
(c) Prepare a plot showing how qcond and wout vary with P2.
Hints:
(1) Layout the solution like you might a hand calculation:
State 1:
P1 = 1000 kPa; T1 = 500 oC
Process 12: Reversible, adiabatic turbine until P = P2
-----
wturb ,out  h1  h2
where s2 = s1 = s(P1,T1); h1 = h(P1, T1); h2 = h(P2, s2)
State 2:
P2 = 10 kPa
also T2 = T(P2, s2) and x2 = x(P2, s2)
Process 2  3: Isobaric, cooling process until liquid is saturated ----
qcond ,out  h2  h3
where h3 = h(P3, x3) and x3 = 0.0
(2) BEFORE you start entering equations, go to the Options Menu and select Unit System and
select SI, kJ, C, mass, and degrees.Enter the equations into the Equations Window and solve.
(3) Set up Parametric Tables and plots as required.
Array Variables: To see a different feature of EES write all of the subscripted variables as array
variables. That is instead of T1 or T_1 write T[1] where the bracketed number gives the number
of the variable in the T-array. When array variables are used, the solution for the array variables
can be found in an Array Table found under the Windows Menu. Array variables are especially
useful for organizing variables for cycle analysis and for plotting values on a Property Plot.
Plots.
To try this, calculate T and s for states 1, 2, and 3.This will greatly facilitate looking at the
properties for cycles and for plotting the data points on Property Plots. To plot on a property plot,
go to the Plots Window and select Property Plot. Now select water and a T-s plot. Now overlay
the plot with the Array Variables by going to the Plots Menu and selecting Overlay Plot. Select
the water property plot and the Array Table. Select s[] for the x-axis and T[] for the y-axis and hit
OK.
106752575
Page 6 of 6
Download