source: branches/WasteWater/ASM1.mso @ 693

Last change on this file since 693 was 509, checked in by gerson bicca, 15 years ago

added mso files

File size: 29.8 KB
Line 
1
2using "WasteWaterUnits";
3
4Model FlowConnector
5
6ATTRIBUTES
7        Pallete         = false;
8        Brief           = "Stream connector of ASM1 components";
9        Info            =
10"
11The stream connector consists of one flow variable and 13 potential variables (ASM1 concentrations).
12";
13
14VARIABLES
15
16        Q               as VolumeFlowRate                       (Brief="Volumetric Flow Rate", Symbol = "Q");
17        Si              as MassConcentration            (Brief="Soluble inert organic matter", Symbol = "S_i");
18        Ss              as MassConcentration            (Brief="Readily biodegradable substrate", Symbol = "S_s");
19        Xi              as MassConcentration            (Brief="Particulate inert organic matter", Symbol = "X_i");
20        Xs              as MassConcentration            (Brief="Slowly biodegradable substrate", Symbol = "X_s");
21        Xbh     as MassConcentration            (Brief="Active heterotrophic biomass", Symbol = "X_{bh}");
22        Xba             as MassConcentration            (Brief= "Active autotrophic biomass", Symbol = "X_{ba}");
23        Xp              as MassConcentration            (Brief="Particulate products from biomass decay", Symbol = "X_p");
24        So              as MassConcentration            (Brief="Dissolved oxygen", Symbol = "S_o");
25        Sno             as MassConcentration            (Brief="Nitrate and nitrite nitrogen", Symbol = "S_{no}");
26        Snh             as MassConcentration            (Brief="Ammonium nitrogen", Symbol = "S_{nh}");
27        Snd             as MassConcentration            (Brief="Soluble biodegradable organic nitrogen", Symbol = "S_{nd}");
28        Xnd     as MassConcentration            (Brief="Particulate biodegradable organic nitrogen", Symbol = "X_{nd}");
29        Salk    as Alkalinity                                           (Brief="Alkalinity", Symbol = "S_{alk}");
30
31end
32
33Model AirFlow
34       
35ATTRIBUTES
36        Pallete                 = false;
37        Brief           = "Airflow connector.";
38        Info                    =
39"
40The Airflow connector consists of a flow variable describing the exchange of
41air between blower and nitrification tank.
42";
43
44VARIABLES
45
46Q_air as VolumeFlowRate (Brief="Volumetric Flow Rate of Air", Symbol = "Q_{air}");
47
48end
49
50Model Stoichiometry
51       
52ATTRIBUTES
53        Pallete         = false;
54        Brief   = "ASM1 stoichiometric coefficients";
55        Info            =
56"This is a partial model providing the stoichiometric coefficients of the ASM1 model.
57";
58
59PARAMETERS
60
61  Y_h   as Real                 (Brief = "Heterotrophic Yield [g Xbh COD formed/(g COD utilised)]", Symbol = "Y_h");
62  Y_a   as Real                 (Brief = "Autotrophic Yield [g Xba COD formed/(g N utilised)]", Symbol = "Y_a");
63  f_p           as Real                 (Brief = "Fraction of biomass to particulate products [-]", Symbol = "f_p");
64  i_xb  as Real                 (Brief = "Fraction nitrogen in biomass [g N/(g COD)]", Symbol = "Y_{xb}");
65  i_xp  as Real                 (Brief = "Fraction nitrogen in particulate products [g N/(g COD)]", Symbol = "Y_{xp}");
66
67SET
68
69 Y_h            =       0.67 ;
70  Y_a   =       0.24 ;
71  f_p           =       0.08 ;
72  i_xb  =       0.086;
73  i_xp  =       0.06 ;
74
75end
76
77Model ASM1base as Stoichiometry
78
79ATTRIBUTES
80        Pallete         = false;
81        Brief           = "Base class of WWTP modelling by ASM1.";
82        Info                    =
83"
84This partial model provides connectors and equations that are needed in the biological
85components (nitrification and denitrification tank) for ASM1 wastewater treatment plant models.
86Parameters are coded according the ASM1 standard distribution.
87Changes to this parameters are subject to the modeller.
88";
89
90VARIABLES
91        mu_h    as decayRate (Brief = "Maximum heterotrophic growth rate f(T)", Symbol = "\mu _{h}");
92        b_h             as decayRate (Brief = "Heterotrophic decay rate f(T)", Symbol = "b_h");
93        mu_a    as decayRate (Brief = "Maximum autotrophic growth rate f(T)", Symbol = "\mu _a");
94        b_a             as decayRate (Brief = "Autotrophic decay rate f(T)", Symbol = "b_a");
95        k_a             as Real                         (Brief = "Ammonification rate f(T)", Symbol = "k_a", Unit = 'm^3/g/d');
96        k_h             as Real                         (Brief = "Maximum specific hydrolysis rate f(T)", Symbol = "k_h");
97        K_x             as Real                         (Brief = "Half-saturation (hydrolysis) f(T)", Symbol = "K_x");
98
99PARAMETERS
100       
101  mu_h_T as decayRate                   (Brief = "Maximum heterotrophic growth rate at T=15 deg C ");
102  b_h_T         as decayRate                    (Brief = "Heterotrophic decay rate at T=15 deg C");
103  mu_a_T as decayRate                   (Brief = "Maximum autotrophic growth rate at T=15 deg C");
104  b_a_T         as decayRate                    (Brief = "Autotrophic decay rate at T=15 deg C");
105  k_a_T         as Real                                         (Brief = "Ammonification rate at T=15 deg C ", Unit = 'm^3/g/d');
106  k_h_T         as Real                                         (Brief = "Maximum specific hydrolysis rate at T=15 deg C");
107  K_x_T         as Real                                         (Brief = "Half-saturation (hydrolysis) at T=15 deg C ");
108
109  K_nh          as MassConcentration    (Brief = "Half-saturation (auto. growth)", Symbol = "K_{nh}");
110   K_s          as MassConcentration    (Brief = "Half-saturation (hetero. growth)", Symbol = "K_{s}");
111  K_oh          as MassConcentration    (Brief = "Half-saturation (hetero. oxygen)", Symbol = "K_{oh}", DisplayUnit = 'g/m^3');
112  K_no          as MassConcentration    (Brief = "Half-saturation (nitrate)", Symbol = "K_{no}", DisplayUnit = 'g/m^3');
113  K_oa          as MassConcentration    (Brief = "Half-saturation (auto. oxygen)", Symbol = "K_{oa}");
114   ny_g         as Real                                                         (Brief = "Anoxic growth rate correction factor ", Symbol = "{ny}_g");
115   ny_h         as Real                                                         (Brief = "Anoxic hydrolysis rate correction factor", Symbol = "{ny}_h");
116
117SET
118
119        mu_h_T  =       4.00 *'1/d';
120        b_h_T           =       0.28 *'1/d';
121        mu_a_T  =       0.50 *'1/d';
122        b_a_T           =       0.10 *'1/d';
123        k_a_T           =       0.06 * 'm^3/g/d';
124        k_h_T           =       1.75;
125        K_x_T           =       0.0175 ;
126        K_nh            =       1.00 * 'g/m^3';
127        K_s                     =       20.0 * 'g/m^3';
128        K_oh            =       0.20 * 'g/m^3';
129        K_no            =       0.50 * 'g/m^3';
130        K_oa                    =       0.40 * 'g/m^3';
131   ny_g                 =       0.8 ;
132   ny_h                 =       0.4;
133
134end
135
136Model DeniTank as ASM1base
137
138ATTRIBUTES
139        Pallete         = true;
140        Icon            = "icon/deni";
141        Brief           = "ASM1 denitrification tank.";
142        Info                    =
143"
144This component models the ASM1 processes and reactions taking place in an unaerated
145(denitrification) tank of a wastewater treatment plant.
146";
147
148 PARAMETERS
149
150        V                               as volume                                               (Brief = "Volume of denitrification tank");
151        Tref            as temperature                          (Brief = "Temperature dependent Kinetic parameters based on 15 deg C");
152        Tscale  as temperature                          (Brief = "adimensional temperatura");
153        eps          as MassConcentration       (Brief = "adimensional temperatura");
154
155Nrates as Integer;
156Nprocess as Integer;
157
158SET
159
160        V                                       =       1000 * 'm^3';
161        Tref                    = (15+273)*'K';
162        Tscale          =  1*'K';
163        Nrates          =       13;
164        Nprocess        =       8;
165        eps                             = 1e-10*'g/l';
166
167VARIABLES
168
169in Inlet                as FlowConnector        (Brief = "Tank Inlet Stream", PosX=0, PosY=0.28, Symbol = "^{in}");
170out Outlet      as FlowConnector        (Brief = "Tank Outlet Stream", PosX=1, PosY=0.3, Symbol = "^{out}");
171
172VARIABLES
173
174        T                                                       as temperature;
175        ProcessRates(Nprocess)  as ReacRate             (Brief = "Process Rates");
176        Reactions(Nrates)               as ReacRate     (Brief = "Reactions Rates");
177        aeration                                as ReacRate;
178
179EQUATIONS
180
181        mu_h = mu_h_T*exp(0.069*(T- Tref)/Tscale);
182
183        b_h = b_h_T*exp(0.069*(T- Tref)/Tscale);
184       
185        mu_a = mu_a_T*exp(0.098*(T- Tref)/Tscale);
186       
187        b_a = b_a_T*exp(0.08*(T- Tref)/Tscale);
188       
189        k_a = k_a_T*exp(0.069*(T- Tref)/Tscale);
190       
191        k_h = k_h_T*exp(0.11*(T- Tref)/Tscale);
192       
193        K_x = K_x_T*exp(0.11*(T- Tref)/Tscale);
194
195#+++++++++++++++ Process Rates ++++++++++++++++++++++++++++++++++++++
196        ProcessRates(1) = mu_h*(Outlet.Ss/(K_s + Outlet.Ss+eps))*(Outlet.So/(K_oh + Outlet.So+eps))*Outlet.Xbh;
197        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;
198        ProcessRates(3)  = mu_a*(Outlet.Snh/(K_nh + Outlet.Snh+eps))*(Outlet.So/(K_oa + Outlet.So+eps))*Outlet.Xba;
199        ProcessRates(4)  = b_h*Outlet.Xbh;
200        ProcessRates(5)  = b_a*Outlet.Xba;
201        ProcessRates(6)  = k_a*Outlet.Snd*Outlet.Xbh;
202        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;
203        ProcessRates(8)  = ProcessRates(7)*Outlet.Xnd/(Outlet.Xs+eps);
204
205# biochemical reactions
206 
207        Reactions(1) = 0*'kg/m^3/s';
208       
209        Reactions(2) = (-ProcessRates(1) - ProcessRates(2))/Y_h + ProcessRates(7);
210       
211        Reactions(3) = 0 *'kg/m^3/s';
212       
213        Reactions(4) = (1 - f_p)*(ProcessRates(4) + ProcessRates(5)) - ProcessRates(7);
214       
215        Reactions(5) = ProcessRates(1) + ProcessRates(2) - ProcessRates(4);
216       
217        Reactions(6) = ProcessRates(3) - ProcessRates(5);
218       
219        Reactions(7) = f_p*(ProcessRates(4) + ProcessRates(5));
220       
221        Reactions(8) = -((1 - Y_h)/Y_h)*ProcessRates(1)- ((4.57 - Y_a)/Y_a)*ProcessRates(3 );
222       
223        Reactions(9) = -((1 - Y_h)/(2.86*Y_h))*ProcessRates(2 ) + ProcessRates(3 )/Y_a;
224       
225        Reactions(10) = -i_xb*(ProcessRates(1 ) + ProcessRates( 2)) - (i_xb + (1/Y_a))*ProcessRates(3 ) + ProcessRates( 6);
226       
227        Reactions(11) = -ProcessRates( 6) +ProcessRates(8 );
228       
229        Reactions(12) = (i_xb - f_p*i_xp)*(ProcessRates(4 ) + ProcessRates( 5)) - ProcessRates( 8);
230       
231        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;
232 
233 " no aeration in this tank "
234  aeration = 0*'kg/m^3/s';
235 
236Inlet.Q = Outlet.Q;
237
238  diff(Outlet.Si)  = (Inlet.Si - Outlet.Si)*Inlet.Q/V + Reactions(1);
239
240 diff(Outlet.Ss) = (Inlet.Ss - Outlet.Ss)*Inlet.Q/V +Reactions(2);
241
242  diff(Outlet.Xi )= (Inlet.Xi - Outlet.Xi)*Inlet.Q/V+Reactions(3);
243
244  diff(Outlet.Xs) = (Inlet.Xs - Outlet.Xs)*Inlet.Q/V+Reactions(4);
245
246  diff(Outlet.Xbh) = (Inlet.Xbh - Outlet.Xbh)*Inlet.Q/V+Reactions(5);
247
248  diff(Outlet.Xba) = (Inlet.Xba - Outlet.Xba)*Inlet.Q/V+Reactions(6);
249
250  diff(Outlet.Xp) = (Inlet.Xp - Outlet.Xp)*Inlet.Q/V+Reactions(7);
251
252  diff(Outlet.So) = (Inlet.So - Outlet.So)*Inlet.Q/V+Reactions(8)+ aeration;
253
254  diff(Outlet.Sno )= (Inlet.Sno - Outlet.Sno)*Inlet.Q/V+Reactions(9);
255
256  diff(Outlet.Snh )= (Inlet.Snh - Outlet.Snh)*Inlet.Q/V+Reactions(10);
257
258  diff(Outlet.Snd) = (Inlet.Snd - Outlet.Snd)*Inlet.Q/V+Reactions(11);
259
260  diff(Outlet.Xnd) = (Inlet.Xnd - Outlet.Xnd)*Inlet.Q/V+Reactions(12);
261
262  diff(Outlet.Salk) = (Inlet.Salk - Outlet.Salk)*Inlet.Q/V+Reactions(13);
263
264end
265
266Model NitriTank as ASM1base
267
268ATTRIBUTES
269        Pallete                 = true;
270        Icon            = "icon/nitri";
271        Brief           = "ASM1 nitrification tank.";
272        Info                    =
273"
274This component models the ASM1 processes and reactions taking place in an aerated (nitrification)
275tank of a wastewater treatment plant.
276";
277
278 PARAMETERS
279
280# aeration system dependent parameters
281  alpha                 as Real                                                 (Brief ="Oxygen transfer factor");
282  de                    as length                                               (Brief = "depth of aeration");
283  R_air                 as GeneralFactor                        (Brief="specific oxygen feed factor [gO2/(m^3*m)]");
284 
285        V                       as volume                                       (Brief = "Volume of nitrification tank");
286                Tref            as temperature (Brief = "Temperature dependent Kinetic parameters based on 15 deg C");
287        Tscale  as temperature (Brief = "adimensional temperatura");
288        eps          as MassConcentration       (Brief = "adimensional temperatura");
289        Nrates as Integer;
290Nprocess as Integer;
291SET
292
293        V               =       1000 * 'm^3';
294Tref                    = (15+273)*'K';
295        Tscale          =  1*'K';
296        alpha           = 0.7;
297  de                            = 4.5 *'m';
298  R_air                         = 23.5 *'g/(m^3*m)';
299eps                             = 1e-16*'g/l';
300Nrates=13;
301Nprocess=8;
302
303VARIABLES
304
305in Inlet                as FlowConnector        (Brief = "Tank Inlet Stream", PosX=0, PosY=0.28, Symbol = "^{in}");
306out Outlet      as FlowConnector        (Brief = "Tank Outlet Stream", PosX=1, PosY=0.3, Symbol = "^{out}");
307in AirIn                as AirFlow      (Brief = "Inlet Air Stream", PosX=0.5, PosY=1);
308
309VARIABLES
310
311        T                                                       as temperature;
312        So_sat                                  as MassConcentration    (Brief="Dissolved oxygen saturation");
313        ProcessRates(Nprocess)  as ReacRate                                     (Brief = "Process Rates");
314        Reactions(Nrates)               as ReacRate                             (Brief = "Reactions Rates");
315        aeration                                as ReacRate;
316       
317EQUATIONS
318
319        mu_h = mu_h_T*exp(0.069*(T- Tref)/Tscale);
320        b_h = b_h_T*exp(0.069*(T- Tref)/Tscale);
321        mu_a = mu_a_T*exp(0.098*(T- Tref)/Tscale);
322        b_a = b_a_T*exp(0.08*(T- Tref)/Tscale);
323        k_a = k_a_T*exp(0.069*(T- Tref)/Tscale);
324        k_h = k_h_T*exp(0.11*(T- Tref)/Tscale);
325        K_x = K_x_T*exp(0.11*(T- Tref)/Tscale);
326
327"Temperature dependent oxygen saturation by Simba"
328  So_sat = abs(13.89 + (-0.3825 + (0.007311 - 0.00006588*T)*T)* T);
329 
330" extends the Oxygen differential equation by an aeration term"
331#aeration [mgO2/l]; AirIn.Q_air needs to be in  Simulationtimeunit [m3*day^-1]
332  aeration = (alpha*(So_sat - Outlet.So)/(So_sat+eps)*AirIn.Q_air*R_air*de)/V;
333
334#Process Rates
335        ProcessRates(1) = mu_h*(Outlet.Ss/(K_s + Outlet.Ss+eps))*(Outlet.So/(K_oh + Outlet.So+eps))*Outlet.Xbh;
336        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;
337        ProcessRates(3)  = mu_a*(Outlet.Snh/(K_nh + Outlet.Snh+eps))*(Outlet.So/(K_oa + Outlet.So+eps))*Outlet.Xba;
338        ProcessRates(4)  = b_h*Outlet.Xbh;
339        ProcessRates(5)  = b_a*Outlet.Xba;
340        ProcessRates(6)  = k_a*Outlet.Snd*Outlet.Xbh;
341        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;
342        ProcessRates(8)  = ProcessRates(7)*Outlet.Xnd/(Outlet.Xs+eps);
343
344# biochemical reactions
345 
346        Reactions(1) = 0*'kg/m^3/s';
347        Reactions(2) = (-ProcessRates(1) - ProcessRates(2))/Y_h + ProcessRates(7);
348        Reactions(3) = 0*'kg/m^3/s';
349        Reactions(4) = (1 - f_p)*(ProcessRates(4) + ProcessRates(5)) - ProcessRates(7);
350        Reactions(5) = ProcessRates(1) + ProcessRates(2) - ProcessRates(4);
351        Reactions(6) = ProcessRates(3) - ProcessRates(5);
352        Reactions(7) = f_p*(ProcessRates(4) + ProcessRates(5));
353        Reactions(8) = -((1 - Y_h)/Y_h)*ProcessRates(1)- ((4.57 - Y_a)/Y_a)*ProcessRates(3 );
354        Reactions(9) = -((1 - Y_h)/(2.86*Y_h))*ProcessRates(2 ) + ProcessRates(3 )/Y_a;
355        Reactions(10) = -i_xb*(ProcessRates(1 ) + ProcessRates( 2)) - (i_xb + (1/Y_a))*ProcessRates(3 ) + ProcessRates( 6);
356        Reactions(11) = -ProcessRates( 6) +ProcessRates(8 );
357        Reactions(12) = (i_xb - f_p*i_xp)*(ProcessRates(4 ) + ProcessRates( 5)) - ProcessRates( 8);
358        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;
359 
360Inlet.Q = Outlet.Q;
361
362  diff(Outlet.Si)  = (Inlet.Si - Outlet.Si)*Inlet.Q/V + Reactions(1);
363
364 diff(Outlet.Ss) = (Inlet.Ss - Outlet.Ss)*Inlet.Q/V +Reactions(2);
365
366  diff(Outlet.Xi )= (Inlet.Xi - Outlet.Xi)*Inlet.Q/V+Reactions(3);
367
368  diff(Outlet.Xs) = (Inlet.Xs - Outlet.Xs)*Inlet.Q/V+Reactions(4);
369
370  diff(Outlet.Xbh) = (Inlet.Xbh - Outlet.Xbh)*Inlet.Q/V+Reactions(5);
371
372  diff(Outlet.Xba) = (Inlet.Xba - Outlet.Xba)*Inlet.Q/V+Reactions(6);
373
374  diff(Outlet.Xp) = (Inlet.Xp - Outlet.Xp)*Inlet.Q/V+Reactions(7);
375
376  diff(Outlet.So) = (Inlet.So - Outlet.So)*Inlet.Q/V+Reactions(8)+ aeration;
377
378  diff(Outlet.Sno )= (Inlet.Sno - Outlet.Sno)*Inlet.Q/V+Reactions(9);
379
380  diff(Outlet.Snh )= (Inlet.Snh - Outlet.Snh)*Inlet.Q/V+Reactions(10);
381
382  diff(Outlet.Snd) = (Inlet.Snd - Outlet.Snd)*Inlet.Q/V+Reactions(11);
383
384  diff(Outlet.Xnd) = (Inlet.Xnd - Outlet.Xnd)*Inlet.Q/V+Reactions(12);
385
386  diff(Outlet.Salk) = (Inlet.Salk - Outlet.Salk)*Inlet.Q/V+Reactions(13);
387
388end
389
390Model WWSource
391
392ATTRIBUTES
393        Pallete                 = true;
394        Icon            = "icon/wwSource";
395        Brief           = "Wastewater source.";
396        Info                    =
397"
398This component provides all ASM1 data at the influent of a wastewater treatment plant.
399";
400
401VARIABLES
402
403out Outlet as FlowConnector (Brief="Influent Stream", Symbol = "^{out}", PosX=1, PosY=0.96);
404
405end
406
407Model EffluentSink
408
409ATTRIBUTES
410        Pallete                 = true;
411        Icon            = "icon/wwSink";
412        Brief           = "Wastewater sink.";
413        Info                    =
414"
415This component terminates an ASM1 wastewater treatment plant model e.g. the wastewater
416flow to the receiving water.
417";
418
419VARIABLES
420
421in Inlet as FlowConnector (Brief="Effluent Stream", Symbol = "^{in}", PosX=0, PosY=0.25);
422
423end
424
425Model blower
426
427ATTRIBUTES
428        Pallete                 = true;
429        Icon            = "icon/blower";
430        Brief           = "Blower for the aeration of the nitrification tanks.";
431        Info                    =
432"
433This component models a blower of a wastewater treatment plant which generates
434an airflow that is needed for the nitrification.
435
436*The blower is connected to the nitrification tank.
437
438*The airflow is controlled by a signal u (-1 <= u <= 1).
439";
440
441#PARAMETERS
442
443#Q_max as VolumeFlowRate        (Brief="Maximum blower capacity");
444#Q_min as VolumeFlowRate        (Brief="Minimum blower capacity");
445
446VARIABLES
447
448out AirOut as AirFlow (Brief="Effluent Stream", Symbol = "Air_{out}", PosX=0.45, PosY=0);
449
450end
451
452Model mixer2
453
454ATTRIBUTES
455        Pallete                 = true;
456        Icon            = "icon/mixer2";
457        Brief           = "Mixer of 2 ASM1 characterised flows.";
458        Info                    =
459"
460This component mixes 2 flows of wastewater (ASM1) of different concentration and different amount.
461";
462
463VARIABLES
464
465in      Inlet1          as FlowConnector (Brief="First Inlet Mixer Stream",Symbol = "^{in1}", PosX=0, PosY=0.5);
466in      Inlet2          as FlowConnector (Brief="Second Inlet Mixer Stream",Symbol = "^{in2}", PosX=0, PosY=0.8);
467out     Outlet  as FlowConnector (Brief="Outlet Mixer Stream", Symbol = "^{out}", PosX=1, PosY=0.65);
468
469EQUATIONS
470
471        Inlet1.Q + Inlet2.Q = Outlet.Q;
472       
473  Outlet.Si = (Inlet1.Si*Inlet1.Q + Inlet2.Si*Inlet2.Q )/(Inlet1.Q + Inlet2.Q );
474
475  Outlet.Ss = (Inlet1.Ss*Inlet1.Q + Inlet2.Ss*Inlet2.Q )/(Inlet1.Q + Inlet2.Q );
476
477  Outlet.Xi = (Inlet1.Xi*Inlet1.Q + Inlet2.Xi*Inlet2.Q )/(Inlet1.Q + Inlet2.Q );
478
479  Outlet.Xs = (Inlet1.Xs*Inlet1.Q + Inlet2.Xs*Inlet2.Q )/(Inlet1.Q + Inlet2.Q);
480
481  Outlet.Xbh = (Inlet1.Xbh*Inlet1.Q + Inlet2.Xbh*Inlet2.Q )/(Inlet1.Q + Inlet2.Q );
482
483  Outlet.Xba = (Inlet1.Xba*Inlet1.Q + Inlet2.Xba*Inlet2.Q )/(Inlet1.Q + Inlet2.Q);
484
485  Outlet.Xp = (Inlet1.Xp*Inlet1.Q + Inlet2.Xp*Inlet2.Q )/(Inlet1.Q + Inlet2.Q);
486
487  Outlet.So = (Inlet1.So*Inlet1.Q + Inlet2.So*Inlet2.Q )/(Inlet1.Q + Inlet2.Q);
488
489  Outlet.Sno = (Inlet1.Sno*Inlet1.Q + Inlet2.Sno*Inlet2.Q )/(Inlet1.Q + Inlet2.Q );
490
491  Outlet.Snh = (Inlet1.Snh*Inlet1.Q + Inlet2.Snh*Inlet2.Q )/(Inlet1.Q + Inlet2.Q );
492
493  Outlet.Snd = (Inlet1.Snd*Inlet1.Q + Inlet2.Snd*Inlet2.Q )/(Inlet1.Q + Inlet2.Q);
494
495  Outlet.Xnd = (Inlet1.Xnd*Inlet1.Q + Inlet2.Xnd*Inlet2.Q)/(Inlet1.Q + Inlet2.Q );
496
497  Outlet.Salk = (Inlet1.Salk*Inlet1.Q + Inlet2.Salk*Inlet2.Q )/(Inlet1.Q + Inlet2.Q );
498
499end
500
501Model mixer3
502
503ATTRIBUTES
504        Pallete                 = true;
505        Icon            = "icon/mixer3";
506        Brief           = "Mixer of 3 ASM1 characterised flows.";
507        Info                    =
508"
509This component mixes 3 flows of wastewater (ASM1) of different concentration and different amount.
510";
511
512VARIABLES
513
514in      Inlet1          as FlowConnector (Brief="First Inlet Mixer Stream", Symbol = "^{in1}", PosX=0, PosY=0.4);
515in      Inlet2          as FlowConnector (Brief="Second Inlet Mixer Stream", Symbol = "^{in2}", PosX=0, PosY=0.6);
516in      Inlet3          as FlowConnector (Brief="Third Inlet Mixer Stream", Symbol = "^{in3}", PosX=0, PosY=0.8);
517out     Outlet  as FlowConnector (Brief="Outlet Mixer Stream", Symbol = "^{out}", PosX=1, PosY=0.6);
518
519EQUATIONS
520
521        Inlet1.Q + Inlet2.Q + Inlet3.Q = Outlet.Q;
522       
523  Outlet.Si = (Inlet1.Si*Inlet1.Q + Inlet2.Si*Inlet2.Q + Inlet3.Si*Inlet3.Q)/(Inlet1.Q + Inlet2.Q + Inlet3.Q);
524
525  Outlet.Ss = (Inlet1.Ss*Inlet1.Q + Inlet2.Ss*Inlet2.Q + Inlet3.Ss*Inlet3.Q)/(Inlet1.Q + Inlet2.Q + Inlet3.Q);
526
527  Outlet.Xi = (Inlet1.Xi*Inlet1.Q + Inlet2.Xi*Inlet2.Q + Inlet3.Xi*Inlet3.Q)/(Inlet1.Q + Inlet2.Q + Inlet3.Q);
528
529  Outlet.Xs = (Inlet1.Xs*Inlet1.Q + Inlet2.Xs*Inlet2.Q + Inlet3.Xs*Inlet3.Q)/(Inlet1.Q + Inlet2.Q + Inlet3.Q);
530
531  Outlet.Xbh = (Inlet1.Xbh*Inlet1.Q + Inlet2.Xbh*Inlet2.Q + Inlet3.Xbh*Inlet3.Q)/(Inlet1.Q + Inlet2.Q + Inlet3.Q);
532
533  Outlet.Xba = (Inlet1.Xba*Inlet1.Q + Inlet2.Xba*Inlet2.Q + Inlet3.Xba*Inlet3.Q)/(Inlet1.Q + Inlet2.Q + Inlet3.Q);
534
535  Outlet.Xp = (Inlet1.Xp*Inlet1.Q + Inlet2.Xp*Inlet2.Q + Inlet3.Xp*Inlet3.Q)/(Inlet1.Q + Inlet2.Q + Inlet3.Q);
536
537  Outlet.So = (Inlet1.So*Inlet1.Q + Inlet2.So*Inlet2.Q + Inlet3.So*Inlet3.Q)/(Inlet1.Q + Inlet2.Q + Inlet3.Q);
538
539  Outlet.Sno = (Inlet1.Sno*Inlet1.Q + Inlet2.Sno*Inlet2.Q + Inlet3.Sno*Inlet3.Q)/(Inlet1.Q + Inlet2.Q + Inlet3.Q);
540
541  Outlet.Snh = (Inlet1.Snh*Inlet1.Q + Inlet2.Snh*Inlet2.Q + Inlet3.Snh*Inlet3.Q)/(Inlet1.Q + Inlet2.Q + Inlet3.Q);
542
543  Outlet.Snd = (Inlet1.Snd*Inlet1.Q + Inlet2.Snd*Inlet2.Q + Inlet3.Snd*Inlet3.Q)/(Inlet1.Q + Inlet2.Q + Inlet3.Q);
544
545  Outlet.Xnd = (Inlet1.Xnd*Inlet1.Q + Inlet2.Xnd*Inlet2.Q + Inlet3.Xnd*Inlet3.Q)/(Inlet1.Q + Inlet2.Q + Inlet3.Q);
546
547  Outlet.Salk = (Inlet1.Salk*Inlet1.Q + Inlet2.Salk*Inlet2.Q + Inlet3.Salk*Inlet3.Q)/(Inlet1.Q + Inlet2.Q + Inlet3.Q);
548
549end
550
551Model wwPump
552
553ATTRIBUTES
554        Pallete                 = true;
555        Icon            = "icon/pump";
556        Brief           = "ASM1 wastewater pump.";
557        Info                    =
558"
559This component models an ASM1 wastewater pump. It generates a wastewater flow
560that is controlled by the signal u (-1 <= u <=1).
561";
562
563PARAMETERS
564
565Q_min as VolumeFlowRate (Brief="minimum pump capacity", Symbol = "Q_{min}", Default = 0);
566Q_max as VolumeFlowRate (Brief="maximum pump capacity", Symbol = "Q_{max}", Default = 20000);
567
568VARIABLES
569
570in               Inlet          as FlowConnector        (Brief="Inlet Stream", Symbol = "^{in}", PosX=0, PosY=0.75);
571out      Outlet         as FlowConnector        (Brief="Outlet Stream", Symbol = "^{out}", PosX=1, PosY=0.4);
572
573EQUATIONS
574
575        Outlet.Q                = Inlet.Q;
576        Outlet.Si       = Inlet.Si;
577        Outlet.Ss       = Inlet.Ss;
578        Outlet.Xi       = Inlet.Xi;
579        Outlet.Xs       = Inlet.Xs;
580        Outlet.Xbh = Inlet.Xbh;
581        Outlet.Xba = Inlet.Xba;
582        Outlet.Xp       = Inlet.Xp;
583        Outlet.So       = Inlet.So;
584        Outlet.Sno      = Inlet.Sno;
585        Outlet.Snh      = Inlet.Snh;
586        Outlet.Snd      = Inlet.Snd;
587        Outlet.Xnd      = Inlet.Xnd;
588        Outlet.Salk = Inlet.Salk;
589
590end
591
592Model divider2
593
594ATTRIBUTES
595        Pallete                 = true;
596        Icon            = "icon/divider2";
597        Brief           = "Flow divider.";
598        Info                    =
599"
600This component divides one ASM1 wastewater flow into two ASM1 wastewater flows.
601";
602PARAMETERS
603
604Frac_1 as fraction;
605
606SUBMODELS
607
608in               Inlet          as FlowConnector        (Brief="Inlet Stream", Symbol = "^{in}", PosX=0, PosY=0.65);
609out      Outlet1        as FlowConnector        (Brief="First Outlet Stream", Symbol = "^{out1}", PosX=1, PosY=0.45);
610out      Outlet2        as FlowConnector        (Brief="Second Outlet Stream", Symbol = "^{out2}", PosX=1, PosY=0.8);
611
612EQUATIONS
613 
614  Inlet.Q = Outlet1.Q + Outlet2.Q;
615 Outlet1.Q = Inlet.Q*Frac_1;
616 
617  Outlet1.Si = Inlet.Si;
618  Outlet1.Ss = Inlet.Ss;
619  Outlet1.Xi = Inlet.Xi;
620  Outlet1.Xs = Inlet.Xs;
621  Outlet1.Xbh = Inlet.Xbh;
622  Outlet1.Xba = Inlet.Xba;
623  Outlet1.Xp = Inlet.Xp;
624  Outlet1.So = Inlet.So;
625  Outlet1.Sno = Inlet.Sno;
626  Outlet1.Snh = Inlet.Snh;
627  Outlet1.Snd = Inlet.Snd;
628  Outlet1.Xnd = Inlet.Xnd;
629  Outlet1.Salk = Inlet.Salk;
630 
631  Outlet2.Si = Inlet.Si;
632  Outlet2.Ss = Inlet.Ss;
633  Outlet2.Xi = Inlet.Xi;
634  Outlet2.Xs = Inlet.Xs;
635  Outlet2.Xbh = Inlet.Xbh;
636  Outlet2.Xba = Inlet.Xba;
637  Outlet2.Xp = Inlet.Xp;
638  Outlet2.So = Inlet.So;
639  Outlet2.Sno = Inlet.Sno;
640  Outlet2.Snh = Inlet.Snh;
641  Outlet2.Snd = Inlet.Snd;
642  Outlet2.Xnd = Inlet.Xnd;
643  Outlet2.Salk = Inlet.Salk;
644
645end
646
647Model secRatios
648
649ATTRIBUTES
650        Pallete                 = false;
651        Brief           = "partial model for ratios of solid components";
652        Info                    =
653"partial model for ASM1 ratios of solid components.
654";
655
656VARIABLES
657# ratios of solid components
658  rXi as Real;
659  rXs as Real;
660  rXbh as Real;
661  rXba as Real;
662  rXp as Real;
663  rXnd as Real;
664
665end
666
667Model secParam
668
669ATTRIBUTES
670        Pallete                 = false;
671        Brief           = "partial model providing clarifier parameters.";
672        Info                    =
673"partial model providing clarifier parameters.
674";
675
676PARAMETERS
677
678zm as length;
679Asc as area;
680
681end
682
683Model secVar
684
685ATTRIBUTES
686        Pallete                 = false;
687        Brief           = "partial models providing variables.";
688        Info                    =
689"partial models providing ASM1 variables.
690";
691
692VARIABLES
693
694        Si              as MassConcentration            (Brief="Soluble inert organic matter");
695        Ss              as MassConcentration            (Brief="Readily biodegradable substrate");
696        So              as MassConcentration            (Brief="Dissolved oxygen");
697        Sno             as MassConcentration            (Brief="Nitrate and nitrite nitrogen");
698        Snh             as MassConcentration            (Brief="Ammonium nitrogen");
699        Snd             as MassConcentration            (Brief="Soluble biodegradable organic nitrogen");
700        Salk    as Alkalinity                                           (Brief="Alkalinity");
701
702        X       as MassConcentration            (Brief="total sludge concentration in m-th layer");
703        Xf      as MassConcentration            (Brief="total sludge concentration in clarifier feed");
704        vS      as SedimentationVelocity (Brief="sink velocity in m-th layer");
705        Jsm     as SedimentationFlux            (Brief="sedimentation flux m-th layer");
706
707end
708
709Model LowerLayerPin
710
711ATTRIBUTES
712        Pallete                 = false;
713        Brief           = "Connector below influent layer.";
714        Info                    =
715"Connector for ASM1 information and mass exchange between layers below the influent layer (feed_layer).
716";
717
718VARIABLES
719
720        Qr as VolumeFlowRate;
721        Qw as VolumeFlowRate;
722
723SedFlux as SedimentationFlux ;
724 
725# total sludge concentration in m-th layer
726        X as MassConcentration;
727 
728# total sludge concentration and sink velocity in(m-1)-th layer (dn=down)
729        X_dn    as MassConcentration;
730        vS_dn   as SedimentationVelocity;
731 
732        Si              as MassConcentration            (Brief="Soluble inert organic matter");
733        Ss              as MassConcentration            (Brief="Readily biodegradable substrate");
734        So              as MassConcentration            (Brief="Dissolved oxygen");
735        Sno             as MassConcentration            (Brief="Nitrate and nitrite nitrogen");
736        Snh             as MassConcentration            (Brief="Ammonium nitrogen");
737        Snd             as MassConcentration            (Brief="Soluble biodegradable organic nitrogen");
738        Salk    as Alkalinity                                           (Brief="Alkalinity");
739
740end
741
742Model UpperLayerPin
743
744ATTRIBUTES
745        Pallete                 = false;
746        Brief           = "Connector below influent layer.";
747        Info                    =
748"Connector for ASM1 information and mass exchange between layers below the influent layer (feed_layer).
749";
750
751VARIABLES
752
753        Qe as VolumeFlowRate;
754
755SedFlux as SedimentationFlux ;
756 
757# total sludge concentration and sink velocity in(m-1)-th layer (dn=down)
758        X_dn    as MassConcentration;
759        vS_dn   as SedimentationVelocity;
760 
761        Si              as MassConcentration            (Brief="Soluble inert organic matter");
762        Ss              as MassConcentration            (Brief="Readily biodegradable substrate");
763        So              as MassConcentration            (Brief="Dissolved oxygen");
764        Sno             as MassConcentration            (Brief="Nitrate and nitrite nitrogen");
765        Snh             as MassConcentration            (Brief="Ammonium nitrogen");
766        Snd             as MassConcentration            (Brief="Soluble biodegradable organic nitrogen");
767        Salk    as Alkalinity                                           (Brief="Alkalinity");
768
769end
770
771Model clarifier
772
773ATTRIBUTES
774        Pallete                 = true;
775        Icon                            ="icon/clarifier";
776        Brief                   = "Simple ASM1 Secondary Clarifier Model";
777        Info                    =
778"This component models very simple the secondary clarification process by
779just using a single fully mixed tank which removes all particulate substances from the effluent
780and returns the sludge. No sedimentation and compression, etc. is considered (for ASM1).
781";
782
783PARAMETERS
784eps     as MassConcentration            (Brief="eps",Default = 1e-11);
785VARIABLES
786  in            Feed as FlowConnector           (Brief = "Feed Stream", Symbol = "^{Feed}", PosX=0, PosY=0.4);
787  out   Effluent as FlowConnector       (Brief = "Effluent Stream", Symbol = "^{Eff}", PosX=1, PosY=0.2);
788  out   Return as FlowConnector         (Brief = "Return Stream", Symbol = "^{Return}", PosX=0.4, PosY=1);
789  out   Waste as FlowConnector          (Brief = "Waste Stream", Symbol = "^{Waste}", PosX=0.6, PosY=1);
790
791 rXi as Real (Lower=-1e-10);
792  rXs as Real(Lower=-1e-10);
793  rXbh as Real(Lower=-1e-10);
794  rXba as Real(Lower=-1e-10);
795  rXp as Real(Lower=-1e-10);
796  rXnd as Real(Lower=-1e-10);
797
798        Si              as MassConcentration            (Brief="Soluble inert organic matter");
799        Ss              as MassConcentration            (Brief="Readily biodegradable substrate");
800        So              as MassConcentration            (Brief="Dissolved oxygen");
801        Sno             as MassConcentration            (Brief="Nitrate and nitrite nitrogen");
802        Snh             as MassConcentration            (Brief="Ammonium nitrogen");
803        Snd             as MassConcentration            (Brief="Soluble biodegradable organic nitrogen");
804        Salk    as Alkalinity                                           (Brief="Alkalinity");
805        X       as MassConcentration            (Brief="sludge concentration in clarifier");
806        Xf      as MassConcentration            (Brief="total sludge concentration in clarifier feed");
807       
808PARAMETERS
809        hsc             as length;
810        Asc             as area;
811FracReturn as fraction;
812FracWaste as fraction;
813SET
814
815hsc=4.0 *'m';
816Asc=1500.0*'m^2';
817
818EQUATIONS
819" total sludge concentration in clarifier feed"
820  Xf = 0.75*(Feed.Xs + Feed.Xbh + Feed.Xba + Feed.Xp + Feed.Xi);
821 
822" ratios of solid components"
823  rXs*Xf = Feed.Xs;
824  rXbh*Xf = Feed.Xbh;
825  rXba*Xf = Feed.Xba;
826  rXp*Xf = Feed.Xp;
827  rXi*Xf = Feed.Xi;
828  rXnd*Xf = Feed.Xnd;
829
830" ODE of sludge concentration"
831  diff(X) = (Feed.Q*Xf - (-(Waste.Q + Return.Q))*X)/(Asc*hsc);
832
833" ODE of soluble components"
834  diff(Si) = (Feed.Q*Feed.Si - (-Effluent.Q)*Si - (-(Waste.Q + Return.Q))*Si)/(Asc*hsc);
835  diff(Ss) = (Feed.Q*Feed.Ss - (-Effluent.Q)*Ss - (-(Waste.Q + Return.Q))*Ss)/(Asc*hsc);
836  diff(So) = (Feed.Q*Feed.So - (-Effluent.Q)*So - (-(Waste.Q + Return.Q))*So)/(Asc*hsc);
837  diff(Sno) = (Feed.Q*Feed.Sno - (-Effluent.Q)*Sno - (-(Waste.Q + Return.Q))*Sno)/(Asc*hsc);
838  diff(Snh) = (Feed.Q*Feed.Snh - (-Effluent.Q)*Snh - (-(Waste.Q + Return.Q))*Snh)/(Asc*hsc);
839  diff(Snd) = (Feed.Q*Feed.Snd - (-Effluent.Q)*Snd - (-(Waste.Q + Return.Q))*Snd)/(Asc*hsc);
840  diff(Salk) = (Feed.Q*Feed.Salk - (-Effluent.Q)*Salk - (-(Waste.Q + Return.Q))* Salk)/(Asc*hsc);
841 
842" volume flow rates"
843  Feed.Q = Effluent.Q + Return.Q + Waste.Q;
844  Return.Q = Feed.Q*FracReturn;
845Waste.Q = Feed.Q*FracWaste;
846
847"effluent, solid and soluble components (ASM1)"
848  Effluent.Si = Si;
849  Effluent.Ss = Ss;
850  Effluent.Xi = 0.0*X;
851  Effluent.Xs = 0.0*X;
852  Effluent.Xbh = 0.0*X;
853  Effluent.Xba = 0.0*X;
854  Effluent.Xp = 0.0*X;
855  Effluent.So = So;
856  Effluent.Sno = Sno;
857  Effluent.Snh = Snh;
858  Effluent.Snd = Snd;
859  Effluent.Xnd = 0.0*X;
860  Effluent.Salk = Salk;
861 
862"return sludge flow, solid and soluble components (ASM1)"
863  Return.Si = Si;
864  Return.Ss = Ss;
865  Return.Xi = rXi*X;
866  Return.Xs = rXs*X;
867  Return.Xbh = rXbh*X;
868  Return.Xba = rXba*X;
869  Return.Xp = rXp*X;
870  Return.So = So;
871  Return.Sno = Sno;
872  Return.Snh = Snh;
873  Return.Snd = Snd;
874  Return.Xnd = rXnd*X;
875  Return.Salk = Salk;
876 
877" waste sludge flow, solid and soluble components (ASM1)"
878  Waste.Si = Si;
879  Waste.Ss = Ss;
880  Waste.Xi = rXi*X;
881  Waste.Xs = rXs*X;
882  Waste.Xbh = rXbh*X;
883  Waste.Xba = rXba*X;
884  Waste.Xp = rXp*X;
885  Waste.So = So;
886  Waste.Sno = Sno;
887  Waste.Snh = Snh;
888  Waste.Snd = Snd;
889  Waste.Xnd = rXnd*X;
890  Waste.Salk = Salk;
891
892end
893
894Model sludge
895
896ATTRIBUTES
897        Pallete                 = true;
898        Icon            = "icon/sludge";
899        Brief           = "to be documented.";
900        Info                    =
901"
902none
903";
904
905VARIABLES
906
907in Inlet as FlowConnector (Brief="Influent Stream", Symbol = "^{in}", PosX=0, PosY=0.5);
908
909end
Note: See TracBrowser for help on using the repository browser.