Contents - Index


$VarInfo

 

The $VarInfo directive allows variable information (e.g., the guess value, limits, units, display format, etc.) to be entered from the Equations window, rather than from the Variable Information dialog.  This directive is very useful when it is necessary to enter commands to EES from a macro or from a text file, as for example, when using the internet EES_App.  A separate directive is needed for each variable.  The format of the VarInfo directive is as follows

 

$VarInfo  VariableName  Guess=V1  Lower=V2  Upper=V3  Units='XXXX'  AltUnits='YYYY'  Display=F1  Style=Bold  Key='Key variable comment'

 

VariableName must be the first parameter.  The variable name does not need to previously defined, so the location of the $VarInfo directive is not important.  However, it is best to place the $VarInfo directives before the first equation in the main section of the Equations window

 

Note that VariableName can designate an array by including [] in VariableName.  See Example 2.

 

Following VariableName, the remaining part of the directive consists of one or more keywords (shown in bold above) followed by an equal sign and a specification. It is only necessary to provide the keyword=specification terms that you are interested in changing and they can be provided in any order.

 

V1, V2, and V3 shown as the specifications for Guess, Lower, and Upper, can be a numerical value or the name of an EES variable.  In the latter case, EES will use the current value of the variable as the value for the specification.  In the Professional version, EES will accept a simple equation, .e.g., x+2, for V1, V2, and V3,  See Example 3,

 

The Units specification can be a string constant (within single quotes) or a string variable.  The units are also set if V1, V2, or V3 is a numerical constant followed by a unit specification.  For example,  $VarInfo X Guess=300 [K] will set the guess value for X to be 300  and the units to be K.

 

The AltUnits specification must have the same dimensions as Units.  

 

The Display specification consists of two characters.  The first character can be A, F, E, G, or T.  A stands for Auto format.  When this format option (the default) is selected, EES will internally choose a format for displaying the value.  F means Fixed Decimal format.  In this case, the number in the second field indicates the number of digits to the right of the decimal separator.  E indicates exponential format.  The number that follows the E is the number of digits to the right of the decimal separator.   G indicates engineering format.  Engineering format is similar to exponential format in that the value is shown with a number followed by an exponent.  However, in engineering format, that exponent is always an integer factor of 3.  The number that follows G is the number of significant figures. T indicates time format  D indicates date format.  In this case, the value in decimal hours is converted to hour:minutes:seconds.  The number in the second display column affects the number of significant figures displayed. For F and E formats, this value will the number of digits to the right of the decimal point.  For G (Engineering) format, this number will be the number of significant figures. 

 

The Style specification controls the appearance of the variable in the Solutions window.  Allowable specifications are Normal, Italic, Bold and Boxed.

 

The Key specification indicates that the variable should be considered to be a key variable.  The comment that appears in the Key variable tab of the Solution window is provided after the equal sign in quotes

 

Note that this directive is applicable for Modules, Subprograms, Functions, and Procedures, as well as for the Main program.  However, keywords Guess, Lower, Upper, and Key are ignored if the directive is used within a Function or Procedures as these programming units do not use guess values or bounds, and do not display key variables.

 

Example 1:

The following example will calculate the specific enthalpy of steam in variable h and set its units to 'kJ/kg'

 

$UnitSystem SI C kPa kJ mass

T=100 [C]

P=50 [kPa]

$VarInfo h Units='kJ/kg'  AltUnits='Btu/lb_m'

h=enthalpy(Steam,T=T,P=P)

 

{Solution: h=2682 [kJ/kg] {1153 Btu/lbm}}

 

 

Example 2:

The following program will set all of the variables in array T to have units of K in both the Procedure and the Main program.

 

Procedure Calct(N:T[1..100])

$VarInfo T[] Units='K'

   T[1]=300 [K]

   Duplicate i=2,N

      T[i]=T[i-1]+1 [K]

   End

End

 

$VarInfo T[] Units='K'

N=24

Call Calct(N:T[1..N])

 

Example 3:

The following program demonstrates how the Professional version will allow equations to be used for the Guess, Lower and Upper values in the $VarInfo directiive.

 

a=2

$varinfo x  Lower=a-10  Guess=a  Upper=a+10

x=y^2+2

y=x^3-362

 

 

 

See also:  Variable Info

Directives