Leakages in water supply networks can be minimized through pressure reduction or by repairing the resulting damage. The effective implementation of the latter approach necessitates the localization of leaks, for which various methods exist. This paper presents a specific software and hardware configuration for constructing a digital twin of pressurized piping systems that can be utilized for this purpose. The proposed method can identify both the flow and position of leaks and is based on solving an equivalent optimization problem, where the objective function depends on the difference between the measured pressure values at specific points and those predicted at the same points under the same boundary conditions by a computational model. Given the multimodality of the formulated problem, particle swarm optimization is implemented for this task. To enable real-time localization, the measured pressure values are transmitted to a microcontroller, which processes the data and sends it to a Python script. This script employs a while loop to continuously monitor the criteria for leak detection, and when these criteria are met, it initiates a procedure for leak localization. The theoretical aspect of the procedure, as well as its practical implementation, is presented below as an example.

  • Simple hardware and software solution for a digital twin of a pressurized piping system.

  • Real-time water leak detection by its position and flow.

  • Leakages detection by solving an equivalent optimisation problem.

  • Leakages localisation by particle swarm optimisation algorithm.

  • Laboratory validation of the leakage localization algorithm.

Leakage in water supply systems is a very prominent water management problem that impedes the rational management of water resources, which, in turn, has numerous negative impacts on various social and environmental aspects. More recently, it can easily be placed in the context of climate change (by considering the principle of rational water use and the paradigm of sustainable development). The efforts being made to address this problem are more than justified, especially when considering that, according to some estimates (Liemberger & Wyatt 2019), over 126 billion m3 of water are lost from water supply systems globally each year. Although there are different types of water leakage (such as the intentional release of water from the system to preserve water quality), the former primarily refers to leakage caused by damage to pipes or failure of pipe joints. Moreover, experience generally confirms that there is a strong positive correlation between the amount of water loss and the age of the system in question, which can be understood as a consequence of damage accumulated over time due to inadequate system maintenance. Since the replacement of the entire infrastructure is usually not a rational solution, the reduction of water losses is usually carried out by adequate water loss management (Skworcow et al. 2009; AbdelMeguid et al. 2010; Berardi et al. 2013). In this regard, it is important to note that pressure reduction in the system is most commonly used to minimize losses, as it decreases the pressure gradient across the flow area and, consequently, reduces leakage flow. However, it should be recognized that pressure reduction (AbdelMeguid & Ulanicki 2011; AbdelMeguid et al. 2011) can only be carried out to a certain extent, i.e. until the minimum pressure conditions prescribed by fire protection are compromised. In this way, it can be concluded that this approach does not address the underlying problem but temporarily alleviates its symptoms and thus is not in the spirit of sustainable development. A more adequate approach, to be applied continuously, relies on selective infrastructure repair that requires leakage localization. In this way, the maintenance challenge is reduced to two tasks: (i) leakage detection, which is relatively easier and involves determining the difference between the volume of water delivered and the volume that entered the system, and (ii) leakage localization, which proves to be a significantly more challenging endeavour.

In general, methods for leakage localization can be classified into two main groups: (i) physical methods, which involve direct system inspection (e.g. visual, acoustic, and infrared thermal inspections), and (ii) theoretical methods, which rely on analysing data collected from field measurements, typically water flow and pressure. Since the methods in the first group require an inspection of the entire infrastructure, or at least a larger part, i.e. a suspicious part, their application is often costly. Consequently, there is a greater focus on improving and developing methods from the second approach. These approaches based on data analysis can further be categorized into three basic groups: transient-based approach, data-based approach, and model-based approach (Chan et al. 2018).

Transient-based approaches are based on analysing the time derivative of flow characteristics (usually pressure fluctuations), which will propagate through the system as a sound wave affecting leakage flow (Ayati et al. 2019). Although this approach is very attractive for relatively large systems, the high speed of sound propagation in pipes (typically between 400 and 1,500 m/s, depending on the mechanical properties of the water and pipes) makes its application complex. It requires sophisticated measuring equipment that must be sensitive to very small pressure changes and capable of high-speed response and sampling frequency (Lee et al. 2006). This is crucial because these approaches rely on applying a Fourier transform, where the temporal change in pressure induced by controlled valve maneuvers is used to construct the system's frequency response. Specifically, the frequency response diagram of a system with water leakage will exhibit additional resonant pressure amplitude peaks that are lower than the resonant amplitude peaks in a system without leakage. Furthermore, the location and magnitude of leakage can be estimated based on this difference (Mpesha et al. 2002).

Data-based approaches are based on the recognition of specific patterns in large datasets collected under various flow conditions in a steady-state flow regime. Namely, the position of a water leak can be determined by identifying anomalies in the collected data, specifically by detecting deviations from the expected patterns characteristic of a functional system without leaks. For this purpose, various data mining techniques can be employed for pattern recognition. For instance, machine learning or deep learning methods can be utilized to pinpoint the location of water leaks using flow data in pipelines (Shravani et al. 2019). Considering that the selective measurement of flow in pipes can be challenging, pressure data in the system is often used for this purpose, and the pattern recognition in this case is performed using neural networks. Moreover, this approach has been proposed for detecting multiple water leak locations (Fang et al. 2019), which represents a particularly complex task (Kim 2018) for real systems; many will agree that it is still out of reach (or at least for practical application).

