using "WasteWaterUnits"; Model FlowConnector ATTRIBUTES Pallete = false; Brief = "Stream connector of ASM1 components"; Info = " The stream connector consists of one flow variable and 13 potential variables (ASM1 concentrations). "; VARIABLES Q as VolumeFlowRate (Brief="Volumetric Flow Rate", Symbol = "Q"); Si as MassConcentration (Brief="Soluble inert organic matter", Symbol = "S_i"); Ss as MassConcentration (Brief="Readily biodegradable substrate", Symbol = "S_s"); Xi as MassConcentration (Brief="Particulate inert organic matter", Symbol = "X_i"); Xs as MassConcentration (Brief="Slowly biodegradable substrate", Symbol = "X_s"); Xbh as MassConcentration (Brief="Active heterotrophic biomass", Symbol = "X_{bh}"); Xba as MassConcentration (Brief= "Active autotrophic biomass", Symbol = "X_{ba}"); Xp as MassConcentration (Brief="Particulate products from biomass decay", Symbol = "X_p"); So as MassConcentration (Brief="Dissolved oxygen", Symbol = "S_o"); Sno as MassConcentration (Brief="Nitrate and nitrite nitrogen", Symbol = "S_{no}"); Snh as MassConcentration (Brief="Ammonium nitrogen", Symbol = "S_{nh}"); Snd as MassConcentration (Brief="Soluble biodegradable organic nitrogen", Symbol = "S_{nd}"); Xnd as MassConcentration (Brief="Particulate biodegradable organic nitrogen", Symbol = "X_{nd}"); Salk as Alkalinity (Brief="Alkalinity", Symbol = "S_{alk}"); end Model AirFlow ATTRIBUTES Pallete = false; Brief = "Airflow connector."; Info = " The Airflow connector consists of a flow variable describing the exchange of air between blower and nitrification tank. "; VARIABLES Q_air as VolumeFlowRate (Brief="Volumetric Flow Rate of Air", Symbol = "Q_{air}"); end Model Stoichiometry ATTRIBUTES Pallete = false; Brief = "ASM1 stoichiometric coefficients"; Info = "This is a partial model providing the stoichiometric coefficients of the ASM1 model. "; PARAMETERS Y_h as Real (Brief = "Heterotrophic Yield [g Xbh COD formed/(g COD utilised)]", Symbol = "Y_h"); Y_a as Real (Brief = "Autotrophic Yield [g Xba COD formed/(g N utilised)]", Symbol = "Y_a"); f_p as Real (Brief = "Fraction of biomass to particulate products [-]", Symbol = "f_p"); i_xb as Real (Brief = "Fraction nitrogen in biomass [g N/(g COD)]", Symbol = "Y_{xb}"); i_xp as Real (Brief = "Fraction nitrogen in particulate products [g N/(g COD)]", Symbol = "Y_{xp}"); SET Y_h = 0.67 ; Y_a = 0.24 ; f_p = 0.08 ; i_xb = 0.086; i_xp = 0.06 ; end Model ASM1base as Stoichiometry ATTRIBUTES Pallete = false; Brief = "Base class of WWTP modelling by ASM1."; Info = " This partial model provides connectors and equations that are needed in the biological components (nitrification and denitrification tank) for ASM1 wastewater treatment plant models. Parameters are coded according the ASM1 standard distribution. Changes to this parameters are subject to the modeller. "; VARIABLES mu_h as decayRate (Brief = "Maximum heterotrophic growth rate f(T)", Symbol = "\mu _{h}"); b_h as decayRate (Brief = "Heterotrophic decay rate f(T)", Symbol = "b_h"); mu_a as decayRate (Brief = "Maximum autotrophic growth rate f(T)", Symbol = "\mu _a"); b_a as decayRate (Brief = "Autotrophic decay rate f(T)", Symbol = "b_a"); k_a as Real (Brief = "Ammonification rate f(T)", Symbol = "k_a", Unit = 'm^3/g/d'); k_h as Real (Brief = "Maximum specific hydrolysis rate f(T)", Symbol = "k_h"); K_x as Real (Brief = "Half-saturation (hydrolysis) f(T)", Symbol = "K_x"); PARAMETERS mu_h_T as decayRate (Brief = "Maximum heterotrophic growth rate at T=15 deg C "); b_h_T as decayRate (Brief = "Heterotrophic decay rate at T=15 deg C"); mu_a_T as decayRate (Brief = "Maximum autotrophic growth rate at T=15 deg C"); b_a_T as decayRate (Brief = "Autotrophic decay rate at T=15 deg C"); k_a_T as Real (Brief = "Ammonification rate at T=15 deg C ", Unit = 'm^3/g/d'); k_h_T as Real (Brief = "Maximum specific hydrolysis rate at T=15 deg C"); K_x_T as Real (Brief = "Half-saturation (hydrolysis) at T=15 deg C "); K_nh as MassConcentration (Brief = "Half-saturation (auto. growth)", Symbol = "K_{nh}"); K_s as MassConcentration (Brief = "Half-saturation (hetero. growth)", Symbol = "K_{s}"); K_oh as MassConcentration (Brief = "Half-saturation (hetero. oxygen)", Symbol = "K_{oh}", DisplayUnit = 'g/m^3'); K_no as MassConcentration (Brief = "Half-saturation (nitrate)", Symbol = "K_{no}", DisplayUnit = 'g/m^3'); K_oa as MassConcentration (Brief = "Half-saturation (auto. oxygen)", Symbol = "K_{oa}"); ny_g as Real (Brief = "Anoxic growth rate correction factor ", Symbol = "{ny}_g"); ny_h as Real (Brief = "Anoxic hydrolysis rate correction factor", Symbol = "{ny}_h"); SET mu_h_T = 4.00 *'1/d'; b_h_T = 0.28 *'1/d'; mu_a_T = 0.50 *'1/d'; b_a_T = 0.10 *'1/d'; k_a_T = 0.06 * 'm^3/g/d'; k_h_T = 1.75; K_x_T = 0.0175 ; K_nh = 1.00 * 'g/m^3'; K_s = 20.0 * 'g/m^3'; K_oh = 0.20 * 'g/m^3'; K_no = 0.50 * 'g/m^3'; K_oa = 0.40 * 'g/m^3'; ny_g = 0.8 ; ny_h = 0.4; end Model DeniTank as ASM1base ATTRIBUTES Pallete = true; Icon = "icon/deni"; Brief = "ASM1 denitrification tank."; Info = " This component models the ASM1 processes and reactions taking place in an unaerated (denitrification) tank of a wastewater treatment plant. "; PARAMETERS V as volume (Brief = "Volume of denitrification tank"); Tref as temperature (Brief = "Temperature dependent Kinetic parameters based on 15 deg C"); Tscale as temperature (Brief = "adimensional temperatura"); eps as MassConcentration (Brief = "adimensional temperatura"); Nrates as Integer; Nprocess as Integer; SET V = 1000 * 'm^3'; Tref = (15+273)*'K'; Tscale = 1*'K'; Nrates = 13; Nprocess = 8; eps = 1e-10*'g/l'; VARIABLES in Inlet as FlowConnector (Brief = "Tank Inlet Stream", PosX=0, PosY=0.28, Symbol = "^{in}"); out Outlet as FlowConnector (Brief = "Tank Outlet Stream", PosX=1, PosY=0.3, Symbol = "^{out}"); VARIABLES T as temperature; ProcessRates(Nprocess) as ReacRate (Brief = "Process Rates"); Reactions(Nrates) as ReacRate (Brief = "Reactions Rates"); aeration as ReacRate; EQUATIONS mu_h = mu_h_T*exp(0.069*(T- Tref)/Tscale); b_h = b_h_T*exp(0.069*(T- Tref)/Tscale); mu_a = mu_a_T*exp(0.098*(T- Tref)/Tscale); b_a = b_a_T*exp(0.08*(T- Tref)/Tscale); k_a = k_a_T*exp(0.069*(T- Tref)/Tscale); k_h = k_h_T*exp(0.11*(T- Tref)/Tscale); K_x = K_x_T*exp(0.11*(T- Tref)/Tscale); #+++++++++++++++ Process Rates ++++++++++++++++++++++++++++++++++++++ ProcessRates(1) = mu_h*(Outlet.Ss/(K_s + Outlet.Ss+eps))*(Outlet.So/(K_oh + Outlet.So+eps))*Outlet.Xbh; ProcessRates(2) = mu_h*(Outlet.Ss/(K_s + Outlet.Ss+eps))*(K_oh/(K_oh + Outlet.So+eps))*(Outlet.Sno/(K_no + Outlet.Sno+eps))*ny_g*Outlet.Xbh; ProcessRates(3) = mu_a*(Outlet.Snh/(K_nh + Outlet.Snh+eps))*(Outlet.So/(K_oa + Outlet.So+eps))*Outlet.Xba; ProcessRates(4) = b_h*Outlet.Xbh; ProcessRates(5) = b_a*Outlet.Xba; ProcessRates(6) = k_a*Outlet.Snd*Outlet.Xbh; ProcessRates(7) = k_h*((Outlet.Xs/(Outlet.Xbh+eps))/(K_x + (Outlet.Xs/(Outlet.Xbh+eps)))*((Outlet.So/(K_oh + Outlet.So+eps)) + ny_h*(K_oh/(K_oh + Outlet.So+eps))*(Outlet.Sno/(K_no +Outlet.Sno+eps))))*Outlet.Xbh; ProcessRates(8) = ProcessRates(7)*Outlet.Xnd/(Outlet.Xs+eps); # biochemical reactions Reactions(1) = 0*'kg/m^3/s'; Reactions(2) = (-ProcessRates(1) - ProcessRates(2))/Y_h + ProcessRates(7); Reactions(3) = 0 *'kg/m^3/s'; Reactions(4) = (1 - f_p)*(ProcessRates(4) + ProcessRates(5)) - ProcessRates(7); Reactions(5) = ProcessRates(1) + ProcessRates(2) - ProcessRates(4); Reactions(6) = ProcessRates(3) - ProcessRates(5); Reactions(7) = f_p*(ProcessRates(4) + ProcessRates(5)); Reactions(8) = -((1 - Y_h)/Y_h)*ProcessRates(1)- ((4.57 - Y_a)/Y_a)*ProcessRates(3 ); Reactions(9) = -((1 - Y_h)/(2.86*Y_h))*ProcessRates(2 ) + ProcessRates(3 )/Y_a; Reactions(10) = -i_xb*(ProcessRates(1 ) + ProcessRates( 2)) - (i_xb + (1/Y_a))*ProcessRates(3 ) + ProcessRates( 6); Reactions(11) = -ProcessRates( 6) +ProcessRates(8 ); Reactions(12) = (i_xb - f_p*i_xp)*(ProcessRates(4 ) + ProcessRates( 5)) - ProcessRates( 8); Reactions(13) = -i_xb/14*ProcessRates( 1) + ((1 - Y_h)/(14*2.86*Y_h) - (i_xb/14))*ProcessRates( 2) - ((i_xb/14) + 1/(7*Y_a))*ProcessRates( 3) + ProcessRates(6 )/14; " no aeration in this tank " aeration = 0*'kg/m^3/s'; Inlet.Q = Outlet.Q; diff(Outlet.Si) = (Inlet.Si - Outlet.Si)*Inlet.Q/V + Reactions(1); diff(Outlet.Ss) = (Inlet.Ss - Outlet.Ss)*Inlet.Q/V +Reactions(2); diff(Outlet.Xi )= (Inlet.Xi - Outlet.Xi)*Inlet.Q/V+Reactions(3); diff(Outlet.Xs) = (Inlet.Xs - Outlet.Xs)*Inlet.Q/V+Reactions(4); diff(Outlet.Xbh) = (Inlet.Xbh - Outlet.Xbh)*Inlet.Q/V+Reactions(5); diff(Outlet.Xba) = (Inlet.Xba - Outlet.Xba)*Inlet.Q/V+Reactions(6); diff(Outlet.Xp) = (Inlet.Xp - Outlet.Xp)*Inlet.Q/V+Reactions(7); diff(Outlet.So) = (Inlet.So - Outlet.So)*Inlet.Q/V+Reactions(8)+ aeration; diff(Outlet.Sno )= (Inlet.Sno - Outlet.Sno)*Inlet.Q/V+Reactions(9); diff(Outlet.Snh )= (Inlet.Snh - Outlet.Snh)*Inlet.Q/V+Reactions(10); diff(Outlet.Snd) = (Inlet.Snd - Outlet.Snd)*Inlet.Q/V+Reactions(11); diff(Outlet.Xnd) = (Inlet.Xnd - Outlet.Xnd)*Inlet.Q/V+Reactions(12); diff(Outlet.Salk) = (Inlet.Salk - Outlet.Salk)*Inlet.Q/V+Reactions(13); end Model NitriTank as ASM1base ATTRIBUTES Pallete = true; Icon = "icon/nitri"; Brief = "ASM1 nitrification tank."; Info = " This component models the ASM1 processes and reactions taking place in an aerated (nitrification) tank of a wastewater treatment plant. "; PARAMETERS # aeration system dependent parameters alpha as Real (Brief ="Oxygen transfer factor"); de as length (Brief = "depth of aeration"); R_air as GeneralFactor (Brief="specific oxygen feed factor [gO2/(m^3*m)]"); V as volume (Brief = "Volume of nitrification tank"); Tref as temperature (Brief = "Temperature dependent Kinetic parameters based on 15 deg C"); Tscale as temperature (Brief = "adimensional temperatura"); eps as MassConcentration (Brief = "adimensional temperatura"); Nrates as Integer; Nprocess as Integer; SET V = 1000 * 'm^3'; Tref = (15+273)*'K'; Tscale = 1*'K'; alpha = 0.7; de = 4.5 *'m'; R_air = 23.5 *'g/(m^3*m)'; eps = 1e-16*'g/l'; Nrates=13; Nprocess=8; VARIABLES in Inlet as FlowConnector (Brief = "Tank Inlet Stream", PosX=0, PosY=0.28, Symbol = "^{in}"); out Outlet as FlowConnector (Brief = "Tank Outlet Stream", PosX=1, PosY=0.3, Symbol = "^{out}"); in AirIn as AirFlow (Brief = "Inlet Air Stream", PosX=0.5, PosY=1); VARIABLES T as temperature; So_sat as MassConcentration (Brief="Dissolved oxygen saturation"); ProcessRates(Nprocess) as ReacRate (Brief = "Process Rates"); Reactions(Nrates) as ReacRate (Brief = "Reactions Rates"); aeration as ReacRate; EQUATIONS mu_h = mu_h_T*exp(0.069*(T- Tref)/Tscale); b_h = b_h_T*exp(0.069*(T- Tref)/Tscale); mu_a = mu_a_T*exp(0.098*(T- Tref)/Tscale); b_a = b_a_T*exp(0.08*(T- Tref)/Tscale); k_a = k_a_T*exp(0.069*(T- Tref)/Tscale); k_h = k_h_T*exp(0.11*(T- Tref)/Tscale); K_x = K_x_T*exp(0.11*(T- Tref)/Tscale); "Temperature dependent oxygen saturation by Simba" So_sat = abs(13.89 + (-0.3825 + (0.007311 - 0.00006588*T)*T)* T); " extends the Oxygen differential equation by an aeration term" #aeration [mgO2/l]; AirIn.Q_air needs to be in Simulationtimeunit [m3*day^-1] aeration = (alpha*(So_sat - Outlet.So)/(So_sat+eps)*AirIn.Q_air*R_air*de)/V; #Process Rates ProcessRates(1) = mu_h*(Outlet.Ss/(K_s + Outlet.Ss+eps))*(Outlet.So/(K_oh + Outlet.So+eps))*Outlet.Xbh; ProcessRates(2) = mu_h*(Outlet.Ss/(K_s + Outlet.Ss+eps))*(K_oh/(K_oh + Outlet.So+eps))*(Outlet.Sno/(K_no + Outlet.Sno+eps))*ny_g*Outlet.Xbh; ProcessRates(3) = mu_a*(Outlet.Snh/(K_nh + Outlet.Snh+eps))*(Outlet.So/(K_oa + Outlet.So+eps))*Outlet.Xba; ProcessRates(4) = b_h*Outlet.Xbh; ProcessRates(5) = b_a*Outlet.Xba; ProcessRates(6) = k_a*Outlet.Snd*Outlet.Xbh; ProcessRates(7) = k_h*((Outlet.Xs/(Outlet.Xbh+eps))/(K_x + (Outlet.Xs/(Outlet.Xbh+eps)))*((Outlet.So/(K_oh + Outlet.So+eps)) + ny_h*(K_oh/(K_oh + Outlet.So+eps))*(Outlet.Sno/(K_no +Outlet.Sno+eps))))*Outlet.Xbh; ProcessRates(8) = ProcessRates(7)*Outlet.Xnd/(Outlet.Xs+eps); # biochemical reactions Reactions(1) = 0*'kg/m^3/s'; Reactions(2) = (-ProcessRates(1) - ProcessRates(2))/Y_h + ProcessRates(7); Reactions(3) = 0*'kg/m^3/s'; Reactions(4) = (1 - f_p)*(ProcessRates(4) + ProcessRates(5)) - ProcessRates(7); Reactions(5) = ProcessRates(1) + ProcessRates(2) - ProcessRates(4); Reactions(6) = ProcessRates(3) - ProcessRates(5); Reactions(7) = f_p*(ProcessRates(4) + ProcessRates(5)); Reactions(8) = -((1 - Y_h)/Y_h)*ProcessRates(1)- ((4.57 - Y_a)/Y_a)*ProcessRates(3 ); Reactions(9) = -((1 - Y_h)/(2.86*Y_h))*ProcessRates(2 ) + ProcessRates(3 )/Y_a; Reactions(10) = -i_xb*(ProcessRates(1 ) + ProcessRates( 2)) - (i_xb + (1/Y_a))*ProcessRates(3 ) + ProcessRates( 6); Reactions(11) = -ProcessRates( 6) +ProcessRates(8 ); Reactions(12) = (i_xb - f_p*i_xp)*(ProcessRates(4 ) + ProcessRates( 5)) - ProcessRates( 8); Reactions(13) = -i_xb/14*ProcessRates( 1) + ((1 - Y_h)/(14*2.86*Y_h) - (i_xb/14))*ProcessRates( 2) - ((i_xb/14) + 1/(7*Y_a))*ProcessRates( 3) + ProcessRates(6 )/14; Inlet.Q = Outlet.Q; diff(Outlet.Si) = (Inlet.Si - Outlet.Si)*Inlet.Q/V + Reactions(1); diff(Outlet.Ss) = (Inlet.Ss - Outlet.Ss)*Inlet.Q/V +Reactions(2); diff(Outlet.Xi )= (Inlet.Xi - Outlet.Xi)*Inlet.Q/V+Reactions(3); diff(Outlet.Xs) = (Inlet.Xs - Outlet.Xs)*Inlet.Q/V+Reactions(4); diff(Outlet.Xbh) = (Inlet.Xbh - Outlet.Xbh)*Inlet.Q/V+Reactions(5); diff(Outlet.Xba) = (Inlet.Xba - Outlet.Xba)*Inlet.Q/V+Reactions(6); diff(Outlet.Xp) = (Inlet.Xp - Outlet.Xp)*Inlet.Q/V+Reactions(7); diff(Outlet.So) = (Inlet.So - Outlet.So)*Inlet.Q/V+Reactions(8)+ aeration; diff(Outlet.Sno )= (Inlet.Sno - Outlet.Sno)*Inlet.Q/V+Reactions(9); diff(Outlet.Snh )= (Inlet.Snh - Outlet.Snh)*Inlet.Q/V+Reactions(10); diff(Outlet.Snd) = (Inlet.Snd - Outlet.Snd)*Inlet.Q/V+Reactions(11); diff(Outlet.Xnd) = (Inlet.Xnd - Outlet.Xnd)*Inlet.Q/V+Reactions(12); diff(Outlet.Salk) = (Inlet.Salk - Outlet.Salk)*Inlet.Q/V+Reactions(13); end Model WWSource ATTRIBUTES Pallete = true; Icon = "icon/wwSource"; Brief = "Wastewater source."; Info = " This component provides all ASM1 data at the influent of a wastewater treatment plant. "; VARIABLES out Outlet as FlowConnector (Brief="Influent Stream", Symbol = "^{out}", PosX=1, PosY=0.96); end Model EffluentSink ATTRIBUTES Pallete = true; Icon = "icon/wwSink"; Brief = "Wastewater sink."; Info = " This component terminates an ASM1 wastewater treatment plant model e.g. the wastewater flow to the receiving water. "; VARIABLES in Inlet as FlowConnector (Brief="Effluent Stream", Symbol = "^{in}", PosX=0, PosY=0.25); end Model blower ATTRIBUTES Pallete = true; Icon = "icon/blower"; Brief = "Blower for the aeration of the nitrification tanks."; Info = " This component models a blower of a wastewater treatment plant which generates an airflow that is needed for the nitrification. *The blower is connected to the nitrification tank. *The airflow is controlled by a signal u (-1 <= u <= 1). "; #PARAMETERS #Q_max as VolumeFlowRate (Brief="Maximum blower capacity"); #Q_min as VolumeFlowRate (Brief="Minimum blower capacity"); VARIABLES out AirOut as AirFlow (Brief="Effluent Stream", Symbol = "Air_{out}", PosX=0.45, PosY=0); end Model mixer2 ATTRIBUTES Pallete = true; Icon = "icon/mixer2"; Brief = "Mixer of 2 ASM1 characterised flows."; Info = " This component mixes 2 flows of wastewater (ASM1) of different concentration and different amount. "; VARIABLES in Inlet1 as FlowConnector (Brief="First Inlet Mixer Stream",Symbol = "^{in1}", PosX=0, PosY=0.5); in Inlet2 as FlowConnector (Brief="Second Inlet Mixer Stream",Symbol = "^{in2}", PosX=0, PosY=0.8); out Outlet as FlowConnector (Brief="Outlet Mixer Stream", Symbol = "^{out}", PosX=1, PosY=0.65); EQUATIONS Inlet1.Q + Inlet2.Q = Outlet.Q; Outlet.Si = (Inlet1.Si*Inlet1.Q + Inlet2.Si*Inlet2.Q )/(Inlet1.Q + Inlet2.Q ); Outlet.Ss = (Inlet1.Ss*Inlet1.Q + Inlet2.Ss*Inlet2.Q )/(Inlet1.Q + Inlet2.Q ); Outlet.Xi = (Inlet1.Xi*Inlet1.Q + Inlet2.Xi*Inlet2.Q )/(Inlet1.Q + Inlet2.Q ); Outlet.Xs = (Inlet1.Xs*Inlet1.Q + Inlet2.Xs*Inlet2.Q )/(Inlet1.Q + Inlet2.Q); Outlet.Xbh = (Inlet1.Xbh*Inlet1.Q + Inlet2.Xbh*Inlet2.Q )/(Inlet1.Q + Inlet2.Q ); Outlet.Xba = (Inlet1.Xba*Inlet1.Q + Inlet2.Xba*Inlet2.Q )/(Inlet1.Q + Inlet2.Q); Outlet.Xp = (Inlet1.Xp*Inlet1.Q + Inlet2.Xp*Inlet2.Q )/(Inlet1.Q + Inlet2.Q); Outlet.So = (Inlet1.So*Inlet1.Q + Inlet2.So*Inlet2.Q )/(Inlet1.Q + Inlet2.Q); Outlet.Sno = (Inlet1.Sno*Inlet1.Q + Inlet2.Sno*Inlet2.Q )/(Inlet1.Q + Inlet2.Q ); Outlet.Snh = (Inlet1.Snh*Inlet1.Q + Inlet2.Snh*Inlet2.Q )/(Inlet1.Q + Inlet2.Q ); Outlet.Snd = (Inlet1.Snd*Inlet1.Q + Inlet2.Snd*Inlet2.Q )/(Inlet1.Q + Inlet2.Q); Outlet.Xnd = (Inlet1.Xnd*Inlet1.Q + Inlet2.Xnd*Inlet2.Q)/(Inlet1.Q + Inlet2.Q ); Outlet.Salk = (Inlet1.Salk*Inlet1.Q + Inlet2.Salk*Inlet2.Q )/(Inlet1.Q + Inlet2.Q ); end Model mixer3 ATTRIBUTES Pallete = true; Icon = "icon/mixer3"; Brief = "Mixer of 3 ASM1 characterised flows."; Info = " This component mixes 3 flows of wastewater (ASM1) of different concentration and different amount. "; VARIABLES in Inlet1 as FlowConnector (Brief="First Inlet Mixer Stream", Symbol = "^{in1}", PosX=0, PosY=0.4); in Inlet2 as FlowConnector (Brief="Second Inlet Mixer Stream", Symbol = "^{in2}", PosX=0, PosY=0.6); in Inlet3 as FlowConnector (Brief="Third Inlet Mixer Stream", Symbol = "^{in3}", PosX=0, PosY=0.8); out Outlet as FlowConnector (Brief="Outlet Mixer Stream", Symbol = "^{out}", PosX=1, PosY=0.6); EQUATIONS Inlet1.Q + Inlet2.Q + Inlet3.Q = Outlet.Q; Outlet.Si = (Inlet1.Si*Inlet1.Q + Inlet2.Si*Inlet2.Q + Inlet3.Si*Inlet3.Q)/(Inlet1.Q + Inlet2.Q + Inlet3.Q); Outlet.Ss = (Inlet1.Ss*Inlet1.Q + Inlet2.Ss*Inlet2.Q + Inlet3.Ss*Inlet3.Q)/(Inlet1.Q + Inlet2.Q + Inlet3.Q); Outlet.Xi = (Inlet1.Xi*Inlet1.Q + Inlet2.Xi*Inlet2.Q + Inlet3.Xi*Inlet3.Q)/(Inlet1.Q + Inlet2.Q + Inlet3.Q); Outlet.Xs = (Inlet1.Xs*Inlet1.Q + Inlet2.Xs*Inlet2.Q + Inlet3.Xs*Inlet3.Q)/(Inlet1.Q + Inlet2.Q + Inlet3.Q); Outlet.Xbh = (Inlet1.Xbh*Inlet1.Q + Inlet2.Xbh*Inlet2.Q + Inlet3.Xbh*Inlet3.Q)/(Inlet1.Q + Inlet2.Q + Inlet3.Q); Outlet.Xba = (Inlet1.Xba*Inlet1.Q + Inlet2.Xba*Inlet2.Q + Inlet3.Xba*Inlet3.Q)/(Inlet1.Q + Inlet2.Q + Inlet3.Q); Outlet.Xp = (Inlet1.Xp*Inlet1.Q + Inlet2.Xp*Inlet2.Q + Inlet3.Xp*Inlet3.Q)/(Inlet1.Q + Inlet2.Q + Inlet3.Q); Outlet.So = (Inlet1.So*Inlet1.Q + Inlet2.So*Inlet2.Q + Inlet3.So*Inlet3.Q)/(Inlet1.Q + Inlet2.Q + Inlet3.Q); Outlet.Sno = (Inlet1.Sno*Inlet1.Q + Inlet2.Sno*Inlet2.Q + Inlet3.Sno*Inlet3.Q)/(Inlet1.Q + Inlet2.Q + Inlet3.Q); Outlet.Snh = (Inlet1.Snh*Inlet1.Q + Inlet2.Snh*Inlet2.Q + Inlet3.Snh*Inlet3.Q)/(Inlet1.Q + Inlet2.Q + Inlet3.Q); Outlet.Snd = (Inlet1.Snd*Inlet1.Q + Inlet2.Snd*Inlet2.Q + Inlet3.Snd*Inlet3.Q)/(Inlet1.Q + Inlet2.Q + Inlet3.Q); Outlet.Xnd = (Inlet1.Xnd*Inlet1.Q + Inlet2.Xnd*Inlet2.Q + Inlet3.Xnd*Inlet3.Q)/(Inlet1.Q + Inlet2.Q + Inlet3.Q); Outlet.Salk = (Inlet1.Salk*Inlet1.Q + Inlet2.Salk*Inlet2.Q + Inlet3.Salk*Inlet3.Q)/(Inlet1.Q + Inlet2.Q + Inlet3.Q); end Model wwPump ATTRIBUTES Pallete = true; Icon = "icon/pump"; Brief = "ASM1 wastewater pump."; Info = " This component models an ASM1 wastewater pump. It generates a wastewater flow that is controlled by the signal u (-1 <= u <=1). "; PARAMETERS Q_min as VolumeFlowRate (Brief="minimum pump capacity", Symbol = "Q_{min}", Default = 0); Q_max as VolumeFlowRate (Brief="maximum pump capacity", Symbol = "Q_{max}", Default = 20000); VARIABLES in Inlet as FlowConnector (Brief="Inlet Stream", Symbol = "^{in}", PosX=0, PosY=0.75); out Outlet as FlowConnector (Brief="Outlet Stream", Symbol = "^{out}", PosX=1, PosY=0.4); EQUATIONS Outlet.Q = Inlet.Q; Outlet.Si = Inlet.Si; Outlet.Ss = Inlet.Ss; Outlet.Xi = Inlet.Xi; Outlet.Xs = Inlet.Xs; Outlet.Xbh = Inlet.Xbh; Outlet.Xba = Inlet.Xba; Outlet.Xp = Inlet.Xp; Outlet.So = Inlet.So; Outlet.Sno = Inlet.Sno; Outlet.Snh = Inlet.Snh; Outlet.Snd = Inlet.Snd; Outlet.Xnd = Inlet.Xnd; Outlet.Salk = Inlet.Salk; end Model divider2 ATTRIBUTES Pallete = true; Icon = "icon/divider2"; Brief = "Flow divider."; Info = " This component divides one ASM1 wastewater flow into two ASM1 wastewater flows. "; PARAMETERS Frac_1 as fraction; SUBMODELS in Inlet as FlowConnector (Brief="Inlet Stream", Symbol = "^{in}", PosX=0, PosY=0.65); out Outlet1 as FlowConnector (Brief="First Outlet Stream", Symbol = "^{out1}", PosX=1, PosY=0.45); out Outlet2 as FlowConnector (Brief="Second Outlet Stream", Symbol = "^{out2}", PosX=1, PosY=0.8); EQUATIONS Inlet.Q = Outlet1.Q + Outlet2.Q; Outlet1.Q = Inlet.Q*Frac_1; Outlet1.Si = Inlet.Si; Outlet1.Ss = Inlet.Ss; Outlet1.Xi = Inlet.Xi; Outlet1.Xs = Inlet.Xs; Outlet1.Xbh = Inlet.Xbh; Outlet1.Xba = Inlet.Xba; Outlet1.Xp = Inlet.Xp; Outlet1.So = Inlet.So; Outlet1.Sno = Inlet.Sno; Outlet1.Snh = Inlet.Snh; Outlet1.Snd = Inlet.Snd; Outlet1.Xnd = Inlet.Xnd; Outlet1.Salk = Inlet.Salk; Outlet2.Si = Inlet.Si; Outlet2.Ss = Inlet.Ss; Outlet2.Xi = Inlet.Xi; Outlet2.Xs = Inlet.Xs; Outlet2.Xbh = Inlet.Xbh; Outlet2.Xba = Inlet.Xba; Outlet2.Xp = Inlet.Xp; Outlet2.So = Inlet.So; Outlet2.Sno = Inlet.Sno; Outlet2.Snh = Inlet.Snh; Outlet2.Snd = Inlet.Snd; Outlet2.Xnd = Inlet.Xnd; Outlet2.Salk = Inlet.Salk; end Model secRatios ATTRIBUTES Pallete = false; Brief = "partial model for ratios of solid components"; Info = "partial model for ASM1 ratios of solid components. "; VARIABLES # ratios of solid components rXi as Real; rXs as Real; rXbh as Real; rXba as Real; rXp as Real; rXnd as Real; end Model secParam ATTRIBUTES Pallete = false; Brief = "partial model providing clarifier parameters."; Info = "partial model providing clarifier parameters. "; PARAMETERS zm as length; Asc as area; end Model secVar ATTRIBUTES Pallete = false; Brief = "partial models providing variables."; Info = "partial models providing ASM1 variables. "; VARIABLES Si as MassConcentration (Brief="Soluble inert organic matter"); Ss as MassConcentration (Brief="Readily biodegradable substrate"); So as MassConcentration (Brief="Dissolved oxygen"); Sno as MassConcentration (Brief="Nitrate and nitrite nitrogen"); Snh as MassConcentration (Brief="Ammonium nitrogen"); Snd as MassConcentration (Brief="Soluble biodegradable organic nitrogen"); Salk as Alkalinity (Brief="Alkalinity"); X as MassConcentration (Brief="total sludge concentration in m-th layer"); Xf as MassConcentration (Brief="total sludge concentration in clarifier feed"); vS as SedimentationVelocity (Brief="sink velocity in m-th layer"); Jsm as SedimentationFlux (Brief="sedimentation flux m-th layer"); end Model LowerLayerPin ATTRIBUTES Pallete = false; Brief = "Connector below influent layer."; Info = "Connector for ASM1 information and mass exchange between layers below the influent layer (feed_layer). "; VARIABLES Qr as VolumeFlowRate; Qw as VolumeFlowRate; SedFlux as SedimentationFlux ; # total sludge concentration in m-th layer X as MassConcentration; # total sludge concentration and sink velocity in(m-1)-th layer (dn=down) X_dn as MassConcentration; vS_dn as SedimentationVelocity; Si as MassConcentration (Brief="Soluble inert organic matter"); Ss as MassConcentration (Brief="Readily biodegradable substrate"); So as MassConcentration (Brief="Dissolved oxygen"); Sno as MassConcentration (Brief="Nitrate and nitrite nitrogen"); Snh as MassConcentration (Brief="Ammonium nitrogen"); Snd as MassConcentration (Brief="Soluble biodegradable organic nitrogen"); Salk as Alkalinity (Brief="Alkalinity"); end Model UpperLayerPin ATTRIBUTES Pallete = false; Brief = "Connector below influent layer."; Info = "Connector for ASM1 information and mass exchange between layers below the influent layer (feed_layer). "; VARIABLES Qe as VolumeFlowRate; SedFlux as SedimentationFlux ; # total sludge concentration and sink velocity in(m-1)-th layer (dn=down) X_dn as MassConcentration; vS_dn as SedimentationVelocity; Si as MassConcentration (Brief="Soluble inert organic matter"); Ss as MassConcentration (Brief="Readily biodegradable substrate"); So as MassConcentration (Brief="Dissolved oxygen"); Sno as MassConcentration (Brief="Nitrate and nitrite nitrogen"); Snh as MassConcentration (Brief="Ammonium nitrogen"); Snd as MassConcentration (Brief="Soluble biodegradable organic nitrogen"); Salk as Alkalinity (Brief="Alkalinity"); end Model clarifier ATTRIBUTES Pallete = true; Icon ="icon/clarifier"; Brief = "Simple ASM1 Secondary Clarifier Model"; Info = "This component models very simple the secondary clarification process by just using a single fully mixed tank which removes all particulate substances from the effluent and returns the sludge. No sedimentation and compression, etc. is considered (for ASM1). "; PARAMETERS eps as MassConcentration (Brief="eps",Default = 1e-11); VARIABLES in Feed as FlowConnector (Brief = "Feed Stream", Symbol = "^{Feed}", PosX=0, PosY=0.4); out Effluent as FlowConnector (Brief = "Effluent Stream", Symbol = "^{Eff}", PosX=1, PosY=0.2); out Return as FlowConnector (Brief = "Return Stream", Symbol = "^{Return}", PosX=0.4, PosY=1); out Waste as FlowConnector (Brief = "Waste Stream", Symbol = "^{Waste}", PosX=0.6, PosY=1); rXi as Real (Lower=-1e-10); rXs as Real(Lower=-1e-10); rXbh as Real(Lower=-1e-10); rXba as Real(Lower=-1e-10); rXp as Real(Lower=-1e-10); rXnd as Real(Lower=-1e-10); Si as MassConcentration (Brief="Soluble inert organic matter"); Ss as MassConcentration (Brief="Readily biodegradable substrate"); So as MassConcentration (Brief="Dissolved oxygen"); Sno as MassConcentration (Brief="Nitrate and nitrite nitrogen"); Snh as MassConcentration (Brief="Ammonium nitrogen"); Snd as MassConcentration (Brief="Soluble biodegradable organic nitrogen"); Salk as Alkalinity (Brief="Alkalinity"); X as MassConcentration (Brief="sludge concentration in clarifier"); Xf as MassConcentration (Brief="total sludge concentration in clarifier feed"); PARAMETERS hsc as length; Asc as area; FracReturn as fraction; FracWaste as fraction; SET hsc=4.0 *'m'; Asc=1500.0*'m^2'; EQUATIONS " total sludge concentration in clarifier feed" Xf = 0.75*(Feed.Xs + Feed.Xbh + Feed.Xba + Feed.Xp + Feed.Xi); " ratios of solid components" rXs*Xf = Feed.Xs; rXbh*Xf = Feed.Xbh; rXba*Xf = Feed.Xba; rXp*Xf = Feed.Xp; rXi*Xf = Feed.Xi; rXnd*Xf = Feed.Xnd; " ODE of sludge concentration" diff(X) = (Feed.Q*Xf - (-(Waste.Q + Return.Q))*X)/(Asc*hsc); " ODE of soluble components" diff(Si) = (Feed.Q*Feed.Si - (-Effluent.Q)*Si - (-(Waste.Q + Return.Q))*Si)/(Asc*hsc); diff(Ss) = (Feed.Q*Feed.Ss - (-Effluent.Q)*Ss - (-(Waste.Q + Return.Q))*Ss)/(Asc*hsc); diff(So) = (Feed.Q*Feed.So - (-Effluent.Q)*So - (-(Waste.Q + Return.Q))*So)/(Asc*hsc); diff(Sno) = (Feed.Q*Feed.Sno - (-Effluent.Q)*Sno - (-(Waste.Q + Return.Q))*Sno)/(Asc*hsc); diff(Snh) = (Feed.Q*Feed.Snh - (-Effluent.Q)*Snh - (-(Waste.Q + Return.Q))*Snh)/(Asc*hsc); diff(Snd) = (Feed.Q*Feed.Snd - (-Effluent.Q)*Snd - (-(Waste.Q + Return.Q))*Snd)/(Asc*hsc); diff(Salk) = (Feed.Q*Feed.Salk - (-Effluent.Q)*Salk - (-(Waste.Q + Return.Q))* Salk)/(Asc*hsc); " volume flow rates" Feed.Q = Effluent.Q + Return.Q + Waste.Q; Return.Q = Feed.Q*FracReturn; Waste.Q = Feed.Q*FracWaste; "effluent, solid and soluble components (ASM1)" Effluent.Si = Si; Effluent.Ss = Ss; Effluent.Xi = 0.0*X; Effluent.Xs = 0.0*X; Effluent.Xbh = 0.0*X; Effluent.Xba = 0.0*X; Effluent.Xp = 0.0*X; Effluent.So = So; Effluent.Sno = Sno; Effluent.Snh = Snh; Effluent.Snd = Snd; Effluent.Xnd = 0.0*X; Effluent.Salk = Salk; "return sludge flow, solid and soluble components (ASM1)" Return.Si = Si; Return.Ss = Ss; Return.Xi = rXi*X; Return.Xs = rXs*X; Return.Xbh = rXbh*X; Return.Xba = rXba*X; Return.Xp = rXp*X; Return.So = So; Return.Sno = Sno; Return.Snh = Snh; Return.Snd = Snd; Return.Xnd = rXnd*X; Return.Salk = Salk; " waste sludge flow, solid and soluble components (ASM1)" Waste.Si = Si; Waste.Ss = Ss; Waste.Xi = rXi*X; Waste.Xs = rXs*X; Waste.Xbh = rXbh*X; Waste.Xba = rXba*X; Waste.Xp = rXp*X; Waste.So = So; Waste.Sno = Sno; Waste.Snh = Snh; Waste.Snd = Snd; Waste.Xnd = rXnd*X; Waste.Salk = Salk; end Model sludge ATTRIBUTES Pallete = true; Icon = "icon/sludge"; Brief = "to be documented."; Info = " none "; VARIABLES in Inlet as FlowConnector (Brief="Influent Stream", Symbol = "^{in}", PosX=0, PosY=0.5); end