Kalman Filters for Leak Diagnosis in Pipelines: Brief History and Future Research

: The purpose of this paper is to provide a structural review of the progress made on the detection and localization of leaks in pipelines by using approaches based on the Kalman ﬁlter. To the best of the author’s knowledge, this is the ﬁrst review on the topic. In particular, it is the ﬁrst to try to draw the attention of the leak detection community to the important contributions that use the Kalman ﬁlter as the core of a computational pipeline monitoring system. Without being exhaustive, the paper gathers the results from different research groups such that these are presented in a uniﬁed fashion. For this reason, a classiﬁcation of the current approaches based on the Kalman ﬁlter is proposed. For each of the existing approaches within this classiﬁcation, the basic concepts, theoretical results, and relations with the other procedures are discussed in detail. The review starts with a short summary of essential ideas about state observers. Then, a brief history of the use of the Kalman ﬁlter for diagnosing leaks is described by mentioning the most outstanding approaches. At last, brief discussions of some emerging research problems, such as the leak detection in pipelines transporting heavy oils; the main challenges; and some open issues are addressed.


Introduction
Because of the operation conditions, onshore and offshore pipelines are subjected to environmental loads (wind, waves, current, seabed movements, and earthquakes) that can provoke undesirable vibrations, stress, fatigue problems, and the propagation of cracks [1,2]. In particular, this last issue is an important source of leaks together with the aging of the pipelines, failures in the installation, illegal extractions, and terrorist sabotage. For this reason, to avoid environmental disasters, the oil and gas sectors invest generous resources for the development of robust and reliable leak detection systems, which according to the API RP 1130 standard, can be classified as external or internal systems [3]. External systems use local sensors (e.g., acoustic microphones or fiber optic cables) to send an alarm when a leak occurs, and they do not perform the computation for diagnosing a leak. Internal systems utilize field instrumentation outputs, which monitor internal pipeline parameters (e.g., pressure, temperature, flow rate, and viscosity), and algorithmic monitoring tools. Therefore, internal systems are also known as computational pipeline monitoring systems (CPM systems) [4].
Among the algorithmic tools that have been extensively used for dealing with the fault diagnosis of pipelines, the state observers have proved to be a powerful tool for the estimation in real-time of the internal state variables of a given system (e.g., a pipeline). These estimations are based on the knowledge of available measurements (inputs and outputs of such a system) and other known parameters. Concretely, a state estimator is a model of a system with an online adaptation (correction) based on available measurements for reconstructing unknown information; see Figure 1 [5]. Usually, the model is given in a state-space representation, which can be, in general, continuous-time or discrete-time, deterministic or stochastic, and finite-dimensional or infinite-dimensional.

State Estimator
Model+Adaptation term Pipeline Figure 1. Architecture of a computational pipeline monitoring (CPM) system based on a state estimator.
Several types of state estimators, such as Kalman filters, Luenberger-type observers, high gain observers, and sliding mode observers, have been used for leak detection and localization. Three good reviews that summarize the research and development of state estimator-based leak detection systems for liquid pipelines are given in [6,7]. The literature, however, still lacks a more in-depth review of state of the art in leak detection using Kalman filters, which are the most commonly used estimators for detecting and localizing leaks, and according to D. Simon, are "the best linear estimators" [8]. For this reason, this work aims to fill this gap, since the approaches based on these filters deserve a separate study.
There are several versions of the Kalman filter for dealing with the diversity of physical systems and their associated problems. For example, the ensemble Kalman filter (EnKF), which is suitable for problems with a large number of variables, such as those described by partial differential equations [9]. For estimating the states of nonlinear systems, there are ad hoc versions, such as the extended Kalman filter (EKF), the unscented Kalman filter (UKF), and the particle filter (PF). This paper focuses only on the versions that are used for leak detection, such as The Kalman filter, the discrete Kalman filter, and the extended Kalman filter, among others (see Appendix A for mathematical details). It is important to note that in recent years, several Kalman-based pipeline leak diagnosis methodologies have been proposed, which demonstrates their applicability and support from the scientific community. This paper is organized as follows. Section 2 presents a brief review of basic concepts for understanding the functioning of state observers. Section 3 introduces a tentative classification of the Kalman filter-based methods proposed to this day. Section 4 presents the history of the evolution of the Kalman filter-based methods in the area of leak detection. Concretely, this section highlights the contributions that have been a milestone in leak diagnosis. Finally, in Section 5, some recommendations for future research are given. Appendix A presents the mathematical structure of different types of Kalman filters that have been employed in leak detection tasks.

