source: branches/gasifier/simplified_gasifier.mso @ 976

Last change on this file since 976 was 748, checked in by Rodolfo Rodrigues, 15 years ago

Initial import of the simplified gasifier model

File size: 19.7 KB
Line 
1#*---------------------------------------------------------------------
2* EMSO Model Library (EML) Copyright (C) 2004 - 2009 ALSOC.
3*
4* This LIBRARY is free software; you can distribute it and/or modify
5* it under the therms of the ALSOC FREE LICENSE as available at
6* http://www.enq.ufrgs.br/alsoc.
7*
8* EMSO Copyright (C) 2004 - 2009 ALSOC, original code
9* from http://www.rps.eng.br Copyright (C) 2002-2004.
10* All rights reserved.
11*
12* EMSO is distributed under the therms of the ALSOC LICENSE as
13* available at http://www.enq.ufrgs.br/alsoc.
14*
15*----------------------------------------------------------------------
16* Equilibrium modeling of a biomass gasifier
17*----------------------------------------------------------------------
18*
19*   Description:
20*       Thermodynamic equilibrium modeling of a biomass gasifier.
21*
22*   Assumptions:
23*       * thermodynamic equilibrium
24*               * steady-state
25*               * ideal gas relations
26*               * ambient and atmospheric input conditions (To,Po)
27*               * global gasification reaction:
28*                       CHONS + H2O + Air -> CO + CO2 + CH4 + H2
29*                               + H2O + O2 + N2 + SO2
30*               * all oxygen is consumed in the process
31*
32*       Specify:
33*               * ultimate biomass analysis (dry.massfrac)
34*               * moisture biomass ratio (moisture.massfrac)
35*               * equivalence ratio (phi)
36*               * relative air humidity (air.rh)
37*               * equilibrium temperature (Teq)
38*
39*----------------------------------------------------------------------
40* Author: Rodolfo Rodrigues and Argimiro R. Secchi
41* GIMSCOP/UFRGS - Group of Integration, Modeling, Simulation,
42*                                       Control, and Optimization of Processes
43*   LASIM/UFRGS - Simulation Laboratory
44*   LPR/UFRGS - Residues Processing Laboratory
45*               Federal University of Rio Grande do Sul
46*               Porto Alegre (RS), Brazil
47* $Id$
48*--------------------------------------------------------------------*#
49
50using "types";
51
52
53#*---------------------------------------------------------------------
54* Melhorias a fazer:
55*       * adicionar o 'char' aos balanços de massa e energia;
56*       * considerar a cinza nos balanços de massa e energia;
57*       * adicionar cromo e cloro ao modelo;
58*--------------------------------------------------------------------*#
59
60
61
62#*---------------------------------------------------------------------
63*       Model of dry biomass
64*--------------------------------------------------------------------*#
65Model dry_biomass
66        ATTRIBUTES
67        Brief = "Model of dry biomass";
68       
69       
70        PARAMETERS
71        NElem           as Integer      (Brief="Number of elements", Default=5); # CHONS...
72        Mw_(NElem)      as molweight(Brief="Molecular weight of elements");
73       
74        HHVcalc         as Switcher (Brief="High heat value calculation",
75                                Valid=["(Boie,1952)","(Zainal,2001)","(Higman,2003)","(Souza-Santos,2004)",
76                                "(Basu,2006)","Known data"], Default="(Souza-Santos,2004)");
77
78
79        SET
80        NElem = 5; # C,H,O,N,S
81        Mw_ = [12.011,1.0079,15.99994,14.0067,32.06]*'kg/kmol'; # C,H,O,N,S
82
83       
84        VARIABLES
85        massfrac(NElem) as fraction     (Brief="Mass fraction (Ultimate analysis)", Symbol="frac_{mass}", Unit='kg/kg');
86        molfrac(NElem)  as fraction     (Brief="Molar fraction", Symbol="frac_{mol}", Unit='kmol/kmol');
87        ash                     as fraction     (Brief="Mass ash fraction", Unit='kg/kg'); # only used to HHV calculation
88        Mw                      as molweight(Brief="Molecular weight");
89       
90        F                       as flow_mol     (Brief="Molar flow rate");
91        Fmass           as flow_mass(Brief="Mass flow rate", Symbol="F_{mass}");
92        na(NElem)       as positive     (Brief="Matrix of elements");
93        H                       as enth_mol     (Brief="Molar enthalpy");
94        Hmass           as enth_mass(Brief="Mass enthalpy", Upper=1e9, Symbol="H_{mass}");
95        HHV                     as enth_mass(Brief="Mass high heat value", Symbol="HHV_{mass}", Upper=1e10);
96        HHV_            as enth_mass(Brief="Known data for high heat value", Upper=1e10);
97        HHVmol          as enth_mol (Brief="Molar high heat value", Symbol="HHV_{mol}");
98        LHV                     as enth_mass(Brief="Mass low heat value", Upper=1e9, Symbol="LHV_{mass}");
99        LHVmol          as enth_mol (Brief="Molar low heat value", Symbol="LHV_{mol}");
100       
101       
102        EQUATIONS       
103        "Molar fraction of fuel formula"
104        na = massfrac*Mw_(1)/massfrac(1)/Mw_;
105       
106        "Mass fraction normalisation"
107        sum(massfrac) = 1;
108
109        "Molecular weight of fuel formula"
110        Mw = sum(Mw_*na);
111       
112        "Molar fraction of biomass"
113        molfrac = na/sum(na);   
114       
115        "Mass flow rate"
116        Fmass = F*Mw;
117       
118        "Molar enthalpy"
119        Hmass*Mw = H;
120       
121        switch HHVcalc # CHONSA
122                case "(Boie,1952)":
123                "Equation of Boie"
124                HHV = sum([35.16,116.225,11.09,6.28,10.465]*massfrac)*'kJ/kg';
125               
126                case "(Zainal,2001)":
127                "Reed and Levie (1985)"
128                HHVmol = (sum([34.0945,13.23,-11.986,0,0]*massfrac/(1+ash)) - 1.53*ash + 6.85)*'kJ/kmol';
129               
130                case "(Higman,2003)":
131                "Dulong formula"
132                HHV = (sum([34.91,117.83,-10.34,-1.51,10.05]*massfrac/(1+ash)) - 2.11*ash)*'MJ/kg';
133               
134                case "(Souza-Santos,2004)":
135                "Souza-Santos (2004)"
136                HHV = (sum([34.245,110.198,-11.985,-11.985,0]*massfrac/(1+ash)) - 1.53*ash + 0.0685)*'MJ/kg';
137               
138                case "(Basu,2006)":
139                "Dulong and Petit formula"
140                HHV = sum([33.823,144.25,-14.28,0,9.418]*massfrac)*'MJ/kg';
141
142                case "Known data":
143                "Known data"
144                HHV = HHV_;
145        end
146       
147       
148        "Molar high heat value"
149        HHVmol = HHV*Mw;
150       
151        "Molar low heat value"
152        LHVmol = LHV*Mw;
153end
154
155
156
157#*---------------------------------------------------------------------
158*       Model of moisture biomass
159*--------------------------------------------------------------------*#
160Model moisture_biomass
161        ATTRIBUTES
162        Brief = "Model of moisture biomass";
163       
164       
165        PARAMETERS
166#       NComp   as Integer      (Brief="Number of components", Default=8);
167        Mw              as molweight(Brief="Molecular weight");
168       
169        Ho              as enth_mol (Brief="Molar standard enthalpy of formation");
170        Hv              as enth_mol (Brief="Molar enthalpy of vaporization");
171       
172#       Ho(NComp)       as enth_mol (Brief="Molar standard enthalpy of formation");
173#       Hv(NComp)       as enth_mol (Brief="Molar enthalpy of vaporization");
174#       Tb(NComp)       as temperature (Brief="Boiling point temperature");
175       
176       
177        SET
178#       NComp = 8; #PP.NumberOfComponents;
179        Mw = 18.0152*'kg/kmol'; # H2O
180       
181        Ho = -2.42e5*'kJ/kmol'; #PP.IdealGasEnthalpyOfFormationAt25C();
182        Hv = 4.065e4*'kJ/kmol'; #PP.IdealGasEnthalpyOfFormation(Tb);
183#       Tb = PP.NormalBoilingPoint();
184       
185       
186        VARIABLES
187        F                       as flow_mol     (Brief="Molar flow rate");
188        Fmass           as flow_mass(Brief="Mass flow rate", Symbol="F_{mass}");
189        molfrac         as positive     (Brief="Molar relative moisture of biomass", Symbol="frac_{mol}", Unit='kmol/kmol');
190        massfrac        as positive     (Brief="Mass relative moisture of biomass", Symbol="frac_{mass}", Unit='kg/kg', Default=0.1);
191        H                       as enth_mol     (Brief="Molar enthalpy");
192        Hmass           as enth_mass(Brief="Mass enthalpy", Lower=-1e9, Symbol="H_{mass}");
193       
194       
195        EQUATIONS
196        "Mass flow rate"
197        Fmass = F*Mw;
198       
199        "Mole enthalpy"
200        H = Ho + Hv;   
201       
202        "Mass enthalpy"
203        Hmass*Mw = H;
204end
205
206
207
208#*---------------------------------------------------------------------
209*       Model of a biomass feed
210*--------------------------------------------------------------------*#
211Model raw_biomass
212        ATTRIBUTES
213        Brief = "Model of a biomass feed";
214       
215       
216        PARAMETERS
217        To      as temperature  (Brief="Ambient temperature", Default=298);
218        Po      as pressure             (Brief="Atmospheric pressure", Default=1);
219       
220       
221        VARIABLES
222        dry                     as dry_biomass  (Brief="Dry biomass", Symbol="_{dry}");
223        moisture        as moisture_biomass     (Brief="Moisture biomass", Symbol="_{moist}");
224       
225        F                       as flow_mol             (Brief="Molar flow rate");
226        Fmass           as flow_mass    (Brief="Mass flow rate", Symbol="F_{mass}");
227        Mw                      as molweight    (Brief="Molecular weight");
228       
229        h                       as enth_mol     (Brief="Molar enthalpy");
230        hmass           as enth_mass    (Brief="Mass enthalpy", Upper=1e9, Symbol="H_{mass}");
231        T                       as temperature  (Brief="Temperature");
232
233
234        EQUATIONS
235        "Molecular weight"
236        Mw = (1 - moisture.molfrac)*dry.Mw + moisture.molfrac*moisture.Mw;
237       
238        "Molar fraction of moisture" # kmol of M by kmol of B
239        moisture.molfrac*(moisture.massfrac+(1 - moisture.massfrac)*moisture.Mw/dry.Mw) =
240                moisture.massfrac;
241
242        "Dry biomass flow rate"
243        dry.Fmass = (1 - moisture.massfrac)*Fmass;
244       
245        "Moisture biomass flow rate"
246        moisture.Fmass = moisture.massfrac*Fmass;
247
248        "Raw biomass flow rate"
249        Fmass = F*Mw;
250       
251        "Mass enthalpy"
252        hmass = (1 - moisture.massfrac)*dry.Hmass + moisture.massfrac*moisture.Hmass;
253       
254        "Mole enthalpy"
255        h = hmass*Mw;
256       
257        "Mass low heat value" ## adicionado de 'stream_feed'
258        dry.LHV = dry.HHV - moisture.Hv*dry.massfrac(2)/2/dry.Mw_(2); # (Souza-Santos,2004)
259#       dry.LHV = (dry.HHV*(1-moisture.massfrac)
260#               - moisture.Hv*moisture.massfrac - (1-.moisture.massfrac))
261#               *(18*dry.massfrac(2)/200); # (Mansaray,1998) p.26 -> ?????
262
263#       dry.LHV = dry.HHV - 22604*'kJ/kg'*dry.massfrac(2)
264#               - 2581*'kJ/kg'*moisture.massfrac; # (Basu,2006) p.449   
265       
266        "Temperature"
267        T = To;
268end
269
270
271
272#*---------------------------------------------------------------------
273*       Model of an air stream
274*--------------------------------------------------------------------*#
275Model air_stream
276        ATTRIBUTES
277        Brief = "Model of an air stream";
278       
279       
280        PARAMETERS
281outer PP                as Plugin       (Brief="External physical properties", Type="PP");
282        NComp           as Integer      (Brief="Number of components", Default=8);
283        Mw(NComp)       as molweight;
284       
285        To      as temperature  (Brief="Ambient temperature", Default=298);
286        Po      as pressure             (Brief="Atmospheric pressure", Default=1);
287       
288       
289        VARIABLES
290        F                       as flow_mol     (Brief="Molar flow rate");
291        Fmass           as flow_mass(Brief="Mass flow rate", Symbol="F_{mass}");
292        Fvol            as flow_vol     (Brief="Volumetric flow rate", Symbol="F_{vol}");
293       
294        z(NComp)        as fraction     (Brief="Molar fraction", Unit='kmol/kmol');
295        zmass(NComp)as fraction (Brief="Mass fraction", Unit='kg/kg', Symbol="z_{mass}");
296
297        sh                      as positive     (Brief="Specific humidity", Unit='g/kg');
298        rh                      as percent      (Brief="Relative humidity");
299
300        Mws                     as molweight;
301        vm                      as volume_mol;
302        T                       as temperature;
303        P                       as pressure;
304        Pv(NComp)       as pressure;
305        h                       as enth_mol;
306       
307       
308        SET
309        NComp = 8; # PP.NumberOfComponents;
310        Mw = PP.MolecularWeight();
311       
312       
313        EQUATIONS
314        "Mixture Molecular weight"
315        Mws = sum(z*Mw);
316       
317        "Mass flow rate"
318        Fmass = F*Mws;
319       
320        "Volumetric flow rate"
321        Fvol = F*vm;
322       
323        "Temperature"
324        T = To;
325       
326        "Pressure"
327        P = Po;
328       
329
330        "Molar Volume"
331        vm = PP.VapourVolume(T,P,z);
332       
333       
334        "Mass water fraction"
335        zmass(1) = sh;
336       
337        "Mass oxygen fraction"
338        zmass(2) = 0.2316*(1-zmass(1)); # (Basu,2006) p.446: 23.16% O2, 76.8% N2, 0.04% inerts
339       
340        "Mass nitrogen fraction"
341        sum(zmass) = 1;
342       
343        "Air composition" # <<---
344        z(4:NComp) = 0;
345#       zmass(4:8) = 0;
346       
347        "Molar fraction"
348        z*sum(zmass/Mw) = zmass/Mw;
349
350        "Relative humidity"
351        rh = z(1)*P/Pv(1)*100;
352       
353        "Vapour pressure"
354        Pv = PP.VapourPressure(T);
355       
356        "Enthalpy"
357        h = sum(PP.IdealGasEnthalpyOfFormationAt25C()*z) + PP.VapourEnthalpy(T,P,z);
358end
359
360
361
362Model stream_gasifier
363        ATTRIBUTES
364        Brief = "Model of a gasifier stream";
365       
366       
367        PARAMETERS
368outer PP                as Plugin       (Brief="External physical properties", Type="PP");
369        NComp           as Integer      (Brief="Number of components", Default=8);
370        NElem           as Integer      (Brief="Number of elements", Default=5);
371        na(NElem,NComp)as positive(Brief="Matrix of elements per component");
372        Mw(NComp)       as molweight(Brief="Molecular weight of components");
373        Ho(NComp)       as enth_mol     (Brief="Molar component enthalpy");
374       
375       
376        VARIABLES
377        F                       as flow_mol (Brief="Molar Flow Rate");
378        Fmass           as flow_mass(Brief="Mass flow rate", Symbol="F_{mass}");
379        z(NComp)        as fraction     (Brief="Molar Fraction");
380        zmass(NComp)as fraction (Brief="Mass fraction", Unit='kg/kg', Symbol="z_{mass}");
381       
382        N(NComp)        as positive     (Brief="Mole fraction of component by initial biomass", Unit='kmol/kmol', Symbol="N_{mol}");
383        Nmass(NComp)as positive (Brief="Mass fraction of component by initial biomass", Unit='kmol/kmol', Symbol="N_{mass}");
384
385        Mws                     as molweight(Brief="Molecular weight of stream");
386
387        T                       as temperature(Brief="Temperature");
388        P                       as pressure (Brief="Pressure");
389       
390        h                       as enth_mol (Brief="Molar stream enthalpy");
391        hmass           as enth_mass(Brief="Mass stream enthalpy", Lower=-1e10, Upper=1e10, Symbol="h_{mass}");
392        E                       as enth_mol     (Brief="Specific energy");
393        v                       as fraction     (Brief="Vapourization fraction");
394       
395
396        SET
397        NComp = 8; # PP.NumberOfComponents;
398        NElem = 5; # C,H,O,N,S
399       
400        #                  C H O N S
401        na(:,1) = [0,2,1,0,0]; # H2O
402        na(:,2) = [0,0,2,0,0]; # O2
403        na(:,3) = [0,0,0,2,0]; # N2
404        na(:,4) = [1,0,1,0,0]; # CO
405        na(:,5) = [1,0,2,0,0]; # CO2
406        na(:,6) = [1,4,0,0,0]; # CH4
407        na(:,7) = [0,2,0,0,0]; # H2
408        na(:,8) = [0,0,2,0,1]; # SO2
409       
410        Mw = PP.MolecularWeight();
411        Ho = PP.IdealGasEnthalpyOfFormationAt25C();
412
413        EQUATIONS       
414        "Mass stream enthalpy"
415        hmass*Mws = h; 
416
417        "Mole fraction normalisation"
418        sum(z) = 1;
419       
420        "Vapour stream"
421        v = 1;
422end
423
424
425
426#*---------------------------------------------------------------------
427*       Model of a specific stream
428*--------------------------------------------------------------------*#
429Model stream_feed as stream_gasifier
430        ATTRIBUTES
431        Brief = "Model of a specific feed stream";
432       
433       
434        PARAMETERS
435        To      as temperature  (Brief="Ambient temperature", Default=298);
436        Po      as pressure             (Brief="Atmospheric pressure", Default=1);
437       
438       
439        VARIABLES
440        Fuel    as raw_biomass  (Brief="Raw biomass", Symbol="_{fuel}");
441        Air             as air_stream   (Brief="Air stream", Symbol="_{air}");
442       
443        phi             as Real                 (Brief="Equivalence ratio", Lower=0, Symbol="\phi");
444        Fw              as Real                 (Brief="Mass air-fuel ratio", Lower=0);
445        Fm              as Real                 (Brief="Molar air-fuel ratio", Lower=0);
446       
447       
448        EQUATIONS
449        "Molar flow rate"
450        F = Fuel.moisture.F + Air.F;
451
452        "Mass stream feed flow rate"
453        Fmass = Fuel.moisture.Fmass + Air.Fmass;
454       
455       
456        "Molecular weight of stream"
457        Mws*F = Fuel.moisture.F*Fuel.moisture.Mw + Air.F*Air.Mws;
458
459        "Mass fraction"
460        zmass*Mws = z*Mw;
461       
462        "Molar fraction by biomass"
463        N*Fuel.dry.F = z*F;
464       
465        "Mass fraction by biomass"
466        Nmass*Fuel.dry.Mw = N*Mw;
467
468       
469        "Molar stream enthalpy"
470        h*F = Fuel.moisture.F*Fuel.moisture.H + Air.F*Air.h;
471       
472#*---------------------------------------------------------------------
473*       C  + O2 -> CO2                                          Hc(C) < 0
474*       H2 + O2 -> H2O                                          Hc(H) < 0
475*       S  + O2 -> SO2                                          Hc(S) < 0
476*       CO2 + H2O + N2 + SO2 -> CHNOS + O2      LHV > 0
477*       C + H2 + N2 + O2 + S -> CHNOS           Hf = LHV + Hc(C+H+S)
478*--------------------------------------------------------------------*#
479        "Biomass enthalpy"
480        Fuel.dry.H = Fuel.dry.LHVmol
481                + (Fuel.dry.na(1)*Ho(5) + 0.5*Fuel.dry.na(2)*Ho(1)
482                + Fuel.dry.na(5)*Ho(8)); # CHONS CO2,H2O,SO2
483#       H2O, O2, N2, CO, CO2, CH4, H2, SO2
484       
485        "Input energy"
486        E = Fuel.dry.LHVmol;
487       
488        "Temperature"
489        T = To;
490        "Pressure"
491        P = Po;
492       
493       
494        # [H2O, O2, N2]/[Initial dry biomass]
495       
496        "Mass water fraction"
497        Nmass(1) = Air.sh*Air.Fmass/Fuel.dry.Fmass + Fuel.moisture.massfrac;
498       
499        "Mass oxygen fraction"
500        Nmass(2) = Air.zmass(2)*Air.Fmass/Fuel.dry.Fmass;
501       
502        "Molar fraction" # only O2,N2,H2O in the air
503        Nmass(4:NComp) = 0;
504       
505
506        "Equivalence ratio"
507        phi = N(2)/(1 + 0.25*Fuel.dry.na(2) - 0.5*Fuel.dry.na(3) + Fuel.dry.na(5));
508       
509        "Equivalence rate of gasifying" # (Melgar,2007)
510        Fm = Air.F/Fuel.dry.F; # molar base
511        Fw = Air.Fmass/Fuel.dry.Fmass; # mass base
512end
513
514
515
516#*---------------------------------------------------------------------
517*       Model of a product stream
518*--------------------------------------------------------------------*#
519Model stream_products as stream_gasifier
520        ATTRIBUTES
521        Brief = "Model of a product stream";
522
523       
524        PARAMETERS
525        LHV_syngas(3)   as enth_mass;
526       
527       
528        VARIABLES
529        Fvol    as flow_vol     (Brief="Volumetric flow rate (no solid)", Symbol="F_{vol}");
530        vm              as volume_mol(Brief="Molar Volume");
531        z_db(NComp-1)as fraction        (Brief="Molar fraction in dry base");
532       
533        LHV             as enth_mass(Brief="Mass low heat value", Upper=1e10, Symbol="LHV_{mass}");
534
535
536        SET
537        LHV_syngas = [12.622,35.814,10.788]*'MJ/kg'; # CO,CH4,H2
538       
539       
540        EQUATIONS
541        "Volumetric flow rate (no solid)"
542        Fvol = F*vm;
543
544        "Mass flow rate"
545        Fmass = F*Mws;
546
547        "Molar Volume"
548        vm = PP.VapourVolume(T,P,z);
549       
550        "Molecular weight of stream"
551        Mws = sum(z*Mw);
552       
553        "Mass fraction"
554        zmass*Mws = z*Mw;
555
556        "Mass fraction in dry base"
557        z_db*(1 - z(1)) = z(2:NComp);
558       
559       
560        "Low heat value of biomass syn-gas"
561        LHV = (zmass(4)*LHV_syngas(1) + zmass(6)*LHV_syngas(2)
562                + zmass(7)*LHV_syngas(3)); # /(zmass(4) + zmass(6) + zmass(7));
563end
564
565
566
567#######################################################################
568#                                                       MAIN MODEL
569#######################################################################
570
571#*---------------------------------------------------------------------
572*       Equilibrium model of a biomass gasifier
573*--------------------------------------------------------------------*#
574Model gasifier
575        ATTRIBUTES
576        Info = "
577== Description ==
578        Thermodynamic equilibrium modeling of a biomass gasifier.
579
580== Assumptions ==
581* thermodynamic equilibrium;
582* steady-state;
583* ideal gas relations;
584* ambient and atmospheric input conditions (To,Po);
585* global gasification reaction:
586                CHONS + H2O + air -> CO + CO2 + CH4 + H2 + H2O + N2 + SO2
587* no oxygen in the products.
588
589== Specify ==
590* ultimate biomass analysis (dry.massfrac);
591* moisture biomass ratio (moisture.massfrac);
592* equivalence ratio (phi);
593* relative air humidity (air.rh);
594* equilibrium temperature (Teq).
595";     
596
597
598        PARAMETERS
599        PP      as Plugin(Brief="External physical properties",
600                Type="PP",
601                Components = ["water","oxygen","nitrogen","carbon monoxide",
602                "carbon dioxide","methane","hydrogen","sulfur dioxide"],
603                LiquidModel = "IdealLiquid",
604                VapourModel = "Ideal"
605        );
606       
607        NComp   as Integer      (Brief="Number of components", Default=8);
608        NElem   as Integer      (Brief="Number of elements", Default=5);
609       
610        NReac   as Integer      (Brief="Number of reactions", Default=2);
611        stoic(NComp,NReac)      as Real (Brief="Stoichiometric matrix of considered reaction", Symbol="\nu");
612        Rg              as Real         (Brief="Universal gas constant", Unit='J/mol/K', Default=8.314);       
613        Po              as Integer      (Brief="Atmospheric pressure", Default=1);
614
615        VARIABLES
616        Inlet           as stream_feed  (Brief="Inlet stream", Symbol="^{in}", PosX=0.7165, PosY=0);
617        Outlet          as stream_products(Brief="Outlet stream", Symbol="^{out}", PosX=0.7165, PosY=1);
618       
619        K(NReac)        as positive             (Brief="Equilibrium constant", Lower=0);
620        G(NComp)        as enth_mol             (Brief="Component Gibbs free energy"); 
621        Teq                     as temperature  (Brief="Equilibrium temperature", Symbol="T_{eq}");
622       
623        eff_cg          as Real                 (Brief="Cold gas efficiency", Symbol="\eta_{cg}");
624       
625       
626        SET
627        NComp = PP.NumberOfComponents; # 8
628        NElem = 5; # C,H,O,N,S
629#*---------------------------------------------------------------------
630*       Considered equilibrium reaction:
631*               C + 2H2 <-> CH4
632*               CO + H2O <-> CO2 + H2
633*--------------------------------------------------------------------*#
634        NReac = 2;
635        stoic(:,1) = [ 0, 0, 0, 0, 0, 1,-2, 0]; # C + 2H2 <-> CH4
636        stoic(:,2) = [-1, 0, 0,-1, 1, 0, 1, 0]; # CO + H2O <-> CO2 + H2
637       
638       
639        EQUATIONS
640        for k in [1:NElem]
641        "Material balance"
642                Inlet.F*sum(Inlet.z*Inlet.na(k,:))
643                        + Inlet.Fuel.dry.Fmass*Inlet.Fuel.dry.massfrac(k)/Inlet.Fuel.dry.Mw_(k)
644                        = Outlet.F*sum(Outlet.z*Outlet.na(k,:));
645        end
646
647
648        "Fraction normalisation"
649        sum(Outlet.z) = 1;
650
651
652        "Heat balance"
653        Inlet.F*(Inlet.z(1)*Inlet.Fuel.moisture.H + sum(Inlet.z(2:NComp)*Inlet.Ho(2:NComp)))
654                + Inlet.Fuel.dry.F*Inlet.Fuel.dry.H = Outlet.F*Outlet.h;
655       
656       
657        for j in [1:NReac]
658        "Equilibrium constant"
659                K(j) = prod(Outlet.z^stoic(:,j));
660
661        "Gibbs energy of reaction"
662                sum(stoic(:,j)*G) = -Rg*Outlet.T*ln(K(j));
663        end
664       
665       
666        "Gibbs energy of component"
667        G = PP.IdealGasGibbsOfFormation(Outlet.T);
668
669        Outlet.h = sum(PP.IdealGasEnthalpyOfFormationAt25C()*Outlet.z)
670                + PP.VapourEnthalpy(Outlet.T,Outlet.P,Outlet.z);
671
672
673        "Output energy"
674        Outlet.E = Outlet.N(4)*(Inlet.Ho(4)-Inlet.Ho(5)) + Outlet.N(7)*(Inlet.Ho(7)
675                -Inlet.Ho(1)) + Outlet.N(6)*(Inlet.Ho(6)-Inlet.Ho(5)-Inlet.Ho(1));
676       
677        "Cold gas efficiency"
678        eff_cg = Outlet.E/Inlet.E;
679       
680       
681        # Outlet stream
682       
683        "Equilibrium temperature"
684        Outlet.T = Teq;
685
686        "Mechanical equilibrium"
687        Outlet.P = Inlet.P;
688       
689       
690        "Molar fraction by initial biomass"
691        Outlet.N*Inlet.Fuel.dry.F = Outlet.z*Outlet.F;
692       
693        "Mass fraction by initial biomass"
694        Outlet.Nmass*Inlet.Fuel.dry.Mw = Outlet.N*Outlet.Mw;
695end
696
Note: See TracBrowser for help on using the repository browser.