# Optimization of Water Pressure of a Distribution Network within the Water-Energy Nexus
## Materials and Methods  
### WDN Simulation  
The present hydraulic analysis of WDN aims to calculate indefinite parameters, such as the flow rate, the velocity, and the pressure of nodes, using input data related to these parameters. Both the energy equation and the continuity equation must be considered when analyzing WDN from a hydraulic perspective. According to the continuity equation, the mass flow rate in a pipe must remain constant at a steady-state condition. In addition, the energy equation determines the amount of energy head loss on the two sides of a pipe as a function composed of characteristics related to the flowing fluid, the specifications of the pipe, and the features of the flow (flow rate or velocity). Moreover, the Hazen-Williams, Darcy-Weisbach, and Manning relations are often used to determine the energy head loss in a pipe. Some of the equations used to analyze WDNs are nonlinear and iteration processes are used to solve them. The most common procedure is the gradient method. This procedure is the basis of the analyses carried out by many software programs in this field, including EPANET. With this method, there is no need to make an initial estimation of the flow rate in the pipes or the head of the nodes because the improved values of the flow rate and heads are directly used in each iteration. Although more equations need to be solved when using this method, its computational robustness is much higher in comparison to other methods [39]. Many software packages have been developed for the hydraulic analysis of WDNs. EPANET 2.0 is the most well-known and commonly used and it is used in this study also because of its open-source design and its extensive set of developed lateral tools. For example, EPANET can connect to the programming environment of technical computing software, while it can also exploit both the demand-driven simulation method (DDSM) and the HDSM in the hydraulic analysis of networks. In the DDSM, it is assumed that the demands are fixed and known in advance, regardless of nodal pressure variations. However, this assumption is only acceptable under normal conditions and when the existing pressure meets the minimum pressure required by the consumer. It cannot satisfy systems with pressure lower than the required value at some nodes [40]. The relationship between the actual supplied flow rate and the pressure in each node is taken into account in the HDSM. Research in this field, in the last three decades, has proven the dependency of the output flow rate on the pressure of the nodes [41; 42; 43; 44]. Due to the importance of the pressure of each node for computing the consumed energy in domestic WPBSs, this study uses the HDSM to properly account for pressure alterations and evaluate the hydraulic parameters of nodal heads and velocity in pipes more realistically than DDSM. To conduct a pressure-based hydraulic analysis of the networks, the available discharge of a node should not be considered constant (\(\rm Q_{j}^{req}\)). The mentioned value must be computed by Equation (1) based on the existing pressure of the node (\(\rm Q_{j}^{avt}\)) [44]. \[\text{Q}_{\text{j}}^{\text{avl}}=\left\{