source: trunk/eml/reactors/pfr.mso @ 1006

Last change on this file since 1006 was 813, checked in by Rafael de Pelegrini Soares, 14 years ago

Fixed PFR model and sample

  • Property svn:keywords set to Id
File size: 3.4 KB
Line 
1#*-------------------------------------------------------------------
2* EMSO Model Library (EML) Copyright (C) 2004 - 2007 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 - 2007 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* Author: Rafael de P. Soares and Paula B. Staudt
17* $Id: pfr.mso 813 2009-08-05 19:00:16Z rafael $
18*--------------------------------------------------------------------*#
19
20using "streams";
21
22Model pfr
23
24ATTRIBUTES
25        Pallete         = true;
26        Brief           = "Model of a Generic PFR with constant mass holdup";
27        Icon            = "icon/pfr";
28        Info            =
29"== Requires the information of ==
30* Reaction values
31* Heat of reaction
32* Pressure profile
33";
34
35PARAMETERS
36
37outer PP                                                        as Plugin               (Brief = "External Physical Properties", Type="PP");
38outer   NComp                                           as Integer              (Brief="Number of components");
39                NReac                                           as Integer              (Brief="Number of reactions");
40                stoic(NComp, NReac)     as Real                         (Brief = "Stoichiometric Matrix");
41                NDisc                                           as Integer              (Brief="Number of points of discretization", Default=10);
42                Mw(NComp)                               as molweight    (Brief="Component Mol Weight");
43                L                                                               as length               (Brief="Reactor Length");
44                Across                                          as area                 (Brief="Cross section area");
45
46SET
47       
48        Mw   = PP.MolecularWeight();
49
50VARIABLES
51
52in      Inlet   as stream       (Brief = "Inlet Stream", PosX=0, PosY=0.5076, Symbol="_{in}");
53out     Outlet  as stream       (Brief = "Outlet Stream", PosX=1, PosY=0.5236, Symbol="_{out}");
54
55        str(NDisc+1) as vapour_stream;
56        vol(NDisc+1) as vol_mol;
57        rho(NDisc+1) as dens_mass;
58       
59        q(NDisc)                                as heat_rate;
60
61        M(NComp, NDisc)         as mol                  (Brief = "Molar holdup");
62        Mt(NDisc)                       as mol                  (Brief = "Molar holdup");
63        C(NComp, NDisc)         as conc_mol     (Brief="Components concentration", Lower=-1e-6);
64        E(NDisc)                                as energy               (Brief="Total Energy Holdup on element");
65        r(NReac, NDisc)                 as reaction_mol;
66        Hr(NReac, NDisc)        as heat_reaction;
67        #Hf(NComp, NDisc)       as heat_reaction;
68
69EQUATIONS
70
71"Inlet boundary"
72        str(1).F = Inlet.F;
73        str(1).T = Inlet.T;
74        str(1).P = Inlet.P;
75        str(1).z = Inlet.z;
76
77"Outlet boundary"
78        Outlet.F = str(NDisc+1).F;
79        Outlet.T = str(NDisc+1).T;
80        Outlet.P = str(NDisc+1).P;
81        Outlet.z = str(NDisc+1).z;
82        Outlet.h = str(NDisc+1).h;
83        Outlet.v = str(NDisc+1).v;
84       
85        for z in [1:NDisc] do
86                for c in [1:NComp] do
87                        "Component Molar Balance"
88                        diff(M(c,z)) = (str(z).F*str(z).z(c) - str(z+1).F*str(z+1).z(c))
89                                + sum(stoic(c,:)*r(:, z)) * Across*L/NDisc;
90                end
91               
92                "Energy Balance"
93                diff(E(z)) = str(z).F*str(z).h - str(z+1).F*str(z+1).h +
94                        sum(Hr(:,z)*r(:,z)) * Across*L/NDisc - q(z);
95
96                "Energy Holdup"
97                E(z) = Mt(z)*str(z+1).h - str(z+1).P*Across*L/NDisc;
98
99                "mass flow is considered constant"
100                str(z+1).F*vol(z+1)*rho(z+1) = str(z).F*vol(z)*rho(z);
101       
102                "Molar concentration"
103                C(:,z) * Across*L/NDisc = M(:,z);
104               
105                "Geometrical constraint"
106                Across*L/NDisc = Mt(z) * vol(z);
107
108                "Molar fraction"
109                str(z+1).z * Mt(z) = M(:,z);
110               
111                #Hf(:,z) = PP.IdealGasEnthalpyOfFormation(str(z+1).T);
112                #Hr(:,z) = -sum(stoic*Hf(:, z));
113        end
114
115        for z in [1:NDisc+1] do
116                "Specific Volume"
117                vol(z) = PP.VapourVolume(str(z).T, str(z).P, str(z).z);
118               
119                "Specific Mass"
120                rho(z) = PP.VapourDensity(str(z).T, str(z).P, str(z).z);
121        end
122end
Note: See TracBrowser for help on using the repository browser.