Fuel Blending Properties in ProductMixer: Stream and Final Product Characteristics

Problem Statement

       This article presents the mathematical formulation of an automatic product blending optimization algorithm for petroleum refineries. Refinery product blending is a fundamental optimization problem in petroleum refining. Multiple blending components with different flow rates and quality properties must be combined to produce a final product that satisfies all specification limits while achieving a defined optimization objective.
       The ProductMixer component formulates this task as a linear programming (LP) problem. Instead of relying on predefined blend recipes, it automatically generates a linear programming model (LP model) from the current process conditions, available component flows, and fuel quality specifications. A linear programming (LP) solver then determines the optimal allocation of each incoming stream. By changing only the objective function while keeping the same system of constraints, the algorithm supports different optimization strategies, including maximizing product yield, minimizing additive consumption, minimizing residual streams, and meeting fuel quality specifications. ProductMixer acts as a blending optimization engine inside the refinery digital twin.

Mathematical Model Structure

       For each blending component, the algorithm automatically creates a set of decision variables representing possible material allocation within the blend blending model. The correspondence between the mathematical notation and the Java implementation is provided in Appendix A. Java LP Variable Groups.

       Component Flow Variables
       For every available component i, the following variables are introduced:
        - available mass flow of the component.
        - mass flow directed to the final product.
        - mass flow directed to a residual stream.
        - volumetric contribution of the component to the final product.
The optimization determines the values of Pi​ and Ri​, while the available flow Mi​ is provided by the simulation model.

       Aggregated Variables
       To simplify the mathematical formulation, ProductMixer also introduces aggregated variables:
        - total product mass flow;
       ​ - total residual mass flow;
       ​ - total product volume;
       ​ and — residual flows assigned to different outlet groups when multiple residual destinations are available.
These variables are calculated automatically from the individual component flows and are used to formulate global material balance equations and product blending constraints.

       Auxiliary Variables
       Additional auxiliary variables are generated to represent product properties and optimization penalties:
       ​- calculated value of the j-th quality property;
        - penalty variable associated with the corresponding quality constraint;
       ​ - global penalty variable used to limit the overall deviation from product specifications.
The generated variables form the basis of the linear programming model and are subsequently connected through material balance equations, quality constraints, and the selected objective function.

Material Balance Equations

       The first group of constraints ensures mass conservation for every blending component. Each incoming stream can only be divided into two destinations: the final product or a residual stream.
       For every component iii, the following material balance equation is generated:

       where:
        is the available mass flow;
        is the mass flow directed to the final product;
       ​ is the mass flow directed to the residual stream.

       The total product flow is calculated as the sum of all product contributions:

       Similarly, the total residual flow is

       If multiple residual destinations are available, ProductMixer automatically creates independent balance equations for each residual group. To evaluate volumetric product specifications, the algorithm also converts mass flows into volumetric contributions using component densities:

where is the density of component iii.

       The total product volume is then computed as


       These equations form the structural foundation of the blending model. Every feasible solution produced by the LP solver automatically satisfies the conservation of mass before product blending constraints are evaluated.

Product Quality Constraints

       Product quality constraints ensure that the blended product satisfies all required specification limits. Unlike material balance equations, which describe physical conservation, these constraints define the acceptable operating region of the optimization problem. For each quality property j the ProductMixer blend optimization algorithm automatically generates a linear constraint based on the properties of the available blending components (blend components). The value of the blended property is calculated as a weighted average of the blend component properties:

where:
       - calculated value of the jjj-th product quality property;
        - value of property jjj for component iii;
        - volumetric contribution of component iii;
        — total product volume.
       The calculated property must satisfy the corresponding product specification:

where ​ and ​ are the minimum and maximum allowable specification limits.

       Since the blending model is formulated as a linear programming problem, ProductMixer transforms these equations into an equivalent system of linear inequalities before passing them to the LP solver.

       For product properties that may temporarily violate their target values, the model automatically introduces non-negative penalty variables: .

       These variables quantify the deviation from the required specification and allow the optimization to continue even when a fully feasible solution does not exist.

       To evaluate the overall solution quality, the individual penalties are combined into a global penalty measure:

