Novel hybrid algorithm method for predicting CO2 internal corrosion rate of tight gas pipeline

The integration of QPSO and DE with BNN stabilizes tight gas pipeline CO2 corrosion rate predictions, addressing structural and parameter issues for accurate corrosion rate estimation.

CN120316441APending Publication Date: 2025-07-15SOUTHWEST PETROLEUM UNIV
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202510427607.6
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-04-07
Publication Date
2025-07-15

AI Technical Summary

Technical Problem

The prior art is difficult to accurately predict the CO2 corrosion rate in tight gas pipelines, especially considering complex mechanisms such as electrochemical corrosion, microbial corrosion and under-scale corrosion of aqueous phase, carbon dioxide and condensate in multiphase flows.

Method used

The integrated QPSO-DE-BNN neural network algorithm is adopted to determine the number of hidden layer nodes and differential evolution optimization weights through quantum particle swarm optimization, combine PCA dimensionality reduction processing data, build multiple BNN sub-models and integrate prediction results, solving the structural instability of traditional models and easy-to-be-pooling problems of local optimization.

Benefits of technology

Accurate prediction of the corrosion rate in CO2 in tight gas pipelines is achieved, with the corrosion prediction error being less than 10%, and the root mean square error RMSE is 0.0125, which improves the accuracy and stability of corrosion prediction.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120316441A_ABST
    Figure CN120316441A_ABST
Patent Text Reader

Abstract

The invention discloses a novel hybrid algorithm method for predicting the CO2 internal corrosion rate of a tight gas pipeline. Aiming at the problem of corrosion perforation of the tight gas pipeline, key corrosion factors such as CO2 partial pressure, pH value and water accumulation probability are comprehensively considered, and a model integrating a neural network (BNN), a quantum particle swarm optimization (QPSO) algorithm and a differential evolution (DE) algorithm is provided. QPSO is used for determining the number of nodes of a BNN hidden layer, DE is used for optimizing the weight of a model, and dimension reduction processing is carried out on multiple corrosion factors through principal component analysis (PCA) so as to reduce data redundancy. And a Bagging integration algorithm is introduced, and a plurality of BNN model results are fused to improve the prediction precision. Experiments prove that the maximum relative error of the corrosion prediction result is-9.27%, and the prediction precision is obviously superior to that of a traditional model. A new scheme is provided for tight gas pipeline corrosion prediction, the method is suitable for conventional conveying temperature, pressure and flow conditions, and powerful technical support is provided for pipeline maintenance and safe operation.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to a new hybrid algorithm for predicting the internal corrosion rate of CO2 in tight gas pipelines, and relates to the field of corrosion prediction of oil and gas pipelines. Background Technique

[0002] The components transported by tight gas pipelines are complex. In addition to methane, there are also water, condensate oil, carbon dioxide, etc. to form multiphase flow. The water phase, carbon dioxide, and condensate oil interact with each other to form mechanisms such as electrochemical corrosion, microbial corrosion, and under-deposit corrosion, which damage the pipeline and cause problems such as corrosion perforation. Therefore, it is urgent to carry out research on predicting the corrosion rate of tight gas pipelines.

[0003] BNN is a probability model that integrates Bayesian statistical theory and deep learning framework. Different from traditional neural networks, BNN regards the weight parameters in the network as probability distributions rather than fixed values, and realizes the quantitative evaluation of model uncertainty through Bayesian inference. The number of hidden layer nodes of BNN determined by QPSO and the weights of BNN optimized by DE are used to train multiple BNN sub-models. Multiple training subsets are generated through Bootstrap sampling to enhance model diversity. Therefore, the present invention is based on the integrated QPSO-DE-BNN neural network algorithm, and establishes a method for a new hybrid algorithm for predicting the internal corrosion rate of CO2 in tight gas pipelines, specifically solving the problem of tight gas pipeline corrosion prediction, and escorting the integrity of oil and gas pipelines. Summary of the Invention

[0004] The purpose of the present invention is to overcome the above-mentioned disadvantages of the prior art, deeply integrate quantum particle swarm optimization (QPSO), differential evolution (DE) and binary Bayesian neural network (BNN), and solve the problems of unstable traditional model structure and easy to fall into local optimum of parameters through a three-level collaborative mechanism of structure optimization-parameter optimization-ensemble learning, so as to realize the accurate construction of the corrosion rate prediction model.

