A method for predicting corrosion rate in natural gas pipelines

By using the CNN-BO-Transformer model and DeepSHAP interpretation method in the corrosion rate prediction in natural gas pipelines, the problem of feature extraction unrelated features affecting model performance in the prior art is solved, and the transparency and credibility of the model are improved, so as to achieve Accurate corrosion rate prediction.

CN119202558BActive Publication Date: 2025-02-07SOUTHWEST PETROLEUM UNIV
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202411686087.2
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-11-24
Publication Date
2025-02-07
Estimated Expiration
2044-11-24

AI Technical Summary

Technical Problem

When predicting corrosion rates in natural gas pipelines, the prior art has the problem that feature extraction irrelevant features affect the performance of the model. At the same time, the "black box problem" of deep learning models limits the transparency and credibility of the model.

Method used

A CNN-BO-Transformer model is proposed, combining convolutional neural network (CNN) and a Transformer model optimized using Bayesian optimization (BO) to predict corrosion rates in natural gas pipelines through feature extraction and Bayesian optimization, and Use DeepSHAP to interpret the model.

Benefits of technology

This model can accurately predict the corrosion rate in natural gas pipelines, solving the problem that irrelevant features affect the model performance during feature extraction, and at the same time, it provides clear explanation through DeepSHAP, which improves the transparency and credibility of the model.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119202558B_ABST
    Figure CN119202558B_ABST
Patent Text Reader

Abstract

The present invention discloses a method for predicting the corrosion rate in a natural gas pipeline, comprising: collecting a data set of corrosion test data in a natural gas pipeline; analyzing and preprocessing the data set of corrosion test data, and dividing the preprocessed data set into a training set and a test set; establishing a CNN-BO-Transformer model, inputting the training set into a CNN network for feature extraction, inputting the output data of the CNN network into a Transformer model optimized using Bayesian optimization (BO), and outputting a predicted value of the corrosion rate in the natural gas pipeline; inputting the test set into the CNN-BO-Transformer for model performance evaluation; and using DeepSHAP to interpret the CNN-BO-Transformer model. The present invention can accurately predict the corrosion rate in a natural gas pipeline through the CNN-BO-Transformer model.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The invention belongs to the technical field of oil and gas pipeline safety assessment, and in particular relates to a method for predicting the corrosion rate in a natural gas pipeline. Background Art

[0002] Due to the influence of corrosion and high working pressure, the service life of natural gas pipelines is often greatly shortened. Therefore, effective protection and prediction of pipeline corrosion is crucial to ensure the long-term stable operation of pipelines.

[0003] In the field of oil and gas pipeline corrosion prediction, the existing technologies are mainly divided into three types of models: empirical models, semi-empirical models and mechanism models. These models involve the mechanism of pipeline corrosion to varying degrees. With the advancement of information technology, the role of big data and intelligent algorithms in the oil and gas industry has become increasingly prominent. They are used to explore the complex relationship between corrosion rate and various influencing factors. Prediction technology based on intelligent algorithms and statistical methods is called data-driven model because it relies on data-driven.

[0004] Although traditional models have played a role in predicting oil and gas pipeline corrosion, they have obvious limitations. Most empirical models and mechanism models are based on classical regression or fitting techniques, which fail to fully consider the characteristics of oil and gas pipeline corrosion as a nonlinear random process. In addition, traditional machine learning models, such as random forest (RF), support vector regression (SVR) and K nearest neighbor (KNN) models, although they show strong performance in predicting the corrosion rate in pipelines, they require manual feature selection and extraction, which is not only time-consuming but also easily interfered by irrelevant or redundant features, thus affecting the overall performance of the model.

[0005] Furthermore, although deep learning networks have been widely used in oil and gas pipeline corrosion prediction due to their powerful data processing capabilities, the complexity of their models has also brought about the so-called "black box problem". This problem makes it difficult for researchers to effectively interpret and verify the model's prediction results, limiting the transparency and credibility of the model in practical applications. Therefore, developing a model that can accurately predict the corrosion rate in natural gas pipelines and provide clear explanations has become a technical challenge that needs to be urgently addressed in this field. Summary of the invention

[0006] In order to solve the above technical problems, the present invention proposes a method for predicting the corrosion rate in a natural gas pipeline, comprising:

[0007] Collect corrosion data sets from coupon experiments in natural gas pipelines;

[0008] Analyzing and preprocessing the coupon test corrosion data set, and dividing the preprocessed data set into a training set and a test set;

[0009] Establish a CNN-BO-Transformer model, where the CNN-BO-Transformer model includes a CNN network and a Transformer model optimized using Bayesian optimization (BO);

