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