Tank Farm Simulation for Refinery Digital Twin Models

       Modern refineries rarely operate under perfectly steady conditions. Feedstock production changes throughout the day, process units adjust their throughput, maintenance activities temporarily reduce capacity, and downstream facilities continuously modify product demand. As a result, flow rates throughout the refinery constantly fluctuate. Without an effective buffering mechanism, these fluctuations propagate across the entire production chain. A temporary increase in upstream production can overload downstream units, while a sudden decrease may force expensive process slowdowns or even equipment shutdowns. The larger and more integrated the refinery, the more critical stable material flow becomes.
A tank farm is far more than a storage facility. In modern petroleum refining, it acts as a dynamic control element that absorbs flow disturbances, maintains inventory within safe operating limits, and delivers a stable outlet flow despite continuously changing inlet conditions.
This capability is especially important in Digital Twin models, where realistic simulation of storage dynamics directly affects production planning, refinery logistics, equipment utilization, and process optimization. Treating a tank farm as a passive storage node often produces unrealistic simulation results and inaccurate operational forecasts.
This article explains how tank farm simulation can represent dynamic inventory behavior, automatic flow regulation, and operational constraints in refinery Digital Twins. It also describes the control algorithm implemented in the Petroleum Refining Library (PRL), where a flowing tank farm continuously adjusts its operating mode according to process conditions while maintaining material balance and operational stability.

Why Traditional Tank Farm Models Are No Longer Sufficient?

       Many simulation models still represent a tank farm as a simple storage vessel with a fixed inventory balance:

Inventory = Previous Inventory + Inlet Flow − Outlet Flow

       Although mathematically correct, this simplified approach ignores the operational reality of refinery tank farms. In practice, outlet flow cannot change instantaneously. Pumping systems have minimum and maximum capacities, pipelines impose allowable ramp rates, and operators intentionally maintain inventory around a target level to provide sufficient buffer capacity for unexpected process disturbances. Maintenance activities, emergency shutdowns, and temporary interruptions in downstream transportation further complicate daily operation.
       As a consequence, the tank farm itself becomes an active participant in refinery process control rather than a passive storage location. A realistic digital twin must therefore simulate not only inventory accumulation but also operational decision-making.

       At every simulation step, the model should determine:
        - whether inventory remains within safe operating limits;
        - whether outlet flow should increase or decrease;
        - whether pump capacity constraints are satisfied;
        - whether flow-rate changes exceed allowable ramp limits;
        - whether the facility should switch to another operating mode, such as flow correction, steady flow, overflow protection, or pumping down.
       Only by combining these operational rules with material balance can a digital twin accurately reproduce the behavior of a real refinery tank farm and provide reliable results for production planning, logistics optimization, and operational analysis.

What Is a Flowing Tank Farm?

       A flowing tank farm is a storage system designed not only for temporary product accumulation but also for continuous regulation of flow between interconnected refinery processes.
Unlike traditional storage facilities like accumulative tank farms, where tanks are primarily used for receiving, storing, blending, and shipping products in separate operational stages, a flowing tank farm continuously receives and dispatches flows at the same time. The stored inventory acts as a dynamic buffer that absorbs short-term flow fluctuations while maintaining stable downstream operation.
This operating principle is widely used in oil and gas processing, particularly for crude oil, stabilized condensate, intermediate refinery streams, and finished petroleum products transported through pipelines. The objective is not to maximize storage utilization but to ensure uninterrupted production and stable process conditions.
Instead of functioning as passive storage, the tank farm becomes an active element of the refinery control system. It continuously compensates for differences between incoming and outgoing flow rates while maintaining inventory within predefined operating limits.

The Equivalent Tank Model

       Although an industrial tank farm may consist of dozens of physical tanks, pipelines, pumps, and valves, its dynamic behavior can often be represented by a single equivalent storage model. Instead of simulating every individual tank, the Digital Twin tracks the total inventory stored within the facility. The equivalent inventory changes according to the material balance:

Inventory = Previous Inventory + Inlet Flow − Outlet Flow

       The controller continuously adjusts the outlet flow while ensuring that inventory remains between predefined minimum and maximum operating levels. This abstraction dramatically simplifies simulation while preserving the operational behavior that is most important for production planning and process optimization. It also allows the same control algorithm to represent facilities of very different sizes without increasing model complexity.

Target Inventory Instead of Maximum Storage

       One of the most important differences between a flowing and an accumulative tank farm is the operating objective.
