scieee AI-readable full text Open interactive document viewer

Real-time leak diagnosis in water distribution systems based on a bank of observers and a genetic algorithm

Navarro Díaz, Adrián,Delgado-Aguiñaga, J.A.,Puig Cayuela, Vicenç,Santos Ruiz, Ildeberto de los

Abstract

The main contribution of this paper is to present a novel solution for the leak diagnosis problem in branched pipeline systems considering the availability of pressure head and flow rate sensors on the upstream (unobstructed) side and the downstream (constricted) side. This approach is based on a bank of Kalman filters as state observers designed on the basis of the classical water hammer equations and a related genetic algorithm (GA) which includes a fitness function based on an integral error that helps obtaining a good estimation despite the presence of noise. For solving the leak diagnosis problem, three stages are considered: (a) the leak detection is performed through a mass balance; (b) the region where the leak is occurring is identified by implementing a reduced bank of Kalman filters which localize the leak by sweeping all regions of the branching pipeline through a GA that reduces the computational effort; (c) the leak position is computed through an algebraic equation derived from the water hammer equations in steady-state. To assess this methodology, experimental results are presented by using a test bed built at the Tuxtla Gutiérrez Institute of Technology, Tecnológico Nacional de México (TecNM). The obtained results are then compared with those obtained using a classic extended Kalman filter which is widely used in solving leak diagnosis problems and it is highlighted that the GA approach outperforms the EKF in two cases whereas the EKF is better in one case.

Full text