where ​ represents the priority assigned to the corresponding quality property.

       By generating all blending constraints automatically from the current product specification and the available component properties, ProductMixer can adapt the blending model to changing feedstock composition and product requirements without modifying the mathematical formulation.

Objective Functions

       The objective function defines the optimization strategy while the system of material balance equations and quality constraints remains unchanged. This separation allows the same mathematical model to be reused for different refinery operating scenarios by modifying only the optimization objective. Depending on the selected operating mode, the ProductMixer blend optimization algorithm automatically generates one of several objective functions.

       Maximum Product Recovery
       When the objective is to maximize production, the optimization maximizes the total amount of blended product:

where

       This objective is typically used when sufficient blending components are available and the primary goal is to maximize product yield while satisfying all quality specifications.


       Minimum Residual Production

       When minimizing valuable residual streams is the primary objective, the optimization minimizes the total residual flow:

where

       If multiple residual destinations exist, ProductMixer can assign different priorities to each residual group.


       Minimum Quality Deviation

       When product specifications cannot all be satisfied simultaneously, the optimization minimizes the total quality deviation represented by the penalty variables:

or, more generally, .

       This objective finds the solution with the smallest overall specification violation while preserving material balance and all technological constraints.


       Lexicographic Optimization

       In many refinery applications, multiple objectives must be optimized simultaneously. ProductMixer implements this using a weighted objective function that establishes a priority hierarchy between competing goals.

       A typical objective function is:

where
- high-priority residual flow;
- secondary residual flow;
— quality penalty variables;
— global quality penalty;
​ — optimization priorities.

       By selecting sufficiently different weight coefficients, the optimization behaves as a lexicographic solver, satisfying higher-priority objectives before considering lower-priority ones. This approach enables ProductMixer to solve a wide range of blend optimization problems using a single mathematical formulation while changing only the objective function according to the operational strategy.

Automatic LP Model Generation

       Unlike traditional blending systems that rely on manually prepared blending models, ProductMixer constructs the linear programming problem automatically during simulation. The generated LP problem is recreated whenever the simulation state changes.
       For every optimization cycle, the algorithm performs the following steps:
  1. Reads the available blending component flows from the simulation model.
  2. Retrieves the quality properties of every component.
  3. Loads the product quality specifications.
  4. Creates the required decision variables.
  5. Generates material balance equations.
  6. Generates product quality constraints.
  7. Selects the appropriate objective function.
  8. Solves the LP problem.
  9. Applies the calculated flow distribution to the simulation model.

       As a result, the blending model is regenerated every time the process conditions change. No manual reformulation of the mathematical model is required. The overall workflow can be represented as

       The generated LP model contains only linear equations and inequalities, allowing standard linear programming solvers to obtain an optimal solution efficiently even for large blending problems. Because the mathematical formulation is generated directly from the current simulation state, the optimization automatically adapts to:

        - changing feedstock availability;
        - varying component properties;
        - updated product specifications;
        - different optimization objectives;

        - changing process topology.

       This automatic model generation enables ProductMixer to operate as an optimization engine within a refinery digital twin, continuously recalculating optimal blending decisions as process conditions evolve.

Benefits of the Mathematical Formulation

       The proposed mathematical formulation provides a flexible and scalable framework for solving refinery blending problems. Because the blending model is generated automatically from the current simulation state, the same algorithm can be applied to different products, blending schemes, and operating conditions without modifying the mathematical structure.
       The approach offers several practical advantages:
       Automatic model generation eliminates the need to manually formulate linear programming problems for each blending scenario.
       Reusable mathematical formulation allows different optimization strategies to be implemented by changing only the objective function while preserving the same system of constraints.
       Guaranteed material balance ensures that every feasible solution satisfies conservation of mass.
       Automatic quality verification enforces all product specification limits during optimization.
       Scalability allows the model to handle arbitrary numbers of blending components, quality properties, and residual streams.
       Computational efficiency enables large optimization problems to be solved within seconds using standard LP solvers.
       Digital twin integration allows optimization to be executed continuously as operating conditions change, providing real-time support for refinery decision making.
       These characteristics make the proposed algorithm suitable not only for standalone blend optimization but also as a core component of refinery-wide simulation and digital twin platforms.

