- 1Mechanical Engineering Department, Universidad Francisco de Paula Santander, Seccional Ocaña, Vía Acolsure, Sede el Algodonal Ocaña, Ocaña, Colombia
- 2Industrial Multiphase Flow Laboratory (LEMI), Mechanical Engineering Department, São Carlos School of Engineering (EESC), University of São Paulo (USP), São Carlos, Brazil
- 3Grupo Automatización y Control (A&C), Universidad de Pamplona, Pamplona, Colombia
The identification of flow patterns in multiphase systems is crucial in hydrocarbon production engineering, as they determine the behavior of crude oil transport through pipelines and flowlines in oil fields. Proper classification of these patterns contributes to improved hydraulic design, optimal selection of separation equipment, and effective field operation strategies. This study proposes a model based on a Transformer neural network for identifying flow patterns in two-phase liquid–liquid (water–oil) systems in horizontal pipelines. A database containing 2,146 data points was used, including variables such as pipe diameter, mixture velocity, superficial velocities of each phase, and oil viscosity. The results show excellent model performance, with accuracies of 95.55% during training, 91.28% in validation, and 90% in the final test. These findings demonstrate the model’s ability to capture complex relationships between hydrodynamic variables and flow topologies, making it a promising alternative tool for the analysis, monitoring, and optimization of multiphase transport in the oil industry.
Highlights
• Transformer-based neural networks were implemented to classify oil–water flow patterns in horizontal pipelines, demonstrating the applicability of deep learning to multiphase flow problems.
• A structured database was developed using experimental data and key hydraulic and physical parameters from benchmark studies.
• The proposed model achieved high classification accuracy, particularly for stratified and annular flow patterns, confirming its ability to capture complex interface dynamics.
• Validation with multiple experimental datasets confirmed the model’s generalization capability and robustness across different operating conditions.
• The results contribute to advancing the integration of artificial intelligence in multiphase flow research, supporting improved design and monitoring of transport systems in the oil and gas industry.
1 Introduction
The oil and gas industry faces increasingly complex flow assurance challenges, mainly due to the presence of multiphase flows in wells, transport lines, and production systems. Flow patterns, understood as the spatial configurations of the interfaces between immiscible phases (gas, oil, and water), are decisive in the design and optimization of production and transport operations. Accurate prediction of these patterns improves operational efficiency, reduces the risk of failure, and mitigates environmental impacts (Vargas et al., 2019; Trallero et al., 1997; Shi et al., 2021; Rodriguez and Oliemans, 2006). In particular, in two-phase liquid–liquid systems, such as water and oil flows, identifying the flow pattern is essential for estimating design parameters such as pressure drop, phase retention fraction, and transport stability.
Accurate identification of flow patterns not only has implications for operational performance but also for the integrity of conveyance systems. Some flow patterns can lead to conditions that favor localized corrosion on the inner wall of pipelines, which can lead to structural failure (Al-Sarkhi et al., 2017). In particular, carbon dioxide (CO2)-induced corrosion is a critical factor in the degradation of materials in the oil and gas industry that favors the occurrence of stress corrosion cracking (SCC-CO2), a phenomenon accelerated in the presence of mechanical stresses and CO2-rich, humid environments (Meng et al., 2024; Huang et al., 2025; Liu et al., 2024). This type of deterioration compromises the structural integrity of transmission lines, especially in systems operating under high-pressure and high-temperature conditions. In addition, mechanisms such as erosion–corrosion, sediment deposition, and flow pattern fluctuations contribute significantly to pipeline deterioration in two-phase systems (Liu et al., 2025). The precise characterization of these flow patterns under real operating conditions is therefore essential to ensure the efficient and safe transportation of hydrocarbons (Izwan Ism et al., 2015; Camperos et al., 2023; Álvarez-Pacheco et al., 2024).
Transitions between flow patterns directly affect the pressure gradient and the spatial and temporal distribution of phases (Ruiz-Diaz et al., 2026), and therefore, the safety and efficiency of transportation through pipelines (Yang et al., 2021). The ability to accurately predict the transition limits between flow patterns is an essential aspect of operational risk management in oil production and transportation processes, as it influences the dynamic response of control systems and the performance of critical components such as valves, pumps, and sensors (Perera et al., 2017). In typical multiphase systems in the oil industry, the oil–water flow may experience variations along the line due to changes in slope, diameter, roughness, or the presence of chokes, resulting in the evolution and continuous transition of the flow pattern (Li and Fan, 2020). These transitions not only affect the hydraulic stability of the system but can also alter the stress distribution on the pipeline walls, increasing the risk of corrosive and erosive phenomena. Therefore, their identification and accurate modeling are essential for optimizing transport and the integrity of the production system.
With technological advancements and the development of artificial intelligence (AI) based techniques, machine learning approaches have been widely applied in the characterization and prediction of flow behaviors in pipelines and multiphase systems (dos Santos Ambrosio et al., 2022; Hernandez Cely et al., 2024; Gómez-Camperos et al., 2026). Several recent studies have demonstrated the effectiveness of intelligent models in improving the accuracy of flow pattern identification. For example, a lightweight multipath neural network (FPRnet), based on multidomain feature fusion, has been developed that achieved 98.4% accuracy in the classification of horizontal two-phase oil and water flow patterns, significantly outperforming conventional models in efficiency and accuracy (OuYang et al., 2023). Similarly, a model based on a backpropagation neural network optimized by a genetic algorithm (GA-BP) achieved an accuracy of 87.25%, demonstrating its applicability for interpreting production profile data in horizontal wells (Shi et al., 2023).
Other approaches have explored hybrid methods and deep networks to improve the identification of flow patterns and modeling of transport variables. For example, a fuzzy inference system (FIS) showed greater accuracy and reliability than BP neural networks, facilitating real-time monitoring and reducing operational costs (Wu et al., 2022). Long short-term memory (LSTM) networks have also been used for pattern recognition in standpipes, achieving accurate results even under dynamic flow variations (Ruiz-Díaz et al., 2024a). Convolutional networks (CNN) and artificial neural networks (ANN) have also been proposed with logarithmic normalization techniques, improving the robustness and generalization of the models (Chen et al., 2023; Al-Naser et al., 2016). Convolutional approaches rely on local receptive fields and typically require deep and dilated stacks to span long, multi-scale dependencies, whereas LSTM models remain sequential at inference and cope poorly with non-stationary flow pattern transitions unless long input windows are used. In contrast, Transformer architectures leverage global self-attention, enabling parallel training and efficient inference with moderate windows, which is advantageous for liquid–liquid flow pattern identification.
Recently, the application of artificial intelligence in pipelines has extended beyond flow pattern recognition to include predicting and monitoring operating conditions. Çolak (2025a) developed an artificial neural network model to estimate the apparent viscosity of kerosene oil, achieving a correlation coefficient of 0.9985, while Çolak (2025b) implemented neural models with different training algorithms to predict the kerosene formation distance in pipelines, highlighting Bayesian regularization as the most accurate method. These studies confirm the feasibility and growing relevance of AI techniques for addressing challenges in crude oil transportation and complex flow management, strengthening the motivation of the present work, oriented to the intelligent identification of two-phase oil–water flow patterns using Transformer neural networks.
This study focuses on the application of Transformer neural networks (TNNs) for the classification of water–oil flow patterns in horizontal pipes of different diameters. Unlike previous research employing conventional neural networks, support vector machines (SVMs), or other artificial intelligence techniques, this work proposes a TNN-based architecture to capture the nonlinear and spatiotemporal dependencies present in multiphase flow data.
This approach represents a novel contribution, as the application of TNNs for liquid–liquid flow pattern identification remains limited in the literature. Furthermore, the study aims to reduce the existing gap in the automatic and accurate identification of multiphase flow patterns, demonstrating that these networks can deliver high levels of accuracy and robustness even with limited experimental datasets, positioning them as a promising tool for the monitoring and intelligent analysis of multiphase transport in the petroleum industry.
The proposed approach targets online monitoring of oil–water flow patterns in transport lines and production systems, providing both flow pattern prediction and a confidence indicator suitable for operational use. Scalability is achieved through lightweight adaptation of a pre-trained model using a representative subset of local data, while preserving the core architecture and inference times compatible with continuous operation.
2 Materials and methods
2.1 Database structuring and processing
For the development of the present study, a database containing 2,146 samples was structured. The information is characterized by the following parameters: internal diameter of the pipe, superficial velocity of the water and oil phases, velocity of the mixture, and viscosity of the oil. All data vary within a certain range and have a specific type of flow pattern associated with them. These properties are shown in Table 1.
The studies selected to structure the database correspond to ten investigations carried out by various authors in recent years. One of the main objectives of these studies is the identification of flow patterns in two-phase oil and water flows in horizontal pipelines. The investigations differ in terms of the pipeline geometry, the viscosity of the oil used, the range of superficial velocities studied, the number of patterns found, and the technique used for their identification. Table 2 presents the general information of each of the selected references.
2.1.1 Data scaling
To train the neural network, it is necessary to adjust the information to be used as model inputs to a specific range, providing accurate data that allow the network to relate the supplied variables to the predicted pattern. The input vector to the network X was scaled in a range from 0 to 1, using the Min–Max scaling technique. Equation 1 presents the mathematical definition to perform the scaling of that numerical information.
where X represents the original values, Xmin and Xmax are the minimum and maximum values of each feature, respectively, and Xscaled is the scaled value (Ruiz-Díaz et al., 2024a). This process ensured that all values of each feature were within the range [0, 1], facilitating the analysis and improving the performance of the machine learning algorithm.
2.1.2 Target variable coding
The categorical variable in this study represents six different flow patterns. One-hot encoding was applied to this variable for use in the machine learning models. This technique transforms each of the six examples of the variable into a 6-position binary vector. In each vector, a single position has the value 1, indicating the presence of the respective flow pattern, while the other positions have the value 0. This ensures that each flow pattern is represented uniquely and without introducing artificial order, allowing machine learning algorithms to process the data effectively and without implicit assumptions about the relationship between categories. Table 3 presents the coding applied to each of the flow patterns.
2.2 Development of the model based on the Transformer architecture
An architecture based on Transformers, known for its efficiency in handling data sequences, was used in the development of the predictive model for the identification of flow patterns. Several essential hyperparameters were selected for the model configuration: number of classes, model size, number of attention heads, dropout, number of layers, feed-forward network size, and activation function. Table 4 presents the configuration and parameter settings for the best performance obtained for the model.
An empirical tuning process was conducted to determine the optimal hyperparameters. Various combinations of the number of layers, attention heads, vector dimensions, feed-forward network size, dropout rate, activation function, batch size, learning rate, and number of epochs were iteratively tested using a parameter sweep approach. Each configuration was trained and validated on the same dataset split, and the model achieving the highest validation accuracy was selected as the final configuration. This empirical optimization procedure is commonly employed in deep learning when analytical optimization is infeasible due to the model’s complexity and nonlinearity.
The training and evaluation processes were performed in the Google Colab environment using Python with the TensorFlow and Keras frameworks. The experiments were executed with GPU acceleration (NVIDIA Tesla T4, 16 GB VRAM) and 12.7 GB of available RAM. Each epoch required approximately 1.1 s on average after initialization, resulting in a total training time of approximately 17 min for the 900 epochs.
The model starts with an input layer that accepts fixed-dimensional feature vectors. This initial layer is transformed by a dense layer to obtain a higher-dimensional representation. This representation is then converted to a three-dimensional form suitable for multi-head attention. The encoder block, a fundamental component of the Transformer architecture, consists of several multi-head attention layers followed by feed-forward layers. Multi-head attention is mathematically defined as
where Q, K, and V are the vectors corresponding to queries, keys, and values,
The attention function is expressed as
where
where x represents the input vector to the network, and b is a bias vector (Vaswani, 2017). This block also includes a residual connection and a normalization layer:
where X represents the input vector to the layer (Zhang et al., 2024). This process is repeated over five layers, each contributing to the transformation and refinement of the representations.
The decoder block follows a similar structure to the encoder block, also applying multi-head attention and feed-forward layers with residual connections and normalization, which allows refining the representations generated by the encoder. Before the output layer, a flattening layer is applied to convert the three-dimensional representations into a single dimension. Finally, the output layer is a dense layer with a SoftMax activation function that produces the probabilities of membership to each of the six defined classes (Zhang et al., 2024):
The model was trained using the Adam optimizer and categorical cross-entropy loss function. The dataset was split into training and validation sets, applying regularization techniques such as dropout to prevent overfitting. This meticulous approach ensures that the Transformer model can identify flow patterns effectively and accurately, providing a robust solution for the proposed task. Figure 2 shows the architectural schematic of the developed model.
2.3 Evaluation and optimization of the developed model
A rigorous methodology was implemented to evaluate and optimize the performance of the Transformer neural network model for the identification of flow patterns in two-phase oil–water systems in horizontal conduits. Optimization began with the implementation of the Adam algorithm, a stochastic gradient descent method based on adaptive estimation of first- and second-order moments. A learning rate of 0.0008, empirically determined to balance convergence and stability during training, was selected. A series of simulations was performed where all related hyperparameters were modified and adjusted. The initial split of the training and test data was standardized to 80% and 20%, respectively, and 20% of the training data were used for validation. The loss function chosen was the categorical cross-entropy, defined as
where
where TP, TN, FP, and FN represent true positives, true negatives, false positives, and false negatives, respectively (Gómez-Camperos et al., 2026). For further comprehensive analysis, a confusion matrix was generated, and class-wise performance metrics were calculated. Precision, recall, and F1-score were computed for each class and on a weighted average, respectively (Ruiz-Diaz et al., 2026).
These metrics provide a balanced assessment of model performance, especially in unbalanced class situations common in two-phase flow patterns. Additionally, a heat map visualization of the confusion matrix was implemented, facilitating the identification of systematic error patterns in the classification of flow patterns. This multifaceted evaluation approach allows for a robust quantitative characterization of model performance in discriminating two-phase flow patterns. The methodology provides a solid basis for iterative model optimization, crucial for improving accuracy in the identification of flow patterns in oil–water systems in horizontal conduits.
3 Results
In this section, the results obtained from the training, validation, and testing of the Transformer neural network model for the identification of flow patterns in two-phase oil–water systems in horizontal conduits are presented. The influence of key hyperparameters on the model’s performance is analyzed. An initial parameter sweep was conducted to evaluate the effect of different configurations (such as the number of layers, neurons, learning rate, and dropout rate) on the model’s accuracy. As expected, these preliminary experiments yielded lower accuracy values because they correspond to the exploratory phase prior to optimization.
The hyperparameter tuning stage revealed that variations in learning rate, dropout rate, number of attention heads, and layer dimensions produced moderate effects on model performance, with accuracies ranging from 35.17% to 58.14% across the training, validation, and test sets (Table 5). These results indicate that increasing model complexity (such as adding more attention heads or enlarging layer dimensions) did not consistently enhance accuracy. Instead, relatively compact configurations were sufficient to capture the main characteristics of the two-phase flow patterns, guiding the subsequent optimization phase that led to the highest performance values reported later.
Table 5. Maximum accuracies obtained for hyperparameters with low impact on flow pattern identification.
The variation of the input vector dimension (dmodel) allowed a substantial improvement in the model performance, reaching its best performance with a value of 16. Under this configuration, accuracies of 87.1%, 86.63%, and 87.21% were reached for the training, validation, and test sets, respectively, which is a 30% improvement compared to previous configurations. This result suggests that a proper representation of the flow features improves the model’s ability to discriminate between different patterns.
The analysis of the performance obtained from the modification of the layers used shows a consistent behavior (see Figure 3). Similar behavior is observed for the training, validation, and test curves, indicating good generalization of the model and consistency and stability between the phases. There is a pronounced drop in accuracy when more than six layers were trialed, suggesting that excessive complexity causes overfitting or problems in gradient propagation and, therefore, loss of generalization capacity; an optimum point is identified between four and five layers to balance complexity and performance. Maximum accuracies of 86.88%, 85.47%, and 85.51% were achieved for the training, validation, and test sets when using five, three, and six layers, respectively.
The number of samples used for training has a significant impact on the model’s stability and accuracy, as evidenced by the results presented in Figure 4. Pronounced fluctuations are observed in all three curves, particularly in the early stages, indicating instability in the learning process, possibly associated with a high learning rate or suboptimal weight initialization. The accuracy of the training set tends to increase, while the validation and test sets exhibit a decreasing trend, suggesting a progressive overfitting process. This behavior suggests that the model successfully fits the training data but loses generalization capability when exposed to unseen data, highlighting the need for improved regularization or hyperparameter tuning to stabilize learning.
The configuration achieved maximum accuracies of 89.58%, 89.24%, and 87.21% for the training, validation, and test sets, respectively.
The variation in the number of epochs reveals a consistent upward trend in the training accuracy curve, indicating that the model continues to improve its fit to the training data as the number of epochs increases (Figure 5). In contrast, the validation and test curves show moderate fluctuations and a slight divergence from the training curve, suggesting the onset of mild overfitting. This behavior reflects a common phenomenon in deep learning, where prolonged training enhances performance on the training set while yielding marginal or unstable improvements on unseen data. Nevertheless, the model maintains a stable generalization capacity, as the validation and test accuracies remain close to each other. Overall, the learning process appears stable but could benefit from improved regularization to further reduce the gap between training and validation. For 900 epochs, the model reaches a maximum training accuracy of 95.26%, while validation and test accuracies peak at 90.09% and 90.47% for 800 and 700 epochs, respectively.
Figure 6 presents the comparison of the performance obtained with the different activation functions considered in the model. The accuracies achieved in the training, validation, and test sets for each function are shown, allowing visual identification of the performance variations between them. In general, it is observed that nonlinear functions, especially those with smooth activations, provide better performance than linear or saturation functions. This trend suggests that properly selecting the activation function significantly influences the model’s ability to represent complex relationships and generalize effectively.
The exploration of different activation functions has revealed that the linear exponential unit (ELU) function offers the highest performance, achieving a training accuracy of 95.55%, a validation accuracy of 91.28%, and a test accuracy of 90%. This result even exceeds the maximum obtained in the previous optimization, which is the highest performance in all the training performed. The superiority of the ELU function can be attributed to its unique properties, which include mitigation of the gradient fading problem and the ability to produce negative activations, which can be especially beneficial for modeling complex patterns in two-phase flows (see Figure 7).
Figure 7. Training and validation performance using the ELU activation function: (a) Accuracy and (b) loss.
Analysis of the confusion matrix (see Figure 8) reveals particularly outstanding performance in identifying two specific types of flow patterns: annular (A) and stratified (ST). For the annular pattern, the model achieved 249 correct predictions, while for the stratified pattern, 256 hits were achieved, out of the total number of examples available for each respective class. This high hit rate in these categories suggests that the model has effectively captured the distinctive characteristics of these flow patterns.
Table 6 summarizes the model’s performance for each flow pattern class, reporting accuracy, sensitivity, and F1-score metrics derived from the confusion matrix. The model achieved maximum values of 97% for the annular (A) flow pattern across all three metrics, confirming its strong ability to detect and classify this category.
Overall, the metrics range between 81% and 97% across classes, indicating robust and consistent generalization of the model. The annular (A) pattern exhibits the best overall performance, while the dispersed water-in-oil (D w/o) and intermittent (I) patterns also show solid results, with accuracy and sensitivity values above 88%. The macro and weighted averages (92% accuracy, 91% sensitivity, and 91% F1-score) further demonstrate the model’s effectiveness in the multiclass classification of oil–water flow patterns, underscoring its potential as a reliable tool for petroleum and multiphase flow applications.
The validation of the developed model was carried out using external datasets from experimental work done by Trallero and of Tulsa (1995), Nädler and Mewes (1997), Gras et al. (2008), and Wegmann and Rudolf von Rohr (2006), ensuring that all validation samples were entirely independent from those used in the training phase, thus avoiding any potential data leakage. The validation dataset extracted from Trallero and of Tulsa (1995) comprises 134 experimental points, obtained under specific conditions including a 0.05 m diameter pipe and an oil viscosity of 0.0288 Pa·s. These data are particularly relevant because they represent well-characterized and widely recognized experimental conditions in two-phase oil–water flow research. The reference dataset includes four flow pattern types: stratified & mixed interface (ST & MI), stratified (ST), dispersion oil-in-water (D o/w), and dispersion water-in-oil (D w/o), while the model was originally trained with six flow pattern categories.
When comparing the model predictions with the reference classifications, an overall accuracy of 92.53% was obtained, indicating a high degree of consistency between the predicted and experimental flow patterns (see Figure 9). Minor discrepancies were mainly found near the transition regions between stratified and dispersed patterns, which may be attributed to the intrinsic overlap between classes and the limited number of samples in those boundaries within the training dataset. Overall, the model shows strong generalization capability for this validation case, accurately reproducing the global topology of the flow map.
Figure 9. Flow map from Trallero and of Tulsa (1995). (a) Original flow map (modified from the reference). (b) Predicted flow patterns generated by the proposed model for this dataset.
The validation set extracted from Nädler and Mewes (1997) comprises 61 data points, obtained under specific experimental conditions including a 0.059 m diameter pipe and an oil with a viscosity of 0.022 Pa s. Comparing the predictions made by the model with the reference categorical values, the calculated accuracy percentage is 32.79%, and the number of model hits for this dataset was 20 (see Figure 10). This relatively low accuracy suggests that the model exhibits limited generalization for this dataset, likely due to the restricted representation of similar operating conditions in the training data and the imbalance among flow pattern categories. Nevertheless, the model is able to correctly capture the transition trend between stratified and dispersed flow regions, indicating partial learning of the underlying physical behavior.
Figure 10. Flow map from Nädler and Mewes (1997). (a) Original flow map (modified from the reference). (b) Predicted flow patterns generated by the proposed model for this dataset.
The validation dataset extracted from Gras et al. (2008) comprises 138 experimental points, obtained under conditions that include a 0.021 m internal diameter pipe and an oil viscosity of 0.799 Pa·s. When comparing the model predictions with the reference flow patterns, an overall accuracy of 80.43% was achieved, corresponding to 111 correctly classified samples (see Figure 11). The high viscosity of the oil in this dataset promotes more complex interfacial behaviors, such as thicker films and irregular dispersion zones, which challenge the model’s generalization capability. The moderate discrepancies observed in the transition regions between annular (A) and dispersed oil-in-water (D o/w) flow patterns are likely due to the limited representation of such high-viscosity cases within the training dataset. Nevertheless, the model successfully reproduces the dominant flow structure and the overall topological distribution of flow patterns, confirming its ability to extrapolate to operating conditions not explicitly included during training.
Figure 11. Flow map from Gras et al. (2008). (a) Original flow map (modified from the reference). (b) Predicted flow patterns generated by the proposed model for this dataset.
The validation dataset extracted from Wegmann and Rudolf von Rohr (2006) comprises 213 data points, obtained under experimental conditions that include a 0.0056 m internal diameter pipe and an oil viscosity of 0.0052 Pa·s. When comparing the model predictions with the reference classifications, an overall accuracy of 58.22% was achieved, corresponding to 124 correctly identified samples (see Figure 12). The reduced accuracy observed for this dataset can be attributed to the distinct flow conditions, particularly the very small pipe diameter and low oil viscosity, which induce capillary-dominated flow structures that differ significantly from those represented in the training data. Despite these limitations, the model adequately captures the global distribution of flow patterns and preserves the main transition trends between stratified (ST) and dispersed (D w/o) regions, indicating partial extrapolation capability beyond the primary training domain.
Figure 12. Flow map from Nädler and Mewes (1997). (a) Original flow map (modified from the reference). (b) Predicted flow patterns generated by the proposed model for this dataset.
4 Conclusion
This study represents a significant advancement in the application of deep learning to the prediction of two-phase flow patterns. The developed Transformer-based model achieved high classification accuracy, demonstrating its potential as a valuable tool for both industrial applications and academic research in multiphase flow analysis.
Hyperparameter optimization indicated that a learning rate of 0.0008 and a dropout rate of 0.002 yielded the best model performance, while an input vector dimension of 16 resulted in training and validation accuracies of 87.10% and 86.63%, respectively. Furthermore, employing the exponential linear unit (ELU) activation function enhanced the network’s capability to capture nonlinear behaviors, achieving a maximum training accuracy of 95.55%.
The model exhibited strong performance in identifying annular and stratified flow patterns, with accuracies reaching up to 97%, confirming its robustness and reliability. Validation using independent experimental datasets demonstrated satisfactory generalization and consistency under real operating conditions, positioning the model as a promising tool for the oil and gas industry in the design and optimization of multiphase transport systems.
Despite its strong performance, some discrepancies with experimental observations remain, revealing opportunities for further improvement. Future work should focus on enhancing the model’s capability to characterize transition regions between flow patterns and extending its applicability to a broader range of flow conditions and geometrical configurations.
Data availability statement
The datasets presented in this article are not readily available because none. Requests to access the datasets should be directed to Carlos Ruiz, Y2FybG9zcnVpejk3OEB1c3AuYnI=.
Author contributions
LQ-A: Formal analysis, Writing – review and editing. CR-D: Formal analysis, Supervision, Validation, Visualization, Writing – original draft. JG-C: Conceptualization, Methodology, Project administration, Writing – review and editing. OR: Methodology, Supervision, Visualization, Writing – original draft. AP-G: Conceptualization, Data curation, Methodology, Writing – review and editing.
Funding
The authors declare that financial support was received for the research and/or publication of this article. The authors would like to acknowledge the support provided by Universidad Francisco de Paula Santander (Seccional Ocaña), the Industrial Multiphase Flow Laboratory (LEMI), and Universidad de Pamplona. Carlos Ruiz gratefully acknowledges the support of the Ministerio de Ciencia, Tecnología e Innovación of Colombia. Oscar Rodriguez also acknowledges CNPq for the research productivity grant (Proc. 311057/2020-9).
Conflict of interest
The authors declare that the research was conducted in the absence of any commercial or financial relationships that could be construed as a potential conflict of interest.
Generative AI statement
The authors declare that no Generative AI was used in the creation of this manuscript.
Any alternative text (alt text) provided alongside figures in this article has been generated by Frontiers with the support of artificial intelligence and reasonable efforts have been made to ensure accuracy, including review by the authors wherever possible. If you identify any issues, please contact us.
Publisher’s note
All claims expressed in this article are solely those of the authors and do not necessarily represent those of their affiliated organizations, or those of the publisher, the editors and the reviewers. Any product that may be evaluated in this article, or claim that may be made by its manufacturer, is not guaranteed or endorsed by the publisher.
References
Al-Naser, M., Elshafei, M., and Al-Sarkhi, A. (2016). Artificial neural network application for multiphase flow patterns detection: a new approach. J. Pet. Sci. Eng. 145, 548–564. doi:10.1016/J.PETROL.2016.06.029
Al-Sarkhi, A., Pereyra, E., Mantilla, I., and Avila, C. (2017). Dimensionless oil-water stratified to non-stratified flow pattern transition. J. Pet. Sci. Eng. 151, 284–291. doi:10.1016/J.PETROL.2017.01.016
Al-Wahaibi, T., Al-Wahaibi, Y., Al-Ajmi, A., Al-Hajri, R., Yusuf, N., Olawale, A., et al. (2014). Experimental investigation on flow patterns and pressure gradient through two pipe diameters in horizontal oil-water flows. J. Pet. Sci. Eng. 122, 266–273. doi:10.1016/J.PETROL.2014.07.019
Álvarez-Pacheco, C. E., Ruiz-Diaz, C. M., and Hernandez-Rodriguez, O. M. (2024). Chordal measurement of phase fraction distribution in a static gas-liquid system using collimated gamma-ray densitometer and artificial neural networks. Rev. Ingenio 21 (1), 29–35. doi:10.22463/2011642x.4098
Cai, J., Li, C., Tang, X., Ayello, F., Richter, S., and Nesic, S. (2012). Experimental study of water wetting in oil-water two phase flow-horizontal flow of model oil. Chem. Eng. Sci. 73, 334–344. doi:10.1016/J.CES.2012.01.014
Camperos, J. A. G., Diaz, C. M. R., and Cely, M. M. H. (2023). Specialist system in flow pattern identification using artificial neural networks. J. Appl. Eng. Sci. 21 (1), 285–299. doi:10.5937/JAES0-40309
Cely, M., Cavalheiro, H. L., Camperos, J., Garcia, A. P., Pagliarini, S., Diaz, C., et al. (2024). Identificação de padrões de escoamento bifásico água-óleo em tubulações horizontais da indústria óleo-gás através de técnicas de inteligência artificial. Ed. Científica Digit. doi:10.37885/978-65-5360-640-1
Chen, H., Dang, Z., Park, S. S., and Hugo, R. (2023). Robust CNN-based flow pattern identification for horizontal gas-liquid pipe flow using flow-induced vibration. Exp. Therm. Fluid Sci. 148, 110979. doi:10.1016/J.EXPTHERMFLUSCI.2023.110979
Çolak, A. B. (2025a). Investigating a machine learning algorithm’s applicability for simulating the apparent viscosity of waxy crude oil in a pipeline. Int. J. Oil, Gas Coal Technol. 37 (3), 321–337. doi:10.1504/IJOGCT.2025.145438
Çolak, A. B. (2025b). Performance analysis of different artificial intelligence algorithms in estimating wax appearance distance in thick-walled crude oil pipeline. Model Earth Syst. Environ. 11 (6), 1–14. doi:10.1007/S40808-025-02627-1/METRICS
Dasari, A., Desamala, A. B., Dasmahapatra, A. K., and Mandal, T. K. (2013). Experimental studies and probabilistic neural network prediction on flow pattern of viscous oil–water flow through a circular horizontal pipe. Ind. Eng. Chem. Res. 52 (23), 7975–7985. doi:10.1021/IE301430M
dos Santos Ambrosio, J., Lazzaretti, A. E., Pipa, D. R., and da Silva, M. J. (2022). Two-phase flow pattern classification based on void fraction time series and machine learning. Flow Meas. Instrum. 83, 102084. doi:10.1016/J.FLOWMEASINST.2021.102084
Gómez-Camperos, J. A., R․ Diaz, C. M., Hernandez-Cely, M. M., Rodriguez, O. M. H. ․, and Pardo-Garcia, A. (2026). Dense-gas/liquid two-phase flow pattern recognition using convolutional neural networks and transfer learning. Int. J. Multiph. Flow 194, 105479. doi:10.1016/J.IJMULTIPHASEFLOW.2025.105479
Grassi, B., Strazza, D., and Poesio, P. (2008). Experimental validation of theoretical models in two-phase high-viscosity ratio liquid–liquid flows in horizontal and slightly inclined pipes. Int. J. Multiph. Flow 34 (10), 950–965. doi:10.1016/j.ijmultiphaseflow.2008.03.006
Huang, Y., Wang, X., Lu, K., and Hu, J. (2025). Carbon steel pipeline CO2 erosion-corrosion damage prediction model and numerical simulation research. Geoenergy Sci. Eng. 246, 213558. doi:10.1016/J.GEOEN.2024.213558
Ibarra, R., Markides, C., and Matar, O. (2015). Towards a universal dimensionless map of flow regime transitions in horizontal liquid-liquid flows.
Izwan Ismail, A. S., Ismail, I., Zoveidavianpoor, M., Mohsin, R., Piroozian, A., Misnan, M. S., et al. (2015). Experimental investigation of oil–water two-phase flow in horizontal pipes: pressure losses, liquid holdup and flow patterns. J. Pet. Sci. Eng. 127, 409–420. doi:10.1016/J.PETROL.2015.01.038
Li, Z. C., and Fan, C. L. (2020). A novel method to identify the flow pattern of oil–water two-phase flow. J. Pet. Explor Prod. Technol. 10 (8), 3723–3732. doi:10.1007/S13202-020-00987-1
Li, C., Liu, K., and Liu, S. (2025). A Survey of loss functions in deep learning. Mathematics 13 (15), 2417. doi:10.3390/MATH13152417
Liu, Z., Yin, P., Mou, C., Wang, S., Shang, L., Cao, X., et al. (2024). Unraveling the corrosion behavior and mechanism of DLC film on the inner surface of N80 lengthy pipeline in CO2-H2S-Cl− environment. Surf. Coat. Technol. 494, 131350. doi:10.1016/J.SURFCOAT.2024.131350
Liu, Z., Liu, J., Mou, C., Zhang, L., Cao, X., Chen, L., et al. (2025). Anti-sediment wear coupled corrosion protective coating for oil and gas exploitation pipeline protection. Chem. Eng. J. 505, 159867. doi:10.1016/J.CEJ.2025.159867
Meng, S., Yue, P., Zhang, S., Li, H., Zhao, Y., Hua, Y., et al. (2024). Synergistic effects of CO2 and H2S on stress corrosion cracking of stainless steel 254SMo in extremely aggressive oilfield environment. Corros. Commun. 16, 81–95. doi:10.1016/J.CORCOM.2024.03.003
Nädler, M., and Mewes, D. (1997). Flow induced emulsification in the flow of two immiscible liquids in horizontal pipes. Int. J. Multiph. Flow 23 (1), 55–68. doi:10.1016/s0301-9322(96)00055-9
OuYang, L., Jin, N., Ren, W., and Zong, Y. (2023). FPRnet: a lightweight multi-domain multi-stream network for complex horizontal oil-water two-phase flow pattern recognition. Flow Meas. Instrum. 94, 102471. doi:10.1016/J.FLOWMEASINST.2023.102471
Perera, K., Pradeep, C., Mylvaganam, S., and Time, R. W. (2017). Imaging of oil-water flow patterns by Electrical Capacitance tomography. Flow Meas. Instrum. 56, 23–34. doi:10.1016/J.FLOWMEASINST.2017.07.002
Rodriguez, O. M. H., and Oliemans, R. V. A. (2006). Experimental study on oil–water flow in horizontal and slightly inclined pipes. Int. J. Multiph. Flow 32 (3), 323–343. doi:10.1016/J.IJMULTIPHASEFLOW.2005.11.001
Ruiz-Díaz, C. M., Quispe-Suarez, B., and González-Estrada, O. A. (2024a). Two-phase oil and water flow pattern identification in vertical pipes applying long short-term memory networks. Emergent Mater 7 (5), 1983–1995. doi:10.1007/s42247-024-00631-2
Ruiz-Díaz, C. M., Perilla-Plata, E. E., and González-Estrada, O. A. (2024b). Two-phase flow pattern identification in vertical pipes using transformer neural networks. Inventions 9 (1), 15. doi:10.3390/inventions9010015
Ruiz-Diaz, C. M., Pacheco, C. E. A., da Silva, E. O., Bochio, G., Postal, A. T., and Rodriguez, O. M. H. (2026). Experimental study on dense-gas/oil flow in horizontal and slightly upward inclined pipes. Int. J. Multiph. Flow 194, 105477. doi:10.1016/J.IJMULTIPHASEFLOW.2025.105477
Shi, J., and Yeung, H. (2017). Characterization of liquid-liquid flows in horizontal pipes. AIChE J. 63 (3), 1132–1143. doi:10.1002/AIC.15452
Shi, J., Lao, L., and Yeung, H. (2017). Water-lubricated transport of high-viscosity oil in horizontal pipes: the water holdup and pressure gradient. Int. J. Multiph. Flow 96, 70–85. doi:10.1016/J.IJMULTIPHASEFLOW.2017.07.005
Shi, X., Dong, F., and Tan, C. (2021). Horizontal oil-water two-phase flow characterization and identification with pulse-wave ultrasonic Doppler technique. Chem. Eng. Sci. 246, 117015. doi:10.1016/J.CES.2021.117015
Shi, S., Liu, J., Hu, H., and Zhou, H. (2023). A research on a GA-BP neural network based model for predicting patterns of oil-water two-phase flow in horizontal wells. Geoenergy Sci. Eng. 230, 212151. doi:10.1016/J.GEOEN.2023.212151
Tan, J., Jing, J., Hu, H., and You, X. (2018). Experimental study of the factors affecting the flow pattern transition in horizontal oil–water flow. Exp. Therm. Fluid Sci. 98, 534–545. doi:10.1016/J.EXPTHERMFLUSCI.2018.06.020
Tan, J., Hu, H., Vahaji, S., Jing, J., and Tu, J. (2022). Effects of drag-reducing polymers on the flow patterns, pressure gradients, and drag-reducing rates of horizontal oil–water flows. Int. J. Multiph. Flow 153, 104136. doi:10.1016/J.IJMULTIPHASEFLOW.2022.104136
Trallero, J. L., and of Tulsa, U. (1995). Oil-water flow patterns in horizontal pipes. Tulsa, Oklahoma: Department of Petroleum, Engineering, University of Tulsa. Ph.D. Thesis.
Trallero, J. L., Sarica, C., and Brill, J. P. (1997). A study of Oil/water flow patterns in horizontal pipes. SPE Prod. & Facil. 12 (03), 165–172. doi:10.2118/36609-PA
Vargas, R. E. V., Munaro, C. J., Ciarelli, P. M., Medeiros, A. G., Amaral, B. G. d., Barrionuevo, D. C., et al. (2019). A realistic and public dataset with rare undesirable real events in oil wells. J. Pet. Sci. Eng. 181, 106223. doi:10.1016/J.PETROL.2019.106223
Vaswani, A., Shazeer, N., Parmar, N., Uszkoreit, J., Jones, L., Gomez, A. N., et al. (2017). Attention is all you need. Adv. Neural Inf. Process Syst. 30. Available online at: https://proceedings.neurips.cc/paper_files/paper/2017/file/3f5ee243547dee91fbd053c1c4a845aa-Paper.pdf.
Wang, W., Cheng, W., Li, K., Lou, C., and Gong, J. (2013). Flow patterns transition law of oil-water two-phase flow under a wide range of oil phase viscosity condition. J. Appl. Math. 2013 (SI14), 1–8. doi:10.1155/2013/291217
Wegmann, A., and Rudolf von Rohr, P. (2006). Two phase liquid-liquid flows in pipes of small diameters. Int. J. Multiph. Flow 32 (8), 1017–1028. doi:10.1016/j.ijmultiphaseflow.2006.04.001
Wu, Y., Guo, H., Song, H., and Deng, R. (2022). Fuzzy inference system application for oil-water flow patterns identification. Energy 239, 122359. doi:10.1016/J.ENERGY.2021.122359
Yang, J., Li, P., Zhang, X., Lu, X., Li, Q., and Mi, L. (2021). Experimental investigation of oil–water flow in the horizontal and vertical sections of a continuous transportation pipe. Sci. Rep. 11 (1), 20092. doi:10.1038/S41598-021-99660-8
Glossary
TNN Transformer neural networks
A Annular
b Bias vector
CO2 Carbon dioxide
D Internal diameter of the pipe
D w/o Water-in-oil dispersion
D o/w Oil-in-water dispersion
dmodel Input vector dimension
ELU Exponential linear unit
FIS Fuzzy inference system
FN False negatives
FP False positives
FPRnet Lightweight multi-stream neural network
GA-BP Backpropagation neural network optimized with a genetic algorithm
I Intermittent
JO Oil superficial velocity
JW Water superficial velocity
JO+W Mixing velocity
K Vector corresponding to keys
L Loss function
LSTM Long short-term memory
N Total number of classes
Q Vector corresponding to queries
SCC-CO2 Stress corrosion cracking
SVM Support vector machine
ST Stratified
ST & MI Stratified with interface mixing
TP True positives
TN True negatives
V Vector corresponding to values
X Original values
Xmin Minimum value
Xmax Maximum value
Xscaled Scaled value
µO Oil viscosity
Keywords: Transformer neural network, flow pattern identification, two-phase flow, liquid–liquid flow, horizontal pipelines
Citation: Quintero-Arias L, Ruiz-Diaz CM, Gómez-Camperos JA, Rodriguez OMH and Pardo-Garcia A (2026) Application of Transformer neural networks for the classification of two-phase oil–water flow patterns in horizontal pipelines. Front. Mech. Eng. 11:1710934. doi: 10.3389/fmech.2025.1710934
Received: 24 September 2025; Accepted: 27 November 2025;
Published: 07 January 2026.
Edited by:
Aliyu M Aliyu, University of Lincoln, United KingdomReviewed by:
Andaç Batur Çolak, Niğde Ömer Halisdemir University, TürkiyeHanyu Xie, Southwest Petroleum University, China
Rajab Omar, University of Nottingham, United Kingdom
Cristian Andres Hernandez Salazar, Industrial University of Santander, Colombia
Copyright © 2026 Quintero-Arias, Ruiz-Diaz, Gómez-Camperos, Rodriguez and Pardo-Garcia. This is an open-access article distributed under the terms of the Creative Commons Attribution License (CC BY). The use, distribution or reproduction in other forums is permitted, provided the original author(s) and the copyright owner(s) are credited and that the original publication in this journal is cited, in accordance with accepted academic practice. No use, distribution or reproduction is permitted which does not comply with these terms.
*Correspondence: Carlos Mauricio Ruiz-Diaz, Y2FybG9zcnVpejk3OEB1c3AuYnI=
Leider Quintero-Arias1