#### Abstract

The pipeline inspection gauge (PIG, lowercase pig is commonly used) with a bypass valve is widely used in pipeline inspection because it operates at a low speed without reducing the flow rate. Understanding the dynamics of a bypass pig in a gas pipeline would contribute to the design of the pig and the control of pig speed. This paper deals with the dynamic model for the process of a bypass pig travelling through a hilly gas pipeline. The method of characteristics (MOC) is used to solve the equations of unsteady gas flow. The backward flow of the gas in the bypass valve and pipe is shown by a simulation of pigging for a hilly gas pipeline. Parametric sensitivity analysis of pigging in the horizontal gas pipe using a bypass pig is then carried out. The results indicate that the speed of a bypass pig is most sensitive to the gas speed in the pipe followed by the bypass area and the friction of the pig. A formula, obtained from the results of the simulations using response surface methodology (RSM), is presented to predict the steady speed of a bypass pig in the horizontal gas pipeline.

#### 1. Introduction

Regular pigging for the gas pipelines is one standard procedure for the operators. Generally, a pig is a piston that is installed in a pipe to perform certain operations such as liquid removal, inspection of the pipe, and cleaning out debris. Fluid is pumped upstream of the pig to drive it in motion [1–3]. In many cases, the flow rate in the pipelines is required not to decrease too much during the pigging operations because of the demand of the downstream [4–6]. However, the pig speed needs to be limited to within a moderate range during such operations [7, 8]. In particular, intelligent pigs for pipeline inspection require that the pigging speed be limited to medium. Therefore, implementation of a bypass control strategy is the only appropriate technique for several such pigging operations [9, 10].

In general, a bypass control strategy uses a bypass valve to adjust the pressure difference between the tail and nose of the pig. As a part of the fluid pours out of the bypass hole through the pig body, the pig speed can be reduced to a desired range.

A literature investigation indicates that few studies focus on bypass valve pigs. Nguyen et al. performed modeling and simulation of pig flow control in a natural gas pipeline [11]. The dynamics of a pig with a fixed bypass in the gas pipeline was studied by Hosseinalipour et al. In this research, the basic equations of gas flow were discretized by the finite difference method [12]. Tan et al. studied a new butterfly-shaped bypass valve and presented its working principle [13]. Lesani et al. explored the derivation and solution of two- and three-dimensional (2D and 3D, respectively) dynamic equations for the pig passing through the liquid pipeline [5].

The prediction and control of the pig speed is critical to the pigging operation. To understand the dynamic behavior of the pig, the pig dynamic equation must be coupled with the governing equations of flows [14–16]. The method of characteristics (MOC) was employed to transform the partial differential equations of flows to ordinary differential equations [17–19]. This method is quite efficient to solve the governing equations of transient gas flows.

There already exist some works relating to the dynamics of the pig in gas pipelines. Esmaeilzadeh et al. presented a mathematical model of the dynamics of a pig travelling through gas pipelines [17]. The process of a pig restarting from a stoppage in a horizontal gas pipe was simulated by Nguyen et al. In this paper, the gas equations were solved by MOC [11]. Xu and Li developed a pigging mathematical model coupling with the quasi-steady-state flow model [20]. In addition, Mirshamsi and Rafeeyan analyzed the process of a pig through a 3D gas pipeline by assuming the pig as a rigid body with a bypass [21, 22]. It seems that few of the studies pay attention to the backward flow of gas in the bypass valve and pipe. Therefore, the simulation of pigging for hilly gas pipelines would be a difficulty for these pigging models.

A literature survey reveals that very few papers focus on the simulations of pigging in hilly gas pipelines using a pig with a bypass valve. Also, there are few calculations or simulations for estimating the speed of the bypass pig in gas pipelines. This paper deals with the dynamic model for the process of a bypass pig travelling through a hilly gas pipeline. The equations for unsteady gas flow are solved by MOC. The bypass flow through the pig is assumed to be incompressible for calculating the pressure difference between the tail and nose of the pig. In this pigging model, the backward flow of gas in the bypass valve and pipe is taken into account, which is shown by a simulation of pigging for a hilly gas pipeline. Parametric sensitivity analysis of pigging in the horizontal gas pipe using a bypass pig is then carried out. Lastly, RSM is used to study the steady speed of a bypass pig in the horizontal gas pipeline. A formula, obtained from the results of the RSM simulations, is presented to predict the steady speed of a bypass pig in the horizontal gas pipeline.

#### 2. Mathematical Modeling

