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

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

added work stream

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 15.9 KB
RevLine 
[79]1#*-------------------------------------------------------------------
2* EMSO Model Library (EML) Copyright (C) 2004 - 2007 ALSOC.
[1]3*
[79]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
[1]17*----------------------------------------------------------------------
[79]18* Author: Paula B. Staudt and Rafael de P. Soares
[1]19* $Id: streams.mso 594 2008-08-08 21:47:39Z bicca $
20*---------------------------------------------------------------------*#
21
22using "types";
23
24Model stream
[117]25        ATTRIBUTES
26        Pallete = false;
27        Brief = "General Material Stream";
[123]28        Info =
[117]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       
[1]33        PARAMETERS
[117]34        outer NComp as Integer (Brief = "Number of chemical components", Lower = 1);
[1]35
36        VARIABLES
[346]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");
[523]42        z(NComp) as fraction    (Brief = "Stream Molar Fraction");
[1]43end
44
[117]45Model liquid_stream as stream
46        ATTRIBUTES
47        Pallete = false;
48        Brief = "Liquid Material Stream";
[123]49        Info =
[117]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
[1]54        PARAMETERS
[117]55        outer PP as Plugin(Brief = "External Physical Properties", Type="PP");
[1]56       
57        EQUATIONS
[117]58        "Liquid Enthalpy"
59        h = PP.LiquidEnthalpy(T, P, z);
60        "Liquid stream"
61        v = 0;
[1]62end
63
[117]64Model vapour_stream as stream
65        ATTRIBUTES
66        Pallete = false;
67        Brief = "Vapour Material Stream";
[123]68        Info =
[117]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
[1]73        PARAMETERS
[117]74        outer PP as Plugin(Brief = "External Physical Properties", Type="PP");
[1]75       
76        EQUATIONS
[117]77        "Vapour Enthalpy"
78        h = PP.VapourEnthalpy(T, P, z);
79        "Vapour stream"
80        v = 1;
[1]81end
82
[125]83Model streamPH as stream
[298]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       
[125]99        PARAMETERS
100        outer PP as Plugin(Brief = "External Physical Properties", Type="PP");
101       
102        VARIABLES
[551]103        x(NComp) as fraction    (Brief = "Liquid Molar Fraction",Hidden=true);
104        y(NComp) as fraction    (Brief = "Vapour Molar Fraction",Hidden=true);
[346]105
[125]106        EQUATIONS
107        "Flash Calculation"
108        [v, x, y] = PP.FlashPH(P, h, z);
[346]109       
[125]110        "Enthalpy"
[584]111        h = (1-v)*PP.LiquidEnthalpy(T, P, x) + v*PP.VapourEnthalpy(T, P, y);
[346]112       
[125]113end
114
[562]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       
[578]126        Additionally, the liquid composition '''x''', the vapor
127        composition '''y''' and the stream entropy are calculated.     
[562]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
[117]144Model sink
145        ATTRIBUTES
[321]146        Pallete = true;
[310]147        Icon = "icon/Sink";
[290]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.
[117]152
[290]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
[117]163        PARAMETERS
[147]164        outer PP                        as Plugin               (Brief = "External Physical Properties", Type="PP");
165        outer NComp             as Integer              (Brief = "Number of chemical components", Lower = 1);
[297]166                  M(NComp)      as molweight    (Brief = "Component Mol Weight");
[117]167       
[147]168        SET
169
170        M   = PP.MolecularWeight();
171       
[117]172        VARIABLES
[584]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);
[551]175        x(NComp)                as fraction             (Brief = "Liquid Molar Fraction",Hidden=true);
176        y(NComp)                as fraction             (Brief = "Vapour Molar Fraction",Hidden=true);
[297]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");
[501]184        T_Cdeg                  as temperature  (Brief = "Temperature in °C", Lower=-200);
[346]185
[117]186        EQUATIONS
187        "Flash Calculation"
[123]188        [v, x, y] = PP.FlashPH(Inlet.P, Inlet.h, Inlet.z);
[147]189       
190        "Average Molecular Weight"
191        Mw = sum(M*Inlet.z);
192
[297]193        "Molar Density"
194                rhom * vm = 1;
195               
196        "Mass or Molar Density"
197        rhom * Mw = rho;
[147]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       
[501]211        "Temperature in °C"
212        T_Cdeg = Inlet.T - 273.15 * 'K';
213
[117]214end
[299]215
[311]216Model simple_sink
217        ATTRIBUTES
[321]218        Pallete = true;
[311]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
[584]227        in Inlet                as stream       (Brief = "Inlet Stream", PosX=0, PosY=0.5308, Protected=true,Symbol="_{in}");
[311]228end
229
[299]230Model energy_source
231        ATTRIBUTES
[321]232        Pallete = true;
[310]233        Icon = "icon/energy_source";
[562]234        Brief = "Energy stream source";
[299]235
236        VARIABLES
[555]237        out OutletQ             as power(Brief = "Outlet energy stream", PosX=1, PosY=0.46, Symbol="_{out}");
[594]238
[299]239end
[569]240
[594]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
[569]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
[571]367
[578]368Model source
[571]369
[576]370ATTRIBUTES
[571]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
[576]383         * Molar or mass composition
[571]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
[576]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");
[585]400                  CompositionBasis              as Switcher             (Brief = "Molar or Mass Composition", Valid = ["Molar", "Mass"], Default="Molar");
[577]401                  ValidPhases                           as Switcher             (Brief = "Valid Phases for Flash Calculation", Valid = ["Vapour-Only", "Liquid-Only","Vapour-Liquid"], Default="Vapour-Liquid");
[571]402       
403
[576]404SET
405
[571]406        M   = PP.MolecularWeight();
407
[576]408VARIABLES
409
[584]410        out Outlet                      as stream                       (Brief = "Outlet stream", PosX=1, PosY=0.5256, Symbol="_{out}",Protected=true);
[576]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       
[571]420        x(NComp)                        as fraction                     (Brief = "Liquid Molar Fraction",Hidden=true);
421        y(NComp)                        as fraction                     (Brief = "Vapour Molar Fraction",Hidden=true);
422       
[576]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       
[571]430        EQUATIONS
431
[585]432switch CompositionBasis
[571]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"
[575]446        Outlet.z*sum(zmass/M) = zmass/M;
[571]447
448end
449
[577]450switch ValidPhases
[575]451       
[577]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
[576]489"Flash Calculation"
[571]490        [Outlet.v, x, y] = PP.Flash(Outlet.T, Outlet.P, Outlet.z);
491
[576]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);
[571]494
[577]495"Molar Volume"
496        vm = (1-Outlet.v)*PP.LiquidVolume(Outlet.T, Outlet.P, x) + Outlet.v*PP.VapourVolume(Outlet.T,Outlet.P,y);
[571]497
[577]498end
499
[576]500"Molar Density"
[577]501        rhom * vm = 1;
502
503"Average Molecular Weight"
504        Mw = sum(M*Outlet.z);
505
[576]506"Mass or Molar Density"
[571]507        rhom * Mw = rho;
508
[576]509"Flow Mass"
[571]510        Fw      =  Mw*Outlet.F;
511
[576]512"Volumetric Flow"
[571]513        Fvol = Outlet.F*vm ;
514       
[576]515"Temperature in °C"
[571]516        T_Cdeg = Outlet.T - 273.15 * 'K';
517
[576]518"Equate Flow"
519        Outlet.F = F;
520
521"Equate Pressures"
522        Outlet.P = P;
523
524"Equate Temperatures"
525        Outlet.T = T;
526
[571]527end
[579]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
[584]560        out Outlet                      as stream                       (Brief = "Outlet stream", PosX=1, PosY=0.5256, Symbol="_{out}",Protected=true);
[579]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
Note: See TracBrowser for help on using the repository browser.