Wastewater Treatment Plant: Modelling and Validation of an Activated Sludge Process

: The aim of the present paper is to develop a reliable and accurate model of the wastewater biochemical treatment process and to explore the behaviour through a general dynamic simulation environment, namely the INtegrated Simulation Environment Language (INSEL), for the analysis of the energy demand of the whole wastewater treatment plant. In particular, the presented model pays special attention to the chemical kinetics involved in the activated sludge process for the reduction of nitrogen and carbon compounds. According to the best practices, the plant configuration considered in this work includes the denitrification ‐ nitrification process, performed by completely mixed reactors. In particular, the process analysed in this paper is based on the Ludzak ‐ Ettinger process. The biological process is simulated according to the well ‐ known method widely used in the literature, namely the Activated Sludge Model No 1 (ASM1). The model includes a set of equations for the calculation of aerobic growth of heterotrophs, anoxic growth of heterotrophs, aerobic growth of autotrophs, decay of autotrophs, ammonification of soluble nitrogen, hydrolysis of entrapped organics, and hydrolysis of entrapped organic nitrogen. All these equations, along with energy and mass balances, are solved by the explicit Euler method. The developed model is validated using literature data, showing a great accuracy (deviation below 1%). As for the temperature, results show that, between 15 and 25 °C, in the initial part of the process, transport effects dominate the consumption ones. When the temperature is higher than 30 °C, nitrate consumption is so fast that biomass growth is limited by this effect. Conversely, in case of low temperatures (5–10 °C), biomass growth is not limited by nitrate availability. Finally, results also showed that temperature significantly affects the denitrification process, whereas the effect on the oxygen is lower.


Introduction
The majority of Countries implemented several actions to avoid the disposal of wastes and wastewater without treatment in land and water bodies, since it determines harmful effects on the health of environment, humans and animals [1].Conventional wastewater treatment plants are extremely intensive energy consumers [2], since their processes require large amounts of electrical and thermal energy.Data from Germany as well as from Italy show that electricity demand for wastewater treatment accounts for about 1% of total consumption of the country [3].In particular, the high energy consumption in wastewater treatment plants is mainly due to their heavy mechanical systems, such as pumps and aeration systems, for moving and treating wastewater [4].Therefore, due to the high energy consumption of the wastewater treatments plants, more sustainable and energy-efficient treatments have been developed [5].For example the production of biological energy by-products, such as biogas or biomethane, is obtained by the conversion of wastewater into a stabilised waste [6].Biomethane can be used to supply biomethane vehicles, combined heat and power plants [7], that in turn can produce electricity and heat [8], useful energy vectors for municipal district networks [9].Therefore, according to this paradigm, wastes are no longer an energy and environmental issue, since they become a sustainable energy source [10].Furthermore, such an arrangement is also economically very interesting, due to the savings in terms of waste disposal and to the incomes related to the produced energy [11].
Considering that one of the main costs and energy consumptions of the wastewater treatment plants is due to the biological aerobic treatment, it is important to evaluate the related energy demand and define potential energy measures to reduce it.This treatment, the well-known activated sludge process [12], is equipped with aeration systems, based on air blowers, providing oxygen to the aeration tanks for the reduction of nitrogen and carbon compounds.This process is widely simulated in the literature by using the Activated Sludge Model No 1 (ASM1) [13], performing carbon oxidation, nitrification and denitrification.Although numerous and newer models have suggested several modifications (see references [14] and [15]) for the mathematical modelling of activated sludge process, these have yet to be fully embraced by the international community [16].All these models implemented direct numerical integration of the governing equations, so a system of coupled nonlinear differential equations is obtained [12].In this work, the numerical solution technique is designed so that it provides adequate accuracy for each component, optimizing the computational time and by considering the mean residence time of each component into the reactor.In this way, a higher computational efficiency can be obtained by using different time steps for the various differential equations of the model.
Therefore, the present paper focuses on the development of a reliable and accurate simulation model of the activated sludge process based on the most widespread configuration of the Ludzack-Ettinger layout in steady state conditions, including the denitrification, combined nitrification and secondary settling processes.The aim is the validation of the user-developed model, which will be integrated in a general dynamic simulation environment for the analysis of municipal energy networks, namely INSEL (INtegrated Simulation Environment Language) [3].This is a general dynamic simulation tool, developed at the University of Concordia, which allows one to model any energy system by using built-in components libraries or employing user-developed models.The future aim of this work will be the evaluation of the energy demand of the whole wastewater plant and the potential production of biogas by considering its use in novel and/or existing municipal district networks.Therefore, the whole model will accurately take into account the modelling of buildings load demands, weather conditions, components modelling, control strategies, etc.Most of these components/phenomena models are available in several simulation platforms, whereas by means of this approach, all the phenomena and processes will be available in a unique simulation tool.

