Petroleum Refining Library Overview

       Oil and gas processing facilities are complex systems involving feedstock reception, processing, storage, and product shipment. In the era of digital transformation, digital twins and simulation modeling have become powerful tools for supporting operational and planning decisions in the oil and gas industry.

Petroleum Refining Library (PRL)

is a process simulator for AnyLogic focused on operational and production management

Refinery Simulation and Digital Twin Architecture

       Modern refinery simulation requires more than standalone process models. A comprehensive refinery digital twin integrates process units, tank farms, pipelines, utilities, production planning, logistics, blending and separation nodes, loading racks, flow routing and switching nodes, product dispatch facilities, and numerous other components of refinery production infrastructure into a unified simulation environment. The Petroleum Refining Library is designed precisely for this purpose. The Source component provides the upstream feedstock supply layer, connecting production planning with continuous refinery flows. See Source in Refinery Simulation: Complete Guide for a complete overview. Built on the AnyLogic simulation platform, it provides a comprehensive set of domain-specific components for modeling process units, tank farms, pipelines, blending and separation nodes, loading racks, flow routing systems, utilities, production planning, logistics, and other elements of refinery infrastructure. By combining these components within a single modeling framework, engineers can rapidly develop comprehensive refinery digital twins while retaining the flexibility to adapt each model to project-specific requirements.
        The Petroleum Refining Library provides a comprehensive framework for building refinery digital twins and supporting a wide range of operational management and production planning tasks:
  1. Feedstock distribution. The library supports the modeling of crude oil, natural gas, condensate, and other feedstock flows with flow smoothing. It enables engineers to analyze different routing strategies and distribute feedstocks between primary processing units while considering capacity limitations and operating constraints. Learn more about crude oil supply chain simulation and refinery feedstock transportation from production fields to processing units.
  2. Production planning. Efficient production planning depends on reliable feedstock allocation across multiple process units and storage facilities. Simulation makes it possible to evaluate different production schedules, analyze the impact of changing feedstock availability, and optimize material flows throughout the refinery. This helps improve resource utilization while maintaining production targets and operational flexibility. Petroleum Refining Library coordinates refinery operations through a request-based production planning mechanism that synchronizes process units, storage systems, and logistics operations.
  3. Process unit management. The library enables detailed simulation of processing units and their operating modes. Engineers can model equipment performance, switching between technological schemes, maintenance activities, and interactions between interconnected units. As a process simulator, Petroleum Refining Library helps evaluate the impact of operational decisions before implementing them in real facilities.
  4. Tank farm simulation and control. Is an essential part of refinery logistics because storage systems connect production units with transportation and product distribution. Accurate modeling of flow dynamics, filling and shipment operations, planning modes, blending, additives, and storage constraints allows engineers to evaluate flow dynamics, improve product availability, and optimize refinery logistics under changing operating conditions for each tank. Learn more about refinery tank farm simulation, including accumulative tank farms, shipment planning, tank repairs, passportization, and inventory management. Petroleum Refining Library implements a request-based control mechanism that synchronizes tank farms with process units and logistics operations, ensuring stable refinery performance under changing operating conditions. Learn how tank farms are controlled in refinery digital twins. Refinery simulation challenges caused by tank farms and storage constraints
  5. Dynamic tank reallocation. Allows refinery simulation models to temporarily assign idle tanks to storage areas with capacity shortages. By dynamically balancing storage resources, engineers can optimize tank utilization, maintain production continuity, and evaluate alternative operating scenarios within a refinery digital twin.
  6. Shipment planning. Petroleum Refining Libraryallows users to model product withdrawal requests and transportation operations. Various shipment priorities and loading strategies can be evaluated to ensure that contractual obligations and production targets are satisfied.
  7. Repair simulation. Petroleum Refining Library allows users to model scheduled maintenance and repair operations for storage tanks and processing units. The library supports both accumulative and flowing systems while preserving production plans, shipment schedules, and mass balance.
  8. Optimization schemes. The library provides mechanisms for integrating optimization algorithms with simulation models. Users can perform bottleneck analysis, evaluate alternative operating strategies, and improve facility performance using a process simulator integrated with advanced planning workflows. Learn how hybrid simulation and optimization are integrated in refinery digital twins.
  9. Operational Decision-Making in Oil and Gas Systems. Simulation becomes most valuable when it supports operational decision-making. Engineers can evaluate production scenarios, identify bottlenecks, optimize storage utilization, and compare alternative operating strategies before implementing them in real facilities. This enables more informed decisions for refinery operations, maintenance planning, and logistics management while reducing operational risks.
       Product blending is one of the key operational functions within this architecture. The ProductMixer simulation for refinery digital twins demonstrates how blending optimization can be integrated into an AnyLogic-based refinery model.
       Combined with external databases and enterprise information systems, these capabilities enable the development of realistic digital twins that support oil and condensate deliveries, production planning, storage management, shipment scheduling, process optimization, and scenario analysis. As a result, Petroleum Refining Library helps engineers and decision-makers improve operational efficiency and make more effective strategic decisions.
       Petroleum Refining Library is fully integrated into the AnyLogic simulation environment and provides a comprehensive set of components for modeling oil and gas processing facilities, including process units, tank farms, sources, and blending and splitting nodes. Flexible settings and parameters allow engineers to accurately represent real-world assets.