Citation: Navarro-Díaz, A.; Delgado-Aguiñaga, J.A.; Santos-Ruiz, I.; Puig, V. Real-Time Leak Diagnosis in Water Distribution Systems Based on a Bank of Observers and a Genetic Algorithm. Water 2022,14, 3289. https://doi.org/10.3390/w14203289 Academic Editor: Carmen Teodosiu Received: 1 September 2022 Accepted: 9 October 2022 Published: 18 October 2022 Publisher’s Note: MDPI stays neutral with regard to jurisdictional claims in published maps and institutional affiliations. Copyright: © 2022 by the authors. Licensee MDPI, Basel, Switzerland. This article is an open access article distributed under the terms and conditions of the Creative Commons Attribution (CC BY) license (https:// creativecommons.org/licenses/by/ 4.0/). water Article Real-Time Leak Diagnosis in Water Distribution Systems Based on a Bank of Observers and a Genetic Algorithm Adrián Navarro-Díaz 1, Jorge Alejandro Delgado-Aguiñaga 2,* , Ildeberto Santos-Ruiz 3and Vicenç Puig 4 1Tecnológico de Monterrey, Escuela de Ingeniería y Ciencias, Av. General Ramón Corona 2514, Zapopan C.P. 45138, Mexico 2Centro de Investigación, Innovación y Desarrollo Tecnológico CIIDETEC-UVM, Universidad del Valle de México, Periférico Sur Manuel Gómez Morín 8077, Tlaquepaque C.P. 45601, Mexico 3 Tecnológico Nacional de México/Instituto Tecnológico de Tuxtla Gutiérrez, TURIX-Dynamics Diagnosis and Control Group, Carretera Panamericana S/N, Tuxtla Gutiérrez C.P. 29050, Mexico 4Institut de Robòtica i Informàtica Industrial, CSIC-UPC, C/Llorens i Artigas 4-6, 08028 Barcelona, Spain *Correspondence: jor[email protected] Abstract: The main contribution of this paper is to present a novel solution for the leak diagnosis problem in branched pipeline systems considering the availability of pressure head and flow rate sensors on the upstream (unobstructed) side and the downstream (constricted) side. This approach is based on a bank of Kalman filters as state observers designed on the basis of the classical water hammer equations and a related genetic algorithm (GA) which includes a fitness function based on an integral error that helps obtaining a good estimation despite the presence of noise. For solving the leak diagnosis problem, three stages are considered: (a) the leak detection is performed through a mass balance; (b) the region where the leak is occurring is identified by implementing a reduced bank of Kalman filters which localize the leak by sweeping all regions of the branching pipeline through a GA that reduces the computational effort; (c) the leak position is computed through an algebraic equation derived from the water hammer equations in steady-state. To assess this methodology, experimental results are presented by using a test bed built at the Tuxtla Gutiérrez Institute of Technology, Tecnológico Nacional de México (TecNM). The obtained results are then compared with those obtained using a classic extended Kalman filter which is widely used in solving leak diagnosis problems and it is highlighted that the GA approach outperforms the EKF in two cases whereas the EKF is better in one case. Keywords: leak diagnosis; branched pipeline systems; Kalman filter; genetic algorithm; experimental results 1. Introduction Nowadays, a safe fluid transportation process is a challenging issue since natural and/or abnormal events as aging pipes but also illegal intrusion could cause leaks, which in turn, produce economic losses, disasters and environmental pollution. In the last decades, legislators have reinforced laws to protect the environment against pollution by demanding to guarantee a safe fluid transportation process. The scientific community has paid attention to this problem and several pipeline monitoring techniques have been developed from different perspectives to reduce the impact of undesirable events, such as leaks, no matter what fluid is transported. In particular, taking care of water is of the special interest since it ensures the safety of water and is directly related to public health issues due to its worldwide inherent importance. Such techniques can be divided in two main approaches: external methods and model-based methods. The first ones use external equipment such as acoustic systems, electronic listening sticks, infra-red thermography, etc., to determine the leak location (theses methods are often expensive, require experienced user and most of the time it is require to use them all along the pipeline and sometimes even to empty it). Water 2022,14, 3289. https://doi.org/10.3390/w14203289 https://www.mdpi.com/journal/water Water 2022,14, 3289 2 of 20 As an alternative, there are computational algorithms that, in general, uses a mathematical model of the pipe together with the inlet and outlet measurements in order to isolate the leak. This work is a novel model-based proposal for a leak detection an isolation problem in a branched pipeline system. Recently in [ 1 ], it has been shown that unfortunately a great amount of drinking water is lost through leaks in the distribution systems. According to this study, the worse cases correspond to the water distribution networks (WDN) in the Mexican cities of Chihuahua, San Luis Potosí and Tuxtla Gutiérrez with a water loss more than 40% and even up to 65% in the case of Tuxtla Gutiérrez. On the one hand, the problem of leak diagnosis in WDNs has been addressed as a large-scale and complex problem. Most of these strategies consider two essential steps: (a) sensor placement and (b) leak localization. In the first step, based on the number of available head sensors, an optimization-based strategy is applied to select the best location for those sensors aiming to identify all possible leak scenarios. In the second step, the leak localization strategy is then applied to identify the leak location. This is the core of most leak diagnosis strategies for WDN [2–6]. Moreover, in the water distribution process, the water is initially taken from natural sources as rivers or lakes, and then is transported to treatment plants to be purified. After that, the distribution to the final consumers begins. In this last process, the distribution system is built with secondary elements which may adopt the shape of branching configurations. In this work, the localization of leaks in WDNs with this topological configuration is addressed since it represents a realistic challenge. Previous works have already considered the leak problem for this type of systems as described in [ 7 – 9 ]. In [ 7 ], authors proposed a two-step-based methodology to identify leak parameters in pipeline networks. As a first step, the region where the leak occurs is identified on the basis of a residual analysis of the flow rate which is generated between the measurements from the leaky WDN and their estimation using a model without leaks. In a second step, the leak parameters are identified via the use of the so-called extended Kalman filters by relying on an observability property fulfilled for both configurations: closed-loop and branching. Similarly in [ 8 ], authors proposed an algorithm for detecting and localizing a single leak in pipelines with multiple branches based on a similarity model. This approach is formulated in three stages. The first two stages involve the fulfillment of generic conditions deduced from head loss and flow rate balances for detecting and locating the specific section where the leak is present, whereas the third stage is focused on leak localization. More recently in [ 9 ], a solution for the multi-leak diagnosis problem in a branched pipeline system is proposed. This scheme basically involves two essential steps: leak region identification based on flow-rate residuals with a related Nearest Neighbors (k-NN) classifier, and then leak parameter identification (magnitude and position) via the use of the so-called Extended Kalman Filters (EKFs) for each leak based on a simple generic model and fed with pressure head estimations provided by an initial EKF. Other approaches also exist on the basis of transient wave analysis and artificial intelligence [10,11], respectively. The main contribution of this paper is a novel implementation of a genetic algorithm together with a bank of Kalman filters to identify the parameters of a leak. At the same time, the computational effort is minimized since it deals with a complex water distribution system. For the sake of illustration, some experimental results are presented using a pilot plant built at Tuxtla Gutiérrez Institute of Technology (TecNM-Tuxtla). The paper is organized as follows: Section 2presents some mathematical preliminaries. The leak detection and isolation (LDI) scheme for branching pipeline systems is presented in Section 3. The case study is fully described in Section 4, including several experiments in a pilot plant, and finally in Section 5, some conclusions are given and future perspectives are discussed. Water 2022,14, 3289 3 of 20 2. Preliminaries 2.1. Pipeline Dynamical Model The transient flow in a closed conduit is described by a couple of quasi-linear hyperbolic partial differential equations known as the water hammer equations. The derivation of these equations is carried out by considering the following assumptions: the fluid is slightly compressible, the duct wall is slightly deformable, the convective velocity changes are negligible, and the fluid density is assumed to be constant [12,13]: Momentum Equation: ∂Q(t,z) ∂t+gAφ∂H(t,z) ∂z+µQ(t,z)|Q(t,z)|=0 (1) Continuity Equation: b2∂Q(t,z) ∂z+gAφ∂H(t,z) ∂t=0 (2) where Q(t , z) stands for the flow-rate [m 3 /s]; H(t , z) is the pressure head [m]; z is the length coordinate [m]; t is the time coordinate [s]; g is the gravity acceleration [m/s 2 ]; Aφ is the cross-section area [m 2 ]; b is the pressure wave speed in the fluid [m/s]; µ=τ/ 2 φAφ [m −3 ], where φ is the inner diameter [m] and τ is the friction factor computed using Swamee-Jain equation as described in [ 14 , 15 ] which depends among other things on the flow regime and is suitable for smooth pipelines (plastic pipelines). Moreover, this friction factor does not consider non-stationary losses because it implies a more complex model structure with non-significant improving in leak diagnosis as discussed in [16]. 2.2. Solution of Governing Equations through the Method of Characteristics (MOC) A closed-form solution for those quasi-linear hyperbolic partial differential Equations (1) and (2) is not available in general, but only for some specific boundary conditions. However, several numerical-approximation-based methods have been developed as the well-known method of characteristics (MOC) which is one of the most frequently used due to its suitability for a numerical implementation in a computer (see [ 12 , 13 , 17 ], for more details). By applying this method, an approximate solution can be carried out via a discrete integration at any point (k , i) discretizing the pipe according to the scheme shown in Figure 1. i−th Pipe i +1−th Pipe Boundary Conditions ∆zi∆zi+1 Hk−1 i+1 Qk−1 i+1 Hk−1 i Qk−1 i Hk−1 i+1 Qk−1 i+1 Figure 1. Pipeline discretization using the MOC. Thus, after applying the MOC method through the characteristic line (Figure 2), a couple of equations, namely characteristic equations, are obtained as follows: Along the positive characteristic line A P Qk i=Cp−CaHk i(3) Along the negative characteristic line BP Qk i=Cn−CaHk i(4) Water 2022,14, 3289 4 of 20 Hk−1 i−1 Qk−1 i−1 Hk−1 i+1 Qk−1 i+1 Hk iQk i Characteristic Lines z t A R C S B T t0 t0+ ∆t ∆zi∆zi+1 Figure 2. MOC-based discretization scheme. Needless to say, Equations (3) and (4) can be solved together. In their a posteriori representation: A posteriori head equation: Hk i=Cp−Cn 2Ca(5) A posteriori flow equation: Qk i=Cp+Cn 2(6) where: Cp=Qk−1 i−1+gAφ bHk−1 i−1−µi−1∆tQk−1 i−1Qk−1 i−1 Cn=Qk−1 i+1−gAφ bHk−1 i+1−µi+1∆tQk−1 i+1Qk−1 i+1(7) and: Ca=gAφ b(8) 2.2.1. Convergence and Stability Conditions Following a procedure developed in [ 18 ], it can be shown that the stability of Equations (3) and (4) is satisfied when ∆z=b∆t (Courant condition). It implies that the characteristic line through T in Figure 2must intersect the line A C between A and C and between C and B . For a single pipe, the computational time interval and spatial grid spacing can be selected in such a way that this condition is satisfied. However, this situation is hard to reach if the system has more than one pipe (i.e., branched pipeline system). Since it is advantageous to compute with specified time and space intervals, the following linear interpolation may be used (see Figure 2): Qk−1 Ri−1=Qk−1 i−b∆t ∆ziQk−1 i−Qk−1 i−1 Qk−1 Si+1=Qk−1 i−b∆t ∆zi+1Qk−1 i−Qk−1 i+1(9) Hk−1 Ri−1=Hk−1 i−b∆t ∆ziHk−1 i−Hk−1 i−1 Hk−1 Si+1=Hk−1 i−b∆t ∆zi+1Hk−1 i−Hk−1 i+1 The values of Hk i and Qk i may now be determined from Equations (3) and (4) by replacing Hk−1 i−1 and Qk−1 i−1 ( Hk−1 i+1 and Qk−1 i+1 ) by Hk−1 Ri−1 and Qk−1 Ri−1 ( Hk−1 Si+1 and Qk−1 Si+1 ). This is due to the characteristics through T now pass through R and S instead of through A Water 2022,14, 3289 5 of 20 and B , respectively. More information can be found in [ 12 ]. Thus, the Courant condition can be fixed using the smallest branch, ∆z , in a branched pipe system ensuring, that every point R and S fall inside the characteristic lines. It should be noted that such an interpolation presented by Equation (9) causes attenuation and dispersion of steep waves speeds, so, spurious waves could be generated at each boundary resulting in a slight error in the model (more information can be found in [ 12 ]). However, such an modeling error is minimized in the branch identification process due to the nature of the discrete time extended Kalman filter design, as described in Section 3.2.2 later on. 2.2.2. Special Boundary Conditions The solution of the governing Equations (1) and (2) by using the MOC method are fully defined by a related pair of initial and boundary conditions. Such conditions describe a special relationship that defines the head and the discharge at this point. Without loss of generality, these conditions can describe a complete branched pipeline system. The algorithm presented in Section 3is also applicable if more complex boundary conditions are needed (see [12]). 2.3. Discrete Time Extended Kalman Filter The EKF is an algorithm for estimating unmeasured states of nonlinear dynamical systems in discrete-time considering additive uncertainties: Xk=F(Xk−1,Uk) + Wk(10) Yk=CXk+Vk(11) where Wk and Vk are disturbance and measurement noise, respectively. The EKF is designed to minimize the covariance of the estimation error and is implemented in the following form [19,20]: b Xk=b Xk−+KkYk− Cb Xk−(12) where b Xk−=F(Xk−1 , Uk) is the a priori estimate, and b Xk is the a posteriori estimate obtained by adding a correction term including the Kalman gain Kk and the error between the measurements Ykand their estimation. 2.4. Genetic Algorithms Genetic algorithms (GAs) are a type of heuristic optimization approach useful for solving non-convex optimization problems [ 21 ]. The heuristic GA search method is inspired by the theory of natural evolution. GA uses a recursive methodology to find a value (or some values) which match, exactly or approximately to a solution (solutions) in optimization and search problems [ 21 ]. Six phases are considered in a generic algorithm as shown in Figure 3(more information can be found in [ 22 , 23 ]). The recursive process is repeated until a termination condition has been reached (namely termination in Figure 3). Common termination conditions include minimum criteria (a solution is found that satisfies minimum stopping criteria), allocated budget (computation time) reached, etc. In this paper, GA will be used to find leaks in WDNs with complex branched pipeline topology. The searching process for finding the leak location could be difficult (or even impossible in some cases because of observability issues) via model-based algorithms based on a single observer that have been designed to try to locate the leak in the exact branch. On the other hand, if a bank of observers is designed to localize the position of the leak, a large computational effort could be necessary due to the high number of branches in the system. Therefore, the authors propose to reduce the number of observers in the bank and to implement a genetic algorithm to optimize the LDI process (more details are provided in Section 3). Water 2022,14, 3289 6 of 20 Initial Population Fitness Function Selection Crossover Mutation Termination end Yes No Figure 3. Genetic algorithm scheme. 3. LDI Scheme in a Branched Pipeline WDN The LDI process is the task of determining if the WDN is working under a leak (i.e., leak detection) and, finding its location once it has been detected (i.e., leak isolation) [ 24 , 25 ]. However, for branched pipeline WDNs, the LDI problem could be a challenging task in case of complex and large scale case studies. 3.1. General Branched Pipeline LDI System Design Principles Without loss of generality and for the sake of simplicity, a general branched pipeline can be modeled with just three types of nodes: input, inner and output nodes. Input nodes represent the upstream inputs of the system, (Figure 4c) (input measurement). In the same way, inner nodes correspond to the branching junction of several pipes (Figure 4b). Finally, output nodes characterize the downstream outputs of the system (Figure 4a). Each node is related to a vector which is built by the flow-rate and the pressure head corresponding to such a node, as Figure 4shows. Notice that, in the inner node, three flow rates are considered: Qi+1 denotes the flow-rate between the nodes Ni and Ni+1 ; Q0 i+1 is the flow-rate between the nodes Ni+1 and Ni+2 ; and, finally, Q00 i+1 denotes the flow-rate between the nodes Ni+1 and Ni+3 . These variables are related with the equation at the boundary condition corresponding to a “branching junction” in the MOC. For the output nodes, the downstream valve boundary condition could be the most suitable for its characterization (see [ 12 ]). Here, the relative valve opening is fixed since orifice opening remains constant over the transient response. Nout Hout Qout  (a) Ni Ni+1 Ni+2 Ni+3 Hi Qi    Hi+1 Qi+1 Q0 i+1 Q00 i+1    Hi+2 Qi+2  Hi+3 Qi+3  (b) Nin Hin Qin  (c) Figure 4. Atomic representation for an output, inner an input node. ( a ) Output Node; ( b ) Inner Node; (c) Input Node. Water 2022,14, 3289 7 of 20 To complete the whole LDI system design, the characterization of a leak in a particular branch should be carried out. This can be done following a similar idea as for the inner nodes presented above (Figure 4), but under certain considerations (see Figure 5): Note that the leak flow influence is additive (because of the mass conservation law). That is, the flow rate before the leak Q+ l must be equal to the sum of the flow rate after the leak, Q− l plus the flow through the leak hole, that is Q+ l=Q− l+Ql (Figure 5). Thus, the boundary condition equation for a leak node in Figure 5following the branching junction derivation yields: Hl=Cpl−Cnl−Ql 2Ca Q+ l=Cpl−CaHl Q− l=Cnl−CaHl (13) where Cpl and Cnl are defined through the characteristic line. Noticed that subscripts pl and nl denote the point before and after the leak, respectively. Moreover, in Equation (7) µi−1=µi+1=µl and Ql is computed as in (16) , see [ 12 ]. It is worth noting that in Equation (9)∆zi=zf while ∆zi+1=zi−zf ( zi is the distance between the i -th and (i+1)-th node where the leak is located). Nl Ql HlQ+ l Q− lNi Ni+1 Figure 5. Leak characterization scheme. As outlined above, the present approach assumes only flow and pressure sensors at the input (upstream) and output (downstream) nodes. Thus, the flow-rate and the pressure head at the input nodes will be considered as the system entries, whereas the output node measurements will be the system outputs. Thus, a branched pipeline system can be characterized as individual units (nodes). Figure 6shows a general scheme architecture built by n inputs nodes, m− 2 layers of inner nodes and l outputs nodes. Here, each ki denotes the number of nodes at the i-th inner layer. . . . . . . . . . . . . . . . . . . . . . N(1,1) N(2,1) N(n,1) N(1,2) N(2,2) N(k1,2) N(1,m) N(2,m) N(l,m) Figure 6. General branched pipeline system architecture. Now, each flow-rate and pressure head can be computed using Equations (5) , (6) , (9) and (13) , together with its respective boundary conditions. Proceeding in this way, the pipeline system architecture shown in Figure 6can be modelled using a difference equation system as follows: Water 2022,14, 3289 8 of 20 Xk=F(Xk−1,Uk)(14) Yk=CXk(15) where: X=hH1,Q1,Q0 1,Q00 1, . . . , Hp,Qp,Q0 p,Q00 p,Hl,Q+ l,Q− l,Hout1,Qout1, . . . , Houto,QoutoiT U=hHin1,Qin1, . . . , Hinq,QinqiT C=h02o×(4p+3)|I2oi where the subscript q , p and o denote the number of inputs, inner and output nodes, respectively. 3.2. Leak Detection and Isolation Process In this work, the authors propose three phases for the LDI process: leak detection, branch identification and leak isolation. Leak detection aims at detecting when the leak appears in the system; branch identification consists in establishing the nodes among which the leak is located; and, lastly, leak isolation consists in determining the distance between the inner node of the fixed branch in a previous phase and leak position. More details of these processes are explained in the following. 3.2.1. Leak Detection Considering the mass conservation law, the flow-rate through a leak hole, Ql , can be calculated using the following relationship [26]: Ql= q ∑Qin − q ∑Qout (16) Thus, the leak can be detected using the simple mass balance (16) altogether with a threshold δ establishing the leak condition as follows: |Ql|>δ . This threshold should be defined experimentally according to the noise in the measurements (as e.g., δ must be at least larger than a number of times the variance of the difference between ∑Qin −∑Qout to avoid false alarms). Moreover, the calculation of Ql will be used in the isolation process as discussed below. 3.2.2. Branch Identification If a leak occurs, an alarm is triggered when |Ql|>δ . Other kind of alarms can be found in [ 27 ]. At this point, the GA-based branch identification algorithm following the principles presented in Section 2.4 is started. To do that, the size of phenotype (population) must be defined by the designer considering the computational effort and according to the number of branches. Such a population is a subset of the natural number set N limited up to the number of branches in the pipeline as follows: P⊆Q={1, 2, . . . , no}(17) where Q stands for the search space, no is the number of branches. It should be noted that the population is taken randomly from Q. The branch identification process is done via an implementation of n0 o=kPk (the cardinality of the set P ) EKFs by using (12) for a system description given by (14) which allows the estimation error to be minimized. Such observer only differ in the position of the leak variables, Hl , Q+ l and Q− l , in Equation (14) , preserving the order of the branch in question given by a number in P (i.e., for a number i∈P , the leak node is induced at position li/2 of the corresponding branch). Water 2022,14, 3289 9 of 20 Fitness function . The bank of EKFs is used to generate a residual vector defined as r(t) = [r1(t),r2(t),· · · ,ro(t)]T . Each residual ri(t) is the difference between the observer output flows and the measured output flows normalized with respect to the real (measured) flows: ri(t) = Qi(t)−b Qi(t) Qi(t)(18) where Qi and b Qi stand for the flow-rate, measured and estimated in the i -th output node, respectively. This normalization is used because of the possible differences between output flows allowing the residuals to be comparable in [0, 1]scale. GA-based algorithm aims at finding the leaking-branch (each of them characterized by an observer) based on finding leak location that minimizes the L2 -norm residual (i.e., the lowest energy observer) as in [28]: min sZt0+Tw t0 r(t)Tr(t)dt(19) where Twis a time window. Once the winning population is found, a new set of phenotypes is randomly generated to replace the ones that have not survived and thus, to complete the whole population for the new iteration (in other words, a new set of branch number, that has not already been tried, is selected randomly). If no new population is generated, the termination conditions are achieved. 3.2.3. Leak Isolation The last step of the LDI process is to estimate the distance between the upstream node of the winner branch and the leak point bzf , see Figure 7. As it can be seen, the inputoutput pipe sections that include the leak node are shown with dashed line (input q to output o ). Those input-output that do not pass through to the leak node are denoted by dashed lines (input and output number 1). The process to isolate the leak is carry out taken any input-output pipeline that contains the leak node (for example input j to output k , solid line). Then, let us consider that it is possible to compute the pressure drop between two consecutive nodes using Equation (1) in steady state, i.e., ∂Q(t,z) ∂t= 0 and ∂H(t,z) ∂z=Hn+−Hn− zn, it yields: Hn+−Hn−=znµn gAφ Q2 n(20) where Hn+ and Hn− denote the measured pressures at the previous and posterior nodes, respectively; Qn is the flow-rate, µn is computed as in Equation (1) and zn is the distance through the analyzed section. Now, following the scheme depicted in Figure 7, it is possible to take any input-output branch (input j to output k , for instance) and using (20) it is possible to compute the pressure drop in all inner nodes. By hypothesis, the measurements of the inner nodes are not available, but, it is possible to sum recursively the result given by Equation (20) through the whole pipe-section under study (note that Hn appears with negative sign in the first section but with positive sign in the next section, such that if (20) is summed recursively, the inner pressure measurements disappear). After some algebraic manipulations it results in: bzf=Hinj−Houtk−∑n i=1µiziQ2 i µl((Q+ l)2−(Q− l)2)(21) where Hinj and Houtk are the pressure head at upstream and downstream, respectively, in the considered branch (see Figure 7); µi and µl are the constant µ (as in Equation (1) ) but being µl computed with the friction factor in the branch where the leak is induced; Qi the flow-rate in the i -th pipe in the network; and zi the distance of the pipe between Water 2022,14, 3289 16 of 20 leak leak (a) Pressure head and flow-rate at upstream node (system inputs). (b) Output residuals. r5 r4 r1 r2 r3 (c) Flow-rates at downstrem nodes. (system outputs). ˆ Q4 Q4 ˆ Q5 Q5 ˆ Q6 Q6 (d) Distance between the upstream leak node and the leak position (Leak Isolation). zfˆzf L Figure 14. Experiment 3: leak induced in valve 3: ( a ) Pressure head and flow rate at upstream, (b) Output residuals, (c) Flow rate at downstream nodes and, (d) Leak position. 4.4. Some Final Remarks (1) The algorithm can hardly identify the parameters of a leak with a rate greater than 10 % of the nominal flow since this event can be considered as a catastrophic failure instead of a simple fault, this is because the assumptions to obtain a modeling of the system could not be fulfilled correctly. Moreover the smallest leak that can be detected depends directly on the accuracy of the flow rate sensors (noise variance). (2) To obtain moving average values of the input and output measurements, they are filtered with the equation [31]: ςF(k) = 1 2N+1(ς(K+N) + ς(k+N−1) + ... +ς(k−N)) (25) where ςF(k) is the smoothed value for the signal ς(•) at time k , N is the number of neighboring data taken on either side of ςF(k), and 2N+1 is the span dimension. (3) The initial conditions of the observer, X0 are fixed as follows: H40 , Q40 , H50 , Q50 , H60and Q60are equal to the mean values of the measured outputs in a steady-state leak-free condition. (4) The inner pressure initial conditions (i.e., H20 , H30 ) are calculated using the wellknow Darcy-Weisbach friction equation [15,29]: Hi0=Hi−10−µiziQ2 i0 Water 2022,14, 3289 17 of 20 where i={2, 3}. (5) On the other hand, the inner flow-rate initial conditions. Q20 , Q0 20 , Q00 20 , Q30 , Q0 30 , Q00 30 , are computed using the law of conservation of mass: Qi0=Q0 i0+Q00 i0(26) where, as before, i={ 2, 3 } . Moreover, due to the same law and in steady-state conditions, the next relationships must be satisfied: Q0 30=Q40 , Q00 30=Q50 , Q00 20= Q60and Q0 20=Q30(see Figure 10). (6) As is well known, the friction factor, τ in Equation (1) , radically changes with the flow velocity in smooth pipes (pipes with a relative roughness usually lower than 1 × 10 −3 ). That is why in the present work, the friction factor is calculated by using the Swamee-Jain [15]: τ(Q) = 0.25 log10er 3.7 +5.74 Re0.9 2(27) It is worth noting that it is not necessary to update the friction factor once the leak appears, since its size by hypothesis is lower than 10% of the nominal flow rate in a steady-state (see point (1)). The friction factors are shown in Table 3. leak leak (a) Pressure head and flow-rate at upstream node (system inputs). (b) Output residuals. r5 r1 r2 r3 r4 (c) Flow-rates at downstrem nodes. (system outputs). ˆ Q4 Q4 ˆ Q5 Q5 ˆ Q6 Q6 (d) Distance between the upstream leak node and the leak position (Leak Isolation). zfˆzf L Figure 15. Experiment 4: leak induced in valve 4: ( a ) Pressure head and flow rate at upstream, (b) Output residuals, (c) Flow rate at downstream nodes and, (d) Leak position. Water 2022,14, 3289 18 of 20 Table 3. Friction factors for each branch. Branch Number Symbol Value 1τ12.40 ×10−2 2τ22.68 ×10−2 3τ33.67 ×10−2 4τ45.95 ×10−2 5τ53.76 ×10−2 leak leak (a) Pressure head and flow-rate at upstream node (system inputs). (b) Output residuals. r4 r3 r2 r1 r5 (c) Flow-rates at downstrem nodes. (system outputs). ˆ Q4 Q4 ˆ Q5 Q5 ˆ Q6 Q6 (d) Distance between the upstream leak node and the leak position (Leak Isolation). zfˆzf L Figure 16. Experiment 5: leak induced in valve 5: ( a ) Pressure head and flow rate at upstream, (b) Output residuals, (c) Flow rate at downstream nodes and, (d) Leak position. 5. Conclusions and Future Work The present work deals with the real-time leak detection and isolation problem in branched pipeline systems present in many real water distribution networks. The approach has been split into three main stages: leak detection, branch isolation and leak location. The scheme only assumes flow and pressure sensors at the beginning and the end of the system. Water 2022,14, 3289 19 of 20 The first point to underline is that in complex water distribution systems, the leak location problem could be difficult to solve due to the high number of nodes (branches) in the system. That is why the authors propose a genetic based algorithm together with a bank of observer which aims to isolate the leaking branch by reducing the computational effort. The leak location was carried out using the pressure drop between an input and an output node of the branch in question and the flow-rate through it. The approach estimated the leaking branch accurately and the leak position in a very acceptable way. The use of a integration error as a fitness function, altogether with the Kalman filter, helped obtain a good estimation despite the presence of noise. As a future work, three paths will be addressed: (i) the proposed approach will be refined to achieve better performance; (ii) the authors will explore the possibility of extending the approach to locate two leaks; (iii) the algorithm will be tested to locate leaks in a real water distribution network. Author Contributions: Conceptualization, A.N.-D. and J.A.D.-A.; methodology, A.N.-D. and J.A.D.-A. ; software, A.N.-D.; validation, A.N.-D., J.A.D.-A., I.S.-R. and V.P.; formal analysis, I.S.-R. and V.P.; investigation, A.N.-D. and J.A.D.-A.; resources, A.N.-D., J.A.D.-A. and I.S.-R.; data curation, I.S.-R.; writing—original draft preparation, A.N.-D. and J.A.D.-A.; writing—review and editing, I.S.-R. and V.P.; visualization, J.A.D.-A. and V.P.; supervision, A.N.-D.; funding acquisition, A.N.-D. and I.S.-R. All authors have read and agreed to the published version of the manuscript. Funding: The APC was funded by Tecnológico de Monterrey. The experimental work was supported in part by Tecnológico Nacional de México (TecNM) under grant 14515.22-P. Institutional Review Board Statement: Not applicable Informed Consent Statement: Not applicable Data Availability Statement: Not applicable. Conflicts of Interest: The authors declare no conflict of interest. References 1. OECD. Water Governance in Cities; OECD Studies on Water; OECD Publishing: Paris, France, 2016; p. 140. [CrossRef] 2. Santos-Ruiz, I.; López-Estrada, F.R.; Puig, V.; Valencia-Palomo, G.; Hernández, H.R. Pressure Sensor Placement for Leak Localization in Water Distribution Networks Using Information Theory. Sensors 2022,22, 443. [CrossRef] [PubMed] 3. Morales-González, I.O.; Santos-Ruiz, I.; López-Estrada, F.R.; Puig, V. Pressure Sensor Placement for Leak Localization Using Simulated Annealing with Hyperparameter Optimization. In Proceedings of the 2021 5th International Conference on Control and Fault-Tolerant Systems (SysTol), Saint-Raphaël, France, 29–30 September 2021; pp. 205–210. [CrossRef] 4. Perez, R.; Sanz, G.; Puig, V.; Quevedo, J.; Cuguero Escofet, M.A.; Nejjari, F.; Meseguer, J.; Cembrano, G.; Mirats Tur, J.M.; Sarrate, R. Leak Localization in Water Networks: A Model-Based Methodology Using Pressure Sensors Applied to a Real Network in Barcelona [Applications of Control]. IEEE Control Syst. Mag. 2014,34, 24–36. [CrossRef] 5. Levinas, D.; Perelman, G.; Ostfeld, A. Water Leak Localization Using High-Resolution Pressure Sensors. Water 2021 ,13, 591. [CrossRef] 6. Sun, C.; Parellada, B.; Puig, V.; Cembrano, G. Leak Localization in Water Distribution Networks Using Pressure and Data-Driven Classifier Approach. Water 2020,12, 54. [CrossRef] 7. Delgado-Aguiñaga, J.; Besançon, G. EKF-based leak diagnosis schemes for pipeline networks. IFAC-PapersOnLine 2018 , 51, 723–729. [CrossRef] 8. Torres, L.; Verde, C.; Molina, L. Leak diagnosis for pipelines with multiple branches based on model similarity. J. Process Control 2021,99, 41–53. [CrossRef] 9. Delgado-Aguiñaga, J.; Santos-Ruiz, I.; Besançon, G.; López-Estrada, F.; Puig, V. EKF-based observers for multi-leak diagnosis in branched pipeline systems. Mech. Syst. Signal Process. 2022,178, 109198. [CrossRef] 10. Pan, B.; Capponi, C.; Meniconi, S.; Brunone, B.; Duan, H.F. Efficient leak detection in single and branched polymeric pipeline systems by transient wave analysis. Mech. Syst. Signal Process. 2022,162, 108084. [CrossRef] 11. Liao, Z.; Yan, H.; Tang, Z.; Chu, X.; Tao, T. Deep learning identifies leak in water pipeline system using transient frequency response. Process Saf. Environ. Prot. 2021,155, 355–365. [CrossRef] 12. Chaudhry, M.H. Transient-flow equations. In Applied Hydraulic Transients; Springer: Berlin/Heidelberg, Germany, 2014; pp. 35–64. 13. Streeter, V.L.; Lai, C. Water-hammer analysis including fluid friction. Trans. Am. Soc. Civ. Eng. 1963,128, 1491–1524. [CrossRef] 14. Srbislava, G.; Ivana, A.; Petara, K.; Markob, J.; Nikolab, B.; Vojislavc, G. A review of explicit approximations of Colebrook’s equation. FME Trans. 2011,39, 67–71. Water 2022,14, 3289 20 of 20 15. Abdulameer, L.S.; Dzhumagulova, N.; Algretawee, H.; Zhuravleva, L.; Alshammari, M.H. Comparison between Hazen-Williams and Darcy-Weisbach Equations to Calculate Head Loss through Conveyancing Treated Wastewater in Kerbala City, Iraq. East.-Eur. J. Enterp. Technol. 2022,1, 115. [CrossRef] 16. Dulhoste, J.F.; Besançon, G.; Ortiz, F.L.T.; Begovich, O.; Navarro, A. About friction modeling for observer-based leak estimation in pipelines. In Proceedings of the 2011 50th IEEE Conference on Decision and Control and European Control Conference, Orlando, FL, USA, 12–15 December 2011; pp. 4413–4418. 17. Carlsson, J. Water Hammer Phenomenon Analysis Using the Method of Characteristics and Direct Measurements Using a “Stripped” Electromagnetic Flow Meter. Master’s Thesis, Royal Institute of Technology, Stockholm, Sweden, 2016. 18. O’Brien, G.G.; Hyman, M.A.; Kaplan, S. A Study of the Numerical Solution of Partial Differential Equations. J. Math. Phys. 1950 , 29, 223–251. [CrossRef] 19. Simon, D. Optimal State Estimation: Kalman, H Infinity, and Nonlinear Approaches; John Wiley & Sons: Hoboken, NJ, USA, 2006. 20. Fujii, K.; The ACDA-Sim-J Group. Extended Kalman Filter. Reference Manual. 2013; pp. 14–22. Available online: https: //www-jlc.kek.jp/2004sep/subg/offl/kaltest/doc/ReferenceManual.pdf (accessed on 3 May 2022). 21. Katoch, S.; Chauhan, S.S.; Kumar, V. A review on genetic algorithm: Past, present, and future. Multimed. Tools Appl. 2021 , 80, 8091–8126. [CrossRef] [PubMed] 22. Kumar, M.; Husain, M.; Upreti, N.; Gupta, D. Genetic Algorithm: Review and Application (1 December 2010). Available online: https://ssrn.com/abstract=3529843 (accessed on 16 April 2022). 23. Mathew, T.V. Genetic Algorithm. Report Submitted at IIT Bombay 2012. Indian Institute of Technology, Bombay, Mumbai. Available online: http://datajobstest.com/data-science-repo/Genetic-Algorithm-Guide-[Tom-Mathew].pdf (accessed on 16 April 2022). 24. Isermann, R. Fault-Diagnosis Systems: An Introduction from Fault Detection to Fault Tolerance; Springer: Berlin/Heidelberg, Germany, 2005. 25. Gertler, J.J. Fault Detection and Diagnosis in Engineering Systems; CRC Press: Boca Raton, FL, USA, 2017. 26. Boaz, L.; Kaijage, S.; Sinde, R. An overview of pipeline leak detection and location systems. In Proceedings of the 2nd Pan African International Conference on Science, Computing and Telecommunications (PACT 2014), Arusha, Tanzania, 14–18 July 2014; pp. 133–137. 27. Soldevila, A.; Boracchi, G.; Roveri, M.; Tornil-Sin, S.; Puig, V. Leak detection and localization in water distribution networks by combining expert knowledge and data-driven models. Neural Comput. Appl. 2022,34, 4759–4779. [CrossRef] 28. Navarro, A.; Delgado-Aguiñaga, J.A.; Sánchez-Torres, J.D.; Begovich, O.; Besançon, G. Evolutionary Observer Ensemble for Leak Diagnosis in Water Pipelines. Processes 2019,7, 913. [CrossRef] 29. Lindstrom, L.; Gracy, S.; Magnusson, S.; Sandberg, H. Leakage Localization in Water Distribution Networks: A Model-Based Approach. arXiv 2022, arXiv:2204.00050. 30. Santos-Ruiz, I.; Bermúdez, J.; López-Estrada, F.; Puig, V.; Torres, L.; Delgado-Aguiñaga, J. Online leak diagnosis in pipelines using an EKF-based and steady-state mixed approach. Control Eng. Pract. 2018,81, 55–64. [CrossRef] 31. Delgado-Aguiñaga, J.; Begovich, O. Water leak diagnosis in pressurized pipelines: A real case study. In Modeling and Monitoring of Pipelines and Networks; Verde, C., Torres, L., Eds.; Springer International Publishing: Berlin/Heidelberg, Germany, 2017; pp. 235–262.