##### 2.1. Pig Dynamic Equation

The model of a pig moving in a pipeline with a bypass valve is shown in Figure 1. An amount of the flow in a pipeline passes through the bypass hole and builds up a pressure difference between the tail and nose of the pig, which drives the pig in motion. The dynamic equation of the pig can be expressed as follows:where *m*, , *A*_{p}, *A*_{h}, *p*_{tail}, *p*_{nose}, *F*_{fp}, *F*_{p}, and *θ* are the mass of the pig, velocity of the pig, cross-sectional area of the pipe, area of the bypass hole, pressure on the pig tail, pressure on the pig nose, friction force of the pig, driving force generated by the pressure difference, and angle between the pipe and the horizontal plane, respectively.

As is known, there are occasions that the pig stops in the pipeline and requires a larger driving pressure to push it in motion. Thus, the relationship between the static friction *F*_{sta} and dynamic friction *F*_{dyn} of the pig can be expressed in the following form:

##### 2.2. Model of Gas Flow in a Hilly Pipeline

The following assumptions are adopted to simplify the pigging model:(1)The gas is an ideal gas(2)The gas flow is quasi-steady heat flow(3)The fluid in the pipeline is a single-phase gas(4)The diameter of the pipeline is unchanged during pigging

The unsteady flow dynamics can be modeled based on the fundamental fluid dynamic equations [11, 17, 18, 23]: continuity equation, momentum equation, and energy equation, respectively, as follows:where *u*, *ρ*, *p*, *x*, , and *t* are the velocity, density, pressure, distance, gravity parameter, and time, respectively. In addition, *F*_{f}, *A*_{p}, *γ*, *S*, and *q* are the friction force, cross-sectional area of the pipe, ratio of specific heat, pipe perimeter, and rate of heat inflow, respectively.

In gas pipelines, there are occasions that the gas flows backward, which causes the friction force *F*_{f} to reverse. Therefore, the sign function of velocity sgn (*u*) should be added before the friction force *F*_{f}. From the perspective of the fluid mechanics books and papers, the friction factor and the friction force are given, respectively, as follows [24]:where Re, *d*, *k*, and *f* are the Reynolds number, diameter of the pipe, pipe wall roughness, and friction factor, respectively. Equations (3)∼(5) can be rewritten in the following form:where

The nonlinear hyperbolic partial differential system of equation (7) can be transformed into ordinary differential equations which can be integrated by finite differences. Matrix **A** has 3 real eigenvalues, *λ*:where *c* is the sound speed. Thus, the eigenvectors of matrix **A** can be written as

For each pair of *λ* and *υ*, equation (7) can be rewritten in the form

By writing equation (7) along the characteristic line, now we get the compatibility equations:

Figure 2 shows the relationship between variables *u*, *p*, and *ρ* at the time step *t*_{j−1} and at the following time step *t*_{j} [17, 25]. At the time step *t*_{j−1}, variables *u*, *p*, and *ρ* at grid points *S*, *M*, and *R* are obtained from linear interpolation of the data on *O*, *N*, and *L*. Then, the gas flow parameters at point *P* can be derived from previously calculated grid points *S*, *M*, and *R*.

Equations (12)∼(14) are integrated along the corresponding characteristic line to obtain the desired variables. Equations (15)∼(17) are obtained by linear interpolation. In the following three equations, *X* denotes the desired parameters *u*, *p*, or *ρ*:

According to equations (12)∼(14), we getwhere

The sampling time, *∆t*, and the sampling distance, *∆x*, are chosen under the CFL stability condition [24]:

##### 2.3. Pressure Difference Generated by the Bypass

Generally, a bypass valve is used in a smart pig for pipeline inspection. Several conventional pigging operations for liquid and debris removal should be done before using the smart pig. In a clean pipe, the pressure difference between the tail and the nose of the pig is generally in the range of 0.3∼1.5 bar. Therefore, the pressure disturbance generated by the pig is negligible compared to the gas pressure, typically up to several megapascals. In addition, when the speed of natural gas is less than 200 m/s, it can be treated as incompressible with an error less than 5% [25].

With the assumption that the gas can be treated as incompressible as it passes through the bypass valve, the gas velocity on the tail and nose of the pig can be written as the following:where *u*_{tail}, *u*_{nose}, and are the gas velocity on the tail of the pig, on the nose of the pig, and in the hole of the pig, respectively.

