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 Type Behavior Discrete Same as described earlier for getting discrete input values. Free For C#, the property returns null
. For Python, the property returnsNone
.Formula The 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 Content Behavior None or null The variable is switched to the Free definition type if it is supported by the boundary condition. Otherwise, an error is issued. Single quantity object The 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 0 The 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 variables The variable is switched to Tabular Data. Does not fall into any of the above categories An error is issued, indicating that you should either: The following figure shows a sample message.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.
- 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 itsDiscreteValues
:d.XComponent.Output.DiscreteValues = None