Pipeline Leakage Detection and Localization Using a Reliable Pipeline-Mechanism Model Incorporating a Bayesian Model Updating Approach

: Pipeline transportation is widely used in industrial production and daily life. In order to reduce the waste of resources and economic losses caused by pipeline leakage, effective pipeline leakage detection and localization technology is particularly important. Among the many leakage detection methods, the model-based method for pipeline leakage detection and localization is widely used. However, the key to the method is how to obtain an accurate and reliable pipeline model to ensure and improve the detection accuracy. This paper proposes a novel method to obtain a reliable pipeline-mechanism model that fused data and mechanism models based on Bayesian theory. Moreover, in the process of Bayesian fusion, the complexity and calculations in the mechanism models were greatly reduced by establishing a surrogate model. After that, the multidimensional posterior distribution was sampled by the Markov chain Monte Carlo-differential evolution adaptive metropolis (ZS) (MCMC-DREAM (ZS)) algorithm, and the uncertainty in the model was updated to obtain a reliable pipeline-mechanism model. Subsequently, the pipeline resistance coefﬁcient, which could be calculated based on the reliable pipeline-mechanism model, was proposed as an indicator for detecting whether the pipeline leaked or not. Finally, the pipeline leak model was used to determine the location of the leak. The reliable pipeline-mechanism model was applied in an experimental device to validate its performance. The results showed that the proposed method improved the accuracy and reliability of the mechanism model, and, in addition, the leakage could be accurately located.


