Analytical solution of linearized equations for transient gas flows in gas pipelines

. We consider the new class of high precision simplified linear models of transient high-pressure gas flows along linear sections of pipelines. Representatives of this class are obtained from different initial models defined by partial differential equations. The new models are based on the exact solution of the Klein-Gordon equation, which appears as a result of piecewise linear approximation of nonlinear models in the form of Charny's equations [1–4] or piecewise constant approximation in models that describe deviations of pressure and mass flow rates from their values in the basic stationary mode [10–13, 16–17]. The new class of models has significant advantages over nonlinear simplified models in optimization problems of large-scale networks, reducing the calculation time by more than two orders of magnitude. They are also free from errors of the approximate inverse Laplace transform or dimensionality reduction techniques traditionally applied in such situations.


Introduction
The emergence of cheap gas significantly changes its role in the energy sector of developed countries. In addition to the traditional technological reasons [1], variations of gas flow in high-pressure pipelines have systemic reasons as well. They relate fluctuations in the gas supply market and the growing frequency of connection and disconnection of gas-consuming electric generators, which compensate for the intermittent production of wind and solar-based energy. In this regard, the need for analysis, control, and optimization of gas flows in highpressure gas pipelines with complex structure increases significantly. Often, the time allowed for analysis and making operational decisions is limited. Therefore, efficient models of unsteady gas regimes and high-speed algorithms are essential.
The paper has a structure as follows. Section I provides a brief overview of simplified models of transient gas motion described by equations with lumped parameters. Section II describes the methods of piecewise linear and piecewise constant linearization leading to the Klein-Gordon equation. In section III, we present the solution of the Klein-Gordon equation using Green's functions. Its features are studied as applicable to gas problems. Section IV discusses a method for reducing the dimensions of the constructed models without compromising their accuracy. Section V describes the application of the developed models to real gas flows. It takes into account the non-isothermal nature of the processes and describes numerical experiments.

A brief overview of lumped parameter models
Simplified lumped models of unsteady gas motion have emerged as a tool to speed up computations over partial differential equations (PDE) models. In simplified models, pressure, and mass flow values are analyzed only at the ends of the pipe segments. For many tasks of analysis, optimization of gas flows, and their control, this is quite acceptable. Such models for a linear section (simple gas pipeline [1]) can be described by time-dependent algebraic equations [1,2], linear [14][15][16] or nonlinear [9] ordinary differential equations or their systems, transfer functions [6,10,17], systems of algebraic linear equations [8] in cases of discrete-time models.

Nonlinear simplified models
Apparently, the first model with lumped parameters was proposed in [2]. It is based on experiments showing that in a wide range of transient processes, the hydraulic resistance coefficient does not change much. The experimental results and details of this model are presented in [2]. An important property of the nonstationary algebraic model is its exact coincidence with the stationary model in case of a steady-state regime. An extension of this model and its use for non-isothermal processes is described in [5], which includes the overview of the publications in Russian on simplified models as well. The publication [9] describes another nonlinear model having the form of an ordinary differential equation. In stationary mode, it provides an accurate solution as well. Model [9] becomes stationary if we equate the derivative with respect to time to zero. An important requirement leading to the model [9] is the preliminary segmentation of a linear pipe section with segment lengths less than 5 km. The model is created for each pipeline. It uses the Lagrange theorem from calculus. The value of the derivative in this theorem is selected to obtain the exact solution in the stationary mode. Despite the high quality of nonlinear models in stationary modes, they also have drawbacks: it is difficult to solve effectively optimization problems effectively with nonlinear models in large gas transmission networks. Preliminary segmentation sharply increases the dimensionality of the system of equations being solved. The program that implements the solution of optimization problems on a dynamic nonlinear model [9] is described in [19] and is the open-source software.

Linear simplified models
Linear models for unsteady gas regimes can be divided into three groups. The first group, described in [15,17], is based on dimension-reduction algorithms for linear dynamical systems. Therefore, the corresponding models are built in two stages. First, the initial time horizon and pipes used in the nonlinear model for the transient gas flows are divided into small steps and intervals. Then, the model dimension is reduced by one of the well-known methods. It is difficult to estimate the error of such models, although some specific examples of calculations look good in comparison with exact solutions for PDE obtained by classical numerical methods.
Another group of linear simplified models "starts" with a linearized model describing unsteady gas motion for deviations of pressure and mass flow along a linear section from the corresponding stationary values. These equations by themselves are already approximate. They can be obtained in many ways and differ slightly from each other. Usually, they are associated with the expansion of nonlinear terms in a Taylor series in equations like Charny's equations [3,4] in terms of deviations and discarding all terms of the second-order smallness and higher. The first work of this kind is [10] and the authors of subsequent works [11][12][13][14]16] use it as a baseline. A valuable tool in these works is direct and inverse Laplace transforms. The latter is usually associated with a significant level of errors that is difficult to avoid.

