[690] | 1 | #*------------------------------------------------------------------- |
---|
[75] | 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. |
---|
| 14 | * |
---|
| 15 | *--------------------------------------------------------------------- |
---|
[98] | 16 | * Author: Estefane Horn, Núbia do Carmo Ferreira |
---|
[75] | 17 | *$Id: valve.mso 690 2008-11-21 17:02:51Z jjunges $ |
---|
| 18 | *-------------------------------------------------------------------*# |
---|
[57] | 19 | |
---|
[325] | 20 | using "streams"; |
---|
[57] | 21 | |
---|
[1] | 22 | #*------------------------------------------------------------------- |
---|
[75] | 23 | * Model of a valve (simplified) |
---|
[1] | 24 | *-------------------------------------------------------------------- |
---|
| 25 | * |
---|
| 26 | * Author: Paula B. Staudt |
---|
| 27 | *--------------------------------------------------------------------*# |
---|
[204] | 28 | Model valve_simplified |
---|
[277] | 29 | ATTRIBUTES |
---|
| 30 | Pallete = true; |
---|
[305] | 31 | Icon = "icon/Valve"; |
---|
[277] | 32 | Brief = "Model of a very simple valve - used in distillation column models."; |
---|
| 33 | Info = |
---|
[353] | 34 | "== Assumptions == |
---|
| 35 | * no flashing liquid in the valve; |
---|
| 36 | * the flow in the valve is adiabatic; |
---|
| 37 | * dynamics in the valve are neglected; |
---|
| 38 | * linear flow type. |
---|
[277] | 39 | |
---|
[353] | 40 | == Specify == |
---|
| 41 | * the inlet stream |
---|
| 42 | * the plug position (x) OR outlet temperature (Outlet.T) OR outlet pressure (Outlet.P) |
---|
[277] | 43 | |
---|
| 44 | OR |
---|
| 45 | |
---|
[353] | 46 | * the inlet stream excluding its flow (Inlet.F) |
---|
| 47 | * the outlet pressure (Outlet.P) OR outlet flow (Outlet.F) |
---|
| 48 | * the plug position (x) |
---|
| 49 | "; |
---|
[204] | 50 | |
---|
[1] | 51 | PARAMETERS |
---|
[270] | 52 | outer PP as Plugin(Type="PP"); |
---|
[176] | 53 | outer NComp as Integer; |
---|
[1] | 54 | |
---|
| 55 | VARIABLES |
---|
[351] | 56 | in Inlet as stream (Brief = "Inlet stream", PosX=0, PosY=0.7365, Symbol="_{in}"); |
---|
| 57 | out Outlet as streamPH (Brief = "Outlet stream", PosX=1, PosY=0.7365, Symbol="_{out}"); |
---|
[1] | 58 | x as fraction (Brief="Plug Position"); |
---|
| 59 | rho as dens_mass (Brief="Fluid Density", Default=1e3); |
---|
[37] | 60 | v as vol_mol (Brief="Specific volume", Default=1e3); |
---|
[372] | 61 | Pdrop as press_delta (Brief = "Pressure Drop", DisplayUnit = 'kPa', Symbol ="\Delta P"); |
---|
| 62 | Pratio as positive (Brief = "Pressure Ratio", Symbol ="P_{ratio}"); |
---|
[1] | 63 | |
---|
| 64 | PARAMETERS |
---|
| 65 | rho_ref as dens_mass (Brief="Reference Density", Default=1e4); |
---|
[176] | 66 | k as Real (Brief="Valve Constant", Unit='gal/min/psi^0.5'); |
---|
[1] | 67 | |
---|
| 68 | EQUATIONS |
---|
[372] | 69 | "Overall Molar Balance" |
---|
[1] | 70 | Inlet.F = Outlet.F; |
---|
[372] | 71 | |
---|
| 72 | "Componente Molar Balance" |
---|
[1] | 73 | Inlet.z = Outlet.z; |
---|
| 74 | |
---|
| 75 | "Energy Balance" |
---|
| 76 | Inlet.h = Outlet.h; |
---|
| 77 | |
---|
[372] | 78 | "Pressure Drop" |
---|
| 79 | Outlet.P = Inlet.P - Pdrop; |
---|
| 80 | |
---|
| 81 | "Pressure Ratio" |
---|
| 82 | Outlet.P = Inlet.P * Pratio; |
---|
| 83 | |
---|
[1] | 84 | "Density" |
---|
| 85 | rho = Inlet.v*PP.VapourDensity((Inlet.T+Outlet.T)/2, (Inlet.P+Outlet.P)/2, Outlet.z) + |
---|
| 86 | (1-Inlet.v)*PP.LiquidDensity((Inlet.T+Outlet.T)/2, (Inlet.P+Outlet.P)/2, Outlet.z); |
---|
| 87 | |
---|
[37] | 88 | "Volume" |
---|
| 89 | v = Inlet.v*PP.VapourVolume((Inlet.T+Outlet.T)/2, (Inlet.P+Outlet.P)/2, Outlet.z) + |
---|
| 90 | (1-Inlet.v)*PP.LiquidVolume((Inlet.T+Outlet.T)/2, (Inlet.P+Outlet.P)/2, Outlet.z); |
---|
| 91 | |
---|
[372] | 92 | if Pdrop > 0 then |
---|
[109] | 93 | "Flow" |
---|
[372] | 94 | Outlet.F * v = k*x*sqrt(Pdrop * rho_ref / rho ) ; |
---|
[109] | 95 | else |
---|
| 96 | "Closed" |
---|
[176] | 97 | Outlet.F = 0 * 'kmol/h'; |
---|
[109] | 98 | end |
---|
[1] | 99 | end |
---|
[558] | 100 | |
---|
| 101 | Model valve_flow |
---|
| 102 | ATTRIBUTES |
---|
| 103 | Pallete = true; |
---|
| 104 | Icon = "icon/Valve"; |
---|
[567] | 105 | Brief = "Model of a very simple valve for setting the flow with a controller."; |
---|
[558] | 106 | Info = |
---|
| 107 | "== Assumptions == |
---|
[567] | 108 | * nothing happens in this valve |
---|
[558] | 109 | |
---|
| 110 | == Specify == |
---|
| 111 | * the inlet stream |
---|
[567] | 112 | * the flow fraction |
---|
[558] | 113 | "; |
---|
| 114 | |
---|
| 115 | PARAMETERS |
---|
| 116 | outer PP as Plugin(Type="PP"); |
---|
| 117 | outer NComp as Integer; |
---|
| 118 | |
---|
| 119 | MinFlow as flow_mol(Default=0); |
---|
| 120 | MaxFlow as flow_mol(Default=1000); |
---|
| 121 | |
---|
| 122 | VARIABLES |
---|
| 123 | in Inlet as stream (Brief = "Inlet stream", PosX=0, PosY=0.7365, Symbol="_{in}"); |
---|
[567] | 124 | out Outlet as stream (Brief = "Outlet stream", PosX=1, PosY=0.7365, Symbol="_{out}"); |
---|
[558] | 125 | in FlowFraction as fraction (Brief="Flow Signal", PosX=0.5, PosY=0); |
---|
| 126 | |
---|
| 127 | EQUATIONS |
---|
| 128 | "Overall Molar Balance" |
---|
[567] | 129 | Outlet.F = Inlet.F; |
---|
| 130 | "Temperature" |
---|
| 131 | Outlet.T = Inlet.T; |
---|
| 132 | "Pressure" |
---|
| 133 | Outlet.P = Inlet.P; |
---|
[558] | 134 | "Energy Balance" |
---|
[567] | 135 | Outlet.h = Inlet.h; |
---|
| 136 | "Vapour fraction" |
---|
| 137 | Outlet.v = Inlet.v; |
---|
[558] | 138 | |
---|
[567] | 139 | "Componente Molar Balance" |
---|
| 140 | Outlet.z = Inlet.z; |
---|
[558] | 141 | |
---|
[567] | 142 | "Flow computation" |
---|
[558] | 143 | Outlet.F = MinFlow + FlowFraction*(MaxFlow-MinFlow); |
---|
| 144 | end |
---|
| 145 | |
---|
[587] | 146 | Model valve |
---|
| 147 | |
---|
[586] | 148 | ATTRIBUTES |
---|
| 149 | Pallete = true; |
---|
| 150 | Icon = "icon/Valve"; |
---|
[587] | 151 | Brief = "Model of a valve."; |
---|
| 152 | Info = |
---|
| 153 | "== Model of valves == |
---|
| 154 | * Linear; |
---|
| 155 | * Parabolic; |
---|
| 156 | * Equal; |
---|
| 157 | * Quick; |
---|
| 158 | * Hyperbolic. |
---|
| 159 | |
---|
| 160 | == Assumptions == |
---|
| 161 | * First Order Dynamic; |
---|
| 162 | * Only Liquid or Only Vapour; |
---|
| 163 | * Isentalpic. |
---|
| 164 | |
---|
| 165 | == Specify == |
---|
| 166 | * the valve type; |
---|
| 167 | * the Valve Coefficient (Cv); |
---|
| 168 | * the valve time constant (Tau). |
---|
| 169 | "; |
---|
[586] | 170 | |
---|
| 171 | PARAMETERS |
---|
[587] | 172 | |
---|
| 173 | outer PP as Plugin (Brief = "External Physical Properties", Type = "PP"); |
---|
[586] | 174 | outer NComp as Integer (Brief = "Number of chemical components", Lower = 1); |
---|
| 175 | |
---|
[587] | 176 | ValveType as Switcher (Valid = ["linear", "parabolic", "equal", "quick", "hyperbolic"], Default = "linear"); |
---|
| 177 | ValidPhases as Switcher (Brief = "Valid Phases for Flash Calculation", Valid = ["Vapour-Only", "Liquid-Only"], Default="Liquid-Only"); |
---|
[690] | 178 | # Tau as time_sec (Brief="valve time constant"); |
---|
[587] | 179 | rho60F as dens_mass (Brief = "Water Mass Density at 60 F",Hidden=true); |
---|
| 180 | |
---|
[586] | 181 | VARIABLES |
---|
[690] | 182 | W as flow_mass(DisplayUnit='kg/s'); |
---|
[587] | 183 | Pdrop as press_delta (Brief = "Pressure Drop", DisplayUnit = 'kPa', Symbol ="\Delta P"); |
---|
| 184 | Fvol as flow_vol (Brief = "Volumetric Flow"); |
---|
| 185 | fc as positive (Brief = "Opening Function",Hidden=true); |
---|
| 186 | Cv as Real (Brief="Valve Flow Coefficient", Unit='gal/min/psi^0.5'); |
---|
[690] | 187 | Cv1 as Real (Brief="Valve Flow Coefficient", Unit='m^2'); |
---|
| 188 | Cg as Real (Brief="Valve Gas Flow Coefficient", Unit='ft^3/h/psi'); |
---|
| 189 | C as Real (Brief="Liquid-gas Coefficient Ratio", Unit='(ft^3/gal)*(min/h)/(psi^.5)'); |
---|
[587] | 190 | StemPosition as fraction (Brief = "Actual valve stem position"); |
---|
[690] | 191 | a as Real; |
---|
| 192 | #b as Real (Brief="d", Unit='1/(psi^.5)'); |
---|
[587] | 193 | vm as vol_mol (Brief = "Mixture Molar Volume"); |
---|
| 194 | rho as dens_mass (Brief = "Mixture Mass Density"); |
---|
[690] | 195 | # vsp as fraction (Brief = "Valve stem position",Hidden=true); |
---|
[587] | 196 | |
---|
| 197 | in Inlet as stream (Brief = "Inlet stream", PosX=0, PosY=0.7365, Symbol="_{in}"); |
---|
| 198 | out Outlet as streamPH (Brief = "Outlet stream", PosX=1, PosY=0.7365, Symbol="_{out}"); |
---|
[690] | 199 | #in vsignal as fraction (Brief = "Flow Signal", PosX=0.5, PosY=0); |
---|
[587] | 200 | |
---|
[586] | 201 | SET |
---|
[587] | 202 | |
---|
| 203 | rho60F = 984.252 * 'kg/m^3'; |
---|
[586] | 204 | |
---|
| 205 | EQUATIONS |
---|
| 206 | |
---|
[690] | 207 | #"First order valve dynamics" |
---|
| 208 | # Tau*diff(StemPosition) = vsp-StemPosition; |
---|
[586] | 209 | |
---|
[690] | 210 | #"Flow Signal" |
---|
| 211 | # vsp = vsignal; |
---|
[586] | 212 | |
---|
| 213 | "Pressure Drop" |
---|
| 214 | Outlet.P = Inlet.P - Pdrop; |
---|
| 215 | |
---|
| 216 | "Enthalpy Balance" |
---|
| 217 | Outlet.h = Inlet.h; |
---|
| 218 | |
---|
| 219 | "Molar Balance" |
---|
| 220 | Outlet.F = Inlet.F; |
---|
| 221 | |
---|
| 222 | "Outlet Composition" |
---|
| 223 | Outlet.z = Inlet.z; |
---|
[690] | 224 | |
---|
| 225 | Cv1=Cv*'1/(gal/min/psi^0.5)'*2.3837e-5*'m^2'; |
---|
[586] | 226 | |
---|
[690] | 227 | switch ValidPhases |
---|
| 228 | |
---|
| 229 | ############################################################# |
---|
| 230 | |
---|
[587] | 231 | case "Liquid-Only": |
---|
| 232 | |
---|
| 233 | if Pdrop > 0 then |
---|
[586] | 234 | |
---|
[587] | 235 | "Valve Equation - Liquid Flow" |
---|
| 236 | Fvol = fc*(Cv/sqrt(1/rho60F))*sqrt(Pdrop/rho); |
---|
[690] | 237 | "Liquid-gas Coefficient Ratio" |
---|
| 238 | C*Cv=Cg; |
---|
| 239 | a=1/(1.6764e-2*C*'1/((ft^3/gal)*(min/h)/(psi^.5))')*sqrt(Pdrop/Inlet.P); |
---|
[586] | 240 | else |
---|
| 241 | |
---|
[587] | 242 | "Valve Equation - Liquid Flow" |
---|
| 243 | Fvol = fc*(Cv/sqrt(1/rho60F))*sqrt(Pdrop/rho); |
---|
[690] | 244 | "Liquid-gas Coefficient Ratio" |
---|
| 245 | C*Cv=Cg; |
---|
| 246 | a=1/(1.6764e-2*C*'1/((ft^3/gal)*(min/h)/(psi^.5))')*sqrt(Pdrop/Inlet.P); |
---|
[586] | 247 | end |
---|
| 248 | |
---|
[587] | 249 | "Liquid Mass Density" |
---|
[586] | 250 | rho = PP.LiquidDensity(Inlet.T,Inlet.P,Inlet.z); |
---|
[587] | 251 | |
---|
| 252 | "Liquid Molar Volume" |
---|
| 253 | vm = PP.LiquidVolume(Inlet.T,Inlet.P,Inlet.z); |
---|
[690] | 254 | |
---|
[587] | 255 | |
---|
[690] | 256 | |
---|
| 257 | ############################################################ |
---|
| 258 | |
---|
[587] | 259 | case "Vapour-Only": |
---|
[586] | 260 | |
---|
[587] | 261 | if Pdrop > 0 then #Update for gas flow !!!! |
---|
[690] | 262 | |
---|
| 263 | "Liquid-gas Coefficient Ratio" |
---|
| 264 | C*Cv=Cg; |
---|
| 265 | a=1/(1.6764e-2*C*'1/((ft^3/gal)*(min/h)/(psi^.5))')*sqrt(Pdrop/Inlet.P); |
---|
[587] | 266 | |
---|
[690] | 267 | if 1.5708 > a then |
---|
| 268 | "Valve Equation - Vapour Flow" |
---|
| 269 | #Fvol = fc*Cg*sqrt(Inlet.P/1000*rho60F/rho);####rho60f/rho ok!!!! |
---|
| 270 | #Fvol = fc*Cv*sqrt(Pdrop/1000*rho60F/rho); |
---|
| 271 | #W = fc*Cv1*sqrt(Pdrop/1000*rho); |
---|
| 272 | Fvol = fc*0.13446*'psi^.5'*Cg*sqrt(Inlet.P/1000*rho60F/rho)*sin(a*'rad'); |
---|
| 273 | |
---|
| 274 | else |
---|
| 275 | "Valve Equation - Vapour Flow" |
---|
| 276 | Fvol = fc*0.13446*Cv*sqrt(Inlet.P*rho60F/rho); |
---|
| 277 | end |
---|
[587] | 278 | else |
---|
| 279 | |
---|
| 280 | "Valve Equation - Vapour Flow" |
---|
| 281 | Fvol = fc*(Cv/sqrt(1/rho60F))*sqrt(Pdrop/rho); |
---|
| 282 | |
---|
[690] | 283 | "Liquid-gas Coefficient Ratio" |
---|
| 284 | C*Cv=Cg; |
---|
| 285 | a=1/(1.6764e-2*C*'1/((ft^3/gal)*(min/h)/(psi^.5))')*sqrt(Pdrop/Inlet.P); |
---|
[587] | 286 | end |
---|
| 287 | |
---|
| 288 | "Vapour Mass Density" |
---|
| 289 | rho = PP.VapourDensity(Inlet.T,Inlet.P,Inlet.z); |
---|
[690] | 290 | #rho=3.708741*'kg/m^3'; |
---|
[587] | 291 | "Vapour Molar Volume" |
---|
| 292 | vm = PP.VapourVolume(Inlet.T,Inlet.P,Inlet.z); |
---|
| 293 | |
---|
| 294 | end |
---|
| 295 | |
---|
[690] | 296 | ###################################################### |
---|
| 297 | |
---|
[586] | 298 | "Calculate Mass Flow" |
---|
[690] | 299 | Fvol = Inlet.F*vm; |
---|
[586] | 300 | |
---|
[690] | 301 | W=Fvol*rho; |
---|
| 302 | |
---|
| 303 | |
---|
[587] | 304 | switch ValveType #Update the valve Type |
---|
[586] | 305 | |
---|
| 306 | case "linear": |
---|
| 307 | |
---|
| 308 | "Opening Equation" |
---|
[587] | 309 | fc = StemPosition; |
---|
[586] | 310 | |
---|
| 311 | case "parabolic": |
---|
| 312 | |
---|
| 313 | "Opening Equation" |
---|
[587] | 314 | fc = StemPosition^2; |
---|
[586] | 315 | |
---|
| 316 | case "equal": |
---|
| 317 | |
---|
| 318 | "Opening Equation" |
---|
[587] | 319 | fc = StemPosition^2/(2-StemPosition^4)^(1/2); |
---|
[586] | 320 | |
---|
| 321 | case "quick": |
---|
| 322 | |
---|
| 323 | "Opening Equation" |
---|
[587] | 324 | fc = 10*StemPosition/sqrt(1+99*StemPosition^2); |
---|
[586] | 325 | |
---|
| 326 | case "hyperbolic": |
---|
| 327 | |
---|
| 328 | "Opening Equation" |
---|
[587] | 329 | fc = 0.1*StemPosition/sqrt(1-0.99*StemPosition^2); |
---|
[586] | 330 | |
---|
| 331 | end |
---|
| 332 | |
---|
| 333 | end |
---|
| 334 | |
---|