Constants

Constants are fixed values that represent model inputs, fixed constants, or any other value that does not change. Constants are not modified by the solver as it searches for a solution. As such, constants do not contribute to the number of degrees of freedom (DOF).

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

Example

 ! Example model that demonstrates constant declarations
 Model example
   Constants
     c0                 ! no initial value provided - default = 1
     c1 = 1.5           ! initializes to 1.5
     c2 = 2 * c1        ! initializes to 3.0
     c3 = exp(c2) * c1  ! initializes to exp(3.0) * 1.5
     my_constant = 5    ! initializes to 5.0
   End Constants

   Variables
     x[1:c2] = my_constant ! create a vector of 3 initialized to 5
   End Variables

   Equations
     x[1:c2-1] = c3
     x[c2] = c1 + c2 + x[1]
   End Equations
 End Model
💬