source: trunk/eml/streams.mso @ 632

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

improved streams model

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 13.3 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 631 2008-09-23 20:23:00Z bicca $
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                   (Brief = "Stream Molar Flow Rate");
38        T as temperature                (Brief = "Stream Temperature");
39        P as pressure                   (Brief = "Stream Pressure");
40        h as enth_mol                   (Brief = "Stream Enthalpy");
41        v as fraction                   (Brief = "Vapourization fraction");
42        z(NComp) as fraction    (Brief = "Stream Molar 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",Hidden=true);
104        y(NComp) as fraction    (Brief = "Vapour Molar Fraction",Hidden=true);
105
106        EQUATIONS
107        "Flash Calculation"
108        [v, x, y] = PP.FlashPH(P, h, z);
109       
110        "Enthalpy"
111        h = (1-v)*PP.LiquidEnthalpy(T, P, x) + v*PP.VapourEnthalpy(T, P, y);
112       
113end
114
115Model streamPHS as streamPH
116        ATTRIBUTES
117        Brief = "Stream with built-in flash calculation";
118        Info = "
119        This model should be used when the vaporization fraction
120        is unknown.
121       
122        The built-in flash calculation will determine the stream
123        state as a function of the overall composition '''z''', the
124        pressure '''P''' and the enthalpy '''h'''.
125       
126        Additionally, the liquid composition '''x''', the vapor
127        composition '''y''' and the stream entropy are calculated.     
128        ";
129        Pallete = false;
130       
131PARAMETERS
132        outer PP as Plugin(Brief = "External Physical Properties", Type="PP");
133       
134VARIABLES
135        s as entr_mol   (Brief = "Stream Entropy");
136
137EQUATIONS
138
139"Entropy"
140        s = (1-v)*PP.LiquidEntropy(T, P, x) +   v*PP.VapourEntropy(T, P, y);
141       
142end
143
144Model source
145ATTRIBUTES
146        Pallete = true;
147        Icon = "icon/Source";
148        Brief = "Material stream source";
149        Info = "
150        This model should be used for boundary streams.
151        Usually these streams are known and come from another process
152        units.
153
154        The user should specify:
155         * Total molar (mass or volumetric) flow
156         * Temperature
157         * Pressure
158         * Molar or mass composition
159       
160        No matter the specification set, the model will calculate some
161        additional properties:
162         * Mass density
163         * Mass flow
164         * Mass compostions
165         * Specific volume
166         * Vapour fraction
167         * Volumetric flow
168         * Liquid and Vapour compositions
169        ";
170
171PARAMETERS
172        outer PP                                                as Plugin                       (Brief = "External Physical Properties", Type="PP");
173        outer NComp                             as Integer                      (Brief = "Number of chemical components", Lower = 1);
174                  M(NComp)                              as molweight    (Brief = "Component Mol Weight");
175                  CompositionBasis              as Switcher             (Brief = "Molar or Mass Composition", Valid = ["Molar", "Mass"], Default="Molar");
176                  ValidPhases                           as Switcher             (Brief = "Valid Phases for Flash Calculation", Valid = ["Vapour-Only", "Liquid-Only","Vapour-Liquid"], Default="Vapour-Liquid");
177       
178
179SET
180
181        M   = PP.MolecularWeight();
182
183VARIABLES
184
185        out Outlet                      as stream                       (Brief = "Outlet stream", PosX=1, PosY=0.5256, Symbol="_{out}",Protected=true);
186       
187        Composition(NComp) as fraction                  (Brief = "Stream Composition");
188        F                                                               as flow_mol             (Brief = "Stream Molar Flow Rate");
189        Fw                                                      as flow_mass            (Brief = "Stream Mass Flow");
190        Fvol                                    as flow_vol        (Brief = "Volumetric Flow");
191        T                                                               as temperature  (Brief = "Stream Temperature");
192        T_Cdeg                                          as temperature  (Brief = "Temperature in °C", Lower=-200);
193        P                                                               as pressure             (Brief = "Stream Pressure");
194       
195        x(NComp)                        as fraction                     (Brief = "Liquid Molar Fraction",Hidden=true);
196        y(NComp)                        as fraction                     (Brief = "Vapour Molar Fraction",Hidden=true);
197       
198        Mw                                              as molweight                    (Brief = "Average Mol Weight",Protected=true);
199        vm                                              as volume_mol           (Brief = "Molar Volume",Protected=true);       
200        rho                                             as dens_mass                    (Brief = "Stream Mass Density",Protected=true);
201        rhom                                            as dens_mol                     (Brief = "Stream Molar Density",Protected=true);
202       
203        zmass(NComp)            as fraction                             (Brief = "Mass Fraction",Protected=true);
204       
205        EQUATIONS
206
207switch CompositionBasis
208
209        case "Molar":
210"Stream Molar Composition"
211        Outlet.z = Composition/sum(Composition);
212
213"Stream Mass Composition"
214        zmass = M*Outlet.z / Mw;
215
216        case "Mass":
217"Stream Mass Composition"
218        zmass = Composition/sum(Composition);
219
220"Stream Molar Composition"
221        Outlet.z*sum(zmass/M) = zmass/M;
222
223end
224
225switch ValidPhases
226       
227        case "Liquid-Only":
228
229"Vapour Fraction"
230        Outlet.v = 0;
231
232"Liquid Composition"
233        x = Outlet.z;
234
235"Vapour Composition"
236        y = Outlet.z;
237
238"Overall Enthalpy"
239        Outlet.h = PP.LiquidEnthalpy(Outlet.T, Outlet.P, x);
240
241"Molar Volume"
242        vm = PP.LiquidVolume(Outlet.T, Outlet.P, x);
243
244        case "Vapour-Only":
245
246"Vapor Fraction"
247        Outlet.v = 1;
248
249"Liquid Composition"
250        x = Outlet.z;
251
252"Vapour Composition"
253        y = Outlet.z;
254
255"Overall Enthalpy"
256        Outlet.h = PP.VapourEnthalpy(Outlet.T, Outlet.P, y);
257
258"Molar Volume"
259        vm = PP.VapourVolume(Outlet.T, Outlet.P, y);
260
261
262        case "Vapour-Liquid":
263
264"Flash Calculation"
265        [Outlet.v, x, y] = PP.Flash(Outlet.T, Outlet.P, Outlet.z);
266
267"Overall Enthalpy"
268        Outlet.h = (1-Outlet.v)*PP.LiquidEnthalpy(Outlet.T, Outlet.P, x) + Outlet.v*PP.VapourEnthalpy(Outlet.T, Outlet.P, y);
269
270"Molar Volume"
271        vm = (1-Outlet.v)*PP.LiquidVolume(Outlet.T, Outlet.P, x) + Outlet.v*PP.VapourVolume(Outlet.T,Outlet.P,y);
272
273end
274
275"Molar Density"
276        rhom * vm = 1;
277
278"Average Molecular Weight"
279        Mw = sum(M*Outlet.z);
280
281"Mass or Molar Density"
282        rhom * Mw = rho;
283
284"Flow Mass"
285        Fw      =  Mw*Outlet.F;
286
287"Volumetric Flow"
288        Fvol = Outlet.F*vm ;
289       
290"Temperature in °C"
291        T_Cdeg = Outlet.T - 273.15 * 'K';
292
293"Equate Flow"
294        Outlet.F = F;
295
296"Equate Pressures"
297        Outlet.P = P;
298
299"Equate Temperatures"
300        Outlet.T = T;
301       
302end
303
304Model simple_source
305
306ATTRIBUTES
307        Pallete = true;
308        Icon = "icon/Source";
309        Brief = "Simple Material stream source";
310        Info = "
311        This model should be used for boundary streams.
312        Usually these streams are known and come from another process
313        units.
314
315        The user should specify:
316         * Total molar flow
317         * Temperature
318         * Pressure
319         * Molar composition
320";
321
322PARAMETERS
323        outer PP                                                as Plugin                       (Brief = "External Physical Properties", Type="PP");
324        outer NComp                             as Integer                      (Brief = "Number of chemical components", Lower = 1);
325                  M(NComp)                              as molweight    (Brief = "Component Mol Weight");
326                  ValidPhases                           as Switcher             (Brief = "Valid Phases for Flash Calculation", Valid = ["Vapour-Only", "Liquid-Only","Vapour-Liquid"], Default="Vapour-Liquid");
327       
328
329SET
330
331        M   = PP.MolecularWeight();
332
333VARIABLES
334
335        out Outlet                      as stream                       (Brief = "Outlet stream", PosX=1, PosY=0.5256, Symbol="_{out}",Protected=true);
336       
337        MolarComposition(NComp) as fraction                     (Brief = "Stream Molar Composition");
338        F                                                               as flow_mol             (Brief = "Stream Molar Flow Rate");
339        T                                                               as temperature  (Brief = "Stream Temperature");
340        T_Cdeg                                          as temperature  (Brief = "Temperature in °C", Lower=-200);
341        P                                                               as pressure             (Brief = "Stream Pressure");
342       
343        x(NComp)                        as fraction                     (Brief = "Liquid Molar Fraction",Hidden=true);
344        y(NComp)                        as fraction                     (Brief = "Vapour Molar Fraction",Hidden=true);
345       
346
347EQUATIONS
348
349"Stream Molar Composition"
350        Outlet.z = MolarComposition/sum(MolarComposition);
351
352
353switch ValidPhases
354       
355        case "Liquid-Only":
356
357"Vapour Fraction"
358        Outlet.v = 0;
359
360"Liquid Composition"
361        x = Outlet.z;
362
363"Vapour Composition"
364        y = Outlet.z;
365
366"Overall Enthalpy"
367        Outlet.h = PP.LiquidEnthalpy(Outlet.T, Outlet.P, x);
368
369
370        case "Vapour-Only":
371
372"Vapor Fraction"
373        Outlet.v = 1;
374
375"Liquid Composition"
376        x = Outlet.z;
377
378"Vapour Composition"
379        y = Outlet.z;
380
381"Overall Enthalpy"
382        Outlet.h = PP.VapourEnthalpy(Outlet.T, Outlet.P, y);
383
384
385        case "Vapour-Liquid":
386
387"Flash Calculation"
388        [Outlet.v, x, y] = PP.Flash(Outlet.T, Outlet.P, Outlet.z);
389
390"Overall Enthalpy"
391        Outlet.h = (1-Outlet.v)*PP.LiquidEnthalpy(Outlet.T, Outlet.P, x) + Outlet.v*PP.VapourEnthalpy(Outlet.T, Outlet.P, y);
392
393end
394
395"Temperature in °C"
396        T_Cdeg = Outlet.T - 273.15 * 'K';
397
398"Equate Flow"
399        Outlet.F = F;
400
401"Equate Pressures"
402        Outlet.P = P;
403
404"Equate Temperatures"
405        Outlet.T = T;
406
407end
408
409Model sink
410        ATTRIBUTES
411        Pallete = true;
412        Icon = "icon/Sink";
413        Brief = "Material stream sink";
414        Info = "
415        This model should be used for boundary streams when additional
416        information about the stream is desired.
417
418        Some of the additional informations calculated by this models are:
419         * Mass density
420         * Mass flow
421         * Mass compostions
422         * Specific volume
423         * Vapour fraction
424         * Volumetric flow
425         * Liquid and Vapour compositions
426        ";
427
428        PARAMETERS
429        outer PP                        as Plugin               (Brief = "External Physical Properties", Type="PP");
430        outer NComp             as Integer              (Brief = "Number of chemical components", Lower = 1);
431                  M(NComp)      as molweight    (Brief = "Component Mol Weight");
432                  rhoModel              as Switcher             (Brief = "Density model", Valid = ["volume", "correlation"], Default="volume");
433       
434        SET
435
436        M   = PP.MolecularWeight();
437       
438        VARIABLES
439        in Inlet                as stream               (Brief = "Inlet Stream", PosX=0, PosY=0.5308, Symbol="_{in}");
440        v                               as fraction             (Brief = "Vapourization fraction");
441        x(NComp)                as fraction             (Brief = "Liquid Molar Fraction",Hidden=true);
442        y(NComp)                as fraction             (Brief = "Vapour Molar Fraction",Hidden=true);
443        zmass(NComp)    as fraction             (Brief = "Mass Fraction");
444        Mw                              as molweight    (Brief = "Average Mol Weight");
445        vm                              as volume_mol   (Brief = "Molar Volume");       
446        rho                             as dens_mass    (Brief = "Stream Mass Density");
447        rhom                    as dens_mol             (Brief = "Stream Molar Density");
448        Fw                              as flow_mass    (Brief = "Stream Mass Flow");
449        Fvol            as flow_vol     (Brief = "Volumetric Flow");
450        s                               as entr_mol             (Brief = "Stream Entropy");
451        T_Cdeg                  as temperature  (Brief = "Temperature in °C", Lower=-200);
452
453        EQUATIONS
454        "Flash Calculation"
455        [v, x, y] = PP.FlashPH(Inlet.P, Inlet.h, Inlet.z);
456       
457        "Average Molecular Weight"
458        Mw = sum(M*Inlet.z);
459
460        switch rhoModel
461                case "volume":
462        "Molar Density"
463                rhom * vm = 1;
464               
465                case "correlation":
466        "Mass Density"
467                rho * ((1-v)/PP.LiquidDensity(Inlet.T,Inlet.P,x) + v/PP.VapourDensity(Inlet.T,Inlet.P,y)) = 1;
468        end
469       
470        "Mass or Molar Density"
471        rhom * Mw = rho;
472
473        "Flow Mass"
474        Fw      =  Mw*Inlet.F;
475
476        "Molar Volume"
477        vm = (1-v)*PP.LiquidVolume(Inlet.T, Inlet.P, x) + v*PP.VapourVolume(Inlet.T,Inlet.P,y);
478       
479        "Volumetric Flow"
480        Fvol = Inlet.F*vm ;
481       
482        "Mass Fraction"
483        zmass = M*Inlet.z / Mw;
484       
485        "Overall Entropy"
486        s = (1-v)*PP.LiquidEntropy(Inlet.T, Inlet.P, x) +
487                v*PP.VapourEntropy(Inlet.T, Inlet.P, y);
488       
489        "Temperature in °C"
490        T_Cdeg = Inlet.T - 273.15 * 'K';
491
492end
493
494Model simple_sink
495        ATTRIBUTES
496        Pallete = true;
497        Icon = "icon/Sink";
498        Brief = "Simple material stream sink";
499        Info = "
500        This model should be used for boundary streams when no additional
501        information about the stream is desired.
502        ";
503       
504        VARIABLES
505        in Inlet                as stream       (Brief = "Inlet Stream", PosX=0, PosY=0.5308, Symbol="_{in}");
506end
507
508Model energy_stream
509        ATTRIBUTES
510        Pallete = false;
511        Brief = "General Energy Stream";
512        Info =
513        "This is the basic building block for the EML models.
514        Every model should have input and output energy streams
515        derived from this model.";
516
517        VARIABLES
518        Q as heat_rate(Brief="Energy rate");
519end
520
521Model work_stream
522        ATTRIBUTES
523        Pallete = false;
524        Brief = "General Work Stream";
525        VARIABLES
526        Work            as power(Brief = "work");
527end
528
529Model work_source
530        ATTRIBUTES
531        Pallete = true;
532        Icon = "icon/work_source";
533        Brief = "Work stream source";
534
535        VARIABLES
536        out OutletWork          as work_stream (Brief = "work stream", PosX=1, PosY=0.46);
537
538end
539
540Model energy_source
541        ATTRIBUTES
542        Pallete = true;
543        Icon = "icon/energy_source";
544        Brief = "Enegry stream source";
545
546        VARIABLES
547        out OutletQ             as energy_stream (Brief = "Outlet energy stream", PosX=1, PosY=0.46, Symbol="_{out}");
548end
Note: See TracBrowser for help on using the repository browser.