# State Analysis of the Water Quality in Rivers in Consideration of Diffusion Phenomenon
## 2 Materials and Methods
### Mathematical Model of a River Including the Phenomenon of Diffusion  
The mathematical modelling of phenomena occurring in the aquatic environment makes it necessary to analyse all the factors affecting water quality. The phenomenon of diffusion is an important factor influencing water quality. Diffusion is examined considering the spatial conditions such as length, width and depth of a river. Based on the above considerations and the Gauss-Ostrogradsky theorem, the phenomenon of diffusion can be described as follows:  
\[\frac{\partial x}{\partial t}-div(D\ grad\ x)+\delta=0 \tag{18}\]  
where \(x\)--state vector dependent on river length and time, \(D\)--diffusion coefficient in the isotopic medium, and \(\delta\)--intensity of generation or disappearance of the transferred agent. Disregarding the velocity of water flow and taking the diffusion value as a constant, we obtain an equation of the form:  
\[\frac{\partial x}{\partial t}-\frac{\partial}{\partial z}-\left(D\ \frac{\partial x}{\partial z}\right)+\delta=0 \tag{19}\]Taking into account the self-cleaning process of the river, Equation (19) is extended by an additional factor:  
\[\frac{\partial x}{\partial t}-\frac{\partial}{\partial z}-\left(D\ \frac{\partial x}{ \partial z}\right)+Ax+\delta=0 \tag{20}\]  
where \(A=\left[ \begin{array}{cc}-k_{1}&0;&-k_{2}\end{array} \right.\)\(-k_{3}\)\(\left.\right]\) is a state matrix in which the \(k_{i}=1,\ldots,N\) coefficients determine the rate of response of the state variables. Considering a state vector that depends on time, length and additionally on the width and depth of the river, Equation (20) has the form:  
\[\frac{\partial x}{\partial t}-\left(D\ \frac{\partial^{2}x}{\partial z_{1}^{2}}+D \ \frac{\partial^{2}x}{\partial z_{2}^{2}}+D\ \frac{\partial^{2}x}{\partial z_{3}^{2}}\right)+Ax+\delta=0 \tag{21}\]  
where \(z_{1}\), \(z_{2}\), and \(z_{3}\)--spatial coordinates for length, width and depth, respectively. Assuming that a change in diffusion along the spatial variable, with that being the water depth, is negligible in relation to the width and length of the water body, this value can be ignored, while taking into account its flow velocity:  
\[\frac{\partial x}{\partial t}-\left(D\ \frac{\partial^{2}x}{\partial z_{1}^{2}}+D \ \frac{\partial^{2}x}{\partial z_{2}^{2}}\right)+V\ \frac{\partial x}{\partial z_{1}}+Ax+\delta=0 \tag{22}\]  
where \(V=diag(v,v)\)--diagonal matrix representing the flow velocity over a given length \(z_{1}\). The solution of the above equations is possible with known boundary conditions which take the following form:  
\[x(z_{1},t_{0})=f_{p1}(z_{1}) \tag{23}\]  
\[x(z_{2},t_{0})=f_{p2}(z_{2}) \tag{24}\]  
\[x(0,t)=f_{b}(t) \tag{25}\]  
where the functions \(f_{p1}\), \(f_{p2}\), and \(f_{b}\) are known for the corresponding coordinates. Ensuring the compatibility and stability of the solution requires the adoption of an appropriate discretization step factor. In order to determine the \(dt\) value in conjunction with \(dz\), the Courant diffusion number rule is as follows:  
\[dt\leq\frac{dz^{2}}{2D} \tag{26}\]  
where \(D\)--diffusion coefficient, \(dt\), and \(dz\)--distances between nodes. The Courant number describes a mathematical condition, for the convergence of mathematical methods, for solving hyperbolic partial differential equations. It stipulates that the length of the time step must not exceed a certain limit value; otherwise, the method loses stability. This relationship is important when testing with diffusion. Solving the advective-diffusion transport equation is difficult because the advection part is hyperbolic and the diffusion part is parabolic. The criterion for the participation of both parts in the transfer of medium is the Peclet number, which for a grid of nodes distant from each other by \(dx\) is determined as follows: \(P=u\ dx/D\), where \(u\)--average stream velocity, \(D\)--diffusion coefficient, \(P=\infty\) for advectional transfer only, when \(D=0,\ P=0\) for diffusion-only transfer, when \(u=0\).