XVars

Exposed Variables

You can set which parameters are “exposed” in the Key Parameters view through adding or removing XVar blocks. The following is an example of an XVar block:

<XVar variableName>
  description = "Description of the variable"
  min = minimum value
  max = maximum value
</XVar>

The lines in this block are as follows:

  • <XVar variableName> Begins the XVar block for variableName. The variable name here must exactly match the variable that you are trying to define.
  • description Describes the variable and will appear when the cursor is placed over the variable name in the Key Parameters view.
  • min This is the minimum value for the variable and is optional. Setting a minimum can be very useful with certain simulation parameters such as cell size, which can cause an instability if incorrectly specified.
  • max This is the maximum value for the variable and is optional.

Note

The name of the key parameter will turn red if there is no value given for the parameter, or if the parameter is not greater than or equal to min and less than or equal to max, if they are specified.

Primary Variables

The Primary Variables are variables that correspond to the XVar blocks defined in the above Exposed Variables section. The syntax for setting primary variables is the same as setting any other user-defined variable:

$ VARIABLENAME = default value

Variable names are generally in all capital letters. If you redefine this value through the Key Parameters pane, it will overwrite the default value set in the .pre file.

Setting Key Parameters

You can also declare your primary variables right before their respective XVar blocks and essentially condense the Exposed Variables and Primary Variables sections into one, as shown below:

$ VARIABLEONE = default value
<XVar VARIABLEONE>
  description = "First variable"
  min = minimum value
  max = maximum value
</XVar>

$ VARIABLETWO = default value
<XVAR VARIABLETWO>
  description = "Second variable"
</XVar>

The parameters defined in the sections above then can be passed as the values for global variables that define your simulation. For example, if you defined a variable named NDIM as below:

$ NDIM  = 3
<XVar NDIM>
  description = "Number of simulated dimensions"
  min = 3
</XVar>

You could then use this parameter as the value for the global variable dimension.

dimension = NDIM

For more information on global variables, see either Global Variables or the section on global variables in VSim Reference.