SlideShare une entreprise Scribd logo
1  sur  60
PROGRAMMING FOR
MECHANICAL ENGINEERS
IN
ENGINEERING EQUATION SOLVER
With hands-on training!
Naveed ur Rehman
http://www.naveedurrehman.com/
Introduction to EES
• EES (pronounced ’ease’): “Engineering Equation Solver”
• Developed by S.A. Klein and G.F. Nellis at University of
Wisconsin–Madison.
• Licensed and distributed by F-Chart software
(http://fchart.com)
• Demo version can be acquired free from
http://fchart.com/ees/demo.php
• Licensing and ordering information can obtained from
http://fchart.com/ees/ and http://fchart.com/ees/order.php
• Single user license fee: $600-$1200
2naveedurrehman.com
Salient features
• Support non-sequential codes (or equations)
• Support sequential programming language (as in C,
MATLAB, Pascal and FORTRAN etc. including
conditioning, looping and functional approaches etc.)
• Built-in mathematical functions (e.g. PVT diagrams,
Moody, Heat exchanger etc.)
• Built-in Thermo-physical property functions (e.g. for
steam, refrigerants, air, gases etc.)
• Support display of results in several visual formats (e.g.
graphs, contours, diagrams etc.)
3naveedurrehman.com
Salient features
• Diagram window:
4naveedurrehman.com
Salient features
• Parametric solutions:
5naveedurrehman.com
Salient features
• Solutions on property diagrams:
6naveedurrehman.com
Application areas
Following are the few application areas and courses where
EES can be utilized:
• Thermodynamics
• Engineering mechanics
• Fluid mechanics
• Heat transfer
• Gas dynamics
• IC Engines
• Steam and gas turbines
• Refrigeration & air conditioning
• Renewable energy technologies
• Final Year Project
7naveedurrehman.com
Environment
“Equations window”
“Menu”
“Toolbar”
Remember, EES is case-insensitive
i.e. ABC = abc = AbC = Abc…
8naveedurrehman.com
Solving an equation
X + 3 = 5
Try:
To obtain solution:
[Menu] Calculate > Solve
or
Press “F2” key
In Solution Window:
9naveedurrehman.com
Solving an equation
Try:
A + 3 = 5 * 4
B + 3 = 5 ^ 2
C = 5 + ( 3 * (4 - 2 ^ 5 ) ) / 100
D + 2 * D = 9
E ^ 2 = 100
50 = F ^ (1/2)
G ^ 1.333 = 0.4
10naveedurrehman.com
Solving an equation
Try:
3*H^2 - 4*H - 5 = 0
0.5*J^3 - 3*J^2 - 4*J - 5 = 0
(K+3)*(K-4)*(K+5)=1/K
SQRT(2) = X + SQRT(X+1)
3𝐻2 − 4𝐻 − 5 = 0
0.5𝐽3 − 3𝐽2 − 4𝐽 − 5 = 0
𝐾 + 3 𝐾 − 4 𝐾 + 5 =
1
𝐾
2 = 𝑋 + 𝑋 + 1
11naveedurrehman.com
Solving system of equations
Try:
X + Y = 10
X - 2*Y = 5
12
X + Y + Z = 10
X - 2*Y = 5
X + Z = 4
X + Y + Z = 10
X + Y = 0
What about this:
Remember, number of variables = number of equations!
ERROR!
naveedurrehman.com
Solving system of equations
Try:
V = pi * (R^2) * H
R = 10
H = 12
13
Calculate volume of cylinder where radius is 10 m and
height = 12 m (using 𝑉 = 𝜋𝑅2 𝐻)
Calculate height of cylinder where radius is 10 m and
volume = 3000 m3 (using 𝑉 = 𝜋𝑅2 𝐻)
V = pi * (R^2) * H
R = 10
V = 3000
naveedurrehman.com
Solving system of equations
Try:
R = G + 2
G = 2 * B
B = 3
14
Diameter of red ball is 2” more than that of green ball.
While the diameter of green ball is twice than that of blue
ball. If the diameter of blue ball is 3”, calculate diameters of
other two balls.
Codes:
naveedurrehman.com
Solving system of equations
Try:
M_left = M_right
M_left = F*3
M_right = 12*8
15
𝑀𝑙𝑒𝑓𝑡 = 𝑀𝑟𝑖𝑔ℎ𝑡
𝑀𝑙𝑒𝑓𝑡 = 𝐹. 3
𝑀𝑟𝑖𝑔ℎ𝑡 = 12 × 8
Hint: Codes:
naveedurrehman.com
Engineering units
Try:
16
T = 30 [C]
A = 40 [m^2]
To insert a unit from list,
right-click editor, select
“Units list”. After selecting
unit from list, click “Paste”.
naveedurrehman.com
Units consistency check
Try:
T = 30 [C]
A = 40 [m^2]
U = T+A
17
To check consistency of units:
[Menu] Calculate > Check units
or
Press “F8” key
naveedurrehman.com
Units consistency check
Try:
T = 30 [C]
A = 40 [m^2]
U = T * A
18
Consistency check:
Right-click equation and select “Set
variable Units”. Input the valid unit
(C*m^2) for U and click “Ok”.
naveedurrehman.com
Units conversion
Try:
A = 30*Convert(ft,m)
B = 10*Convert(MJ, kJ)
C = 100*Convert(kJ/kg,BTU/lbm)
19
Solution:
Note: Unit to each variable is automatically assigned.
Convert statement is used to do unit conversion:
Convert ( from-unit , to-unit )
naveedurrehman.com
Converting temperature units
Try:
TheF = ConvertTEMP(C,F,30) "Convert 30 deg. C to deg. F"
TheC = ConvertTEMP(F,C,100) "Convert 100 deg. F to deg. C"
20
Solution:
ConvertTemp statement is used to do unit conversion
between degree centigrade (°C) and Fahrenheit (°F):
ConvertTEMP ( from-unit , to-unit, value)
naveedurrehman.com
Formatted equations
Try:
f_c = 100
A =(1/pi^2)/f_c
21
To view formatted equations:
[Menu] Windows > Formatted Equations
or
Press “Ctrl + F” key
naveedurrehman.com
Formatted equations
Variable display options for Formatted Equations Window:
22naveedurrehman.com
Formatted equations
Try:
Re_D=1000
L|plus=10
f_bar=(4/Re_D)*(3.44/sqrt(L|plus)+(1.25/(4*L|plus)+64/4-
3.44/sqrt(L|plus))/(1+0.00021/L|plus^2))
sigma=1
23
Formatted Equations:
naveedurrehman.com
Comments
Try:
A = 10 "Area of surface"
W = 4 "!Width of surface"
H = A/W {Height of surface}
C = 400 {!Looks like constant}
24
Formatted equations:
To set color and font style:
[Menu] Options > Preferences > Equations
Set properties for type I and type II comments.
Click “Store” to save your preferences.
Type I comment: “ “ or { }
Type II comment: “! “ or {! }
naveedurrehman.com
Bookmarking
Bookmarks are helpful in lengthy programs.
To add a bookmark, use following directive:
$Bookmark …caption…
For example:
$Bookmark COMRPESSOR
To access bookmarks, right-click in editor
and select bookmark from the list given at the
end.
25naveedurrehman.com
Variable information
Try:
D ^2=100
J = D + 50
26
To view variable info:
[Menu] Options > Variable Info
or
Press “F9” key
Solution:
naveedurrehman.com
Variable information
Try:
D^2=100
J = D + 50
27
Solution constraint:
The value variable D of must
be less than 0.
Do the following settings in Variable info:
Note that, a good guess may speed up processing.
Another purpose of variable info is to replace a particular
variable everywhere in codes. For this, try to rename
variable “D” as “E” and press “Ok”.
naveedurrehman.com
Exporting values
28
To export:
$export /A 'filename' var1 var2 ….
Where,
• Flag /A is optional and is used to append contents.
• Filename can have following extensions:
1. csv, tab, dat: these extensions are generally
accepted by most of the software e.g. MATLAB,
EXCEL.
2. txt: this extension will create file which is read-able
by Open Lookup Table command from Tables menu.
If file name is just ‘clipboard’, contents will be copied to
clipboard.
naveedurrehman.com
Importing values
29
To import:
$import ‘filename’, var1 var2 ….
Try:
Create a file ‘c:data.txt’ with the following contents:
1000 500 100
Then, solve these codes:
$import 'c:data.txt', a b c
d = a + b + c
Solution:
naveedurrehman.com
Constants
30
To add a pre-defined constant:
[Menu] Options > Constants
Select constant from list and click “Paste”.
Try:
mass = 10
weight = mass*g#
Remember, constants are not treated as variables!
For example, in above, there are just two variables i.e.
“mass” and “weight” and hence, this system of equations
has some solution.
Custom constants may be added to the list.
naveedurrehman.com
Arrays
31
An array (or vector) is an organized collection of different
values of same variable. Arrays are helpful in batch
processing, making plots, etc.
Try:
T[1]=100 "the first element of the array T"
T[2]=200 "the second element of the array T"
T[3]=300 "the third element of the array T"
In above, the variable “T” is not a scalar variable, but it is
an array (or vector) having values 100, 200 and 300 placed
at index 1, 2 and 3 respectively.
$Arrays ON and $Arrays OFF directive may be used to
switch the display of Arrays window.
naveedurrehman.com
Multi-dimensional arrays
32
Try:
T[1,1]=100
T[1,2]=200
T[1,3]=300
T[2,1]=444
T[2,2]=555
T[2,3]=666
Arrays Table:
Above is an example of 2D array. More dimensions can be
added by using “,” separator in square brackets.
naveedurrehman.com
Duplicate statement
33
Duplicate statement provides a convenient method for
carrying out similar operations on multiple elements of an
array.
Duplicate index = start,stop
equation(s) to be duplicated
End
duplicate i=1,4
T[i]=i
end
Try: Arrays Table:
naveedurrehman.com
Duplicate statement
34
Try:
For the 10 points of “X”, the value of “Y” is “X^2+10”. Using
duplicate statement, generate array table for X and Y such
that:
duplicate i=1,10
Y[i] = i^2 + 10
X[i]=i
end
Solution::
Hint: Both X and Y are vectors. A
scalar variable as iterator may be
used in duplicate statement.
naveedurrehman.com
2D plots
35
To draw plot:
[Menu] Plots > Now Plot Window > X-Y Plot
Select variables for X and Y axis and click “Ok”.
Try:
Draw X-Y plot for
previous example.
naveedurrehman.com
3D plots
36
To draw plot:
[Menu] Plots > Now Plot Window > X-Y-Z Plot
Select variables for X, Y and Z axis, opt “3-D Plot” and click
“Ok”.
Try:
Draw plot for the
following:
duplicate i=1,10
X[i]=i
Y[i] = i + 1
Z[i] = i
end
naveedurrehman.com
Lookup tables
37
Lookup Tables provide a convenient method of saving and
accessing tabular data, useful for interpolation and curve
fitting.
To add a lookup table:
[Menu] Tables > New Lookup Table
• Suggest suitable title. This will be used while retrieving values.
• Select number of rows and columns required in table.
• Data can be entered manually or can be copy-pasted from
MATLAB, EXCEL etc.
• Lookup tables can be exported to a file for sharing purpose.
• Also, they can be imported from CSV files, a famous export
extension supported by common data loggers.
naveedurrehman.com
Lookup tables
38
Try:
Time taken by a metallic
ball when dropped from
different height were
recorded as shown in
table.
Develop a lookup table
titled: “FALL” for this
data.
naveedurrehman.com
Interpolation in lookup table
39
Interpolated data can be retrieved from lookup tables using
Interpolate statement.
X = Interpolate('TableName', 'Var1', 'Var2', Var=Val)
Try:
Using lookup table created in previous example:
Ans_1 = Interpolate('FALL','Height','Time',Time=230)
Ans_2 = Interpolate('FALL','Height','Time',Height=45)
Solution:
naveedurrehman.com
Other lookup functions
40
• Lookup: Return value at given row and column
X = Lookup('Table',Row,Column)
• LookupRow: Return row#. Value matching in column.
X = LookupRow('Table',Column,Value)
• LookupCol: Return column#. Value matching in row.
X = LookupCol('Table',Row,Value)
• AvgLookup: Return average of values.
X = AvgLookup(‘Table','ColName',[StartRow,StopRow])
• SumLookup: Return average of values.
X = SumLookup(‘Table','ColName',[StartRow,StopRow])
naveedurrehman.com
Regression
41
Regression is a useful method to find dependence of one
variable on to other variables.
To find linear regression equation:
[Menu] Tables > Linear Regression
Select dependent variable and independent variable(s).
Click “Fit” to find the fitted equation.
To find statistics regarding fit, click “Stats”.
Polynomial order can be increased and cross-terms may be
added to increase accuracy.
naveedurrehman.com
Regression
42
Try:
For the following data, determine 2nd order polynomial of
“TIME” as a function of “HEIGHT” and “VELOCITY”:
naveedurrehman.com
Parametric tables
43
Parametric tables are used for parametric studies in which the
effect of one variable (the independent variable) on another
variable (the dependent variable) is studied.
To create parametric table:
Writing codes conventionally in editor and then click:
[Menu] Tables > New Parametric Table
To populate (or solve) a parametric table:
[Menu] Calculate > Solve Table
Or
Press ‘F3’ key.
naveedurrehman.com
Parametric tables
44
Try:
Surface area of a cylinder is given by:
𝐴 = 𝜋𝑅2 + 2𝜋𝑅𝐿
Complete the following table:
naveedurrehman.com
Parametric tables with a check
45
To check whether the parametric solution is required, use:
$IfNot ParametricTable
…relations…
$EndIf
For example, in previous problem, constant values of L and
R may be given inside codes:
$IfNot ParametricTable
L= 30
R = 50
$EndIf
naveedurrehman.com
Functions
46
To access available functions:
[Menu] Options > Function Info
Select function from list and click “Paste”.
naveedurrehman.com
Useful math functions
47
• Trigonometric functions:
sin, cos, tan
• Trigonometric inverse functions:
arcsin, arccos, arctan
• Hyperbolic functions:
sinh, cosh, tanh
• Hyperbolic inverse functions:
arcsinh, arccosh, arctanh
• Logarithmic and exponent functions:
ln, log10, exp
• Other functions:
abs, floor,
sum, average, mod, max, min
naveedurrehman.com
Useful fluid properties functions
48
• CP and CV: Specific heats at const. pressure and volume
• PRESSURE, TEMPERATURE and VOLUME
• DENSITY: It is also the reciprocal of specific volume
• ENTHALPY, ENTROPY, INTENERGY (Internal energy)
and QUALITY
• P_CRIT, T_CRIT, V_CRIT: Critical properties
• P_SAT and T_SAT: Saturation properties
• T_TRIPLE: Triple point temperature
• PRANDTL: Prandtl number used in heat transfer
• HUMRAT and WETBULB
naveedurrehman.com
Useful fluid properties functions
49
Try:
How much amount of heat per kg of water 100 kPa will be
required to rise temperature from 30°C to 80°C?
Solution:
𝑞 = ℎ 𝑇=80℃,𝑃=100𝑘𝑃𝑎 − ℎ 𝑇=30℃,𝑃=100𝑘𝑃𝑎
Codes:
P = 100 [kPa]
T1 = 30 [C]
T2 = 80 [C]
H1 = ENTHALPY(Steam,T=T1,P=P)
H2 = ENTHALPY(Steam,T=T2,P=P)
Q = H2 - H1
2 1
naveedurrehman.com
Strings
50
String variables are defined within single-quotes.
For example:
F$ = ‘Some string value’
They can be used in place of fluid name, for example:
F$ = 'Steam'
P = P_CRIT(F$)
mode$ = 'blue'
$if mode$='blue'
x=1
$else
x=0
$endif
They can also be used in switching, for example:
Solve these codes with
mode$ value of ‘blue’
and then ‘red’. Check the
value of variable b in
each case.
naveedurrehman.com
Diagram window
51
Diagram Window provides the capability to easily develop a
user-friendly, graphical interface to an EES program.
To open diagram window:
[Menu] Windows > Diagram Window
or
Press ‘Ctrl+D’ key
“Toolbar”
When it is visible, diagram window is in edit
mode. Otherwise, it is in execution mode.
To view toolbar, press ‘Ctrl+D’ again.
naveedurrehman.com
Diagram window
52
Try:
In diagram window, ask user to input values of radius (R”)
and length (L”) of a cylinder. Calculate surface area of
cylinder using 𝐴 = 𝜋𝑅2
+ 2𝜋𝑅𝐿
Diagram window: Codes:
$ifnot diagramwindow
R=1
L = 1
$endif
A = pi*R^2 + 2*pi*R*L
naveedurrehman.com
Diagram window
53
Try:
In diagram window, ask user to select fluid (Ethanol or
Steam) and then show the critical pressure accordingly.
Hint: Use string list.
Diagram window: Codes:
$ifnot diagramwindow
F$=‘Steam'
$endif
P = P_CRIT(F$)
naveedurrehman.com
Subprograms
54
Subprograms help in compartmentalize length codes.
To use a subprogram, first declare and define it one time
and then call it as many times as required. For example:
Declaring and defining a subprogram ‘DOF’:
Subprogram DOF(X : Y, Z) “X=inputs, Y,Z = returns”
X=2*Y+3*Z
X^2=Y^2+Z^2
end
Calling above subprogram two times:
Call DOF(5: B, C)
K=10
Call DOF(K: D, E)
Solution:
naveedurrehman.com
Subprograms
55
Try:
Write a subprogram to calculate length of cylinder by
calling in radius and surface area.
“Declaration and definition of subprogram: CylinderLength”
Subprogram CylinderLength(R,A: L)
A = pi*R^2 + 2*pi*R*L
End
“Calls to subprogram: CylinderLength”
Call CylinderLength(2,600:Length_1)
Call CylinderLength(10,9000:Length_2)
naveedurrehman.com
Practice problems
56
Problem #1
The admission fee at a small fair is $1.50 for children and
$4.00 for adults. On a certain day, 2200 people enter the
fair and $5050 is collected. How many children and how
many adults attended?
Ans: Adults = 700, Children = 1500
SOLUTION:
c = 1.5 "admission fee for children"
a = 4 "admission fee for adults"
p = 2200 "total number of people entered fair"
t = 5050 "total fee collected"
p = nc + na "nc is number of children and na is number of adults"
t = nc*c + na*a "Done!"
naveedurrehman.com
Practice problems
57
Problem #2
Calculate the least distance between following points using
parametric tables feature of EES:
• (0,2) and (10,18)
• (19,9) and (-6,16)
• (-9,0) and (-4,-10)
Distance formula: 𝑑2 = 𝑦2 − 𝑦1
2 + 𝑥2 − 𝑥1
2
Ans: 18.87, 25.96 and 11.18
naveedurrehman.com
Practice problems
58
Problem #3
Determine magnitude and direction of resultant force:
Ans: 629.1 N, 67.89°
Solution:
F_Rx = 600*cos(30) - 400*sin(45)
F_Ry = 600*sin(30) + 400*cos(45)
F_R = SQRT(F_Rx^2 + F_Ry^2)
theta = ARCTAN(F_Ry/F_Rx)
naveedurrehman.com
Practice problems
59
Problem #4
A piston cylinder device initially contains 0.4m3 of air at 100
kPa and 80°C. The air is now compressed to 0.1m3 in such
a way that the temperature inside the cylinder remains
constant. Determine the work done during this process.
Isothermal work done formula: 𝑃1 𝑉1 ln
𝑉2
𝑉1
Ans: -55.45 kJ
naveedurrehman.com
Practice problems
60
Problem #5
Consider a steam power plant operating on the simple ideal
Rankine cycle. Steam enters the turbine at 3MPa and
350°C and is condensed in the condenser at a pressure of
75 kPa. Determine the thermal efficiency of this cycle.
Ans: 26%
naveedurrehman.com

Contenu connexe

Tendances

Seminar Topic on Chemical Exergy
Seminar Topic on Chemical ExergySeminar Topic on Chemical Exergy
Seminar Topic on Chemical Exergy
Nishant Shah
 
Thermodynamics of axial compressor and turbine - 3rd December 2009
Thermodynamics of axial compressor and turbine - 3rd December 2009Thermodynamics of axial compressor and turbine - 3rd December 2009
Thermodynamics of axial compressor and turbine - 3rd December 2009
CangTo Cheah
 

Tendances (20)

Chapter 7: Heat Exchanger
Chapter 7: Heat ExchangerChapter 7: Heat Exchanger
Chapter 7: Heat Exchanger
 
Basic Unit Conversions for Turbomachinery Calculations
Basic Unit Conversions for Turbomachinery Calculations Basic Unit Conversions for Turbomachinery Calculations
Basic Unit Conversions for Turbomachinery Calculations
 
Regenerative rankine cycle (Closed Feedwater Heaters)
Regenerative rankine cycle (Closed Feedwater Heaters)Regenerative rankine cycle (Closed Feedwater Heaters)
Regenerative rankine cycle (Closed Feedwater Heaters)
 
Boiling and Condensation heat transfer -- EES Functions and Procedures
Boiling and Condensation heat transfer -- EES Functions and ProceduresBoiling and Condensation heat transfer -- EES Functions and Procedures
Boiling and Condensation heat transfer -- EES Functions and Procedures
 
Module 10 (air standard cycle)
Module 10 (air standard cycle)Module 10 (air standard cycle)
Module 10 (air standard cycle)
 
A QUICK ESTIMATION METHOD TO DETERMINE HOT RECYCLE REQUIREMENTS FOR CENTRIFUG...
A QUICK ESTIMATION METHOD TO DETERMINE HOT RECYCLE REQUIREMENTS FOR CENTRIFUG...A QUICK ESTIMATION METHOD TO DETERMINE HOT RECYCLE REQUIREMENTS FOR CENTRIFUG...
A QUICK ESTIMATION METHOD TO DETERMINE HOT RECYCLE REQUIREMENTS FOR CENTRIFUG...
 
Final lab report for thermos 2(mech)
Final lab report for thermos 2(mech)Final lab report for thermos 2(mech)
Final lab report for thermos 2(mech)
 
Psychrometry and Air conditioning load estimation
Psychrometry and Air conditioning load estimationPsychrometry and Air conditioning load estimation
Psychrometry and Air conditioning load estimation
 
Refrigeration
RefrigerationRefrigeration
Refrigeration
 
Compressor
CompressorCompressor
Compressor
 
Gas Compressor Calculations Tutorial
Gas Compressor Calculations TutorialGas Compressor Calculations Tutorial
Gas Compressor Calculations Tutorial
 
One dim, steady-state, heat conduction_with_heat_generation
One dim, steady-state, heat conduction_with_heat_generationOne dim, steady-state, heat conduction_with_heat_generation
One dim, steady-state, heat conduction_with_heat_generation
 
Modelling of a cooling tower in EES
Modelling of a cooling tower in EESModelling of a cooling tower in EES
Modelling of a cooling tower in EES
 
Thermodynamics chapter 3
Thermodynamics chapter 3Thermodynamics chapter 3
Thermodynamics chapter 3
 
Heat conduction equation
Heat conduction equationHeat conduction equation
Heat conduction equation
 
Transient heat conduction
Transient heat conductionTransient heat conduction
Transient heat conduction
 
Seminar Topic on Chemical Exergy
Seminar Topic on Chemical ExergySeminar Topic on Chemical Exergy
Seminar Topic on Chemical Exergy
 
Numerical methods for 2 d heat transfer
Numerical methods for 2 d heat transferNumerical methods for 2 d heat transfer
Numerical methods for 2 d heat transfer
 
Presentation on Calculation of Polytropic and Isentropic Efficiency of natura...
Presentation on Calculation of Polytropic and Isentropic Efficiency of natura...Presentation on Calculation of Polytropic and Isentropic Efficiency of natura...
Presentation on Calculation of Polytropic and Isentropic Efficiency of natura...
 
Thermodynamics of axial compressor and turbine - 3rd December 2009
Thermodynamics of axial compressor and turbine - 3rd December 2009Thermodynamics of axial compressor and turbine - 3rd December 2009
Thermodynamics of axial compressor and turbine - 3rd December 2009
 

Similaire à Programming for Mechanical Engineers in EES

SAMPLE QUESTIONExercise 1 Consider the functionf (x,C).docx
SAMPLE QUESTIONExercise 1 Consider the functionf (x,C).docxSAMPLE QUESTIONExercise 1 Consider the functionf (x,C).docx
SAMPLE QUESTIONExercise 1 Consider the functionf (x,C).docx
anhlodge
 
More instructions for the lab write-up1) You are not obli.docx
More instructions for the lab write-up1) You are not obli.docxMore instructions for the lab write-up1) You are not obli.docx
More instructions for the lab write-up1) You are not obli.docx
gilpinleeanna
 

