Routes the flow from the input to one of the outputs.
At design time you can choose the initially selected output. It can be changed at runtime by calling the functions toggle() and select(). For example, the block is named selectOutput. To select output 1 at runtime, call: selectOutput.select(1). To select output 2: selectOutput.select(2).
In addition, you have an option of selecting output based on the incoming batch.
FluidSelectOutput is a zero-capacity block, it does not contain any amount of fluid. The output batch at the selected output of the FluidSelectOutput block is the same as the one at the input. The On new batch … action can be used to switch the output depending on the incoming batches.
If required, you can set the Limited output rate option and define the upper limit for the rate in the parameter Maximum output rate). The specified rate cannot be lower than the value of Utils.RATE_TOLERANCE constant, i.e. 1.0e-9. If rate value falls below this value after recalculation, it will be snapped to 0.Demo model: FluidSelectOutput
- Select output
Here you define how the output will be selected. There are two alternative options:
Syntax: boolean selectOnCondition
- By calling select() function — the output can be changed at runtime by calling the block functions toggle() and select().
- Conditionally, on each batch — the output will be selected by evaluating the boolean condition specified in the Condition (true is Output 1) field below. The condition is evaluated for each new batch and the output is selected based on the result.
Set new value at runtime: set_selectOnCondition(new value)
true — Conditionally, on each batch
false — By calling select() function
[Visible and applies only if Select output is set to Conditionally, on each batch]
Here you specify the boolean condition that will be evaluated for each new batch. If the result is true, output 1 is selected, otherwise — output 2.Value type: boolean
Local variable: Object batch — the batch
- Initial selection
If the option is selected (the value is equal to true), the flow from the input will be initially routed to the output 1, if false — to output 2. The initially selected output can be changed at runtime by calling select() function, or by evaluating the boolean condition for each new batch, depending on the Select output parameter value.
Syntax: boolean selectOutput1
- Limited output rate
If the option is selected (the value is equal to true), you are able to specify a custom upper limit of the output rate, per output.
Syntax: boolean limitRateOut
Change the value at runtime: set_limitRateOut(true) or set_limitRateOut(false)
- Maximum output rate
[Visible and applies only if the Limited output rate option is set]
Custom upper limit of the output rate, at each output. The default value is 10 cubic meters per second.Syntax: double maxRateOut
Set new value at runtime: set_maxRateOut(new value)
- Show batches in flowchart
If set, the block icon will display the current batch color.
Syntax: boolean showBatchesInFlowchart
- On new batch
Action executed when a new batch appears at the input. It will not necessarily start flowing into the block. You can, for example, change the selected output in this action.
Local variable: Object batch — the batch
- On rate change
Action executed when any of the flow rates changes.
Changing something in the action may result in another immediate rate change and immediately following another call of On rate change, so the user can possibly create a livelock.Local variables:
double inrate — the current input rate
double out1rate — the current output rate at port out1
double out2rate — the current output rate at port out2
- Selecting output
Function Description int toggle() Selects the output different to the one currently selected. Returns 1 if output 1 becomes selected or 2 if output 2 becomes selected. void select(int output) Selects the specified output (output argument must be 1 or 2).
- Fluid amount
Function Description double amountPassed() Returns the total amount passed through the input port since the start of the simulation. double amountPassed(AmountUnits units) Returns the total amount of fluid (in given units), which passed through the input port of the block since the start of the simulation.
- Flow rate
Function Description double currentRate() Returns the current flow rate of fluid that goes in. double currentRate(FlowRateUnits units) Returns the current flow rate (in given units) of fluid at the block input.
- Resetting statistics
Function Description void resetStats() Resets statistics collected for this block, including the statistics collected for its ports.
- The input port.
- The upper output port, output 1.
- The lower output port, output 2.
How can we improve this article?