State Estimators
In many engineering applications, some variables cannot be directly measured, either because there are no sensors for them or because the cost is prohibitive. An alternative to addressing this problem is to obtain a dynamical estimation of the required variables by using state estimators.
A general definition of a state estimator is as follows: an algorithmic tool that estimates the variables of a process using (1) a mathematical model represented in state space, (2) the available measurements of the process (inputs and outputs), and (3) an error correction (adaptation) term to ensure the convergence of the algorithm.
To derive a general structure of a state estimator, let us consider the general structure of the continuous model of a system in a state-space representation given as follows: where x(t) ∈ R n is the state vector;ẋ(t) ∈ R n is the state derivative vector; u(t) ∈ R m is the external (exogenous) input vector or control signal; y(t) ∈ R p represents the output vector, i.e., the measured states (variables) acquired by sensors; f ∈ R n represents the vector field; and h ∈ R p is the continuous output function.
Since a state estimator is the model of the system plus a correction (adaptation term), this can be expressed as follows: wherex(t) andŷ(t) are the online estimations of x(t) and y(t), respectively; and K(x(t)) is the gain of the observer. Thus, the design of the state observer consists of choosing an appropriate gain K(x(t)) so that the estimation error tends to 0 when t → ∞ with the desired properties of time convergence and robustness. If the observation error e(t) is defined as follows, the dynamics of the error observation can be derived from (1) and (2), and expressed aṡ An observer connected to a pipeline has the structure of the block diagram shown in Figure 2. The inputs in a pipeline can be the flow rate provided by a pump, the level of a tank, the flow rate, or the pressure that results from the opening or closing of a valve. These inputs, or at least a subset of them, must be registered to be injected into the state estimators. The state, which is the smallest possible subset of system variables that can represent the complete state of a system at any time, can be either the pressure or flow rate at any coordinate along the pipeline or the position of a leak. The measured outputs are the measurements provided by in situ sensors (flow meters, pressure transducers, or thermocouples). The design and choice of a state estimator depends on many factors: the application in which the estimates will be used, the nature of the system, the nature of the variables to be estimated, the type of information that will be available for performing the estimation, the nature of such information (e.g., discrete or continuous), and the characteristics of the required estimates. In this spirit, an abbreviated procedure for designing a state estimator for leak diagnosis purposes is proposed in Figure 3.
Steps for designing a state estimator • Step 1: Identify the available information (observations, data, measurements, and records) for performing the estimation.
• Step 2: Formulate a model assuming convenient assumptions and constraints.
• Step 3: Set the model in a state-space representation.
• Step 4: Set the equations of the state observer.
• Step 5: Compute the gain of the state observer.

