Material Balance in Refinery Digital Twins

       Material balance is the core consistency layer of refinery digital twins, ensuring physical correctness of all material flows across sources, process units, and reservoir parks. In Petroleum Refining Library, it is not treated as a global post-check, but as a distributed property embedded in every operational element of the system. Within this architecture, material balance defines the feasible physical state space of the digital twin. All optimization, scheduling, and control decisions operate strictly within this constraint layer, ensuring that simulation results remain physically consistent and executable in real refinery operations.
Material balance defines the feasible state space of the digital twin, and all optimization, scheduling, and control decisions are constrained within it, ensuring physically consistent and executable simulation behavior

Hierarchical Structure of Material Balance in Refinery Digital Twins

       Material balance in refinery digital twins is implemented as a hierarchical system rather than a single global constraint. In Petroleum Refining Library, conservation is enforced locally at each structural level (Tank, Reservoir Park, line, Plant) and then propagated through aggregation across the refinery network.
       At the lowest level, Sources generate oil and gas streams grouped into production fields, defining initial flow conditions for the system.
       At the processing level, Process Units (Plants) transform incoming oil and gas streams through parallel lines and operating modes. Each unit maintains local balance by accounting for outputs, internal consumption, losses, and storage effects.
       At the storage level, Reservoir Parks (Tank Farms) coordinate multiple tanks that handle accumulation, blending, and dispatch. Each park maintains local balance by accounting for inflows, outflows, and the change in total stored inventory, ensuring that dynamic variations in tank levels are explicitly reflected in the material balance together with losses and operational effects.
       No physical transport layer — instantaneous node coupling!
       A similar modeling principle is applied to all other system components, where each node type follows the same local material balance logic adapted to its specific operational role within the refinery network. At the system level, these elements are connected through direct flow relationships, without explicit transport infrastructure. Oil and gas transfer is represented as instantaneous exchange between nodes, while dynamic effects are handled by the simulation engine. This hierarchical structure ensures that local conservation at each element produces globally consistent behavior across the refinery digital twin. Tank farms extend the material balance network by introducing storage variables that directly influence routing and allocation decisions.

Continuous Flow and Event-Driven Simulation

       Refinery digital twins in Petroleum Refining Library operate as continuous flow systems implemented on top of an event-driven simulation engine. Oil and gas streams are treated as continuous quantities evolving over time, while system state updates occur at discrete simulation events triggered by changes in production plans, optimization outputs, or operational conditions.
       Between events, flows are propagated through the system under fixed operating conditions. When an event occurs, the simulation recalculates flow distributions, updates operating modes, and applies control decisions generated by the optimization layer. This creates a structured time-discretization of an otherwise continuous physical process.
       A key consequence of this approach is the presence of short-term transient inconsistencies during state transitions. These effects arise from the non-instantaneous activation of control actions and the discrete timing of optimization updates. Once the system stabilizes after an event, material balance is fully restored at all levels of the model.
       Tank farms play a central role in this dynamic behavior by absorbing flow fluctuations and decoupling process units from immediate upstream and downstream disturbances. This buffering effect ensures numerical stability and allows the simulation to maintain realistic temporal evolution of material flows across the refinery network.

Tank Farms as Dynamic Balance Buffers

       Reservoir Parks (Tank Farms) act as dynamic buffering elements in refinery digital twins, decoupling production from consumption while maintaining strict local material balance constraints.
       Each tank farm consists of multiple storage units operating within defined capacity limits, including minimum and maximum fill levels. Incoming flows are distributed across available tanks, while outgoing flows are coordinated through shared dispatch logic. Unlike process units, tank farms do not transform material but regulate its temporal distribution. This introduces controlled delay between inflow and outflow, allowing short-term imbalances between production and demand to be absorbed without violating conservation rules.
       In Petroleum Refining Library, tank farms may function as passive storage buffers or as active coordination nodes for blending and shipment preparation. Regardless of their role, all reservoirs strictly preserve local mass consistency.
This buffering behavior is essential for stabilizing refinery-wide dynamics under changing operating conditions and ensuring feasible execution of production plans generated by optimization systems.

