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

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

updated flash model/icon

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