Mrs Isabelle Queinnec

Mr Ibrahim Cherki

Mr Marc Héran

Mrs Amal Choukchou

Mrs Sihem Tebbani

Mr Karim Yadi

Mrs Samia

Mr Claude

Otacılio B L Neto

Antoine Haddon

Farouk Aichouche

Jérôme Harmand

Michela Mulas

Keywords: Flexibility, Modelling, Control, Reuse, Optimization, Wastewater treatment, Observation Flexibilité, Modélisation, Contrôle, Réutilisation, Optimisation, Traitement des eaux usées, Observation

To meet the challenges of the scarcity of good quality water resources, the reuse of treated wastewater ("REUT" in French or "REUSE" in English) appears to be a solution for the future. It prevents the treated water from being released into the environment without giving it a second life, or even more. To do this, we are promoting a paradigm shift in which wastewater is no longer seen as waste to be depolluted but a new resource that can be treated on a custom basis, depending on the needs and uses in new energy recovery facilities, to recover nutrients and other molecules of interest. This sustainable management of water resources comes up against many challenges, in particular technical problems such as the lack of flexibility of current wastewater treatment plants. Faced with the great challenge of providing, in a dynamic and economically acceptable manner, a quality of treated water adapted to the needs of agriculture, and in order to reduce the environmental impacts, automatic control technologies certainly have an essential role to play. This study, which is freed from current regulatory limitations as it is essentially carried out in simulations, presents the preliminary results of research with the development of a simulation platform for a flexible system combining activated sludge treatment plants with a membrane filtration process. We evaluate how the control of the whole, based on the use of industrial controllers and advanced control, can be used to adapt in real time, under conditions of martial measurements and in the presence of uncertainties and disturbances, a water whose the quality meets the needs of the plants / crops or, on the contrary, when necessary, meets the quality constraints required for release into the environment. The approach requires knowing the needs of plants. As the latter are difficult to continuously measure, part of the work is dedicated to the synthesis of unknown input observers to estimate the amount of water available for the plant in the soil (and therefore accessible for evapotranspiration). Finally, since the cost of wastewater treated by membrane filtration technologies is often prohibitive for users, we are evaluating the extent to which recourse to optimal control approaches, in particular the Maximum Pontryagin Principle, would make it possible to reduce these cost by optimizing the management of the clogging of these membranes and thus minimizing the functioning cost of these systems.

iii

Résumé en Français

Pour répondre aux enjeux de la raréfaction des ressources en eau de bonne qualité, la réutilisation des eaux usées traitées ('REUT' ou 'REUSE') apparaît comme une solution d'avenir. Elle permet de ne pas rejeter l'eau traitée dans l'environnement sans lui faire subir une seconde vie, voire davantage. Pour cela, nous promouvons un changement de paradigme dans lequel les eaux usées ne sont plus vues comme des déchets à dépolluer mais une nouvelle ressource pouvant être traitée à façon, dépendant des besoins et des usages dans de nouvelles installations de récupération d'énergie, de nutriments et autres molécules d'intérêt. Cette gestion de la ressource en eau se heurte à de nombreux défis, notamment des problèmes techniques tels que le manque de flexibilité des stations d'épuration actuelles. Face au grand défi de fournir, de manière dynamique et économiquement acceptable, une qualité d'eau traitée adaptée aux besoins de l'agriculture, et afin de réduire les impacts environnementaux, les technologies de l'automatique ont assurément un rôle essentiel à jouer. Cette étude, qui s'affranchit des limitations règlementaires actuelles car essentiellement menée en simulations, présente les résultats préliminaires de recherches combinant le développement d'une plateforme de simulation d'un système flexible combinant des systèmes de traitement à boues activées à un procédé de filtration membranaire. Nous évaluons comment le contrôle de l'ensemble, fondé sur l'utilisation de controleurs industriels et de commande avancée, peut être utilisé pour adapter en temps réel, en conditions de mesures partielles et en présence d'incertitudes et de perturbations, une eau dont la qualité répond aux besoins des plantes/cultures ou, au contraire, lorsque nécessaire, est conforme aux exigences de qualité requises pour un rejet dans l'environnement. L'approche nécessite la connaissance des besoins des plantes. Ces dernières étant difficilement mesurables en continu, une partie du travail est dédiée à la synthèse d'observateurs à entrées inconnues pour estimer la quantité d'eau disponible pour la plante dans les sols (et donc accessible pour l'évapotranspiration). Enfin, le coût de l'eau usées traitée par les technologies de filtration membranaire étant souvent rédhibitoire pour les irrigants, nous évaluons dans quelle mesure le recours à des approches de contrôle optimal, notamment le Principe du Maximum de Pontryagin, permettrait de faire baisser ces coût en optimisant la gestion du colmatage de ces membranes et donc le coût de fonctionnement de ces systèmes.

vi conseils qu'il m'a porté pendant les comités de suivi de thése. Merci à Eric Trably pour ses encouragements. Merci à toutes et à tous qui j'ai rencontré au LBE, Merci à Rémi, Dominique, Renaud, Elie, Diana, Kim, Julie, Eric Latrille, Virginie et tous les personnels Je voudrais aussi remercie toutes et tous mes collègues que j'ai rencontré pendant ces années passées au LBE. Merci à Pablo, Hicham, Noémie, lucie, Esmee, ... pour les bons moments et les encouragements. Mes sincères remerciments à mes collègues de Bureau : Gaetano et Fernanda à qui j'apporte toute mon amitié et mon respect, je vais jamais oublié les bons moment que nous avons passer ensemble et je vous souhaite le succès et la réussite dans votre vie.

Then, a particular thanks is addressed to Alain Rapaport for sharing with me his expertise in the field of optimal control and for your guidance during the whole duration of my theses and during the thesis committees. Thank you very much Mr. Denis Douchain for learning me innovative control strategies, particularly cascade control and for your availability to answer my questions either remotely or during my stay at UCLouvain, Belgium, ICTEAM. I would also like to thank you for accepting me in your laboratory and for lending me your office and some essential coffee capsules. Many thanks also to all the administrative staff of ICTEAM, in particular to Marie-Christine Joveneau.

I would like to thank Prof. Marc Héran for sharing with me the interest about the development of the innovative flexible platform, that used in this work, thank you also for accepting to be the referent of my work thesis and for all your guidance which you gave me all along this thesis.

I would like to express all my feelings, my profound respect and my sincere gratitudes to Brahim CHERKI, professor at the University of Tlemcen. You are for me an example of an ideal professor, your qualities, both human and professional, They reflect your good spirit and your kind intention My thoughts naturally go to the Control4Reuse project members , thanks for the Swedish colleagues: Eva Thorin, Monica Odlare, Erik Dahlquist, Heidi Marais and Eva Nordlander, and thanks for the Brazilian colleagues : Michela Mulas, Francesco Corona and Minho Otacilio, for all the exchanges on Modeling and control of WWTP and especially for the time dedicated for sharing with me their expertise to improve the quality of this PhD thesis.

My last words are addressed to my familly, Thank you Mummy Dearest for your wishes for me, I know you would be so proud of me. Thank you Dad for always supporting me in my decisions, even my most difficult ones. You are my real teachers and the reason I am who I am today. Thank you also to my brothers and sisters. You have always inspired me so much and even without knowing it, you contributed to the achievement of this thesis. Thank you my wife for supporting me during the achievement of this thesis (green) and nitrite (red) concentrations in the effluent. . . . . . . . . . . . . 3.4 Effects of dilution. Dynamic ammonium (blue) and nitrate (green) and nitrite (red) concentrations in the effluent for returned sludge directed to anoxic tank (dashed line) or to aerobic tank (continuous line). . . . . . . . . 3.5 Influence of biomass addition. Ammonium (blue) and nitrate (green) and nitrite (red) concentrations in the effluent for two cases of addition of nitrification bacterial : 10 mg/L (dashed line), 1 mg/L (continuous line) . . . . .

List of Tables

1.1 Some of the previous studies on the innovative activated sludge processes .

General Introduction

I. Introduction

World population growth, climate change, decline in biodiversity and increase of food demand are creating a dual challenge for both emerging and developed countries in terms of environmental protection and water demand. At a global scale, wastewater treatment (realized in wastewater treatment plants or WWTP) is one of the essential aspects of water resource preservation, notably since, whatever its quality, wastewater is always finally released in the environment. Water scarcity -or water stress -is a phenomenon that occurs when the demand for water exceeds the available resources. In 2025, more than half of the world's population will live in water-stressed regions [OMS ]. The United Nations Environment Programme (UNEP) estimates that water resources are sufficient if the amount available per person per year is greater than or equal to 1700 m 3 . Less than 1000 m 3 per person per year corresponds to a water stress situation [PNU ]. Water stress can have important consequences for the environment, economy, public health, etc..., and it may lead to important conflicts of use (e.g. agriculture vs. food demand). About 70% of total water consumption worldwide is used for agriculture. In 2017, 4000 Km 3 of water were withdrawn over the world: on this volume only 1,2% is reclaimed after treatment and 6,3% is directly reused without treatment. This situation leads to a worrisome imbalance between demand and availability of water resources. Even if the water resource is saved, which is an obligation in view of the looming shortage, the Agriculture will continue to develop in the world: agricultural production was multiplied by a factor of between 2.5 and 3 over the last 50 years but the cultivated area increased by only 12%. More than 40 % of the increase in food production was provided by irrigated areas, which doubled in surface. During the same period, the area of cultivated land per person has gradually decreased to less than 0.25 ha Fig. 1. Clear evidence of shortage of water sources for irrigation in the regions with water scarcity appears all around the world. In some regions, the overall increase in production has been associated with the degradation of soil and water resources and the worsening of the goods and services provided by the ecosystems involved as biomass, carbon fixation, soil quality, biodiversity, water retention and supply. The increasing water scarcity requires developing efficient technologies that would allow the use of treated wastewater as an 'unconventional water resource', by treating them to a level of quality adapted to the user's needs and usages.

The reasons leading to water stress and the necessity to protect the environment are relevant motivations to develop the reuse of treated wastewater and protect water resources. From an environmental point of view, the reuse of treated wastewater has many advantages. In the case of sensitive natural areas, the benefit is to reduce the volumes rejected into the receiving environment and better control it while limiting biodiversity decline. In addition, the exploitation of this resource makes it possible to reduce the demand on surface freshwater bodies, which often have a high environmental value (wetlands for example). This pressure reduction is achieved either indirectly by using treated wastewater instead of another resource, or directly by the transfer of good quality water where needed. In the latter case, recharging or maintaining the quality of water reserves (surface or underground) for drinking water is often also an issue. Treated wastewater is an economically interesting resource, because it is constant in quantity and, if its quality is controlled, it opens the route to a better management during water scarcity periods to maintain stable agricultural and industrial production. Although, when treated wastewater is reused in agriculture, it does not recharge rivers, this can cause major problems for closed systems such as the Mediterranean Sea, especially since it has a large number of desalination plants, but the reuse of treated wastewater in agriculture remains an alternative that contributes, when relevant, to reduce the pressure on good quality resources. However, the reuse of treated wastewater is still relatively in its infancy and limited throughout the world, due to many constraints that impede the advancement of this field. Some of these impediments are environmental, notably related to salinization risks and to the possible diffusion of heavy metals and micropollutants (cf. in Section. Health risks in reuse chain), while others are sanitary (possible dissemination of pathogens or antibiotic resistance gene -ARG) and economic, such as the ability to guarantee the health of users and to make the reuse of treated wastewater in agriculture acceptable by the citizens. While it is not allowed by the regulation to keep too much nutrients in effluent, the aim of this PhD thesis is to investigate how the use of modelling and control techniques could be used to optimize treatment plants for water reuse and in particular how the quality of treated wastewater could be adapted to crops needs. Indeed, the demand over time of the agriculture is not the same as the 'logic of availability': the 'production' of treated wastewater is almost regular throughout the year, while the demand for water from crops is modulated by agricultural cycles and seasons. It will then be necessary either, to store the treated wastewater 'produced' during periods when there is no demand for water (in which case, the quantity required by crops or plants may correspond to the available quantity of 'stored' treated wastewater, but not the quality), or create a system allowing to operate the WWTP in a flexible way in order to adapt both quantity and quality of wastewater treated 'produced' to the crops needs to come up with the notion of WRRF.

Within the framework of this PhD thesis, the 'flexibility' of a process refers to the ability of a treatment system to be controlled dynamically in such a way the quality of the treated water can be adapted to the quality required for its effective reuse. Thus, the reuse of treated wastewater requires a transition between two operation modes, called hereafter degraded-or full-modes.

The concept of 'adapting treatment to the needs of plants/crops' in a flexible treatment system may be optimized using closed-loop operations, where the water and nutrient needs must be continuously provided to the flexible treatment system (the WRRF) as a set point, either by measurements on the plants/crops themselves, or using mathematical models. Solving optimal control problems subject to disturbances (weather, input effluent characteristics) allow to generate such setpoints in terms of water contents (nutrients) and quantity to be delivered to the plants. There are many objectives that may be pursued with respect to the optimal control problems : they can be the maximization of the biomass produced during a season, the minimization of plant water needs or still the minimization of nutrients delivered to the plants under production yields constraints. Within this thesis, most of the associated risks are neglected or managed through technological considerations. One of the main risks -the sanitary risk related to the dissemination of pathogens into the environment -is supposed to be negligible as long as membrane bioreactors -through membrane filtration -are considered. The membranes are increasingly used as advanced treatment systems, by the combination of a biological treatment using activated sludge and liquid/solid separation by membrane. Using such systems allows one to achieve a water quality that is well adapted to reuse in ensuring a high retention degree of suspended solids. But the main drawback is the fouling of the membranes. It is the main reason for which this process is associated to higher operating energy costs than conventional activated sludge processes where a settling tank is used. This reduces the competitivity of MBR. The development of high-performance membrane reactors in optimizing filtration cleaning over the long term is therefore a major challenge. As membrane fouling is a complex mechanism, it remains difficult to control, despite the implementation of cleaning strategies such as chemical washing, injection of gas bubbles in the vicinity of the membrane, relaxation or backwashing [Charfi et al. 2015]. The control of membrane fouling could reduce the costs associated with membrane maintenance. The development of an optimal strategy for reducing energy consumption costs allows to promote the use of membranes in advanced treatment systems intended for reuse, to provide high quality treated water on the one hand, and to improve the performance of the flexible system for resource recovery on the other hand.

The present studies represent the first steps towards the development of a flexible system of a thoroughly designed and controlled complete reclamation chain for the treatment and reuse of treated wastewater for agricultural purposes. This aims at showcasing the advancements within the notion of wastewater treatment plant flexibility using modelling and control tools and stimulating the interaction with the automatic control at large.

II. How improving reuse of treated wastewater?

The current wastewater treatment plants (represented in the first figure of Fig. 2) aims to treat wastewater at a degree such as normative constraints are verified for the water to be released into the environment while the resulting sludge is, at best, used as fertilizer for agricultural and industrial needs. Such processes are not designed to carry out a treatment aimed at adapting the quality of the treated wastewater to the uses. It is based on the injection of an important amount of energy and produces CO2 and possibly nitrogen oxide, a powerful greenhouse gas.

The perspective of this system needs to be changed to reflect the paradigm shift towards a resource recovery approach as promoted by circular economy [Sfez et al. 2019]. In such a 'vision for the future', much less energy is injected into the system through energy recovery while a 'flexible system' may be optimized in such a way to precisely produce energy and water characteristics adapted to (possibly new) usages (cf. second figure of Fig. 2).

In an ideal situation (cf. the third figure of Fig. 2), the control diagram involves an 'integrated system' composed of the entire treatment chain -from the resource to the soil and plants -the input of this system being composed of the wastewater input characteristics while the output is the production and the state of the biomass of interest (or the state of the different usages we can think of). In this case, the challenge is to design a decision support/control system able to optimally compute the control inputs from the available measurements under a number of practical constraints and external disturbances. To do so, it is necessary to couple models of different natures that are models of WWTP/WRRF, models of water transport/storage, models of soil and plants... Such coupling is very difficult and some models, like models of plants are not so mature than those used for the biological treatment of wastewater. It is why, instead of considering this ideal vision, we will describe in the next section a slighly different approach after having reviewed some intrinsic limitations of the proposed approach.

II.1 Health risks in reuse chain

Irrigation with treated wastewater may have benefits in terms of providing nutrients to crops, mainly with three types of organic components that the wastewater contains: carbon, nitrogen and phosphorus. But it can also have disadvantages, because it also contains various contaminants: as present at trace state, called 'micropollutants'. This term refers Figure 2: The current situation, vision of the future and its ideal implementation for maximizing the recovery of resources in WRRF to a group of mineral or organic substances which can be toxic, even at very low concentrations of the order of micro or nano-grams per liter [Shakir et al. 2017]. They are used during industrial processes or are part of the composition of many agricultural or domestic products. These molecules can be grouped into several categories: pesticides, pharmaceutical or veterinary residues, organic compounds derived from plastics, etc. The reused wastewater also contains some pathogens (virus, fungi, bacteria etc) and emerging contaminants as antibiotic resistant genes which can render bacteria resistant. Therefore, the transfer of infections by these categories of contaminants is one of the main issues in the reuse of treated wastewater. In the following Section , we present some important limitations related to the health risks and environmental impacts.

II.2 Reuse limitations

The challenge of the reuse of treated wastewater in agriculture is double: on the one hand the preservation of water resources, and on the other hand the recovery of nutrients (in particular nitrogen and phosphorus) for crops or industrial usages. However, the reuse of treated wastewater for agriculture has many limitations that place it under a certain restriction such as :

• The presence of dissolved salts in water can have several agronomic consequences.

As the salinity increases, the osmotic gradient between soil water and plant root cells decreases. The plant must therefore expend more energy to recover water, which affects its growth [START_REF] Tchobanoglous | [END_REF]].

• The irrigation system used may have difficulties in dealing with loaded wastewaters. The fact of using such quality-tailored waters and thus the characteristics of treated wastewater can promote fouling through biofilm formation and/or chemical precipitation, notably when drip irrigation is used, [Lequette et al. 2019].

• The Nutrient contained in treated wastewater provide fertilizer value for crop production, but in some cases their form is proper to readily infiltrated into the soil, which can affect the quality of groundwater. [START_REF] Candela | [END_REF].

II.3 Limitations of the proposed approach

The innovative approach we propose presents a number of limitations that will deserve future work. Among these limitations, it should be underlined that if there are many models of plants describing the needs for water, there are very few models involving their needs in terms of nitrogen compounds and even less with respect to phosphorus or other compounds of interest. In addition, it is particularly difficult to propose optimization criterion that could be considered universal: with respect to which objective the innovative approach we propose should be optimal to? In the absence of obvious indicators and criteria to evaluate the performances, how to evaluate the reuse of treated water in terms of cost, performance and environmental impacts? Finally, what exactly flexibility stands for within the framework of this study?

III. Aims and Objectives

All around the world, treated or untreated wastewater is reused for irrigation of plants and crops [START_REF] Jiménez | Water reuse: An international survey of current practice, issues and needs[END_REF]. Treated wastewaters are widely reused for irrigation in semi-arid countries by necessity. The concept of reclaiming wastewater for reuse in agriculture promotes a shift from traditional irrigation to fertigation [Chojnacka et al. 2020],

where both irrigation and fertilization must satisfy the requirements of the plants/crops. Several approaches are developed for resources recovery and reuse for agriculture purposes, but the concept of adapting wastewater treatment to the plants/crops requirements for reuse is new and thus rarely studied.

An analysis of the current situation of water management and a review of advanced irrigation and wastewater treatment practices highlight the need for flexible efficient treatment wastewater facilities that considers wastewater as a water resource that can be reused in adapting its quality to the requirements of plants/crops. The objective of this work is to develop and study such strategies for the operation of a wastewater treatment system to produce water of adaptable quality that can be reused in agriculture. We propose an innovative approach that involves the use of a new concept of flexible wastewater treatment system, from which the system is dynamically controlled to operate according to demand. Therefore, the approach schematically represented in 3 is to use a first model that allows to identify (or to estimate using an observer) the water and/or nitrogen needs of the crop/plant, which is then used as setpoints within a flexible WRRF. In a closed loop, the flexible system will be dynamically controlled to meet the needs required by the plant/crop model. The optimal nitrogen requirement for crop is used to adapt the treatment in the flexible system and provide the necessary quality for optimal growth of the crops.

Additionally, this flexible system must be capable of providing several qualities of treated wastewater to meet irrigation needs during periods of water stress ( nutrients recovery in the treated water for reuse), but also to comply with discharging constraints outside of irrigation periods. In addition, it must be controlled in such a way the transitions periods between these two operating modes remain as small as possible. In this concept the transition dynamics between these two modes of operation are studied in order to determine the best combinations of the control degrees to minimize the response time of a transition (the time needed to switch from one mode to the other).

Furthermore, to adapt the output of the WRRF to plant needs, it is necessary to close the loop: since it is difficult to online estimate the water needs for the plant, we developed a method, based on the use of unknown input observers, to estimate plant needs in terms of water (more precisely we estimate the evapotranspiration of the plants) using measurements of soil water content.

Finally, to optimize the management of MBR and improve performances of such system, we developed optimal control algorithms to maximize the water produced over a given period of time while minimizing the required energy. The PhD thesis is organized as follows. The first chapter is a literature review that provides a general introduction of biological pathways to treat carbon and nitrogen present in wastewater, beginning with a brief introduction to aerobic treatment systems and the main processes used in conventional treatment with a description of their concept.

Chapter II describes the development of a simulation flexible platform able to be controlled in such a way to adapt the treatment according to requirements of plants/crops. This platform is analyzed numerically with respect to its possible functioning configurations, each of them representing an operating mode. Depending on the configurations of its actuators, the steady states are characterized. Additionally, an advanced control system is proposed based on the implementation of simple robust industrial controllers in cascade (PI). In terms of control design, several objectives are then pursued: by manipulating the continuous available actuators, we first show how controlling the output nitrate concentration S N O3 and then the ratio S N O3 /S N H in effluent. The requirements of crops used (the setpoints) is the optimal solution for the problem of maximizing crop biomass at the end of a growing season.

Chapter III presents the study of the time needed to switch from one functioning mode to another. The objective of this part is to analyze the best combination of control degrees for each operation mode, and to use these different degrees of freedom to minimize the time response to go from one mode to another.

Chapter IV is a preliminary study for estimating the water needed by a culture, under weather disturbances, from the measurement of the soil water content (SW C). This work is intended to optimize irrigation supply by providing guidelines to growers and farmers on sustainable water management.

Finally, chapter V presents a methodology to synthesize an optimal control feedback for membrane filtration system in order to improve the performances of filtration in wastewater system. Given the high price of the water produced for REUSE, the pursued objective is to optimize the whole process in minimizing the energy consumption under performance constraints.

The reader being familiar with the modeling of bioprocesses for environmental processes and the basis of control systems may directly go to chapter 2.

CHAPTER 1

Modeling and control of a WRRF for water Reuse A wastewater treatment plant, named WWTP, typically uses a combination of mechanical, physical, chemical and biological processes to remove pollutants from the influent wastewater. The activated sludge process is the most commonly used water treatment process. The biological treatment process removes major organic matter -carbon and/or nitrogen and phosphorus -from wastewater by means of microorganisms. In what follows we restrict attention to carbon and nitrogen removal. The biodegradable organic matter is oxidized by the micro-organisms and carbon dioxide is produced. Biological nitrogen removal is a two-step process that involves nitrification and denitrification. The activated sludge (flocculated biomass) is gravitationally separated from the treated wastewater in the secondary settler, and most of it is returned to the biological process through a recirculation circuit. Several process configurations exist.

Conventional activated sludge processes

The characteristics of an activated sludge process depend on the flow regime in the reactor, the size, the number and the configuration of the reactors used together with the recycle flows and the influent parameters, i.e. the environmental conditions or system constraints under which biological processes are constrained to operate. From the large variety of nitrification/denitrification activated sludge processes, three basic configurations are most frequently used in practice.

1.1.2.1 Pre-denitrification process [Ludzack & Ettinger 1962] has proposed a nitrification-denitrification process taking place simultaneously in a single tank. [Barnard 1973] proposed a modification of the Ludzack-Ettinger system by completely separating the anoxic and aerobic reactors to allow a predenitrification process Fig. 1.1 to take place. In this process, the denitrification step, which takes place in the anoxic reactor is placed upstream of the aerobic reactor of nitrification.

Wastewater coming into the process firstly passes through the denitrification step such as the organic matter contained in the wastewater is used as a source of carbon for denitrification. The ammonia is oxidized into nitrate in the final aerobic stage, and the nitrified liquor is recycled to the denitrification step by an internal recirculation.

Post-denitrification process

In a post-denitrification process (cf. Fig. 1.2), the nitrification step of the aerobic reactor is placed before denitrification process. The influent is discharged to the aerobic reactor where aerobic growth of both the heterotrophic and nitrifying organisms take place while nitrification is completed in the first reactor. Therefore, sufficient sludge age is allowed. The mixed liquor from the aerobic reactor passes through the anoxic reactor. Most of the This process was developed to improve the performance of pre-denitrification processes. The cost of pumping power for recycling the mixed liquor is very high for predenitrification process [Miyaji et al. 1981], in particular for a large scale wastewater treatment plant. The modification consists in creating a multi-stage process in which the denitrification and the nitrification compartments are arranged alternatively in series. Wastewater is equally divided into each of the denitrification compartments (cf. Fig1.3). Wastewater flow through the nitrification and denitrification compartments, successively while a limited part of the mixed liquor from the final nitrification compartment is recycled to the first denitrification compartment. Recent 'innovative activated sludge processes' have been proposed. They are advanced versions of the activated sludge process, aiming at improving performance relatively to a conventional process in terms of effluent quality while reducing operating costs. Several upgrading process designs for wastewater treatment plants have been developed (for instance Table .1.1), in response to changes in treatment needs and advances in understanding of process. These configuration processes have been used basically to maintain pollutant discharges within the restrictions that protect water resources.

Control of wastewater treatment plants

Automatic control is used in various industrial processes, including wastewater treatment.

To control a process, we must be able to 'act on it' with a control signal. Generally, the aim of control is to maintain one or several outputs of the process at desired value(s), despite disturbances. To do so, a fundamental concept is to use feedback using the available knowledge (measurements) or estimates of these outputs to compute the input signal -the control.

