**2. Methodology**

### *2.1. Availability of Excess Energy*

In any pipe of a network at a certain instant with a steady flow regime, the total energy line (Figure 1) can be defined as a straight line, if there are no local head losses, between the head in each boundary nodes. The head in each node will be higher than or equal to a minimum pressure *pmin*, usually imposed by regulators to guarantee a quality service to the population. In each point of the pipe, whenever the head is higher than this minimum pressure, there is excess energy. This excess energy will vary in time, as the demand in the network is not constant, affecting both the pipe flow and the pressure in the nodes.

**Figure 1.** Energy excess at each point of a pipe, defined as the hydraulic head above minimum pressure, for several instances where a steady state is observed.

The hydraulic energy, *E* (Wh), at any point of the pipe is defined as

$$E = \mathfrak{p} \mathbb{g} Q H \Delta t \tag{1}$$

where ρ is the water density (kg/m3), *g* is the gravitational acceleration (m2/s), *Q* is the flow rate (m3/s), *H* is the hydraulic head (m), meaning the total energy flow subtracted by the topographic elevation of the point, and Δ*t* (h), a time interval. This time interval can be considered as the duration of a steady state.

To estimate the excess energy in the upstream and downstream nodes of Figure 1, the minimum pressure is subtracted from the hydraulic charges:

$$\begin{cases} E\_{up} = \mathfrak{pgQ}\_t \left( H\_{up} - p\_{\min} \right) \Delta t \\ E\_{dn} = \mathfrak{pgQ}\_t \left( H\_{dn} - p\_{\min} \right) \Delta t \end{cases} \tag{2}$$

However, it can be argued that the application of this definition of the excess energy in an entire network cannot be done without taking into account the topography. The excess energy at a given point is often needed to ensure the minimum pressure in another and hence, is not available.

Considering the reach, defined as a sequence of pipes, sketched in Figure 2a, excess energy exists in every point of its water path, but none of this excess is available, since the most downstream point is at the minimum pressure and extra head losses would cause this pressure to decrease. Instead, if we consider the reach sketched in Figure 2b, the minimum pressure is not limited at the downstream extremity but at a high point along the path. The excess downstream from this point is partly available. During the network design, there is usually an effort to minimize this difference by using smaller diameters, as a means to control the pressure. Alternatively, the installation of turbines could be used to dissipate this excess energy.

The available energy at a point in a WSS can hence be defined as the excess energy that can be extracted from the flow without causing pressure below the minimum at any other point. To quantify how much of the excess energy is available for hydropower production, critical points must then be identified. The critical point corresponds to the position in a network where the difference between the total energy and the minimum pressure is minimum but higher than zero. This difference is the head that can be taken from the total energy line. This head and the downstream total energy line are represented by a dotted line in Figure 2b.

**Figure 2.** Examples of reaches. (**a**) Reach without available energy; (**b**) Reach with available energy; (**c**) Reach belonging to a closed network with available energy: effect of the extraction in one critical point; (**d**) Reach belonging to a closed network with available energy: effect of the extraction in two critical points.

The former examples always considered a single reach with no other connecting path between the upstream and the downstream sections either than the presented reach. The positioning of a valve or a turbine in Figure 2b would not have an impact in the discharge along the reach. However, if the reach was in a closed network, which is common in urban WSSs, the introduction of an energy converter and consequent adjustment of the energy distribution would have an impact in the discharge, as represented in Figure 2c. Moreover, the following critical point in the reach is now the point that was at minimum pressure before. If the new critical point is considered for the extraction of energy, a new readjustment occurs and the resulting total energy distribution is presented in Figure 2d.

The available energy in a network is given by the sum of the available energy at every critical point and hence its assessment requires a dynamic process. Also, as mentioned, the available head varies with the demand, which in a WSS is variable throughout the day. Nevertheless, a simpler and more immediate way for estimating available energy is to consider the steady state conditions with maximum flows, and hence the minimum heads.

An algorithm was developed to access the potential for hydropower in water supply networks taking into account the previous considerations for available energy in a network (Figure 3). Input data are composed of the network geometry, available consumption data (discharges distributed along the WSS) and minimum pressures to be assured at every node.

The consumption that leads to the average lowest pressure in the network is identified in the analysis. The nodes that do not fulfill the criteria of minimal pressure under these conditions are considered to be non-consumptive nodes, where the pressure is only required to be positive to avoid cavitation.

**Figure 3.** Algorithm to estimate the potential for hydropower of a network, given by the total available energy.

Since energy depends on both head and flow rate, the available energy cannot be evaluated solely based on available head in the critical points. For all the nodes in the network, a value *A* is defined, if the node is valid, as:

$$A\_n = \Delta H\_n \max\left(Q\_l\right) \tag{3}$$

where the index *l* refers to the ID of all pipes connecting to the node *n*,

$$
\Delta H\_{\text{ll}} = H\_{\text{n}} - p\_{\text{min}} \tag{4}
$$

and *Hn* is the hydraulic head over the node *n* in the current hydraulic state. If the node is not valid, *A* is zero. The nodes are then re-ordered in decreasing order of *A*.

For the node with the highest *A*, the head from Equation (4) is extracted by applying a local head loss in the pipe connecting to the node with the highest discharge. This extraction implies a new energetic equilibrium in the network that needs to be calculated. If the minimum pressure is satisfied in all the consumptive nodes after the network recalculation, the extracted head is given by the imposed head loss, and the available power in that node is given by the head and max (*Ql*). The power *P* of the new state is given by the sum of the available power in the new node, the available power in the all the nodes where a head loss was previously imposed and the power that is dissipated in each PRV, if they exist, multiplied by the water volumetric weight. The new node is accepted only if there is an increment in the calculation of the power, to ensure that it does not negatively affect the nodes previously gathered. If it is not accepted, the following highest *A* is tested and so forth until there is an acceptance or the valid nodes are exhausted.

The procedure of ordering the nodes according to the value of *A* is repeated with each new accepted equilibrium in the network. Moreover, when extracting the head in a new node, the flow discharge in the previous ones will be affected, and so the potential of both has to be calculated.

When all valid nodes have been evaluated, an estimation of the annual available energy *Epot* can be given by the power *P* multiplied by the considered time window Δ*t*. The potential for hydropower of a network is hence evaluated through the total available energy.
