Flowing Tank Farm Control in Petroleum Refining Library
Flowing tank farms are widely used in petroleum refineries to provide hydraulic buffering and maintain stable material transfer between interconnected process units. Unlike accumulative tank farms, whose primary purpose is long-term product storage and shipment planning, flowing tank farms support continuous production by compensating for temporary differences between incoming and outgoing flow rates. Depending on the refinery configuration, a flowing tank farm may operate under different control strategies. When transferring products to pipelines or remote facilities, the pumping system typically regulates the outlet flow while respecting equipment limitations such as minimum and maximum pumping capacities and allowable flow-rate changes. In contrast, when the tank farm supplies another process unit within the refinery, the discharge rate is usually determined by the receiving unit according to its current production capacity, making dedicated pumping control unnecessary. Because these operating conditions differ significantly, modern refinery simulation models require flexible runtime control mechanisms that support both automatic flow regulation and externally controlled operation. Such mechanisms allow engineers to modify operating parameters, monitor the current operating state, and integrate custom control logic while preserving realistic process behavior throughout the simulation. The following sections describe the operating principles, runtime control strategies, and event-driven mechanisms used to control flowing tank farms before presenting their implementation in the Petroleum Refining Library. Typical Applications: transfer to pipelines; inter-unit product transfer; intermediate hydraulic buffers; refinery digital twins; dynamic production planning
Operating Modes
The operating strategy of a flowing tank farm depends on its position within the refinery process. When transferring products through pipelines or other transportation systems, the reservoir park regulates the outlet flow while respecting pumping equipment limitations. When supplying a downstream process unit, the discharge rate is determined by the receiving unit, eliminating the need for automatic pumping control. Accordingly, flowing tank farms support two operating modes: Automatic Outflow Control— the reservoir park continuously adjusts the outlet flow to maintain the target inventory level while respecting the configured minimum and maximum pumping capacities. Demand-Driven Outflow — the outlet flow is determined by the downstream process unit according to its current processing capacity, while the reservoir park operates as a hydraulic buffer without automatic flow regulation. The operating mode is selected before the simulation starts and remains unchanged throughout model execution.
Dynamic Runtime Control
Runtime control enables a flowing tank farm to adapt to changing operating conditions without interrupting the simulation. In Automatic Outflow Control mode, the control algorithm continuously regulates the outlet flow to maintain the target inventory level. The target inventory can be updated at runtime, and the pumping rate is automatically adjusted until the new operating point is reached. In Demand-Driven Outflow mode, the outlet flow is determined by the downstream process unit rather than by the reservoir park. Runtime control is therefore limited to monitoring the operating state and updating the discharge rate in response to changing process conditions. Both operating modes expose runtime events that allow application code to monitor the control cycle and implement custom operating logic.
Runtime Control Strategy
Unlike accumulative tank farms, where control decisions are typically triggered by discrete operational events such as tank filling, product shipment, or tank switching, a flowing tank farm behaves as a continuously balanced hydraulic system. Since all equivalent tanks operate in parallel and share a common inventory, there are no individual tank events that naturally indicate when control actions should be performed. Instead, the overall hydraulic state of the reservoir park becomes the primary source of control information. Parameters such as the current inventory level, deviation from the target inventory, inlet flow, outlet flow, and pumping state provide a complete picture of the system and allow control decisions to be made continuously throughout the simulation. For this reason, flowing tank farms are typically controlled by periodically evaluating their operating state rather than reacting to discrete events. During each control cycle, application code can monitor the reservoir park, adjust the target inventory, or dynamically recalculate the outlet flow required by downstream process units. This periodic control strategy provides a simple and predictable mechanism for implementing application-specific operating logic. This approach is particularly important when a flowing tank farm is located inside a refinery rather than at the refinery boundary. In such configurations, the reservoir park primarily serves as a hydraulic buffer between interconnected process units, while the downstream unit continuously determines the required discharge rate according to its current production capacity. The runtime control API therefore provides the mechanisms required to monitor the operating state of the reservoir park and dynamically coordinate product transfer between interconnected refinery units.
Accumulative Tank Farm — control is primarily event-driven. Decisions are triggered by operational events such as tank filling, product shipment, or tank switching.
Flowing Tank Farm — control is primarily state-driven. Decisions are based on the continuously evaluated hydraulic state of the entire reservoir park, including inventory level, flow rates, and pumping conditions.
Flowing Tank Farm Control in Petroleum Refining Library
The Reservoir Park Flowing (RpFlowing) component extends the generic ReservoirPark template with runtime methods and event callbacks specific to flowing tank farms. All common reservoir park control capabilities, including operator commands, runtime configuration, flow routing, and common event notifications, are inherited from ReservoirPark and are described in Tank Farm Control. This section describes only the functionality unique to RpFlowing. The operating mode is configured before the simulation starts using the autoAdjustOutflowSpeed property. Depending on the selected mode, RpFlowing either automatically regulates the outlet flow to maintain the target inventory level or allows the downstream process unit to determine the discharge rate. The runtime API is organized into three groups: configuration parameters, runtime methods, and event callbacks. Together, they provide complete programmatic control over Flowing Tank Farm behavior during simulation. The following sections describe each of these API groups in detail.
Although both operating modes share the same runtime API, some methods and event callbacks are available only when automatic outlet flow control is enabled. The following sections describe these differences in detail.
Runtime Configuration
The operating behavior of RpFlowing is defined by a small set of configuration parameters that determine the selected operating mode and the behavior of the automatic flow control algorithm.Additional configuration parameters define the correction interval, target inventory level, and pumping constraints used by the automatic control algorithm. The most important parameter is autoAdjustOutflowSpeed, which selects the operating strategy before the simulation starts. When autoAdjustOutflowSpeed = true, RpFlowing automatically regulates the outlet flow to maintain the configured target inventory level while respecting the minimum and maximum pumping capacities. The outlet flow is adjusted gradually according to the configured correction interval. When autoAdjustOutflowSpeed = false, automatic outlet flow regulation is disabled. The discharge rate is determined by the downstream process unit, while RpFlowing continues to monitor the operating state and generate runtime events required for application-specific control logic. The operating mode is fixed for the entire simulation and cannot be changed at runtime.
Target Inventory Control
In Automatic Outflow Control mode, RpFlowing regulates the outlet flow to maintain the specified target inventory level. If the target inventory is updated during simulation, the controller gradually adjusts the pumping rate until the new operating point is reached. Target inventory control is available only when autoAdjustOutflowSpeed = true. In Demand-Driven Outflow mode, the outlet flow is determined by the downstream process unit, and target inventory regulation is not applied.
Method;Description
getGoalLoad();Returns the current target inventory level.
setGoalLoad();Updates the target inventory level during simulation.
isAboveGoalLoad();Returns whether the current inventory exceeds the target level.
isBelowGoalLoad();Returns whether the current inventory is below the target level.
Flow correction is the primary operating state of RpFlowing. During each control cycle, the component evaluates the current operating conditions and updates the outlet flow according to the selected operating mode. In Automatic Outflow Control mode, the outlet flow is gradually increased or decreased to maintain the target inventory level. In Demand-Driven Outflow mode, automatic flow correction is disabled. The control cycle is still executed, allowing application code to update the maximum discharge rate according to the current requirements of the downstream process unit.
onFlowCorrection() - triggered during every flow correction cycle. in Automatic Outflow Control, the event is generated after each automatic flow adjustment. in Demand-Driven Outflow, the event is generated with the same frequency, allowing application code to recalculate the maximum outlet flow determined by the downstream process unit.
Pumping-Down Control
When the inlet flow stops, RpFlowing automatically enters Pumping-Down mode. Instead of stopping the discharge immediately, the component gradually reduces the outlet flow while continuing to empty the reservoir park. This approach prevents abrupt flow changes and provides a smooth transition until the remaining inventory is discharged. Pumping-Down Control is available only in Automatic Outflow Control mode.
onPumpingDown() - triggered during each Pumping-Down control cycle and provides an opportunity to monitor the current discharge process or execute application-specific logic.
Overflow Protection
Overflow Protection prevents the reservoir park from exceeding its maximum allowable inventory level. When the inventory reaches the configured limit, the inlet valve is automatically closed to stop further product inflow. Normal operation resumes after the inventory decreases below the maximum threshold. This mechanism operates independently of the selected operating mode and provides safe operation under both Automatic Outflow Control and Demand-Driven Outflow configurations.
onInputValveChange() - triggered whenever the inlet valve changes its state (opened or closed), allowing application code to monitor overflow protection or synchronize external control logic.
Operating State Monitoring
RpFlowing provides runtime methods for monitoring the current operating state and inventory conditions during simulation. These methods allow application code to track the execution of the control algorithm and respond to changing process conditions without directly affecting the built-in control logic.
Method;Description
getCurrentLoad();Returns the current inventory level.
getGoalLoad();Returns the configured target inventory level.
isAboveGoalLoad();Returns true if the current inventory exceeds the target level.
isBelowGoalLoad();Returns true if the current inventory is below the target level.
isInputValveOpened();Returns the current state of the inlet valve.
isPumpingDown();Returns true when Pumping-Down mode is active.
RpFlowing provides a set of runtime callbacks that notify application code about the execution of the control algorithm and changes in the operating state. These callbacks enable custom monitoring, logging, and application-specific control logic without modifying the built-in flow control algorithm.
Event;Description
onFlowCorrection();Triggered during every flow correction cycle.
onGoalLoadChange();Triggered when the target inventory level is updated.
onPumpingDown();Triggered during each Pumping-Down control cycle.
onInputValveChange();Triggered whenever the inlet valve is opened or closed.
onFlowCorrection() - this callback is available in both operating modes. In Automatic Outflow Control, it is triggered after each automatic flow correction cycle. In Demand-Driven Outflow, it provides a convenient point for updating the maximum outlet flow according to the requirements of the downstream process unit. onGoalLoadChange() - this callback is available only in Automatic Outflow Control mode. It is triggered whenever the target inventory level changes, allowing application code to respond to the new operating conditions while the controller gradually converges to the updated target. onPumpingDown()- triggered during every Pumping-Down control cycle while the reservoir park is being emptied after the inlet flow stops. This callback is available only in Automatic Outflow Control mode. onInputValveChange() - triggered whenever the inlet valve changes state because of normal operation or overflow protection. The callback can be used for monitoring, event logging, or synchronization with external control logic.
The RpFlowing runtime API enables application developers to monitor operating conditions, modify control parameters, and integrate custom operating logic directly into refinery simulation models. Runtime methods can be used to query the current operating state or update control settings, while event callbacks provide convenient extension points for executing user-defined logic during the simulation. The following examples demonstrate typical Java API usage for both operating modes. The first example updates the target inventory level in Automatic Outflow Control mode, while the second illustrates application-specific control logic executed during the runtime control cycle.
if (rpFlowing.isAboveGoalLoad(0.6)) {
rpFlowing.setTargetLoad(0.6, true);
}
if (rpFlowing.isBelowUserLoad(0.5)) {
rpFlowing.setGoalLoad(0.5, false);
}
Conclusion
Flowing tank farms play a key role in maintaining stable product transfer between interconnected refinery process units. By supporting both Automatic Outflow Control and Demand-Driven Outflow, RpFlowing can accurately represent a wide range of real refinery operating scenarios, from pipeline transportation systems to internal process connections. The runtime methods and event callbacks described in this article allow application developers to monitor operating conditions, adjust control parameters, and integrate custom operating logic without modifying the built-in control algorithms. Together, these capabilities provide a flexible foundation for developing refinery digital twin models that combine realistic process behavior with application-specific control strategies. Together, the runtime methods, automatic control algorithms, and event callbacks make RpFlowing suitable for implementing realistic refinery transfer systems ranging from simple process connections to complex refinery digital twins with application-specific operating logic. The same runtime API supports both Automatic Outflow Control and Demand-Driven Outflow, allowing a single component to represent a wide range of refinery operating scenarios without changing the application architecture.
FAQ
1 What is Flowing Tank Farm Control? Flowing Tank Farm Control is a set of runtime methods and event callbacks that allow application code to monitor and control RpFlowing during simulation.
2 What is the purpose of autoAdjustOutflowSpeed? The autoAdjustOutflowSpeed property selects the operating mode before the simulation starts. When enabled, RpFlowing automatically regulates the outlet flow to maintain the target inventory level. When disabled, the outlet flow is determined by the downstream process unit.
3 Can the operating mode be changed during simulation? No. The operating mode is selected during model configuration and remains unchanged throughout the simulation.
4 Can the target inventory level be modified at runtime? Yes. The target inventory can be updated during simulation only in Automatic Outflow Control mode. RpFlowing gradually adjusts the outlet flow until the new operating point is reached.
5 When is onFlowCorrection() triggered? onFlowCorrection() is triggered during every flow correction cycle in both operating modes. In Demand-Driven Outflow mode, it is typically used to update the maximum discharge rate requested by the downstream process unit.
6 When is onGoalLoadChange() available? onGoalLoadChange() is available only in Automatic Outflow Control mode and is triggered whenever the target inventory level changes.
7 When is onPumpingDown() triggered? onPumpingDown() is triggered while the reservoir park is emptying after the inlet flow stops. This callback is available only in Automatic Outflow Control mode.
8 What is onInputValveChange() used for? onInputValveChange() is triggered whenever the inlet valve is opened or closed. It can be used for monitoring, logging, or synchronizing external control logic.