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: tank.mso 883 2009-11-12 17:23:49Z bicca $ |
---|
17 | *--------------------------------------------------------------------*# |
---|
18 | |
---|
19 | using "streams"; |
---|
20 | |
---|
21 | Model VesselVolume |
---|
22 | |
---|
23 | ATTRIBUTES |
---|
24 | Pallete = false; |
---|
25 | Brief = "Model to calculate vessel total volume and vessel filled volume from |
---|
26 | different geometries and orientations."; |
---|
27 | Info = |
---|
28 | "== SET == |
---|
29 | *Orientation: vessel position - vertical or horizontal; |
---|
30 | *Heads (bottom and top heads are identical) |
---|
31 | **elliptical: 2:1 elliptical heads (25% of vessel diameter); |
---|
32 | **hemispherical: hemispherical heads (50% of vessel diameter); |
---|
33 | **flat: flat heads (0% of vessel diameter); |
---|
34 | *Diameter: Vessel diameter; |
---|
35 | *Lenght: Side length of the cylinder shell; |
---|
36 | "; |
---|
37 | |
---|
38 | PARAMETERS |
---|
39 | PI as positive (Brief="Pi value", Default=3.141593,Hidden=true, Symbol="\pi"); |
---|
40 | Gconst as acceleration (Brief="Gravity Acceleration",Default=9.81,Hidden=true); |
---|
41 | |
---|
42 | Orientation as Switcher (Valid=["vertical","horizontal"],Default="vertical"); |
---|
43 | Heads as Switcher (Valid=["elliptical","hemispherical","flat"],Default="flat"); |
---|
44 | Diameter as length (Brief="Vessel diameter", Default= 2, Symbol="D_{i}"); |
---|
45 | Lenght as length (Brief="Side length of the cylinder shell", Default= 6, Symbol="L_{vessel}"); |
---|
46 | |
---|
47 | Vhead_elliptical as volume (Brief="Elliptical Head Total Volume",Hidden=true, Symbol="V_{head}^{elliptical}"); |
---|
48 | Vhead_hemispherical as volume (Brief="Hemispherical Head Total Volume",Hidden=true, Symbol="V_{head}^{hemispherical}"); |
---|
49 | Vcylinder as volume (Brief="Cylinder Total Volume",Hidden=true, Symbol="V_{cylinder}"); |
---|
50 | radius as length (Brief="Vessel radius",Hidden=true, Symbol="R_{cylinder}"); |
---|
51 | |
---|
52 | SET |
---|
53 | |
---|
54 | Gconst = 9.81 * 'm/(s^2)'; |
---|
55 | Vhead_elliptical = (PI*Diameter^3)/12; |
---|
56 | Vhead_hemispherical = (PI*Diameter^3)/6; |
---|
57 | Vcylinder = 0.25*(PI*Diameter^2)*Lenght; |
---|
58 | radius = 0.5*Diameter; |
---|
59 | |
---|
60 | VARIABLES |
---|
61 | |
---|
62 | Vtotal as volume (Brief="Vessel total volume",Protected=true, Symbol="V_{total}"); |
---|
63 | Vfilled as volume (Brief="Vessel volume content",Protected=true, Symbol="V_{filled}"); |
---|
64 | Level as length (Brief="liquid height", Protected=true); |
---|
65 | Across as area (Brief="Vessel cylinder shell Cross section area", Hidden=true, Symbol="A_{cross}"); |
---|
66 | |
---|
67 | EQUATIONS |
---|
68 | |
---|
69 | switch Orientation |
---|
70 | |
---|
71 | case "vertical": |
---|
72 | |
---|
73 | "Vessel Cross Section Area" |
---|
74 | Across = 0.25*(PI*Diameter^2); |
---|
75 | |
---|
76 | switch Heads |
---|
77 | |
---|
78 | case "elliptical": |
---|
79 | |
---|
80 | "Vessel Total Volume" |
---|
81 | Vtotal = Vhead_elliptical + Vcylinder; |
---|
82 | |
---|
83 | if Level < 0.25*Diameter then |
---|
84 | |
---|
85 | "Vessel Filled Volume" |
---|
86 | Vfilled = 0.25*PI*(((Diameter*Level)/(0.25*Diameter))^2)*(0.25*Diameter-Level/3); |
---|
87 | |
---|
88 | else |
---|
89 | |
---|
90 | "Vessel Filled Volume" |
---|
91 | Vfilled = 0.25*PI*(Diameter^2)*(Level - 0.25*Diameter/3); |
---|
92 | |
---|
93 | end |
---|
94 | |
---|
95 | case "hemispherical": |
---|
96 | |
---|
97 | "Vessel Total Volume" |
---|
98 | Vtotal = Vhead_hemispherical + Vcylinder; |
---|
99 | |
---|
100 | if Level < 0.5*Diameter then |
---|
101 | |
---|
102 | "Vessel Filled Volume" |
---|
103 | Vfilled = 0.25*PI*(Level^2)*(2*Diameter-4*Level/3); |
---|
104 | |
---|
105 | else |
---|
106 | |
---|
107 | "Vessel Filled Volume" |
---|
108 | Vfilled = 0.25*PI*((2/3)*((0.5*Diameter)^3) - (0.25*(Diameter)^3) + Level*Diameter^2); |
---|
109 | |
---|
110 | end |
---|
111 | |
---|
112 | case "flat": |
---|
113 | |
---|
114 | "Vessel Total Volume" |
---|
115 | Vtotal = Vcylinder; |
---|
116 | |
---|
117 | "Vessel Filled Volume" |
---|
118 | Vfilled = Across*Level; |
---|
119 | |
---|
120 | end |
---|
121 | |
---|
122 | case "horizontal": |
---|
123 | |
---|
124 | "Vessel Cross Section Area" |
---|
125 | Across = (radius^2)*acos((radius-Level)/radius)-(radius-Level)*sqrt((2*radius*Level-Level^2)); |
---|
126 | |
---|
127 | switch Heads |
---|
128 | |
---|
129 | case "elliptical": |
---|
130 | |
---|
131 | "Vessel Total Volume" |
---|
132 | Vtotal = Vhead_elliptical + Vcylinder; |
---|
133 | |
---|
134 | "Vessel Filled Volume" |
---|
135 | Vfilled = 0.5236*Level^2*(1.5*Diameter-Level) + Across*Lenght; |
---|
136 | |
---|
137 | case "hemispherical": |
---|
138 | |
---|
139 | "Vessel Total Volume" |
---|
140 | Vtotal = Vhead_hemispherical + Vcylinder; |
---|
141 | |
---|
142 | "Vessel Filled Volume" |
---|
143 | Vfilled = 1.0472*Level^2*(1.5*Diameter-Level) + Across*Lenght; |
---|
144 | |
---|
145 | case "flat": |
---|
146 | |
---|
147 | "Vessel Total Volume" |
---|
148 | Vtotal = Vcylinder; |
---|
149 | |
---|
150 | "Vessel Filled Volume" |
---|
151 | Vfilled = Across*Lenght; |
---|
152 | |
---|
153 | end |
---|
154 | |
---|
155 | end |
---|
156 | |
---|
157 | end |
---|
158 | |
---|
159 | Model TankVL |
---|
160 | |
---|
161 | ATTRIBUTES |
---|
162 | Pallete = true; |
---|
163 | Icon = "icon/TankVL"; |
---|
164 | Brief = "Model of a Tank With Thermodynamic Equilibrium."; |
---|
165 | Info = |
---|
166 | "== ASSUMPTIONS == |
---|
167 | * perfect mixing of both phases; |
---|
168 | * thermodynamics equilibrium. |
---|
169 | |
---|
170 | == SET == |
---|
171 | *Orientation: vessel position - vertical or horizontal; |
---|
172 | *Heads (bottom and top heads are identical) |
---|
173 | **elliptical: 2:1 elliptical heads (25% of vessel diameter); |
---|
174 | **hemispherical: hemispherical heads (50% of vessel diameter); |
---|
175 | **flat: flat heads (0% of vessel diameter); |
---|
176 | *Diameter: Vessel diameter; |
---|
177 | *Lenght: Side length of the cylinder shell; |
---|
178 | |
---|
179 | == SPECIFY == |
---|
180 | * the Inlet stream; |
---|
181 | * the outlet flows: OutletVapour.F and OutletLiquid.F; |
---|
182 | * the InletQ (the model requires an energy stream, also you can use a controller for setting the heat duty using the heat_flow model). |
---|
183 | |
---|
184 | == OPTIONAL == |
---|
185 | * the TankVL model has three control ports |
---|
186 | ** TI OutletLiquid Temperature Indicator; |
---|
187 | ** PI OutletLiquid Pressure Indicator; |
---|
188 | ** LI Level Indicator; |
---|
189 | |
---|
190 | == INITIAL CONDITIONS == |
---|
191 | * Initial_Temperature : the Tank temperature (OutletLiquid.T); |
---|
192 | * Levelpercent_Initial : the Tank liquid level in percent (LI); |
---|
193 | * Initial_Composition : (NoComps) OutletLiquid compositions. |
---|
194 | "; |
---|
195 | |
---|
196 | PARAMETERS |
---|
197 | outer PP as Plugin (Brief = "External Physical Properties", Type="PP"); |
---|
198 | outer NComp as Integer (Brief = "Number of components", Lower = 1); |
---|
199 | |
---|
200 | Mw(NComp) as molweight (Brief="Mol Weight", Hidden=true); |
---|
201 | |
---|
202 | Gconst as acceleration (Brief="Gravity Acceleration",Default=9.81,Hidden=true); |
---|
203 | low_flow as flow_mol (Brief = "Low Flow",Default = 1E-6, Hidden=true); |
---|
204 | zero_flow as flow_mol (Brief = "No Flow",Default = 0, Hidden=true); |
---|
205 | KfConst as Real (Brief="Constant for K factor pressure drop", Unit= 'mol/(s*(Pa^0.5))',Default = 1, Hidden=true); |
---|
206 | Kfactor as positive (Brief="K factor for pressure drop", Lower = 1E-8, Default = 2); |
---|
207 | |
---|
208 | NormalFlow as Switcher (Brief="Normal Flow", Valid = ["on", "off"], Default = "on",Hidden=true); |
---|
209 | |
---|
210 | Levelpercent_Initial as positive (Brief="Initial liquid height in Percent", Default = 0.70); |
---|
211 | Temperature_Initial as temperature (Brief="Initial Liquid Temperature", Default = 330); |
---|
212 | Composition_Initial(NComp) as fraction (Brief="Initial Composition", Default = 0.10); |
---|
213 | |
---|
214 | SET |
---|
215 | |
---|
216 | Mw=PP.MolecularWeight(); |
---|
217 | Gconst = 9.81 * 'm/(s^2)'; |
---|
218 | low_flow = 1E-6 * 'kmol/h'; |
---|
219 | zero_flow = 0 * 'kmol/h'; |
---|
220 | KfConst = 1*'mol/(s*(Pa^0.5))'; |
---|
221 | |
---|
222 | VARIABLES |
---|
223 | |
---|
224 | Geometry as VesselVolume (Brief="Vessel Geometry", Symbol=" "); |
---|
225 | |
---|
226 | in Inlet as stream (Brief="Feed Stream", PosX=0.22, PosY=0, Symbol="_{in}"); |
---|
227 | out OutletLiquid as liquid_stream (Brief="Liquid outlet stream", PosX=0.43, PosY=1, Symbol="_{out}^{Liquid}"); |
---|
228 | out OutletVapour as vapour_stream (Brief="Vapour outlet stream", PosX=0.68, PosY=0, Symbol="_{out}^{Vapour}"); |
---|
229 | in InletQ as power (Brief="Heat Duty", PosX=0.735, PosY=1, Protected =true,Symbol="Q_{in}"); |
---|
230 | |
---|
231 | TotalHoldup(NComp) as mol (Brief="Molar Holdup in the Vessel", Protected=true); |
---|
232 | LiquidHoldup as mol (Brief="Molar liquid holdup", Protected=true); |
---|
233 | VapourHoldup as mol (Brief="Molar vapour holdup", Protected=true); |
---|
234 | |
---|
235 | E as energy (Brief="Total Energy Holdup in the Vessel", Protected=true); |
---|
236 | vL as volume_mol (Brief="Liquid Molar Volume", Protected=true); |
---|
237 | vV as volume_mol (Brief="Vapour Molar volume", Protected=true); |
---|
238 | Pdrop as press_delta (Brief = "Pressure Drop", DisplayUnit = 'kPa', Symbol ="\Delta P", Protected=true); |
---|
239 | Peq as pressure (Brief="Equilibrium pressure on the liquid surface", Protected=true, Symbol="\Delta P_{eq}"); |
---|
240 | Pstatic as pressure (Brief="Static head at the bottom of the tank", Protected = true, Symbol="P_{static}^{Liquid}"); |
---|
241 | |
---|
242 | out TI as control_signal (Brief="Temperature Indicator", PosX=0.525, PosY=0, Protected=true); |
---|
243 | out PI as control_signal (Brief="Pressure Indicator", PosX=0.368, PosY=0, Protected=true); |
---|
244 | out LI as control_signal (Brief="Level Indicator", PosX=1, PosY=0.6, Protected=true); |
---|
245 | |
---|
246 | INITIAL |
---|
247 | |
---|
248 | "Initial level Percent" |
---|
249 | LI = Levelpercent_Initial; |
---|
250 | |
---|
251 | "Initial Outlet Liquid Temperature" |
---|
252 | OutletLiquid.T = Temperature_Initial; |
---|
253 | |
---|
254 | "Initial Outlet Liquid Composition Normalized" |
---|
255 | OutletLiquid.z(1:NComp - 1) = Composition_Initial(1:NComp - 1)/sum(Composition_Initial); |
---|
256 | |
---|
257 | EQUATIONS |
---|
258 | |
---|
259 | switch NormalFlow |
---|
260 | |
---|
261 | case "on": |
---|
262 | Inlet.F = Kfactor *sqrt(Pdrop)*KfConst; |
---|
263 | |
---|
264 | when Inlet.F < low_flow switchto "off"; |
---|
265 | |
---|
266 | case "off": |
---|
267 | Inlet.F = zero_flow; |
---|
268 | |
---|
269 | when Inlet.P > OutletVapour.P switchto "on"; |
---|
270 | |
---|
271 | end |
---|
272 | |
---|
273 | "Component Molar Balance" |
---|
274 | diff(TotalHoldup)=Inlet.F*Inlet.z - OutletLiquid.F*OutletLiquid.z - OutletVapour.F*OutletVapour.z; |
---|
275 | |
---|
276 | "Energy Balance" |
---|
277 | diff(E) = Inlet.F*Inlet.h - OutletLiquid.F*OutletLiquid.h - OutletVapour.F*OutletVapour.h + InletQ; |
---|
278 | |
---|
279 | "Molar Holdup" |
---|
280 | TotalHoldup = LiquidHoldup*OutletLiquid.z + VapourHoldup*OutletVapour.z; |
---|
281 | |
---|
282 | "Energy Holdup" |
---|
283 | E = LiquidHoldup*OutletLiquid.h + VapourHoldup*OutletVapour.h - OutletLiquid.P*Geometry.Vtotal; |
---|
284 | |
---|
285 | "Mol fraction normalisation" |
---|
286 | sum(OutletLiquid.z)=1.0; |
---|
287 | |
---|
288 | "Mol fraction normalisation" |
---|
289 | sum(OutletLiquid.z)=sum(OutletVapour.z); |
---|
290 | |
---|
291 | "Liquid Volume" |
---|
292 | vL = PP.LiquidVolume(OutletLiquid.T, Peq, OutletLiquid.z); |
---|
293 | |
---|
294 | "Vapour Volume" |
---|
295 | vV = PP.VapourVolume(OutletVapour.T, Peq, OutletVapour.z); |
---|
296 | |
---|
297 | "Chemical Equilibrium" |
---|
298 | PP.LiquidFugacityCoefficient(OutletLiquid.T, Peq, OutletLiquid.z)*OutletLiquid.z = |
---|
299 | PP.VapourFugacityCoefficient(OutletVapour.T, Peq, OutletVapour.z)*OutletVapour.z; |
---|
300 | |
---|
301 | "Thermal Equilibrium" |
---|
302 | OutletVapour.T = OutletLiquid.T; |
---|
303 | |
---|
304 | "Mechanical Equilibrium" |
---|
305 | OutletVapour.P = Peq; |
---|
306 | |
---|
307 | "Static Head" |
---|
308 | Pstatic = PP.LiquidDensity(OutletLiquid.T, Peq, OutletLiquid.z) * Gconst * Geometry.Level; |
---|
309 | |
---|
310 | "Mechanical Equilibrium for the Liquid Phase" |
---|
311 | OutletLiquid.P = Peq + Pstatic; |
---|
312 | |
---|
313 | "Pressure Drop" |
---|
314 | Pdrop = Inlet.P - OutletVapour.P; |
---|
315 | |
---|
316 | "Geometry Constraint" |
---|
317 | Geometry.Vtotal = LiquidHoldup * vL + VapourHoldup * vV; |
---|
318 | |
---|
319 | "Temperature indicator" |
---|
320 | TI * 'K' = OutletLiquid.T; |
---|
321 | |
---|
322 | "Pressure indicator" |
---|
323 | PI * 'atm' = OutletLiquid.P; |
---|
324 | |
---|
325 | "Level indicator" |
---|
326 | LI*Geometry.Vtotal= Geometry.Vfilled; |
---|
327 | |
---|
328 | "Liquid Level" |
---|
329 | LiquidHoldup * vL = Geometry.Vfilled; |
---|
330 | |
---|
331 | end |
---|
332 | |
---|
333 | Model TankL |
---|
334 | |
---|
335 | ATTRIBUTES |
---|
336 | Pallete = true; |
---|
337 | Icon = "icon/TankL"; |
---|
338 | Brief = "Model of a Tank."; |
---|
339 | Info = |
---|
340 | "== ASSUMPTIONS == |
---|
341 | * liquid phase only; |
---|
342 | |
---|
343 | == SET == |
---|
344 | *Orientation: vessel position - vertical or horizontal; |
---|
345 | *Heads (bottom and top heads are identical) |
---|
346 | **elliptical: 2:1 elliptical heads (25% of vessel diameter); |
---|
347 | **hemispherical: hemispherical heads (50% of vessel diameter); |
---|
348 | **flat: flat heads (0% of vessel diameter); |
---|
349 | *Diameter: Vessel diameter; |
---|
350 | *Lenght: Side length of the cylinder shell; |
---|
351 | |
---|
352 | == SPECIFY == |
---|
353 | * the Inlet stream; |
---|
354 | * the OutletLiquid.F; |
---|
355 | * the InletQ (the model requires an energy stream, also you can use a controller for setting the heat duty using the heat_flow model). |
---|
356 | |
---|
357 | == OPTIONAL == |
---|
358 | * the TankL model has three control ports |
---|
359 | ** TI OutletLiquid Temperature Indicator; |
---|
360 | ** PI OutletLiquid Pressure Indicator; |
---|
361 | ** LI Level Indicator; |
---|
362 | |
---|
363 | == INITIAL CONDITIONS == |
---|
364 | * Initial_Temperature : the Tank temperature (OutletLiquid.T); |
---|
365 | * Levelpercent_Initial : the Tank liquid level in percent (LI); |
---|
366 | * Initial_Composition : (NoComps) OutletLiquid compositions. |
---|
367 | "; |
---|
368 | |
---|
369 | PARAMETERS |
---|
370 | outer PP as Plugin (Brief = "External Physical Properties", Type="PP"); |
---|
371 | outer NComp as Integer (Brief = "Number of components", Lower = 1); |
---|
372 | |
---|
373 | Gconst as acceleration (Brief="Gravity Acceleration",Default=9.81,Hidden=true); |
---|
374 | low_flow as flow_mol (Brief = "Low Flow",Default = 1E-6, Hidden=true); |
---|
375 | zero_flow as flow_mol (Brief = "No Flow",Default = 0, Hidden=true); |
---|
376 | KfConst as Real (Brief="Constant for K factor pressure drop", Unit= 'mol/(s*(Pa^0.5))',Default = 1, Hidden=true); |
---|
377 | Kfactor as positive (Brief="K factor for pressure drop", Lower = 1E-8, Default = 2); |
---|
378 | |
---|
379 | NormalFlow as Switcher (Brief="Normal Flow", Valid = ["on", "off"], Default = "on",Hidden=true); |
---|
380 | |
---|
381 | |
---|
382 | Levelpercent_Initial as positive (Brief="Initial liquid height in Percent", Default = 0.70); |
---|
383 | Temperature_Initial as temperature (Brief="Initial Liquid Temperature", Default = 330); |
---|
384 | Composition_Initial(NComp) as fraction (Brief="Initial Composition", Default = 0.10); |
---|
385 | |
---|
386 | SET |
---|
387 | |
---|
388 | Gconst = 9.81 * 'm/(s^2)'; |
---|
389 | low_flow = 1E-6 * 'kmol/h'; |
---|
390 | zero_flow = 0 * 'kmol/h'; |
---|
391 | KfConst = 1*'mol/(s*(Pa^0.5))'; |
---|
392 | |
---|
393 | VARIABLES |
---|
394 | |
---|
395 | Geometry as VesselVolume (Brief="Vessel Geometry", Symbol=" "); |
---|
396 | |
---|
397 | in Inlet as stream (Brief="Feed Stream", PosX=0.22, PosY=0, Symbol="_{in}"); |
---|
398 | out OutletLiquid as liquid_stream (Brief="Liquid outlet stream", PosX=0.43, PosY=1, Symbol="_{out}^{Liquid}"); |
---|
399 | in InletQ as power (Brief="Heat Duty", PosX=0.735, PosY=1, Protected =true,Symbol="Q_{in}"); |
---|
400 | |
---|
401 | TotalHoldup(NComp) as mol (Brief="Molar Holdup in the Vessel", Protected=true); |
---|
402 | |
---|
403 | E as energy (Brief="Total Energy Holdup in the Vessel", Protected=true); |
---|
404 | vL as volume_mol (Brief="Liquid Molar Volume", Protected=true); |
---|
405 | Pstatic as pressure (Brief="Static head at the bottom of the tank", Protected = true, Symbol="P_{static}^{Liquid}"); |
---|
406 | |
---|
407 | out TI as control_signal (Brief="Temperature Indicator", PosX=0.525, PosY=0, Protected=true); |
---|
408 | out PI as control_signal (Brief="Pressure Indicator", PosX=0.368, PosY=0, Protected=true); |
---|
409 | out LI as control_signal (Brief="Level Indicator", PosX=1, PosY=0.6, Protected=true); |
---|
410 | |
---|
411 | INITIAL |
---|
412 | |
---|
413 | "Initial level Percent" |
---|
414 | LI = Levelpercent_Initial; |
---|
415 | |
---|
416 | "Initial Outlet Liquid Temperature" |
---|
417 | OutletLiquid.T = Temperature_Initial; |
---|
418 | |
---|
419 | "Initial Outlet Liquid Composition Normalized" |
---|
420 | OutletLiquid.z(1:NComp - 1) = Composition_Initial(1:NComp - 1)/sum(Composition_Initial); |
---|
421 | |
---|
422 | EQUATIONS |
---|
423 | |
---|
424 | #* |
---|
425 | switch NormalFlow |
---|
426 | |
---|
427 | case "on": |
---|
428 | Inlet.F = Kfactor *sqrt(Pstatic)*KfConst; |
---|
429 | |
---|
430 | when Inlet.F < low_flow switchto "off"; |
---|
431 | |
---|
432 | case "off": |
---|
433 | Inlet.F = zero_flow; |
---|
434 | |
---|
435 | when Inlet.P > OutletLiquid.P switchto "on"; |
---|
436 | |
---|
437 | end |
---|
438 | *# |
---|
439 | "Component Molar Balance" |
---|
440 | diff(TotalHoldup)=Inlet.F*Inlet.z - OutletLiquid.F*OutletLiquid.z; |
---|
441 | |
---|
442 | "Energy Balance" |
---|
443 | diff(E) = Inlet.F*Inlet.h - OutletLiquid.F*OutletLiquid.h + InletQ; |
---|
444 | |
---|
445 | "Energy Holdup" |
---|
446 | E = sum(TotalHoldup)*OutletLiquid.h; |
---|
447 | |
---|
448 | "Static Head" |
---|
449 | Pstatic = PP.LiquidDensity(OutletLiquid.T, Inlet.P, OutletLiquid.z) * Gconst * Geometry.Level; |
---|
450 | |
---|
451 | "Mechanical Equilibrium" |
---|
452 | Inlet.P + Pstatic = OutletLiquid.P; |
---|
453 | |
---|
454 | "Liquid Volume" |
---|
455 | vL = PP.LiquidVolume(OutletLiquid.T, OutletLiquid.P, OutletLiquid.z); |
---|
456 | |
---|
457 | "Molar Holdup" |
---|
458 | TotalHoldup = OutletLiquid.z*sum(TotalHoldup); |
---|
459 | |
---|
460 | "Liquid Level" |
---|
461 | Geometry.Vfilled = sum(TotalHoldup) * vL; |
---|
462 | |
---|
463 | "Temperature indicator" |
---|
464 | TI * 'K' = OutletLiquid.T; |
---|
465 | |
---|
466 | "Pressure indicator" |
---|
467 | PI * 'atm' = OutletLiquid.P; |
---|
468 | |
---|
469 | "Level indicator" |
---|
470 | LI*Geometry.Vtotal= Geometry.Vfilled; |
---|
471 | |
---|
472 | end |
---|
473 | |
---|
474 | Model SumpTank |
---|
475 | |
---|
476 | ATTRIBUTES |
---|
477 | Pallete = true; |
---|
478 | Icon = "icon/SumpTank"; |
---|
479 | Brief = "Model of a tank with 2 material inlet streams and with thermodynamic equilibrium."; |
---|
480 | Info = |
---|
481 | "== ASSUMPTIONS == |
---|
482 | * perfect mixing of both phases; |
---|
483 | * thermodynamics equilibrium. |
---|
484 | |
---|
485 | == SET == |
---|
486 | *Orientation: vessel position - vertical or horizontal; |
---|
487 | *Heads (bottom and top heads are identical) |
---|
488 | **elliptical: 2:1 elliptical heads (25% of vessel diameter); |
---|
489 | **hemispherical: hemispherical heads (50% of vessel diameter); |
---|
490 | **flat: flat heads (0% of vessel diameter); |
---|
491 | *Diameter: Vessel diameter; |
---|
492 | *Lenght: Side length of the cylinder shell; |
---|
493 | |
---|
494 | == SPECIFY == |
---|
495 | * the Inlet stream; |
---|
496 | * the outlet flows: OutletVapour.F and OutletLiquid.F; |
---|
497 | * the InletQ (the model requires an energy stream, also you can use a controller for setting the heat duty using the heat_flow model). |
---|
498 | |
---|
499 | == OPTIONAL == |
---|
500 | * the SumpTank model has three control ports |
---|
501 | ** TI OutletLiquid Temperature Indicator; |
---|
502 | ** PI OutletLiquid Pressure Indicator; |
---|
503 | ** LI Level Indicator; |
---|
504 | |
---|
505 | == INITIAL CONDITIONS == |
---|
506 | * Initial_Temperature : the Tank temperature (OutletLiquid.T); |
---|
507 | * Levelpercent_Initial : the Tank liquid level in percent (LI); |
---|
508 | * Initial_Composition : (NoComps) OutletLiquid compositions. |
---|
509 | "; |
---|
510 | |
---|
511 | PARAMETERS |
---|
512 | outer PP as Plugin (Brief = "External Physical Properties", Type="PP"); |
---|
513 | outer NComp as Integer (Brief = "Number of components", Lower = 1); |
---|
514 | |
---|
515 | Mw(NComp) as molweight (Brief="Mol Weight", Hidden=true); |
---|
516 | pi as positive (Brief="Pi value", Default=3.141593,Hidden=true, Symbol="\pi"); |
---|
517 | g as acceleration (Brief="Gravity Acceleration",Default=9.81,Hidden=true); |
---|
518 | |
---|
519 | Heads as Switcher (Valid=["elliptical","hemispherical","flat"],Default="flat"); |
---|
520 | Diameter as length (Brief="Vessel diameter", Symbol="D_{i}"); |
---|
521 | Lenght as length (Brief="Side length of the cylinder shell", Symbol="L_{vessel}"); |
---|
522 | |
---|
523 | Vhead_elliptical as volume (Brief="Elliptical Head Total Volume",Hidden=true, Symbol="V_{head}^{elliptical}"); |
---|
524 | Vhead_hemispherical as volume (Brief="Hemispherical Head Total Volume",Hidden=true, Symbol="V_{head}^{hemispherical}"); |
---|
525 | Vcylinder as volume (Brief="Cylinder Total Volume",Hidden=true, Symbol="V_{cylinder}"); |
---|
526 | radius as length (Brief="Vessel radius",Hidden=true, Symbol="R_{cylinder}"); |
---|
527 | |
---|
528 | Levelpercent_Initial as positive (Brief="Initial liquid height in Percent", Default = 0.70); |
---|
529 | Temperature_Initial as temperature (Brief="Initial Liquid Temperature", Default = 330); |
---|
530 | Composition_Initial(NComp) as fraction (Brief="Initial Composition", Default = 0.10); |
---|
531 | |
---|
532 | SET |
---|
533 | |
---|
534 | Mw=PP.MolecularWeight(); |
---|
535 | |
---|
536 | g = 9.81 * 'm/(s^2)'; |
---|
537 | Vhead_elliptical = (pi*Diameter^3)/12; |
---|
538 | Vhead_hemispherical = (pi*Diameter^3)/6; |
---|
539 | Vcylinder = 0.25*(pi*Diameter^2)*Lenght; |
---|
540 | radius = 0.5*Diameter; |
---|
541 | |
---|
542 | VARIABLES |
---|
543 | |
---|
544 | in InletLiquid as stream (Brief="Feed Stream", PosX=0.22, PosY=0, Symbol="_{in}"); |
---|
545 | out OutletLiquid as liquid_stream (Brief="Liquid outlet stream", PosX=0.50, PosY=1, Symbol="_{out}^{Liquid}"); |
---|
546 | in InletVapour as stream (Brief="Vapour outlet stream", PosX=1, PosY=0.20, Symbol="_{out}^{Vapour}"); |
---|
547 | out OutletVapour as vapour_stream (Brief="Vapour outlet stream", PosX=0.68, PosY=0, Symbol="_{out}^{Vapour}"); |
---|
548 | InletQ as power (Brief="Heat Duty", Protected =false,Symbol="Q_{in}"); |
---|
549 | |
---|
550 | Vtotal as volume (Brief="Vessel total volume",Protected=true, Symbol="V_{total}"); |
---|
551 | Vfilled as volume (Brief="Vessel volume content",Protected=true, Symbol="V_{filled}"); |
---|
552 | |
---|
553 | TotalHoldup(NComp) as mol (Brief="Molar Holdup in the Vessel", Protected=true); |
---|
554 | LiquidHoldup as mol (Brief="Molar liquid holdup", Protected=true); |
---|
555 | VapourHoldup as mol (Brief="Molar vapour holdup", Protected=true); |
---|
556 | |
---|
557 | E as energy (Brief="Total Energy Holdup in the Vessel", Protected=true); |
---|
558 | vL as volume_mol (Brief="Liquid Molar Volume", Protected=true); |
---|
559 | vV as volume_mol (Brief="Vapour Molar volume", Protected=true); |
---|
560 | Level as length (Brief="liquid height", Protected=true); |
---|
561 | Across as area (Brief="Vessel cylinder shell Cross section area", Hidden=true, Symbol="A_{cross}"); |
---|
562 | #Pdrop as press_delta (Brief = "Pressure Drop", DisplayUnit = 'kPa', Symbol ="\Delta P", Protected=true); |
---|
563 | |
---|
564 | Peq as pressure (Brief="Equilibrium pressure on the liquid surface", Protected=true, Symbol="P_{eq}"); |
---|
565 | Pstatic as pressure (Brief="Static head at the bottom of the tank", Protected = true, Symbol="P_{static}^{Liquid}"); |
---|
566 | |
---|
567 | out LI as control_signal (Brief="Level Indicator", PosX=1, PosY=0.73, Protected=true); |
---|
568 | out TI as control_signal (Brief="Temperature Indicator", PosX=1, PosY=0.40, Protected=true); |
---|
569 | |
---|
570 | INITIAL |
---|
571 | |
---|
572 | "Initial level Percent" |
---|
573 | LI = Levelpercent_Initial; |
---|
574 | |
---|
575 | "Initial Outlet Liquid Temperature" |
---|
576 | OutletLiquid.T = Temperature_Initial; |
---|
577 | |
---|
578 | "Initial Outlet Liquid Composition Normalized" |
---|
579 | OutletLiquid.z(1:NComp - 1) = Composition_Initial(1:NComp - 1)/sum(Composition_Initial); |
---|
580 | |
---|
581 | EQUATIONS |
---|
582 | |
---|
583 | "Vessel Cross Section Area" |
---|
584 | Across = 0.25*(pi*Diameter^2); |
---|
585 | |
---|
586 | switch Heads |
---|
587 | |
---|
588 | case "elliptical": |
---|
589 | |
---|
590 | "Vessel Total Volume" |
---|
591 | Vtotal = Vhead_elliptical + Vcylinder; |
---|
592 | |
---|
593 | if Level < 0.25*Diameter then |
---|
594 | |
---|
595 | "Vessel Filled Volume" |
---|
596 | Vfilled = 0.25*pi*(((Diameter*Level)/(0.25*Diameter))^2)*(0.25*Diameter-Level/3); |
---|
597 | |
---|
598 | else |
---|
599 | |
---|
600 | "Vessel Filled Volume" |
---|
601 | Vfilled = 0.25*pi*(Diameter^2)*(Level - 0.25*Diameter/3); |
---|
602 | |
---|
603 | end |
---|
604 | |
---|
605 | case "hemispherical": |
---|
606 | |
---|
607 | "Vessel Total Volume" |
---|
608 | Vtotal = Vhead_hemispherical + Vcylinder; |
---|
609 | |
---|
610 | if Level < 0.5*Diameter then |
---|
611 | |
---|
612 | "Vessel Filled Volume" |
---|
613 | Vfilled = 0.25*pi*(Level^2)*(2*Diameter-4*Level/3); |
---|
614 | |
---|
615 | else |
---|
616 | |
---|
617 | "Vessel Filled Volume" |
---|
618 | Vfilled = 0.25*pi*((2/3)*((0.5*Diameter)^3) - (0.25*(Diameter)^3) + Level*Diameter^2); |
---|
619 | |
---|
620 | end |
---|
621 | |
---|
622 | case "flat": |
---|
623 | |
---|
624 | "Vessel Total Volume" |
---|
625 | Vtotal = Vcylinder; |
---|
626 | |
---|
627 | "Vessel Filled Volume" |
---|
628 | Vfilled = Across*Level; |
---|
629 | |
---|
630 | end |
---|
631 | |
---|
632 | "Component Molar Balance" |
---|
633 | diff(TotalHoldup) = InletLiquid.F*InletLiquid.z + InletVapour.F*InletVapour.z- OutletLiquid.F*OutletLiquid.z - OutletVapour.F*OutletVapour.z; |
---|
634 | |
---|
635 | "Energy Balance" |
---|
636 | diff(E) = InletLiquid.F*InletLiquid.h + InletVapour.F*InletVapour.h - OutletLiquid.F*OutletLiquid.h - OutletVapour.F*OutletVapour.h + InletQ; |
---|
637 | |
---|
638 | "Molar Holdup" |
---|
639 | TotalHoldup = LiquidHoldup*OutletLiquid.z + VapourHoldup*OutletVapour.z; |
---|
640 | |
---|
641 | "Energy Holdup" |
---|
642 | E = LiquidHoldup*OutletLiquid.h + VapourHoldup*OutletVapour.h - OutletLiquid.P*Vtotal; |
---|
643 | |
---|
644 | "Mol fraction normalisation" |
---|
645 | sum(OutletLiquid.z)=1.0; |
---|
646 | |
---|
647 | "Mol fraction normalisation" |
---|
648 | sum(OutletLiquid.z)=sum(OutletVapour.z); |
---|
649 | |
---|
650 | "Liquid Volume" |
---|
651 | vL = PP.LiquidVolume(OutletLiquid.T, Peq, OutletLiquid.z); |
---|
652 | |
---|
653 | "Vapour Volume" |
---|
654 | vV = PP.VapourVolume(OutletVapour.T, Peq, OutletVapour.z); |
---|
655 | |
---|
656 | "Chemical Equilibrium" |
---|
657 | PP.LiquidFugacityCoefficient(OutletLiquid.T, Peq, OutletLiquid.z)*OutletLiquid.z = |
---|
658 | PP.VapourFugacityCoefficient(OutletVapour.T, Peq, OutletVapour.z)*OutletVapour.z; |
---|
659 | |
---|
660 | "Thermal Equilibrium" |
---|
661 | OutletVapour.T = OutletLiquid.T; |
---|
662 | |
---|
663 | "Mechanical Equilibrium for the Vapour Phase" |
---|
664 | OutletVapour.P = Peq; |
---|
665 | |
---|
666 | "Static Head" |
---|
667 | Pstatic = PP.LiquidDensity(OutletLiquid.T, Peq, OutletLiquid.z) * g * Level; |
---|
668 | |
---|
669 | "Mechanical Equilibrium for the Liquid Phase" |
---|
670 | OutletLiquid.P = Peq + Pstatic; |
---|
671 | |
---|
672 | #*"Pressure Drop" |
---|
673 | Pdrop = min([InletLiquid.P,InletVapour.P]) - OutletLiquid.P; |
---|
674 | #OutletLiquid.P = InletLiquid.P - Pdrop; |
---|
675 | *# |
---|
676 | |
---|
677 | "Geometry Constraint" |
---|
678 | Vtotal = LiquidHoldup * vL + VapourHoldup * vV; |
---|
679 | |
---|
680 | "Level indicator" |
---|
681 | LI*Vtotal= Vfilled; |
---|
682 | |
---|
683 | "Temperature indicator" |
---|
684 | TI * 'K' = OutletVapour.T; |
---|
685 | |
---|
686 | "Liquid Level" |
---|
687 | LiquidHoldup * vL = Vfilled; |
---|
688 | |
---|
689 | end |
---|
690 | |
---|