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

Last change on this file since 797 was 797, checked in by gerson bicca, 14 years ago

updated static flash model

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 13.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 797 2009-07-18 21:19:35Z 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
276Model flash_steady
277
278ATTRIBUTES
279        Pallete         = true;
280        Icon            = "icon/Flash";
281        Brief           = "Model of a static PH flash.";
282        Info            =
283"This model is for using the flashPH routine available on VRTherm.
284
285== ASSUMPTIONS ==
286* perfect mixing of both phases;
287* thermodynamics equilibrium.
288* static model.
289
290== SPECIFY ==
291* The Inlet stream;
292* The heat duty;
293* The outlet pressure.
294";     
295
296PARAMETERS
297
298outer PP                as Plugin(Brief = "External Physical Properties", Type="PP");
299outer NComp     as Integer;
300
301VARIABLES
302
303in      Inlet                   as stream                       (Brief="Feed Stream", PosX=0, PosY=0.48, Symbol="_{in}");
304out     OutletLiquid    as liquid_stream        (Brief="Liquid outlet stream", PosX=0.43, PosY=1, Symbol="_{out}^{Liquid}");
305out     OutletVapour    as vapour_stream        (Brief="Vapour outlet stream", PosX=0.43, PosY=0, Symbol="_{out}^{Vapour}");
306in      InletQ                  as power                        (Brief="Heat Duty", PosX=1, PosY=0.81, Protected =true,Symbol="Q_{in}");
307
308        vfrac           as fraction             (Brief="Vaporization fraction", Symbol="\phi", Protected =true);
309        h                       as enth_mol             (Brief="Mixture enthalpy", Hidden =true);
310        Pratio          as positive     (Brief = "Pressure Ratio", Symbol ="P_{ratio}", Protected =true);       
311        Pdrop           as press_delta  (Brief = "Pressure Drop", DisplayUnit = 'kPa', Symbol ="\Delta P", Protected =true);
312
313EQUATIONS
314
315if vfrac > 0 and vfrac <1
316
317then
318"The flash calculation"
319        [vfrac, OutletLiquid.z, OutletVapour.z] = PP.Flash(OutletVapour.T, OutletVapour.P, Inlet.z);
320
321else
322"Chemical equilibrium"
323        [vfrac,OutletLiquid.z,OutletVapour.z]=PP.FlashPH(OutletLiquid.P,h,Inlet.z);
324
325end
326
327"Global Molar Balance"
328        Inlet.F = OutletVapour.F + OutletLiquid.F;
329
330"Vapour Fraction"
331        OutletVapour.F = Inlet.F * vfrac;
332
333"Energy Balance"
334        Inlet.F*(h - Inlet.h) = InletQ;
335        Inlet.F*h = Inlet.F*(1-vfrac)*OutletLiquid.h + Inlet.F*vfrac*OutletVapour.h;
336
337"Thermal Equilibrium"
338        OutletVapour.T = OutletLiquid.T;
339       
340"Mechanical Equilibrium"
341        OutletVapour.P = OutletLiquid.P;
342
343"Pressure Drop"
344        OutletLiquid.P  = Inlet.P - Pdrop;
345
346"Pressure Ratio"
347        OutletLiquid.P = Inlet.P * Pratio;
348
349end
350
351Model FlashPHSteady
352        ATTRIBUTES
353        Pallete         = false;
354        Icon            = "icon/Flash";
355        Brief           = "Another model of a static PH flash.";
356        Info            =
357"This model shows how to model a pressure enthalpy flash
358directly with the EMSO modeling language.
359
360This model is for demonstration purposes only, the flashPH
361routine available on VRTherm is much more robust.
362
363== Assumptions ==
364* perfect mixing of both phases;
365
366== Specify ==
367* the feed stream;
368* the heat duty;
369* the outlet pressure.
370";     
371       
372        PARAMETERS
373outer PP as Plugin(Brief = "External Physical Properties", Type="PP");
374outer NComp as Integer;
375        B as Real(Default=1000, Brief="Regularization Factor");
376
377        VARIABLES
378in      Inlet as stream(Brief="Feed Stream", PosX=0, PosY=0.5421, Symbol="_{in}");
379out     OutletL as liquid_stream(Brief="Liquid outlet stream", PosX=0.4790, PosY=1, Symbol="_{outL}");
380out     OutletV as vapour_stream(Brief="Vapour outlet stream", PosX=0.4877, PosY=0, Symbol="_{outV}");
381in      InletQ as power (Brief="Rate of heat supply", PosX=1, PosY=0.7559, Symbol="_{in}");
382        vfrac as fraction(Brief="Vaporization fraction", Symbol="\phi");
383        vsat as Real(Lower=-0.1, Upper=1.1, Brief="Vaporization fraction if saturated", Symbol="\phi_{sat}");
384        Tsat as temperature(Lower=173, Upper=1473, Brief="Temperature if saturated");
385        xsat(NComp) as Real(Lower=0, Upper=1, Brief="Liquid composition if saturated");
386        ysat(NComp) as Real(Lower=0, Upper=1, Brief="Vapour composition if saturated");
387        Pratio as positive (Brief = "Pressure Ratio", Symbol ="P_{ratio}");     
388        Pdrop as press_delta (Brief = "Pressure Drop", DisplayUnit = 'kPa', Symbol ="\Delta P");
389       
390        zero_one as fraction(Brief="Regularization Variable");
391        one_zero as fraction(Brief="Regularization Variable");
392
393        EQUATIONS
394        "Chemical equilibrium"
395        PP.LiquidFugacityCoefficient(Tsat, OutletL.P, xsat)*xsat =
396                PP.VapourFugacityCoefficient(Tsat, OutletV.P, ysat)*ysat;
397
398        "Global Molar Balance"
399        Inlet.F = OutletV.F + OutletL.F;
400        OutletV.F = Inlet.F * vfrac;
401
402        "Component Molar Balance"
403        Inlet.F*Inlet.z = OutletL.F*xsat + OutletV.F*ysat;
404        sum(xsat) = sum(ysat);
405
406        "Energy Balance if saturated"
407        Inlet.F*Inlet.h  + InletQ =
408                Inlet.F*(1-vsat)*PP.LiquidEnthalpy(Tsat, OutletL.P, xsat) +
409                Inlet.F*vsat*PP.VapourEnthalpy(Tsat, OutletV.P, ysat);
410
411        "Real Energy Balance"
412        Inlet.F*Inlet.h  + InletQ =
413                Inlet.F*(1-vfrac)*OutletL.h + Inlet.F*vfrac*OutletV.h;
414
415        "Thermal Equilibrium"
416        OutletV.T = OutletL.T;
417       
418        "Mechanical Equilibrium"
419        OutletV.P = OutletL.P;
420
421        "Pressure Drop"
422        OutletL.P  = Inlet.P - Pdrop;
423
424        "Pressure Ratio"
425        OutletL.P = Inlet.P * Pratio;
426
427        # regularization functions
428        zero_one = (1 + tanh(B * vsat))/2;
429        one_zero = (1 - tanh(B * (vsat - 1)))/2;
430       
431        vfrac = zero_one * one_zero * vsat + 1 - one_zero;
432        OutletL.z = zero_one*one_zero*xsat + (1-zero_one*one_zero)*Inlet.z;
433        OutletV.z = zero_one*one_zero*ysat + (1-zero_one*one_zero)*Inlet.z;
434end
Note: See TracBrowser for help on using the repository browser.