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

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

updated flash model

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 12.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 711 2009-02-13 19:33:49Z 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: OutletV.F and OutletL.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 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        ATTRIBUTES
175        Pallete         = true;
176        Icon            = "icon/Flash";
177        Brief           = "Model of a Steady State flash.";
178        Info            =
179"== Assumptions ==
180* both phases are perfectly mixed.
181       
182== Specify ==
183* the feed stream;
184* the outlet pressure (OutletV.P);
185* the outlet temperature OR the heat supplied.
186";
187       
188        PARAMETERS
189outer PP as Plugin(Brief = "External Physical Properties", Type="PP");
190       
191        VARIABLES
192in      Inlet as stream(Brief="Feed Stream", PosX=0, PosY=0.5421, Symbol="_{in}");
193out     OutletL as liquid_stream(Brief="Liquid outlet stream", PosX=0.4790, PosY=1, Symbol="_{outL}");
194out     OutletV as vapour_stream(Brief="Vapour outlet stream", PosX=0.4877, PosY=0, Symbol="_{outV}");
195in      InletQ as power (Brief="Rate of heat supply", PosX=1, PosY=0.7559, Symbol="_{in}");
196        vfrac as fraction (Brief="Vapourization fraction", Symbol="\phi");
197        Pratio as positive      (Brief = "Pressure Ratio", Symbol ="P_{ratio}");       
198        Pdrop as press_delta (Brief = "Pressure Drop", DisplayUnit = 'kPa', Symbol ="\Delta P");
199
200        EQUATIONS
201        "The flash calculation"
202        [vfrac, OutletL.z, OutletV.z] = PP.Flash(OutletV.T, OutletV.P, Inlet.z);
203       
204        "Global Molar Balance"
205        Inlet.F = OutletV.F + OutletL.F;
206       
207        "Vaporization Fraction"
208        OutletV.F = Inlet.F * vfrac;
209       
210        "Energy Balance"
211        Inlet.F*Inlet.h  + InletQ = OutletL.F*OutletL.h + OutletV.F*OutletV.h;
212       
213        "Thermal Equilibrium"
214        OutletV.T = OutletL.T;
215       
216        "Mechanical Equilibrium"
217        OutletV.P = OutletL.P;
218
219        "Pressure Drop"
220        OutletL.P  = Inlet.P - Pdrop;
221
222        "Pressure Ratio"
223        OutletL.P = Inlet.P * Pratio;
224end
225
226#*----------------------------------------------------------------------
227* Model of a steady-state PH flash.
228*---------------------------------------------------------------------*#
229Model FlashPHSteady
230        ATTRIBUTES
231        Pallete         = true;
232        Icon            = "icon/Flash";
233        Brief           = "Model of a static PH flash.";
234        Info            =
235"This model is for using the flashPH routine available on VRTherm.
236
237== Assumptions ==
238* perfect mixing of both phases;
239
240== Specify ==
241* the feed stream;
242* the heat duty;
243* the outlet pressure.
244";     
245
246        PARAMETERS
247outer PP as Plugin(Brief = "External Physical Properties", Type="PP");
248outer NComp as Integer;
249
250        VARIABLES
251in      Inlet as stream(Brief="Feed Stream", PosX=0, PosY=0.5421, Symbol="_{in}");
252out     OutletL as liquid_stream(Brief="Liquid outlet stream", PosX=0.4790, PosY=1, Symbol="_{outL}");
253out     OutletV as vapour_stream(Brief="Vapour outlet stream", PosX=0.4877, PosY=0, Symbol="_{outV}");
254in      InletQ as power (Brief="Rate of heat supply", PosX=1, PosY=0.7559, Symbol="_{in}");
255        vfrac as fraction(Brief="Vaporization fraction", Symbol="\phi");
256        h as enth_mol(Brief="Mixture enthalpy");
257        Pratio as positive (Brief = "Pressure Ratio", Symbol ="P_{ratio}");     
258        Pdrop as press_delta (Brief = "Pressure Drop", DisplayUnit = 'kPa', Symbol ="\Delta P");
259
260        EQUATIONS
261
262        "Chemical equilibrium"
263        [vfrac,OutletL.z,OutletV.z]=PP.FlashPH(OutletL.P,h,Inlet.z);
264
265        "Global Molar Balance"
266        Inlet.F = OutletV.F + OutletL.F;
267        OutletV.F = Inlet.F * vfrac;
268
269        "Energy Balance"
270        Inlet.F*(h - Inlet.h) = InletQ;
271        Inlet.F*h = Inlet.F*(1-vfrac)*OutletL.h + Inlet.F*vfrac*OutletV.h;
272
273        "Thermal Equilibrium"
274        OutletV.T = OutletL.T;
275       
276        "Mechanical Equilibrium"
277        OutletV.P = OutletL.P;
278
279        "Pressure Drop"
280        OutletL.P  = Inlet.P - Pdrop;
281
282        "Pressure Ratio"
283        OutletL.P = Inlet.P * Pratio;
284end
285
286#*----------------------------------------------------------------------
287* Another model of a steady-state PH flash.
288* It is recommended to use [v,x,y]=PP.FlashPH(P,h,z) instead of.
289*---------------------------------------------------------------------*#
290Model FlashPHSteadyA
291        ATTRIBUTES
292        Pallete         = true;
293        Icon            = "icon/Flash";
294        Brief           = "Another model of a static PH flash.";
295        Info            =
296"This model shows how to model a pressure enthalpy flash
297directly with the EMSO modeling language.
298
299This model is for demonstration purposes only, the flashPH
300routine available on VRTherm is much more robust.
301
302== Assumptions ==
303* perfect mixing of both phases;
304
305== Specify ==
306* the feed stream;
307* the heat duty;
308* the outlet pressure.
309";     
310       
311        PARAMETERS
312outer PP as Plugin(Brief = "External Physical Properties", Type="PP");
313outer NComp as Integer;
314        B as Real(Default=1000, Brief="Regularization Factor");
315
316        VARIABLES
317in      Inlet as stream(Brief="Feed Stream", PosX=0, PosY=0.5421, Symbol="_{in}");
318out     OutletL as liquid_stream(Brief="Liquid outlet stream", PosX=0.4790, PosY=1, Symbol="_{outL}");
319out     OutletV as vapour_stream(Brief="Vapour outlet stream", PosX=0.4877, PosY=0, Symbol="_{outV}");
320in      InletQ as power (Brief="Rate of heat supply", PosX=1, PosY=0.7559, Symbol="_{in}");
321        vfrac as fraction(Brief="Vaporization fraction", Symbol="\phi");
322        vsat as Real(Lower=-0.1, Upper=1.1, Brief="Vaporization fraction if saturated", Symbol="\phi_{sat}");
323        Tsat as temperature(Lower=173, Upper=1473, Brief="Temperature if saturated");
324        xsat(NComp) as Real(Lower=0, Upper=1, Brief="Liquid composition if saturated");
325        ysat(NComp) as Real(Lower=0, Upper=1, Brief="Vapour composition if saturated");
326        Pratio as positive (Brief = "Pressure Ratio", Symbol ="P_{ratio}");     
327        Pdrop as press_delta (Brief = "Pressure Drop", DisplayUnit = 'kPa', Symbol ="\Delta P");
328       
329        zero_one as fraction(Brief="Regularization Variable");
330        one_zero as fraction(Brief="Regularization Variable");
331
332        EQUATIONS
333        "Chemical equilibrium"
334        PP.LiquidFugacityCoefficient(Tsat, OutletL.P, xsat)*xsat =
335                PP.VapourFugacityCoefficient(Tsat, OutletV.P, ysat)*ysat;
336
337        "Global Molar Balance"
338        Inlet.F = OutletV.F + OutletL.F;
339        OutletV.F = Inlet.F * vfrac;
340
341        "Component Molar Balance"
342        Inlet.F*Inlet.z = OutletL.F*xsat + OutletV.F*ysat;
343        sum(xsat) = sum(ysat);
344
345        "Energy Balance if saturated"
346        Inlet.F*Inlet.h  + InletQ =
347                Inlet.F*(1-vsat)*PP.LiquidEnthalpy(Tsat, OutletL.P, xsat) +
348                Inlet.F*vsat*PP.VapourEnthalpy(Tsat, OutletV.P, ysat);
349
350        "Real Energy Balance"
351        Inlet.F*Inlet.h  + InletQ =
352                Inlet.F*(1-vfrac)*OutletL.h + Inlet.F*vfrac*OutletV.h;
353
354        "Thermal Equilibrium"
355        OutletV.T = OutletL.T;
356       
357        "Mechanical Equilibrium"
358        OutletV.P = OutletL.P;
359
360        "Pressure Drop"
361        OutletL.P  = Inlet.P - Pdrop;
362
363        "Pressure Ratio"
364        OutletL.P = Inlet.P * Pratio;
365
366        # regularization functions
367        zero_one = (1 + tanh(B * vsat))/2;
368        one_zero = (1 - tanh(B * (vsat - 1)))/2;
369       
370        vfrac = zero_one * one_zero * vsat + 1 - one_zero;
371        OutletL.z = zero_one*one_zero*xsat + (1-zero_one*one_zero)*Inlet.z;
372        OutletV.z = zero_one*one_zero*ysat + (1-zero_one*one_zero)*Inlet.z;
373end
Note: See TracBrowser for help on using the repository browser.