Flow Smoothing in Digital Twin Simulation: Converting Production Plans into Continuous Flows

Why Flow Smoothing Is Required in Digital Twin Simulation

       Modern oil and gas Digital Twin models must represent not only production plans but also the continuous behavior of material flows over time. However, production data used for simulation is often provided as aggregated planning information, such as daily or monthly production volumes. For example, an oil and gas field may have the following monthly production plan:
        - January: 100,000 tons
        - February: 150,000 tons
       To use this data in a dynamic simulation model, monthly volumes must be converted into continuous flow rates (for example, tons per hour).        Such instantaneous changes rarely represent real production behavior. In actual oil and gas systems, production rates change gradually due to operational constraints, pipeline dynamics, equipment limitations, and production management practices.
In a Digital Twin, unrealistic flow changes can propagate through the entire supply chain.

       A sudden increase in feedstock flow may affect pipeline loading, tank farm residuals, and refinery feedstock availability, creating artificial bottlenecks or incorrect operational scenarios. Flow smoothing provides a mechanism to convert discrete production plans into realistic continuous flow profiles while preserving the original planned production volume. The objective is not to change the production plan, but to ensure that the transition between different planning periods is represented correctly in a dynamic simulation model.

Limitations of Direct Production Plan Conversion

       Converting a production plan into a constant flow rate is a straightforward mathematical operation, but it does not always provide a realistic representation of an operating system. A monthly production plan describes the expected accumulated volume over a period of time. It does not contain information about how quickly the production rate should change when moving from one planning period to another. When this data is directly converted into a dynamic simulation input, the model assumes an instantaneous change in operating conditions at the planning boundary. From a mathematical perspective, this approach is correct because the total monthly volume is preserved. However, from an operational perspective, it introduces an artificial discontinuity into the material flow.
       In real oil and gas production systems, changes in production rates are influenced by multiple factors:
        - production ramp-up and ramp-down limitations;
        - pipeline operating conditions;
        - equipment response time;
        - storage capacity availability;
        - coordination between upstream and downstream facilities.

       A Digital Twin must consider these dynamic effects because downstream assets respond not only to the total received volume but also to the expected incoming flow rate over time. This is especially important for tank farms and other storage systems. The operating logic of a storage system typically evaluates the expected incoming flow together with current residuals and available capacity to determine the required withdrawal rate. In other words, the model uses the predicted feedstock delivery profile to calculate how quickly material should be removed from the storage system to maintain a stable operating condition. If the incoming flow changes abruptly due to an unrealistic planning transition, the actual received flow can differ significantly from the value expected by the control logic. As a result, the calculated withdrawal strategy may no longer be valid. This can lead either to incorrect operational decisions or to artificial simulation events such as tank overfilling and false capacity limitations.
       Therefore, the challenge is not the conversion of production volumes into flow rates itself. The challenge is creating a continuous operational profile that:
        - follows the production plan;
        - preserves the total planned volume;
        - avoids unrealistic flow discontinuities;
        - provides physically meaningful input for downstream simulation objects.

Volume-Preserving Flow Smoothing Algorithm

       Flow smoothing in a Digital Twin should not be considered as a simple filtering operation that reduces fluctuations in a signal. Its purpose is different: it transforms discrete production planning data into a continuous operational flow while maintaining the original material balance. The main principle of the algorithm is that smoothing changes only the distribution of mass flow over time, but does not change the total planned production mass.
       For a given planning period:

Mplanned = Msimulated

when no external operational limitations are applied.
       The algorithm uses two main inputs:
        - the current actual mass flow rate at the end of the planning period;
        - the target mass flow rate defined by the next production plan.
       Instead of applying an instantaneous change at the month boundary, the transition is distributed over a predefined smoothing period.
       The transition is applied before the end of the current planning period rather than at the beginning of the next one. This approach ensures that the next period remains consistent with its original production plan.

       For example, if the next month production plan is reduced to zero, applying smoothing at the beginning of that month would introduce additional production mass and violate the planned target. By performing the transition at the end of the current month, the algorithm can redistribute the remaining mass flow while preserving the production plan.

       The algorithm therefore provides three important properties:

       Flow continuity — eliminates unrealistic instantaneous changes between planning periods;
       Mass balance preservation — maintains the original production target after smoothing;

       Operational consistency — creates realistic input data for downstream assets such as pipelines, tank farms, and refinery units.

Why Flow Smoothing Is Applied at the End of the Planning Period?

       A key design decision in the flow smoothing algorithm is the location of the transition period. The smoothing is applied at the end of the current planning period rather than at the beginning of the next one. This approach is required to preserve the production plan of the upcoming period. The production plan defines the total mass that should be delivered during each planning period, and the smoothing algorithm must not introduce additional production into the next period.
       Consider a case where the next month's production plan is significantly reduced or even equal to zero. If the smoothing transition starts at the beginning of the next month, the transition flow will contribute additional mass to that month before reaching the new target flow rate.
       This ensures that:
       - the next planning period starts with the correct target flow rate;
       - the total production mass of each period remains unchanged;
       - the transition does not create artificial production outside the planned period.

       This approach is especially important for Digital Twin models, where production plans are used together with downstream constraints such as tank farm capacity, pipeline limitations, and refinery processing requirements.

