Refinery Maintenance Simulation in Digital Twins

Maintenance Is Part of the Simulation Model

       In many simulation models, maintenance is treated as an external event that simply makes equipment unavailable. However, this approach does not reflect refinery operations, where a single asset shutdown affects the entire continuous material flow network. The resulting impact depends on refinery topology, equipment configuration, and available buffering capacity, including accumulative and flowing tank farms.
Maintenance simulation is the process of modeling scheduled shutdowns and equipment availability within a refinery digital twin to evaluate their impact on production, material flows, storage utilization, and refinery performance.
       Therefore, maintenance should be modeled as an integral part of the production process. A scheduled shutdown changes asset availability, and the digital twin dynamically recalculates oil and gas flows and operating constraints across the refinery.
The objective is not simply to represent equipment downtime, but to simulate how the refinery continues operating under maintenance conditions while preserving material balance and adapting the production network to the new operating scenario.
       In many simulation models, maintenance is represented by simply changing equipment status from Operating to Unavailable. While this correctly models asset downtime, it does not capture the refinery-wide impact of losing that asset. In a refinery digital twin, maintenance is modeled as a network event: flows are redistributed, storage operations change, production capacities are updated, and optimization constraints are recalculated. The objective is not to simulate the repair itself, but to evaluate how the refinery adapts while maintaining feasible flows and continuous operation.
       Although the AnyLogic Fluid Library does not provide automatic support for maintenance scheduling, maintenance behavior can be implemented using dedicated classes.

Maintenance Impact on Production Planning

       Maintenance activities directly affect refinery production planning by reducing available processing capacity and changing operating constraints. A refinery digital twin automatically updates asset availability and recalculates feasible production scenarios under the new operating conditions.
       The model evaluates how available process units, alternative operating modes, feed allocation, product yields, and storage utilization should be adjusted to maintain material balance and maximize production continuity.
This allows engineers to assess the real impact of planned shutdowns on refinery throughput, product availability, and operational constraints before maintenance execution, helping identify potential bottlenecks and optimize production strategies.

Modeling Scheduled Shutdowns

       In a refinery digital twin, maintenance is modeled through scheduled shutdowns of process unit lines and storage tanks. Each maintenance event is defined by the affected asset together with its start and end dates.

Process Unit (Plant) Maintenance

       For process units, maintenance activities are modeled at the process line level rather than at the entire unit level. This approach reflects real refinery and oil & gas processing operations, where individual lines within the same process unit may have different capacities, operating modes, product yields, and technical constraints.
       When a specific process line is scheduled for maintenance, it automatically enters the Repair state in the digital twin and becomes unavailable for production. The maintenance event triggers the inner plant optimization module, which recalculates the production schedule and redistributes available feed streams among the remaining operating lines.
       The optimization algorithm evaluates the current operating conditions of all available lines, including maximum throughput limits, operating modes, product specifications, and process constraints. The objective is to determine the best achievable operating configuration while considering the reduced processing capacity caused by the maintenance activity.
If the remaining operating lines do not have sufficient capacity to process the available feedstock, the excess flow is redirected through a bypass route, if such a route is available in the process configuration. When no bypass option exists, the incoming feed rate must be reduced.
       A reduction in feed intake creates a chain effect throughout the production system. The upstream tank farm may experience an increase in residuals due to reduced withdrawal capacity, or upstream process units may need to reduce their operating rates because the downstream unit can no longer accept the planned flow. Thus, a local maintenance event can affect material balances and operating conditions across the entire interconnected production network.
       The impact is also transferred downstream. Since one process line is unavailable, the total outlet flow from the unit decreases, and the production rates of individual products change according to the available processing modes and the resulting operating conditions.
       Maintenance events can also require changes in the operating strategy of the affected process unit. In many production systems, especially for front-end processing units, the priority is not always to maximize economic margin but to process the maximum possible amount of available feedstock. In such cases, operators may switch the remaining lines to alternative operating modes that provide lower-value product yields but allow higher feed processing rates.
       These high-throughput operating modes are typically selected when maintaining production continuity and avoiding feedstock restrictions becomes more important than maximizing product profitability.
       By automatically recalculating production allocation after maintenance events, the digital twin provides a realistic representation of equipment downtime consequences, including changes in production rates, product balances, tank farm residuals, upstream constraints, and overall system performance. This enables engineers to evaluate maintenance scenarios, identify bottlenecks, and optimize maintenance schedules before actual execution.
       However, the impact of maintenance is not limited to the period when equipment is unavailable. The transition into and out of maintenance can also significantly affect production performance. While long-term planning models often assume that shutdown and restart occur instantaneously, real process units require transient startup and shutdown periods during which operating conditions and product quality may temporarily deviate from normal operation. These transient periods are especially important for products with stringent quality requirements, such as aviation fuels, where startup operations may generate off-spec product before stable production conditions are achieved. To capture these effects, advanced refinery digital twins support configurable transient operating modes that simulate shutdown, startup, and stabilization periods, improving the accuracy of maintenance evaluation and production planning scenarios.

