source: trunk/eml/stage_separators/flash.mso @ 334

Last change on this file since 334 was 334, checked in by Argimiro Resende Secchi, 16 years ago

Add vfrac in dynamic flash.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 9.0 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* Author: Paula B. Staudt
16* $Id: flash.mso 334 2007-08-05 23:10:55Z arge $
17*--------------------------------------------------------------------*#
18
19using "streams";
20
21Model flash
22        ATTRIBUTES
23        Pallete         = true;
24        Icon            = "icon/Flash";
25        Brief           = "Model of a dynamic flash.";
26        Info            =
27        "Assumptions:
28         * both phases are perfectly mixed.
29       
30        Specify:
31         * the feed stream;
32         * the outlet flows: OutletV.F and OutletL.F.
33
34        Initial Conditions:
35         * the flash initial temperature (OutletL.T);
36         * the flash initial level (Level);
37         * (NoComps - 1) OutletL (OR OutletV) compositions.
38        ";
39       
40        PARAMETERS
41outer PP as Plugin (Brief = "External Physical Properties", Type="PP");
42outer NComp as Integer (Brief = "Number of chemical components", Lower = 1);
43        V as volume (Brief="Total Volume of the flash");
44        Mw(NComp) as molweight;
45        orientation as Switcher (Valid=["vertical","horizontal"],Default="vertical");
46        diameter as length (Brief="Vessel diameter");
47
48        SET
49        Mw=PP.MolecularWeight();
50
51        VARIABLES
52in      Inlet as stream(Brief="Feed Stream", PosX=0, PosY=0.5421);
53out     OutletL as liquid_stream(Brief="Liquid outlet stream", PosX=0.4790, PosY=1);
54out     OutletV as vapour_stream(Brief="Vapour outlet stream", PosX=0.4877, PosY=0);
55in      InletQ as energy_stream (Brief="Rate of heat supply", PosX=1, PosY=0.7559);
56
57        M(NComp) as mol (Brief="Molar Holdup in the tray");
58        ML as mol (Brief="Molar liquid holdup");
59        MV as mol (Brief="Molar vapour holdup");
60        E as energy (Brief="Total Energy Holdup on tray");
61        vL as volume_mol (Brief="Liquid Molar Volume");
62        vV as volume_mol (Brief="Vapour Molar volume");
63        Level as length (Brief="liquid height");
64        Across as area (Brief="Flash Cross section area");
65        vfrac as positive (Brief="Vapourization fraction");
66
67        EQUATIONS
68        "Component Molar Balance"
69        diff(M)=Inlet.F*Inlet.z - OutletL.F*OutletL.z - OutletV.F*OutletV.z;
70       
71        "Energy Balance"
72        diff(E) = Inlet.F*Inlet.h - OutletL.F*OutletL.h - OutletV.F*OutletV.h + InletQ.Q;
73       
74        "Molar Holdup"
75        M = ML*OutletL.z + MV*OutletV.z;
76       
77        "Energy Holdup"
78        E = ML*OutletL.h + MV*OutletV.h - OutletL.P*V;
79       
80        "Mol fraction normalisation"
81        sum(OutletL.z)=1.0;
82
83        "Mol fraction normalisation"
84        sum(OutletL.z)=sum(OutletV.z);
85
86        "Vaporization Fraction"
87        OutletV.F = Inlet.F * vfrac;
88
89        "Liquid Volume"
90        vL = PP.LiquidVolume(OutletL.T, OutletL.P, OutletL.z);
91
92        "Vapour Volume"
93        vV = PP.VapourVolume(OutletV.T, OutletV.P, OutletV.z);
94       
95        "Chemical Equilibrium"
96        PP.LiquidFugacityCoefficient(OutletL.T, OutletL.P, OutletL.z)*OutletL.z =
97                PP.VapourFugacityCoefficient(OutletV.T, OutletV.P, OutletV.z)*OutletV.z;
98       
99        "Thermal Equilibrium"
100        OutletV.T = OutletL.T;
101       
102        "Mechanical Equilibrium"
103        OutletV.P = OutletL.P;
104       
105        "Geometry Constraint"
106        V = ML * vL + MV * vV;
107
108        switch orientation
109        case "vertical":
110        "Cross Section Area"
111                Across = 0.5 * asin(1) * diameter^2;
112       
113        "Liquid Level"
114                ML * vL = Across * Level;
115
116        case "horizontal":
117        "Cylindrical Side Area"
118                Across = 0.25*diameter^2 * (asin(1) - asin((diameter - 2*Level)/diameter)) +
119                                (Level - 0.5*diameter)*sqrt(Level*(diameter - Level));
120
121        "Liquid Level"
122                0.5 * asin(1) * diameter^2 * ML* vL = Across * V;
123        end
124end
125
126#*----------------------------------------------------------------------
127* Model of a  Steady State flash
128*---------------------------------------------------------------------*#
129Model flash_steady
130        ATTRIBUTES
131        Pallete         = true;
132        Icon            = "icon/Flash";
133        Brief           = "Model of a Steady State flash.";
134        Info            =
135        "Assumptions:
136         * both phases are perfectly mixed.
137       
138        Specify:
139         * the feed stream;
140         * the outlet pressure (OutletV.P);
141         * the outlet temperature OR the heat supplied.
142        ";
143       
144        PARAMETERS
145outer PP as Plugin(Brief = "External Physical Properties", Type="PP");
146       
147        VARIABLES
148in      Inlet as stream(Brief="Feed Stream", PosX=0, PosY=0.5421);
149out     OutletL as liquid_stream(Brief="Liquid outlet stream", PosX=0.4790, PosY=1);
150out     OutletV as vapour_stream(Brief="Vapour outlet stream", PosX=0.4877, PosY=0);
151in      InletQ as energy_stream (Brief="Rate of heat supply", PosX=1, PosY=0.7559);
152        vfrac as fraction (Brief="Vapourization fraction");
153
154        EQUATIONS
155        "The flash calculation"
156        [vfrac, OutletL.z, OutletV.z] = PP.Flash(OutletV.T, OutletV.P, Inlet.z);
157       
158        "Global Molar Balance"
159        Inlet.F = OutletV.F + OutletL.F;
160       
161        "Vaporization Fraction"
162        OutletV.F = Inlet.F * vfrac;
163       
164        "Energy Balance"
165        Inlet.F*Inlet.h  + InletQ.Q = OutletL.F*OutletL.h + OutletV.F*OutletV.h;
166       
167        "Thermal Equilibrium"
168        OutletV.T = OutletL.T;
169       
170        "Mechanical Equilibrium"
171        OutletV.P = OutletL.P;
172end
173
174#*----------------------------------------------------------------------
175* Model of a steady-state PH flash.
176*---------------------------------------------------------------------*#
177Model FlashPHSteady
178        ATTRIBUTES
179        Pallete         = true;
180        Icon            = "icon/Flash";
181        Brief           = "Model of a static PH flash.";
182        Info            = "
183        This model is for using the flashPH
184        routine available on VRTherm.
185
186        Assumptions:
187         * perfect mixing of both phases;
188
189        Specify:
190         * the feed stream;
191         * the heat duty;
192         * the outlet pressure.
193        ";     
194
195        PARAMETERS
196outer PP as Plugin(Brief = "External Physical Properties", Type="PP");
197outer NComp as Integer;
198
199        VARIABLES
200in      Inlet as stream(Brief="Feed Stream", PosX=0, PosY=0.5421);
201out     OutletL as liquid_stream(Brief="Liquid outlet stream", PosX=0.4790, PosY=1);
202out     OutletV as vapour_stream(Brief="Vapour outlet stream", PosX=0.4877, PosY=0);
203in      InletQ as energy_stream (Brief="Rate of heat supply", PosX=1, PosY=0.7559);
204        vfrac as fraction(Brief="Vaporization fraction");
205        h as enth_mol(Brief="Mixture enthalpy");
206
207        EQUATIONS
208
209        "Chemical equilibrium"
210        [vfrac,OutletL.z,OutletV.z]=PP.FlashPH(OutletL.P,h,Inlet.z);
211
212        "Global Molar Balance"
213        Inlet.F = OutletV.F + OutletL.F;
214        OutletV.F = Inlet.F * vfrac;
215
216        "Energy Balance"
217        Inlet.F*(h - Inlet.h) = InletQ.Q;
218        Inlet.F*h = Inlet.F*(1-vfrac)*OutletL.h + Inlet.F*vfrac*OutletV.h;
219
220        "Thermal Equilibrium"
221        OutletV.T = OutletL.T;
222       
223        "Mechanical Equilibrium"
224        OutletV.P = OutletL.P;
225end
226
227#*----------------------------------------------------------------------
228* Another model of a steady-state PH flash.
229* It is recommended to use [v,x,y]=PP.FlashPH(P,h,z) instead of.
230*---------------------------------------------------------------------*#
231Model FlashPHSteadyA
232        ATTRIBUTES
233        Pallete         = true;
234        Icon            = "icon/Flash";
235        Brief           = "Another model of a static PH flash.";
236        Info            = "
237        This model shows how to model a pressure enthalpy flash
238        directly with the EMSO modeling language.
239
240        This model is for demonstration purposes only, the flashPH
241        routine available on VRTherm is much more robust.
242
243        Assumptions:
244         * perfect mixing of both phases;
245
246        Specify:
247         * the feed stream;
248         * the heat duty;
249         * the outlet pressure.
250        ";     
251       
252        PARAMETERS
253outer PP as Plugin(Brief = "External Physical Properties", Type="PP");
254outer NComp as Integer;
255        B as Real(Default=1000, Brief="Regularization Factor");
256
257        VARIABLES
258in      Inlet as stream(Brief="Feed Stream", PosX=0, PosY=0.5421);
259out     OutletL as liquid_stream(Brief="Liquid outlet stream", PosX=0.4790, PosY=1);
260out     OutletV as vapour_stream(Brief="Vapour outlet stream", PosX=0.4877, PosY=0);
261in      InletQ as energy_stream (Brief="Rate of heat supply", PosX=1, PosY=0.7559);
262        vfrac as fraction(Brief="Vaporization fraction");
263        vsat as Real(Lower=-0.1, Upper=1.1, Brief="Vaporization fraction if saturated");
264        Tsat as temperature(Lower=173, Upper=1473, Brief="Temperature if saturated");
265        xsat(NComp) as Real(Lower=0, Upper=1, Brief="Liquid composition if saturated");
266        ysat(NComp) as Real(Lower=0, Upper=1, Brief="Vapour composition if saturated");
267       
268        zero_one as fraction(Brief="Regularization Variable");
269        one_zero as fraction(Brief="Regularization Variable");
270
271        EQUATIONS
272        "Chemical equilibrium"
273        PP.LiquidFugacityCoefficient(Tsat, OutletL.P, xsat)*xsat =
274                PP.VapourFugacityCoefficient(Tsat, OutletV.P, ysat)*ysat;
275
276        "Global Molar Balance"
277        Inlet.F = OutletV.F + OutletL.F;
278        OutletV.F = Inlet.F * vfrac;
279
280        "Component Molar Balance"
281        Inlet.F*Inlet.z = OutletL.F*xsat + OutletV.F*ysat;
282        sum(xsat) = sum(ysat);
283
284        "Energy Balance if saturated"
285        Inlet.F*Inlet.h  + InletQ.Q =
286                Inlet.F*(1-vsat)*PP.LiquidEnthalpy(Tsat, OutletL.P, xsat) +
287                Inlet.F*vsat*PP.VapourEnthalpy(Tsat, OutletV.P, ysat);
288
289        "Real Energy Balance"
290        Inlet.F*Inlet.h  + InletQ.Q =
291                Inlet.F*(1-vfrac)*OutletL.h + Inlet.F*vfrac*OutletV.h;
292
293        "Thermal Equilibrium"
294        OutletV.T = OutletL.T;
295       
296        "Mechanical Equilibrium"
297        OutletV.P = OutletL.P;
298       
299        # regularization functions
300        zero_one = (1 + tanh(B * vsat))/2;
301        one_zero = (1 - tanh(B * (vsat - 1)))/2;
302       
303        vfrac = zero_one * one_zero * vsat + 1 - one_zero;
304        OutletL.z = zero_one*one_zero*xsat + (1-zero_one*one_zero)*Inlet.z;
305        OutletV.z = zero_one*one_zero*ysat + (1-zero_one*one_zero)*Inlet.z;
306end
Note: See TracBrowser for help on using the repository browser.