Research on the steady‐state operation optimization technology of oil pipeline

Most of the crude oil produced in China is highly viscous and easy to condense, and the pipeline transportation method is mostly heated. At present, frequency conversion technology is gradually applied to oil pump units. In order to find the best pipeline operation scheme, this paper is based on MATLAB programming software and established a corresponding mathematical model of oil pipeline energy consumption. This model innovatively takes the rotational speed of the variable frequency pump as one of the model optimization variables, calculating the pressure change and temperature change between stations of the pipeline, predicting the energy consumption of the pipeline and can guide the optimized operation of the pipeline, which has a high popularization and application value. An example of Qingtie Fourth‐line crude oil pipeline shows that among the genetic algorithm, particle swarm optimization, and simulated annealing algorithms for solving the optimization model, the particle swarm optimization algorithm has fast convergence speed, short optimization time, obtains the most optimal scheme, and can reduce energy consumption by 7.84%, which proves the practicability and creativity of the optimization model.


| 4065
LIU et aL. hot oil pipeline system is also the focus of many scholars' research. Through a lot of literature research, we can set the energy consumption of the pipeline system in the following two directions: 1. Improving the equipment of hot oil pipeline system Using new energy-saving equipment to replace the old equipment can greatly reduce the energy consumption of the hot oil pipeline system. Among them, the most representative is the application of frequency conversion technology in the oil pump unit, 11 because each oil pump in the long-distance pipeline oil pump unit has a long operation time and large power consumption, which greatly increases the transportation cost of oil and gas resources. At present, power frequency fixed-speed motors are mostly used in oil pump units of long oil pipelines in China, which have good operating results, high operating efficiency, and strong reliability and safety. However, the flexibility of the power frequency constant speed motor is not enough, and it cannot change the power frequency according to the flow of the long-distance pipelines. Even when the flow of long-distance pipeline is small, the operation speed of the motor still remains at the initial setting state, lacking great flexibility, which is not conducive to improving the operational efficiency of the long-distance pipeline oil pump unit. 12,13 Of course, in addition to the improvement of the oil pump, there are some other improvements in the process equipment. This paper summarizes the process equipment and technical improvements of the oil pipeline system, as shown in Table 1. 2. Improvement of the operation plan for the hot oil pipeline system Reducing energy consumption by improving the operation scheme of the hot oil pipeline system is currently the most studied method. With the continuous development of mathematics and computer science, the continuous updating of artificial intelligence technology and intelligent optimization algorithms makes the process of solving many engineering problems simple, and the solution is better. At present, computer technology has been applied in many fields to obtain optimal solutions, such as microgrid, solar energy, and renewable energy. [24][25][26][27][28][29][30][31][32] Many scholars have also proposed T A B L E 1 Improvement of process equipment or technology of the oil pipeline system Replacing expander with a turboexpander The use of gas turbine outlet gas and the waste heat of the turboexpander helps to recover energy Improve the energy efficiency of the system Golchoobian et al 2019 23 different solutions in the hot oil pipeline system, as shown in Table 2.  As can be seen from Tables 1 and 2, first of all, new equipment will gradually replace old equipment in the future, especially the application of variable frequency pumps in hot oil pipeline systems. Secondly, it is also extremely important to use optimization algorithms to optimize the model. This method can reduce the waste of resources in the empirical method and improve the operation efficiency of the pipeline system. Although there is a lot of research results in these two aspects, there are very few studies combining these two methods. This paper innovatively introduces the speed of the variable frequency pump as one of the optimization variables in the hot oil pipeline model and uses three intelligent optimization algorithms, genetic algorithm, particle swarm optimization, and simulated annealing algorithm, to solve the model. The article introduces in detail the treatment process of the variable frequency pump and the establishment process of the optimization model, which provides guidance significance for the improvement of the hot oil pipeline in the future.
The rest of the article is arranged as follows: In the second part, the paper introduces in detail the treatment method of the variable frequency pump and the detailed process of the mathematical model of the oil pipeline, including the thermal calculation, hydraulic calculation, energy consumption calculation, and the basic information of the objective function of the pipeline system. In the third part of the article, the basic parameters and actual operating data of the simulated pipeline are given. In the fourth part, we compare the pressure change, temperature change, and energy consumption calculation of the three algorithms with the actual scheme give the optimal scheme under the three algorithms, respectively, and draw the relevant conclusions in the fifth part.