A Proposed Classification for the Kalman Filter-Based Approaches
The CPM systems that have used the Kalman filter as the principal algorithmic tool can be categorized into three approaches, according to the architecture of the leak diagnosis algorithm. (1) The approaches based on the estimations of a bank of filters; (2) the approaches based on the estimation of variables (e.g., pressures and flow rates) at different locations along the pipeline; and (3) the approaches based on the direct estimation of the leak parameters, which are added to the pipeline flow model as if they were states. This classification is inspired by three influential contributions that were presented in three different years, as shown in the timeline infographic in Figure 4. In 1980, Tørris Digernes proposed the first contribution based on a bank of Kalman filters [10]. In 1988, Benkherouf and Allidina introduced the first contribution based on the estimation of the hydraulic variables at different points of the pipeline [11], and in 2007, Besançon et al. proposed the first approach based on the direct estimation of the leak parameters [12]. The following describes each of these approaches.  Approaches based on a bank of filters. These approaches were the first proposed for detecting and localizing leaks in pipelines by using Kalman filters. The architecture of these approaches is illustrated in Figure 5, which is a set of Kalman filters that act (or perform an estimate) in parallel. Each filter is different from the other because each filter is constructed from a pipeline model with a leak in a prescribed position that is different from the leak positions involved in the other models that are used to build the other filters. For example, a leak diagnosis algorithm for a 100-meter pipe can be constructed with ten filters. The first filter can be designed to detect a leak in the first 10 m of the pipe, the second in the next 10 m, and so on. On the one hand, the filters forming the bank can be independent of each other, or they can be dependent, that is, interconnected. The interconnection between filters can be cascading or peer-to-peer. On the other hand, the information that each filter receives to make the estimate can be the same (pressures and/or flow rates at the ends) or different (pressures and/or flow rates measured at certain positions of the pipe).
A bank of estimators has been successfully used by commercial leak detection systems, such as PipePatrol software supplied by KROHNE Group [13]. The main disadvantage of these approaches, however, is that in order to have better accuracy regarding the leak position, a bank of many filters must be designed, which implies that a high computational cost is required for finding the numerical solution of each filter. For this reason, another class of approaches was proposed for reducing the computational burden: the approaches based on the estimations of internal variables.
Approaches based on the estimation of internal pressures and flow rates. These approaches use a unique Kalman filter. The states of the model used for designing the Kalman filter are the internal pressures and flow rates at different (positions) coordinates distributed along the pipeline. Once the states are estimated by the Kalman filter, the leak is localized by using the estimations for solving auxiliary algebraic equations (e.g., head loss balances). The accuracy of the leak location is achieved by increasing the number of estimated internal variables. This fact implies that more states must be estimated, and therefore, a greater computational burden is imparted. The architecture of these approaches is illustrated in Figure 6.
Approaches based on the direct estimation of the leak parameters. These kinds of approaches were proposed to avoid using several filters and to discretize the space in many nodes. In this class of approaches, the leak localization is performed by a unique Kalman filter, which is designed from a mathematical model that involves the leak parameters as state variables in order to be estimated. Usually, these approaches involve the Kalman filter described in Appendix A.3. The architecture of these approaches is illustrated in Figure 7.
,. . , .., n n P P P Q Q Q Figure 6. Architecture of approaches based on the estimation of internal pressures and flow rates. The following section details different Kalman-based approaches that were presented over time, and highlights the main characteristics, advantages, and disadvantages of the main contributions.