Linearization methods leading to the Klein-Gordon equation
The equations for an isothermal unsteady gas motion for a simple pipeline in the Charny form [3,4] are 0 < < , 0 < < � (4) Here, the state variables , , and represent the velocity, pressure, and density of the gas, respectively. They depend on time ∈ (0, � ) and spatial coordinate ∈ (0, ). Parameter is pipe length, is the constant angle of the inclination of the pipe, is the acceleration of gravity, is coefficient of hydraulic resistance. This is a dimensionless parameter characterizing friction. The rest of the parameters describe the inner diameter of the pipe, , and are the coefficient of compressibility, the special gas constant, and the absolute temperature of the gas respectively. In the general case = ( , ), but we will temporarily assume that = . In Section V, we will omit this restriction as well as the isothermal condition. The value = √ in the first approximation can be considered as the speed of sound in the gas. Because the term ( � )/ in (2) is small we will discard it in following transformations Imagine that the linear section under consideration consists of a sequence of short segments. Then equations (1) -(4) are applicable to each segment. Let assume that for the �� segment � � ≈ � � + χ , = 1,2, … , . Let = is the mass flow rate of the gas flowing through a constant cross-section of the pipe. Then, after simple transformations, system (1) -(4) for each segment transforms into a linear second-order hyperbolic equation of the form The parameters of the piecewise linear approximation of the parabola = � in (2) can be found if, for example, the basic stationary mode for the considered linear section is known. Publication [8] describes this procedure in detail. We will name the model (5) -(9) as Model A.
Consider now the Model B, which also leads to an equation ( , and remove all terms of the order ( ), ( ) and above. The formulas for the corresponding coefficients in (11) - (12) are determined in the process of transformations. It is easy to exclude the function ( , ) from (11) - (12). As a result, we again come to equation (5), but now its coefficients depend on the coefficients from (11) - (12). Thus, equation (5) with initial conditions (8) and boundary conditions (9) describe both models.
In the next sections, we will have a deal with the Model A only, but all results remain the same and for Model B with obvious replacement pressures and flow rates by corresponding their variations.

The Klein-Gordon equation for transient gas flows and its analytic solution using Green's functions
An analytical solution to equation (5) with the corresponding initial and boundary conditions may be obtained in diverse ways. The simplest way is to apply a change of variables that reduces (5) to the Klein-Gordon equation [6,7] Formula (14) allows finding the solution ( , ) q x t of equation (5). Having received ( , ) q x t we can get the pressure ( , ) p x t from (1).

Important note.
The physical process of gas flow cannot contain hyperbolic sines in (19). They can be avoided by choosing a small enough segment with length that satisfies the inequality 0 < < /�| |. This condition forms the segmentation rule. Typically, the length of a segment about 5 kilometers is OK, but it can be much longer.

The discrete linear transient flow models and dimensionality reduction without accuracy compromising
Considering the solution (17) at discrete moments of time and assuming that values (0, ) and ( , ) for each time interval are presented as piecewise constant, the integrals in (17) can be presented in closed form. This significantly accelerates the computational procedures because in such case the connection (0, ), ( , ), with (0, ) and ( , ), at discrete moments of time is described by the matrix equations (20) Here are − dimensional vectors, is the number of time intervals.
are the inlet and outlet pressures respectively and are inlet and outlet mass flow rates, are vectors determined by the initial conditions, are triangular constant × matrices, calculated from the analytical solution.
Consider two adjacent segments with models of the form (20) - (21). Left segment Right segment

Application of the developed models to real gas and nonisothermal processes, information on numerical experiments
The initial stationary mode for the case of changing with and non-isothermal modes allow choosing the segmentation of the linear section so that for each segment it is possible to assign its own constant value of the gas temperature and compression ratio and obtain a solution for this segment. The segment convolution procedure described above makes it possible to obtain linear models of unsteady gas regimes that satisfactorily describe the nonisothermal the motion of real gases in pipelines. We implemented described above approach into the GATRO (GАs Transportations Optimization) software package. GATRO uses described models for optimization of largescale gas transportation networks including multiple compressor stations. We made numerical experiments to estimate the GATRO performance for the real gas pipeline system in the United States with a total pipe length of about 600 km. The system contains 90 pipelines, 78 nodes, and 4 compressor stations. We compared the performance and results of calculations for the same gas network with GRAIL [19]. GRAIL is an open-source software solving gas network optimization problems. It works with simplified nonlinear gas flow models. It is currently the fastest program in this category. The by the GATRO and GRAIL methods are described in [8].