Introduction
Pipeline transportation plays an important role in industrial production and daily life.Moreover, pipeline transportation is also an important infrastructure of human society because of its large capacity, simple construction, low price and easy control.However, there are always some problems such as corrosion, aging and external force in the pipelines.Under the influence of various internal and external factors, the phenomenon of pipeline leakage exists widely.Pipeline leakage has caused a huge waste of resources and economic losses.Therefore, in order to ensure the safety and reliability of the pipeline system, timely detection and localization of pipeline leakage is very important in industrial production and daily life.For this reason, a lot of pipeline leakage detection and localization methods have been proposed by industry and academia [1][2][3].The current pipeline leakage detection methods can be mainly divided into three categories: (1) environmental detection outside a pipeline; (2) detection of a pipeline's internal condition; (3) detection of the fluid flow state in a pipeline.The first category is concerned with detecting and locating leakages by detecting changes in the environmental medium outside a pipeline.At present, the Water 2022, 14, 1255 2 of 20 ground penetrating radar method is commonly used [4].The second one detects defects in a pipeline's wall by instruments, such as optical fiber sensors [5,6], acoustic sensors [7], magnetic leakage technology [8], etc.The third one establishes a model based on effective data, such as flow and pressure that describe the flow state of the pipeline, and then completes the real-time monitoring and positioning of a leak point.This type of method mainly includes the negative pressure wave method [9,10], pressure gradient method [11], volume/mass balance method [12] and transient test-based techniques (TTBTs) [13,14].In the last couple of decades, TTBTs could be used in pressurized pipes and are more widely developed due to the stronger real-time nature of the acquired measurement data and lower capital cost [15,16].Currently, TTBTs mainly include the inverse transient-based method (ITM) [17], frequency response-based method (FRM) [18], transient damping-based method (TDM) [19] and transient reflection-based method (TRM) [20].Zeng et al. [21] used the transient pressure in a pipeline through a custom-made in-pipe fiber optic sensor array for pipeline leakage detection and localization.Duan et al. [22] established a pipeline model using the hydraulic properties of fluid transient flow and used FRM to detect leaks in complex pipelines.Meniconi et al. [23] confirmed the potential of TTBTs for fault detection in real pipe systems by two series of transient tests.Brunone et al. [24] introduced the smart-portable pressure water maker (S-PPWM) device, which could be used for fault detection in pressurized transmission mains within TTBTs.However, the effectiveness of these methods is highly dependent on the accuracy of the pipeline model used.From the perspective of model building, mechanism modeling and data-driven modeling, these are the two main approaches.The data-driven approach does not require any specific in-depth knowledge of pipeline hydraulics, it just learns from the collected historical data, coupled with some statistical or pattern recognition tools.Among them, an artificial neural network (ANN) and support vector machine (SVM) are the most commonly used.For example, Wang et al. [25] used an eigenvector containing multiple sources of information for leak recognition by an SVM classifier.Zadlkarami et al. [26] proposed the multi-layer perceptron neural network classifier using process pipeline flow and pressure signals for leak detection and localization.Da Cruz et al. [27] utilized various machine learning algorithms with acoustic data to detect and locate leaks in gas pipelines.
For the pipeline leak detection method based on the mechanism model, the reliability of the model has a great influence on the pipeline leak detection results.However, due to the complicated changes of pipeline operating conditions and many uncertainties in the actual process, even complex and advanced mathematical models cannot accurately simulate a pipeline for actual operation.There is always a certain deviation between the obtained model and the actual model, which in turn leads to a decrease in the correctness of leakage detection and localization, resulting in the occurrence of false alarms or leak alarms.On the other hand, from the perspective of water supply safety, the analysis of potential hydraulic network failures, which allows for greater insight into failures occurring in a pipe [28], also depends on the reliability of the pipe simulation or model.Therefore, eliminating model uncertainty and improving the model accuracy and robustness have become hot research topics for pipeline leakage detection and water supply safety.An alternative way to improve model reliability is to fuse the mechanism model and the datadriven model, the deviation of the model due to uncertainty can be adjusted and corrected according to the change in actual operation parameters.Gerhard et al. [29] proposed a leakage detection and localization method that combined real-time transient models and artificial neural networks.Soldevila et al. [30] used a data-driven model to evaluate residuals obtained by means of the comparison between the measurements and the values obtained by the water-distribution-network model for leak localization.Wang et al. [31] established a hybrid model, which used an RBF neural network to compensate for the pipeline-mechanism model error.Nevertheless, these methods have certain limitations.First, the data-driven model has the problems of repeated modeling and low computational efficiency, that is, after each new design scheme is generated, it is necessary to re-collect data to train a new data-driven model.Second, a large amount of sample data is required to establish a data-driven model.Third, the general combination of the data-driven model and mechanism model often only updates the uncertainty in the output of the model, while ignoring the uncertainty of the parameters in the model.
Bayesian theory is an effective technique for quantifying the uncertainty of the parameters in a model.The parameters in a model to be estimated can be treated as random variables and, then, some relevant observed variables, or known conditions, can be used to infer the parameters in order to obtain the posterior conditional probability of the variables.In this way, the quantitative analysis of the model parameter uncertainties is realized.Originally, the Bayesian method was used to analyze the sensitivity of eigenvectors and eigenvalues [32,33].Beck et al. [34] studied a Bayesian update and reliability method based on a Markov Chain.Kennedy et al. [35] used a Bayesian approach to model error quantification and unknown parameter estimation.Recently, Bayesian methods have been widely used in various fields, such as medicine [36], urban environment [37], ecosystems [38], etc. Fleming et al. [39] used Markov modeling technology to predict the influence of detection strategies on the reliability of a pipe network system, and used the Bayesian method to quantify and analyze the uncertainty of the parameters of a pipe network system.Rougier et al. [40] evaluated parameter uncertainty through Bayesian theory and obtained posterior distributions of leakage location and size.For a nonlinear high-dimensional posterior probability distribution, sampling methods are often used for sampling statistical analysis.Among them, the Markov chain Monte Carlo method (MCMC) is an efficient sampling method.At present, many sampling algorithms have been derived from the MCMC method, which can be divided into single-chain MCMC sampling algorithms and multi-chain MCMC sampling algorithms.The DREAM (differential evolution adaptive metropolis) algorithm is a representative of the multi-chain MCMC sampling algorithm, which was proposed by Vrugt et al. in 2009 [41], and was improved to become the DREAM(ZS) algorithm in 2012 [42].It has been verified that the algorithm has higher search efficiency for solving high-dimensional nonlinear problems.
In this paper, the reliable pipeline-mechanism model was established by integrating the statistical data and the mechanism model based on Bayesian theory.In the process of Bayesian fusion, a surrogate model was used to greatly reduce the calculational complexity and load.The posterior probability density was sampled and analyzed by the DREAM(ZS) algorithm.Then, based on the reliable pipeline-mechanism model, a pipeline resistance coefficient observer and a pipeline-leakage model were established, which were used to detect and locate pipeline leakage, respectively.
The contributions of this paper are summarized as follows: (1) Through Bayesian fusion of historical statistics and the pipeline-mechanism model, the uncertainty in the mechanism model was quantified and updated, and a pipelinereliability model was established; (2) Based on the pipeline-reliability model, the pipe resistance coefficient could be calculated as an indicator for leak detection, and the pipeline-leakage model could be obtained for leak localization.
The remainder of this paper is organized as follows: in Section 2, the pipeline-reliability model is established and pipeline detection and localization technology based on the reliability model are described in detail; in Section 3, the research results are analyzed and discussed through experiments; finally, the conclusions are given and future work is discussed in Section 4.