[0010] Inputting the training set into the CNN network for feature extraction, inputting the output data of the CNN network into the Transformer model optimized by Bayesian Optimization (BO), outputting the predicted value of the corrosion rate in the natural gas pipeline, and obtaining a trained CNN-BO-Transformer model;

[0011] Input the test set into the trained CNN-BO-Transformer model to evaluate the model performance;

[0012] DeepSHAP is used to calculate the feature contribution value of each variable in the experimental corrosion data set, a summary graph is generated based on the feature contribution value, and the CNN-BO-Transformer model is explained using the summary graph.

[0013] Preferably, the experimental corrosion data set includes temperature, Cl ion content, pressure, CO2 partial pressure, liquid flow rate, liquid wall shear force, gas wall shear force, liquid holdup and gas flow rate.

[0014] Preferably, the process of analyzing and preprocessing the experimental corrosion data set includes:

[0015] Performing Spearman correlation matrix analysis on the experimental corrosion data sets to obtain correlations between the experimental corrosion data sets;

[0016] Use XGBoost to extract feature importance of the experimental corrosion data set to obtain a first feature importance ranking;

[0017] The experimental corrosion data set is normalized to obtain a preprocessed data set.

[0018] Preferably, the process of inputting the training set into the CNN network for feature extraction includes:

[0019] Performing feature extraction on the training set based on the one-dimensional convolution of the CNN network, wherein the convolution kernel of the one-dimensional convolution is 3 to capture detail information, and 0 padding is set to 1 to retain all feature parameters;

[0020] After two CNN network feature extractions, the output data of the CNN network is obtained.

[0021] Preferably, the hyperparameters of the Transformer model include the number of heads in the multi-head attention, the number of sub-encoder layers of the encoder, the dropout rate and the learning rate.

[0022] Preferably, the process of interpreting the CNN-BO-Transformer model includes:

[0023] Using DeepSHAP to calculate the feature contribution value of each variable in the experimental corrosion data set, generating a summary graph based on the feature contribution value, and using the summary graph to explain the CNN-BO-Transformer model;

[0024] A second feature importance ranking is obtained based on the summary graph, and the first feature importance ranking is compared with the second feature importance ranking.

[0025] Compared with the prior art, the present invention has the following advantages and technical effects:

[0026] The invention provides a method for predicting the corrosion rate in a natural gas pipeline. First, a corrosion data set of a hanging sheet experiment in a natural gas pipeline is collected; secondly, the corrosion data set of the hanging sheet experiment is analyzed and preprocessed, and the preprocessed data set is divided into a training set and a test set; then a CNN-BO-Transformer model is established, wherein the CNN-BO-Transformer model includes a CNN network and a Transformer model optimized by Bayesian optimization (BO); further, the training set is input into the CNN network for feature extraction, the output data of the CNN network is input into the Transformer model optimized by Bayesian optimization (BO), and the predicted value of the corrosion rate in the natural gas pipeline is output to obtain the trained CNN-BO-Transformer model; then, the test set is input into the trained CNN-BO-Transformer model for model performance evaluation; finally, DeepSHAP is used to calculate the feature contribution value of each variable in the experimental corrosion data set, a summary graph is generated based on the feature contribution value, and the CNN-BO-Transformer model is explained by the summary graph.

[0027] The present invention can accurately predict the corrosion rate in natural gas pipelines through the CNN-BO-Transformer model, which solves the technical problem in the prior art that irrelevant features damage the model performance during feature extraction. At the same time, the DeepSHAP interpretation method is used to analyze the impact of each feature on the predicted value, providing researchers with more valuable tools. BRIEF DESCRIPTION OF THE DRAWINGS

[0028] The drawings constituting a part of the present application are used to provide a further understanding of the present application. The illustrative embodiments and descriptions of the present application are used to explain the present application and do not constitute an improper limitation on the present application. In the drawings:

[0029] Figure 1 This is a flow chart of a method for predicting corrosion rate in a natural gas pipeline according to an embodiment of the present invention;

[0030] Figure 2 A schematic diagram of the Spearman correlation matrix of a data set of an embodiment of the present invention;

[0031] Figure 3 Sorting the importance of features extracted by XGBoost in an embodiment of the present invention;

[0032] Figure 4 This is a diagram of the CNN-Transformer model architecture of an embodiment of the present invention;

[0033] Figure 5 This is a data graph of model performance evaluation indicators of an embodiment of the present invention;

[0034] Figure 6 It is a model performance evaluation index diagram of an embodiment of the present invention;

