Advanced Linear Optimization for Refinery Flow Allocation (part 3)

       When building optimization models for refinery digital twins, the problem often goes beyond simply splitting an incoming feed between parallel process lines, as described in Part 2. Real refinery systems introduce additional constraints, such as blending different feedstocks, downstream unit capacity limits, upstream tank farm capacity, and dependencies between interconnected process units. Such relationships require specialized equations and linear constraints in optimization that capture the physical and operational behavior of the refinery. This part focuses on these refinery-specific constraints and shows how they can be incorporated into linear optimization models for refinery digital twins and petroleum refining simulations.

1. Split Complex Flow Allocation into Sequential Optimization Steps

Problem
       Complex flow-allocation problems are often easier to solve by decomposing them into several sequential optimization problems. Consider a flowing tank farm supplying four condensate stabilization units (CSUs), with two parallel lines at each unit. Downstream, high-pressure vent gas, stabilized condensate and NGL are processed by separate units whose capacities are lower than the combined capacity of all eight CSU lines.
       Each CSU line can operate in three modes (the product slate remains the same, while product yields, flow destinations, and routing change):
       1. Normal mode — produces high-pressure vent gas, on-spec stabilized condensate, and NGL, which are routed to their respective downstream processing units.
       2. Stabilized-condensate-only mode — produces high-pressure vent gas and on-spec stabilized condensate, with the stabilized condensate routed through a pipeline to its downstream processing unit, while NGL is sent through a separate pipeline for processing at another refinery.
       3. Transition mode — produces high-pressure vent gas, stabilized condensate, and off-spec NGL. Neither the stabilized condensate nor NGL is sent to the downstream processing units; both are sent through a pipeline for processing at another refinery.
       The optimization must determine how to allocate the incoming flow between CSU lines and which operating mode to assign to each line, while respecting downstream capacities and the available capacity of the upstream tank farm.

Solution
       Instead of solving all these decisions in a single optimization problem, decompose the task into three sequential steps:
  1. Normal operation. Determine the maximum number of CSU lines that can operate in normal mode and optimize their loading within the downstream capacity limits.
  2. Transition mode. If feed remains after Step 1, select an available CSU line and switch it to transition mode.
  3. Tank farm unloading. If flow still remains, distribute the remaining flow among available CSU lines to maximize the unloading rate of the tank farm.
       This decomposition reduces the complexity of the optimization model by separating product-quality constraints, downstream capacity limits, operating modes, and tank farm unloading into manageable subproblems. In this formulation, Steps 1 and 3 are optimization problems, while Step 2 is a discrete mode-selection decision.

Conclusions

       This example demonstrates how linear programming can be integrated directly into refinery simulation to dynamically optimize feed flow allocation between parallel process lines. The optimization accounts for line operating limits, active and idle states, unaccepted flow, and operational priorities. The unaccepted flow can subsequently be routed through a bypass or to another destination in the simulation model.
       Although this formulation is relatively simple, it represents a typical flow allocation problem within a process unit. In practice, however, flow allocation can become considerably more complex, involving different feedstock compositions, interconnected process units, dependent operating constraints, and more complex flow-routing schemes. These cases will be addressed in the third part of this series.

FAQ

1. What is the purpose of linear programming in refinery flow allocation?
Linear programming is used to determine how an incoming feed flow should be optimally allocated between parallel process lines while satisfying their operating constraints and minimizing unaccepted flow.

2. Why is mixed-integer linear programming required?
Binary variables are needed to represent the operating state of each process line. A line can either remain idle or operate within its defined minimum and maximum throughput.

3. What constraints can be included in the optimization model?
The model can account for minimum and maximum line throughput, additional capacity limits, bypass flow constraints, line priorities, and operating states. It can also be extended to minimize the number of active lines.

4. What is unaccepted or residual flow?
Unaccepted flow is the portion of the incoming feed that cannot be processed by the available process lines under the current operating constraints and must therefore be diverted elsewhere.

5. When is the optimization problem solved in PRL?
The optimization can be triggered by a change in incoming flow, a change in the operating parameters of the process unit, or an explicit request from the user.

6. How is the optimization problem solved in Petroleum Refining Library?
PRL formulates the optimization problem and solves it using a built-in wrapper around the ojAlgo optimization solver.

7. What does the optimization return to the simulation model?
The solver returns the optimal flow assigned to each process line and the resulting unaccepted flow. These values are then applied directly to the simulation.

8. Can the optimization handle an arbitrary number of process lines?
Yes. The mathematical formulation can be generalized to (N) parallel process lines, with each line having its own operating limits, state variables, and priority parameters.

9. How does the optimization differ from a simple flow distribution rule?
Unlike a predefined distribution rule, the optimization evaluates the complete set of constraints and selects the best feasible combination of active lines and flow rates for the current operating conditions.

10. Can this approach be used in a refinery digital twin?
Yes. The combination of dynamic simulation and optimization is well suited to refinery digital twins, where the optimal operating decision may need to be recalculated as process conditions change.