[0005] This method for a new hybrid algorithm for predicting the internal corrosion rate of CO2 in tight gas pipelines specifically includes the following steps:

[0006] Step 1: Obtain the collected data;

[0007] Step 2: Perform PCA dimensionality reduction processing on the data;

[0008] Step 3: Construct a BNN neural network prediction model;

[0009] Step 4: Use the QPSO algorithm to obtain the optimal number of hidden layer nodes of the BNN neural network;

[0010] Step 5: Set the number of hidden layer nodes of the BNN model according to the result of Step 4, and use DE to optimize the BNN weight parameters;

[0011] Step 6: Establish multiple BNN neural network models using the number of hidden layer nodes output by QPSO and the weight parameters optimized by DE;

[0012] Step 7: Integrate the prediction results of multiple models to obtain the final prediction result.

[0013] Furthermore, the corrosion factors of the tight gas pipeline included in the sampled data in Step 1 include 7 corrosion factors such as operating temperature (°C), total pressure, CO2 partial pressure, gas flow rate, liquid flow rate, water accumulation probability, and pH.

[0014] Furthermore, Step 2 specifically includes the following steps:

[0015] Step 2.1: Standardize the data to obtain the standardized matrix Z;

[0016] Step 2.2: Calculate the covariance matrix;

[0017] Step 2.3: Calculate the eigenvalues;

[0018] Step 2.4: Calculate the principal component score matrix T.

[0019] Furthermore, Step 2.1 is specifically as follows:

[0020] First, calculate the mean and standard deviation of each corrosion factor. The mean and standard deviation calculation formulas are as follows:

[0021]

[0022]

[0023] In Equation (1), X ij is the i-th data of the j-th corrosion factor, is the mean of the j-th corrosion factor;

[0024] In Equation (2), S j is the standard deviation of the j-th factor;

[0025] Finally, use the standardization formula to process the data to obtain the standardized matrix Z. The standardization formula is:

[0026]

[0027] In Equation (3), Zij represents the i-th data of the j-th corrosion factor.

[0028] Furthermore, Step 2.2 is specifically as follows:

[0029] Calculate the covariance matrix according to the covariance matrix calculation formula. The covariance matrix calculation formula is:

[0030]

[0031] In formula (4), R is the covariance matrix.

[0032] Furthermore, step 2.3 is specifically as follows:

[0033] Perform eigenvalue decomposition on the covariance matrix. Let the eigenvalues of R be λ1 ≥ λ2 ≥ λ3 ≥... ≥ λ k ≥ 0, and the corresponding eigenvectors be V1, V2,... V k . λ k , V k respectively represent the Kth eigenvalue and eigenvector.

[0034] Furthermore, step 2.4 is specifically as follows:

[0035] Calculate the principal component score matrix T according to the principal component score formula. The principal component score formula is:

[0036]

[0037] In formula (5), Z i is the ith row of the standardized data matrix Z, and t ik represents the score of the ith sample on the kth principal component.

[0038] Furthermore, step 4 specifically includes the following steps:

[0039] Step 4.1: Perform grid initialization processing on the QPSO-BNN-based algorithm model;

[0040] Step 4.2: Determine the individual fitness through iterative operations and update the parameters of the position according to the results;

[0041] Step 4.3: Determine whether the iteration of the prediction model ends. If the number of iterations reaches the maximum value or the target threshold is reached after iteration, the iteration ends; otherwise, return to 4.2 for iteration.

[0042] Furthermore, step 4.1 is specifically as follows:

[0043] For the grid initialization processing, the initialization objects are the number of parameters optimized using the QPSO algorithm, the total number of particles used for optimization, the maximum number of iterations, the upper and lower bounds of each particle, the contraction and expansion coefficient β, the random number μ, and the acceptable mean square error used to determine whether to end the use.

[0044] Furthermore, step 4.2 is specifically as follows:

[0045] After the data is reduced in dimension by PCA, it is used as the training set and input into the QPSO-BNN model;