Process Units (Plants) and Deterministic Flow Transformation

       Process Units (Plants) represent the core transformation layer of refinery digital twins, where incoming oil and gas streams are converted into multiple output products according to deterministic operating logic.
       Each unit operates as a structured system of parallel processing lines, where incoming flows are distributed based on active operating modes. The transformation defined by "recipe-based yield structures" that determine how input streams are split into outputs, internal consumption, and losses. These recipes are derived from statistical data, operational history, and process engineering models, and may vary depending on feedstock composition, operating conditions, and seasonal factors. Despite the complexity of physical refining processes, Process Units in Petroleum Refining Library remain fully deterministic at the simulation level. Given identical inputs and operating states, they always produce the same output distribution, ensuring reproducibility and stability of the digital twin.
       Local material balance is strictly preserved within each unit by accounting for all incoming and outgoing flows, including own consumption and unit-specific losses. This guarantees that transformation processes remain physically consistent even under changing operating modes and dynamic system conditions.
       At the system level, Process Units serve as primary conversion nodes that define how raw and intermediate materials are progressively refined into final products across the refinery network.

Network-Level Material Balance

       At the highest level of abstraction, refinery digital twins operate as an integrated material flow network, where Sources, Process Units (Plants), Reservoir Parks, and other functional elements are connected through direct flow relationships.
In Petroleum Refining Library, physical transport infrastructure such as pipelines is not modeled as a separate entity. Instead, flow transfer is represented as instantaneous exchange between system nodes, while temporal behavior is handled by the simulation engine. This abstraction allows the model to focus on mass conservation and operational constraints without introducing unnecessary structural complexity.
       Global material balance in the refinery emerges from the interaction of all local elements. Each node enforces its own conservation rules, and the aggregation of these local balances ensures system-wide consistency. As a result, the digital twin does not rely on a single global constraint equation but instead achieves coherence through distributed enforcement across the network.
This structure is particularly important in dynamic environments, where production plans, optimization outputs, and operational conditions change continuously. The network-level formulation ensures that oil and gas flow is neither created nor lost at the system scale, while still allowing flexible redistribution across the refinery. Thus, the refinery digital twin can be interpreted as a physically consistent flow network in which global balance is an emergent property of locally constrained interactions.

Hybrid Consistency: Simulation and Optimization Coupling

       Material balance becomes most critical in hybrid refinery digital twins where optimization and simulation operate as tightly coupled layers of the same decision system.
       In Petroleum Refining Library, optimization models (primarily linear programming) generate target flow allocations across Sources, Process Units, and Reservoir Parks. These targets define an ideal operating plan that satisfies capacity constraints, production goals, and blending requirements under a simplified mathematical representation of the refinery.
The simulation layer is responsible for executing these plans under physically consistent conditions. It continuously enforces material balance at every node while propagating flows through a dynamic, event-driven system. When optimized targets cannot be fully realized due to local constraints—such as storage saturation, unit availability, or transient system states—the simulation adjusts actual flows while preserving local conservation rules.
       This creates a clear separation of responsibilities: optimization defines the desired system state, while simulation determines the feasible physical realization of that state. Material balance acts as the coupling mechanism between these layers, ensuring that any deviation between planned and executed behavior remains physically consistent and traceable.
As a result, the digital twin operates as a closed-loop system in which optimization proposes, simulation validates, and material balance guarantees coherence between planning and real system dynamics.

Atomic Delay and Transient Flow Imbalance

       In refinery digital twins, material balance remains structurally preserved, but transient deviations may emerge during state transitions due to the timing of control execution. This phenomenon is referred to as atomic delay in control activation.
Within Petroleum Refining Library, operational changes—such as switching process unit modes, activating routing decisions, or applying optimization outputs—are executed as discrete events inside a continuous-flow simulation. Although conservation rules are strictly enforced at each node, the application of new control states is not instantaneous.
       During the short interval between event triggering and full propagation of updated flow configurations, parts of the system may still operate under previous control logic while new decisions are already partially active. This overlap produces a temporary mismatch between intended and realized flow distributions, which appears as a short-lived imbalance.
       Crucially, this effect does not violate material conservation. It is a direct consequence of event-driven synchronization in a discretized execution environment. Once the system completes the transition and reaches a stable configuration, local material balance is fully restored across all elements of the model.
       In hybrid simulation–optimization systems, where control updates may occur frequently, these transient effects become more visible, but they remain bounded and systematically resolved within the simulation cycle.

