Product Mixer Automatic Blending Algorithm

Why Automatic Product Blending Is Needed

       The Product Mixer component in the Anylogic-based Petroleum Refining Library automatically blends multiple intermediate streams into a single finished product using an automatic product blending algorithm for petroleum refining and refinery simulation. See the ProductMixer refinery simulation example to explore how the algorithm responds to changing stream conditions and product specifications. During each calculation, every incoming stream is divided into two parts: an accepted portion that participates in blending and a rejected portion that leaves the Product Mixer through dedicated residual outlets for further processing elsewhere in the refinery. Whenever operating conditions change, the automatic product blending algorithm recalculates these proportions without user intervention. This enables the refinery digital twin to continuously adapt to changing process conditions while supporting refinery optimization, production optimization, and fuel quality requirements. This article explains how the automatic blending algorithm operates. The mathematical formulation of the optimization model—including the objective functions, constraints, and LP formulation—is presented in the companion article Product Mixer Mathematical Model. Learn how ProductMixer Performance Metrics evaluate the results of Automatic Product Blending. For information about runtime configuration, recalculation control, and the ProductMixer API, see ProductMixer Control in Refinery Simulation.
       It should be noted that the ProductMixer can also operate in manual mode, where blend ratios are specified by the user rather than calculated automatically.
       Start with the ProductMixer Complete Guide before exploring the automatic blending algorithm

When Automatic Recalculation Is Triggered

       The Product Mixer continuously monitors conditions that may affect the optimal blend composition. Whenever one of these conditions changes, the component automatically starts a new optimization cycle to recalculate the accepted and rejected portions of all incoming streams. Streams are rejected whenever including them would violate one or more product quality constraints or reduce the selected optimization objective.
       Automatic recalculation is triggered when:
  • the flow rate of any incoming stream changes;
  • the product specification changes, for example due to seasonal fuel requirements;
  • the user manually requests a new calculation.
Learn how ProductMixer Performance Metrics are updated after each automatic recalculation.
       Each optimization cycle is performed independently using the current process conditions and the latest product quality specifications loaded from the database. As a result, the Product Mixer always operates with an up-to-date blending solution without requiring manual adjustment.

Optimization Objectives

       The Product Mixer supports two optimization objectives that can be selected by the user during model configuration. The selected objective determines how the embedded optimization algorithm evaluates alternative blending solutions. Internally, the Product Mixer formulates and solves a linear programming optimization problem for fuel blending optimization. The mathematical formulation is intentionally omitted from this article and is discussed separately. The optimization objective can also be switched dynamically during simulation runtime, enabling the Product Mixer to adapt its blending strategy to changing operational requirements.

       Production Maximization
       This mode is typically used while the production plan has not yet been fulfilled. The algorithm seeks to maximize finished product recovery by minimizing rejected streams while satisfying refinery blending constraints. Incoming streams can also be assigned different priorities, allowing the optimizer to preferentially utilize more valuable or strategically important components.

       Additive Minimization
       Once the production target has been achieved, the optimization objective can be switched to minimizing the consumption of the balancing additive. In this mode, the Product Mixer continues producing the finished product while reducing the use of this expensive component, helping lower operating costs without violating product quality specifications.

       The complete mathematical formulation of the automatic LP model generation process is described in Linear Programming Algorithm for Automatic Product Blend Optimization.

Product Quality Constraints

       Before solving the optimization problem, the Product Mixer retrieves both the required product specifications and the quality properties of every incoming stream. These data define the optimization constraints. The required specifications include octane number, vapor pressure, benzene content, aromatic hydrocarbons, and other quality parameters. At the same time, the algorithm retrieves the corresponding properties of every incoming stream. Using this information, it evaluates whether a feasible fuel blend can be produced while satisfying all quality requirements.
       Since different quality properties use different blending bases, the Product Mixer also retrieves the corresponding basis for each specification from the database. For example, octane number is evaluated on a mass basis, whereas aromatic hydrocarbon content is evaluated on a volumetric basis. This ensures that each optimization constraint is formulated using the correct measurement basis.
       The Product Mixer can also account for nonlinear blending effects when required. While the optimization problem is formulated as a linear programming model, nonlinear blending behavior may be approximated by introducing additional intermediate blending stages or by using historical stream participation statistics derived from previous blending operations. This allows the model to better reflect real refinery blending behavior without sacrificing the efficiency of linear optimization.

Accepted and Rejected Streams

       Unlike conventional blending systems, the Product Mixer does not simply combine all incoming streams into a finished product. Instead, during each optimization cycle, the automatic blending algorithm determines what portion of every incoming stream should participate in the blend and what portion should be excluded. The accepted portions are combined to produce the final fuel blend, while rejected portions remain available for further refinery processing. At the same time, the rejected portions leave the Product Mixer through dedicated residual outlets, with one rejected stream corresponding to each incoming stream. These residual streams remain available for further processing elsewhere in the refinery model, allowing valuable intermediate products to be reused instead of discarded. This mechanism enables the Product Mixer to maximize product recovery while maintaining product quality specifications and preserving the flexibility of the refinery flowsheet.