[0046] By iteratively calculating the individual optimal position P best,i and the global optimal value g best , substituting into the average value formula of all particle individual optimal positions to calculate the average value m of all particle individual optimal positions best ;

[0047] According to the concept of quantum interference, that is, the particles in QPSO will affect each other, increasing the diversity of the search and preventing falling into local optimal solutions, update the particle positions, then the double-optimal guiding position P i formula, the average value formula of all particle individual optimal positions, and the particle position update formula are as follows:

[0048] P i = P best,i + rand×(g best - P best,i ) (6)

[0049]

[0050]

[0051] In formula (6), P i is composed of the individual optimal P best,i of the particle and the global optimal position g best , and is a kind of guidance for the particle to find the global optimal number of hidden layer nodes;

[0052] In formula (8), X i (t + 1) is the position of particle i at the (t + 1)-th iteration after update, P i is composed of the individual optimal p best,i of the particle and the global optimal position g best , β is the contraction and expansion coefficient, X i (t) is the position of the particle at the t-th iteration, and μ is a random number uniformly distributed in the interval [0, 1].

[0053] Furthermore, the specific content of step 4.3 is as follows:

[0054] After using the QPSO algorithm to seek the optimal solution once, calculate the mean square error MSE predicted by the BNN network after each optimization. If the mean square error MSE predicted by the BNN network is less than the set limit mean square error, stop the iteration; or, when the number of iterations reaches the maximum value, stop the iteration; otherwise, return to step 4.2 to re-iterate.

[0055] Furthermore, step 5 specifically includes the following steps:

[0056] Step 5.1, set the number of BNN hidden layer nodes output by step 4;

[0057] Step 5.2: Initialize the parameters of the DE algorithm;

[0058] Step 5.3: Calculate the individual fitness value through iterative operations and determine whether the new parameters replace the old parameters;

[0059] Step 5.4: Determine whether the iteration of the prediction model ends. If the number of iterations reaches the maximum value or the target threshold is reached after iteration, the iteration ends; otherwise, return to 5.3 for iteration.

[0060] Furthermore, the specific content of Step 5.2 is as follows:

[0061] The parameters for initializing the DE algorithm are the initial population size, the maximum number of iterations, the mutation factor (F), the crossover rate (CR), the weight boundary range, and the acceptable mean square error used to determine whether to end the use.

[0062] Furthermore, the specific content of Step 5.3 is as follows:

[0063] Part of the data after PCA dimensionality reduction is used as the training set and input into the DE-BNN model;

[0064] Mutant individuals, that is, the new weights of the BNN, are generated by linearly combining different individuals randomly selected from the population. The formula for generating mutant individuals is as follows:

[0065] V i (t) = X r1 (t) + F · (X r2 (t) - X r3 (t)) (9)

[0066] In Equation (9), X i (t) is the weight parameter set of the BNN neural network, and r1 ≠ r2 ≠ r3. The F formula is the mutation factor that controls the scaling of the difference vector (X r2 (t) - X r3 (t)). Vi(t) is a mutant individual generated by linearly combining different individuals randomly selected from the weight parameter set;

[0067] The mutant individual Vi(t) and the target individual X i (t) generate U i (t) through a crossover operation. The binomial crossover is adopted, and the specific formula is as follows:

[0068]

[0069] In Equation (10), u ij , v ij and x ij respectively represent the trial individual U iThe j-th element of (t), the j-th element of the mutated individual Vi(t), and the j-th element of the target individual Xi(t). CR is the crossover probability, usually taking values in the range (0, 1). jrand is an integer randomly selected from {1, 2,.., n} (n is the individual dimension, i.e., the number of BNN weights). When j = jrand, it means that at least one decision variable of the trial individual Ui(t) comes from the individual Vi(t).

[0070] Determine whether the trial individual Ui(t) replaces the target individual Xi(t) and enters the next generation population according to the value of the objective function MSE.

[0071] Furthermore, the specific content of step 5.3 is as follows:

[0072] Continuously repeat the above mutation, crossover, and selection operations until the stopping condition is met. The stopping condition is usually reaching the maximum number of iterations or the error index of the model reaching a preset threshold. In each iteration process, new individuals are generated through the mutation operation, diversity is increased through the crossover operation, and the selection operation determines which individuals enter the next generation population, so that the population evolves continuously and gradually finds better BNN weight parameters. Otherwise, return to step 5.3 for re-iteration.

