Download as pdf or txt
Download as pdf or txt
You are on page 1of 22

water

Article
EPANET INP Code for Incomplete Mixing Model in Cross
Junctions for Water Distribution Networks
Daniel Hernández Cervantes 1 , José Antonio Arciniega Nevárez 2 , Helena M. Ramos 3, * ,
Xitlali Delgado Galván 2 , Joseph Daniel Pineda Sandoval 4 and Jesús Mora Rodríguez 2, *

1 División de Ingenierías del Campus Guanajuato, Universidad de Guanajuato, Guanajuato 36000, Mexico;
hernandez.daniel@ugto.mx
2 Departamento de Ingeniería Geomática e Hidráulica, Universidad de Guanajuato, Av. Juárez 77,
Guanajuato 36000, Mexico; ja.arciniega@ugto.mx (J.A.A.N.); xdelgado@ugto.mx (X.D.G.)
3 Civil Engineering Research and Innovation for Sustainability (CERIS), Civil Engineering Department,
Instituto Superior Tecnico, University of Lisbon, Av. Rovisco Pais 1, 1049-001 Lisboa, Portugal
4 Engineering Division, Universidad de Guanajuato, Guanajuato 36000, Mexico; jd.pinedasandoval@ugto.mx
* Correspondence: hramos.ist@gmail.com (H.M.R.); jesusmora@ugto.mx (J.M.R.)

Abstract: EPANET can be used to simulate quality on water distribution networks. The EPANET
model considers that the mixing on cross junctions of pipes is complete, including the cases of two
contiguous inlets and two contiguous outlets. The output concentration of this model is the same
value on the two outlets. This research proposes a code to generate an INP file for EPANET but with
an incomplete mixing scenario in the crossings. The cross junctions are identified, and their hydraulic
and concentration conditions are analyzed for each quality time step. Bypass pipes are included in
the model to remove concentrations generated by the complete mixing model, preserve continuity
in water quality and ensure the correct allocation of concentration. The concentration at the outlets
is obtained by a system of polynomial equations representing the incomplete mixing model as a
function of the hydraulic and concentration at the junction inlets. The outlets’ concentrations are
incorporated by setpoint boosters. Validations are described to demonstrate the achievement of the
Citation: Hernández Cervantes, D.; new code. An average relative concentration difference of up to 14% is obtained in networks with
Arciniega Nevárez, J.A.; Ramos, different scenarios for the two mixing models.
H.M.; Delgado Galván, X.; Pineda
Sandoval, J.D.; Mora Rodríguez, J.
Keywords: water quality; EPANET toolbox; MATLAB; cross junctions; WDN; incomplete mixing model
EPANET INP Code for Incomplete
Mixing Model in Cross Junctions for
Water Distribution Networks. Water
2023, 15, 4253. https://doi.org/
1. Introduction
10.3390/w15244253
EPANET 2.00.12 simulates quality models on pressure pipes for diverse studies. In
Academic Editors: Miaomiao Ye,
the case of the model for the outlets after a Cross Junction (CJ), EPANET proposes that the
Tuqiao Zhang and Shipeng Chu
concentration of a substance be a result of a simply flow-weighted sum of the concentrations
Received: 10 November 2023 coming from the inlet pipes. In this case, the mixing of fluid is taken to be complete and
Revised: 9 December 2023 instantaneous [1]. Some researchers have demonstrated numerically and experimentally that
Accepted: 10 December 2023 the resulting mixture is neither instantaneous nor complete after CJ [2–12]. Most of these
Published: 12 December 2023 researchers rely on computational fluid dynamics (CFD) with the use of tracers to obtain the
distribution of concentrations in the flows after CJ. The most common tracers are salts, Sodium
Chloride, Chlorine, Copper Sulphate, and the use of color in laminar flow [11–14]. The use of
a tracer in experimental models is important to obtain the concentration at the outlets of the
Copyright: © 2023 by the authors.
CJ under diverse conditions to validate the numerical scenarios normally modeled in CFD.
Licensee MDPI, Basel, Switzerland.
Simulating the concentration at the outlets in the CJs more accurately is important
This article is an open access article
distributed under the terms and
because it allows us to know the effect that these simulations generate on the total concen-
conditions of the Creative Commons
tration in the network. For this case, there are two water quality applications that have
Attribution (CC BY) license (https:// modified the EPANET functions to incorporate the Incomplete Mixing Model (IMM): One
creativecommons.org/licenses/by/ of them is EPANET-BAM [5], and the other is AZRED II [15]. Both have been published in
4.0/). scientific journals. In fact, the calculation methodology used by EPANET-BAM has been

Water 2023, 15, 4253. https://doi.org/10.3390/w15244253 https://www.mdpi.com/journal/water


Water 2023, 15, 4253 2 of 22

considered by the authors of EPANET to incorporate that mixing model in a prototype


version of EPANET 3.0 [16], but it has not been made available yet. These kinds of applica-
tions are restricted to some specific networks and require validation with experimental and
real networks.
In 2021, ref. [17] proposed a System of 12 Polynomial Equations (S12PE) to obtain an
IMM at CJs. The equations were obtained by the relation of the concentrations in the inlets
and the outlets of the CJ. Each equation was obtained with nine scenarios simulated with a
CFD model (a total of 108 scenarios was obtained). The CFD model was validated using
four experimental scenarios described in [18] by the same authors.
The S12PE of the IMM was validated for various diameters of CJ with a CFD model [17].
Diameters variate in 0.076 m × 0.051 m; 0.076 m × 0.076 m; 0.102 m × 0.076 m; 0.102 m
× 0.102 m; 0.152 m × 0.102 m; 0.203 m × 0.254; 0.203 m × 0.305 m; 0.305 m × 0.305 m
and 0.76 m × 0.305 m. The CJs simulated in CFD maintain the hydraulic structure and
numerical parameters of their accurate representation from the experimental model that
was used for its validation. The concentration at the outlets of the CJs varied from 0.1%
to 11.8% in the S12PE regarding the CFD model. However, 72.5% of the outlets have an
error below 2.0%. The other 17.5% of the outlets have an error between 2.2% and 4%, and
finally, 10% of the outlets have an error greater than 4% [17]. Therefore, the IMM by S12PE
has an efficient representation of different configurations of CJs commonly used in water
distribution networks.
The consequence of better representing the IMM on CJs in the water distribution
network is that the lack of accuracy in the simulation of water quality can lead to errors in
two kinds of applications: (1) The detection of low concentrations of chlorine, which may
affect the proposal of Booster Chlorine Stations needed to maintain the minimum required
concentration [5,19–24] and (2) the design of monitoring systems, such as the optimal
placement of sensors to detect contaminant events [25–47]. The accuracy of these models is
also necessary to simulate the spatio-temporal dispersion of the chemical and microbial
agents during accidental or intentional pollutant events. In this paper, the IncByPass code is
described to generate an INP file that implements the IMM on CJs in the EPANET scenarios.
In the methodology section, the process to generate the IncByPass and its validations to
guarantee the results of the hydraulic and quality simulation with the IMM in EPANET is
described. The novelty of this paper is the application of a new Incomplete Mixing Model
(IMM) to obtain the concentration at the outlets according to their flow and concentration
inlets. This IMM was validated experimentally for the concentrations and with a CFD
model for diverse kinds of diameters used on distribution water networks. The outlet
concentrations from the CJs are determined in a code named IncByPass, which considers:
• Identifying the time step in which the CJ has a flow with two contiguous inlets and
two contiguous outlets;
• Including a bypass at the CJ that was identified to incorporate the IMM;
• The IMM was implemented by the S12PE for every CJ at every time step;
• It was assigned the concentration at the outlets according to its similarity with the
flows and concentrations on the CJ validated with the CFD model;
• Patterns and controls of EPANET were programmed to activate booster stations and
open and close pipelines in the bypass according to the flow conditions to guarantee
the two contiguous inlets and outlets of every time step; These novelties proposed
by the IncByPass code were validated on diverse network scenarios described in the
following chapters of the paper.

2. Materials and Methods