Brief History
To the best of our knowledge, the first work presenting an approach based on the Kalman filter to detect and localize faults in pipelines was written by Tørris Digernes [10]. This work, entitled Real-time failure detection and identification applied to supervision of oil transport in pipelines, presents a methodology based on multiple parallel filters that are independent of each other: a bank of filters. Each filter was designed from a dynamical model representing a prescribed fault situation. In particular, two fault types were treated by Digernes: single leaks and sensor faults. By applying this methodology, the fault recognition is performed by identifying the filter having the highest probability of representing the plant in the fault situation. The probability is calculated by using the multiple-model hypothesis probability test, which when performed, requires the error estimation between the available measurements from the pipeline and their estimates provided by the filter. To show the potentiality of his methodology, Digernes presented some simulations' results. In such simulations, the features of the oil pipeline between Ekofisk in the North Sea and the terminal in Teesside, UK, were used. The filters were designed from finite models expressed by space-discrete equations that represent the mass and the momentum balance of the fluid in a pipeline. To compute the estimation errors, pressures and flow rates at the inlet and outlet of the pipeline were used, as were pressures at two points along the pipeline. The principal disadvantage of this approach is that in case of a leak, a large number of filters is needed to obtain an acceptable resolution of the leak position. This pioneering work has inspired another important contribution. For example, in [14,15], the same approach was tested in a simulation environment for a long-distance pipeline of water, and only the following aspects were different: the use of a backward time-central space discretization scheme for lumping the continuity and momentum equations together, the use of a modified version of the Kalman filter, and the introduction of a feedforward law for computing the leak magnitude.
Years later, Benkherouf and Allidina (B&A) presented the work entitled Leak detection and location in gas pipelines, which proposes a Kalman filter for detecting and finding the position of a single leak [11]. The filter is based on a lumped version of a distributed one-dimensional isothermal model (two partial differential equations describing the continuity and momentum conservation) that describes the gas flow through a single pipeline with fictitious leaks distributed along with it. To obtain the distributed model, both viscous and turbulent effects of the flow were neglected, and it was assumed that both the temperature changes within the gas and the heat exchanges with the surroundings of the pipeline are small. The lumped model was formulated using the method of characteristics (MOC). By using this approach, the position of the leak is determined through the following algebraic equations that relate the fictitious leaks estimated with the Kalman filter to the real one: where z L is the real position leak, Q L i and z L i are the flows and positions of the fictitious leaks, i is the fictitious leak index, and N is the total number of fictitious leaks. The methodology of B&A surpasses the Digernes approach in the sense that only one filter has to be designed. For this reason, it has also been the inspiration for a significant number of works. For example, in [16], the authors used the same approach with a slight modification in the covariance formula to locate a leak in a pipeline of water. Moreover, they tested the approach in simulations and in the laboratory. In [17], the same approach was tested together with a technique called the extended boundary approach. In [18], a comparison between B&A's approach and the algorithm proposed in [19] (which does not have the Kalman filter as a core of the diagnosis system) was presented. According to the authors' conclusions, the cycle time of B&A's method is longer, but gains on accuracy.
In 2001, Verde presented the work entitled Multi-leak detection and isolation in fluid pipelines [20], which proposes a bank of Kalman filters for localizing leaks in a hydraulic pipeline. Each Kalman filter is designed to diagnose a section of the pipeline, which, in fact, is divided into N sections. Concretely, each KF is designed to estimate the states (pressures and flow rates) at prescribed points (locations) of the pipeline by considering that a leak is occurring in a pipeline section delimited by two prescribed points. If the pipeline is divided into N sections, as small as desired, N Kalman filters must be designed: each one by considering a leak in a different section. If there are many sections, the computational cost is higher. The estimation error of each KF is used to localize the leak. If a leak develops in a given section, the error associated with the section remains around 0, and the rest do not.
Because the methodology was proposed for a hydraulic pipeline, the Kalman filters were designed from a space-discrete version of the water hammer (WH) equations given as follows: which were proposed by Chaudhry in his prestigious work Applied Hydraulic Transients [21]. For WH equations, (z, t) ∈ [0, L] × [0, ∞) gathers the space (m) and time (s) coordinates, respectively; L is the length of the pipe; H(z, t) is the pressure head (m); Q(z, t) is the flow rate (m 3 /s); b is the wave speed in the fluid (m/s); g is the gravitational acceleration (m/s 2 ); A r is the cross-sectional area of the pipe (m 2 ); φ is the inside diameter of the pipe (m); and Js is the quasi-steady friction term, which may be expressed by the Darcy-Weisbach relation as where f is the Darcy-Weisbach friction factor. The method used to numerically solve the WH equation was the first-order finite difference method (FDM). By assuming pressures at the ends of the pipeline as the boundary conditions and after applying the FDM, the fluid model can be represented as n sets of coupled nonlinear dynamic equations given in state-space representation.
In 2003, Verde et al. showed that the isolation (localization) of two simultaneous leaks is not feasible only with steady-state data of the fluid in a pipeline [22]. For this reason, Besançon et al. presented an approach based on a single extended Kalman filter and suitable inputs to obtain unsteady data from the pipeline [12]. The filter was constructed from a model deduced from a. The order of this model is the minimal to represent two leaks, so we can say that this model is a minimal-order model for two leaks. In order to estimate two leaks, four states with a constant dynamic that represent both positions and both leak coefficients were joined to the minimal-order model.
Since the pressures at the ends of the pipeline were considered as inputs, in order to excite the pipeline, they were manipulated to be triangular. The estimation of the positions, and the estimation of the coefficients, were both achieved. The estimation results have shown, however, that the estimation is sensitive to the initial conditions. Moreover, experimental results were not presented to validate the approach. Torres et al. presented similar methodologies in [23,24], but a lumped model obtained via the orthogonal collocation method was used. There are two main reasons why this algorithm could not work with experimental data. The first reason: the reduced order of the finite model that resulted from the discretization of the spatial domain into three sections; this would not be a problem if auxiliary inputs were not needed to ensure the convergence of the estimation. Usually, however, these inputs are periodical with fixed or variable frequency. If the frequency of the required input is too high, the finite model is no longer representative of a real pipeline. A solution to this concern may be the increase of the order such that the model becomes representative to high frequencies. The second reason may be that the values of the leak positions may take values between 0 and L. A solution to this concern could be a reduction of this interval.
In 2010, Dos Santos et al. introduced a new approach for detecting gas leaks in high-pressure distribution networks [25]. Each pipeline of the network was modeled as a linear parameter-varying (LPV) system driven by the source node mass flow together with the pressure as the scheduling parameter. The mass flow at the offtake was considered as the system output. The leak position was added as a state of the LPV system, from which a Kalman filter was designed. The effectiveness of the CPM system was illustrated with real and simulated data.
In 2011, Navarro et al. proposed an extended Kalman filter for locating leaks in a plastic pipeline, which was constructed from a discretized model both in time and in space. For the design of the filter, the space discretization was nonuniform and was a function of the unknown leak location; furthermore, the time domain was discretized by using Heun's method. The method was validated in real-time in a laboratory [26].
In 2015, Verde and Rojas presented an iterative scheme for locating sequential leaks, namely, one leak after another. The core of the method is a continuous extended Kalman filter with a prescribed degree of stability, which is constructed from the model of the flow in a pipeline with an equivalent leak; check Appendix A.4. The equivalent leak is a fictitious leak with a position in which a single leak would have to produce specific values of pressure and flow rate along the pipeline at a steady-state, but the values are actually caused by two or more leaks [22]. The equivalent leak must satisfy two criteria: (1) water loss equivalence and (2) energy equivalence [27]. In the case of a pipeline with a single branch and a leak, the equivalent leak is caused by the branch and leak outflows; in addition, it always has a position between both extractions.
In order to address the same concern, in 2016, Delgado et al. presented an approach for localizing sequential leaks by using an extended Kalman filter (Appendix A.2) for estimating parameters (Appendix A.3): the parameters of each sequential leak such as position and size. The filter was designed from a discrete time-space model derived from the WH equations and was modified at each new leak occurrence via an adaptation strategy to augment the size of the model's state vector. The augmentation of the state is done to include the parameters of the actual sequential leak. The approach was validated by using experimental data [28].
In 2016, Verde et al. presented a Kalman-based approach for detecting and localizing single leaks in a pipeline with a branch junction [29]. The approach requires the following information for producing a diagnosis: the flow rate together with the pressure head at the pipeline ends, the position (the spatial coordinate) of the branch junction, and the flow rate through the branch. The approach involves a selector algorithm (a simple algebraic equation that can be deduced from a head loss balance), and two localization algorithms, which are two Kalman filters designed from two different mathematical models, each one representing the flow dynamics of the pipeline before and after the branch, respectively. The goal of the selector algorithm is to indicate whether the leak is to the left (upstream) or to the right (downstream) of the branch. Depending on the indication of the selector, one of the two Kalman filters can be used to estimate the position of the leak. The approach was numerically tested with synthetic and experimental data from a hydraulic test apparatus.
In 2017, Delgado et al. described the successful localization of a leak in a pipeline of the water distribution network in Guadalajara, Mexico [30]. The localization was achieved by using a discrete-time extended Kalman filter (Appendix A.3), which was constructed by a lumped version of the WH equations. Additionally, Navarro et al. presented a two-stage leak isolation methodology based on a fitting loss coefficient calibration. In the first stage, an extended Kalman filter is used to fix the equivalent straight length (ESL) of the pipeline. Once the leak is detected, an algebraic observer allows for estimating the leak position from the ESL fixed by the extended Kalman filter. Since leak isolation is performed in equivalent length coordinates, a transformation to the original coordinates is necessary [31].
In 2018, Santos-Ruiz et al. introduced a methodology for leak detection and localization based on data fusion from two approaches: a steady-state estimation and an extended Kalman filter [32]. The proposed method considers only pressure-head and flows rate measurements at the pipeline end. The approach was tested in real-time by using a USB device for the data acquisition. The novelty of this approach is that the steady-state solution for a nonlinear pipeline model of the pipeline is merged with the dynamic state estimation obtained from the EKF observer, by using Bayesian data fusion in order to refine the leak diagnosis. In the same year, Delgado et al. proposed a method based on two steps for solving the leak diagnosis problem in pipeline networks [33]. In a first step, a faulty system and a nominal model are used to generate residuals with an analysis that allows identifying the region where the leak occurs. As a second step and by using the information generated in the first step, the leak position and magnitude are estimated through extended Kalman filters. The proposed two-step methodology minimizes the problem of observer design, since it avoids the design of an observer for each section of the network. On the other hand, Liu et al. suggested handling multi-leak detection problems in oil pipelines by using unscented Kalman filters [34]. Leaks are detected one at a time with an observer; therefore, the number of observers must be increased when a new leak occurs.
In Table 1, all these approaches are classified according to the decade of their presentation. Additionally, this table contains some works that propose methodologies based on the Kalman filter for addressing different problems associated with the pipeline operation monitoring, which does not concern leak or fault detection.  [12], [14][15][16], [18], [20], [23,24], [35][36][37][38][39] 2010-Up to the present [25,26], [28][29][30][31][32][33][34], [40-55], In Table 2, a taxonomy of CPM systems according mainly to the type of Kalman filter employed in the solution formulation of the leak detection and location is presented. In addition, other parameters are highlighted, such as the fluid involved in the study, the type of leak, either single or multiple leaks, and also the type of validation (in a simulation, in a laboratory, or in the field).  According to API 1155, there are four metrics for evaluating leak detection systems: reliability, sensitivity, accuracy, and robustness. Despite the large amount of academic work based on the Kalman filter, however, only some of them provide a report on such metrics within a field context. In Table 3, these works are listed. Table 3. Contributions with declared performance metrics.