Model-based approaches, such as the procedure presented in this paper, are used to approximate the location of water leaks by comparing measured data with predictions from a hydraulic model at the same flow positions and under identical flow conditions (pressures are typically compared, though tracer concentration may also be used). The comparative analysis in this context can be performed in various ways. One method involves constructing the so-called pressure sensitivity matrix , with components that describe the change in pressure at location i in response to a change in flow at location j due to a unit water leakage (Pérez et al. 2011). This matrix thus describes how system pressure varies with changes in leak location, where columns j represent potential leak locations, and rows i correspond to pressure measurement points. The comparative analysis is performed by constructing a residual pressure vector , whose components are the differences between measured and predicted pressures at the same points. This vector is then compared to the columns of the pressure sensitivity matrix , and various criteria can be applied to assess the degree of match, thereby identifying the leak location (Casillas Ponce et al. 2014). Another interesting localization approach is based on the application of Bayesian classifiers (Soldevila et al. 2017). In this method, the leak localization process is relaxed, i.e. leakage localization is seen as a task that does not have a deterministic solution but a probabilistic one. A hydraulic model is employed to simulate potential leak scenarios, after which the Bayesian classifier is used to analyse the differences between measured and predicted pressure data to indicate the probable location of the leak. It is also important to note that mixed approaches can be utilized; for example, combining hydraulic models with a database (Soldevila et al. 2016).

This paper presents a model-based methodology for localizing water leakage. The approach is framed as an equivalent optimization problem in which the objective function should be minimized, as it represents a measure of the difference between measured and predicted pressures at the same points within the system and under the same flow conditions. While this procedure is already established (Wu & Sage 2006), it is important to note that this can lead to a multimodal problem, characterized by multiple equivalent solutions. Consequently, the formulated problem will be addressed here using a specific swarm-based meta-heuristic optimization algorithm (Simon 2013), which is suitable for these cases. Moreover, this procedure will aid in forming a digital twin of the physical system in consideration, which will be used to process the pressure and flow data obtained in real time to identify the position and magnitude of potential water leakages (theoretically more than one leak). A particularly interesting aspect of this procedure lies in the fact that it can be relatively easily applied to existing systems with a limited number of leakages, thereby allowing for the timely recognition of new damages and motivating the direction of system development towards the establishment of digital twins (Brahmbhatt et al. 2023).

It must be noted that there is a limited number of research studies dealing with the establishment of a digital twin of a water distribution network, including various applications such as improving management (Conejos Fuertes et al. 2020), evaluating the effects of changing water demands (Pesantez et al. 2022), or state estimation (Bonilla et al. 2022). In terms of leak localization, Brahmbhatt et al. (2023) rely only on conducting computational experiments for benchmark networks, while in work by Gómez-Coronel et al. (2023), the digital twin methodology for leak detection and localization was tested on a real hydraulic system, but with leaks occurring only in the main pipeline section, allowing only three leak locations. Therefore, to the best of the author's knowledge, there is no previous research with the methodology proposed in this paper; the novelty lies in establishing a digital twin based on laboratory experiments with optimization approach for leak localisation allowing smaller leaks that can occur anywhere in the considered model of the water distribution network.

A specific model-based approach is presented below, which requires the modelling of stationary flow through pipe j, with known water demands at junctions i, where the pipes converge. It should be noted that solving the problem framed in this manner essentially involves inverse modelling of the system. In the conventional case, system modelling is reduced to solving the matrix equation , where A is a known matrix that describes the system characteristics, x is an unknown vector of pressures at the junctions i, and b is a given vector of water demands at the same junctions.

In contrast, when localizing water leakage, the system matrix A is not known in advance because the location of the leakage, that is, the flow area from which the water is leaking, is also unknown. Moreover, it is important to note that the flow rate from this area varies with changes in system pressure (Clayton & Van Zyl 2007), meaning the unknown in question is the surface flow area of the leakage. However, for a given arrangement of water demands at the junctions i, localizing water leaks can be approached as an iterative process in which measured system pressures (which account for leakage losses) are compared to pressures obtained by a calibrated hydraulic model of the system. This model, while accounting for overall system demands , includes one or more additional consumptions that simulate leaks.

It becomes evident that if the location and amount of added consumption correspond to the actual location and quantity of the water leak, the difference between measured and predicted pressures will be minimal (which will mean that the location and amount of the leak have been determined). In this way, the water leakage localization problem is reduced to the minimization of the objective function given the form
(1)
which represents the L2 norm of the residual pressure vector
(2)
which has m components (typically far fewer than the total number of junctions) and is used to sequentially group the differences between the measured pressure and the pressure predicted by the hydraulic model at the same junction k, for an assumed leak position x and flow , which are grouped in the vector of design variables
(3)
That is the subject of optimisation. It should be noted that the location of the leak is determined by coordinate x, which continuously changes along the pipeline, generating a two-dimensional search space in which it is necessary to find the vector x that minimizes the objective function . Since the analytical form of the objective function (Equation (1)) is not known in advance, its minimum must be found numerically by progressively improving the initial assumption of the vector x (Equation (3)) through an iterative process.
To minimize the objective function (Equation (1)), the search for the argument x that will minimize its value and is defined in the plane will be conducted using the particle swarm optimization (PSO) procedure (Clerc 2010), also known as PSO. The method begins by setting a finite number of random solution assumptions , where , which are updated iteratively through the iterations e. In the context of PSO, assumed solutions are often interpreted as particles or agents that move incrementally through the search space from one iteration e to the next in search of an optimal solution. If the movement of particles in the search space is understood as the motion of material points, the position of particles at the beginning of the next iteration can be written as follows:
(4)
where represents its current position, its velocity, and is a fictitious time parameter, often interpreted as the time required for learning or for exchanging information between particles. As the method's name suggests, the PSO method mimics the dynamics of individuals within different colonies, such as the movement of ants while searching for food. The motivation for this comes from the efficiency of such processes, which can easily be explained through evolutionary arguments. In this case, the movement of each individual is described by two components: (i) a decision-making component based on the individual's previous search experiences and (ii) a decision-making component based on the collective experience (made possible by pheromones). This kind of behaviour is imitated using the velocity model (Simon 2013).
(5)
in which represents the velocity of particle p at the beginning of the next iteration , is the velocity of particle p at the current iteration e, w is the inertia factor that describes the tendency to maintain the current direction and velocity, is the model parameter that describes the influence of individual experience in determining the next search direction, is the model parameter that describes the influence of collective experience in determining the next search direction, are the coordinates of particle p in the current iteration e, are the best coordinates found by particle p up to the current iteration (local optimum), are the best coordinates found globally up to the current iteration (global optimum), and and are random vectors with components sampled from the uniform distribution during each particle velocity update, ranging from 0 to 1 (to avoid favouring any particular direction of particle movement). Also, it should be noted that the velocity model (Equation (5)) uses the Hadamard product of vectors , so that the components of some vector a, created by the product , are defined by the product .