The methodology to generate the IncByPass and its validation is made with the
following steps: (1) Description of EPANET water quality model related to CJs and the
application of the IMM. (2) Description of the code IncByPass to explain the process that
generates the modification of the network to implement the IMM and the incorporation on
EPANET. (3) Application of IncByPass with constant consumption verifying the results of
The methodology to generate the IncByPass and its validation is made with
lowing steps: (1) Description of EPANET water quality model related to CJs and
plication of the IMM. (2) Description of the code IncByPass to explain the proc
generates the modification of the network to implement the IMM and the incorp
Water 2023, 15, 4253 on EPANET. (3) Application of IncByPass with constant consumption verifying 3 of 22 th
of the generated code. And finally, (4) validation of the model on constant consu
and tanks around the network to verify the stabilized conditions on the hydrau
the generated code. And finally, (4) validation of the model on constant consumption and
quality with the IncByPass.
tanks around the network to verify the stabilized conditions on the hydraulic and quality
with the IncByPass.
2.1. EPANET Quality Model Related to CJs and the Application of the IMM
2.1. EPANET Quality Model Related to CJs and the Application of the IMM
The EPANET water quality model uses a Lagrangian approach for tracking
The EPANET water quality model uses a Lagrangian approach for tracking at fixed
time intervals
time intervals for afor a series
series of discrete
of discrete sections
sections of of the 1).
the pipe (Figure pipe (Figure
step, i
In each step, 1). In each
it generates
ates a mix along the pipe and
a mix along the pipe and the nodes [1]. the nodes [1].

Figure1. 1.
Figure Segments
Segments of pipes
of pipes in quality
in quality stepsa simulation
steps during during a simulation
in EPANET. in EPANET.

The time intervals used to simulate the quality model must be shorter than the hy-
The time intervals used to simulate the quality model must be shorter than
draulic calculation interval; EPANET proposes 5 min for each qstep. However, the un-
draulic comes
certainty calculation
from theinterval;
completeEPANET
mixing at proposes 5 min
the CJs, which forhave
could eachan qstep.
impact However,
on the th
tainty comes from the complete mixing at the CJs, which could have
effectiveness of their results since the concentration is obtained by Equation (1), which an impac
averages the value
effectiveness of the results
of their concentration
since for
theboth outlets, according
concentration to the weighted
is obtained of
by Equation (1)
concentrations and flows on the inlets of the CJ.
averages the value of the concentration for both outlets, according to the weighted
centrations and flows on the inlets
∑ j∈ Ik Qof
j C jthe
+ QCJ.
k,ext Ck,ext
Ci = (1)
∑ j∈ Ik ∑
Q j + Qk,ext
𝑗∈𝐼𝑘 𝑗 𝑗 + 𝑄𝑘,𝑒𝑥𝑡 𝐶𝑘,𝑒𝑥𝑡
𝑄𝐶
𝐶𝑖 =
where Ci represents the concentration at the outlets∑on 𝑄CJ.+Q𝑄j is
𝑗∈𝐼the
𝑘 𝑗
the flow rate at the inlets
𝑘,𝑒𝑥𝑡
of the CJ. Qk ,ext is the external source flow entering at node k. Ck ,ext is the concentration of
where
the Ci represents
external flow enteringthe concentration
at node k. Ik is the setat the outlets
of pipes on the
at the inlets CJ. k.
on node Qj is the flow rat
inletsIn of
contrast,
the CJ.the IMM
Qk,ext thatexternal
is the is going source
to be applied in the IncByPass
flow entering at nodeconsiders
k. Ck,ext isthe
the conce
S12PE [17] to obtain the concentration at the outlets of the CJ (Figure
of the external flow entering at node k. Ik is the set of pipes at the inlets on 2). The inlets at node k.
the CJ are represented by the flows QN and QW and concentration CN and CW ; they are
In contrast, the IMM that is going to be applied in the IncByPass considers th
represented by the relation IN (horizontal axis in Figure 2). And the outlets are represented
[17]
by theto obtain
flow QE and theQSconcentration at the C
, and the concentration outlets of the CJ (Figure 2). The inlets at th
E and CS that are going to be obtained by
represented
the relation OUT by(vertical
the flows QFigure
axis in N and 2). QW and concentration CN and CW; they are repr
by the relation IN (horizontal axis in Figure 2). And the outlets are represented by
QE and QS, and the concentration CE and CS that are going to be obtained by the
OUT (vertical axis in Figure 2).
Water 2023, 15,
Water 2023, 15, 4253
x FOR PEER REVIEW 44 of
of 22
22

Figure 2.
Figure 2. Model
Model of
of S12PE
S12PE to
to obtain
obtain the
the outlet
outlet concentration
concentration at
at CJs.
CJs.

Finally, to
Finally, to obtain
obtain the
the adequate
adequate polynomial
polynomial equation
equation for
for the
the specific
specific concentration at
proportion of
the outlets, the most similar proportion of the
the flow
flow between the inlets and the outlet flows
(Equation (2)).
must be obtained (Equation (2)).
𝑄 𝑄𝐸
Q𝑁 and Q 𝑄𝑟𝑂𝑈𝑇==Q E
QrI𝑄N𝑟𝐼𝑁== 𝑄N𝑊 and (2)
(2)
QW rOUT
Q𝑄S
𝑆

where 𝑄 and 𝑄𝑟𝑂𝑈𝑇 are the proportion of the flows at the inlets and the outlets of the
where QrI𝑟𝐼𝑁 N and QrOUT are the proportion of the flows at the inlets and the outlets of the
CJ. These relations are used to verify the minimum difference of flow relations from one
CJ. These relations are used to verify the minimum difference of flow relations from one of
of the 12 polynomial equations, considering Equation (3).
the 12 polynomial equations, considering Equation (3).
𝑅𝑖 = |𝑄𝑟𝐼𝑁 − 𝑄𝑟𝐼𝑁𝒊 | + |𝑄𝑟𝑂𝑈𝑇 − 𝑄𝑟𝑂𝑈𝑇𝒊 | (3)
Ri = | QrI N − QrI Ni | + | QrOUT − QrOUTi | (3)
where Ri is the absolute sum of differences for the polynomial equation for i from 1 to 12.
𝑄𝑟𝐼𝑁 and
where Ri is𝑄𝑟𝑂𝑈𝑇𝒊 are the proportion
the absolute of the flows
sum of differences at the
for the inlets and equation
polynomial outlets of for
the iCJ for each
from 1 to
of the
12. QrIpolynomial
N and QrOUTi equations. The minimum
are the proportion of thevalue
flowsofatRthe
i will be considered
inlets and outletssimilar to the
of the CJ for
mostof
each similar scenario toequations.
the polynomial use the relation OUT to value
The minimum obtainofthe Ri concentrations
will be considered at the outlets
similar to
for amost
the specific CJ. scenario to use the relation OUT to obtain the concentrations at the outlets
similar
for a The assumptions
specific CJ. to apply the S12PE are regarding the velocity and the concentration.
The velocity in the pipes
The assumptions around
to apply the the CJ is
S12PE arebetween
regarding 0.4the
m/s and 2.5and
velocity m/s,
thewith a relation
concentration.
The
fromvelocity infor
0.3 to 3.0 thethe
pipes aroundatthe
velocities theCJ is between
inlets and for 0.4them/s and 2.5
velocities at m/s, with aThe
the outlets. relation
con-
from 0.3 to at
centrations 3.0the
forinlets
the velocities
assumed aatrelationship
the inlets and fromfor the
0 to 2.0velocities
(horizontalat the
axisoutlets.
of FigureThe 2).
concentrations
In this case, at the inlets
limitsassumed a relationship
of the S12PE occur when fromthe0 range
to 2.0 (horizontal
of velocitiesaxis of Figure
around the CJ2).
Inand
is 0.30 this 3.0.
case,And
the for
limits
theof the S12PE occur
concentrations, thewhen
limitsthe range
are of velocities
in relation to the around
value IN;theforCJ10is
0.30 and 3.0. And for the concentrations, the limits are in relation to the
of the polynomial equations, the limit of IN is around 5, and only for the equations S6 and value IN; for 10 of
the
S10 polynomial
is the limit of equations,
IN around the limit of IN is around 5, and only for the equations S6 and
2.5.
S10 is the limit of IN around 2.5.
2.2. Code to Generate IncByPass
2.2. Code to Generate IncByPass
To apply IncByPass on EPANET, auxiliary nodes and pipes are implemented at each
CJ ofTo theapply IncByPass
network. on EPANET,
This process auxiliary
was made nodes and
to eliminate thepipes are implemented
resulting concentration at from
each
CJ of the network. This process was made to eliminate the resulting
the complete mixing model at the outlets of the junction and to establish the value of the concentration from
the complete mixing model at the outlets of the junction and to establish the value of
proposed concentration with the IMM by the S12PE described in Section 2.1. This modifi-
the proposed concentration with the IMM by the S12PE described in Section 2.1. This
cation was performed by maintaining the hydraulic functionality of the network during
modification was performed by maintaining the hydraulic functionality of the network
the extended simulation period and establishing the adequate properties of the auxiliary
during the extended simulation period and establishing the adequate properties of the
nodes and pipes.
auxiliary nodes and pipes.
Firstly, new junctions are generated: Naux, Waux, Eaux and Saux (Figure 3) around
Firstly, new junctions are generated: Naux, Waux, Eaux and Saux (Figure 3) around the
the CJs. These junctions are 1 cm from the CJ, and the auxiliary junctions acquire the ele-
CJs. These junctions are 1 cm from the CJ, and the auxiliary junctions acquire the elevation
vation of the CJ without demand. These junctions will function as a quality source of the
of the CJ without demand. These junctions will function as a quality source of the type
type of setpoint boosters; this is a source that fixes the concentration of any flow leaving
of setpoint boosters; this is a source that fixes the concentration of any flow leaving the
the node [1].
node [1].
pipes of 1 cm in length. These new pipes maintain the same diameter and roughness, and
the length of the original pipes are updated by reducing 1 cm length of the bypass.
Thirdly, the next step is to generate bypasses with two pipes of 0.5 cm in length, with
Water 2023, 15, x FOR PEER REVIEWthe same diameter and roughness as the original one. The bypasses include a node5 with of 22
the same elevation as the CJ without demand. The bypasses connect the auxiliary nodes
Water 2023, 15, 4253 5 of 22
with the junction “C”. At the beginning of the simulation, the bypass pipes have a closed
status. This does
Secondly, thenot affect
pipes the hydraulic
around functionality.
the CJ were cut 1 cm distance to connect them to the aux-
iliary nodes (Figure 3). Now, junction “C” is connected to the auxiliary nodes with 4 new
pipes of 1 cm in length. These new pipes maintain the same diameter and roughness, and
the length of the original pipes are updated by reducing 1 cm length of the bypass.
Thirdly, the next step is to generate bypasses with two pipes of 0.5 cm in length, with
the same diameter and roughness as the original one. The bypasses include a node with
the same elevation as the CJ without demand. The bypasses connect the auxiliary nodes
with the junction “C”. At the beginning of the simulation, the bypass pipes have a closed
status. This does not affect the hydraulic functionality.

Figure 3. Implementation of auxiliary nodes


Figure 3. nodes and
and bypasses
bypasses at
at the
the CJs.
CJs.

Secondly,
To activatethethepipes
IMM,around
the CJ the
mustCJpresent
were cut 1 cm distance
a condition of flow to with
connect
twothem to the
contiguous
auxiliary nodes (Figure 3). Now, junction “C” is connected to the auxiliary
inlets and two contiguous outlets. Therefore, the direction of the flow must be verified nodes with
for
4every
new pipes of 1 cm in length. These new pipes maintain the same diameter
step of the hydraulic simulation. In Figure 4, diverse cases of this flow for any CJ and roughness,
and theobserved.
can be length of The
the original
boundaries pipes
areare updatedwith
identified by reducing 1 cmdirections
the cardinal length of(North,
the bypass.
South,
Thirdly,
East and West). the next step is to generate bypasses with two pipes of 0.5 cm in length, with
the same diameter and roughness as the original one. The bypasses include a node with
the same elevation as the CJ without demand. The bypasses connect the auxiliary nodes
Figure
with 3. Implementation
the junction “C”. At of the
auxiliary nodes of
beginning and bypasses
the at the the
simulation, CJs.bypass pipes have a closed
status. This does not affect the hydraulic functionality.
To activate
To activate the
the IMM,
IMM, the the CJ
CJ must
must present
present aa condition
condition ofof flow
flow with
with two
two contiguous
contiguous
inlets and two contiguous outlets. Therefore, the direction of the flow
inlets and two contiguous outlets. Therefore, the direction of the flow must be verifiedmust be verified for
for
every step
every stepof ofthe
thehydraulic
hydraulicsimulation.
simulation.InIn Figure
Figure 4, diverse
4, diverse cases
cases of this
of this flowflow for any
for any CJ canCJ
canobserved.
be be observed.The The boundaries
boundaries are identified
are identified withwith the cardinal
the cardinal directions
directions (North,
(North, South,
South, East
EastWest).
and and West).
Figure 4. Cases of mixing for two inlets and outlets contiguous.

In any case of flow mixing, the bypass will be activated at the outlets (Figure 5), and
those pipes’ status changes to open. The original pipes at the outlets change the status to
closed (symbol X in Figure 5). At the pipes of the bypass, a high bulk coefficient (kb =
−2000) is assigned with the objective of consuming the chemical concentration, consider-
ing that the concentration at the final of the pipe, on the auxiliary nodes, the quality must
be zero. At that moment, the incomplete mixing is calculated with the S12PE, as was de-
scribed in Section 2.1, and the result will be assigned to the property of Source Quality of
Figure 4.
4. Cases of
of mixing for
for two
two inlets
inlets and
and outlets contiguous.
contiguous.
EPANETCases
Figure for the mixing
nodes CE and CS and, inoutlets
this way, continue the following quality steps.
In any case of flow mixing, the bypass will be activated at the outlets (Figure (Figure 5),
5), and
those pipes’
those pipes’ status
status changes
changes to to open.
open. The original pipes at the outlets change the status to
closed(symbol
closed (symbolXXinin Figure
Figure 5). 5).
At Atthethe
pipespipes of bypass,
of the the bypass,
a higha bulk
highcoefficient (kb = −(kb
bulk coefficient 2000)=
−2000)
is is assigned
assigned with thewith the objective
objective of consumingof consuming
the chemicalthe concentration,
chemical concentration,
considering consider-
that the
concentration at the final of at
ing that the concentration thethe
pipe, onofthe
final theauxiliary
pipe, onnodes, the quality
the auxiliary mustthe
nodes, bequality
zero. Atmust
that
moment, the incomplete mixing is calculated with the S12PE, as was described
be zero. At that moment, the incomplete mixing is calculated with the S12PE, as was de- in Section 2.1,
and the result
scribed will be
in Section 2.1,assigned
and thetoresult
the property of Source to
will be assigned Quality of EPANET
the property for theQuality
of Source nodes Cof E
and CS and,
EPANET forinthe
this way, C
nodes continue
E and CSthe following
and, quality
in this way, steps. the following quality steps.
continue
Water
Water2023,
2023,15,
15,x4253
FOR PEER REVIEW 6 of 22 6 of 2

Figure5.5.Activation
Figure Activation of the
of the bypass
bypass assigning
assigning the incomplete
the incomplete mixingmixing
at the CJatoutlets.
the CJ outlets.

InIneach
eachquality step
quality of 5of
step min, the code
5 min, mademade
the code the complete analysisanalysis
the complete for the mentioned
for the mentioned
CJs. Therefore, the hydraulic simulation requires actualization every 5 min. This process
CJs. Therefore, the hydraulic simulation requires actualization every 5 min. This proces
was codified following the next steps to obtain the incomplete mixing:
was codified following the next steps to obtain the incomplete mixing:
1. The network is loaded, the CJs are recognized, and the properties of the connection
1. The
are networktoisgenerate
organized loaded,the theauxiliary
CJs arenodes,
recognized, and the
as in Figure 4; properties of the connectio
2. are organized to generate the auxiliary nodes,
The hydraulics and quality parameters are initialized with counters, as in Figure 4; and empty
2. The hydraulics
matrices and quality
are generated parameters
to be filled are initialized
with information with counters,
on the following steps; and empty ma
3. Iftrices
the CJarepresents
generatedflowstowith two inlets
be filled withand two contiguous
information on theoutlets (Figure
following 5), then
steps;
3. the bypass is going to activate at the outlets (the original outlets
If the CJ presents flows with two inlets and two contiguous outlets (Figure change their status to 5), the
closed, and the pipes of the bypass change their status to open);
the bypass is going to activate at the outlets (the original outlets change their statu
4. Then, the flow is registered in the matrix at the four boundaries and the quality
to closed, and the pipes of the bypass change their status to open);
concentration at the inlets (N and W);
5.4. Then,
The the flowmixing
incomplete is registered in the
is calculated bymatrix
the S12PE,at the
andfour boundaries
the results and the
are assigned to quality
the con
centration at the inlets (N and W);
property Source Quality at the final nodes of the bypass at the outlets (E and S);
6.5. Theresults
The incomplete mixinginisthe
are registered calculated
matrix thatby will
the S12PE,
be used and the results
to generate are assigned
patterns for the to th
property
node working Source Quality
as source at the
quality final nodes
in EPANET. TheofPatterns
the bypass at the outlets
of EPANET (E and S);
are generated,
6. indicating
The results theareconcentration
registeredthat is going
in the matrixto be
thatestablished
will be usedat thetooutlets;
generate patterns for th
7. The
node working as source quality in EPANET. The Patterns ofofEPANET
model is simulated with these changes to obtain the quality the resultsareand
generated
continue to the next quality step;
indicating the concentration that is going to be established at the outlets;
8. Once a simulation is completed in the total hours (e.g., if the original network simula-
7. The model is simulated with these changes to obtain the quality of the results and
tion is 24 h), it compares the quality results at time 0:00 with the final time, 24:00. If
continue to the next quality step;
there is a relative error less than 0.001 in all the nodes, an additional day of simula-
8. Once
tion willa simulation
be run until is thecompleted
relative error in the total hours
mentioned above(e.g., if the (another
is reached original 24network
h of simu
lation is 24
simulation is h), it compares the quality results at time 0:00 with the final time, 24:00. I
increased);
9. Inthere is a24
the last relative
h, witherror less than
the relative 0.001
errors lessin all the
than nodes,
0.001, an additional
the model day of simulatio
will be simulated to
generate
will be run controls
untiloftheEPANET
relative byerror
IncByPass.
mentionedThe controls
above is arereached
generated to indicate
(another 24 h of sim
when
ulation the is
outlets and source quality should operate based on the hydraulic direction
increased);
9. flows
In the around
last 24theh,CJs;
with the relative errors less than 0.001, the model will be simulated
10. And the code IncByPass is finished (Figure 6).
to generate controls of EPANET by IncByPass. The controls are generated to indicat
when the outlets and source quality should operate based on the hydraulic directio
flows around the CJs;
10. And the code IncByPass is finished (Figure 6).
Water 2023,15,
Water2023, 15,4253
x FOR PEER REVIEW 7 of
of 22
22

Figure6.6.Flowchart
Figure Flowchartof
ofthe
thecode
codeofofIncByPass.
IncByPass.

EPANET
EPANETcan canexport
exportthethescenarios
scenariosin inaafile
filewith
withananINP
INPextension.
extension.This
Thisfile
fileisiswritten
written
in
inASCII
ASCII text
text format [1]. The
format [1]. TheINPINPfile
filecontains
containsthe the description
description of of
thethe network
network andandthethe
op-
operating conditions of the simulation, and the file can be created or modified
erating conditions of the simulation, and the file can be created or modified in any text in any text
editor,
editor,spreadsheet
spreadsheetprogram
programor orby
byprogramming
programmingcodes. codes. ItItisisorganized
organizedintointo27 27sections
sections
(Table
(Table 1), [1]. This file can be read back into EPANET by importing it for analysisof
1), [1]. This file can be read back into EPANET by importing it for analysis ofthe
the
modifications.
modifications. This property is used by the code IncByPass to incorporate the IMMwith
This property is used by the code IncByPass to incorporate the IMM with
the
thehydraulic
hydraulicand andquality
qualitymodifications
modificationsvalidated
validatedtotosimulate
simulateon onEPANET.
EPANET.
Table 1. Sections of Input file format on EPANET.
Table 1. Sections of Input file format on EPANET.
Network System Water Options and Network
Network System Water Options and Network
Components Operation Quality Reporting Map/Tags
Components Operation Quality Reporting Map/Tags
Title Curves Quality Options Coordinates
Title Curves Quality Options Coordinates
Junctions * Patterns * Reactions * Times * Vertices
Junctions *
Reservoirs Patterns *
Energy Reactions
Sources * * Times
Report * Vertices
Labels
Reservoirs
Tanks Energy
Status Sources *
Mixing Report Labels
Backdrop
Pipes *
Tanks Controls *
Status Mixing Tags
Backdrop
Pumps Rules
Pipes * Controls * Tags
Valves Demands
Pumps
Emitters Rules
Valves
Note: * Sections modified by theDemands
IncByPass to incorporate the IMM.
Emitters
Note:All
* Sections modified made
the simulations by the on
IncByPass
EPANET to incorporate
consider a the IMM. substance without reaction
chemical
in the track through the distribution networks. The quality model simulates a chemical in
mg/LAll theasimulations
with made onof
relative diffusivity EPANET considermodel
1. The reaction a chemical substance
for the wall andwithout
bulk isreaction
of first
in thein
order track
boththrough the distribution
cases. However, networks.
the reaction The quality
coefficient model
for the wallsimulates
pipe and abulk
chemical
flow isin
mg/LInwith
zero. this acase,
relative diffusivity ofare
the simulations 1. going
The reaction
to showmodel for the
the effect wall
of the and bulk
mixing at theis CJs
of first
to
order inthe
measure both cases. However,
differences the reaction
of the IMM with the coefficient for the Model
Complete Mixing wall pipe and of
(CMM) bulk flow is
EPANET.
Water 2023, 15, x FOR PEER REVIEW 8 of 22
zero. In this case, the simulations are going to show the effect of the mixing at the CJs to
measure the differences of the IMM with the Complete Mixing Model (CMM) of EPANET.
Water 2023, 15, 4253 zero. In this case, the simulations are going to show the effect of the mixing at the CJs 8 ofto
22
2.3. Application
measure of IncByPass
the differences of thewithIMM Constant
with theDemand
Complete to Verify the Model
Mixing Results(CMM)
of the Generated
of EPANET. Code
This section is going to show the application of IncByPass for the modification of the
CJsApplication
2.3. to prepareofthe scenarios
IncByPass withfor the IMM
Constant in twotonetworks
Demand (Figureof7).theThe
Verify the Results networks
Generated Code are
2.3. Application of IncByPass with Constant Demand to Verify the Results of the Generated Code
IM1.net and IM2.net and have a constant demand during the simulation,
This section is going to show the application of IncByPass for the modification of the with diverse
This sectionfrom
concentrations is going to show the
the reservoirs. application of IncByPass for the modification
at the of the
CJs to prepare the scenarios for the IM1.net
IMM in is twothenetworks
only CJ with two
(Figure reservoirs
7). The networks inlets,
are
CJs to prepare
one of them the scenarios
with a chemical for the IMM
concentration in two networks
of 1.0 mg/L (Figure
and the 7).
twosimulation, The
demand nodes networks are
IM1.net and IM2.net and have a constant demand during withatdiverse
the out-
IM1.net and
lets (Figure 7a); IM2.net
thethe and
pipes have a constant
are 2 inches demand
in diameter. during
The IM2.netthe simulation,
(Figure with
7b) has diverse
twoinlets,
reser-
concentrations
concentrations from
from thereservoirs.
reservoirs. IM1.net
IM1.net isisthe
theonly
onlyCJCJwith
with two
two reservoirs
reservoirs atatthe
the inlets,6
voirs,
one of one with
them with a chemical concentration
a chemical concentration of
concentrationofof1.0 1.5 mg/L,
1.0mg/L
mg/Landseven
andtwo CJs, with
twodemand diverse
demandnodes diameters
nodesatat the out-
one of
6 ×them
× 6,(Figure with
4, 47a); 4a×chemical
× 4,the 3, 3 × 2, 2 2× inches
2 (inches). One junction has a set point source the
quality outlets
of 1.5
lets pipes are in diameter. The IM2.net (Figure
(Figure 7a); the pipes are 2 inches in diameter. The IM2.net (Figure 7b) has two reservoirs, 7b) has two reser-
mg/L.one
voirs, The demands are 10 and 20 L/s, respectively.
one with awith a chemical
chemical concentration
concentration of 1.5ofmg/L,
1.5 mg/L,sevenseven
CJs, CJs,
withwith diverse
diverse diameters
diameters 6 × 66,
×66,×64,× 4,
4× 4 ×4,4,44×× 3,
3, 33 ××2,2,22× ×2 (inches).
2 (inches).OneOne junction hashas
junction a set point
a set source
point quality
source of 1.5
quality of
mg/L. The demands are 10 and 20 L/s,
1.5 mg/L. The demands are 10 and 20 L/s, respectively. respectively.

Figure 7. Networks IM1.net (a) and IM2.net (b) for the application and validation of IncByPass.

2.3.1. 7.
Figure
Figure Application of Incomplete
7. Networks IM1.net
Networks IM1.net Mixing(b)
(a) and IM2.net
(a) and IM2.net onfor
(b) IM1.net
for with Constant
the application
the application Consumption
and validation
and validation
of IncByPass.
of IncByPass.
2.3.1. The networkofIM1.net
Application was Mixing
Incomplete proposed on to show with
IM1.net the differences in the concentrations
Constant Consumption
considering
2.3.1. EPANET
Application mixing CMM
of Incomplete Mixing andonthe IMM with Constant
IM1.net the S12PEConsumption
for constant consump-
The network IM1.net was proposed to show the differences in the concentrations
tionThe
andnetwork
to show IM1.net
the effectwas
of the application
proposed of thethe
IncByPass. The relative difference ob-
considering EPANET mixing CMM and thetoIMM show with thedifferences
S12PE for in the concentrations
constant consumption
tained is up to 80% when
considering theCMM
inletsand
havethe1.0IMM
mg/Lwithon the west reservoir and 0.0 mg/L on
and to showEPANET
the effectmixing
of the application of the IncByPass. theThe
S12PE for constant
relative differenceconsump-
obtained
the
tion north
and reservoir. At the outlets, the CMM obtains a value of 0.5 mg/L, and with the
is up to to
80%show thethe
when effect of the
inlets haveapplication
1.0 mg/Lof onthe
theIncByPass. The relative
west reservoir and 0.0difference
mg/L onob- the
S12PE,
tained the values
is up to 80% are
when0.10 mg/L for
the inlets the east
have 1.0 node and
mg/La on 0.90
theof mg/L
west for the
reservoir south
and node
0.0the (Figure
mg/L on
north reservoir. At the outlets, the CMM obtains value 0.5 mg/L, and with S12PE,
8).
the
the north
valuesreservoir. At thefor
are 0.10 mg/L outlets, the
the east CMM
node andobtains
0.90 mg/La value of 0.5
for the mg/L,
south nodeand with 8).
(Figure the
S12PE, the values are 0.10 mg/L for the east node and 0.90 mg/L for the south node (Figure
8).

Figure8.8.Mixing
Figure Mixingresults
resultsfrom
fromthe
theEPANET
EPANETmodel
modeland
andthe
theS12PE.
S12PE.

The function of the Bypass allows the nodes with the quality source to assign the
Figure 8. Mixingproposed
concentration results from
bythe
theEPANET model
S12PE. As and the
shown S12PE. 9, the pipes of the bypass (from
in Figure
node C to nodes NauxC-1 and NauxC-2) have a high coefficient reaction (Kb = −2000) to
eliminate the homogeneous concentrations of 0.5 mg/L for both bypasses, that EPANET
mixing provides. Therefore, the IMM of S12PE is assigned by the variable source quality
Water 2023, 15, x FOR PEER REVIEW 9 of 22

Water 2023, 15, 4253 9 of 22


The function of the Bypass allows the nodes with the quality source to assign the
concentration proposed by the S12PE. As shown in Figure 9, the pipes of the bypass (from
innode C to nodes
the nodes NauxC-1
NauxC-1 and NauxC-2)
and NauxC-2 haveas
working a high coefficient
Setpoint Booster reaction (Kba=specific
and with −2000) to
time
eliminate the homogeneous concentrations of 0.5 mg/L for both bypasses, that EPANET
pattern obtained from the INP code.
mixing provides. Therefore, the IMM of S12PE is assigned by the variable source quality
in the nodes NauxC-1 and NauxC-2 working as Setpoint Booster and with a specific time
pattern obtained from the INP code.

Figure 9. Function of a Bypass at the CJ.


Figure 9. Function of a Bypass at the CJ.
2.3.2. Application of Incomplete Mixing on IM2.net with Constant Demands
2.3.2. Application
The IM2.net of Incomplete
obtains Mixing
a relative meanonerror
IM2.net withinConstant
of 231% Demands
the chemical obtained at the
Thefor
nodes IM2.net
the two obtains a relative
kinds of mixing.mean error of 231%around
The concentration in the chemical obtained
the networks with at
thethe nodes
EPA-
for the two kinds of mixing. The concentration around the networks
NET mixing shows a range of concentrations between 0.40 and 1.50 mg/L, and, on the with the EPANET
mixing shows
other hand, a range
there of concentrations
are concentrations from between
0.00 to 1.50.40 and
mg/L. 1.50
The mg/L,
main and, on
difference thethe
is that other
hand,
model there
withare concentrations
the IMM has zones from 0.00extreme
with to 1.5 mg/L. The maincompared
concentrations differencewith
is that
thethe
CMMmodel
(Figure
with 10). has zones with extreme concentrations compared with the CMM (Figure 10).
the IMM

Figure10.
Figure 10.Comparison
Comparison between
between EPANET
EPANET mixing
mixingand
andincomplete
incompletemixing
mixinginin
IM2.net.
IM2.net.

Thenumerical
The numerical results
results in the chemical
chemicalconcentrations
concentrationsare areobtained
obtainedfrom
fromthethe
relative
relative
difference based on the IMM. Figure 11 shows 23 of the 30 junctions, where 3 of
difference based on the IMM. Figure 11 shows 23 of the 30 junctions, where 3 of them them have
have
a relative error greater than a thousand, 2 junctions with a value higher than a
a relative error greater than a thousand, 2 junctions with a value higher than a hundredhundred
and 2 junctions with infinite value due to the fact that the concentration on the IMM was
0.0 mg/L and on the CMM was 0.40 mg/L.
Water 2023, 15, x FOR PEER REVIEW 10 of 22

Water 2023, 15, 4253 and 2 junctions with infinite value due to the fact that the concentration on the IMM10was
of 22

0.0 mg/L and on the CMM was 0.40 mg/L.

Figure 11. Difference in the concentration and the relative error compared to the IMM. Seven nodes
Figure 11. Difference in the concentration and the relative error compared to the IMM. Seven nodes
arenot
are notconsidered
considered here.
here.

2.4. Validation of the Model with a Variable Consumption and Tanks around the Network to Verify
2.4. ValidationConditions
the Stabilized of the Model onwith a Variable and
the Hydraulic Consumption
Quality with andtheTanks around the Network to
IncByPass
Verify the Stabilized Conditions on the Hydraulic and Quality with the IncByPass
The model validation is developed to guarantee that the simulation maintains the
The model
hydraulic validation
and quality is developed
conditions with the to guarantee that
incorporation of thethe simulation
auxiliary maintains
junctions the
and pipes
hydraulic and quality
and the patterns conditions
and controls for thewith
IMM theofincorporation
the S12PE. In this of the auxiliary
validation, thejunctions and
tanks around
pipes and the must
the network patterns and controls
maintain for the IMM
an established cycleofevery
the S12PE.
24 h toInemptying,
this validation, the
filling andtanks
the
around the network
concentration must maintain an established cycle every 24 h to emptying, filling
of the chemical.
and theTheconcentration
scenario of the ofnetworks
the chemical.will remain constant if the hydraulic and quality variables
The scenario of the networks
do not change every 24 h of simulation. will remain
This can constant if thewhen
be verified hydraulicthese and quality do
parameters varia-
not
bles do not
change overchange
time inevery 24 h of simulation.
the following This can beRegarding
days of the simulation. verified when these parameters
the quality parameters,
do
thenot changeand
junctions overtanks
time must
in theinitially
following have days of the simulation.
a specific concentration. Regarding the quality
This concentration
parameters,
must be verifiedthe junctions and tanks
at hour zero, must values
and these initiallywill
have a specific
serve as the concentration.
initial parameters Thisofcon-
the
simulationmust
centration for thebe next quality
verified steps.
at hour zero, and these values will serve as the initial parame-
ters ofThe
thethird network
simulation foristhe
thenext
Net3.net
quality from EPANET (Figure 12), which has 2 reservoirs,
steps.
3 tanks around the network, 2 pumps,
The third network is the Net3.net from EPANET 117 pipes, and 92 nodes—9
(Figure 12), which of them are CJ and
has 2 reservoirs,
3present 1 general
tanks around thepattern
network,and 24 pumps,
specific patterns
117 pipes, of consumption
and 92 nodes—9 in some nodes.
of them areThe
CJ total
and
base demand
present 1 generalis 192 L/s. The
pattern andpipes have patterns
4 specific diameters ofofconsumption
8 to 99 inches, inwith
some65.48
nodes.kmThe
of length;
total
the roughness
base demand is varies
192 from 110 to
L/s. The 199 with
pipes havethe friction loss
diameters of 8calculated
to 99 inches,by the Hazen–Williams
with 65.48 km of
equation.
length; theTo evaluatevaries
roughness the stepsfrom of110
thetoIncByPass
199 with the with variable
friction lossconsumption,
calculated bythe thechemical
Hazen–
concentration is to be injected in two different concentrations
Williams equation. To evaluate the steps of the IncByPass with variable consumption, the from the sources. From the
reservoir on the left, the injected concentration is 5 mg/L, and
chemical concentration is to be injected in two different concentrations from the sources. from the reservoir on the
right,the
From thereservoir
injected concentration
on the left, theisinjected
1 mg/L.concentration is 5 mg/L, and from the reservoir
on theAccording
right, the to the methodology
injected concentration described
is 1 mg/L.in steps 1, 2 and 3, the process involves recog-
nizing the CJ to perform some parameters. Here, a modified network is obtained according
to the presence of CJs and the generation of support matrices, with the information of the
CJs and the mixing cases (ID of nodes and auxiliary pipes and matrix with the hydraulic
behavior of the CJs).
In step 4, the matrices are generated according to the codification of two subroutines
that present the information of the CJ by the Counters and IDs of the CJs and the auxiliary
node indexes and for new pipes in the Bypasses. Then, a support matrix is generated
indicating one of the four types of mixing cases being carried out at the CJ with the
contiguous flow inlets and contiguous flow outlets at the CJs.
Water 2023,
Water 15,15,
2023, 4253
x FOR PEER REVIEW 11 of 11
22of 22

Figure 12. Network Net3.net for the application and validation


Figure 12. validation of
of IncByPass
IncByPass for
forvariable
variableconsump-
consumption.
tion.
The network originally had simulation times that were set as default (Table 2). How-
ever, According to the methodology
since this analysis depends on the described
qualityintime
steps 1, 2(qstep),
step and 3, then
the process involves
the hydraulic steps
recognizing
will be coupledthe CJto to perform
these some
qsteps parameters.
without alteringHere, a modified
its base network Therefore,
performance. is obtained the
according to
simulation the presence
times of CJs and
will be adapted the generation
as follows in Tableof2.support matrices, with the infor-
mation of the CJs and the mixing cases (ID of nodes and auxiliary pipes and matrix with
Table 2. Changebehavior
the hydraulic in calculation
of thetimes
CJs).for application with IncByPass.
In step 4, the matrices are generated according to the codification of two subroutines
Default Values in EPANET Times Modification in
that
Timepresent the information
Parameters in EPANETof the CJ by the Counters and IDs of the CJs and the auxiliary
(h) IncByPass (h)
node indexes and for new pipes in the Bypasses. Then, a support matrix is generated in-
Hydraulic
dicating one of Time Steptypes of mixing cases
the four 1:00
being carried out at the CJ with 0:05the
* contig-
Quality
uous flow Time
inlets andStep
contiguous flow outlets0:05 at the CJs. 0:05
Pattern Time Step 1:00 0:05 *
The network originally had simulation times that were set as default (Table 2). How-
Reporting Time Step 1:00 1:00
ever, since this analysis depends on the quality time step (qstep), then the hydraulic steps
Note: * Values changed by IncByPass.
will be coupled to these qsteps without altering its base performance. Therefore, the sim-
ulation times will be adapted as follows in Table 2.
In the following steps 5 to 7 of the methodology, the main objective is to maintain
simulation every
Table 2. Change 5 min. This
in calculation frequency
times is necessary
for application because the dynamics of chemical
with IncByPass.
concentrations will be handled in the boosters based on the result of the S12PE. The
Default Values in Times Modification in IncBy-
chemical concentrations
Time Parameters at the outlets of the bypasses are simulated in EPANET with
in EPANET
Water 2023, 15, x FOR PEER REVIEW EPANET (h) 12 of 22
patterns associated at the junctions, like a set point booster on the Pass (h)
source quality property
Hydraulic
(Figure 13). Time Step 1:00 0:05 *
Quality Time Step 0:05 0:05
Pattern Time Step 1:00 0:05 *
Reporting Time Step 1:00 1:00
Note: * Values changed by IncByPass.

In the following steps 5 to 7 of the methodology, the main objective is to maintain


simulation every 5 minutes. This frequency is necessary because the dynamics of chemical
concentrations will be handled in the boosters based on the result of the S12PE. The chem-
ical concentrations at the outlets of the bypasses are simulated in EPANET with patterns
associated at the junctions, like a set point booster on the source quality property (Figure
13).

Figure 13. Pattern for concentration on the node Naux189-4 injected like source quality.
Figure 13. Pattern for concentration on the node Naux189-4 injected like source quality.

The multiplier values of the patterns will be adapted according to the number of
times of the qstep (Figure 14). That is, if hstep = 1 h = 3600 s and qstep = 5 min = 300 s, then
the number of times that qstep fits into hstep would be established by Equation (4).
ℎ𝑠𝑡𝑒𝑝
Figure 13. Pattern for concentration on the node Naux189-4 injected like source quality.

The multiplier values of the patterns will be adapted according to the number of
times of the qstep (Figure 14). That is, if hstep = 1 h = 3600 s and qstep = 5 min = 300 s, then
Water 2023, 15, 4253 12 of 22
the number of times that qstep fits into hstep would be established by Equation (4).
ℎ𝑠𝑡𝑒𝑝
𝑛= (4)
The multiplier values of the patterns will be 𝑞𝑠𝑡𝑒𝑝
adapted according to the number of times
of theIn
qstep
this (Figure 14). That
case, n would haveis,aifvalue
hstepof=12,
1 hrepresenting
= 3600 s andtheqstep = 5 min
number = 300as,multiplier
of times then the
number of times that
will be repeated qstep
for each fits into
qstep. hstep would
By repeating eachbeofestablished by Equation
the 24 multipliers (4).(a standard
12 times
24 h simulation pattern), a modified pattern with 288 multipliers in total is generated (Fig-
hstep
ure 14). This process is performed for neach = demand pattern in the network; in Net3.net, (4)
five demand patterns were modified. qstep

Figure 14. Modification of the demand patterns of the network to obtain 288 multipliers
Figure 14. Modification of the demand patterns of the network to obtain 288 multipliers.

The
In thisprocess
case, n of the IncByPass
would explained
have a value in Section 2.1
of 12, representing the is implemented,
number of times and the net-
a multiplier
work
will be changes
repeated itsforname to NET3_INC.inp,
each qstep. and it
By repeating each of identifies the nine12
the 24 multipliers CJs in the
times network.
(a standard
Figure 15 shows an example of the IncByPass for each pipe around a CJ, considering
24 h simulation pattern), a modified pattern with 288 multipliers in total is generated that
the distance of the auxiliary nodes with the CJ is 1 cm. The IncByPass generates
(Figure 14). This process is performed for each demand pattern in the network; in Net3.net, 4 auxiliary
pipes,
five 8 pipes
demand of the bypass,
patterns 4 nodes on the original pipes, and 4 other nodes on the bypass
were modified.
for each CJ.
The process of the IncByPass explained in Section 2.1 is implemented, and the network
changes its name to NET3_INC.inp, and it identifies the nine CJs in the network. Figure 15
shows an example of the IncByPass for each pipe around a CJ, considering that the distance of
Water 2023, 15, x FOR PEER REVIEW 13 of 22
the auxiliary nodes with the CJ is 1 cm. The IncByPass generates 4 auxiliary pipes, 8 pipes of
the bypass, 4 nodes on the original pipes, and 4 other nodes on the bypass for each CJ.

Figure15.
Figure 15.Example
Exampleofofthe
theCJ
CJresulting
resultingfrom
fromthe
theINP
INPcode
codetotoincorporate
incorporatethe
theincomplete
incompletemixing.
mixing.

InInstep
step88ofofthe
themethodology,
methodology,the theperformance
performanceofofthe
thehydraulic
hydraulicandandquality
qualitymodel
modelofof
theoriginal
the originalNET3.inp
NET3.inphas hasbeen
beenmaintained,
maintained,andandaafurther
furthercomparison
comparisonwas wasmade
madebetween
between
theflow
the flowrates
ratesofofthe
thepipes
pipes from
from thethe sources
sources (Figure
(Figure 16)16)
andand of the
of the level
level in the
in the three
three tanks
tanks of
of the network with the NET3_INC.net (Figure 17). The simulation was modified accord-
ing to the time options for the Hydraulic Step and Time Reporting Step to 5 min for both,
and the Total Time Simulation, with 10 days of simulation, could observe the preservation
of the hydraulic with the IncByPass.
Figure 15. Example of the CJ resulting from the INP code to incorporate the incomplete mixing.
Water 2023, 15, 4253 13 of 22
In step 8 of the methodology, the performance of the hydraulic and quality model of
the original NET3.inp has been maintained, and a further comparison was made between
the flow rates of the pipes from the sources (Figure 16) and of the level in the three tanks
the network
of the with
network withthethe
NET3_INC.net
NET3_INC.net(Figure
(Figure17).
17).The
Thesimulation
simulation was modified
modifiedaccord-
according
toing
thetotime options
the time for the
options Hydraulic
for the Step
Hydraulic andand
Step Time Reporting
Time Step
Reporting toto5 5min
Step minfor
forboth,
both,and
the
andTotal TimeTime
the Total Simulation, with
Simulation, 10 days
with of of
10 days simulation,
simulation,could
couldobserve
observe the preservation of
the preservation
the hydraulic
of the with
hydraulic thethe
with IncByPass.
IncByPass.

Water 2023, 15, x FOR PEER REVIEWFigure 16. Comparison between NET3.net and Net3_INC.net for flow rate for three pipes (furthest
14 of 22
Figure 16. Comparison between NET3.net and Net3_INC.net for flow rate for three pipes (furthest
from the sources).
from the sources).

Figure17.
Figure 17.Comparison
Comparisonof
ofthe
thepressure
pressureinintanks
tanks1,1,22and
and33ofofthe
theNET3.net
NET3.netand
andNET3_INC.net.
NET3_INC.net.

Forstep
For step9 9ofofthe
the methodology,
methodology, Figure
Figure 18 shows
18 shows a numerical
a numerical comparison
comparison of theof therates
flow flow
atrates
the at thehour
final finalof hour
the of the simulation
simulation (hourall
(hour 240); 240);
the all therates
flow floware
rates are conserved
conserved in the
in the same
same proportion.
proportion. These verifications
These verifications corroborate
corroborate that the modification
that the modification by these does
by these bypasses bypasses
not
does the
affect nothydraulic
affect the functionality
hydraulic functionality and
and that they canthat they cantobe
be applied applied
control to control
incomplete incom-
mixing.
plete mixing.
Figure 17. Comparison of the pressure in tanks 1, 2 and 3 of the NET3.net and NET3_INC.net.

For step 9 of the methodology, Figure 18 shows a numerical comparison of the flow
rates at the final hour of the simulation (hour 240); all the flow rates are conserved in the
same proportion. These verifications corroborate that the modification by these bypasses
Water 2023, 15, 4253 14 of 22
does not affect the hydraulic functionality and that they can be applied to control incom-
plete mixing.

Figure18.
Figure 18. Comparison
Comparisonat
atthe
theend
endtime
timeof
of10
10days
daysof
offlow
flowrates
ratesof
ofsome
somepipes
pipesand
andits
itsabsolute
absoluteerror.
error.

Finally,at
Finally, atthe
theend
endofofstep
step9,9,the
theresulting
resultingprocess
processfrom
fromthetheIncByPass
IncByPassisisthatthatcontrols
controls
are generated
are generated in in the
the pipelines
pipelines around
around thethe nodes
nodes toto specify
specify when
when thethe bypasses
bypasses are are open
open
during
duringthe
thesimulation.
simulation. ForFor example,
example, at at the
the CJ
CJ 119
119 (Figure
(Figure 19),
19), from
from hour
hour 16,
16, the
the inlets
inlets are
are
the
the pipes
pipes Taux119-2
Taux119-2 and and Taux119-4,
Taux119-4, andand the
the outlets
outlets are
are the
the bypasses
bypasses 119-1
119-1 aa and
and b,b, and
and
Water 2023, 15, x FOR PEER REVIEW 15 of 22
119-3
119-3aaand
andb. b. The
The value
value 1.0000
1.0000 can
can be
be seen
seen in
in the
the third
third column
column of of the
the control
control when
when the the
status
statusof
ofthe
thepipe
pipeisisopen,
open,and
andthe
thevalue
valueof of0.0000
0.0000when
whenthe thestatus
statusisisclosed.
closed.

Figure19.
Figure 19.Controls
Controlsfor
forthe
theactivation
activationofofthe
thepipes
pipesatatthe
theCJ
CJ119.
119.

Afterverifying
After verifyingthe
thehydraulic
hydraulicconstant
constantconditions
conditionsfor forthe
theIncByPass,
IncByPass,thethequality
qualitymodel
model
isisevaluated
evaluatedto toshow
showthethecomparison
comparisonbetween
between the
theconcentration
concentration of of the
thetanks
tanksalong
alongthe
the
network(Figure
network (Figure20).
20).In
Inthis
thiscase,
case,the
thesimulation
simulationrequires
requiresmoremorethan
than4040days
daystotoobtain
obtainthe
the
constantconcentration
constant concentrationononthethe tanks
tanks forfor
thethe complete
complete mixing.
mixing. It could
It could be observed
be observed that
that tank
2tank
is the2 most
is theaffected
most affected by the model
by the mixing mixingatmodel
the CJ.atInthe
thisCJ. In this 10%
network, network,
of the10% of the
junctions
junctions
have have two
two inlets and inlets and two
two outlets, andoutlets, and of
the effect thethe
effect of the
mixing at mixing
the CJ isatminimal.
the CJ is minimal.
After verifying the hydraulic constant conditions for the IncByPass, the quality model
is evaluated to show the comparison between the concentration of the tanks along the
network (Figure 20). In this case, the simulation requires more than 40 days to obtain the
Water 2023, 15, 4253
constant concentration on the tanks for the complete mixing. It could be observed that
15 of 22
tank 2 is the most affected by the mixing model at the CJ. In this network, 10% of the
junctions have two inlets and two outlets, and the effect of the mixing at the CJ is minimal.

Figure20.
Figure 20.Concentration
Concentrationinintanks
tanksand
andaacomparison
comparisonbetween
betweenthe
thetwo
twomixing
mixingmodels.
models.

Finally,after
Finally, afterthe
thevalidations
validationsofofthe
themethodology
methodologyfor forthe
theconstant
constantconsumption
consumptionand and
theconstant
the constant conditions for the thehydraulics
hydraulicsand
andchemical
chemicalconcentration,
concentration, a description
a descriptionof the
of
results
the of the
results IncByPass
of the for for
IncByPass the the
scenarios considering
scenarios a variation
considering on the
a variation on consumption
the consumption dur-
ing 24 h24for
during a scenario
h for of network
a scenario of networkwithwith
a high quantity
a high of CJs
quantity ofand
CJs aand
realacase
real for the
case quan-
for the
tification of the
quantification of differences of the
the differences of CMM and and
the CMM the IMM are provided
the IMM in this
are provided research.
in this research.

3.3.Results
Results
Water 2023, 15, x FOR PEER REVIEW The 16 first
of 22
Theresults
resultsare
aredescribed
describedwith
withthe
theapplication
applicationofofthe
theIncByPass
IncByPassfor
fortwo
twocases.
cases.The
The first
case
caseisisaanetwork
networkwith
withaahigh
highquantity
quantityofofCJ,
CJ,and
andthe
thesecond
secondcase
caseisisan
anadapted
adaptedsector
sectorof of
downtown
downtownRomita,
Romita,México.
México.
3.1. Network with a High Quantity of CJs
3.1. Network with a High Quantity of CJs
This network is based on [48], where the network has two reservoirs, 961 nodes, 843
This network is based on [48], where the network has two reservoirs, 961 nodes, 843
of which are CJ, and 1862 pipes, which are practically 88% of the nodes. The simulation is
of which are CJ, and 1862 pipes, which are practically 88% of the nodes. The simulation is
made with constant demand. The injected concentration is 1.6 mg/L for the upper reser-
made with constant demand. The injected concentration is 1.6 mg/L for the upper reservoir
voir and 0.8 mg/L for the left one. This specific scenario has reaction coefficients of −0.327
and 0.8 mg/L for the left one. This specific scenario has reaction coefficients of −0.327 for
for the bulk and −0.195 for the wall. The diverse variation of the chemical across the pipes
the bulk and −0.195 for the wall. The diverse variation of the chemical across the pipes
is shown in Figure 21. The five junctions with a major difference in concentration are iden-
is shown in Figure 21. The five junctions with a major difference in concentration are
tified in the rectangular zone of the network (Figure 21a).
identified in the rectangular zone of the network (Figure 21a).

Figure 21.Comparison
Figure21. Comparisonbetween
betweenEPANET
EPANETmixing
mixing(a)
(a)and
andIMM
IMMofof843
843CJs
CJs(b).
(b).

The
Thesimulation
simulationwas
wasdeveloped
developed considering
considering aa constant
constant demand
demand withwith reaction
reaction coeffi-
coeffi-
cients
cients to obtain a diverse case of analysis and visualize the effect of the reaction ofthe
to obtain a diverse case of analysis and visualize the effect of the reaction of the
chemical
chemicalalong
alongthe
thenetwork.
network.The
Thejunctions
junctionsthat
thatpresent
presenthigher
higherdifferences
differencesininconcentration
concentration
are
areshown
shown inin Figure 22. The
Figure 22. Themajor
majordifference
differenceinin concentration
concentration was
was on on
nodenode
863,863,
withwith
0.29
0.29 mg/L, representing a relative difference of 26%.
mg/L, representing a relative difference of 26%.
Figure 21. Comparison between EPANET mixing (a) and IMM of 843 CJs (b).

The simulation was developed considering a constant demand with reaction coeffi-
cients to obtain a diverse case of analysis and visualize the effect of the reaction of the
Water 2023, 15, 4253 chemical along the network. The junctions that present higher differences in concentration
16 of 22
are shown in Figure 22. The major difference in concentration was on node 863, with 0.29
mg/L, representing a relative difference of 26%.

Figure 22. Junctions with major differences of concentration in the network of 843 CJs.
Figure 22. Junctions with major differences of concentration in the network of 843 CJs.

According to
According to the
the analysis
analysis of
of the
the concentrations
concentrations at
at the
the 961
961 junctions,
junctions, 8%
8% of
of the
the junctions
junc-
tions have differences between 0.15 and 0.29 mg/L (Figure 23). Most of
have differences between 0.15 and 0.29 mg/L (Figure 23). Most of the junctions the junctions havehave
differences between 0.14 and 0.05 mg/L, representing 67% of the junctions, and 25%
differences between 0.14 and 0.05 mg/L, representing 67% of the junctions, and 25% of the of the
junctions have a difference of less than 0.04 mg/L. The relative difference regarding the the
Water 2023, 15, x FOR PEER REVIEW junctions have a difference of less than 0.04 mg/L. The relative difference regarding 17 of 22
IMM shows that the greater difference is 54%, and the mean relative difference is 14%,
IMM shows that the greater difference is 54%, and the mean relative difference is 14%, with
with a standard deviation of 0.0874.
a standard deviation of 0.0874.

Figure23.
Figure Differenceofofthe
23.Difference theconcentration
concentrationand
andrelative
relativeerror
errorin
inthe
thenetwork
networkof
of843
843CJs.
CJs.

In this network, with the scenario of reaction coefficients and specific location of
In this network, with the scenario of reaction coefficients and specific location of
sources, the difference in concentration shows that the CMM of EPANET maximizes
sources, the difference in concentration shows that the CMM of EPANET maximizes the
the concentration of a chemical. In the case where the CMM is used for simulations of
concentration of a chemical. In the case where the CMM is used for simulations of disin-
disinfectants like chlorine, this maximization affects the establishment of the concentration
fectants like chlorine, this maximization affects the establishment of the concentration in-
injected at the sources.
jected at the sources.
3.2. Network Based in Romita Downtown in Guanajuato State in México
3.2. Network Based in Romita Downtown in Guanajuato State in México
The second case is a network based in a sector of downtown Romita in México. Accord-
The
ing to second
[49], case is a network
the population registeredbased incity’s
in the a sector of downtown
water supply system Romita in México.
is 31,066 Ac-
inhabitants.
cording to [49], the population registered in the city’s water supply
The network was adapted to use in this research. The network has two reservoirs near system is 31,066 in-
habitants.
them to show The network was adapted
another case differentto use the
from in this
caseresearch.
in SectionThe network
3.1. has twoinjected
The chemical reser-
voirs
fromnear them at
the tanks tothe
showleftanother case of
and bottom different from the
the network is 1case
and in Sectionrespectively.
5 mg/L, 3.1. The chemical
In this
injected from
case, there the
are notanks at thereactions.
chemical left and bottom of the network
The network is 1 and
has 143 pipes 5 mg/L,
with 14.22respectively.
km of length
In this
and 81case, there are
junctions, nowhich
46 of chemical reactions.
are CJ, Theone
and it has network
generalhaspattern
143 pipes with 14.22 km
of consumption withof
length and 81 junctions, 46 of which are CJ, and it has one general pattern
multipliers varying between 0.606 and 1.372. The total demand simulated in the network of consumption
with multipliers
is 60.75 l/s. Thevarying
pipes arebetween 0.606
3, 4 and and 1.372.
6 inches The totalwith
in diameter, demand
140 simulated
and 150 pipe in the net-
friction
work is 60.75for
coefficients l/s.the
TheHazen–Williams
pipes are 3, 4 andequation.
6 inches in diameter,
After with 140 and
the simulation of the150 pipe friction
IncByPass, the
coefficients
results of the forchemical
the Hazen–Williams
concentrationequation.
on pipes areAfter the simulation
shown of In
in Figure 24. thethis
IncByPass,
Figure, a the
less
results of the chemical concentration on pipes are shown in Figure 24. In this Figure, a less
extreme concentration on the CMM could be observed. Also, the junction numbers in the
network (a) are those with major difference concentrations respecting the IMM.
voirs near them to show another case different from the case in Section 3.1. The chemical
injected from the tanks at the left and bottom of the network is 1 and 5 mg/L, respectively.
In this case, there are no chemical reactions. The network has 143 pipes with 14.22 km of
length and 81 junctions, 46 of which are CJ, and it has one general pattern of consumption
with multipliers varying between 0.606 and 1.372. The total demand simulated in the net-
Water 2023, 15, 4253 17 of 22
work is 60.75 l/s. The pipes are 3, 4 and 6 inches in diameter, with 140 and 150 pipe friction
coefficients for the Hazen–Williams equation. After the simulation of the IncByPass, the
results of the chemical concentration on pipes are shown in Figure 24. In this Figure, a less
extreme
extremeconcentration
concentrationononthe
theCMM
CMMcouldcouldbe
beobserved.
observed.Also,
Also,the
thejunction
junctionnumbers
numbersin inthe
the
network
network(a)(a)are
arethose
thosewith
withmajor
majordifference
differenceconcentrations
concentrationsrespecting
respectingthe
theIMM.
IMM.

Figure24.
Figure
Water 2023, 15, x FOR PEER REVIEW 24.Comparison
Comparisonbetween
betweenEPANET
EPANETmixing
mixingand
andIMM
IMMininRomita.net.
Romita.net. 18 of 22

The
Thesimulation
simulationwas wasmade
made considering
considering a variable
a variabledemand
demandconsumption.
consumption.However, the
However,
concentration
the concentrationof theofchemical is maintained
the chemical constant
is maintained due todue
constant the reaction coefficient
to the reaction being
coefficient
being
zero zero during
during this simulation.
this simulation. Also, theAlso, the consumption
consumption flowinvaries
flow varies in the
the same same propor-
proportion due
totion
onedue to one
pattern forpattern for all the consumption
all the consumption junctions, andjunctions,
the flowand the flow
direction ondirection
the pipeson the
does
pipes
not doesduring
change not change during the
the simulation simulation
time. time. The
The junctions that junctions that present
present a higher a higher
concentration
concentration
difference difference
are shown are shown
in Figure 25. The in chemical
Figure 25.concentration
The chemicalobtains
concentration obtains
a constant valuea
constant
after 5 h ofvalue after 5 h
simulation forofthe
simulation
CMM. Infor thethe CMM.
case InIMM,
of the the case
theofIncByPass
the IMM,generates
the IncByPass
the
generates
scenario thestabilized
with scenario with stabilized
conditions conditions
for the beginningforof
the beginning
the simulation.of the simulation.

Figure 25. Junctions with major differences of concentration in the Romita network.
Figure 25. Junctions with major differences of concentration in the Romita network.

InFigure
In Figure26,26,the
thedifference
differencebetween
betweenthe thetwo
twomixing
mixingprocedures
proceduresisisshown.
shown.According
According
totothe
theanalysis
analysisofofthetheconcentrations
concentrationsatatthethe81
81junctions,
junctions,28.4%
28.4%ofofthe
thejunctions
junctionshave
havevalues
values
between1.03
between 1.03toto0.09
0.09mg/L,
mg/L,a ahigher
higherconcentration
concentration is is obtained
obtained byby
thethe CMM,
CMM, withwith a range
a range of
91ofto
918%to 8% of relative
of relative error,
error, andand 50.6%
50.6% of the
of the junctions
junctions have have an absolute
an absolute relative
relative difference
difference of
5%of with
5% withmoremore concentration
concentration untiluntil 0.09 mg/L.
0.09 mg/L. Finally,
Finally, 21% of21%
theofjunctions
the junctions
have ahave a re-
reduced
duced concentration of between 1.22 and 0.27 mg/L, with a range of 23
concentration of between 1.22 and 0.27 mg/L, with a range of 23 to 7% relative error. Theto 7% relative error.
The mean
mean relative
relative difference
difference is with
is 12%, 12%, awith a standard
standard deviation
deviation of 0.1931.
of 0.1931.
In this network, without the scenario of reaction coefficient, the difference in con-
centration shows that the CMM of EPANET in some zones of the network minimizes the
concentration of the chemical. However, generally, the CMM tends to uniformize concen-
tration. The accuracy of models in designing monitoring sensors to detect pollutant events
could be affected by this tendency to uniformize the CMM of EPANET. The proposed IMM
obtained by IncByPass is a validated and more realistic alternative to follow solutions for
the quality models in water networks.
In Figure 26, the difference between the two mixing procedures is shown. According
to the analysis of the concentrations at the 81 junctions, 28.4% of the junctions have values
between 1.03 to 0.09 mg/L, a higher concentration is obtained by the CMM, with a range
of 91 to 8% of relative error, and 50.6% of the junctions have an absolute relative difference
of 5% with more concentration until 0.09 mg/L. Finally, 21% of the junctions have a re-
Water 2023, 15, 4253
duced concentration of between 1.22 and 0.27 mg/L, with a range of 23 to 7% relative 18 of 22
error.
The mean relative difference is 12%, with a standard deviation of 0.1931.

Figure 26.
Figure Difference of
26. Difference of the
the concentration
concentration and
and relative
relative error
error in
in the
the Romita
Romita network.
network.

4. Discussion and Conclusions


In this network, without the scenario of reaction coefficient, the difference in concen-
trationIn shows
summary,
thatthe main
the CMMaspects of the proposed
of EPANET in somecode,
zonesIncByPass, are as follows:
of the network (a) Iden-
minimizes the
tifying the CJs in the network, as well as their properties, like IDs, connections, infras-
concentration of the chemical. However, generally, the CMM tends to uniformize concen-
tructure and their hydraulic operability; (b) the code that modifies the network, adding
tration. The accuracy of models in designing monitoring sensors to detect pollutant events
nodes and accessory pipes that allow concentration control at the identified crossings;
could be affected by this tendency to uniformize the CMM of EPANET. The proposed
(c) the generation of Patterns associated to the nodes at the outlets of the CJ, where the
IMM obtained by IncByPass is a validated and more realistic alternative to follow solu-
concentration is obtained by the IMM with the S12PE for each quality time interval, qstep
tions for the quality models in water networks.
(normally of 5 min); (d) a network is obtained in INP format for further simulation and
analysis, using the EPANET.
EPANET has demonstrated performance issues during extended simulations under
slow flow variations, leading to oscillations and instabilities, particularly in scenarios
with multiple tanks in the network. In response to these challenges, Ref. [50] proposed
a methodology utilizing the Global Gradient Algorithm (GGA) for unsteady problems
involving variable tank heads. However, this approach introduced numerical problems
and oscillations, impacting the accuracy of the simulations. Although a patch released
on 18 May 2020 addressed accuracy bugs related to tanks in EPANET, a fundamental
problem persists. In this model, mixing at tanks considers a long period simulation of
248 h to stabilize quality conditions at tanks; further hours showed no changes in quality
parameters in the tanks.
The ongoing challenge with EPANET and many existing approaches lies in the absence
of cross terms, such as the space derivative of the head in mass balance equations and
the time derivative of volume in momentum equations. This leads to a separation of
the integration of mass balance equations in time from the integration in the space of
momentum equations, as highlighted by [51].
The software tool known as IncByPass affords users an alternative approach to calculat-
ing water quality within the context of the EPANET modeling framework. This alternative
approach is underpinned by a proposed mixing model, which has been demonstrated in
prior research to enhance the precision of concentration predictions in comparison to the
default model employed by EPANET.
Utilizing IncByPass allows users to gain the capacity to seamlessly integrate their
water quality calculations with EPANET, avoiding the cumbersome file downloading
and import/export processes often associated with alternative software solutions. It is
important to note that the utilization of IncByPass ensures that water distribution networks
remain unaffected hydraulically, as confirmed through validation exercises involving both
constant and variable consumption scenarios. This unaltered hydraulic integrity engenders
a heightened level of trustworthiness in the ensuing water quality analyses.
Water 2023, 15, 4253 19 of 22

The computational resources required for generating the IMM files exhibit significant
time variability depending on the complexity of hydraulic networks. The measure of the
time was made with the integrated function in MATLAB R2018b tic and toc. However, it
used a system equipped with a 3.7 GHz processor, 5.5 GB RAM, and a 127 GB solid-state
drive. These hardware specifications played a crucial role in the performance and the time
required to obtain results. For relatively simple networks with a few CJs examples, the
process can be completed within seconds, whereas for more intricate networks, such as
the one incorporating 843 CJs components, it may extend to up to 10 h. It is noteworthy
that the variability in result generation time is directly associated with the number of CJ
components in the networks and the technical specifications of the utilized equipment.
This time span encompasses various tasks, including network modification, step-by-step
simulation, identification of mixing instances, control and pattern generation for integration
into EPANET, and determination of initial concentrations to establish a representative
model from the outset. Notably, the most intricate network, denoted as “net3,” which
encompasses dual sources, pump controls, multiple storage tanks, diverse usage patterns,
and 20% of nodes featuring CJ elements, underscores the disparities between the EPANET
and IncByPass mixing models. It is imperative to compare the results following a specific
number of days to attain a state of cyclic water quality behavior and discern the disparities
within the final 24 h of consumption. During this validation process, it becomes evident that
more than 40 days are requisite for the tank concentrations to stabilize at a consistent level.
It is significant to emphasize that the disparities between the mixing models of
EPANET and IncByPass can exceed a relative error of 90% in certain locations. In both cases,
under varying conditions, the concentration trends established by IncByPass circumvent
the attainment of averaged concentrations that could otherwise lead to network homogene-
ity. The IncByPass model introduces the IMM, which furnishes an alternative approach to
visualizing the simulation of disinfectant distribution within the network and aids in the
strategic placement of sensors for pollutant detection. This capability significantly enhances
the accuracy and efficacy of pertinent studies in this domain.
The outcomes are made attainable through the implementation of a software program
named IncByPass, which has been meticulously crafted to facilitate water quality simula-
tion, accounting for incomplete mixing within the EPANET framework. Importantly, this
tool leverages the EPANET-MATLAB toolkit [52], a comprehensive collection of program-
ming functions tailored to the EPANET programming environment, thereby streamlining
the process of incorporating IncByPass into existing workflows.

Author Contributions: Conceptualization, D.H.C., J.A.A.N. and J.M.R.; methodology, D.H.C., J.A.A.N.
and J.M.R.; software, D.H.C.; validation, D.H.C., J.D.P.S. and J.M.R.; formal analysis, D.H.C., J.A.A.N.,
H.M.R., X.D.G. and J.M.R.; investigation, D.H.C.; resources, J.A.A.N., H.M.R., X.D.G. and J.M.R.; data
curation, D.H.C., J.D.P.S. and J.M.R.; writing—D.H.C. and J.M.R.; original draft preparation, D.H.C.
and J.M.R.; writing—review and editing, J.A.A.N., H.M.R., X.D.G., J.D.P.S. and J.M.R.; visualization,
J.D.P.S. and J.M.R.; supervision, J.A.A.N., H.M.R. and X.D.G.; project administration, J.M.R.; funding
acquisition, H.M.R., X.D.G. and J.M.R. All authors have read and agreed to the published version of
the manuscript.
Funding: The authors would like to thank CERIS for the funding support through the Foundation
for Science and Technology through the funding UIDB/04625/2020, EAPA_0001/2022—HY4RES
and the opportunity to develop this research.
Data Availability Statement: Data is contained within the article.
Acknowledgments: Water System Supply of Romita and Comisión Estatal del Agua of Guanajuato
for sharing information for academic projects. Acknowledgment for the scholarship of CONAHCYT
for the first and fifth authors and the SNI of CONAHCYT for the fourth and sixth authors.
Conflicts of Interest: The authors declare no conflict of interest.
Water 2023, 15, 4253 20 of 22

References
1. Rossman, L.A. EPANET 2. User’s Manual; US Environmental Protection Agency: Cincinnati, OH, USA, 2000; p. 200. Available
online: http://nepis.epa.gov/Adobe/PDF/P1007WWU.pdf (accessed on 7 December 2023).
2. Van Bloemen, W.B.; Hammond, G.; Shadid, J.; Collis, S.; Murray, R. A comparison of Navier-Stokes and network models to predict
chemical transport in municipal water distribution systems. In Proceedings of the World Water and Environmental Resources
Congress. Impacts of Global Climate Change, Anchorage, AK, USA, 15–19 May 2005. [CrossRef]
3. Webb, S.W. High-fidelity simulation of the influence of local geometry on mixing in crosses in water distribution systems. In
Proceedings of the ASCE World Water & Environmental Resources Congress, Tampa, FL, USA, 15–19 May 2007. [CrossRef]
4. Romero-Gomez, P.; Ho, C.K.; Choi, C.Y. Mixing at cross junctions in water distribution systems. I: Numerical study. J. Water
Resour. Plan. Manag. 2008, 134, 285–294. [CrossRef]
5. Ho, C.K.; Khalsa, S.S. EPANET-BAM: Water quality modeling with incomplete mixing in pipe junctions. In Proceedings of the
Water Distribution Systems Analysis, Kruger National Park, South Africa, 17–20 August 2008.
6. Song, I.; Romero-Gomez, P.; Choi, C.Y. Experimental verification of incomplete solute mixing in a pressurized pipe network with
multiple cross junctions. J. Hydraul. Eng. 2009, 135, 1005–1011. [CrossRef]
7. Andrade, M.A.; Rojano, F.; Romero-Gomez, P.; Choi, C.Y. Integrated water quality modeling of water distribution systems. In
Proceedings of the Water Distribution Systems Analysis, Tucson, AZ, USA, 12–15 September 2010. [CrossRef]
8. Liu, H.; Yuan, Y.; Zhao, M.; Zheng, X.; Lu, J.; Zhao, H. Study of Mixing at Cross Junction in Water Distribution Systems Based on
Computational Fluid Dynamics. In Proceedings of the ICPTT 2011: Sustainable Solutions for Water, Sewer, Gas, and Oil Pipelines,
Beijing, China, 26–29 October 2011. [CrossRef]
9. Yu, T.C.; Shao, Y.; Shen, C. Mixing at cross joints with different pipe sizes in water distribution systems. J. Water Resour. Plan.
Manag. 2014, 140, 658–665. [CrossRef]
10. Shao, Y.; Yang, Y.J.; Jiang, L.; Yu, T.; Shen, C. Experimental testing and modeling analysis of solute mixing at water distribution
pipe junctions. Water Res. 2014, 56, 133–147. [CrossRef] [PubMed]
11. Mompremier, R.; Pelletier, G.; Mariles, Ó.A.F.; Ghebremichael, K. Impact of incomplete mixing in the prediction of chlorine
residuals in municipal water distribution systems. J. Water Supply Res. Technol.—AQUA 2015, 64, 904–914. [CrossRef]
12. Hernández-Cervantes, D.; Delgado-Galván, X.; Nava, J.L.; López-Jiménez, P.A.; Rosales, M.; Mora Rodríguez, J. Validation of a
computational fluid dynamics model for a novel residence time distribution analysis in mixing at cross-junctions. Water 2018, 10, 733.
[CrossRef]
13. McKenna, S.A.; O’Hern, T.; Hartenberger, J. Detailed investigation of solute mixing in pipe joints through high speed photography.
In Proceedings of the Water Distribution Systems Analysis, Kruger National Park, South Africa, 17–20 August 2008. [CrossRef]
14. Ho, C.K.; O’Rear, L., Jr. Evaluation of solute mixing in water distribution pipe junctions. J. Am. Water Work. Assoc. 2009, 101,
116–127. [CrossRef]
15. Choi, C.Y.; Shen, J.Y.; Austin, R.G. Development of a comprehensive solute mixing model (AZRED) for double-tee, cross, and wye
junctions. In Proceedings of the Water Distribution Systems Analysis, Kruger National Park, South Africa, 17–20 August 2008.
[CrossRef]
16. Rossman, L.A. An overview of EPANET version 3.0. In Proceedings of the Water Distribution Systems Analysis, Tucson, AZ,
USA, 12–15 September 2010. [CrossRef]
17. Hernández Cervantes, D.; López-Jiménez, P.A.; Arciniega, N.J.A.; Delgado, G.X.; Jiménez, M.M.R.; Pérez-Sánchez, M.; Mora, R.J.
Incomplete mixing model at cross-junctions in EPANET by polynomial equations. Water 2021, 13, 453. [CrossRef]
18. Hernández, C.D.; Mora, R.J.; Delgado, G.X.; Ortiz, M.J.; Jiménez, M.M.R. Optimal use of chlorine in water distribution networks
based on specific locations of booster chlorination: Analyzing conditions in Mexico. Water Sci. Techol. 2016, 16, 493–505. [CrossRef]
19. Ewald, G.; Zubowicz, T.; Brdys, M.A. Multiprocessor implementation of parallel multiobjective genetic algorithm for optimized
allocation of chlorination stations in drinking water distribution system-a new water quality model approach. IFAC Proc. Vol.
2013, 46, 123–128. [CrossRef]
20. Meng, F.; Liu, S.; Auckenthaler, P.; Bai, L.; Wang, H.; Wu, X. Optimization of booster disinfection with backtracking algorithm. In
Proceedings of the 1st International Conference on Consumer Electronics, Communications and Networks (CECNet), Xianning,
China, 16–18 April 2011. [CrossRef]
21. Hongxiang, W.; Wenxian, G.; Jianxin, X.; Hongmei, G. A hybrid PSO for optimizing locations of booster chlorination stations
in water distribution systems. In Proceedings of the International Conference on Intelligent Computation Technology and
Automation Changsha, Changsha, China, 11–12 May 2010. [CrossRef]
22. Drewa, M.; Brdys, M.A. Optimized allocation of chlorination stations for integrated quantity and quality control in drinking
water distribution systems. IFAC Proc. Vol. 2007, 40, 73–78. [CrossRef]
23. Kurek, W.; Brdys, M.A. Optimised allocation of chlorination stations by multi-objective genetic optimisation for quality control in
drinking water distribution systems. IFAC Proc. Vol. 2006, 39, 232–237. [CrossRef]
24. Alcocer-Yamanaka, V.H.; Tzatchkov, V.G.; Arreguín-Cortés, F.I. Modelo de calidad del agua en redes de distribución. Ing. Hidraul.
Mex. 2004, 19, 77–88. Available online: http://repositorio.imta.mx/handle/20.500.12013/743 (accessed on 7 December 2023).
Water 2023, 15, 4253 21 of 22

25. Afzali, A.S.; Jafari-Asl, J.; Banifakhr, E.; Houssein, E.H.; Ben Seghier, M.E.A. Risk-Based Design Optimization of Contamination
Detection Sensors in Water Distribution Systems: Application of an Improved Whale Optimization Algorithm. Water 2023, 15, 2217.
[CrossRef]
26. Piazza, S.; Sambito, M.; Freni, G. Analysis of optimal sensor placement in looped water distribution networks using different
water quality models. Water 2023, 15, 559. [CrossRef]
27. Brentan, B.M.; Carpitella, S.; Izquierdo, J.; Montalvo, I. Multi-objective, rule and preference-based placement of quality sensors in
water supply networks. IFAC-Pap. 2022, 55, 482–489. [CrossRef]
28. Tsitsifli, S.; Kanakoudis, V. Identification of Suitable Locations in a Small Water Supply Network for the Placement of Water
Quality Sensors Based on Different Criteria under Demand-Driven Conditions. Water 2022, 14, 2504. [CrossRef]
29. Marlim, M.S.; Kang, D. Optimal water quality sensor placement by accounting for possible contamination events in water
distribution networks. Water 2021, 13, 1999. [CrossRef]
30. Nikolopoulos, D.; Ostfeld, A.; Salomons, E.; Makropoulos, C. Resilience assessment of water quality sensor designs under
cyber-physical attacks. Water 2021, 13, 647. [CrossRef]
31. Shahra, E.Q.; Wu, W.; Gomez, R. Human Health Impact Analysis of Contaminant in IoT-Enabled Water Distributed Networks.
Appl. Sci. 2021, 11, 3394. [CrossRef]
32. Ciaponi, C.; Creaco, E.; Di Nardo, A.; Di Natale, M.; Giudicianni, C.; Musmarra, D.; Santonastaso, G.F. Reducing impacts of
contamination in water distribution networks: A combined strategy based on network partitioning and installation of water
quality sensors. Water 2019, 11, 1315. [CrossRef]
33. Nono, D.; Basupi, I. Robust booster chlorination in water distribution systems: Design and operational perspectives under
uncertainty. J. Water Supply Res. Technol.—AQUA 2019, 68, 399–410. [CrossRef]
34. Palleti, V.R.; Kurian, V.; Narasimhan, S.; Rengaswamy, R. Actuator network design to mitigate contamination effects in water
distribution networks. Comput. Chem. Eng. 2018, 108, 194–205. [CrossRef]
35. Taormina, R.; Galelli, S.; Tippenhauer, N.O.; Salomons, E.; Ostfeld, A.; Eliades, D.G.; Aghashahi, M.; Sundararajan, R.; Pourahmadi,
M.; Banks, M.K.; et al. Battle of the attack detection algorithms: Disclosing cyber attacks on water distribution networks. J. Water
Resour. Plan. Manag. 2018, 144, 04018048. [CrossRef]
36. Xuesong, Y.; Jie, S.; Chengyu, H. Research on contaminant sources identification of uncertainty water demand using genetic
algorithm. Clus Comp. 2017, 20, 1007–1016. [CrossRef]
37. Rathi, S.; Gupta, R. Optimal sensor locations for contamination detection in pressure-deficient water distribution networks using
genetic algorithm. Urban Water J. 2017, 14, 160–172. [CrossRef]
38. Rathi, S.; Gupta, R. A simple sensor placement approach for regular monitoring and contamination detection in water distribution
networks. KSCE J. Civ. Eng. 2016, 20, 597–608. [CrossRef]
39. Zeng, D.; Gu, L.; Lian, L.; Guo, S.; Yao, H.; Hu, J. On cost-efficient sensor placement for contaminant detection in water distribution
systems. IEEE Trans. Industr Inform. 2016, 12, 2177–2185. [CrossRef]
40. Rathi, S.; Gupta, R. A critical review of sensor location methods for contamination detection in water distribution networks.
Water Qual. Res. J. Canada 2015, 50, 95–108. [CrossRef]
41. Di Nardo, A.; Di Natale, M.; Musmarra, D.; Santonastaso, G.F.; Tzatchkov, V.; Alcocer-Yamanaka, V.H. A district sectorization for
water network protection from intentional contamination. Procedia Eng. 2014, 70, 515–524. [CrossRef]
42. Rathi, S.; Gupta, R. Monitoring stations in water distribution systems to detect contamination events. ISH J. Hydraul. Eng. 2014,
20, 142–150. [CrossRef]
43. Schwartz, R.; Lahav, O.; Ostfeld, A. Integrated hydraulic and organophosphate pesticide injection simulations for enhancing
event detection in water distribution systems. Water Res. 2014, 63, 271–284. [CrossRef] [PubMed]
44. Alvisi, S.; Franchini, M.; Gavanelli, M.; Nonato, M. Near-optimal scheduling of device activation in water distribution systems to
reduce the impact of a contamination event. J. Hydroinform. 2012, 14, 345–365. [CrossRef]
45. Janke, R.; Murray, R.; Haxton, T.M.; Taxon, T.; Bahadur, R.; Samuels, W.; Morley, K. Threat Ensemble Vulnerability Assessment-Sensor
Placement Optimization Tool (TEVA-SPOT) Graphical User Interface User’s Manual; US EPA National Homeland Security Research
Center (NHSRC): Cincinnati, OH, USA, 2012; p. 115. Available online: https://cfpub.epa.gov/si/si_public_record_report.cfm?
Lab=NHSRC&subject=Homeland%20Security%20Research&dirEntryId=257684 (accessed on 7 December 2023).
46. Weickgenannt, M.; Kapelan, Z.; Blokker, M.; Savic, D.A. Risk-based sensor placement for contaminant detection in water
distribution systems. J. Water Res. Plan. Man. 2010, 136, 629–636. [CrossRef]
47. Preis, A.; Ostfeld, A. Multiobjective contaminant response modeling for water distribution systems security. J. Hydroinform. 2008,
10, 267–274. [CrossRef]
48. Paez, N.; Saldarriaga, J.; Bohorquez, J. Water quality modeling considering incomplete mixing in extended periods. Proc. Eng.
2017, 186, 54–60. [CrossRef]
49. CEAG. 22 Diagnóstico Sectorial de Agua Potable y Saneamiento 2019; Comisión Estatal del Agua de Guanajuato: Guanajuato, Mexico, 2019.
50. Avesani, D.; Righetti, M.; Righetti, D.; Bertola, P. The Extension of EPANET Source Code to Simulate Unsteady Flow in Water
Distribution Networks with Variable Head Tanks. J. Hydroinform. 2012, 14, 960–973. [CrossRef]
Water 2023, 15, 4253 22 of 22

51. Todini, E. Extending the Global Gradient Algorithm to Unsteady Flow Extended Period Simulations of Water Distribution
Systems. J. Hydroinform. 2010, 13, 167–180. [CrossRef]
52. Eliades, D.G.; Kyriakou, M.; Vrachimis, S.; Polycarpou, M.M. EPANET-MATLAB Toolkit: An Open-Source Software for Interfacing
EPANET with MATLAB. In Proceedings of the 14th International Conference on Computing and Control for the Water Industry,
Amsterdam, The Netherlands, 7–9 November 2016. [CrossRef]

Disclaimer/Publisher’s Note: The statements, opinions and data contained in all publications are solely those of the individual
author(s) and contributor(s) and not of MDPI and/or the editor(s). MDPI and/or the editor(s) disclaim responsibility for any injury to
people or property resulting from any ideas, methods, instructions or products referred to in the content.

You might also like