# LSTM Network for the Oxygen Concentration Modeling of a Wastewater Treatment Plant
## 3 Materials and Methods
### Description of Datasets  
The WWTP is monitored through a Supervisory Control And Data Acquisition (SCADA) system used to manage the control protocols, alarm handling and also for data collection. From the SCADA interface, the user can have access to sensors equipped in the chemical-physical reactor (where the wastewater is pre-treated), in the biological reactor and in the two membrane bioreactors, called, respectively, MBR1 and MBR2.  
In this way, the signals of interest can be downloaded. The value of \(q_{in}(t)\) is obtained from the chemical-physical reactor, from which it goes as input into the biological reactor, after the preprocessing of the wastewater. In the reactor, the sensors measure the ingoing oxygen flow rate, \(q_{oss}(t)\), and the oxygen concentration, \(O(t)\), at a height of 4 m. Then, the measure of the output liquid substrate flow rate, \(q_{ol}(t)\), is obtained from MBR1 and MBR2, as the sum of the two components that flow from the biological reactor into the two membrane bioreactors.  
Lastly, \(COD_{in}\) is obtained through laboratory analysis, as well as \(q_{om}(t)\), which is acquired daily by the operators who remove it from the reactor. These quantities are not considered in the models, not only because their values are constant, but also due to the difficulty of acquiring them. Six different datasets are collected, each one containing six days of data, as shown in Table 2. All the datasets contain the three inputs and the output previously described. Dataset 1 is used as a testing dataset, while the remaining five datasets are used to train and validate the models. Because the plant's dynamical behavior does not change during the time studied, the acquisition date of the datasets should not affect the input-output relationship. If the dynamic is correctly estimated by the models, they should present satisfactory results on all the acquired datasets, not being dependent on the acquisition date. For this reason, this partition between testing and training/validation results is reasonable.  
Due to the privacy policy, the full description of the data is not available. Nevertheless, it is possible to present the conditioned data (see Section 3.3.1) without revealing the working point. Table 3 shows the average and the variance of such signals.  
The first and second central moments of the six datasets, although similar, present differences that are not negligible. This fact can be explained by considering the normal data variability through the practice of a real plant. In fact, in the considered weeks, the waste showed different compositions, the membranes had different occlusions, the reactor had a small stop for maintenance, and these or other elements can affect the measurements.  
\begin{table}
\begin{tabular}{c c c} \hline
**Dataset Name** & **Start Date** & **End Date** \\ \hline Dataset 1 & 6 December 2021 & 11 December 2021 \\ Dataset 2 & 15 December 2021 & 20 December 2021 \\ Dataset 3 & 21 December 2021 & 26 December 2021 \\ Dataset 4 & 27 December 2021 & 1 January 2022 \\ Dataset 5 & 1 December 2022 & 6 May 2022 \\ \hline \end{tabular}
\end{table}
Table 2: Description of datasets.