Maintaining Mass Balance During Flow Smoothing

Написать алгоритм

Transition from Actual Operating Conditions to Future Production Plans

       A key feature of the flow smoothing algorithm is that the transition does not start from the average flow rate calculated from the current monthly production plan. Instead, it starts from the current actual mass flow rate generated by the Digital Twin at the end of the planning period. This distinction is important because the current flow rate already reflects the actual operating state of the system, including previous planning transitions and operational constraints.
       A simplified approach would assume: Current month average flow → Smoothing transition → Next month planned flow
       However, this approach ignores the dynamic history of the system. The actual operating flow at the end of the month may differ from the monthly average because of:
  • previous flow transitions;
  • downstream equipment limitations;
  • pipeline restrictions;
  • storage system behavior.
       The PRL approach uses the actual simulated flow as the starting point:
Current actual mass flow rate (at the end of current period) → Linear smoothing transition → Next period target mass flow rate (from production plan).
       This ensures continuity of the Digital Twin state. The model does not restart the production system at each planning boundary; instead, it continues the existing operating trajectory and gradually moves toward the new planned condition.
       This approach is especially important when production plans change significantly between periods. The transition begins from the real current state of the system and not from an artificial average value, resulting in more realistic behavior of downstream assets such as pipelines, tank farms, and processing facilities.
       At the initial moment of a simulation, this transition is not applied because no previous operational state exists. The Digital Twin assumes that the modeled system was already operating before the simulation start and that the initial period continues from an existing production state rather than from zero flow.

Configuring Flow Smoothing Parameters

       The flow smoothing algorithm provides two main parameters that control how the transition between production periods is represented in the Digital Twin model:
       SMOOTHING_DURATION — defines the total time period over which the flow transition is performed;
       SMOOTHING_INTERVAL — defines the time step used to recalculate the intermediate flow values during the transition.
       These parameters control the temporal resolution and smoothness of the transition but do not affect the total planned production mass.

Smoothing duration

       SMOOTHING_DURATION determines how quickly the system moves from the current operating flow rate to the target flow rate of the next production period.
       The appropriate value depends on the required level of operational realism. In PRL, this parameter is configurable by the model user. For monthly production plans, a smoothing duration of approximately five days is recommended as a practical balance between preserving planning accuracy and avoiding unrealistic flow discontinuities.

Smoothing interval

       SMOOTHING_INTERVAL defines how frequently the transition flow rate is recalculated.
       For example: SMOOTHING_DURATION = 5 days, SMOOTHING_INTERVAL = 6 hours creates 5 × 24 / 6=20 calculation steps.

       A smaller interval provides a higher temporal resolution of the transition, while a larger interval creates fewer intermediate points. The interval affects the representation of the transition in the simulation model but does not change the final target flow rate or the preserved production mass. Together, these parameters allow engineers to adapt the Digital Twin behavior to the required simulation detail while maintaining the fundamental principles of the algorithm:
  • continuous flow transition;
  • preservation of planned production mass;
  • realistic interaction with downstream assets.

Impact of Flow Smoothing on Downstream Simulation Accuracy

Flow smoothing is not intended to replace physical constraints or operational control logic inside a Digital Twin. Its purpose is to provide realistic input data for downstream simulation objects by avoiding artificial changes in feedstock delivery rates.
This is especially important for tank farms, which operate as dynamic buffers between production sources and processing facilities. The storage behavior depends on the relationship between:
  • incoming mass flow rate;
  • current residuals;
  • available storage capacity;
  • required withdrawal rate.
Based on the expected incoming flow, the Digital Twin calculates the required withdrawal strategy to maintain stable operation. If the incoming flow profile is unrealistic, the calculated operating decisions may also become incorrect.
  • For example, without flow smoothing, a monthly production plan transition can create an artificial increase in incoming feedstock:
The tank farm model may interpret this as a real operational change and increase the required withdrawal rate. However, if the actual production system would increase its flow gradually, this decision is based on incorrect information.
Possible consequences include:
  • incorrect estimation of tank residuals;
  • unnecessary increase of withdrawal rates;
  • artificial tank filling scenarios;
  • false identification of capacity limitations.
  • With flow smoothing, the Digital Twin receives a continuous and realistic feedstock profile:
As a result, downstream objects can evaluate their operational behavior based on a more realistic representation of future incoming flows.
  • It is important to note that flow smoothing does not eliminate real operational limitations. If a pipeline, valve, tank farm, or processing unit cannot accept the calculated flow rate, the physical constraints of the Digital Twin model will still limit the actual flow. The smoothing algorithm only ensures that these constraints are evaluated using realistic input conditions.

Flow Smoothing Implementation in PRL Source Agent