[0035] Figure 7 This is a DeepSHAP summary diagram of the CNN-BO-Transformer model of an embodiment of the present invention. DETAILED DESCRIPTION

[0036] It should be noted that, in the absence of conflict, the embodiments and features in the embodiments of the present application can be combined with each other. The present application will be described in detail below with reference to the accompanying drawings and in combination with the embodiments.

[0037] Example 1: Figure 1 As shown, this embodiment provides a method for predicting the corrosion rate in a natural gas pipeline, including:

[0038] S1. Collect the corrosion data set of the coupon test inside the natural gas pipeline;

[0039] Specifically, the experimental data of a gas field hanging in Northwest China were collected. The experimental data set contained 2548 records, and 9 measured factors affecting the internal corrosion rate were considered as input variables for training the neural network model. They included 1) temperature, °C; 2) Cl ion content, mg / L; 3) pressure, MPa; 4) CO2 partial pressure, MPa; 5) liquid flow rate, m / s; 6) liquid wall shear force, Pa; 7) gas wall shear force, Pa; 8) liquid holdup; 9) gas flow rate, m / s. The corrosion rate is the output variable, in mm / year.

[0040] S2, analyzing and preprocessing the coupon test corrosion data set, and dividing the preprocessed data set into a training set and a test set;

[0041] S21. Perform Spearman correlation matrix analysis on the experimental sample data to observe the strength of the correlation between the experimental data. Figure 2 As shown, the Spearman correlation matrix diagram of the data set;

[0042] S22. Use XGBoost to extract feature importance for the experimental sample data. The top three factors that have the greatest impact on the internal corrosion rate in the pipeline are: pressure, liquid wall shear force, and liquid holdup. Figure 3 As shown, a schematic diagram of the importance ranking of features extracted by XGBoost;

[0043] S23. Normalize the experimental sample data and split it into a training set and a test set in a ratio of 8:2.

[0044] S3. Establish a CNN-BO-Transformer model, wherein the CNN-BO-Transformer model includes a CNN network and a Transformer model optimized using Bayesian optimization (BO); Figure 4 As shown in the figure, the CNN-Transformer model architecture diagram.

[0045] S4, inputting the training set into the CNN network for feature extraction, inputting the output data of the CNN network into the Transformer model optimized by Bayesian optimization (BO), outputting the predicted value of the corrosion rate in the natural gas pipeline, and obtaining a trained CNN-BO-Transformer model;

[0046] S41: Input the above training set into the CNN network and use one-dimensional convolution for feature extraction, where the convolution kernel is 3 and 0 is padded to 1. The convolution kernel is set to 3 to ensure that more detailed information can be captured during the convolution operation and improve the performance of the convolution layer. 0 padding ensures that all feature parameters can be retained. In order to retain all the extracted feature parameters, the pooling layer is not used to reduce the dimension of the feature.

[0047] S42: After two CNN network feature extractions, the output data is input into the Transformer model, the Transformer model is TransformerEncoder, and the hyperparameters of the Transformer model are optimized using Bayesian optimization (BO), mainly including the number of heads in the multi-head attention, the number of sub-encoder layers of the encoder, the loss rate and the learning rate, and the optimal hyperparameters of the model are obtained when the number of heads in the multi-head attention is 3, the number of sub-encoder layers of the encoder is 3, the loss rate is 0.035, and the learning rate is 0.0006;

[0048] S43: Input data passes through the Transformer model and outputs the predicted value.

[0049] S5. Input the test set into the trained CNN-BO-Transformer model to evaluate the model performance.

[0050] In this example, the performance of this model is evaluated with traditional machine learning models, Transformer, and CNN-Transformer. The coefficient of determination (R 2 ), root mean square error (RMSE), and mean absolute error (MAE) to evaluate the performance of the model. The performance evaluation index data of the six models are as follows: Figure 5 The CNN-BO-Transformer model developed in this embodiment is better than the unoptimized model R 2 The performance was improved by 0.035, which was the best in performance evaluation (R 2 =0.9807, RMSE=0.061, MAE=0.0181), which proves the effectiveness and accuracy of the model;

[0051] In this embodiment, six model performance evaluation index diagrams are shown as follows: Figure 6 shown.

[0052] S6. Using DeepSHAP to calculate the feature contribution value of each variable in the experimental corrosion data set, generating a summary graph based on the feature contribution value, and using the summary graph to explain the CNN-BO-Transformer model;

[0053] Furthermore, the process of explaining the CNN-BO-Transformer model includes:

[0054] Using DeepSHAP to calculate the feature contribution value of each variable in the experimental corrosion data set, generating a summary graph based on the feature contribution value, and using the summary graph to explain the CNN-BO-Transformer model;