Similaire à Programming for Mechanical Engineers in EES (20)

Structures
StructuresStructures
Structures
 
Travaux Pratique Matlab + Corrige_Smee Kaem Chann
Travaux Pratique Matlab + Corrige_Smee Kaem ChannTravaux Pratique Matlab + Corrige_Smee Kaem Chann
Travaux Pratique Matlab + Corrige_Smee Kaem Chann
 
MATLAB for Technical Computing
MATLAB for Technical ComputingMATLAB for Technical Computing
MATLAB for Technical Computing
 
Es272 ch1
Es272 ch1Es272 ch1
Es272 ch1
 
Modules and Scripts- Python Assignment Help
Modules and Scripts- Python Assignment HelpModules and Scripts- Python Assignment Help
Modules and Scripts- Python Assignment Help
 
SAMPLE QUESTIONExercise 1 Consider the functionf (x,C).docx
SAMPLE QUESTIONExercise 1 Consider the functionf (x,C).docxSAMPLE QUESTIONExercise 1 Consider the functionf (x,C).docx
SAMPLE QUESTIONExercise 1 Consider the functionf (x,C).docx
 
Ch3
Ch3Ch3
Ch3
 
Introduction to programming - class 3
Introduction to programming - class 3Introduction to programming - class 3
Introduction to programming - class 3
 