Applications of Petroleum Refining Library

Refinery Production Planning
Process Unit Simulation
Tank Farm Optimization
Pipeline Simulation
Loading Rack Simulation
Product Dispatch Simulation
Supply Chain Simulation
Refinery Digital Twin Development

Why Use a Specialized Petroleum Refining Library?

       Although AnyLogic provides powerful general-purpose simulation capabilities, developing refinery models from scratch often requires significant engineering effort. A specialized Petroleum Refining Library provides reusable industry-specific components that accelerate model development, improve consistency, and simplify the implementation of complex refinery logic, including process units, tank farms, transportation systems, and production planning workflows.
       In addition, Petroleum Refining Library includes a large collection of reusable Java class templates that provide advanced modeling capabilities and significantly simplify the development, customization, and maintenance of large-scale AnyLogic models. These utilities cover many common tasks encountered in industrial simulation projects and allow engineers to focus on process logic instead of implementing supporting infrastructure from scratch.
  • Control and model management.The library contains classes for processing control requests and model commands. They support object identification, state management, serialization, and replay mechanisms, enabling the creation of controllable and reproducible digital twins.
  • Data export and reporting. Shared export utilities provide convenient mechanisms for collecting and writing structured simulation results to Excel and other external formats. This simplifies reporting and integration with corporate information systems.
  • Maintenance and repair scheduling. Specialized classes support equipment repair planning under operational constraints (for RpAccumulative and RpFlowing). They efficiently track maintenance intervals and dynamically apply schedule changes during simulation, making it possible to represent realistic maintenance strategies.
  • Statistical analysis tools. The library includes a wide range of statistical classes for collecting and processing information about material flows, equipment utilization, loading levels, inventories, and other performance indicators. These tools provide detailed insight into system behavior and simplify model analysis.
  • Centralized model constants. Configuration classes provide centralized access to model parameters and constants loaded from databases or external sources. This approach improves maintainability and facilitates scenario management.
  • Plant synchronization mechanisms. The library contains utilities for coordinating operating modes between interconnected facilities and process units. Such mechanisms are especially useful for building integrated supply chain and cluster-level models.
  • Extensible Java framework. Beyond these examples, the library contains numerous additional Java utilities and templates designed to accelerate the development of industrial-scale oil and gas models. These components provide a solid software foundation for creating flexible, maintainable, and highly customized digital twins in AnyLogic.
       As a result, Petroleum Refining Library not only provides domain-specific simulation blocks, but also delivers an extensive software framework that helps engineers develop sophisticated oil and gas models faster and with significantly less programming effort. The corresponding classification of refinery digital twin models explains how these simulation architectures are organized according to engineering objectives.
       Material balance is automatically enforced across all Petroleum Refining Library nodes, ensuring mass conservation both locally and at the global system level.
       Petroleum Refining Library is intended for engineers, researchers, and developers working on digital twins for oil and gas facilities. It is used by refineries, gas processing plants, universities, research organizations, and AnyLogic users developing advanced process and production models. With Petroleum Refining Library, engineers can concentrate on solving real industrial challenges instead of spending time building simulation infrastructure from the ground up.

       To demonstrate the capabilities of the library, let us consider a simplified gas condensate processing plant. A condensate stabilization unit operates in two modes — stabilization and deethanization — producing several products that are accumulated in dedicated tank farms before shipment. Regardless of the farm type, their operation relies on common tanks farm control principles. Because the LPG storage capacity is limited, the operating mode must periodically switch when storage is full or production targets are achieved. The model records product flows and enables engineers to evaluate production plans and analyze facility utilization. Let's do it with Petroleum Refining Library!
       The model of this gas condensate processing plant is implemented in AnyLogic using the Petroleum Refining Library.
Feed sources simulate unstable gas condensate inflow and support different planning modes. They are connected to the condensate stabilization plant, which flexibly defines product separation and output streams.
The stabilization unit is connected to tank farms, which provide flexible configuration of product withdrawal priorities. In this example, only Priority A is used, ensuring that tank farms are filled to meet the current month's shipment targets. The product dispatch nodes dynamically monitor plan execution and support different withdrawal strategies, including maximum-rate operation, uniform withdrawal, and daily scheduled withdrawal.
       After the simulation starts, the feed sources begin sending unstable gas condensate to the stabilization unit according to the specified production plan. The feed then enters the stabilization plant, which consists of two process lines. At the moment, one line is operating in stabilization mode, while the other is operating in deethanization mode. At certain periods, both lines switch to deethanization mode simultaneously, as shown now. This behavior is caused by the limited capacity of the NGL receiving tank farm, which periodically becomes completely full. When both tanks are filled and no additional NGL can be accepted, the plant automatically switches to deethanization mode. If we accelerate the simulation, we can see that as storage capacity becomes available again, one of the process lines returns to stabilization mode, while the other continues operating in deethanization mode.
In addition to the NGL tank farm, the model includes several other farms. However, due to their large capacities, they do not significantly affect the operation of the process unit. As time progresses, production targets for all product streams are successfully achieved. At the same time, the product dispatch nodes gradually approach one hundred percent completion of the scheduled shipment targets.
       This example demonstrates how the Petroleum Refining Library for AnyLogic can be used to model real-world oil refining and gas condensate processing facilities with a high level of detail.
You can also watch the full video on our YouTube channel.