The inertia factor w typically decreases as the number of iterations increases, under the assumption that the optimal solution is being approached over time. This parameter is used to balance global exploration (with relatively high values, e.g. 1.0, modelling space exploration, while relatively low values, e.g. 0.2, model space exploitation). The second term on the right side of Equation (5) can be interpreted as the particle's reliability in the search for the best solution, with its magnitude modelling the preference for the particle's best position obtained so far. On the other hand, the last term on the right side of Equation (5) can be interpreted as the significance of trust in other particles' searches, favouring the global best solution obtained so far. Accordingly, the first term on the right side of Equation (5) is usually interpreted as a diversification term, modelling the preference for searching unexplored areas, while the sum of the other two terms is typically interpreted as an intensification factor, modelling the preference for searching in known areas where the particle has moved (with individual and collective components).

In the presented approach, it is particularly important to note that additional constraints can be easily added to narrow down the search space or to focus on specific parts of it. For instance, this can be useful if the analysis excludes new pipes (due to their presumed low probability of leakage). Additionally, the approach allows for the straightforward inclusion of multiple potential water leak locations. However, with each additional leak location, the dimensionality of the search space increases, which in turn raises the computing power requirements.

The presented methodology was used to develop a digital twin designed for real-time localization of water leaks in a physical system, and some related hardware and software aspects are discussed as follows.

First of all, a digital twin of a physical system requires a calibrated computer model of that system (Koppel & Vassiljev 2009). In this case, this entails a hydraulic model of the water supply system, where the pipe roughness and local loss coefficients are calibrated so that, under the same water demand at junctions i, the measured and modelled pressures coincide (Vassiljev et al. 2015). It is particularly important to note that model calibration establishes the initial state of the system, assuming no existing water leaks. If leaks are present, however, their effects will be reflected in the calibrated values of the parameters and .

The model calibration procedure primarily requires measuring the roughness of the pipe wall. At the same time, since cannot be measured directly, its value must be determined indirectly by measuring the hydraulic parameters of the flow which are affected by it. For this purpose, the unknown roughness can be related to the Darcy frictional coefficient , pipe diameter D, and Reynolds number by the Swamee–Jain equation (Swamee & Jain 1976) given in the form
(6)
and valid for the range 10−6 < < 10−2 and 5,000 < < 108 in which the deviation from the Colebrook–White equation is less than 1%. On the other hand, and since the Darcy frictional coefficient cannot be measured directly, it can be related to the average velocity of the flow , acceleration of gravity g, the length L and diameter D of the pipe by the Darcy–Weisbach equation
(7)
in which on the left-hand side represents the head loss obtained along the pipe length L assuming that the pipe cross-section is constant. Accordingly, Equation (6) can be written as follows:
(8)
and can be solved for the unknown roughness (since all the other variables in Equation (8) can be obtained by measurements). Since the equation is nonlinear, a Newton method can be applied so that the initial guess solution can be progressively updated by the iterative algorithm
(9)
where the residual function follows from Equation (8) in the form
(10)
and its derivative is given in the form
(11)
The iterative process given by Equation (9) is repeated until the difference between two successive roughnesses and becomes smaller than some predefined convergence criteria.

Even in cases where there are small pre-existing leaks, i.e. relatively small leaks that are unknown in advance, it should be recognized that the application of the presented pipe roughness calibration procedure will also account for their influence in leak localization. These leaks will cause an increase in flow within the pipes, which in turn leads to higher flow velocity and greater pressure drop, ultimately resulting in a higher roughness value. In other words, the presented procedure can also be used in cases of pre-existing small leaks that have not been previously recorded to localize these leaks when they become larger – which is inevitable to occur with time.

Once the pipe roughness's are determined, the local loss coefficients can be calibrated by treating their value at junctions i as design variables and resolving the optimization problem by searching for a solution that will minimize the difference between the measured and predicted pressure in junctions i. It should be noted that the procedure can be conducted for more than one scenario of water demands at junctions i so that the objective function is defined as a sum of all L2 norms of vectors with components given by the difference of the measured and predicted pressure value at junctions i. Same as before, the PSO algorithm can be used for this purpose.

Some remarks on hardware features

It should be recognized that model-based approaches require (i) known water demands at all points where water is delivered to consumers and (ii) pressure values at specific pre selected points. In water supply networks, water demands at junctions i are generally available; however, this information is typically provided as cumulative monthly usage data for billing rather than as instantaneous, real-time data. This limitation imposes a restriction, as water demands at junctions are essential for predicting the pressure distribution using the system's hydraulic model, which is then compared with measured pressures at the same locations. Given that real-time water demand data is typically unavailable, analyses are often conducted using average values of water demand and pressure, though this may reduce the accuracy of leak localization. Therefore, in the following discussion, it is assumed that real-time water demand data is available, as the development of water supply networks is progressing towards such capabilities, enhancing feasibility for future applications.

Although it is not necessary to measure system pressures to preserve the functionality of the water supply system, these measurements are required for system maintenance, which can help in locating potential water leaks. When pressure gauges are installed for this purpose, their number and positions should be carefully selected to maximize their effectiveness in detecting leaks. This ensures that each gauge's reading accurately represents the pressure in its surrounding area and that these areas complement one another. This topic has received considerable attention (Blesa et al. 2015), and more recently, pressures in areas without sensors have been reconstructed using various interpolation techniques based on surrounding known pressures (Soldevila et al. 2018).