Traditional storage facilities often aim to maximize available inventory while ensuring sufficient capacity for future deliveries.
A flowing tank farm follows a different strategy.
       Its objective is to maintain inventory close to a predefined target level that provides sufficient flexibility for both unexpected increases in inlet flow and temporary interruptions of downstream transportation. If inventory becomes too low, the system loses its ability to compensate for supply interruptions. If inventory becomes too high, the available buffer capacity decreases and the risk of overflow increases. For this reason, the controller continuously regulates outlet flow to keep inventory near the target operating level while respecting equipment limitations and operational constraints. This dynamic inventory control forms the foundation of realistic tank farm simulation and enables Digital Twin models to reproduce the behavior of real refinery operations with much higher accuracy than static inventory calculations.

Operating Modes of a Flowing Tank Farm

       A flowing tank farm continuously evaluates its operating conditions and automatically selects the most appropriate control strategy. Rather than operating with a fixed outlet flow, it adapts its behavior according to the current inventory level, inlet flow rate, equipment constraints, and downstream operating requirements.
In the Petroleum Refining Library (PRL), the tank farm operates as a finite-state controller that switches between several operating modes. Each mode is designed to solve a specific operational problem while maintaining material balance and ensuring safe refinery operation.
For more details, see here

Intelligent State Transitions

       The operating modes described above are not selected manually. Instead, the controller continuously evaluates process conditions and automatically switches between states whenever operating criteria change. This state-based control architecture allows the Digital Twin to respond naturally to changing refinery conditions while preserving stable operation and maintaining realistic equipment behavior. Rather than relying on fixed operating rules, the tank farm behaves as an adaptive control system capable of balancing production, storage, and transportation under continuously changing process conditions.
See: Appendix A. Mathematical Model of Flowing Tank Farm Simulation

Dynamic Flow Control Algorithm

       As illustrated in example Figure below, the flowing tank farm is located between several upstream production units generating variable product flows and the downstream processing facilities connected by the transfer pipeline. Since the downstream refinery is capable of processing significantly larger volumes than the tank farm can store, the reservoir park serves as a short-term hydraulic buffer rather than a long-term storage facility. The control algorithm therefore determines the outlet flow Vout(t) at every control interval to keep the inventory close to its target operating level while smoothing fluctuations of the combined inlet flow Vin(t), preventing overflow or depletion, and satisfying all equipment and operational constraints.

Step 1. Collect Current Operating Data

       The control cycle begins by reading the current process variables from the simulation model.
       These include:
       - total inlet flow from all upstream sources;
       - current outlet flow;
       - total inventory stored in the tank farm;
       - operating mode;
       - pump availability and constraints;
       - pipeline constraints.
       Because all calculations are performed using the current process state, the controller continuously adapts to changing refinery conditions without requiring predefined operating schedules.

Step 2. Determine the Operating Mode

       Next, the controller determines which operating mode should be active.
The decision primarily depends on three factors:
  • current inventory level;
  • relationship between inlet and outlet flow;
  • equipment availability.
For example:
  • inventory close to the target activates Steady Flow;
  • significant inventory deviation activates Flow Correction;
  • inventory approaching the maximum limit activates Overflow Protection;
  • loss of inlet flow activates Pumping Down.
This operating mode determines which control strategy will be used during the current calculation cycle.

Step 3. Calculate the Allowable Outlet Flow Range

       Rather than immediately selecting a new outlet flow, the controller first determines the range of physically acceptable values. Several operational constraints are evaluated simultaneously.
Pump Capacity. Every pumping system has minimum and maximum operating capacities.
The outlet flow must remain within these limits to ensure safe and reliable equipment operation.
Inventory Constraints. The selected outlet flow must not cause inventory to exceed the maximum operating level or fall below the minimum allowable inventory. These limits preserve sufficient storage capacity while preventing interruptions in downstream supply.
Flow Ramp Rate. Pipeline systems generally cannot tolerate abrupt flow changes. For this reason, the controller limits the maximum increase or decrease in outlet flow during each control interval.This constraint reduces hydraulic shocks, minimizes pressure fluctuations, and better represents actual refinery operating practice.
The intersection of all these constraints defines the allowable operating range for the outlet flow.

Step 4. Calculate the Preferred Outlet Flow

       Once the allowable range has been established, the controller determines the preferred outlet flow.