Method
This section presents the analysis of wastewater biochemical treatments, paying special attention to the chemical kinetics involved in the activated sludge process for the reduction of nitrogen and carbon compounds.According to the best practices, the plant configuration considered in this work includes the denitrification-nitrification process, performed by completely mixed reactors.In particular, the process analysed here is based on the Ludzak-Ettinger process, where three stages are included: anoxic, aerobic and sedimentation.The biological process is simulated according to the well-known method widely used in literature, namely the Activated Sludge Model No 1 (ASM1) [13], by means of a user-developed code.The model, reported in the Appendix, includes a set of equations for the calculation of aerobic growth of heterotrophs, anoxic growth of heterotrophs, aerobic growth of autotrophs, decay of autotrophs, ammonification of soluble nitrogen, hydrolysis of entrapped organics and hydrolysis of entrapped organic nitrogen.All these equations, along with energy and mass balances are solved by the explicit Euler method.This method has been preferred to the Ordinary Differential Equations (ODE) solver included in the MATLAB tool.The developed model evaluates the energy demand of the process and it is validated according to the plant configuration that the 624 action of the European Cooperation in Science and Technology proposes [18,19] (COST, a reference point for the comparison of the automatic treatment control systems).The COST Action 624 is dedicated to the optimisation of the performance and cost-effectiveness of wastewater management systems.Therefore, the action is focussing on increasing the knowledge of microbiological systems.The following subsections present system layout, model and validation procedure.

System Layout
The most widespread configuration based on the Ludzack-Ettinger process is investigated (Figure 1), which consists of: (i) an anoxic process, the denitrification process, where the heterotrophic bacteria convert nitrates (NO3) into ammonia nitrogen (NH3 and NH4 + ), (ii) an aerobic process, the combined nitrification process, where the heterotrophic and autotrophic bacteria operate with dissolved oxygen in order to remove the carbonaceous substrate and ammonia nitrogen and (iii) the sedimentation process, for the removal and recirculation of the activated sludge.Two recirculation lines are needed.Because the inlet nitrates' concentration is negligible, in order to obtain sufficient concentration values for the development of the denitrification process, the first recirculation line R1 allows one to supply nitrates obtained by the combined nitrification process to the denitrification process.Note that the denitrification process can be performed only using carbon compounds.Therefore, by means of this process, the simultaneous reduction of the nitrate and carbon substrate concentrations is obtained.Note that the denitrification process is located before the combined nitrification process, to avoid adding further organic compounds (e.g., methanol) to the process.The second recirculation line R2 is mainly proportioned for the recirculation of bacteria, although it also sends nitrogen compounds.

