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 | * |
---|
19 | * |
---|
20 | * |
---|
21 | *---------------------------------------------------------------------- |
---|
22 | * Author: Rodolfo Rodrigues |
---|
23 | * $Id$ |
---|
24 | *--------------------------------------------------------------------*# |
---|
25 | |
---|
26 | using "tank_basic"; |
---|
27 | |
---|
28 | |
---|
29 | #*--------------------------------------------------------------------- |
---|
30 | * only vapour phase |
---|
31 | *--------------------------------------------------------------------*# |
---|
32 | |
---|
33 | Model equil_vap as tank_vap |
---|
34 | ATTRIBUTES |
---|
35 | Pallete = true; |
---|
36 | Icon = "icon/cstr"; |
---|
37 | Brief = "Model of a generic vapour-phase Equilibrium CSTR"; |
---|
38 | Info = " |
---|
39 | Requires the information of: |
---|
40 | * number of reactions |
---|
41 | * matrix of stoichiometric coefficients (compounds, reaction) |
---|
42 | "; |
---|
43 | |
---|
44 | PARAMETERS |
---|
45 | NReac as Integer (Brief="Number of reactions", Default=1); |
---|
46 | stoic(NComp,NReac) as Real (Brief="Stoichiometric matrix"); |
---|
47 | Rg as Real (Brief="Universal gas constant", Unit='J/mol/K', Default=8.314); |
---|
48 | fs(NComp) as pressure (Brief="Fugacity in standard state", Default=1, DisplayUnit='atm'); |
---|
49 | T0 as temperature (Brief="Reference temperature", Default=298.15); |
---|
50 | |
---|
51 | VARIABLES |
---|
52 | out Outlet as vapour_stream; # Outlet stream |
---|
53 | |
---|
54 | Gs(NComp) as energy_mol (Brief="Gibbs energy in standard state"); |
---|
55 | K(NReac) as Real (Brief="Equillibrium constant",Default=1.5); |
---|
56 | activ(NComp)as Real (Brief="Activity",Default=0.2); |
---|
57 | phi(NComp) as fugacity (Brief="Fugacity coefficient", Default=1); |
---|
58 | |
---|
59 | rate(NComp) as reaction_mol (Brief="Overall component rate of reaction"); |
---|
60 | extent(NReac) as flow_mol (Brief="Extent of reaction"); |
---|
61 | conv(NComp) as Real (Brief="Fractional conversion of component", Default=0); # Lower=-1e3, Upper=1e3); |
---|
62 | |
---|
63 | EQUATIONS |
---|
64 | "Outlet stream" |
---|
65 | Outlet.F*Outlet.z = Outletm.F*Outletm.z + rate*V; |
---|
66 | |
---|
67 | "Mechanical equilibrium" |
---|
68 | Outlet.P = Outletm.P; |
---|
69 | |
---|
70 | "Energy balance" |
---|
71 | Outlet.F*Outlet.h = Outletm.F*Outletm.h; |
---|
72 | |
---|
73 | "Steady-state" |
---|
74 | Outlet.F = Inlet.F+sum(sumt(stoic*extent)); |
---|
75 | |
---|
76 | "Gibbs Energy of Formation" |
---|
77 | Gs = PP.IdealGasGibbsOfFormation(Outlet.T); |
---|
78 | |
---|
79 | # "Gibbs Energy of Formation without Cp correction" |
---|
80 | # Gs = PP.IdealGasGibbsOfFormationAt25C()*Outlet.T/T0+PP.IdealGasEnthalpyOfFormationAt25C()*(1-Outlet.T/T0); |
---|
81 | |
---|
82 | "Equilibrium constant" |
---|
83 | K = exp(-sumt(Gs*stoic)/(Rg*Outlet.T)); |
---|
84 | |
---|
85 | for j in [1:NReac] |
---|
86 | "Equilibrium" |
---|
87 | K(j) = prod(activ^stoic(:,j)); |
---|
88 | end |
---|
89 | |
---|
90 | for i in [1:NComp] |
---|
91 | "Outlet molar fraction" |
---|
92 | Outlet.F*Outlet.z(i) = (Inlet.F*Inlet.z(i) + sumt(stoic(i,:)*extent)); |
---|
93 | end |
---|
94 | |
---|
95 | for i in [1:NComp] |
---|
96 | if (Outletm.z(i) > 0) then |
---|
97 | "Molar conversion" |
---|
98 | Outlet.F*Outlet.z(i) = Outletm.F*Outletm.z(i)*(1 - conv(i)); |
---|
99 | else if (Outlet.z(i) > 0) then |
---|
100 | "Molar conversion" |
---|
101 | conv(i) = 1; # ? |
---|
102 | else |
---|
103 | "Molar conversion" |
---|
104 | conv(i) = 0; # ? |
---|
105 | end |
---|
106 | end |
---|
107 | end |
---|
108 | |
---|
109 | "Fugacity coefficient" |
---|
110 | phi = PP.VapourFugacityCoefficient(Outlet.T,Outlet.P,Outlet.z); |
---|
111 | |
---|
112 | "Activity" |
---|
113 | activ = phi*Outlet.P*Outlet.z/fs; |
---|
114 | end |
---|