AnyLogic
Expand
Font size

FluidMerge

Merges two streams of flow into one; the output flow rate equals the sum of the input rates.

Can work in three modes:

  • Neutral — In neutral mode neither of the inputs gets priority and no additional constraints apply. If the output can accept more than the sum of the maximum input rates, both input rates are maximized. If not, the inputs rate "quotas" are distributed non-deterministically.
  • Proportional — In proportional mode the block applies additional constraint: input 1 rate / Fraction 1 = input 2 rate / Fraction 2, therefore the input rates depend on each other as well as on the allowed output rate.
  • Priority — In priority mode FluidMerge tries to maximize the rate of one of the inputs, and the other input will get what’s left. Sometimes, to avoid flow priority conflicts, you may need to customize the priority values (by assigning integer values) to achieve desired global priorities.

In the priority mode, the dot indicating the priority input becomes orange in case the flow values are not in accordance with the priorities. This may well be a normal situation, but it also may signal that the flows are distributed not in the desired way and that setting custom priorities is required.

The output batch of FluidMerge may be the same as the one at the chosen input, same as at the priority input, default, or custom. The latter option is useful when, for example, the block models mixing of two different substances that results in creating the third one. The On new batch… actions can be used to change the mode and/or priorities depending on the input batches. If the output batch is set to be same as the one at the input whose batch is null (because of no flow), another input’s batch is used as the output batch.

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.

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

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

Parameters

Mode
The mode of merge. One of the following:
Neutral — neither of the inputs gets priority
Proportional — input rates must obey the proportion rules
Priority — one of the inputs has priority over another
Get value: mode
Set new value at runtime: set_mode(new value)
Valid values:
FluidMerge.SPLITMERGE_NEUTRAL
FluidMerge.SPLITMERGE_PROPORTIONAL
FluidMerge.SPLITMERGE_PRIORITY
Fraction 1
[Visible and applies only if the Mode is Proportional] In proportion mode, the (relative) fraction of input 1 rate. If the user dynamically changes the parameter value, the output batch is updated according to the current parameters settings.
Syntax: double fraction1
Set new value at runtime: set_fraction1(new value)
Fraction 2
[Visible and applies only if the Mode is Proportional] In proportion mode, the (relative) fraction of input 2 rate. If the user dynamically changes the parameter value, the output batch is updated according to the current parameters settings.
Syntax: double fraction2
Set new value at runtime:set_fraction2(new value)
Custom priorities
[Visible and applies only if the Mode is Priority] If the option is selected (the value is equal to true), the priorities of inflows will be set to custom values, otherwise — to 0 and 1. Priorities affects the LP solver when it tries to maximize the flow through the system.
Syntax: boolean customPriorities Change the value at runtime: set_customPriorities(new value)
Priority
[Visible and applies only if the Mode is Priority and the Custom properties option is not set] Applies in priority mode with default (non-custom) priorities. If the Input 1 option is selected (the value is equal to true), input 1 has priority over input 2, otherwise Input 2 has the priority. This results in priority values 1 and 0.
Syntax: boolean priorityInput1
Change the value at runtime:set_priorityInput1(new value)
Priority of input 1
[Visible and applies only if the Mode is Priority and the Custom properties option is set] Applies in the priority mode with custom priorities. Defines the priority of the input 1 flow of this block in the overall flowchart. Must be a non-negative integer.
Syntax: int priorityInput1Custom
Change the value at runtime: set_priorityInput1Custom(new value)
Priority of input 2
[Visible and applies only if the Mode is Priority and the Custom properties option is set] Applies in the priority mode with custom priorities. Defines the priority of the input 2 flow of this block in the overall flowchart. Must be a non-negative integer.
Syntax: int priorityInput2Custom
Change the value at runtime:set_priorityInput2Custom(new value)
Output batch is
Defines how the output batch of this block is formed. One of the following:
Same as at input 1 — same is the batch at input 1
Same as at input 2 — same is the batch at input 2
Same as at priority input — same is the batch at the priority input (priority mode only)
Default — set to default batch
Custom — defined by the Output batch parameter below
Get value: modeBatch
Set new value at runtime: set_modeBatch(new value)
Valid values:
FluidMerge.OUTPUT_BATCH_IN1
FluidMerge.OUTPUT_BATCH_IN2;
FluidMerge.OUTPUT_BATCH_PRIORITY
FluidMerge.OUTPUT_BATCH_DEFAULT
FluidMerge.OUTPUT_BATCH_CUSTOM
Output batch
[Visible and applies only if the Output batch is is Custom] Defines the batch to be created at the output, which may depend on the input batches.
Type of the value: Object
Local variables:
Object batch1 — the batch at input 1
Object batch2 — the batch at input 2
Custom batch color
[Visible and applies only if the Output batch is Custom] If set, the output batch color is defined by the Batch color parameter below, otherwise the standard color mapping applies.
Syntax: boolean customBatchColor
Set new value at runtime:set_customBatchColor(new value)
Batch color
[Visible and applies only if the Custom batch color option is set] Defines the color of the output batch.
Type of the value: Color
Local variable:
Object batch — the output batch
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(new value)
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.
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.
Local variable:
Object batch — the batch
On new batch at output
Action executed when a new batch appears at either of the inputs, or the mode, priority, or other parameters of the block change, which may (or may not) result in a new batch going out.
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

Fluid amount
Function Description
double amountPassed() Returns the total amount passed through the output port of the block 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.
Output batch
Function Description
double updateOutputBatch() Forces immediate recalculation of the output batch and its color according to the current parameters settings.
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?