[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 680 2008-11-18 13:18:51Z arge $ |
---|
| 17 | *--------------------------------------------------------------------*# |
---|
| 18 | |
---|
| 19 | using "streams"; |
---|
| 20 | |
---|
| 21 | Model flash |
---|
[270] | 22 | ATTRIBUTES |
---|
| 23 | Pallete = true; |
---|
[300] | 24 | Icon = "icon/Flash"; |
---|
[270] | 25 | Brief = "Model of a dynamic flash."; |
---|
| 26 | Info = |
---|
[353] | 27 | "== Assumptions == |
---|
| 28 | * both phases are perfectly mixed. |
---|
[270] | 29 | |
---|
[353] | 30 | == Specify == |
---|
| 31 | * the feed stream; |
---|
| 32 | * the outlet flows: OutletV.F and OutletL.F. |
---|
[270] | 33 | |
---|
[353] | 34 | == Initial Conditions == |
---|
| 35 | * the flash initial temperature (OutletL.T); |
---|
| 36 | * the flash initial level (Level); |
---|
| 37 | * (NoComps - 1) OutletL (OR OutletV) compositions. |
---|
| 38 | "; |
---|
[270] | 39 | |
---|
[1] | 40 | PARAMETERS |
---|
[323] | 41 | outer PP as Plugin (Brief = "External Physical Properties", Type="PP"); |
---|
| 42 | outer NComp as Integer (Brief = "Number of chemical components", Lower = 1); |
---|
[235] | 43 | V as volume (Brief="Total Volume of the flash"); |
---|
[1] | 44 | Mw(NComp) as molweight; |
---|
[235] | 45 | orientation as Switcher (Valid=["vertical","horizontal"],Default="vertical"); |
---|
| 46 | diameter as length (Brief="Vessel diameter"); |
---|
| 47 | |
---|
[1] | 48 | SET |
---|
| 49 | Mw=PP.MolecularWeight(); |
---|
[235] | 50 | |
---|
[1] | 51 | VARIABLES |
---|
[352] | 52 | in Inlet as stream(Brief="Feed Stream", PosX=0, PosY=0.5421, Symbol="_{in}"); |
---|
| 53 | out OutletL as liquid_stream(Brief="Liquid outlet stream", PosX=0.4790, PosY=1, Symbol="_{outL}"); |
---|
| 54 | out OutletV as vapour_stream(Brief="Vapour outlet stream", PosX=0.4877, PosY=0, Symbol="_{outV}"); |
---|
| 55 | in InletQ as energy_stream (Brief="Rate of heat supply", PosX=1, PosY=0.7559, Symbol="_{in}"); |
---|
[1] | 56 | |
---|
| 57 | M(NComp) as mol (Brief="Molar Holdup in the tray"); |
---|
| 58 | ML as mol (Brief="Molar liquid holdup"); |
---|
| 59 | MV as mol (Brief="Molar vapour holdup"); |
---|
| 60 | E as energy (Brief="Total Energy Holdup on tray"); |
---|
| 61 | vL as volume_mol (Brief="Liquid Molar Volume"); |
---|
| 62 | vV as volume_mol (Brief="Vapour Molar volume"); |
---|
| 63 | Level as length (Brief="liquid height"); |
---|
[235] | 64 | Across as area (Brief="Flash Cross section area"); |
---|
[680] | 65 | vMfrac as positive (Brief="Vapour Molar fraction", Symbol="\ksi"); |
---|
[352] | 66 | vfrac as positive (Brief="Vapourization fraction", Symbol="\phi"); |
---|
[372] | 67 | Pratio as positive (Brief = "Pressure Ratio", Symbol ="P_{ratio}"); |
---|
| 68 | Pdrop as press_delta (Brief = "Pressure Drop", DisplayUnit = 'kPa', Symbol ="\Delta P"); |
---|
[235] | 69 | |
---|
[1] | 70 | EQUATIONS |
---|
| 71 | "Component Molar Balance" |
---|
| 72 | diff(M)=Inlet.F*Inlet.z - OutletL.F*OutletL.z - OutletV.F*OutletV.z; |
---|
| 73 | |
---|
| 74 | "Energy Balance" |
---|
[310] | 75 | diff(E) = Inlet.F*Inlet.h - OutletL.F*OutletL.h - OutletV.F*OutletV.h + InletQ.Q; |
---|
[1] | 76 | |
---|
| 77 | "Molar Holdup" |
---|
| 78 | M = ML*OutletL.z + MV*OutletV.z; |
---|
| 79 | |
---|
| 80 | "Energy Holdup" |
---|
| 81 | E = ML*OutletL.h + MV*OutletV.h - OutletL.P*V; |
---|
| 82 | |
---|
| 83 | "Mol fraction normalisation" |
---|
| 84 | sum(OutletL.z)=1.0; |
---|
[333] | 85 | |
---|
[1] | 86 | "Mol fraction normalisation" |
---|
| 87 | sum(OutletL.z)=sum(OutletV.z); |
---|
[333] | 88 | |
---|
[680] | 89 | if Inlet.F > 0 then |
---|
| 90 | "Vaporization Ratio" |
---|
| 91 | OutletV.F = Inlet.F * vfrac; |
---|
| 92 | else |
---|
| 93 | "Vaporization Ratio" |
---|
| 94 | OutletV.F = (OutletV.F + OutletL.F) * vfrac; |
---|
| 95 | end |
---|
| 96 | |
---|
[333] | 97 | "Vaporization Fraction" |
---|
[680] | 98 | MV = (ML + MV) * vMfrac; |
---|
[333] | 99 | |
---|
[1] | 100 | "Liquid Volume" |
---|
| 101 | vL = PP.LiquidVolume(OutletL.T, OutletL.P, OutletL.z); |
---|
[333] | 102 | |
---|
[1] | 103 | "Vapour Volume" |
---|
| 104 | vV = PP.VapourVolume(OutletV.T, OutletV.P, OutletV.z); |
---|
| 105 | |
---|
| 106 | "Chemical Equilibrium" |
---|
| 107 | PP.LiquidFugacityCoefficient(OutletL.T, OutletL.P, OutletL.z)*OutletL.z = |
---|
| 108 | PP.VapourFugacityCoefficient(OutletV.T, OutletV.P, OutletV.z)*OutletV.z; |
---|
| 109 | |
---|
| 110 | "Thermal Equilibrium" |
---|
| 111 | OutletV.T = OutletL.T; |
---|
| 112 | |
---|
| 113 | "Mechanical Equilibrium" |
---|
| 114 | OutletV.P = OutletL.P; |
---|
[372] | 115 | |
---|
| 116 | "Pressure Drop" |
---|
| 117 | OutletL.P = Inlet.P - Pdrop; |
---|
| 118 | |
---|
| 119 | "Pressure Ratio" |
---|
| 120 | OutletL.P = Inlet.P * Pratio; |
---|
| 121 | |
---|
[1] | 122 | "Geometry Constraint" |
---|
[235] | 123 | V = ML * vL + MV * vV; |
---|
| 124 | |
---|
| 125 | switch orientation |
---|
| 126 | case "vertical": |
---|
| 127 | "Cross Section Area" |
---|
| 128 | Across = 0.5 * asin(1) * diameter^2; |
---|
| 129 | |
---|
[1] | 130 | "Liquid Level" |
---|
[235] | 131 | ML * vL = Across * Level; |
---|
| 132 | |
---|
| 133 | case "horizontal": |
---|
| 134 | "Cylindrical Side Area" |
---|
| 135 | Across = 0.25*diameter^2 * (asin(1) - asin((diameter - 2*Level)/diameter)) + |
---|
| 136 | (Level - 0.5*diameter)*sqrt(Level*(diameter - Level)); |
---|
| 137 | |
---|
| 138 | "Liquid Level" |
---|
| 139 | 0.5 * asin(1) * diameter^2 * ML* vL = Across * V; |
---|
| 140 | end |
---|
[1] | 141 | end |
---|
| 142 | |
---|
| 143 | #*---------------------------------------------------------------------- |
---|
| 144 | * Model of a Steady State flash |
---|
| 145 | *---------------------------------------------------------------------*# |
---|
[117] | 146 | Model flash_steady |
---|
[270] | 147 | ATTRIBUTES |
---|
| 148 | Pallete = true; |
---|
[300] | 149 | Icon = "icon/Flash"; |
---|
[270] | 150 | Brief = "Model of a Steady State flash."; |
---|
| 151 | Info = |
---|
[353] | 152 | "== Assumptions == |
---|
| 153 | * both phases are perfectly mixed. |
---|
[270] | 154 | |
---|
[353] | 155 | == Specify == |
---|
| 156 | * the feed stream; |
---|
| 157 | * the outlet pressure (OutletV.P); |
---|
| 158 | * the outlet temperature OR the heat supplied. |
---|
| 159 | "; |
---|
[270] | 160 | |
---|
[1] | 161 | PARAMETERS |
---|
[323] | 162 | outer PP as Plugin(Brief = "External Physical Properties", Type="PP"); |
---|
[1] | 163 | |
---|
| 164 | VARIABLES |
---|
[352] | 165 | in Inlet as stream(Brief="Feed Stream", PosX=0, PosY=0.5421, Symbol="_{in}"); |
---|
| 166 | out OutletL as liquid_stream(Brief="Liquid outlet stream", PosX=0.4790, PosY=1, Symbol="_{outL}"); |
---|
| 167 | out OutletV as vapour_stream(Brief="Vapour outlet stream", PosX=0.4877, PosY=0, Symbol="_{outV}"); |
---|
| 168 | in InletQ as energy_stream (Brief="Rate of heat supply", PosX=1, PosY=0.7559, Symbol="_{in}"); |
---|
| 169 | vfrac as fraction (Brief="Vapourization fraction", Symbol="\phi"); |
---|
[372] | 170 | Pratio as positive (Brief = "Pressure Ratio", Symbol ="P_{ratio}"); |
---|
| 171 | Pdrop as press_delta (Brief = "Pressure Drop", DisplayUnit = 'kPa', Symbol ="\Delta P"); |
---|
[1] | 172 | |
---|
| 173 | EQUATIONS |
---|
| 174 | "The flash calculation" |
---|
| 175 | [vfrac, OutletL.z, OutletV.z] = PP.Flash(OutletV.T, OutletV.P, Inlet.z); |
---|
| 176 | |
---|
| 177 | "Global Molar Balance" |
---|
| 178 | Inlet.F = OutletV.F + OutletL.F; |
---|
[333] | 179 | |
---|
| 180 | "Vaporization Fraction" |
---|
[1] | 181 | OutletV.F = Inlet.F * vfrac; |
---|
[117] | 182 | |
---|
[1] | 183 | "Energy Balance" |
---|
[310] | 184 | Inlet.F*Inlet.h + InletQ.Q = OutletL.F*OutletL.h + OutletV.F*OutletV.h; |
---|
[1] | 185 | |
---|
| 186 | "Thermal Equilibrium" |
---|
| 187 | OutletV.T = OutletL.T; |
---|
| 188 | |
---|
| 189 | "Mechanical Equilibrium" |
---|
| 190 | OutletV.P = OutletL.P; |
---|
[372] | 191 | |
---|
| 192 | "Pressure Drop" |
---|
| 193 | OutletL.P = Inlet.P - Pdrop; |
---|
| 194 | |
---|
| 195 | "Pressure Ratio" |
---|
| 196 | OutletL.P = Inlet.P * Pratio; |
---|
[1] | 197 | end |
---|
[321] | 198 | |
---|
| 199 | #*---------------------------------------------------------------------- |
---|
| 200 | * Model of a steady-state PH flash. |
---|
| 201 | *---------------------------------------------------------------------*# |
---|
| 202 | Model FlashPHSteady |
---|
| 203 | ATTRIBUTES |
---|
| 204 | Pallete = true; |
---|
| 205 | Icon = "icon/Flash"; |
---|
| 206 | Brief = "Model of a static PH flash."; |
---|
[353] | 207 | Info = |
---|
| 208 | "This model is for using the flashPH routine available on VRTherm. |
---|
[321] | 209 | |
---|
[353] | 210 | == Assumptions == |
---|
| 211 | * perfect mixing of both phases; |
---|
[321] | 212 | |
---|
[353] | 213 | == Specify == |
---|
| 214 | * the feed stream; |
---|
| 215 | * the heat duty; |
---|
| 216 | * the outlet pressure. |
---|
| 217 | "; |
---|
[321] | 218 | |
---|
| 219 | PARAMETERS |
---|
| 220 | outer PP as Plugin(Brief = "External Physical Properties", Type="PP"); |
---|
| 221 | outer NComp as Integer; |
---|
| 222 | |
---|
| 223 | VARIABLES |
---|
[352] | 224 | in Inlet as stream(Brief="Feed Stream", PosX=0, PosY=0.5421, Symbol="_{in}"); |
---|
| 225 | out OutletL as liquid_stream(Brief="Liquid outlet stream", PosX=0.4790, PosY=1, Symbol="_{outL}"); |
---|
| 226 | out OutletV as vapour_stream(Brief="Vapour outlet stream", PosX=0.4877, PosY=0, Symbol="_{outV}"); |
---|
| 227 | in InletQ as energy_stream (Brief="Rate of heat supply", PosX=1, PosY=0.7559, Symbol="_{in}"); |
---|
| 228 | vfrac as fraction(Brief="Vaporization fraction", Symbol="\phi"); |
---|
[321] | 229 | h as enth_mol(Brief="Mixture enthalpy"); |
---|
[372] | 230 | Pratio as positive (Brief = "Pressure Ratio", Symbol ="P_{ratio}"); |
---|
| 231 | Pdrop as press_delta (Brief = "Pressure Drop", DisplayUnit = 'kPa', Symbol ="\Delta P"); |
---|
[321] | 232 | |
---|
| 233 | EQUATIONS |
---|
| 234 | |
---|
| 235 | "Chemical equilibrium" |
---|
| 236 | [vfrac,OutletL.z,OutletV.z]=PP.FlashPH(OutletL.P,h,Inlet.z); |
---|
| 237 | |
---|
| 238 | "Global Molar Balance" |
---|
| 239 | Inlet.F = OutletV.F + OutletL.F; |
---|
| 240 | OutletV.F = Inlet.F * vfrac; |
---|
| 241 | |
---|
| 242 | "Energy Balance" |
---|
| 243 | Inlet.F*(h - Inlet.h) = InletQ.Q; |
---|
| 244 | Inlet.F*h = Inlet.F*(1-vfrac)*OutletL.h + Inlet.F*vfrac*OutletV.h; |
---|
| 245 | |
---|
| 246 | "Thermal Equilibrium" |
---|
| 247 | OutletV.T = OutletL.T; |
---|
| 248 | |
---|
| 249 | "Mechanical Equilibrium" |
---|
| 250 | OutletV.P = OutletL.P; |
---|
[372] | 251 | |
---|
| 252 | "Pressure Drop" |
---|
| 253 | OutletL.P = Inlet.P - Pdrop; |
---|
| 254 | |
---|
| 255 | "Pressure Ratio" |
---|
| 256 | OutletL.P = Inlet.P * Pratio; |
---|
[321] | 257 | end |
---|
| 258 | |
---|
| 259 | #*---------------------------------------------------------------------- |
---|
| 260 | * Another model of a steady-state PH flash. |
---|
| 261 | * It is recommended to use [v,x,y]=PP.FlashPH(P,h,z) instead of. |
---|
| 262 | *---------------------------------------------------------------------*# |
---|
| 263 | Model FlashPHSteadyA |
---|
| 264 | ATTRIBUTES |
---|
| 265 | Pallete = true; |
---|
| 266 | Icon = "icon/Flash"; |
---|
| 267 | Brief = "Another model of a static PH flash."; |
---|
[353] | 268 | Info = |
---|
| 269 | "This model shows how to model a pressure enthalpy flash |
---|
| 270 | directly with the EMSO modeling language. |
---|
[321] | 271 | |
---|
[353] | 272 | This model is for demonstration purposes only, the flashPH |
---|
| 273 | routine available on VRTherm is much more robust. |
---|
[321] | 274 | |
---|
[353] | 275 | == Assumptions == |
---|
| 276 | * perfect mixing of both phases; |
---|
[321] | 277 | |
---|
[353] | 278 | == Specify == |
---|
| 279 | * the feed stream; |
---|
| 280 | * the heat duty; |
---|
| 281 | * the outlet pressure. |
---|
| 282 | "; |
---|
[321] | 283 | |
---|
| 284 | PARAMETERS |
---|
| 285 | outer PP as Plugin(Brief = "External Physical Properties", Type="PP"); |
---|
| 286 | outer NComp as Integer; |
---|
| 287 | B as Real(Default=1000, Brief="Regularization Factor"); |
---|
| 288 | |
---|
| 289 | VARIABLES |
---|
[352] | 290 | in Inlet as stream(Brief="Feed Stream", PosX=0, PosY=0.5421, Symbol="_{in}"); |
---|
| 291 | out OutletL as liquid_stream(Brief="Liquid outlet stream", PosX=0.4790, PosY=1, Symbol="_{outL}"); |
---|
| 292 | out OutletV as vapour_stream(Brief="Vapour outlet stream", PosX=0.4877, PosY=0, Symbol="_{outV}"); |
---|
| 293 | in InletQ as energy_stream (Brief="Rate of heat supply", PosX=1, PosY=0.7559, Symbol="_{in}"); |
---|
| 294 | vfrac as fraction(Brief="Vaporization fraction", Symbol="\phi"); |
---|
| 295 | vsat as Real(Lower=-0.1, Upper=1.1, Brief="Vaporization fraction if saturated", Symbol="\phi_{sat}"); |
---|
[321] | 296 | Tsat as temperature(Lower=173, Upper=1473, Brief="Temperature if saturated"); |
---|
| 297 | xsat(NComp) as Real(Lower=0, Upper=1, Brief="Liquid composition if saturated"); |
---|
| 298 | ysat(NComp) as Real(Lower=0, Upper=1, Brief="Vapour composition if saturated"); |
---|
[372] | 299 | Pratio as positive (Brief = "Pressure Ratio", Symbol ="P_{ratio}"); |
---|
| 300 | Pdrop as press_delta (Brief = "Pressure Drop", DisplayUnit = 'kPa', Symbol ="\Delta P"); |
---|
[321] | 301 | |
---|
| 302 | zero_one as fraction(Brief="Regularization Variable"); |
---|
| 303 | one_zero as fraction(Brief="Regularization Variable"); |
---|
| 304 | |
---|
| 305 | EQUATIONS |
---|
| 306 | "Chemical equilibrium" |
---|
| 307 | PP.LiquidFugacityCoefficient(Tsat, OutletL.P, xsat)*xsat = |
---|
| 308 | PP.VapourFugacityCoefficient(Tsat, OutletV.P, ysat)*ysat; |
---|
| 309 | |
---|
| 310 | "Global Molar Balance" |
---|
| 311 | Inlet.F = OutletV.F + OutletL.F; |
---|
| 312 | OutletV.F = Inlet.F * vfrac; |
---|
| 313 | |
---|
| 314 | "Component Molar Balance" |
---|
| 315 | Inlet.F*Inlet.z = OutletL.F*xsat + OutletV.F*ysat; |
---|
| 316 | sum(xsat) = sum(ysat); |
---|
| 317 | |
---|
| 318 | "Energy Balance if saturated" |
---|
| 319 | Inlet.F*Inlet.h + InletQ.Q = |
---|
| 320 | Inlet.F*(1-vsat)*PP.LiquidEnthalpy(Tsat, OutletL.P, xsat) + |
---|
| 321 | Inlet.F*vsat*PP.VapourEnthalpy(Tsat, OutletV.P, ysat); |
---|
| 322 | |
---|
| 323 | "Real Energy Balance" |
---|
| 324 | Inlet.F*Inlet.h + InletQ.Q = |
---|
| 325 | Inlet.F*(1-vfrac)*OutletL.h + Inlet.F*vfrac*OutletV.h; |
---|
| 326 | |
---|
| 327 | "Thermal Equilibrium" |
---|
| 328 | OutletV.T = OutletL.T; |
---|
| 329 | |
---|
| 330 | "Mechanical Equilibrium" |
---|
| 331 | OutletV.P = OutletL.P; |
---|
[372] | 332 | |
---|
| 333 | "Pressure Drop" |
---|
| 334 | OutletL.P = Inlet.P - Pdrop; |
---|
| 335 | |
---|
| 336 | "Pressure Ratio" |
---|
| 337 | OutletL.P = Inlet.P * Pratio; |
---|
| 338 | |
---|
[321] | 339 | # regularization functions |
---|
| 340 | zero_one = (1 + tanh(B * vsat))/2; |
---|
| 341 | one_zero = (1 - tanh(B * (vsat - 1)))/2; |
---|
| 342 | |
---|
| 343 | vfrac = zero_one * one_zero * vsat + 1 - one_zero; |
---|
| 344 | OutletL.z = zero_one*one_zero*xsat + (1-zero_one*one_zero)*Inlet.z; |
---|
| 345 | OutletV.z = zero_one*one_zero*ysat + (1-zero_one*one_zero)*Inlet.z; |
---|
| 346 | end |
---|