Crude oil pipeline wax precipitation rate prediction method based on whale algorithm optimized BP neural network
By introducing the whale algorithm optimization technology into the BP neural network, the problems of slow convergence and poor prediction accuracy of the traditional BP neural network in predicting the wax deposition rate of crude oil pipelines are solved, and a more efficient and stable wax deposition rate prediction is achieved to ensure ensure the safe and efficient operation of oil pipelines.
Patent Information
- Application Number
- CN202410953986.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-07-11
- Publication Date
- 2024-10-01
AI Technical Summary
The traditional BP neural network has problems such as slow convergence speed, poor prediction accuracy and unstable prediction when predicting the wax deposition rate of crude oil pipelines. This is mainly due to the random selection of the initial neural network weights and thresholds, which leads to uncertainty and instability in the prediction results.
The whale algorithm is used to optimize the BP neural network. By taking the wax deposition rate of the crude oil pipeline as the objective function, the whale algorithm is used to optimize the weights and thresholds of the BP neural network, and a mapping model between the independent variables and the objective function is established to achieve wax deposition in the crude oil pipeline. Effective prediction of velocity.
It improves the convergence speed and prediction accuracy of the BP neural network, enhances the stability of the prediction results, significantly reduces the average absolute error, root mean square error and average absolute percentage error, and provides a more accurate prediction of the wax deposition rate of crude oil pipelines. Help develop a reasonable pigging cycle to ensure the smooth, safe and efficient operation of oil pipelines.
Smart Images