[0073] Furthermore, in step 7, multiple prediction results of the QPSO-DE-BNN ensemble model are calculated, and the results are averaged. The calculated average corrosion rate is the final corrosion rate. Description of the Drawings

[0074] Figure 1 It is a flowchart of optimizing the number of hidden layer nodes of BNN based on QPSO provided by the present invention;

[0075] Figure 2 It is the results of 7 times of using QPSO to optimize the number of hidden layer nodes of BNN provided by the present invention;

[0075] Figure 3 It is a flowchart of optimizing the BNN weights based on DE provided by the present invention;

[0076] Figure 4 It is a flowchart of a new hybrid algorithm for predicting the CO2 internal corrosion rate of tight gas pipelines based on the integrated QPSO-DE-BNN provided by the present invention;

[0077] Figure 5 It is the final corrosion rate obtained by integrating the prediction results of the model for predicting the CO2 internal corrosion rate of tight gas pipelines based on the integrated QPSO-DE-BNN provided by the present invention for the test set. Specific Implementation Method

[0078] See Figure 4As shown in the figure, the present invention provides a method for a new hybrid algorithm for predicting the internal corrosion rate of CO2 in tight gas pipelines. The specific steps are as follows:

[0079] Step 1: Obtain the on-site data of seven corrosion factors including operating temperature (°C), total pressure, CO2 partial pressure, gas flow rate, liquid flow rate, water accumulation probability, and pH contained in the corrosion factors of the tight gas pipeline.

[0080] Step 2: Perform PCA dimensionality reduction processing on the data, and divide 30% of the data as the training set and 70% as the test set. The specific process is as follows:

[0081] Step 2.1: First, calculate the mean and standard deviation of each corrosion factor. The mean and standard deviation calculation formulas are as follows:

[0082]

[0083]

[0084] In formula (1), X ij is the i-th data of the j-th corrosion factor, is the mean of the j-th corrosion factor;

[0085] In formula (2), S j is the standard deviation of the j-th factor;

[0086] Finally, use the standardization formula to process the data to obtain the standardized matrix Z. The standardization formula is:

[0087]

[0088] In formula (3), Z ij represents the i-th data of the j-th corrosion factor.

[0089] Step 2.2 is specifically:

[0090] Calculate the covariance matrix according to the covariance matrix calculation formula. The covariance matrix calculation formula is:

[0091]

[0092] In formula (4), R is the covariance matrix.

[0093] Step 2.3 is specifically:

[0094] Perform eigenvalue decomposition on the covariance matrix. Let the eigenvalues of R be λ1 ≥ λ2 ≥ λ3 ≥... ≥ λ k ≥ 0, and the corresponding eigenvectors are V1, V2,... V k . λ k , V krespectively represent the K-th eigenvalue and eigenvector.

[0095] Step 2.4 is specifically as follows:

[0096] Calculate the principal component score matrix T according to the principal component score formula, and the principal component score formula is:

[0097]

[0098] In formula (5), Z i is the i-th row of the standardized data matrix Z, and t ik represents the score of the i-th sample on the k-th principal component.

[0099] Step 3: Construct a BNN neural network prediction model, set the number of input layers to 7, and the number of final output layers to 1.

[0100] Step 4: Use the QPSO algorithm to obtain the optimal number of hidden layer nodes of the BNN neural network. The specific process is as follows:

[0101] Step 4.1: The grid initialization process, and its initialization objects are the number of parameters optimized using the QPSO algorithm, the total number of particles used for optimization, the maximum number of iterations, the upper and lower bounds of each particle, the contraction and expansion coefficient β, the random number μ, and the acceptable mean square error used to judge whether to end the use.

[0102] Part of the data after PCA dimensionality reduction is used as the training set and input into the QPSO-BNN model;

[0103] Through iterative calculation of the individual optimal position P best,i and the global optimal value g best , substitute them into the average value formula of all particle individual optimal positions to calculate the average value m best ;

[0104] According to the concept of quantum interference, that is, the particles in QPSO will affect each other, increasing the diversity of the search and preventing falling into local optimal solutions, update the particle positions. Then the double-optimal guiding position P i formula, the average value formula of all particle individual optimal positions, and the particle position update formula are:

