#*------------------------------------------------------------------- * EMSO Model Library (EML) Copyright (C) 2004 - 2007 ALSOC. * * This LIBRARY is free software; you can distribute it and/or modify * it under the therms of the ALSOC FREE LICENSE as available at * http://www.enq.ufrgs.br/alsoc. * * EMSO Copyright (C) 2004 - 2007 ALSOC, original code * from http://www.rps.eng.br Copyright (C) 2002-2004. * All rights reserved. * * EMSO is distributed under the therms of the ALSOC LICENSE as * available at http://www.enq.ufrgs.br/alsoc. * *--------------------------------------------------------------------- * Author: Estefane Horn, Núbia do Carmo Ferreira *$Id: valve.mso 920 2010-02-26 17:20:34Z rafael $ *-------------------------------------------------------------------*# using "streams"; #*------------------------------------------------------------------- * Model of a valve (simplified) *-------------------------------------------------------------------- * * Author: Paula B. Staudt *--------------------------------------------------------------------*# Model valve_simplified ATTRIBUTES Pallete = true; Icon = "icon/Valve"; Brief = "Model of a very simple valve - used in distillation column models."; Info = "== Assumptions == * no flashing liquid in the valve; * the flow in the valve is adiabatic; * dynamics in the valve are neglected; * linear flow type. == Specify == * the inlet stream * the plug position (x) OR outlet temperature (Outlet.T) OR outlet pressure (Outlet.P) OR * the inlet stream excluding its flow (Inlet.F) * the outlet pressure (Outlet.P) OR outlet flow (Outlet.F) * the plug position (x) "; PARAMETERS outer PP as Plugin(Type="PP"); outer NComp as Integer; VARIABLES in Inlet as stream (Brief = "Inlet stream", PosX=0, PosY=0.7365, Symbol="_{in}"); out Outlet as streamPH (Brief = "Outlet stream", PosX=1, PosY=0.7365, Symbol="_{out}"); x as fraction (Brief="Plug Position"); rho as dens_mass (Brief="Fluid Density", Default=1e3); v as vol_mol (Brief="Specific volume", Default=1e3); Pdrop as press_delta (Brief = "Pressure Drop", DisplayUnit = 'kPa', Symbol ="\Delta P"); Pratio as positive (Brief = "Pressure Ratio", Symbol ="P_{ratio}"); PARAMETERS rho_ref as dens_mass (Brief="Reference Density", Default=1e4); k as Real (Brief="Valve Constant", Unit='gal/min/psi^0.5'); EQUATIONS "Overall Molar Balance" Inlet.F = Outlet.F; "Componente Molar Balance" Inlet.z = Outlet.z; "Energy Balance" Inlet.h = Outlet.h; "Pressure Drop" Outlet.P = Inlet.P - Pdrop; "Pressure Ratio" Outlet.P = Inlet.P * Pratio; "Density" rho = Inlet.v*PP.VapourDensity((Inlet.T+Outlet.T)/2, (Inlet.P+Outlet.P)/2, Outlet.z) + (1-Inlet.v)*PP.LiquidDensity((Inlet.T+Outlet.T)/2, (Inlet.P+Outlet.P)/2, Outlet.z); "Volume" v = Inlet.v*PP.VapourVolume((Inlet.T+Outlet.T)/2, (Inlet.P+Outlet.P)/2, Outlet.z) + (1-Inlet.v)*PP.LiquidVolume((Inlet.T+Outlet.T)/2, (Inlet.P+Outlet.P)/2, Outlet.z); if Pdrop > 0 * 'atm' then "Flow" Outlet.F * v = k*x*sqrt(Pdrop * rho_ref / rho ) ; else "Closed" Outlet.F = 0 * 'kmol/h'; end end Model valve_flow ATTRIBUTES Pallete = true; Icon = "icon/Valve"; Brief = "Model of a very simple valve for setting the flow with a controller."; Info = "== ASSUMPTIONS == * nothing happens in this valve == SET == * MinFlow: the Minimum Flow Allowable in the valve; * MaxFlow: the Maximum Flow Allowable in the valve; == SPECIFY == * the Inlet stream * the FlowFraction (the model requires an inlet signal, also you can use a controller for setting the FlowFraction) "; PARAMETERS outer PP as Plugin (Brief = "External Physical Properties", Type="PP"); outer NComp as Integer (Brief="Number of Components"); MinFlow as flow_mol(Brief="Minimum Flow Allowable in the valve", Default=0); MaxFlow as flow_mol(Brief="Maximum Flow Allowable in the valve", Default=1000); VARIABLES in Inlet as stream (Brief ="Inlet stream", PosX=0, PosY=0.7365, Symbol="_{in}",Protected=true); out Outlet as stream (Brief ="Outlet stream", PosX=1, PosY=0.7365, Symbol="_{out}",Protected=true); in FlowFraction as control_signal (Brief ="Flow Signal", PosX=0.5, PosY=0,Protected=true); EQUATIONS "Overall Molar Balance" Outlet.F = Inlet.F; "Temperature" Outlet.T = Inlet.T; "Pressure" Outlet.P = Inlet.P; "Energy Balance" Outlet.h = Inlet.h; "Vapour fraction" Outlet.v = Inlet.v; "Componente Molar Balance" Outlet.z = Inlet.z; "Flow computation" Outlet.F = MinFlow + FlowFraction*(MaxFlow-MinFlow); end Model valve ATTRIBUTES Pallete = true; Icon = "icon/Valve"; Brief = "Model of a valve."; Info = "== Model of valves == * Linear; * Parabolic; * Equal; * Quick; * Hyperbolic. == Assumptions == * First Order Dynamic; * Only Liquid or Only Vapour; * Isentalpic. == Specify == * the valve type; * the Valve Coefficient (Cv); * the valve time constant (Tau). "; PARAMETERS outer PP as Plugin (Brief = "External Physical Properties", Type = "PP"); outer NComp as Integer (Brief = "Number of chemical components", Lower = 1); ValveType as Switcher (Valid = ["linear", "parabolic", "equal", "quick", "hyperbolic"], Default = "linear"); ValidPhases as Switcher (Brief = "Valid Phases for Flash Calculation", Valid = ["Vapour-Only", "Liquid-Only"], Default="Liquid-Only"); # Tau as time_sec (Brief="valve time constant"); rho60F as dens_mass (Brief = "Water Mass Density at 60 F",Hidden=true); VARIABLES W as flow_mass(DisplayUnit='kg/s'); Pdrop as press_delta (Brief = "Pressure Drop", DisplayUnit = 'kPa', Symbol ="\Delta P"); Fvol as flow_vol (Brief = "Volumetric Flow"); fc as positive (Brief = "Opening Function",Hidden=true); Cv as Real (Brief="Valve Flow Coefficient", Unit='gal/min/psi^0.5'); Cv1 as Real (Brief="Valve Flow Coefficient", Unit='m^2'); Cg as Real (Brief="Valve Gas Flow Coefficient", Unit='ft^3/h/psi'); C as Real (Brief="Liquid-gas Coefficient Ratio", Unit='(ft^3/gal)*(min/h)/(psi^.5)'); StemPosition as fraction (Brief = "Actual valve stem position"); a as Real; #b as Real (Brief="d", Unit='1/(psi^.5)'); vm as vol_mol (Brief = "Mixture Molar Volume"); rho as dens_mass (Brief = "Mixture Mass Density"); # vsp as fraction (Brief = "Valve stem position",Hidden=true); in Inlet as stream (Brief = "Inlet stream", PosX=0, PosY=0.7365, Symbol="_{in}"); out Outlet as streamPH (Brief = "Outlet stream", PosX=1, PosY=0.7365, Symbol="_{out}"); #in vsignal as fraction (Brief = "Flow Signal", PosX=0.5, PosY=0); SET rho60F = 984.252 * 'kg/m^3'; EQUATIONS #"First order valve dynamics" # Tau*diff(StemPosition) = vsp-StemPosition; #"Flow Signal" # vsp = vsignal; "Pressure Drop" Outlet.P = Inlet.P - Pdrop; "Enthalpy Balance" Outlet.h = Inlet.h; "Molar Balance" Outlet.F = Inlet.F; "Outlet Composition" Outlet.z = Inlet.z; Cv1=Cv*'1/(gal/min/psi^0.5)'*2.3837e-5*'m^2'; switch ValidPhases ############################################################# case "Liquid-Only": if Pdrop > 0 * 'atm' then "Valve Equation - Liquid Flow" Fvol = fc*(Cv/sqrt(1/rho60F))*sqrt(Pdrop/rho); "Liquid-gas Coefficient Ratio" C*Cv=Cg; a=1/(1.6764e-2*C*'1/((ft^3/gal)*(min/h)/(psi^.5))')*sqrt(Pdrop/Inlet.P); else "Valve Equation - Liquid Flow" Fvol = fc*(Cv/sqrt(1/rho60F))*sqrt(Pdrop/rho); "Liquid-gas Coefficient Ratio" C*Cv=Cg; a=1/(1.6764e-2*C*'1/((ft^3/gal)*(min/h)/(psi^.5))')*sqrt(Pdrop/Inlet.P); end "Liquid Mass Density" rho = PP.LiquidDensity(Inlet.T,Inlet.P,Inlet.z); "Liquid Molar Volume" vm = PP.LiquidVolume(Inlet.T,Inlet.P,Inlet.z); ############################################################ case "Vapour-Only": if Pdrop > 0 * 'atm' then #Update for gas flow !!!! "Liquid-gas Coefficient Ratio" C*Cv=Cg; a=1/(1.6764e-2*C*'1/((ft^3/gal)*(min/h)/(psi^.5))')*sqrt(Pdrop/Inlet.P); if 1.5708 > a then "Valve Equation - Vapour Flow" #Fvol = fc*Cg*sqrt(Inlet.P/1000*rho60F/rho);####rho60f/rho ok!!!! #Fvol = fc*Cv*sqrt(Pdrop/1000*rho60F/rho); #W = fc*Cv1*sqrt(Pdrop/1000*rho); Fvol = fc*0.13446*'psi^.5'*Cg*sqrt(Inlet.P/1000*rho60F/rho)*sin(a*'rad'); else "Valve Equation - Vapour Flow" Fvol = fc*0.13446*Cv*sqrt(Inlet.P*rho60F/rho); end else "Valve Equation - Vapour Flow" Fvol = fc*(Cv/sqrt(1/rho60F))*sqrt(Pdrop/rho); "Liquid-gas Coefficient Ratio" C*Cv=Cg; a=1/(1.6764e-2*C*'1/((ft^3/gal)*(min/h)/(psi^.5))')*sqrt(Pdrop/Inlet.P); end "Vapour Mass Density" rho = PP.VapourDensity(Inlet.T,Inlet.P,Inlet.z); #rho=3.708741*'kg/m^3'; "Vapour Molar Volume" vm = PP.VapourVolume(Inlet.T,Inlet.P,Inlet.z); end ###################################################### "Calculate Mass Flow" Fvol = Inlet.F*vm; W=Fvol*rho; switch ValveType #Update the valve Type case "linear": "Opening Equation" fc = StemPosition; case "parabolic": "Opening Equation" fc = StemPosition^2; case "equal": "Opening Equation" fc = StemPosition^2/(2-StemPosition^4)^(1/2); case "quick": "Opening Equation" fc = 10*StemPosition/sqrt(1+99*StemPosition^2); case "hyperbolic": "Opening Equation" fc = 0.1*StemPosition/sqrt(1-0.99*StemPosition^2); end end