| MODELS AND METHODS
The crude oil pipeline system is a complex system that contains multiple parts, each of which has a mutual influence. This complex system mainly includes the pipeline itself, the station yard, the crude oil transported in the pipe, and the relevant external environment that has an important impact on the pipeline system. Therefore, before the calculation of the system, it is necessary to simplify the complex pipeline system into available abstract mathematical expressions. This paper is mainly based on the following assumptions: 1. The conveying medium flows stably in the pipe. 2. Single-phase (liquid phase) homogeneous flow of conveying medium in the pipe. 3. The temperature of the conveying medium in the pipe is constant along the radial direction, and only the change of the axial temperature is considered.
The structural diagram of the oil pipeline of the fourth line of Qingtie is shown in Figure 1, in which all the pump combinations are in series, and the mode of three in use and one for standby is adopted. In addition, the model building is mainly based on the following formula.

| Treatment method of frequency conversion pump
There are some frequency conversion pumps in Qingtie's four-line pipeline system, and the characteristics of the pump are changed by the change of the speed of the frequency conversion pump. According to the actual experience on the spot, the calculation accuracy of the characteristic curve of the variable frequency pump using the similarity theorem is not ideal. In this paper, the least square method is used to return the performance of the oil pump to be described as a polynomial. We define the flow-head and flow-power of the oil pump with the frequency converter as the relationship between Equations (1) and (2).
The flow-head relationship fitting equation of the inverter pump is as follows: The flow-power relationship fitting equation of the oil pump is as follows: In practical engineering problems, multiple nonlinear regression is a very common situation and has also achieved very good results, such as the regression model of the ternary cubic polynomial in (3).
At the same time, Equation (3) can be replaced by appropriate variables to transform the nonlinear topic into a linear problem. The transformation method is (4).
After the transformation, the regression model becomes a multiple linear regression model, namely formula (5): The unknown constant (that is, the formula coefficient) 0 , 1 , 2 , ⋅⋅⋅, 11 is called the regression model coefficient. If n sets of data are known and the ith set is (y i , x 1i , x 2i , ⋅⋅⋅, x 11i ), then the linear regression model can be expressed as: where represents the random error term. Regression analysis is used to calculate the regression coefficient (formula coefficient) of the multiple linear regression models with the objective of minimizing the square sum of random errors. Expressed as a matrix: in which: In the multiple linear regression problem, a large amount of data needs to be processed, and many advanced mathematical bits of knowledge such as linear algebra and statistics are involved, which needs to be solved with the help of computer software. Equation (4) can be solved with = regress(y, X) in MATLAB based on the regression algorithm. In MATLAB, the regression function returns the least squares fitting solution of y = X .

| Treatment results of variable frequency pump
Qingtie four-line pipeline adopts a closed conveying method, and the pumps of each pump station are connected in series. The coding method is a combination of frequency conversion speed coding, such as 2400-2800-2300. The relevant parameters of the oil pumps at each station are shown in Table 3.
As shown in Table 3, only station 1, station 3, station 5, station 6, and station 7 have inverter pumps. Among them, station 1 and station 7 are the same type of oil pumps, station 3 and station 5 are the same type of oil pumps, and station 6 is another kind of oil pump, so this calculation only needs to fit three oil pumps.

Inverter pumps at station 1 and station 7
The characteristic equation was obtained by using the least square regression method, and the pressure head curve and power curve of the speed-regulating pump at stations 1 and 7 were fitted, as shown in Figure 2.
It can be seen from Figure 3 that the fitting method used in this paper has high precision, with the error of the pressure head fitting within 5% and the power fitting error within 5%, which can well fit and calculate the characteristic curve of the variable speed pump. The fitting results are shown in Equations (9) and (10).
Pressure head equation: 2. Inverter pumps at station 3 and station 5 The characteristic equation was obtained by using the least square regression method, and the pressure head curve and power curve of the speed-regulating pump at stations 3 and 5 were fitted, as shown in Figure 3.
It can be seen from Figure 3 that the fitting method used in this paper has high precision, the fitting error of the head is within 5%, and the fitting error of the power is within 5%, which can well fit the characteristic curve of the variable speed pump, and the fitting results are shown in formula (11) and (12).
Pressure head equation: Power equation: 3. Inverter pump at station 6 The characteristic equation was obtained by using the least square regression method, and the pressure head curve and power curve of the station 6 speed-regulating pump was fitted, as shown in Figure 4.
It can be seen from Figure 6 that the error of pressure head fitting is within 5%, and the error of power fitting is also within 5%, which can well fit and calculate the characteristic curve of the variable speed pump. The fitting results are shown in Equations (13) and (14).
Pressure head equation: Power equation:

Establish the objective function
There are two main energy consumption in the operation of crude oil pipeline: (a) power consumption of pump unit; h -Heating efficiency of the heating station; q-Low heating value of fuel, kJ/kg.

Optimization variables
In order to accurately simulate this process, the combined opening method of the pump units of each pumping station, the speed of the variable frequency pump, and the outbound temperature of the heating station are used as the optimization variables of the hot oil pipeline.
in which: C -Pump unit combination mode of the ith pump station; rs i -Speed of variable frequency pump of the pump unit in the ith pumping station; T -the Outbound temperature of heating station number i.

Constraint conditions 4. (a) Inbound pressure constraint
The inlet suction pressure of the pump shall be greater than the allowable cavitation allowance of the pump, and the inlet pressure of the pump station shall be greater than the allowable minimum inlet pressure.
in which: H -Inlet head of the ith pumping station, m; H ini_min -Allowable minimum inlet head of the ith pumping station.

(b) Outbound pressure constraints
The head provided by the pump station shall not be less than the head required for normal oil transportation and shall meet the strength requirements of the pipeline, that is, the outbound pressure shall not exceed the maximum pressure of the pipeline. (c) Pipe hydraulic restraint When calculating the pipeline friction, first calculate the Rayleigh number (here, it is assumed that the fluid is Newtonian fluid).  Table 4.
At the same time, the head provided by the pump station must not be less than the pressure loss of the pipeline between the pump stations.
in which: h i -Friction between pump stations, m; h -Local friction between pumping stations, m; h -Friction between heating stations, m; ΔZ i -Height difference between starting and ending points, m.

(d) Outbound oil temperature constraints
In a hot oil pipeline system, if the outbound temperature of crude oil is too low, important physical parameters of the crude oil may deteriorate, such as viscosity, yield value, and a "condensation accident" is likely to occur. If the outbound temperature is too high, the change in viscosity with increasing temperature after the temperature of the crude oil exceeds a certain value will be very small and very uneconomical, so the temperature needs to be controlled within a suitable range.
in which: [T out_max ]-The maximum outbound temperature of the ith hot station, °C; [T out_min ]-The minimum outbound temperature of the ith hot station, °C.
(e) Incoming oil temperature restriction The temperature of oil entering the station shall be higher than the specified value to prevent the shutdown of the condensate pipeline.
in which: T -Incoming temperature of heating station number i, °C; [T in_min ]-Minimum inlet temperature of the ith hot station, °C.
The distribution of temperature drop along the pipeline is calculated by the Sukhov formula, which is as follows. 48 in which: T L -Oil temperature L meters from the start of the pipeline, °C; T 0 -The ground temperature of buried pipeline environment, °C; T R -Oil temperature at the beginning of the pipeline, °C; G-Mass flow in the pipeline, kg/s; c-Specific heat capacity of oil at average temperature, J/kg °C; K-Total heat transfer coefficient of the pipeline; i-Hydraulic slope of the pipeline; g-Acceleration constant of gravity, 9.8 m/s 2 ; (f) Heating furnace thermal load constraint If the heat load of the heating furnace exceeds the rated value, safety accidents may occur. If the heat load is low, the efficiency will be very low. in which: Q rmin -Minimum heat load of the heating furnace, kJ/kg; Q -Thermal load of the ith heating station, kJ/kg; Q rmax -Rated heat load of the heating furnace (maximum heat load), kJ/kg.  Table 5.
There is a certain power limit for the pump in the pump station, and the limit conditions are as follows: in which: P min -The minimum power allowed by the pump, kW; P i -Power of the ith pumping station, kW; P max -Maximum power allowed by the pump, kW.

(h) Variable speed pump speed restriction
The speed of the variable speed pump shall run within a certain range, and its speed restriction is: in which: rs min -The minimum allowable speed of the pump, L/min; rs i -Rotation speed of frequency conversion pump in the ith pumping station, L/min; rs max -The maximum speed allowed by the pump, L/min.

