System to monitor and locate water leaks using LabVIEW software

Water pipelines are prone to critical failures due to aging, corrosion, and external factors. These failures can lead to water leaks in the pipeline, which in turn can cause property damage and environmental contamination if not detected in time. This work presents a system for monitoring and locating water leaks using LabVIEW software. The system describes the mathematical model used to locate the leak, which is implemented in a virtual instrument, obtaining the flow and pressure behavior of the system in the presence and absence of leaks in a transient state through a virtual platform coupled to a data acquisition system. With the implementation of the mathematical model in the virtual instrument, it was possible to locate the leak in real time to ensure its immediate correction, without false alarms.


Introduction
Water pipeline leaks are a problem due to the scarcity of water resources. Monitoring and locating leaks has become a priority for the water industry due to the costs associated with water loss [1]. In addition to costs related to water production, transport, and waste, they also cause secondary financial losses due to supply disruptions, erosion of pipe beds, and damage to buildings and roads. The amount of water lost through leakage usually represents 20%-30% of total production. This percentage can even reach 50% for older distribution networks [2].
There are different methods for locating water leaks. They can be broadly classified as external or hardware-based monitoring methods and internal or software-based monitoring methods. Mass and energy balance are some of the methods used to locate leaks [3][4][5][6][7][8]. The disadvantage of this method is that it is highly sensitive to various disturbances and pipeline dynamics. Hydrostatic testing requires removing the pipeline from operation and injecting pressurized air into the pipeline. By monitoring the pressure in the pipeline for a certain time, the presence of a leak is identified if a drop in pressure occurs. This concludes the existence of a leak and to locate it, it is necessary to segment, seal, and repeat the test until its position is located. These tests, in which devices are placed directly in the pipes, are known as pre-locators. The information they obtain about the noise level is stored and analyzed to find the leak location by measuring the acoustic resonance. The pressure flow deviation method is used extensively in model-based leak monitoring techniques in combination with a massbalance approach to cover full-time leak detection for a wide range of operating conditions. Pressure flow diversion methods are essentially a subset of the direct backward transient analysis. The first applied field of the direct backward transient analysis method was the wide use in groundwater transport problems based on a steady state pipe network model [9,10]. A common problem with the above methods is that the extraction of leakage information is insufficient. The extracted features cannot accurately represent all useful information from the raw pressure signal. Therefore, there is a need to find a more efficient feature extraction method, which can improve the performance of existing leak detection methods [11].
The aim of this work is to study the effect of the water hammer equations on the distribution of pressures and flows through the pipes. From the continuity equation and Darcy's law, an equation to know the location of the leak was proposed. The mathematical model is validated in a steady state and with transient effects generated by the opening of valves that simulate leaks, which are distributed along the pipeline. As the objective of the model is the development of algorithms for leak detection, results are presented that validate the dynamic characterization when the system is affected by one and multiple leaks. A virtual instrument was designed and implemented that contains the above equations and with the help of flow and pressure sensors automatically detect the leakage.

Mathematical model
Equations that describe the transient response of a fluid through a pipeline are known in the literature as water hammer equations, among them are the continuity equation and Darcy's law.

Darcy's law
Darcy's equation is used to calculate the energy loss due to friction in straight sections and long round pipes, for both laminar and turbulent flow. The difference between the two flows is in the evaluation of the dimensionless friction factor f. Equation (1) is described as follows.
where L is the tube length, D is the diameter of the pipe, v is the average flow velocity, f is the friction factor and g is the gravity.

Continuity equation
This is derived from the principle of conservation of mass, and states that the volumetric flow through any section in a duct (pipe or channel) is kept constant. This is met if between the two sections there are no leaks. Equation (2) is described as follows.
where ṁ& is the mass-flow inlet, ṁ' is the mass flow at outlet, and () (+ is the mass change rate within the boundaries. To obtain the length where the leakage occurs, the continuity equation and Darcy's law are used. From the continuity equation, which states that the energy entering the system must be equal to the energy going out, Equation (3) is obtained.
The equation is reduced a little to P 0 = P $ = 0 as these two pressures are at the atmospheric pressure as shown in Equation (4).
Knowing that m , = m $ + m 0 , the equation is divided by m , as shown in Equation (5).
As ṁ= p * Q, where p is density and Q is volumetric flow rate, the equations are transformed to volumetric flow rate since the densities are cancelled out as can be observed in Equation (6).
Now entering Darcy's law for the values of h as described in Equation (7). .
Taking the speeds to volumetric flow rate, Equation (8) is obtained.
As P $ = 0, then the first term remains as -" . which will be called Hm , (pressure head in meters of water column). Simplifying, Equation (9) is obtained.
L B = L , + L $ , where L B is the total length of the pipe. By replacing L B , Equation (11) is obtained. ;.
Equation (12) is obtained by taking the common factor of L , , which is the desired length.
L , = C,$,, E) " " + F3< " ! "5 The mathematical model was applied in the LabVIEW software to find the is leak location. To check the mathematical model, an experimental pipe test bench was made, as described in reference [12,13], and a virtual instrument was developed for automated leak acquisition and detection as described in section 3.

Experimental configuration
For the development of the research, a user interface was created, which provides the operator with flow and pressure data, as well as graphs and controls for the correct visualization and automation of the leak detection system [14]. Figure 1 shows the experimental configuration used. The equipment consists of (a) a main tank, (b) a drainage tank, (c) an inlet pressure sensor, (d) an outlet pressure sensor, (e) an inlet flow sensor, (f) an outlet flow sensor, (g), (h),(i),(j) leakage discharge valves, (k) a water pump, and (l) a 6 m long pipe. In this equipment, water was pumped from the reservoir to the measuring section and returned by gravity through the drainage pipe. To regulate and measure the flow, an inlet and outlet flow sensor was used. Similarly, to measure the pressure in the system, an inlet and outlet pressure sensor described by [14] was used.

Development of the virtual instrument
The virtual instrument consists of different windows, a simulation window which is the main panel where the user can observe a process simulation as shown in Figure 1. In addition, another data acquisition window where the user can view in real-time both the inlet and outlet pressure and flow, a window to locate the leak is shown in Figure 2, and the behavior when leaks occur is shown in Figure 3.

Principles of leak detection and location
Under normal operating conditions, all parameters in a pipeline must satisfy a transient flow model that is made up of a series of basic equations such as conservation of mass, conservation of momentum, conservation of energy and the equation of state for the fluid in the pipeline.
However, when a water leak occurs, the measured values of the operating parameters will deviate from the predicted values resulting from the transient model, which forms a basis for detecting the leak. The principle and the proposed implementation can be described as: • Real-time data acquisition: pressure and flow signals are collected in real time by measuring instruments installed at both ends of the pipe.  Table 1 presents the data of the tests carried out for the calibration of the system (without leaks) and with leaks in each of the sections.

Conclusions
The results showed consistency and good Accuracy with respect to the proposed algorithm for detecting leaks in the experimental pipeline. Regarding the results obtained with the automated detection system using the virtual instrument, we can say that it allows real-time leak detection, ensuring its immediate correction. As a result, the problems that arise behind a leak can be reduced. The experimental data in Table 1 shows that there is an increase in the static pressure profile at the location of the leak, despite boundary conditions and this effect is noticeable in pipes. The pressure increase due to a leak and its influence on the overall pressure distribution is a function of the size of the leak and the pipe inlet flow. A mathematical model was proposed based on the continuity equation and Darcy's law for leakage location. The accuracy and applicability of the model have been verified by comparing the predicted value with the measured results. It was observed that a pipe affected by a leakage hole internally generates a gradient jump in the fluid pressure.