Calibration and Validation Procedure
The calibration and validation procedure of the developed code is carried out by means of the COST simulation benchmark plant and data [17], in steady state condition.The aim of the work is to develop a suitable simulation code for the biological processes to be integrated in the energy commercial software INtegrated Simulation Environment Language (INSEL).In the COST benchmark, different data are available in terms of initial and boundary conditions as well as results obtained by means of several different commercial software.The benchmark simulation plant is reported in Figure 2.This consists of 5 biological tanks-in-series with a secondary settler.The total biological volume is 5999 m 3 (tanks 1 and 2, each 1000 m 3 , and tanks 3, 4 and 5, each 1333 m 3 ).Tanks 1 and 2 are unaerated, but fully mixed.Tanks 3, 4 and 5 are aerated, with kLa (oxygen transfer rate (day −1 ), provided by the blowers' manufacturers) of 10 hr −1 for tanks 3 and 4, and kLa of 3.5 hr −1 for tank 5.The concentration of dissolved oxygen for tanks 3, 4 and 5 is 8 gm −3 [17].A non-reactive secondary settler with a volume of 6000 m 3 (area of 1500 m 2 and a depth of 4 m) is subdivided into 10 layers, with a feed point at 2.2 m from the bottom (i.e., at the middle of the sixth layer).Two recirculation lines are expected: the nitrate internal recycle from the fifth to the first tank for a default flow rate of 55,338 m 3 /d, and the return-activated sludge (RAS) recycled from the first layer of the secondary settler to the tank 1 inlet for a default flow rate of 18,446 m 3 /d.Note that RAS is the settled biomass returned to the treatment process to provide organisms which will continue removing pollutants.Since this is a living and growing process, it will continue to build biomass.However, an uncontrolled biomass growth must be avoided.Therefore, the amount of biomass in the process is controlled by removing (wasting) a certain amount of it each day.This excess biomass removed from the secondary system is known as waste or waste-activated sludge (WAS).It is assumed that the waste is continuously pumped from the secondary settler for a default rate of 385 m 3 /d.
The COST provides a data file including influent concentration values of 12 components of the model, reported for each 15-minute interval for 14 days.As previously explained, pH is assumed neutral and, therefore, the alkalinity Salk is assumed equal to 7 mol m −3 each time step.The data include diurnal variations in flow and Chemical Oxygen Demand (COD) load and also take into account three disturbance weather events: dry weather, a storm and a rain event.In order to verify the code, the obtained results are compared with those provided by the COST after a simulation of 100-150 days, considering same boundary conditions and inputs.

Results and Discussion
In this section, results obtained from the numerical code are reported in order to show the model validation and the robustness analysis.The validation was carried out by considering the benchmark COST data obtained with other commercial software by taking into account the following boundary and initial conditions.In particular, the validation of the anoxic tank and aerobic tank model, as well as the validation of the whole process, was performed on seven days of simulations, according to the available data.These data are included in a fully defined simulation protocol developed as a tool for evaluating activated sludge wastewater treatment control strategies.The COST simulation benchmark data are representative of three disturbances: dry weather, a storm event and a rain event.In this work, data related to a dry weather file is used.This considers normal diurnal variations in flow and COD load.The initial wastewater parameters refer to the wastewater after preliminary treatments (screenings, degritting, oil extraction and primary settling).

Qint
The results of the validation of the anoxic tank model are shown in Figure 3.The concentrations were compared with the benchmark data.The error about the inert suspended solids, SI, in the first tank is extremely low, below 10 −9 after 3 days of simulation (Figure 3a), since in the first anoxic tank, no production or consumption rate occurs.Although the oscillations reported in Figure 3b, seem to be large, for the particulate inert organic matter, XI, the error tends to zero, showing values lower than 10 −5 , after the seven days of available data (Figure 3b).The figure shows that the errors are definitively acceptable according to the typical accuracy of the engineering calculations.In addition, this error is significantly lower than any possible measurement errors regarding such variables.On the other hand, a certain instability of the solution can also be detected for day 1.However, this leads to some oscillations only in the error, not in the solution.In fact, Figure 3 displays the error for XI, not the variable XI itself.The error is in the order of magnitude 10 −5 .Therefore, the variable XI is only marginally affected by these fluctuations.Additional comments have been added in the text.The total suspended solids (TSS) concentrations along the settler height are also compared by obtaining satisfying results (Table 3).In the anoxic tank, a really low oxygen level is obtained, as expected, because the only oxygen supply comes from the internal recirculation line; therefore, a minimum level of oxygen is detected (Figure 4).In the first seven days of simulation, the concentration of nitrite and nitrate grows due to the following reasons: (i) the nitrogen feed from sewage and (ii) the higher rate of recirculation than the consumption rate.The concentration of heterotrophic bacteria grows both for the recirculation and feed effect, but also for the production rate of the facultative bacteria capable to consume nitrates (Figure 4).Optimal results in terms of percentage error with respect to the COST benchmark data were obtained for the aeration tank.In particular, in Figure 5, the concentration values of the dissolved oxygen, heterotrophic and autotrophic bacteria and carbon substrate obtained by the nitrification and carbon compounds' removal processes in the first aeration tank were reported.Due to the aerobic environment, the concentration of the dissolved oxygen is obviously high.In this tank, during the observed days, a remarkable growth of the heterotrophic bacteria concentration is obtained, from 2100 to 2425 gm −3 , and simultaneously, the removal of the carbon substrate from 1.45 to 1.23 gm −3 , according to a linear trend.The nitrification process leads to the increase of the autotrophic bacteria concentration, from 70 to 102 gm −3 , and a reduction of ammonia nitrogen (Figure 6a).In fact, as reported in this figure, the process leads to the transformation of the ammonia nitrogen into nitrate and nitrite nitrogen.

Sensitivity Analysis
In order to prove the model robustness and the quality of the obtained results, a sensitivity analysis is performed by varying the most important kinetic-chemical parameters.For sake of brevity, the results only show the variation of: (i) ˆA  = the maximum autotrophic growth rate (day −1 ), (ii) KS = the substrate half saturation constant (gCOD m −3 ), (iii) KNO = the nitrate half saturation constant (g NO3-N m −3 ) and (iv) the temperature of the biological treatment.By varying ˆA  from 0.35 and 0.65 day −1 (Figure 7a), the analysis showed that the autotrophs concentration in the second anoxic tank significantly decreases for ˆA  values lower than 0.45 day −1 (typical values of water treatment plants with inlet low ammonia concentrations or no-optimal pH values).As expected, for low values of KS, the concentration of heterotrophs in the last aerobic tank more rapidly reaches sufficiently high values (Figure 7b).The value of KNO can be used to assess if the environment where a process occurs is anoxic.In particular, when the nitrate concentration is higher enough than the nitrate half saturation constant and the dissolved oxygen concentration is smaller enough than the oxygen half saturation constant, the tank can be modelled as anoxic.In this case, the electron acceptor is the nitrate and the switching functions included in the model are able to simulate the denitrification process, and consequently, the possible heterotrophic growth.For the typical operating range of this constant, 0.1-0.5 gm −3 , no significant difference was detected.Conversely, by varying KNO from 0.001 to 10 gm −3 , slight differences are obtained (Figure 8).In particular, for high values of KNO, a decrease in the heterotrophs growth and an anoxic environment can occur.The temperature in the biological treatment is an important parameter affecting all the processes.In fact, according to the Arrhenius equation, the kinetics of the chemical reaction dramatically depends on the temperature, according to the following equation [20]: , where  = 1.047 is the Arrhenius coefficient .This parameter is varied from 5 to 35 °C, in order to simulate the potential variation of the influent temperature during the months of the year.In the anoxic tank, the study on the temperature effects is carried out by analysing the relation between the nitrates consumption (Figure 9b) and heterotrophs growth (Figure 9a).For temperatures higher than 30 °C, the nitrates concentration goes almost to zero due to the high consumption rate.As a consequence, at high temperatures, the low nitrates concentration reduces the biomass growth and determines a low heterotrophic bacteria concentration.The trend at 20 °C is due to the following reasons: first, the nitrate feed prevails on the consumption rate of the heterotrophs, subsequently, up to 30 days, the heterotrophic bacteria concentration increases, and the consumption rate balances the nitrate feed and the stationary condition is reached.This trend is the same for temperatures between 15 and 20 °C.Conversely, for low temperatures, see isothermal curves at 5 and 10 °C, the nitrate consumption rate is low, and therefore, the biomass is featured by a minor limiting effect.This determines a high heterotrophic bacteria concentration and therefore, a great consumption of nitrates, which falls to zero after 20 days (Figure 9b).Subsequently, heterotrophic bacteria concentration reaches a stationary concentration value.This effect reflects the empirical result obtained in winter operation, when high heterotrophic bacteria concentrations are measured.
For the process occurring in the aerobic environment, the force causing the oxygen supply is the difference between the saturation oxygen concentration and the effective oxygen concentration.It is well known as the saturation oxygen concentration is temperature-dependent.In particular, the higher the temperature, the lower the saturation oxygen concentration.As it is shown, between 15 and 25 °C, the dissolved oxygen concentration is high enough to determine quite high heterotrophic bacteria concentrations and low carbonaceous substrate concentrations due to the high substrate removal (Figure 10).For temperatures higher than 25 °C or lower than 15 °C, high substrate concentrations are obtained.In the first case, this is due to a low oxygen concentration, and in the second case, to low values of maximum velocity of substrate degradation.In the aerobic environment, the ammonia nitrogen is degraded by autotrophic bacteria, operating only with sufficient dissolved oxygen concentration values.For low temperatures, ammonia nitrogen concentrations are high (Figure 11b), because although the dissolved oxygen is sufficient for both the nitrification and carbonaceous substrate removal, the maximum growth rate parameter of autotrophs is low (Figure 12).Conversely, for high temperatures, the dissolved oxygen decreases (Figure 11a), but the consumption rate is high from a kinetic point of view.As the temperature grows, an increase of the ammonia removal by the autotrophic bacteria is obtained.

Energy Analysis
This section presents the analyses of the effluent quality index (EQI) and the electric energy demand obtained by the simulations carried out using different volumes of anoxic (1000, 1250, 1500 and 2000 m 3 ) and aerated tanks (1333, 1666, 2000 and 2600 m 3 ).In order to evaluate the best possible solutions from the energy and environmental points of view, simulations are performed by taking into account the same layout (two anoxic tanks and three aerated tanks) and same input data used for the validation process.Results are analysed after the steady-state condition is reached.
Table 4 shows the most interesting cases compared to the base case in terms of primary energy consumption of the aeration systems and CO2 emissions.The best result is obtained using anoxic tanks of 1000 m 3 and aerobic tanks slightly larger than the reference case (1333 m 3 ), with a reduction of 13% of primary energy consumption and CO2 emissions.Note that all the selected solutions respect the limit values of the concentrations TSSe, CODe, SNtot (sum of SNKe and SNOe) and BOD5,e (the quantity of biodegradable organic matter contained, evaluated using the biochemical oxygen demand of microorganisms after five days) equal to 30, 100, 18 and 10 gm −3 , respectively.Therefore, EQI values are acceptable from an environmental point of view.

Conclusions
This work presented the development and the validation of a detailed model for the simulation of the activated sludges biological process in wastewater treatment plants.In particular, the developed model is validated according to the plant configuration that the 624 action of the European Cooperation in Science and Technology proposes (a reference point for the comparison of the automatic treatment control systems).In order to prove the model robustness and the quality of the obtained results, a sensitivity analysis was performed by varying the most important kinetic-chemical parameters and temperature.The developed model showed a great accuracy, presenting a deviation with respect to the benchmark data below 1%.Results showed that biomass growth is only slightly affected by the selection of the kinetic constant, which should increase from 0.001 to 10 gm −3 in order to detect a relevant effect on the growth of the biomass.As for the temperature, between 15 and 25 °C, in the initial part of the process, transport effects dominate the consumption ones.When the temperature is higher than 30 °C, nitrate consumption is so fast that biomass growth is limited by this effect.Conversely, in case of low temperatures (5-10 °C), biomass growth is not limited by nitrate availability.Finally, results also showed that temperature significantly affects the denitrification process, whereas the effect on the oxygen is lower.This is due to the fact that at high temperatures, ammonia is rapidly converted by the autotrophic bacteria.
The development of this model is only the first step of a longer research project on wastewater treatment plans.In fact, the final aim is the development of a comprehensive library of programming blocks for each process of the plant to be included in the INSEL energy simulation software, in order to evaluate the processes' energy demand and simulate the whole wastewater treatment plant coupled with renewable energy sources.In particular, the research project aims at investigating the integration of wastewater treatment plants in novel and/or existing district networks, considering the energy that can be produced by the biogas obtained by the wastewater plants.

System Model
The biological model used is ASM1 in the final form, published in 1987 [14].The model considers kinetic and stoichiometric coefficients and the concentrations of the 12 components.In Table A1, a description of the main components is reported.

Parameter
Description Unit 1 SI Soluble inert organic matter: consists of organic compounds that do not take part in the wastewater treatment processes mgCODl −3

SS
Readily biodegradable substrate: simple organic carbon compounds that provide energy to heterotrophic bacteria mgCODl −3 3 XI Particulate inert organic matter: undissolved organic particles such as soil organic matter or other particulates isolated by sieving or filtration mgCODl −3
The previous units are expressed in COD (chemical oxygen demand), i.e., the amount of oxygen necessary to oxidize all of the organic carbon completely to CO2 and H2O.
The previous Table A2 has to be read in the following way.SI and XI (column 1 and 3, respectively) are not involved in any conversion processes, but their concentration in considered because it is included into the effluent COD value.SS (column 2) is removed by the growth of heterotrophic bacteria ( 1/ H Y  ) under aerobic or anoxic conditions ( 1/ H Y  ) and is formed by the hydrolysis of particulate organic matter (+1).The slowly biodegradable substrate XS (column 4), is removed by hydrolysis (−1) and formed by decay of both heterotrophic and autotrophic biomass.The decay also transforms biomass into inert particulate products; therefore, the term fP (the fraction of biomass to particulate products) is included (1−fP).As a consequence, the particulate products arising from biomass decay XP (column 7) are obtained by the decay of heterotrophic and autotrophic biomass.Note that the readily biodegradable material is considered to be the only substrate for growth of the heterotrophic biomass XB,H (column 5) obtained by the growth under aerobic (+1) or anoxic conditions (+1), whereas the growth of the autotrophs XB,A (column 6) only occurs under aerobic conditions (+1).The considered concentration of oxygen SO (column 8) only includes biological processes, i.e., the amount of oxygen which must be provided to meet the bacteria metabolic needs.Therefore, the oxygen utilization is associated only with aerobic growth of the heterotrophic ( ) and autotrophic biomass ( (4.57 ), discarding the microbial decay.This assumption differs from the more traditional approaches.The net loss of biomass associated with decay is considered by the heterotrophic yield, lower than unity.The biomass grown obtained by the substrate removal must always be lower than the biomass loss.The term 4.57 is the stoichiometric coefficient for aerobic growth of autotrophs, i.e., the theoretical oxygen demand associated to the oxidation of ammonia nitrogen to nitrate nitrogen.The nitrate and nitrite nitrogen, SNO (column 9), is produced by aerobic growth of the autotrophic bacteria ( 1/ A Y  ) and removed during the anoxic growth of the heterotrophic biomass ( (1 ) / 2.86 ).Note that the nitrite nitrogen is an intermediate obtained during the nitrification process, therefore, for the sake of simplicity, the model assumes that nitrate is the only oxidized form of nitrogen.The term 2.86 is the stoichiometric coefficient for anoxic growth of the heterotrophic biomass, i.e., the theoretical oxygen for the conversion of nitrate nitrogen to nitrogen gas (N2).The soluble ammonia nitrogen, SNH (column 10), is formed by ammonification of soluble biodegradable organic nitrogen (+1) and is removed by growth of the biomass.The ammonia nitrogen is consumed for the aerobic growth of the autotrophic biomass ( 1/ A Y  ).However, nitrogen is also incorporated into biomass during cell synthesis and a term is included ( XB i  ) for the nitrogen used during growth of both heterotrophs and autotrophs.
The soluble organic nitrogen, SND (column 11), is formed by hydrolysis of particulate organic nitrogen (+1) and converted to ammonia nitrogen by ammonification (−1).The particulate biodegradable organic nitrogen, XND (column 12), is generated from decay of both heterotrophic and autotrophic biomass ( X B i ), minus the amount associated with the inert particulate products, and is lost by ammonification ( P XP f i  ).pH of the process included in the column alkalinity, Salk (column 13), is considered about neutral, therefore, the model includes 12 mass balance equations to adequately simulate an activated sludge system performing carbon oxidation, nitrification and denitrification.
For each process j of the previous table, the rate is defined in the last column of Table A2.This table represents a set of 13 differential equations (13 columns), each one including a time-variation term ( ), an outlet flow ( All these equations are solved by implementing the explicit Euler method, forming a set of explicit algebraic equations.The numerical resolution of the model is based on the following differential equation: where C represents the concentration of a generic component and ∆t is the time step adopted so that the term   C t t   is not negative, i.e., the criterion adopted to define the maximum time step avoids obtaining physically impossible solutions: Combining the relative mass balances and condition (3) for each component, the time step is where i t  is the time step on component i, V is the tank volume, Ci is the concentration of the ith component in the tank, Oi is the outlet mass flow rate from the tank, Ki is the mass flow rate consumed of the ith component for biological process and i  is the mean residence time of the ith component in the tank, i.e., the amount of time that a component remains in the reactor.Equation (A4) demonstrates that the maximum allowable step size for each component may be different and depends on the mean residence time of the component.The numerical technique is organised so that it provides adequate accuracy for each component without wasting computational time.
Finally, the settling system is simulated considering the double exponential settling velocity function, see the equations reported in Reference [21].

Aeration Energy Demand Evaluation
In order to evaluate the energy demand of the aeration process to maintain the optimal concentration of dissolved oxygen, So, step by step, the following control strategies are implemented.The value Δ is iteratively calculated by the code.The code calculates the value Δ by itself within a certain number of cycles, in order to add or subtract to the kLa coefficient and maintain the outlet concentration, So, from the aerobic process within the recommended range of 1-4 gm −3 .In particular, during each iteration, if So is less than or equal to the minimum value (So,min = 1 gm −3 ), kLa is increased by a certain value Δ, iteratively calculated in order to meet the criterion that So will be higher than 1 gm −3 .Conversely, if So is greater than or equal to the maximum value (So,max = 4 gm −3 ), kLa is decreased by a certain value Δ, iteratively calculated so that So will be lower than 4 gm −3 .
In this way, the optimal concentration of dissolved oxygen is step-by-step pursued, and the code reaches it by itself within a certain number of cycles.According to the previous control strategy, to maintain So in the recommended range of 1-4 gm −3 in the tank the concentration, blowers have to provide an amount of oxygen greater than or equal to the amount evaluated as: The aeration power demand, AP (kW), is calculated from the kLa according to the following relation [22], valid for Degrémont DP230 porous disks at an immersion depth of 4 m: The power needed for pumping, PP (kW), is calculated as:   int 1 0.004 0.008 0.05 24 where Qint is the internal recirculation flow rate (m 3 d −1 ), Qr is the external recirculation flow rate (m 3 d −1 ) and Qw is the waste-activated sludge flow rate (m 3 d −1 ).
The mixing power, MP (kW), is also considered.According to the COST benchmark, for all five tanks, the power is calculated only if kLa is lower than 20 d −1 : where V is the volume of the tank (m 3 ).If the available power is greater than the demand (AP + PP + MP), kLa remains equal to the previously calculated value.If the available power is lower than the demand, kLa is instead recalculated, but in this case, the biological process is performed at lower effluent quality.For this reason, an effluent quality index (EQI) (kg pollutions d −1 ), based on a weighting of the compounds into effluent, e, having main influence on the quality of the receiving water, was evaluated in the model.It is defined as: where Bi are weighting factors, as deduced from Reference [22].

Figure 3 .
Figure 3. Percentage error in the first anoxic tank on the inert suspended solids (a) and on the particulate inert organic matter (b).

Figure 4 .
Figure 4. Dissolved oxygen (a), nitrate and nitrite (b), and heterotrophic bacteria (c) in the first anoxic tank.

Figure 6 .
Figure 6.Ammonia nitrogen (a) and nitrate and nitrite nitrogen (b) in the first aeration tank.

Figure 7 .
Figure 7. Autotrophs in the second anoxic tank for different values of the maximum autotrophic growth rate (a), heterotrophs in the third aerobic tank for different values of the substrate half saturation constant (b).

Figure 8 .
Figure 8. Heterotrophs in the second anoxic tank for different values of the substrate half saturation constant.

Figure 9 .
Figure 9. Heterotrophs (a) and nitrates (b) in the first anoxic tank for different temperature values.

Figure 10 .
Figure 10.Carbonaceous substrate (a) and heterotrophs (b) in the first aerobic tank for different temperature values.

Figure 11 .
Figure 11.Dissolved oxygen (a) and ammonia nitrogen (b) in the first aerobic tank for different temperature values.

Figure 12 .
Figure 12.Autotrophs in the first aerobic tank for different temperature values.

Table 1 .
Boundary and initial conditions in the biological process.

Table 2
reports a comparison of the effluent concentrations with commercial software after 150 days of simulation, a sufficient time to reach the steady state condition.

Table 2 .
Comparison of the effluent concentrations with commercial software.

Table 3 .
Comparison of the total suspended solids (TSS) concentrations in the clarifier with commercial software (n/a=not applicable).

Table 4 .
Primary energy consumption and CO2 emission comparison using different tank volumes.

Table A2 .
Process kinetics and stoichiometry for carbon oxidation, nitrification and denitrification.