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

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

starting to update the EML (new gui)

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