TALLER PARCIAL II CÁLCULO 3246 (CASTRO,SALAZAR,SHIGUANGO)
TALLER PARCIAL II CÁLCULO 3246 (CASTRO,SALAZAR,SHIGUANGO)TALLER PARCIAL II CÁLCULO 3246 (CASTRO,SALAZAR,SHIGUANGO)
TALLER PARCIAL II CÁLCULO 3246 (CASTRO,SALAZAR,SHIGUANGO)
 
COMPANION TO MATRICES SESSION II.pptx
COMPANION TO MATRICES SESSION II.pptxCOMPANION TO MATRICES SESSION II.pptx
COMPANION TO MATRICES SESSION II.pptx
 
Matlab solved tutorials 2017 june.
Matlab solved tutorials  2017 june.Matlab solved tutorials  2017 june.
Matlab solved tutorials 2017 june.
 
Apclass (2)
Apclass (2)Apclass (2)
Apclass (2)
 
MATLAB-Introd.ppt
MATLAB-Introd.pptMATLAB-Introd.ppt
MATLAB-Introd.ppt
 
More instructions for the lab write-up1) You are not obli.docx
More instructions for the lab write-up1) You are not obli.docxMore instructions for the lab write-up1) You are not obli.docx
More instructions for the lab write-up1) You are not obli.docx
 