Why Material Balance Defines the Feasible State Space

       In refinery digital twins, material balance is not only a conservation rule but also the primary constraint that defines the feasible state space of the entire system. Every valid simulation state must satisfy local balance conditions across Sources, Process Units, and Reservoir Parks, ensuring that all material flows remain physically consistent.
       Unlike optimization models, which define feasibility through mathematical constraints in an abstract variable space, Petroleum Refining Library enforces feasibility through explicit physical behavior of the system itself. Each node is required to maintain internal consistency at every simulation step, and the global system state is valid only if all local balances are simultaneously satisfied.
       As a result, material balance becomes the governing layer that separates feasible operational states from purely mathematical solutions. It ensures that the digital twin does not operate in an abstract solution space, but remains grounded in physically executable refinery behavior.

Conclusion: Material Balance as the Core Consistency Layer

       Material balance is the fundamental consistency mechanism of refinery digital twins, ensuring physically valid behavior of material flows across Sources, Process Units (Plants), Reservoir Parks, and the full refinery network.
       In Petroleum Refining Library, material balance is implemented as a distributed system property, not a centralized constraint. Each operational element enforces its own local conservation logic, while global consistency emerges from the interaction and aggregation of these local balances. This hierarchical formulation allows the digital twin to remain both physically interpretable and scalable across large refinery networks.
       The hybrid nature of the system—combining continuous flow representation with event-driven execution—introduces transient effects during state transitions. These effects are not violations of conservation laws but a natural consequence of asynchronous control activation and discretized update cycles.
       By coupling strict local balance enforcement with simulation–optimization integration, Petroleum Refining Library ensures that all operational decisions remain physically executable. Within this framework, material balance defines the feasible state space of the refinery digital twin and acts as the foundational layer connecting physical behavior, dynamic simulation, and optimization-driven planning into a single coherent system.

FAQ

1 What is material balance in a refinery digital twin?
Material balance is the core consistency mechanism that ensures all material flows in the digital twin are physically conserved across Sources, Process Units, Reservoir Parks, and the overall refinery network.

2 How is material balance implemented in Petroleum Refining Library?
In Petroleum Refining Library, material balance is implemented locally at each operational element. Every Source, Process Unit, and Reservoir Park maintains its own conservation logic, while global consistency emerges from aggregation across the system. Material balance is enforced locally. There is no single global balancing equation applied to the entire refinery. Instead, system-wide consistency is the result of all local balances working together.

3 What equation is used for material balance in Petroleum Refining Library?
Each node follows a conservation structure that accounts for incoming flows, outgoing flows, storage changes, losses, and internal consumption. Additional terms may apply depending on the element type (e.g., reservoir evaporation, gas consumption in units).

4 How does Petroleum Refining Library handle losses in material balance?
Losses are modeled as both fixed and process-dependent components. They may vary by unit type, operating mode, or storage behavior and are applied directly within the local balance of each element.

5 What is the role of tank farms in material balance?
Tank farms act as dynamic buffers that regulate temporal differences between inflow and outflow. They ensure stability of the system by absorbing fluctuations while maintaining strict local conservation constraints.

6 Can material balance be violated in the simulation?
No. Material balance is strictly preserved at the model level. However, short-term transient effects may appear during event transitions due to asynchronous control activation, which are resolved within the simulation cycle.

7 Why do transient imbalances appear in the model?
They occur due to atomic delay in control activation. Flow updates in an event-driven system are not instantaneous, which can create short-lived mismatches between planned and actual flows.

8 How does optimization interact with material balance?
Optimization generates target flow distributions, while simulation enforces physical feasibility. Material balance acts as the coupling layer ensuring that optimized decisions remain executable within the physical constraints of the system.

9 What defines the feasible state space of the refinery digital twin?
The feasible state space is defined by material balance constraints at all local elements. Any system state that violates local conservation rules is considered physically infeasible.

10 Why is material balance important for digital twins?
It ensures that simulation results remain physically meaningful, allows reliable execution of optimization outputs, and guarantees consistency between planning models and real refinery behavior.