Results Application
A combined Kalman filter-discrete wavelet transform method for leakage detection of crude oil pipelines.

Main pipelines
Gas pipelines LPV modelling and identfication for leakage detection.
Sensitivity: A leak about 10% of the nominal flow rate was detected 24 minutes after its occurrence

Main pipelines
Identificability of multi-leaks in a pipeline Accuracy: 12% of error Main pipelines Minimal order nonlinear observer for leak detection.
Accuracy: 1.36% of error with respect to the pipeline length in a noisy data scenario.

Main pipelines
Online burst detection in a water distribution system using the Kalman filter and hydraulic modelling.

Pipeline networks
Real-time leak isolation based on a fault model approach algorithm in a water pipeline prototype Accuracy: 3.6% of error with respect to the ESL.

Main pipelines
Research on natural gas pipeline leak detection algorithm and simulation. Accuracy: 0.11% of locating error.

Main pipelines
Note that the accuracy of any methodology is strongly determined by the instruments in the physical installation but also by the availability of a proper system model.

Future Research
Hitherto, three main approaches for estimating leak locations using the Kalman filter have been reported in the literature. Such methods are based on banks of filters, on pressure and flow rate estimations, and on the direct estimation of leak parameters. Table 2 lists our current state of knowledge regarding leak location studies. It is clear from this table that some studies still do not involve field testing. In addition, one can realize that most of the research has focused on detecting and locating leaks in water pipelines. Very few studies have addressed the problem of leaks in pipelines that transport other types of fluids, such as oil, gas, or heavy oils.
In particular, proposing a leak detection system for heavy oils is important in the petroleum industry because of the enormous increase in oil demand and the progressive exhaustion of low-viscosity oil reservoirs. Moreover, the leak localization in multiphase flow pipelines (typical in oil production) is a pending issue that has not even been deeply addressed with other algorithmic tools. Therefore, there is a clear need for laboratory investigation of leak localization in multiphase flow pipelines.
The detection of single leaks remains an important concern that requires algorithms with better performance metrics; therefore, it is necessary to continue investigating to improve the Kalman filters used for it. Furthermore, most of the proposed Kalman-based approaches for single leaks require measurements from four sensors to perform the leak localization in a pipeline. Therefore, an improvement would be the reduction of this number of sensors. One way to do it is by using the same technique as the inverse transient analysis (ITA) approaches, as proposed in [56], in order to deal with the alteration of the flow through a maneuver such as the opening/closing of a valve; another would be by manipulating the frequency controller of a pump. The goal of this alteration is to obtain more information on the flow status.
At this point, it is necessary to say that ITA approaches and the Kalman-based approaches (proposed until today) have in common that an inverse problem is solved (the identification of the leak parameters) by minimizing the error between the numerical solution of a model and the available recordings. However, the Kalman-based approaches (proposed until today) do not need the generation of transients as ITA approaches need, but they require more measurements to compensate for the lack of information that a transient can give.
Regarding multiple faults, it is necessary that part of the research efforts focus on the development of new tools for the localization of multiple leaks (or faults), since this is an important issue that has not yet been approached meritoriously. It is worth mentioning that the presence of multiple leaks is a very common problem in countries plagued by vandalism and theft of hydrocarbons. Usually, in these places the pipelines are infested by simultaneously activated illegal taps.
Finally, the location of leaks using Kalman filters is a challenging area that will require rigorous experimental validation and addressing some concerns, such as the extension of existing algorithms for complex pipeline configurations, including branched pipelines or pipeline networks.

