source: branches/gui/eml/stage_separators/flash.mso @ 796

Last change on this file since 796 was 796, checked in by gerson bicca, 13 years ago

updated flash model

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 13.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* Author: Paula B. Staudt
16* $Id: flash.mso 796 2009-07-18 21:08:44Z bicca $
17*--------------------------------------------------------------------*#
18
19using "streams";
20
21Model flash
22
23ATTRIBUTES
24        Pallete         = true;
25        Icon            = "icon/Flash";
26        Brief           = "Model of a Dynamic Flash Vessel.";
27        Info            =
28"== ASSUMPTIONS ==
29* perfect mixing of both phases;
30* thermodynamics equilibrium.
31
32== SET ==
33*Orientation: vessel position - vertical or horizontal;
34*Heads (bottom and top heads are identical)
35**elliptical: 2:1 elliptical heads (25% of vessel diameter);
36**hemispherical: hemispherical heads (50% of vessel diameter);
37**flat: flat heads (0% of vessel diameter);
38*Diameter: Vessel diameter;
39*Lenght: Side length of the cylinder shell;
40       
41== SPECIFY ==
42* the Inlet stream;
43* the outlet flows: OutletVapour.F and OutletLiquid.F;
44* the InletQ (the model requires an energy stream, also you can use a controller for setting the heat duty using the heat_flow model).
45
46== OPTIONAL ==
47* the Flash model has three control ports
48** TI OutletLiquid Temperature Indicator;
49** PI OutletLiquid Pressure Indicator;
50** LI Level Indicator;
51
52== INITIAL CONDITIONS ==
53* Initial_Temperature :  the Flash temperature (OutletLiquid.T);
54* Initial_Level : the Flash liquid level (Level);
55* Initial_Composition : (NoComps) OutletLiquid compositions.
56";
57       
58PARAMETERS
59outer PP                as Plugin       (Brief = "External Physical Properties", Type="PP");
60outer NComp     as Integer      (Brief = "Number of components", Lower = 1);
61
62        Mw(NComp)               as molweight    (Brief="Mol Weight", Hidden=true);
63        pi                      as positive             (Brief="Pi value", Default=3.141593,Hidden=true, Symbol="\pi");
64       
65        Orientation     as Switcher     (Valid=["vertical","horizontal"],Default="vertical");
66        Heads                   as Switcher     (Valid=["elliptical","hemispherical","flat"],Default="flat");
67        Diameter                as length               (Brief="Vessel diameter", Symbol="D_{i}");
68        Lenght                  as length               (Brief="Side length of the cylinder shell", Symbol="L_{vessel}");
69       
70        Vhead_elliptical                as volume               (Brief="Elliptical Head Total Volume",Hidden=true, Symbol="V_{head}^{elliptical}");
71        Vhead_hemispherical     as volume               (Brief="Hemispherical Head Total Volume",Hidden=true, Symbol="V_{head}^{hemispherical}");
72        Vcylinder                               as volume               (Brief="Cylinder Total Volume",Hidden=true, Symbol="V_{cylinder}");
73        radius                                  as length               (Brief="Vessel radius",Hidden=true, Symbol="R_{cylinder}");
74       
75        Levelpercent_Initial                    as positive     (Brief="Initial liquid height in Percent", Default = 0.70);
76        Temperature_Initial                             as temperature  (Brief="Initial Liquid Temperature", Default = 330);
77        Composition_Initial(NComp)              as fraction             (Brief="Initial Composition", Default = 0.10);
78
79SET
80
81        Mw=PP.MolecularWeight();
82
83        Vhead_elliptical        = (pi*Diameter^3)/12;
84        Vhead_hemispherical = (pi*Diameter^3)/6;
85        Vcylinder = 0.25*(pi*Diameter^2)*Lenght;
86        radius = 0.5*Diameter;
87
88VARIABLES
89
90in      Inlet                   as stream                       (Brief="Feed Stream", PosX=0, PosY=0.48, Symbol="_{in}");
91out     OutletLiquid    as liquid_stream        (Brief="Liquid outlet stream", PosX=0.43, PosY=1, Symbol="_{out}^{Liquid}");
92out     OutletVapour    as vapour_stream        (Brief="Vapour outlet stream", PosX=0.43, PosY=0, Symbol="_{out}^{Vapour}");
93in      InletQ                  as power                        (Brief="Heat Duty", PosX=1, PosY=0.81, Protected =true,Symbol="Q_{in}");
94
95        Vtotal                  as volume                       (Brief="Vessel total volume",Protected=true, Symbol="V_{total}");
96        Vfilled                 as volume                       (Brief="Vessel volume content",Protected=true, Symbol="V_{filled}");
97
98        TotalHoldup(NComp)              as mol  (Brief="Molar Holdup in the Vessel", Protected=true);
99        LiquidHoldup                    as mol  (Brief="Molar liquid holdup", Protected=true);
100        VapourHoldup                    as mol  (Brief="Molar vapour holdup", Protected=true);
101       
102        E                       as energy               (Brief="Total Energy Holdup in the Vessel", Protected=true);
103        vL                      as volume_mol   (Brief="Liquid Molar Volume", Protected=true);
104        vV                      as volume_mol   (Brief="Vapour Molar volume", Protected=true);
105        Level           as length               (Brief="liquid height", Protected=true);
106        Across          as area                 (Brief="Vessel cylinder shell Cross section area", Hidden=true, Symbol="A_{cross}");
107        vfrac           as positive     (Brief="Vapourization fraction", Symbol="\phi", Protected=true);
108        Pratio          as positive             (Brief = "Pressure Ratio", Symbol ="P_{ratio}", Protected=true);       
109        Pdrop           as press_delta  (Brief = "Pressure Drop", DisplayUnit = 'kPa', Symbol ="\Delta P", Protected=true);
110
111out     TI as control_signal    (Brief="Temperature Indicator", PosX=1, PosY=0.39, Protected=true);
112out     PI as control_signal    (Brief="Pressure Indicator", PosX=1, PosY=0.21, Protected=true);
113out     LI as control_signal    (Brief="Level Indicator", PosX=1, PosY=0.59, Protected=true);
114
115INITIAL
116
117"Initial level Percent"
118        LI = Levelpercent_Initial;
119       
120"Initial Outlet Liquid Temperature"
121        OutletLiquid.T = Temperature_Initial;
122       
123"Initial Outlet Liquid Composition Normalized"
124        OutletLiquid.z(1:NComp - 1) = Composition_Initial(1:NComp - 1)/sum(Composition_Initial);
125
126EQUATIONS
127
128switch Orientation
129
130case "vertical":
131
132"Vessel Cross Section Area"
133        Across = 0.25*(pi*Diameter^2);
134
135switch Heads
136
137case "elliptical":
138
139"Vessel Total Volume"
140        Vtotal = Vhead_elliptical +     Vcylinder;
141
142if Level < 0.25*Diameter then
143
144"Vessel Filled Volume"
145        Vfilled = 0.25*pi*(((Diameter*Level)/(0.25*Diameter))^2)*(0.25*Diameter-Level/3);
146
147else
148
149"Vessel Filled Volume"
150        Vfilled = 0.25*pi*(Diameter^2)*(Level - 0.25*Diameter/3);
151
152end
153
154case "hemispherical":
155
156"Vessel Total Volume"
157        Vtotal = Vhead_hemispherical + Vcylinder;
158
159if Level < 0.5*Diameter then
160
161"Vessel Filled Volume"
162        Vfilled = 0.25*pi*(Level^2)*(2*Diameter-4*Level/3);
163
164else
165
166"Vessel Filled Volume"
167        Vfilled = 0.25*pi*((2/3)*((0.5*Diameter)^3) - (0.25*(Diameter)^3) + Level*Diameter^2);
168
169end
170
171case "flat":
172
173"Vessel Total Volume"
174        Vtotal = Vcylinder;
175
176"Vessel Filled Volume"
177        Vfilled = Across*Level;
178
179end
180
181case "horizontal":
182
183"Vessel Cross Section Area"
184        Across = (radius^2)*acos((radius-Level)/radius)-(radius-Level)*sqrt((2*radius*Level-Level^2));
185
186switch Heads
187
188case "elliptical":
189
190"Vessel Total Volume"
191        Vtotal = Vhead_elliptical +     Vcylinder;
192
193"Vessel Filled Volume"
194        Vfilled = 0.5236*Level^2*(1.5*Diameter-Level) + Across*Lenght;
195
196case "hemispherical":
197
198"Vessel Total Volume"
199        Vtotal = Vhead_hemispherical + Vcylinder;
200
201"Vessel Filled Volume"
202        Vfilled = 1.0472*Level^2*(1.5*Diameter-Level) + Across*Lenght;
203
204case "flat":
205
206"Vessel Total Volume"
207        Vtotal = Vcylinder;
208
209"Vessel Filled Volume"
210        Vfilled = Across*Lenght;
211
212end
213
214end
215
216"Component Molar Balance"
217        diff(TotalHoldup)=Inlet.F*Inlet.z - OutletLiquid.F*OutletLiquid.z - OutletVapour.F*OutletVapour.z;
218       
219"Energy Balance"
220        diff(E) = Inlet.F*Inlet.h - OutletLiquid.F*OutletLiquid.h - OutletVapour.F*OutletVapour.h + InletQ;
221       
222"Molar Holdup"
223        TotalHoldup = LiquidHoldup*OutletLiquid.z + VapourHoldup*OutletVapour.z;
224       
225"Energy Holdup"
226        E = LiquidHoldup*OutletLiquid.h + VapourHoldup*OutletVapour.h - OutletLiquid.P*Vtotal;
227       
228"Mol fraction normalisation"
229        sum(OutletLiquid.z)=1.0;
230
231"Mol fraction normalisation"
232        sum(OutletLiquid.z)=sum(OutletVapour.z);
233
234"Vaporization Fraction"
235        OutletVapour.F = Inlet.F * vfrac;
236
237"Liquid Volume"
238        vL = PP.LiquidVolume(OutletLiquid.T, OutletLiquid.P, OutletLiquid.z);
239
240"Vapour Volume"
241        vV = PP.VapourVolume(OutletVapour.T, OutletVapour.P, OutletVapour.z);
242       
243"Chemical Equilibrium"
244        PP.LiquidFugacityCoefficient(OutletLiquid.T, OutletLiquid.P, OutletLiquid.z)*OutletLiquid.z =
245                PP.VapourFugacityCoefficient(OutletVapour.T, OutletVapour.P, OutletVapour.z)*OutletVapour.z;
246       
247"Thermal Equilibrium"
248        OutletVapour.T = OutletLiquid.T;
249       
250"Mechanical Equilibrium"
251        OutletVapour.P = OutletLiquid.P;
252
253"Pressure Drop"
254        OutletLiquid.P  = Inlet.P - Pdrop;
255
256"Pressure Ratio"
257        OutletLiquid.P = Inlet.P * Pratio;
258
259"Geometry Constraint"
260        Vtotal = LiquidHoldup * vL + VapourHoldup * vV;
261
262"Temperature indicator"
263        TI * 'K' = OutletLiquid.T;
264
265"Pressure indicator"
266        PI * 'atm' = OutletLiquid.P;
267
268"Level indicator"
269        LI*Vtotal= Vfilled;
270
271"Liquid Level"
272        LiquidHoldup * vL = Vfilled;
273
274end
275
276#*----------------------------------------------------------------------
277* Model of a steady-state flash.
278*---------------------------------------------------------------------*#
279Model flash_steady
280
281ATTRIBUTES
282        Pallete         = true;
283        Icon            = "icon/Flash";
284        Brief           = "Model of a static PH flash.";
285        Info            =
286"This model is for using the flashPH routine available on VRTherm.
287
288== Assumptions ==
289* perfect mixing of both phases;
290
291== Specify ==
292* The feed stream;
293* The heat duty;
294* The outlet pressure.
295";     
296
297PARAMETERS
298
299outer PP                        as Plugin(Brief = "External Physical Properties", Type="PP");
300outer NComp     as Integer;
301
302VARIABLES
303
304in      Inlet                                           as stream                               (Brief="Feed Stream", PosX=0, PosY=0.5421, Symbol="_{in}");
305out     OutletLiquid            as liquid_stream                (Brief="Liquid outlet stream", PosX=0.4790, PosY=1, Symbol="_{outL}");
306out     OutletVapour            as vapour_stream        (Brief="Vapour outlet stream", PosX=0.4877, PosY=0, Symbol="_{outV}");
307in      InletQ                                          as power                                (Brief="Rate of heat supply", PosX=1, PosY=0.7559, Symbol="_{in}");
308
309        vfrac           as fraction                     (Brief="Vaporization fraction", Symbol="\phi");
310        h                               as enth_mol             (Brief="Mixture enthalpy");
311        Pratio          as positive                     (Brief = "Pressure Ratio", Symbol ="P_{ratio}");       
312        Pdrop           as press_delta  (Brief = "Pressure Drop", DisplayUnit = 'kPa', Symbol ="\Delta P");
313
314EQUATIONS
315
316if vfrac > 0 and vfrac <1
317
318then
319"The flash calculation"
320        [vfrac, OutletLiquid.z, OutletVapour.z] = PP.Flash(OutletVapour.T, OutletVapour.P, Inlet.z);
321
322else
323"Chemical equilibrium"
324        [vfrac,OutletLiquid.z,OutletVapour.z]=PP.FlashPH(OutletLiquid.P,h,Inlet.z);
325
326end
327
328"Global Molar Balance"
329        Inlet.F = OutletVapour.F + OutletLiquid.F;
330
331"Vapour Fraction"
332        OutletVapour.F = Inlet.F * vfrac;
333
334"Energy Balance"
335        Inlet.F*(h - Inlet.h) = InletQ;
336        Inlet.F*h = Inlet.F*(1-vfrac)*OutletLiquid.h + Inlet.F*vfrac*OutletVapour.h;
337
338"Thermal Equilibrium"
339        OutletVapour.T = OutletLiquid.T;
340       
341"Mechanical Equilibrium"
342        OutletVapour.P = OutletLiquid.P;
343
344"Pressure Drop"
345        OutletLiquid.P  = Inlet.P - Pdrop;
346
347"Pressure Ratio"
348        OutletLiquid.P = Inlet.P * Pratio;
349
350end
351
352#*----------------------------------------------------------------------
353* Another model of a steady-state PH flash.
354* It is recommended to use [v,x,y]=PP.FlashPH(P,h,z) instead of.
355*---------------------------------------------------------------------*#
356Model FlashPHSteady
357        ATTRIBUTES
358        Pallete         = true;
359        Icon            = "icon/Flash";
360        Brief           = "Another model of a static PH flash.";
361        Info            =
362"This model shows how to model a pressure enthalpy flash
363directly with the EMSO modeling language.
364
365This model is for demonstration purposes only, the flashPH
366routine available on VRTherm is much more robust.
367
368== Assumptions ==
369* perfect mixing of both phases;
370
371== Specify ==
372* the feed stream;
373* the heat duty;
374* the outlet pressure.
375";     
376       
377        PARAMETERS
378outer PP as Plugin(Brief = "External Physical Properties", Type="PP");
379outer NComp as Integer;
380        B as Real(Default=1000, Brief="Regularization Factor");
381
382        VARIABLES
383in      Inlet as stream(Brief="Feed Stream", PosX=0, PosY=0.5421, Symbol="_{in}");
384out     OutletL as liquid_stream(Brief="Liquid outlet stream", PosX=0.4790, PosY=1, Symbol="_{outL}");
385out     OutletV as vapour_stream(Brief="Vapour outlet stream", PosX=0.4877, PosY=0, Symbol="_{outV}");
386in      InletQ as power (Brief="Rate of heat supply", PosX=1, PosY=0.7559, Symbol="_{in}");
387        vfrac as fraction(Brief="Vaporization fraction", Symbol="\phi");
388        vsat as Real(Lower=-0.1, Upper=1.1, Brief="Vaporization fraction if saturated", Symbol="\phi_{sat}");
389        Tsat as temperature(Lower=173, Upper=1473, Brief="Temperature if saturated");
390        xsat(NComp) as Real(Lower=0, Upper=1, Brief="Liquid composition if saturated");
391        ysat(NComp) as Real(Lower=0, Upper=1, Brief="Vapour composition if saturated");
392        Pratio as positive (Brief = "Pressure Ratio", Symbol ="P_{ratio}");     
393        Pdrop as press_delta (Brief = "Pressure Drop", DisplayUnit = 'kPa', Symbol ="\Delta P");
394       
395        zero_one as fraction(Brief="Regularization Variable");
396        one_zero as fraction(Brief="Regularization Variable");
397
398        EQUATIONS
399        "Chemical equilibrium"
400        PP.LiquidFugacityCoefficient(Tsat, OutletL.P, xsat)*xsat =
401                PP.VapourFugacityCoefficient(Tsat, OutletV.P, ysat)*ysat;
402
403        "Global Molar Balance"
404        Inlet.F = OutletV.F + OutletL.F;
405        OutletV.F = Inlet.F * vfrac;
406
407        "Component Molar Balance"
408        Inlet.F*Inlet.z = OutletL.F*xsat + OutletV.F*ysat;
409        sum(xsat) = sum(ysat);
410
411        "Energy Balance if saturated"
412        Inlet.F*Inlet.h  + InletQ =
413                Inlet.F*(1-vsat)*PP.LiquidEnthalpy(Tsat, OutletL.P, xsat) +
414                Inlet.F*vsat*PP.VapourEnthalpy(Tsat, OutletV.P, ysat);
415
416        "Real Energy Balance"
417        Inlet.F*Inlet.h  + InletQ =
418                Inlet.F*(1-vfrac)*OutletL.h + Inlet.F*vfrac*OutletV.h;
419
420        "Thermal Equilibrium"
421        OutletV.T = OutletL.T;
422       
423        "Mechanical Equilibrium"
424        OutletV.P = OutletL.P;
425
426        "Pressure Drop"
427        OutletL.P  = Inlet.P - Pdrop;
428
429        "Pressure Ratio"
430        OutletL.P = Inlet.P * Pratio;
431
432        # regularization functions
433        zero_one = (1 + tanh(B * vsat))/2;
434        one_zero = (1 - tanh(B * (vsat - 1)))/2;
435       
436        vfrac = zero_one * one_zero * vsat + 1 - one_zero;
437        OutletL.z = zero_one*one_zero*xsat + (1-zero_one*one_zero)*Inlet.z;
438        OutletV.z = zero_one*one_zero*ysat + (1-zero_one*one_zero)*Inlet.z;
439end
Note: See TracBrowser for help on using the repository browser.