Source Control in Refinery Simulation: Runtime Flow Management and API

       Modern refinery simulation requires flexible control of feedstock flows during model execution. Source Control in Refinery Simulation provides runtime mechanisms for adjusting flow rates, applying speed limits, and responding to operating changes without modifying the simulation model. The Petroleum Refining Library (PRL) Source API supports both individual source element control and combined output control, allowing engineers to limit or restore flow rates, configure source connections, and respond to flow changes through event-driven callbacks.

Why Runtime Source Control Matters in Refinery Simulation

       Refinery operating conditions can change during simulation, requiring feedstock flow rates to be adjusted without modifying the model structure. Runtime Source Control provides this capability by allowing engineers to impose and remove flow limits while the simulation is running.
       The PRL Source API supports two control levels: individual Source elements and the combined Source output. This allows a specific feedstock stream to be restricted independently or a common limit to be applied to the total output.
Runtime control also supports event-driven model response. When a Source element changes speed, onSpeedChange() provides the updated flow rates with zero atomic delay, allowing downstream logic to respond immediately without periodic polling.
       This creates a simple operational control cycle:

Operating condition → flow limit → Source speed change → downstream response

       Runtime Source Control is therefore useful for refinery flow control, production planning, and digital twin scenarios where feedstock conditions may change during model execution.

Source Runtime Control API

       The Source runtime API provides flow control at both the individual source-element and combined-output levels. These methods allow engineers to set or restore speed limits, monitor current flow constraints, and configure connections between Source elements and external fluid flows.

Source Flow Connections

       The connect() method establishes Source output connections and is normally called once during model setup. It initializes the connections between Source elements and external fluid flows and validates the configured routing.
The connection can also be deferred until after model startup when delayed connection is enabled. This allows the Source to establish its output connections later in the simulation initialization sequence rather than immediately during model construction.
       The method supports two configurations:
  • Multiple output flows — each Source element is connected to the output corresponding to its product.
  • Single output flow — all Source element flows are merged into one combined output.
       In the standard connection mode, connect() cannot be called again after the Source has been initialized and its outputs have been defined.

Source Runtime Events and Callbacks

       Source event callbacks provide an event-driven interface for integrating Source behavior with custom simulation logic. They support initialization hooks and immediate response to source flow-rate changes.
       This event-driven approach eliminates periodic polling and is useful for synchronizing downstream logic with changing feedstock flows.

Conclusion

       Source Control in Refinery Simulation provides flexible runtime control of refinery feedstock flows. Engineers can set and monitor speed limits for individual source elements or a combined output, restore maximum flow capacity, and configure Source connections. Event callbacks such as onSpeedChange() provide an immediate response to flow-rate changes. Together, these capabilities make Source suitable for refinery flow control, production planning, and refinery digital twin applications.

FAQ

1. Can Source flow rates be changed during simulation?
Yes. The Source API allows flow-rate limits to be changed at runtime for individual source elements or for a combined Source output.

2. Can I control individual Source elements separately?
Yes. Use setElementSpeedLimit() with the corresponding sourceId.

3. Can I control the total Source flow?
Yes. setSpeedLimit() controls the total output rate when all Source flows are merged into a single output.

4. How can I restore the maximum flow rate?
Use resetElementSpeedLimit() for an individual source element or resetSpeedLimit() for a combined Source output.

5. Can Source notify the model when its flow rate changes?
Yes. The onSpeedChange() event provides updated speeds for the affected source elements with zero atomic delay.

6. Can Source outputs be connected after model construction?
Yes. The connect() method establishes the output connections and can be configured to defer connection until after startup.

7. What units are used for Source speed limits?
The public API specifies speed limits in tons per hour.