[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 920 2010-02-26 17:20:34Z rafael $ |
---|
| 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 | |
---|
[909] | 92 | if Pdrop > 0 * 'atm' 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 |
---|
[808] | 102 | |
---|
| 103 | ATTRIBUTES |
---|
| 104 | Pallete = true; |
---|
| 105 | Icon = "icon/Valve"; |
---|
| 106 | Brief = "Model of a very simple valve for setting the flow with a controller."; |
---|
| 107 | Info = |
---|
| 108 | "== ASSUMPTIONS == |
---|
[567] | 109 | * nothing happens in this valve |
---|
[808] | 110 | |
---|
| 111 | == SET == |
---|
| 112 | * MinFlow: the Minimum Flow Allowable in the valve; |
---|
| 113 | * MaxFlow: the Maximum Flow Allowable in the valve; |
---|
| 114 | |
---|
| 115 | == SPECIFY == |
---|
| 116 | * the Inlet stream |
---|
| 117 | * the FlowFraction (the model requires an inlet signal, also you can use a controller for setting the FlowFraction) |
---|
[558] | 118 | "; |
---|
| 119 | |
---|
[808] | 120 | PARAMETERS |
---|
| 121 | outer PP as Plugin (Brief = "External Physical Properties", Type="PP"); |
---|
| 122 | outer NComp as Integer (Brief="Number of Components"); |
---|
[558] | 123 | |
---|
[808] | 124 | MinFlow as flow_mol(Brief="Minimum Flow Allowable in the valve", Default=0); |
---|
| 125 | MaxFlow as flow_mol(Brief="Maximum Flow Allowable in the valve", Default=1000); |
---|
[558] | 126 | |
---|
[808] | 127 | VARIABLES |
---|
| 128 | |
---|
| 129 | in Inlet as stream (Brief ="Inlet stream", PosX=0, PosY=0.7365, Symbol="_{in}",Protected=true); |
---|
| 130 | out Outlet as stream (Brief ="Outlet stream", PosX=1, PosY=0.7365, Symbol="_{out}",Protected=true); |
---|
[920] | 131 | in FlowFraction as control_signal (Brief ="Flow Signal", PosX=0.5, PosY=0,Protected=true); |
---|
[558] | 132 | |
---|
[808] | 133 | EQUATIONS |
---|
| 134 | "Overall Molar Balance" |
---|
[567] | 135 | Outlet.F = Inlet.F; |
---|
[808] | 136 | |
---|
| 137 | "Temperature" |
---|
[567] | 138 | Outlet.T = Inlet.T; |
---|
[808] | 139 | |
---|
| 140 | "Pressure" |
---|
[567] | 141 | Outlet.P = Inlet.P; |
---|
[808] | 142 | |
---|
| 143 | "Energy Balance" |
---|
[567] | 144 | Outlet.h = Inlet.h; |
---|
[808] | 145 | |
---|
| 146 | "Vapour fraction" |
---|
[567] | 147 | Outlet.v = Inlet.v; |
---|
[558] | 148 | |
---|
[808] | 149 | "Componente Molar Balance" |
---|
[567] | 150 | Outlet.z = Inlet.z; |
---|
[558] | 151 | |
---|
[808] | 152 | "Flow computation" |
---|
[558] | 153 | Outlet.F = MinFlow + FlowFraction*(MaxFlow-MinFlow); |
---|
[808] | 154 | |
---|
[558] | 155 | end |
---|
| 156 | |
---|
[587] | 157 | Model valve |
---|
| 158 | |
---|
[586] | 159 | ATTRIBUTES |
---|
| 160 | Pallete = true; |
---|
| 161 | Icon = "icon/Valve"; |
---|
[587] | 162 | Brief = "Model of a valve."; |
---|
| 163 | Info = |
---|
| 164 | "== Model of valves == |
---|
| 165 | * Linear; |
---|
| 166 | * Parabolic; |
---|
| 167 | * Equal; |
---|
| 168 | * Quick; |
---|
| 169 | * Hyperbolic. |
---|
| 170 | |
---|
| 171 | == Assumptions == |
---|
| 172 | * First Order Dynamic; |
---|
| 173 | * Only Liquid or Only Vapour; |
---|
| 174 | * Isentalpic. |
---|
| 175 | |
---|
| 176 | == Specify == |
---|
| 177 | * the valve type; |
---|
| 178 | * the Valve Coefficient (Cv); |
---|
| 179 | * the valve time constant (Tau). |
---|
| 180 | "; |
---|
[586] | 181 | |
---|
| 182 | PARAMETERS |
---|
[587] | 183 | |
---|
| 184 | outer PP as Plugin (Brief = "External Physical Properties", Type = "PP"); |
---|
[586] | 185 | outer NComp as Integer (Brief = "Number of chemical components", Lower = 1); |
---|
| 186 | |
---|
[587] | 187 | ValveType as Switcher (Valid = ["linear", "parabolic", "equal", "quick", "hyperbolic"], Default = "linear"); |
---|
| 188 | ValidPhases as Switcher (Brief = "Valid Phases for Flash Calculation", Valid = ["Vapour-Only", "Liquid-Only"], Default="Liquid-Only"); |
---|
[690] | 189 | # Tau as time_sec (Brief="valve time constant"); |
---|
[587] | 190 | rho60F as dens_mass (Brief = "Water Mass Density at 60 F",Hidden=true); |
---|
| 191 | |
---|
[586] | 192 | VARIABLES |
---|
[690] | 193 | W as flow_mass(DisplayUnit='kg/s'); |
---|
[587] | 194 | Pdrop as press_delta (Brief = "Pressure Drop", DisplayUnit = 'kPa', Symbol ="\Delta P"); |
---|
| 195 | Fvol as flow_vol (Brief = "Volumetric Flow"); |
---|
| 196 | fc as positive (Brief = "Opening Function",Hidden=true); |
---|
| 197 | Cv as Real (Brief="Valve Flow Coefficient", Unit='gal/min/psi^0.5'); |
---|
[690] | 198 | Cv1 as Real (Brief="Valve Flow Coefficient", Unit='m^2'); |
---|
| 199 | Cg as Real (Brief="Valve Gas Flow Coefficient", Unit='ft^3/h/psi'); |
---|
| 200 | C as Real (Brief="Liquid-gas Coefficient Ratio", Unit='(ft^3/gal)*(min/h)/(psi^.5)'); |
---|
[587] | 201 | StemPosition as fraction (Brief = "Actual valve stem position"); |
---|
[690] | 202 | a as Real; |
---|
| 203 | #b as Real (Brief="d", Unit='1/(psi^.5)'); |
---|
[587] | 204 | vm as vol_mol (Brief = "Mixture Molar Volume"); |
---|
| 205 | rho as dens_mass (Brief = "Mixture Mass Density"); |
---|
[690] | 206 | # vsp as fraction (Brief = "Valve stem position",Hidden=true); |
---|
[587] | 207 | |
---|
| 208 | in Inlet as stream (Brief = "Inlet stream", PosX=0, PosY=0.7365, Symbol="_{in}"); |
---|
| 209 | out Outlet as streamPH (Brief = "Outlet stream", PosX=1, PosY=0.7365, Symbol="_{out}"); |
---|
[690] | 210 | #in vsignal as fraction (Brief = "Flow Signal", PosX=0.5, PosY=0); |
---|
[587] | 211 | |
---|
[586] | 212 | SET |
---|
[587] | 213 | |
---|
| 214 | rho60F = 984.252 * 'kg/m^3'; |
---|
[586] | 215 | |
---|
| 216 | EQUATIONS |
---|
| 217 | |
---|
[690] | 218 | #"First order valve dynamics" |
---|
| 219 | # Tau*diff(StemPosition) = vsp-StemPosition; |
---|
[586] | 220 | |
---|
[690] | 221 | #"Flow Signal" |
---|
| 222 | # vsp = vsignal; |
---|
[586] | 223 | |
---|
| 224 | "Pressure Drop" |
---|
| 225 | Outlet.P = Inlet.P - Pdrop; |
---|
| 226 | |
---|
| 227 | "Enthalpy Balance" |
---|
| 228 | Outlet.h = Inlet.h; |
---|
| 229 | |
---|
| 230 | "Molar Balance" |
---|
| 231 | Outlet.F = Inlet.F; |
---|
| 232 | |
---|
| 233 | "Outlet Composition" |
---|
| 234 | Outlet.z = Inlet.z; |
---|
[690] | 235 | |
---|
| 236 | Cv1=Cv*'1/(gal/min/psi^0.5)'*2.3837e-5*'m^2'; |
---|
[586] | 237 | |
---|
[690] | 238 | switch ValidPhases |
---|
| 239 | |
---|
| 240 | ############################################################# |
---|
| 241 | |
---|
[587] | 242 | case "Liquid-Only": |
---|
| 243 | |
---|
[909] | 244 | if Pdrop > 0 * 'atm' then |
---|
[586] | 245 | |
---|
[587] | 246 | "Valve Equation - Liquid Flow" |
---|
| 247 | Fvol = fc*(Cv/sqrt(1/rho60F))*sqrt(Pdrop/rho); |
---|
[690] | 248 | "Liquid-gas Coefficient Ratio" |
---|
| 249 | C*Cv=Cg; |
---|
| 250 | a=1/(1.6764e-2*C*'1/((ft^3/gal)*(min/h)/(psi^.5))')*sqrt(Pdrop/Inlet.P); |
---|
[586] | 251 | else |
---|
| 252 | |
---|
[587] | 253 | "Valve Equation - Liquid Flow" |
---|
| 254 | Fvol = fc*(Cv/sqrt(1/rho60F))*sqrt(Pdrop/rho); |
---|
[690] | 255 | "Liquid-gas Coefficient Ratio" |
---|
| 256 | C*Cv=Cg; |
---|
| 257 | a=1/(1.6764e-2*C*'1/((ft^3/gal)*(min/h)/(psi^.5))')*sqrt(Pdrop/Inlet.P); |
---|
[586] | 258 | end |
---|
| 259 | |
---|
[587] | 260 | "Liquid Mass Density" |
---|
[586] | 261 | rho = PP.LiquidDensity(Inlet.T,Inlet.P,Inlet.z); |
---|
[587] | 262 | |
---|
| 263 | "Liquid Molar Volume" |
---|
| 264 | vm = PP.LiquidVolume(Inlet.T,Inlet.P,Inlet.z); |
---|
[690] | 265 | |
---|
[587] | 266 | |
---|
[690] | 267 | |
---|
| 268 | ############################################################ |
---|
| 269 | |
---|
[587] | 270 | case "Vapour-Only": |
---|
[586] | 271 | |
---|
[909] | 272 | if Pdrop > 0 * 'atm' then #Update for gas flow !!!! |
---|
[690] | 273 | |
---|
| 274 | "Liquid-gas Coefficient Ratio" |
---|
| 275 | C*Cv=Cg; |
---|
| 276 | a=1/(1.6764e-2*C*'1/((ft^3/gal)*(min/h)/(psi^.5))')*sqrt(Pdrop/Inlet.P); |
---|
[587] | 277 | |
---|
[690] | 278 | if 1.5708 > a then |
---|
| 279 | "Valve Equation - Vapour Flow" |
---|
| 280 | #Fvol = fc*Cg*sqrt(Inlet.P/1000*rho60F/rho);####rho60f/rho ok!!!! |
---|
| 281 | #Fvol = fc*Cv*sqrt(Pdrop/1000*rho60F/rho); |
---|
| 282 | #W = fc*Cv1*sqrt(Pdrop/1000*rho); |
---|
| 283 | Fvol = fc*0.13446*'psi^.5'*Cg*sqrt(Inlet.P/1000*rho60F/rho)*sin(a*'rad'); |
---|
| 284 | |
---|
| 285 | else |
---|
| 286 | "Valve Equation - Vapour Flow" |
---|
| 287 | Fvol = fc*0.13446*Cv*sqrt(Inlet.P*rho60F/rho); |
---|
| 288 | end |
---|
[587] | 289 | else |
---|
| 290 | |
---|
| 291 | "Valve Equation - Vapour Flow" |
---|
| 292 | Fvol = fc*(Cv/sqrt(1/rho60F))*sqrt(Pdrop/rho); |
---|
| 293 | |
---|
[690] | 294 | "Liquid-gas Coefficient Ratio" |
---|
| 295 | C*Cv=Cg; |
---|
| 296 | a=1/(1.6764e-2*C*'1/((ft^3/gal)*(min/h)/(psi^.5))')*sqrt(Pdrop/Inlet.P); |
---|
[587] | 297 | end |
---|
| 298 | |
---|
| 299 | "Vapour Mass Density" |
---|
| 300 | rho = PP.VapourDensity(Inlet.T,Inlet.P,Inlet.z); |
---|
[690] | 301 | #rho=3.708741*'kg/m^3'; |
---|
[587] | 302 | "Vapour Molar Volume" |
---|
| 303 | vm = PP.VapourVolume(Inlet.T,Inlet.P,Inlet.z); |
---|
| 304 | |
---|
| 305 | end |
---|
| 306 | |
---|
[690] | 307 | ###################################################### |
---|
| 308 | |
---|
[586] | 309 | "Calculate Mass Flow" |
---|
[690] | 310 | Fvol = Inlet.F*vm; |
---|
[586] | 311 | |
---|
[690] | 312 | W=Fvol*rho; |
---|
| 313 | |
---|
| 314 | |
---|
[587] | 315 | switch ValveType #Update the valve Type |
---|
[586] | 316 | |
---|
| 317 | case "linear": |
---|
| 318 | |
---|
| 319 | "Opening Equation" |
---|
[587] | 320 | fc = StemPosition; |
---|
[586] | 321 | |
---|
| 322 | case "parabolic": |
---|
| 323 | |
---|
| 324 | "Opening Equation" |
---|
[587] | 325 | fc = StemPosition^2; |
---|
[586] | 326 | |
---|
| 327 | case "equal": |
---|
| 328 | |
---|
| 329 | "Opening Equation" |
---|
[587] | 330 | fc = StemPosition^2/(2-StemPosition^4)^(1/2); |
---|
[586] | 331 | |
---|
| 332 | case "quick": |
---|
| 333 | |
---|
| 334 | "Opening Equation" |
---|
[587] | 335 | fc = 10*StemPosition/sqrt(1+99*StemPosition^2); |
---|
[586] | 336 | |
---|
| 337 | case "hyperbolic": |
---|
| 338 | |
---|
| 339 | "Opening Equation" |
---|
[587] | 340 | fc = 0.1*StemPosition/sqrt(1-0.99*StemPosition^2); |
---|
[586] | 341 | |
---|
| 342 | end |
---|
| 343 | |
---|
| 344 | end |
---|
| 345 | |
---|