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

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

updated dynamic models

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 10.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* Author: Paula B. Staudt
16* $Id: flash.mso 879 2009-11-09 16:11:31Z bicca $
17*--------------------------------------------------------------------*#
18
19using "tank";
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        Gconst          as acceleration (Brief="Gravity Acceleration",Default=9.81,Hidden=true);
64       
65        Levelpercent_Initial                    as positive     (Brief="Initial liquid height in Percent", Default = 0.70);
66        Temperature_Initial                             as temperature  (Brief="Initial Liquid Temperature", Default = 330);
67        Composition_Initial(NComp)              as fraction             (Brief="Initial Composition", Default = 0.10);
68
69SET
70
71        Mw=PP.MolecularWeight();
72
73        Gconst  = 9.81 * 'm/(s^2)';
74
75VARIABLES
76
77        Geometry                as VesselVolume (Brief="Vessel Geometry", Symbol=" ");
78
79in      Inlet                   as stream                       (Brief="Feed Stream", PosX=0, PosY=0.48, Symbol="_{in}");
80out     OutletLiquid    as liquid_stream        (Brief="Liquid outlet stream", PosX=0.43, PosY=1, Symbol="_{out}^{Liquid}");
81out     OutletVapour    as vapour_stream        (Brief="Vapour outlet stream", PosX=0.43, PosY=0, Symbol="_{out}^{Vapour}");
82in      InletQ                  as power                        (Brief="Heat Duty", PosX=1, PosY=0.81, Protected =true,Symbol="Q_{in}");
83
84        TotalHoldup(NComp)              as mol  (Brief="Molar Holdup in the Vessel", Protected=true);
85        LiquidHoldup                    as mol  (Brief="Molar liquid holdup", Protected=true);
86        VapourHoldup                    as mol  (Brief="Molar vapour holdup", Protected=true);
87       
88        E                       as energy               (Brief="Total Energy Holdup in the Vessel", Protected=true);
89        vL                      as volume_mol   (Brief="Liquid Molar Volume", Protected=true);
90        vV                      as volume_mol   (Brief="Vapour Molar volume", Protected=true);
91        vfrac           as positive     (Brief="Vapourization fraction", Symbol="\phi", Protected=true);
92        Pratio          as positive             (Brief = "Pressure Ratio", Symbol ="P_{ratio}", Protected=true);       
93        Pdrop           as press_delta  (Brief = "Pressure Drop", DisplayUnit = 'kPa', Symbol ="\Delta P", Protected=true);
94
95        Peq             as pressure             (Brief="Equilibrium pressure on the liquid surface", Protected=true, Symbol="\Delta P_{eq}");
96        Pstatic         as pressure             (Brief="Static head at the bottom of the tank", Protected = true, Symbol="P_{static}^{Liquid}");
97
98out     TI as control_signal    (Brief="Temperature Indicator", PosX=1, PosY=0.39, Protected=true);
99out     PI as control_signal    (Brief="Pressure Indicator", PosX=1, PosY=0.21, Protected=true);
100out     LI as control_signal    (Brief="Level Indicator", PosX=1, PosY=0.59, Protected=true);
101
102INITIAL
103
104"Initial level Percent"
105        LI = Levelpercent_Initial;
106       
107"Initial Outlet Liquid Temperature"
108        OutletLiquid.T = Temperature_Initial;
109       
110"Initial Outlet Liquid Composition Normalized"
111        OutletLiquid.z(1:NComp - 1) = Composition_Initial(1:NComp - 1)/sum(Composition_Initial);
112
113EQUATIONS
114
115"Component Molar Balance"
116        diff(TotalHoldup)=Inlet.F*Inlet.z - OutletLiquid.F*OutletLiquid.z - OutletVapour.F*OutletVapour.z;
117       
118"Energy Balance"
119        diff(E) = Inlet.F*Inlet.h - OutletLiquid.F*OutletLiquid.h - OutletVapour.F*OutletVapour.h + InletQ;
120       
121"Molar Holdup"
122        TotalHoldup = LiquidHoldup*OutletLiquid.z + VapourHoldup*OutletVapour.z;
123       
124"Energy Holdup"
125        E = LiquidHoldup*OutletLiquid.h + VapourHoldup*OutletVapour.h - OutletLiquid.P*Geometry.Vtotal;
126       
127"Mol fraction normalisation"
128        sum(OutletLiquid.z)=1.0;
129
130"Mol fraction normalisation"
131        sum(OutletLiquid.z)=sum(OutletVapour.z);
132
133"Vaporization Fraction"
134        OutletVapour.F = Inlet.F * vfrac;
135
136"Liquid Volume"
137        vL = PP.LiquidVolume(OutletLiquid.T, Peq, OutletLiquid.z);
138
139"Vapour Volume"
140        vV = PP.VapourVolume(OutletVapour.T, Peq, OutletVapour.z);
141       
142"Chemical Equilibrium"
143        PP.LiquidFugacityCoefficient(OutletLiquid.T, Peq, OutletLiquid.z)*OutletLiquid.z =
144                PP.VapourFugacityCoefficient(OutletVapour.T, Peq, OutletVapour.z)*OutletVapour.z;
145       
146"Thermal Equilibrium"
147        OutletVapour.T = OutletLiquid.T;
148
149"Mechanical Equilibrium for the Vapour Phase"
150        OutletVapour.P = Peq;
151       
152"Static Head"   
153        Pstatic = PP.LiquidDensity(OutletLiquid.T, Peq, OutletLiquid.z) * Gconst * Geometry.Level;
154
155"Mechanical Equilibrium for the Liquid Phase"
156        OutletLiquid.P = Peq + Pstatic;
157
158"Pressure Drop"
159        OutletLiquid.P  = Inlet.P - Pdrop;
160
161"Pressure Ratio"
162        OutletLiquid.P = Inlet.P * Pratio;
163
164"Geometry Constraint"
165        Geometry.Vtotal = LiquidHoldup * vL + VapourHoldup * vV;
166
167"Temperature indicator"
168        TI * 'K' = OutletLiquid.T;
169
170"Pressure indicator"
171        PI * 'atm' = OutletLiquid.P;
172
173"Level indicator"
174        LI*Geometry.Vtotal= Geometry.Vfilled;
175
176"Liquid Level"
177        LiquidHoldup * vL = Geometry.Vfilled;
178
179end
180
181Model flash_steady
182
183ATTRIBUTES
184        Pallete         = true;
185        Icon            = "icon/Flash";
186        Brief           = "Model of a static PH flash.";
187        Info            =
188"This model is for using the flashPH routine available on VRTherm.
189
190== ASSUMPTIONS ==
191* perfect mixing of both phases;
192* thermodynamics equilibrium.
193* static model.
194
195== SPECIFY ==
196* The Inlet stream;
197* The heat duty;
198* The outlet pressure.
199";     
200
201PARAMETERS
202
203outer PP                as Plugin(Brief = "External Physical Properties", Type="PP");
204outer NComp     as Integer;
205
206VARIABLES
207
208in      Inlet                   as stream                       (Brief="Feed Stream", PosX=0, PosY=0.48, Symbol="_{in}");
209out     OutletLiquid    as liquid_stream        (Brief="Liquid outlet stream", PosX=0.43, PosY=1, Symbol="_{out}^{Liquid}");
210out     OutletVapour    as vapour_stream        (Brief="Vapour outlet stream", PosX=0.43, PosY=0, Symbol="_{out}^{Vapour}");
211in      InletQ                  as power                        (Brief="Heat Duty", PosX=1, PosY=0.81, Protected =true,Symbol="Q_{in}");
212
213        vfrac           as fraction             (Brief="Vaporization fraction", Symbol="\phi", Protected =true);
214        h                       as enth_mol             (Brief="Mixture enthalpy", Hidden =true);
215        Pratio          as positive     (Brief = "Pressure Ratio", Symbol ="P_{ratio}", Protected =true);       
216        Pdrop           as press_delta  (Brief = "Pressure Drop", DisplayUnit = 'kPa', Symbol ="\Delta P", Protected =true);
217
218EQUATIONS
219
220if vfrac > 0 and vfrac <1
221
222then
223"The flash calculation"
224        [vfrac, OutletLiquid.z, OutletVapour.z] = PP.Flash(OutletVapour.T, OutletVapour.P, Inlet.z);
225
226else
227"Chemical equilibrium"
228        [vfrac,OutletLiquid.z,OutletVapour.z]=PP.FlashPH(OutletLiquid.P,h,Inlet.z);
229
230end
231
232"Global Molar Balance"
233        Inlet.F = OutletVapour.F + OutletLiquid.F;
234
235"Vapour Fraction"
236        OutletVapour.F = Inlet.F * vfrac;
237
238"Energy Balance"
239        Inlet.F*(h - Inlet.h) = InletQ;
240        Inlet.F*h = Inlet.F*(1-vfrac)*OutletLiquid.h + Inlet.F*vfrac*OutletVapour.h;
241
242"Thermal Equilibrium"
243        OutletVapour.T = OutletLiquid.T;
244       
245"Mechanical Equilibrium"
246        OutletVapour.P = OutletLiquid.P;
247
248"Pressure Drop"
249        OutletLiquid.P  = Inlet.P - Pdrop;
250
251"Pressure Ratio"
252        OutletLiquid.P = Inlet.P * Pratio;
253
254end
255
256Model FlashPHSteady
257        ATTRIBUTES
258        Pallete         = false;
259        Icon            = "icon/Flash";
260        Brief           = "Another model of a static PH flash.";
261        Info            =
262"This model shows how to model a pressure enthalpy flash
263directly with the EMSO modeling language.
264
265This model is for demonstration purposes only, the flashPH
266routine available on VRTherm is much more robust.
267
268== Assumptions ==
269* perfect mixing of both phases;
270
271== Specify ==
272* the feed stream;
273* the heat duty;
274* the outlet pressure.
275";     
276       
277        PARAMETERS
278outer PP as Plugin(Brief = "External Physical Properties", Type="PP");
279outer NComp as Integer;
280        B as Real(Default=1000, Brief="Regularization Factor");
281
282        VARIABLES
283in      Inlet as stream(Brief="Feed Stream", PosX=0, PosY=0.5421, Symbol="_{in}");
284out     OutletL as liquid_stream(Brief="Liquid outlet stream", PosX=0.4790, PosY=1, Symbol="_{outL}");
285out     OutletV as vapour_stream(Brief="Vapour outlet stream", PosX=0.4877, PosY=0, Symbol="_{outV}");
286in      InletQ as power (Brief="Rate of heat supply", PosX=1, PosY=0.7559, Symbol="_{in}");
287        vfrac as fraction(Brief="Vaporization fraction", Symbol="\phi");
288        vsat as Real(Lower=-0.1, Upper=1.1, Brief="Vaporization fraction if saturated", Symbol="\phi_{sat}");
289        Tsat as temperature(Lower=173, Upper=1473, Brief="Temperature if saturated");
290        xsat(NComp) as Real(Lower=0, Upper=1, Brief="Liquid composition if saturated");
291        ysat(NComp) as Real(Lower=0, Upper=1, Brief="Vapour composition if saturated");
292        Pratio as positive (Brief = "Pressure Ratio", Symbol ="P_{ratio}");     
293        Pdrop as press_delta (Brief = "Pressure Drop", DisplayUnit = 'kPa', Symbol ="\Delta P");
294       
295        zero_one as fraction(Brief="Regularization Variable");
296        one_zero as fraction(Brief="Regularization Variable");
297
298        EQUATIONS
299        "Chemical equilibrium"
300        PP.LiquidFugacityCoefficient(Tsat, OutletL.P, xsat)*xsat =
301                PP.VapourFugacityCoefficient(Tsat, OutletV.P, ysat)*ysat;
302
303        "Global Molar Balance"
304        Inlet.F = OutletV.F + OutletL.F;
305        OutletV.F = Inlet.F * vfrac;
306
307        "Component Molar Balance"
308        Inlet.F*Inlet.z = OutletL.F*xsat + OutletV.F*ysat;
309        sum(xsat) = sum(ysat);
310
311        "Energy Balance if saturated"
312        Inlet.F*Inlet.h  + InletQ =
313                Inlet.F*(1-vsat)*PP.LiquidEnthalpy(Tsat, OutletL.P, xsat) +
314                Inlet.F*vsat*PP.VapourEnthalpy(Tsat, OutletV.P, ysat);
315
316        "Real Energy Balance"
317        Inlet.F*Inlet.h  + InletQ =
318                Inlet.F*(1-vfrac)*OutletL.h + Inlet.F*vfrac*OutletV.h;
319
320        "Thermal Equilibrium"
321        OutletV.T = OutletL.T;
322       
323        "Mechanical Equilibrium"
324        OutletV.P = OutletL.P;
325
326        "Pressure Drop"
327        OutletL.P  = Inlet.P - Pdrop;
328
329        "Pressure Ratio"
330        OutletL.P = Inlet.P * Pratio;
331
332        # regularization functions
333        zero_one = (1 + tanh(B * vsat))/2;
334        one_zero = (1 - tanh(B * (vsat - 1)))/2;
335       
336        vfrac = zero_one * one_zero * vsat + 1 - one_zero;
337        OutletL.z = zero_one*one_zero*xsat + (1-zero_one*one_zero)*Inlet.z;
338        OutletV.z = zero_one*one_zero*ysat + (1-zero_one*one_zero)*Inlet.z;
339end
Note: See TracBrowser for help on using the repository browser.