Tank Farm (Reservoir Park) Maintenance

       Storage tanks (for accumulative and flowing parks) follow a different maintenance logic. Before a tank can enter maintenance, its remaining inventory must be transferred to other available tanks. If sufficient storage capacity is unavailable, the maintenance cannot begin.
       Accumulative tank farm. Unlike process unit lines, storage tanks within the same tank farm are typically similar in size and operating characteristics. Therefore, maintenance activities can be scheduled at the tank farm level, allowing the digital twin to automatically select the most suitable tank for maintenance—typically the tank requiring the minimum amount of product transfer. In most operational scenarios, the key factor is not the specific tank selected for maintenance, but the resulting reduction in available storage capacity of the entire tank farm.
       Before a tank enters the Repair state, the digital twin initiates an automatic residual transfer procedure. The remaining product volume in the selected tank is gradually redistributed among the other available tanks in the tank farm. During the transfer process, the digital twin continuously evaluates the available receiving capacity of other tanks. When a receiving tank reaches its maximum allowable filling level, the transfer operation is automatically switched to the next suitable tank. This sequential filling logic continues until the maintenance tank is completely emptied.
The algorithm considers tank states, current fill levels, maximum operating limits, and tank availability to ensure that the transition to maintenance does not violate physical storage constraints. As a result, the digital twin accurately represents the temporary reduction of tank farm capacity, changes in available storage space, and potential operational limitations caused by maintenance activities. A detailed description of the tank selection algorithm, residual transfer logic, and tank farm maintenance workflow is provided in a dedicated article.
       Flowing Tank Farm Maintenance. Unlike accumulative tank farms, flowing tank farms have a specific operational requirement: all tanks within the same operating group must maintain equal residual levels. Therefore, the general maintenance workflow is similar to accumulative tank farms: when a tank is scheduled for maintenance, it is transferred to the Repair state and becomes unavailable for operation. However, the residual redistribution algorithm is different because the remaining tanks must preserve equal residual levels after the maintenance transition. Before the selected tank enters maintenance, the digital twin calculates the total residual volume available in the tank group and determines the new equilibrium level considering the reduced number of operating tanks. The remaining product from the tank under maintenance is not transferred to a single receiving tank but is uniformly redistributed among all active tanks in the same group.
       As a result, each operating tank receives an equal additional volume, and the residual levels remain identical across all available tanks. The algorithm preserves the fundamental operating condition of a flowing tank farm: the residual level distribution before and after the transfer remains balanced, while the total product mass is fully conserved.
After maintenance is completed and the tank returns to operation, the digital twin performs the reverse redistribution procedure. A calculated amount of product is transferred from the operating tanks back into the restored tank, reducing the residual levels of all active tanks by the same amount. This process continues until the equilibrium state is restored across the larger number of available tanks.
       The reverse transfer ensures that adding storage capacity back into the system does not create an artificial imbalance between tanks. Both maintenance removal and restoration are therefore modeled as controlled transitions between different capacity states of the tank group while preserving material balance and operational constraints.
By implementing this balancing logic, the digital twin realistically represents maintenance scenarios in flowing tank farms, including temporary capacity reduction, residual redistribution, and recovery of normal operating conditions after equipment return.
A detailed description of the flowing tank farm balancing algorithm, residual equalization rules, and maintenance workflow is provided in a dedicated article.

Automatic Material Flow Reconfiguration

       When a refinery asset enters maintenance, the objective is not simply to remove it from the model, but to preserve continuous refinery operation under the new constraints. The digital twin therefore updates asset availability and treats the unavailable asset as if it no longer exists in the material flow network. The reconfiguration strategy is not predefined by the maintenance model. Instead, it emerges naturally from the refinery topology, operating constraints, and control logic implemented in the digital twin. As a result, every scheduled shutdown is simulated as a change in the material flow network rather than as an isolated equipment event.

