Research on Oil and Gas Pipeline Operation Optimization Based on Improved Newton-Raphson Method

. Oil and gas pipelines are the main channel to ensure national energy security and national economic development due to the safety and efficiency of the transportation coast. To achieve an optimal state of pipeline operation in terms of safety and efficiency is the crucial important issue throughout the life cycle of a pipeline system. However, the optimization problem of the pipeline network system is a typical Mixed Integer Non-Linear Problem (MINLP) which are extremely difficult to solve. An optimal solution to keep pipeline operated in most efficient state under the premise of safe operation is given in the paper by using the dynamical programming method. Firstly, the improved Newton-Raphson method is used to solve the discrete pipeline system, and the operating parameters such as temperature, pressure and flow of any section surface in the pipeline are obtained. The fluid parameter values of the each discrete nodes can ensure the safety of the pipeline. Based on this, the total energy consumption cost is set as the objective function, and the oil and gas pipeline operation optimization model is then established, and the dynamic programming method is used to solve it, so that it can obtain the optimal solution of the current working conditions in a reasonable computational cost. The actual example shows that the energy cost of the optimized operation scheme can be reduced by 6.8% compared with the pre-optimization scheme.


Introduction
Oil and gas pipelines transport the life blood of China's economic development and are closely related to the normal life of citizens and the industrial production. By the end of 2014, the total mileage of nationwide oil and gas pipelines had exceeded 120,000 kilometers. Based on the existing monitoring methods, it is almost impossible for operator & management staff to completely control the each section of the oil and gas pipeline during operation, so it is difficult to carry out precise control to set the oil and gas pipelines operate under optimal conditions. How to make all the operating parameters of such a large oil and gas pipeline system operate within the reasonable and controllable operating range and under optimal conditions is the key issue for the oil and gas pipeline industry.
The optimization theory is designed to find the optimal solution among many possible choices, and it can be divided into two categories: constrained optimization and unconstrained optimization. Natural gas pipeline operation optimization problems are typical mixed integer nonlinear programming (MINLP) partly due to its nonlinear objective function and the constraints, even more the constraints could be non-convex. Therefore it is extremely difficult to solve this kind of optimization problem (the natural gas pipeline optimization) by using the conventional mathematical method, and simplifications and assumption are usually necessary. Aiming at the optimization problems faced by oil and gas pipeline industry, a new method based on optimal control and its application has been proposed in the paper after numerical analysis with the characteristics of oil and gas pipelines.
To achieve the optimal state of the pipeline system, one must obtain the parameter value of each node when the system is in the real status which is transient. The data information is foundation for determining the system's objective function. Further, reasonable and effective control of various operating parameters is a necessary measure to ensure system safety. But in-depth analysis of such problems has rarely been conducted in international research on oil and gas pipeline systems [1]. Therefore, this article first describes how to determine the operating parameter values and use them as simulation modules in the optimization loop.

Model Formulation and Boundary Conditions
Taking the gas pipeline system as an example, its components include valves, pipeline segments, compressors, etc. The governing equations of the pipeline segments and the compressor are the most complicated. In order to improve the calculation efficiency while not influencing the computation accuracy distinctly, the pipeline segments can be simplified as one-dimensional tube flow to quickly obtain fluid parameter information (such as pressure P, flow rate Q, temperature T) at any of its nodes. Taking the change in pipe cross-sectional area into consideration, the governing equation can be selected as follows: 1 Continuity equation: where the friction coefficient in the formula can be calculated according to the ColeBrook-White formula stated as below: The boundary conditions of the system can be set as: (1) either the outlet pressure or outlet temperature is controlled by the setting values or equations; (2) the inlet pressure to be controlled.
In transient situations, the initial conditions of the system can be calculated by the results obtained from the steady state. The state equation of the natural gas can be a given equation of state, such as BWRS, AGA or a state equation as shown below:

Discretization Scheme
In order to solve the governing equations listed in 2.1, the box discretization scheme can be chosen to obtain discretized nonlinear equations. In this paper, (density ρ, velocity u, temperature T) is used as the basic variable. For any chosen variable, it can be expressed in the following form:

Algorithm to Solve Nonlinear Equations
The discretized governing equations would become solvable with the boundary conditions and initial conditions. After that, the nonlinear equations set, i.e., a matrix times a vector equals to another vector shall be formed. Assuming that the matrix is expressed as C. hence C (x) is the coefficient matrix, and x is the solution vector.
If the Newton method is used to solve this system of nonlinear equations, a function as below can be introduced: (10) where (i = 1, 2, 3...N). Then the problem of solving the nonlinear equations is transformed into a root-seeking problem, as follows: For any point X0 and its neighbors, the Taylor expansion is: If in the form of a matrix, there are: where J is the Jacobian matrix and If the high order item is neglected, the following equation is derived: The basic Newton method (the Newton-Raphson method) uses the following iterative method: The Newton-Raphson method is neither a global convergence nor even a descent algorithm. This paper proposes an optimization algorithm to overcome the shortcomings of the Newton-Raphson method. This approach will combine the fast convergence and global convergence strategies of the Newton-like methods. The objective function shall be selected as follows: Then through mathematical computation, it can be seen that the Newton iteration along the gradient direction of the objective function can always find a value that can cause the value of the objective function to decrease.
So a new iterative approach can be taken: Where is the step size of the gradient direction, the initial value of the note must be 1. If the value does not satisfy the falling condition, a backtracking algorithm can be used.

