Flowing Tank Farm Operating Algorithms for Refinery Digital Twin Simulation

What Is a Flowing Tank Farm?

       A flowing tank farm functions as a buffer tank system designed to temporarily decouple upstream and downstream refinery processes in refinery production planning and digital twin and dynamic simulation software by regulating product flow through intermediate storage while accurately representing refinery process dynamics. Unlike accumulative tank farms, which primarily support long-term storage and shipment planning, flowing refinery tank farm focus on flow management. Their primary objectives are to smooth inlet flow fluctuations, maintain stable downstream operation, support refinery process control, and enable controlled equipment startup and shutdown.
       Flowing tank farms operate using several specialized control algorithms, each designed for a particular operating condition. The digital twin control system automatically switches between these algorithms to maintain stable operation while minimizing unnecessary computational effort. The following sections describe the operating algorithms implemented in the flowing tank farm model as buffer tanks and explain when each algorithm is applied.

Operating Algorithms Overview

       A single outlet flow controller cannot efficiently handle all operating conditions encountered during refinery operation. During normal production, the objective is to stabilize the outlet flow. During feed interruption, the objective becomes maximizing downstream operating time. During overflow conditions, product safety has higher priority than flow stability. Because these objectives are fundamentally different, the flowing tank farm automatically switches between specialized operating algorithms.
       The selection of the active algorithm depends on factors such as inlet flow availability, tank inventory, target inventory level, and operating constraints. As process conditions evolve, the digital twin control system automatically transitions between algorithms to maintain stable flow, protect the tank farm from abnormal operating conditions, and reduce unnecessary computational effort whenever possible.In addition to the automatic operating algorithms, the model also provides a user-selectable Direct Flow simulation mode. Unlike the operating algorithms, this mode disables flowing tank farm dynamics entirely by replacing the tank farm with an ideal pipeline. It is intended for long-term production planning and other simulation studies where detailed tank farm behavior is not required.
       The flowing tank farm model includes the following operating algorithms and simulation mode:
  • Flow Correction — active outlet flow regulation to smooth inlet flow fluctuations and maintain the target inventory level.
  • Steady Flow — reduced-frequency monitoring during stable operating conditions to minimize computational overhead.
  • Pumping Down — controlled tank discharge after the inlet flow has stopped.
  • Overflow Protection — prevention of tank overfilling by restricting the incoming flow until a safe operating level is restored.
  • Direct Flow (user-selected simulation mode) — replaces the flowing tank farm with an ideal pipeline for simplified and faster simulation.
       Each algorithm addresses a different operational objective. Rather than solving all operating conditions with a single controller, the flowing tank farm automatically selects the most appropriate algorithm for the current process state.

Flow Correction

       Flow Correction is the primary operating algorithm of the flowing tank farm. It is activated at simulation startup and whenever stable operating conditions must be restored. It provides active flow control by continuously regulating the outlet flow to maintain the target inventory level and stabilize downstream operation.
       Two outlet flow control strategies are supported. The appropriate control strategy is selected according to the refinery configuration.
       1 Automatic Flow Control. The algorithm continuously adjusts the outlet flow to maintain the tank inventory close to the target level while smoothing fluctuations in the incoming flow. Depending on the refinery configuration, the outlet flow may be controlled directly or automatically recalculated within the operating limits of the pumping system [Vmin; Vmax]. During operation, the outlet flow is periodically updated to compensate for inventory deviations while respecting pump capacity and flow ramp-rate limits (±∆V). This allows the tank farm to respond to changing process conditions without introducing abrupt flow variations. The resulting automatic flow control improves process stability while minimizing unnecessary control actions. This adaptive behavior improves overall process control by maintaining stable operating conditions despite fluctuations in upstream production.
       Once the inlet and outlet flows are balanced and the tank inventory remains within the allowable tolerance around the target level, the control system automatically switches to the Steady Flow algorithm, where frequent recalculations are no longer required.
       2. External Flow Control. The desired outlet flow is determined by external control algorithms, while the flowing tank farm continues to smooth flow fluctuations and maintain the target inventory level. This strategy is commonly applied when the tank farm is located at the refinery inlet, where pipeline constraints are absent and the allowable outlet flow is primarily determined by the operating limits of downstream process units rather than by pipeline hydraulics.

Steady Flow

       The Steady Flow algorithm is designed for stable operating conditions where active flow regulation is no longer required. After the target inventory level has been reached and the inlet and outlet flows are balanced, the digital twin suspends frequent outlet flow recalculations and enters a low-frequency monitoring mode. The tank farm periodically verifies that the inventory remains within the allowable tolerance around the target level. If a significant deviation is detected, the control system automatically returns to the Flow Correction algorithm to restore the desired operating conditions. Unlike active flow control, this algorithm performs only periodic monitoring until operating conditions change.

Pumping Down

       The Pumping Down algorithm is activated when the inlet flow is no longer available. Rather than stopping the outlet flow immediately, the control system gradually reduces the pumping rate (±∆V) within the allowable operating limits until the minimum sustainable flow (Vmin) is reached. The remaining product is then discharged at this minimum flow rate for as long as sufficient inventory remains. This strategy maximizes downstream operating time and allows process units to shut down in a controlled manner while avoiding abrupt flow interruptions. If the inlet flow is restored, the control system automatically switches back to the Flow Correction algorithm

