#*--------------------------------------------------------------------- * 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. * *---------------------------------------------------------------------- * Model of an equilibrium reactor *---------------------------------------------------------------------- * * * *---------------------------------------------------------------------- * Author: Rodolfo Rodrigues * $Id$ *--------------------------------------------------------------------*# using "tank_basic"; #*--------------------------------------------------------------------- * only vapour phase *--------------------------------------------------------------------*# Model equil_vap as tank_vap ATTRIBUTES Pallete = true; Icon = "icon/cstr"; Brief = "Model of a generic vapour-phase Equilibrium CSTR"; Info = " Requires the information of: * number of reactions * matrix of stoichiometric coefficients (compounds, reaction) "; PARAMETERS NReac as Integer (Brief="Number of reactions", Default=1); stoic(NComp,NReac) as Real (Brief="Stoichiometric matrix"); Rg as Real (Brief="Universal gas constant", Unit='J/mol/K', Default=8.314); fs(NComp) as pressure (Brief="Fugacity in standard state", Default=1, DisplayUnit='atm'); T0 as temperature (Brief="Reference temperature", Default=298.15); VARIABLES out Outlet as vapour_stream; # Outlet stream Gs(NComp) as energy_mol (Brief="Gibbs energy in standard state"); K(NReac) as Real (Brief="Equillibrium constant",Default=1.5); activ(NComp)as Real (Brief="Activity",Default=0.2); phi(NComp) as fugacity (Brief="Fugacity coefficient", Default=1); rate(NComp) as reaction_mol (Brief="Overall component rate of reaction"); extent(NReac) as flow_mol (Brief="Extent of reaction"); conv(NComp) as Real (Brief="Fractional conversion of component", Default=0); # Lower=-1e3, Upper=1e3); EQUATIONS "Outlet stream" Outlet.F*Outlet.z = Outletm.F*Outletm.z + rate*V; "Mechanical equilibrium" Outlet.P = Outletm.P; "Energy balance" Outlet.F*Outlet.h = Outletm.F*Outletm.h; "Steady-state" Outlet.F = Inlet.F+sum(sumt(stoic*extent)); "Gibbs Energy of Formation" Gs = PP.IdealGasGibbsOfFormation(Outlet.T); # "Gibbs Energy of Formation without Cp correction" # Gs = PP.IdealGasGibbsOfFormationAt25C()*Outlet.T/T0+PP.IdealGasEnthalpyOfFormationAt25C()*(1-Outlet.T/T0); "Equilibrium constant" K = exp(-sumt(Gs*stoic)/(Rg*Outlet.T)); for j in [1:NReac] "Equilibrium" K(j) = prod(activ^stoic(:,j)); end for i in [1:NComp] "Outlet molar fraction" Outlet.F*Outlet.z(i) = (Inlet.F*Inlet.z(i) + sumt(stoic(i,:)*extent)); end for i in [1:NComp] if (Outletm.z(i) > 0) then "Molar conversion" Outlet.F*Outlet.z(i) = Outletm.F*Outletm.z(i)*(1 - conv(i)); else if (Outlet.z(i) > 0) then "Molar conversion" conv(i) = 1; # ? else "Molar conversion" conv(i) = 0; # ? end end end "Fugacity coefficient" phi = PP.VapourFugacityCoefficient(Outlet.T,Outlet.P,Outlet.z); "Activity" activ = phi*Outlet.P*Outlet.z/fs; end