source: trunk/BioModel/reactors/digester.mso @ 1008

Last change on this file since 1008 was 1008, checked in by Argimiro Resende Secchi, 21 months ago

Adding BioModel? to the MSO library.

File size: 14.9 KB
Line 
1#*-------------------------------------------------------------------
2* Biorrefinaria Petrobras
3*--------------------------------------------------------------------
4* Nome do arquivo: digester.mso
5* Projeto: Modelo integrado de producao de etanol 1G/2G
6* Conteudo: biodigestor de vinhaca e/ou xilose
7*--------------------------------------------------------------------*#
8
9#*-------------------------------------------------------------------
10*
11* Versao 2.3
12* Autores:   Anderson R. A. Lino e Gabriel C. Fonseca
13* Data:    03/2016
14* Adpatacao: Andreza A Longati
15* Data:    09/2018
16*
17*--------------------------------------------------------------------
18*Descricao: modelo do tanque de biodigestao que sera empregado
19*na biorrefinaria
20*--------------------------------------------------------------------
21
22*--------------------------------------------------------------------
23*Hipoteses assumidas: 1 - estatico
24*                     2 - adiabatico
25*--------------------------------------------------------------------
26
27*--------------------------------------------------------------------
28*Notas: Foi feito o flowsheet teste para averiguar o modelo
29*--------------------------------------------------------------------*#
30
31using "main_stream";
32using "assumptions";
33
34Model digester_generic
35       
36        ATTRIBUTES
37        Pallete         = true;
38        Icon            = "icon/digester";
39        Brief           = "Model of an anaerobic digester";
40        Info            =
41"== GENERAL ==
42        Model of an anaerobic digester. The reactions specified should
43        represent the removal of COD, without producing anything. The
44        biomass and biogas produced are based on the amount of COD in
45        the inlet or the removed COD.
46
47== ASSUMPTIONS ==
48* All three-phases are involved;
49* Steady-state.
50* Outlet temperatures are equal to the Inlet
51
52== SPECIFY ==
53* The inlet streams:
54  flow rate
55  temperature
56  pressure
57  stream composition;
58* Conversion for each reaction;
59* Hydraulic retention time (HRT), cell retention time (CRT) or load rate (loadRate);
60* Sludge humidity;
61* Cell production (Yxs) or methane production (Yps).
62
63== SET ==
64* Chemical Oxygen Demand for each compound (COD);
65* Number of reactions (NReac);
66* Stoichiometric matrix (stoic);
67* Limiting reagent for each reaction (limit);
68* The position in the compound vector of the water (NWater), the
69        cells (NCell), the CO2 (NCO2) and the methane (NCH4);
70* Methane molar fraction in the biogas (CH4frac);
71* Inlet density (dens_in);
72* Outlet density (dens_out);
73* Sludge density (dens_sludge);
74* Basic composition (mass or molar);
75* Number of stream components(Ncomp/NcompS).
76";
77
78#*-------------------------------------------------------------------
79#Parametros
80*--------------------------------------------------------------------*#
81
82        PARAMETERS
83       
84outer   PP                      as Plugin               (Brief = "External Physical Properties (Fluid Phase)", Type="PP");
85outer   PPS             as Plugin               (Brief = "External Physical Properties (Solid Phase)", Type="PP");
86outer   NComp           as Integer              (Brief = "Number of Chemical Components for the Fluid Phase", Lower = 1);
87outer   NCompS          as Integer              (Brief = "Number of Chemical Components for the Solid Phase", Lower = 1);
88outer   flu as ConstituentFluid         (Symbol = " ", Protected = true);
89outer   sol as ConstituentSolid         (Symbol = " ", Protected = true);
90                M(NComp)        as molweight    (Brief = "Component Mol Weight (Fluid Phase), Vector Size = NComp", Protected=true, Hidden=true);
91                MS(NCompS)  as molweight        (Brief = "Component Mol Weight (Solid Phase), Vector Size = NCompS", Protected=true, Hidden=true);
92               
93        COD(NComp + NCompS)                     as molweight    (Brief = "Chemical Oxygen Demand of each compound in the inlet stream");
94        NReac                                                   as Integer              (Brief = "Number Of Reactions", Default = 1);
95        stoic(NComp + NCompS, NReac)    as Real                 (Brief = "Stoichiometric Matrix, Matrix Size = NComp+NCompS, NReac");
96        limit(NReac)                                    as Integer              (Brief = "Limiting Compound Index Number, Vector Size = NReac", Lower = 1);
97        CH4frac                         as fraction             (Brief = "CH4 fraction in the biogas", Default = 0.6);
98        dens_in                         as dens_mass    (Brief = "Inlet Stream Density", Default = 1000);
99        dens_out                        as dens_mass    (Brief = "Outlet Liquid Stream Density", Default = 1000);
100        dens_sludge                     as dens_mass    (Brief = "Oultet Solid Stream Density", Default = 1000);
101
102
103       
104#*-------------------------------------------------------------------
105* Declaracao de variaveis
106*--------------------------------------------------------------------*#
107
108        VARIABLES
109in      Inlet                   as main_stream          (Brief = "Inlet Stream", PosX=0, PosY=0.5, Symbol="_{in}", Protected = false);
110        Inter                   as main_stream_eq       (Brief = "Intermediate Stream", Protected = true);
111out     Outlet                  as main_stream_eq       (Brief = "Outlet Stream", PosX=1.0, PosY=0.5, Symbol="_{outL}", Protected = false);
112out     Gas                     as main_stream_eq       (Brief = "Outlet Gas Stream", PosX=0.5, PosY=0, Symbol="_{outG}", Protected = false);
113out Sludge                      as main_stream_eq       (Brief = "Outlet Sludge Stream", PosX=0.5, PosY=1, Symbol = "_{outS}");
114       
115        r(NComp + NCompS, NReac)        as Real                 (Brief = "Ratio between component (i) production/consumption for the limiting component, Matrix Size = NComp+NCompS, NReac");
116        conv(NReac)                                     as fraction             (Brief = "Reaction Conversion Based on Limiting Component, Vector Size = NReac", Symbol = "X");
117       
118        COD_in                  as conc_mass (Brief = "Chemical Oxygen Demand of the Inlet Stream");
119        COD_out                 as conc_mass (Brief = "Chemical Oxygen Demand of the Outlet Liquid Stream");
120        COD_removed             as flow_mass (Brief = "Chemical Oxygen Demand Removed");
121       
122        HRT                             as time_h       (Brief = "Hydraulic Retention Time");
123        CRT                             as time_h       (Brief = "Cell Retention Time");
124       
125        loadRate                as Real         (Brief = "Chemical Oxygen Demand Load Rate", Unit = 'kg/m^3/d'); #pode chegar a 45 kg/m^3, mas o recomendado eh 15
126        sludgeRate              as Real         (Brief = "Chemical Oxygen Demand Load Rate (Cell Mass Basis)", Unit = '1/h'); #ate 0.0833 1/h
127       
128        V                               as volume       (Brief = "Reactor Volume", Upper = 1e5);
129        Cmicro                  as conc_mass(Brief = "Microorganisms Concentration in the Reactor");
130        Yxs                             as positive     (Brief = "Solid Production Coefficient"); #deve ser entre 0.1 e 0.2
131        Yps                             as volume_mass  (Brief = "CH4 Production Ratio (Removed COD Basis)"); #melhorar essa nomenclatura
132       
133        sludgeHumidity  as fraction (Brief = "Sludge Humidity"); #deve ser entre 0.95 e 0.97
134       
135        SET
136        Outlet.Phase = "Liquid";
137        Gas.Phase = "Vapour";
138        Sludge.Phase = "Liquid";
139        Inter.Phase = "Liquid";
140       
141#*-------------------------------------------------------------------
142* Equacoes do modelo
143*--------------------------------------------------------------------*#
144
145        EQUATIONS
146       
147        "Mass Balance"
148        Inlet.Total.Fw = Outlet.Total.Fw + Sludge.Total.Fw + Gas.Total.Fw;
149       
150        "Ratio between component (i) production/consumption for the limiting component"
151        r(1:NComp+NCompS,:) = stoic(1:NComp+NCompS,:) * conv * Inlet.Total.z(limit);
152       
153        if (NReac equal 1) then
154                "Component Molar Balance (Fluid Phase)"
155                Inter.Fluid.F * Inter.Fluid.z(1:NComp) = Inlet.Fluid.F * Inlet.Fluid.z(1:NComp) + Inlet.Total.F * r(1:NComp,1);
156       
157                "Component Molar Balance (Solid Phase)"
158                Inter.Solid.F * Inter.Solid.z(1:NCompS) = Inlet.Solid.F * Inlet.Solid.z(1:NCompS) + Inlet.Total.F * r(NComp+1:NComp+NCompS,1);
159        else
160                "Component Molar Balance (Fluid Phase)"
161                Inter.Fluid.F * Inter.Fluid.z(1:NComp) = Inlet.Fluid.F * Inlet.Fluid.z(1:NComp) + Inlet.Total.F * sumt(r(1:NComp,:));
162       
163                "Component Molar Balance (Solid Phase)"
164                Inter.Solid.F * Inter.Solid.z(1:NCompS) = Inlet.Solid.F * Inlet.Solid.z(1:NCompS) + Inlet.Total.F * sumt(r(NComp+1:NComp+NCompS, :));   
165        end
166       
167        for i in [1:NComp] do
168                if i equal flu.Water then
169                        "Mass Balance for the Decanter Part"
170                        Inter.Fluid.F * Inter.Fluid.z(i) = Outlet.Fluid.F * Outlet.Fluid.z(i) + Sludge.Fluid.F * Sludge.Fluid.z(i);
171                       
172                        "Only Water is Present in the Fluid Phase of the Sludge"
173                        Sludge.Fluid.z(i) = 1;
174                else
175                        "Mass Balance for the Decanter Part"
176                        Inter.Fluid.F * Inter.Fluid.z(i) = Outlet.Fluid.F * Outlet.Fluid.z(i);
177                       
178                        "Only Water is Present in the Fluid Phase of the Sludge"
179                        Sludge.Fluid.z(i) = 0;
180                end
181        end
182       
183        "Sum of Molar Fractions (Solid Phase)"
184        sum(Outlet.Solid.z) = 1;
185       
186        "Sum of Molar Fractions (Fluid Phase)"
187        sum(Outlet.Fluid.z) = 1;
188       
189        "No Cells Are Lost in This Stream"
190        Outlet.Solid.z(sol.Yeast) = 0;
191       
192        "Sum of Molar Fractions (Fluid Phase)"
193        sum(Inter.Fluid.z) = 1;
194       
195        "Sum of Molar Fractions (Solid Phase)"
196        sum(Inter.Solid.z) = 1;
197       
198        for i in [1:NCompS] do
199                if i equal sol.Yeast then
200                        "Cell Growth"
201                        Inter.Solid.Fw * Inter.Solid.zw(i) + Yxs * COD_in * Inlet.Total.Fw / dens_in = Sludge.Solid.Fw * Sludge.Solid.zw(i);
202                       
203                        "Only Cell is Present in the Solid Outlet"
204                        Sludge.Solid.zw(i) = 1;
205                else
206                        "Component Mass Balance (Solid Phase)"
207                        Inter.Solid.Fw * Inter.Solid.zw(i) = Outlet.Solid.Fw * Outlet.Solid.zw(i);
208                       
209                        "Only Cell is Present in the Solid Outlet"
210                        Sludge.Solid.zw(i) = 0;
211                end
212        end
213       
214        for i in [1:NComp] do
215                if i equal flu.CH4 then
216                        "Biogas Composition"
217                        Gas.Fluid.z(i) = CH4frac;
218                else if i equal flu.CO2 then
219                        "Biogas Composition"
220                        Gas.Fluid.z(i) = 1 - CH4frac;
221                else
222                        "Biogas Composition"
223                        Gas.Fluid.z(i) = 0;
224                end
225                end
226        end
227       
228        "Outlet Gas Composition (Solid Phase)"
229        Gas.Solid.z = Inlet.Solid.z;
230       
231        "Methane Production"
232        Gas.Fluid.F * Gas.Fluid.z(flu.CH4) = Yps / (22.7 * 'l/mol') * COD_removed;
233       
234        "Sludge Humidity"
235        sludgeHumidity * Sludge.Total.Fw = Sludge.Fluid.Fw;
236       
237        "Hydraulic Retention Time" #tempo de detencao hidraulica
238        HRT * Inlet.Total.Fw = V * dens_in;
239       
240        "Cell Retention Time"
241        CRT * Sludge.Total.Fw = V * dens_sludge;
242       
243        "Chemical Oxygen Demand of the Inlet Stream" #demanda quimica de oxigenio da entrada
244        COD_in * Inlet.Total.Fw = sum(COD * Inlet.Total.z) * Inlet.Total.F * dens_in;
245
246        "Chemical Oxygen Demand of the Inlet Stream" #demanda quimica de oxigenio da saida
247        COD_out * Outlet.Total.Fw = sum(COD * Outlet.Total.z) * Outlet.Total.F * dens_out;
248       
249        "Chemical Oxygen Demand removed"
250        COD_removed = COD_in * Inlet.Total.Fw / dens_in - COD_out * Outlet.Total.Fw / dens_out;
251       
252        "Load Rate" #carga organica volumetrica
253        loadRate * V * dens_in = Inlet.Total.Fw * COD_in;
254       
255        "Sludge Rate" #carga biologica
256        sludgeRate * Cmicro * V * dens_in = Inlet.Total.Fw * COD_in;
257       
258        "Microorganisms Concentration in the Reactor"
259        Cmicro * (Sludge.Total.Fw / dens_sludge + Outlet.Total.Fw / dens_out) = Sludge.Solid.Fw;
260       
261        "Outlet Gas Flow (Solid Phase)"
262        Gas.Solid.F = 1e-6 * 'kmol/h';
263
264        "Mechanical Equilibrium 1"
265        Inter.P = Inlet.P;
266       
267        "Thermal Equilibrium 1"
268        Inter.T = Inlet.T;
269       
270        "Mechanical Equilibrium 2"
271        Inter.P = Outlet.P;
272       
273        "Thermal Equilibrium 2"
274        Inter.T = Outlet.T;
275       
276        "Mechanical Equilibrium 3"
277        Inter.P = Sludge.P;
278       
279        "Thermal Equilibrium 3"
280        Inter.T = Sludge.T;
281       
282        "Mechanical Equilibrium 4"
283        Inter.P = Gas.P;
284       
285        "Thermal Equilibrium 4"
286        Inter.T = Gas.T;
287
288end
289
290FlowSheet teste_digester_Generic
291       
292#*-------------------------------------------------------------------
293* Declaracao de dispositivos (ou blocos contendo o modelo)
294*--------------------------------------------------------------------*#
295
296        DEVICES
297        S101 as main_sourceR;
298        E101 as digester_generic;
299       
300#*-------------------------------------------------------------------
301* Especifica as conexoes entre os modelos
302*--------------------------------------------------------------------*#
303       
304        CONNECTIONS
305        S101.Outlet to E101.Inlet;
306       
307#*-------------------------------------------------------------------
308* Especifica variaveis definidas no modelo
309*--------------------------------------------------------------------*#
310       
311        SPECIFY
312        S101.Solid.F = 1 * 'kmol/h';
313        S101.Fluid.F = 9580.18 * 'kmol/h';
314        S101.T = 353.15 * 'K';
315        S101.P = 1 * 'bar';
316        S101.CompositionOfFluid = [0.982, 0, 0.00045, 0.00186, 0, 0, 0, 0, 0, 0, 0, 0.00037, 0.000477, 0, 0.000740, 0.000156, 0, 0, 0.0138, 0, 0, 0, 0, 0, 0];
317        S101.CompositionOfSolid = [0.551, 0.0750, 0.2623, 0.1117, 0, 0, 0, 0, 0];
318       
319        E101.conv = [0.72, 0.72, 0.72, 0.72, 0.72, 0.72, 0.72, 0.72, 0.72, 0.72];
320       
321        #especificar um dos dois. O primeiro para baixas DQO de entrada e o segundo para altas.
322        E101.HRT = 10.8 * 'h';
323        E101.sludgeHumidity = 0.97;
324        E101.Yps = 0.29 * 'l/g';
325       
326#*-------------------------------------------------------------------
327#Parametros
328*--------------------------------------------------------------------*#
329       
330        PARAMETERS
331        PP as Plugin    (Brief = "External Physical Properties",
332                Type="PP",
333                Project = "../Flowsheets/v2_2/Fluid_v2_2.vrtherm"
334        );
335        PPS as Plugin   (Brief = "External Physical Properties",
336                Type="PP",
337                Project = "../Flowsheets/v2_2/Solid_v2_2.vrtherm"
338        );
339       
340        NComp   as Integer      (Brief = "Number of chemical components in the fluid phase");
341        NCompS  as Integer      (Brief = "Number of chemical components in the solid phase");
342        flu as ConstituentFluid(Symbol = " ", Protected = true);
343        sol as ConstituentSolid(Symbol = " ", Protected = true);
344       
345#*-------------------------------------------------------------------
346* Define o valor dos parametros declarados no modelo
347*--------------------------------------------------------------------*#
348       
349        SET
350        NComp = PP.NumberOfComponents();
351        NCompS = PPS.NumberOfComponents();
352        S101.CompositionBasis = "Molar";
353       
354        E101.COD = [0, 384, 192, 160, 96, 0, 0, 0, 0, 0, 64, 8, 366.4, 0, 64, 160, 192, 112, 16, 0, 0, 0, 0, 0, 0, 192, 160, 366.4, 0, 39.824, 32, 0, 0, 0] * 'g/mol';
355       
356        #anaerobic reactor
357        E101.NReac = 10;
358        #Sucrose
359        E101.stoic (:,1) = [0, -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0];
360        #glucose
361        E101.stoic (:,2) = [0, 0, -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0];
362        #xylose
363        E101.stoic (:,3) = [0, 0, 0, -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0];
364        #ethanol
365        E101.stoic (:,4) = [0, 0, 0, 0, -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0];
366        #acetic acid
367        E101.stoic (:,5) = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0];
368        #furfural
369        E101.stoic (:,6) = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0];
370        #5-HMF
371        E101.stoic (:,7) = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0];
372        #glycerol
373        E101.stoic (:,8) = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0];
374        #solunkn
375        E101.stoic (:,9) = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0];
376        #lignin_sol
377        E101.stoic (:,10) = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0];
378        E101.limit = [2, 3, 4, 5, 15, 16, 17, 18, 19, 13];
379       
380#*-------------------------------------------------------------------
381* Condicoes iniciais e opcoes de Solver
382*--------------------------------------------------------------------*#
383       
384        OPTIONS
385        Dynamic = false;
386end
387
Note: See TracBrowser for help on using the repository browser.