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

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

updated source_testing

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