There are several general incentives to use control strategies in wastewater treatment plants:

• Meeting a strict effluent demand.

• Dampening the impact of process disturbances, as the load to a wastewater treatment plant usually shows large variations.

• Achieving a cost-effective solution, i.e. optimizing the operation in order to minimize operating costs.

The first step in the design of an automatic control system is to determine which are the available input and output signals. In a WWTP, many variables can be used to control nitrogen removal:

Control of hydraulic variables : Significant cost savings by utilizing the concept of optimization in the design of WW plants. [Guerrero et al. 2012] Min. Operating costs, Min.

Pollutants discharge, Min.

Risk of microbiologyrelated solids separation problems Optimisation process using multicriteria optimization for costs, pollutants and risk of microbiology [Mucha & Mikosz 2016] Energy-efficient optimization for upgrading municipal WWTP in Poland Optimization of the existing bioreactor and installation of microfiltration membrane units inside the bioreactor [Samiotis et al. 2018] Minimized waste sludge yields and excellent treatment efficiency Efficient wastewater treatment, minimization of sludge accumulation and significant reduction of excess sludge, with relatively low specific energy consumption using the complete solids retention activated sludge approach Table 1.1: Some of the previous studies on the innovative activated sludge processes

• Control of internal recirculation rate : it allows to recirculate nitrite/nitrate from the aerated reactor to the anoxic one to denitrify. As a consequence, this affects both the denitrification and nitrification processes, or more precisely the nitrate and ammonium nitrogen concentrations in the effluent.

• The sludge recycling flow rate: the control of the return sludge flow rate affects the concentration of return sludge and mixed liquor in the tanks. Practically, this control is designed to maintain a constant biomass concentration in the tanks. Incorrect flow control will either -to clogging the filtration system (secondary clarify or membrane) by solids and bacteria when the sludge return flow is minimal -or will result in reduced solids deposited in the filtration system and the return of sludge, which contains more water

• Excess sludge flow rate: It is an important control in the sludge activated process because the wasting rate determines the solid retention time (SRT) Which, in return, affects the bacteria growth rate, oxygen consumption, nitrification activity and final effluent quality.

Control of physical variables:

• Dissolved Oxygen : oxygen transfer coefficient is manipulated for controlling the concentration of dissolved oxygen in order to control the ammonium concentration resulting from nitrification.

• The external carbon source : when there is a lack of readily biodegradable substrate in influent, or when a post denitrifying configuration is used, a control of the external carbon source is used to control the denitrification.

A new outlook for wastewaters

Within the framework of circular economy, wastewater is regarded as a source of energy, nutrients and water and not only as a source of pollution. The paradigm shift from wastewater treatment plants towards water resource recovery facilities (WRRFs) -that we already mentioned in the introduction -creates a challenge to design, modeling and control new plants, by changing treatment needs and objectives, starting from nutrients recovery and water reuse to energy recovery and sustainability.

The selection of the system design to be used, as well as its modes of operation, will depend on some key factors:

• WRRF effluent requirements have a direct effect on the selection of the process to achieve specific treated water quality, energy and sustainability goals and objectives. Conventional technologies generally tend to increase treatment efficiency, by improving the performance of nitrogen and carbon removal process to best achieve discharge standards.

1.1.6 Modeling concept for activated sludge systems Activated sludge bioreactors are very complex systems regarding hydraulics, biochemical reactions and because they are subject to input disturbance, that is the variability in the composition of influent wastewater. Activated sludge bioreactors are therefore very difficult to model and a significant number of simplifications need to be made before constructing a feasible activated sludge bioreactor model that can be simulated. Activated sludge bioreactors come in different forms, sizes and configurations. In this thesis, only a small part of them is considered, i.e. the activated sludge reactors and the immersed membrane reactor (without taking into account the fouling in the platform proposed) both assumed to be continuously fed. For general guidance, the reader can refer to [Eddy et al. 2003].

Bioreactor hydraulics

Flow patterns by means of continuous flow reactors are very complex resulting from complicated tanks geometry and the location and design of the inlets, outlets, mixers and aeration devices. According to these characteristics as well as different operating conditions, such as liquid and air flow rates and mixing intensities, reactors can present a certain range of undesirable hydraulic conditions [Kjellstrand 2006]. Hydraulic conditions affect the residence time distributions of the liquid and solid phases in the mixed liquor.

Large-scale bioreactors rarely exhibit a perfectly mixed nor ideal plug flow behaviors, the internal flow pattern generally falling 'somewhere in between'. These conditions, nor completely mixed nor plugged flow, are generally modeled with a cascade of reactors as represented in Fig. 1.4. When increasing the number of reactors in the cascade, the distribution of residence times in the cascade tends to appear as a plug flow and eventually reaches an ideal plug flow when N → ∞. The cascade bioreactor structure can be adjusted by varying the number, the volumes and the sequence of completely stirred tank reactors (CSTR), recycling rate, addition of sidestream tanks to represent dead zones, introducing by-passes to represent short circuits, etc.

The topology identification of the 'series tank' model is typically performed initially by identifying recirculation zones, dead zones and short circuits in the physical system via tracer tests, i.e. the temporal response to the pulse or step change in the concentration of an introduced substance in the influent, and then fitting the response curve of the mathematical 'series tank' model to the measurements [START_REF] Olsson | Wastewater treatment systems: Modelling: Diagnosis and control[END_REF].

Experimental studies in the identification of structures of wastewater treatment plant models using the 'series tank' approach show that the structure of connections between reactors is often subject to change with operating conditions (influent flow rate, aeration rate, mixing, etc.) [Alex et al. 2002].

Depending on the objectives to be achieved and the characteristics of the influent to be treated, very different situations may be encountered and the literature shows that in general, under WWTP operating conditions, plug flow reactors are the most efficient Chapter 1. Modeling and control of a WRRF for water Reuse [de Gooijer et al. 1996] [Scuras et al. 2001]. Moreover, reactors perfectly mixed in series of volumes sized according to the influent with a hydraulic retention time (HRT) capable of ensuring a desired treatment performance are generally sufficient to correctly approximate the input-output behaviour of a plug-flow reactor, hence the configurations encountered in real systems and in associated benchmarks, such as the BSM1. where C is the vector of the concentrations of various components in the bioreactor, and V is the liquid phase volume, which is constant in a CSTR. The concentration C of each component inside the bioreactor is decreased by sinks and increased by sources. In the bioreactors described in this thesis, these sinks and sources are attributed to the mass flow of liquid with main outflow and inflow, mass flow of air (e.g. aeration) and a secondary outflow (e.g. waste activated sludge (WAS)). The secondary inflows (e.g. as for instance chemical dosing of external carbon for denitrification) are not considered. If aeration and chemical dosing are not taken into account, the mass balance equation for any CSTR can be expressed as follows:

d dt (CV ) = Q in C in -Q out C out ± rV (1.2)
C, C in and C out being the vectors of concentrations of all considered wastewater constituents in the influent, in the reactor and in the effluent, respectively; r is the vector of reaction rates and dim(r) = dim(C); V is the active volume of the reactor; Q in and Q out are the influent and effluent flow rates. Keeping in mind that in a completely stirred tank reactor (CSTR) C out = C and Q in = Q out , the mass balance of a CSTR can be expressed with the following ordinary differential equations (ODE).

dC dt = Q in V (C in -C) ± r (1.3) with initial conditions C(0) = C 0 .
The ratio Q in V defines the dilution rate D, i.e. the reciprocal of the hydraulic retention time (HRT).

The reaction term r in Equation 1.3 can be calculated using different models and modeling approaches.

Modeling biochemical reactions

The kinetics of biochemical processes describe the rate at which the biomass grows -as a function of the state variables and in particular as a function of substrates concentrations. Substrates are supposed to be transformed into products and biomass in a single step without any consideration of the complex reactions that occur at a single cellular level. The macroscopic models do not take into neither account any variation in the composition and activity of individual cells (and thus often group different bacterial species into a single type of biomass). It is characterized by its concentration X(gm -3 ), its maximum growth rate μ(d -1 ), its decay rate k D (d -1 ), a yield coefficient Y (-). depending on the function used to model its growth, it includes other kinetics and stoichiometric parameters such as, e.g. Monod constants K for different substrates.

Activated Sludge Models (ASMs)

The first period of activated sludge models development was from the 1950 to 1960. [Eckenfelder Jr & Porges 1957] proposed simple, empirical equations to estimate the amount of excess sludge produced and oxygen demand in the tank. The second phase of activated sludge models development can be characterized as the formal application of chemical reaction-type kinetics to link (at steady state) microbial growth and the use of the organic substrate under aerobic conditions [START_REF] Wanner | Activated sludge solids separation[END_REF]. In 1982 the International Water Quality Association (IWAQ) promoted the formation of an international working group in charge of accelerating the development of dynamic modeling of wastewater treatment plants, to create a common platform of agreement and to propose a simple starting model. The group focused its first efforts on inventorying existing models and the constraints to their development. It was concluded that there were a large number of dynamic models, the diffusion of which was hampered by their complexity, lack of order in their presentation and the limits of computer power. The results of the group were published in 1987 in a report that presented the model known today as the ASM1 model [START_REF] Henze | [END_REF], a model designed to describe degradation of organic matter, nitrification and denitrification in an activated sludge process. The most important achievements of the group were a consensus on the biological processes that make up the model, the normalization of symbols, the presentation of the model using matrix notation, the proposal of 'default' values for the model parameters and the adoption of COD and its fraction to characterize wastewater. In 1995, the work of the study group was extended to publish the ASM2 version, which is aimed at predicting the behavior of phosphorus. In 1999 there were two additional modifications with the appearance of the ASM2d version (modified version of ASM2) [Henze et al. 1999], and the ASM3 version which was designed to provide a response to phenomena that ASM1 was unable to simulate, such as reserve substrate storage, for periods of absence of substrate. Such models are intended to be capable of predicting the performance of single-reactor of activated sludge systems and to be used as a tool by engineers for process design and optimization of activated sludge wastewater treatment plants (WWTPs). Even though models mentioned above are the most widely known ASMs to the technical and scientific communities, a number of other activated sludge models have been published and successfully tested in a number of studies.

Structure Activated Sludge Models (ASMs)

The activated sludge models represent a matrix structure that will be presented here with more details.

The vector of reaction rates, r ∈ R n in Equation 1.2 and Equation 1.3 takes the form:

r =     r 1 ( Ĉ1 ⊆ C, u) . . . r n ( Ĉn ⊆ C, u)     (1.4)
r j where j = 1 : n represents the rate of change of the concentration of the j-th component C j as a result of biological and chemical reactions that occur inside the reactor. C is the vector of concentrations of soluble and particulate components, including bacterial biomass. Ĉj is the vector of concentrations which are used as arguments in the rate equation r j . u is the vector of external inputs. The number of reaction rates n is equal to the number of unknown concentrations in order to form a closed system of equation required to verify the existence of a single solution to a system of algebraic equations. Each component C j is a substrate or a product for one or more biological or chemical processes, such as denitrification, nitrification, hydrolysis, etc. These processes p ∈ R m can be represented as :

p =     p 1 ( C1 ⊆ C, u) . . . p m ( Cm ⊆ C, u)     (1.5)
with m is the number of processes. Each reaction rate r j for component j can be expressed as a linear combination of several process rate

p i ∀j ∈< 1, n >: r j = m i=1 a i,j p i (1.6)
Equation 1.6 can also be written in the matrix form as :

r = A T p (1.7)
where A ∈ R m×n is the matrix of stoichiometric parameters, also known as the 'Petersen' or 'Gujer' matrix

A =     a 1,1 • • • a 1,n . . . . . . . . . a m,1 • • • a m,n    
(1.8)

Activated Sludge Models (ASMs)

Each stoichiometric parameter a i,j in matrix A is the link between the rate of the i-th process p i and the rate of change of the concentration of the j-th component C j due to that process. If a i,j > 0 then the component C j is a product, if a i,j < 0 then the component C j is a substrate, if a i,j = 0 the component C j does not take part in that process. In simulations of a CSTR, the vector of state variables x ∈ R n is equal to the vector of concentrations in the bulk liquid, x = C. Thus, if we replace C with x, then ẋ = r and Equation 1.7 can be expressed as :

ẋ = A T p (1.9)
Each process p ∈ p must satisfy two principal laws of chemistry : the law of conservation of mass (matter) and the law of conservation of energy. The law of conservation of matter stipulates that in an ordinary chemical reaction, the mass of the products is equal to the mass of the reactants. Matter cannot be created or destroyed, although it can be reorganized. The law of conservation of energy stipulates that energy cannot be created or destroyed, but can change its form. In the context of activated sludge models (ASMs), the conservation of these two fundamental laws necessitates that, in the most general form, each process p conserves the mass of carbon (C), nitrogen (N) and phosphorus (P) and net electrical charge. The amounts of C, N, P and electrical charge in all components are written in a mass and charge conservation matrix. The quantities of C, N, P and electrical charge in all components are written in a mass and charge conservation matrix :

I 4×n =     I 1,1 • • • I 1,n . . . . . . . . . I 4,1 • • • I 4,n     (1.10)
where Wi I i,j is the quantities of C, N, P and electrical charge for i= 1, 2, 3 and 4 respectively. for the j-th component. Each reaction r ∈ r must satisfy all four balance equations, which imposes restrictions on the choice of stoichiometric parameters a i,j ∈ A m×n . In order to satisfy all balance equations, the following matrix equation must be satisfied.

A m×n (I 4×n ) T ≈ 0 m×4 (1.11)
For the purpose to satisfy the equation 1.11, on k non-zero stoichiometric parameters in the matrix A, k -4m parameters are selected manually and the others, i.e. 4m parameters must be calculated by solving the equation 1.11 to ensure the conservation and continuity of mass and charge.

Reaction kinetics

The processes p ∈ p in Equation 1.4 represent different biochemical enzymatic reactions carried out by different types of bacteria in the activated sludge process. These reactions are linked to the consumption of substrates, the production of products, the consumption or release of energy and the growth or degradation of biomass. In a general form, the rate of a process with a single substrate and a single bacterial biomass without consideration of temperature variation is expressed as :

p(X, S) = mµ(X, S) (1.12)
where p(X, S)(gm -3 d -1 ) is the process rate, m(d -1 ) is the maximum growth rate; µ(X, S) is the process rate dependency function on substrate (S) and biomass (X) concentrations;

In biotechnology and in the ASM models, the process rates p(X, S) are proportional to the biomass concentration X(gm -3 ) and thus µ(X, S) = µ(S)X. Equation 1.12 then takes the form as :

k(X, S) = mµ(S)X (1.13)
The value of p(X, S) is lower than the maximum process rate m because of the limitation substrate effects, diffusion effects, inhibition, competition for different types of bacteria to same substrate, etc. These effects are accounted for in a non-dimensional function µ(S) < 1 , which may take one of the following forms as shown in Table . 1.2

Model Kinetics expression µ(S)

1 1 st order kinetics S 2 Monod S K S +S 3 Moser S R K R S +S R 4 Haldane S S 2
Ki +S+K H Table 1.2: Reaction kinetics dependent on single substrate concentration With K S , K S and K H denote the half-saturation constant respectively for Monod, Moser and Haldane equation and K i is the inhibition constant. Monod kinetics is a specific case of Moser kinetics where R = 1.

The population dynamics of bacterial species in ASM models consider two opposite mechanisms: growth and decay. The net growth of a bacterial species which considers biomass growth, maintenance, decay, and lysis is calculated as superposition of two opposing mechanisms as shown in Equation 1.14:

p(X, S) = mµ(S)X -k D X (1.14) With k D (d -1
) is the bacterial decay coefficient.

Activated Sludge Model No. 1

The Activated Sludge Model No. 1 (ASM1) is the most widely accepted biological wastewater treatment model. It is widely used to model aerobic WWTP that perform organic carbon oxidation, nitrification and denitrification. The model does not describe phosphorus removal. The ASM1 considers two types of bacteria (heterotrophs and autotrophs) and is based on eight fundamental biological processes : Anoxic growth of heterotrophs, Aerobic growth of heterotrophs, Aerobic growth of autotrophs, Decay of heterotrophs, Decay of autotrophs, Ammonification of soluble organic nitrogen, Hydrolysis of entrapped organics and Hydrolysis of entrapped organic nitrogen. In this model, the chemical oxygen demand and total nitrogen (COD and TN, respectively) are decomposed into several state variables, 'according to physico-chemical criteria (particulate, soluble) and biodegradability (inert, 1.2. Activated Sludge Models (ASMs) 29 rapidly or slowly biodegradable)'. For the COD fractions, we consider the soluble readily biodegradable matter S S , the soluble inert S I , the particulate slowly biodegradable matter X S , the particulate inert X I , the particulate inert from biomass decay X P , the heterotrophic biomass X BH and the autotrophic biomass X BA . For the fractions of TN, we consider the soluble organic S N D , the ammoniacal nitrogen S N H . The particulate organics are X N D , nitrates and nitrites S N O ; and two other state variables, the oxygen S O and the alkalinity S ALK . The model includes 19 stoichiometric and kinetic constants which are used as parameters for the process rate equations. Figure 1.5 illustrates the biological processes used in ASM1. Therefore, in aerobic conditions, heterotrophs (X BH ) oxidize the readily biodegradable organic substrate (S S ) to carbon dioxide, while autotrophs allow the oxidation of ammoniacal nitrogen (S N H ) into nitrite and nitrate (S N O ). Subsequently, part of the active biomass (X BH and X BA ) is subjected to cell lysis generating biodegradable organic (X S ) and nitrogen (X N D ) fractions, hence the concept of dead-regeneration, and an inert fraction (X P ). The particulate fractions (X S and X N D ) are then hydrolyzed to produce soluble organic S S and soluble organic nitrogen (S N D ). Although ASM1 has proved to work well in a wide range of ap-Figure 1.5: Overview of ASM1 processes plications for the original purposes for which it was designed, such as predicting sludge production, oxygen demand and effluent quality, the model has certain limitations:

• It does not describe the restrictive effects of alkalinity as well as N, P and other inorganic nutrients on the growth of biomass;

• It divides particulate organic matter into two separate compartments : from the influent (X I ) and biomass decomposition (X P ). In reality, these two COD fractions cannot be separated one from each other;

• The combined effects of death, predation, biomass lysis, and endogenous respiration of storage products are described as a combined effect of lysis, hydrolysis, and growth mechanisms, but not modeled individually.

A modified Activated Sludge Model ASM1-2ND

Within the framework of water reuse, it may be important to consider the different forms of nitrogen. Since nitrite is an intermediate product, which can in principle be easily oxidized into nitrate, most activated sludge models consider nitrification as a single step process such as ASM1 model 1.7. The assumption of one-step nitrification is generally acceptable when modeling classical treatment processes. However, the treatment plant operation may reveal nitrite accumulation due to incorrect design or ineffective operation. Therefore, it is interesting to examine both nitrification and denitrification as a two-step processes.

The ASM1-2ND model [START_REF] Ostace | [END_REF]] is developed as an enhanced ASM1 with two step nitrification/denitrification processes1.6. The principal components of the modified model (ASM1-2ND) remain the same as the components of the ASM1 model. The total chemical oxygen demand (COD) is divided into three categories: Biodegradable COD, non-biodegradable COD and active biomass. But the nitrogen components are modified, since nitrification is modeled as a two-step process: the nitrate and nitrite concentrations, represented in a single variable (S N O ) in the ASM1 are represented in the ASM1-2ND by two different state variables (S N O 2 and S N O 3 ), where the S N O 2 component is the intermediate for the nitrification and denitrification processes. The autotrophic bacteria (X BA ) of ASM1 is also divided in two biomass types: a group oxidizes ammonium to nitrite: these are the Nitrosomonas bacteria (X AOB ), and a group oxidizes nitrite to nitrate: these are the Nitrobacter bacteria (X N OB ).

Towards a flexible water resource recovery facility (WRRF)

As the industry moves towards resource recovery, including water, energy, and nutrients, several initiatives are promoting this new name (Water Resource Recovery Facilities -WRRF) for wastewater treatment plants (WWTPs). The wastewater treatment technology progress to provide more advanced treatment processes, and more technical advances is included to conventional WWTP as:

• Advances in Membrane Bioreactor Applications

• Use and application of wastewater treatment process modeling for the development of new designs and evaluation of alternatives The objective of flexibility, in terms of water resource recovery facilities, is to adapt their functioning to short-term variations in requirements. The sources or levers of flexibility can be :

• The configuration changes, by means of switches (as valves), the flexible configuration can result in several sub-configurations, of which each sub-configuration is useful for one operating mode.

• Through the introduction of additional control levers, the system can achieve performance levels in terms of quality not possible with the classic configuration, which contains fewer degrees of control, and it allows to optimize the operation and giving more flexibility.

The proposed flexible platform is an upgraded design of the conventional wastewater treatment plants (WWTPs). The idea of the design is to build a configuration that contains several control degrees in order to be able to give the plant more flexibility and overcome some limits that the conventional WWTPs. The platform is designed to provide efficient control of quality and quantity of the nitrogen forms at its output, to allow an optimal reuse of treated water in agriculture. The particularity of this platform lies in the fact that it is able to operate in different configurations, thanks to the available valves (considered to have only two positions 0 or 1). They allow the platform to be operated in several given configurations. Since the effluent is intended for reuse, a high quality filtration is necessary: the platform includes a membrane which is supposed to be ideal to ensure perfect sludge separation (fouling phenomena were not taken into account). For a more detailed presentation, the reader will refer to the next chapter.

Remark 1.3.1. When working on control of complex systems, two cases arise: either the complex system is a real system either it is a virtual process. Within the framework of this manuscript, the flexible platform is not a model for a real process but considered as a 'toy WWRF' (a virtual process for us) to be controlled. As such, we will consider its model as unknown: it is why it will not be considered for control synthesis. In addition, to facilitate the implementation of the proposed control strategies on a pilot/real system, we will concentrate on the design of simple industrial control algorithm instead of on the synthesis of 'advanced control systems' that would require complex models which the development may be a long and tedious task.

Modeling of plants/crops needs

An important benefit of reuse is fertilization through irrigation (fertigation), as wastewater contains nitrogen compounds, which are essential plant nutrients. Therefore, special attention is given to how nitrogen dynamics are taken into account in crop models.

Modeling of plants/crops needs

Crop models are tools developed to estimate crop yields as a function of plant characteristics, weather, soil conditions and applied management practices. These models represent farming systems at a large scale (at least a field) and simulate growth and development of a crop growing on a uniform area of land.

A wide range of models have been developed over the years, from empirical to mechanistic and for various different purposes (educational, scientific, commercial) [START_REF] Jones | [END_REF]. There are few models that have been developed to be parsimonious and that are also formulated clearly as dynamical systems. Generally, they have been established specifically for control or optimization purposes, as simplifications of more complex models. Only one of these models includes nitrogen dynamics. This model, called the crop-soil model [Pelak et al. 2017], has been developed as a simplified version of AquaCrop, a standard simulation model of the FAO (Food and Agriculture Organization of the UN), The crop-soil model [Pelak et al. 2017] is proposed following the ideas of AquaCrop, where soil moisture and nitrogen balance are considered. Crops are mainly represented by the canopy cover (the fraction of ground covered by the crop), the other variables being the vertically averaged relative soil moisture and nitrogen content per unit area of soil, for which balance equations are established. Accumulated biomass can then be computed as a function of these variables. This model [Pelak et al. 2017] has been used to study an optimal irrigation problem, that is the maximization of biomass production at harvest, without any constraint on the total amount of water. The study was realized as part of Control4Reuse project (cf. control4reuse.net). The only adaptation for the considered problem is to take the fertilization term as function of the product of the irrigation flow-rate per unit area and the nitrogen concentration of the irrigation water. In this context, to determine the irrigation and fertilization requirements for optimal crop growth, a problem of maximizing crop biomass at the end of the growing season is considered. This as an optimal control problem, over a fixed time horizon that represents a growing season. The solutions of this optimal problem is used as the optimal nitrogen requirements for crops irrigation, that is as a setpoint for the simulation platform.

In this thesis, we will not discuss the modeling of plants/crops, but we will take the solutions found from the problem of optimal irrigation for nitrogen needs (solution of the problem of maximizing biomass production) solved in another research context and use it as references in our treatment system in order to control it such as it is able to provide water of appropriate quality to the plants/crops and ensure optimal production (for more details visit the appendix III).

The Water balance is the application of the principle of conservation of water contained in a given volume of soil. The water content of the soil during a growing season changes according to the crop, which can draw a certain amount of water from a reservoir whose water content varies over time, mainly depending on rainfall and actual evapotranspiration.

The water balance Fig. 1.8 equation is based on the continuity equation and can be expressed as follows, for a given period and a given basin:

P + I -ET -D r -R o ± ∆Q = 0 (1.15)
where P is precipitation, I irrigation, ET evapotranspiration, D r drainage, R o runoff, and ∆Q the variation of soil water content during a given irrigation interval. We are interested in this part of thesis only by the management of water resources for irrigation. The modeling consists in writing a dynamic system which allows to identify water resources in the soil: a soil model that provides information on the water state on the system from which the plant takes the necessary water resource for its growth.

Modeling and control of fouling in membrane filtration systems

Operating a WRRF for Water reuse including a membrane reactor has an important drawback: the energy needed for operating the system will have as a consequence to increase the price of the treated water. To render reuse economically viable, it is thus particularly important to optimize the whole process and, in particular, the way the membrane system is operated in order to minimize fouling. For that purpose, we need a simple and generic mathematical model able to predict the fouling dynamics. A generic model is a model that can reproduce as well as possible a quite large number of different situations in the field of membrane filtration for this prupose. Most existing fouling models are complicated: either they have many parameters, or their validity range is reduced since they are only valid under many assumptions, which limit their usefulness [Di Bella et al. 2008], [Janus 2014].