Its objective is simple: move the inventory toward the target level as efficiently as possible. If inventory is above the target, the controller attempts to increase the outlet flow. If inventory is below the target, it attempts to decrease the outlet flow. However, the preferred value is only accepted if it satisfies all operational constraints calculated in the previous step. Otherwise, the closest feasible value is selected. This approach ensures that every control decision remains physically achievable.

Step 5. Handle Exceptional Operating Conditions

       Certain operating situations require additional control logic beyond normal inventory regulation. One important example is the sudden loss of inlet flow. If plant flow production unexpectedly stops, maintaining a high outlet flow could rapidly empty the tank farm and interrupt downstream operation. Instead, the controller gradually reduces the outlet flow while respecting the maximum allowable ramp rate. The stored inventory is therefore used strategically to extend downstream operation for as long as possible. Similar protective logic is applied when inventory approaches the maximum operating limit or when equipment becomes unavailable because of maintenance or operational restrictions.

Step 6. Update the Digital Twin

       After the outlet flow has been determined, the Digital Twin updates the material balance. The new inventory is calculated using the current inlet flow, outlet flow, and simulation time step. These updated values become the starting point for the next control cycle. Because this procedure is repeated throughout the simulation, the Digital Twin continuously reproduces the dynamic interaction between production, storage, transportation, and process control.

Continuous Closed-Loop Control

       Unlike static production planning tools, the algorithm operates as a closed-loop control system.
Every calculation depends on the current state of the refinery, allowing the model to respond naturally to fluctuations in production, changing inventory levels, maintenance activities, and transportation constraints.
This continuous recalculation enables the Digital Twin to simulate realistic refinery behavior while maintaining material balance, operational stability, and safe equipment operation.

Operational Constraints in Tank Farm Simulation

       A realistic tank farm simulation must consider far more than material balance alone. Every flow adjustment is limited by physical equipment capabilities, operational safety requirements, and refinery operating procedures.
Ignoring these constraints may produce mathematically correct results that cannot be achieved in practice.
For this reason, the Digital Twin evaluates all operational constraints before applying a new outlet flow.

Material Balance

       Material balance is the foundation of every tank farm simulation.
At each simulation step, the inventory changes according to the difference between incoming and outgoing material flows.
When the inlet flow exceeds the outlet flow, inventory increases.
When the outlet flow exceeds the inlet flow, inventory decreases.
Although this principle appears straightforward, maintaining material balance becomes significantly more challenging when equipment limitations and operational constraints are introduced. The controller must continuously balance inventory stability with changing production conditions while ensuring that every calculated operating point remains physically feasible.

Inventory Operating Limits

       A tank farm is never operated between completely empty and completely full conditions.
Instead, operators define a safe operating range bounded by minimum and maximum inventory levels.
The minimum inventory ensures that downstream production can continue during temporary interruptions of upstream supply and prevents pump cavitation or loss of suction.
The maximum inventory provides sufficient free capacity to absorb unexpected increases in production and avoids the risk of overflow.
Between these limits, the controller continuously attempts to maintain inventory near a predefined target inventory level. This target represents the optimal balance between operational flexibility and storage utilization.
Maintaining inventory near the target level significantly improves refinery stability by allowing the tank farm to absorb both positive and negative flow disturbances.

Pump Capacity Constraints

       The outlet flow is also constrained by the pumping equipment installed at the facility. Every pump has a minimum stable operating capacity and a maximum allowable throughput. Operating below the minimum flow may reduce pump efficiency or cause mechanical problems, while exceeding the maximum capacity is physically impossible and may damage equipment. Consequently, the controller always verifies that the calculated outlet flow remains within the available pumping capacity before applying any control action. If multiple pumps are available, the allowable operating range may change dynamically depending on equipment availability and maintenance schedules.

Flow Ramp Rate Limits

       One of the most important aspects of refinery operation is the limitation on how quickly flow rates may change. Although a Digital Twin can instantaneously calculate any new flow value, real pumping systems cannot. Rapid changes in outlet flow may produce hydraulic shocks, pressure fluctuations, excessive mechanical stress, and unstable pipeline operation. For this reason, the controller limits the maximum increase and decrease in outlet flow during each control interval. Instead of immediately switching from one operating point to another, the outlet flow changes gradually until the desired operating condition is reached. This produces smoother equipment operation while more accurately representing the behavior of industrial pumping systems.

