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