It should be noted that implementing the necessary hardware prerequisites for constructing a digital twin of the water supply system is not straightforward for several reasons, one of which is the requirement for a complex telemetry infrastructure. While these challenges complicate the development of such systems, they do not prevent it. The benefits of these systems have been recognized on several occasions (Pesantez et al. 2022), and their use should be encouraged for more rational and responsible management of water supply systems.

Some remarks on software features

Once the water demand at all junctions i and pressure values at some junctions i have been collected and transmitted in real-time to some central computational unit, they can be processed using the previously described calculation procedure to localize a possible water leak. Among the many different programming languages that can be used for the computer implementation of the related calculation procedure, defined by Equations (1)–(5), Python (Van Rossum & Drake 2009) stands out as a particularly attractive alternative. Namely, in that case, the wntr package can be accessed (Klise et al. 2020), which was originally designed to simulate and analyse the resilience of water supply networks. Moreover, the commands of the wntr package can be used to access the hydraulic model previously developed in the EPANET programme (Rossman 2000), which is commonly used for analyzes of practical importance, i.e. for real water supply systems. In this way, Python provides an attractive programming environment in which the previously illustrated calculation algorithm can be implemented using a while loop that tests various amounts and positions of water leaks until the objective function, as defined by Equation (1), is minimized. Some detailed implementation aspects of this procedure are illustrated below, focusing on an example of a digital twin of such a system.

The proposed procedure was tested under laboratory conditions using a physical model of the pressurized pipeline system, as shown in Figure 1. To replicate the geometry of a closed district metered area zone, which is used to monitor water inflow and outflow (essential for leakage monitoring), the pipes in the physical model were arranged in the form of a regular octahedron with internal angles of 135 degrees (Figure 1(a)). The sides of the octahedron are 1 m long and made of Polypropylene Random Copolyme (PPR) pipes with an internal diameter of 13.2 mm, commonly used in domestic installations. However, since the roughness of these pipes is relatively low and the pipes themselves are relatively short, a thin rope with consistent roughness was threaded through the pipes to increase the pressure drop due to friction. Using the previously described calibration procedure, the cumulative roughness of the pipes was found to be 0.11 mm.
Figure 1

(a) A plan of the pressurized pipeline system is used to illustrate the application of a digital twin in water leak localization, with indications of the position and dimensions of all characteristic elements, and (b) a photograph of the constructed pressurized pipeline system showing all characteristic elements and measuring devices, such as pressure gauges and flow meters, as well as the position of the inlet flow from the elevated red bucket.

Figure 1

(a) A plan of the pressurized pipeline system is used to illustrate the application of a digital twin in water leak localization, with indications of the position and dimensions of all characteristic elements, and (b) a photograph of the constructed pressurized pipeline system showing all characteristic elements and measuring devices, such as pressure gauges and flow meters, as well as the position of the inlet flow from the elevated red bucket.

Close modal

At the midpoint of each side of the formed octahedron, pressure gauges with a measurement range from 0 to 0.35 bar, an accuracy of 1% of full scale, and an output voltage range from 0 to 5 V were installed (Figure 1(b)). These pressure gauges were connected to a microcontroller equipped with a 10-bit resolution analog-to-digital converter, allowing pressure head changes of only a few millimetres to be measured. It should be noted that the pipes were carefully levelled in advance, ensuring all pressure sensors were aligned in the same plane perpendicular to the local gravity vector. To maintain a constant and known pressure at the system's inflow, located at the midpoint of one pipe (Figure 1(a)), the inflow point was connected by a rubber tube to the bottom of an open tank positioned at a specific height and continuously refilled with water (red bucket in Figure 1(b)). Since the tank is open on the upper side, any excess water overflows, so the pressure at the system's inlet is determined by the height difference between the inlet and pipe elevation, along with previously measured pressure head losses along this flow path. By adjusting the tank's position, different pressure conditions in the system can be tested.

To measure the flow at the exit of the system, which represents the water demands at junction i, the corners of the two opposite sides of the formed octahedron are equipped with flow meters and output regulation valves to control the outflow (Figure 1). For this purpose, flow meters with a measuring range from 1 to 30 l/min, an accuracy of 2% of full scale, and an output voltage range from 0 to 5 V were used. Additionally, one such flow metre was placed at the entrance to the system (Figure 1) to measure the difference between the water inflow and outflow, which represents the flow related to leaking. This difference was used to verify the predicted leakage amount determined by the previous calculation procedure.

To simulate water leakage in the system, circular openings with a diameter of 5.0 mm (with an area of 20 mm2) were created on the pipes and covered with rubber closures. The openings were positioned on the outside of the formed octahedron to allow water to flow freely into the pool where the entire installation is located (Figure 1(b)). Starting from the inlet flow position in the system (Figure 1(a)), the openings were made at a constant distance of 12.5 cm, resulting in a total of 64 openings, which were numbered in a counterclockwise direction. These openings were used to simulate water leaks in different positions by simply removing some of the rubber closures. The previously illustrated procedure was employed to locate the position of the leaks and to identify their flow values. Moreover, to examine the influence of the size of the opening through which the water leaks, modular shutters were prepared that can cover only a segment of the formed opening. In this way, leakage was made possible through openings with surface flow areas of 2, 4, 6, and 12 mm2, as well as in the case without a cover (20 mm2), which was interesting for considering the influence of leakage flow on the ability to localize the leak.

Localization of water leaks is carried out in real-time so that the collected data of water demands at junctions (collected in a vector variable q_measured) and pressures at the midpoint of pipes (collected in vector variable p_measured) are continuously delivered via the microcontroller to the central computing unit (PC), where a while loop is continuously executed, within which the difference between the measured pressures and those predicted by the hydraulic model (for the same water demands and collected in vector variable p_predicted) is computed and stored in a variable p_residual.

