Variables

Variables

Variables are calculated values that represent model states. Variables are modified by the solver as it searches for a solution. Each additional variable adds a degree of freedom to the problem.

Variables are declared in the Variables ... End Variables section of the model file. The variables may be defined in one section or in multiple declarations throughout the model. Variable initialization is performed sequentially, from top to bottom. If a variable does not have an initial value given, a default value of 1.0 is assigned. Variables may also be a function of other parameters or variable initial conditions. These initial conditions are processed once as the first step after the model parsing.

Scope

All variables have global scope. This facilitates the exchange of information between models but can also lead to name conflicts. Object variables have the object name pre-pended. In order to use an object's variable in an equation, a connection must be made to a user-defined variable.

Global Name

Variables are identified by the simulation mode, file name, model or object name, and variable name. These names are separated by a period to form a global name. These global names are used in configuration files to identify the variable.

Example

 ! Example variable declarations in test.apm
 Variables
   v0                 ! no initial value, default = 1
   v1 = 1.5           ! initializes to 1.5
   v2 = 2 * v1        ! initializes to 3.0
   v3 = exp(v2) * v1  ! initializes to exp(3.0) * 1.5

   x < 5              ! initializes to 1.0 (default)
                      !   with upper bound 5
   y = 2              ! initializes to 2.0
   z = 1.8 < 2.3 >=0  ! initializes to 1.8
                      !   with upper bound 2.3
                      !   and lower bound 0
 End Variables