Acm aleppo cpc training fifth session
Acm aleppo cpc training fifth sessionAcm aleppo cpc training fifth session
Acm aleppo cpc training fifth session
 
Implementasi Pemodelan Sistem Ke TeeChart 2
Implementasi Pemodelan Sistem Ke TeeChart  2Implementasi Pemodelan Sistem Ke TeeChart  2
Implementasi Pemodelan Sistem Ke TeeChart 2
 
Computational Assignment Help
Computational Assignment HelpComputational Assignment Help
Computational Assignment Help
 
Introduction to r
Introduction to rIntroduction to r
Introduction to r
 
Tutorial 2
Tutorial     2Tutorial     2
Tutorial 2
 
Apclass
ApclassApclass
Apclass
 

Dernier

1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdf
QucHHunhnh
 
Making and Justifying Mathematical Decisions.pdf
Making and Justifying Mathematical Decisions.pdfMaking and Justifying Mathematical Decisions.pdf
Making and Justifying Mathematical Decisions.pdf
Chris Hunter
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdf
ciinovamais
 
Beyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactBeyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global Impact
PECB
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdf
QucHHunhnh
 
The basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxThe basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptx
heathfieldcps1
 

Dernier (20)

1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdf
 
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and Mode
 
Making and Justifying Mathematical Decisions.pdf
Making and Justifying Mathematical Decisions.pdfMaking and Justifying Mathematical Decisions.pdf
Making and Justifying Mathematical Decisions.pdf
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdf
 
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
 
