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

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

more updates

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