AnyLogic 9
Expand
Font size

FluidSelectInput

Routes the flow from one of the two inputs to the output (the input is set in the parameter Select).

FluidSelectInput is a zero-capacity block, it does not contain any amount of fluid.

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.

The output batch of the FluidSelectInput block is the same as the one at the selected input. The On new batch … actions can be used to switch the input depending on the incoming batches.

Changing the input dynamically at model runtime

The input selected at design time can be changed at runtime by calling the functions toggle() and select().

For example, the block is named selectInput. To select input 1 at runtime, call: selectInput.select(1). To select input 2: selectInput.select(2).

Demo model: FluidSelectInput Open the model page in AnyLogic Cloud. There you can run the model or download it (by clicking Model source files).

Parameters

Select
Here you can choose whether the flow from Input 1, or Input 2 goes into the output. When the input 1 is selected, input 2 is blocked, and vice versa. If the value is set to true, the flow goes from the input 1.
Syntax: boolean selectInput1
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.
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. 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 at input 1
Action executed when a new batch appears at the Input 1. It will not necessarily start flowing into the block. You can, for example, change the selected input in this action.
Local variable: Object batch — the batch
On new batch at input 2
Action executed when a new batch appears at the Input 2. It will not necessarily start flowing into the block. You can, for example, change the selected input 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 in1rate — the current input rate at port in1
double in2rate — the current input rate at port in2
double outrate — the current output rate

Functions

Selecting input
Function Description
int toggle() Selects the input different from the one currently selected. Returns 1 if input 1 becomes selected or 2 if input 2 becomes selected.
void select(int input) Selects the specified input (input argument must be 1 or 2).
Fluid amount
Function Description
double amountPassed() Returns the total amount passed through the output port since the start of the simulation.
double amountPassed(AmountUnits units) Returns the total amount of fluid (in given units) passed through the output 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 out.
double currentRate(FlowRateUnits units) Returns the current flow rate (in given units) of fluid at the block output.
Resetting statistics
Function Description
void resetStats() Resets statistics collected for this block, including the statistics collected for its ports.

Ports

in1
The upper input port, Input 1.
in2
The lower input port, Input 2.
out
The output port.
How can we improve this article?