Class 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdfClass 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdf
 
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The Basics
 
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxBasic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
 
Beyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactBeyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global Impact
 
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdf
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introduction
 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy Consulting
 
The basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxThe basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptx
 
Mixin Classes in Odoo 17 How to Extend Models Using Mixin Classes
Mixin Classes in Odoo 17  How to Extend Models Using Mixin ClassesMixin Classes in Odoo 17  How to Extend Models Using Mixin Classes
Mixin Classes in Odoo 17 How to Extend Models Using Mixin Classes
 
Micro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdfMicro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdf
 
How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17
 
Energy Resources. ( B. Pharmacy, 1st Year, Sem-II) Natural Resources
Energy Resources. ( B. Pharmacy, 1st Year, Sem-II) Natural ResourcesEnergy Resources. ( B. Pharmacy, 1st Year, Sem-II) Natural Resources
Energy Resources. ( B. Pharmacy, 1st Year, Sem-II) Natural Resources
 
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptxINDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
 
Unit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxUnit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptx
 

Programming for Mechanical Engineers in EES

  • 1. PROGRAMMING FOR MECHANICAL ENGINEERS IN ENGINEERING EQUATION SOLVER With hands-on training! Naveed ur Rehman http://www.naveedurrehman.com/
  • 2. Introduction to EES • EES (pronounced ’ease’): “Engineering Equation Solver” • Developed by S.A. Klein and G.F. Nellis at University of Wisconsin–Madison. • Licensed and distributed by F-Chart software (http://fchart.com) • Demo version can be acquired free from http://fchart.com/ees/demo.php • Licensing and ordering information can obtained from http://fchart.com/ees/ and http://fchart.com/ees/order.php • Single user license fee: $600-$1200 2naveedurrehman.com
  • 3. Salient features • Support non-sequential codes (or equations) • Support sequential programming language (as in C, MATLAB, Pascal and FORTRAN etc. including conditioning, looping and functional approaches etc.) • Built-in mathematical functions (e.g. PVT diagrams, Moody, Heat exchanger etc.) • Built-in Thermo-physical property functions (e.g. for steam, refrigerants, air, gases etc.) • Support display of results in several visual formats (e.g. graphs, contours, diagrams etc.) 3naveedurrehman.com
  • 4. Salient features • Diagram window: 4naveedurrehman.com
  • 5. Salient features • Parametric solutions: 5naveedurrehman.com
  • 6. Salient features • Solutions on property diagrams: 6naveedurrehman.com
  • 7. Application areas Following are the few application areas and courses where EES can be utilized: • Thermodynamics • Engineering mechanics • Fluid mechanics • Heat transfer • Gas dynamics • IC Engines • Steam and gas turbines • Refrigeration & air conditioning • Renewable energy technologies • Final Year Project 7naveedurrehman.com
  • 8. Environment “Equations window” “Menu” “Toolbar” Remember, EES is case-insensitive i.e. ABC = abc = AbC = Abc… 8naveedurrehman.com
  • 9. Solving an equation X + 3 = 5 Try: To obtain solution: [Menu] Calculate > Solve or Press “F2” key In Solution Window: 9naveedurrehman.com
  • 10. Solving an equation Try: A + 3 = 5 * 4 B + 3 = 5 ^ 2 C = 5 + ( 3 * (4 - 2 ^ 5 ) ) / 100 D + 2 * D = 9 E ^ 2 = 100 50 = F ^ (1/2) G ^ 1.333 = 0.4 10naveedurrehman.com
  • 11. Solving an equation Try: 3*H^2 - 4*H - 5 = 0 0.5*J^3 - 3*J^2 - 4*J - 5 = 0 (K+3)*(K-4)*(K+5)=1/K SQRT(2) = X + SQRT(X+1) 3𝐻2 − 4𝐻 − 5 = 0 0.5𝐽3 − 3𝐽2 − 4𝐽 − 5 = 0 𝐾 + 3 𝐾 − 4 𝐾 + 5 = 1 𝐾 2 = 𝑋 + 𝑋 + 1 11naveedurrehman.com
  • 12. Solving system of equations Try: X + Y = 10 X - 2*Y = 5 12 X + Y + Z = 10 X - 2*Y = 5 X + Z = 4 X + Y + Z = 10 X + Y = 0 What about this: Remember, number of variables = number of equations! ERROR! naveedurrehman.com
  • 13. Solving system of equations Try: V = pi * (R^2) * H R = 10 H = 12 13 Calculate volume of cylinder where radius is 10 m and height = 12 m (using 𝑉 = 𝜋𝑅2 𝐻) Calculate height of cylinder where radius is 10 m and volume = 3000 m3 (using 𝑉 = 𝜋𝑅2 𝐻) V = pi * (R^2) * H R = 10 V = 3000 naveedurrehman.com
  • 14. Solving system of equations Try: R = G + 2 G = 2 * B B = 3 14 Diameter of red ball is 2” more than that of green ball. While the diameter of green ball is twice than that of blue ball. If the diameter of blue ball is 3”, calculate diameters of other two balls. Codes: naveedurrehman.com
  • 15. Solving system of equations Try: M_left = M_right M_left = F*3 M_right = 12*8 15 𝑀𝑙𝑒𝑓𝑡 = 𝑀𝑟𝑖𝑔ℎ𝑡 𝑀𝑙𝑒𝑓𝑡 = 𝐹. 3 𝑀𝑟𝑖𝑔ℎ𝑡 = 12 × 8 Hint: Codes: naveedurrehman.com
  • 16. Engineering units Try: 16 T = 30 [C] A = 40 [m^2] To insert a unit from list, right-click editor, select “Units list”. After selecting unit from list, click “Paste”. naveedurrehman.com
  • 17. Units consistency check Try: T = 30 [C] A = 40 [m^2] U = T+A 17 To check consistency of units: [Menu] Calculate > Check units or Press “F8” key naveedurrehman.com
  • 18. Units consistency check Try: T = 30 [C] A = 40 [m^2] U = T * A 18 Consistency check: Right-click equation and select “Set variable Units”. Input the valid unit (C*m^2) for U and click “Ok”. naveedurrehman.com
  • 19. Units conversion Try: A = 30*Convert(ft,m) B = 10*Convert(MJ, kJ) C = 100*Convert(kJ/kg,BTU/lbm) 19 Solution: Note: Unit to each variable is automatically assigned. Convert statement is used to do unit conversion: Convert ( from-unit , to-unit ) naveedurrehman.com
  • 20. Converting temperature units Try: TheF = ConvertTEMP(C,F,30) "Convert 30 deg. C to deg. F" TheC = ConvertTEMP(F,C,100) "Convert 100 deg. F to deg. C" 20 Solution: ConvertTemp statement is used to do unit conversion between degree centigrade (°C) and Fahrenheit (°F): ConvertTEMP ( from-unit , to-unit, value) naveedurrehman.com
  • 21. Formatted equations Try: f_c = 100 A =(1/pi^2)/f_c 21 To view formatted equations: [Menu] Windows > Formatted Equations or Press “Ctrl + F” key naveedurrehman.com
  • 22. Formatted equations Variable display options for Formatted Equations Window: 22naveedurrehman.com
  • 24. Comments Try: A = 10 "Area of surface" W = 4 "!Width of surface" H = A/W {Height of surface} C = 400 {!Looks like constant} 24 Formatted equations: To set color and font style: [Menu] Options > Preferences > Equations Set properties for type I and type II comments. Click “Store” to save your preferences. Type I comment: “ “ or { } Type II comment: “! “ or {! } naveedurrehman.com
  • 25. Bookmarking Bookmarks are helpful in lengthy programs. To add a bookmark, use following directive: $Bookmark …caption… For example: $Bookmark COMRPESSOR To access bookmarks, right-click in editor and select bookmark from the list given at the end. 25naveedurrehman.com
  • 26. Variable information Try: D ^2=100 J = D + 50 26 To view variable info: [Menu] Options > Variable Info or Press “F9” key Solution: naveedurrehman.com
  • 27. Variable information Try: D^2=100 J = D + 50 27 Solution constraint: The value variable D of must be less than 0. Do the following settings in Variable info: Note that, a good guess may speed up processing. Another purpose of variable info is to replace a particular variable everywhere in codes. For this, try to rename variable “D” as “E” and press “Ok”. naveedurrehman.com
  • 28. Exporting values 28 To export: $export /A 'filename' var1 var2 …. Where, • Flag /A is optional and is used to append contents. • Filename can have following extensions: 1. csv, tab, dat: these extensions are generally accepted by most of the software e.g. MATLAB, EXCEL. 2. txt: this extension will create file which is read-able by Open Lookup Table command from Tables menu. If file name is just ‘clipboard’, contents will be copied to clipboard. naveedurrehman.com
  • 29. Importing values 29 To import: $import ‘filename’, var1 var2 …. Try: Create a file ‘c:data.txt’ with the following contents: 1000 500 100 Then, solve these codes: $import 'c:data.txt', a b c d = a + b + c Solution: naveedurrehman.com
  • 30. Constants 30 To add a pre-defined constant: [Menu] Options > Constants Select constant from list and click “Paste”. Try: mass = 10 weight = mass*g# Remember, constants are not treated as variables! For example, in above, there are just two variables i.e. “mass” and “weight” and hence, this system of equations has some solution. Custom constants may be added to the list. naveedurrehman.com
  • 31. Arrays 31 An array (or vector) is an organized collection of different values of same variable. Arrays are helpful in batch processing, making plots, etc. Try: T[1]=100 "the first element of the array T" T[2]=200 "the second element of the array T" T[3]=300 "the third element of the array T" In above, the variable “T” is not a scalar variable, but it is an array (or vector) having values 100, 200 and 300 placed at index 1, 2 and 3 respectively. $Arrays ON and $Arrays OFF directive may be used to switch the display of Arrays window. naveedurrehman.com
  • 32. Multi-dimensional arrays 32 Try: T[1,1]=100 T[1,2]=200 T[1,3]=300 T[2,1]=444 T[2,2]=555 T[2,3]=666 Arrays Table: Above is an example of 2D array. More dimensions can be added by using “,” separator in square brackets. naveedurrehman.com
  • 33. Duplicate statement 33 Duplicate statement provides a convenient method for carrying out similar operations on multiple elements of an array. Duplicate index = start,stop equation(s) to be duplicated End duplicate i=1,4 T[i]=i end Try: Arrays Table: naveedurrehman.com
  • 34. Duplicate statement 34 Try: For the 10 points of “X”, the value of “Y” is “X^2+10”. Using duplicate statement, generate array table for X and Y such that: duplicate i=1,10 Y[i] = i^2 + 10 X[i]=i end Solution:: Hint: Both X and Y are vectors. A scalar variable as iterator may be used in duplicate statement. naveedurrehman.com
  • 35. 2D plots 35 To draw plot: [Menu] Plots > Now Plot Window > X-Y Plot Select variables for X and Y axis and click “Ok”. Try: Draw X-Y plot for previous example. naveedurrehman.com
  • 36. 3D plots 36 To draw plot: [Menu] Plots > Now Plot Window > X-Y-Z Plot Select variables for X, Y and Z axis, opt “3-D Plot” and click “Ok”. Try: Draw plot for the following: duplicate i=1,10 X[i]=i Y[i] = i + 1 Z[i] = i end naveedurrehman.com
  • 37. Lookup tables 37 Lookup Tables provide a convenient method of saving and accessing tabular data, useful for interpolation and curve fitting. To add a lookup table: [Menu] Tables > New Lookup Table • Suggest suitable title. This will be used while retrieving values. • Select number of rows and columns required in table. • Data can be entered manually or can be copy-pasted from MATLAB, EXCEL etc. • Lookup tables can be exported to a file for sharing purpose. • Also, they can be imported from CSV files, a famous export extension supported by common data loggers. naveedurrehman.com
  • 38. Lookup tables 38 Try: Time taken by a metallic ball when dropped from different height were recorded as shown in table. Develop a lookup table titled: “FALL” for this data. naveedurrehman.com
  • 39. Interpolation in lookup table 39 Interpolated data can be retrieved from lookup tables using Interpolate statement. X = Interpolate('TableName', 'Var1', 'Var2', Var=Val) Try: Using lookup table created in previous example: Ans_1 = Interpolate('FALL','Height','Time',Time=230) Ans_2 = Interpolate('FALL','Height','Time',Height=45) Solution: naveedurrehman.com
  • 40. Other lookup functions 40 • Lookup: Return value at given row and column X = Lookup('Table',Row,Column) • LookupRow: Return row#. Value matching in column. X = LookupRow('Table',Column,Value) • LookupCol: Return column#. Value matching in row. X = LookupCol('Table',Row,Value) • AvgLookup: Return average of values. X = AvgLookup(‘Table','ColName',[StartRow,StopRow]) • SumLookup: Return average of values. X = SumLookup(‘Table','ColName',[StartRow,StopRow]) naveedurrehman.com
  • 41. Regression 41 Regression is a useful method to find dependence of one variable on to other variables. To find linear regression equation: [Menu] Tables > Linear Regression Select dependent variable and independent variable(s). Click “Fit” to find the fitted equation. To find statistics regarding fit, click “Stats”. Polynomial order can be increased and cross-terms may be added to increase accuracy. naveedurrehman.com
  • 42. Regression 42 Try: For the following data, determine 2nd order polynomial of “TIME” as a function of “HEIGHT” and “VELOCITY”: naveedurrehman.com
  • 43. Parametric tables 43 Parametric tables are used for parametric studies in which the effect of one variable (the independent variable) on another variable (the dependent variable) is studied. To create parametric table: Writing codes conventionally in editor and then click: [Menu] Tables > New Parametric Table To populate (or solve) a parametric table: [Menu] Calculate > Solve Table Or Press ‘F3’ key. naveedurrehman.com
  • 44. Parametric tables 44 Try: Surface area of a cylinder is given by: 𝐴 = 𝜋𝑅2 + 2𝜋𝑅𝐿 Complete the following table: naveedurrehman.com
  • 45. Parametric tables with a check 45 To check whether the parametric solution is required, use: $IfNot ParametricTable …relations… $EndIf For example, in previous problem, constant values of L and R may be given inside codes: $IfNot ParametricTable L= 30 R = 50 $EndIf naveedurrehman.com
  • 46. Functions 46 To access available functions: [Menu] Options > Function Info Select function from list and click “Paste”. naveedurrehman.com
  • 47. Useful math functions 47 • Trigonometric functions: sin, cos, tan • Trigonometric inverse functions: arcsin, arccos, arctan • Hyperbolic functions: sinh, cosh, tanh • Hyperbolic inverse functions: arcsinh, arccosh, arctanh • Logarithmic and exponent functions: ln, log10, exp • Other functions: abs, floor, sum, average, mod, max, min naveedurrehman.com
  • 48. Useful fluid properties functions 48 • CP and CV: Specific heats at const. pressure and volume • PRESSURE, TEMPERATURE and VOLUME • DENSITY: It is also the reciprocal of specific volume • ENTHALPY, ENTROPY, INTENERGY (Internal energy) and QUALITY • P_CRIT, T_CRIT, V_CRIT: Critical properties • P_SAT and T_SAT: Saturation properties • T_TRIPLE: Triple point temperature • PRANDTL: Prandtl number used in heat transfer • HUMRAT and WETBULB naveedurrehman.com
  • 49. Useful fluid properties functions 49 Try: How much amount of heat per kg of water 100 kPa will be required to rise temperature from 30°C to 80°C? Solution: 𝑞 = ℎ 𝑇=80℃,𝑃=100𝑘𝑃𝑎 − ℎ 𝑇=30℃,𝑃=100𝑘𝑃𝑎 Codes: P = 100 [kPa] T1 = 30 [C] T2 = 80 [C] H1 = ENTHALPY(Steam,T=T1,P=P) H2 = ENTHALPY(Steam,T=T2,P=P) Q = H2 - H1 2 1 naveedurrehman.com
  • 50. Strings 50 String variables are defined within single-quotes. For example: F$ = ‘Some string value’ They can be used in place of fluid name, for example: F$ = 'Steam' P = P_CRIT(F$) mode$ = 'blue' $if mode$='blue' x=1 $else x=0 $endif They can also be used in switching, for example: Solve these codes with mode$ value of ‘blue’ and then ‘red’. Check the value of variable b in each case. naveedurrehman.com
  • 51. Diagram window 51 Diagram Window provides the capability to easily develop a user-friendly, graphical interface to an EES program. To open diagram window: [Menu] Windows > Diagram Window or Press ‘Ctrl+D’ key “Toolbar” When it is visible, diagram window is in edit mode. Otherwise, it is in execution mode. To view toolbar, press ‘Ctrl+D’ again. naveedurrehman.com
  • 52. Diagram window 52 Try: In diagram window, ask user to input values of radius (R”) and length (L”) of a cylinder. Calculate surface area of cylinder using 𝐴 = 𝜋𝑅2 + 2𝜋𝑅𝐿 Diagram window: Codes: $ifnot diagramwindow R=1 L = 1 $endif A = pi*R^2 + 2*pi*R*L naveedurrehman.com
  • 53. Diagram window 53 Try: In diagram window, ask user to select fluid (Ethanol or Steam) and then show the critical pressure accordingly. Hint: Use string list. Diagram window: Codes: $ifnot diagramwindow F$=‘Steam' $endif P = P_CRIT(F$) naveedurrehman.com
  • 54. Subprograms 54 Subprograms help in compartmentalize length codes. To use a subprogram, first declare and define it one time and then call it as many times as required. For example: Declaring and defining a subprogram ‘DOF’: Subprogram DOF(X : Y, Z) “X=inputs, Y,Z = returns” X=2*Y+3*Z X^2=Y^2+Z^2 end Calling above subprogram two times: Call DOF(5: B, C) K=10 Call DOF(K: D, E) Solution: naveedurrehman.com
  • 55. Subprograms 55 Try: Write a subprogram to calculate length of cylinder by calling in radius and surface area. “Declaration and definition of subprogram: CylinderLength” Subprogram CylinderLength(R,A: L) A = pi*R^2 + 2*pi*R*L End “Calls to subprogram: CylinderLength” Call CylinderLength(2,600:Length_1) Call CylinderLength(10,9000:Length_2) naveedurrehman.com
  • 56. Practice problems 56 Problem #1 The admission fee at a small fair is $1.50 for children and $4.00 for adults. On a certain day, 2200 people enter the fair and $5050 is collected. How many children and how many adults attended? Ans: Adults = 700, Children = 1500 SOLUTION: c = 1.5 "admission fee for children" a = 4 "admission fee for adults" p = 2200 "total number of people entered fair" t = 5050 "total fee collected" p = nc + na "nc is number of children and na is number of adults" t = nc*c + na*a "Done!" naveedurrehman.com
  • 57. Practice problems 57 Problem #2 Calculate the least distance between following points using parametric tables feature of EES: • (0,2) and (10,18) • (19,9) and (-6,16) • (-9,0) and (-4,-10) Distance formula: 𝑑2 = 𝑦2 − 𝑦1 2 + 𝑥2 − 𝑥1 2 Ans: 18.87, 25.96 and 11.18 naveedurrehman.com
  • 58. Practice problems 58 Problem #3 Determine magnitude and direction of resultant force: Ans: 629.1 N, 67.89° Solution: F_Rx = 600*cos(30) - 400*sin(45) F_Ry = 600*sin(30) + 400*cos(45) F_R = SQRT(F_Rx^2 + F_Ry^2) theta = ARCTAN(F_Ry/F_Rx) naveedurrehman.com
  • 59. Practice problems 59 Problem #4 A piston cylinder device initially contains 0.4m3 of air at 100 kPa and 80°C. The air is now compressed to 0.1m3 in such a way that the temperature inside the cylinder remains constant. Determine the work done during this process. Isothermal work done formula: 𝑃1 𝑉1 ln 𝑉2 𝑉1 Ans: -55.45 kJ naveedurrehman.com
  • 60. Practice problems 60 Problem #5 Consider a steam power plant operating on the simple ideal Rankine cycle. Steam enters the turbine at 3MPa and 350°C and is condensed in the condenser at a pressure of 75 kPa. Determine the thermal efficiency of this cycle. Ans: 26% naveedurrehman.com

Notes de l'éditeur

  1. x + y = 10xy x^2 + y^3 = 3xy