#*------------------------------------------------------------------- * 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: Paula B. Staudt * $Id: flash.mso 918 2010-02-25 16:45:10Z rafael $ *--------------------------------------------------------------------*# using "tank"; Model flash as VesselVolume ATTRIBUTES Pallete = true; Icon = "icon/Flash"; Brief = "Model of a Dynamic Flash Vessel."; Info = "== ASSUMPTIONS == * perfect mixing of both phases; * thermodynamics equilibrium. == SET == *Orientation: vessel position - vertical or horizontal; *Heads (bottom and top heads are identical) **elliptical: 2:1 elliptical heads (25% of vessel diameter); **hemispherical: hemispherical heads (50% of vessel diameter); **flat: flat heads (0% of vessel diameter); *Diameter: Vessel diameter; *Lenght: Side length of the cylinder shell; == SPECIFY == * the Inlet stream; * the outlet flows: OutletVapour.F and OutletLiquid.F; * the InletQ (the model requires an energy stream, also you can use a controller for setting the heat duty using the heat_flow model). == OPTIONAL == * the Flash model has three control ports ** TI OutletLiquid Temperature Indicator; ** PI OutletLiquid Pressure Indicator; ** LI Level Indicator; == INITIAL CONDITIONS == * Initial_Temperature : the Flash temperature (OutletLiquid.T); * Initial_Level : the Flash liquid level (Level); * Initial_Composition : (NoComps) OutletLiquid compositions. "; PARAMETERS outer PP as Plugin (Brief = "External Physical Properties", Type="PP"); outer NComp as Integer (Brief = "Number of components", Lower = 1); Mw(NComp) as molweight (Brief="Mol Weight", Hidden=true); Levelpercent_Initial as positive (Brief="Initial liquid height in Percent", Default = 0.70); Temperature_Initial as temperature (Brief="Initial Liquid Temperature", Default = 330); Composition_Initial(NComp) as fraction (Brief="Initial Composition", Default = 0.10); SET Mw=PP.MolecularWeight(); VARIABLES in Inlet as stream (Brief="Feed Stream", PosX=0, PosY=0.48, Symbol="_{in}"); out OutletLiquid as liquid_stream (Brief="Liquid outlet stream", PosX=0.43, PosY=1, Symbol="_{out}^{Liquid}"); out OutletVapour as vapour_stream (Brief="Vapour outlet stream", PosX=0.43, PosY=0, Symbol="_{out}^{Vapour}"); in InletQ as power (Brief="Heat Duty", PosX=1, PosY=0.81, Protected =true,Symbol="Q_{in}"); TotalHoldup(NComp) as mol (Brief="Molar Holdup in the Vessel", Protected=true); LiquidHoldup as mol (Brief="Molar liquid holdup", Protected=true); VapourHoldup as mol (Brief="Molar vapour holdup", Protected=true); E as energy (Brief="Total Energy Holdup in the Vessel", Protected=true); vL as volume_mol (Brief="Liquid Molar Volume", Protected=true); vV as volume_mol (Brief="Vapour Molar volume", Protected=true); vfrac as positive (Brief="Vapourization fraction", Symbol="\phi", Protected=true); Pratio as positive (Brief = "Pressure Ratio", Symbol ="P_{ratio}", Protected=true); Pdrop as press_delta (Brief = "Pressure Drop", DisplayUnit = 'kPa', Symbol ="\Delta P", Protected=true); Peq as pressure (Brief="Equilibrium pressure on the liquid surface", Protected=true, Symbol="\Delta P_{eq}"); Pstatic as pressure (Brief="Static head at the bottom of the tank", Protected = true, Symbol="P_{static}^{Liquid}"); out TI as control_signal (Brief="Temperature Indicator", PosX=1, PosY=0.39, Protected=true); out PI as control_signal (Brief="Pressure Indicator", PosX=1, PosY=0.21, Protected=true); out LI as control_signal (Brief="Level Indicator", PosX=1, PosY=0.59, Protected=true); INITIAL "Initial level Percent" LI = Levelpercent_Initial; "Initial Outlet Liquid Temperature" OutletLiquid.T = Temperature_Initial; "Initial Outlet Liquid Composition Normalized" OutletLiquid.z(1:NComp - 1) = Composition_Initial(1:NComp - 1)/sum(Composition_Initial); EQUATIONS "Component Molar Balance" diff(TotalHoldup)=Inlet.F*Inlet.z - OutletLiquid.F*OutletLiquid.z - OutletVapour.F*OutletVapour.z; "Energy Balance" diff(E) = Inlet.F*Inlet.h - OutletLiquid.F*OutletLiquid.h - OutletVapour.F*OutletVapour.h + InletQ; "Molar Holdup" TotalHoldup = LiquidHoldup*OutletLiquid.z + VapourHoldup*OutletVapour.z; "Energy Holdup" E = LiquidHoldup*OutletLiquid.h + VapourHoldup*OutletVapour.h - OutletLiquid.P*Vtotal; "Mol fraction normalisation" sum(OutletLiquid.z)=1.0; "Mol fraction normalisation" sum(OutletLiquid.z)=sum(OutletVapour.z); "Vaporization Fraction" OutletVapour.F = Inlet.F * vfrac; "Liquid Volume" vL = PP.LiquidVolume(OutletLiquid.T, Peq, OutletLiquid.z); "Vapour Volume" vV = PP.VapourVolume(OutletVapour.T, Peq, OutletVapour.z); "Chemical Equilibrium" PP.LiquidFugacityCoefficient(OutletLiquid.T, Peq, OutletLiquid.z)*OutletLiquid.z = PP.VapourFugacityCoefficient(OutletVapour.T, Peq, OutletVapour.z)*OutletVapour.z; "Thermal Equilibrium" OutletVapour.T = OutletLiquid.T; "Mechanical Equilibrium for the Vapour Phase" OutletVapour.P = Peq; "Static Head" Pstatic = PP.LiquidDensity(OutletLiquid.T, Peq, OutletLiquid.z) * Gconst * Level; "Mechanical Equilibrium for the Liquid Phase" OutletLiquid.P = Peq + Pstatic; "Pressure Drop" OutletLiquid.P = Inlet.P - Pdrop; "Pressure Ratio" OutletLiquid.P = Inlet.P * Pratio; "Geometry Constraint" Vtotal = LiquidHoldup * vL + VapourHoldup * vV; "Temperature indicator" TI * 'K' = OutletLiquid.T; "Pressure indicator" PI * 'atm' = OutletLiquid.P; "Level indicator" LI*Vtotal= Vfilled; "Liquid Level" LiquidHoldup * vL = Vfilled; end Model flash_steady ATTRIBUTES Pallete = true; Icon = "icon/Flash"; Brief = "Model of a static PH flash."; Info = "This model is for using the flashPH routine available on VRTherm. == ASSUMPTIONS == * perfect mixing of both phases; * thermodynamics equilibrium. * static model. == SPECIFY == * The Inlet stream; * The heat duty; * The outlet pressure. "; PARAMETERS outer PP as Plugin(Brief = "External Physical Properties", Type="PP"); outer NComp as Integer; VARIABLES in Inlet as stream (Brief="Feed Stream", PosX=0, PosY=0.48, Symbol="_{in}"); out OutletLiquid as liquid_stream (Brief="Liquid outlet stream", PosX=0.43, PosY=1, Symbol="_{out}^{Liquid}"); out OutletVapour as vapour_stream (Brief="Vapour outlet stream", PosX=0.43, PosY=0, Symbol="_{out}^{Vapour}"); in InletQ as power (Brief="Heat Duty", PosX=1, PosY=0.81, Protected =true,Symbol="Q_{in}"); vfrac as fraction (Brief="Vaporization fraction", Symbol="\phi", Protected =true); h as enth_mol (Brief="Mixture enthalpy", Hidden =true); Pratio as positive (Brief = "Pressure Ratio", Symbol ="P_{ratio}", Protected =true); Pdrop as press_delta (Brief = "Pressure Drop", DisplayUnit = 'kPa', Symbol ="\Delta P", Protected =true); EQUATIONS if vfrac > 0 and vfrac <1 then "The flash calculation" [vfrac, OutletLiquid.z, OutletVapour.z] = PP.Flash(OutletVapour.T, OutletVapour.P, Inlet.z); else "Chemical equilibrium" [vfrac,OutletLiquid.z,OutletVapour.z]=PP.FlashPH(OutletLiquid.P,h,Inlet.z); end "Global Molar Balance" Inlet.F = OutletVapour.F + OutletLiquid.F; "Vapour Fraction" OutletVapour.F = Inlet.F * vfrac; "Energy Balance" Inlet.F*(h - Inlet.h) = InletQ; Inlet.F*h = Inlet.F*(1-vfrac)*OutletLiquid.h + Inlet.F*vfrac*OutletVapour.h; "Thermal Equilibrium" OutletVapour.T = OutletLiquid.T; "Mechanical Equilibrium" OutletVapour.P = OutletLiquid.P; "Pressure Drop" OutletLiquid.P = Inlet.P - Pdrop; "Pressure Ratio" OutletLiquid.P = Inlet.P * Pratio; end Model FlashPHSteady ATTRIBUTES Pallete = false; Icon = "icon/Flash"; Brief = "Another model of a static PH flash."; Info = "This model shows how to model a pressure enthalpy flash directly with the EMSO modeling language. This model is for demonstration purposes only, the flashPH routine available on VRTherm is much more robust. == Assumptions == * perfect mixing of both phases; == Specify == * the feed stream; * the heat duty; * the outlet pressure. "; PARAMETERS outer PP as Plugin(Brief = "External Physical Properties", Type="PP"); outer NComp as Integer; B as Real(Default=1000, Brief="Regularization Factor"); VARIABLES in Inlet as stream(Brief="Feed Stream", PosX=0, PosY=0.5421, Symbol="_{in}"); out OutletL as liquid_stream(Brief="Liquid outlet stream", PosX=0.4790, PosY=1, Symbol="_{outL}"); out OutletV as vapour_stream(Brief="Vapour outlet stream", PosX=0.4877, PosY=0, Symbol="_{outV}"); in InletQ as power (Brief="Rate of heat supply", PosX=1, PosY=0.7559, Symbol="_{in}"); vfrac as fraction(Brief="Vaporization fraction", Symbol="\phi"); vsat as Real(Lower=-0.1, Upper=1.1, Brief="Vaporization fraction if saturated", Symbol="\phi_{sat}"); Tsat as temperature(Lower=173, Upper=1473, Brief="Temperature if saturated"); xsat(NComp) as Real(Lower=0, Upper=1, Brief="Liquid composition if saturated"); ysat(NComp) as Real(Lower=0, Upper=1, Brief="Vapour composition if saturated"); Pratio as positive (Brief = "Pressure Ratio", Symbol ="P_{ratio}"); Pdrop as press_delta (Brief = "Pressure Drop", DisplayUnit = 'kPa', Symbol ="\Delta P"); zero_one as fraction(Brief="Regularization Variable"); one_zero as fraction(Brief="Regularization Variable"); EQUATIONS "Chemical equilibrium" PP.LiquidFugacityCoefficient(Tsat, OutletL.P, xsat)*xsat = PP.VapourFugacityCoefficient(Tsat, OutletV.P, ysat)*ysat; "Global Molar Balance" Inlet.F = OutletV.F + OutletL.F; OutletV.F = Inlet.F * vfrac; "Component Molar Balance" Inlet.F*Inlet.z = OutletL.F*xsat + OutletV.F*ysat; sum(xsat) = sum(ysat); "Energy Balance if saturated" Inlet.F*Inlet.h + InletQ = Inlet.F*(1-vsat)*PP.LiquidEnthalpy(Tsat, OutletL.P, xsat) + Inlet.F*vsat*PP.VapourEnthalpy(Tsat, OutletV.P, ysat); "Real Energy Balance" Inlet.F*Inlet.h + InletQ = Inlet.F*(1-vfrac)*OutletL.h + Inlet.F*vfrac*OutletV.h; "Thermal Equilibrium" OutletV.T = OutletL.T; "Mechanical Equilibrium" OutletV.P = OutletL.P; "Pressure Drop" OutletL.P = Inlet.P - Pdrop; "Pressure Ratio" OutletL.P = Inlet.P * Pratio; # regularization functions zero_one = (1 + tanh(B * vsat))/2; one_zero = (1 - tanh(B * (vsat - 1)))/2; vfrac = zero_one * one_zero * vsat + 1 - one_zero; OutletL.z = zero_one*one_zero*xsat + (1-zero_one*one_zero)*Inlet.z; OutletV.z = zero_one*one_zero*ysat + (1-zero_one*one_zero)*Inlet.z; end