Process Tank

Accumulates the fluid up to the Capacity level, optionally delays (e.g. processes) it for a given amount of time, and lets it flow out. The Capacity is a dynamic parameter and is re-evaluated at the beginning of each cycle, i.e. first time at the start of simulation, and then each time the fluid has completely flowed out. The input rates are not limited, the output rate can optionally be limited.

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.

The ProcessTank block allows you to specify actions executed when the tank becomes full, when the delay is finished and the fluid is ready to flow out, and when it has completely flowed out and the tank is empty.

Demo model: ProcessTank

Parameters

Capacity [dynamic]
The total amount of fluid to be accumulated in the tank before the processing (delay) starts.
Type of value: double
Delay time
The time the fluid must stay in the tank after it reaches the Capacity level and before it can start flowing out.
Syntax: double delayTime
Set new value at runtime: set_delayTime(new value)
Limited output rate
If the option is selected (true), you are able to specify a custom upper limit of the tank outflow rate.
Syntax: boolean limitRateOut
Set new 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 tank outflow rate. The default value is 1 cubic meter per second.
Syntax: double maxRateOut
Set new value at runtime: set_maxRateOut(new value)
Output batch is
Defines the output batch of the tank. Choose one of the following options:
Same as the original batch - the output batch is the same batch that has flowed into the tank
Default - the output batch is set to the default batch BatchTypes.DEFAULT_BATCH
Custom - the output batch is defined by the Output batch parameter below.
Get value: modeOutputBatch
Set new value at runtime: set_modeOutputBatch(new value)
Valid values: ProcessTank.OUTPUT_BATCH_IN1           - Same as the original batch
           ProcessTank.OUTPUT_BATCH_DEFAULT
 -  Default
           ProcessTank.OUTPUT_BATCH_CUSTOM  -
Custom
Output batch [dynamic]
[Visible and applies only if the Output batch is: Custom] Defines the output batch. Here you can access the input batch, so the output batch may depend on the input batch.
Type of value: Object
Local variable:  Object originalbatch - the input batch
Custom batch color
[Visible and applies only if the Output batch is: Custom] If set, the batch color is defined by the Batch color parameter below, otherwise the standard color mapping applies.
Syntax: boolean customOutputBatchColor
Set new value at runtime: set_customOutputBatchColor(new value)
Batch color [dynamic]
[Visible and applies only if the Custom batch color option is selected] Defines the color of the output batch.
Type of value: Color
Local variable:  Object batch - the batch
Animation
Storage tank
Here you specify the space markup element Storage Tank that is used to animate this process tank.
Syntax: StorageTank storageTank
Set new value at runtime: set_storageTank(new value)
Show batches in flowchart
If set, the block icon will display the current batch color.
Syntax: boolean showBatchesInFlowchart
Set new value at runtime: set_showBatchesInFlowchart(new value)
Actions
On full [code]
Action executed when the fluid has reached the Capacity level and the input of the tank gets closed.
On ready [code]
Action executed when the fluid has spent the required time in the tank (if any), just before it is allowed to flow out.
On empty [code]
Action executed when the fluid has completely flowed out of the tank, just before the new cycle starts.
On rate change [code]
Action executed when any of the flow rates (input or output) changes. Please 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 of fluid currently contained in the tank.

boolean isEmpty() - Tests if the tank is empty. Returns true if the tank is empty, and false otherwise.

boolean isEmptying() - Tests if the fluid has been processed, the output is open, input is closed and the tank is still not empty.

boolean isFilling() - Tests if the tank currently being filled, i.e. input is open, the output is closed and the amount is below the required capacity.

boolean isProcessing() - Tests if the fluid is currently being processed, i.e. the input and output are closed and the processing delay is being executed. 

void forceProcessing() - If called while in the filling up phase on a partially filled but not empty tank, closes input and immediately starts processing regardless of the amount of fluid in the tank. Does not affect the capacity or processing time. Calls the On full action as if the tank was filled up. If called during processing or emptying phases, or if the tank is empty, does nothing. 

double amountPassedIn() - Returns the total amount of fluid passed through the in port of the tank since the start of the simulation.

double amountPassedOut() - Returns the total amount of fluid passed through the out port of the tank since the start of the simulation.

double amount(AmountUnits units) - Returns the amount of fluid (in given amount units) currently contained in the tank.

double amountPassedIn(AmountUnits units) - Returns the total amount of fluid (in given amount units) passed through the in port of the tank since the start of the simulation.

double amountPassedOut(AmountUnits units) - Returns the total amount of fluid (in given amount units) passed through the out port of the tank since the start of the simulation.

Object getBatch(int index) - Returns the batch with the specified index. Batch with the index 0 is the one at 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.

double getBatchSize(int index, AmountUnits units) - Returns the size of the batch with the specified index.

Color getBatchColor(int index) - Returns the color of the batch with the specified index.

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.

int numberOfBatches() - Returns the number of batches currently present in the tank, including possible zero-size batches.

double currentRateIn() - Returns the current flow rate of fluid that comes in.

double currentRateIn(FlowRateUnits units) - Returns the current flow rate (in given rate units) of fluid that comes in.

double currentRateOut() - Returns the current flow rate of fluid that goes out.

double currentRateOut(FlowRateUnits units) - Returns the current flow rate (in given rate units) of fluid that goes out.

void resetStats() - Resets statistics collected for this block, including the statistics collected for its ports.

double remainingTime() - If the fluid is currently delayed (being "processed"), returns the remaining delay time in seconds. At other times, returns 0.

double remainingTime(TimeUnits units) - If the fluid is currently delayed (being "processed"), returns the remaining delay time in given time units. At other times, returns 0. For example, remainingTime(MINUTE) returns remaining delay time in minutes.

Ports

in
The input port.
out
The output port.