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