[0105] P i = P best,i + rand × (g best - P best,i ) (6)

[0106]

[0107]

[0108] In Equation (6), P i is composed of the individual optimal P best,i of the particle and the global optimal position g best and is a guidance for the particle to find the global optimal number of hidden layer nodes;

[0109] In Equation (8), X i (t + 1) is the position of particle i at the (t + 1)-th iteration after update, and P i is composed of the individual optimal p best,i of the particle and the global optimal position g best , β is the contraction and expansion coefficient, X i (t) is the position of the particle at the t-th iteration, and μ is a random number uniformly distributed in the interval [0, 1].

[0110] Furthermore, Step 4.3 is as follows:

[0111] After each time of seeking the optimal solution using the QPSO algorithm, calculate the mean square error MSE predicted by the BNN network after each optimization. If the mean square error MSE predicted by the BNN network is less than the set limit mean square error, stop the iteration; or, when the number of iterations reaches the maximum value, stop the iteration; otherwise, return to Step 4.2 to re-iterate.

[0112] Step 5: Run the results 7 times to obtain the optimal number of hidden layer nodes as Figure 2 shown, which are 10, 14, 10, 19, 6, 14, 17 respectively.

[0113] Step 6: Optimize the weights of the BNN neural network using DE, and the specific process is as follows:

[0114] Step 6.1: According to the results of the optimal number of hidden layer nodes in Step 5, set 7 BNN models respectively.

[0115] Step 6.2: Initialize the parameters of the DE algorithm, and the parameters are the initial population size, the maximum number of iterations, the mutation factor (F), the crossover rate (CR), the weight boundary range, and the acceptable mean square error used to judge whether to end the use.

[0116] Step 6.3: Use part of the data after PCA dimensionality reduction as the training set to input the DE-BNN model;

[0117] Generate mutant individuals, that is, the new weights of the BNN, by linearly combining different individuals randomly selected from the population. The formula for generating mutant individuals is as follows:

[0118] V i (t) = X r1 (t) + F · (X r2 (t) - X r3 (t)) (9)

[0119] In Equation (9), X i (t) is the weight parameter set of the BNN neural network, and r1 ≠ r2 ≠ r3. The F-type mutation factor controls the scaling of the difference vector (X r2 (t) - X r3 (t)). Vi(t) is a mutant individual generated by randomly selecting different individuals from the weight parameter set for linear combination;

[0120] The mutant individual Vi(t) and the target individual X i (t) generate U i (t) through the crossover operation. Binomial crossover is adopted, and the specific formula is as follows:

[0121]

[0122] In Equation (10), u ij , v ij and x ij represent the j-th element of the trial individual U i (t), the j-th element of the mutant individual Vi(t), and the j-th element of the target individual Xi(t) respectively. CR is the crossover probability, usually taking values in the range of (0, 1). Jrand is an integer randomly selected from {1, 2,.., n} (n is the individual dimension, that is, the number of BNN weights). When j = jrand, it means that at least one decision variable of the trial individual Ui(t) comes from the individual Vi(t).

[0123] Determine whether the trial individual Ui(t) replaces the target individual Xi(t) and enters the next generation population according to the value of the objective function MSE.

[0124] Furthermore, Step 6.4 is specifically as follows:

[0125] Continuously repeat the above mutation, crossover, and selection operations until the stopping condition is met. The stopping condition is usually to reach the maximum number of iterations or the error index of the model reaches the preset threshold. In each iteration process, new individuals are generated through the mutation operation, diversity is increased through the crossover operation, and the selection operation determines which individuals enter the next generation population, so that the population evolves continuously and gradually finds better BNN weight parameters. Otherwise, return to Step 6.3 for re-iteration.

[0126] Step 7: Obtain a new hybrid algorithm model of QPSO-DE-BNN for predicting the CO2 internal corrosion rate of tight gas pipelines with 7 optimized hidden layer node numbers and weights.

[0127] Step 8: Integrate the prediction results of multiple models to obtain the final prediction result. The prediction result is as Figure 5As shown. The maximum value of the corrosion prediction error is -9.27%, the minimum value is 0.03%, and the root mean square error RMSE is 0.0125.

