# LSTM Network for the Oxygen Concentration Modeling of a Wastewater Treatment Plant
## 1 Introduction  
A WasteWater Treatment Plant (WWTP) is a plant where wastewater is treated to remove pollutants, exploiting biological and chemical reactions, before being released back into the environment. The modeling and control of this process is not trivial, because the treatment depends on the nature and the characteristics of the wastewater. Wastewater usually firstly undergoes chemical-physical treatments in order to remove the solid part of the waste, and then biological treatments for the organic components. One of the most common biological treatments used in WWTPs is the Conventional Activated Sludge (CAS) process, in which bacteria are used to nitriify and denittify wastewater. Considering the complexity of the process, the control of a WWTP can be a challenging task: several flows may be involved, among with a huge variety of different biological and chemical reactions; it is necessary to provide a sufficient oxygen quantity but without an excess of aeration, reaching a trade-off between energy consumption and process demand, with a growing attention to environment-related problems. To design an optimal control strategy, it is necessary to have an accurate model of the process [1]. In [2], a review on the current state of the art regarding the modeling of activated sludge WWTPs is presented. The model of the entire WWTP is usually composed of two main components: the hydraulic model that takes into account the different flows in input and output in the reactor, and the Activated Sludge Model (ASM) that models the biological and chemical reactions inside the tank due to the activated sludge process. The so-called Activated Sludge Model No. 1 (ASM1) [3] was extended in recent years to consider phosphorus dynamics in ASM2, [4] and to include the storage of organic substrates as a new process with an easier calibration in ASM3 [5]. ASM1 is still the most used model, and it can be considered the state of the art because several successive works are based on it [6; 7; 8]. However, complex and specialized models require the identification of more specific parameters subject to high sensitivity, with expensive and time-consuming procedures, far from practical applications. Hence, these specialized models are not a good choice for process design. For practical applications, in [9], the combination of the process knowledge with new artificial intelligence techniques is proposed. In [2], in addition to the most diffused WWTP white-box modeling, some black-box methodologies based on Neural Network (NN) techniques were presented with interesting results. In view of all these considerations, in this work, an NN approach, in particular a Long Short-Term Memory (LSTM) network, is explored to model a WWTP located in Mortara (Pavia, Italy), managed by the company ASMortara S.p.A. The main goal was the development of a model for the biological reactor of the plant to improve several critical aspects of the process, such as the oxygen concentration regulation or the design of a fault detection system. The data used in this paper have been collected with a simple switching controller enabling (disabling) the input flow if the oxygen concentration inside the reactor is below (above) a certain threshold. The effect of this control strategy is an on/off oxygen flow rate that generates important oscillations in the oxygen concentration evolution. Having a better model of the system would make it possible to design a more advanced control strategy and to improve the energy consumption. In order to highlight the capabilities of the proposed approach, the LSTM performances are compared with those obtained with a standard AutoRegressive model with eXogenous input (ARX). Because, in this kind of process, the knowledge of the biological reactions is limited, the NN approach can represent a promising alternative to the white-box one. Moreover, considering the large amount of input-output data that can be collected on the plant, these approaches are good candidates for control design.