Overflow Protection

       The Overflow Protection algorithm is activated when the tank inventory reaches the maximum allowable operating level. To prevent tank overfilling, the incoming flow is immediately stopped or diverted through a bypass, while the outlet flow continues to reduce the tank inventory. Rather than returning to normal operation immediately after the inventory drops below the maximum level, the algorithm remains active until a predefined recovery level is reached (< Max). This hysteresis prevents frequent switching between operating algorithms caused by small inventory fluctuations near the operating limit. Once the inventory returns to a safe operating range, the control system automatically switches back to the Flow Correction algorithm.

Direct Flow Simulation Mode

       Unlike the operating algorithms described above, Direct Flow is a user-selected simulation mode rather than an automatic control algorithm. When enabled, the flowing tank farm is replaced by an ideal pipeline, where the outlet flow always equals the inlet flow. Consequently, no active flow control or inventory regulation is performed. As a result, no flow smoothing, inventory balancing, or protective operating algorithms are applied. As a result, detailed process dynamics associated with intermediate storage are intentionally omitted.
       This mode can be enabled or disabled at any time during simulation, allowing the model complexity to be adjusted without modifying the process flowsheet. It is particularly suitable for refinery production planning, refinery process optimization, production planning and digital twin applications, and large-scale digital Twin software applications, where detailed tank farm simulation has only a limited influence on overall simulation results but substantially increases computational effort. Guidelines for selecting an appropriate level of tank farm abstraction and the impact of replacing a flowing tank farm with an ideal pipeline are discussed in our article "Why Tank Farms Make Refinery Simulation Difficult?"

Implementation in the Petroleum Refining Library

       The operating algorithms described in this article are fully implemented in the Petroleum Refining Library (PRL) for AnyLogic. The Flowing Tank Farm component automatically manages transitions between operating algorithms according to the current process conditions, including inlet flow availability, tank inventory, target inventory level, and overflow protection requirements. The component implements a complete refinery flow control solution that automatically adapts to changing operating conditions while preserving stable refinery operation.
       The component also supports both outlet flow control strategies described above. The outlet flow may be calculated automatically by the flowing tank farm or determined by external control algorithms, allowing the model to represent both long-distance pipeline transportation and refinery feedstock transfer scenarios.
       For studies where detailed tank farm dynamics are unnecessary, the Direct Flow simulation mode can be enabled at any time during simulation. In this mode, the flowing tank farm is replaced by an ideal pipeline, significantly reducing computational effort while preserving the overall refinery process structure.
       The state-based architecture allows the same model to support detailed operational analysis, long-term refinery production planning, process optimization and refinery optimization studies, and large-scale digital twin software applications without changing the process flowsheet.

Conclusion

       Rather than relying on a universal controller, the flowing tank farm applies specialized operating algorithms optimized for different refinery operating conditions. This state-based approach improves numerical stability, reduces computational effort, and more accurately represents the operational behavior of real refinery buffer tanks.
       Accurate simulation of flowing tank farms requires more than simple flow balancing. The proposed state-based architecture combines multiple flow control strategies to achieve stable operation, realistic process behavior, and efficient long-term refinery simulation. The state-based control architecture presented in this article combines four automatic operating algorithms with an optional simplified simulation mode. This approach enables accurate tank farm simulation for refinery digital twin software, allowing engineers to balance simulation accuracy and computational performance in both operational studies and long-term refinery production planning. This state-based architecture allows flowing tank farms to combine realistic process behavior with efficient long-term simulation, making it suitable for both operational digital twins and strategic refinery planning supporting both detailed dynamic simulation and long-term production planning.

FAQ

1 What is a flowing tank farm?
A flowing tank farm is an intermediate buffering system that regulates product flow between upstream and downstream refinery processes. Its primary purpose is to smooth flow fluctuations, maintain stable downstream operation, and support controlled equipment startup and shutdown rather than long-term product storage.

2 Why does a flowing tank farm require multiple operating algorithms?
Different operating conditions require different control strategies. Normal operation, stable flow conditions, feed interruption, and overflow protection cannot be handled efficiently by a single algorithm. A state-based control system allows the most appropriate algorithm to be selected automatically.

3 What is the purpose of the Flow Correction algorithm?
The Flow Correction algorithm actively regulates the outlet flow to maintain the target inventory level while smoothing inlet flow fluctuations. It is the primary operating algorithm and automatically restores stable operating conditions whenever disturbances occur.

4 What is the difference between Flow Correction and Steady Flow?
Flow Correction continuously adjusts the outlet flow to restore the target inventory level. Steady Flow is activated after equilibrium has been reached and reduces the frequency of control calculations while periodically monitoring the tank inventory. This significantly decreases computational effort during long-term simulation.

5 When should Direct Flow simulation mode be used?
Direct Flow is intended for refinery production planning and other long-term simulation studies where detailed tank farm dynamics are unnecessary. In this mode, the flowing tank farm is replaced by an ideal pipeline, reducing computational effort while preserving the overall refinery process structure.

6 Can a flowing tank farm be replaced by an ideal pipeline?
Yes, when detailed flow dynamics have only a limited influence on the simulation objectives. The Direct Flow simulation mode replaces the tank farm with an ideal pipeline, making it possible to accelerate large refinery simulations. The impact of this simplification depends on the process configuration and is discussed in the article "Why Tank Farms Make Refinery Simulation Difficult?"