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 a Gibbs 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 gibbs_vap as tank_vap |
---|
34 | ATTRIBUTES |
---|
35 | Pallete = true; |
---|
36 | Icon = "icon/cstr"; |
---|
37 | Brief = "Model of a generic vapour-phase Gibbs CSTR"; |
---|
38 | Info = " |
---|
39 | Requires the information of: |
---|
40 | * number of elements |
---|
41 | * matrix of elements (elements, compounds) |
---|
42 | "; |
---|
43 | |
---|
44 | PARAMETERS |
---|
45 | outer NElem as Integer (Brief="Number of elements", Default=1); |
---|
46 | Rg as Real (Brief="Universal gas constant", Unit='J/mol/K', Default=8.314); |
---|
47 | na(NElem,NComp) as Real (Brief="Number of elements per component"); |
---|
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 | lambda(NElem) as energy_mol (Brief="Lagrangian multiplier"); |
---|
56 | phi(NComp) as fugacity (Brief="Fugacity coefficient", Default=1); |
---|
57 | activ(NComp) as Real (Brief="Activity", Lower=1e-20); |
---|
58 | |
---|
59 | rate(NComp) as reaction_mol (Brief="Overall component rate of reaction"); |
---|
60 | conv(NComp) as Real (Brief="Fractional conversion of component", Default=0); |
---|
61 | Fi(NComp) as flow_mol (Brief="Component molar flow rate"); |
---|
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 | "Steady-state" |
---|
71 | Outlet.F = sum(Fi); |
---|
72 | |
---|
73 | "Component molar flow rate" |
---|
74 | Fi = Outlet.F*Outlet.z; |
---|
75 | |
---|
76 | "Energy balance" |
---|
77 | Outlet.F*Outlet.h = Outletm.F*Outletm.h; |
---|
78 | |
---|
79 | "Element balance" |
---|
80 | sumt(Fi*na) = sumt(Outletm.F*Outletm.z*na); |
---|
81 | |
---|
82 | "Gibbs Energy of Formation" |
---|
83 | Gs = PP.IdealGasGibbsOfFormation(Outlet.T); |
---|
84 | |
---|
85 | # "Gibbs Energy of Formation without Cp correction" |
---|
86 | # Gs = PP.IdealGasGibbsOfFormationAt25C()*Outlet.T/T0+PP.IdealGasEnthalpyOfFormationAt25C()*(1-Outlet.T/T0); |
---|
87 | |
---|
88 | for i in [1:NComp] |
---|
89 | "Lagrangian multiplier" |
---|
90 | Gs(i) + sumt(lambda*na(:,i)) = -Rg*Outlet.T*ln(activ(i)); |
---|
91 | |
---|
92 | if (Outletm.z(i) > 0) then |
---|
93 | "Molar conversion" |
---|
94 | Fi(i) = Outletm.F*Outletm.z(i)*(1 - conv(i)); |
---|
95 | else if (Outlet.z(i) > 0) then |
---|
96 | "Molar conversion" |
---|
97 | conv(i) = 1; # ? |
---|
98 | else |
---|
99 | "Molar conversion" |
---|
100 | conv(i) = 0; # ? |
---|
101 | end |
---|
102 | end |
---|
103 | |
---|
104 | end |
---|
105 | |
---|
106 | "Fugacity coefficient" |
---|
107 | phi = PP.VapourFugacityCoefficient(Outlet.T,Outlet.P,Outlet.z); |
---|
108 | |
---|
109 | "Activity" |
---|
110 | activ = phi*Outlet.P*Outlet.z/fs; |
---|
111 | end |
---|