Controlling the Output Variable

Output variables are not limited to the Discrete variable definition type, so the behavior when getting and setting outputs is slightly different from that of inputs.

Getting Discrete Output Values

The following table shows the get behavior for the different variable definition types.

Variable Definition TypeBehavior
DiscreteSame as described earlier for getting discrete input values.
FreeFor C#, the property returns null. For Python, the property returns None.
FormulaThe property returns the series of evaluated variable values.
Setting Discrete Output Values

The following table shows the set behavior according to the list content provided to the property.

List ContentBehavior
None or nullThe variable is switched to the Free definition type if it is supported by the boundary condition. Otherwise, an error is issued.
Single quantity objectThe variable is switched to the Constant definition type if supported in the interface. Otherwise, Constant (ramped) can be chosen. If neither of those two types are supported, Tabular Data is the default.
Two quantity objects, with the first value being 0The variable is switched to Constant (ramped) if supported in the interface. Otherwise, Tabular Data is the default.
As many quantity objects as discrete values for the input variablesThe variable is switched to Tabular Data.
Does not fall into any of the above categoriesAn error is issued, indicating that you should either:
  • Provide the appropriate number of values.

  • Change the number of input values first, as the input value count is used to determine the row count of the tabular data. Output values must then comply with this number of rows.

The following figure shows a sample message.
Setting Variable Definition Type by Acting on Discrete Values

The variable definition type can also be modified by setting the DiscreteValues property on the variable. To set a variable to a particular variable type, you set the values that are consistent with that variable type. Examples follow:

  • To set an input variable to Tabular Data, assign a list of discrete values:

    d.XComponent.Output.DiscreteValues = [Quantity("1 [m]"), Quantity("10 [m]")]

  • To set a variable to Free, assign None to its DiscreteValues:

    d.XComponent.Output.DiscreteValues = None