Figure CN118734890A_ABST
Abstract
Description
Technical Field
[0001] The invention relates to a crude oil pipeline wax deposition rate prediction method based on a whale algorithm (WOA) optimized BP neural network (whale algorithm optimized BP neural network), and belongs to the field of petroleum and natural gas industry. Background Art
[0002] More than 80% of the crude oil produced in my country is waxy crude oil with high freezing point, high viscosity and high wax content, with wax content ranging from about 10% to 37%, and some even exceeding 40%. Under typical reservoir conditions (pressure of 55-103MPa and temperature of 70-120℃), the wax in this crude oil is completely dissolved in the crude oil in liquid form, making the crude oil present a low-viscosity Newtonian fluid state. However, during pipeline transportation, due to changes in the internal environment of the pipeline, a temperature difference will occur between the crude oil and the pipeline, resulting in a heat transfer effect, causing the crude oil to gradually cool down. When the oil temperature drops below the wax precipitation point, the wax crystals dissolved in the crude oil will gradually precipitate and form wax deposits on the pipe wall over time. Wax deposition will reduce the effective oil flow area of the pipeline, increase the friction resistance of the pipeline, reduce the pipeline's transportation capacity, and also increase the transportation cost, difficulty and risk. If wax deposition leads to pipeline blockage and pressure accumulation, it may cause production safety accidents and cause immeasurable damage to the ecological environment and the lives and health of personnel. In order to prevent wax deposition from causing production safety problems and ensure the smooth operation of waxy crude oil pipelines, it is necessary to accurately understand the pipeline wax deposition rate and formulate a reasonable cleaning cycle.
[0003] In terms of the research on wax deposition rate prediction based on theoretical models, in China, in 2019, Ye Bing et al. used OLGA software to simulate and analyze the uninsulated waxy crude oil pipeline of a deepwater oil field in the South China Sea, and studied the wax deposition law of deepwater waxy crude oil pipelines. In the same year, Zhang Zaixiao et al. established a wax deposition rate prediction model for the Liuhua 16-2 oilfield pipeline through an indoor loop wax deposition experiment, and introduced the concept of the total amount of wax per unit time for the entire pipeline, describing the wax deposition rate of the entire pipeline. In foreign countries, in 2019, Giancarlo et al. used two commercial software, OLGA and LedaFlow, to simulate the wax deposition process in pipelines under multiphase flow, and simulated and predicted the wax deposition rate in the pipeline based on actual working condition data. In addition, in 2021, Yu X et al. conducted a wax deposition experiment for gas-liquid two-phase flow in a vertical pipeline, and predicted the wax deposition rate by observing the evolution of the wax layer and the average wax layer thickness.
[0004] There are two main factors that affect wax deposition: one is the physical properties of crude oil, such as the wax precipitation point, the freezing point, and the viscosity; the other is the transportation temperature of crude oil, the temperature difference between crude oil and the pipe wall, the flow rate of crude oil, the flow rate of pipeline, and the operation time of pipeline. The wax content in crude oil is the main factor causing wax deposition on the pipe wall. Generally speaking, the higher the wax content, the more serious the wax deposition on the pipe wall, but when there are colloids and asphaltene in the crude oil, the wax deposition mechanism will be weakened. The effect of crude oil temperature on wax deposition depends on factors such as the wax precipitation point, the oil wall temperature difference, and the crude oil flow rate. Under the same flow rate and oil wall temperature difference, the wax deposition rate in different temperature sections is not the same. Therefore, the wax deposition process is very complicated, and it is affected by a variety of external working conditions from the precipitation of wax crystals to the formation of wax deposition. The main influencing mechanisms include factors such as temperature, pressure, oil wall temperature difference, and flow rate. The prediction of wax deposition rate is a complex nonlinear mapping problem affected by multiple factors. The BP neural network algorithm has a strong nonlinear mapping ability, but the traditional BP network algorithm has problems such as slow convergence speed, poor prediction accuracy, and unstable prediction. These problems mainly stem from the random selection of initial neural network weights and thresholds, which leads to uncertainty and instability in the prediction results. To solve these problems, researchers proposed a method based on the whale algorithm to optimize the BP neural network for predicting the wax deposition rate of crude oil pipelines. This method aims to improve the convergence speed, improve the prediction accuracy, and enhance the stability of the prediction results. Summary of the invention
[0005] The purpose of the present invention is to provide a method for predicting the wax deposition rate of crude oil pipelines based on a whale algorithm-optimized BP neural network, which can predict the wax deposition rate of crude oil pipelines online, thereby adjusting the cleaning cycle and other operations according to the wax deposition rate of crude oil pipelines to ensure the smooth, safe and efficient operation of oil pipelines.
[0006] The present invention adopts the wax deposition rate of crude oil pipeline as the objective function, and defines six parameters as independent variables: temperature difference, viscosity, wall shear stress, average flow rate, temperature gradient at the wall, and wax molecule concentration gradient at the wall. Through detailed analysis and normalization of these independent variables and objective functions, a mapping model between independent variables and objective functions is established. The BP neural network optimized by the whale algorithm is continuously trained and learned, thereby realizing effective prediction of the wax deposition rate of crude oil pipeline.
[0007] The method involves using a BP neural network optimized based on the whale algorithm to predict the wax deposition rate of crude oil pipelines. The specific steps include:
[0008] Step 1: Collect experimental data of wax deposition in crude oil pipelines, perform data segmentation processing, and normalize the data;
[0009] Step 2: Initialize the BP neural network, set the number of training rounds, learning rate and target accuracy, and determine the network architecture;
[0010] Step 3: Set the parameters of the Whale Optimization Algorithm (WOA) and define the mean square error of the training set and the test set as the fitness function;
[0011] Step 4: Calculate the fitness value of each whale and record the whale position corresponding to the optimal fitness value;
[0012] Step 5: Update the algorithm parameters a, A, P, l that control the search behavior;
[0013] Step 6: Determine the whale's position update strategy based on whether the P value is greater than 0.5 and whether the A value is greater than 1;
[0014] Step 7: Check whether the termination condition of the algorithm is met, such as reaching the maximum number of iterations, and output the optimal initial weight and threshold; if the termination condition is not met, return to step 4 and repeat;
[0015] Step 8: Set the obtained optimal initial weights and thresholds into the neural network;
[0016] Step 9: Calculate the output error of the BP neural network;
[0017] Step 10: If the output error does not reach the set learning accuracy or the maximum number of training times, update the weights and thresholds, return to step 9 and repeat; if any termination condition is met, denormalize the result and output the final prediction result.
[0018] Advantages of the invention:
[0019] The whale optimization algorithm is combined with the BP neural network to establish a prediction model for the wax deposition rate of crude oil pipelines. Compared with the traditional BP neural network prediction model, the mean absolute error, root mean square error and mean absolute percentage error of the WOA-BP neural network prediction model are greatly reduced. It is proved that the introduction of the whale optimization algorithm can avoid the low prediction accuracy of the BP neural network algorithm due to falling into the local optimal point. The model can be used to quickly and accurately predict the wax deposition rate of crude oil, which is helpful to study the internal mechanism of wax deposition in crude oil pipelines and provide a theoretical basis for formulating a reasonable cleaning cycle.
[0020] The present invention discloses a crude oil pipeline wax deposition rate prediction method based on a whale algorithm and a BP neural network, which is convenient, real-time and online, and is of great significance for ensuring the smooth, safe and efficient operation of oil pipelines. The present invention can accurately predict the wax deposition rate of crude oil pipelines, has a wide range of applications, and has a high degree of accuracy. BRIEF DESCRIPTION OF THE DRAWINGS
[0021] Figure 1This is a flow chart of the wax deposition rate prediction method based on the whale algorithm to optimize the BP neural network.
[0022] Figure 2 This is the fitness curve of the wax deposition rate prediction method based on the whale algorithm to optimize the BP neural network.
[0023] Figure 3 Comparison between the predicted output and expected output of the BP neural network and the whale algorithm for optimizing the BP neural network to predict the wax deposition rate in pipelines.
[0024] Figure 4 Comparison of the errors in predicting pipeline wax deposition rate using BP neural network and whale algorithm-optimized BP neural network.
[0025] Table 1 is an example of the implementation of wax deposition rate based on the whale algorithm to optimize the BP neural network. DETAILED DESCRIPTION
[0026] The following is combined with Figure 1 The method of the present invention is described in further detail:
[0027] The wax deposition rate prediction method based on the whale algorithm to optimize the BP neural network, the specific process is shown in Figure 1 , the steps include:
[0028] Determine the initial structure of BP neural network
[0029] Usually, when designing a BP neural network, a three-layer network (i.e., one hidden layer) should be given priority. Although increasing the number of hidden layers in the BP neural network can reduce calculation errors and improve calculation accuracy, it will make the structure of the BP neural network more complex, thereby extending the training time of the BP neural network and increasing the tendency of the BP neural network to "overfit".
[0030] The neural network designed and used in the present invention has three layers of networks.
[0031] The input quantities of the BP neural network input layer include the temperature difference, viscosity, wall shear stress, average flow velocity, wall temperature gradient and wall wax concentration gradient of the crude oil pipeline.
[0032] The number of nodes in the output layer is 1; the number of nodes in the hidden layer is determined by the empirical formula for calculating the number of elements in the hidden layer. The commonly used empirical formula is as follows:
[0033]
[0034] Among them, n is the number of nodes in the input layer of the BP neural network, m is the number of nodes in the hidden layer of the BP neural network, α is a constant between 1 and 10, and i is the number of nodes in the output layer. From the empirical formula, it can be seen that when m=6, the optimal number of hidden layer nodes calculated should be 9;
[0035] In order to facilitate calculation and comparison, the neurons in the input layer and output layer need to be normalized. The normalization formula is:
[0036]
[0037] Among them, x i is the eigenvalue before normalization, x max 、x min are the maximum and minimum eigenvalues before normalization, i is the eigenvalue number, representing the i-th eigenvalue, i∈1,…,n; y max ,y min It is the expected maximum and minimum value after normalization, and generally defaults to 1 and -1.
[0038] The output layer of the BP neural network has only one output, namely the wax deposition rate of the crude oil pipeline, so the output layer of the BP neural network has only one neuron.
[0039] Considering the characteristics of wax deposition rate, linear transfer functions are used between the input layer, hidden layer and output layer. Therefore, the transfer function of the output layer neurons uses the S-type logarithmic function logsig(), and the transfer function of the hidden layer neurons of the neural network uses the S-type tangent function tansig(). This is because the output mode 0-1 just meets the output requirements of the network. After many experiments, the number of training times is set to 800 and the training target is set to 10 -3 , the learning rate is set to 0.01.
[0037] In the whale algorithm to optimize the BP neural network calculation, the prediction error of the BP neural network is used as the fitness value. For non-compliant situations, it is optimized using methods such as contraction-surrounding mechanism, spiral bubble net predation, random search, etc., and it is iteratively updated. When the fitness conditions are met, the optimization results are used as the optimal weights and thresholds of the BP neural network.
[0040] This example takes the wax deposition rate of the pipeline as the target. Figure 3 , Figure 4 This paper gives an example of the wax deposition rate prediction method based on the whale algorithm to optimize the BP neural network.
[0041] Initialize BP network structure
[0042] It includes setting the number of neurons and learning rate of the network's input layer, hidden layer, and output layer, as well as the input and output of training samples.
[0043] Select an encoding scheme
[0044] Before using the whale algorithm to solve the problem, the solution space of the problem is encoded. To ensure the high accuracy of the network weights and thresholds, Gu uses real number encoding, that is, the entire network weight and threshold distribution is represented by a set of real number strings, and each individual represents a real number string consisting of the connection weights of the input layer and the hidden layer, the connection weights of the hidden layer and the output layer, the hidden layer threshold, and the output layer threshold.
[0045] Determine the fitness function
[0046] The fitness function is established by the sum of squared errors between the network's predicted output value and the expected output value, and the calculation formula is:
[0047]
[0048] Where: k is the coefficient; n is the number of network output nodes; yi is the expected value of the ith node of the BP neural network; o i is the predicted value of the i-th node.
[0049] Surrounding the prey
[0050] In the stage of surrounding the prey, the whale closest to the prey is first defined as the best whale, and then other whales update their own positions according to the position of the best whale, thereby surrounding the prey. The mathematical formula corresponding to this process is:
[0051]
[0052] In the formula: In the formula: λ is the number of iterations; x'(λ) is the position of the best whale; x(λ) is the current position of the whale; A is the coefficient variable; a is the convergence factor, and will gradually decrease linearly from 2 to 0 as λ increases; r1 and r2 are random numbers between [0, 1].
[0053] Bubble Net Attack
[0054] After entering the bubble net attack phase, the humpback whale will not only further shrink the encirclement, but also spiral upward toward the prey. Assuming that the probability of choosing these two behaviors is the same, the updated position of the whale is calculated according to the following formula:
[0055]
[0056] Wherein: b is the logarithmic spiral shape constant; 1 is a random number between [-1, 1].
[0057] Searching for prey
[0058] During the prey search phase, the whales will randomly select a whale from the population to approach, thereby improving the global search capability of the whale group. The mathematical formula for this process is:
[0059] x(λ+1)=xrand (λ)-A·|2r2·x rand (λ)-x(λ)| (6)
[0060] Where: x rand (λ) is the randomly selected whale position to approach.
[0061] Output optimal end
[0062] When the stop operation condition is met, the maximum number of training times is reached and the optimization process ends; if the accuracy requirements are not met, it is necessary to return and recalculate.
[0063] In order to compare the differences between the BP neural network and the BP neural network optimized by the whale algorithm, the present invention lists the error comparison between the BP neural network and the BP neural network optimized by the whale algorithm under the same pipeline operation conditions, such as Figure 4 As shown. Five groups of data were randomly selected to verify the model. The comparison shows that the prediction effect of the improved model is significantly improved.
[0064] The present invention takes the experimental data of wax deposition rate of crude oil pipeline by previous researchers as an example. After the whale algorithm optimizes the BP neural network model to complete the training and learning, the neural network of 30 working conditions is used for identification verification. The verification results are as follows: Figure 3 , Figure 4 In this example, the average absolute percentage error of the five groups of wax deposition rates is 2.8429%, which is sufficient for industrial applications. Table 1 Wax deposition rate data of some crude oil pipes
Claims
1. The method for predicting the wax deposition rate of crude oil pipelines based on the whale algorithm (WOA) optimized BP neural network described in this claim is characterized by: The prediction results are more accurate, rely on fewer key parameters, and have stronger global search performance.
2. The whale algorithm described in this claim optimizes the BP neural network structure, mainly: using the whale algorithm to optimize the BP neural network to establish a prediction model, using the prediction error of the BP neural network as the fitness value of the whale algorithm, and using the shrinking and surrounding mechanism, spiral bubble net predation and random prey search operations of the whale algorithm to adjust individuals that do not meet the fitness conditions. Subsequently, through iterative updates, when the fitness value meets the conditional requirements, the optimization results are used as the optimal weights and thresholds of the BP neural network. Finally, the optimized initial connection weights and thresholds are used as the initial state of the neural network to train and predict the sample data to accelerate the convergence speed of the neural network and improve the prediction accuracy. This method can effectively improve the performance and prediction ability of the BP neural network.
3. This claim covers a neural network structure optimized by the whale algorithm, the notable feature of which is that the population position is updated by setting the best search agent and the random search agent, which has the advantages of simple principle, few adjustable parameters and strong optimization ability. This method effectively reduces the problem of falling into local minima and overfitting when using BP neural network alone. The main optimization steps include: Step 1: Normalize the data, establish a BP neural network, determine the network topology, and initialize the network weights and thresholds; Step 2: Initialize the parameters of the whale algorithm, calculate the decision length, and select the mean square error as the objective function for optimization; Step 3: Set the stopping criteria of the algorithm and use the whale algorithm to optimize the weights and threshold parameters of the BP neural network; Step 4: Apply the optimal weights and threshold parameters optimized by the whale algorithm to the BP neural network, and output the optimized WOA-BP model. Use this model for training and prediction, and compare and analyze it with the BP network before optimization. After completing these steps, the prediction model of crude oil pipeline wax deposition rate was successfully established based on the BP neural network optimized by the whale algorithm.
Citation Information
Cited By
Method and system for predicting stress of buried natural gas pipeline under action of landslide
CN121543355A
Method and system for predicting stress of buried natural gas pipeline under landslide action
CN121543355B