It is why some authors proposed simple models that can be suitable for control purposes. For example, [Benyahia et al. 2013] developed a fouling model which is mathematically simple to be used for the control and optimization of filtration systems. Several control strategies have been developed and applied to membrane filtration processes in order to improve their performances, such as for example [Smith et al. 2006] where it has been developed a control strategy that monitors the evolution of the transmembrane pressure (TMP) over time and starts a 15-second backwash cycle when the TMP exceeds a given set point. Another strategy developed by [Robles et al. 2014] allows to optimize the backwash frequencies based on control of the permeability calculated from the online measurements of TMP and permeate flow. Moreover, strategies for optimal control of membrane processes have been developed preliminary by [START_REF] Cogan & Chellam | A method for determining the optimal back-washing frequency and duration for dead-end microfiltration[END_REF], [START_REF] Cogan | Optimal backwashing in dead-end bacterial microfiltration with irreversible Bibliography attachment mediated by extracellular polymeric substances production[END_REF], where a prediction of optimal switching times between filtration and backwash periods that maximizes net water production over a fixed operating time for membrane filtration process is obtained. Then comes the works of the thesis of [Kalboussi 2018], which has revisited the latter studies and developed a muich more generic optimal control for filtration/backwash sequences to maximize the production of permeate from a filtration system operating at constant TMP. Our approach is an extension of the works of [Kalboussi 2018], as we consider that its more appropriate to have the constant permeate flow with a variable TMP in a filtration system, when it comes to filtering wastewater, than to consider a constant TMP with variable permeate flow.

Optimal control

In recent years, the optimal control theory has come out as a very interesting tool for optimizing the operation of membrane filtration systems. The aim of optimal control is to find the optimal control actions, that minimizes (or maximizes) an integral performance criterion related to the state of a dynamic system (with constraints if required) and doing so within a fixed time period or with a free terminal time [Harmand et al. 2019].

In principle" an optimal control problem is essentially defined by three components:

• The process model: it defines the inputs, outputs and states and describes the dynamics of the real system.

• The objective function (or optimization criteria): it expresses mathematically the costs to be minimized or the benefits to be maximized.

• The constraints: these denote the set of allowable values for the state or the control.

In this work, we used the Pontryagin Maximum Principle (PMP) to derive necessary optimality conditions, because it is an important tool in the theory of optimal control. With the application of the PMP, we can exhaustively characterize the properties of optimal control, understand all the subtility of its 'synthesis' and and even sometimes, express the optimal strategy in terms of state feedback. This principle, formulated by L. S. Pontryagin [START_REF] Pontryagin | Lev Semenovich Pontryagin. Mathematical theory of optimal processes[END_REF]], gives necessary conditions of optimality and allows the determination of optimal trajectories when they exist. This principle is available in several versions derived from its initial version depending on terminal conditions and other possible constraints. Indeed, the statement of its equations vary according to the objective and the constraints of the problem and in particular whether the final time is fixed or not in the cost function.

The general statement of the Pontryagin Maximum Principle without constraints is recalled in the following Section 1.5.2.

General statement of the Pontryagin Maximum Principle

We consider the following control problem:

ẋ = f (x(t), u(t)) (1.16)
where In addition, we define the cost of a control u on [0, T ] as :

x(0) = x 0 is the initial condition, f is class C 1 function in R n (i.e. f is differentiable on R,
C(u) = T 0 h(x u (t), u(t))dt + Φ(x u (T )) (1.17)
where T is fixed, h is a class C 1 function in R, x u is the solution trajectory of Equation 1.16 associated with the u control and x u (T ) is the terminal state of the system penalised by a cost Φ(x u (T )).

We consider the following optimal control problem: determining a trajectory starting from x 0 (initial condition) and maximising (or minimising) the cost over the period of time T .

The Hamiltonian associated with the optimization problem is defined as :

H(x, p, p 0 , u) = p T f (x, u) + p 0 h(x, u) (1.18)
where p is a vector in R n . In order to simplify the writing, we adopt the following notation for the scalar product:

p T f (x, u) =< p, f (x, u) > (1.19)
If the control u ∈ U associated to the trajectory x(.) is optimal on [0, T ], then there is an application p(.) : [0, T ] -→ R n continuous called the adjoint vector, and a real p 0 0, such that the pair (p(.), p 0 ) is non-trivial (i.e. (p(.), p 0 ) = (0, 0)), and such that, for almost all

t ∈ [0, T ]. ẋ(t) = ∂H ∂p (x(t), p(t), p 0 , u(t)) ṗ(t) = - ∂H ∂x (x(t), p(t), p 0 , u(t)) (1.20)
with H(x(t), p(t), p 0 , u(t)) is the Hamiltonian of the system, and for which the condition of maximization [0, T ] writes :

H(x(t), p(t), p 0 , u(t)) = max υ∈Ω H(x(t), p(t), p 0 , υ) a.e. t ∈ [0, T ] (1.21)
The adjoint vector must be constructed in such a way as to verify the conditions of transversality at both ends (or just one of them) :

x(0) = x 0 p(T ) = -∇Φ(x(T )) (1.22)
Let us formulate the following remarks:

• The convention p 0 0 leads to the maximum principle. The convention leads to the minimum principle, i.e. the condition of Equation 1.21 would be a minimum condition;

• The general statement of the Pontryagin Maximum Principle refers to the possible existence of target reachability problems using a scalar noted p 0 . If for p 0 = 0 there is a solution that verifies the necessary conditions of optimality (Equation 1.20, 1.21) then the extreme is called 'abnormal'. This occurs in very singular cases of optimal control problems, for example in a situation where one starts from an initial condition that is already in the target;

• In problems with a free terminal state (without target), p 0 does not vanish because there is no reachability problem (no abnormal trajectory) and one can take p 0 = 1;

• The terminal condition p(T ) = -∇Φ(x(T )) is also known as the transversality condition. Without a terminal cost on the final state of the system (Φ = 0), the terminal condition is written p(T ) = 0.

CHAPTER 2

From WWTP to WRRF : the necessity of more flexibility to adapt the quality of treated waters to new usages This chapter is being submitted in an international journal. It presents the main results of the manuscript related to the flexibility of treatment systems for REUSE in coupling the model of the platform with a model of plant growth to be used for the computation of optimal output nitrogen concentration to be delivered to the plant. The first step consists in a numerical investigation of the platform for analyzing the steady states that can be reached by manipulating the various controllers. Using these results, we propose an open-loop control strategy to deliver the appropriate output nitrogen concentration depending on both the input effluent characteristics and the available controls. This strategy is satisfying as long as input effluent characteristic are known and constant. However, because the system operates in the presence of disturbances, and depending on the objective pursued, we propose two industrial-based closed-loop control strategies to automatically find the best system configuration and controls with respect to the required output nitrogen concentration. These two strategies are evaluated in the presence of disturbances and uncertainty.

Introduction

The Mediterranean Rim is a hotspot within a context where current changes (population increase, global warming, increase of food demand, decline in biodiversity, etc.) lead to the necessity to priorize the withdraw of surface waters of good quality for human consumption. While human activities have increasing bad consequences on water quality -which are amplified by global changes -alternative water resources need to be found, agriculture being the largest consumer with 70 % of water consumption [START_REF] Boretti | Reassessing the projections of the world water development report[END_REF], [START_REF] Abbott | [END_REF]], [START_REF] Ouali | Modelling environment contamination with heavy metals in flathead grey mullet Mugil cephalus and upper sediments from north African coasts of the Mediterranean Sea[END_REF]]. To tackle this challenge, we must change the paradigm, turning from promoting maximum treatment of wastewater before disposal in the environment to considering wastewater as a water containing nutrients whose treatment has to be tailored according to usages [START_REF] Ait-Mouheb | [END_REF], [Villarín & Merel 2020]. Indeed, recovering nutrients from wastewater is an important challenge of circular economy [Robles et al. 2020]. To do so, different systems exist depending on the desired goal. Some WWTP -rather called WRRF for water resources recovery factory in this context -are designed so as to recover energy [Cornel et al. 2011][Wang et al. 2020], while others optimize nutrient recovery [START_REF] Nowak | [END_REF][START_REF] Mo | Energy-nutrients-water nexus: integrated resource recovery in municipal wastewater treatment plants[END_REF]. What about keeping these nutrients in the water at a level optimized for specific usages and promote fertigation practices? This would require more 'flexible treatment systems', as opposed to the actual ones that are usually only able to work in a static treatment mode both in industry or in urban areas whatever they allow nutrient recovering, or not [Hansen et al. 2016], [Murray & Ray 2010], [Vergine et al. 2017]. Actual WWTP operate in such a way the quality of the output effluent is as constant as possible to comply with normative constraints while the system in itself may be highly dynamical to 'reject input disturbances' (since the input flow and pollutant concentrations varies over time).

Although not well defined in the specific context of REUSE -and it is not the objective of the present paper to do it -'flexibility' reflects here the 'robust' ability of a treatment system to be dynamically controlled in such a way the quality of treated waters may be tailored depending on the required quality for its effective reuse. In other terms, it reflects the fact that there exists several 'ways' for the system to deliver a given quality of water (we will come back on this conceptual view later on). Indeed, available culture and plant models highlight a fundamental property of almost all plants: their 'optimal requirements' in terms of water and nutrients highly vary with time and, very often, are decoupled one from the other. In addition, the different forms of nitrogen may be important from an agronomic point of view, ammonium being much less subject to leaching than nitrate while being less bio-accessible. In actual irrigation practices, at best, it is only the quantity of water which is optimized while nutrients are supplied once or twice during the growth cycle of the crop. Depending on weather conditions and actual practices, it may happen that part of these nutrients be lost by run off or infiltration possibly causing damage to water tables.

As a consequence, a flexible WRRF should exhibit the following main characteristics:

Chapter 2. From WWTP to WRRF : the necessity of more flexibility to adapt the quality of treated waters to new usages

• It should be able to deliver a water in which the ratios between the different forms of nitrogen could be controlled;

• It should be able to follow setpoints in terms of water flows and quality corresponding to those that can be considered as optimal with respect to agronomic needs;

• It should be able to switch from one mode to the other -that is from a 'complete treatment', in which the water content must comply with normative constraints to a 'partial or degraded treatment mode' in which water quality is managed according to usage -in a reasonable time while internal/external disturbances be rejected;

• These three points being constrained i) by the necessity to manage both environmental and sanitary risks and ii) treatment costs;

Wastewater treatment by activated sludge does not effectively promote nutrient and energy recovery. During this treatment, the carbon and nitrogen (nutrients) in the wastewater are converted into biomass, nitrogen gas and carbon dioxide, which means that a large part of the energy and nutrient content of the wastewater is dissipated to the detriment of a significant energy supply [Sills et al. 2016]. Conventional wastewater treatment is carried out by combining the stages of nitrification and denitrification in two separate tanks maintained in aerobic and anoxic conditions, respectively. The pre-denitrification and post-denitrification configurations are the most common [START_REF] Barker & Dold | COD and nitrogen mass balances in activated sludge systems[END_REF]. In the pre-denitrification configuration, the anoxic tank is placed upstream of the aerobic reactor: it receives the nitrate from the aerobic tank through a recirculation loop. In the post-denitrification configuration, the anoxic tank is placed downstream of the aerobic reactor but often requires the addition of external carbon for denitrification. To deal with the advantages of all configurations, possibly only punctually -and thus in avoiding their drawbacks, we have conceived a platform including all of them (nitrogen removal with pre/post-denitrification or no treatment at all depending on the position of a number of valves and pumps).

The use of membrane bioreactors (MBRs) for wastewater treatment has increased dramatically due to technological advancements and lower operating costs for membranes.

The high effluent quality offered compared to conventional activated sludge systems makes the membranes particularly suitable for reuse [START_REF] Judd | The status of membrane bioreactor technology[END_REF]], mainly due to the complete retention of solids and thus its capacity to prevent pathogen diffusion. In addition, the presence of a membrane allows the solid retention time to be accurately controlled. This is why the last tank of our flexible system is a membrane bioreactor. As a whole, the platform thus involves three tanks, one anoxic and two aerobic, the last tank being considered as a perfect membrane bioreactor.

The simulation of such a platform is possible using the activated sludge models (ASM) which have succeeded in forming an industrial standard for modeling wastewater treatment processes. Since ASM1 ( [Henze et al. 2000]), several models of activated sludge (ASM) and some extensions have been published. They fixed some weaknesses of the ASM1 and included new processes. Nevertheless, ASM1 remains the model most often cited in the literature although nitrification is modeled as a one-step process. For our purpose (we must be able to manage the different forms of nitrogen), the nitrification will be modeled here as a two-stage process as proposed in [START_REF] Ostace | [END_REF].

Controlling the flexible platform is challenging in itself. To do so, we take advantage of control actions available on the process, called 'actuators', allowing us to act on the variables of the process while the available 'sensors' inform us about the state of the process. In the literature, we find many examples and applications of control strategies involving a set of control variables and sensors: actuators include flow rates (input, recirculation or waste flows), aeration power, positions of valves while sensors include 'environmental variables' like pH, temperature, pressure, flows, dissolved oxygen or 'process variables' like biomass, COD or nutrient concentrations in more advanced configurations. The main process characteristics to be controlled include the oxygen concentrations in the aerobic tanks, the hydraulic as well as the solid retention times or still nutrient concentrations or suspended solids that must comply with normative constraints. In control engineering, inputs and outputs are classified into different classes.

Inputs include actuators -that we can tune according to a given control objective -and disturbances -that are either measured or not and the consequences of which we must counterbalance, precisely in using actuators. Outputs are usually classified in two families depending whether they are measured (through sensors) or not. For instance, it may be interesting to control a concentration which is not directly measured. In such a case, we must use an 'observer' -also called a 'software sensor' to reconstruct/estimate the output using the available information -the model and the available online -or offlinesensors. As mentioned here above, most control strategies available in the literature aim at maintaining, at lowest possible cost, the main process variables within ranges specified by normative constraints. Some works apply control strategies in sludge treatment as in [START_REF] Barbu | [END_REF]], but most of the articles do so in secondary treatment. Some of them aim to improve controlling the dissolved oxygen concentration (S O ) in aerobic reactors, by manipulating the oxygen transfer coefficient (K L a), using different control techniques [START_REF] Revollar | [END_REF], [Santién et al. 2019]. Improving the setpoint regulation of (S O ) in the nitrification process has also been the goal of many papers, such as [Błaszkiewicz et al. 2014], [START_REF] Santin | [END_REF]]. Another variable that can be manipulated in biological treatment is the internal recirculation rate. Some control strategies allow to maintain this recirculation flowrate fixed, while others, like in [Santín et al. 2016] propose to consider it as the manipulated variable to maintain constant the nitrate setpoint (S N O 3 ) in the last anoxic reactor. It should be noticed here that the IWA is at the origin of a number of control benchmarking activities making intensive use of IWA models of activated sludge treatment systems and has contributed a lot to the development of this domain [Alex et al. 2018].

Here, the challenge is to make extensive use of simulations, using the available models of the activated sludge systems, to propose a simulator for a flexible platform. Then, evaluating on this platform new control strategies able to manage the system such Chapter 2. From WWTP to WRRF : the necessity of more flexibility to adapt the quality of treated waters to new usages that to adapt the quality of treated water to agronomic needs. In other words, as opposed to most available works of the literature, the control system will not be used to maintain the outputs at constant levels fixed by regulation constraints but rather to use the available control to act on the process in such a way the most important outputs, from a reuse viewpoint, follow the required setpoints. You still have to be able to determine what these setpoints should be, and notably, with respect to which objectives the control system has to be designed for. To do so, in parallel to this work, we used plant growth models and solve optimal control problems the results of which are candidate setpoints in terms of water quantity and quality over time.

The present paper is organized as follows. In the first section, the flexible platform and its model are presented, in checking the stoichiometric discontinuities for the model used is then given. In second section, the functioning modes are characterized with respect to the available actuators (valves and pumps): in particular the steady states the system can attain are computed via a numerical approach, in which an open loop control strategy has been proposed. In third section, a control system is proposed based on the implementation of simple robust industrial controllers in cascade. These controllers are then evaluated in fourth section using setpoints generated by means of plant models and corresponding to the optimal requirements of plants before some conclusions are drawn.

Materials and methods

A flexible platform

The flexible WRRF platform considered here has been developed within the framework of the European project 'Control4Reuse' (cf. control4reuse.net). The idea of the design was to build a configuration that contains the most important number of control degrees to maximize its flexibility: the platform proposes a mix between several configurations (predenitrification, post-denitrification and step-feed) using three valves, allowing the plant to operate in different modes ('Reuse', also called 'degraded' here, or 'conventional treatment' mode).

System description and design

The WRRF is made of three reactors in series: an anoxic reactor (R1) of volume 4000 m 3 , and an aerobic reactor (R2) of volume 6000 m 3 followed by an aerobic membrane bioreactor (R3) of volume 3000 m 3 ; all reactors are completely mixed (cf 2.1), the membrane is ideal (perfect separation of soluble and particular matters) and thus no fouling phenomena are taken into account. The WRRF contains three valves (named (A), (B) and (C)) that have two positions. Referring to Figure 2.1, we adopt the following conventions:

• if V alve(A) = 1 (resp. V alve(A) = 0) -→ Q B = Q in and Q C = 0 (resp. Q B = 0 and Q C = Q in ); • if V alve(B) = 1 (resp. V alve(B) = 0) -→ Q D = Q B and Q C = 0 (resp. Q D = 0 and Q C = Q B ); • if V alve(C) = 1 (resp. V alve(C) = 0) -→ Q E = Q RAS and Q F = 0 (resp. Q E = 0 and Q F = Q RAS ).
The The configuration in which the external recirculation (Q RAS ) from R3 to the anoxic tank R1 with V alve(C) = 0 and the internal recirculation (Q int ) are nonzero allows to eliminate nitrogen by denitrification of recycled nitrate (corresponding to a predenitrification system). In such a configuration, the denitrification can be controlled by the recirculation rate. By feeding the aerobic tank R2 with the input flow (V alve(A) = 1 and V alve(B) = 0), the denitrification takes place after the nitrification (corresponding to a post-denitrification system if V alve(C) = 0). In this configuration, the denitrification may become limiting because the carbon source may have been consumed in R2 and may not be available anymore as an energy source. When the input flow is directed towards the MBR reactor R3 (both V alves(A) and (B) equal 1), the nitrification can be controlled by the sludge retention time (SRT) and the dissolved oxygen concentration (DO).

Depending on valve's position, there are 6 specific configurations of interest for the proposed flexible WRRF: they are reported in Table 2.1. There are many other configurations but they are not of interest: for instance, notice that when V alve(A) = 0, the position of the V alve(B) does not matter. quality of treated waters to new usages The configuration C1 (read V alve(A) = 0, V alve(B) = 0, and V alve(C) = 0 in Table 2.1) may be considered to be equivalent to the conventional activated sludge process which comprises a series of completely mixed reactors with a recirculation.

V alve(A) V alve(B) V alve(C) Description 0 0 0 Configuration C1 0 0 1 Configuration C2 1 0 0 Configuration C3 1 0 1 Configuration C4 1 1 0 Configuration C5 1 1 1 Configuration C6
In the configuration C3 (V alve(A) = 1, V alve(B) = 0 and V alve(C) = 0) the process will behave as a post-denitrification system without any carbon source addition: denitrification rate is expected to be low. If the hydraulic retention time (HRT) is large enough, the configuration may exhibit high rate nitrification as long as there is enough oxygen in R2.

In the configuration C5 (V alve(A) = 1, V alve(B) = 1, V alve(C) = 0), the nitrification will be limited due to a short HRT. The three remaining configurations are different from the first three by the position of V alve(C): this will mostly affect the performances of nitrification and denitrification depending on the quantity of nitrate which is injected back to R1. A number of additional hypotheses have been introduced:

• It is supposed that there is no nitrate at the process input and it is all under ammoniacal form and as proposed by IWA, the total nitrogen content can be computed using the formula

N T K = 2 3 N N H 4 + 1 3 N organic ;
• The maximum recirculation rate of the mixed liquor Q int is 100 % compared to the input flow (Q int = 24000 m 3 /d);

• The maximum sludge recirculation rate Q RAS is 500 % compared to the flow the input flow (Q RAS = 120000 m 3 /d);

• As for BSM1, the WRRF is designed for a constant influent dry-weather flow rate of 24000 m 3 .d -1 and a constant biodegradable COD in the influent of 350 g.m -3 . When dynamical inputs are used, their average values are given in Table 2.2; The volumes of tanks are chosen such that the minimum possible HRT equals 3 hours.

Model description

The WRRF platform is modelled according to the flow scheme represented in Fig. 2.1. The biological reactions inside each reactor are modeled using the ASM1-2ND model [START_REF] Ostace | [END_REF]]. As already mentioned, it differs from the original ASM1 [Henze et al. 2000] by considering a two-step reaction for the nitrification process realized by two groups of autotrophic bacteries, namely the AOB and the NOB for ammoniumoxidizing and nitrite oxidizing bacteries and named in the model X AOB and X N OB , respectively.

The aerobic growth rates of the AOB and NOB (ρ 5 and ρ 6 in Table 2.4) are given by:

ρ AOB = µ AOB S N H K N H + S N H S O K OA + S O X AOB (2.1) ρ N OB = µ N OB S N O 2 K N O 2 + S N O 2 S O K OA + S O K N H S N H + K N H X N OB (2.2)
Equation ( 2.1) describes the first step of nitrification (partial nitrification): when the ammonium is oxidized into nitrite, both ammonium (S N H ) and dissolved oxygen (S O ) act as limiting factors, while in Eq. (2.2) by using a 'switching function', the ammonium (S N H ) behaves as an inhibitor for the second oxidation step of nitrite (S N O 2 ) into nitrate(S N O 3 ).

For the denitrification, the facultative heterotrophic biomass can remove organic carbon through anoxic respiration by using nitrite or nitrate, which serve as electron acceptors in the absence of dissolved oxygen and transform them into dinitrogen.

For the denitrification, the reaction rates (ρ 2 and ρ 3 in Table 2.4) are given by the following expressions:

ρ BH N O2 = µ H η N O2 S s K s + S s K OH K OH + S O S N O2 K N O + S N O2 S N H K N H + S N H X BH (2.3) ρ BH N O3 = µ H η N O3 S s K s + S s K OH K OH + S O S N O3 K N O + S N O3 S N H K N H + S N H X BH (2.4)
The list of model parameters as well as the kinetics/stoichiometric coefficients values are reported in Table 2.12. The complete WRRF model is defined by the following equations for the soluble S i,R and particulate X i,R components in all reactors where i stands for the component (i = 1, 2, ..., 16) (cf. Table .2.2) and R stands for the tank R = 1..3). For the first tank R = 1 the mass balance equation is:

dS i,1 dt = 1 V 1 (Q in,1 S i in ,1 -Q 1 .S i,1 ) + r j (2.5) dX i,l=1 dt = 1 V 1 (Q in,1 X i in ,1 -Q 1 .X i,1 ) + r j (2.6) With Q in,1 = Q F + Q int + Q A
For the second aerobic tank R = 2, the mass balance equation is:

dS i,2 dt = 1 V 2 (Q in,2 S i in ,2 -Q 2 .S i,2 -Q int .S i,2 ) +
dX i,2 dt = 1 V 2 (Q in,2 X i in ,2 -Q 2 X i,2 -Q int X i,2 ) + r j (2.8) With Q in,2 = Q 1 + Q E + QC
Finally, for the third tank R = 3, the mass balance equation for the membrane bioreactor is:

dS i,3 dt = 1 V 3 (Q in,3 .S i in ,3 -Q ef S i,3 -Q RAS S i,3 -Q W AS S i,3 ) + r j (2.9) dX i,3 dt = 1 V 3 (Q in,3 X i in ,3 -Q RAS .X i,3 -Q W AS .X i,3 ) + r j (2.10) With Q in,3 = Q D + Q 2
The dynamics for dissolved oxygen (S O,R ) is a special case since it obeys in each tank to the same dynamical equation than S i,R but with additional terms corresponding to the external addition of oxygen

(K L a)(S Osat -S O,R ), whereR = 1, 2, 3.
Unless otherwise stated, the influent characteristics of the constant input and the average of dynamic input are reported in Table . 2.2.

Stoichiometric discontinuities checking