Maintenance Scheduling

       A refinery digital twin does not generate maintenance schedules. Instead, it uses the approved maintenance plan as an input to the simulation. Each maintenance event is defined by the affected asset and its start and end dates. For process units, the schedule also specifies the line to be taken out of service. During the defined period, the corresponding asset automatically enters the Repair state and its availability status is updated accordingly. This separation of responsibilities allows maintenance planning and production simulation to remain independent. Maintenance schedules may originate from enterprise planning systems, engineering decisions, or predictive maintenance models, while the digital twin evaluates their impact on refinery operations, flows, storage utilization, and production performance.
       Although maintenance schedules in refinery digital twins are usually provided as deterministic inputs with predefined start and end dates, simulation models are also highly suitable for analyzing stochastic equipment failures and unplanned downtime. Such problems require additional methods based on reliability analysis, stochastic processes, and Markov chain models, and are beyond the scope of this work. However, the simulation framework can naturally support these extensions by incorporating probabilistic equipment states and failure scenarios. This enables the evaluation of production risks, unexpected downtime impacts, and maintenance strategies under uncertainty.

Example: Simulating a Scheduled Shutdown

Scenario:
        - 4 parallel CDU lines;
        - 1 CDU line under scheduled maintenance;
        - Downstream Vacuum Unit operating near capacity;
        - Intermediate crude storage available.

       Once maintenance begins, the selected CDU line enters the Repair state and becomes unavailable. The digital twin immediately updates equipment availability and recalculates material flows throughout the refinery.
       Crude oil is automatically redistributed among the remaining CDU lines. If their combined capacity is insufficient, part of the incoming crude is temporarily buffered in the tank farm, while downstream process units receive reduced feed. The optimization model simultaneously updates equipment availability constraints and determines a new feasible operating plan that satisfies material balance, processing capacities, and storage limitations.
       If the maintenance schedule also includes a storage tank, its inventory is first transferred to other available tanks. When sufficient storage capacity is unavailable, the maintenance is postponed until the required conditions are met. This simulation enables engineers to evaluate not only the direct loss of processing capacity, but also the cascading impact of maintenance on material routing, storage utilization, downstream units, and overall refinery throughput before the shutdown begins.

Conclusion

       Maintenance is an integral part of refinery operations, not an external event. Every scheduled shutdown changes the set of available assets, modifies production capacities, and reconfigures material flows throughout the refinery.
       A refinery digital twin must therefore simulate maintenance as a change in the operating state of process unit lines and storage tanks while automatically adapting the material flow network to the new operating conditions. This allows engineers to evaluate production plans under realistic maintenance scenarios without violating material balance or manually rebuilding the process model.
       Ultimately, the goal of maintenance simulation is not to model equipment downtime, but to predict how a refinery continues operating while individual assets become temporarily unavailable. This approach can be implemented using AnyLogic simulation technology.

FAQ

1 How are maintenance shutdowns modeled in refinery digital twins?
Maintenance is modeled by temporarily changing the operating state of refinery assets, such as process unit lines or storage tanks. During the scheduled maintenance period, these assets become unavailable for material flow, and the digital twin automatically recalculates production capacities, material routing, and operating constraints.

2 Why is maintenance modeled at the line level instead of the process unit level?
Process unit lines often have different capacities, operating limits, and processing characteristics. Scheduling maintenance at the line level allows the digital twin to accurately represent the production impact of shutting down a specific line while keeping the remaining lines in operation.

3 How is storage tank maintenance simulated?
Before a storage tank can enter maintenance, its inventory must be transferred to other available tanks whenever sufficient capacity exists. If the transfer cannot be completed, the maintenance is disabled. In many cases, the digital twin can automatically select the most suitable tank for maintenance based on the current operating conditions.

4 How does maintenance affect material flows?
Rather than simply removing equipment from service, a refinery digital twin automatically reconfigures the material flow network. Depending on the refinery configuration, material may be redistributed to other process units, redirected to storage, routed through alternative flow paths, or upstream production may be reduced.

5 Does a refinery digital twin generate maintenance schedules?
No. Maintenance schedules are typically created by maintenance planning systems or engineering teams. The digital twin uses the approved schedule as an input and evaluates its impact on production, storage utilization, logistics, and material flows.

6 How is maintenance integrated with production optimization?
During maintenance, unavailable process unit lines are automatically excluded from the optimization problem through availability constraints. The optimization model then recalculates feed distribution, production capacities, and material routing using the remaining available assets.

7 Can refinery digital twins model startup and shutdown transitions?
Yes. While many models assume instantaneous shutdown and restart for long-term planning, advanced refinery digital twins can simulate transient startup and stabilization periods, including the production of off-spec material, providing more realistic maintenance scenarios.

8 Why is maintenance simulation more complex in refineries than in other industries?
Unlike discrete manufacturing, a refinery is a continuous material flow network. Taking a single process unit line or storage tank out of service can affect production capacities, storage operations, logistics, and downstream processing. As a result, maintenance must be simulated as a change in the entire material flow network rather than as isolated equipment downtime.