Transactions Template JOURNAL OF ENGINEERING RESEARCH AND TECHNOLOGY, VOLUME 4, ISSUE 2, JUNE, 2017 61 Modelica-Based Model for Activated Sludge System Khalil T. Matar 1 , Fahid K.J. Rabah 2 , Mohamed M. Abdelati 3 Abstractβ€”Activated sludge system is the most important stage in municipal wastewater treatment process. It is a biological operation used for treating sewage by means of microorganism. One type of activated sludge systems is the oxidation ditch. In this work, models derived through object-oriented programming will be used to build a simulation model for a typical oxidation ditch. The derived model was constructed and programmed using Modelica language. The simulation model will help better understand the system behavior. Thereby, the model will be provided as an assessment or evaluation tool for the performance of control schemes. The tool gave the expected results, in terms of reducing the concentration of organic matter in wastewater coming out from oxidation ditches. Key wordsβ€” oxidation ditch, modeling, Modelica, activated sludge, wastewater treatment plant I INTRODUCTION Wastewater is water containing solids, whether sus- pended or dissolved. Therefore, wastewater treatment is defined as the process of separating solids from water to get cleaner water that can be reused or safely disposed into the environment. There are many methods used for separating solids from water such as physical, chemical, and biological methods [1].In this paper a biological method for wastewater treatment was focused on and modeled. The principal bio- logical processes used for wastewater treatment are divided into two main categories; the first category is the suspended growth processes while the second one is the attached growth processes[2]. For the suspended growth processes, microorganisms are maintained in suspension while convert- ing organic matter or other constituents in the wastewater to gases and cell tissue. Examples for these processes are con- ventional activated sludge system, oxidation ditches(OD), sequencing batch reactors (SBR), aerated lagoons and up flow sludge blanket reactors. On the other hand, the at- tached growth processes are characterized by microorgan- isms responsible for conversion of organic matter or other constituents in wastewater to gases and cell tissue are at- tached to some inert material such as: rocks, sand, ce- ramic, or plastic materials. This research contributes to the rehabilitation of the wastewater treatment plant of the European Hospital located in the southern of Gaza Strip. This plant receives a daily average amount of 141 m of untreated wastewater coming out of the European hospital. The average concentration of organic matter)BOD) entering the plant is 317 mg /L [3], so this wastewater needs to be treated before it is injected into the aquifer or prior to use in irrigation, to prevent the pollu- tion of the groundwater. The plant utilizes an oxidation ditch for the biological treatment process. The main objective of this research is to create a simulation model for the organic matter removal process from wastewater in the OD using the component-oriented language Modelica in order to better understand the process dynamics and investigate the effi- ciency of possible control schemes. In [4,5] wastewater pumping stations are modeled using Modelica. In [6] The Modelica application library Wastewater containing three Activated Sludge Models of different complexity with the essential components of municipal wastewater treatment plants is presented. In [7] the dynamic optimization method was applied to a wastewater treatment plant (WWTP) mod- el. With the help of the library Wastewater an ASM No. 2d model of the WWTP Jena was examined and evaluated. This research deals with mathematical modeling and process control of OD wastewater treatment in Europe- an hospital in KhanYounis as a case study. The increased importance of biological purification processes has also resulted in increasing interest in their mathematical model- ing, for understanding as well as for predictive and control purposes. The plant under study consists of 15 parts, as illustrated in the process flow diagram depicted inFigure1.Part I: IN- LET PUMPING STATION consists of a tank for wastewater collection entering the wastewater to plant, in addition to the two screw pumps capacity of each is 10 L/S. Part II: MUNCHER which is used to remove solids. Part III: OXI- DATION DITCH, which is the most important part of the plant because the biological treatment process occurs within this part. Part IV: SEDIMENTATAION TANK, which is used to separate and remove Settleable suspended solids. Part V: FLOWMETER &CHLORINATION, which is used to control the sterilization process and to add chlorine. Part VI: SLUDGE PUMPING STATION, which is a tank to col- lect the sludge for distribution either to oxidation ditch or to be sent for sludge treatment. Part VII: SLUDGE CONSOL- IDATION TANK, which is a tank that mixes the sludge to become homogeneous, so it is transferred for drying. Part VIII: DISTRIBUTION CHAMBER, which is the place where the treated water is being distributed to downstream units. Part IX: FINAL COLLECTION TANKS, which are used to collect water that has been treated. Part X: OUTLET PUMPING STATION, which is used to transfer the water that has been treated to Finishing Ponds and Soakaway Ar- ea. Part XI: SOAKAWAY AREA, are ponds to inject treated water into groundwater. Part XII: CHLRINATION UNIT, which is used for the disinfection of treated water using chlorine. Part XIII: SLUDGE DRYING BEDS, is the place, Khalil T. Matar, Fahid K.J. Rabah, and Mohamed M. Abdelati/ Modelica-Based Model for Activated Sludge System (2017) 62 Figure 1: European hospital Gaza-sewage treatment plant where the sludge is being dried for disposal or some industrial use. The rest of this paper is organized as follows: Section 2 describes the biological treatment stage, Section 3 describes modeling, and Section 4 presents simulation results. Finally, Section 5 provides a conclusion and an outlook on future work. II PROCESS DESCRIPTION Activated sludge is a process for treat- ing wastewater using microorganisms in the presence or absence of oxygen. The activated sludge process is a biolog- ical process that can be used to convert dissolved and partic- ulate organic biodegradable compounds into acceptable end products and remove nutrients, such as nitrogen and phos- phorus. In this paper, it is focused on organic matter as the major contaminant material. There are a variety of types of activated sludge plants. Such as, conventional activated sludge system, oxidation ditches, sequencing batch reactor (SBR), aerated lagoons, and up flow anaerobic sludge blan- ket (UASB). The plant under study utilizes an oxidation ditch which is a suspended growth system as shown in Figure 2. It is a modified version of the conventional activated sludge system. Oxidation ditches may be considered as a traditional completely-mixed systems characterized by long detention hydraulic time and sludge age. Oxidation ditch consists of one or multiple channels forming a loop, oval or horseshoe. Wastewater is recycled in the oxidation ditch by using a rotating brush. The brush has another function which is dissolving some atmospheric oxygen in the liquor which is necessary for microorganisms growth. Figure 2: The oxidation ditch under study. The flow velocity in the oxidation ditch is maintained in the range of 25-30 cm/s to keep the microorganisms sus- pended. In general the process consists of anoxic zone fol- lowed by aerobic one as illustrated in Figure 3. At the influent to the oxidation ditch, there are organic matter and nitrates (NO ) coming from the aerobic zone along with a low level of dissolved oxygen (O2) (which is usually less than 0.5 mg O2 /L). This is called anoxic condition where denitrification occurs. At the end of the anoxic zone and the beginning of the aerobic zone at the brush, the pollutants that exist are: the remaining organic matter that was not used for denitrification in addition to O2 introduced by the aerator and ammonium (NH ) that comes http://en.wikipedia.org/wiki/Sewage Khalil T. Matar, Fahid K.J. Rabah, and Mohamed M. Abdelati/ Modelica-Based Model for Activated Sludge System (2017) 63 with influent and passes through the anoxic zone without any reduction in its concentration. In these conditions both BOD5 (organic matter measurement unit) removal and nitri- fication occurs ( conversion of NH to NO ) under aerobic conditions. At the end of the aerobic zone the dissolved oxy- gen is reduced again to around zero due to the consumption by the microorganism. Oxidation ditches differ from con- ventional activated sludge system in terms of the ability to achieve the removal targets with high-performance and low operation and maintenance costs. In addition, OD produces less sludge compared to other activated sludge biological treatment processes[8,9,10]. Figure 3: The process flow in oxidation ditches. III MODEL DERIVATION For the modeling of oxidation ditch process, component models are not found in the standard simulation tool librar- ies. In this work, it is not intended to build a sophisticated model for detailed investigations rather to conclude with a manageable working model. The objective is to design a simulation tool that simulates oxidation ditch operations, particularly the reduction of organic matter (i.e. reduction of BOD concentration. To this end, the modeling and simula- tion environment β€œDymola” which is based on the compo- nent-oriented language Modelica was used [2]. The modeling of oxidation ditch is addressed in the lit- erature as completely mixed reactor [8,9]. The OD process is illustrated in the simplified schematic drawing as shown in Figure 4. The following variable notation will be used in the model development: Q wastewater flow rate, (m3/d). πœƒ hydraulic detention time of the reac- tor, (day). πœƒ the mean cell-residence time, (day). S concentration of the limiting sub- strate in solution, (mg/L). Y maximum yield coefficient measured during any finite period of logarith- mic growth, defined as the ratio of the mass of cells formed to the mass of substrate consumed, (mg biomass / mg substrate). π‘˜ endogenous decay coefficient, (1/day) 𝑉 reactor volume, (m 3 ). 𝑋 concentration of microorganisms in the influent, (mg/L). 𝑋 concentration of microorganisms in the reactor, (mg/L). 𝑄 sludge waste flow rate, (m 3 /d). 𝑋 concentration of biomass in the re- turn line, (mg/L). 𝑄 effluent flow rate, (m 3 /d). 𝑋 concentration of biomass in the ef- fluent, (mg/L). Figure 4: Oxidation ditch system: Completely mixed reactor with solids recycles The biomass concentration in the influent (X0) of this reactor is negligible compared to the biomass concentration in the reactor (X). The hydraulic detention time in the OD is related to the reactor's volume and the flow rate as follows: πœƒ = 𝑉 𝑄 (1) The net production of sludge during wastewater treat- ment Px, measured in KgVss/d, is given by the following equation: 𝑃π‘₯ = π‘Œ 1 + π‘˜ πœƒ 𝑄(𝑆1 βˆ’ 𝑆2) (2) Where S1 and S2 are the concentration of organic matter in the influent an effluent , respectively. The concentration of oxygen (R ) kg O2/d affects the reduction of organic matter as well as the net production of sludge. In [1,2] it has been shown that these quantities are related as follows: 𝑅 = 𝑄 (𝑆 βˆ’ 𝑆 ) βˆ’ 1.42𝑃 (3) Solving Equations 2 and 3 results in the following equa- tion; 𝑆 = 𝑆 βˆ’ 𝐾 𝑅 𝑄 (4) Where K is a coefficient that depends on Y,k and ΞΈ . Khalil T. Matar, Fahid K.J. Rabah, and Mohamed M. Abdelati/ Modelica-Based Model for Activated Sludge System (2017) 64 After describing the mathematical equations of the oxi- dation ditch system, the following is a description of the wastewater treatment control system. The main strategy fol- lowed is to control the treatment efficiency by controlling the oxygen concentration in the oxidation ditch. In the Oxidation ditches the amount of dissolved oxy- gen is controlled through adjusting the speed of the rotating brush. Manufacturers of aerators provide an empirical quad- ratic equation that relates R and the rotational speed of the brush (r). The parameters of such an equation depend on the physical characteristics of the aerator. The one used in this study has the following characteristic equation: 𝑅 = π‘Ÿ2 - π‘Ÿ + (5) The feedback in the controller is the concentration of organic matter at the effluent (S ). An oxygen sensor is used to estimate this quantity assuming a quadratic relation- ship between r and oxygen level (O).Depending on the char- acteristics of the brush aerator installed in the OD under study , the relation of (O) to( r ) is as follows: 𝑂 = 0.0116[ 1250 (π‘Ÿ βˆ’ 500) + π‘Ÿ 8(π‘Ÿ βˆ’ 500) βˆ’ 65π‘Ÿ (π‘Ÿ βˆ’ 500) ] (6) Now, the control problem is to adjust the aerator speed to keep the organic matter of the effluent at a specific level. In order to carry simulations, an estimate for the daily variation of influent is required. An estimate is depicted in Figure 5. Figure 5: Daily flow pattern of wastewater in the hospital IV IMPLEMENTATION PROCEDURE This subsection describes briefly how modeling is im- plemented in Modelica using the Dymola tool. The first step is defining the wastewater connector (W). Its icon is repre- sented by a small blue square and it is defined as follows: connector W Real S(min=0.0); Real X(min=0.0); flow Real Q; end W; Figure 6: Modelica code of the oxidation ditch. To build an oxidation ditch model, two wastewater connect- ors (w1 and w2)are needed, in addition to an output con- nector (O) of type real and input connector (r) of type real. Being governed by equations 1 to 6, its Modelica code is shown in Figure 6. V SIMULATION RESULTS The goal of the simulation is to verify the derived model and to see the progress of operations in the oxidation ditch. The con- trol problem is a typical feedback control scenario in which the concentration of organic matter at the effluent is measured in correlation to the oxygen sensor reading, compared to a refer- ence value, then resultant error signal is used to derive the con- troller which adjusts the aerator speed. Consequently, the level of dissolved oxygen is adapted which is the key factor of the microorganisms production that affects the organic matter con- sumption. However, excess amounts of oxygen levels are unde- sired as it leads to growth of the filamentous bacteria which cause sludge bulking. It is recommended to keep the oxygen level below 3 mgO2/l. The top level module of such a system may be implemented in β€œDymola” as illustrated in Figure 7. The proposed process controller is based on a PID controller with limited output, anti-windup compensation and set point weighting as illustrated in Figure 8. This PID controller is available in the Modelica standard library and it is explained thoroughly in[11]. The controller is tuned and its output is lim- ited to the range from zero to 1460 rpm which is the maximum possible speed of our aerator. Khalil T. Matar, Fahid K.J. Rabah, and Mohamed M. Abdelati/ Modelica-Based Model for Activated Sludge System (2017) 65 Figure 7: The system model Figure 8: PID controller with limited output The simulated controller of this process is shown in Figure 9. Figure 9: Process controller The lower part of the controller has a PID module with limited output, anti-windup compensation and set point weighting. Its output specifies the required speed of the aerator . The upper part has an integrator with a limited out- put from zero to one. In regular cases, the error signal is positive and the inte- grator saturates to unity value. Once the dissolve oxygen exceeds the specified threshold (Oβ‰ˆ3 mg/l), the integrator output starts to decrease and eventually saturates to 0. This gives a measure for the persistence of the dissolved oxygen to exceed the threshold value. The result of this integrator is multiplied with the output of the Limited PID module to generate the recommended speed of aerator. The Variable Frequency Drive (VFD) is modelled by a first-order block with a time constant of 5 s resulting in an acceleration time of about half a minute to move forward or backward between zero speed and rated speed states. The wastewater flow pattern at the influent is illustrated in Figure 5. The concentration of organic matter at influent and ef- fluent of the oxidation ditch are illustrated in Figure 10. The concentration of organic matter at the influent equals 290 mgBOD5/L while the resultant steady state concentration of organic matter at the effluent is reduced to 20 mgBOD5/L. Figure 10: Concentration of organic matter at influent and effluent of oxidation ditch . The speed of aerator is shown in Figure 11,while the readings of the oxygen sensor are shown in Figure 12. Both are reasonable compared to field measurements and are within the acceptable range. Figure 11: Aerator rotational speed Figure 12: Oxygen concentration in the OD. S2=20 mgBOD5/L S1=290 mgBOD5/L Oxidation ditch Khalil T. Matar, Fahid K.J. Rabah, and Mohamed M. Abdelati/ Modelica-Based Model for Activated Sludge System (2017) 66 VI CONCLUSION This paper targeted a small size hospital’s plant, which depends on oxidation ditch to treat wastewater. The study presents an easily controlled and managed model for the oxidation ditch of the wastewater treatment plant of the European hospital. The model provides a tool for testing the system performance and controlling its treatment pro- cess. It also helps in understanding the dynamics of the system and allows designing a stable and robust control- ler unit for the system. The following conclusions were de- rived from this work: 1- The control system enabled the control of oxygen concentration from 0 to 2 mg O2/L. 2- The system enabled the controlled reduction of or- ganic matter concentration in the range of 290 to 20 mg BOD5/L by controlling the brush speed and ,consequently, the concentration of dissolved oxy- gen in the OD. In Future work, this model will be developed to include the simulation of ammonia and nitrate reduction in the OD treatment unit. The work will study the development of the control system and will introduce a new effective tech- niques in the control process. REFERENCES [1] Metcalf and Eddy Wastewater Engineering: Treatment, Disposal, Reuse. New York, USA, McGraw- Hill )1979 11-11 ( . [2] Davis, M. and Cornwell, D. Introduction to Environ- mental Engineering. McGraw-Hill,2006. [3] Al-Sheikh, J. Design and construct alteration and con- struction works at the European Gaza hospital. Gaza Strip, Palestine, ministry of health (2002) IV& 3. [4] Abdelati, M., Felgner, F. and Frey, G. Modeling, Simu- lation and Control of a Water Recovery and Irrigation System. The 8th International Conference on Informat- ics in Control, Automation and Robotics (ICINCO-8), Noordwijkerhout, Netherlands,(2011) 323-329. [5] Abdelati, M., Felgner, F. and Frey, G. Modeling Wastewater Pumping Stations for Cost-Efficient Con- trol. 16th IEEE International Conference on Emerging Technologies and Factory Automation (ETFA ), (2012). [6] Reichl, G. Wastewater a Library for Modeling and Simulation of Wastewater Treatment Plants in Modeli- ca. Technische UniversitΓ€tIlmenau, Ilmenau, Germany (2003). [7] Ziehn, T.,Reichl, G. andArnold, E. Application of the Modelica library Wastewater for optimization purpos- es. 4th International Modelica Conference, (2005) 351- 356. [8] U.S. Environmental Protection Agency (EPA). Wastewater Technology Fact Sheet Oxidation Ditches. Retrieved September 2000,from http://water.epa.gov/scitech/wastetech/upload/2002_06 _28_mtb_oxidation_ditch.pdf [9] Abusam, A.,Keesman, K.J.,Spanjers, H., G. van Strate- nand and Meinema, K. a procedure for benchmarking specific full scale activated sludge plants used for car- bon and nitrogen removal. IFAC,(2002). [10] Pons, M., Mourot, G. andRagot, J. Modeling and simu- lation of a carrousel for long-term operation(2011, Au- gust 28).Retrived September 2, 2011, from https://hal.archives-ouvertes.fr/hal-00632752/document [11] Astrom, K. and Hagglund, T.PID Controllers: Theory, Design, and Tuning. North Carolina, USA, Instrument Society of America,