[1] | 1 | #*------------------------------------------------------------------- |
---|
[72] | 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. |
---|
[1] | 14 | *---------------------------------------------------------------------- |
---|
| 15 | * Author: Paula B. Staudt |
---|
| 16 | * $Id: tank.mso 981 2016-05-23 12:46:53Z arge $ |
---|
| 17 | *--------------------------------------------------------------------*# |
---|
| 18 | |
---|
| 19 | using "streams"; |
---|
| 20 | |
---|
[879] | 21 | Model VesselVolume |
---|
[794] | 22 | |
---|
| 23 | ATTRIBUTES |
---|
[879] | 24 | Pallete = false; |
---|
| 25 | Brief = "Model to calculate vessel total volume and vessel filled volume from |
---|
| 26 | different geometries and orientations."; |
---|
[794] | 27 | Info = |
---|
[879] | 28 | "== SET == |
---|
[795] | 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; |
---|
[794] | 36 | "; |
---|
| 37 | |
---|
| 38 | PARAMETERS |
---|
[918] | 39 | Pi as positive (Brief="Pi value", Default=3.141593,Hidden=true, Symbol="\pi"); |
---|
[879] | 40 | Gconst as acceleration (Brief="Gravity Acceleration",Default=9.81,Hidden=true); |
---|
[795] | 41 | |
---|
| 42 | Orientation as Switcher (Valid=["vertical","horizontal"],Default="vertical"); |
---|
| 43 | Heads as Switcher (Valid=["elliptical","hemispherical","flat"],Default="flat"); |
---|
[879] | 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}"); |
---|
[794] | 46 | |
---|
[795] | 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}"); |
---|
[831] | 51 | |
---|
[794] | 52 | SET |
---|
[795] | 53 | |
---|
[879] | 54 | Gconst = 9.81 * 'm/(s^2)'; |
---|
[918] | 55 | Vhead_elliptical = (Pi*Diameter^3)/12; |
---|
| 56 | Vhead_hemispherical = (Pi*Diameter^3)/6; |
---|
| 57 | Vcylinder = 0.25*(Pi*Diameter^2)*Lenght; |
---|
[794] | 58 | radius = 0.5*Diameter; |
---|
[831] | 59 | |
---|
[794] | 60 | VARIABLES |
---|
| 61 | |
---|
[879] | 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}"); |
---|
[795] | 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 | |
---|
[794] | 67 | EQUATIONS |
---|
| 68 | |
---|
[795] | 69 | switch Orientation |
---|
| 70 | |
---|
| 71 | case "vertical": |
---|
| 72 | |
---|
| 73 | "Vessel Cross Section Area" |
---|
[918] | 74 | Across = 0.25*(Pi*Diameter^2); |
---|
[795] | 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" |
---|
[918] | 86 | Vfilled = 0.25*Pi*(((Diameter*Level)/(0.25*Diameter))^2)*(0.25*Diameter-Level/3); |
---|
[795] | 87 | |
---|
| 88 | else |
---|
| 89 | |
---|
| 90 | "Vessel Filled Volume" |
---|
[918] | 91 | Vfilled = 0.25*Pi*(Diameter^2)*(Level - 0.25*Diameter/3); |
---|
[795] | 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" |
---|
[918] | 103 | Vfilled = 0.25*Pi*(Level^2)*(2*Diameter-4*Level/3); |
---|
[795] | 104 | |
---|
| 105 | else |
---|
| 106 | |
---|
| 107 | "Vessel Filled Volume" |
---|
[918] | 108 | Vfilled = 0.25*Pi*((2/3)*((0.5*Diameter)^3) - (0.25*(Diameter)^3) + Level*Diameter^2); |
---|
[795] | 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" |
---|
[981] | 125 | Across = (radius^2)*acos((radius-Level)/radius)/'rad'-(radius-Level)*sqrt((2*radius*Level-Level^2)); |
---|
[795] | 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 | |
---|
[879] | 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 | |
---|
[831] | 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 | |
---|
[795] | 273 | "Component Molar Balance" |
---|
| 274 | diff(TotalHoldup)=Inlet.F*Inlet.z - OutletLiquid.F*OutletLiquid.z - OutletVapour.F*OutletVapour.z; |
---|
[794] | 275 | |
---|
[795] | 276 | "Energy Balance" |
---|
| 277 | diff(E) = Inlet.F*Inlet.h - OutletLiquid.F*OutletLiquid.h - OutletVapour.F*OutletVapour.h + InletQ; |
---|
[794] | 278 | |
---|
[795] | 279 | "Molar Holdup" |
---|
| 280 | TotalHoldup = LiquidHoldup*OutletLiquid.z + VapourHoldup*OutletVapour.z; |
---|
| 281 | |
---|
[794] | 282 | "Energy Holdup" |
---|
[879] | 283 | E = LiquidHoldup*OutletLiquid.h + VapourHoldup*OutletVapour.h - OutletLiquid.P*Geometry.Vtotal; |
---|
[794] | 284 | |
---|
[795] | 285 | "Mol fraction normalisation" |
---|
| 286 | sum(OutletLiquid.z)=1.0; |
---|
| 287 | |
---|
| 288 | "Mol fraction normalisation" |
---|
| 289 | sum(OutletLiquid.z)=sum(OutletVapour.z); |
---|
| 290 | |
---|
[794] | 291 | "Liquid Volume" |
---|
[831] | 292 | vL = PP.LiquidVolume(OutletLiquid.T, Peq, OutletLiquid.z); |
---|
[795] | 293 | |
---|
| 294 | "Vapour Volume" |
---|
[831] | 295 | vV = PP.VapourVolume(OutletVapour.T, Peq, OutletVapour.z); |
---|
[794] | 296 | |
---|
[795] | 297 | "Chemical Equilibrium" |
---|
[831] | 298 | PP.LiquidFugacityCoefficient(OutletLiquid.T, Peq, OutletLiquid.z)*OutletLiquid.z = |
---|
| 299 | PP.VapourFugacityCoefficient(OutletVapour.T, Peq, OutletVapour.z)*OutletVapour.z; |
---|
[794] | 300 | |
---|
[795] | 301 | "Thermal Equilibrium" |
---|
| 302 | OutletVapour.T = OutletLiquid.T; |
---|
| 303 | |
---|
| 304 | "Mechanical Equilibrium" |
---|
[831] | 305 | OutletVapour.P = Peq; |
---|
[794] | 306 | |
---|
[831] | 307 | "Static Head" |
---|
[879] | 308 | Pstatic = PP.LiquidDensity(OutletLiquid.T, Peq, OutletLiquid.z) * Gconst * Geometry.Level; |
---|
[831] | 309 | |
---|
| 310 | "Mechanical Equilibrium for the Liquid Phase" |
---|
| 311 | OutletLiquid.P = Peq + Pstatic; |
---|
| 312 | |
---|
[795] | 313 | "Pressure Drop" |
---|
[831] | 314 | Pdrop = Inlet.P - OutletVapour.P; |
---|
[794] | 315 | |
---|
[795] | 316 | "Geometry Constraint" |
---|
[879] | 317 | Geometry.Vtotal = LiquidHoldup * vL + VapourHoldup * vV; |
---|
[795] | 318 | |
---|
| 319 | "Temperature indicator" |
---|
| 320 | TI * 'K' = OutletLiquid.T; |
---|
| 321 | |
---|
| 322 | "Pressure indicator" |
---|
| 323 | PI * 'atm' = OutletLiquid.P; |
---|
| 324 | |
---|
| 325 | "Level indicator" |
---|
[879] | 326 | LI*Geometry.Vtotal= Geometry.Vfilled; |
---|
[795] | 327 | |
---|
| 328 | "Liquid Level" |
---|
[879] | 329 | LiquidHoldup * vL = Geometry.Vfilled; |
---|
[795] | 330 | |
---|
[794] | 331 | end |
---|
| 332 | |
---|
[799] | 333 | Model TankL |
---|
| 334 | |
---|
| 335 | ATTRIBUTES |
---|
[270] | 336 | Pallete = true; |
---|
[799] | 337 | Icon = "icon/TankL"; |
---|
| 338 | Brief = "Model of a Tank."; |
---|
[270] | 339 | Info = |
---|
[799] | 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] | 353 | * the Inlet stream; |
---|
[799] | 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). |
---|
[1] | 356 | |
---|
[799] | 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); |
---|
[821] | 365 | * Levelpercent_Initial : the Tank liquid level in percent (LI); |
---|
[799] | 366 | * Initial_Composition : (NoComps) OutletLiquid compositions. |
---|
[353] | 367 | "; |
---|
[270] | 368 | |
---|
[649] | 369 | PARAMETERS |
---|
[799] | 370 | outer PP as Plugin (Brief = "External Physical Properties", Type="PP"); |
---|
| 371 | outer NComp as Integer (Brief = "Number of components", Lower = 1); |
---|
| 372 | |
---|
[879] | 373 | Gconst as acceleration (Brief="Gravity Acceleration",Default=9.81,Hidden=true); |
---|
[831] | 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 | |
---|
[799] | 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); |
---|
[781] | 385 | |
---|
| 386 | SET |
---|
| 387 | |
---|
[879] | 388 | Gconst = 9.81 * 'm/(s^2)'; |
---|
[831] | 389 | low_flow = 1E-6 * 'kmol/h'; |
---|
| 390 | zero_flow = 0 * 'kmol/h'; |
---|
| 391 | KfConst = 1*'mol/(s*(Pa^0.5))'; |
---|
[799] | 392 | |
---|
[649] | 393 | VARIABLES |
---|
[1] | 394 | |
---|
[879] | 395 | Geometry as VesselVolume (Brief="Vessel Geometry", Symbol=" "); |
---|
| 396 | |
---|
[799] | 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}"); |
---|
[721] | 400 | |
---|
[799] | 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); |
---|
[828] | 405 | Pstatic as pressure (Brief="Static head at the bottom of the tank", Protected = true, Symbol="P_{static}^{Liquid}"); |
---|
| 406 | |
---|
[799] | 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); |
---|
[782] | 410 | |
---|
[799] | 411 | INITIAL |
---|
[649] | 412 | |
---|
[799] | 413 | "Initial level Percent" |
---|
| 414 | LI = Levelpercent_Initial; |
---|
[782] | 415 | |
---|
[799] | 416 | "Initial Outlet Liquid Temperature" |
---|
| 417 | OutletLiquid.T = Temperature_Initial; |
---|
[1] | 418 | |
---|
[799] | 419 | "Initial Outlet Liquid Composition Normalized" |
---|
| 420 | OutletLiquid.z(1:NComp - 1) = Composition_Initial(1:NComp - 1)/sum(Composition_Initial); |
---|
[1] | 421 | |
---|
[799] | 422 | EQUATIONS |
---|
| 423 | |
---|
[831] | 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 | *# |
---|
[799] | 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 | |
---|
[649] | 445 | "Energy Holdup" |
---|
[799] | 446 | E = sum(TotalHoldup)*OutletLiquid.h; |
---|
| 447 | |
---|
[828] | 448 | "Static Head" |
---|
[879] | 449 | Pstatic = PP.LiquidDensity(OutletLiquid.T, Inlet.P, OutletLiquid.z) * Gconst * Geometry.Level; |
---|
[828] | 450 | |
---|
[649] | 451 | "Mechanical Equilibrium" |
---|
[828] | 452 | Inlet.P + Pstatic = OutletLiquid.P; |
---|
[799] | 453 | |
---|
[649] | 454 | "Liquid Volume" |
---|
[799] | 455 | vL = PP.LiquidVolume(OutletLiquid.T, OutletLiquid.P, OutletLiquid.z); |
---|
| 456 | |
---|
| 457 | "Molar Holdup" |
---|
| 458 | TotalHoldup = OutletLiquid.z*sum(TotalHoldup); |
---|
[1] | 459 | |
---|
[799] | 460 | "Liquid Level" |
---|
[879] | 461 | Geometry.Vfilled = sum(TotalHoldup) * vL; |
---|
[1] | 462 | |
---|
[799] | 463 | "Temperature indicator" |
---|
| 464 | TI * 'K' = OutletLiquid.T; |
---|
[1] | 465 | |
---|
[799] | 466 | "Pressure indicator" |
---|
| 467 | PI * 'atm' = OutletLiquid.P; |
---|
[649] | 468 | |
---|
[799] | 469 | "Level indicator" |
---|
[879] | 470 | LI*Geometry.Vtotal= Geometry.Vfilled; |
---|
[781] | 471 | |
---|
[1] | 472 | end |
---|
| 473 | |
---|
[800] | 474 | Model SumpTank |
---|
| 475 | |
---|
| 476 | ATTRIBUTES |
---|
| 477 | Pallete = true; |
---|
| 478 | Icon = "icon/SumpTank"; |
---|
[820] | 479 | Brief = "Model of a tank with 2 material inlet streams and with thermodynamic equilibrium."; |
---|
[800] | 480 | Info = |
---|
| 481 | "== ASSUMPTIONS == |
---|
[805] | 482 | * perfect mixing of both phases; |
---|
| 483 | * thermodynamics equilibrium. |
---|
[800] | 484 | |
---|
| 485 | == SET == |
---|
[805] | 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); |
---|
[800] | 491 | *Diameter: Vessel diameter; |
---|
| 492 | *Lenght: Side length of the cylinder shell; |
---|
| 493 | |
---|
| 494 | == SPECIFY == |
---|
| 495 | * the Inlet stream; |
---|
[805] | 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). |
---|
[800] | 498 | |
---|
| 499 | == OPTIONAL == |
---|
[821] | 500 | * the SumpTank model has three control ports |
---|
[805] | 501 | ** TI OutletLiquid Temperature Indicator; |
---|
| 502 | ** PI OutletLiquid Pressure Indicator; |
---|
[800] | 503 | ** LI Level Indicator; |
---|
| 504 | |
---|
| 505 | == INITIAL CONDITIONS == |
---|
| 506 | * Initial_Temperature : the Tank temperature (OutletLiquid.T); |
---|
[821] | 507 | * Levelpercent_Initial : the Tank liquid level in percent (LI); |
---|
[800] | 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 | |
---|
[805] | 515 | Mw(NComp) as molweight (Brief="Mol Weight", Hidden=true); |
---|
[800] | 516 | pi as positive (Brief="Pi value", Default=3.141593,Hidden=true, Symbol="\pi"); |
---|
[820] | 517 | g as acceleration (Brief="Gravity Acceleration",Default=9.81,Hidden=true); |
---|
[805] | 518 | |
---|
| 519 | Heads as Switcher (Valid=["elliptical","hemispherical","flat"],Default="flat"); |
---|
[800] | 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 | |
---|
[805] | 534 | Mw=PP.MolecularWeight(); |
---|
| 535 | |
---|
[820] | 536 | g = 9.81 * 'm/(s^2)'; |
---|
[805] | 537 | Vhead_elliptical = (pi*Diameter^3)/12; |
---|
| 538 | Vhead_hemispherical = (pi*Diameter^3)/6; |
---|
[800] | 539 | Vcylinder = 0.25*(pi*Diameter^2)*Lenght; |
---|
| 540 | radius = 0.5*Diameter; |
---|
| 541 | |
---|
| 542 | VARIABLES |
---|
| 543 | |
---|
[805] | 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}"); |
---|
[800] | 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); |
---|
[805] | 554 | LiquidHoldup as mol (Brief="Molar liquid holdup", Protected=true); |
---|
| 555 | VapourHoldup as mol (Brief="Molar vapour holdup", Protected=true); |
---|
[800] | 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); |
---|
[805] | 559 | vV as volume_mol (Brief="Vapour Molar volume", Protected=true); |
---|
[800] | 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}"); |
---|
[826] | 562 | #Pdrop as press_delta (Brief = "Pressure Drop", DisplayUnit = 'kPa', Symbol ="\Delta P", Protected=true); |
---|
[800] | 563 | |
---|
[825] | 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}"); |
---|
[820] | 566 | |
---|
[883] | 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); |
---|
[800] | 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 | |
---|
[805] | 586 | switch Heads |
---|
[800] | 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" |
---|
[805] | 633 | diff(TotalHoldup) = InletLiquid.F*InletLiquid.z + InletVapour.F*InletVapour.z- OutletLiquid.F*OutletLiquid.z - OutletVapour.F*OutletVapour.z; |
---|
[800] | 634 | |
---|
| 635 | "Energy Balance" |
---|
[805] | 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 | |
---|
[800] | 641 | "Energy Holdup" |
---|
[805] | 642 | E = LiquidHoldup*OutletLiquid.h + VapourHoldup*OutletVapour.h - OutletLiquid.P*Vtotal; |
---|
| 643 | |
---|
| 644 | "Mol fraction normalisation" |
---|
| 645 | sum(OutletLiquid.z)=1.0; |
---|
[800] | 646 | |
---|
[805] | 647 | "Mol fraction normalisation" |
---|
| 648 | sum(OutletLiquid.z)=sum(OutletVapour.z); |
---|
[800] | 649 | |
---|
| 650 | "Liquid Volume" |
---|
[820] | 651 | vL = PP.LiquidVolume(OutletLiquid.T, Peq, OutletLiquid.z); |
---|
[800] | 652 | |
---|
[805] | 653 | "Vapour Volume" |
---|
[820] | 654 | vV = PP.VapourVolume(OutletVapour.T, Peq, OutletVapour.z); |
---|
[800] | 655 | |
---|
[805] | 656 | "Chemical Equilibrium" |
---|
[820] | 657 | PP.LiquidFugacityCoefficient(OutletLiquid.T, Peq, OutletLiquid.z)*OutletLiquid.z = |
---|
| 658 | PP.VapourFugacityCoefficient(OutletVapour.T, Peq, OutletVapour.z)*OutletVapour.z; |
---|
[800] | 659 | |
---|
[805] | 660 | "Thermal Equilibrium" |
---|
| 661 | OutletVapour.T = OutletLiquid.T; |
---|
| 662 | |
---|
[820] | 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; |
---|
[805] | 668 | |
---|
[820] | 669 | "Mechanical Equilibrium for the Liquid Phase" |
---|
| 670 | OutletLiquid.P = Peq + Pstatic; |
---|
| 671 | |
---|
[826] | 672 | #*"Pressure Drop" |
---|
[820] | 673 | Pdrop = min([InletLiquid.P,InletVapour.P]) - OutletLiquid.P; |
---|
| 674 | #OutletLiquid.P = InletLiquid.P - Pdrop; |
---|
[826] | 675 | *# |
---|
[805] | 676 | |
---|
| 677 | "Geometry Constraint" |
---|
| 678 | Vtotal = LiquidHoldup * vL + VapourHoldup * vV; |
---|
| 679 | |
---|
[800] | 680 | "Level indicator" |
---|
| 681 | LI*Vtotal= Vfilled; |
---|
| 682 | |
---|
[807] | 683 | "Temperature indicator" |
---|
[834] | 684 | TI * 'K' = OutletVapour.T; |
---|
[807] | 685 | |
---|
[805] | 686 | "Liquid Level" |
---|
| 687 | LiquidHoldup * vL = Vfilled; |
---|
| 688 | |
---|
[800] | 689 | end |
---|
| 690 | |
---|
[913] | 691 | Model tank_simplified |
---|
| 692 | ATTRIBUTES |
---|
| 693 | Pallete = true; |
---|
| 694 | Icon = "icon/Tank"; |
---|
| 695 | Brief = "Model of a simplified tank."; |
---|
| 696 | Info = |
---|
| 697 | "== Specify == |
---|
| 698 | * the Inlet flow rate; |
---|
| 699 | |
---|
| 700 | == Initial Conditions == |
---|
| 701 | * the tank initial level (Level); |
---|
| 702 | "; |
---|
| 703 | |
---|
| 704 | PARAMETERS |
---|
| 705 | k as Real (Brief="Valve Constant", Unit = 'm^2.5/h', Default=4); |
---|
| 706 | A as area (Brief="Tank area", Default=2); |
---|
| 707 | |
---|
| 708 | VARIABLES |
---|
| 709 | Level as length(Brief="Tank level"); |
---|
| 710 | in Fin as flow_vol(Brief="Input flow", PosX=0.3037, PosY=0); |
---|
| 711 | out Fout as flow_vol(Brief="Output flow", PosX=1, PosY=1); |
---|
| 712 | |
---|
| 713 | EQUATIONS |
---|
| 714 | "Mass balance" |
---|
| 715 | diff(A*Level) = Fin - Fout; |
---|
| 716 | |
---|
| 717 | "Valve equation" |
---|
| 718 | Fout = k*sqrt(Level); |
---|
| 719 | end |
---|