AnyLogic
Expand
Font size

FluidSource

The FluidSource block generates the flow. It is a typical starting block of a Fluid Library flowchart.

The block can work as a source with infinite capacity or as a source with the limited initial amount that can be refilled by calling the inject() function. This block has a desired output rate, and the actual rate may be less or equal to the specified rate. The specified rate cannot be lower than the value of Utils.RATE_TOLERANCE constant, that is, 1.0e-9. If rate value falls below this value after recalculation, it will be snapped to 0.

The Fluid Library will try to maximize the out flow of all fluid sources; therefore, the priority of FluidSource out flow is set to 1 by default. Sometimes, to resolve flow priority conflicts, you may need to customize the out flow priority by further increasing it.

The batch type generated by FluidSource can be customized. To change the batch type dynamically in the infinite capacity mode you should change the Batch property (call set_customBatch()), while the Custom batch property should be selected. In the limited amount mode, you can specify the batch type and color as optional arguments of the inject() function.

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

Properties

Maximum rate
If selected, this block does not set an upper limit for the output rate (the limit must be set by other blocks down the flow).
Name: maxRate
Type: boolean
Set new value at runtime: set_maxRate(new value)
Rate
[Visible and applies unless the Maximum rate option is set]
The maximum (desired) output rate.
Name: rate
Type: double
Set new value at runtime: set_rate(new value)
Mode
Defines whether the FluidSource block will be able to generate infinite amount of flow (Infinite capacity) or a limited amount, which can be refilled by calling the inject() function (Limited amount, call inject() to refill).
Name: infiniteCapacity
Type: boolean
Set new value at runtime: set_infiniteCapacity(new value)
Initial amount
[Visible and applies if Mode: Limited amount, call inject() to refill]
The amount initially contained in the block in the limited amount mode. This value cannot be less than the value of Utils.TOLERANCE.
Name: initialAmount
Type: double
Set new value at runtime: set_initialAmount(new value)
Custom priority
If the option is set (the value equals true), the priority of outflow will be defined by the Output flow priority property below, otherwise it equals 1. Priority affects the LP solver when it tries to maximize the flow through the system.
Name: customPriority
Type: boolean
Set new value at runtime: set_customPriority(new value)
Output flow priority
[Visible and applies if the Custom priority option is set]
A custom priority of the outflow of this block in the overall flowchart. Must be a positive integer.
Name: priorityOutCustom
Type: int
Set new value at runtime: set_priorityOutCustom(new value)
Custom batch
If the option is selected (the value is true), the output batch will be defined by the Batch property below. If not, it will be the same as the input batch.
Name: modeBatchCustom
Type: boolean
Set new value at runtime: set_modeBatchCustom(new value)
Batch
[Visible and applies if the Custom batch option is set]
Defines the output batch. Applies in both modes, but in the limited amount mode can be overridden by the inject() function.
Name: customBatch
Type: Object
Set new value at runtime: set_customBatch(new value)
Custom batch color
[Visible and applies if the Custom batch option is set]
If set, the batch color is defined by the Batch color property below, otherwise the standard color mapping applies. Applies in both modes, but in the limited amount mode can be overridden by the inject() function.
Name: customBatchColor
Type: boolean
Set new value at runtime: set_customBatchColor(new value)
Batch color
[Visible and applies if the Custom batch color option is set]
Defines the color of the output batch. Applies in both modes, but in the limited amount mode can be overridden by the inject() function.
Type: Color
Local variable: Object batch — the output batch

Animation

Storage tank
The the name of the Storage tank space markup shape used to animate (both in 2D and 3D animation). The storage tank will be animated if the FluidSource block is set to generate batches, that is, the Custom batch option must be checked and the Batch must be specified.
Name: storageTank
Type: StorageTank
Show batches in flowchart
If set, the block icon will display the current batch color.
Name: showBatchesInFlowchart
Type: boolean

Actions

On empty
[Visible and applies if Mode: Limited amount, call inject() to refill]
The action executed in the limited amount mode when there is no more fluid to output.
On new batch at output
[Visible and applies if Mode: Limited amount, call inject() to refill]
The action executed in the limited amount when a new batch appears at the block output.
Local variable: Object batch — the batch
On rate change
The action executed when the flow rate 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 variable: double outrate — the current output rate

Functions

Fluid amount
Function Description
double amount() In infinite capacity mode returns infinity. Otherwise returns the amount remaining in the block, possibly belonging to multiple batches.
double amount(AmountUnits units) Returns infinity in infinite capacity mode. Otherwise returns the amount of fluid (in given units) remaining in the block, possibly belonging to multiple batches.
double amountPassed() Returns the total amount of fluid passed through the output port of the pipeline 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.
Batches
Function Description
int numberOfBatches() Returns the number of batches currently present in the block, including possible zero-length batches.
Object getBatch(int index) Returns the batch with the specified index. Batch with index 0 is the closest to the block output.
double getBatchSize(int index) Returns the size of the batch with the specified index. Batch with index 0 is the closest to the block output.
double getBatchSize(int index, AmountUnits units) Returns the size of the batch (in given units) with the specified index.
Color getBatchColor(int index) Returns the color of the batch with the specified index.
double getBatchOffset(int index) Returns the total size of all batches located closer to output than the batch with the given index. Intended use is custom animation.
Fluid injection (in the limited amount mode)
Function Description
double inject(double amount, Object batch, Color color) Adds a batch of the specified type and color to the output queue of the block. In infinite capacity mode does nothing.
The given amount cannot be less than the Utils.TOLERANCE value.
double inject(double amount, AmountUnits units, Object batch, Color color) Adds a batch (in given units) of the specified type and color to the output queue of the block. In infinite capacity mode does nothing.
The given amount cannot be less than the Utils.TOLERANCE value.
double inject(double amount, Object batch) Adds a batch of the specified type to the output queue of the block. The color of the batch is determined according to the property setting of the block. In infinite capacity mode does nothing.
The given amount cannot be less than the Utils.TOLERANCE value.
double inject(double amount, AmountUnits units, Object batch) Adds a batch of the specified type (in given units) to the output queue of the block. The color of the batch is determined according to the property setting of the block. In infinite capacity mode does nothing.
The given amount cannot be less than the Utils.TOLERANCE value.
double inject(double amount) Adds the specified amount to the output queue of the block. The batch and color of the amount are determined according to the property setting of the block. In infinite capacity mode does nothing.
The given amount cannot be less than the Utils.TOLERANCE value.
double inject(double amount, AmountUnits units) Adds the specified amount of fluid (in given units) to the output queue of the block. The batch and color of the amount are determined according to the property setting of the block. In infinite capacity mode does nothing.
The given amount cannot be less than the Utils.TOLERANCE value.
Resetting statistics
Function Description
void resetStats() Resets statistics collected for this block, including the statistics collected for its ports.

Ports

out
The output port.
How can we improve this article?