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

Last change on this file since 323 was 323, checked in by Argimiro Resende Secchi, 15 years ago

Set some port positions.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 8.9 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 323 2007-07-25 21:16:09Z 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.5);
53out     OutletL as liquid_stream(Brief="Liquid outlet stream", PosX=0.5, PosY=0.5);
54out     OutletV as vapour_stream(Brief="Vapour outlet stream", PosX=0.5, PosY=0);
55in      InletQ as energy_stream (Brief="Rate of heat supply", PosX=1, PosY=0.75);
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
66        EQUATIONS
67        "Component Molar Balance"
68        diff(M)=Inlet.F*Inlet.z - OutletL.F*OutletL.z - OutletV.F*OutletV.z;
69       
70        "Energy Balance"
71        diff(E) = Inlet.F*Inlet.h - OutletL.F*OutletL.h - OutletV.F*OutletV.h + InletQ.Q;
72       
73        "Molar Holdup"
74        M = ML*OutletL.z + MV*OutletV.z;
75       
76        "Energy Holdup"
77        E = ML*OutletL.h + MV*OutletV.h - OutletL.P*V;
78       
79        "Mol fraction normalisation"
80        sum(OutletL.z)=1.0;
81        "Mol fraction normalisation"
82        sum(OutletL.z)=sum(OutletV.z);
83       
84        "Liquid Volume"
85        vL = PP.LiquidVolume(OutletL.T, OutletL.P, OutletL.z);
86        "Vapour Volume"
87        vV = PP.VapourVolume(OutletV.T, OutletV.P, OutletV.z);
88       
89        "Chemical Equilibrium"
90        PP.LiquidFugacityCoefficient(OutletL.T, OutletL.P, OutletL.z)*OutletL.z =
91                PP.VapourFugacityCoefficient(OutletV.T, OutletV.P, OutletV.z)*OutletV.z;
92       
93        "Thermal Equilibrium"
94        OutletV.T = OutletL.T;
95       
96        "Mechanical Equilibrium"
97        OutletV.P = OutletL.P;
98       
99        "Geometry Constraint"
100        V = ML * vL + MV * vV;
101
102        switch orientation
103        case "vertical":
104        "Cross Section Area"
105                Across = 0.5 * asin(1) * diameter^2;
106       
107        "Liquid Level"
108                ML * vL = Across * Level;
109
110        case "horizontal":
111        "Cylindrical Side Area"
112                Across = 0.25*diameter^2 * (asin(1) - asin((diameter - 2*Level)/diameter)) +
113                                (Level - 0.5*diameter)*sqrt(Level*(diameter - Level));
114
115        "Liquid Level"
116                0.5 * asin(1) * diameter^2 * ML* vL = Across * V;
117        end
118end
119
120#*----------------------------------------------------------------------
121* Model of a  Steady State flash
122*---------------------------------------------------------------------*#
123Model flash_steady
124        ATTRIBUTES
125        Pallete         = true;
126        Icon            = "icon/Flash";
127        Brief           = "Model of a Steady State flash.";
128        Info            =
129        "Assumptions:
130         * both phases are perfectly mixed.
131       
132        Specify:
133         * the feed stream;
134         * the outlet pressure (OutletV.P);
135         * the outlet temperature OR the heat supplied.
136        ";
137       
138        PARAMETERS
139outer PP as Plugin(Brief = "External Physical Properties", Type="PP");
140       
141        VARIABLES
142in      Inlet as stream(Brief="Feed Stream", PosX=0, PosY=0.5);
143out     OutletL as liquid_stream(Brief="Liquid outlet stream", PosX=0.5, PosY=0.5);
144out     OutletV as vapour_stream(Brief="Vapour outlet stream", PosX=0.5, PosY=0);
145in      InletQ as energy_stream (Brief="Rate of heat supply", PosX=1, PosY=0.75);
146        vfrac as fraction;
147
148        EQUATIONS
149        "The flash calculation"
150        [vfrac, OutletL.z, OutletV.z] = PP.Flash(OutletV.T, OutletV.P, Inlet.z);
151       
152        "Global Molar Balance"
153        Inlet.F = OutletV.F + OutletL.F;
154        "Vaporisation Fraction"
155        OutletV.F = Inlet.F * vfrac;
156       
157        "Energy Balance"
158        Inlet.F*Inlet.h  + InletQ.Q = OutletL.F*OutletL.h + OutletV.F*OutletV.h;
159       
160        "Thermal Equilibrium"
161        OutletV.T = OutletL.T;
162       
163        "Mechanical Equilibrium"
164        OutletV.P = OutletL.P;
165end
166
167#*----------------------------------------------------------------------
168* Model of a steady-state PH flash.
169*---------------------------------------------------------------------*#
170Model FlashPHSteady
171        ATTRIBUTES
172        Pallete         = true;
173        Icon            = "icon/Flash";
174        Brief           = "Model of a static PH flash.";
175        Info            = "
176        This model is for using the flashPH
177        routine available on VRTherm.
178
179        Assumptions:
180         * perfect mixing of both phases;
181
182        Specify:
183         * the feed stream;
184         * the heat duty;
185         * the outlet pressure.
186        ";     
187
188        PARAMETERS
189outer PP as Plugin(Brief = "External Physical Properties", Type="PP");
190outer NComp as Integer;
191
192        VARIABLES
193in      Inlet as stream(Brief="Feed Stream", PosX=0, PosY=0.5);
194out     OutletL as liquid_stream(Brief="Liquid outlet stream", PosX=0.5, PosY=0.5);
195out     OutletV as vapour_stream(Brief="Vapour outlet stream", PosX=0.5, PosY=0);
196in      InletQ as energy_stream (Brief="Rate of heat supply", PosX=1, PosY=0.75);
197        vfrac as fraction(Brief="Real vaporization fraction");
198        h as enth_mol(Brief="Mixture enthalpy");
199
200        EQUATIONS
201
202        "Chemical equilibrium"
203        [vfrac,OutletL.z,OutletV.z]=PP.FlashPH(OutletL.P,h,Inlet.z);
204
205        "Global Molar Balance"
206        Inlet.F = OutletV.F + OutletL.F;
207        OutletV.F = Inlet.F * vfrac;
208
209        "Energy Balance"
210        Inlet.F*(h - Inlet.h) = InletQ.Q;
211        Inlet.F*h = Inlet.F*(1-vfrac)*OutletL.h + Inlet.F*vfrac*OutletV.h;
212
213        "Thermal Equilibrium"
214        OutletV.T = OutletL.T;
215       
216        "Mechanical Equilibrium"
217        OutletV.P = OutletL.P;
218end
219
220#*----------------------------------------------------------------------
221* Another model of a steady-state PH flash.
222* It is recommended to use [v,x,y]=PP.FlashPH(P,h,z) instead of.
223*---------------------------------------------------------------------*#
224Model FlashPHSteadyA
225        ATTRIBUTES
226        Pallete         = true;
227        Icon            = "icon/Flash";
228        Brief           = "Another model of a static PH flash.";
229        Info            = "
230        This model shows how to model a pressure enthalpy flash
231        directly with the EMSO modeling language.
232
233        This model is for demonstration purposes only, the flashPH
234        routine available on VRTherm is much more robust.
235
236        Assumptions:
237         * perfect mixing of both phases;
238
239        Specify:
240         * the feed stream;
241         * the heat duty;
242         * the outlet pressure.
243        ";     
244       
245        PARAMETERS
246outer PP as Plugin(Brief = "External Physical Properties", Type="PP");
247outer NComp as Integer;
248        B as Real(Default=1000, Brief="Regularization Factor");
249
250        VARIABLES
251in      Inlet as stream(Brief="Feed Stream", PosX=0, PosY=0.5);
252out     OutletL as liquid_stream(Brief="Liquid outlet stream", PosX=0.5, PosY=0.5);
253out     OutletV as vapour_stream(Brief="Vapour outlet stream", PosX=0.5, PosY=0);
254in      InletQ as energy_stream (Brief="Rate of heat supply", PosX=1, PosY=0.75);
255        vfrac as fraction(Brief="Real vaporization fraction");
256        vsat as Real(Lower=-0.1, Upper=1.1, Brief="Vaporization fraction if saturated");
257        Tsat as temperature(Lower=173, Upper=1473, Brief="Temperature if saturated");
258        xsat(NComp) as Real(Lower=0, Upper=1, Brief="Liquid composition if saturated");
259        ysat(NComp) as Real(Lower=0, Upper=1, Brief="Vapour composition if saturated");
260       
261        zero_one as fraction(Brief="Regularization Variable");
262        one_zero as fraction(Brief="Regularization Variable");
263
264        EQUATIONS
265        "Chemical equilibrium"
266        PP.LiquidFugacityCoefficient(Tsat, OutletL.P, xsat)*xsat =
267                PP.VapourFugacityCoefficient(Tsat, OutletV.P, ysat)*ysat;
268
269        "Global Molar Balance"
270        Inlet.F = OutletV.F + OutletL.F;
271        OutletV.F = Inlet.F * vfrac;
272
273        "Component Molar Balance"
274        Inlet.F*Inlet.z = OutletL.F*xsat + OutletV.F*ysat;
275        sum(xsat) = sum(ysat);
276
277        "Energy Balance if saturated"
278        Inlet.F*Inlet.h  + InletQ.Q =
279                Inlet.F*(1-vsat)*PP.LiquidEnthalpy(Tsat, OutletL.P, xsat) +
280                Inlet.F*vsat*PP.VapourEnthalpy(Tsat, OutletV.P, ysat);
281
282        "Real Energy Balance"
283        Inlet.F*Inlet.h  + InletQ.Q =
284                Inlet.F*(1-vfrac)*OutletL.h + Inlet.F*vfrac*OutletV.h;
285
286        "Thermal Equilibrium"
287        OutletV.T = OutletL.T;
288       
289        "Mechanical Equilibrium"
290        OutletV.P = OutletL.P;
291       
292        # regularization functions
293        zero_one = (1 + tanh(B * vsat))/2;
294        one_zero = (1 - tanh(B * (vsat - 1)))/2;
295       
296        vfrac = zero_one * one_zero * vsat + 1 - one_zero;
297        OutletL.z = zero_one*one_zero*xsat + (1-zero_one*one_zero)*Inlet.z;
298        OutletV.z = zero_one*one_zero*ysat + (1-zero_one*one_zero)*Inlet.z;
299end
Note: See TracBrowser for help on using the repository browser.