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

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

updates

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