In order to close the COD and nitrogen balance, the total COD and N reacting under process conditions must match the total COD and N consumption. Balance equations form the basis of any model description. These equations describe the way the concentrations vary in a reactor over the time as the result of chemical and biological conversions and of transport processes. The original ASM1-2ND model proposed in [START_REF] Ostace | [END_REF]) contains some typing errors and inconsistencies in their stoichiometric matrix. Before using it, we should check the continuity of the stoichiometric and the consistency of the kinetic rate expressions ( [START_REF] Hauduc | ASM type biokinetic activated sludge models: theoretical and functional analysis toward a default parameter set[END_REF]). This verification does not intend to address model structure problems linked either to modelling concepts or to simplifications used in the ASM1-2ND model. Rather, the approach checks and corrects the COD and nitrogen mass balances to ensure the continuity and conservation of the chemical elements (C, N, O). Generally, each component is represented by a state variable, which is typically expressed in terms of COD equivalents, elements (e.g. N) or charge. The Gujer matrix (Table . 2.3, 2.4 contains both the stoichiometric coefficients for each state variable and the associated kinetics for each state variable. Browsing the column associated with a given variable allows us to see in which conversions it is involved. By multiplying the stoichiometric coefficients § ¦ ¤ ¥ v j,i with their respective rate equations, one gets the total conversion equation for each compound.

To check continuity, the composition matrix is formed in terms of conserved balances (cf. Table 2.6), that is terms of COD, N and charge. In the stoichiometric matrix, the biomass is expressed in terms of COD, but it contain also some nitrogen: this is taken into account in the composition matrix. The continuity is checked by multiplying the composition matrix (Table . 2.6) and the stoichiometry matrix (Table. 2.5), that contain all the conserved balances. The multiplication of the two matrices leads to zero when the balance is closed.

11 j=1 v j,i c i,comp = 0 with comp = COD, N, charge.
In particuler, the kinetic rate expression to model nutrient (ammonia) limitation in the heterotrophic growth process was missed in the original model, which could induce negative ammonia concentration values. To correct this error, a Monod kinetics

S N H
K N H,H S N H was added in the three first processes. Such a checking has been realized by ([Petersen et al. 2001]) ( [Rieger et al. 2012]) for the ASM1. Notice that since the stoichiometric matrix published in ( [START_REF] Ostace | [END_REF]) for the ASM1-2ND model contained many typing errors, the whole corrected stoichiometric matrix for the ASM1-2ND model has been rewritten (cf. Table. 2.3) In particuler, the kinetic rate expression to model nutrient (ammonia) limitation in the heterotrophic growth process was missed in the original model, which could induce negative ammonia concentration values. To correct this error, a Monod kinetics Process

S N H K N H,H S N
A 1,9 = - (1 -Y H ) Y H A 5,9 = - (-i COD,N O2 -Y AOB ) Y AOB A 6,9 = - (-i COD,N O3 -Y N OB ) Y N OB
S I S S X I X S X BH X AOB X N OB X P S O S N O2 S N O3 S N 2 S N H S N D X N D S ALK 1 -1/Y H 1 A 1,9 -i XB A 1,16 2 -1/Y H 1 A 2,10 A 2,12 -i XB A 2,16 3 -1/Y H 1 A 3,11 A 3,12 -i XB A 3,16 4
1 -f P -1 f P A 4,15 5 1 A 5,9 1/Y AOB A 5,13
A 5,16 6 1

A 6,9 -1/Y N OB 1/Y N OB -i XB A 6,16 7
1 -f P -1 f P A 7,15 8
1 -f P -1 f P A 8,15 9 1 -1 A 9,16 10 1 -1 11 1 2.3. Results 51 A 2,10 = - (1 -Y H ) (i N O2,N 2 Y H ) A 3,11 = - (1 -Y H ) i N O3,N 2 Y H A 2,12 = -A 2,10 = (1 -Y H ) (i N O2,N 2 Y H ) A 3,12 = (1 -Y H ) i N O3,N 2 Y H A 5,13 = -1/Y AOB -i XB A 4,15 = i XB -f p i XP A 7,15 = i XB -f p i XP A 8,15 = i XB -f p i XP A 1,16 = -i XB i Charge,SN Hx A 2,16 = -(1 -Y H )/(i N O2,N 2 * Y H )i Charge,SN Ox -i XB i Charge,SN Hx A 3,16 = -(1 -Y H )/(i N O3,N 2 * Y H )i Charge,SN Ox -i XB i Charge,SN Hx A 5,16 = -i XB i Charge,SN Hx + (1/Y AOB )2i Charge,SN Ox A 6,16 = -i XB i Charge,SN Hx A 9,16 = i Charge,SN Hx

Results

2.3.1 Numerical analysis of the platform at steady state 2.3.1.1 Numerical procedure WRRF simulations are carried out in the same way as described in the BSM1, i.e. initial conditions correspond to the simulations of the system under constant inputs by using the values reported in Table 2.2 over 300 days. This time period was found sufficient to reach a pseudo-steady-state for all states in the system. Concerning the dynamical simulations of the system (when it is subject to time-varying inputs), the input data set for the influent dynamic concentrations corresponds to that one given in the BSM1LT in dry weather condition [BSM ]: these data, from t = 0 to t = 300, are used for dynamic simulations (cf. Figures 2.2 and 2.3).

Consider the platform represented in Figure 2.1, where the configurations of interest related to the specific valve positions are reported in Table 2.1. The first analysis of this platform consists in characterizing the steady-states it is possible to attain in playing with the different valves of the system. To do so, a total of Chapter 2. From WWTP to WRRF : the necessity of more flexibility to adapt the quality of treated waters to new usages of interest) and for a grid of possible control values acting on the process through

N SS = N V alve × N kLa × N Q sim- ulations (cf.
µ H S S K S +S S S O K OH +S O X BH 2 Anoxic growth of Heter. on S N O2 µ H η N O2 S S K S +S S K OH K OH +S O S N O2 K N O +S N O2 S N H S N H +K N H X BH 3 Anoxic growth of Heter. on S N O3 µ H η N O3 S S K S +S S K OH K OH +S O S N O3 K N O +S N O3 S N H S N H +K N H X BH 4 Decay of Heterotrophs b H X BH 5 Aerobic growth of Nitrosomonas µ AOB S N H K N H +S N H S O K OA +S O X AOB 6 Aerobic growth of Nitrobacter µ N OB S N 02 K N H +S N H S O K OA +S O K N H K N H +S N H X N OB 7 Decay of Nitrosomonas b AOB X AOB 8 Decay of Nitrobacter b N OB X N OB 9 Ammonification K a S N D X BH 10 Hydrolysis of entrapped organics K h X S /X BH K X +X S /X BH ( S O K OH +S O + η g K OH K OH +S O S N O2 +S N O3 K N Ox +S N O2 +S N O3 )X BH 11 Hydrolysis of nitrogen r 10 ( N N D X S )
S I S S X I X S X BH X AOB X N OB X P S O S N O2 S N O3 S N 2 S N H S N D X N D S
Variable COD N charge 1 S I 1 0 0 2 S S 1 0 0 3 X I 1 0 0 4 X S 1 0 0 5 X BH 1 0.086 0 6 X AOB 1 0.086 0 7 X N OB 1 0.086 0 8 X P 1 0 0 9 S O 1 © c i,comp 0 10 S N O 2 -3.43 1 -0.71 11 S N O 3 -4.75 1 0.71 12 S N 2 -1.71 1 0 13 S N H 0 1 0.71 14 S N D 0 1 0 15 X N D 0 1 0 16 S ALK 0 0 -1 Table 2.6: composition matrix
K L a 1 , K L a 2 , Q RAS , Q W AS and Q int (see Figure 2.4).
To investigate the attainable steady states, a simulation loop was launched for each combination of control variables. The discretization of control degree values was uniform. The steady states set formed by the N SS steady states obtained (all state variables of the effluent -the values of the variables in the last aerobic compartment together with the corresponding process configuration and the associated control variables (reported in Table 2.7)) were saved in a steady-state matrix, which has (30240 × 24) elements consisting of two sub-matrices (cf.

Variable Description

V alve(A) V alve(A) = 1 or 0 (Q in is directed to the V alve(B) or to the anoxic tank R1) V alve(B)

V alve(B) = 1 or 0 (Q in is directed to the MBR R3 or to the aerobic tank R2) V alve(C) V alve(C) = 1 or 0 (Q RAS is directed to the anoxic tank R1 or to the aerobic tank R2)

Q RAS Open loop (no active controller), Q RAS = Q in : Q in : 5 × Q in Q int Open loop (no active controller), Q int = 0 : Q in : Q int K L a 1
Open loop (no active controller), K L a 1 = 50 : 50 : 300

K L a 2
Open loop (no active controller), K L a 2 = 50 : 50 : 300

Q W AS
Open loop (no active controller), Q W AS = 0 : 100 : 1300

N V alve N K L a N Q No. Steady stat N SS 2 × 3 6 × 6 5 × 14 × 2 30240× (16 variables)& (8 controllers)
Table 2.8: Combinations for the controls and the corresponding steady states

Open loop control

In this section, we use the results obtained in the previous section for an open loop control strategy. In particular, depending on the output water requirements in terms of ammonium nitrogen or/and nitrate, the user can configure/reconfigure the system (playing with both Some simulations are plotted in 2.5 to illustrate the range of steady states it is possible to attain in playing with the manipulated variables (see appendix C). Notice that using a given combination of the controls makes it possible to favor a given form of nitrogen with respect to others. A particularly interesting feature of the exercise is that playing both with the configuration of the system and with control actions makes is possible to achieve more or less the same target, leading to an important characteristic of the flexibility concept, which opens the route to important research about the automatic operation of such a system, notably in the area of reconfiguration control systems [Aichouche et al. 2020].

Results

57

Figure 2.5: Attainable steady-states for the different forms of nitrogen according to manipulated variables the valves and the control values) to obtain, at steady state, these required output characteristics. Indeed, assume the control objective is to follow a setpoint given as a piecewise constant nitrate concentration. Further assume the static inputs of the process are known and 'close' to those with which the numerous simulations realized in the previous section have been realized (cf. Table 2.2). An algorithm can then browse the database composed of all situations simulated -and depending on the inputs and on the required nitrate concentration -find the one which is the closest, and finally adopt the corresponding configuration while the controls are set to those values found in the database. In other words, the openloop control strategy simply consists in applying the corresponding configuration of valves and control inputs to the process for it to deliver the appropriate output nitrate concentration.

In order to illustrate such a flexibility concept, this open-loop control strategy is tested in simulation by using the algorithm [1] reported hereafter with the piecewise output concentration setpoint plotted in Figures 2.6 2.7 for both constant and then dynamical inputs (dashed line), respectively. For the static case, we assume the static inputs are exactly those given in Table 2.2. For the dynamic case, the dynamical input data used correspond to inputs of the dry weather conditions used in the BSM1LT [BSM ] from t = 0 to t = 300 days. We consider the piecewise constant setpoint for the nitrate plotted in Figure (2.6). For each value of the setpoint, the configuration -out of the six reported in Table 2.1 -and represented by the succession of colors -is identified as the one allowing to obtain the closest nitrate value saved during the open loop simulations. Table 2.9 reports the corresponding configuration and control values that must be applied.

Algorithm 1 Search S * N O3 in data.S N O3 i ← 0 while data.S N O3 [i] = S * N O3 do i ← i + 1 if data.S N O3 [i] is equal to S * N O3 then k L a 1 ← data.k L a 1 [i] k L a 2 ← data.k L a 2 [i] V A ← data.V A [i] V B ← data.V B [i] V C ← data.V C [i] Q W AS ← data.Q W AS [i] Q RAS ← data.Q RAS [i] Q int ← data.Q int [i] else (S * N O3 is not fined)
We can notice that the approach is particularly efficient: the process delivers a value for the output nitrate concentration which is very close to the required setpoint whatever the input are constant (cf Figure (2.6) or dynamic (cf Figure 2.6). However, it should be noticed that such an approach makes important hypotheses, in particular:

• The inputs are assumed to be constant and perfectly known; Chapter 2. From WWTP to WRRF : the necessity of more flexibility to adapt the quality of treated waters to new usages

S * N O3 k L a 1 k L a 2 V A V B V C Q W AS Q RAS Q int 15,2 100 300 1 1 0 400 2 × Q in Q in 7.5 100 150 1 1 1 300 Q in 0 22 200 300 0 0 1 700 Q in Q in 14.8 150 300 1 1 0 300 Q in 0 7 100 250 1 1 0 400 Q in Q in 15.1 150 200 1 0 0 300 Q in 0 Table 2.9:
: Valve A , V B : Valve B , V C : Valve C
• The model is assumed to be noise free and its parameters perfectly known in order to build the database;

• At present time, this open loop approach is not optimized at all. In particular, taking advantage of the flexibility of the platform, it may happen that two different configurations allow the same output to be obtained: in such a case it could be interesting to consider other criteria such as the one requiring the less energy or still the one minimizing sludge production.

Otherwise said, the open-loop control strategy requires a very high quantity of information which is usually unavailable in a real case: the inputs are usually not well characterized while the system is subject to uncertainty or disturbances and the measurements subject to noise. It is why a closed-loop approach should be preferred.

Dynamical analysis

Two industrial strategies for the closed-loop operation and control of the WRRF platform

The Proportional-Integral PI control remains one of the the most widely used controller in industry due to its simplicity and ease of tuning. For a PI controller, the error signal, e(t) between the setpoint and actual process output is used to generate the proportional (P) and integral(I) control actions with the resulting signals weighted and summed to form the control signal u(t) to be applied to the plant ( [Bennett 1993]). The mathematical expression of the PI controller is recalled in (2.11) where K P and K I are the proportional and integral gains of the controller:

u(t) = K p e(t) + K i t 0 e(τ ) dτ (2.11)
A saturation may be added as a guarantee that the desired setpoint cannot exceed the maximum capacity of the manipulated variables. This can cause the phenomenon of windup, which reflects the fact that the error between the setpoint and the measurement is non-zero and remains of the same sign. However, the simulation results showed here that 2.3. Results 61 such a system was not necessary. In this work, two types of control systems are proposed depending on the objective pursued:

1. The first control strategy focuses on the development of a system allowing a trajectory tracking of the effluent nitrate concentration. The 'advanced industrial control' consists in a cascade of PI controllers represented in Figure 2.8 (or in the Figure . 2.9 for more illustration): the k L a to be applied to aerobic reactors is the output of a PI controlling the dissolved oxygen concentration in the reactor such that a setpoint in S N H 4 to be attained, this S N H 4 setpoint being itself the output of a controller having in its input the S N O 3 setpoint. However, the nitrate concentration being affected by the denitrification, this strategy necessitates the addition of three additional controllers allowing the adjustment of the internal and the external recirculation loops through Q int , Q RAS and Q W AS , respectively, where each PI controls the S N O 3 in the last MBR reactor. These controllers allow the control of the SRT of the system. Notice that each control acts as a kind of disturbance for the others but since the system is stable, it does not affect the global performances of the system as it will be seen in the results. In addition, the configuration is very robust since, in case of a loop failure, the others continue to regulate the nitrate concentration. The valve position control is also acting as a disturbance for the system. It can be qualified of an industrial controller since it uses only two measurements that are the ammonium and nitrate concentrations in the lats basin (S N O 3 being precisely the variable to be controlled in this first control strategy). The 6 controller parameters K P (i) and K i (i), i = 1..3 were tuned by trial and error using dynamical input and setpoint data.

In addition, the control Q W AS was saturated:

0m 3 /d ≤ Q W AS ≤ 1300m 3 /d.
2. The second control strategy represented in Figure 2.10 (or in the Figure . 2.11 for more illustration) consists in controlling a ratio between the nitrate and ammonia concentrations S N O 3 /S N H 4 . Again a combination of PI controllers is proposed. The closed-loop control configuration consists of 4 independent PI controllers, all having as single input the actual ratio S N O 3 /S N H 4 , which is supposed to be measured. The 4 actuators of the 4 PI controllers are i) K L a (the same aeration control is applied to avoid partial nitrification) to control the oxygen concentration S O in the last reactor and ii) the three recirculation and waste sludge pumps

Q int , Q RAS and Q W AS . Saturation was considered to limit k L a: 0 ≤ k L a ≤ 300d -1 . The returned activated sludge flow rate Q RAS limits are 0 ≤ Q RAS ≤ 5Q in and 0 ≤ Q int ≤ Q in .
At first guess, gains K P (i) and K I (i), i = 1..4, are initially tuned using the Matlab's linearizing tool before being optimized to improve their performance with a trial and error approach. Again, notice that this approach is particularly robust with respect to actuator failure since each controller can compensate for problems arising on other control loops.

Proof of concept: 'complete treatment mode'

In this section, we evaluate the nitrate control strategy when the platform is used in the 'complete treatment mode' which should typically be used when there is no need of water To be more realistic, we only performed simulations under dynamical conditions. The input values used for BOD 5 and COD tot are presented in Figure 2.12. The input flow and input total nitrogen concentration are the same as those used in the previous section (dynamic influent data from BSM1LT [BSM ] under dry weather condition), cf Figures (2.2) and (2.3).

The result of this strategy of control for complete treatment mode is given in Figure 2.13 where N tot in the output is plotted and in Figure 2.14 where the output BOD 5 and COD tot concentrations are plotted. The corresponding controllers are reported in Figure 2.15. It can be observed that, although considering highly disturbed inputs, this strategy was able to keep the effluent under the discharge standards (Table . 2.10) in terms of total nitrogen N tot , N H 4 , COD tot and BOD 5 . In the previous section, it was demonstrated that the platform is able to deliver waters which the quality complies with normative constraints -operation mode to be used during periods where no water is needed for irrigation. In this section, we show how the proposed strategies behave when there is a need for irrigation. The WRRF was simulated to first perform i) nitrate control trajectory tracking by using the first closed-loop strategy (2.9 and 2.8) under constant input conditions (no input disturbance) and then under dynamical input conditions. Secondly ii) to perform nitrate to ammonium nitrogen ratio control trajectory tracking closed-loop strategy (2.10 and 2.11) under dynamical input condition.

1. For the 'degraded mode' (we adapt the output nitrate concentration to requirements), when constant inputs are used (cf. Setpoint generation In the previous section, we presented the performance results of the two proposed control strategies depending on the objective pursued using piecewise constant set-points. The objective of the present section is to show how the WRRF, a kind of 'treatment plant of the future' can be managed to deliver water quantity and quality (in terms of nitrogen concentrations) adapted to cultures/plants. Thus we concentrate on the application of the first control strategy. To do so, it is necessary to generate the water and nitrogen set-points to be followed and that could be considered as the 'optimal ones', in a sense to be specified. To generate these set-points, we propose to use available crop models and solve an optimal control problem. There are a very large number of such models in the literature (cf. for instance the state of the art proposed by [START_REF] Jones | [END_REF]). Most of them, for not saying all, only include water needs (no consideration of nitrogen) and are by far too complicated to be used in optimization approaches. Recently, a crop model ( [Pelak et al. 2017]) has been proposed following what we could call a systemic modelling approach from an automatic control viewpoint. It appears to be sufficiently simple for our purpose. The idea we followed is to apply to such a model optimal control techniques to find the 'best' water and nitrogen trajectories as setpoint for our work. Since it is not the objective of the present paper to work on the optimal control of plant growth, we do not further present the approach but rather use the generated setpoint as presented in the following figures (optimal total nitrogen requirements are plotted in dashed black line). In addition, since nitrogen is brought to the plant by water, it is assumed there is more water than necessary and we essentially concentrate on nitrogen content. It is then supposed that the optimal needs in term of water can be perfectly followed. Thus, we only use the total nitrogen requirement trajectory for the nitrate setpoint. Since we work with a membrane system, note that the nitrogen contained in the biomass is not released in the effluent and total nitrogen in the output cannot account on this part. It will be confirmed by the simulations but it is almost equivalent to control output nitrate concentration than controlling the total output nitrogen content of the effluent.

Performance indexes

It should be noticed also that we do not know a priori which of the 6 possible configurations reported in Table 2.1 is the most appropriate for the system to better track the optimal nitrogen trajectory. Thus, all six configurations were simulated first in the absence (unknown constant inputs) and then in the presence of disturbances (in the presence of dynamic inputs, cf. In order to compare the different configurations, important performance indexes such as the total amount of nitrogen provided to the crop through the effluent (both using static (AN T S) and dynamic influent (AN T D)) were computed for each configuration as :

T otalAmountof N itrogen = 139 0 N tot Q ef dt (2.12)
Where N tot is the concentration of total nitrogen, Q ef is the effluent.

Results

73

We also evaluated actual energy costs for the control strategy applied. The pumping energy cost (P E)[kWh d -1 ] is calculated using the product of the flow rate with the pumping economy coefficient P F (kWh m -3 ) as:

P E = 1 t simul i=N i=1 P F i t simul 0 Q i (t)dt (2.13) Where N=3, Q 1 (t)=Q int , Q 2 (t)=Q RAS and Q 3 (t)=Q W AS .
The (P E) is calculated without taking into account the energy for pumping the effluent by the membrane. The pumping economy coefficients are taken from the BSM1:

P E = 1 139 139 0 (0.004Q int (t) + 0.008Q RAS (t) + 0.05Q W AS (t))dt
(2.14) P E is calculated for all considered configurations and for the complete treatment mode. Energy demand for aeration (AE)[kWh d -1 ] cost is calculated with Equation 2.15, which relates AE to the oxygen mass transfer coefficient k L a in each aerated reactor:

AE = 1 139 × 10 3 139 0 V R2 K L a 1 + V R3 K L a 2 dt (2.15)
where V R2 and V R3 are the volumes of the second and final reactors respectively. We noted (P ES) for the pumping energy when using static influent, (P ED) when using dynamic influent, as well as, (AES) and (AED) when using static and dynamic influent respectively.

1. Simulation results when the mean input total nitrogen concentration is 35g.N/m 3 Figures 2.28 show that as underlined above and whatever the configuration considered i) the output nitrate concentration is very close to the total nitrogen concentration, because the optimal amount of nitrogen demanded by the plant before t < 35 is always less than or equal to the amount of nitrogen in the inputs, ii) unless in the transient at the very beginning of the time period, there is almost no nitrite (which is toxic) in the effluent and iii) from about t = 35 there is obviously not enough total nitrogen in the input for the system to be able to perfectly track the output nitrogen setpoint. On overall, it can be seen that configuration C4 seems to be the best to achieve our objectives: over the total period of time, it is the one which delivers the highest quantity of nitrogen (see. Table 2.11) . As expected, Table 2.11 shows that the degraded mode (for adapting the quality of wastewater treated to crops requirements) costs significantly less than treating using the complete mode operation. While the C4 configuration was the best in terms of nitrogen supplied to plants, the configuration C2 has the advantage of providing the best results in terms of costs highlighting a necessary compromise between energy used and savings in chemical fertilizer.

2. Simulation results when the mean input total nitrogen concentration is 55g.N/m 3

Limits of the approach

In the previous sections, it was supposed that the irrigation is not limited by the available water. This means that the water flow produced by the treatment plant (which equals Q in -Q W AS ) is greater than the water required by the culture. In other words, the WRRF produces more water than needed by the culture. If this water contains a high quantity of nitrogen, the water not used for irrigation cannot be released in the environment. In such a case it is necessary either to produce less water (which appears to be a complex problem quality of treated waters to new usages since the outputs of the system in terms of quality vs quantity cannot easily be decoupled) or to store it and send it back to the treatment head when the treatment plant becomes available to treat it. An alternative is to conceive systems where different qualities of waters including the quality provided by the WRRF, can be mixed together. This approach yields complex, but very interesting optimal control problems that are actually not solved but that should be investigated in future work.

Conclusions

The present study presented the modeling, the analysis and the control of a platform proposed for the recovery of nitrogen resources from treated wastewater. The flexibility of the platform was studied. A dynamical model was developed to be used for dynamic simulations under both static and dynamic conditions.Using intensive simulations at steady state, an open loop control strategy was proposed the limitations of which were highlighted. To overcome the weaknesses of this open-loop strategy, closed-loop approaches were developed to allow the trajectory tracking of the nitrogen forms (nitrite or ratio between the nitrate and ammonia) in the effluent.

The first strategy focuses on the control of the effluent nitrate concentration: we first applied it for the 'complete treatment mode' which should typically be used when reuse is not needed. To be more realistic, the simulations were performed assuming the presence of disturbances in the input (dynamic influent). The results showed that this strategy is able to keep the effluent under the discharge standards. Moreover, the same strategy was applied for nitrate control trajectory tracking for 'irrigation' or 'degraded mode' under two input conditions (static and dynamic). For both cases nitrate concentration perfectly tracked the references while all the controllers remained in their admissible ranges without saturating. Depending on agronomic practices, a second control strategy was developed allowing the user to play with the different forms of nitrogen. Indeed, if nitrogen is mainly under the nitrate form, it is readily leachable into the soil, which is not suitable for some soils for which it may be desirable to prefer the ammonia form. Regarding these issues, the second strategy is developed to perform nitrate to ammonium nitrogen ratio control trajectory tracking. Again, very good results were obtained in the presence of dynamical input disturbances: the nitrate to ammonium ratio followed quite well the setpoint. Finally, a major original aspect of this work was the use the modeling and dynamic simulations for coupling the treatment mode with optimal references of plant/crops nitrogen requirement generated using a crop model. The approach was evaluated using the six possible configurations for the WRRF platform proposed both in the absence and in the presence of disturbances using the nitrate control trajectory tracking. Among the different configurations, the results show that if the total nitrogen available in the influent is lower than that required by the crop, whatever the platform configuration used and the control strategy, it is never possible to achieve the required nitrogen levels. Moreover, thanks to its flexibility, some configurations do better than others under the same inputs both in view of the nitrogen quantity supplied to the soil/plants and energy costs. Finally, the results showed that modeling and control tools are able to provide significant contributions to the concept of flexibility, which appears central for conceiving future WRRF.

Chapter 2. From WWTP to WRRF : the necessity of more flexibility to adapt the quality of treated waters to new usages

K N H-I 5 g N H 4 -N m -3 Conversion factor for N O - 3 into COD i COD,N O3 -1,1414285 g COD.g N -1 Conversion factor for N O - 2 into COD i COD,N O 2 -3,4268028 g COD.g N -1 Stoichiometric factor for N O - 3 reduction to N 2 (amount of COD provided by reduction) i N O3,N 2 40/14 g COD.g N -1 Stoichiometric factor for N O - 2 reduction to N 2 i N O2,N 2 1,7242857 g COD.g N -1
Conversion factor for

N H + 4 into charge i Charge,SN H X 1/14 Charge.g N -1 Conversion factor for N O - 3 into charge i Charge,SN O X -1/14 Charge.g N -1
CHAPTER 3

Flexibility of Waste Resource Recovery Facilities for water Reuse Flexibility is required for a more efficient management of water in order to deal with a multiple of (sometimes new) usages. When reusing treated wastewater for irrigation during periods of water stress, conserving some nutrients in treated water for plant needs -in 'degrading the treatment degree' -may present some advantages. On the contrary, when no water is needed for irrigation, the treatment plant must be able to realize a 'full treatment' (in eliminating the pollutants from wastewater and respect the limit imposed by discharge standards). This flexibility in the treatment ability requires a transition between these two operation modes to be minimized. The aim of this work is to study the concept of flexibility related to the capacity to adjust the water treatment degree -as quickly as possible -to changes in. This demand corresponds for instance to plant/crops requirements within the context of treated wastewater reuse while, in other periods, it corresponds to normative constraints. The purpose of the proposed approach is to control the transition between these two operating modes by considering different scenarios. In this paper, we analyze a flexible platform and study different combinations of controls (valves positions, recirculation flows and sludge age) highlighting several functioning modes to be chosen depending on REUSE usages.

Abstract 81

Abstract

In this paper, a new flexible wastewater treatment scheme is proposed to be used within the framework of wastewater reuse (REUSE). From a configuration where the water is treated to guarantee normative constraints, we propose a flexible configuration able to adapt, in minimal time, the quality and the quantity of water to usage. In other terms, the proposed scheme is able to treat water for purpose. Using model analysis and simulations, we show how a simulation platform may be used to demonstrate the flexible characteristics of the scheme, in particular when dealing with the decoupling of water fluxes and the different forms of nitrogen contents in the output treated water.

Introduction

