# Qualification of Hydraulic Analysis Models for Optimal Design of Water Distribution Systems
## 2 Methodology
\(\mathrm{d}E\) is the energy imbalance in each pipe, and \(\mathrm{d}d_{n}\) is the discharge imbalance in each node given as:  
\[[\mathrm{d}E]=\big{[}A_{pp}\big{]}\big{[}Q_{i}\big{]}+\big{[}A_{pn}\big{]}[H_{ i}]+\big{[}A_{p0}\big{]}[H_{0}\big{]}[\mathrm{d}d_{n}]=\big{[}A_{np}\big{]}[Q_{i}]-[d_{ n}] \tag{6}\]The gradient method solves the system of equations presented in Equation (5), considering that each iteration is ruled by the following conditions:  
\[[\text{d}Q]=[Q_{i+1}]-[Q_{i}][\text{d}H]=[H_{i+1}]-[H_{i}] \tag{7}\]  
Finally, the solution of the system of Equation (5) can be achieved by solving the following matrixes:  
\[ \begin{split}[H_{i+1}]=-\Big{\{}&[A_{np}]\left( \left[N\right]\left[A_{pp}\right]^{\prime}\right)^{-1}\!\big{[}A_{pn}\big{]} \Big{\}}^{-1}\Big{\{}&[A_{np}]\left(\left[N\right]\left[A_{pp} \right]^{\prime}\right)^{-1}\!\big{(}\big{[}A_{pp}\big{]}\!\big{[}Q_{i}\big{)} \big{)}+\big{[}A_{p0}\big{]}[H_{0}]-\big{(}\big{[}A_{np}\big{]}\big{[}Q_{i} \big{)}\big{)}-\big{[}A_{n}\big{]}\Big{\}}\\ &[Q_{i+1}]=\Big{\{}&[l]-\Big{(}\big{[}N\big{]}\big{[} A_{pp}\big{]}^{\prime}\Big{)}-\big{[}A_{pp}\big{]}\Big{\}}[Q_{i}]-\Big{\{} \Big{(}\big{[}N\big{]}\big{[}A_{pp}\big{]}^{\prime}\Big{)}^{-1}\big{(}\big{[}A _{pn}\big{]}[H_{i+1}]+\big{[}A_{p0}\big{]}[H_{0}]\Big{)}\Big{\}}\end{split}  \tag{8}\]  
On the other hand, the pressure-driven analysis (PDA) is known for simulating more realistically the behavior of the system in case of abnormal operating conditions. For this approach, the assumptions are not focused on the water demand. Instead, the nodal pressure defines how much water can be supplied according to several conditions. These conditions or relationships are the nodal head-outflow relationship (HOR) and the leakage relationship [17]. The nodal head-outflow relationship (HOR) is parabolic and continues the equation in which for nodal heads above the desirable head pressure (\(H^{des}\)), the required demand (\(Q^{rot}\)) can be withdrawn, and for nodal head pressure below the minimum head (\(H^{min}\)), no demand can be withdrawn. If the required demand is between the thresholds (\(H^{des}\) and \(H^{min}\)), a portion of the required demand can be withdrawn (\(Q^{rot}\)). Many researchers have studied this relationship, with the one presented by [PERSON] et al. [18] having superior results. For every node \(j\) in the network, the HOR is given as:  
\[ \begin{split}\text{Adequate flow : }& H_{j}\geq H_{j}^{des}\to\ Q_{j}^{rot} =Q_{j}^{rot}\\ \text{Partial flow : }& H_{j}^{min}<H_{j}<H_{j}^{des}\to Q_{j}^{ rot}=Q_{j}^{rot}\Big{(}\frac{H_{j}-H_{j}^{min}}{H_{j}^{des}-H_{j}^{min}}\Big{)}^{( \frac{1}{H_{j}})}\\ \text{No flow : }& H_{j}\leq\ H_{j}^{min}\to\ Q_{j} ^{rot}=0\end{split}  \tag{9}\]  
The leakage relationship in the pipes of the system given by [PERSON] [17] models the leakage of each pipe \(ij\), assigning the effects to its start and end nodes as follows:  
\[Q_{Li}=C_{L}\sum_{j=1}^{m}\frac{L_{ij}}{2}\bigg{(}\frac{H_{i}-GL_{i}}{2}\bigg{)} ^{K} \tag{10}\]  
where \(Q_{Li}\), \(H_{i}\), and \(GL_{i}\) correspond to the leakage discharge head and ground level of node \(i\), \(L_{ij}\) is the length of pipes connected to node \(i\), and \(C_{L}\) is a fixed coefficient from network characteristics obtained from [19] the methodology. K is the pressure exponent that is determined by the FAVAD theory [18]. The energy and mass balance equation for the pressure-driven analysis are both nonlinear and given in matrix form as follows:  
\[\left[\begin{array}{cc} \begin{bmatrix}A_{pp}\\ A_{np}\end{bmatrix} \end{bmatrix} \begin{bmatrix}A_{pn}\\ A_{m}\end{bmatrix} \right]\left[ \begin{bmatrix}\begin{bmatrix}Q_{p}\\ H_{n}\end{bmatrix}\end{bmatrix} \right]=\left[ \begin{array}{cc}-\big{[}A_{p0 }\big{]}[H_{0}]\\ \begin{bmatrix}0\end{bmatrix}\end{array} \right] \tag{11}\]  
where most of the terms can be derived from the demand-driven analysis. \(A_{m}\) is a diagonal matrix conformed by the scalar product of \(-d_{n}\) and \(H^{-1}\).