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