source: trunk/eml/streams.mso @ 322

Last change on this file since 322 was 321, checked in by Argimiro Resende Secchi, 15 years ago

Fix Pallete of streams.mso and add flashPH as another model of flash for devices.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 9.1 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* Model of basic streams
17*----------------------------------------------------------------------
18* Author: Paula B. Staudt and Rafael de P. Soares
19* $Id: streams.mso 321 2007-07-20 14:30:53Z arge $
20*---------------------------------------------------------------------*#
21
22using "types";
23
24Model stream
25        ATTRIBUTES
26        Pallete = false;
27        Brief = "General Material Stream";
28        Info =
29        "This is the basic building block for the EML models.
30        Every model should have input and output streams derived
31        from this model.";
32       
33        PARAMETERS
34        outer NComp as Integer (Brief = "Number of chemical components", Lower = 1);
35
36        VARIABLES
37        F as flow_mol;
38        T as temperature;
39        P as pressure;
40        z(NComp) as fraction(Brief = "Overall Molar Fraction");
41        h as enth_mol;
42        v as fraction(Brief = "Vapourisation fraction");
43end
44
45Model liquid_stream as stream
46        ATTRIBUTES
47        Pallete = false;
48        Brief = "Liquid Material Stream";
49        Info =
50        "Model for liquid material streams.
51        This model should be used only when the phase of the stream
52        is known ''a priori''.";
53
54        PARAMETERS
55        outer PP as Plugin(Brief = "External Physical Properties", Type="PP");
56       
57        EQUATIONS
58        "Liquid Enthalpy"
59        h = PP.LiquidEnthalpy(T, P, z);
60        "Liquid stream"
61        v = 0;
62end
63
64Model vapour_stream as stream
65        ATTRIBUTES
66        Pallete = false;
67        Brief = "Vapour Material Stream";
68        Info =
69        "Model for vapour material streams.
70        This model should be used only when the phase of the stream
71        is known ''a priori''.";
72
73        PARAMETERS
74        outer PP as Plugin(Brief = "External Physical Properties", Type="PP");
75       
76        EQUATIONS
77        "Vapour Enthalpy"
78        h = PP.VapourEnthalpy(T, P, z);
79        "Vapour stream"
80        v = 1;
81end
82
83Model streamPH as stream
84        ATTRIBUTES
85        Brief = "Stream with built-in flash calculation";
86        Info = "
87        This model should be used when the vaporization fraction
88        is unknown.
89       
90        The built-in flash calculation will determine the stream
91        state as a function of the overall composition '''z''', the
92        pressure '''P''' and the enthalpy '''h'''.
93       
94        Additionally, the liquid composition '''x''' and the vapor
95        composition '''y''' are calculated.     
96        ";
97        Pallete = false;
98       
99        PARAMETERS
100        outer PP as Plugin(Brief = "External Physical Properties", Type="PP");
101       
102        VARIABLES
103        x(NComp) as fraction(Brief = "Liquid Molar Fraction");
104        y(NComp) as fraction(Brief = "Vapour Molar Fraction");
105       
106        EQUATIONS
107        "Flash Calculation"
108        [v, x, y] = PP.FlashPH(P, h, z);
109        "Enthalpy"
110        h = (1-v)*PP.LiquidEnthalpy(T, P, x) +
111                v*PP.VapourEnthalpy(T, P, y);
112end
113
114Model source
115        ATTRIBUTES
116        Pallete = true;
117        Icon = "icon/Source";
118        Brief = "Material stream source";
119        Info = "
120        This model should be used for boundary streams.
121        Usually these streams are known and come from another process
122        units.
123
124        The user should specify:
125         * Total molar (mass or volumetric) flow
126         * Temperature
127         * Pressure
128         * Molar (mass or volumetric) composition
129       
130        No matter the specification set, the model will calculate some
131        additional properties:
132         * Mass density
133         * Mass flow
134         * Mass compostions
135         * Specific volume
136         * Vapour fraction
137         * Volumetric flow
138         * Liquid and Vapour compositions
139        ";
140
141        PARAMETERS
142        outer PP                        as Plugin               (Brief = "External Physical Properties", Type="PP");
143        outer NComp             as Integer              (Brief = "Number of chemical components", Lower = 1);
144                  M(NComp)      as molweight    (Brief = "Component Mol Weight");
145                  rhoModel              as Switcher             (Brief = "Density model", Valid = ["volume", "correlation"], Default="volume");
146       
147        SET
148
149        M   = PP.MolecularWeight();
150
151        VARIABLES
152        out Outlet                      as stream;
153        x(NComp)                        as fraction                     (Brief = "Liquid Molar Fraction");
154        y(NComp)                        as fraction                     (Brief = "Vapour Molar Fraction");
155        hl                                      as enth_mol;
156        hv                                      as enth_mol;
157        zmass(NComp)            as fraction                     (Brief = "Mass Fraction");
158        Mw                                      as molweight            (Brief = "Average Mol Weight");
159        vm                                      as volume_mol           (Brief = "Molar Volume");       
160        rho                                     as dens_mass            (Brief = "Stream Mass Density");
161        rhom                            as dens_mol                     (Brief = "Stream Molar Density");
162        Fw                                      as flow_mass            (Brief = "Stream Mass Flow");
163        Fvol                    as flow_vol         (Brief = "Volumetric Flow");
164       
165        EQUATIONS
166        "Flash Calculation"
167        [Outlet.v, x, y] = PP.Flash(Outlet.T, Outlet.P, Outlet.z);
168       
169        "Overall Enthalpy"
170        Outlet.h = (1-Outlet.v)*PP.LiquidEnthalpy(Outlet.T, Outlet.P, x) +
171                Outlet.v*PP.VapourEnthalpy(Outlet.T, Outlet.P, y);
172       
173        hl = PP.LiquidEnthalpy(Outlet.T, Outlet.P, x);
174        hv = PP.VapourEnthalpy(Outlet.T, Outlet.P, y);
175       
176        "Average Molecular Weight"
177        Mw = sum(M*Outlet.z);
178
179        switch rhoModel
180                case "volume":
181        "Molar Density"
182                rhom * vm = 1;
183               
184                case "correlation":
185        "Mass Density"
186                rho*((1-Outlet.v)/PP.LiquidDensity(Outlet.T,Outlet.P,x) + Outlet.v/PP.VapourDensity(Outlet.T,Outlet.P,y)) = 1;
187        end
188       
189        "Mass or Molar Density"
190        rhom * Mw = rho;
191
192        "Flow Mass"
193        Fw      =  Mw*Outlet.F;
194
195        "Molar Volume"
196        vm = (1-Outlet.v)*PP.LiquidVolume(Outlet.T, Outlet.P, x) + Outlet.v*PP.VapourVolume(Outlet.T,Outlet.P,y);
197       
198        "Volumetric Flow"
199        Fvol = Outlet.F*vm ;
200       
201        "Mass Fraction"
202        zmass = M*Outlet.z / Mw;       
203       
204end
205
206Model simple_source
207        ATTRIBUTES
208        Pallete = true;
209        Icon = "icon/Source";
210        Brief = "Simple material stream source";
211        Info = "
212        This model should be used for boundary streams.
213        Usually these streams are known and come from another process
214        units.
215
216        The user should specify:
217         * Total molar flow
218         * Temperature
219         * Pressure
220         * Molar composition
221        ";
222
223        PARAMETERS
224        outer PP                        as Plugin               (Brief = "External Physical Properties", Type="PP");
225        outer NComp             as Integer              (Brief = "Number of chemical components", Lower = 1);
226       
227        VARIABLES
228        out Outlet                      as stream;
229        x(NComp)                        as fraction                     (Brief = "Liquid Molar Fraction");
230        y(NComp)                        as fraction                     (Brief = "Vapour Molar Fraction");
231        hl                                      as enth_mol;
232        hv                                      as enth_mol;
233       
234        EQUATIONS
235        "Flash Calculation"
236        [Outlet.v, x, y] = PP.Flash(Outlet.T, Outlet.P, Outlet.z);
237       
238        "Overall Enthalpy"
239        Outlet.h = (1-Outlet.v)*PP.LiquidEnthalpy(Outlet.T, Outlet.P, x) +
240                Outlet.v*PP.VapourEnthalpy(Outlet.T, Outlet.P, y);
241
242        hl = PP.LiquidEnthalpy(Outlet.T, Outlet.P, x);
243        hv = PP.VapourEnthalpy(Outlet.T, Outlet.P, y);
244end
245
246Model sink
247        ATTRIBUTES
248        Pallete = true;
249        Icon = "icon/Sink";
250        Brief = "Material stream sink";
251        Info = "
252        This model should be used for boundary streams when additional
253        information about the stream is desired.
254
255        Some of the additional informations calculated by this models are:
256         * Mass density
257         * Mass flow
258         * Mass compostions
259         * Specific volume
260         * Vapour fraction
261         * Volumetric flow
262         * Liquid and Vapour compositions
263        ";
264
265        PARAMETERS
266        outer PP                        as Plugin               (Brief = "External Physical Properties", Type="PP");
267        outer NComp             as Integer              (Brief = "Number of chemical components", Lower = 1);
268                  M(NComp)      as molweight    (Brief = "Component Mol Weight");
269                  rhoModel              as Switcher             (Brief = "Density model", Valid = ["volume", "correlation"], Default="volume");
270       
271        SET
272
273        M   = PP.MolecularWeight();
274       
275        VARIABLES
276        in Inlet                as stream;
277        v                               as fraction;
278        x(NComp)                as fraction             (Brief = "Liquid Molar Fraction");
279        y(NComp)                as fraction             (Brief = "Vapour Molar Fraction");
280        zmass(NComp)    as fraction             (Brief = "Mass Fraction");
281        Mw                              as molweight    (Brief = "Average Mol Weight");
282        vm                              as volume_mol   (Brief = "Molar Volume");       
283        rho                             as dens_mass    (Brief = "Stream Mass Density");
284        rhom                    as dens_mol             (Brief = "Stream Molar Density");
285        Fw                              as flow_mass    (Brief = "Stream Mass Flow");
286        Fvol            as flow_vol     (Brief = "Volumetric Flow");
287       
288        EQUATIONS
289        "Flash Calculation"
290        [v, x, y] = PP.FlashPH(Inlet.P, Inlet.h, Inlet.z);
291       
292        "Average Molecular Weight"
293        Mw = sum(M*Inlet.z);
294
295        switch rhoModel
296                case "volume":
297        "Molar Density"
298                rhom * vm = 1;
299               
300                case "correlation":
301        "Mass Density"
302                rho * ((1-v)/PP.LiquidDensity(Inlet.T,Inlet.P,x) + v/PP.VapourDensity(Inlet.T,Inlet.P,y)) = 1;
303        end
304       
305        "Mass or Molar Density"
306        rhom * Mw = rho;
307
308        "Flow Mass"
309        Fw      =  Mw*Inlet.F;
310
311        "Molar Volume"
312        vm = (1-v)*PP.LiquidVolume(Inlet.T, Inlet.P, x) + v*PP.VapourVolume(Inlet.T,Inlet.P,y);
313       
314        "Volumetric Flow"
315        Fvol = Inlet.F*vm ;
316       
317        "Mass Fraction"
318        zmass = M*Inlet.z / Mw;
319       
320end
321
322Model simple_sink
323        ATTRIBUTES
324        Pallete = true;
325        Icon = "icon/Sink";
326        Brief = "Simple material stream sink";
327        Info = "
328        This model should be used for boundary streams when no additional
329        information about the stream is desired.
330        ";
331       
332        VARIABLES
333        in Inlet                as stream;
334end
335
336Model energy_stream
337        ATTRIBUTES
338        Pallete = false;
339        Brief = "General Energy Stream";
340        Info =
341        "This is the basic building block for the EML models.
342        Every model should have input and output energy streams
343        derived from this model.";
344
345        VARIABLES
346        Q as heat_rate(Brief="Energy rate");
347end
348
349Model energy_source
350        ATTRIBUTES
351        Pallete = true;
352        Icon = "icon/energy_source";
353        Brief = "Enegry stream source";
354
355        VARIABLES
356        out OutletQ             as energy_stream;
357end
Note: See TracBrowser for help on using the repository browser.