Fluid Select Output

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.

Demo model: FluidSelectOutput

Parameters

Select output
Here you define how the output will be selected. There are two alternative options:
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. 
Syntax: boolean selectOnCondition
Set new value at runtime: set_selectOnCondition(new value)
Valid values: 
true   -  Conditionally, on each batch
                      false -  By calling select() function
Condition (true is Output 1) [dynamic]
[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.
Type of value: 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 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)
Animation
Show batches in flowchart
If set, the block icon will display the current batch color.
Syntax: boolean showBatchesInFlowchart
Actions
On new batch [code]
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 [code]
Action executed when any of the flow rates changes. Please note that 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

Functions

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 in port of the block since the start of the simulation.

void resetStats() - Resets statistics collected for this block, including the statistics collected for its ports.

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.

toggle()- Selects the output different to the one currently selected.

select(int input) - Selects the specified output (output argument must be 1 or 2).

Ports

in
The input port.
out1
The upper output port, output 1.
out2
The lower output port, output 2.