## 5 A Simulation Example  
The model is first verified with a simulation example. In this example, the process noise and measurement noise of this simulated gas pipeline are assumed to be Gaussian white noise. The specific parameters are:  
\[L=10\ \text{km},\ D=0.25\ \text{m},\ c=330\ \text{m}/\text{s},\ \lambda=0.05.\]  
The boundary conditions are: \(P(0,t)=2\ \text{MPa},\ Q(L,t)=2.6\ \text{kg}/\text{s}\). Generally, the length of each segment needs to be slightly larger than or equal to the distance that sound travels within one sampling period of the sensor ( ). If the segment length is shorter than that distance, then it is possible to miss the data. If the segment length is too long, then the precision may be reduced. In this example, the sampling frequencies \(f\) of pressure sensors are assumed to be 1 Hz, therefore \(\Delta x=c/f=330\ \text{m}\). Therefore, the pipeline is divided into \(N-1=L/\Delta x\approx 30\) segments by the characteristic line method, namely \(N=31\). It is assumed that the leakage occurs at 500 s, and the leakage point is 4 km away from the starting pressure sensor. To simulate a slow small leakage, set the leakage rate to be 4% of the total flow rate, i.e., 0.1 kg/s. In this simulation example, there are three pressure observation points at 3.3 km, 6.6 km, and 9.9 km, namely \(P_{11,j}\), \(P_{21,j}\), and \(P_{31,j}\), respectively. The state vector is:  
\[\mathbf{X}_{j}=[P_{1,j},P_{2,j},P_{3,j},\ldots,P_{31,j},Q^{-}_{1,j},Q^{-}_{2,j}, \ldots,Q^{-}_{31,j^{\prime}},K_{2,j},K_{3,j},\ldots,K_{30,j}]^{T}.\]Therefore, in this simulation example, the measurement matrix is a matrix of \(3\times 91\)\(\mathbf{H}(1,11)=1\), \(\mathbf{H}(2,21)=1\), and \(\mathbf{H}(3,31)=1\). The rest of the elements are set as 0. The initial condition is:  
\[\hat{\mathbf{X}}_{\mathbf{0}}=[P_{1,0},P_{2,0},P_{3,0},\cdots,P_{31,0},Q_{1,0}^{-},Q_{2, 0}^{-},\cdots,Q_{31,0}^{-},K_{2,0},K_{3,0},\cdots,K_{30,0}]^{T}.\]  
Among them:  
\[P_{11,0}=1,\!949,\!679\ \mathrm{Pa},\,P_{21,0}=1,\!898,\!024\ \mathrm{Pa},\,P_{31,0}=1,\! 844,\!923\ \mathrm{Pa}\]  
\[Q_{1,0}^{-}=\cdots=Q_{31,0}^{-}=2.6\mathrm{kg/s}\]  
\[K_{2,0}=K_{2,0}=\cdots=K_{30,0}=0\]  
\[\hat{\mathbf{P}}_{\mathbf{0}}=\left[ \begin{array}{cccc}0&\mathbf{0}&\mathbf{0}&0&\mathbf{0}\\ \mathbf{0}&\sigma_{\mathrm{PQ}}^{2}\mathbf{I}_{3\mathbf{0}}&\mathbf{0}&\mathbf{0}&\mathbf{0}\\ \mathbf{0}&\mathbf{0}&\sigma_{\mathrm{PQ}}^{2}\mathbf{I}_{3\mathbf{0}}&\mathbf{0}&\mathbf{0}\\ 0&\mathbf{0}&\mathbf{0}&0&\mathbf{0}\\ \mathbf{0}&\mathbf{0}&\mathbf{0}&\sigma_{\mathrm{K0}}^{2}\mathbf{I}_{2\mathbf{9}}\end{array}  \right].\]  
\(\hat{\mathbf{P}}_{\mathbf{0}}\) is a \(91\times 91\) diagonal matrix, where \(\mathbf{I}_{\mathbf{k}}\) is a \(k\times k\) diagonal matrix. Here, the assumptions are:  
\[\sigma_{\mathrm{PQ}}^{2}=10^{8}(\mathrm{Pa})^{2},\ \sigma_{\mathrm{Q0}}^{2}=0.3( \mathrm{kg/s})^{2},\ \mathrm{and}\ \sigma_{\mathrm{K0}}^{2}=0.2(\mathrm{kg/s})^{2}.\]  
The covariance of process noise and measurement noise is known. It is assumed that it does not vary with the state variable [12]. \[\mathbf{Q}=\left[ \begin{array}{cccc}0&\mathbf{0}&\mathbf{0}&\mathbf{0}&\mathbf{0}\\ \mathbf{0}&\sigma_{\mathrm{P}}^{2}\mathbf{I}_{3\mathbf{0}}&\mathbf{0}&\mathbf{0}&\mathbf{0}\\ \mathbf{0}&\mathbf{0}&\sigma_{\mathrm{Q}}^{2}\mathbf{I}_{3\mathbf{0}}&\mathbf{0}&\mathbf{0}\\ 0&\mathbf{0}&\mathbf{0}&0&\mathbf{0}\\ \mathbf{0}&\mathbf{0}&\mathbf{0}&\mathbf{0}&\sigma_{K}^{2}\mathbf{I}_{2\mathbf{9}}\end{array} \right], \ \mathbf{R}=\left[ \begin{array}{cccc}\sigma_{\mathrm{PM}}^{2}&0&0\\ 0&\sigma_{\mathrm{PM}}^{2}&0\\ 0&0&\sigma_{\mathrm{PM}}^{2}\end{array} \right]\]  
where \(\sigma_{P}^{2}\) is the noise variance of pressure, \(\sigma_{\mathrm{Q}}^{2}\) and \(\sigma_{K}^{2}\) are the variance of the noise of flow and leakage rate, respectively. \(\sigma_{\mathrm{PM}}^{2}\) is the measurement noise variance of pressure. Here, the assumptions are: \(\sigma_{P}^{2}=10^{8}(\mathrm{Pa})^{2}\), \(\sigma_{\mathrm{Q}}^{2}=0.25(\mathrm{kg/s})^{2}\), and \(\sigma_{K}^{2}=0.1(\mathrm{kg/s})^{2}\).