In the Petroleum Refining Library (PRL), flow smoothing is implemented within the Source agent, which is responsible for converting production plans into continuous material flows for Digital Twin simulation.
The Source agent receives production plans defined over discrete planning periods, such as monthly production volumes. These plans are then transformed into continuous mass flow rates that can be used by downstream simulation objects.
The overall workflow is:
Production plan (monthly mass values) | v Source agent (plan conversion to mass flow rate) | v Flow smoothing algorithm | v Continuous feedstock flow | v Pipeline / Tank Farm / Refinery Units

The smoothing mechanism is applied when a transition between planning periods occurs. At this point, the Source agent already has the current actual mass flow rate generated by the simulation and uses it as the starting point for the transition.
The algorithm then:
  1. Calculates the target mass flow rate from the next production plan.
  2. Creates a linear transition between the current actual flow and the future planned flow.
  3. Applies the transition during the configured smoothing period.
  4. Adjusts the remaining part of the current planning period to preserve the total planned mass.
The main configurable parameters are:
  • SMOOTHING_DURATION — defines the duration of the transition period;
  • SMOOTHING_INTERVAL — defines the calculation step used during the transition.
The resulting flow profile remains continuous while maintaining the original production target:
Mplanned=MsimulatedM_{planned}=M_{simulated}Mplanned​=Msimulated​unless additional operational constraints are introduced by downstream equipment.
Because the Source agent operates within the AnyLogic simulation environment, further limitations are handled by the physical model itself. For example, valves, pipelines, tank farms, and processing units can restrict the actual accepted flow according to their capacity and operating conditions.
This separation of responsibilities allows the Digital Twin to combine:
  • realistic production plan conversion;
  • dynamic flow behavior;
  • physical equipment constraints.

Example: Monthly Production Plan Transition with Flow Smoothing

To illustrate the flow smoothing mechanism, consider a simplified production scenario where a source changes its monthly production target.
The production plans are:

Planning period

Production plan

January

10,000 tons

February

20,000 tons

Assume that the January production plan is converted into an average mass flow rate:
QJan=10,00031×24=13.44 t/hQ_{Jan}=\frac{10,000}{31 \times 24}=13.44 \ t/hQJan​=31×2410,000​=13.44 t/hFor February:
QFeb=20,00028×24=29.76 t/hQ_{Feb}=\frac{20,000}{28 \times 24}=29.76 \ t/hQFeb​=28×2420,000​=29.76 t/hWithout smoothing, the Digital Twin would apply an instantaneous change:
January: 13.44 t/h | | v February: 29.76 t/h

Such a step change does not represent a realistic production transition.
Applying flow smoothingAssume:
  • SMOOTHING_DURATION = 5 days
  • SMOOTHING_INTERVAL = 24 hours
At the end of January, the Digital Twin starts a transition from the current actual flow rate to the February target value.
For example:
Current actual flow: 13.44 t/h Next month target: 29.76 t/h

The transition is distributed over the final five days of January:

Day

Mass flow rate

Jan 26

13.44 t/h

Jan 27

16.70 t/h

Jan 28

19.96 t/h

Jan 29

23.22 t/h

Jan 30

26.49 t/h

Jan 31

29.76 t/h

However, this transition alone would increase the total January production mass because the final days contain a higher flow rate than the original monthly average.
To maintain the production target of 10,000 tons, the algorithm compensates for this additional transition mass by slightly reducing the flow rate during the non-transition part of January.
As a result:
  • the final days of January gradually approach the February operating condition;
  • the main part of January operates at a slightly lower flow rate;
  • the total January production remains exactly 10,000 tons.
The final profile becomes:
Normal January operation slightly reduced flow | | v Linear transition | | v February target flow

The important result is that flow smoothing changes only when the mass is delivered, not how much mass is delivered.
  • Therefore, the Digital Twin receives a realistic continuous production profile while maintaining the original production plan.

Conclusion: Why Flow Smoothing Is Essential for Oil and Gas Digital Twins

Production planning data and dynamic simulation models operate at different levels of detail. Production plans define target mass quantities over a specific period, while Digital Twins must reproduce the continuous behavior of material flows and equipment interactions over time.
Direct conversion of monthly production plans into constant flow rates can create unrealistic discontinuities at planning boundaries. These artificial changes may affect downstream simulation results, especially for tank farms and other storage systems that rely on predicted incoming flows to determine operational strategies.
The flow smoothing approach described in this article addresses this challenge by:
  • converting discrete production plans into continuous mass flow profiles;
  • preserving the original production mass balance;
  • maintaining continuity between consecutive planning periods;
  • using the actual current operating flow as the transition starting point;
  • providing realistic input conditions for pipelines, tank farms, and refinery units.
In a Digital Twin environment, accurate flow representation is essential because operational decisions depend not only on total production volumes but also on how these volumes are distributed over time.
  • By applying volume-preserving flow smoothing, oil and gas simulation models can better represent real production behavior, avoid artificial bottlenecks, and provide more reliable analysis of supply chains, storage systems, and refinery operations.