| Optimization algorithm
This article is based on MATLAB software programming, calling the optimization solver, using the genetic algorithm (GA), particle swarm algorithm (PSO), simulated annealing algorithm (SA) to solve the model.

Genetic algorithm (GA)
Based on the optimization model of the crude oil pipeline, according to the characteristics of the genetic algorithm, the optimization variables are coded to form the fitness function of the genetic algorithm. In the evolution process, the population size is 120, the crossover probability is 0.9, the mutation probability is 3%, and the termination criterion is the maximum evolution algebra 300. The flow of the solution step is shown in Figure 5.

Particle swarm optimization (PSO)
According to the characteristics of the particle swarm algorithm and the optimization model of the energy consumption of the pipeline operation, the optimized variables are coded to form the fitness function of the particle swarm algorithm. The particle number is 40, the particle length is 42, the maximum speed is 15% of the variation range of each dimension variable, and the acceleration coefficient is 2.0. The flow of the solution step is shown in Figure 6.

Simulated annealing algorithm (SA)
According to the characteristics of the simulated annealing algorithm and the optimization model of the energy consumption of the pipeline, the optimized variables are coded to form the objective function of the simulated annealing algorithm. The initial temperature is 100, the end temperature is 0.001, and the cooling factor is 0.98. The flow of the solution step is shown in Figure 7.

| Basic parameters of pipeline operation
The design pressure of the Qingtie Fourth-Line is 6.3 MPa, the diameter is 711 mm, and the length is 548.5 km. In addition to the first station, there are 5 heat pump stations,  Figure 8. In addition, the design throughput from 1 station to 3 stations is 1650 × 10 4 t/a, and the design throughput from 3 stations to 6 stations is 2000 × 10 4 t/a, and the design throughput from 6 stations to 9 stations is 1500 × 10 4 t/a.

| Actual pipeline operation scheme
In order to better compare with the optimized scheme, this paper collected the actual operation data of the pipeline system in January 2018, as shown in Table 6. The heat transfer coefficient K and the ground temperature between stations are shown in Table 7, where the arithmetic average of the natural ground temperature at the ends of each pipe section is taken as the natural ground temperature along the pipe section.

| Comparative analysis of optimization schemes
In the second part, this paper establishes the hot oil pipeline model of the study case and takes the pump combination mode, pump speed, and heating station temperature as the optimization variables, so it can be known that the pump speed, inlet, and outlet temperature and pressure in the new optimization scheme must be changed. In this part, we also mainly analyze these aspects.

Pipe inlet and outlet pressure analysis
To achieve the ideal pressure solution is to reduce the consumption of pressure energy, that is, to reduce the outbound pressure and increase the inbound pressure as much as possible, but this is only an ideal situation. In the actual optimization scheme, the inlet and outlet temperature, pump speed, and other factors are involved. Here, this paper pays End NO Yes more attention to the analysis of the pressure drop between stations or the whole pipe section. The greater the pressure drop, the better the performance in reducing pressure energy consumption. Therefore, the pressure changes of the actual scheme and the three optimization schemes are compared as shown in Figure 9.
As shown in Figure 9, the pressure change trend of the optimization scheme and the actual scheme is similar. It can be clearly seen from the figure that the inlet pressure of the actual operation scheme is low in most cases. However, it is also difficult to find out which scheme has less pressure energy consumption only based on the curve in the figure, because the outbound pressure of various schemes is not consistent. Here, we can calculate the total pressure drop of the pipe segment by using the relevant data of each pump station, among which the total pressure of the scheme obtained by genetic algorithm (GA) is 0.34 MPa lower than the actual scheme, the total pressure of the scheme obtained by particle swarm optimization (PSO) is 0.65 MPa lower than the actual scheme, and the total pressure of the optimized scheme by simulated annealing method (SA) is 0.72 MPa lower than the actual scheme. It can be seen that the simulated annealing algorithm is better in reducing the pressure energy, and the genetic algorithm has a lower pressure reducing ability.