Methods
In our study, the uncertainties of the pipeline-mechanism model mainly come from three aspects: (1) model input variables-here the uncertainty comes from the operating pressure and flow data at pipeline inlets and outlets, which are obtained by sensors; (2) model parameters-these parameters, such as the pipeline resistance coefficient, the angle of the fluid to the horizontal axis and internal diameter, are usually obtained by measurement or experience, which are inherently uncertain; (3) quantitative relationship between model input and output-due to the inadequacies and limitations of the acquired knowledge of the process, there is uncertainty in the quantitative relationship between inputs and outputs in the modeling process.In this paper, by fusing the pipeline-mechanism model and statistical data, a reliable pipeline-mechanism model integrating knowledge and data was established, which quantified the uncertainty between inputs and outputs and the uncertainty of model parameters.The obtained model was used to calculate the pipeline resistance coefficient, which could be used as an indicator for pipeline leakage detection.The scheme of the proposed method is shown in Figure 1.
Water 2022, 14, x FOR PEER REVIEW 4 of 21 of the fluid to the horizontal axis and internal diameter, are usually obtained by measurement or experience, which are inherently uncertain; (3) quantitative relationship between model input and output-due to the inadequacies and limitations of the acquired knowledge of the process, there is uncertainty in the quantitative relationship between inputs and outputs in the modeling process.In this paper, by fusing the pipeline-mechanism model and statistical data, a reliable pipeline-mechanism model integrating knowledge and data was established, which quantified the uncertainty between inputs and outputs and the uncertainty of model parameters.The obtained model was used to calculate the pipeline resistance coefficient, which could be used as an indicator for pipeline leakage detection.The scheme of the proposed method is shown in Figure 1.

Pipeline-Mechanism Model
Based on the principle of hydraulics, the pipeline-mechanism model was established through the continuity equation, motion momentum equation and energy equation followed in the operation of the pipeline fluid, and then a virtual pipeline could be constructed.Through the pipeline-mechanism model, the pressure and flow of the fluid in a pipeline were analyzed and calculated with respect to time along a pipeline.The real-time transient mechanism model can be expressed as in [43,44]:

Pipeline-Mechanism Model
Based on the principle of hydraulics, the pipeline-mechanism model was established through the continuity equation, motion momentum equation and energy equation followed in the operation of the pipeline fluid, and then a virtual pipeline could be constructed.Through the pipeline-mechanism model, the pressure and flow of the fluid in a pipeline were analyzed and calculated with respect to time along a pipeline.The real-time transient mechanism model can be expressed as in [43,44]: Water 2022, 14, 1255 where Equation ( 1) is the flow continuity equation, Equation ( 2) is the motion momentum equation and Equation ( 3) is the energy equation.P is the average pressure of the pipeline section, v is the average velocity of the pipe section, ρ is the average density of fluid, λ is the hydraulic resistance coefficient, g is the acceleration of gravity, α is the angle of the fluid to the horizontal axis, D is the inner diameter of the pipe, a is the pressure wave propagation speed, t is time, x is the distance along the pipeline, C V is the heat energy for the liquid in the pipe, k is the ground thermal conductivity, T(r) is a function of temperature, T is the liquid temperature and r is the radial distance from a specific position along the pipeline to the center of the pipe diameter.If the fluid in the pipeline was liquid, the influence of temperature on the fluid flow was usually negligible, that is, the energy change in the pipeline could be ignored, so the original Equation ( 3) was not considered in our work.
If only fluid changes at different positions in a pipeline were considered and the change in the fluid state with time was ignored, the steady state model of a pipeline could be established, and the fluid flow parameters of each point along the pipeline could be obtained through model Equations ( 1) and ( 2).Then, the steady state model of a pipeline can be formulated as The pipeline steady-state model is a system of ordinary differential equations, which can be solved using the fourth-order Runge-Kutta method.The pipeline real-time transient model is a set of nonlinear partial differential equations, which can usually be solved by the characteristic line method.There are three types of boundary conditions for the characteristic line method, which are inlet flow and outlet pressure head (QH), inlet pressure head and outlet flow (HQ) and inlet pressure head and outlet pressure head (HH), respectively.

