source: branches/gui/eml/streams.mso @ 585

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

fixed

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 15.7 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 585 2008-07-28 23:31:29Z 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 sink
145        ATTRIBUTES
146        Pallete = true;
147        Icon = "icon/Sink";
148        Brief = "Material stream sink";
149        Info = "
150        This model should be used for boundary streams when additional
151        information about the stream is desired.
152
153        Some of the additional informations calculated by this models are:
154         * Mass density
155         * Mass flow
156         * Mass compostions
157         * Specific volume
158         * Vapour fraction
159         * Volumetric flow
160         * Liquid and Vapour compositions
161        ";
162
163        PARAMETERS
164        outer PP                        as Plugin               (Brief = "External Physical Properties", Type="PP");
165        outer NComp             as Integer              (Brief = "Number of chemical components", Lower = 1);
166                  M(NComp)      as molweight    (Brief = "Component Mol Weight");
167       
168        SET
169
170        M   = PP.MolecularWeight();
171       
172        VARIABLES
173        in Inlet                as stream               (Brief = "Inlet Stream", PosX=0, PosY=0.5308, Protected=true,Symbol="_{in}");
174        v                               as fraction             (Brief = "Vapourization fraction",Hidden=true);
175        x(NComp)                as fraction             (Brief = "Liquid Molar Fraction",Hidden=true);
176        y(NComp)                as fraction             (Brief = "Vapour Molar Fraction",Hidden=true);
177        zmass(NComp)    as fraction             (Brief = "Mass Fraction");
178        Mw                              as molweight    (Brief = "Average Mol Weight");
179        vm                              as volume_mol   (Brief = "Molar Volume");       
180        rho                             as dens_mass    (Brief = "Stream Mass Density");
181        rhom                    as dens_mol             (Brief = "Stream Molar Density");
182        Fw                              as flow_mass    (Brief = "Stream Mass Flow");
183        Fvol            as flow_vol     (Brief = "Volumetric Flow");
184        T_Cdeg                  as temperature  (Brief = "Temperature in °C", Lower=-200);
185
186        EQUATIONS
187        "Flash Calculation"
188        [v, x, y] = PP.FlashPH(Inlet.P, Inlet.h, Inlet.z);
189       
190        "Average Molecular Weight"
191        Mw = sum(M*Inlet.z);
192
193        "Molar Density"
194                rhom * vm = 1;
195               
196        "Mass or Molar Density"
197        rhom * Mw = rho;
198
199        "Flow Mass"
200        Fw      =  Mw*Inlet.F;
201
202        "Molar Volume"
203        vm = (1-v)*PP.LiquidVolume(Inlet.T, Inlet.P, x) + v*PP.VapourVolume(Inlet.T,Inlet.P,y);
204       
205        "Volumetric Flow"
206        Fvol = Inlet.F*vm ;
207       
208        "Mass Fraction"
209        zmass = M*Inlet.z / Mw;
210       
211        "Temperature in °C"
212        T_Cdeg = Inlet.T - 273.15 * 'K';
213
214end
215
216Model simple_sink
217        ATTRIBUTES
218        Pallete = true;
219        Icon = "icon/Sink";
220        Brief = "Simple material stream sink";
221        Info = "
222        This model should be used for boundary streams when no additional
223        information about the stream is desired.
224        ";
225       
226        VARIABLES
227        in Inlet                as stream       (Brief = "Inlet Stream", PosX=0, PosY=0.5308, Protected=true,Symbol="_{in}");
228end
229
230Model energy_source
231        ATTRIBUTES
232        Pallete = true;
233        Icon = "icon/energy_source";
234        Brief = "Energy stream source";
235
236        VARIABLES
237        out OutletQ             as power(Brief = "Outlet energy stream", PosX=1, PosY=0.46, Symbol="_{out}");
238end
239
240Model info_stream
241        ATTRIBUTES
242        Pallete = true;
243        Icon = "icon/Info_Stream";
244        Brief = "Material stream information";
245        Info = "
246        This model should be used for middle streams when additional
247        information about the stream is desired.
248
249        Some of the additional informations calculated by this models are:
250         * Mass density
251         * Mass flow
252         * Mass compostions
253         * Specific volume
254         * Vapour fraction
255         * Volumetric flow
256         * Liquid and Vapour compositions
257         * Viscosity
258         * Heat Capacity
259         * Thermal Conductivity
260         * Temperature in Celsius Degrees
261        ";
262
263PARAMETERS
264        outer PP                        as Plugin                       (Brief = "External Physical Properties", Type="PP");
265        outer NComp     as Integer                      (Brief = "Number of chemical components", Lower = 1);
266                  M(NComp)      as molweight    (Brief = "Component Mol Weight");
267       
268SET
269
270        M   = PP.MolecularWeight();
271       
272VARIABLES
273
274        in      Inlet           as stream               (Brief = "Inlet Stream", PosX=0, PosY=0.5308, Protected=true , Symbol="_{in}");
275        out     Outlet          as stream               (Brief = "Outlet Stream", PosX=1, PosY=0.5308, Protected=true , Symbol="_{out}");
276       
277        v                                               as fraction                     (Brief = "Vapourization fraction",Hidden=true);
278        x(NComp)                        as fraction                     (Brief = "Liquid Molar Fraction",Hidden=true);
279        y(NComp)                        as fraction                     (Brief = "Vapour Molar Fraction",Hidden=true);
280       
281        Fw                                      as flow_mass            (Brief = "Stream Mass Flow",Protected=true);
282        Fvol                            as flow_vol             (Brief = "Volumetric Flow",Protected=true);
283        T_Cdeg                          as temperature          (Brief = "Temperature in °C", Lower=-200,Protected=true);
284
285        Mu                                      as viscosity            (Brief="Stream Viscosity",Lower=0.0001, Symbol = "\mu",Protected=true);
286        Cp                                      as cp_mol                       (Brief="Stream Molar Heat Capacity", Upper=1e10,Protected=true);       
287        K                                               as conductivity         (Brief="Stream Thermal Conductivity", Default=1.0, Lower=1e-5, Upper=500,Protected=true);
288        Mw                                      as molweight            (Brief = "Average Mol Weight",Protected=true);
289        vm                                      as volume_mol   (Brief = "Molar Volume",Protected=true);       
290        rho                                     as dens_mass            (Brief = "Stream Mass Density",Protected=true);
291        rhom                                    as dens_mol             (Brief = "Stream Molar Density",Protected=true);
292        s                                               as entr_mol             (Brief = "Stream Entropy",Protected=true);
293        zmass(NComp)    as fraction                     (Brief = "Mass Fraction",Protected=true);
294       
295EQUATIONS
296
297"Flash Calculation"
298        [v, x, y] = PP.FlashPH(Inlet.P, Inlet.h, Inlet.z);
299       
300"Average Molecular Weight"
301        Mw = sum(M*Inlet.z);
302
303"Mass Density"
304        rho * ((1-v)/PP.LiquidDensity(Inlet.T,Inlet.P,x) + v/PP.VapourDensity(Inlet.T,Inlet.P,y)) = 1;
305       
306"Mass or Molar Density"
307        rhom * Mw = rho;
308
309"Flow Mass"
310        Fw      =  Mw*Inlet.F;
311
312"Molar Volume"
313        vm = (1-v)*PP.LiquidVolume(Inlet.T, Inlet.P, x) + v*PP.VapourVolume(Inlet.T,Inlet.P,y);
314       
315"Volumetric Flow"
316        Fvol = Inlet.F*vm ;
317       
318"Mass Fraction"
319        zmass = M*Inlet.z / Mw;
320
321"Stream Heat Capacity"
322        Cp      =       (1-v)*PP.LiquidCp(Inlet.T, Inlet.P, x) + v*PP.VapourCp(Inlet.T,Inlet.P,y);
323
324"Stream Viscosity"
325        Mu      =       (1-v)*PP.LiquidViscosity(Inlet.T, Inlet.P, x) + v*PP.VapourViscosity(Inlet.T,Inlet.P,y);
326
327"Stream ThermalConductivity"
328        K       =       (1-v)*PP.LiquidThermalConductivity(Inlet.T, Inlet.P, x) + v*PP.VapourThermalConductivity(Inlet.T,Inlet.P,y);
329
330"Stream Overall Entropy"
331        s = (1-v)*PP.LiquidEntropy(Inlet.T, Inlet.P, x) + v*PP.VapourEntropy(Inlet.T, Inlet.P, y);
332       
333"Temperature in °C"
334        T_Cdeg = Inlet.T - 273.15 * 'K';
335
336"Outlet Flow"
337        Outlet.F = Inlet.F;
338
339"Outlet Temperature"
340        Outlet.T = Inlet.T;
341
342"Outlet Pressure"
343        Outlet.P = Inlet.P;
344
345"Outlet Vapour Fraction"
346        Outlet.v = Inlet.v;
347
348"Outlet Enthalpy"
349        Outlet.h = Inlet.h;
350
351"Outlet Composition"
352        Outlet.z= Inlet.z;
353
354end
355
356Model source
357
358ATTRIBUTES
359        Pallete = true;
360        Icon = "icon/Source";
361        Brief = "Material stream source";
362        Info = "
363        This model should be used for boundary streams.
364        Usually these streams are known and come from another process
365        units.
366
367        The user should specify:
368         * Total molar (mass or volumetric) flow
369         * Temperature
370         * Pressure
371         * Molar or mass composition
372       
373        No matter the specification set, the model will calculate some
374        additional properties:
375         * Mass density
376         * Mass flow
377         * Mass compostions
378         * Specific volume
379         * Vapour fraction
380         * Volumetric flow
381         * Liquid and Vapour compositions
382        ";
383
384PARAMETERS
385        outer PP                                                as Plugin                       (Brief = "External Physical Properties", Type="PP");
386        outer NComp                             as Integer                      (Brief = "Number of chemical components", Lower = 1);
387                  M(NComp)                              as molweight    (Brief = "Component Mol Weight");
388                  CompositionBasis              as Switcher             (Brief = "Molar or Mass Composition", Valid = ["Molar", "Mass"], Default="Molar");
389                  ValidPhases                           as Switcher             (Brief = "Valid Phases for Flash Calculation", Valid = ["Vapour-Only", "Liquid-Only","Vapour-Liquid"], Default="Vapour-Liquid");
390       
391
392SET
393
394        M   = PP.MolecularWeight();
395
396VARIABLES
397
398        out Outlet                      as stream                       (Brief = "Outlet stream", PosX=1, PosY=0.5256, Symbol="_{out}",Protected=true);
399       
400        Composition(NComp) as fraction                  (Brief = "Stream Composition");
401        F                                                               as flow_mol             (Brief = "Stream Molar Flow Rate");
402        Fw                                                      as flow_mass            (Brief = "Stream Mass Flow");
403        Fvol                                    as flow_vol        (Brief = "Volumetric Flow");
404        T                                                               as temperature  (Brief = "Stream Temperature");
405        T_Cdeg                                          as temperature  (Brief = "Temperature in °C", Lower=-200);
406        P                                                               as pressure             (Brief = "Stream Pressure");
407       
408        x(NComp)                        as fraction                     (Brief = "Liquid Molar Fraction",Hidden=true);
409        y(NComp)                        as fraction                     (Brief = "Vapour Molar Fraction",Hidden=true);
410       
411        Mw                                              as molweight                    (Brief = "Average Mol Weight",Protected=true);
412        vm                                              as volume_mol           (Brief = "Molar Volume",Protected=true);       
413        rho                                             as dens_mass                    (Brief = "Stream Mass Density",Protected=true);
414        rhom                                            as dens_mol                     (Brief = "Stream Molar Density",Protected=true);
415       
416        zmass(NComp)            as fraction                             (Brief = "Mass Fraction",Protected=true);
417       
418        EQUATIONS
419
420switch CompositionBasis
421
422        case "Molar":
423"Stream Molar Composition"
424        Outlet.z = Composition/sum(Composition);
425
426"Stream Mass Composition"
427        zmass = M*Outlet.z / Mw;
428
429        case "Mass":
430"Stream Mass Composition"
431        zmass = Composition/sum(Composition);
432
433"Stream Molar Composition"
434        Outlet.z*sum(zmass/M) = zmass/M;
435
436end
437
438switch ValidPhases
439       
440        case "Liquid-Only":
441
442"Vapour Fraction"
443        Outlet.v = 0;
444
445"Liquid Composition"
446        x = Outlet.z;
447
448"Vapour Composition"
449        y = Outlet.z;
450
451"Overall Enthalpy"
452        Outlet.h = PP.LiquidEnthalpy(Outlet.T, Outlet.P, x);
453
454"Molar Volume"
455        vm = PP.LiquidVolume(Outlet.T, Outlet.P, x);
456
457        case "Vapour-Only":
458
459"Vapor Fraction"
460        Outlet.v = 1;
461
462"Liquid Composition"
463        x = Outlet.z;
464
465"Vapour Composition"
466        y = Outlet.z;
467
468"Overall Enthalpy"
469        Outlet.h = PP.VapourEnthalpy(Outlet.T, Outlet.P, y);
470
471"Molar Volume"
472        vm = PP.VapourVolume(Outlet.T, Outlet.P, y);
473
474
475        case "Vapour-Liquid":
476
477"Flash Calculation"
478        [Outlet.v, x, y] = PP.Flash(Outlet.T, Outlet.P, Outlet.z);
479
480"Overall Enthalpy"
481        Outlet.h = (1-Outlet.v)*PP.LiquidEnthalpy(Outlet.T, Outlet.P, x) + Outlet.v*PP.VapourEnthalpy(Outlet.T, Outlet.P, y);
482
483"Molar Volume"
484        vm = (1-Outlet.v)*PP.LiquidVolume(Outlet.T, Outlet.P, x) + Outlet.v*PP.VapourVolume(Outlet.T,Outlet.P,y);
485
486end
487
488"Molar Density"
489        rhom * vm = 1;
490
491"Average Molecular Weight"
492        Mw = sum(M*Outlet.z);
493
494"Mass or Molar Density"
495        rhom * Mw = rho;
496
497"Flow Mass"
498        Fw      =  Mw*Outlet.F;
499
500"Volumetric Flow"
501        Fvol = Outlet.F*vm ;
502       
503"Temperature in °C"
504        T_Cdeg = Outlet.T - 273.15 * 'K';
505
506"Equate Flow"
507        Outlet.F = F;
508
509"Equate Pressures"
510        Outlet.P = P;
511
512"Equate Temperatures"
513        Outlet.T = T;
514
515end
516
517Model simple_source
518
519ATTRIBUTES
520        Pallete = true;
521        Icon = "icon/Source";
522        Brief = "Simple Material stream source";
523        Info = "
524        This model should be used for boundary streams.
525        Usually these streams are known and come from another process
526        units.
527
528        The user should specify:
529         * Total molar flow
530         * Temperature
531         * Pressure
532         * Molar composition
533";
534
535PARAMETERS
536        outer PP                                                as Plugin                       (Brief = "External Physical Properties", Type="PP");
537        outer NComp                             as Integer                      (Brief = "Number of chemical components", Lower = 1);
538                  M(NComp)                              as molweight    (Brief = "Component Mol Weight");
539                  ValidPhases                           as Switcher             (Brief = "Valid Phases for Flash Calculation", Valid = ["Vapour-Only", "Liquid-Only","Vapour-Liquid"], Default="Vapour-Liquid");
540       
541
542SET
543
544        M   = PP.MolecularWeight();
545
546VARIABLES
547
548        out Outlet                      as stream                       (Brief = "Outlet stream", PosX=1, PosY=0.5256, Symbol="_{out}",Protected=true);
549       
550        MolarComposition(NComp) as fraction                     (Brief = "Stream Molar Composition");
551        F                                                               as flow_mol             (Brief = "Stream Molar Flow Rate");
552        T                                                               as temperature  (Brief = "Stream Temperature");
553        T_Cdeg                                          as temperature  (Brief = "Temperature in °C", Lower=-200);
554        P                                                               as pressure             (Brief = "Stream Pressure");
555       
556        x(NComp)                        as fraction                     (Brief = "Liquid Molar Fraction",Hidden=true);
557        y(NComp)                        as fraction                     (Brief = "Vapour Molar Fraction",Hidden=true);
558       
559
560EQUATIONS
561
562"Stream Molar Composition"
563        Outlet.z = MolarComposition/sum(MolarComposition);
564
565
566switch ValidPhases
567       
568        case "Liquid-Only":
569
570"Vapour Fraction"
571        Outlet.v = 0;
572
573"Liquid Composition"
574        x = Outlet.z;
575
576"Vapour Composition"
577        y = Outlet.z;
578
579"Overall Enthalpy"
580        Outlet.h = PP.LiquidEnthalpy(Outlet.T, Outlet.P, x);
581
582
583        case "Vapour-Only":
584
585"Vapor Fraction"
586        Outlet.v = 1;
587
588"Liquid Composition"
589        x = Outlet.z;
590
591"Vapour Composition"
592        y = Outlet.z;
593
594"Overall Enthalpy"
595        Outlet.h = PP.VapourEnthalpy(Outlet.T, Outlet.P, y);
596
597
598        case "Vapour-Liquid":
599
600"Flash Calculation"
601        [Outlet.v, x, y] = PP.Flash(Outlet.T, Outlet.P, Outlet.z);
602
603"Overall Enthalpy"
604        Outlet.h = (1-Outlet.v)*PP.LiquidEnthalpy(Outlet.T, Outlet.P, x) + Outlet.v*PP.VapourEnthalpy(Outlet.T, Outlet.P, y);
605
606
607end
608
609"Temperature in °C"
610        T_Cdeg = Outlet.T - 273.15 * 'K';
611
612"Equate Flow"
613        Outlet.F = F;
614
615"Equate Pressures"
616        Outlet.P = P;
617
618"Equate Temperatures"
619        Outlet.T = T;
620
621end
Note: See TracBrowser for help on using the repository browser.