Numerical Results
To solve the above mathematical model, the initial conditions and boundary conditions are given as follows: a) Initial conditions: inlet pressure: PIN; inlet temperature: TIN; outlet pressure: POUT. b) Pipeline import and export boundary conditions: If the pipe diameter of the beginning and end of the pipeline is assumed to be constant, the cross-sectional area is also unchanged, which is the first type of boundary condition. The expression is as follows: R2: soil thickness; R1: the radius from the center of the pipe to the soil layer (including coating and filling layers); h: the actual depth of the pipeline to the center of the pipeline; D: diameter of the pipe. The transient thermal model of the pipeline and the surrounding environment is listed as follows: Then the unit heat flow can be calculated as the third type of boundary condition, and the expression is as follows: By C++ programming and numerical calculation, the results under different working conditions are as follows: (1) Initial conditions: PIN=4MPa, POUT=1MPa, TIN=20°C, the velocity and pressure distribution in the pipeline under given conditions are shown in Figure 1 and Figure 2.

Optimization for the Natural Gas Pipeline
For decades, experts and scholars have tried to solve the oil and gas pipeline optimization problem by using the gradient method, artificial intelligence method, linear approximation method, etc. However due to the computational cost, the optimality of the results, so the above mentioned method is not suitable [2][3][4] for the given problems. Because of the structural characteristics, the oil and gas pipeline system can be transformed into a multistage decision problem, and the dynamic programming method in the optimization theory is then applied to solve the problem. The advantage of the dynamic programming method is that it is not sensitive to the nonlinear and nonconvexity of the objective function and constraints; the computation time is controllable; the global optimal solution can be obtained [5]. Therefore, it is the algorithm with priority for solving the pipeline optimization model in this paper.

Optimization Model
Taking the optimization problem of the gas pipeline operation as an example, a mathematical model is established. that is, under the condition of known inlet as flow, pressure, temperature and downstream outlet pressure, the startup schemes of each compressor station is solved. so that the total energy consumption of the compressor station could be the lowest. The mathematical model is as follows:  (24) is the objective function of the gas pipeline operation optimization problem, that is, to minimize the total energy consumption of the entire line of gas stations. Equation (25) is the constraint condition for the optimization of gas pipeline operation, including the pressure distribution constraint of the gas station, the feasible domain constraint of the compressor, the pressure constraint of the pipeline, the pressure drop of the pipeline and the temperature drop constraint, and the constraints of the inlet and outlet of the compressor.

Pipeline operation optimization based on dynamic programming method
Dynamic programming is a method to solve the optimization problem of multi-stage decision process. The multi-stage decision process can be defined as follows: some processes have certain characteristics, which can be divided into a series of interrelated sub-processes according to time period or space, and specific decisions are made in each sub-process in which specific effect [5] are generated in the overall process. The optimization problem of gas pipeline can also be solved by dynamic programming method [6][7][8]. The parameters of the dynamic programming model for the optimization of gas pipeline operation are as follows: Stage k: the suction side of the k-th compressor station to the suction side of the k+1-th compressor station; The indication function: Total energy consumption from the first station to the k-th compressor station.
The flow chart of the dynamic planning method for gas pipeline operation optimization problem is addressed as follows: (1) Determine the state space. Starting from the first station, determine the state space (discharge pressure set) for each compressor station. The upper and lower limits of the state space are determined by the highest and lowest discharge pressures of the compressor station. The highest discharge pressure the compressor station is usually taken from the design pressure of the pipeline (ie, the maximum allowable pipeline operating pressure); the minimum discharge pressure of the compressor station is generally not specified, but can be calculated based on the customer's minimum required pressure at the end of the pipeline. [9][10][11][12].
(2) Recursive within the station. The purpose of the recursive within the station is to calculate the optimal indication function corresponding to each state variable in the current stage, that is, to calculate the minimum total energy consumption corresponding to each discharge pressure of the compressor station, and to record the recursive relationship in each compressor station. .
(3) Recursive between stations. The function of the station recursive is to calculate the discharge space of the first compressor station (discharge pressure, discharge temperature, total energy consumption of the former station), and calculate the hydraulic and thermal power of the pipeline segments to obtain the inbound space of the first compressor station. (Suction pressure, suction temperature, and total energy consumption of the previous station).
(4) Algorithm backtracking. Starting from the last station, according to the results recorded by the recursions in each stage of the station, the optimal discharge status of the compressor station, the corresponding suction status, and the discharge status of the previous station are found.
Taking a trunk pipeline of PetroChina as a prototype, a virtual pipeline as shown in Figure 5 is established. There are 8 compressor stations in the pipeline, and there are 2~3 compressors in each compressor station. Single gas source single user, there is no sub-transmission station in the middle.

Figure 5 Virtual Pipeline System
In order to verify the optimality of the optimization model and algorithm, this paper uses the simulation module of Chapter 2 to calculate a custom scheme, and the custom scheme opens a compressor station less than the optimal scheme. The results of the optimal and custom schemes are shown in Tables 1 and 2. The total consumption of the optimized solution is 146.95, and the total consumption of the custom solution is 156.9. It saves 9.95, which is about 6.8% of the total gas consumption.

Conclusion
In this paper, the whole process of establishing mathematical simulation and mathematical model of the process flow control parameters calculated at each position of the piping system in detail is elaborated. Optimization of operating parameters is calculated based on the optimal algorithm. The mathematical model to explain the governing equation for the parameters of each node in the pipeline system are describes in detail, and the operation parameters are optimized by the presented dynamic programming method. With the mathematic model, the discretized operation parameters of the system can be calculated and analyzed under different operating conditions, such as flow velocity profile, temperature and pressure. With all of these information, the pipeline could be assured to set in the safety circumstance. Then the global optimization method is used to optimize the calculation and analysis of the pipeline parameters, as the results showed that the total consumption has been saved by 6.8%.