Pipeline Constraints

       The downstream pipeline may impose additional operational limitations. Depending on pipeline length, diameter, hydraulic resistance, and operating pressure, certain flow rates may not be achievable even if sufficient pumping capacity is available.
Long-distance pipelines often require especially smooth flow transitions to minimize transient hydraulic effects. For this reason, pipeline limitations are evaluated together with pump capacity and inventory constraints before the controller accepts a new outlet flow.

Equipment Availability

       Operational constraints are not constant throughout the refinery lifecycle.
Maintenance activities, equipment failures, valve isolation, and pipeline shutdowns continuously modify the available operating envelope.
Instead of assuming constant equipment availability, the Digital Twin dynamically updates all operational limits according to the current refinery configuration.
This allows engineers to evaluate maintenance scenarios, equipment upgrades, and emergency situations while maintaining realistic process behavior.

Combining Multiple Constraints

       The controller never evaluates these constraints independently.
Instead, every control decision represents the intersection of all applicable operating limits.
The selected outlet flow must simultaneously satisfy:
  • material balance;
  • inventory operating limits;
  • pump capacity;
  • allowable flow ramp rate;
  • pipeline operating constraints;
  • equipment availability.
Only after all these conditions have been verified does the controller apply the new outlet flow.
This multi-constraint approach enables the Digital Twin to reproduce the behavior of a real refinery rather than an idealized mathematical model.

Simulation Example: Flow Smoothing in Practice

       The primary purpose of a flowing tank farm is not to maximize storage utilization but to stabilize downstream operation despite continuously changing upstream production.
The following example demonstrates how the control algorithm responds to realistic fluctuations in inlet flow while maintaining stable refinery operation.

Initial Operating Conditions

       Assume a refinery tank farm operating under normal production conditions.
The upstream process units deliver product with continuously changing flow rates caused by process disturbances, feedstock variability, and operational adjustments. At the beginning of the simulation, the tank farm inventory is close to its target level, allowing the controller to compensate for both positive and negative flow deviations.
The Digital Twin continuously evaluates the operating conditions and recalculates the outlet flow at each control interval.

Initial Operating Conditions

       Figure X illustrates a typical inlet flow profile.
Instead of remaining constant, the incoming flow continuously changes throughout the simulation period.
Some variations are relatively small and represent normal process disturbances, while others correspond to significant production changes caused by equipment operation or process adjustments.
Without buffering, every fluctuation would immediately propagate downstream.

Automatic Outlet Flow Regulation

       Rather than simply copying the inlet flow, the controller adjusts the outlet flow gradually.
Small inlet disturbances are almost completely absorbed by the tank farm.
Larger disturbances are compensated over multiple control intervals while respecting:
  • pump capacity limits;
  • maximum allowable flow ramp;
  • inventory operating limits;
  • pipeline operating constraints.
As a result, the outlet flow remains significantly smoother than the inlet flow.
This behavior reduces hydraulic disturbances, improves downstream process stability, and minimizes unnecessary operating adjustments.

Inventory Response

       The inventory changes dynamically as the controller absorbs process disturbances.
When inlet flow temporarily exceeds outlet flow, inventory increases.
When inlet flow becomes lower than outlet flow, the stored product is gradually released.
Instead of oscillating between minimum and maximum storage levels, the controller continuously drives the inventory toward the target operating level.
This allows the tank farm to preserve sufficient buffer capacity for future disturbances while maintaining reliable downstream supply.

Dynamic Behavior

       One of the most important characteristics of the algorithm is that the three process variables evolve simultaneously:
  • inlet flow changes according to upstream production;
  • outlet flow follows the controller decisions;
  • inventory reflects the cumulative difference between the two.
Because these variables are tightly coupled, the Digital Twin accurately reproduces transient refinery behavior rather than simply calculating static material balances.
The result is a realistic simulation of refinery operation during changing production conditions.

Operational Benefits

       The simulation demonstrates several important advantages of dynamic flow control.
Compared with a passive storage model, the flowing tank farm:
  • reduces outlet flow fluctuations;
  • maintains inventory near its target level;
  • prevents overflow and inventory depletion;
  • minimizes abrupt pump operating changes;
  • improves downstream process stability;
  • increases operational flexibility during production disturbances;
  • supports more accurate production planning and refinery logistics.
These benefits become increasingly important in large integrated refineries, where even small flow disturbances can propagate through multiple process units and significantly affect overall plant performance.

Why This Matters for Digital Twins?

       A Digital Twin is expected to reproduce the behavior of the physical refinery as accurately as possible.
