[403] | 1 | #*--------------------------------------------------------------------- |
---|
| 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 | *---------------------------------------------------------------------- |
---|
| 16 | * Model of an equilibrium reactor |
---|
| 17 | *---------------------------------------------------------------------- |
---|
| 18 | * |
---|
[415] | 19 | * Description: |
---|
| 20 | * Thermodynamic equilibrium modeling of a reactor based on |
---|
| 21 | * equilibrium constants approach. |
---|
[403] | 22 | * |
---|
[415] | 23 | * Assumptions: |
---|
| 24 | * * thermodynamic equilibrium |
---|
| 25 | * * steady-state |
---|
[403] | 26 | * |
---|
[415] | 27 | * Specify: |
---|
| 28 | * * inlet stream |
---|
| 29 | * * stoichiometric matrix |
---|
| 30 | * * equilibrium temperature |
---|
| 31 | * |
---|
[403] | 32 | *---------------------------------------------------------------------- |
---|
| 33 | * Author: Rodolfo Rodrigues |
---|
| 34 | * $Id$ |
---|
| 35 | *--------------------------------------------------------------------*# |
---|
| 36 | |
---|
| 37 | using "tank_basic"; |
---|
| 38 | |
---|
| 39 | |
---|
| 40 | #*--------------------------------------------------------------------- |
---|
| 41 | * only vapour phase |
---|
| 42 | *--------------------------------------------------------------------*# |
---|
| 43 | Model equil_vap as tank_vap |
---|
| 44 | ATTRIBUTES |
---|
| 45 | Pallete = true; |
---|
| 46 | Icon = "icon/cstr"; |
---|
[415] | 47 | Brief = "Model of a generic vapour-phase equilibrium CSTR"; |
---|
[403] | 48 | Info = " |
---|
| 49 | Requires the information of: |
---|
| 50 | * number of reactions |
---|
[415] | 51 | * matrix of stoichiometric coefficients (components by reactions) |
---|
[403] | 52 | "; |
---|
| 53 | |
---|
| 54 | PARAMETERS |
---|
| 55 | NReac as Integer (Brief="Number of reactions", Default=1); |
---|
| 56 | stoic(NComp,NReac) as Real (Brief="Stoichiometric matrix"); |
---|
| 57 | Rg as Real (Brief="Universal gas constant", Unit='J/mol/K', Default=8.314); |
---|
| 58 | fs(NComp) as pressure (Brief="Fugacity in standard state", Default=1, DisplayUnit='atm'); |
---|
[415] | 59 | To as temperature (Brief="Reference temperature", Default=298.15); |
---|
[403] | 60 | |
---|
| 61 | VARIABLES |
---|
| 62 | out Outlet as vapour_stream; # Outlet stream |
---|
| 63 | |
---|
[415] | 64 | G(NComp) as energy_mol (Brief="Gibbs free-energy of formation"); |
---|
[403] | 65 | K(NReac) as Real (Brief="Equillibrium constant",Default=1.5); |
---|
| 66 | activ(NComp)as Real (Brief="Activity",Default=0.2); |
---|
| 67 | |
---|
| 68 | rate(NComp) as reaction_mol (Brief="Overall component rate of reaction"); |
---|
| 69 | extent(NReac) as flow_mol (Brief="Extent of reaction"); |
---|
| 70 | conv(NComp) as Real (Brief="Fractional conversion of component", Default=0); # Lower=-1e3, Upper=1e3); |
---|
| 71 | |
---|
| 72 | EQUATIONS |
---|
| 73 | "Outlet stream" |
---|
| 74 | Outlet.F*Outlet.z = Outletm.F*Outletm.z + rate*V; |
---|
| 75 | |
---|
| 76 | "Mechanical equilibrium" |
---|
| 77 | Outlet.P = Outletm.P; |
---|
| 78 | |
---|
| 79 | "Energy balance" |
---|
| 80 | Outlet.F*Outlet.h = Outletm.F*Outletm.h; |
---|
| 81 | |
---|
| 82 | "Steady-state" |
---|
[415] | 83 | Outlet.F = Inlet.F + sum(sumt(stoic*extent)); |
---|
[403] | 84 | |
---|
[415] | 85 | "Gibbs free-energy of formation" |
---|
| 86 | G = PP.IdealGasGibbsOfFormation(Outlet.T); |
---|
[403] | 87 | |
---|
[415] | 88 | # "Gibbs free-energy of formation without Cp correction" |
---|
| 89 | # G = PP.IdealGasGibbsOfFormationAt25C()*Outlet.T/To+PP.IdealGasEnthalpyOfFormationAt25C()*(1-Outlet.T/To); |
---|
[403] | 90 | |
---|
[415] | 91 | "Gibbs free energy of reaction" |
---|
| 92 | # sumt(G*stoic) = -Rg*Outlet.T*ln(K); |
---|
| 93 | K = exp(-sumt(G*stoic)/(Rg*Outlet.T)); |
---|
[403] | 94 | |
---|
| 95 | for j in [1:NReac] |
---|
[415] | 96 | "Equilibrium constant" |
---|
[403] | 97 | K(j) = prod(activ^stoic(:,j)); |
---|
| 98 | end |
---|
| 99 | |
---|
| 100 | for i in [1:NComp] |
---|
| 101 | "Outlet molar fraction" |
---|
| 102 | Outlet.F*Outlet.z(i) = (Inlet.F*Inlet.z(i) + sumt(stoic(i,:)*extent)); |
---|
| 103 | end |
---|
| 104 | |
---|
| 105 | for i in [1:NComp] |
---|
| 106 | if (Outletm.z(i) > 0) then |
---|
| 107 | "Molar conversion" |
---|
| 108 | Outlet.F*Outlet.z(i) = Outletm.F*Outletm.z(i)*(1 - conv(i)); |
---|
| 109 | else if (Outlet.z(i) > 0) then |
---|
| 110 | "Molar conversion" |
---|
| 111 | conv(i) = 1; # ? |
---|
| 112 | else |
---|
| 113 | "Molar conversion" |
---|
| 114 | conv(i) = 0; # ? |
---|
| 115 | end |
---|
| 116 | end |
---|
| 117 | end |
---|
| 118 | |
---|
[415] | 119 | "Activity" |
---|
| 120 | activ = PP.VapourFugacityCoefficient(Outlet.T,Outlet.P,Outlet.z)*Outlet.P*Outlet.z/fs; |
---|
| 121 | end |
---|
[403] | 122 | |
---|
[415] | 123 | |
---|
| 124 | #*--------------------------------------------------------------------- |
---|
| 125 | * only liquid-phase |
---|
| 126 | *--------------------------------------------------------------------*# |
---|
| 127 | Model equil_liq as tank_liq |
---|
| 128 | ATTRIBUTES |
---|
| 129 | Pallete = true; |
---|
| 130 | Icon = "icon/cstr"; |
---|
| 131 | Brief = "Model of a generic liquid-phase equilibrium CSTR"; |
---|
| 132 | Info = " |
---|
| 133 | Requires the information of: |
---|
| 134 | * number of reactions |
---|
| 135 | * matrix of stoichiometric coefficients (components by reactions) |
---|
| 136 | "; |
---|
| 137 | |
---|
| 138 | PARAMETERS |
---|
| 139 | NReac as Integer (Brief="Number of reactions", Default=1); |
---|
| 140 | stoic(NComp,NReac) as Real (Brief="Stoichiometric matrix"); |
---|
| 141 | Rg as Real (Brief="Universal gas constant", Unit='J/mol/K', Default=8.314); |
---|
| 142 | Ps as pressure (Brief="Standard pressure", Default=1, DisplayUnit='bar'); |
---|
| 143 | To as temperature (Brief="Reference temperature", Default=298.15); |
---|
| 144 | |
---|
| 145 | VARIABLES |
---|
| 146 | out Outlet as liquid_stream; # Outlet stream |
---|
| 147 | |
---|
| 148 | G(NReac) as enth_mol (Brief="Gibbs free-energy of formation"); |
---|
| 149 | K(NReac) as fraction (Brief="Equillibrium constant"); |
---|
| 150 | activ(NComp)as Real (Brief="Activity"); |
---|
| 151 | |
---|
| 152 | rate(NComp) as reaction_mol (Brief="Overall component rate of reaction"); |
---|
| 153 | extent(NReac)as flow_mol (Brief="Extent of reaction"); |
---|
| 154 | conv(NComp) as Real (Brief="Fractional conversion of component", Default=0); |
---|
| 155 | |
---|
| 156 | EQUATIONS |
---|
| 157 | "Outlet stream" |
---|
| 158 | Outlet.F*Outlet.z = Outletm.F*Outletm.z + rate*V; |
---|
| 159 | |
---|
| 160 | "Mechanical equilibrium" |
---|
| 161 | Outlet.P = Outletm.P; |
---|
| 162 | |
---|
| 163 | "Energy balance" |
---|
| 164 | Outlet.F*Outlet.h = Outletm.F*Outletm.h; |
---|
| 165 | |
---|
| 166 | "Steady-state" |
---|
| 167 | Outlet.F = Inlet.F + sum(sumt(stoic*extent)); |
---|
| 168 | |
---|
| 169 | "Gibbs free-energy of formation" |
---|
| 170 | G = PP.IdealGasGibbsOfFormation(Outlet.T); |
---|
| 171 | |
---|
| 172 | # "Gibbs free-energy of formation without Cp correction" |
---|
| 173 | # G = PP.IdealGasGibbsOfFormationAt25C()*Outlet.T/To+PP.IdealGasEnthalpyOfFormationAt25C()*(1-Outlet.T/To); |
---|
| 174 | |
---|
| 175 | "Gibbs free energy of reaction" |
---|
| 176 | # sumt(G*stoic) = -Rg*Outlet.T*ln(K); |
---|
| 177 | K = exp(-sumt(G*stoic)/(Rg*Outlet.T)); |
---|
| 178 | |
---|
| 179 | for j in [1:NReac] |
---|
| 180 | "Equilibrium constant" |
---|
| 181 | K(j) = prod(activ^stoic(:,j)); |
---|
| 182 | end |
---|
| 183 | |
---|
| 184 | for i in [1:NComp] |
---|
| 185 | "Outlet molar fraction" |
---|
| 186 | Outlet.F*Outlet.z(i) = (Inlet.F*Inlet.z(i) + sumt(stoic(i,:)*extent)); |
---|
| 187 | end |
---|
| 188 | |
---|
| 189 | for i in [1:NComp] |
---|
| 190 | if (Outletm.z(i) > 0) then |
---|
| 191 | "Molar conversion" |
---|
| 192 | Outlet.F*Outlet.z(i) = Outletm.F*Outletm.z(i)*(1 - conv(i)); |
---|
| 193 | else if (Outlet.z(i) > 0) then |
---|
| 194 | "Molar conversion" |
---|
| 195 | conv(i) = 1; # ? |
---|
| 196 | else |
---|
| 197 | "Molar conversion" |
---|
| 198 | conv(i) = 0; # ? |
---|
| 199 | end |
---|
| 200 | end |
---|
| 201 | end |
---|
| 202 | |
---|
[403] | 203 | "Activity" |
---|
[415] | 204 | activ = PP.LiquidFugacityCoefficient(Outlet.T,Outlet.P,Outlet.z)*Outlet.z |
---|
| 205 | *exp(PP.LiquidVolume(Outlet.T,Outlet.P,Outlet.z)*(Outlet.P - Ps)/Rg/Outlet.T); |
---|
[403] | 206 | end |
---|