An AnyLogic refinery simulation can run successfully while valuable intermediate products are diverted into residual flows because of downstream capacity constraints. This article explains how the
FlowDiscrepancy component in
Petroleum Refining Library (PRL) 2.2.5 supports dynamic flow monitoring using custom Java classes and message storage. These streams are transferred to
tank farms, routed to
product mixers for blending, stored in product tanks, and eventually shipped to customers through
loading racks. However, downstream components cannot always accept the incoming flow. A tank farm may have insufficient available capacity, a product mixer may reach its maximum throughput, or equipment may become temporarily unavailable because of
maintenance or other operational restrictions. Imbalances between
production and shipment plans can create similar situations. When these constraints are correctly represented in the simulation model, an affected stream may be redirected into a residual flow. This mechanism preserves the model's operational constraints and allows the simulation to continue without requiring upstream process units to discharge material into unavailable or capacity-constrained destinations. From a simulation-engineering perspective, the model may behave exactly as intended. From a production and economic perspective, however, the result may be undesirable. The problem becomes particularly significant when the diverted stream contains a valuable intermediate product that has already passed through several processing, separation, or purification stages. Instead of reaching its intended destination for further processing or blending, the material accumulates in a residual flow, potentially reducing the economic value of the production process.