Actual wastewater treatment plants (WWTP) aim at treating wastewater in such a way they comply with normative constraints before discharged into environment (rivers lakes etc). However there is the need nowadays for a paradigm shift within the framework of circular economy: from a waste to be treated wastewater can be viewed as new resources to be processed for purpose. To do so, WWTP have to be operated with more 'flexibility'.

Although intensive attention has been given to WWTP, especially to biological nitrogen and carbon removal processes [START_REF] Kraume | [END_REF], a large number of alternative configurations have been proposed [START_REF] Hreiz | [END_REF]] in order to improve the performance of the treatment either in terms of cost [START_REF] Zarrad | [END_REF] or in terms of quality [van Kempen et al. 2005]. In any case, the configuration should contain an aerobic capacity to promote the nitrification while an anoxic zone must be used to promote denitrification. The two-steps nitrification-denitrification process revealed to be the most economical viable for the total elimination of nitrogen and carbon.

Conventional WWT is accomplished by combining denitrification and nitrification steps requiring oxygen and organic carbon, respectively. The separation of conditions may be done in time or in space by imposing sequentially anoxic and aerobic conditions in a single reactor [Du Toit et al. 2007], or, by having a minimum of 2 reactors of which one is maintained anoxic and the other aerobic. The pre-denitrification and the post-denitrification configurations are the most widespread [START_REF] Barker & Dold | COD and nitrogen mass balances in activated sludge systems[END_REF]. In the pre-denitrification design, the anoxic tank is placed upstream of the aerobic reactor in order to use the carbon present in the effluent for the denitrification. Therefore, nitrified liquor recycling to the anoxic reactor is needed to recirculate nitrate from the aerobic reactor. In the postdenitrification configuration, the anoxic tank is placed downstream of the aerobic reactor. This configuration allows a better nitrate removal efficiency than the pre-denitrification process. However, since carbon source is consumed in the aerated tank, it may become limiting in the anoxic reactor. Therefore, the addition of carbon source may be required in order to achieve an efficient denitrification.

The flexibility concept in WWTP relates to its capacity to adjust -as quickly as possible -to changes in demand, corresponding for instance to plant needs within the context of treated wastewater reuse. On one side, the flexible configuration allows to operate the WWTP in a mode to eliminate the components from wastewater or, on the other side, to keep nutrients or to decouple the water content from the water quantity (play with nutrient contents in the output effluent). In classical configurations, the nitrogen in ammoniacal form (N H + 4 ) is oxidized into nitrates (N O - 3 ) and then reduced into nitrogen gas (N 2 ). In a flexible system, it is expected that the level of the different forms of nitrogen may be adjusted with respect to agriculture requirements. for instance, in some cases, the ammoniacal form of nitrogen (N H + 4 ) will be favored while in others the nitrate form will be preferred. Moreover, keeping (N H + 4 ) requires lower energy consumption than when water is treated to provide nitrates (N O - 3 ). Indeed, performing nitrification requires much more energy because nitrifying bacteria need more time to develop and thus induce a higher oxygen consumption. However,the ammoniacal nitrogen is not directly assimilable by plants: microorganisms in the soil are responsible for transforming (N H + 4 ) into (N O - 3 ) that are more bioavailable.

In the present paper, a new flexible configuration is suggested in the aim to control the transition between the conventional treatment (full treatment mode) and the adaptive treatment (reuse mode) by considering different scenarios. Our first objective is to analyze the best combination between valves positions, recirculation flows and sludge age for each operation mode, and to use this different degrees of freedom to minimize the time response to go from one mode to another one. When designed with the concern of recovering material and/or energy from a given effluent, a WWTP is renamed WRRF for Waste Resource Recovery Facilities. From now and upward, we will thus use WRRF instead of WWTP.

A flexible platform of WRRF

Platform description

The flexible platform configuration consists of an anoxic tank (V 4 = 56 L) followed by aerobic tank (V 5 = 56L) and aerobic tank with membrane (MBR) (V 6 = 40 L). The membrane is supposed to be ideal (perfect separation of soluble and particular matters) to promote sludge separation (fouling phenomena were not taken into account). The plant was designed to treat a flow Q in = 270 L/d. The platform (represented in Figure 3.1) can be operated as a one (only tank 6) -or two (tanks 5 and 6) -or three (Tank 4, 5 and 6)stage process by adjusting influent feeding location (step feeding) and recirculation rates. Denitrification takes place in the anoxic tank whereas nitrification and carbon oxidation are accomplished in both aerobic and MBR tanks. Since nitrates are not present in the influent, they have to be brought into the anoxic reactor by internal recycling of the nitrified mixed liquor from the aerobic reactor when there is a need to reduce the effluent nitrate. This is done by tuning the external recirculation and playing with the position of the valve 'C'. The waste activated sludge (WAS) flow rate in MBR tank is controlled to reach a specific sludge retention time corresponding to different operation modes (full / Adaptive). The dissolved oxygen (DO) concentration in the aerobic and MBR tank are maintained above 2.0 mg/L, while the DO level of the anoxic tank is supposed to be 0 mg/L. The constant influent characteristics are available in the table 3.1.

mgCOD.L -1 X BH,in Active heterotrophic biomass 0 mgCOD.L -1 X AOB,in Active Nitrosomonas biomass 0 mgCOD.L -1 X N OB,in Active Nitrobacter biomass 0 mgCOD.L -1 X P,in Particulate product 20.22 mgCOD.L -1 S O,in Dissolved oxygen 0 mgO 2 .L -1 S N O2,in Nitrite nitrogen 0 mgN.L -1 S N O3,in Nitrate nitrogen 0 mgN L -1 S N 2,in Nitrogen gas 0 mgN.L -1 S N H,in Ammonia nitrogen 36 mgN.L -1 S N D,in Biodegradable organic nitrogen 1.69 mgN.L -1 X N D,in Particulate biodegradable nitrogen 0 mgN.L -1 Q in Input flow 270 m 3 .d -1
In the literature, SRT is usually considered from a steady-state perspective. At steady-state, the static SRT is defined as the mass of microorganisms in the system divided by the mass of microorganisms wasted per time unit:

SRT = X r V r X w Q w + Q e X e ( 3.3)
Where:

V r : Total volume of aeration tanks, m 3 ; X r : Total suspended solids (T SS) concentration in the reactor, mg/L; X w : Total suspended solids (T SS) concentration in the waste activated sludge, mg/L; X e : Total suspended solids (T SS) concentration in effluent,mg/L; Q w : Waste activated sludge (W AS) flow rate, m 3 /d; Qe: effluent flow rate, m 3 /d X e = X r in completely mixed reactor:

SRT = V r Q w (3.4)
The first modeling step consists in determining the initial operating conditions of the WRRF associated with each operation mode:

Reuse Mode

It is necessary to find conditions in which the biological treatment will make it possible to preserve the nitrogen under its form N H + 4 . It means that the sludge age (SRT) must not be too high, so that nitrification will be limiting or it will not take place. The tests are done with a sludge removal rate (SRR), Q w varying between 10 m 3 /d and 40 m 3 /d. It is assumed that no oxygen limitation occurs and no nitrite accumulates.

Complete treatment Mode

The SRR applied in this mode must make nitrification possible to treat nitrogen. Simulations are made with Q w varying between 0.1 m 3 /d and 6 m 3 /d.

Platform simulation

In order to analyze the platform and to determine the best transition strategy from one mode of operation to another in terms of quality and time response, it is necessary to identify the scenarios for each mode of operation. Each scenario represents a mode of operation. To study the transition from one operating mode to another, we study the switch of environmental conditions (positions of valves, values of control signals). Different switches are simulated and the corresponding time responses -corresponding to the time required for the system to switch from one steady state to another one -are observed. It should be noted that the valves in the different configurations are supposed to be all or nothing valves. Each value thus represents a direction of the corresponding fluxes. The first two scenarios are used to model the adaptive treatment (useful for reuse), while the second two scenarios represent the full -or complete -treatment (conventional treatment).

A Valve B Valve C Operating Mode 1 1 0 Scenario S1 1 0 0 Scenario S2 0 ∀ 0 Scenario S3 0 ∀ 1 Scenario S4
Remark 3.4.1. The symbol ∀ in Table 3.2 is used to designate the fact that the corresponding valve position has no importance: for instance if Valve A equals 0, the position of Valve B does not change anything to the configuration of the platform.

Scenario S1

The anoxic and aerobic tanks (4 and 5) are not in operation, whereas the tank 6 is in operation, with the valves positioned at valve A = 1, valve B = 1. The internal and external recirculations are not activated Q ext =Q int =0 and sludge extraction from the tank 6 is Q w = 32.4 L/d.

Scenario S2

The anoxic tank ( 4) is not in operation, were the aerobic and MBR tanks (5 and 6)

Scenario S3

During this scenario all tanks (4, 5 and 6) are in operation, the valve A = 0, B = ∀ and C = 0, the flows of internal and external recirculation are active and are directed towards the anoxic basin and sludge extraction from the 6 tank Q w = 1.4 L/d.

Scenario S4

In this scenario, the configuration is the same for the scenario S3, except for the valve C, that results in position 1. It means that the returned sludge is oriented to the aerobic tank. As we will see, the transitions dynamics between the different modes of operation depend a lot on the initial conditions. Usually, water for reuse is needed during spring and summer times while complete treatment is required during fall and winter where water should be treated to comply with discharge of water in the environment. To simulate such conditions, we varied the time at which we switch from one operation mode to another one.

During the various simulations carried out, different components of the effluent are followed, in particular the different forms of nitrogen, as well as the bacterial populations present in the bioreactor.

Results and discussion

In the present work the results of simulation will be shown, focusing on the transition from the reuse mode to the full one or vice-versa, and describing the nitrogen dynamic during both modes. The alteration from the reuse to full mode had as goal the reduction of response time and to obtain N O - 3 in effluent. On the dissimilarity,when the alteration from the full to reuse one, the objective was to reach a concentration of N H + 4 less than 30 mg.N/L.

Influence of retention time on reuse mode

Figure 3.2 shows the transition from the scenario S1 (reuse mode) to the scenario S3 (complete treatment mode). Different initial conditions at the time of switching explain the observed difference in time responses: remember that the X N OB bacteria grow exponentially. At 200 days the transition occurs. At this instant the X N OB biomass concentration is lower than the one when the transition occurs at 100 day (the more the bacteria are subjected to higher wasted sludge flow Q w = 32.4 L/d for prolonged time, the more its concentration are diminished). It should be noted that in practice, such difference may not be observed: depending on the time during which X AOB and X N OB have not been grown under appropriate conditions, they can simply be considered to be absent of the system. In other words, while simulations may consider very small concentration (that may have no physical meanings), X AOB and/or X N OB may have definitely been washed out from the system. We can also note that the duration of partial nitrification is longer in the case where the transition was applied at 200 day because of the growth rate of X AOB bacteria is greater than the growth rate of X N OB bacteria, then the growth of X AOB is faster to X N OB . To simulate realistic situations, such considerations should be studied with care.

Influence of returned sludge direction

Figure 3.3 shows the comparison between two transition cases. The first one is the switch from scenario S1 to scenario S3 (dashed line) whilst the second one is the swith from scenario S1 to scenario S4 (continuous line). The first transition occurs 200 days slower than the second one. In the later one the returned sludge was directed to the aerobic tank at the instant of transition. This set-up promotes the nitrifying bacteria growth (X AOB , X N OB ), since it reduces the lag phase. On the other hand, in the first transition, the returned sludge was directed to the anoxic tank. In this case, the initial growth of nitrifying bacteria at the transition instant is not encouraged, It leads to an increase in the lag phase.

Effects of dilution on the returned sludge

The transition from S1 to S4 (from the reuse mode to the full treatment mode) was also simulated in considering two different values of the returned sludge, that were 100 L/d and 270L/d. In Figure 3.4 the profiles corresponding to this different values of returned sludge were plotted. When the flow of returned sludge equals 100 L/d (dashed line), the time response was shorter than 270 L/d (continuous line). In the same simulations, an increase in total nitrogen concentrations (N H + 4 , N O - 3 and N O - 2 ) was observed since low returned sludge flow means low dilution rate and more concentrated nutrients. So, in terms of time response the returned sludge equal to 100 L/d seems to be the most important but not in terms in terms of nutrient concentrations in the effluent. In addition, N O - 2 is important during partial nitrification, which is problematic given the toxic characteristics of nitrite.

Influence of biomass addition on the reduction of response time (bioaugmentation)

The next step is to focus on the use of bio-augmentation (addition of nitrifying bacteria) to minimize the time to switch from scenarios S1 to S4. From a simulation viewpoint, it is equivalent to change initial condition of nitrifying bacteria (X AOB and X N OB ) in the reactors according to the following rules:

• X AOB = 10 mg/L; X N OB = 10 mg/L (dashed line in fig 3.5).

• X AOB = 1 mg/L; X N OB = 1 mg/L (continuous line in fig 3.5).

In figure 3.5, both profiles are represented when the added concentration of bacterial is 1 mg/L on both (X AOB and X N OB ). A short partial nitrification was observed because of an insufficient concentration of X N OB to obtain a sufficient growth and a full nitrification (N O - 2 to N O - 3 ). On the contrary, with the addition of 10 mg/L, a complete nitrification was observed. The addition of a more important bacterial concentration influenced positively the time response, reducing it from 50 days with the addition of 1 mg/L to 30 days with 10 mg/L. The Bio-augmentation is therefore a solution in order to decrease the time response of the system as well as the consequent formation of nitrites.

Two cycles simulation of transitions from Reuse to Full treatment

The figure 3.6 shows two transition cycles from the reuse mode to the complete mode. The first cycle was performed after 100 days of operation to the reuse mode to switch after that to full one again. The second cycle was started after 200 days in this cycle. The transition from the full to the reuse mode (from scenario S3 to S1) requires a limiting nitrification to obtain some N H + 4 in the effluent. This transition is fast since it depends only on the time necessary for the nitrifying bacteria to be washed out using the waste sludge flow. This transition is completed in only 15 days (figure 3.6). When comparing the observed time responses for all simulated transitions, the addition of biomass (X AOB and X N OB ) at the time of transition seems to be the most appropriate Figure 3.5: Influence of biomass addition. Ammonium (blue) and nitrate (green) and nitrite (red) concentrations in the effluent for two cases of addition of nitrification bacterial : 10 mg/L (dashed line), 1 mg/L (continuous line) strategy. Indeed, autotrophic bacteria and in particular X N OB autotrophs develops very slowly. In addition, when working without bio-augmentation, the risk for nitrite accumulation in the transient is very high.

Conclusion

A new flexible wastewater treatment configuration was proposed in this paper. The basic objective underlying its design is to improve the transition operation between the resource recovery mode (Reuse) to the conventional treatment mode (full). In the present study various possible scenarios were discussed with the aim to analyze and design different transition situations. Suitable scenarios were selected for each operating mode in order to determine the best transition to minimize the time response and to ensure effluent quality in accordance with agriculture requirements. An improvement on the response time by an addition of nitrifying bacteria was observed. A future work will investigate extensions of the results to take in account a dynamics influent flow with manipulating in different control degree.

Abstract

In this paper, we present a new procedure using an observer for estimating soil water content (SWC), a key parameter of soils when dealing with the adaptation of water plant requirements within the framework of irrigation. Results showed that the estimation of SWC by means of the observer was good. On the one hand, the estimation of the unknown part of the soil-plant water balance equation (negative component) has been found to be noise-free and values of evapotranspiration ET, drainage Dr and runoff Ro were estimated after filtering the simulated data. On the other hand, SWC has been found to increase after each water supply and decrease in the interval separating two successive irrigations. In addition, crop water requirements of avocado were found to be as much as 622 mm (for the 2016 dataset) and 380 mm (for the 2018 dataset) during the growing season from June throughout September. The findings of this research helped accounting for the net water requirements of avocado with the aim to optimize irrigation supply and provide guidelines to growers and farmers on sustainable irrigation of this crop under Lebanon's Mediterranean climate and limited water resources.

Introduction

Avocado (Persea americana Mill) is a subtropical tree native to Central America not very demanding in terms of light and water and can withstand reduced water supplies [Nakasone et al. 1998], [Bower 1985], [START_REF] Cutting | [END_REF]] and [Bower & Jackson 2003]. However, yields, fruit quality and tree health will suffer from unbalanced water management [Celedón et al. 2012]. When placed under water stress, avocado trees develop blockages, which are not reversible [Martens et al. 1994]. Therefore, significant, sustained stress periods will result in lasting damage to avocado's tree capacity to draw water and nutrients [Dirou 2003]. With adequate water supplies, the trees will produce new shoots and fruits and the effect of the stress damage will diminish [Partridge 1997], [Carr 2013b].

The standard irrigation strategy for crops is to maintain a certain level of soil moisture in the top root zone within the Readily Available Water (RAW) range for water sensitive crops (-20 kPa maximum) throughout the growing period [Carr 2013a], [Müller et al. 2016]. As avocado is an evergreen tree, the soil moisture should be monitored throughout the year and during the non-bearing period of the growth cycle. Irrigation is needed in summer and in some cases in spring whenever winter rainfall is not sufficient [Pegg 1978]. In all cases, good irrigation management practices combined with good soil management result in increased productivity of avocado trees [START_REF] Karam | [END_REF].

Under Mediterranean climate, characterized by hot and dry summers and dominantly humid winters, irrigation is practiced to restore water deficits due to high crop evapotranspiration (ET). In order to maintain adequate soil water content in the top soil profile, irrigation scheduling based on regular readings of the soil water content in the root zone has the advantage to supply the needed water requirements to crops to avoid prolonged periods of water stress. Avocado is known to have shallow root system expanding over the top 60 cm of the soil profile. Short irrigation intervals combined with reduced water applications have been shown to improve the tree performance and increase yield, while saving amounts of water that can be used to irrigate other crops [START_REF] Karam | [END_REF].

A first objective of this study was to monitor at online basis soil water content (SWC) in the root zone by means of digital tensiometers and determine crop water requirements of avocado under Lebanon's Mediterranean climate. The second objective was to provide growers and farmers with practical information on sound irrigation management of this crop under the prevailing water shortages during summer period.

Soil water content measurement and dynamical modeling 4.3.1 Soil Water Content Measurement

Soil water potential (in cbar) in the 0-45 cm of the soil profile is currently measured with resistive devices. Such sensors respond to changes in soil water potential at the desired depth. This type of digital tensiometers is an electrical conductor and thereby provides relative indication of the soil moisture status. As the soil dries up, water is removed from the sensor and the resistance measurement increases. Conversely, when the soil is rewetted, the resistance lowers. This is a non-destructive method that provides accurate indication on the soil water availability to plants without any maintenance and can remain in the soil during long periods of time.

Using such sensors, values of soil water content (SWC, in cbar) can be measured online and converted into mm of water depth using the following simple conversion equation [START_REF] Karam | [END_REF]:

SW C| mm = ( SW C(t)| cbar 100 ) × F C(%υ) × 10 15 (4.1)
Where 100 is a factor to convert from cbar to bar and 15 is the pressure (in bar) at permanent wilting point, while FC is field capacity (in % of volume). 10 is a conversion factor to convert water content volumetric water (in %) into mm of water depth (1 % of volumetric water corresponds to 1 cm or 10 mm of water depth).

4.3. Soil water content measurement and dynamical modeling 97

Water mass-balance modelling

The water balance approach to irrigation scheduling keeps track of the soil water deficit by accounting for all water additions and subtractions from the soil root zone. Crop water consumption or evapotranspiration accounts for the biggest subtraction of water from the root zone while precipitation and irrigation provide the major additions [Andales 2014].

The different components of the soil-plant water balance can be used to write down the following water balance in soil over Q given period of time:

P + I -ET -D r -R o ± ∆Q = 0 (4.2)
where P is precipitation, I irrigation, ET evapotranspiration, D r drainage, R o runoff, and ∆Q the variation of soil water content during a given irrigation interval.

The mass balance 4.2 can be rewritten as the following continuous time ordinary differential equation :

dSW C(t) dt = f (SW C(t))(P (t) + I(t) -ET (t) -D r (t) -R o (t)) (4.3)
where SWC is the Soil Water Content while f (SW C(t)) = 0 if SW C(t) < 0 and f (SW C(t)) = 1 otherwise to guarantee the positivity of SWC.

Remark 4.3.1. In this paper, we work with trees. Thus it is assumed that the volume of soil containing accessible water -the root zone -is constant. If we were considering developing crops, we would take into account its growing volume as proposed, for instance, in the model proposed in [Kalboussi et al. 2019].

The dynamic of SW C depends on two kinds of terms, that we will denote here as 'inputs' because they act on its dynamic. Some of them are known (P and I notably) while others are unknown (as ET , D r and R o ). Our objective is to estimate what contributes to the negative influence of SW C in order to compensate it with irrigation. In other terms, we aim at providing a systematic procedure to continuously estimate the sum -ET -Dr -Ro.

To do so, we know the dynamic of the mass balance of water content in soil, i.e. 4.3, and the in-real-time (or online) measurement of SW C(t) provided by 4.2. Remark 4.3.2. In practice, SW C is measured at a given depth. In all rigor, we should write a model including the depth at which the sensor is positioned and write down the dynamic of SWC at this depth. However, this model would be much more complicated than 4.3. As a first approximation, we rather use 4.3 as a basis for estimating the unknown component of the dynamic of SW C as it is described in the next section. It is equivalent to assuming that water mass balance in soil is equivalent to a simple tank that fills up and empties depending on what is added (u) and withdrawn (w), respectively.

Chapter 4. Processing Soil Water Content Measurements to Estimate Crop Water

Requirements and Optimize Irrigation Supply

Observer design for estimating crop water requirements

In the following, we use systems theory to build an observer for the term -ET -D r -R o .

From now on, we denote u(t) = P (t) + I(t) and w(t) = -ET (t) -D r (t) -R o (t). In a systemic approach, u(t) is called a 'known input' while w(t) is qualified as an 'unknown input'. Equation 4.3 is then rewritten as:

dSW C(t) dt = f (SW C(t))(u(t) + w(t)) (4.4)
In a first attempt, it was assumed that w(t) is an unknown constant (in practice it may vary slowly with time). Under this assumption, we can write the dynamic of w as:

dw dt = 0 (4.5)
Following the disturbance accommodation control theory (cf.

for instance [Harmand et al. 2000]), we consider the 'augmented' dynamical system under a matrix form:

dSW C(t) dt dw dt = 0 1 0 0 SW C(t) w(t) + 1 0 u(t) (4.6)
which is simply a way of rewriting both 4.4 and 4.4 which are two simple first order differential ordinary equations in a concatenated manner as a single dynamical system of dimension 2.

In addition, recall that SW C(t) is measured. Let us denote y(t) = SW C(t). Referring to control systems theory, we can then build an 'observer' (or an 'estimator') for w(t)denoted ŵ(t)computed as the 'output' of the following observer:

dξ 1 (t) dt dξ 2 (t) dt = 0 1 0 0 ξ 1 (t) ξ 2 (t) + 1 0 u(t) + K 1 K 2 (y(t) -ŷ(t)) (4.7)
Which rewrites:

dξ 1 (t) dt dξ 2 (t) dt = -K 1 1 -K 2 0 ξ 1 (t) ξ 2 (t) + 1 0 u(t) + K 1 K 2 y(t) (4.8)
where ŷ(t) = ξ 1 (t) and ŵ(t) = ξ 2 (t) and K T = (K 1 K 2 ) T is the 'gain' of the observer, chosen such that the system 4.8 guaranties that lim t→inf (y(t) -ŷ(t)) = 0

This modeling for w(t) resents an important drawback: since it assumes w varies slowly with time (rigorously, it is a constant!), it will give bad results if it is not the case.

In order to relax this hypothesis, we decided to "augment" the model chosen for w in assuming it is the output of a second order system. Such an hypothesis can be formalized in replacing the model 4.4 by the following differential system:

dw 1 (t) dt dw 2 (t) dt = 0 1 0 0 w 1 (t) w 2 (t) (4.9)
with w(t) = w 1 (t) In other terms, w(t) = α + βt is now the sum of an unknown constant α, and a line which the slope β must be estimated.

In doing so, 4.6 is rewritten as:

    dSW C(t) dt dw 1 (t) dt dw 2 (t) dt     =    0 1 0 0 0 1 0 0 0       SW C(t) w 1 (t) w 2 (t)    +    1 0 0    u(t) (4.10)
Finally the observer equation can be deduced for the new unknown input model:

    dξ 1 (t) dt dξ 2 (t) dt dξ 3 (t) dt     =    -K 1 1 0 -K 2 0 1 -K 3 0 0       ξ 1 (t) ξ 2 (t) ξ 3 (t)    +    1 0 0    u(t) +    K 1 K 2 K 3    y(t) (4.11)
where ŷ(t) = ξ 1 (t) and ŵ(t) = ξ 2 (t) and K T = (K 1 K 2 K 3 ). While system 4.4 is a system with one known and one unknown input, system 4.8 -or 4.11 -is a system -of higher dimension -but with two known inputs (u(t) and y(t)). In other words, replacing a system of one dimension with an unknown input with a higher dimensional system with only known inputs allows us to estimate the unknown input of the latter. In addition, playing with K we can choose the 'speed' (or the 'rate') at which the estimate converges towards the 'true' value (the actual value) of the unknown input.

Of course, to guarantee that property, the system must be observable what can be easily checked for the above system whatever the model chosen for w.

In practice, the observer 4.11 an then be used to estimate w(t) from the knowledge of a time series of u(t) and of y(t). In practice, it is well known that under semi-arid or arid climates, ET is the main contributor to w. As a consequence,estimating w allows us to estimate the crop requirements ET .

Practical application 4.5.1 The experimental setup

Digital tensiometers (Watermark, Irrometer Inc., California) in the range of 0-199 cbar were installed at different depths in the 0-45 cm layer of the soil profile during two seasons: i) the 2016 growing season (June through September) and ii) the 2018 growing season, in two orchards cropped with avocado (Persea americana Mill) in Lebanon.

Observer design and results

The proposed approach was applied to data obtained on the orchards described here above (cf. Fig. 4.1 to Fig. 4.6). The purpose was to provide online soil water monitoring in the root zone and determine crop water requirements using a proposed soil-plant water balance approach. The ultimate goal was to provide irrigation advisory on this crop to growers and farmers to better manage the limited available water resources.