The hydraulic model of the subject pressurized piping system was created using the EPANET programme, incorporating junctions at the same locations as the openings intended for simulating water leakage. Accordingly, the model includes a total of 64 junctions (excluding the water tank) and 65 pipes, each measuring 12.5 cm in length (Figure 2). This arrangement of the model enables hydraulic analyses of the pressurized piping system using the wntr package for various positions of the assumed water leakage, which correspond to the locations in the created model and which is necessary for finding the minimum of the objective function from Equation (1). It should also be noted that the matching positions of junctions and real leakage do not represent a limiting factor for the detection of water leaks in real systems, as the number of junctions in the model, stored in a variable n_junctions, is arbitrary and can therefore be increased (thereby improving the accuracy of localization).
Figure 2

Hydraulic model of the considered pressurized piping system, displaying the arrangement and numbering of junctions used to simulate water leakage.

Figure 2

Hydraulic model of the considered pressurized piping system, displaying the arrangement and numbering of junctions used to simulate water leakage.

Close modal

For embedding the previously illustrated computational instructions into a Python script, it is important to note that the indexing of vector elements in Python starts from 0, while the numbering of junctions taken from the hydraulic model generated in EPANET (saved in the file model.inp) starts at 1. This means that the position of some vector components should be increased by one, while others should be decreased by one.

If the sequence numbers of the junctions where pressure measurements were taken are stored in the measurement_junctions vector, which contains a total of n_measurements components, the following Python script can be used with some commands from the wntr package to determine whether there is a leak in the system or if the difference p_residual between the measured pressure and the predicted by the hydraulic model exceeds a predetermined tolerance. If so, the algorithm for localizing water leakage is executed, which is based on the subsequent process of minimizing the objective function given by Equation (1) using the PSO algorithm.

# Loading the hydraulic model from EPANET

wn = wntr.network.WaterNetworkModel(’model.inp’)

# Loading data for pressures and water demands

while (p_residual > tolerance):

 import measured_pressures as p_measured

 import water_demand as q_measured

# Assigning the loaded water demands to the junctions

 for i in range(0,n_junction):

  junction = wn.get_node(str(i + 1))

junction.demand_timeseries_list[0].base_value = q_measured[i]

# Evaluating pressures in the system

 sim = wntr.sim.EpanetSimulator(wn)

 results = sim.run_sim()

 pressure = results.node[’pressure’]

 for i in range(0,n_junction):

  p_predicted[i] = pressure.loc[0,str(i + 1)]

# Evaluating pressure residuals

 p_residual = 0.0

 for i in range(0,n_measurements):

  junction = measurement_junctions[i]-1

  p_residual = p_residual + abs(p_measured[junction]-p_predicted[junction])

To validate the proposed procedure, a series of experimental analyses was conducted, and a representative example is presented below. Specifically, to examine the influence of the effective leakage area on the accuracy of leakage localization, the valves installed at water demand points located at junctions 13, 21, 45, and 53 (Figure 2) were adjusted so that, with a pressure head of 1.64 m at junction 1 (i.e. the inlet point), the following water consumption rates were measured: q13 = 0.041 l/s, q21 = 0.032 l/s, q45 = 0.012 l/s, and q53 = 0.014 l/s, as shown in Figure 3(a).
Figure 3

Illustration (a) represents the tested configuration of system parameters, with leakage set at junction 42 and an inflow pressure head of 1.64 m. Illustrations (b)–(f) show the predicted location of water leakage for five different leakage openings (effective leakage areas from 2 to 20 mm2). Each illustration reflects the results of 30 successive localization attempts, where the size of the circle (diameter) indicates the number of times leakage was identified at the circle centre, and the colour of the circle represents the leakage flow according to the colour bar.

Figure 3

Illustration (a) represents the tested configuration of system parameters, with leakage set at junction 42 and an inflow pressure head of 1.64 m. Illustrations (b)–(f) show the predicted location of water leakage for five different leakage openings (effective leakage areas from 2 to 20 mm2). Each illustration reflects the results of 30 successive localization attempts, where the size of the circle (diameter) indicates the number of times leakage was identified at the circle centre, and the colour of the circle represents the leakage flow according to the colour bar.

Close modal

Water leakage was introduced at junction 42 (Figure 3(a)), and the effective leakage area was varied between experiments as previously specified. Since leakage flow has a nonlinear relationship with the pressure at the leakage point, it was calculated based on the measured difference between the inlet flow at junction 1 and the measured outflows at the junctions where water demands were simulated. In this way, for the tested effective leakage areas of 2, 4, 6, 12, and 20 mm2, the following water leakage flows were determined: 0.013, 0.020, 0.040, 0.049, and 0.059 l/s, respectively. It should be noted that the choice of leak location and leakage amount was not random. Specifically, the leakage flow rate for the smallest effective leakage area aligns with water demands on that side of the pressurized piping system, making both detection and localization of the leak particularly challenging. Namely, note that the flows in question are difficult to distinguish because they are relatively small (compared to other flows in the system) and cause only a minimal drop in pressure head.

To localize the leak, the previously presented application of the PSO algorithm was used with a total of 50 particles, and the model parameters were selected with the following values: c1 = 1.5, c2 = 2.0, Ir = 0.01, and w = 0.8. It is important to note that the parameters of the model remained constant during all experiments and that for each effective leakage area, a total of 30 consecutive localization attempts were carried out, which was primarily necessary given that the application of the PSO method is of a stochastic nature (for vectors and ) and therefore regularly validated statistically. The obtained results are shown in Figure 3, where the localization results for all examined cases are illustrated with coloured circles. At the same time, the size of the circle indicates the number of localization attempts that localized the same leakage point, and the colour of the circle indicates the determined leakage flow.