Temperature analysis of pipe inlet and outlet
Because the crude oil transported by this pipeline is easily condensable and highly viscous crude oil, the excessive temperature will cause excess heat consumption, and condensate accidents may occur if the temperature is too low. Figure 10 shows the temperature change of the inlet and outlet between stations.
Different from the pressure change of the inlet and outlet, although a few optimized outlet temperatures increase, it is obvious from Figure 10 that the outlet temperatures of the three optimized schemes are mostly smaller than the outlet temperatures of the actual schemes, and the inlet temperatures generally have little difference. It shows that all three schemes have a better ability to reduce heat consumption. In addition, the total temperature drop of the entire pipe section is also calculated in this paper. Compared with the actual scheme temperature drop, the temperature of the genetic algorithm (GA) optimization scheme decreased by 2.43°C, the particle swarm algorithm (PSO) optimization scheme decreased by 2.63°C, and the simulated annealing algorithm (SA) optimization scheme decreased by 2.13°C. Therefore, the optimization scheme obtained by the particle swarm algorithm can reduce heat consumption more.

Energy consumption forecast
Energy consumption is the main content of this study, which is mainly divided into electricity consumption and oil consumption. Here, the oil consumption and electricity consumption of each station are converted into standard coal units for better analysis and calculation of energy consumption. Compare the actual operation scheme with each optimization scheme, as shown in Figure 11.
It can be seen from Figure 11 that the energy consumption of the actual scheme is significantly higher than the energy consumption of the three optimized schemes. Compared with the actual scheme, the total energy consumption of the scheme obtained by the genetic algorithm optimization was reduced by 7.57%, the power consumption was reduced by 7.00%, and the fuel consumption was reduced by 7.86%; The total energy consumption of the solution obtained by particle swarm algorithm optimization was reduced by 7.84%, power consumption was reduced by 7.48%, and fuel consumption was reduced by 8.01%. The total energy consumption of the solution obtained by the optimization of the simulated annealing algorithm was reduced by 6.01%, the power consumption was reduced by 7.19%, and the fuel consumption was reduced by 5.44%. It can be seen that the optimization solution solved by the particle swarm algorithm has the lowest production energy consumption, so it is the optimal solution. Based on the comparison of the pressure, temperature, and energy consumption of each inlet and outlet above, it is found that although the solution of particle swarm optimization algorithm does not show optimality in reducing the pressure drop of the pipeline, the difference between the solution and the maximum pressure drop is not large, so the optimization solution of particle swarm optimization algorithm is better. In addition, the paper also presents the optimal solutions of the three optimization algorithms as shown in Tables 8-10.

| Comparative analysis of optimization algorithms
In the previous section, we compared the optimization schemes and found that the solution based on particle swarm optimization was better. But in order to find a better optimization algorithm, its performance is also very important, that is, the efficiency of the algorithm. According to the optimization case in this paper, the optimization calculation is carried out for the working conditions of 8 months in 2018. Taking the working conditions of January as an example, the iterative convergence diagram is shown in Figure 12.
It can be seen from Figure 12 that the genetic algorithm converges in about 40 generations and takes 87.97 seconds. The particle swarm algorithm converges in about 40 generations and takes 32.89 seconds; The simulated annealing algorithm converged before 400 generations and takes 261.45 seconds. Among the three algorithms, the particle swarm algorithm had the least calculation time, and the convergence algebra was similar to the genetic algorithm.
In order to better compare the performance of the three algorithms to solve the model in this paper, eight working conditions of the Qingtie line are calculated, which are collected in different months of 2018, and the final energy consumption calculated by the three algorithms is shown in Figure 13.  Analyzing Figure 13, we can draw the following conclusion: When the three algorithms solve the 8-month working condition, the particle swarm optimization algorithm finds the most optimal solutions and recommends the particle swarm optimization algorithm to solve the model from the aspect of optimal solution quality. In addition, the completion time of the three algorithms is shown in Figure 14.
As shown in Figure 14, by comparing the solution time of three algorithms in different months, it is obvious that the particle swarm optimization algorithm has more advantages in solution time. From the aspect of optimization efficiency, particle swarm optimization is also recommended to solve the model.

| CONCLUSIONS
Based on the MATLAB 2019a programming software, this paper uses Qingtie four-line oil pipeline as a practical case to study the steady-state optimization of the oil pipeline.
1. For hot oil pipelines with variable frequency pumps, the variable frequency pumps can be considered in the modeling of hot oil pipelines and processed using least squares.

T A B L E 9
The solution obtained by the particle swarm algorithm