## 2 The Pipeline Transient Flow Model Containing the Virtual Multi-Point Leakages  
Since EKF can only be applied to the form of discrete time and discrete space for state estimation, it is necessary to discretize the pipeline length and leakage rate. The basic idea is presented below. First, the pipeline model is divided into \(N-1\) segments, and the position coordinates on each segment point are \(x_{1}\), \(x_{2}\),..., \(x_{i}\), \(x_{i+1}\),..., \(x_{N-1}\), \(x_{N}\). Assume the leakage happens at points \(x_{2}\),..., \(x_{i}\), \(x_{i+1}\),..., \(x_{N-1}\), \(N-2\) segments. At time \(t\), the pressure, flow, and virtual leakage rate at point \(x_{i}\) are represented as \(P(x_{i},t)\), \(Q(x_{i},t)\), and \(K(x_{i},t)\), respectively. The actual leaking pipeline and the virtual multi-point leaking pipeline are shown in Figures 1 and 2, respectively. The method of a characteristic line is used to solve the basic control equation of natural gas flow. Combining the above ideas, the leakage is virtually distributed at segment points, as shown in Figure 3, and the corresponding discrete equations can be obtained as [72; 73]  
\[(P_{i,j}^{-}-P_{i-1,j-1}^{+})+\frac{c}{A}(Q_{i,j}^{-}-Q_{i-1,j-1}^{+})+\frac{ \lambda c^{3}\Delta t}{4 DA^{2}}(\frac{Q_{i,j}^{-}\Big{|}Q_{i,j}^{-}\Big{|}}{P_ {i,j}^{-}}+\frac{Q_{i-1,j-1}^{+}\Big{|}Q_{i-1,j-1}^{+}}{P_{i-1,j-1}^{+}})=0 \tag{1}\]  
\[(P_{i,j}^{+}-P_{i+1,j-1}^{-})-\frac{c}{A}(Q_{i,j}^{+}-Q_{i+1,j-1}^{-})-\frac {\lambda c^{3}\Delta t}{4 DA^{2}}(\frac{Q_{i+1,j-1}^{-}\Big{|}Q_{i+1,j-1}^{-} }{P_{i+1,j-1}^{-}}+\frac{Q_{i,j}^{+}\Big{|}Q_{i,j}^{+}\Big{|}}{P_{i,j}^{+}})=0 \tag{2}\]  
where \(i\) is the subscript to represent a segment \(x_{i}\), \(j\) is the subscript to represent time \(t_{j}\), \(Q_{i,j}^{-}\) is mass flow before the leakage point at the segment \(x_{i}\) at time \(t_{j}\), kg/s, \(Q_{i,j}^{+}\) is mass flow after the leakage point, kg/s, \(P_{i,j}^{-}\) is pressure before the leakage point, Pa, \(P_{i,j}^{+}\) is pressure after the leakage point, Pa, \(A\) is the cross-sectional area of pipe, m\({}^{2}\), \(c\) is the speed of sound, m/s, \(D\) is pipe diameter, m, and \(\lambda\) is the hydraulic friction coefficient. Figure 1: A real leakage in a continuous pipeline model. Figure 2: Virtual multi-point leakages in a discrete pipeline model. Since the leakage occurs in the vertical direction, it can be assumed that the momentum change caused by the leakage in the horizontal direction can be ignored. According to the principle of mass conservation, the boundary conditions at the leakage point can be given as  
\[P_{i,j}^{+}=P_{i,j}^{-}=P_{i,j} \tag{3}\]  
\[Q_{i,j}^{-}-Q_{i,j}^{+}=K_{i,j}. \tag{4}\]  
Among them, \(i\) = 1, 2,..., \(N;j\) = 1, 2,..., \(P_{i,j}^{-}\), and \(Q_{i,j}^{-}\) represent the mass flow and pressure at time \(t_{j}\) at \(x_{i}^{-}\) position (before the leakage point), namely \(P_{i,j}^{-}=P(x_{i}^{-},t_{j})\) and \(Q_{i,j}^{-}=Q(x_{i}^{-},t_{j})\). In the same way, \(P_{i,j}^{+}=P(x_{i}^{+},t_{j})\), \(Q_{i,j}^{+}=Q(x_{i}^{+},t_{j})\), \(P_{i,j}=P(x_{i},t_{j})\), \(K_{i,j}=K(x_{i},t_{j})\), and \(x_{i}=(i-1)\Delta x\). The EKF-based method proposed in this paper assumes that the leakage rate at each segment point is constant in time [74, 75, 76, 77, 78], namely,  
\[K_{i,j}=K_{i,j-1}. \tag{5}\]  
Equations (1)-(5) are based on the basic idea of filter estimation, and the discretized pipeline transient flow model including virtual multi-point leakage can now be established, as follows. To make the virtual leakage rate a component of the state variables in the above model, Equations (3) and (4) are substituted into Equations (1) and (2) to give  
\[ \begin{array}{cc}(P_{i,j}-P_{i-1,j-1})&+\frac{\xi}{A}(Q_{i,j}^{-}-Q_{i-1,j- 1}^{-}+K_{i-1,j-1})+\frac{\lambda\lambda^{2}\Delta t}{4D\Delta^{2}}\\ \times(\frac{Q_{i,j}^{-}|Q_{i,j}^{-}|}{P_{i,j}}+\frac{(Q_{i-1,j-1}^{-}K_{i-1,j- 1})|Q_{i-1,j-1}^{-}-K_{i-1,j-1}^{-}|}{P_{i-1,j-1}})=0\end{array}  \tag{6}\]  
Figure 3: Discretization for virtual multi-point leakage in a pipeline. \[