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 simplified Gibbs reactor. |
---|
17 | * This model requires VRTherm (www.vrtech.com.br) to run. |
---|
18 | *---------------------------------------------------------------------- |
---|
19 | * |
---|
20 | * |
---|
21 | * |
---|
22 | *---------------------------------------------------------------------- |
---|
23 | * Author: Rafael de Pelegrini Soares |
---|
24 | * $Id$ |
---|
25 | *--------------------------------------------------------------------*# |
---|
26 | |
---|
27 | using "types"; |
---|
28 | |
---|
29 | Model gibbs_reactor_simple |
---|
30 | ATTRIBUTES |
---|
31 | Info = |
---|
32 | "Model for reactor in thermodynamic equilibrium based on Gibbs free |
---|
33 | energy. |
---|
34 | |
---|
35 | The user should specify T, P and ni. |
---|
36 | |
---|
37 | There is a correction for G0 as a function of the temperature. |
---|
38 | This correction considers that H0 does not depend on the temperature. |
---|
39 | This is a good approximation for most cases (less than 2% of error)"; |
---|
40 | |
---|
41 | PARAMETERS |
---|
42 | outer PP as Plugin (Brief="External physical properties", Type="PP"); |
---|
43 | outer NComp as Integer (Brief="Number of components", Default=1); |
---|
44 | |
---|
45 | stoic(NComp) as Real; |
---|
46 | |
---|
47 | R as Real(Brief="Universal gas constant", Unit='J/mol/K', Default=8.314); |
---|
48 | T0 as temperature(Default = 298.15); |
---|
49 | P0 as pressure(Default=1); |
---|
50 | G0(NComp) as energy_mol (Brief="Gibbs energy in standard state"); |
---|
51 | H0(NComp) as energy_mol (Brief="Enthalpy in standard state"); |
---|
52 | |
---|
53 | SET |
---|
54 | G0 = PP.IdealGasGibbsOfFormationAt25C(); |
---|
55 | H0 = PP.IdealGasEnthalpyOfFormationAt25C(); |
---|
56 | |
---|
57 | VARIABLES |
---|
58 | T as temperature; |
---|
59 | P as pressure; |
---|
60 | ni(NComp) as positive(Brief="Initial number of mols", Unit='mol'); |
---|
61 | n(NComp) as positive(Brief="Number of mols at equilibrium", Unit='mol', Upper=2); |
---|
62 | advance as Real(Unit='mol', Lower=-2, Upper=2); |
---|
63 | |
---|
64 | K as Real(Brief="Reaction equilibrium constant at T"); |
---|
65 | K0 as Real(Brief="Reaction equilibrium constant at T0"); |
---|
66 | K1 as Real(Brief="Reaction equilibrium constant correction from T0 to T"); |
---|
67 | |
---|
68 | phi(NComp) as fugacity(Brief="Fugacity coefficient", Default=1); |
---|
69 | |
---|
70 | EQUATIONS |
---|
71 | "Equilibrium constant at 298 K" |
---|
72 | K0 = exp(-sum(stoic*G0)/(R*T0)); |
---|
73 | "Equilibrium constant temperature correction" |
---|
74 | K1 = exp(sum(stoic*H0)/(R*T0) * (1- T0/T)); |
---|
75 | "Equilibrium constant at T" |
---|
76 | K = K1*K0; |
---|
77 | |
---|
78 | "Equilibrium rule" |
---|
79 | K = prod( (n/sum(n)*phi*P/P0) ^ stoic); |
---|
80 | |
---|
81 | "Reaction advance" |
---|
82 | n = ni + stoic * advance; |
---|
83 | |
---|
84 | "Fugacity coefficient" |
---|
85 | phi = PP.VapourFugacityCoefficient(T, P, n/sum(n)); |
---|
86 | end |
---|
87 | |
---|
88 | # Ethane decomposition to produce ethylene and hydrogen at 1000 degC |
---|
89 | FlowSheet gibbs_reactor_simple_sample as gibbs_reactor_simple |
---|
90 | PARAMETERS |
---|
91 | PP as Plugin(Brief="Physical Properties", |
---|
92 | Type="PP", |
---|
93 | Components = ["ethane", "ethylene", "hydrogen"], |
---|
94 | LiquidModel = "PR", |
---|
95 | VapourModel = "PR" |
---|
96 | ); |
---|
97 | NComp as Integer; |
---|
98 | |
---|
99 | SET |
---|
100 | NComp = PP.NumberOfComponents; |
---|
101 | stoic = [-1, 1, 1]; |
---|
102 | |
---|
103 | SPECIFY |
---|
104 | T = (1000 + 273.15) * 'K'; |
---|
105 | P = 1 * 'atm'; |
---|
106 | ni = [1, 0, 0] * 'mol'; |
---|
107 | |
---|
108 | # Expected results: |
---|
109 | # advance = 0.9; |
---|
110 | # n = [0.1, 0.9, 0.9] |
---|
111 | |
---|
112 | OPTIONS |
---|
113 | Dynamic = false; |
---|
114 | end |
---|