In gas pipelines, the speed of pigs can be erratic, which makes the driving pressure of the pig positive or negative. From the perspective of the fluid mechanics books and papers, the pressure difference generated by the bypass valve is given as follows [10]:

In this equation, *C*_{h} is the discharge coefficient of the valve, which is determined by the structure of the valve and the properties of the medium. Generally, *C*_{h} is between 0.6 and 0.8.

##### 2.4. Boundary Conditions

In this paper, the boundary conditions are considered as constant inlet flow rate and constant pressure at the outlet. As shown in Figure 3, using the backward and forward characteristics next to the pig, the pressure on the tail and nose of the pig can be expressed as follows [25]:

To calculate equation (23), the gas parameters at points *R*_{tail} and *N*_{tail} should be obtained firstly, which can be solved as the following steps [25]:(1)Calculate the gas parameters at point *N*_{tail} by linear extrapolating from two points *L* and *N*:(2)Find out the position of point *R*_{tail}:(3)Calculate the flow parameters at point *R*_{tail} by linear interpolating from two points *L* and *N*:

With the gas parameters at points *T* and *O*, the gas parameters at points *N*_{nose} and *S*_{nose} can be calculated in the same way, which can be expressed as follows:

If *p*_{tail}*>p*_{nose}, substituting equations (21) and (23) into equation (22), we get the relationshipwhere

By solving equation (28) under the condition of *>* , the velocity of bypass flow can be written as follows:

If *p*_{tail}* < p*_{nose}, substituting equations (21) and (23) into equation (22), we get the relationshipwhere

By solving equation (28) under the condition of *<* , the velocity of bypass flow can be written as follows:

Substituting into equation (21), the values *u*_{tail} and *u*_{nose} can be calculated. Now, parameters *p*_{tial} and *p*_{nose} can be obtained by solving equation (23).

##### 2.5. Initial Conditions

Steady-state momentum equation (4) and energy equation (5) for gas flow can be converted into ordinary differential equations by assuming ∂/∂*t* = 0. Now, we get the steady-state equations:

The initial fluid variables *u*, *p*, and *ρ* for both upstream and downstream gas flows can be calculated by solving equations (34)∼(36) using the Runge–Kutta method.

##### 2.6. Numerical Solution

In general, a number of discrete points are adopted to express the pipe curve. Thus, sin*θ* in equation (1) of each point can be expressed by the adjacent points. At each time step, sin*θ* of the current pig position can be obtained by interpolation of the adjacent points. Then, the speed and position of the pig can be solved from equation (1) by using the Runge–Kutta method.

To simulate the pigging process in the gas pipeline, the pipeline is divided into two sections: one behind the pig and the other in front of it. At the first time step, the dynamic equations for both upstream and downstream gas flows are solved to obtain the driving pressure of the pig. In the next step, the Runge–Kutta method is used to solve the speed equation of the pig to obtain speed and the new position of the pig. The calculations are repeated until the pig arrives at a given position in the pipeline or the time step reaches the end.

#### 3. Simulation of Pigging for a Hilly Gas Pipeline Using a Pig with a Bypass

A pipe curve shown in Figure 4 is used for the simulation of pigging in a hilly natural gas pipeline using a pig with the bypass hole. Numerical values of the parameters used in this pigging simulation are shown in Table 1.

In order to test the mesh independence, numerical solution is carried out by utilizing the grid systems with 800,000 cells, 1,250,000 cells, 5,000,000 cells, and 20,000,000 cells at an initial position of 4700 m and in a computing time of 200 s. The pig speed of these simulations is figured out in Figure 5. The pig speed gap between grid systems of 5 M and 20 M cells is much smaller than the gap between 0.8 M and 1.2 M. Thus, to balance computational economy and prediction accuracy, the grid system of 5 M cells is chosen for this study.

The pig speed and the gas speed in the bypass valve are figured out in Figures 6 and 7, which show that the two speeds increase to a high level when the pig moves into a downhill section. In addition, the pig stops quickly when it rushes into the uphill section because the pressure difference between the tail and nose of the pig reduces to a level that is insufficient to overcome the friction, shown in Figure 8. This way, the gas in the bypass flows backwards for a period of time. After 10 seconds, the gas speed in the bypass value increases to about 12 m/s, building up a pressure difference of about 0.35 bar to drive the pig in motion.

