selector.py
- class openconcept.utilities.selector.SelectorComp(**kwargs)
Bases:
ExplicitComponent
Selects an output from the set of user-specified inputs based on the selector input at runtime.
For example, if the inputs argument is [‘A’, ‘B’, ‘C’], then a selector value of 0 would return input ‘A’, a selector value of 1 would return input ‘B’, and a selector value of 2 would return input ‘C’.
In practice, the inputs may be vectors. Suppose ‘A’ has the value [10, 10, 10, 10], ‘B’ has the value [5, 5, 5, 5], and ‘C’ has the value [7, 7, 7, 7], then a selector of [0, 1, 2, 1] would make the ‘result’ output take on the value [10, 5, 7, 5].
If the selector value is out of range, a warning is raised and zero is returned where the selector value is invalid.
- Inputs:
selector (int) – Selects which input to route to the output based on the order they were specified; must be in the range [0, # of inputs) and if the data type is not already an int, it is rounded to the nearest integer value (vector, default 0)
user defined inputs (any) – The data inputs must be specified by the user using the input_names option and all inputs must have the same units, if none are specified error is raised (vector)
- Outputs:
result (same as selected input) – The same value as the input selected by the selector input (vector)
- Options:
num_nodes (int) – Length of all inputs and outputs (scalar, default 1)
input_names (iterable of strings) – List of the names of the the user-specified inputs
units (string) – OpenMDAO-style units of the inputs; all inputs should have these units