[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 334 2007-08-05 23:10:55Z 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 = |
---|
| 27 | "Assumptions: |
---|
| 28 | * both phases are perfectly mixed. |
---|
| 29 | |
---|
| 30 | Specify: |
---|
| 31 | * the feed stream; |
---|
| 32 | * the outlet flows: OutletV.F and OutletL.F. |
---|
| 33 | |
---|
| 34 | Initial Conditions: |
---|
| 35 | * the flash initial temperature (OutletL.T); |
---|
| 36 | * the flash initial level (Level); |
---|
| 37 | * (NoComps - 1) OutletL (OR OutletV) compositions. |
---|
| 38 | "; |
---|
| 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 |
---|
[325] | 52 | in Inlet as stream(Brief="Feed Stream", PosX=0, PosY=0.5421); |
---|
| 53 | out OutletL as liquid_stream(Brief="Liquid outlet stream", PosX=0.4790, PosY=1); |
---|
| 54 | out OutletV as vapour_stream(Brief="Vapour outlet stream", PosX=0.4877, PosY=0); |
---|
| 55 | in InletQ as energy_stream (Brief="Rate of heat supply", PosX=1, PosY=0.7559); |
---|
[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"); |
---|
[334] | 65 | vfrac as positive (Brief="Vapourization fraction"); |
---|
[235] | 66 | |
---|
[1] | 67 | EQUATIONS |
---|
| 68 | "Component Molar Balance" |
---|
| 69 | diff(M)=Inlet.F*Inlet.z - OutletL.F*OutletL.z - OutletV.F*OutletV.z; |
---|
| 70 | |
---|
| 71 | "Energy Balance" |
---|
[310] | 72 | diff(E) = Inlet.F*Inlet.h - OutletL.F*OutletL.h - OutletV.F*OutletV.h + InletQ.Q; |
---|
[1] | 73 | |
---|
| 74 | "Molar Holdup" |
---|
| 75 | M = ML*OutletL.z + MV*OutletV.z; |
---|
| 76 | |
---|
| 77 | "Energy Holdup" |
---|
| 78 | E = ML*OutletL.h + MV*OutletV.h - OutletL.P*V; |
---|
| 79 | |
---|
| 80 | "Mol fraction normalisation" |
---|
| 81 | sum(OutletL.z)=1.0; |
---|
[333] | 82 | |
---|
[1] | 83 | "Mol fraction normalisation" |
---|
| 84 | sum(OutletL.z)=sum(OutletV.z); |
---|
[333] | 85 | |
---|
| 86 | "Vaporization Fraction" |
---|
| 87 | OutletV.F = Inlet.F * vfrac; |
---|
| 88 | |
---|
[1] | 89 | "Liquid Volume" |
---|
| 90 | vL = PP.LiquidVolume(OutletL.T, OutletL.P, OutletL.z); |
---|
[333] | 91 | |
---|
[1] | 92 | "Vapour Volume" |
---|
| 93 | vV = PP.VapourVolume(OutletV.T, OutletV.P, OutletV.z); |
---|
| 94 | |
---|
| 95 | "Chemical Equilibrium" |
---|
| 96 | PP.LiquidFugacityCoefficient(OutletL.T, OutletL.P, OutletL.z)*OutletL.z = |
---|
| 97 | PP.VapourFugacityCoefficient(OutletV.T, OutletV.P, OutletV.z)*OutletV.z; |
---|
| 98 | |
---|
| 99 | "Thermal Equilibrium" |
---|
| 100 | OutletV.T = OutletL.T; |
---|
| 101 | |
---|
| 102 | "Mechanical Equilibrium" |
---|
| 103 | OutletV.P = OutletL.P; |
---|
| 104 | |
---|
| 105 | "Geometry Constraint" |
---|
[235] | 106 | V = ML * vL + MV * vV; |
---|
| 107 | |
---|
| 108 | switch orientation |
---|
| 109 | case "vertical": |
---|
| 110 | "Cross Section Area" |
---|
| 111 | Across = 0.5 * asin(1) * diameter^2; |
---|
| 112 | |
---|
[1] | 113 | "Liquid Level" |
---|
[235] | 114 | ML * vL = Across * Level; |
---|
| 115 | |
---|
| 116 | case "horizontal": |
---|
| 117 | "Cylindrical Side Area" |
---|
| 118 | Across = 0.25*diameter^2 * (asin(1) - asin((diameter - 2*Level)/diameter)) + |
---|
| 119 | (Level - 0.5*diameter)*sqrt(Level*(diameter - Level)); |
---|
| 120 | |
---|
| 121 | "Liquid Level" |
---|
| 122 | 0.5 * asin(1) * diameter^2 * ML* vL = Across * V; |
---|
| 123 | end |
---|
[1] | 124 | end |
---|
| 125 | |
---|
| 126 | #*---------------------------------------------------------------------- |
---|
| 127 | * Model of a Steady State flash |
---|
| 128 | *---------------------------------------------------------------------*# |
---|
[117] | 129 | Model flash_steady |
---|
[270] | 130 | ATTRIBUTES |
---|
| 131 | Pallete = true; |
---|
[300] | 132 | Icon = "icon/Flash"; |
---|
[270] | 133 | Brief = "Model of a Steady State flash."; |
---|
| 134 | Info = |
---|
| 135 | "Assumptions: |
---|
| 136 | * both phases are perfectly mixed. |
---|
| 137 | |
---|
| 138 | Specify: |
---|
| 139 | * the feed stream; |
---|
| 140 | * the outlet pressure (OutletV.P); |
---|
| 141 | * the outlet temperature OR the heat supplied. |
---|
| 142 | "; |
---|
| 143 | |
---|
[1] | 144 | PARAMETERS |
---|
[323] | 145 | outer PP as Plugin(Brief = "External Physical Properties", Type="PP"); |
---|
[1] | 146 | |
---|
| 147 | VARIABLES |
---|
[325] | 148 | in Inlet as stream(Brief="Feed Stream", PosX=0, PosY=0.5421); |
---|
| 149 | out OutletL as liquid_stream(Brief="Liquid outlet stream", PosX=0.4790, PosY=1); |
---|
| 150 | out OutletV as vapour_stream(Brief="Vapour outlet stream", PosX=0.4877, PosY=0); |
---|
| 151 | in InletQ as energy_stream (Brief="Rate of heat supply", PosX=1, PosY=0.7559); |
---|
[333] | 152 | vfrac as fraction (Brief="Vapourization fraction"); |
---|
[1] | 153 | |
---|
| 154 | EQUATIONS |
---|
| 155 | "The flash calculation" |
---|
| 156 | [vfrac, OutletL.z, OutletV.z] = PP.Flash(OutletV.T, OutletV.P, Inlet.z); |
---|
| 157 | |
---|
| 158 | "Global Molar Balance" |
---|
| 159 | Inlet.F = OutletV.F + OutletL.F; |
---|
[333] | 160 | |
---|
| 161 | "Vaporization Fraction" |
---|
[1] | 162 | OutletV.F = Inlet.F * vfrac; |
---|
[117] | 163 | |
---|
[1] | 164 | "Energy Balance" |
---|
[310] | 165 | Inlet.F*Inlet.h + InletQ.Q = OutletL.F*OutletL.h + OutletV.F*OutletV.h; |
---|
[1] | 166 | |
---|
| 167 | "Thermal Equilibrium" |
---|
| 168 | OutletV.T = OutletL.T; |
---|
| 169 | |
---|
| 170 | "Mechanical Equilibrium" |
---|
| 171 | OutletV.P = OutletL.P; |
---|
| 172 | end |
---|
[321] | 173 | |
---|
| 174 | #*---------------------------------------------------------------------- |
---|
| 175 | * Model of a steady-state PH flash. |
---|
| 176 | *---------------------------------------------------------------------*# |
---|
| 177 | Model FlashPHSteady |
---|
| 178 | ATTRIBUTES |
---|
| 179 | Pallete = true; |
---|
| 180 | Icon = "icon/Flash"; |
---|
| 181 | Brief = "Model of a static PH flash."; |
---|
| 182 | Info = " |
---|
| 183 | This model is for using the flashPH |
---|
| 184 | routine available on VRTherm. |
---|
| 185 | |
---|
| 186 | Assumptions: |
---|
| 187 | * perfect mixing of both phases; |
---|
| 188 | |
---|
| 189 | Specify: |
---|
| 190 | * the feed stream; |
---|
| 191 | * the heat duty; |
---|
| 192 | * the outlet pressure. |
---|
| 193 | "; |
---|
| 194 | |
---|
| 195 | PARAMETERS |
---|
| 196 | outer PP as Plugin(Brief = "External Physical Properties", Type="PP"); |
---|
| 197 | outer NComp as Integer; |
---|
| 198 | |
---|
| 199 | VARIABLES |
---|
[325] | 200 | in Inlet as stream(Brief="Feed Stream", PosX=0, PosY=0.5421); |
---|
| 201 | out OutletL as liquid_stream(Brief="Liquid outlet stream", PosX=0.4790, PosY=1); |
---|
| 202 | out OutletV as vapour_stream(Brief="Vapour outlet stream", PosX=0.4877, PosY=0); |
---|
| 203 | in InletQ as energy_stream (Brief="Rate of heat supply", PosX=1, PosY=0.7559); |
---|
[333] | 204 | vfrac as fraction(Brief="Vaporization fraction"); |
---|
[321] | 205 | h as enth_mol(Brief="Mixture enthalpy"); |
---|
| 206 | |
---|
| 207 | EQUATIONS |
---|
| 208 | |
---|
| 209 | "Chemical equilibrium" |
---|
| 210 | [vfrac,OutletL.z,OutletV.z]=PP.FlashPH(OutletL.P,h,Inlet.z); |
---|
| 211 | |
---|
| 212 | "Global Molar Balance" |
---|
| 213 | Inlet.F = OutletV.F + OutletL.F; |
---|
| 214 | OutletV.F = Inlet.F * vfrac; |
---|
| 215 | |
---|
| 216 | "Energy Balance" |
---|
| 217 | Inlet.F*(h - Inlet.h) = InletQ.Q; |
---|
| 218 | Inlet.F*h = Inlet.F*(1-vfrac)*OutletL.h + Inlet.F*vfrac*OutletV.h; |
---|
| 219 | |
---|
| 220 | "Thermal Equilibrium" |
---|
| 221 | OutletV.T = OutletL.T; |
---|
| 222 | |
---|
| 223 | "Mechanical Equilibrium" |
---|
| 224 | OutletV.P = OutletL.P; |
---|
| 225 | end |
---|
| 226 | |
---|
| 227 | #*---------------------------------------------------------------------- |
---|
| 228 | * Another model of a steady-state PH flash. |
---|
| 229 | * It is recommended to use [v,x,y]=PP.FlashPH(P,h,z) instead of. |
---|
| 230 | *---------------------------------------------------------------------*# |
---|
| 231 | Model FlashPHSteadyA |
---|
| 232 | ATTRIBUTES |
---|
| 233 | Pallete = true; |
---|
| 234 | Icon = "icon/Flash"; |
---|
| 235 | Brief = "Another model of a static PH flash."; |
---|
| 236 | Info = " |
---|
| 237 | This model shows how to model a pressure enthalpy flash |
---|
| 238 | directly with the EMSO modeling language. |
---|
| 239 | |
---|
| 240 | This model is for demonstration purposes only, the flashPH |
---|
| 241 | routine available on VRTherm is much more robust. |
---|
| 242 | |
---|
| 243 | Assumptions: |
---|
| 244 | * perfect mixing of both phases; |
---|
| 245 | |
---|
| 246 | Specify: |
---|
| 247 | * the feed stream; |
---|
| 248 | * the heat duty; |
---|
| 249 | * the outlet pressure. |
---|
| 250 | "; |
---|
| 251 | |
---|
| 252 | PARAMETERS |
---|
| 253 | outer PP as Plugin(Brief = "External Physical Properties", Type="PP"); |
---|
| 254 | outer NComp as Integer; |
---|
| 255 | B as Real(Default=1000, Brief="Regularization Factor"); |
---|
| 256 | |
---|
| 257 | VARIABLES |
---|
[325] | 258 | in Inlet as stream(Brief="Feed Stream", PosX=0, PosY=0.5421); |
---|
| 259 | out OutletL as liquid_stream(Brief="Liquid outlet stream", PosX=0.4790, PosY=1); |
---|
| 260 | out OutletV as vapour_stream(Brief="Vapour outlet stream", PosX=0.4877, PosY=0); |
---|
| 261 | in InletQ as energy_stream (Brief="Rate of heat supply", PosX=1, PosY=0.7559); |
---|
[333] | 262 | vfrac as fraction(Brief="Vaporization fraction"); |
---|
[321] | 263 | vsat as Real(Lower=-0.1, Upper=1.1, Brief="Vaporization fraction if saturated"); |
---|
| 264 | Tsat as temperature(Lower=173, Upper=1473, Brief="Temperature if saturated"); |
---|
| 265 | xsat(NComp) as Real(Lower=0, Upper=1, Brief="Liquid composition if saturated"); |
---|
| 266 | ysat(NComp) as Real(Lower=0, Upper=1, Brief="Vapour composition if saturated"); |
---|
| 267 | |
---|
| 268 | zero_one as fraction(Brief="Regularization Variable"); |
---|
| 269 | one_zero as fraction(Brief="Regularization Variable"); |
---|
| 270 | |
---|
| 271 | EQUATIONS |
---|
| 272 | "Chemical equilibrium" |
---|
| 273 | PP.LiquidFugacityCoefficient(Tsat, OutletL.P, xsat)*xsat = |
---|
| 274 | PP.VapourFugacityCoefficient(Tsat, OutletV.P, ysat)*ysat; |
---|
| 275 | |
---|
| 276 | "Global Molar Balance" |
---|
| 277 | Inlet.F = OutletV.F + OutletL.F; |
---|
| 278 | OutletV.F = Inlet.F * vfrac; |
---|
| 279 | |
---|
| 280 | "Component Molar Balance" |
---|
| 281 | Inlet.F*Inlet.z = OutletL.F*xsat + OutletV.F*ysat; |
---|
| 282 | sum(xsat) = sum(ysat); |
---|
| 283 | |
---|
| 284 | "Energy Balance if saturated" |
---|
| 285 | Inlet.F*Inlet.h + InletQ.Q = |
---|
| 286 | Inlet.F*(1-vsat)*PP.LiquidEnthalpy(Tsat, OutletL.P, xsat) + |
---|
| 287 | Inlet.F*vsat*PP.VapourEnthalpy(Tsat, OutletV.P, ysat); |
---|
| 288 | |
---|
| 289 | "Real Energy Balance" |
---|
| 290 | Inlet.F*Inlet.h + InletQ.Q = |
---|
| 291 | Inlet.F*(1-vfrac)*OutletL.h + Inlet.F*vfrac*OutletV.h; |
---|
| 292 | |
---|
| 293 | "Thermal Equilibrium" |
---|
| 294 | OutletV.T = OutletL.T; |
---|
| 295 | |
---|
| 296 | "Mechanical Equilibrium" |
---|
| 297 | OutletV.P = OutletL.P; |
---|
| 298 | |
---|
| 299 | # regularization functions |
---|
| 300 | zero_one = (1 + tanh(B * vsat))/2; |
---|
| 301 | one_zero = (1 - tanh(B * (vsat - 1)))/2; |
---|
| 302 | |
---|
| 303 | vfrac = zero_one * one_zero * vsat + 1 - one_zero; |
---|
| 304 | OutletL.z = zero_one*one_zero*xsat + (1-zero_one*one_zero)*Inlet.z; |
---|
| 305 | OutletV.z = zero_one*one_zero*ysat + (1-zero_one*one_zero)*Inlet.z; |
---|
| 306 | end |
---|