The sensor's readings were converted from cbar in mm using Eq.4.1 before being injected in the observer Eq.4.11 . The observer gain was chosen using a try and error approach using the 2016 dataset and applied without additional settings to the 2018 dataset. It is to be noticed that the available dataset is not noisy (cf. Fig. 4.2 to Fig. 4.5). Thus, it is expected the observer to be not very sensitive to noise and we can choose gains relatively high. In order to tune the observer, we decided to use an original optimization technique consisting in tuning K in such a way that the innovation -using one dataset -is minimized. It was checked a posteriori that the obtained observer was stable. Stabilizing gains used to obtain the results presented below were [184001800] T corresponding to closed loop poles of the observer -the system 4.11 arbitrarily placed at : [-6.11 -5.95 + 17i -5.95 -17i] T . slopes modeling the response of the plant to irrigation periods. In other words, after each irrigation event, the response of the plant -view as a constant plus a straight line has to be re-calibrated as proposed with respect to model 4.9. Second, notice that the estimated signal ŵ(t) is not only negative -while it is actually supposed to give an estimation of the sum of all negative contributions to the dynamic of SW C. There are several possible explanations. Either measurements or the input signal are a little bit biased. Having chosen high gains for the observer, there are some overshoots including negative estimations of SW C while it should be constrained to be positive. Globally however, the results are good and very interesting from a practical viewpoint: using an observer for estimating ET is very innovative and useful for users.

Discussion and conclusions

Results obtained within the frame of this study showed that soil sensing was quantitative and accurate method, since it is based on online readings of the soil water potential at different depths of the soil profile, and convert the readings into water depth (in mm) that are used by the soil-plant balance through the proposed equation. This chapter is published : F. Aichouche, N. Kalboussi, A. Rapaport and J. Harmand, "Modeling and optimal control for production-regeneration systems -preliminary results -," 2020 European Control Conference (ECC), Saint Petersburg, Russia, 2020, DOI: 10.23919/ECC51009.2020.9143741. The quality requirements for reusing treated wastewater imposes the treatment to comply with strict normative constraints. In most cases, this has as a consequence to increase the treatment cost and discourage water reuse. As already mentioned, MBRs are good candidates for treating wastewater to be reused since they allow the production of very high quality waters. However, they suffer of a very important drawback which is the necessity to manage membrane fouling. To decrease their operating costs, their functioning must be optimized. We developed an automatic tools for the optimization of membrane fouling management. More precisely, we propose an algorithm for minimizing the energy consumption under performance constraints using a generic modeling approach. The main characteristic of our results is its genericity since the hypotheses under which the results remain valid include a very large class of systems called 'production' and 'regeneration' systems. In this framework, a simple general model is introduced and the results of a closed-loop optimal control is synthesized.

Abstract 107

Abstract

This work presents a general model for production -regeneration systems, alternating two functioning modes, the first one as a production process while the second one regenerates the process performances. Such systems are quite common in industry: they include for instance filtration/backwash of membranes, discharge/charge of accumulators. Basically, in these systems the sequence of production/regeneration over time cycles is the manipulating variable. A simple mathematical model involving a single explanatory 'hidden variable' to capture the dynamic behavior of the process in both functioning modes is designed. Based on the Pontryagin's Maximum Principle, we characterize the optimal control strategy for a given criterion minimizing the energy consumption under a constraint on the performances.

Introduction

Many systems in industry require alternating 'production' and 'regeneration', or 'recovering' and 'maintenance' modes. It is for example the case of membrane or accumulator systems. During the membrane filtration, the matter is accumulated until a occurring fouling phenomenon. After that, since it is necessary to remove this matter, a regeneration process of the membrane called 'backwash phase' is used [Sutherland & Chase 2011] [Robles et al. 2018]. Practically, the mass of matter accumulated onto the membrane surface can be measured online, and this variable could be chosen to describe the state of the membrane process in models [Lan et al. 2017]. In discharge/charge systems, the available energy depends on the quantity of energy stored either electro-chemically, hydraulically (or electro-statically). When the available energy goes down a given threshold, the system has to be recharged. In this case, the variable that best describes the state of the accumulator is the quantity of energy stored (typically a force or an available voltage). In both cases, the state of the system can be described by a single variable that changes monotonously with time: the mass of matter attached onto the membrane or the force (e.g. the voltage) continuously increase during the production phase. Then, during the regeneration or maintenance phase -which also consumes energy and makes the system unavailable for production -the state of the system monotonously decreases (the mass attached onto the membrane or the inverse of the available voltage or force). However, for certain systems such as electric ones, the two phases could be operated simultaneously, as a convex combination of the dynamics of each phase. We address the control problem which consists in fixing a given performance to be attained (for instance a quantity of fluid to be filtered or a quantity of energy to be used for producing a good), the control variable being the sequence of production/regeneration cycles over time. Notice that there exists necessarily a trade-off between the times spent in production in regeneration phases: the time spent in the production phase brings us closer to our production goal. However, greater the preliminary resultstime spent in production lower the efficiency of the process, thus necessitating to switch to the regeneration phase at certain instants. Therefore we shall look for control strategies minimizing the total energy required to attain the target. Such problems have been solved but for maximizing the net water production of a membrane filtration system over a fixed time horizon [Kalboussi et al. 2018] or the optimal energy management strategies of charge/discharge accumulators [START_REF] Robles | Optimal control based charging/discharging strategy of dual battery energy storage system for wind Bibliography power dispatch[END_REF]]. In the present work, the generic modeling of such systems is introduced, and a different cost function where a minimization of energy consumption is considered, once the level of production is fixed. In the literature of production/regeneration systems, the total production with a final constraint -or with free end time was already considered [Kalboussi et al. 2018[START_REF] Robles | Optimal control based charging/discharging strategy of dual battery energy storage system for wind Bibliography power dispatch[END_REF]]. The paper is organized as follows. First, model and general assumptions are presented leading to an optimal control problem. Then, we apply the Pontryagin's Maximum Principle (PMP), and discuss about singular arc and switching curve for the control synthesis. Finally, a numerical application is presented and discussed before conclusions and perspectives are given.

Modeling and preliminaries

Let x(t) be a variable describing the state of the process at time t -for instance the mass of the membrane deposit during the water filtration or the inverse of available voltage at both terminals of a battery. During the production phase, we can assume that x(t) is growing according to a dynamics ẋ = f p (x). During the regeneration phase, this dynamics is reversed according to a dynamics ẋ = -f r (x). We consider a control u(t) that takes values 1 during production and -1 during regeneration (or in [-1, 1] if a combination of both modes is possible). Then, the controlled dynamics can be written as follows:

ẋ = 1 + u 2 f p (x) - 1 -u 2 f r (x), x(0) = x 0 . (5.1)
For convenience, we define: 5.1) can be written as:

f + (x) = f p (x) + f r (x) 2 , f -(x) = f p (x) -f r (x) 2 Equation (
ẋ = f -(x) + u f + (x), x(0) = x 0 .
(5.2)

Let us assume that the total energy demand is the sum of the energy needed during the production phase and the one required for regeneration: it is given by a function E T that depends on x(t), such that:

E T (x 0 , u(•)) = t f 0 1 + u(t) 2 l p (x(t)) + 1 -u(t) 2 l r (x(t) dt (5.3)

Modeling and preliminaries 109

where l p and l r are the energies per unit of time required respectively for the production and the the regeneration.

It is further assumed that the energy needed for production or regeneration is proportional to a flux (more generally a quantity of something over a period of time) over an entity playing the role of a 'resistance'. The functions l p and l r can then be expressed as:

l p (x) = Q p τ p (x), l r (x) = Q R τ r (x) (5.4)
where Q p and Q r are typically (constant) fluxes while the functions describing the way that the state affects production and regeneration phases are τ p (•) and τ r (•), respectively. One usually considers that the regeneration speed is higher than the wear or fouling speed. This amounts to require the following assumption.

Assumption 5.3.1. One has f r (x) > f p (x) for any x > 0.

For convenience, we define:

l + (x) = l p (x) + l r (x) 2 , l -(x) = l p (x) -l r (x) 2
Then, equation ( 5.3) can be simply written as:

E T (x 0 , u(•)) = t f 0 (l + (x(t)) + u(t) l -(x(t)))dt (5.5)
Given an initial state x 0 ≥ 0, the objective is to determine an optimal strategy u(•) that takes values -1 or 1 for minimizing E T (x 0 , u(•)) for a given total production p * .

The process stops at the first time t f for which the target is reached: p(t f ) = p * , where the production p(t) at time t is given by

p(t) = t 0 1 + u(t) 2 Q p - 1 -u(t) 2 Q r dt (5.6)
The production dynamics is then

ṗ = 1 + u 2 Q p - 1 -u 2 Q r , p(0) < p (5.7)
For convenience, we define:

Q + = Q p + Q r 2 , Q -= Q p -Q r 2
Equation (5.7) can be written as:

ṗ = Q -+ uQ + , p(0) < p (5.

8) preliminary results -

To summarize, we consider the following optimal control problem:

inf u(•) t f 0 (l + (x(t)) + u(t)l -(x(t))) dt subject to ẋ = f -(x) + u f + (x), x(0) = x 0 ṗ = Q -+ u Q + , p(0) = p 0 u ∈ [-1, 1]
where t f is the first entry time in the target

T = {(x, p) s.t. p ≥ p } Remark 5.3.1.
As one has Q + > 0 and Q + > Q -, the target can be reached in finite time, taking for instance the control u = 1 at any time. However, it is well known from the theory of optimal control that the existence of an optimal trajectory can be guaranteed when the velocity set is convex. Therefore, we shall consider for the mathematical analysis that the control u(•) can take values in the interval [-1, 1]. The question of practical applicability of a control that takes values different to -1 and 1 relies then on bang-bang approximations.

When a membrane operates in filtration, the flow resistance is never null and increases according to the mass x formed on the membrane surface, which subsequently decreases the permeate flux. Thus, we assume that the rate f p at which the mass of material adheres to the membrane surface during filtration is a positive decreasing function. When changing to backwash operation, the mass is decomposed and the membrane's permeability increases again. Therefore, the mass detachment can be described by a positive increasing function f r .

For simplicity, we consider in this study the simple expressions of the functions f p , f r , l p , l r :

f p (x) = -a p x + b p , f r (x) = a r x l p (x) = c p x + d p , l r = c r x + d r ( 5
= [0, x max ] × [0, p )
is invariant and we shall consider initial conditions (x 0 , p 0 ) in the domain D only.

Application of the Maximum Principle

Let us first introduce the Hamiltonian of the system:

H(x, λ x , λ p , u) = λ x [f -(x) + uf + (x)] +λ p [Q -+ uQ + ] + λ 0 [l + (x) + u l -(x)] (5.11)
where λ 0 is equal to -1 or 0. The PMP states that for any optimal solution u (•) there exists adjoint variables λ x (•), λ p (•) solutions of the adjoint system

λx (t) = -∂ x H(x(t), λ x (t), λ p (t), u (t)) λp (t) = -∂ p H(x(t), λ x (t), λ p (t), u (t))
where u (t) maximizes u → H(x(t), λ x (t), λ p (t), u) at almost any t ∈ [0, t f ], with the transversality conditions

λ x (t f ) λ p (t f ) ∈ -N T (x(t f ), p(t f ))
(where N T denotes the normal cone to the set T ). Moreover, the vector (λ x (•), λ p (•), λ 0 ) is not identically null and one has

H(t) = max u∈[-1,1] H(x(t), λ x (t), λ p (t), u) = 0, t ∈ [0, t f ] (5.12)
(see for instance [Harmand et al. 2019]). Here, the adjoint equations are

λx = -λ x f -(x) -λ 0 l + (x) -u λ x f + (x) + λ 0 l -(x) (5.13) λp = 0 (5.14)
with the transversality conditions

λ x (t f ) = 0, λ p (t f ) ≥ 0 (5.15)
From (5.11), we define the switching function 5.16) preliminary resultswhich gives the following maximization condition

φ(t) = λ x (t)f + (x(t)) + λ p Q + + λ 0 l -(x(t)) (
u (t) = 1 when φ(t) > 0 -1 when φ(t) < 0 a.e. t ∈ [0, t f ] (5.17)
We begin by a Lemma about λ 0 and λ p .

Lemma 5.4.1. For any optimal solution, one has the following properties i. λ 0 = -1 i.e. there does not exist abnormal extremal,

ii. there exists t < t f such that u

(t) = 1 is optimal for t ∈ [ t, t f ],
iii. λ p is a positive constant.

Proof. i. If λ 0 = 0, the solution λ x (•) of ( 5.13) for the terminal condition (5.15) is identically equal to zero. Then, λ p is non null and the Hamiltonian is constant equal to λ p (Q -+ Q + ) which contradicts (5.12).

ii. At terminal time, the terminal conditions (5.15) give

φ(t f ) = λ p Q + -l -(x(t f ))
, where λ p is non negative and l -(x(t f ) is negative under Assumption 5.3.1. Therefore φ(t f ) > 0 and by continuity of φ(•), we conclude from (5.17) that there exists t < t f such that u (t) = 1 is optimal for t ∈ [ t, t f ].

iii. If λ p =0, consider the optimal control u (t) = 1 for t ∈ [ t, t f ]. On this time interval one has then

H(x(t), λ x (t), λ p , u (t)) = λ x (t)(f -(x(t)) + f + (x(t))) -(l + (x(t)) + l -(x(t)))
which is a continuous function of t. The terminal conditions (5.15) give then

H(t f ) = -(l + (x(t f )) + l -(x(t f ))) < 0. Therefore condition (5.12) is violated on [ t, t f ].
We focus now on the study of singular arcs, locus for which φ is null on a time interval of non null measure.

Singular arcs

For simplicity we drop the time dependency:

ẋ = -(a p + a r )x + b p 2 + u (-a p + a r )x + b p λx = λ x a p + a r 2 + c p + c r 2 + u a p -a r 2 λ x + c p -c r 2 φ = λ x (a r -a p )x + b p 2 + λ p Q + + (c r -c p )x -d p + d r 2 H = λ x -(a P + a r )x + b p 2 + λ p Q -- (c p + c r )x + d p + d r 2 + uφ
Conditions φ = 0 and H = 0 give together the system of two equations in (λ x , λ v ):

((a r -a p )x + b p ) λ x + 2Q + λ p = (c p -c r )x + d p -d r (-(a P + a r )x + b p ) λ x + 2Q -λ p = (c p + c r )x + d p + d r (5.18)
Its discriminant ∆(x) is given by the following expression

∆(x) = (a p Q r + a r Q p ) x -b p Q r which is null for the particular value x∆ = b p Q r a p Q r + a r Q p
If φ is null when x = x∆ , the system (5.18) admits an unique solution, for which a direct computation gives λx

(x) = P x (x) ∆(x) , λp (x) = P p (x) ∆(x) (5.19) with    P x (x) = -(c p Q r + c r Q p )x -(d p Q r + d r Q p ) P p (x) = (a r c p -a p c r )x 2 + (a r d p -a p d r + b p c r )x + b p d r
As λ p is constant along any optimal trajectory, we deduce that φ can be null only at isolated values x, positive roots of the polynomial

P p (x) -λ p ∆(x) = 0
In any case, a singular arc is possible only for constant values of x equal to x∆ or x with ∆(x) = 0. Then, the corresponding value of the control for the trajectory to stay at

x = x is ū = - f -(x) f + (x) = -(a p + a r )x + b p (a r -a p )x + b p (5.20) A straightforward computation gives φ = 1 2 (a r b p λ x + (a r c p -a p c r )x + b p c r )
(5.21) preliminary resultsthat we write using the expression of φ as follows:

φ = a r b p (a r -a p )x + b p φ + ψ(x, λ p ) (5.22)
where the function ψ has the expression (5.10) that the denominator in expression (5.22) is always positive and thus ψ is well defined. Therefore a singular arc x = x with x = x∆ has to satisfy

ψ(x, λ p ) = 1 2 M (x, λ p ) (a r -a p )x + b p with M (x, λ p ) = (a p -a r )(a p c r -a r c p )x 2 -2(a p c r -a r c p )b p x +a r b p (d p -d r -2λ p Q + ) + b 2 p c r Notice from condition
Γ(x) = ψ(x, λp (x)) = 0 (5.23)
Finally, a straightforward but lengthy computation (verified with Maple) gives the following expression of Γ Γ

(x) = - 1 2 N (x) ∆(x) with N (x) = -(a r c p -a p c r ) (a p Q r + a r Q p )x 2 -2b p Q r x +a r b p (d p Q r + d r Q p ) + b 2 p c r Q r Consequently,
a singular arc x = x with x = x∆ is a root of N . We consider that the case for which x∆ could be also a root of N is non generic. Notice that the signs of the coefficients of the polynomial N ensures that when real roots exists, at least one is positive. Moreover, when the condition a r c p -a p c r > 0 (5.24) is fulfilled, there is exactly one positive root given by

x = b p Q r + b 2 p Q 2 r + arbp(dpQr+drQp)+b 2 p crQr arcp-apcr a p Q r + a r Q p (5.25)
However, accordingly to Lemma 5.4.1.iii, an arc x = x can be part of an optimal solution only if its corresponding adjoint λp (x), given by expression (5.19), is positive. Consider for any root x of N with λ p (x) > 0 the function

γ x(x) = ψ(x, λ p (x)) (5.26)
Let us show that if it is non increasing in the neighborhood of x, then the arc x = x cannot belong to an optimal solution. Indeed, if x = x is reached from below at a time t s < t f , then u(t) = 1 is optimal on any time interval (t s -δ, t c ) with δ sufficiently enough, and therefore φ has to be positive for δ small enough (as the locus where φ can change its sign are isolated). An another hand, γ x non increasing implies that for δ small enough γ x is non negative on (t s -δ, t s ). This implies from (5.21) that φ cannot decrease on the interval (t s -δ, t s ) and therefore cannot change its sign at t. A similar argumentation applies if x = x is reached from above.

Consider now the candidate singular arc x = x∆ . Substituting this value in (5.21) for φ = 0 gives the corresponding value of λ x , and then φ = 0 provides the value of λ p :

λx (x ∆ ) = - c p Q r + c r Q p a p Q r + a r Q p λp (x ∆ ) = - C (a p Q r + a r Q p ) 2 (Q p + Q r ) with C = a r (a r (d r -d p ) -b p c r )Q 2 p +2a r (a p (d r -d p ) -b p c p )Q p Q r +(a 2 p (d r -d p ) + (a p c r -c p (a p + a r ))b p )Q 2 r (5.27)
Therefore, if the number C is positive, the arc x = x ∆ cannot be part of an optimal solution.

Notice that generically, roots of N and x ∆ have different values of λp (x). Therefore, an optimal solution cannot have more than one singular arc. Notice also that as u(t) = 1 is optimal on the interval [ t, t f ] (cf. Lemma 5.4.1.iii) and H is null at any time, this imposes the final state xf = x(t f ) to satisfy the condition λ

p Q p -l p (x f ) = 0, that is xf = λ p (x)Q p -d p c p
Finally, if an optimal solution possesses a singular arc, this imposes that the singular arc is left with p = p such that

p = p -Q p xf x dx f p (x) = p -            Q p a p log -a p x + b p -a p xf + b p if a p > 0 Q p b p (x f -x) if a p = 0
(5.28)

Chapter 5. Modeling and optimal control for production-regeneration systemspreliminary results -

Switching curve

We know from Lemma 5.4.1 that for any optimal solution, the control u(t) = 1 is optimal on an interval [ t, t f ]. Therefore, for each possible terminal state x f in [0, x max ], one can determine in backward time the possible locus in the (p, x) plane where the switching function φ changes its sign (if this happens). This defines a curve C (when it exists), where an optimal control switches from -1 to 1 or from ū to 1 (when x = x is a singular arc).

We characterize this curve.

For the control u = 1, one has ẋ = -a p x + b, ṗ = Q p and

H = λ x (-a p x + b) + λ p Q p -c p x -d p
For x f = x(t f ) one can determine from H = 0 and the terminal condition λ x (t f ) = 0 the value of the constant λ p as a function of x f :

λ † p (x f ) = c p x f + d p Q p
From H = 0, the adjoint λ x can be determined as a function of x f and x (as long as the switching function is positive):

λ † x (x f , x) = - c p (x f -x) b p -a p x
Then, the switching function φ can be also expressed as a function of x f and x:

φ † (x f , x) = 1 2Qp(apx-bp) (a p c r -a r c p )Q p x 2 +(c p (a p Q r + a r Q p )x f + a p (d r Q p + d p Q r ) -b p c r Q p )x -b p (c p Q r x f + d p Q r + d r Q p )
Consider then the root x c of the polynomial x → φ(x f , x) which is the closest to x f (if it exists). It corresponds to the value of x where the function φ changes it sign for the first backward time. The corresponding value of p is then 5.29) and (p c , x c ) belongs then to C. Therefore, the curve C (if it exists) can be parameterized by the final value x f . 5.6. Switching curve 117 Lemma 5.6.1. The curve C (when it exists) is such that

p c = p -            Q p a p log -a p x c + b p -a p x f + b p if a p > 0 Q p b p (x f -x c ) if a p = 0 (
1. x f → x c is increasing, 2. lim x f →xmax x c (t f ) = x max Proof. 1) If x f → x c is not increasing, there exists x f 2 > x f 1 such that x c (x f 2 ) ≤ x c (x f 1 ).
As the trajectories of the dynamics with u = +1 cannot cross in the (p, x) plane, one has necessarily p c (x f 2 ) < p c (x f 1 ). Then, the trajectory with u = -1 reaching the switching point (p c (x f 1 ), x c (x f 1 )) has to cross the trajectory joining (p c (x f 1 ), x c (x f 1 )) to (p , x f 2 ) with u = 1, that is in contradiction with the definition of C.

2) As x f → x c is increasing, there exists a limit xc of x c when x f tends to x max (which is less or equal to x max ). Let pc be the corresponding value of p c . If xc < x max , consider then the trajectory in the (p, x) plane that arrives to (p c , xc ) with the control u = -1 and leave (p c , xc ) with u = 1. As one has ẋ < 0 wit u = -1 and ẋ > 0 with u = 1, this trajectory belongs to the subset {(p, x), x ≥ xc }. At any point (p, x) which is above this trajectory, the control u = -1 cannot be optimal because then it has to switch to u = 1 outside C. Therefore, the trajectory that arrives to (p c , xc ) with the control u = -1 is a locus of commutation with x > xc , which contradicts xc < x max .

When a singular arc x = x is optimal, (p, x) necessarily belongs to C. Therefore the curve C exists and is parameterized by x f . It can be determined by continuation, x f → x c being solution of the Cauchy problem

dx c dx f = - ∂ x f φ † (x f , x c ) ∂ x φ † (x f , x c ) , x c (x f ) = x for x f ≥ xf . Computation gives the following expression dx c dx f = A 1 x c + B 1 A 2 x c -A 1 x f + B 2 with the parameters A 1 = -c p (a p Q r + a r Q p ), B 1 = b p c p Q r A 2 = 2(a p c r -a r c p )Q p , B 2 = a p (d r Q p + d p Q r ) -b p c r Q p
One can easily check that the solution is given by

x c = x + A 1 x f -B 2 -A 2 x A 2 + (A 1 x f -B 2 -A 2 x) 2 +2 A 2 (A 1 x -B 1 )(x f -x f ) A 2
(5.30) preliminary results -

The curve C can be then determined by expressions (5.29) and (5.30) for x f ∈ [x f , x max ), accordingly to Lemma 5.6.1.

Optimal synthesis

We assume that there exists a single candidate singular arc, which seems to be realistic situations as illustrated in Section 5.8. Indeed, the absence of singular arc appears to be degenerate cases, with no trade-off between production and regeneration. Having several singular arcs imposes strong conditions on the parameters, which seem unrealistic.

Assumption 5.7.1. There exists an unique x among xδ and the roots of N that belongs to (0, x max ) with ū ∈ [-1, 1], such that λp (x) > 0 and γ x(•) is increasing on (0, x max ).

In particular, this assumption is fulfilled when:

• C given in (5.27) is positive,

• condition (5.24) is fulfilled and x given in (5.25) satisfies x < x max and λp (x) > 0, where λp (•) is given in (5.19),

• ū defined in (5.20) belongs to (0, 1),

• γ x(•) defined in (5.26) is increasing on (0, x max ).

Proposition 5.7.1. Under Assumption 5.7.1, define the following partition of the domain D: S = {x} × [0, p] (where p is given by (5.28))

D -= {(x, p) ∈ D, x ≤ x c (x f ), x f ∈ (x f , x max ]} D + = D \ (D ∪ S)
(5.31)

Then, the following feedback control is optimal.

u(x, p) =     
+1, (x, p) ∈ D + ū, (x, p) ∈ S (where ū is given by (5.20)) -1, (x, p) ∈ D - (5.32) Proof. At (x, p) where φ = 0, λ p = λp (x) given in (5.19) and has to be positive (Lemma 5.4.1). ψ(x, p) is given by Γ(x) defined in (5.23). As we have assumed that N has only one root with positive λp , we deduce that ψ is not null when x = x. The sign of Γ for x = x has to be the same than γ x (otherwise by continuity another root would exist), that is negative for x < x and positive for x > x. From (5.22), the following properties are then satisfied.

• φ = 0 with x < x ⇒ φ < 0. φ can change its sign only when decreasing. Only switch from u = 1 to u = -1 can be optimal in the sub-domain {x < x}.

• φ = 0 with x > x ⇒ φ > 0. φ can change its sign only when increasing. Only a switch from u = -1 to u = 1 can be optimal in the sub-domain {x > x}.

Consider an initial condition with x 0 < x. The control u = -1 makes x(•) decreasing, remaining in {x < x} and then cannot switch to reach the target with u = +1, which contradicts its optimality (Lemma 5.4.1). We deduce that u = +1 is optimal at any x < x.

If the initial condition belongs to D + with x 0 ≥ x, none of the solutions with u = +1 or u = -1 reaches a locus of commutation S or C. Therefore, u = +1 is optimal until t f . So, u = +1 is optimal when the state belongs to D + .

Consider now an initial condition in D -. The optimal control has to switch. Otherwise, it will be equal to +1 and as x(•) with u = +1 is increasing, it will have to cross the switching curve C. So u = -1 is optimal until the trajectory reaches C (and then enters the sub-domain D -) or reaches S. u = -1 is thus optimal when the state belongs to D -. Finally, when an optimal trajectory reaches S from below or from above, it has to stay on S with the control ū until it exits S. If not, it leaves S either with u = -1 and enters the sub-domain D + (but we have proved that u = +1 is optimal on this domain), either with u = 1 and enters the sub-domain D -(and u =is optimal on this domain).

Application

We consider a filtration system and give the complete synthesis with the construction of the switching curve given in Section 5.6. It is usually assumed that the transmembrane pressure (TMP) τ p and τ r during filtration and backwash are positive functions obtained Darcy's law, as: 5.33) with Q p and Q r are the filtration and the backwash flow rates, respectively, and A the membrane area. Practically the backwash flow rate is considered higher or equal to the filtration rate. Then, one can write Q r = c Q p with c > 1. Parameters values are given in Table 5.1.

τ p (x) = Q p A µ R tot (x), τ r (x) = Q r A µ R tot (x) (

Conclusion

We have proposed a methodology to determine an optimal feedback synthesis. This synthesis looks similar to the one of filtration problems with fixed terminal time [Kalboussi et al. 2018], but the determination of the singular arc is here much more complex, requiring the consideration of the auxiliary functions ∆, Γ, λp and γ x. For linear dynamics, this leads to explicit polynomials whose coefficients can be determined analytically from the parameters of the problem. A future work will investigate extensions of the results to more general classes of dynamics.

At the present time, wastewater could be said to be a 'load' : rejecting it into the environment is a kind of 'threat'. It is necessary to treat it after use to ensure a quality that respects discharge limits and avoid direct or indirect environmental problems. At an extreme limit, the water can be treated at a degree allowing its reuse as tap water...but at undesirable and unsustainable environmental and economical prices. Indeed, such a treatment requires the use of an important energy cost (notably for nutrient removal).

But wastewater is also to be considered as an opportunity, notably for resource recovery. When regarded as a non conventional source for water and nutrients, it is a valuable alternative to the mobilization of natural water of good quality and wastewater treatment plants 'WWTPs' should turn out to water resource recovery facilities 'WRRFs'. Recovery can include different -and more or less innovative -options such as energy (for instance through biogas production) and nutrients recovery (mainly nitrogen and phosphorus but also possibly other molecules of interest through 'biorefinery').

The work presented in this manuscript is devoted to draw a picture for the future and to give a perspective of the treatment and resource recovery for the reuse of wastewater in agriculture. To maximize the flexibility of WRRF, it is proposed to make intensive use of advanced modelling and control techniques and to develop methodologies and tools for improving the functioning of such processes. Such a flexible system can allow the user to manage several operating modes to ensure a supply of a quality adapted to the plant/crop requirements, without ignoring some situations where the reuse is not the suitable alternative. In such a case, the proposed approaches should be used to optimize the actual treatment plants.

Globally, the main achievements of this study are summarized hereafter. In contrast to the conventional approach of separating the sludge produced from the wastewater treated and transforming it before using it in agriculture as a 'fertilizer', the new approach adopted in this study is able to recover the water and its nutrients by adapting its quality and quantity according to the crops requirements in real time and realize 'fertigation'.

To do so and using advanced modeling and control industrial techniques, a new flexible platform is proposed that can operate in several configuration modes. The platform is used firstly within an open loop approach strategy making intensive use of simulations. Such an approach could be further exploited to apply artificial intelligence strategies (as neural preliminary resultsnetworks) to provide relevant control laws. To be more generic, and depending on the objective pursued, two improved closed-loop approaches were developed and evaluated in the presence of different uncertainty and disturbances. These approaches were synthesized in coupling a crop model with closed-loop industrial approaches. More specifically, the crop model was used as a basis for solving optimal control problems, the solutions of which were used as setpoints for the WRRF. The approach was successfully applied to six possible configurations of the flexible platform both in the absence and in the presence of disturbances. In addition, the results were compared to the performances of a conventional treatment approach. The platform coupled with the crop requirement was capable of generating an optimal requirement in terms of nitrogen. The results indicated that there are configurations that can save more energy while providing less nutrients, and vice versa (other configurations were delivering more nutrients but with more energy consumption).

The conventional approach was found to be the one that consumes the most energy while not valorizing the nutrients.

The importance of considering the case when the reuse mode is not always the best solution for wastewater management brought us to improve the WRRF plant to be able to switch to conventional treatment mode in a minimum time, as well as the reverse, when switching from a conventional treatment mode to a reuse mode if necessary. This issue has been studied in order to improve both the flexibility of the proposed platform and to illustrate, through simulated scenarios, the most relevant control handles for this type of problem. This approach was successful and the switching time from one mode to another was minimized using a bio-augmentation strategy.

To provide the good quantity and quality of water, crops water stress must be monitored. As a preliminary study to provide information on the water requirements for our treatment system on the one hand and to optimize irrigation by supplying the exact amount of water required by the crops on the other hand, a new processing procedure was developed. With the help of an observer, we have succeeded in estimating the part of water used by the plant for its evapotranspiration. This study is supposed to provide guidelines to growers and farmers on sustainable water management as well as to future reuse strategies even if practical validation is needed on different crops and environments.

Finally, to adopt the previously developed platform application as an alternative to WTTP and to use it as a WRRF, we decided to improve its flexibility: this has been done in chapters 1 and 2 in upgrading its energy efficiency. Since it uses a membrane as a filtration system, and because it represents the most energy-consuming component, an automatic control strategy was developed that could operate the membrane in an optimal way to reduce energy consumption under performance constraints. As preliminary results, a generic model was used and the optimal feedback synthesis was performed. It should be further developed for a general membrane model in future works.

Furthermore, it is important to notice that an originality of the present study with respect to others that can be found in the literature is that it seems to be one of the first ones where we investigate the principle of adapting the quality of treated water to the crops requirements in coupling a model of a flexible platform with an irrigation model. Using large-scale modeling and dynamic systems tools, we developed a number of control algorithms capable of improving the functioning of the WRRF.

Perspectives might be divided into the following aspects. For improving the platform modeling, it should be noted that the flexibility is one of the main characteristics. Special efforts were made during the construction of the platform in order to ensure its applicability to other benchmarks or other case studies that might become relevant. Considering modelling and simulation, the flexibility is especially important as WWTP flowsheets are frequently changing to achieve, for instance, adapted required quality. One might also want to evaluate a different and innovative process by comparing it with a reference one. Also, the modeling of specific parts of the process is rapidly evolving nowadays, such as the qualification and quantification of nitrous oxide emissions, which represents an important pollutant factor. Other nutrients of interest such as phosphorus should also be included. The modelling platform could also be improved by integrating the dynamic of some micropollutant, such as emerging compounds and pathogens notably to generate data to be used in risk assessment approaches. Another important effort to be made when taking into account environmental impact assessment consists in the coupling of an LCA (Life cycle analysis) model with the platform in order to evaluate potential gains of using the platform and evaluate environmental impacts.

Although the platform did not present a limitation regarding the level of water quality provided except in the case where there was not enough nitrogen in the influent and the amount required was higher than the amount in the influent, it would be interesting to study the problem of mixing several qualities of waters in order to provide a quality preliminary resultsadapted to -possible new -usages and/or needs.

Another important effort to be made is the consideration of possible improvements in WRRF platform designIn this sense, efforts have to be made in order to consider the platform modelling in a rigorous way or at least to validate the uncertainties linked to a plant size range to allow the redesign of alternative configurations. Accordingly, one might think of an exhaustive list of perspective scenarios (with design changes) to be evaluated and optimized such as the inclusion of anaerobic ammonium oxidation in the mainstream as well as a multitude of processes for the treatment and reuse of wastewater.

Considering that the influents dynamics may have nutrient levels that vary over time (in some cases the amount of nutrient present in the influent may reach a level sufficient to meet the needs while in other periods this level will never be reached) it is important to look at the problem of producing a nutrient-rich quality when time allows it and to use a storage system that could use this quality when needed. It requires to model the dynamic of stored waters, notably with respect to pathogens, which is a difficult task.

Finally, in view of the optimization aspects, the methodology is evolving rapidly and recent advances in machine learning have been helpful in the area of cost optimization. According to the best of our knowledge, the use of these tools for efficient function analysis and approximation has not been used within the context of water treatment for reuse: this could represent an important gain in terms of cost optimization of the WRRF platform, but also when the optimization is subject to multiple stiff constraints.

The chemical concentrations in reactors A(k) (k = 1, . . . , 3) thus follow the dynamics ṠA(k)

I = 1 V (k) Q (k) I S (k) I -Q (k) O S A(k) I ṠA(k) S = 1 V (k) Q (k) I S (k) S -Q (k) O S A(k) S + k h X A(k) BH X A(k) S X A(k) BH K X + X A(k) S X A(k) BH   S A(k) O K OH + S A(k) O + η g K OH K OH + S A(k) O S A(k) N O 2 + S A(k) N O 3 K N O + S A(k) N O 2 + S A(k) N O 3   - µ H X A(k) BH Y H S A(k) N H K N H + S A(k) N H S A(k) S K S + S A(k) S 1 K OH + S A(k) O   S A(k) O + η N O2 K OH S A(k) N O 2 K N O + S A(k) N O 2 + η N O 3 K OH S A(k) N O 3 K N O + S A(k) N O 3   ẊA(k) I = 1 V (k) Q (k) I X (k) I -Q (k) O X A(k) I ẊA(k) S = 1 V (k) Q (k) I X (k) S -Q (k) O X A(k) S -k h X A(k) BH X A(k) S X A(k) BH K X + X A(k) S X A(k) BH   S A(k) O K OH + S A(k) O + η g K OH K OH + S A(k) O S A(k) N O 2 + S A(k) N O 3 K N O + S A(k) N O 2 + S A(k) N O 3   + (1 -f P ) b H X A(k) BH + b AOB X A(k) AOB + b N OB X A(k) N OB ẊA(k) BH = 1 V (k) Q (k) I X (k) BH -Q (k) O X A(k) BH -b H X A(k) BH + µ H X A(k) BH S A(k) N H K N H + S A(k) N H S A(k) S K S + S A(k) S 1 K OH + S A(k) O   S A(k) O + η N O 2 K OH S A(k) N O 2 K N O + S A(k) N O 2 + η N O 3 K OH S A(k) N O 3 K N O + S A(k) N O 3   ẊA(k) AOB = 1 V (k) Q (k) I X (k) AOB -Q (k) O X A(k) AOB + µ AOB S A(k) N H K N H + S A(k) N H S A(k) O K OA + S A(k) O X A(k) AOB -b AOB X A(k) AOB ẊA(k) N OB = 1 V (k) Q (k) I X (k) N OB -Q (k) O X A(k) N OB + µ N OB S A(k) N O 2 S A(k) N O 2 + K N O K N H I K N H I + S A(k) N H S A(k) O K OA + S A(k) O X A(k) N OB -b N OB X A(k) N OB ẊA(k) P = 1 V (k) Q (k) I X (k) P -Q (k) O X A(k) P + f P b BH X A(k) BH + b AOB X A(k) AOB + b N OB X A(k) N OB 131 ṠA(k) O = 1 V (k) Q (k) I S (k) O -Q (k) O S A(k) O + 1 - 3.34 Y AOB µ AOB S A(k) N H K N H + S A(k) N H S A(k) O K OA + S A(k) O X A(k) AOB + K L a A(k) (S SAT O -S A(k) O ) + 1 - 1 Y H µ H S A(k) S K S + S A(k) S S A(k) O K OH + S A(k) O S A(k) N H K N H + S A(k) N H X A(k) BH + 1 - 1.14 Y N OB µ N OB S A(k) N O 2 S A(k) N O 2 + K N O K N H I K N H I + S A(k) N H S A(k) O K OA + S A(k) O X A(k) N OB ṠA(k) N O 2 = 1 V (k) Q (k) I S (k) N O 2 -Q (k) O S A(k) N O 2 - (1 -Y H ) (1.72Y H ) µ H η N O 2 S A(k) S K S + S A(k) S K OH K OH + S A(k) O S A(k) N O 2 K N O + S A(k) N O 2 S A(k) N H K N H + S A(k) N H X A(k) BH + µ AOB Y AOB S A(k) N H K N H + S A(k) N H S A(k) O K OA + S A(k) O X A(k) AOB - µ N OB Y N OB S A(k) N O 2 S A(k) N O 2 + K N O K N H I K N H I + S A(k) N H S A(k) O K OA + S A(k) O X A(k) N OB ṠA(k) N O 3 = 1 V (k) Q (k) I S (k) N O 3 -Q (k) O S A(k) N O 3 - (1 -Y H ) (2.86Y H ) µ H η N O 3 S A(k) S K S + S A(k) S K OH K OH + S A(k) O S A(k) N O 3 K N O + S A(k) N O 3 S A(k) N H K N H + S A(k) N H X A(k) BH + µ N OB 1 Y N OB S A(k) N O 2 S A(k) N O 2 + K N O K N H I K N H I + S A(k) N H S A(k) O K OA + S A(k) O X A(k) N OB ṠA(k) N 2 = 1 V (k) Q (k) I S (k) N 2 -Q (k) O S A(k) N 2 + 1 -Y H 2.86Y H µ H η N O 2 S A(k) S K S + S A(k) S K OH K OH + S A(k) O S A(k) N O 2 K N O + S A(k) N O 2 S A(k) N H K N H + S A(k) N H X A(k) BH + 1 -Y H 1.72Y H µ H η N O 3 S A(k) S K S + S A(k) S K OH K OH + S A(k) O S A(k) N O 3 K N O + S A(k) N O 3 S A(k) N H K N H + S A(k) N H X A(k) BH ṠA(k) N H = 1 V (k) Q (k) I S (k) N H -Q (k) O S A(k) N H -i XB + 1 Y AOB µ AOB S A(k) N H K N H + S A(k) N H S A(k) O K OA + S A(k) O X A(k) AOB + k a S A(k) N D X A(k) BH -i XB µ H X A(k) BH S A(k) N H K N H + S A(k) N H S A(k) S K S + S A(k) S 1 K OH + S A(k) O S A(k) O + η N O 2 K OH S A(k) N O 2 K N O + S A(k) N O 2 + η N O 3 K OH S A(k) N O 3 K N O + S A(k) N O 3 + µ N OB S A(k) N O 2 S A(k) N O 2 + K N O K N H I K N H I + S A(k) N H S A(k) O K OA + S A(k) O X A(k) N OB ṠA(k) N D = 1 V (k) Q (k) I S (k) N D -Q (k) O S A(k) N D -k a S A(k) N D X A(k) BH + X A(k) N D X A(k) S     k h X A(k) S X A(k) BH K X + X A(k) S X A(k) BH   S A(k) O K OH + S A(k) O + η g K OH K OH + S A(k) O S A(k) N O 2 + S A(k) N O 3 K N O + S A(k) N O 2 + S A(k) N O 3   X A(k) BH    
132 Appendix A. State-space equations for ASM1-2ND model in WRRF plaftorm ẊA(1) [Pelak et al. 2017] denoted by θ C . We consider the parameters referring to the dynamics of a modern corn cultivar grown on a silty loam type soil.

N D = 1 V (k) Q (k) I X (k) N D -Q (k) O X A(k) N D + (i XB -f P i XP ) b H X A(k) BH + b AOB X A(k) AOB + b N OB X A(k) N OB - X A(k) N D X A(k) S     k h X A(k) S X A(k) BH K X + X A(k) S X A(k) BH   S A(k) O K OH + S A(k) O + η g K OH K OH + S A(k) O S A(k) N O 2 + S A(k) N O 3 K N O + S A(k) N O 2 + S A(k) N O 3   X A(k) BH     ṠA(1) ALK = 1 V (k) Q (k) I S (k) ALK -Q (k) O S A(k) ALK - 1 14 (2Y AOB + i XB )µ AOB S A(k) N H K N H + S A(k) N H S A(k) O K OA + S A(k) O X A(k) AOB - 1 14 (i XB - 1 -Y H 1.72Y H )µ H η N O 2 S A(k) S K S + S A(k) S K OH K OH + S A(k) O S A(k) N O 2 K N O + S A(k) N O 2 S A(k) N H K N H + S A(k) N H X A(k) BH - 1 14 (i XB - 1 -Y H 2.86Y H )µ H η N O 3 S A(k) S K S + S A(k) S K OH K OH + S A(k) O S A(k) N O 3 K N O + S A(k) N O 3 S A(k) N H K N H + S A(k) N H X A(k) BH - 1 14 i XB µ H X A(k) BH S A(k) N H K N H + S A(k) N H S A(k) S K S + S A(k) S S A(k) O K OH + S A(k) O + 1 14 µ N OB S A(k) N O 2 S A(k) N O 2 + K N O K N H I K N H I + S A(k) N H S A(k) O K OA + S A(k) O X A(k) N OB
As a simplification, we consider the absence of any rainfall and assume constant reference evapotranspiration, the water loss due to the impact of climate on evaporation and plant transpiration.

Optimal control formulation

To determine the irrigation and fertilization requirements for optimal crop growth, we consider the problem of maximizing crop biomass at the end of the growing season. We write this as an optimal control problem, over a fixed time horizon that represents a growing season. The optimal control problem is solved using a dynamic programming approach for maximising the crops biomass.

Contribution des approches de modélisation et de contrôle pour améliorer la flexibilité des systèmes de traitement pour la réutilisation des eaux usées traitées en agriculture Résumé en Français Pour répondre aux enjeux de la raréfaction des ressources en eau de bonne qualité, la réutilisation des eaux usées traitées ('REUT' ou 'REUSE') apparaît comme une solution d'avenir. Elle permet de ne pas rejeter l'eau traitée dans l'environnement sans lui faire subir une seconde vie, voire davantage. Pour cela, nous promouvons un changement de paradigme dans lequel les eaux usées ne sont plus vues comme des déchets à dépolluer mais une nouvelle ressource pouvant être traitée à façon, dépendant des besoins et des usages dans de nouvelles installations de récupération d'énergie, de nutriments et autres molécules d'intérêt. Cette gestion de la ressource en eau se heurte à de nombreux défis, notamment des problèmes techniques tels que le manque de flexibilité des stations d'épuration actuelles. Face au grand défi de fournir, de manière dynamique et économiquement acceptable, une qualité d'eau traitée adaptée aux besoins de l'agriculture, et afin de réduire les impacts environnementaux, les technologies de l'automatique ont assurément un rôle essentiel à jouer. Cette étude, qui s'affranchit des limitations règlementaires actuelles car essentiellement menée en simulations, présente les résultats préliminaires de recherches combinant le développement d'une plateforme de simulation d'un système flexible combinant des systèmes de traitement à boues activées à un procédé de filtration membranaire. Nous évaluons comment le contrôle de l'ensemble, fondé sur l'utilisation de controleurs industriels et de commande avancée, peut être utilisé pour adapter en temps réel, en conditions de mesures martielles et en présence d'incertitudes et de perturbations, une eau dont la qualité répond aux besoins des plantes/cultures ou, au contraire, lorsque nécessaire, est conforme aux exigences de qualité requises pour un rejet dans l'environnement. L'approche nécessite la connaissance des besoins des plantes. Ces dernières étant difficilement mesurables en continu, une partie du travail est dédié à la synthèse d'observateurs à entrées inconnues pour estimer la quantité d'eau disponible pour la plante dans les sols (et donc accessible pour l'évapotranspiration). Enfin, le coût de l'eau usées traitée par les technologies de filtration membranaire étant souvent rédhibitoire pour les irrigants, nous évaluons dans quelle mesure le recours à des approches de contrôle optimal, notamment le Principe du Maximum de Pontryagin, permettrait de faire baisser ces coût en optimisant la gestion du colmatage de ces membranes et dionc le coût de fonctionnement de ces systèmes.

Mots clés: Flexibilité, Modélisation, Contrôle, Réutilisation, Optimisation, Taitement des eaux usées, Observation.

  Finally, I thank all those who directly or indirectly contributed to this work, Thank you very much ! 1 Evolution of irrigated and non-irrigated cultivated areas (1961-2008) FAO(2010b) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8 2 The current situation, vision of the future and its ideal implementation for maximizing the recovery of resources in WRRF . . . . . . . . . . . . . . . 11 3 Our strategy for close the loop between the WRRF model and the Corps/plants model . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14 1.1 Pre-denitrification process . . . . . . . . . . . . . . . . . . . . . . . . . . 19 1.2 Post-denitrification process . . . . . . . . . . . . . . . . . . . . . . . . . . 19 1.3 Step-feed process . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20 1.4 Graphical representation of a cascade of N CSTR, the concentration variations over time in response to a pulse are shown in the top . . . . . . . . . . 24 1.5 Overview of ASM1 processes . . . . . . . . . . . . . . . . . . . . . . . . 29 1.6 Scheme of nitrification and denitrification processes in the ASM1-2ND Model . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31 1.7 Scheme of nitrification and denitrification processes in the ASM1 Model . . 31 1.8 Water balance . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34 2.1 Hydraulic process scheme of the proposed flexible platform . . . . . . . . . 45 2.2 Dynamic influent flow Q in . . . . . . . . . . . . . . . . . . . . . . . . . . 54 2.3 Dynamic concentrations of the nitrogen forms and of the total nitrogen in the input . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 55 2.4 Grid diagram for control values for the steady state analysis of the flexible platform . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

  3.6 Two cycles simulation of transitions between Reuse and Full treatment : ammonium (blue), nitrate (green) and nitrite (red) concentrations in the effluent . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4.1 Irrigation I(t), in mm over time (in days) -2016 datase . . . . . . . . . . . 4.2 Measured (in red) and estimated (in black) SW C, in mm over time -2016 dataset . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4.3 Estimated evapotranspiration ET , in mm over time -2016 dataset . . . . . 4.4 Irrigation I(t), in mm over time (in days) -2018 dataset . . . . . . . . . . 4.5 Measured (in red) and estimated (in black) SW C, in mm over time -2018 dataset . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4.6 Estimated evapotranspiration ET , in mm over time -2018 dataset . . . . . 5.1 Optimal synthesis for the considered parameters in the (p, x) plane. The singular arc is in green and the switching curve in yellow. . . . . . . . . . . B.1 Software organization for implementation of WRRF platform . . . . . . . . B.2 Software hierarchy of each Simulink functional block, showing the relationship among the S-function block in the Simulink diagram, the invoked DLL and the header and footer of the C source code . . . . . . . . . . . . . B.3 The main four model blocks implementing the ASM1_2N model in the Simulink platform. Thick wires indicate a vector, whose dimension is indicated above the line. Each block is implemented as DLL executable code which is invoked at run time by the pertinent S-function block in the Simulink diagram. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

  V A : Valve A , V B : Valve B , V C : Valve C . . . . . . . . 2.10 Effluent quality limits for complete treatment mode . . . . . . . . . . . . . 2.11 Comparison of closed-loop effluent in terms of amount of total nitrogen supplied over the period of irrigation and operating cost performance criteria for each configuration and for complete treatment (CT) . . . . . . . . 2.12 Kinetics, parameters and stoichiometric coefficients. . . . . . . . . . . . . 3.1 constant influent characteristics . . . . . . . . . . . . . . . . . . . . . . . . 3.2 valve positions for each scenario . . . . . . . . . . . . . . . . . . . . . . . 5.1 Parameters values . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . D.1 Crop model: State and input variables. . . . . . . . . . . . . . . . . . . . .

Figure 1 :

 1 Figure 1: Evolution of irrigated and non-irrigated cultivated areas (1961-2008) FAO(2010b)

Figure 3 :

 3 Figure 3: Our strategy for close the loop between the WRRF model and the Corps/plants model

Figure 1

 1 Figure 1.1: Pre-denitrification process

Figure

  Figure 1.2: Post-denitrification process

Figure 1

 1 Figure 1.3: Step-feed process

Figure 1 . 4 :

 14 Figure 1.4: Graphical representation of a cascade of N CSTR, the concentration variations over time in response to a pulse are shown in the top

Figure 1 . 6 :

 16 Figure 1.6: Scheme of nitrification and denitrification processes in the ASM1-2ND Model

Figure

  Figure 1.8: Water balance

  WRRF has been designed for an average input flow of 24000 m 3 /d. The platform can be operated as a one-(only tank R3), two-(tanks R2 and R3) or three-(tank R1, R2 and R3) stage process by adjusting input flow rate (Q in ), step feeding (by-pass) and return activated sludge locations depending on the positions of the valves.

Figure 2 . 1 :

 21 Figure 2.1: Hydraulic process scheme of the proposed flexible platform

  H was added in the three first processes. Such a checking has been realized by([Petersen et al. 2001]) ([Rieger et al. 2012]) for the ASM1. Notice that since the stoichiometric matrix published in ([START_REF] Ostace | [END_REF]) for the ASM1-2ND model contained many typing errors, the whole corrected stoichiometric matrix for the ASM1-2ND model has been rewritten (cf.

Chapter 2 .

 2 From WWTP to WRRF : the necessity of more flexibility to adapt the quality of treated waters to new usages Table 2.3: Stoichiometric matrix of the ASM1-

  Figure 2.4) were performed using static influent values reported in Table2.2, for all design configurations (i.e., each given position of valves over the 6 configurations quality of treated waters to new usages

  From WWTP to WRRF : the necessity of more flexibility to adapt the quality of treated waters to new usages

FigureFigure 2

 2 Figure 2.2: Dynamic influent flow Q in

Table 2. 7 :

 7 Overview of the combinations of controls for the open loop simulations. The notations u = a : b : c means that the successive simulations for the variable u are done with values going from u = a to u = c with a step b.

  Figure 2.6: Nitrate control using the open loop simulations with static influent

Figure 2 . 7 :

 27 Figure 2.7: Nitrate control using the open loop simulations with dynamic influent

Figure 2 . 8 :

 28 Figure 2.8: Control scheme for the nitrate control loop

Figure 2 .

 2 Figure 2.12: Influent COD and BOD for complete treatment mode

  Figure 2.16: Nitrate control: output nitrogen concentrations when using constant influent characteristics

  Figures 2.28 and Figures 2.29, respectively).

Figure 2 .

 2 Figure 2.28: Controlled nitrogen for irrigation needs with constant influent for six configurations design; nitrate S N O 3 (blue), ammonium S N H (green) and nitrite S N O 2 (red) biodegradable organic nitrogen S N D (pink) concentrations, irrigation set-point (black dashed line) and total nitrogen in the effluent (brown dashed line)

  3 14291.1 14055.2 13922.5 14009.8 14398.9 14299.0 Now, assume the input is highly loaded in terms of nitrogen: it is now supposed to contain 55g.N/m 3 of total nitrogen instead of 35g.N/m 3 in the constant input case and an average of 52g.N/m 3 for the simulations realized under dynamical conditions. Corresponding simulations are plotted in Figures 2.30-2.31.

Figure 2 .

 2 Figure 2.30: Control nitrogen for irrigation needs with charged constant influent for six configurations design. nitrate S N O 3 (blue), ammonium S N H (green) and nitrite S N O 2 (red) biodegradable organic nitrogen S N D (pink) concentrations, irrigation set-point (black dashed line) and total nitrogen in the effluent(brown dashed line)

Figure 2 .

 2 Figure 2.31: Control nitrogen for irrigation needs with charged dynamic influent for six configurations design. Nitrate S N O 3 (blue), ammonium S N H (green) and nitrite S N O 2 (red) biodegradable organic nitrogen S N D (pink) concentrations, irrigation set-point (black dashed line) and total nitrogen in the effluent (brown dashed line)

  Contents 3.1 Abstract . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 81 3.2 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 81 3.3 A flexible platform of WRRF . . . . . . . . . . . . . . . . . . . . . . . . 82 3.3.1 Platform description . . . . . . . . . . . . . . . . . . . . . . . . . 82 3.3.2 Model description . . . . . . . . . . . . . . . . . . . . . . . . . . 84 3.3.3 Implementation of WRRF platform . . . . . . . . . . . . . . . . . 84 3.3.4 The Solids Retention Time (SRT) control . . . . . . . . . . . . . . 84 3.4 Platform simulation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 85 3.4.1 Scenario S1 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 86 3.4.2 Scenario S2 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 86 3.4.3 Scenario S3 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 86 3.5 Results and discussion . . . . . . . . . . . . . . . . . . . . . . . . . . . . 87 3.5.1 Influence of retention time on reuse mode . . . . . . . . . . . . . . 87 3.5.2 Influence of returned sludge direction . . . . . . . . . . . . . . . . 88 3.5.3 Effects of dilution on the returned sludge . . . . . . . . . . . . . . 88 3.5.4 Influence of biomass addition on the reduction of response time (bio-augmentation) . . . . . . . . . . . . . . . . . . . . . . . . . . 88 3.5.5 Two cycles simulation of transitions from Reuse to Full treatment . 89 3.6 Conclusion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 91 80 Chapter 3. Flexibility of Waste Resource Recovery Facilities for water Reuse This chapter was published : F. Aichouche, B. Benyahia, M. Héran and J. Harmand, "Flexibility of Waste Resource Recovery Facilities for water Reuse," 2020 European Control Conference (ECC), Saint Petersburg, Russia, 2020, DOI: 10.23919/ECC51009.2020.9143734.

Figure 3

 3 Figure 3.1: Schematic diagram of the flexible platform. Q in . influent; 2. Two position valve (position 1 or 0); 3. feed pump; 4. Anoxic tank; 5. Aerobic tank; 6. Aerobic tank; 7.Perfect membrane; E. Effluent; Q int . Internal sludge recycling; Q ext . external sludge recycling; 11. Air compressor; 12. Mechanical mixer; Q w . Waste sludge.

  are in operation and aerated, the valves position are: valve A = 1, valve B = 0, valve C = 0. The external recirculation is activated and Q ext = 270 L/d while the internal recirculation is not in activated Q int = 0 and sludge extraction from the MBR tank (6) Q w = 32.4 L/d.

Figure 3

 3 Figure 3.2: Influence of retention time. Dynamic ammonium (blue), nitrate (green) and nitrite (red) concentrations for transitions at 100 days (continuous line) and at 200 days (dashed line)

Figure 3

 3 Figure 3.3: Influence of returned sludge direction. Dynamic ammonium (blue), nitrate (green) and nitrite (red) concentrations in the effluent.

Figure 3 . 4 :

 34 Figure 3.4: Effects of dilution. Dynamic ammonium (blue) and nitrate (green) and nitrite (red) concentrations in the effluent for returned sludge directed to anoxic tank (dashed line) or to aerobic tank (continuous line).

Figure 3 . 6 :

 36 Figure 3.6: Two cycles simulation of transitions between Reuse and Full treatment : ammonium (blue), nitrate (green) and nitrite (red) concentrations in the effluent

Figure 4 .

 4 Figure 4.1: Irrigation I(t), in mm over time (in days) -2016 datase

Figure 4 .

 4 Figure 4.2: Measured (in red) and estimated (in black) SW C, in mm over time -2016 dataset

Figure 4 . 3 :

 43 Figure 4.3: Estimated evapotranspiration ET , in mm over time -2016 dataset

Figure 4 . 4 :

 44 Figure 4.4: Irrigation I(t), in mm over time (in days) -2018 dataset

Figure 4 . 5 :

 45 Figure 4.5: Measured (in red) and estimated (in black) SW C, in mm over time -2018 dataset

Figure 4 . 6 :

 46 Figure 4.6: Estimated evapotranspiration ET , in mm over time -2018 dataset

a 5 .

 5 Figure 5.1 illustrates the optimal feedback synthesis.

Figure 5 . 1 :

 51 Figure 5.1: Optimal synthesis for the considered parameters in the (p, x) plane. The singular arc is in green and the switching curve in yellow.

Figure B. 2 :

 2 Figure B.2: Software hierarchy of each Simulink functional block, showing the relationship among the S-function block in the Simulink diagram, the invoked DLL and the header and footer of the C source code

  = f C (x C (t), u C (t)|θ C ), (D.2b) u C (t) ∈ [0, I max ] × [0, F max N ], (D.2c) x C (0) = x 0 , (D.2d)with a given fixed final time T , initial state x 0 , and input upper bounds I max for maximum irrigation and F max N for maximum nitrogen. Restrict ourselves to growing seasons lasting T = 139d.

  . . . . . 55 2.5 Attainable steady-states for the different forms of nitrogen according to manipulated variables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 57 2.6 Nitrate control using the open loop simulations with static influent . . . . . 59 2.7 Nitrate control using the open loop simulations with dynamic influent . . . 59 2.8 Control scheme for the nitrate control loop . . . . . . . . . . . . . . . . . . 62 2.9 Nitrate control diagram . . . . . . . . . . . . . . . . . . . . . . . . . . . . 62 2.10 Control scheme for the S N O 3 /S N H 4 control loop . . . . . . . . . . . . . . 63 2.11 Ratio control diagram . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 63 2.12 Influent COD and BOD for complete treatment mode . . . . . . . . . . . 64 2.13 Effluent concentration of nitrogen forms and total nitrogen for the complete treatment mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 65 2.14 Effluent COD and BOD 5 for the complete treatment mode . . . . . . . . 65 2.15 Controllers for the complete treatment mode . . . . . . . . . . . . . . . . . 65 2.16 Nitrate control: output nitrogen concentrations when using constant influent characteristics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 66 2.17 Nitrate control: internal recirculation flow control Q int when using constant influent characteristics . . . . . . . . . . . . . . . . . . . . . . . . . . 67 2.18 Nitrate control: oxygen transfer coefficient controls k L a 1,2 when using constant influent characteristics . . . . . . . . . . . . . . . . . . . . . . . . 2.19 Nitrate control: waste activated sludge flow control when using constant influent characteristics . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2.20 Nitrate control: returned activated sludge flow control Q RAS when using constant influent characteristics . . . . . . . . . . . . . . . . . . . . . . . . 2.21 Nitrate control: output nitrogen concentrations when using dynamic influent characteristics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2.22 Nitrate control: oxygen transfer coefficients controls (kLa 1,2 ) for dynamic influent characteristics . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2.23 Nitrate control: internal recirculation for nitrate control for dynamic influent characteristics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2.24 Nitrate control: waste activated sludge control for dynamic influent characteristics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2.25 Nitrate control: returned activated sludge flow control for dynamic influent characteristics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2.26 Simulation results obtained for ratio S N O 3 /S N H 4 control strategy . . . . . 2.27 k L a 1,2 , Q W AS , Q int and Q RAS for the ratio S N O 3 /S N H 4 control . . . . . 2.28 Controlled nitrogen for irrigation needs with constant influent for six con-.31 Control nitrogen for irrigation needs with charged dynamic influent for six configurations design. Nitrate S N O 3 (blue), ammonium S N H (green) and nitrite S N O 2 (red) biodegradable organic nitrogen S N D (pink) concentrations, irrigation set-point (black dashed line) and total nitrogen in the effluent (brown dashed line) . . . . . . . . . . . . . . . . . . . . . . . . . Influence of retention time. Dynamic ammonium (blue), nitrate (green) and nitrite (red) concentrations for transitions at 100 days (continuous line) and at 200 days (dashed line) . . . . . . . . . . . . . . . . . . . . . . . . . . . 3.3 Influence of returned sludge direction. Dynamic ammonium (blue), nitrate

	3.1 Schematic diagram of the flexible platform. Q in . influent; 2. Two posi-tion valve (position 1 or 0); 3. feed pump; 4. Anoxic tank; 5. Aerobic tank; 6. Aerobic tank; 7.Perfect membrane; E. Effluent; Q List of Figures 3.2

figurations design; nitrate S N O 3 (blue), ammonium S N H (green) and nitrite S N O 2 (red) biodegradable organic nitrogen S N D (pink) concentrations, irrigation set-point (black dashed line) and total nitrogen in the effluent (brown dashed line) . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2.29 Controlled nitrogen for irrigation needs with dynamic influent for six configurations design; nitrate S N O 3 (blue), ammonium S N H (green) and nitrite S N O 2 (red) biodegradable organic nitrogen S N D (pink) concentrations, irrigation set-point (black dashed line) and total nitrogen in the effluent (brown dashed line) . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2.30 Control nitrogen for irrigation needs with charged constant influent for six configurations design. nitrate S N O 3 (blue), ammonium S N H (green) and nitrite S N O 2 (red) biodegradable organic nitrogen S N D (pink) concentrations, irrigation set-point (black dashed line) and total nitrogen in the effluent(brown dashed line) . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2int . Internal sludge recycling; Q ext . external sludge recycling; 11. Air compressor; 12. Mechanical mixer; Q w . Waste sludge. . . . . . . . . . . . . . . . . . . . .

  1.2 Reaction kinetics dependent on single substrate concentration . . . . . . . . 2.1 Valve position for the 6 configurations of interest . . . . . . . . . . . . . . 2.2 Average influent composition for the WRRF simulation model . . . . . . . 2.3 Stoichiometric matrix of the ASM1-2ND model . . . . . . . . . . . . . . . 2.4 Processes rate equation for ASM1-2ND model . . . . . . . . . . . . . . . . 2.5 Stoichiometric matrix . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2.6 composition matrix . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2.7 Overview of the combinations of controls for the open loop simulations. The notations u = a : b : c means that the successive simulations for the variable u are done with values going from u = a to u = c with a step b. . . 2.8 Combinations for the controls and the corresponding steady states . . . . . 2.9 Table of set-point for nitrate (S * N O 3 ) and their corresponding control values for at steady state.

  Chapter 2. From WWTP to WRRF : the necessity of more flexibility to adapt the quality of treated waters to new usages

Contents 2.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41 2.2 Materials and methods . . . . . . . . . . . . . . . . . . . . . . . . . . . 44 2.2.1 A flexible platform . . . . . . . . . . . . . . . . . . . . . . . . . . 44 2.2.2 System description and design . . . . . . . . . . . . . . . . . . . . 44 2.2.3 Model description . . . . . . . . . . . . . . . . . . . . . . . . . . 47 2.2.4 Stoichiometric discontinuities checking . . . . . . . . . . . . . . . 48 2.3 Results . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 51 2.3.1 Numerical analysis of the platform at steady state . . . . . . . . . . 51 2.3.2 Dynamical analysis . . . . . . . . . . . . . . . . . . . . . . . . . . 60 2.3.3 Proof of concept: 'irrigation' or 'degraded mode' -closed-loop control performances with a piecewise constant setpoint . . . . . . . . 66 2.3.4 Application to fertigation : coupling treatment and irrigation/culture models . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 72 2.4 Conclusions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 76

Table 2 .

 2 1: Valve position for the 6 configurations of interest

Table 2

 2 Chapter 2. From WWTP to WRRF : the necessity of more flexibility to adapt the quality of treated waters to new usages

	r j	(2.7)

.2: Average influent composition for the WRRF simulation model

  Table. 2.3) The expressions of the different indices in the Table 2.3 are given by

Table 2 .

 2

	4: Processes rate equation for ASM1-2ND model

  Table. 2.8) for the variables (30240 × 16) and the control values (30240 × 8), respectively.

  Table of set-point for nitrate (S * N O 3 ) and their corresponding control values for at steady state. V A

  Table 2.2. Total nitrogen (Ntot) is calculated as the sum of S N O 3 , S N O 2 , S N H and S N D . Since we consider perfect separation, particulate nitrogen could not be present in the effluent, and the total chemical oxygen demand COD tot equals the soluble chemical oxygen demand COD S = S I + S S . Table 2.10: Effluent quality limits for complete treatment mode

	Variable Value
	N tOt	< 18gN/m 3
	COD tot < 100gCOD/m 3
	BOD 5	< 10gBOD/m 3
	S N H	< 4gN/m 3