The pressure on the pig tail and nose and pressure difference between the tail and nose of the pig during pigging are shown in Figure 8. It can be seen that when the pig moves to the uphill section, the gas pressure on the nose of the pig increases because of the compression generated by the pig. Additionally, the pressure on the pig nose rises in the uphill section due to the action of gravity. As a result, it is difficult to establish the pressure difference at the tail and nose of the pig, and it requires an increase of gas pressure on the pig tail. This way, the pig speed decreases after starting. After hesitating for about 12 seconds, the pig then can move smoothly.

The distributions of gas pressure and speed are presented as 3D diagrams shown in Figures 9(a) and 9(b), respectively. It can be seen that the gas pressure increases when the pig climbs the uphill section and decreases when the pig travels in the downhill section. In addition, the shock wave of the gas speed, generated by a high speed of the pig, will continue to move forward.

**(a)**

**(b)**

#### 4. Simulation of Pigging in the Horizontal Pipe Using a Bypass Pig

Typically, natural gas pipelines are primarily horizontal or near horizontal. Therefore, the design of bypass pigs and pigging operations generally considers pigging in horizontal pipelines. In this study, a 5 km horizontal gas pipeline is used for calculating the steady speed of the bypass pig. The parameters of the pigging system are listed out in Table 1. The pressure on the pig tail and nose and pressure difference between the tail and nose of the pig are shown in Figure 10(a). The pig speed and the gas speed in the bypass hole are figured out in Figure 10(b). The results show that the pressures and speeds fluctuated within 60 seconds after the pig was started and then gradually reached a stable value.

**(a)**

**(b)**

Parametric sensitivity analysis of pigging in the horizontal gas pipe using a bypass pig is then carried out. As shown in Figure 11, the steady speed of a bypass pig is primarily determined by the pipe diameter, gas speed in the pipe, bypass area, and the friction force of the pig. The mass of the pig makes little difference to the results. Additionally, the pig speed is most sensitive to the gas speed in the pipe followed by the bypass area.

**(a)**

**(b)**

**(c)**

**(d)**

**(e)**

**(f)**

#### 5. Calculation of Steady Speed of the Bypass Pig Using RSM

Response surface methodology (RSM) is a statistical experimental method for optimizing stochastic processes. The objective is to find out the quantitative law between the experimental index [26, 27]. In this research, RSM is used to study the steady speed of a bypass pig in the horizontal gas pipeline. The steady speeds a pig achieved from each run of RSM are listed out in Table 2. An empirical formula for estimating the steady speed of a bypass pig in the horizontal gas pipeline, obtained from the results of the RSM simulations, is as follows:

In this equation, *A*, *B, C, D*, and *E* are the pipe diameter (m), gas pressure (bar), gas speed in the pipe (m/s), proportion of the bypass area to the cross-sectional area of the pipe (%), and driving pressure of the pig generated by the friction of the pig (bar), respectively. Model graphs of equation (37) are shown in Figure 12. The actual value and predicted value of pig speed are compared in Figure 13, which shows a good agreement within an error of 5%.

Obviously, the speed of a bypass pig is mainly determined by the gas speed in the pipeline and can be reduced in several ways: by reducing gas speed and pressure, increasing the bypass valve area, and increasing friction force of the pig.

#### 6. Conclusion

A calculation scheme using MOC to solve the equations of gas flow for estimating the dynamics of the bypass pig has been shown. In this model, the backward flow of the gas in the bypass valve and pipe was taken into account, which was shown by a simulation of pigging for a hilly gas pipeline. Parametric sensitivity analysis of pigging in the horizontal gas pipe using a bypass pig was then carried out. Then, RSM was used to study the steady speed of a bypass pig in the horizontal gas pipeline.

The results indicate that the steady speed of a bypass pig is primarily determined by the pipe diameter, gas speed in the pipe, bypass area, and the friction force of the pig. Additionally, the speed of a bypass pig is most sensitive to the gas speed in the pipe followed by the bypass area and the friction of the pig.

Furthermore, the formula obtained from the results of the RSM simulations can be used to predict the steady speed of a bypass pig in the horizontal gas pipeline. Thus, it could contribute to the design of the bypass pig and the control of pig speed.

Last but not the least, the proposed method and solution can be used to predict the speed of a bypass pig, the gas parameters, and the position of the pig after a given time in pigging operation for a hilly or horizontal gas pipeline.

#### Data Availability

The data used to support the findings of this study are available from the corresponding author upon request.

#### Conflicts of Interest

The authors declare that they have no conflicts of interest.

#### Acknowledgments

This research work was supported by the Graduate Innovation Foundation of SWPU (CX2019BY12) and Research Project of Yibin University (2019QD18).