How the Two-Step Optimization Algorithm Works

       The automatic blending algorithm operates in two stages.
       During the first stage, the Product Mixer formulates and solves a blending optimization problem that determines the accepted portion of each incoming stream. The objective is to satisfy all product quality specifications while maximizing product output or minimizing additive consumption, depending on the selected optimization mode.
       If a feasible solution is found but one or more quality specifications cannot be fully satisfied without additional blending material, the algorithm proceeds to the second stage. At this stage, the required amount of the balancing additive (for example, Methyl tert-Butyl Ether - MTBE) is calculated and added to the blend.
       If the required additive amount remains within the allowable limit, the blend is considered valid and production continues. Otherwise, the optimization is considered infeasible, no finished product is produced, and all incoming streams are directed to the rejected residual streams for further processing elsewhere in the refinery. The execution of the two-stage blending algorithm can be monitored and controlled through the ProductMixer runtime API. See ProductMixer Control in Refinery Simulation for details.

Worked Example: Blend Property Calculation

       Consider a simple blending scenario where a single feed Stream1, enters the ProductMixer at a flow rate much higher than the mixer capacity. The stream has an octane number of 85. The maximum throughput of the ProductMixer is 100 t/h. The blended product has only one quality requirement: the octane number must be at least 90.0. To satisfy this specification, the mixer can add an additive stream M1 with an octane number of 99.

       In this case, the optimization algorithm determines the required flow rates as follows:
       Stream S1: 85.86 t/h
       Additive M1: 14.14 t/h
The total blended flow is therefore exactly 100 t/h, which matches the maximum capacity of the ProductMixer. The resulting octane number is calculated as the mass-weighted average of the component properties:

This simple example illustrates the fundamental principle used by the blending algorithm: selecting stream flow rates so that all product quality constraints are met while maximizing the specified optimization objective.

Benefits of Automatic Blending

       The automatic blending algorithm continuously adapts the blend composition to changing refinery operating conditions without requiring manual intervention. This provides several operational benefits:
       - automatically adapts to changes in feedstock availability and refinery operating conditions;
       - maximizes finished product recovery by minimizing rejected stream portions;
       - minimizes the consumption of balancing additives when this optimization objective is selected;
       - ensures compliance with fuel quality specifications and refinery product quality requirements;
       - automatically recalculates the optimal blend when process conditions or quality requirements change;
       - redirects rejected stream portions to downstream refinery units for further processing.

Conclusion

       The Product Mixer automatically determines the optimal proportion of each incoming stream, ensuring that finished products meet quality specifications while achieving the selected optimization objective. By combining embedded linear optimization with refinery-specific blending logic, the component continuously adapts to changing operating conditions and supports efficient petroleum refining, refinery optimization, and digital twin operation. This article focused on the operational workflow of the automatic blending algorithm. The mathematical formulation of the optimization model, including the objective functions, constraints, and linear programming implementation, is described in a separate article. Together with the mathematical optimization model, the Product Mixer provides a practical implementation of automatic refinery blending suitable for both refinery digital twins and production planning models.

FAQ

1. What does the Product Mixer optimize during automatic product blending?
The Product Mixer automatically determines the accepted portion of every incoming stream to produce a finished product that satisfies all quality specifications while achieving the selected optimization objective.

2. When is the blending algorithm recalculated?
The optimization is automatically triggered whenever an incoming flow changes, product specifications are updated (for example, due to seasonal fuel requirements), or the user manually starts a new calculation.

3. Can the Product Mixer maximize production?
Yes. In Production Maximization mode, the algorithm minimizes rejected streams to maximize the amount of finished product while satisfying all quality constraints.

4. Can the Product Mixer reduce additive consumption?
Yes. In Additive Minimization mode, the algorithm minimizes the use of the balancing additive while continuing to produce fuel that meets the required quality specifications.

5. What happens if no feasible blend exists?
If the required product quality cannot be achieved within the allowable balancing additive limits, the optimization is considered infeasible. In this case, no finished product is produced, and all incoming streams are directed to the residual outlets.

6. Does the Product Mixer account for fuel quality specifications?
Yes. During every optimization cycle, the Product Mixer loads the latest product quality specifications and evaluates properties such as octane number, vapor pressure, benzene content, aromatic hydrocarbons, and other blending constraints.

7. Where is the mathematical formulation of the Product Mixer optimization described?
This article explains the operational workflow of the automatic blending algorithm. The mathematical model, objective functions, constraints, and linear programming formulation are covered in a separate article.

8. How many products can a Product Mixer produce?
A Product Mixer always produces exactly one finished product. Multiple products require multiple Product Mixer components.