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