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.  In the Professional version, the values provided for the Guess, Lower and Upper values can also be arrays.  See Example 4

 

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, as detailed in the Display Formats section.  

 

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 directive.

 

a=2

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

x=y^2+2

y=x^3-362

 

 

Example 4:

The following program demonstrates how the Professional version will allow the $VarInfo directive to set the guess values and lower and upper limits of all variables in an array to Guess, Lower and Upper values defined by other arrays.

 

$UnitSystem SI MASS RAD PA  K J

W=1 [m]    

H=1.5 [m]    

h_bar=30 [W/m^2-K]

k=10 [W/m-K]

Nterm=5

Duplicate i=1,Nterm

 LowerLimit[i]=(2*i-1)*pi/2

 UpperLimit[i]=i*pi

 myGuess[i]=(LowerLimit[i]+UpperLimit[i])/2

End

Duplicate i=1,Nterm

 -k*lambdaW[i]/(h_bar*W)=tan(lambdaW[i])

End

$VarInfo lambdaW[] Guess=myguess[] lower=lowerLimit[] upper=upperLimit[]

 

Example 5:

The following program will set the display format for variable D1 to a datetime format and D2 to a date form.  The values of D1 and D2 are then set to the current date and time.

 

$VarInfo D1 display=d8

$VarInfo D2 display=D8

D1=date(DateTime$)

D2=date(Date$)

 

{Solution:

D1=Apr 22 2022 16:43:13 

D2=Apr 22 2022 

}

 

 

See also:  Variable Info

 Directives