Bayesian Fusion Method
The mechanism model and statistical data were integrated based on Bayesian theory, and the purpose was to quantitatively analyze the model input parameters (including pipeline input variables and pipeline model parameters) and model output errors, so that the model could be revised.The principle of the Bayesian fusion model is shown in Figure 2.
where Equation ( 1) is the flow continuity equation, Equation ( 2) is the motion momentum equation and Equation ( 3) is the energy equation. is the average pressure of the pipeline section,  is the average velocity of the pipe section,  is the average density of fluid,  is the hydraulic resistance coefficient,  is the acceleration of gravity,  is the angle of the fluid to the horizontal axis,  is the inner diameter of the pipe,  is the pressure wave propagation speed,  is time,  is the distance along the pipeline,   is the heat energy for the liquid in the pipe,  is the ground thermal conductivity, () is a function of temperature,  is the liquid temperature and  is the radial distance from a specific position along the pipeline to the center of the pipe diameter.If the fluid in the pipeline was liquid, the influence of temperature on the fluid flow was usually negligible, that is, the energy change in the pipeline could be ignored, so the original Equation ( 3) was not considered in our work.
If only fluid changes at different positions in a pipeline were considered and the change in the fluid state with time was ignored, the steady state model of a pipeline could be established, and the fluid flow parameters of each point along the pipeline could be obtained through model Equations ( 1) and (2).Then, the steady state model of a pipeline can be formulated as The pipeline steady-state model is a system of ordinary differential equations, which can be solved using the fourth-order Runge-Kutta method.The pipeline real-time transient model is a set of nonlinear partial differential equations, which can usually be solved by the characteristic line method.There are three types of boundary conditions for the characteristic line method, which are inlet flow and outlet pressure head (QH), inlet pressure head and outlet flow (HQ) and inlet pressure head and outlet pressure head (HH), respectively.

Bayesian Fusion Method
The mechanism model and statistical data were integrated based on Bayesian theory, and the purpose was to quantitatively analyze the model input parameters (including pipeline input variables and pipeline model parameters) and model output errors, so that the model could be revised.The principle of the Bayesian fusion model is shown in Figure 2.

Bayesian Method
From Bayesian theory, the posterior probability distribution is related to the product of the prior distribution and the likelihood function.Therefore, the method of the Bayesian fusion mechanism model and statistical data shown in Figure 2 can be expressed as Water 2022, 14, 1255 6 of 20 where P(Φ, θ, ∆) is the prior distribution of pipeline model input, pipeline model parameters and model output error, L(Ψ, M(Φ, θ), ∆|Φ, θ) is the Bayesian fusion likelihood function representing the fusion of pipeline-mechanism models and statistical data, P (Φ, θ, ∆) is the posterior distribution of model input, pipeline model parameters, and model output error obtained after Bayesian fusion, M(Φ, θ) is the mechanism models including pipeline knowledge and its uncertainties, Φ is the input to the model, that is, the flow and pressure at the inlet of the pipe, Ψ is the measurements of the model output (containing the uncertainty in the measurement), θ is the pipeline model parameter including pipeline length, diameter, local resistance coefficient, etc., ∆ is the model output error, that is, the difference between the outlet pressure of the pipeline-mechanism model and the measured value of the actual pipeline outlet pressure.

Prior Distribution
The pipeline prior distribution specified in our study came from empirical formulas and data estimated from measurements.The prior probability distribution was assumed to be a normal distribution with the mean value being the measured value or empirical data, and the 95% confidence interval of the normal distribution was the mean ± 10%.The joint prior probability density function was the prior probability density product of each parameter to be calculated, expressed as

Likelihood Function
The key to Bayesian fusion is to determine the likelihood function.The mathematical model considering uncertainty is generally expressed by the following equation: where E is the uncertain information, which leads to the difference between the outlet pressure of the pipeline-mechanism model and the measured value of the actual pipeline outlet pressure.
Assuming that the uncertainty information is normally distribution with a mean value of 0 and a variance of σ 2 , and there are N groups of experimental data, the model input is Φ = {ϕ 1 , ϕ 2 , ϕ 3 , . . . ,ϕ N } and the model output is Ψ = {Ψ 1 , Ψ 2 , Ψ 3 , . . . ,Ψ N }.So, the likelihood function can be expressed as where L Ψ j θ is the likelihood function obtained from the group j.Assuming that all data are independent, the likelihood function can be written as where, The variance of σ 2 can be determined by the method of maximum likelihood estimation, expressed by the following equations: Water 2022, 14, 1255 Substituting Equation ( 13) into Equation (10), the likelihood function for Bayesian fusion can be obtained by the following expression:

Posterior Distribution
Through the obtained prior probability density function (Equation ( 7)) and likelihood function (Equation ( 14)), the posterior probability density function obtained by Bayesian fusion shown in Equation ( 6) could be solved.Then, the joint posterior probability density of the input, parameters, and output data in the model could be obtained based on Bayesian fusion.In addition, the tasks of quantifying error and updating uncertainty could be achieved.

