## 3 Mathematical Process Modeling
### Chlorine Reaction through the Tank  
The expression in Equation (2) is a generalization that must be developed with more precision for the present case. In [21; 22], different models are presented, describing a chlorine decay more adjusted to the reality of the studied plant. Considering the characteristics of the water that reaches the exit of the DWTP, a significant part of the chlorine (fraction \(f\) in Equation (6)) reacts quickly with the existing matter (organic and inorganic) and the rest (fraction 1-\(f\)) of the matter reacts with the remaining chlorine fraction. Therefore, a combined first-order model according to [21], plus a combination of first and second order presented in [22], yields Equation (6):  
\[\frac{\partial c}{\partial t}=D\frac{\partial^{2}c}{\partial x^{2}}-U\frac{ \partial c}{\partial x}-k_{R}c(f)-k_{r}c^{2}(1-f)-k_{s}c(1-f) \tag{6}\]  
where \(k_{R}\) is the decay coefficient for the rapid reaction, and \(k_{r}\) and \(k_{s}\) would be the decay constants of rapid and slow reaction for the remaining chlorine fraction with different characteristics to those that react following \(k_{R}\). Let\(f\) be the fraction of chlorine that reacts quickly in response to the decay constant \(k_{R}\).  
It has been proven by laboratory analysis that, for treated waters without ammonia, the demand for chlorine varies between 0.2 ppm and 0.5 ppm depending on whether its source is from the traditional treatment of granular active carbon filters (GACF) or osmosis (RO). These reactions take place between 5 to 10 min after the chlorine is exposed to the water and follows a decay according to the constant \(k_{R}\). The demand for chlorine is very high, and \(k_{R}\) varies significantly when the existence of ammonium occurs, with values between 7 and 10 times the amount of NH\({}_{4}\)-N detected by the ammonium meter (An1). Constants \(k_{r}\) and \(k_{s}\) were estimated in [23], with values between \(3.3934\times 10^{-5}\) (s\({}^{-1}\)) and \(5.4259\times 10^{-7}\) (s\({}^{-1}\)), respectively. These values (\(k_{r}\) and \(k_{s}\)) are significant because of the importance in the parameterization of the proposed simulator. With those values of \(k_{r}\) and \(k_{s}\), and knowing that the demand for chlorine in its rapid reaction stage is between 0.2 ppm and 1.0 ppm and that the fraction that reacts with the chlorine is around 40%, then \(k_{R}\) is between \(3.046\times 10^{-4}\) (s\({}^{-1}\)) y \(14.05\times 10^{-4}\) (s\({}^{-1}\)), according to experimental data.  
Figure 6 shows the simulator response to a step in the dosage of 1 ppm for a flow of 1.5 m\({}^{3}\)/s parameterized with \(k_{r}\) and \(k_{s}\), and different values of \(k_{R}\) with a reaction fraction of \(f=0.4\) (40%).  
Figure 7 shows a view of one of the studies carried out in steady state with the Comsol CFD on the diffusion of chlorine along the contact tank. Specifically, on the basis of a color scale, the diffusion of chlorine along the tank is represented for a turbulent flow rate RANS \(k\)-\(\varepsilon\) with a flow rate of 2.7 m\({}^{3}\)/s, with a decay constant of 9.0 \(\times\) 10\(-\)4 (s\({}^{-1}\)), a Schmidt number of 0.7, and an initial dosing step of 2 ppm of chlorine.