Energy Flexibility Chances for the Wastewater Treatment Plant of the Benchmark Simulation Model 1

Future energy systems must mainly generate electricity from renewable resources. To deal with the fluctuating availability of wind and solar power, new versatile electricity markets and sustainable solutions concentrating on energy flexibility are needed. In this research, we investigated the potential of energy flexibility achieved through demand-side response for the wastewater treatment plant of the Benchmark Simulation Model 1. First, seven control strategies were simulated and assessed. Next, the flexibility calls were identified, two energy flexibility scenarios were defined and incorporated into the model, and the control strategies were evaluated anew. In this research, the effluent ammonia concentration needed to be maintained within the limits for as long as possible. Strategy 5, which controlled ammonia in Tank 5 at a low value and did not control any nitrate in Tank 2, of Scenario 1, which was characterized by an undetermined on/off aeration cycle, was then found to be the best. Although this control strategy led to high total energy consumption, the percentage of time during which aeration was nearly suspended was one of the highest. This work proposes a methodology that will be useful to plant operators who should soon reduce energy consumption during spikes in electricity prices.


Introduction
To achieve the goals of the Paris Agreement, use of fossil energy must soon be abandoned. Hence, renewable energy production from wind and solar resources must significantly increase, particularly for countries like Germany with only low hydropower capacity and a decided nuclear power phase-out. However, because of the intermittency of wind and solar power, their prioritization will lead to increasing fluctuations in electricity production, and the use of renewable resources in electric grids will increase their uncertainty and variability. Therefore, electricity markets, due to this increasing share of fluctuating renewable energies, are currently going through a phase of agitating transition. In the future, electric grids will have to rely on storage and reserve capacities as well as demand-side resources to address this problem in supply and demand, or their continued operation may be challenged. New smart applications that will manage to adjust quickly to changes of demand and supply should therefore be considered [1][2][3][4][5].
The German electricity market is Europe's largest, with an annual power consumption of around 530 TWh and a generation capacity of 184 GW [6]. In 2015, renewable energy contributed 195.9 TWh (about 30%) towards electricity generation, which, compared to 2005, corresponds to an increase of 213% [2]. Therefore, Germany, which is committed to increasing the contribution of renewable energy to 80% of the total by 2050 [1], will soon need its energy sector to be reorganized. Sustainable solutions for integration of renewable energy have already begun focusing on the potential for energy flexibility as well as storage case of aeration control, the main risk is increased ammonia load in the effluent due to insufficient nitrification.
In this work, we aimed at dealing with price spikes (high peak prices) under real-time pricing tariffs. During real-time pricing, electricity consumers are charged prices that vary over short time intervals, typically hourly, and are quoted one day or less in advance to reflect contemporaneous marginal supply costs, where prices spikes are related to periods of low renewable energy production and the need for load-shedding as a demand-side response [7,21]. Therefore, two energy flexibility scenarios concentrating on load-shedding opportunities within the European Power Exchange spot (day-ahead) electricity market (EPEX SPOT) were investigated under both the default and another six more advanced control strategies of the BSM1. After that, all useful information was extracted and all the necessary comparisons were made.