[0055] Obtaining a second feature importance ranking based on the summary graph, and comparing the first feature importance ranking with the second feature importance ranking;

[0056] Specifically, in order to better explain the model, we used the SHAP algorithm, DeepSHAP, which focuses on explaining deep learning networks. This method uses SHAP values ​​to capture the marginal impact of each parameter on the prediction, while considering the interactions between these parameters and evaluating all possible combinations. DeepSHAP enables us to determine which parameters are driving specific predictions and their respective contributions.

[0057] The effect of input features on the internal corrosion rate is visualized, such as Figure 7 As shown, the DeepSHAP summary diagram of the CNN-BO-Transformer model; at the same time, the feature importance ranking obtained by DeepSHAP to explain the CNN-BO-Transformer model and the feature importance ranking extracted by XGBoost are compared; Figure 7 It can be seen that the most important and the least important are pressure and Cl ion content, while the liquid wall shear force varies greatly. Since the wall shear force mainly affects the corrosion rate by affecting the adhesion and peeling of corrosion products, it is usually not very important. It is highlighted that the model proposed in this embodiment is more suitable for the prediction of corrosion rate in natural gas pipelines.

[0058] The above are only preferred specific implementations of the present application, but the protection scope of the present application is not limited thereto. Any changes or substitutions that can be easily thought of by a person skilled in the art within the technical scope disclosed in the present application should be included in the protection scope of the present application. Therefore, the protection scope of the present application should be based on the protection scope of the claims.

Claims

1. A method for predicting corrosion rate in a natural gas pipeline, characterized in that: The following steps are involved: The corrosion data set of the natural gas pipeline internal hanging test was collected. The corrosion data set contains the measurement factors and corrosion rates that affect the internal corrosion rate. The measurement factors include 1) temperature, °C; 2) Cl ion content, mg / L; 3) pressure, MPa; 4) CO2 partial pressure, MPa; 5) liquid flow rate, m / s; 6) liquid wall shear force, Pa; 7) gas wall shear force, Pa; 8) liquid holdup; 9) gas flow rate, m / s; The unit of corrosion rate is mm / year; The coupon experimental corrosion data set is analyzed and preprocessed, including: performing Spearman correlation matrix analysis on the experimental corrosion data set to obtain the correlation between the experimental corrosion data sets; using XGBoost to extract feature importance of the experimental corrosion data set to obtain a first feature importance ranking; normalizing the experimental corrosion data set to obtain a preprocessed data set; and dividing the preprocessed data set into a training set and a test set; Establish a CNN-BO-Transformer model, where the CNN-BO-Transformer model includes a CNN network and a Transformer model optimized using Bayesian optimization BO; Inputting the training set into the CNN network for feature extraction, inputting the output data of the CNN network into the Transformer model optimized by Bayesian optimization BO, outputting the predicted value of the corrosion rate in the natural gas pipeline, and obtaining a trained CNN-BO-Transformer model; Input the test set into the trained CNN-BO-Transformer model to evaluate the model performance; DeepSHAP is used to calculate the feature contribution value of each variable in the experimental corrosion data set, a summary graph is generated based on the feature contribution value, and the CNN-BO-Transformer model is explained using the summary graph.

2. The method for predicting the corrosion rate in a natural gas pipeline according to claim 1, characterized in that: The process of inputting the training set into the CNN network for feature extraction includes: Performing feature extraction on the training set based on the one-dimensional convolution of the CNN network, wherein the convolution kernel of the one-dimensional convolution is 3 to capture detail information, and 0 padding is set to 1 to retain all feature parameters; After two CNN network feature extractions, the output data of the CNN network is obtained.

3. The method for predicting the corrosion rate in a natural gas pipeline according to claim 1, characterized in that: The hyperparameters of the Transformer model include the number of heads in the multi-head attention, the number of sub-encoder layers of the encoder, the dropout rate, and the learning rate.

4. The method for predicting the corrosion rate in a natural gas pipeline according to claim 1, characterized in that: The process of interpreting the CNN-BO-Transformer model includes: Using DeepSHAP to calculate the feature contribution value of each variable in the experimental corrosion data set, generating a summary graph based on the feature contribution value, and using the summary graph to explain the CNN-BO-Transformer model; A second feature importance ranking is obtained based on the summary graph, and the first feature importance ranking is compared with the second feature importance ranking.

Citation Information

Patent Citations

  • Short-term power load prediction method based on SMBO-BiGRU-Attention

    CN117875365A

  • Oil and gas pipeline corrosion rate prediction method and system based on interpretable ensemble learning

    CN118690910A