Tank

A
container for fluid or bulk matter with infinite capacity, input at the
top and output at the bottom. Optionally can contain some initial fluid
(infinite amount of initial fluid is also possible). When the tank is
not full, its content is always located at the bottom, and is filled
from top. A non-full tank can accept input flow at any rate. When the
tank is full, its input rate is restricted by the output rate (but not
vice versa). When the tank is empty, its output rate is limited to the
input 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
Tank
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.
Tank
can also serve as a source of fluid or as a disposal container with infinite capacity.
Although in the real tank different fluids can get mixed, the
Tank
block preserves the order of the incoming batches and transfers them to
the output in the FIFO order. The output batch can be chosen to be the
same as the original input batch, set to the default batch, or to a
custom batch. You can also customize the batch initially contained in
the tank, if any.
The
Tank
block allows you to define actions executed in the event of tank
becoming full, empty, or the amount falling below or raising above the
specified level. In addition, you can react to a new batch appearing
the input or at the output.
Parameters
- Capacity
- The maximum amount the tank can contain. This value cannot be less than the value of
Utils.TOLERANCE. Infinite capacity can be set by typing
infinity
in the property's field.
Syntax:
double capacity
- Initial amount
- The amount initially contained in the tank. This value cannot be less than the value of
Utils.TOLERANCE. Infinite initial amount can be set by typing
infinity
in the property's field.
Syntax:
double initialAmount
- 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 rate the tank outflow rate.
Syntax:
boolean limitRateOut
- Maximum output rate
- [Visible and applies only if the
Limited output rate
option is set] Custom upper limit of the tank outflow rate. The default value is 10 cubic meters per second.
Syntax:
double maxRateOut
Set new value at runtime:
set_maxRateOut(new value)
- Custom priority
- If the option is set (the value equals
true), the priority of the tank outflow will be set to
Output flow priority, 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
false)
- Output flow priority
- [Visible and applies only if the
Custom priority
option is set] Custom priority of the tank outflow in the overall flowchart. Must be a positive integer.
Syntax:
int priorityOutCustom
Set new value at runtime:
set_priorityOutCustom(new value)
- Custom initial batch
- If set, the fluid initially contained in the tank will be of type
Initial batch. If not, it will be
BatchTypes.DEFAULT_BATCH.
Syntax:
boolean customInitialBatch
Set new value at runtime:
set_customInitialBatch(new value)
- Initial batch
- [Visible and applies only if the
Custom initial batch
option is set] Defines the batch initially contained in the tank.
Syntax:
Object initialBatch
Set new value at runtime:
set_initialBatch(new value)
- Custom batch color
- If set, the initial batch color is defined by the
Batch color
parameter below, otherwise the standard color mapping applies.
Syntax:
boolean customInitialBatchColor
Set new value at runtime:
set_customInitialBatchColor(new value)
- Batch color
[dynamic]
- [Visible and applies only if the
Custom batch color
option is set] Defines the color of the initial batch.
Type of the value:
Color
Local variable:
Object batch
- the initial batch
- Output batch is
- Defines the output batch of the tank. One of the following:
Same as the original batch
– same is the original batch that has flown into the tank
Default
- set to the default batch
BatchTypes.DEFAULT_BATCH
Custom
– defined by the
Output batch
parameter below
Get the value:
modeOutputBatch
Set new value at runtime:
set_modeOutputBatch(new value)
Valid values:
Tank.OUTPUT_BATCH_IN1,
Tank.OUTPUT_BATCH_DEFAULT,
Tank.OUTPUT_BATCH_CUSTOM
- Output batch
[dynamic]
- [Visible and applies only if the
Output batch is
option is set to
Custom] Defines the batch to be created at the tank output.
Type of value:
Object
Local variable:
Object originalbatch
- the initial batch
- Custom batch color
- [Visible and applies only if the
Output batch is
option is set to
Custom] If set, the output batch color is defined by the
Batch color
parameter below, otherwise the standard color mapping applies.
Syntax:
boolean customOutputBatchColor
Change the value at runtime:
set_customOutputBatchColor(true
or
false)
- Batch color
[dynamic]
- [Visible and applies only if the
Custom batch color
option right above is set] Defines the color of the output batch.
Type of the value:
Color
Local variable:
Object batch
- the initial batch
-
Animation
- Storage tank
- Here you can specify the name of
Storage tank
space markup shape used to animate this tank (both in 2D and 3D animation).
Syntax:
StorageTank storageTank
- Show batches in flowchart
- If set, the block icon will display the current batch color.
Syntax:
boolean showBatchesInFlowchart
-
Actions
- On full
[code]
- Action executed when the tank gets full. If the tank is full initially, is not executed at the start of simulation.
- On empty
[code]
- Action
executed when the tank becomes empty. If the tank is initially empty,
the action is not executed at the start of simulation.
- Action on above
- If the option is set (the value equals
true), you can specify the action executed when the amount of fluid in the tank goes up and reaches a particular threshold.
Syntax:
boolean actionOnAbove
- Amount
[dynamic]
- [Visible and applies only if the
Action on above
option is set] The threshold for the
On above
action. This value cannot be less than the value of
Utils.TOLERANCE. If the difference between the threshold value and the value of the
Capacity
parameter is less than
Utils.TOLERANCE, an error will occur.
Type of the value:
double
- On above
[code]
- [Visible and applies only if the
Action on above
option is set] Action executed when the amount of fluid in the tank increases and reaches the threshold specified in the
Amount
parameter right above. Is not executed when the amount is initially
above or at the threshold, or if the threshold is crossed while the
amount is decreasing.
Local variable:
double amount
- the current amount
- Action on below
- If the option is set (the value equals
true), you can specify the action executed when the amount of fluid in the tank decreases and reaches a particular threshold.
Syntax:
boolean actionOnBelow
- Amount
[dynamic]
- [Visible and applies only if the
Action on below
option is set] The threshold for the
On below
action. This value cannot be less than the value of
Utils.TOLERANCE. If the difference between the threshold value and 0 is less than
Utils.TOLERANCE, an error will occur.
Type of the value:
double
- On below
[code]
- [Visible and applies only if the
Action on below
option is set] Action executed when the amount of fluid in the tank decreases and reaches the threshold specified in the
Amount
parameter right above. Is not executed when the amount is initially
below or at the threshold, or if the threshold is crossed while the
amount is increasing.
Local variable:
double amount
- the current amount
- On new batch at input
[code]
- Action executed when a new batch appears at the tank input. It will not necessarily start flowing into the block.
Local variable:
Object batch
- the batch
- On new batch at output
[code]
- Action executed when a new batch reaches the tank output, even if the output batch is set to default or custom.
Local variable:
Object batch
- the batch
- On rate change
[code]
- Action
executed when any of the flow rates (input or output) changes. 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 outrate
- the current output rate
Functions
double amount()
- Returns the amount currently contained in the tank (total of all batches). If the value is less than the value of
Utils.TOLERANCE, returns 0.
double amount(AmountUnits units)
- Returns the amount of fluid (in
given units) currently contained in the tank (total of all batches). If the value is less than the value of
Utils.TOLERANCE, returns 0.
double amountPassedIn()
- Returns the total amount passed through the input port of the tank since the start of the simulation.
double amountPassedIn(AmountUnits units)
- Returns the total amount of fluid (in
given units) passed through the in port of the tank since the start of the simulation.
double amountPassedOut()
- Returns the total amount passed through the output port of the tank since the start of the simulation.
double amountPassedOut(AmountUnits units)
- Returns the total amount of fluid (in
given units) passed through the out port of the tank since the start of the simulation.
double amountMin()
- Returns the historical minimum of the fluid amount in the tank.
double amountMin(AmountUnits units)
- Returns the historical minimum of the fluid amount in the tank in
given units.
double amountMax()
- Returns the historical maximum of the fluid amount in the tank.
double amountMax(AmountUnits units)
- Returns the historical maximum of the fluid amount in the tank in
given units.
double amountAverage()
- Returns the average fluid amount in the tank over the total operating time.
double amountAverage(AmountUnits units)
- Returns the average fluid amount in the tank over the total operating time in
given units.
boolean isFull()
- Tests if the tank is full, i.e. the amount equals the tank capacity. Returns
true
if the tank is full, and
false
otherwise.
boolean isEmpty()
- Tests if the tank is empty.
Returns
true
if the tank is empty, and
false
otherwise.Note that there can still be a zero-size batch in an empty
tank in case it has appeared at the input, but has not actually started
flowing in.
double utilization()
- Returns the currently utilized fraction of the tank capacity, i.e.
amount() / capacity. If the tank's initial amount and capacity are both set as infinite, the function will return 1.
double utilizationTotal()-
Returns the tank average utilization throughout the total operating
time, i.e. the integral instant utilization / (capacity * operating
time)
double currentRateIn()
- Returns the current flow rate of fluid that goes in.
double currentRateIn(FlowRateUnits units)
- Returns the current flow rate (in given units) of fluid at the tank input.
double currentRateOut()
- Returns the current flow rate of fluid that goes out.
double currentRateOut(FlowRateUnits units)
- Returns the current flow rate (in given units) of fluid at the tank output.
void resetStats()
- Resets statistics collected for this block, including the statistics collected for its ports.
int numberOfBatches()
- Returns the number of batches currently present in the tank, 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 tank output, batch with the index
numberOfBatches()-1
is the last batch closest to the tank input.
double getBatchSize(int index)
- Returns the size of the batch with the specified
index. Batch with index 0 is the closest to the tank output, batch with the index
numberOfBatches()-1
is the last batch closest to the tank input.
double getBatchSize(int index, AmountUnits units)
- Returns the size of the batch (in given units) with the specified index.
Batch with index 0 is the closest to the tank output, batch with the index
numberOfBatches()-1
is the last batch closest to the tank input.
double updateOutputBatch()
- Forces immediate recalculation of the output batch and its color according to the current parameters settings.
double getBatchOffset(int index)
- Returns the sum of sizes of all batches under (closer to output) than the batch with a given
index. Intended use is custom animation.
Ports
- in
- The input port.
- out
- The output port.