Ticket #22: oxidation_of_so2.mso

File oxidation_of_so2.mso, 7.3 KB (added by Rodolfo Rodrigues, 16 years ago)
Line 
1#*---------------------------------------------------------------------
2* Expressing Cj=hj(X)
3*----------------------------------------------------------------------
4* Solved problem from Fogler (1999)
5* Problem number: 3-7
6* Page: 87 (Brazilian edition, 2002)
7*----------------------------------------------------------------------
8*
9*   Description:
10*               Expressing of the molar concentration as function of molar
11*       conversion for a continuous reactor which occurs the oxidation
12*       reaction:
13*               2SO2 + O2 -> 2SO3
14*       
15*   Assumptions:
16*       * steady-state
17*       * isotermic and isobaric system
18*       * gaseous phase
19*
20*       Specify:
21*               * the inlet stream (z,P,T)
22*               * the parameters of reaction
23*               * the outlet conversion
24*
25*----------------------------------------------------------------------
26* Author: Christiano D. Wetzel Guerra and Rodolfo Rodrigues
27* GIMSCOP/UFRGS - Group of Integration, Modeling, Simulation, Control,
28*                                       and Optimization of Processes
29* $Id$
30*--------------------------------------------------------------------*#
31
32using "types";
33
34
35#*---------------------------------------------------------------------
36* Model of a stream
37*--------------------------------------------------------------------*#
38
39Model stream
40        PARAMETERS
41ext     NComp   as Integer (Brief="Number of chemical components", Lower=1);
42       
43        VARIABLES
44        C(NComp)as conc_mol(Brief="Concentration", Unit="mol/l", Lower=0);
45        z(NComp)as fraction(Brief="Molar fraction");
46end
47
48
49#*---------------------------------------------------------------------
50* Example 3-7: Cj=hj(X)
51*--------------------------------------------------------------------*#
52
53FlowSheet pfr
54        PARAMETERS
55        NComp   as Integer;
56        stoic(NComp) as Real(Brief="Stoichiometric coefficients");
57        k       as Real (Brief="Specific rate of reaction", Unit="l/mol/s");
58        R               as Real (Brief="Universal gas constant", Unit="atm*l/mol/K", Default=0.082);
59       
60        VARIABLES
61        Inlet   as stream; # Inlet stream
62        Outlet  as stream; # Outlet stream     
63        X               as fraction     (Brief="Molar conversion", Lower=0);
64        r               as reaction_mol (Brief="Rate of reaction of A", Unit="mol/l/s");
65        T               as temperature  (Brief="Temperature", Unit="K");
66        P               as pressure     (Brief="Pressure", Unit="atm");
67        Theta(NComp)as Real     (Brief="Parameter Theta");
68        epsilon as Real         (Brief="Parameter epsilon");
69       
70        EQUATIONS
71        "Outlet molar fraction"
72        Outlet.C = Outlet.z*sum(Outlet.C);
73
74        "Inlet concentration"
75        Inlet.C = Inlet.z*P/(R*T);
76       
77        "Outlet concentration"
78        Outlet.C = Inlet.C(1)*(Theta + stoic*X)/(1 + epsilon*X);
79       
80        "Parameter Theta"
81        Theta = Inlet.z/Inlet.z(1);
82       
83        "Parameter epsilon"
84        epsilon = Inlet.z(1)*sum(stoic);
85
86        "Rate of reaction"
87        (-r) = k*Outlet.C(1)*Outlet.C(2);
88       
89        SET
90        NComp = 4; # A, B, C and I
91        stoic = [-1.0, -0.5, 1.0, 0.0];
92        k = 200*"l/mol/s";
93       
94        SPECIFY
95        "Inlet molar fraction"
96        Inlet.z = [0.28, 0.1512, 0.0, 0.5688];
97        "Inlet pressure"
98        P = 1485*"kPa";
99        "Inlet temperature"
100        T = (227 + 273.15)*"K";
101       
102        "Outlet molar conversion"
103        X = 0.5;
104       
105        OPTIONS
106        mode = "steady";
107end
108
109
110FlowSheet pfr_plot
111        PARAMETERS
112        NComp   as Integer;
113        stoic(NComp) as Real(Brief="Stoichiometric coefficients");
114        k       as Real (Brief="Specific rate of reaction", Unit="l/mol/s");
115        R               as Real (Brief="Universal gas constant", Unit="atm*l/mol/K", Default=0.082);
116       
117        VARIABLES
118        Inlet   as stream; # Inlet stream
119        Outlet  as stream; # Outlet stream     
120        X               as fraction     (Brief="Molar conversion", Lower=0);
121        r               as reaction_mol (Brief="Rate of reaction of A", Unit="mol/l/s");
122        T               as temperature  (Brief="Temperature", Unit="K");
123        P               as pressure     (Brief="Pressure", Unit="atm");
124        Theta(NComp)as Real     (Brief="Parameter Theta");
125        epsilon as Real         (Brief="Parameter epsilon");
126       
127        EQUATIONS
128        "Change time in X"
129        X = time*"1/s";
130       
131        "Outlet molar fraction"
132        Outlet.C = Outlet.z*sum(Outlet.C);
133
134        "Inlet concentration"
135        Inlet.C = Inlet.z*P/(R*T);
136       
137        "Outlet concentration"
138        Outlet.C = Inlet.C(1)*(Theta + stoic*X)/(1 + epsilon*X);
139       
140        "Parameter Theta"
141        Theta = Inlet.z/Inlet.z(1);
142       
143        "Parameter epsilon"
144        epsilon = Inlet.z(1)*sum(stoic);
145
146        "Rate of reaction"
147        (-r) = k*Outlet.C(1)*Outlet.C(2);
148       
149        SET
150        NComp = 4; # A, B, C and I
151        stoic = [-1.0, -0.5, 1.0, 0.0];
152        k = 200*"l/mol/s";
153       
154        SPECIFY
155        "Inlet molar fraction"
156        Inlet.z = [0.28, 0.1512, 0.0, 0.5688];
157        "Inlet pressure"
158        P = 1485*"kPa";
159        "Inlet temperature"
160        T = (227 + 273.15)*"K";
161       
162        OPTIONS
163        time = [0:0.005:1];
164end
165
166
167
168FlowSheet pfr_discreted
169        PARAMETERS
170        NComp   as Integer (Brief="Number of chemical components", Lower=1);
171        stoic(NComp)as Real(Brief="Stoichiometric coefficients");
172        N       as Integer(Brief="Number of discrete points", Default=200);
173        k   as Real(Brief="Specific rate of reaction", Unit="l/mol/s");
174        R       as Real(Brief="Universal gas constant", Unit="atm*l/mol/K", Default=0.082);
175       
176        VARIABLES
177        C(N,NComp)      as conc_mol(Brief="Outlet concentration", Unit="mol/l", Lower=0);
178        Ct(N)   as conc_mol(Brief="Total outlet concentration", Unit="mol/l", Lower=0);
179        z(N,NComp)      as fraction(Brief="Outlet molar fraction", Lower=0);
180        X(N)    as fraction(Brief="Molar conversion", Lower=0, Upper=1);
181        dX      as fraction     (Brief="Molar conversion increment");
182        r(N)    as reaction_mol (Brief="Rate of reaction of A", Unit="mol/l/s");
183       
184        Co(NComp)       as conc_mol(Brief="Inlet concentration", Unit="mol/l", Lower=0);
185        zo(NComp)       as fraction(Brief="Inlet molar fraction");
186       
187        T       as temperature(Brief="Temperature", Unit="K");
188        P       as pressure(Brief="Pressure", Unit="atm");
189        Theta(NComp)as Real(Brief="Parameter Theta");
190        epsilon         as Real(Brief="Parameter epsilon");
191       
192        Cto     as conc_mol(Brief="Total inlet concentration", Unit="mol/l", Lower=0);
193       
194        EQUATIONS
195        "Total inlet concentration"
196        Cto = sum(Co);
197       
198        "Inlet concentration"
199        Co = zo*P/(R*T);
200       
201        "Parameter Theta"
202        Theta = zo/zo(1);
203       
204        "Parameter epsilon"
205        epsilon = zo(1)*sum(stoic);
206
207        "Discrete interval"
208        dX = (X(N) - X(1))/N;
209       
210        for i in [1:(N-2)]
211        "Discrete molar convertion"
212                X(i+1) = X(i) + dX;
213        end
214       
215        for i in [1:N]
216        "Outlet concentration"
217                C(i,:) = Co(1)*(Theta + stoic*X(i))/(1 + epsilon*X(i));
218       
219        "Outlet molar fraction"
220                C(i,:) = z(i,:)*sum(C(i,:));
221       
222        "Total outlet concentration"
223                Ct(i) = sum(C(i,:));
224       
225        "Rate of reaction"
226                (-r(i)) = k*C(i,1)*C(i,2);
227        end
228       
229       
230        SET
231        NComp = 4; # A, B, C and I
232        stoic = [-1.0, -0.5, 1.0, 0.0];
233        k = 200*"l/mol/s";
234#       N = 200;
235       
236        SPECIFY
237        "Inlet molar fraction"
238        zo = [0.28, 0.1512, 0.0, 0.5688];
239        "Inlet pressure"
240        P = 1485*"kPa";
241        "Inlet temperature"
242        T = (227 + 273.15)*"K";
243       
244        "Inlet molar conversion"
245        X(1) = 0.0;
246        "Outlet molar conversion"
247        X(N) = 1.0;
248       
249        OPTIONS
250        mode = "steady";
251end
252
253
254#*---------------------------------------------------------------------
255* Plot using emso2ml.m file (under v0.9.45)
256*----------------------------------------------------------------------
257 N=200; % Numbers of discrete points
258 ncomp=4; % Numbers of components
259 y=zeros(ncomp,N); % Concentration matrix
260 [time, values, name]=emso2ml('pfr_discreted.rlt',0);
261 for n=1:N
262        y(:,n)=values((n-1)*ncomp+1:n*ncomp)';
263 end
264 plot(values(9*N+1:10*N),y(1,:),values(9*N+1:10*N),y(2,:),...
265 values(9*N+1:10*N),y(3,:),values(9*N+1:10*N),y(4,:));
266 legend('SO_2','O_2', 'SO_3', 'N_2');
267 xlabel('Molar conversion, X');
268 ylabel('Molar concentration, (mol/l)');
269*--------------------------------------------------------------------*#