source: trunk/eml/stage_separators/flash.mso @ 494

Last change on this file since 494 was 372, checked in by Argimiro Resende Secchi, 16 years ago

Adding pressure drop variable (Pdrop) and pressure ratio (Pratio) in some models. Need to do the same for other models.

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