It should be noted that only in the first case, i.e. for the smallest effective leakage area (Figure 3(b)), most localization attempts correctly identified the branch of the pressurized piping system but did not precisely pinpoint the leakage junction. However, they did accurately predict the leakage flow, that is, the range of leakage flow (between 0.012 and 0.014 l/s). This is understandable, given that the leakage flow was of a similar order of magnitude to the neighbouring water demands. In contrast, for all other cases where the leakage flow exceeded the neighbouring water demand (Figures 3(c)–3(f)), it can be reasonably concluded that all localization attempts successfully identified both the location and the amount of water leakage. Namely, higher amounts of leakage flow will require higher water velocities in the pressurized piping system, which will then leave a larger ‘trace’ in the pressure field and thus facilitate the minimization of the objective function given by Equation (1).

To evaluate the success of leak localization regarding the amount of leakage flow, the previously presented data can be systematized and displayed as a group using violin plots. Namely, a violin plot is a data visualization tool that combines elements of a box plot and a density plot, making it useful for understanding both the distribution and shape of a dataset. Each ‘violin’ represents a data group and shows density across values; the width of the shape indicates where data points are concentrated. Accordantly, wider sections suggest higher density, while narrower sections indicate fewer data points in that range. By comparing violins side by side, it is easy to establish differences in data distributions across multiple groups.

Figure 4 presents violin plots depicting the distribution of 30 attempts for each leakage location and each tested case of effective leakage area. The width of the ‘violin’ represents the number of attempts that resulted in the same leakage localization (a wider violin indicates a greater number of identical localizations across the 30 attempts), while the height corresponds to the junction number where the leak was detected. It can be observed that the data scattering around junction 42, where leakage occurs, increases as the effective leakage area decreases. Additionally, with a larger effective leakage area, the leakage localization consistently falls within the range of junctions 40–42, with a tendency to converge at junction 42. The localization accuracy is further demonstrated by isolating a suspicious area of only 25 cm within the total system length of 8 m (given that the distance between adjacent junctions is 12.5 cm, which represents 3.125% of the total length). Similarly, Figure 5 shows a violin plot illustrating the distribution of predicted leakage flow. In this case, it can be observed that the data distribution for each effective leakage area examined is significantly narrower, indicating that the leakage flow is consistently well identified.
Figure 4

Violin plot showing predicted leakage locations (junction numbers) for 30 successive attempts conducted across five different effective leakage areas at junction 42.

Figure 4

Violin plot showing predicted leakage locations (junction numbers) for 30 successive attempts conducted across five different effective leakage areas at junction 42.

Close modal
Figure 5

Violin plot showing predicted leakage flow (l/s) for 30 successive attempts conducted across five different effective leakage areas at junction 42.

Figure 5

Violin plot showing predicted leakage flow (l/s) for 30 successive attempts conducted across five different effective leakage areas at junction 42.

Close modal

For further validation of the proposed methodology, different pipeline system configurations, including more complex pipe network configurations, multiple leaks, and varying pipe diameters, should be explored. Future work should also include conducting specialized tests on the localization of longitudinal cracks – i.e. extending over a longer area – since such cracks have been observed in some cases as a result of water hammer. Multiple leaks for PSO optimization will be straightforward to implement, with the increasing need for computational resources. Considering that the methodology proposed in the work provides a fast optimization procedure, important for the fast system response necessary for establishing a digital twin, this expansion will require special attention, including parallelization to obtain a proper strategy for real-life application.

Sensor placement and the number of sensors influence leak localisation efficiency, which is particularly important in asymmetric configurations of pressure systems with complex topological characteristics. Initially conducted tests with fewer pressure gauges measurements led to a reduction in the effectiveness of localization, which was expected. In this case, laboratory tests were conducted on a symmetrical pipe system, and thus the positioning of the pressure gauges was symmetrical, and optimal positioning of pressure measurement probes was not investigated; however, it is something that will be considered in future work.

It must be noted that scaling up the procedure to real-world water supply systems requires addressing several factors that were not as evident in the presented tests. Notably, pressure measurements in real-world systems are likely to be influenced by additional factors not prominent in the laboratory tests. For example, the sensitivity of measuring devices to pressure field oscillations, caused by changes in the velocity field, may impact accuracy. To account for these effects, linear regression was incorporated into the software solution for data acquisition, smoothing collected data over a time window of several seconds to minimize potential measurement oscillations. Although laboratory tests indicated that this was unnecessary due to (i) controlled measurement conditions, (ii) minimal temporal variations in flow velocity, and (iii) high-pressure measurement accuracy, such data smoothing will be essential for real water supply systems. Additionally, an effective noise reduction procedure will be required, which can be achieved by integrated low-pass filters. Although applying the presented method to real-world systems will require addressing additional practical challenges (such as installing complex telemetry equipment and parallelizing the software solution to accommodate a larger swarm of particles for the PSO algorithm), the conducted tests have demonstrated that the proposed methodology, which leverages a digital twin, can, in principle, be used to localize water leaks in pressure systems. Moreover, installing pressure and flow measurement equipment on existing water supply systems – currently used primarily for monitoring key parameters rather than for advanced data processing in leak localization – understandably leads to the development of digital twins, which could significantly enhance the efficient management of such systems.

A specific model-based approach for leak localization is illustrated and utilized to develop a digital twin of an actual pressurized piping system, enabling real-time leak detection. The proposed procedure addresses the leakage localization problem by formulating it as an optimization problem, where the objective function measures the difference between the observed and predicted pressures at predefined control points, assuming an identical distribution of water demands at the junctions. This procedure requires detailed calibration of the hydraulic model of the pressurized piping system under consideration and is primarily intended for detecting and localizing leaks that may subsequently occur but are not currently present. In other words, the approach assumes that any existing leaks are negligible, and their influence is incorporated into the calibration parameters (pipe roughness and local loss coefficients). For hydraulic model calibration, a procedure based on the indirect measurement of pipe roughness and the calibration of local loss coefficients using the PSO method is proposed. The PSO method is also applied to solve the formulated optimization problem for water leak localization, demonstrating high flexibility and effectiveness in finding solutions. This approach allows for the identification of leaks by both position and flow, and it has been tested under laboratory conditions. For the selected scale of the physical model of a pressurized piping system, results indicate that the digital twin can detect leak locations and flow rates with a pressure head change of as little as 2 mm or less, ensuring relevant localization success, especially in terms of predicting the value of leakage flow. The concept of the methodology is relatively straightforward and will soon be tested on a real water supply system.