Claims

1. A method of a new hybrid algorithm for predicting the internal corrosion rate of CO2 in tight gas pipelines, specifically including the following steps: Step 1, obtain the collected data; Step 2, perform PCA dimensionality reduction processing on the data; Step 3, construct a BNN neural network prediction model; Step 4, use the QPSO algorithm to obtain the optimal number of hidden layer nodes of the BNN neural network; Step 5, set the number of hidden layer nodes of the BNN model according to the result of Step 4, and use DE to optimize the BNN weight parameters; Step 6, establish multiple BNN neural network models using the multiple numbers of hidden layer nodes output by QPSO and the weight parameters optimized by DE; Step 7, integrate the prediction results of multiple models to obtain the final prediction result.

2. A method for a new hybrid algorithm for predicting the CO2 internal corrosion rate of a tight gas pipeline according to claim 1, characterized in that, Step 5 specifically includes the following steps: Step 2.1, set the number of BNN hidden layer nodes output by Step 4; Step 2.2, initialize the DE algorithm parameters; Step 2.3, calculate the individual fitness value through iterative operations, and judge whether the new parameters replace the old parameters; Step 2.4, judge whether the prediction model iteration ends. If the number of iterations reaches the maximum value or the target threshold is reached after iteration, the iteration ends. Otherwise, return to 5.3 for iteration.

3. A method of a novel hybrid algorithm for predicting the internal corrosion rate of CO2 in a tight gas pipeline according to claim 2, characterized in that, The specific content of Step 2.2 is: The initialized DE algorithm parameters are the initial population size, the maximum number of iterations, the mutation factor (F), the crossover rate (CR), the weight boundary range, and the acceptable mean square error used to judge whether to end the use.

4. A method for a novel hybrid algorithm for predicting the internal corrosion rate of CO2 in a tight gas pipeline according to claim 2, characterized in that, The specific content of Step 2.3 is: First, part of the data after PCA dimensionality reduction is used as the training set and input into the DE-BNN model; Then, a mutant individual, that is, the new weight of the BNN, is generated by linearly combining different individuals randomly selected from the population. The formula for generating the mutant individual is as follows: Vi(t) = X r1 (t) + F·(X r2 (t) - X r3 (t))(9) In formula (9), X i (t) is the weight parameter set of the BNN neural network, and r1 ≠ r2 ≠ r3. The F-type mutation factor controls the scaling of the difference vector (X r2 (t) - X r3 (t)). Vi(t) is a mutant individual generated by randomly selecting different individuals from the weight parameter set for linear combination; The mutant individual Vi(t) and the target individual X i (t) generate U i (t) through crossover operation. The binomial crossover is adopted, and the specific formula is as follows: In Equation (10), u ij , v ij and x ij represent the j-th element of the trial individual U i (t), the j-th element of the mutant individual Vi(t), and the j-th element of the target individual Xi(t), respectively. CR is the crossover probability, usually taking values in the range (0, 1). jrand is an integer randomly selected from {1, 2,.., n} (n is the individual dimension, i.e., the number of BNN weights). When j = jrand, this means that at least one decision variable of the trial individual Ui(t) comes from the individual Vi(t); Finally, it is determined whether the trial individual Ui(t) replaces the target individual Xi(t) and enters the next generation population according to the value of the objective function MSE.

5. A method for a novel hybrid algorithm for predicting the internal corrosion rate of CO2 in a tight gas pipeline according to claim 2, characterized in that, The specific content of Step 2.4 is: Continuously repeat the above mutation, crossover, and selection operations until the stop condition is met. The stop condition is usually reaching the maximum number of iterations or the error index of the model reaching the preset threshold. In each iteration process, new individuals are generated through the mutation operation, diversity is increased through the crossover operation, and the selection operation determines which individuals enter the next generation population, so that the population evolves continuously and gradually finds better BNN weight parameters. Otherwise, return to Step 2.3 for re-iteration.

6. A method of a novel hybrid algorithm for predicting the internal corrosion rate of CO2 in a tight gas pipeline according to claim 1, characterized in that, Step 6 is to establish multiple QPSO-DE-BNN corrosion prediction models.