Documente Academic
Documente Profesional
Documente Cultură
Engineering
Advanced EES
Lecture 6
Advanced Features
Contents
EES advanced tutorial
(2 Lectures)
Min/Max analysis
(Lect 5)
Uncertainty analysis
Coding conventions
(Lect 6)
String functions, constants
Diagram window
Functions, procedures, modules & subprograms
Loops
Curvefitting
TableRun#, TableValue, Lookup
Disk input and output, formatted output
Other important features
Coding Conventions
Capitalisation:
Use capitals or mixed case for directives such as
$UnitSystem, $IfDef (or if you really insist use
$IFDEF)
Use lowercase (mostly) for variable names
Use mixed case for user defined function names and
logical statements such as If, Do, Repeat-Until,
Duplicate
Most importantly however, be consistent!
Spaces:
Use spaces liberally either side of operators +, -, /,
*, =
Indent and align lines inside If, Do, Duplicate and
inside functions
String Functions
See the Help file for String Functions:
Concat$
Date$
EesFileDir$
LowerCase$
String$
StringLen
StringPos
StringVal
Time$
UpperCase$
Strings
EES handles strings quite elegantly:
Strings
String usage example:
Diagram Window
The Diagram Window (Ctrl+D) provided EES
with a Graphical User Interface that can
contain:
input fields
output fields
radio buttons
drop down boxes
Diagram Window
menu
Functions
EES solves the main body of the program as
a simultaneous set of equations, and not
sequential. That implies that logic cannot be
accommodated in the main body and has to
be added to a function.
For the same reason, loops (apart from
Duplicate) cannot be added to the main
body and has to be implemented in a
function.
Functions that the user defines are no
different from those chosen from the
Options > Function Info menu:
a = cos(theta)
b = sqrt(value)
Functions
Functions must be declared before (above)
the main body of an EES program:
$TabStops 0.5 cm
Function Minimum(x, y)
if (x < y) then
Minimum = x
else
Minimum = y
endif
End
a = 12
The main body of the EES program starts here
b = -10
x_min = Minimum(a, b)
Functions
Logic can be nested to provide more complex
behaviour, for example:
$TabStops 0.5 cm
Function Smallest(x, y, z)
End
a = 12
b = -12
c = 22
x_smallest = Smallest(a, b, c)
Procedures
EES Procedures are very much like EES Functions,
except that they allow multiple inputs and outputs.
The format of a Procedure is:
$TabStops 0.5 cm
Procedure CalcSquareOfTwo(x, y: x_sq, y_sq)
x_sq = x * x
y_sq = y * y
End
a = 12
b = -12
Call CalcSquareOfTwo(a, b: a_sq, b_sq)
Loops
Loops are implemented in a function or a procedure
as follows: (Lecture 6.3 - Loops.EES)
$TabStops 0.5 cm
Function SumOfArray(n, x[1..n])
sum = 0
i=1
Repeat
sum = sum + x[i]
i=i+1
Until (i > n)
SumOfArray = sum
End
c[1] = 12
c[2] = 5
c[3] = 27
c[4] = 9
c[5] = 16
size = 5
sum = SumOfArray(size, c[1..size])
3
4
5
6
7
4
5
6
7
8
2D & 3D interpolation
Lookup files (instead of lookup tables!)
3D Plots
Create LaTeX/PDF Report (MikTex http://miktex.org)
ERROR & WARNING procedures
EES File Types
Distributable programs
Library Manager
Animation (Also plot animation)
$TRACE, Residual Window, $SAVETABLE
End of Lecture 6
0:05