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

Last change on this file since 641 was 641, checked in by gerson bicca, 14 years ago

added source with no flow condition
icons changed

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 16.8 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 641 2008-09-29 18:49:56Z 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}");
238
239end
240
241Model work_source
242        ATTRIBUTES
243        Pallete = true;
244        Icon = "icon/work_source";
245        Brief = "Work stream source";
246
247        VARIABLES
248        out Work                as power(Brief = "Outlet work stream", PosX=1, PosY=0.46, Symbol="_{out}");
249
250end
251
252Model info_stream
253        ATTRIBUTES
254        Pallete = true;
255        Icon = "icon/Info_Stream";
256        Brief = "Material stream information";
257        Info = "
258        This model should be used for middle streams when additional
259        information about the stream is desired.
260
261        Some of the additional informations calculated by this models are:
262         * Mass density
263         * Mass flow
264         * Mass compostions
265         * Specific volume
266         * Vapour fraction
267         * Volumetric flow
268         * Liquid and Vapour compositions
269         * Viscosity
270         * Heat Capacity
271         * Thermal Conductivity
272         * Temperature in Celsius Degrees
273        ";
274
275PARAMETERS
276        outer PP                        as Plugin                       (Brief = "External Physical Properties", Type="PP");
277        outer NComp     as Integer                      (Brief = "Number of chemical components", Lower = 1);
278                  M(NComp)      as molweight    (Brief = "Component Mol Weight");
279       
280SET
281
282        M   = PP.MolecularWeight();
283       
284VARIABLES
285
286        in      Inlet           as stream               (Brief = "Inlet Stream", PosX=0, PosY=0.5308, Protected=true , Symbol="_{in}");
287        out     Outlet          as stream               (Brief = "Outlet Stream", PosX=1, PosY=0.5308, Protected=true , Symbol="_{out}");
288       
289        v                                               as fraction                     (Brief = "Vapourization fraction",Hidden=true);
290        x(NComp)                        as fraction                     (Brief = "Liquid Molar Fraction",Hidden=true);
291        y(NComp)                        as fraction                     (Brief = "Vapour Molar Fraction",Hidden=true);
292       
293        Fw                                      as flow_mass            (Brief = "Stream Mass Flow",Protected=true);
294        Fvol                            as flow_vol             (Brief = "Volumetric Flow",Protected=true);
295        T_Cdeg                          as temperature          (Brief = "Temperature in °C", Lower=-200,Protected=true);
296
297        Mu                                      as viscosity            (Brief="Stream Viscosity",Lower=0.0001, Symbol = "\mu",Protected=true);
298        Cp                                      as cp_mol                       (Brief="Stream Molar Heat Capacity", Upper=1e10,Protected=true);       
299        K                                               as conductivity         (Brief="Stream Thermal Conductivity", Default=1.0, Lower=1e-5, Upper=500,Protected=true);
300        Mw                                      as molweight            (Brief = "Average Mol Weight",Protected=true);
301        vm                                      as volume_mol   (Brief = "Molar Volume",Protected=true);       
302        rho                                     as dens_mass            (Brief = "Stream Mass Density",Protected=true);
303        rhom                                    as dens_mol             (Brief = "Stream Molar Density",Protected=true);
304        s                                               as entr_mol             (Brief = "Stream Entropy",Protected=true);
305        zmass(NComp)    as fraction                     (Brief = "Mass Fraction",Protected=true);
306       
307EQUATIONS
308
309"Flash Calculation"
310        [v, x, y] = PP.FlashPH(Inlet.P, Inlet.h, Inlet.z);
311       
312"Average Molecular Weight"
313        Mw = sum(M*Inlet.z);
314
315"Mass Density"
316        rho * ((1-v)/PP.LiquidDensity(Inlet.T,Inlet.P,x) + v/PP.VapourDensity(Inlet.T,Inlet.P,y)) = 1;
317       
318"Mass or Molar Density"
319        rhom * Mw = rho;
320
321"Flow Mass"
322        Fw      =  Mw*Inlet.F;
323
324"Molar Volume"
325        vm = (1-v)*PP.LiquidVolume(Inlet.T, Inlet.P, x) + v*PP.VapourVolume(Inlet.T,Inlet.P,y);
326       
327"Volumetric Flow"
328        Fvol = Inlet.F*vm ;
329       
330"Mass Fraction"
331        zmass = M*Inlet.z / Mw;
332
333"Stream Heat Capacity"
334        Cp      =       (1-v)*PP.LiquidCp(Inlet.T, Inlet.P, x) + v*PP.VapourCp(Inlet.T,Inlet.P,y);
335
336"Stream Viscosity"
337        Mu      =       (1-v)*PP.LiquidViscosity(Inlet.T, Inlet.P, x) + v*PP.VapourViscosity(Inlet.T,Inlet.P,y);
338
339"Stream ThermalConductivity"
340        K       =       (1-v)*PP.LiquidThermalConductivity(Inlet.T, Inlet.P, x) + v*PP.VapourThermalConductivity(Inlet.T,Inlet.P,y);
341
342"Stream Overall Entropy"
343        s = (1-v)*PP.LiquidEntropy(Inlet.T, Inlet.P, x) + v*PP.VapourEntropy(Inlet.T, Inlet.P, y);
344       
345"Temperature in °C"
346        T_Cdeg = Inlet.T - 273.15 * 'K';
347
348"Outlet Flow"
349        Outlet.F = Inlet.F;
350
351"Outlet Temperature"
352        Outlet.T = Inlet.T;
353
354"Outlet Pressure"
355        Outlet.P = Inlet.P;
356
357"Outlet Vapour Fraction"
358        Outlet.v = Inlet.v;
359
360"Outlet Enthalpy"
361        Outlet.h = Inlet.h;
362
363"Outlet Composition"
364        Outlet.z= Inlet.z;
365
366end
367
368Model source
369
370ATTRIBUTES
371        Pallete = true;
372        Icon = "icon/Source";
373        Brief = "Material stream source";
374        Info = "
375        This model should be used for boundary streams.
376        Usually these streams are known and come from another process
377        units.
378
379        The user should specify:
380         * Total molar (mass or volumetric) flow
381         * Temperature
382         * Pressure
383         * Molar or mass composition
384       
385        No matter the specification set, the model will calculate some
386        additional properties:
387         * Mass density
388         * Mass flow
389         * Mass compostions
390         * Specific volume
391         * Vapour fraction
392         * Volumetric flow
393         * Liquid and Vapour compositions
394        ";
395
396PARAMETERS
397        outer PP                                                as Plugin                       (Brief = "External Physical Properties", Type="PP");
398        outer NComp                             as Integer                      (Brief = "Number of chemical components", Lower = 1);
399                  M(NComp)                              as molweight    (Brief = "Component Mol Weight");
400                  CompositionBasis              as Switcher             (Brief = "Molar or Mass Composition", Valid = ["Molar", "Mass"], Default="Molar");
401                  ValidPhases                           as Switcher             (Brief = "Valid Phases for Flash Calculation", Valid = ["Vapour-Only", "Liquid-Only","Vapour-Liquid"], Default="Vapour-Liquid");
402       
403
404SET
405
406        M   = PP.MolecularWeight();
407
408VARIABLES
409
410        out Outlet                      as stream                       (Brief = "Outlet stream", PosX=1, PosY=0.5256, Symbol="_{out}",Protected=true);
411       
412        Composition(NComp) as fraction                  (Brief = "Stream Composition");
413        F                                                               as flow_mol             (Brief = "Stream Molar Flow Rate");
414        Fw                                                      as flow_mass            (Brief = "Stream Mass Flow");
415        Fvol                                    as flow_vol        (Brief = "Volumetric Flow");
416        T                                                               as temperature  (Brief = "Stream Temperature");
417        T_Cdeg                                          as temperature  (Brief = "Temperature in °C", Lower=-200);
418        P                                                               as pressure             (Brief = "Stream Pressure");
419       
420        x(NComp)                        as fraction                     (Brief = "Liquid Molar Fraction",Hidden=true);
421        y(NComp)                        as fraction                     (Brief = "Vapour Molar Fraction",Hidden=true);
422       
423        Mw                                              as molweight                    (Brief = "Average Mol Weight",Protected=true);
424        vm                                              as volume_mol           (Brief = "Molar Volume",Protected=true);       
425        rho                                             as dens_mass                    (Brief = "Stream Mass Density",Protected=true);
426        rhom                                            as dens_mol                     (Brief = "Stream Molar Density",Protected=true);
427       
428        zmass(NComp)            as fraction                             (Brief = "Mass Fraction",Protected=true);
429       
430        EQUATIONS
431
432switch CompositionBasis
433
434        case "Molar":
435"Stream Molar Composition"
436        Outlet.z = Composition/sum(Composition);
437
438"Stream Mass Composition"
439        zmass = M*Outlet.z / Mw;
440
441        case "Mass":
442"Stream Mass Composition"
443        zmass = Composition/sum(Composition);
444
445"Stream Molar Composition"
446        Outlet.z*sum(zmass/M) = zmass/M;
447
448end
449
450switch ValidPhases
451       
452        case "Liquid-Only":
453
454"Vapour Fraction"
455        Outlet.v = 0;
456
457"Liquid Composition"
458        x = Outlet.z;
459
460"Vapour Composition"
461        y = Outlet.z;
462
463"Overall Enthalpy"
464        Outlet.h = PP.LiquidEnthalpy(Outlet.T, Outlet.P, x);
465
466"Molar Volume"
467        vm = PP.LiquidVolume(Outlet.T, Outlet.P, x);
468
469        case "Vapour-Only":
470
471"Vapor Fraction"
472        Outlet.v = 1;
473
474"Liquid Composition"
475        x = Outlet.z;
476
477"Vapour Composition"
478        y = Outlet.z;
479
480"Overall Enthalpy"
481        Outlet.h = PP.VapourEnthalpy(Outlet.T, Outlet.P, y);
482
483"Molar Volume"
484        vm = PP.VapourVolume(Outlet.T, Outlet.P, y);
485
486
487        case "Vapour-Liquid":
488
489"Flash Calculation"
490        [Outlet.v, x, y] = PP.Flash(Outlet.T, Outlet.P, Outlet.z);
491
492"Overall Enthalpy"
493        Outlet.h = (1-Outlet.v)*PP.LiquidEnthalpy(Outlet.T, Outlet.P, x) + Outlet.v*PP.VapourEnthalpy(Outlet.T, Outlet.P, y);
494
495"Molar Volume"
496        vm = (1-Outlet.v)*PP.LiquidVolume(Outlet.T, Outlet.P, x) + Outlet.v*PP.VapourVolume(Outlet.T,Outlet.P,y);
497
498end
499
500"Molar Density"
501        rhom * vm = 1;
502
503"Average Molecular Weight"
504        Mw = sum(M*Outlet.z);
505
506"Mass or Molar Density"
507        rhom * Mw = rho;
508
509"Flow Mass"
510        Fw      =  Mw*Outlet.F;
511
512"Volumetric Flow"
513        Fvol = Outlet.F*vm ;
514       
515"Temperature in °C"
516        T_Cdeg = Outlet.T - 273.15 * 'K';
517
518"Equate Flow"
519        Outlet.F = F;
520
521"Equate Pressures"
522        Outlet.P = P;
523
524"Equate Temperatures"
525        Outlet.T = T;
526
527end
528
529Model simple_source
530
531ATTRIBUTES
532        Pallete = true;
533        Icon = "icon/Source";
534        Brief = "Simple Material stream source";
535        Info = "
536        This model should be used for boundary streams.
537        Usually these streams are known and come from another process
538        units.
539
540        The user should specify:
541         * Total molar flow
542         * Temperature
543         * Pressure
544         * Molar composition
545";
546
547PARAMETERS
548        outer PP                                                as Plugin                       (Brief = "External Physical Properties", Type="PP");
549        outer NComp                             as Integer                      (Brief = "Number of chemical components", Lower = 1);
550                  M(NComp)                              as molweight    (Brief = "Component Mol Weight");
551                  ValidPhases                           as Switcher             (Brief = "Valid Phases for Flash Calculation", Valid = ["Vapour-Only", "Liquid-Only","Vapour-Liquid"], Default="Vapour-Liquid");
552       
553
554SET
555
556        M   = PP.MolecularWeight();
557
558VARIABLES
559
560        out Outlet                      as stream                       (Brief = "Outlet stream", PosX=1, PosY=0.5256, Symbol="_{out}",Protected=true);
561       
562        MolarComposition(NComp) as fraction                     (Brief = "Stream Molar Composition");
563        F                                                               as flow_mol             (Brief = "Stream Molar Flow Rate");
564        T                                                               as temperature  (Brief = "Stream Temperature");
565        T_Cdeg                                          as temperature  (Brief = "Temperature in °C", Lower=-200);
566        P                                                               as pressure             (Brief = "Stream Pressure");
567       
568        x(NComp)                        as fraction                     (Brief = "Liquid Molar Fraction",Hidden=true);
569        y(NComp)                        as fraction                     (Brief = "Vapour Molar Fraction",Hidden=true);
570       
571
572EQUATIONS
573
574"Stream Molar Composition"
575        Outlet.z = MolarComposition/sum(MolarComposition);
576
577
578switch ValidPhases
579       
580        case "Liquid-Only":
581
582"Vapour Fraction"
583        Outlet.v = 0;
584
585"Liquid Composition"
586        x = Outlet.z;
587
588"Vapour Composition"
589        y = Outlet.z;
590
591"Overall Enthalpy"
592        Outlet.h = PP.LiquidEnthalpy(Outlet.T, Outlet.P, x);
593
594
595        case "Vapour-Only":
596
597"Vapor Fraction"
598        Outlet.v = 1;
599
600"Liquid Composition"
601        x = Outlet.z;
602
603"Vapour Composition"
604        y = Outlet.z;
605
606"Overall Enthalpy"
607        Outlet.h = PP.VapourEnthalpy(Outlet.T, Outlet.P, y);
608
609
610        case "Vapour-Liquid":
611
612"Flash Calculation"
613        [Outlet.v, x, y] = PP.Flash(Outlet.T, Outlet.P, Outlet.z);
614
615"Overall Enthalpy"
616        Outlet.h = (1-Outlet.v)*PP.LiquidEnthalpy(Outlet.T, Outlet.P, x) + Outlet.v*PP.VapourEnthalpy(Outlet.T, Outlet.P, y);
617
618
619end
620
621"Temperature in °C"
622        T_Cdeg = Outlet.T - 273.15 * 'K';
623
624"Equate Flow"
625        Outlet.F = F;
626
627"Equate Pressures"
628        Outlet.P = P;
629
630"Equate Temperatures"
631        Outlet.T = T;
632
633end
634
635Model sourceNoFlow
636
637ATTRIBUTES
638        Pallete = true;
639        Icon = "icon/SourceNoFlow";
640        Brief = "Simple Material stream source with no flow.";
641        Info = "
642        This model should be used for boundary streams.
643        Usually these streams are known and come from another process
644        units.";
645
646PARAMETERS
647        outer PP                                as Plugin                       (Brief = "External Physical Properties", Type="PP");
648        outer NComp             as Integer                      (Brief = "Number of chemical components", Lower = 1);
649
650VARIABLES
651
652        out Outlet                      as stream                       (Brief = "Outlet stream", PosX=1, PosY=0.5256, Symbol="_{out}",Protected=true);
653
654EQUATIONS
655
656"Stream Molar Composition"
657        Outlet.z = 1/NComp;
658
659"Stream Molar Enthalpy"
660        Outlet.h = 0 * 'J/mol';
661
662"Stream Temperature"
663        Outlet.T = 300 * 'K';
664
665"Stream Molar Flow"
666        Outlet.F = 0 * 'kmol/h';
667
668"Stream Pressure"
669        Outlet.P = 1 * 'atm';
670
671"Stream Vapour Fraction"
672        Outlet.v = 0;
673
674end
Note: See TracBrowser for help on using the repository browser.