Table 2

 2

.2), the trajectory tracking for the output nitrate concentrations are plotted in Figures 2.

16-2.20

. As it may be seen, the results are very good. The nitrate concentration is perfectly tracked while all the inputs remain in their admissible ranges and never saturate. The main difference with the results obtained in open-loop is that here the input concentrations are unknown 2. In the second sets of simulations, dynamical input disturbances are used. The results are plotted in Figures 2.21-2.25. Again, the nitrate output concentration follows very well the setpoint and the actuators remain within their respective functioning ranges and never saturate (except for k L a 1,2 but very punctually)

3. Then, the nitrate to ammonium nitrogen ratio control is tested. Very good results (cf. Figures 2.26

Table 2 .

 2 11: Comparison of closed-loop effluent in terms of amount of total nitrogen supplied over the period of irrigation and operating cost performance criteria for each configuration and for complete treatment (CT) AES [kWh d -1 ] 13959.3 13799.8 13145.3 13656.1 13355.7 13822.7 13799.1 AED [kWh d -1 ] 14681.

		CT	C1	C2	C3	C4	C5	C6
	AN T S [kg]	21720	49960	57730	57890	62860	58010	62070
	AN T D [kg]	22089	72570	84810	80890	88970	78460	82880
	P ES [kWh d -1 ] 2909.2	2639.6	2403.2	2889.2	2499.8	2873.2	2811.3
	P ED [kWh d -1 ] 3714.2	3201.8	3003.2	3489.2	3299.8	3493.4	3425.1

Table 2 .

 2 12: Kinetics, parameters and stoichiometric coefficients.

	Parameter	Symbol	value	Units
	Maximum X BH growth rate	µ H	4	d -1
	Half-saturation (hetero. growth)	K S	10	g COD.m -3
	Half-saturation (hetero. oxygen)	K OH	0.2	g O 2 .m -3
	Half-saturation (nitrate and nitrite)	K N O	0.5	g N O 3 -N m -3
	Heterotrophic decay rate	b H	0.3	d -1
	Maximum Nitrosomonas growth rate	µ AOB	0.85	d -1
	Maximum Nitrobacter growth rate	µ N OB	0.65	d -1
	Half-saturation (auto. growth)	K N H	1	g N H 3 -N m -3
	Half-saturation (auto. oxygen)	K OA	0.4	g O 2 .m -3
	Nitrosomonas decay rate	b AOB	0.17	d -1
	Nitrobacter decay rate	b N OB	0.15	d -1
	Anoxic growth rate correction factor	η g	0.8	/
	Ammonification rate	K a	0.05	m 3 (g COD.d) -1
	Maximum specific hydrolysis rate	K h	3	g X S (g X BH .COD.d -1 )
	Half-saturation (hydrolysis)	K X	0.1	g X S (g X BH .COD)-1
	Anoxic growth rate correction factor S N O2	η N O2	0.8	/
	Anoxic growth rate correction factor S N O3	η N O3	0.38	/
	Heterotrophic yield	Y H	0.45	g COD/g COD
	Nitrosomonas yield	Y AOB	0.17	g COD/g N
	Nitrobacter yield	Y N OB	0.15	g COD/g N
	Fraction of biomass to particulate products	f p	0.08	/
	Fraction nitrogen in biomass	i XB	0.086	g N/g COD
	Fraction nitrogen in particulate products	i XP	0.06	g N/g COD
	Ammonia inhibition of nitrite oxidation

Table 3

 3

		.1: constant influent characteristics
	Symbol	Variable	Value Unit
	S I,in	Inert organic matter	21.75 mgCOD.L -1
	S S,in	Readily biodegradable substrate	98	mgCOD.L -1
	X I,in	Particulate inert organic matter	29	mgCOD.L -1
	X S,in	Slowly biodegradable substrate	112

Table 3 .

 3 2: valve positions for each scenario Valve

  .9) where a p , b p , a r , c p , d p , c r , d r are non negative parameters such that the functions f p , f r , l p , l r are not identically null. One can straightforwardly check that the domain {(x, p) s.t. x > 0} is invariant by the dynamics (5.2) whatever is the control law u(•).

	5.4. Application of the Maximum Principle	111
	is invariant by the dynamics (5.1) and that p(•) is increasing whatever is the control. There-
	fore the domain
	D
				Assumption 5.3.1 is
	fulfilled when one has
		a r > a p	(5.10)
	Notice that the interval (0, x max ) with
	x max =	b p a p	(+∞ if a p = 0)

Table 5 .

 5

1: Parameters values

Model description

The biological reactions inside each reactor in the flexible platform are modeled using ASM1-2ND model [START_REF] Ostace | [END_REF]. It is a modified version of Activated Sludge Model 1 (ASM1) [Henze et al. 2000]. The main modification consists in the addition of a two-step process for nitrification and denitrification. While the ASM1 model consider only complete nitrification of ammonia (N H + 4 ) to nitrate (N O - 3 ) by autotrophic bacteria, followed by complete denitrification of nitrate to nitrogen gas, ASM1-2ND uses a 2-steps nitrification model: the nitrification is carried out in two sequential steps, the first one describing the ammonium (N H + 4 ) oxidation to nitrite (N O - 2 ) by Ammonia Oxidizing Bacteria (X AOB ) while the second one models the nitrite oxidation (N O - 2 ) into nitrate (N O - 3 ) by Nitrate Oxidizing Bacteria (X N OB ). The denitrification is performed following a parallel twostep scheme in which nitrate (N O - 3 ) or nitrite (N O - 2 ) is transformed into gas (N 2 ) by heterotrophic bacteria (X BH ).The processes describing the growth of aerobic bacteria are modeled using Monod kinetics and are presented in the equations (3.1) and (3.2). The aerobic growth kinetics of Ammonia Oxidizing Bacteria ρ AOB (mg L -1 d -1 ) is modeled by:

The aerobic growth kinetics of Nitrate Oxidizing Bacteria ρ N OB (mg

) is modeled by:

Where K OA ,K N O2 and K N H are half-saturation rates of oxygen, nitrite and ammonium, respectively. µ AOB , µ N OB are Maximum growth rates of Nitromonas and Nitrobacter, respectively. This model is used for simulating the biological processes that take place in the platform proposed above, in order to predict the growth of bacteria and the resulting consumption of carbon and nitrogen. This is done in taking into account nitrite as an intermediate state variable during the nitrification and denitrification processes.

Implementation of WRRF platform

Set-up of the 'simulation platform' was made under Matlab/Simulink-environment. By using three bioreactor objects, five 2-way flow combiner models, all implemented as Ccode S-function objects. The membrane is supposed to be ideal (the effluent does not contain any particulate component). Furthermore, a hydraulic delay model was add (to avoid algebraic loops). and the controllers for internal recirculation flow rate recirculation flow rate with various connections and valves are integrated.

The Solids Retention Time (SRT) control

The SRT is an important design and control parameter for the activated sludge process. It represents the average length of time that bacteria stay in the process before being wasted. The selected SRT directly affects the bacterial composition in an activated sludge system.

Chapter 4. Processing Soil Water Content Measurements to Estimate Crop Water Requirements and Optimize Irrigation Supply

This chapter is published : F. Karam, A. Mouneimne, F. Aichouche, A. Rapaport, and J. Harmand, "Processing soil water content measurements to estimate crop water requirements and optimize irrigation supply," in IFAC-PapersOnLine, 2019, vol. 52, no. 23. DOI : 10.1016/j.ifacol.2019.11.008 When considering a smart resources recovery, the flexible treatment system must be able to provide the treated wastewater according to the plant/crops requirements in terms of quality (notably nitrogen) and quantity (water irrigation). The best irrigation strategy for crops is to maintain the level of soil moisture in the root zone that exactly meets the needs of the plant/crop. In order to do so, the soil water content in the top soil profile must be observed. First this chapter provides a new preprocessing procedure to transform the raw measured signals into a signal that can be used within a water balance model. Secondly, we design an unknown input observer to estimate the part of water used by the plant for its evapotranspiration. The approach is validated using real time series data obtained from the monitoring of avocado culture under Lebanon's Mediterranean climate. Requirements and Optimize Irrigation Supply Results also showed that the proposed approach was good in simulating the dynamic of soil water content (SW C) in the root zone as the sum of two components of the soil-plant water balance; the first negative with unknown outputs (ET , D r and R o ) and the other positive with known inputs (P and I). The goodness of the proposed approach depends on the availability of input variables and the estimation of unknown outputs. In other words, the proposed approach behaved as a 'watcher' of the different components of the soil-plant water balance system. It was demonstrated that when SW C is monitored at a regular basis, it becomes feasible and reliable calculating ET , being the major unknown output in this complex system.

On the other hand, the calculations of ET made with the proposed 'watcher' approach accounted for the net irrigation requirements of avocado during the growing season from June throughout September. Net irrigation requirements of avocado (the integral of ŵ(t))) were found to as much as 622 mm for the 2016 dataset while it was 380 for the 2018 dataset (to be compared to the volumes of water that were brought and that were 532 mm and 324 mm respectively for both years). This finding helps optimizing irrigation supply by providing guidelines to growers and farmers on sustainable water management for this crop under Lebanon's Mediterranean climate and water resources limitations.

Further validation of the proposed approach is still needed on other crops and different environments. For future works, we suggest calculating net irrigation requirements assuming a threshold level of SW C as a fraction of the total available water in the soil at a desired depth. CHAPTER 5 Modeling and optimal control for production-regeneration systemspreliminary results -

State-space equations for ASM1-2ND model in WRRF plaftorm

The dynamics within each k-th reactor in the plant, as presented in Section 2.2.1, are here detailed. Firstly, we define the total flow-rate entering reactor

)

.

Where :

The total mass entering A(k) of any component

.

We assume constant volume in every tank, so we define the total flow-rate leaving reactor A(k) by Q

I . We assume the plant to have a perfect membrane. Therefore, any term representing particulate mass leaving tank A(3) is implicitly set to zero, i.e., Q

Attainable steady-states

This appendix was added in order to present the figures presented in chapter 2, which shows the attainable steady-states for the different forms of nitrogen according to manipulated variables in the flexible platform.

APPENDIX D

The optimal requirement for agriculture system

For the agricultural system, we consider a crop grown in monoculture that is irrigated continuously with treated wastewater, for example with a drip irrigation system. The aim here is to determine how to supply water and nitrogen to the crop through irrigation for optimal crop growth. Although we do not consider that the water flow-rate through the WWTP can be controlled, we will suppose that the irrigation flow-rate is a controllable input of the crop system. Thus, the aim here is to determine the nitrogen concentration of the irrigation water as well as the irrigation flow-rate to supply for optimal crop growth.

As a first approach, we use an idealized model that considers a simplified crop development process and focuses on the water and nitrogen dynamics of the crop and soil. This dynamical system by [Pelak et al. 2017] simulates the crop-soil system on a uniform area of land, at the scale of a field, over the course of a growing season. The crop is represented by the canopy cover (the fraction of ground covered by a crop) and plant biomass per unit area. The other model variables are the vertically averaged relative soil moisture and nitrogen content per unit area of soil. Abstract in English To meet the challenges of the scarcity of good quality water resources, the reuse of treated wastewater ("REUT" or "REUSE") appears to be a solution for the future. It prevents the treated water from being released into the environment without giving it a second life, or even more. To do this, we are promoting a paradigm shift in which wastewater is no longer seen as waste to be depolluted but a new resource that can be treated on a custom basis, depending on the needs and uses in new energy recovery facilities, to recover nutrients and other molecules of interest. This sustainable management of water resources comes up against many challenges, in particular technical problems such as the lack of flexibility of current wastewater treatment plants. Faced with the great challenge of providing, in a dynamic and economically acceptable manner, a quality of treated water adapted to the needs of agriculture, and in order to reduce the environmental impacts, automatic control technologies certainly have an essential role to play. This study, which is freed from current regulatory limitations as it is essentially carried out in simulations, presents the preliminary results of research with the development of a simulation platform for a flexible system combining activated sludge treatment plants with a membrane filtration process. We evaluate how the control of the whole, based on the use of industrial controllers and advanced control, can be used to adapt in real time, under conditions of martial measurements and in the presence of uncertainties and disturbances, a water whose the quality meets the needs of the plants / crops or, on the contrary, when necessary, meets the quality constraints required for release into the environment. The approach requires knowing the needs of plants. As the latter are difficult to continuously measure, part of the work is dedicated to the synthesis of unknown input observers to estimate the amount of water available for the plant in the soil (and therefore accessible for evapotranspiration). Finally, since the cost of wastewater treated by membrane filtration technologies is often prohibitive for users, we are evaluating the extent to which recourse to optimal control approaches, in particular the Maximum Pontryagin Principle, would make it possible to reduce these cost by optimizing the management of the clogging of these membranes and thus minimizing the functioning cost of these systems.

Keywords: Flexibility, Modelling, Control, Reuse, Optimization, Wastewater treatment , Observation.