Conflicts of Interest:
The authors declare no conflict of interest. The funders had no role in the design of the study; in the collection, analyses, or interpretation of data; in the writing of the manuscript, or in the decision to publish the results. The Kalman filter can be conceptualized as two distinct phases: "prediction" and "correction". The prediction phase uses the state estimate from the previous time step to produce an estimate of the state one time step ahead into the future at k + 1. This predicted state estimate, denoted bŷ x (k + 1|k), is known as the a priori state estimate. Thus, in the correction phase, the a priori state estimate is corrected based on the available measurements of the output y (k + 1). This improved estimate, denoted byx (k + 1|k + 1), is termed the a posteriori state estimate. The covariance matrix of the states, which provides a measure of the estimated accuracy of the state estimate, is Prediction Phase The estimates of the states (since the noise w (k) is assumed to be zero mean) are updated aŝ based on the measurements up to time step k. By taking into account the a priori state estimation in (A4), the covariance matrix can be written (after some algebra) as where the fact has been exploited thatx (k) and x (k) are uncorrelated with w (k).

Correction Phase
Once a new measurement y (k + 1) is available, it can be used to correct the estimates as follows: x (k + 1|k + 1) =x (k + 1|k) + + K (k + 1) (y (k + 1) − Cx (k + 1|k)) , where clearly the estimates are based on the measurements up to time step k + 1 and the optimal feedback gain K (k + 1) is calculated as K (k + 1) = P (k + 1|k) C T CP (k + 1|k) C T + Q −1

. (A7)
According to Equation (A6), K (k + 1) determines which one has more weight in updating the estimated states: the observation error y (k + 1) − Cx (k + 1|k) or the prediction of the states based on the internal modelx (k + 1|k). Finally, by taking into account the a posteriori state estimation in (A6), the covariance matrix can be updated as P (k + 1|k + 1) = (I − K (k + 1) C) P (k + 1|k) . (A8) The corresponding block diagram of the Kalman filter is shown in Figure A1.

Appendix A.2. Extended Kalman Filter
In the theory of nonlinear state estimation, the de facto standard is the extended Kalman filter (EKF), which is the nonlinear version of the Kalman. In many situations, one is confronted with nonlinear system models of the form where w (k) and v (k) denote uncorrelated white noise processes with zero mean and covariances Q (k) and R (k), respectively. In the EKF, the functions f k and g k are used to compute the predicted state (from the previous estimate) and the predicted measurement (from the predicted state), respectively. To update the covariance matrix P(k), however, a first-order Taylor series expansion of (A9) is used. The idea is essentially to linearize the nonlinear system around the current estimate. Thus, at each time step, the Jacobian is evaluated by considering the current predicted states. These matrices are used in the Kalman filter equations.
The extended Kalman filter is then given as follows.