#*------------------------------------------------------------------- * 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 587 2008-08-04 22:45:14Z bicca $ *-------------------------------------------------------------------*# 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 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 == Specify == * the inlet stream * the flow fraction "; PARAMETERS outer PP as Plugin(Type="PP"); outer NComp as Integer; MinFlow as flow_mol(Default=0); MaxFlow as flow_mol(Default=1000); VARIABLES in Inlet as stream (Brief = "Inlet stream", PosX=0, PosY=0.7365, Symbol="_{in}"); out Outlet as stream (Brief = "Outlet stream", PosX=1, PosY=0.7365, Symbol="_{out}"); in FlowFraction as fraction (Brief="Flow Signal", PosX=0.5, PosY=0); 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 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'); StemPosition as fraction (Brief = "Actual valve stem position"); 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; switch ValidPhases case "Liquid-Only": if Pdrop > 0 then "Valve Equation - Liquid Flow" Fvol = fc*(Cv/sqrt(1/rho60F))*sqrt(Pdrop/rho); else "Valve Equation - Liquid Flow" Fvol = fc*(Cv/sqrt(1/rho60F))*sqrt(Pdrop/rho); 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 then #Update for gas flow !!!! "Valve Equation - Vapour Flow" Fvol = fc*(Cv/sqrt(1/rho60F))*sqrt(Pdrop/rho); else "Valve Equation - Vapour Flow" Fvol = fc*(Cv/sqrt(1/rho60F))*sqrt(Pdrop/rho); end "Vapour Mass Density" rho = PP.VapourDensity(Inlet.T,Inlet.P,Inlet.z); "Vapour Molar Volume" vm = PP.VapourVolume(Inlet.T,Inlet.P,Inlet.z); end "Calculate Mass Flow" Fvol = Inlet.F*vm; 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