Generates the flow; is a typical starting block of a Fluid Library flowchart.
Can work as a source with infinite capacity or as source with 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, i.e. 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 parameter Batch (call set_customBatch()), while the parameter Custom batch 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).- 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).
Syntax: boolean maxRate
Set new value at runtime: set_maxRate(true) or set_maxRate(false) - Rate
-
[Visible and applies only if the Maximum rate option is not set]
The maximum (desired) output rate.Syntax: double rate
Set new value at runtime: set_rate(new value) - Mode
-
Here you define 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).
Syntax: boolean infiniteCapacity
Set new value at runtime: set_infiniteCapacity(true) or set_infiniteCapacity(false) - Initial amount
-
[Visible and applies only if the Mode is set to 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.Syntax: double initialAmount
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 parameter below, otherwise it equals 1. Priority affects the LP solver when it tries to maximize the flow through the system.
Syntax: boolean customPriority
Set new value at runtime: set_customPriority(true) or set_customPriority(false) - Output flow priority
-
[Visible and applies only if the Custom priority option is set]
Custom priority of the outflow of this block in the overall flowchart. Must be a positive integer.Syntax: int priorityOutCustom
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 parameter below. If not, it will be the same as the input batch.
Syntax: boolean modeBatchCustom Set new value at runtime: set_modeBatchCustom(true) or set_modeBatchCustom(false)
- Batch
-
[Visible and applies only 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.Syntax: Object customBatch
Set new value at runtime: set_customBatch(new value) - Custom batch color
-
[Visible and applies only if the Custom batch option is set]
If set, the batch color is defined by the Batch color parameter below, otherwise the standard color mapping applies. Applies in both modes, but in the limited amount mode can be overridden by the inject() function.Syntax: boolean customBatchColor
Set new value at runtime: set_customBatchColor(true) or set_customBatchColor(false) -
[Visible and applies only 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 of the value: Color
Local variable: Object batch — the output batch
- Storage tank
-
Here you can specify the name of Storage tank space markup shape used to animate FluidSource (both in 2D and 3D animation). The storage tank will be animated if the FluidSource block is set to generate batches, i.e. the Custom batch option must be checked and the Batch must be specified.
Syntax: StorageTank storageTank
- Show batches in flowchart
-
If set, the block icon will display the current batch color.
Syntax: boolean showBatchesInFlowchart
- On empty
-
[Visible and applies only if the Mode option is set to Limited amount...]
Action executed in the limited amount mode when there is no more fluid to output. - On new batch at output
-
[Visible and applies only if the Mode option is set to Limited amount...]
Action executed in the limited amount when a new batch appears at the block output.Local variable: Object batch — the batch - On rate change
-
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
- 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 parameter 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 parameter 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 parameter 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 parameter 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.
- out
- The output port.
-
How can we improve this article?
-