This research article is part of the project Hydrology of Water Resources and Risk Identification of the Consequences of Climate Change in Karst Areas (23–74), funded by the University of Rijeka.

V.T. conceptualized the study, wrote the Python programme, calibrated the model, and wrote the article, E.G. constructed a physical model of the pressurized system and installed all the sensors, I.L. and E.Z. participated in the realization of the digital twin and reviewed the article.

All relevant data are included in the paper or its Supplementary Information.

The authors declare there is no conflict.

AbdelMeguid
H.
&
Ulanicki
B.
(
2011
) ‘
Pressure and leakage management in water distribution systems via flow modulation PRVs
’,
Water Distribution Systems Analysis 2010
.
Reston, VA
:
American Society of Civil Engineers
, pp.
1124
1139
.
https://doi.org/10.1061/41203(425)102
.
AbdelMeguid
H.
,
Skworcow
P.
,
Paluszczyszyn
D.
&
Ulanicki
B.
(
2010
) ‘
Model predictive control for energy and leakage management in water distribution systems
’,
UKACC International Conference on Control 2010
.
UK
:
Institution of Engineering and Technology, Coventry
, pp.
990
995
,
https://doi.org/10.1049/ic.2010.0416
.
AbdelMeguid
H.
,
Skworcow
P.
&
Ulanicki
B.
(
2011
)
Mathematical modelling of a hydraulic controller for PRV flow modulation
,
Journal of Hydroinformatics
,
13
,
374
389
.
https://doi.org/10.2166/hydro.2011.024
.
Ayati
A. H.
,
Haghighi
A.
&
Lee
P.
(
2019
)
Statistical review of major standpoints in hydraulic transient-based leak detection
,
Journal of Hydraulic Structures
,
5
(
1
),
1
26
.
http://dx.doi.org/10.22055/JHS.2019.27926.1095
.
Berardi
L.
,
Laucelli
D.
&
Ugarelli
R.
,
Giustolisi
O.
(
2015
)
Leakage Management: Planning Remote Real Time Controlled Pressure Reduction in Oppegård Municipality
,
Procedia Engineering
,
119
, pp.
72
81
.
http://dx.doi.org/10.1016/j.proeng.2015.08.855
.
Blesa
J.
,
Nejjari
F.
&
Sarrate
R.
(
2015
)
Robust sensor placement for leak location: analysis and design
,
Journal of Hydroinformatics
,
18
(
1
),
136
148
.
https://doi.org/10.2166/hydro.2015.021
.
Bonilla
C. A.
,
Zanfei
A.
,
Brentan
B.
,
Montalvo
I.
&
Izquierdo
J.
(
2022
)
A digital twin of a water distribution system by using graph convolutional networks for pump speed-based state estimation
,
Water
,
14
(
4
),
514
.
https://doi.org/10.3390/w14040514
.
Brahmbhatt
P.
,
Maheshwari
A.
&
Gudi
R. D.
(
2023
)
Digital twin assisted decision support system for quality regulation and leak localization task in large-scale water distribution networks
,
Digital Chemical Engineering
,
9
,
100127
.
https://doi.org/10.1016/j.dche.2023.100127
.
Casillas Ponce
M. V.
,
Garza Castañón
L. E.
&
Puig Cayuela
V.
(
2014
)
Model-based leak detection and location in water distribution networks considering an extended-horizon analysis of pressure sensitivities
,
Journal of Hydroinformatics
,
16
(
3
),
649
670
.
https://doi.org/10.2166/hydro.2013.019
.
Chan
T. K.
,
Chin
C. S.
&
Zhong
X.
(
2018
)
Review of current technologies and proposed intelligent methodologies for water distributed network leakage detection
,
IEEE Access
,
6
,
78846
78867
.
doi:10.1109/ACCESS.2018.2885444
.
Clayton
C.
&
Van Zyl
J. E.
(
2007
)
The effect of pressure on leakage in water distribution systems
,
Water Management
,
160
,
109
114
.
https://doi.org/10.1680/wama.2007.160.2.109
.
Clerc
M.
(
2010
)
Particle Swarm Optimization
.
Hoboken, New Jersey, USA. John Wiley & Sons Inc
.
doi:10.1002/9780470612163
.
Conejos Fuertes
P.
,
Martínez Alzamora
F.
,
Hervás Carot
M.
&
Alonso Campos
J. C.
(
2020
)
Building and exploiting a digital twin for the management of drinking water distribution networks
,
Urban Water Journal
,
17
(
8
),
704
713
.
https://doi.org/10.1080/1573062X.2020.1771382
.
Fang
Q. S.
,
Zhang
J. X.
,
Xie
C. L.
&
Yang
Y. L.
(
2019
)
Detection of multiple leakage points in water distribution networks based on convolutional neural networks
,
Water Supply
,
19
(
8
),
2231
2239
.
https://doi.org/10.2166/ws.2019.105
.
Gómez-Coronel
L.
,
Santos-Ruiz
I.
,
Torres
L.
,
López-Estrada
F. R.
,
Gómez-Peñate
S.
&
Escobar-Gómez
E.
(
2023
)
Digital twin of a hydraulic system with leak diagnosis applications
,
Processes
,
11
(
10
),
3009
.
https://doi.org/10.3390/pr11103009
.
Kim
S. H.
(
2018
)
Development of multiple leakage detection method for a reservoir pipeline valve system
,
Water Resources Management
,
32
(
6
),
2099
2122
.
https://doi.org/10.1007/s11269-018-1920-x
.
Klise
K. A.
,
Hart
D. B.
,
Bynum
M.
,
Hogge
J.
,
Haxton
T.
,
Murray
R.
&
Burkhardt
J.
(
2020
)
Water Network Tool for Resilience (WNTR) User Manual: Version 0.2.3
.
Washington, DC
:
U.S. EPA Office of Research and Development
.
EPA/600/R-20/185, 82
.
Koppel
T.
&
Vassiljev
A.
(
2009
)
Calibration of a model of an operational water distribution system containing pipes of different age
,
Advances in Engineering Software
,
40
(
8
),
659
664
.
https://doi.org/10.1016/j.advengsoft.2008.11.015
.
Lee
P. J.
,
Lambert
M. F.
,
Simpson
A. R.
,
Vitovský
J. P.
&
Liggett
J.
(
2006
)
Experimental verification of the frequency response method for pipeline leak detection
,
Journal of Hydraulic Research
,
44
(
5
),
693
707
.
https://doi.org/10.1080/00221686.2006.9521718
.
Liemberger
R.
&
Wyatt
A.
(
2019
)
Quantifying the global non-revenue water problem
,
Water Supply
,
19
(
3
),
831
837
.
https://doi.org/10.2166/ws.2018.129
.
Mpesha
W.
,
Hanif Chaudhry
M.
&
Gassman
S. L.
(
2002
)
Leak detection in pipes by frequency response method using a step excitation
,
Journal of Hydraulic Research
,
40
(
1
),
55
62
.
https://doi.org/10.1080/00221680209499873
.
Pérez
R.
,
Puig
V.
,
Pascual
J.
,
Quevedo
J.
,
Landeros
E.
&
Peralta
A.
(
2011
)
Methodology for leakage isolation using pressure sensitivity analysis in water distribution networks
,
Control Engineering Practice
,
19
(
10
),
1157
1167
.
https://doi.org/10.1016/j.conengprac.2011.06.004
.
Pesantez
J. E.
,
Alghamdi
F.
,
Sabu
S.
,
Mahinthakumar
G.
&
Berglund
E. Z.
(
2022
)
Using a digital twin to explore water infrastructure impacts during the COVID-19 pandemic
,
Sustainable Cities and Society
,
77
,
1
15
.
https://doi.org/10.1016/j.scs.2021.103520
.
Rossman
L. A.
(
2000
)
EPANET 2.0 User's Manual
.
Cincinnati, Ohio, USA U.S. Environmental Protection Agency
.
Shravani
D.
,
Prajwal
Y. R.
,
Prapulla
S. B.
,
Salanke
N. S. G. R.
,
Shobha
G.
&
Ahmad
S. F.
(
2019
) ‘
A machine learning approach to water leak localization
’,
4th International Conference on Computational Systems and Information Technology for Sustainable Solution (CSITSS)
.
Bengaluru,
India
, pp.
1
6
.
doi:10.1109/CSITSS47250.2019.9031010
.
Simon
D.
(
2013
)
Evolutionary Optimization Algorithms: Biologically-Inspired and Population Based Approaches to Computer Intelligence
.
Hoboken, New Jersey, USA. John Wiley & Sons Inc
.
Skworcow
P.
,
AbdelMeguid
H.
,
Ulanicki
B.
,
Bounds
P.
&
Patel
R.
(
2009
) ‘
Combined energy and pressure management in water distribution systems
’,
Proceedings of the World Environmental and Water Resources Congress 2009 – Great Rivers
, vol.
342
, pp.
709
718
,
https://doi.org/10.1061/41036(342)70
.
Soldevila
A.
,
Blesa
J.
,
Tornil-Sin
S.
,
Duviella
E.
,
Fernandez-Canti
R. M.
&
Puig
V.
(
2016
)
Leak localization in water distribution networks using a mixed model-based/data-driven approach
,
Control Engineering Practice
,
55
,
162
173
.
https://doi.org/10.1016/j.conengprac.2016.07.006
.
Soldevila
A.
,
Fernandez-Canti
R. M.
,
Blesa
J.
,
Tornil-Sin
S.
&
Puig
V.
(
2017
)
Leak localization in water distribution networks using Bayesian classifiers
,
Journal of Process Control
,
55
,
1
9
.
https://doi.org/10.1016/j.jprocont.2017.03.015
.
Soldevila
A.
,
Jensen
T. N.
,
Blesa
J.
,
Tornil-Sin
S.
,
Fernandez-Canti
R. M.
&
Puig
V.
(
2018
) ‘
Leak localization in water distribution networks using a Kriging data-based approach
’,
IEEE Conference on Control Technology and Applications
.
New York
, NY
.
doi:10.1109/CCTA.2018.8511502
.
Swamee
D. K.
&
Jain
A. K.
(
1976
)
Explicit equations for pipe flow problems
,
Journal of the Hydraulics Division
,
102
,
657
664
.
https://doi.org/10.1061/JYCEAJ.0004542
.
Van Rossum
G.
&
Drake
F. L.
(
2009
)
Python 3 Reference Manual
.
Scotts Valley, CA
:
CreateSpace
.
Vassiljev
A.
,
Koor
M.
&
Koppel
T.
(
2015
)
Real-time demands and calibration of water distribution systems
,
Advances in Engineering Software
,
89
,
108
113
.
https://doi.org/10.1016/j.advengsoft.2015.06.012
.
Wu
Z. Y.
&
Sage
P
. (
2006
) ‘
Water loss detection via genetic algorithm optimization-based model calibration
’,
Water Distribution Systems Analysis Symposium 2006
,
Cincinnati,
Ohio, USA
, pp.
1
11
,
https://doi.org/10.1061/40941(247)180
.
This is an Open Access article distributed under the terms of the Creative Commons Attribution Licence (CC BY 4.0), which permits copying, adaptation and redistribution, provided the original work is properly cited (http://creativecommons.org/licenses/by/4.0/).