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

Last change on this file since 920 was 914, checked in by Rafael de Pelegrini Soares, 13 years ago

T in degC without UOM to avoid confusion, also updated valve icons

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 26.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 914 2010-02-20 15:05:47Z rafael $
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", Protected = true);
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       
131VARIABLES
132        s as entr_mol   (Brief = "Stream Entropy", Protected = true);
133
134EQUATIONS
135
136"Entropy"
137        s = (1-v)*PP.LiquidEntropy(T, P, x) +   v*PP.VapourEntropy(T, P, y);
138       
139end
140
141Model source
142
143ATTRIBUTES
144        Pallete = true;
145        Icon = "icon/Source";
146        Brief = "Material stream source";
147        Info = "
148        This model should be used for boundary streams.
149        Usually these streams are known and come from another process
150        units.
151
152        The user should specify:
153         * Total molar (mass or volumetric) flow
154         * Temperature
155         * Pressure
156         * Molar or mass composition
157       
158        No matter the specification set, the model will calculate some
159        additional properties:
160         * Mass density
161         * Mass flow
162         * Mass compostions
163         * Specific volume
164         * Vapour fraction
165         * Volumetric flow
166         * Liquid and Vapour compositions
167        ";
168
169PARAMETERS
170        outer PP                                                as Plugin                       (Brief = "External Physical Properties", Type="PP");
171        outer NComp                             as Integer                      (Brief = "Number of chemical components", Lower = 1);
172                  M(NComp)                              as molweight    (Brief = "Component Mol Weight", Protected=true);
173                  ValidPhases                           as Switcher             (Brief = "Valid Phases for Flash Calculation", Valid = ["Vapour-Only", "Liquid-Only","Vapour-Liquid"], Default="Vapour-Liquid");
174                  CompositionBasis              as Switcher             (Brief = "Molar or Mass Composition", Valid = ["Molar", "Mass"], Default="Molar");     
175
176SET
177
178        M   = PP.MolecularWeight();
179
180VARIABLES
181
182        out Outlet                      as stream                       (Brief = "Outlet stream", PosX=1, PosY=0.5256, Symbol="_{out}",Protected=true);
183       
184        Composition(NComp) as fraction                  (Brief = "Stream Composition");
185        SumOfComposition as positive                    (Brief = "Sum of Stream Composition",Protected=true);
186        F                                                               as flow_mol             (Brief = "Stream Molar Flow Rate");
187        Fw                                                      as flow_mass            (Brief = "Stream Mass Flow");
188        Fvol                                    as flow_vol        (Brief = "Volumetric Flow");
189        T                                                       as temperature  (Brief = "Stream Temperature");
190        T_Cdeg                                          as Real(Brief = "Temperature in °C", Lower=-250, Upper=5000);
191        P                                                       as pressure(Brief = "Stream Pressure");
192       
193        x(NComp)                        as fraction                     (Brief = "Liquid Molar Fraction",Hidden=true);
194        y(NComp)                        as fraction                     (Brief = "Vapour Molar Fraction",Hidden=true);
195       
196        Mw                                              as molweight                    (Brief = "Average Mol Weight",Protected=true);
197        vm                                              as volume_mol           (Brief = "Molar Volume",Protected=true);       
198        rho                                             as dens_mass                    (Brief = "Stream Mass Density",Protected=true);
199        rhom                                            as dens_mol                     (Brief = "Stream Molar Density",Protected=true);
200       
201        zmass(NComp)            as fraction                             (Brief = "Mass Fraction",Protected=true);
202       
203        EQUATIONS
204
205switch CompositionBasis
206
207        case "Molar":
208"Stream Molar Composition"
209        Outlet.z = Composition/sum(Composition);
210
211"Stream Mass Composition"
212        zmass = M*Outlet.z / Mw;
213
214        case "Mass":
215"Stream Mass Composition"
216        zmass = Composition/sum(Composition);
217
218"Stream Molar Composition"
219        Outlet.z*sum(zmass/M) = zmass/M;
220
221end
222
223switch ValidPhases
224       
225        case "Liquid-Only":
226
227"Vapour Fraction"
228        Outlet.v = 0;
229
230"Liquid Composition"
231        x = Outlet.z;
232
233"Vapour Composition"
234        y = Outlet.z;
235
236"Overall Enthalpy"
237        Outlet.h = PP.LiquidEnthalpy(Outlet.T, Outlet.P, x);
238
239"Molar Volume"
240        vm = PP.LiquidVolume(Outlet.T, Outlet.P, x);
241
242        case "Vapour-Only":
243
244"Vapor Fraction"
245        Outlet.v = 1;
246
247"Liquid Composition"
248        x = Outlet.z;
249
250"Vapour Composition"
251        y = Outlet.z;
252
253"Overall Enthalpy"
254        Outlet.h = PP.VapourEnthalpy(Outlet.T, Outlet.P, y);
255
256"Molar Volume"
257        vm = PP.VapourVolume(Outlet.T, Outlet.P, y);
258
259
260        case "Vapour-Liquid":
261
262"Flash Calculation"
263        [Outlet.v, x, y] = PP.Flash(Outlet.T, Outlet.P, Outlet.z);
264
265"Overall Enthalpy"
266        Outlet.h = (1-Outlet.v)*PP.LiquidEnthalpy(Outlet.T, Outlet.P, x) + Outlet.v*PP.VapourEnthalpy(Outlet.T, Outlet.P, y);
267
268"Molar Volume"
269        vm = (1-Outlet.v)*PP.LiquidVolume(Outlet.T, Outlet.P, x) + Outlet.v*PP.VapourVolume(Outlet.T,Outlet.P,y);
270
271end
272
273"Sum of Composition"
274        SumOfComposition = sum(Composition);
275
276"Molar Density"
277        rhom * vm = 1;
278
279"Average Molecular Weight"
280        Mw = sum(M*Outlet.z);
281
282"Mass or Molar Density"
283        rhom * Mw = rho;
284
285"Flow Mass"
286        Fw      =  Mw*Outlet.F;
287
288"Volumetric Flow"
289        Fvol = Outlet.F*vm ;
290       
291"Temperature in °C"
292        T_Cdeg = Outlet.T/'K' - 273.15;
293
294"Equate Flow"
295        Outlet.F = F;
296
297"Equate Pressures"
298        Outlet.P = P;
299
300"Equate Temperatures"
301        Outlet.T = T;
302
303end
304
305Model source2
306
307ATTRIBUTES
308        Pallete = true;
309        Icon = "icon/Source2";
310        Brief = "Material stream source";
311        Info = "
312        This model should be used for boundary streams.
313        Usually these streams are known and come from another process
314        units.
315
316        The user should specify:
317         * Total molar (mass or volumetric) flow
318         * Temperature
319         * Pressure
320         * Molar or mass composition
321       
322        No matter the specification set, the model will calculate some
323        additional properties:
324         * Mass density
325         * Mass flow
326         * Mass compostions
327         * Specific volume
328         * Vapour fraction
329         * Volumetric flow
330         * Liquid and Vapour compositions
331        ";
332
333PARAMETERS
334        outer PP                                                as Plugin                       (Brief = "External Physical Properties", Type="PP");
335        outer NComp                             as Integer                      (Brief = "Number of chemical components", Lower = 1);
336                  M(NComp)                              as molweight    (Brief = "Component Mol Weight", Protected=true);
337                  ValidPhases                           as Switcher             (Brief = "Valid Phases for Flash Calculation", Valid = ["Vapour-Only", "Liquid-Only","Vapour-Liquid"], Default="Vapour-Liquid");
338                  CompositionBasis              as Switcher             (Brief = "Molar or Mass Composition", Valid = ["Molar", "Mass"], Default="Molar");     
339       
340
341SET
342
343        M   = PP.MolecularWeight();
344
345VARIABLES
346
347        out Outlet                      as stream                       (Brief = "Outlet stream", PosX=0, PosY=0.5256, Symbol="_{out}",Protected=true);
348       
349        Composition(NComp) as fraction                  (Brief = "Stream Composition");
350        SumOfComposition as positive                    (Brief = "Sum of Stream Composition",Protected=true);
351        F                                                               as flow_mol             (Brief = "Stream Molar Flow Rate");
352        Fw                                                      as flow_mass            (Brief = "Stream Mass Flow");
353        Fvol                                    as flow_vol        (Brief = "Volumetric Flow");
354        T                                                               as temperature  (Brief = "Stream Temperature");
355        T_Cdeg                                          as Real(Brief = "Temperature in °C", Lower=-250, Upper=5000);
356        P                                                               as pressure             (Brief = "Stream Pressure");
357       
358        x(NComp)                        as fraction                     (Brief = "Liquid Molar Fraction",Hidden=true);
359        y(NComp)                        as fraction                     (Brief = "Vapour Molar Fraction",Hidden=true);
360       
361        Mw                                              as molweight                    (Brief = "Average Mol Weight",Protected=true);
362        vm                                              as volume_mol           (Brief = "Molar Volume",Protected=true);       
363        rho                                             as dens_mass                    (Brief = "Stream Mass Density",Protected=true);
364        rhom                                            as dens_mol                     (Brief = "Stream Molar Density",Protected=true);
365       
366        zmass(NComp)            as fraction                             (Brief = "Mass Fraction",Protected=true);
367       
368        EQUATIONS
369
370switch CompositionBasis
371
372        case "Molar":
373"Stream Molar Composition"
374        Outlet.z = Composition/sum(Composition);
375
376"Stream Mass Composition"
377        zmass = M*Outlet.z / Mw;
378
379        case "Mass":
380"Stream Mass Composition"
381        zmass = Composition/sum(Composition);
382
383"Stream Molar Composition"
384        Outlet.z*sum(zmass/M) = zmass/M;
385
386end
387
388switch ValidPhases
389       
390        case "Liquid-Only":
391
392"Vapour Fraction"
393        Outlet.v = 0;
394
395"Liquid Composition"
396        x = Outlet.z;
397
398"Vapour Composition"
399        y = Outlet.z;
400
401"Overall Enthalpy"
402        Outlet.h = PP.LiquidEnthalpy(Outlet.T, Outlet.P, x);
403
404"Molar Volume"
405        vm = PP.LiquidVolume(Outlet.T, Outlet.P, x);
406
407        case "Vapour-Only":
408
409"Vapor Fraction"
410        Outlet.v = 1;
411
412"Liquid Composition"
413        x = Outlet.z;
414
415"Vapour Composition"
416        y = Outlet.z;
417
418"Overall Enthalpy"
419        Outlet.h = PP.VapourEnthalpy(Outlet.T, Outlet.P, y);
420
421"Molar Volume"
422        vm = PP.VapourVolume(Outlet.T, Outlet.P, y);
423
424
425        case "Vapour-Liquid":
426
427"Flash Calculation"
428        [Outlet.v, x, y] = PP.Flash(Outlet.T, Outlet.P, Outlet.z);
429
430"Overall Enthalpy"
431        Outlet.h = (1-Outlet.v)*PP.LiquidEnthalpy(Outlet.T, Outlet.P, x) + Outlet.v*PP.VapourEnthalpy(Outlet.T, Outlet.P, y);
432
433"Molar Volume"
434        vm = (1-Outlet.v)*PP.LiquidVolume(Outlet.T, Outlet.P, x) + Outlet.v*PP.VapourVolume(Outlet.T,Outlet.P,y);
435
436end
437
438"Sum of Composition"
439        SumOfComposition = sum(Composition);
440
441"Molar Density"
442        rhom * vm = 1;
443
444"Average Molecular Weight"
445        Mw = sum(M*Outlet.z);
446
447"Mass or Molar Density"
448        rhom * Mw = rho;
449
450"Flow Mass"
451        Fw      =  Mw*Outlet.F;
452
453"Volumetric Flow"
454        Fvol = Outlet.F*vm ;
455       
456"Temperature in °C"
457        T_Cdeg = Outlet.T/'K' - 273.15;
458
459"Equate Flow"
460        Outlet.F = F;
461
462"Equate Pressures"
463        Outlet.P = P;
464
465"Equate Temperatures"
466        Outlet.T = T;
467
468end
469
470Model simple_source
471
472ATTRIBUTES
473        Pallete = true;
474        Icon = "icon/Source";
475        Brief = "Simple Material stream source";
476        Info = "
477        This model should be used for boundary streams.
478        Usually these streams are known and come from another process
479        units.
480
481        The user should specify:
482         * Total molar flow
483         * Temperature
484         * Pressure
485         * Molar composition
486";
487
488PARAMETERS
489        outer PP                                                as Plugin                       (Brief = "External Physical Properties", Type="PP");
490        outer NComp                             as Integer                      (Brief = "Number of chemical components", Lower = 1);
491                  M(NComp)                              as molweight    (Brief = "Component Mol Weight", Protected=true);
492                  ValidPhases                           as Switcher             (Brief = "Valid Phases for Flash Calculation", Valid = ["Vapour-Only", "Liquid-Only","Vapour-Liquid"], Default="Vapour-Liquid");
493       
494
495SET
496
497        M   = PP.MolecularWeight();
498
499VARIABLES
500
501        out Outlet                      as stream                       (Brief = "Outlet stream", PosX=1, PosY=0.5256, Symbol="_{out}",Protected=true);
502       
503        MolarComposition(NComp) as fraction                     (Brief = "Stream Molar Composition");
504        SumOfComposition as positive                    (Brief = "Sum of Stream Composition",Protected=true);
505        F                                                               as flow_mol             (Brief = "Stream Molar Flow Rate");
506        T                                                               as temperature  (Brief = "Stream Temperature");
507        T_Cdeg                                          as Real(Brief = "Temperature in °C", Lower=-250, Upper=5000);
508        P                                                               as pressure             (Brief = "Stream Pressure");
509       
510        x(NComp)                        as fraction                     (Brief = "Liquid Molar Fraction",Hidden=true);
511        y(NComp)                        as fraction                     (Brief = "Vapour Molar Fraction",Hidden=true);
512       
513
514EQUATIONS
515
516"Sum of Composition"
517        SumOfComposition = sum(MolarComposition);
518       
519"Stream Molar Composition"
520        Outlet.z = MolarComposition/sum(MolarComposition);
521
522
523switch ValidPhases
524       
525        case "Liquid-Only":
526
527"Vapour Fraction"
528        Outlet.v = 0;
529
530"Liquid Composition"
531        x = Outlet.z;
532
533"Vapour Composition"
534        y = Outlet.z;
535
536"Overall Enthalpy"
537        Outlet.h = PP.LiquidEnthalpy(Outlet.T, Outlet.P, x);
538
539
540        case "Vapour-Only":
541
542"Vapor Fraction"
543        Outlet.v = 1;
544
545"Liquid Composition"
546        x = Outlet.z;
547
548"Vapour Composition"
549        y = Outlet.z;
550
551"Overall Enthalpy"
552        Outlet.h = PP.VapourEnthalpy(Outlet.T, Outlet.P, y);
553
554
555        case "Vapour-Liquid":
556
557"Flash Calculation"
558        [Outlet.v, x, y] = PP.Flash(Outlet.T, Outlet.P, Outlet.z);
559
560"Overall Enthalpy"
561        Outlet.h = (1-Outlet.v)*PP.LiquidEnthalpy(Outlet.T, Outlet.P, x) + Outlet.v*PP.VapourEnthalpy(Outlet.T, Outlet.P, y);
562
563
564end
565
566"Temperature in °C"
567        T_Cdeg = Outlet.T/'K' - 273.15;
568
569"Equate Flow"
570        Outlet.F = F;
571
572"Equate Pressures"
573        Outlet.P = P;
574
575"Equate Temperatures"
576        Outlet.T = T;
577
578end
579
580Model simple_source2
581
582ATTRIBUTES
583        Pallete = true;
584        Icon = "icon/Source2";
585        Brief = "Simple Material stream source";
586        Info = "
587        This model should be used for boundary streams.
588        Usually these streams are known and come from another process
589        units.
590
591        The user should specify:
592         * Total molar flow
593         * Temperature
594         * Pressure
595         * Molar composition
596";
597
598PARAMETERS
599        outer PP                                                as Plugin                       (Brief = "External Physical Properties", Type="PP");
600        outer NComp                             as Integer                      (Brief = "Number of chemical components", Lower = 1);
601                  M(NComp)                              as molweight    (Brief = "Component Mol Weight", Protected=true);
602                  ValidPhases                           as Switcher             (Brief = "Valid Phases for Flash Calculation", Valid = ["Vapour-Only", "Liquid-Only","Vapour-Liquid"], Default="Vapour-Liquid");
603       
604
605SET
606
607        M   = PP.MolecularWeight();
608
609VARIABLES
610
611        out Outlet                      as stream                       (Brief = "Outlet stream", PosX=1, PosY=0.5256, Symbol="_{out}",Protected=true);
612       
613        MolarComposition(NComp) as fraction                     (Brief = "Stream Molar Composition");
614        SumOfComposition as positive                    (Brief = "Sum of Stream Composition",Protected=true);
615        F                                                               as flow_mol             (Brief = "Stream Molar Flow Rate");
616        T                                                               as temperature  (Brief = "Stream Temperature");
617        T_Cdeg                                          as Real(Brief = "Temperature in °C", Lower=-250, Upper=5000);
618        P                                                               as pressure             (Brief = "Stream Pressure");
619       
620        x(NComp)                        as fraction                     (Brief = "Liquid Molar Fraction",Hidden=true);
621        y(NComp)                        as fraction                     (Brief = "Vapour Molar Fraction",Hidden=true);
622       
623
624EQUATIONS
625
626"Sum of Composition"
627        SumOfComposition = sum(MolarComposition);
628       
629"Stream Molar Composition"
630        Outlet.z = MolarComposition/sum(MolarComposition);
631
632
633switch ValidPhases
634       
635        case "Liquid-Only":
636
637"Vapour Fraction"
638        Outlet.v = 0;
639
640"Liquid Composition"
641        x = Outlet.z;
642
643"Vapour Composition"
644        y = Outlet.z;
645
646"Overall Enthalpy"
647        Outlet.h = PP.LiquidEnthalpy(Outlet.T, Outlet.P, x);
648
649
650        case "Vapour-Only":
651
652"Vapor Fraction"
653        Outlet.v = 1;
654
655"Liquid Composition"
656        x = Outlet.z;
657
658"Vapour Composition"
659        y = Outlet.z;
660
661"Overall Enthalpy"
662        Outlet.h = PP.VapourEnthalpy(Outlet.T, Outlet.P, y);
663
664
665        case "Vapour-Liquid":
666
667"Flash Calculation"
668        [Outlet.v, x, y] = PP.Flash(Outlet.T, Outlet.P, Outlet.z);
669
670"Overall Enthalpy"
671        Outlet.h = (1-Outlet.v)*PP.LiquidEnthalpy(Outlet.T, Outlet.P, x) + Outlet.v*PP.VapourEnthalpy(Outlet.T, Outlet.P, y);
672
673
674end
675
676"Temperature in °C"
677        T_Cdeg = Outlet.T/'K' - 273.15;
678
679"Equate Flow"
680        Outlet.F = F;
681
682"Equate Pressures"
683        Outlet.P = P;
684
685"Equate Temperatures"
686        Outlet.T = T;
687
688end
689
690Model sink
691        ATTRIBUTES
692        Pallete = true;
693        Icon = "icon/Sink";
694        Brief = "Material stream sink";
695        Info = "
696        This model should be used for boundary streams when additional
697        information about the stream is desired.
698
699        Some of the additional informations calculated by this models are:
700         * Mass density
701         * Mass flow
702         * Mass compostions
703         * Specific volume
704         * Vapour fraction
705         * Volumetric flow
706         * Liquid and Vapour compositions
707        ";
708
709        PARAMETERS
710        outer PP                        as Plugin               (Brief = "External Physical Properties", Type="PP");
711        outer NComp             as Integer              (Brief = "Number of chemical components", Lower = 1);
712                  M(NComp)                              as molweight    (Brief = "Component Mol Weight", Protected=true);
713       
714        SET
715
716        M   = PP.MolecularWeight();
717       
718        VARIABLES
719        in Inlet                as stream               (Brief = "Inlet Stream", PosX=0, PosY=0.5308, Protected=true,Symbol="_{in}");
720        v                               as fraction             (Brief = "Vapourization fraction",Hidden=true);
721        x(NComp)                as fraction             (Brief = "Liquid Molar Fraction",Hidden=true);
722        y(NComp)                as fraction             (Brief = "Vapour Molar Fraction",Hidden=true);
723        zmass(NComp)    as fraction             (Brief = "Mass Fraction");
724        Mw                              as molweight    (Brief = "Average Mol Weight");
725        vm                              as volume_mol   (Brief = "Molar Volume");       
726        rho                             as dens_mass    (Brief = "Stream Mass Density");
727        rhom                    as dens_mol             (Brief = "Stream Molar Density");
728        Fw                              as flow_mass    (Brief = "Stream Mass Flow");
729        Fvol            as flow_vol     (Brief = "Volumetric Flow");
730        T_Cdeg                                          as Real(Brief = "Temperature in °C", Lower=-250, Upper=5000);
731
732        EQUATIONS
733        "Flash Calculation"
734        [v, x, y] = PP.FlashPH(Inlet.P, Inlet.h, Inlet.z);
735       
736        "Average Molecular Weight"
737        Mw = sum(M*Inlet.z);
738
739        "Molar Density"
740                rhom * vm = 1;
741               
742        "Mass or Molar Density"
743        rhom * Mw = rho;
744
745        "Flow Mass"
746        Fw      =  Mw*Inlet.F;
747
748        "Molar Volume"
749        vm = (1-v)*PP.LiquidVolume(Inlet.T, Inlet.P, x) + v*PP.VapourVolume(Inlet.T,Inlet.P,y);
750       
751        "Volumetric Flow"
752        Fvol = Inlet.F*vm ;
753       
754        "Mass Fraction"
755        zmass = M*Inlet.z / Mw;
756       
757        "Temperature in °C"
758        T_Cdeg = Inlet.T/'K' - 273.15;
759
760end
761
762Model sink2
763        ATTRIBUTES
764        Pallete = true;
765        Icon = "icon/Sink2";
766        Brief = "Material stream sink";
767        Info = "
768        This model should be used for boundary streams when additional
769        information about the stream is desired.
770
771        Some of the additional informations calculated by this models are:
772         * Mass density
773         * Mass flow
774         * Mass compostions
775         * Specific volume
776         * Vapour fraction
777         * Volumetric flow
778         * Liquid and Vapour compositions
779        ";
780
781        PARAMETERS
782        outer PP                        as Plugin               (Brief = "External Physical Properties", Type="PP");
783        outer NComp             as Integer              (Brief = "Number of chemical components", Lower = 1);
784                  M(NComp)                              as molweight    (Brief = "Component Mol Weight", Protected=true);
785       
786        SET
787
788        M   = PP.MolecularWeight();
789       
790        VARIABLES
791        in Inlet                as stream               (Brief = "Inlet Stream", PosX=1, PosY=0.5308, Protected=true,Symbol="_{in}");
792        v                               as fraction             (Brief = "Vapourization fraction",Hidden=true);
793        x(NComp)                as fraction             (Brief = "Liquid Molar Fraction",Hidden=true);
794        y(NComp)                as fraction             (Brief = "Vapour Molar Fraction",Hidden=true);
795        zmass(NComp)    as fraction             (Brief = "Mass Fraction");
796        Mw                              as molweight    (Brief = "Average Mol Weight");
797        vm                              as volume_mol   (Brief = "Molar Volume");       
798        rho                             as dens_mass    (Brief = "Stream Mass Density");
799        rhom                    as dens_mol             (Brief = "Stream Molar Density");
800        Fw                              as flow_mass    (Brief = "Stream Mass Flow");
801        Fvol            as flow_vol     (Brief = "Volumetric Flow");
802        T_Cdeg                                          as Real(Brief = "Temperature in °C", Lower=-250, Upper=5000);
803
804        EQUATIONS
805        "Flash Calculation"
806        [v, x, y] = PP.FlashPH(Inlet.P, Inlet.h, Inlet.z);
807       
808        "Average Molecular Weight"
809        Mw = sum(M*Inlet.z);
810
811        "Molar Density"
812                rhom * vm = 1;
813               
814        "Mass or Molar Density"
815        rhom * Mw = rho;
816
817        "Flow Mass"
818        Fw      =  Mw*Inlet.F;
819
820        "Molar Volume"
821        vm = (1-v)*PP.LiquidVolume(Inlet.T, Inlet.P, x) + v*PP.VapourVolume(Inlet.T,Inlet.P,y);
822       
823        "Volumetric Flow"
824        Fvol = Inlet.F*vm ;
825       
826        "Mass Fraction"
827        zmass = M*Inlet.z / Mw;
828       
829        "Temperature in °C"
830        T_Cdeg = Inlet.T/'K' - 273.15;
831
832end
833
834Model simple_sink
835        ATTRIBUTES
836        Pallete = true;
837        Icon = "icon/Sink";
838        Brief = "Simple material stream sink";
839        Info = "
840        This model should be used for boundary streams when no additional
841        information about the stream is desired.
842        ";
843       
844        VARIABLES
845        in Inlet                as stream       (Brief = "Inlet Stream", PosX=0, PosY=0.5308, Protected=true,Symbol="_{in}");
846end
847
848Model simple_sink2
849        ATTRIBUTES
850        Pallete = true;
851        Icon = "icon/Sink2";
852        Brief = "Simple material stream sink";
853        Info = "
854        This model should be used for boundary streams when no additional
855        information about the stream is desired.
856        ";
857       
858        VARIABLES
859        in Inlet                as stream       (Brief = "Inlet Stream", PosX=1, PosY=0.5308, Protected=true,Symbol="_{in}");
860       
861end
862
863Model energy_source
864        ATTRIBUTES
865        Pallete = true;
866        Icon = "icon/energy_source";
867        Brief = "Energy stream source";
868
869        VARIABLES
870        out OutletQ             as power(Brief = "Outlet energy stream", PosX=1, PosY=0.40, Symbol="_{out}");
871
872end
873
874Model energy_source2
875        ATTRIBUTES
876        Pallete = true;
877        Icon = "icon/energy_source2";
878        Brief = "Energy stream source";
879
880        VARIABLES
881        out OutletQ             as power(Brief = "Outlet energy stream", PosX=0, PosY=0.40, Symbol="_{out}");
882
883end
884
885Model energy_sink
886        ATTRIBUTES
887        Pallete = true;
888        Icon = "icon/Sink";
889        Brief = "Energy stream sink";
890
891        VARIABLES
892        in InletQ               as power(Brief = "Inlet energy stream", PosX=0, PosY=0.5308, Symbol="_{in}");
893
894end
895
896Model work_source
897        ATTRIBUTES
898        Pallete = true;
899        Icon = "icon/work_source";
900        Brief = "Work stream source";
901
902        VARIABLES
903        out Work                as power(Brief = "Outlet work stream", PosX=1, PosY=0.46, Symbol="_{out}");
904
905end
906
907Model info_stream
908        ATTRIBUTES
909        Pallete = true;
910        Icon = "icon/Info_Stream";
911        Brief = "Material stream information";
912        Info = "
913        This model should be used for middle streams when additional
914        information about the stream is desired.
915
916        Some of the additional informations calculated by this models are:
917         * Mass density
918         * Mass flow
919         * Mass compostions
920         * Specific volume
921         * Vapour fraction
922         * Volumetric flow
923         * Liquid and Vapour compositions
924         * Viscosity
925         * Heat Capacity
926         * Thermal Conductivity
927         * Temperature in Celsius Degrees
928        ";
929
930PARAMETERS
931        outer PP                        as Plugin                       (Brief = "External Physical Properties", Type="PP");
932        outer NComp     as Integer                      (Brief = "Number of chemical components", Lower = 1);
933                  M(NComp)                              as molweight    (Brief = "Component Mol Weight", Protected=true);
934       
935SET
936
937        M   = PP.MolecularWeight();
938       
939VARIABLES
940
941        in      Inlet           as stream               (Brief = "Inlet Stream", PosX=0, PosY=0.50, Protected=true , Symbol="_{in}");
942        out     Outlet          as stream               (Brief = "Outlet Stream", PosX=1, PosY=0.50, Protected=true , Symbol="_{out}");
943       
944        v                                               as fraction                     (Brief = "Vapourization fraction",Hidden=true);
945        x(NComp)                        as fraction                     (Brief = "Liquid Molar Fraction",Hidden=true);
946        y(NComp)                        as fraction                     (Brief = "Vapour Molar Fraction",Hidden=true);
947       
948        F(NComp)        as flow_mol             (Brief = "Component Molar Flow",Protected=true);
949        FwTotal         as flow_mass            (Brief = "Total Mass Flow",Protected=true);
950        Fw(NComp)               as flow_mass            (Brief = "Component Mass Flow",Protected=true);
951        FvolTotal           as flow_vol         (Brief = "Total Volumetric Flow",Protected=true);
952        T_Cdeg                                          as Real(Brief = "Temperature in °C", Lower=-250, Upper=5000, Protected=true);
953
954        Mu                                      as viscosity            (Brief="Stream Viscosity",Lower=0.0001, Symbol = "\mu",Protected=true);
955        Cp                                      as cp_mol                       (Brief="Stream Molar Heat Capacity", Upper=1e10,Protected=true);       
956        K                                               as conductivity         (Brief="Stream Thermal Conductivity", Default=1.0, Lower=1e-5, Upper=500,Protected=true);
957        Mw                                      as molweight            (Brief = "Average Mol Weight",Protected=true);
958        vm                                      as volume_mol   (Brief = "Molar Volume",Protected=true);       
959        rho                                     as dens_mass            (Brief = "Stream Mass Density",Protected=true);
960        rhom                                    as dens_mol             (Brief = "Stream Molar Density",Protected=true);
961        s                                               as entr_mol             (Brief = "Stream Entropy",Protected=true);
962        zmass(NComp)    as fraction                     (Brief = "Mass Fraction",Protected=true);
963       
964EQUATIONS
965
966"Flash Calculation"
967        [v, x, y] = PP.FlashPH(Inlet.P, Inlet.h, Inlet.z);
968       
969"Average Molecular Weight"
970        Mw = sum(M*Inlet.z);
971
972"Mass Density"
973        rho * ((1-v)/PP.LiquidDensity(Inlet.T,Inlet.P,x) + v/PP.VapourDensity(Inlet.T,Inlet.P,y)) = 1;
974       
975"Mass or Molar Density"
976        rhom * Mw = rho;
977
978"Total Flow Mass"
979        FwTotal =  Mw*Inlet.F;
980
981"Component Flow Mass"
982        Fw      =  FwTotal*zmass;
983
984"Molar Volume"
985        vm = (1-v)*PP.LiquidVolume(Inlet.T, Inlet.P, x) + v*PP.VapourVolume(Inlet.T,Inlet.P,y);
986       
987"Total Volumetric Flow"
988        FvolTotal = Inlet.F*vm ;
989       
990"Mass Fraction"
991        zmass = M*Inlet.z / Mw;
992
993"Stream Heat Capacity"
994        Cp      =       (1-v)*PP.LiquidCp(Inlet.T, Inlet.P, x) + v*PP.VapourCp(Inlet.T,Inlet.P,y);
995
996"Stream Viscosity"
997        Mu      =       (1-v)*PP.LiquidViscosity(Inlet.T, Inlet.P, x) + v*PP.VapourViscosity(Inlet.T,Inlet.P,y);
998
999"Stream ThermalConductivity"
1000        K       =       (1-v)*PP.LiquidThermalConductivity(Inlet.T, Inlet.P, x) + v*PP.VapourThermalConductivity(Inlet.T,Inlet.P,y);
1001
1002"Stream Overall Entropy"
1003        s = (1-v)*PP.LiquidEntropy(Inlet.T, Inlet.P, x) + v*PP.VapourEntropy(Inlet.T, Inlet.P, y);
1004       
1005"Temperature in °C"
1006        T_Cdeg = Inlet.T/'K' - 273.15;
1007
1008"Outlet Flow"
1009        Outlet.F = Inlet.F;
1010
1011"Component Molar Flow"
1012        F = Inlet.F*Inlet.z;
1013
1014"Outlet Temperature"
1015        Outlet.T = Inlet.T;
1016
1017"Outlet Pressure"
1018        Outlet.P = Inlet.P;
1019
1020"Outlet Vapour Fraction"
1021        Outlet.v = Inlet.v;
1022
1023"Outlet Enthalpy"
1024        Outlet.h = Inlet.h;
1025
1026"Outlet Composition"
1027        Outlet.z= Inlet.z;
1028
1029end
1030
1031Model sourceNoFlow
1032
1033ATTRIBUTES
1034        Pallete = true;
1035        Icon = "icon/SourceNoFlow";
1036        Brief = "Simple Material stream source with no flow.";
1037        Info = "
1038        This model should be used for boundary streams.
1039        Usually these streams are known and come from another process
1040        units.";
1041
1042PARAMETERS
1043        outer PP                                as Plugin                       (Brief = "External Physical Properties", Type="PP");
1044        outer NComp             as Integer                      (Brief = "Number of chemical components", Lower = 1);
1045
1046VARIABLES
1047
1048        out Outlet                      as stream                       (Brief = "Outlet stream", PosX=1, PosY=0.5256, Symbol="_{out}",Protected=true);
1049
1050EQUATIONS
1051
1052"Stream Molar Composition"
1053        Outlet.z = 1/NComp;
1054
1055"Stream Molar Enthalpy"
1056        Outlet.h = 0 * 'J/mol';
1057
1058"Stream Temperature"
1059        Outlet.T = 300 * 'K';
1060
1061"Stream Molar Flow"
1062        Outlet.F = 0 * 'kmol/h';
1063
1064"Stream Pressure"
1065        Outlet.P = 1 * 'atm';
1066
1067"Stream Vapour Fraction"
1068        Outlet.v = 0;
1069
1070end
1071
1072Model sinkNoFlow
1073        ATTRIBUTES
1074        Pallete = true;
1075        Icon = "icon/SinkNoFlow";
1076        Brief = "Simple material stream sink";
1077        Info = "
1078        This model should be used for seal an outlet material stream port.
1079        ";
1080       
1081        VARIABLES
1082        in Inlet                as stream       (Brief = "Inlet Stream", PosX=0, PosY=0.5308, Protected=true,Symbol="_{in}");
1083
1084EQUATIONS
1085"Stream Molar Flow"
1086        Inlet.F = 0 * 'kmol/h';
1087       
1088end
Note: See TracBrowser for help on using the repository browser.