Conclusion

       Product blend optimization can be formulated as a linear programming problem that combines material balance equations, blending constraints, and configurable objective functions within a single mathematical framework. The algorithm can therefore be used as a general-purpose refinery optimization component.
       The ProductMixer component automatically generates this blending model from the current simulation state, allowing the blending strategy to adapt continuously to changing feedstock availability, product specifications, and process conditions. Because the mathematical formulation remains unchanged while only the objective function is modified, the same optimization engine supports multiple refinery operating strategies without requiring manual model redesign. The presented formulation provides a practical foundation for implementing scalable, real-time refinery product blend optimization in refinery simulation and digital twin applications.

FAQ

1. What is product blend optimization?
Product blend optimization is the process of determining the optimal proportions of multiple blending components to produce a final product that satisfies all quality specifications while achieving a selected operational objective, such as maximizing production or minimizing additive consumption.

2. Why is linear programming used for product blending?
Most refinery blending problems can be formulated using linear material balance equations and linear quality constraints. This allows efficient optimization with standard linear programming (LP) solvers, even for large-scale blending systems.

3. What is optimized by the ProductMixer algorithm?
Depending on the selected operating mode, ProductMixer can maximize product recovery, minimize residual streams, minimize additive consumption, reduce quality deviations, or optimize several objectives simultaneously using weighted priorities.

4. How are product quality specifications enforced?
The algorithm automatically generates quality constraints from the current product specification and component properties. Every feasible LP solution must satisfy these constraints or, when allowed, minimize the corresponding penalty variables.

5. Does the mathematical model change for different optimization tasks?
No. The system of decision variables, material balance equations, and blending constraints remains the same. Only the objective function changes, allowing the same mathematical formulation to support multiple optimization strategies.

6. Can the algorithm handle changing feedstock properties?
Yes. The LP model is generated automatically from the current simulation state. Changes in available components, flow rates, densities, or quality properties are incorporated into the blending model without manual reconfiguration.

7. Can multiple residual streams be optimized?
Yes. ProductMixer supports multiple residual destinations with different optimization priorities, allowing valuable intermediate streams to be recovered before lower-priority residuals.

8. How does ProductMixer integrate with a refinery digital twin?
ProductMixer operates as an embedded optimization engine within the simulation model. It continuously regenerates and solves the LP problem as operating conditions change, enabling real-time blend optimization and decision support.

9. Why does ProductMixer generate the LP model automatically instead of using predefined equations?
Traditional blending systems often require engineers to manually create or modify blending models. ProductMixer automatically generates the LP model from the current simulation state, allowing the optimization to adapt to changing feedstock availability, product specifications, and process topology without manual reformulation.

10. Can the same algorithm optimize gasoline, diesel, and other refinery products?
Yes. The mathematical formulation is independent of the specific product being blended. Any refinery product can be optimized provided that the required component properties and product specifications are available.

Appendix A. Java LP Variable Groups

       The ProductMixer implementation automatically generates the linear programming model using a set of internal variable groups. The following table shows the correspondence between the mathematical notation used in this article and the variable groups generated by the Java implementation.
Notes
       1. The Java variable names are internal implementation details and are not intended to represent the mathematical formulation directly.
       2. During model generation, ProductMixer creates LP variables from these groups automatically according to the current blending configuration.
       3. The mathematical notation used throughout this article is intentionally independent of the implementation, allowing the same formulation to be understood without reference to the source code.