Benchmark Simulation Model 1 and User-Defined Control Strategies under Study
The BSM1 is a useful simulation platform for testing and comparing control strategies in WWT processes. It defines a plant layout, influent loads, test procedures, and evaluation criteria. The plant consists of a five-compartment activated sludge reactor, i.e., two anoxic reactors (Tanks 1 and 2) followed by three aerobic reactors (Tanks 3, 4, and 5), and one 10-layer secondary settler. The BSM1 can also be seen as a figure in [22]. Therefore, the plant combines nitrification (aerobic zone) with pre-denitrification (anoxic zone) for biological nitrogen removal [22][23][24]. Sludge in the secondary settler is recycled to the first anoxic bioreactor (returned activated sludge) in order to maintain the microbiological population; however, some sludge in excess is pumped out of the settler to keep the sludge concentration constant. In addition, some of the mixed liquor is recycled to the first anoxic bioreactor (internal recycle) to enhance nitrogen removal [25]. The International Water Association (IWA)'s Activated Sludge Model 1 (ASM1) as defined by [26] was selected to model the biological reaction, and the double exponential settling velocity model of [27] was selected as a representation of the settling process [18,28,29].
Two reference configurations have already been defined for the BSM1, which are the open-loop configuration where no control is involved and the closed-loop configuration with a defined and active default control strategy added to it [30]. The closed-loop configuration involves two feedback control loops, where the first aims to maintain nitrate concentration in the second anoxic (unaerated) tank (Tank 2) at a set point value of 1 g N m −3 , and the second aims to maintain dissolved oxygen (DO) concentration in the third aeration tank (Tank 5) at a set point value of 2 g O2 m −3 -this is the model's default control strategy. Both default controllers that are used are proportional-integral controllers [22,24,25]. However, it should be emphasized that the default control strategy described above is not the best strategy available, and it is only provided as a test case for the user. This strategy only uses two control handles, the internal recirculation flowrate (for nitrate control), and the oxygen transfer rate in last tank (for DO control). However, there are approximately 30 individual control handles that can be manipulated within the defined benchmark plant and are thus available for the implementation of user-defined control strategies, dramatically increasing the plant's flexibility [22,30].
The influent dynamics are defined for three different weather conditions: dry, rain, and storm [22]. Each of the weather files contains 14 days of influent data at 15 min intervals and defines the influent, which is assumed to be primary effluent. In general, these files were developed based on real data and represent expected diurnal variations in the influent flowrates, chemical oxygen demand (COD) concentrations, and nitrogen concentrations-the dry weather file depicts what is normal diurnal variations [18,30]. To calculate performance, the system (closed-loop configuration) is first run to steady state by applying a defined constant influent file over a 150-day period of stabilization with no noise on the measurements. Dynamic simulation then occurs by first applying 14 days of the dry influent weather file followed by 14 days of the dry, rain, or storm influent file depending Processes 2021, 9, 1854 4 of 14 on which weather conditions the user selects. The performance of the benchmark is then evaluated for the last 7 days of dynamic data [22,24,29].
To carry out simulations, dry weather conditions were selected, a commercial software (SIMBA # ) was used, and the methodology mentioned above was applied. To this end, the following steps were executed: (i) the software ran at steady state for 150 days and stored the file; (ii) it loaded the last file, ran with data given in the dry weather influent file for 14 days (0-14), and stored the file; (iii) it loaded the last file, ran with data given in the dry influent file for 7 days (0-7), and stored the file; (iv) it loaded the last file, ran with data given in the dry weather influent file for 7 days (7)(8)(9)(10)(11)(12)(13)(14), and stored the file; and finally (v) it calculated mean values of effluent-related parameters for the last 7 days (7)(8)(9)(10)(11)(12)(13)(14). However, ASM1 was slightly modified to meet the needs of the software.
In this work, the default control strategy, Strategy 1, as defined above, was first simulated. Subsequently, additional basic control loops, as given by [31], were added, and six new user-defined strategies, Strategies 2-7, were created and simulated (see Table 1). The control loops that were additionally added aimed at either controlling the DO concentration in the first and the second aerobic tank by manipulating the respective mass transfer coefficient k L a values based on DO concentration measurements in each reactor, or by controlling ammonia in the last aerated tank by manipulating the DO concentration set point, i.e., a primary ammonia controller, together with three secondary DO controllers in a cascade control configuration. In regard to ammonia-related strategies, both a strict set point for ammonia concentration and a looser one were tested. Finally, Strategies 2-7 appeared in two versions; one included a nitrate controller, whereas the other included no such controller (see Table 2). Information on the scenarios relating to energy flexibility solutions is given later.

Energy Market in Germany and Analysis of Energy Consumption Data
The different electricity markets include the forward/future market, the day-ahead market, the intraday market, and the balancing market. The forward/future markets run from years before to the day before delivery. In the day-ahead market, electricity is traded one day before delivery, whereas in the intraday market, electricity is traded on the delivery day. Finally, the balancing market, which is the last in a sequence of electricity markets, occurs just minutes before the energy delivery [32][33][34][35][36]. The European Market Coupling, of which EPEX SPOT is a major contributor, allows for electricity to flow freely Processes 2021, 9, 1854 5 of 14 across borders. As such, it is distributed more efficiently all over Europe because flows follow price signals. EPEX SPOT, which was our focus of interest, operates the most liquid day-ahead and intraday markets in Europe. Both markets fulfill different purposes, and they are indispensable links of the energy value chain [37].
In regard to this work, the most important market was the day-ahead. In Europe, day-ahead markets are also known as spot markets, or markets where electricity is traded for immediate use; however, they are practically forward/future markets, as they deal with electricity and reserves for future use. However, the term forward/future market is mostly used for markets that take place before the day-ahead market [33]. The day-ahead market allows electric energy trading one day ahead of energy delivery. It is cleared around noon the day before to the day on which energy is to be delivered. Clearing at noon one day before means 12 h anticipation regarding the first delivery hour, and 35 h anticipation regarding the last delivery hour. Such anticipation is needed by some energy producers, like nuclear plants or coal plants, due to their technical limitations on operational flexibility [32]. In more detail, the trading is driven by its participants. A buyer needs to assess the amount of energy they need in order to fulfil their customer's requirements for the following day, and the cost of its purchase price hour by hour. The seller also submits the quantity they can deliver next day, and at what price level on an hourly basis. The deadline for the members to submit the price and the quantity for which they seek to make an agreement is 12:00 noon Central Europe Time (CET). These bids are inserted into a complex algorithm to calculate the clearing price. This process takes around 42 min. From 12:00 midnight CET next day, the sellers deliver the power at the contracted rate [38].
However, the day-ahead market has to be complemented by the intraday and balancing markets to overcome unplanned events, e.g., unexpected power plant outages, and changing weather conditions, e.g., better wind forecasts, thus allowing market participants to correct for shifts in their day-ahead nominations [33,39]. In Germany, the intraday markets, typically organized by power exchanges, take the form of continuous trading allowing purchasing and selling of electricity throughout the whole day, up to a few minutes before delivery. On the intraday market, market participants trade continuously, 24 h a day, with delivery on the same day. Electricity can be traded up to 5 min before delivery, and through hourly, half-hourly, or quarter-hourly contracts. As this allows for a high level of flexibility, members use the intraday market to make last-minute adjustments and to balance their positions closer to real time, something already mentioned above. However, intraday prices have not been studied as intensively as their day-ahead counterparts, and research typically focuses only on short-term forecasts, so it assumes knowledge of the day-ahead prices. The final balancing of the demand and supply is achieved through the balancing markets, which are controlled by system operators and aim at securing the system's stability [37,39]. More detail on the German Energy Market is given by the Federal Ministry of Economic Affairs and Energy in [40].
In this work, as we concentrated on the German electricity market, we used day-ahead electricity prices as provided by the EPEX SPOT for the calculations. At the time of writing of this document, EPEX SPOT data were available until the end of 2020. For this work, we needed to know electricity prices for at least 14 consecutive days, 24 h a day, as the software used a 14 day data set on a loop for the whole duration of simulations. As it was decided for this work to concentrate on the most recent data, we selected a set of data in autumn 2020 with the values lying between 21 September 2020 and 4 October 2020-this is also shown in Figure 1. During this time, the average electricity price was equal to 39.99 € MWh −1 , with 50% of the values being equal to or lower than the average.
To carry out this research, the educated guess was made that one fourth of the time under study should have been subject to energy flexibility. The 75th percentile for the selected set of data was calculated to determine the corresponding price limit for purchase of electricity, and it was found to be equal to 51.15 € MWh −1 . The time above the limit comprised 19 flexibility calls ranging from 1 hour to 17 consecutive hours. To explain Processes 2021, 9, 1854 6 of 14 further, a price of 51.15 € MWh −1 means that a plant operator can unrestrictedly buy electricity any time it is being sold at a price below or equal to 51.15 € MWh −1 , whereas flexible solutions must be identified each time electricity is being sold at a price over 51.15 € MWh −1 . During these times, options like shutting down the plant, switching off items of equipment, or reducing DO concentration in aeration tanks can be taken into consideration [22].  To carry out this research, the educated guess was made that one fourth of the time under study should have been subject to energy flexibility. The 75th percentile for the selected set of data was calculated to determine the corresponding price limit for purchase of electricity, and it was found to be equal to 51.15 € MWh −1 . The time above the limit comprised 19 flexibility calls ranging from 1 hour to 17 consecutive hours. To explain further, a price of 51.15 € MWh −1 means that a plant operator can unrestrictedly buy electricity any time it is being sold at a price below or equal to 51.15 € MWh −1 , whereas flexible solutions must be identified each time electricity is being sold at a price over 51.15 € MWh −1 . During these times, options like shutting down the plant, switching off items of equipment, or reducing DO concentration in aeration tanks can be taken into consideration [22].
In this work, two energy flexibility scenarios plus the default scenario without energy flexibility were tested per strategy-these scenarios took effect only during the flexibility calls, while the rest of the time the aeration was as per the applied strategy. Both scenarios were selected bearing in mind that the nitrifying bacteria, to the best of our knowledge, would not be endangered at any time. Therefore, the evaluation of the simulation results in terms of effluent water quality was carried out based on ammonia concentration. Scenario 1 recommended shutting off aeration in all three aeration tanks; however, any time ammonia concentration would be over 4 mgN L −1 , the aeration was reinstated. Scenario 2 recommended intermittent aeration, which was subject to a 1 h on/off aeration cycle during which aeration was suspended for the first 30 min and reinstated for the remaining 30 min. Scenario 1 was then characterized by an undetermined on/off aeration cycle that depended on changes of the effluent quality, whereas Scenario 2 depended on a well-determined aeration scheme, which was unaffected by any changes of treated water quality. However, for both scenarios, air flowrate was never equal to zero during the aeration shut-off periods, as a minimum very low air flowrate was maintained to ensure enough mixing without having to use mechanical mixers. This minimum air flowrate corresponded to a kLa-value of 20 d −1 according to guidelines provided by IWA [30]. An overview of the studied flexibility scenarios can be found in Table 3 below.  2 3 4 5 6 7 8 9 10 11 12 13 14 Hourly Electricity Prices over Time (14 days In this work, two energy flexibility scenarios plus the default scenario without energy flexibility were tested per strategy-these scenarios took effect only during the flexibility calls, while the rest of the time the aeration was as per the applied strategy. Both scenarios were selected bearing in mind that the nitrifying bacteria, to the best of our knowledge, would not be endangered at any time. Therefore, the evaluation of the simulation results in terms of effluent water quality was carried out based on ammonia concentration. Scenario 1 recommended shutting off aeration in all three aeration tanks; however, any time ammonia concentration would be over 4 mg N L −1 , the aeration was reinstated. Scenario 2 recommended intermittent aeration, which was subject to a 1 h on/off aeration cycle during which aeration was suspended for the first 30 min and reinstated for the remaining 30 min. Scenario 1 was then characterized by an undetermined on/off aeration cycle that depended on changes of the effluent quality, whereas Scenario 2 depended on a well-determined aeration scheme, which was unaffected by any changes of treated water quality. However, for both scenarios, air flowrate was never equal to zero during the aeration shut-off periods, as a minimum very low air flowrate was maintained to ensure enough mixing without having to use mechanical mixers. This minimum air flowrate corresponded to a k L a-value of 20 d −1 according to guidelines provided by IWA [30]. An overview of the studied flexibility scenarios can be found in Table 3 below.

Simulations and Discussion
As a first step, the control strategies had to be evaluated against ammonia concentrations in the effluent. In this approach, simulations where carried out for each of the  Tables 1 and 2 without any consideration for energy prices (noenergy-flexibility scenario). Simulations were then conducted for the seven control strategies with the integration of energy prices according to Scenario 1 and Scenario 2. The resulting time series from the simulations for two of the seven strategies, Strategy 1 and Strategy 5, are shown in Figures 2 and 3 below, respectively. Further analysis of the performance of the strategies in the different scenarios is presented in Section 3.3.

Condition regarding effluent quality
Effluent ammonia concentration below 4 mgN L −1

Simulations and Discussion
As a first step, the control strategies had to be evaluated against ammonia concentrations in the effluent. In this approach, simulations where carried out for each of the strategies described in Tables 1 and 2 without any consideration for energy prices (no-energyflexibility scenario). Simulations were then conducted for the seven control strategies with the integration of energy prices according to Scenario 1 and Scenario 2. The resulting time series from the simulations for two of the seven strategies, Strategy 1 and Strategy 5, are shown in Figures 2 and 3 below, respectively. Further analysis of the performance of the strategies in the different scenarios is presented in Section 3.3.   Based on Figure 2 above, the time series for the no-flexibilization scenario indicated that the presented control strategies were unable to maintain the ammonia concentration in the effluent below the critical value as defined for the BSM1 model (4 mgN L −1 ) throughout the whole time period of 7 days. The same was true for the remaining strategies. The fact that this also applied to the default strategy (strategy 1) indicates that the BSM1 model has been designed so that water quality in the effluent does not meet the required criteria all the time.
Taking into account the results described above, a comparison between the strategies in relation to their flexibility capacity and treatment performance was carried out for each scenario. The percentage of time during which the concentration limit for ammonia in the effluent was not met was quantified, along with the energy consumption as the sum of aeration energy and pumping energy. In this work, the pumping energy was regarded as the sum of the energy consumed for the removal of the excess sludge for the internal recycle and for the external one. Results are summarized in the following sections.

Control Strategies: No-Energy-Flexibility Scenario
The parameters for the control strategy evaluation for the scenario without energy flexibilization are presented in Table 4 below. Based on Figure 2 above, the time series for the no-flexibilization scenario indicated that the presented control strategies were unable to maintain the ammonia concentration in the effluent below the critical value as defined for the BSM1 model (4 mg N L −1 ) throughout the whole time period of 7 days. The same was true for the remaining strategies. The fact that this also applied to the default strategy (strategy 1) indicates that the BSM1 model has been designed so that water quality in the effluent does not meet the required criteria all the time.
Taking into account the results described above, a comparison between the strategies in relation to their flexibility capacity and treatment performance was carried out for each scenario. The percentage of time during which the concentration limit for ammonia in the effluent was not met was quantified, along with the energy consumption as the sum of aeration energy and pumping energy. In this work, the pumping energy was regarded as the sum of the energy consumed for the removal of the excess sludge for the internal recycle and for the external one. Results are summarized in the following sections.

Control Strategies: No-Energy-Flexibility Scenario
The parameters for the control strategy evaluation for the scenario without energy flexibilization are presented in Table 4 below. As seen in the table above, addition of the nitrate control loop to a strategy slightly deteriorated performance in terms of removal of ammonia. In other words, when comparing two strategies between which the only difference was the existence or not of the nitrate control loop, the one that lacked it ensured a larger percentage of time during which ammonia concentration in the effluent was below 4 mg N L −1 . After running the simulations, lower nitrate concentrations in the effluent were recorded when the nitrate control loop was used, which could have been a result of poorer nitrification. This could have produced higher ammonia concentrations in the effluent, which subsequently increased the length of time during which concentration was above the critical concentration. After all, the role of the nitrate control loop is not related to nitrification-rather, its role is to improve the denitrification that is taking place in the anoxic zone.
Strategy 5, which controlled ammonia in Tank 5 at 1 mg N L −1 and lacked any nitrate control loop, had the best performance of all strategies. On the other hand, Strategy 6, which controlled ammonia in Tank 5 at the much higher value of 3.5 mg N L −1 and included the nitrate control loop, was the worst. This means that the selection of the set point in ammonia-based control strategies was very important. At this point, it is also worth mentioning that the three water quality parameters of interest that are not strongly or not at all related to nitrogen, that is COD (concentration limit in the effluent: 100 g COD m −3 ), total suspended solids (TSS) (concentration limit in the effluent: 30 g SS m −3 ), and 5-day biochemical oxygen demand (BOD 5 ) (concentration limit in the effluent: 10 g BOD5 m −3 ) [22], always remained below the limit for all strategies, making ammonia concentration the critical parameter that required continued attention.
However, in terms of total energy consumption, results were different. As already mentioned, energy in this work was assumed to be the sum of electricity that was consumed for pumping and aeration-the formulas and the coefficients used for the calculation are provided in [22]. In this case, upon the comparison of two strategies for which the only difference was the existence or not of the nitrate control loop, the one including the control loop consumed less energy. This was expected as the nitrate control loop kept alternating the flowrate of the internal recycle and adjusting it to the values required. On the other hand, when the nitrate control loop was excluded, the flowrate remained constant regardless of the needs of the WWT plant. This time, Strategy 6, which controlled ammonia in Tank 5 at 3.5 mg N L −1 , and included a nitrate control loop, appeared to have the best performance of all strategies. On the other hand, Strategy 5, which controlled ammonia in Tank 5 at the much lower value of 1 mg N L −1 and lacked the nitrate control loop, was the worst. From the above, it can be said that the percentage of time over the limit and the energy consumption rate are inversely related. However, the percentage of time over the limit for Strategy 5 was 2.6 times less than that in Strategy 6, and the energy consumed was 1.3 imes higher accordingly. To this end, Strategy 5 was better than Strategy 6; however, the final decision always depends on what the plant operators consider to be more important.

Scenario 1: Undetermined On/Off Aeration Cycle
Scenario 1 ordered that air would be shut off in all three aeration tanks each time the electricity price was equal to or higher than 51.15 € MWh −1 and the ammonia concentration at the exit of the aerobic zone was below 4 mg N L −1 -any time the concentration was over 4 mg N L −1 , aeration did not stop or, if had already been interrupted, it was reinstated. As for the analysis above, the evaluation parameters are summarized in Table 5. Similarly to the case where the no-energy-flexibility scenario was applied, Strategy 5 both had the best performance with respect to percentage of time during which ammonia concentration in the effluent exceeded the limit and consumed the largest amount of energy over time. Even though Strategy 6 was no longer the strategy that consumed the lowest amount of total energy, it still remained the best among the ammonia-related control strategies. In terms of percentage of time during which aeration was shut off, this strategy was characterized by the second longest period during which aeration could remain suspended, behind only Strategy 4, for which difference with Strategy 5 was the inclusion of the nitrate controller. To this end, there seems to be some contradiction, as the strategy that maintained the air blowers switched off for more time than most of remaining strategies also had the highest energy consumption rate. However, as seen in Figure 4, which shows the course of the sum of the k L a values in all three aeration tanks for Strategies 3, 5, and 7, which were selected because all of them excluded the nitrate controller and their comparison was feasible, this occurred due to nature of the control strategy. In regard to this strategy, it is true that the air system was shut down for a long time, but for the rest of time, DO concentration values could freely soar up to 4 mg O2 L −1 each time that was required, significantly increasing the k L a values and consequently the energy consumption. However, based on the priorities set, Strategy 5 was still the best strategy in terms of performance. This strategy ensured the shortest period of time during which ammonia concentration surpassed the limit, which was the highest priority, and, at the same time, it ensured a quite long period of time during which aeration remained shut off, which was the second most important condition, as the idea was to buy as little electricity as possible during the times this was expensive.

Scenario 2: Predetermined On/Off Aeration Cycle
Scenario 2 ordered that air would be shut off in all three aeration tanks each time the electricity price was equal to or higher than 51.15 €, according to the determined aeration cycle of 30 min on/30 min off. This means that for a fixed 12.5% of the 25% of the time that was subject to energy flexibility, the aeration would be suspended. Like the analysis before, the evaluation parameters are summarized in Table 6. was required, significantly increasing the kLa values and consequently the energy consumption. However, based on the priorities set, Strategy 5 was still the best strategy in terms of performance. This strategy ensured the shortest period of time during which ammonia concentration surpassed the limit, which was the highest priority, and, at the same time, it ensured a quite long period of time during which aeration remained shut off, which was the second most important condition, as the idea was to buy as little electricity as possible during the times this was expensive.

Scenario 2: Predetermined On/Off Aeration Cycle
Scenario 2 ordered that air would be shut off in all three aeration tanks each time the electricity price was equal to or higher than 51.15 €, according to the determined aeration cycle of 30 min on/30 min off. This means that for a fixed 12.5% of the 25% of the time that was subject to energy flexibility, the aeration would be suspended. Like the analysis before, the evaluation parameters are summarized in Table 6.  Similarly to before, Strategy 5 once again had the best performance in terms of ammonia removal at the exit of the plant. Strategy 5 was also the best strategy with respect to the percentage of time during which the air blowers remained switched off; however, in this scenario, this made no difference as all strategies were characterized by the same percentage. Finally, the total energy consumed by Strategy 5 was again the largest, with Strategy 6 being the one that consumed the least among the ammonia-related strategies, which was in line with Scenario 1. It is clear from Figure 5a that Scenario 1 removed more ammonia than Scenario 2. All control strategies for Scenario 2 ended up with a higher percentage of time over the ammonia concentration limit than their respective strategies for Scenario 1. This means that the undetermined cycle of Scenario 1, which was governed by effluent quality restrictions, complied with the regulations for a longer period of time than the predetermined cycle of Scenario 2, which was based on a fixed on/off aeration cycle.

Aggregated Results and Final Discussion
Strategy 5 always had the best performance regardless of the scenario. However, as Strategy 5 for Scenario 1 maintained the ammonia concentration in the effluent within limits for a longer time period than any other strategy in both scenarios, this strategy seemed to be the most attractive. Of course, that strategy was characterized by the highest energy consumption overall (see Figure 5b); however, the total energy consumed was of low priority to this work and instead, the important consideration was the amount of energy that had to be bought during the flexibility calls. Even though the time during which aeration was shut off was slightly less (12.35%) than the 12.5% that was ensured by all strategies for Scenario 2 and Strategy 4 for Scenario 1 (see Figure 5c), the fact that the latter had longer time periods during which the ammonia concentration was over the limit helped to determine Strategy 5 for Scenario 1 as the best possible option. From the above, it is clear that the control of ammonia at the exit of Tank 5 was critical. However, despite the fact that Strategies 4 and 5 for both scenarios managed to control the system best, Strategies 6 and 7 significantly failed to achieve this, in spite of all four having aimed at controlling ammonia in the same place. This means that it was not the strategy itself that determined the performance, but the selected set point. Therefore, the stricter the set point, the better the ammonia removal, but, on the other hand, the stricter the set point, the larger the amount of total energy consumed. Similarly to before, Strategy 5 once again had the best performance in terms of ammonia removal at the exit of the plant. Strategy 5 was also the best strategy with respect to the percentage of time during which the air blowers remained switched off; however, in this scenario, this made no difference as all strategies were characterized by the same percentage. Finally, the total energy consumed by Strategy 5 was again the largest, with Strategy 6 being the one that consumed the least among the ammonia-related strategies, which was in line with Scenario 1. It is clear from Figure 5a that Scenario 1 removed more ammon control strategies for Scenario 2 ended up with a higher percentage monia concentration limit than their respective strategies for Scena the undetermined cycle of Scenario 1, which was governed by efflue complied with the regulations for a longer period of time than the p Scenario 2, which was based on a fixed on/off aeration cycle.

Aggregated Results and Final Discussion
Strategy 5 always had the best performance regardless of the s Strategy 5 for Scenario 1 maintained the ammonia concentration limits for a longer time period than any other strategy in both sc seemed to be the most attractive. Of course, that strategy was charac energy consumption overall (see Figure 5b); however, the total ene low priority to this work and instead, the important consideration w ergy that had to be bought during the flexibility calls. Even though t aeration was shut off was slightly less (12.35%) than the 12.5% th strategies for Scenario 2 and Strategy 4 for Scenario 1 (see Figure 5c), had longer time periods during which the ammonia concentratio helped to determine Strategy 5 for Scenario 1 as the best possible op Now, if priority had been given to the amount of time during which aeration had been suspended, Strategy 5 for Scenario 1 would have been replaced by Strategy 4 for Scenario 1 as the best option, meaning that Scenario 1 always outmatched Scenario 2. This is due to the fact that all strategies for Scenario 2, plus Strategy 4 for Scenario 1, had the same percentage of time during which aeration was shut off (12.5%); however, Strategy 4 for Scenario 1 had a shorter period of time during which the ammonia concentration at the exit surpassed the limit. Although Strategy 4 had a slightly higher total energy consumption for Scenario 1 than for Scenario 2, the maximum time during which equipment was switched off for Scenario 2 was half an hour, whereas for Scenario 1, that time was equal to three hours. In general, the more time the equipment is switched off, the greater the possibility that the bacterial culture is affected. Even though the model showed that three consecutive hours of almost zero air provision had no detrimental effect on the bacterial culture, as ammonia removal was able to reinstate when air blowers were switched on again, we recommend that this also be confirmed experimentally.
Even though this is a preliminary piece of work in the field, it is quite useful, as it provides the reader with a methodology for dealing with demand-side energy flexibility in wastewater treatment plants. This work managed to evaluate a number of different control strategies against potential energy flexibility options and opened up new possibilities for more options to follow. Therefore, this methodology can soon be applied to real wastewater treatment plants. In any case, more scenarios must be tested and evaluated in the near future, and concepts like on-site energy storage and the wastewater treatment plant as a micro-grid, together with on-site energy production, either related to anaerobic digestion or not, must be considered. However, these preliminary results appear to be quite promising, and the methodology used can be easily adopted by plant operators who are interested not only in reducing energy consumption when it is expensive, but also in enhancing the water sustainability credentials of their plants.

Conclusions
The definite future prioritization of weather-dependent renewable energy resources in the energy sector will unavoidably lead to fluctuations in electricity production. Because of this insecurity in production, all energy producers and consumers are due to explore energy flexibility schemes in the near future. WWT plants are rather energy-intensive, so potential energy flexibility solutions are imperative so that their operators can cope with high peak electricity prices successfully.
In this work, we sought ways of providing on-site energy flexibility through demandside response for the wastewater treatment plant of the BSM1. The plant was first tested under seven different control strategies, including the default strategy along with six additional more advanced strategies which controlled DO in the whole aerobic zone, either with or without an ammonia primary controller. This analysis, which was the reference point for this work, was free from any energy flexibility scenario. Next, two energy flexibility scenarios were put in place and all strategies were evaluated against the new operating conditions.
Results showed that when the no-energy-flexibility scenario was employed, the ammonia concentration in the effluent was at times higher than the upper limit, so there was a percentage of time during which treated water was not suitable for discharge. Introduction of the flexibility scenarios in the model further diminished this percentage of time; however, Scenario 1, which was based on an undetermined on/off aeration cycle, outperformed Scenario 2, which was based on a predetermined one. Strategy 5 for Scenario 1, which controlled ammonia in Tank 5 at a rather strict set point, was found to be the best option, although the most expensive. However, in this research, the amount of energy that had to be bought during the flexibility calls was more critical than the overall energy consumed, so Strategy 5 for Scenario 1 still remained the best choice as it had a slightly larger percentage of time during which the air blowers were switched off.

Conflicts of Interest:
The authors declare no conflict of interest. Also, the funders had no role in the design of the study; in the collection, analyses, or interpretation of data; in the writing of the manuscript, or in the decision to publish the results.