Makes a mix of fluids coming in from up to five different sources, optionally delays (e.g. processes) the completed mix for a given amount of time, and lets it flow out. The proportion of components in the mix can be defined either by giving the amount of each component, or by providing the total amount and fractions of components.
The input rates are not limited, the output rate can optionally be limited. 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 new mix will start to accumulate only when the previous mix has completely flowed out. Initially the tank is empty. You can change the amounts of components or the total mix amount by calling updateAmounts() function while the tank is empty.
The capacity of this tank can be infinite.
The batch of the mix can be explicitly specified or can be left as default batch.
The MixTank block allows you to specify actions executed when the mix is completed (all components has completely flowed in), when the delay is finished and when the mix has completely flowed out.
Demo model: MixTank
double amount() - Returns the amount of mix currently contained in the tank (the sum of all components). If the amount is less than Utils.TOLERANCE, this function returns 0.
double amount(AmountUnits units) - Returns the amount of mix (in the given amount units) currently contained in the tank (the sum of all components). If the amount is less than Utils.TOLERANCE, this function returns 0.
double capacity() - Returns the maximum amount of mix that can be contained in the tank. If the amount is less than Utils.TOLERANCE, this function returns 0.
boolean isEmpty() - Tests if the tank is empty.
boolean isEmptying() -Tests if the mix has been processed, the output is open, all inputs are closed and the tank is still not empty.
boolean isFilling() -Tests if the tank currently being filled, i.e. at least one of the inputs is open, the output is closed and the amount is below the required capacity.
boolean isProcessing() -Tests if the mix is currently being processed, i.e. all the inputs and outputs are closed and the processing delay is being executed.
double amountPassedIn(int input) - Returns the amount of fluid that has passed through a given input port (1..5) from the start of the simulation.
double amountPassedIn(int input, AmountUnits units) - Returns the amount of fluid (in the given amount units) that has passed through a given input port (1..5) from the start of the simulation.
double amountPassedOut() - Returns the amount of fluid that has passed through the output port of the tank from the start of the simulation.
double amountPassedOut(AmountUnits units) - Returns the amount of fluid (in the given amount units) that has passed through the output port of the tank from the start of the simulation.
boolean updateAmounts() - If the mix is specified by amounts of the components, this function updates the component amounts. If the mix is specified by the total amount and fractions of each component, the function updates the total amount of mix, i.e. forces the mix tank to restart the mix with the new Amount 1..Amount 5 parameters, or the new Capacity (total amount) parameter respectively. The function can be called at any time, however,at the time of the call the tank must be empty.
Object getBatch(int index) - While the tank is emptying, returns the object that describes the output mix. The index can only be 0 in this case. While the tank is not emptying, returns the object that describes one of the 5 input components (possibly null), where index 0 corresponds to input 5, and index 4 corresponds to input 1.
Color getBatchColor(int index) - While the tank is emptying, returns the color of the output mix. The index can only be 0 in this case. While filling or processing, returns the color of one of the input components, where index 0 corresponds to input 5, and index 4 corresponds to input 1. If the color of the output mix differs from the one of the input component, the current color is linearly interpolated during processing with respect to the processing progress.
double getBatchSize(int index) - While the tank is emptying, returns the total amount of the output mix remaining in the tank. In this case the index can only be 0. While filling or processing, returns the amount of an input component with the specified index, where index 0 corresponds to input 5, and index 4 corresponds to input 1.
double getBatchSize(int index, AmountUnits units) - While the tank is emptying, returns the total amount of the output mix remaining in the tank (in the given amount units). In this case the index can only be 0. While filling or processing, returns the amount of an input component with the specified index, where index 0 corresponds to input 5, and index 4 corresponds to input 1.
double updateOutputBatch() - Forces immediate recalculation of the output batch and its color according to the current parameters settings.
double getBatchOffset(int index) - While the tank is emptying, returns 0. Otherwise, returns the total amount of component filled into the tank "below" the component with the given index, where index 0 corresponds to input 5, and index 4 corresponds to input 1. Intended use is custom animation.
int numberOfBatches() - While the tank is emptying, returns 1. Otherwise returns 5 as the number of symbolic input batches in the tank, including null batches.
double currentRateIn(int input) - Returns the current flow rate at a given input port (1..5).
double currentRateIn(FlowRateUnits units, int input) - Returns the current flow rate (in the given rate units) at a given input port (1..5).
double currentRateOut() - Returns the current flow rate of fluid that goes out.
double currentRateOut(FlowRateUnits units) - Returns the current flow rate (in the given rate units) of fluid that goes out.
double amountOf(int input) - Returns the amount of a particular component currently contained in the tank. The component is identified by the number of input (1..5).
double amountOf(int input, AmountUnits units) - Returns the amount of a particular component (in the given amount units) currently contained in the tank. The component is identified by the number of input (1..5).
double remainingTime() - If the mix is currently delayed (being "processed"), returns the remaining delay time in seconds. At other times, returns 0.
double remainingTime(TimeUnits units) - If the mix is currently delayed (being "processed"), returns the remaining delay time in the given time units. At other times, returns 0. For example, remainingTime(MINUTE) returns remaining delay time in minutes.
void resetStats() - Resets statistics collected for this block, including the statistics collected for its ports.