If the tank farm is represented only as a static storage vessel, the model cannot predict the dynamic interaction between inventory, production, pumping systems, and downstream demand.
By incorporating automatic flow control and operational constraints, the Digital Twin captures the true role of the tank farm as an active process control element rather than a passive storage facility.
This enables engineers to evaluate operational strategies, optimize production schedules, analyze equipment limitations, and assess refinery performance under realistic operating conditions.

Figure Recommendations

       A Digital Twin is expected to reproduce the behavior of the physical refinery as accurately as possible.
If the tank farm is represented only as a static storage vessel, the model cannot predict the dynamic interaction between inventory, production, pumping systems, and downstream demand.
By incorporating automatic flow control and operational constraints, the Digital Twin captures the true role of the tank farm as an active process control element rather than a passive storage facility.
This enables engineers to evaluate operational strategies, optimize production schedules, analyze equipment limitations, and assess refinery performance under realistic operating conditions.

Implementation in PRL

       The Petroleum Refining Library (PRL) implements a flowing tank farm as an intelligent simulation component that continuously regulates outlet flow while maintaining material balance and respecting operational constraints.
The component automatically switches between operating modes depending on the current process conditions, including inventory level, inlet flow, and equipment availability.
Key features include:
  • automatic or user-controlled outlet flow;
  • automatic operating mode selection;
  • inventory tracking and material balance;
  • pump and pipeline constraints;
  • configurable flow ramp limits;
  • overflow protection and pumping-down logic;
  • maintenance simulation;
  • built-in operational KPIs.
The component integrates seamlessly with other PRL objects, including process units, separators, mixers, pipelines, and storage facilities, allowing engineers to build refinery-scale Digital Twin models while preserving realistic process dynamics.
By combining automatic flow control with operational constraints, PRL enables accurate simulation of production planning, refinery logistics, and process optimization without requiring users to implement custom control algorithms.

Benefits of Flowing Tank Farm Simulation

       Modeling a tank farm as an active flow control system provides a much more realistic representation of refinery operation than treating it as passive storage.
By continuously balancing inlet flow, outlet flow, and inventory, the Digital Twin captures transient operating conditions that significantly influence production planning and refinery performance.
The main advantages include:
  • smoother downstream flow despite fluctuating upstream production;
  • improved inventory utilization;
  • reduced risk of overflow and inventory depletion;
  • realistic representation of pump and pipeline limitations;
  • support for maintenance and equipment availability analysis;
  • more accurate production planning and refinery logistics;
  • improved Digital Twin fidelity for operational decision-making.
These capabilities allow engineers to evaluate operating strategies before implementation, identify potential bottlenecks, and optimize refinery performance under changing production conditions.

Conclusion

       A flowing tank farm is much more than a storage facility. It is an active control element that stabilizes material flows, maintains inventory within safe operating limits, and improves the overall resilience of refinery operations.
Accurate tank farm simulation requires more than material balance calculations. A realistic Digital Twin must also account for inventory dynamics, equipment constraints, operating modes, and automatic flow control. Only by combining these elements can the model reproduce the behavior of an industrial tank farm under real operating conditions.
The approach presented in this article demonstrates how dynamic flow regulation can be integrated into refinery simulation to support production planning, logistics optimization, and operational analysis. By representing the tank farm as an intelligent control system rather than passive storage, engineers can build Digital Twins that more closely reflect actual refinery behavior and provide more reliable decision support.

FAQ

1 What is a flowing tank farm?
A flowing tank farm is a storage system that continuously receives and dispatches material while automatically regulating outlet flow to stabilize downstream refinery operation.

2 Why is tank farm simulation important?
Tank farm simulation allows engineers to predict inventory changes, evaluate flow control strategies, prevent operational bottlenecks, and improve production planning before changes are implemented in the real refinery.

3 How does a Digital Twin model a tank farm?
A Digital Twin combines material balance, inventory dynamics, operational constraints, and automatic flow control to reproduce the behavior of a real tank farm under changing operating conditions.

4 Why is flow smoothing important?
Flow smoothing reduces the impact of upstream production fluctuations on downstream process units, improving operational stability and reducing unnecessary equipment adjustments.

5 Can PRL automatically control outlet flow?
Yes. PRL supports automatic outlet flow calculation based on inventory level, inlet flow, equipment constraints, and operating mode. Manual outlet flow control is also available for scenario analysis and testing.