ME252_ITintro

advertisement
ME 152 - IT: Interactive Thermodynamics Computer Exercises
1. Basic Equation Solving
Suppose you wish to solve the following set of equations, where x, y, and z are unknowns:
6x2 - 4xy + y - 2z3 = 12
5x - 9y3 + 5z = -3
8xz + 3y2 - 7z2 = 0
Note that these equations are nonlinear and cannot be solved analytically.
STEP 1 - Preprocessing
Simply type the equations as given onto the IT workspace as shown below. You may insert comments or
headings by preceding text lines with a double slash // or by bracketing long sections of text with /* ……. */.
// Nonlinear Equation Solving Example
6*x^2 - 4*x*y + y - 2*z^3 = 12
5*x - 9*y^3 + 5*z = -3
8*x*z + 3*y^2 - 7*z^2 = 0
STEP 2 - Solving
Click the Solve button to prepare the solver. If your equations have syntax errors, an error warning will
appear - click OK and typically the solver will highlight the word or equation that contains the error. If you do
not supply enough equations for the number of unknowns, another error warning will appear - click OK and a
summary of equations and unknowns will appear to help you determine what is missing.
If there are no syntax or number of equations errors, an Initial Guesses table appears. Initial guesses are
required for each unknown and the solver uses a value of 1 as a default guess. You may change these
guesses, however, the default values are often satisfactory. You may also insert Minimum and Maximum
solution values if you know the range of possible solution values. For example, we know that temperature in
Kelvin can never be less than zero; so inserting a Minimum value of 0 for a temperature unknown will
accelerate convergence since the solver will then only search for positive values.
After initial guesses have been set, click OK and wait for the Data Browser table to appear. (Note: if a
previous data set exists, the solver will ask you whether you want to save it or discard it.) If the message
"Equation set successfully solved" appears in the Data Browser, then the values for x, y, and z represent a
valid solution. In this example, there may exist several valid solution sets since the equations are nonlinear.
The particular solution found by the solver depends upon the initial guesses and the search algorithm.
STEP 3 - Postprocessing
Once a valid solution has been found, you may want to copy it to the clipboard for pasting. Highlight the
solution by clicking the upper left rectangle in the table and then click Copy. Options are available for
transposing rows/columns and including variable names. It is suggested that you paste your solution to the
bottom of your equation worksheet before printing a hardcopy. This is done by locating the cursor at the
bottom and then clicking Paste from the Edit menu. Also, be sure to type in appropriate units next to each
solution value. You can now print your entire problem by clicking Print from the File menu. If you wish to have
greater control of how your page looks in terms of font style/size, organization, bold/italic/underline, etc., copy
and paste your entire worksheet to Notepad or Microsoft Word.
Performing parametric studies and plotting results are possible using the Explore and Graph functions.
These features will be used in the next example.
2. Equation Solving with Thermodynamic Property Functions
The following worksheet example shows the solution to a problem from a past Midterm Exam. Note that
through the use of commenting, the problem can be set up in the proper format. The first step in any problem
that involves dimensioned variables is to set the proper units by clicking Units. Here, you may specify the
required set of units - I suggest using kPa instead of bars for pressure, since this is more consistent with kJ. If
you do not set the units, the default of English is used.
// EXAMPLE:
// Given: H2O in a rigid tank undergoing a cooling process, initial P & T known, final T known
m = 10
p1 = 12000
T1 = 400
T2 = 200
// Find:
//
// kg
// kPa
// C
// C
a) pressure at state 2, p2
b) heat transfer, Q
// Assumptions:
//
i) stationary, closed system
ii) constant volume process (W=0)
// ANALYSIS:
// Energy conservation
Q - W = m*(u2-u1)
W=0
// Constant volume process
v1 = v2
// Properties
u1 = u_PT("Water/Steam", p1, T1)
u2 = usat_Px("Water/Steam", p2, x2)
p2 = Psat_T("Water/Steam", T2)
v1 = v_PT("Water/Steam", p1, T1)
v2 = vsat_Px("Water/Steam", p2, x2)
The solver recognizes any variable that is set to a numerical value as a known. You may use any
alphanumeric name for a variable, however, please try to be conventional.
The thermodynamic property functions are found by clicking Properties. A pull-down menu of many common
substances appears; here, Water/Steam is chosen and a list of available property equations is shown. The
function name on the right-hand side of each equation is a special subprogram that the solver recognizes.
The function arguments include the name of the substance, and at least two independent, intensive
properties. These property names are not unique, nor is the variable name on the left-hand side of the
equation.
In this problem, specific internal energy and specific volume properties are needed. To place these equations
onto your worksheet, highlight the equation, double-click it, and then drag the equation to the worksheet. The
equation appears wherever the worksheet cursor was left. Once the property equations have been dragged
over, you may edit the variable names so they are consistent with your nomenclature. At state 1 we know P
and T, so the u_PT and v_PT functions are chosen for u1 and v1. Since state 2 is saturated, the usat_Px and
vsat_Px functions are used for u2 and v2. In addition, the Psat_T property function is needed to define p2
since P and T are not independent variables inside the dome and quality x2 must be found.
The IT solution to this problem is:
Q
p2
u1
u2
v1
v2
x2
-1.672E4
1554
2798
1126
0.02108
0.02108
0.1579
kJ
kPa
kJ/kg
kJ/kg
m3/kg
m3/kg
Try setting up this problem and solving it. For now, omit the comments to speed up the process.
Next, try performing a parametric study where you vary the value of T2 over the range of 20 to 200C in steps
of 20C. To do this, click on Explore and choose the Variable to Sweep and input the range parameters.
Then click OK and wait for the Data Browser to appear. Here, you will see the results corresponding to each
value of T2. Suppose you are interested in the effect of T2 on the heat transfer Q. This is best viewed by
plotting Q vs. T2. Click on Graph, then select T2 as coordinate X and Q as coordinate Y1. Click OK and a
plot should appear. You can add titles, change scales, change lines, change data markers, and add a legend
if you wish. The graph can be printed as a full page or copied, sized, and pasted to your worksheet. There are
many other features in IT, including 1st-order differential equations, integrals, user-defined functions, and prewritten thermodynamic processes (see Help menu). Not bad for a $15 program !!
Effect of Final Temperature on Heat Transfer
-16000
Heat Transfer, Q (kJ)
-18000
-20000
-22000
-24000
-26000
-28000
20
40
60
80
100
120
140
Final temperature, T2 (C)
(deg C)
160
180
200
Download