Surrogate Model
In order to reduce the amount of computation and the computation time in the process of Bayesian fusion, the surrogate model was established to replace the pipeline-mechanism model.In our work, the surrogate model of the pipeline-mechanism model was constructed by the polynomial chaos expansion (PCE) method [45], and the method was mainly based on the theory of chaotic polynomials (polynomial chaos, PC), which approximates and accurately represents a random expansion process through the sum of a series of orthogonal polynomials related to the input parameters.The surrogate model is expressed as where, A A 0 , A i 1 , A i 1 i 2 , . . . is the polynomial coefficient, η n ξ i 1 , ξ i 1 , ξ i 3 , . . . is the n-dimensional Hermite polynomial of degree n, ξ = [Φ, θ, ∆] is an independent random variable containing uncertain parameters in the pipeline model.

Sampling Method
Sampling is widely used in Bayesian inference.In order to obtain the highdimensional and nonlinear joint posterior probability density distribution, the MCMC-DREAM(ZS) algorithm to sample the joint posterior probability density distribution was utilized in our study.The DREAM algorithm belongs to the multi-chain MCMC sampling algorithm, which has better performance than the single-chain MCMC algorithm for parameters with complex distribution.Detailed content of the algorithm can be found in the literature [41,42].

Leak Detection 2.5.1. Pipeline Resistance Coefficient Observer
The resistance coefficient λ of a pipeline is related to the shape of the pipeline and the working condition of the fluid, so it is very difficult to correct it through the uncertainty and quantification of a single parameter.Generally, the resistance coefficient of a pipeline can be obtained through empirical formulas (Blasius formula, Severson's formula, etc.).If the parameters obtained by this method are denoted as λ 1 , it can be expressed as where Re is the Reynolds number, ε is absolute roughness, D is the pipe's inner diameter, f is the empirical formula for calculating pipeline resistance coefficient.Alternatively, the pipeline resistance coefficient can also be calculated from the relationship of the pipeline model, expressed by the following equations: where λ 2 is the resistance coefficient calculated from the relationship of the pipeline model, P H is the inlet pressure of the pipeline, P E is the outlet pressure of the pipeline.Once the reliable pipeline-mechanism model was established, the resistance coefficient obtained by the model was more accurate.
Comparing λ 1 and λ 2 , when the error exceeded a given value, the resistance coefficient could be updated by introducing C 1 and C 2 .In this way, the resistance coefficient λ can be expressed as: A pipeline resistance coefficient can be calculated by the pipeline flow and pressure measured at the inlet and outlet of the pipeline by Equation (20).The pipeline resistance coefficient observer is established by observing the pipeline resistance coefficient of the inlet and outlet of the pipeline in real time.

Leak Detection
The traditional model-based pipeline leak detection method is usually based on monitoring the flow and pressure at the inlet and outlet of a pipeline to judge whether a leak occurs during the operation of the pipeline.However, this method is prone to false negatives and false positives in the case of sudden changes in working conditions, small leakage and large noise.In our study, the change in the inlet and outlet resistance of the pipeline was regarded as an indicator, and when its change exceeded a given value, the pipeline was considered to have a leak.The resistance of the inlet and outlet of a pipeline was observed by establishing a pipeline resistance observer in real time.

Leak Location
The location of pipeline leakage was realized by establishing a pipeline-leakage model.When pipeline leakage occurred, the pipeline leakage point was set as the pipeline boundary condition.Through the steady state model (Equations ( 4) and ( 5)), the pipeline leakage location could be obtained through the following equation: where, Q H is the measured value of the flow at the inlet of the pipeline, Q E is the measured value of the flow at the outlet of the pipeline, λ H is the pipe resistance coefficient calculated from the data at the inlet of the pipeline, λ E is the pipe resistance coefficient calculated from the data at the outlet of the pipeline.
It should be noted that the leakage position calculated according to Equation (21) had large fluctuations, which could be improved by the least squares method to locate the specific leakage.
The numerator and denominator of Equation ( 21) are defined as Water 2022, 14, 1255 9 of 20 When the objective function ∑ n i=1 (L yi − Lr × L xi ) 2 reaches the minimum, the obtained leakage position Lr is shown as

Experimental Device
The feasibility of the proposed method in our work was verified by simulation with the experimental device shown in Figure 3.The total length of the pipeline was about 42 m, the diameter of the pipe was about 0.023 m and the medium in the pipe was water.The pressure and flow at the inlet and outlet of the pipeline were measured by using sensors.As shown in Figure 3, Flowmeter #1 and Pressure Sensor #2 were a flowmeter and a pressure sensor, respectively, at the inlet of the pipeline, and Flowmeter #2 and Pressure Sensor #2 were a flowmeter and a pressure sensor, respectively, at the outlet of the pipeline.The data within 30 s of stable operation of the pipeline was obtained, and the sampling frequency was 1000 Hz, so each set of data contained 30,000 points.The data under different working conditions was obtained by changing the fluid flow and pressure at the inlet of the pipeline, and the leakage of the pipeline was controlled by electromagnetic valves.Two leakage positions were considered in the pipeline, the positions were 30% and 80% of the total length of the pipeline, respectively.The size of the leakage aperture wes controlled by two electromagnetic valves, as shown in the Figure 3. Leakage Apertures 1 and 2 represented large leaks and small leaks, respectively.The large leak aperture was 3 mm and the small leak aperture was 1.2 mm.specific leakage.
The numerator and denominator of Equation ( 21) are defined as Therefore, When the objective function ∑ (  =1   −  ×   ) 2 reaches the minimum, the obtained leakage position  is shown as

Experimental Device
The feasibility of the proposed method in our work was verified by simulation with the experimental device shown in Figure 3.The total length of the pipeline was about 42 m, the diameter of the pipe was about 0.023 m and the medium in the pipe was water.The pressure and flow at the inlet and outlet of the pipeline were measured by using sensors.As shown in Figure 3, Flowmeter #1 and Pressure Sensor #2 were a flowmeter and a pressure sensor, respectively, at the inlet of the pipeline, and Flowmeter #2 and Pressure Sensor #2 were a flowmeter and a pressure sensor, respectively, at the outlet of the pipeline.The data within 30 s of stable operation of the pipeline was obtained, and the sampling frequency was 1000 Hz, so each set of data contained 30,000 points.The data under different working conditions was obtained by changing the fluid flow and pressure at the inlet of the pipeline, and the leakage of the pipeline was controlled by electromagnetic valves.Two leakage positions were considered in the pipeline, the positions were 30% and 80% of the total length of the pipeline, respectively.The size of the leakage aperture wes controlled by two electromagnetic valves, as shown in the Figure 3. Leakage Apertures 1 and 2 represented large leaks and small leaks, respectively.The large leak aperture was 3 mm and the small leak aperture was 1.2 mm.

Model Validation
In this paper, the establishment of pipeline model and Bayesian fusion were carried out in MATLAB 2019b.Through a set of experiments, the pressure and flow of the inlet and outlet of the pipeline under different working conditions were recorded as historical statistical data for the pipeline, and the parameters of the pipeline model could be updated through Bayesian fusion.When the pressure at the inlet of the pipeline was 2.41 bar and the flow velocity was 2.45 m/s, the joint posterior distribution results of the obtained pipeline model parameters are shown in Figure 4, the updated maximum posterior distribution parameter values are shown in Table 1.

Model Validation
In this paper, the establishment of pipeline model and Bayesian fusion were carried out in MATLAB 2019b.Through a set of experiments, the pressure and flow of the inlet and outlet of the pipeline under different working conditions were recorded as historical statistical data for the pipeline, and the parameters of the pipeline model could be updated through Bayesian fusion.When the pressure at the inlet of the pipeline was 2.41 bar and the flow velocity was 2.45 m/s, the joint posterior distribution results of the obtained pipeline model parameters are shown in Figure 4, the updated maximum posterior distribution parameter values are shown in Table 1.

Model Validation
In this paper, the establishment of pipeline model and Bayesian fusion were carried out in MATLAB 2019b.Through a set of experiments, the pressure and flow of the inlet and outlet of the pipeline under different working conditions were recorded as historical statistical data for the pipeline, and the parameters of the pipeline model could be updated through Bayesian fusion.When the pressure at the inlet of the pipeline was 2.41 bar and the flow velocity was 2.45 m/s, the joint posterior distribution results of the obtained pipeline model parameters are shown in Figure 4, the updated maximum posterior distribution parameter values are shown in Table 1.The established model was corrected after using Bayesian fusion.Figure 5 sho actual pipe outlet pressure measurement compared to the model output (before an correction), and it could be seen that the corrected model performed better.As the p statistics increased, the uncertainty of parameters could be updated in real time th Bayesian fusion, making the model more robust and reliable.The established model was corrected after using Bayesian fusion.Figure 5 shows the actual pipe outlet pressure measurement compared to the model output (before and after correction), and it could be seen that the corrected model performed better.As the pipeline statistics increased, the uncertainty of parameters could be updated in real time through Bayesian fusion, making the model more robust and reliable.

Leak Detection
Traditional pipeline leakage detection methods detect pipeline leakage by comparing the flow and pressure residual between the measurements and the values obtained by the mechanism model.However, in the case of large noise and small leakage, this method may cause false negatives and false positives.When leakage occurred at 15 s, the pressure changes at the outlet of the pipeline and the model output change are shown in Figure 6. Figure 6a is the pressure change diagram when a large leak oc-curred, and Figure 6b is a pressure change diagram when a small leak occurred.The residuals between the actual pipeline and the model output after the leakage occurred are shown in Figure 7; the red dotted line is the set threshold, and when the change value exceeded the threshold, it would be regard as a leakage.It could be seen that in the case of a small leakage, the leakage residual was difficult to distinguish from the measurement noise.

Leak Detection
Traditional pipeline leakage detection methods detect pipeline leakage by comparing the flow and pressure residual between the measurements and the values obtained by the mechanism model.However, in the case of large noise and small leakage, this method may cause false negatives and false positives.When leakage occurred at 15 s, the pressure changes at the outlet of the pipeline and the model output change are shown in Figure 6. Figure 6a is the pressure change diagram when a large leak occurred, and Figure 6b is a pressure change diagram when a small leak occurred.The residuals between the actual pipeline and the model output after the leakage occurred are shown in Figure 7; the red dotted line is the set threshold, and when the change value exceeded the threshold, it would be regard as a leakage.It could be seen that in the case of a small leakage, the leakage residual was difficult to distinguish from the measurement noise.

Leak Detection
Traditional pipeline leakage detection methods detect pipeline leakage by comparing the flow and pressure residual between the measurements and the values obtained by the mechanism model.However, in the case of large noise and small leakage, this method may cause false negatives and false positives.When leakage occurred at 15 s, the pressure changes at the outlet of the pipeline and the model output change are shown in Figure 6. Figure 6a is the pressure change diagram when a large leak occurred, and Figure 6b is a pressure change diagram when a small leak occurred.The residuals between the actual pipeline and the model output after the leakage occurred are shown in Figure 7; the red dotted line is the set threshold, and when the change value exceeded the threshold, it would be regard as a leakage.It could be seen that in the case of a small leakage, the leakage residual was difficult to distinguish from the measurement noise.In our work, the leakage could be detected by the pipeline resistance coefficient observer.Comparing the pipeline resistance coefficients of the inlet and outlet of the pipeline, and when the deviation between the two was greater than a given threshold, it was concluded that leakage had occurred.Figure 8 shows the comparison results between the inlet resistance coefficient and the outlet resistance coefficient of the pipeline, and Figure 9 presents the residual plots of the pipeline resistance coefficients at the inlet and outlet of the pipeline in case of a large leakage and a small leakage.In order to evaluate the performance of the proposed method, the traditional pressure residual method and SVM were selected to compare the accuracy.The leak detection accuracy obtained by each method is shown in Table 2.It could be seen that the detection method of the pipeline resistance coefficient observer could obtain better results in the case of small leakages and large noise, compared with the other two methods.In our work, the leakage could be detected by the pipeline resistance coefficient observer.Comparing the pipeline resistance coefficients of the inlet and outlet of the pipeline, and when the deviation between the two was greater than a given threshold, it was concluded that leakage had occurred.Figure 8 shows the comparison results between the inlet resistance coefficient and the outlet resistance coefficient of the pipeline, and 9 presents the residual plots of the pipeline resistance coefficients at the inlet and outlet of the pipeline in case of leakage and a small leakage.In order to evaluate the performance of the proposed method, the traditional pressure residual method and SVM were selected to compare the accuracy.The leak detection accuracy obtained by each method is shown in Table 2.It could be seen that the detection method of the pipeline resistance coefficient observer could obtain better results in the case of small leakages and large noise, compared with the other two methods.In our work, the leakage could be detected by the pipeline resistance coefficient observer.Comparing the pipeline resistance coefficients of the inlet and outlet of the pipeline, and when the deviation between the two was greater than a given threshold, it was concluded that leakage had occurred.Figure 8 shows the comparison results between the inlet resistance coefficient and the outlet resistance coefficient of the pipeline, and Figure 9 presents the residual plots of the pipeline resistance coefficients at the inlet and outlet of the pipeline in case of a large leakage and a small leakage.In order to evaluate the performance of the proposed method, the traditional pressure residual method and SVM were selected to compare the accuracy.The leak detection accuracy obtained by each method is shown in Table 2.It could be seen that the detection method of the pipeline resistance coefficient observer could obtain better results in the case of small leakages and large noise, compared with the other two methods.

Leak Location
When the pipeline leaked, the pipeline-leakage model was used to locate the pipeline leakage.The output of the pipeline-leakage model was processed by the least squares method to reduce the fluctuation of the output.The optimization effect is shown in Figure 10, it could be seen that the fluctuation in the output result could be effectively weakened by the least squares method.

Leak Location
When the pipeline leaked, the pipeline-leakage model was used to locate the pipeline leakage.The output of the pipeline-leakage model was processed by least squares method to reduce the fluctuation of the output.The optimization effect is shown in Figure 10, it could be seen that the fluctuation in the output result could be effectively weakened by the least squares method.

Leak Location
When the pipeline leaked, the pipeline-leakage model was used to locate the pipeline leakage.The output of the pipeline-leakage model was processed by the least squares method to reduce the fluctuation of the output.The optimization effect is shown in Figure 10, it could be seen that the fluctuation in the output result could be effectively weakened by the least squares method.

Figure 1 .
Figure 1.The framework of the proposed method.

Figure 1 .
Figure 1.The framework of the proposed method.

Figure 2 .
Figure 2. The principle of Bayesian fusion.

Figure 2 .
Figure 2. The principle of Bayesian fusion.

Figure 3 .
Figure 3. Experimental device.(a) Photo of experimental setup and components; (b) schematic diagram of experimental setup.

Figure 3 .
Figure 3. Experimental device.(a) Photo of experimental setup and components; (b) schematic diagram of experimental setup.

Figure 4 .Table 1 .
Figure 4. Posterior distribution obtained after Bayesian fusion.("×" represents the paramete when the maximum posterior probability was obtained).(a) Posterior distribution of input a put errors; (b) Posterior distribution of in-model parameters.

Figure 4 .
Figure 4. Posterior distribution obtained after Bayesian fusion.("×" represents the parameter value when the maximum posterior probability was obtained).(a) Posterior distribution of input and output errors; (b) Posterior distribution of in-model parameters.

Water 2022 , 21 Figure 5 .
Figure 5.Comparison of pipeline measurement data and model predictions (before and after correction).

Figure 5 .
Figure 5.Comparison of pipeline measurement data and model (before and after correction).

Figure 5 .
Figure 5.Comparison of pipeline measurement data and model predictions (before and after correction).

Figure 6 .
Figure 6.Comparison between the model output and the actual pressure change value at the outlet of the pipeline when leakage occurred.(a) Large leakage; (b) small leakage.(a)(b)

Figure 6 .Figure 7 .
Figure 6.Comparison between output and the actual pressure change value at the outlet of the pipeline when leakage occurred.(a) Large leakage; (b) small leakage.

Figure 8 .
Figure 8.Comparison of resistance coefficients at the inlet and outlet of the pipeline when leakage occurred.(a) Large leakage; (b) small leakage.

Figure 7 .
Figure 7. Residual the model output and actual pressure at the of the pipeline when (a) Large leakage; (b) small leakage.

Figure 7 .
Figure 7. Residual between the model output and actual pressure at the outlet of the pipeline when leakage occurred.(a) Large leakage; (b) small leakage.

Figure 8 .
Figure 8.Comparison of resistance coefficients at the inlet and outlet of the pipeline when leakage occurred.(a) Large leakage; (b) small leakage.

Figure 8 .Figure 9 .
Figure 8. of resistance coefficients at the inlet and outlet of the pipeline when leakage occurred.(a) Large leakage; (b) small leakage.

Figure 10 .
Figure 10.The least squares method reduced model output fluctuations.(a) Large leakage; (b) small leakage.The location results of the proposed leak model are shown in Figure 11.Compared with the other two localization methods (i.e., NPW and the uncorrected model-based

Figure 9 .
Figure 9. Residuals of resistance coefficients between the inlet and outlet of the pipeline when leakage occurred.(a) Large leakage; (b) small leakage.

Figure 9 .
Figure 9. Residuals of resistance coefficients between the inlet and outlet of the pipeline when leakage occurred.(a) Large leakage; (b) small leakage.

Figure 10 .
Figure 10.The least squares method reduced model output fluctuations.(a) Large leakage; (b) small leakage.The location results of the proposed leak model are shown in Figure 11.Compared with the other two localization methods (i.e., NPW and the uncorrected model-based

Figure 10 .
Figure 10.The least squares model output (a) Large leakage; (b) small leakage.The location results of the proposed leak model are shown in Figure 11.Compared with the other two localization methods (i.e., NPW and the uncorrected model-based method), the comparison results of each localization method are shown in Table3.It could be seen that the proposed method gave better localization accuracy.

Table 1 .
Updated maximum posterior distribution parameter values.

Table 2 .
Comparison of leak-detection accuracy of various methods.

Table 2 .
Comparison of leak-detection accuracy of various methods.

Table 2 .
Comparison of leak-detection accuracy of various methods.