Restricts the flow rate or completely blocks the flow.
Valve has a maximum flow rate, which applies when the valve is open. When the valve is closed, the rate is forced to zero. You can open and close the valve at runtime by calling its open(), close(), and toggle() functions. You can also call the dispense() function to have the valve let through a particular amount and then close. In addition, you can define an arbitrary recurring action to be executed each time a portion of fluid has flown through the valve.
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.
Valve is a zero-capacity block, it does not contain any amount of fluid.
As any other block the Valve block allows you to react to new batches appearing at the input.
Demo model: Valve
double amountPassed() - Returns the total amount passed through the valve since the start of the simulation.
double amountPassed(AmountUnits units) - Returns the total amount (in given units) passed through the valve since the start of the simulation.
double currentRate() - Returns the current flow rate of fluid through the valve.
double currentRate(FlowRateUnits units) - Returns the current flow rate (in given units) of fluid through the valve.
double averageRate() - Returns the average actual rate through the valve throughout the total operating time. If time has ran to infinity, the current input rate is returned.
double averageRate(FlowRateUnits units) - Returns the average actual rate (in given units) through valve throughout the total operating time in given units. If time has ran to infinity, the current input rate is returned.
boolean isClosed() - Tests if the valve is currently closed. Returns true if the valve is closed, and false otherwise.
open() - Opens the valve. Sets the maximum rate to the Rate when open parameter.
close() - Closes the valve (sets the maximum rate to zero).
toggle() - Toggles the state of the valve between open and closed. If the valve is currently closed, calling this function opens it, and vice versa.
double dispense(double amount) - Opens the valve if it is closed, lets the specified amount to pass through, and then closes the valve and calls On dispense completed action. If Recurrent action on portion is set, On portion passed action is executed at the moment when the specified amount passes through and before the valve is closed again. If the moments when these actions must be executed coincides, the order of their execution is undetermined. The value of the given amount cannot be less than the value of Utils.TOLERANCE.
double dispense(double amount, AmountUnits units) - Opens the valve if it is closed, lets the specified amount (in given units) to flow through, and then closes the valve and calls On dispense completed action. If Recurrent action on portion is set, On portion passed action is executed at the moment when the specified amount passes through and before the valve is closed again. If the moments when these actions must be executed coincides, the order of their execution is undetermined. The value of the given amount cannot be less than the value of Utils.TOLERANCE.
double amountDispensedSoFar() - When dispensing is in progress after a call of dispense(), returns the amount dispensed so far (in given units if specified). At other times, returns 0.
double amountDispensedSoFar(AmountUnits units) - When dispensing is in progress after a call of dispense(), returns the amount (in given units) dispensed so far. At other times, returns 0.
double amountPassedInPortion() - When Recurrent action on portion is set, returns the amount passed through the valve in the current portion; this amount is less than the Portion size. If the action is not set, returns 0.
double amountPassedInPortion(AmountUnits units) - When Recurrent action on portion is set, returns the amount (in given units) passed through the valve within the current portion; this amount is less than the Portion size. If the action is not set, returns 0.
double utilization() - Returns the currently utilized fraction of the valve bandwidth, namely the current rate / maximum open rate. If the valve is closed, the current maximum rate equals 0 or is not limited, returns 0.
double utilizationTotal() - Returns the average utilization of the valve bandwidth throughout the total operating time, i.e. the total amount of fluid that actually passed through the valve / maximum total amount that could pass through, given the (possibly changing) open rate and closing times. If time has ran to infinity, the instant utilization is returned. If the open rate has been set to unlimited even once, the function will return 0.
void resetStats() - Resets statistics collected for this block, including the statistics collected for its ports.