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 | * 7. Diffusion with Chemical Reaction in a One Dimensional Slab |
---|
17 | *---------------------------------------------------------------------- |
---|
18 | * |
---|
19 | * Description: |
---|
20 | * This problem is part of a collection of 10 representative |
---|
21 | * problems in Chemical Engineering for solution by numerical methods |
---|
22 | * developed for Cutlip (1998). |
---|
23 | * |
---|
24 | * Subject: |
---|
25 | * * Mass Transfer |
---|
26 | * |
---|
27 | * Numerical method: |
---|
28 | * * Simultaneous ODEs with split boundary conditions |
---|
29 | * * Resolved by finite difference method |
---|
30 | * |
---|
31 | * Reference: |
---|
32 | * * CUTLIP et al. A collection of 10 numerical problems in |
---|
33 | * chemical engineering solved by various mathematical software |
---|
34 | * packages. Comp. Appl. in Eng. Education. v. 6, 169-180, 1998. |
---|
35 | * * http://www.polymath-software.com/ASEE |
---|
36 | * |
---|
37 | *---------------------------------------------------------------------- |
---|
38 | * Author: Rodolfo Rodrigues |
---|
39 | * $Id$ |
---|
40 | *--------------------------------------------------------------------*# |
---|
41 | using "types"; |
---|
42 | |
---|
43 | |
---|
44 | Model problem |
---|
45 | PARAMETERS |
---|
46 | outer N as Integer (Brief="Number of discrete points", Lower=3); |
---|
47 | |
---|
48 | Co as conc_mol (Brief="Constant concentration at the surface"); |
---|
49 | D as diffusivity (Brief="Binary diffusion coefficient"); |
---|
50 | k as Real (Brief="Homogeneous reaction rate constant", Unit='1/s'); |
---|
51 | L as length (Brief="Bottom surface"); |
---|
52 | |
---|
53 | |
---|
54 | VARIABLES |
---|
55 | C(N+2) as conc_mol (Brief="Concentration of reactant"); |
---|
56 | z(N+2) as length (Brief="Distance", Default=1e-3); |
---|
57 | dz as length_delta (Brief="Distance increment"); |
---|
58 | |
---|
59 | |
---|
60 | EQUATIONS |
---|
61 | "Discrete interval" |
---|
62 | dz = (z(N+2) - z(1))/(N+1); |
---|
63 | |
---|
64 | for i in [2:(N+1)] |
---|
65 | "Concentration of reactant" |
---|
66 | (C(i+1) - 2*C(i)+ C(i-1))/(z(i) - z(i-1))^2 |
---|
67 | = (k/D)*C(i); |
---|
68 | |
---|
69 | "Discrete length" |
---|
70 | z(i) = z(i-1) + dz; |
---|
71 | end |
---|
72 | |
---|
73 | # Boundary conditions |
---|
74 | "Initial and boundary condition" # z = 0 |
---|
75 | C(1) = Co; |
---|
76 | |
---|
77 | "Upper boundary" # z = L |
---|
78 | (C(N+2) - C(N+1))/(z(N+2) - z(N+1)) = 0*'kmol/m^4'; |
---|
79 | |
---|
80 | |
---|
81 | SET |
---|
82 | Co= 0.2*'kmol/m^3'; |
---|
83 | D = 1.2e-9*'m^2/s'; |
---|
84 | k = 1e-3/'s'; |
---|
85 | L = 1e-3*'m'; |
---|
86 | end |
---|
87 | |
---|
88 | |
---|
89 | |
---|
90 | FlowSheet numerical_solution |
---|
91 | PARAMETERS |
---|
92 | N as Integer; |
---|
93 | |
---|
94 | |
---|
95 | DEVICES |
---|
96 | reac as problem; |
---|
97 | |
---|
98 | |
---|
99 | SET |
---|
100 | N = 10; # Number of discrete points |
---|
101 | |
---|
102 | |
---|
103 | SPECIFY |
---|
104 | "Lower boundary" |
---|
105 | reac.z(1) = 0*'m'; |
---|
106 | |
---|
107 | "Upper boundary" |
---|
108 | reac.z(N+2) = reac.L; |
---|
109 | |
---|
110 | |
---|
111 | OPTIONS |
---|
112 | Dynamic = false; |
---|
113 | end |
---|
114 | |
---|
115 | |
---|
116 | |
---|
117 | FlowSheet comparative |
---|
118 | PARAMETERS |
---|
119 | N as Integer; |
---|
120 | |
---|
121 | |
---|
122 | VARIABLES |
---|
123 | C_(N+2) as conc_mol (Brief="Concentration of reactant by analytical solution"); |
---|
124 | |
---|
125 | r_ as Real (Brief="Pearson product-moment correlation coefficient"); |
---|
126 | |
---|
127 | Cm as conc_mol (Brief="Arithmetic mean of calculated C"); |
---|
128 | C_m as conc_mol (Brief="Arithmetic mean of analytical C"); |
---|
129 | |
---|
130 | |
---|
131 | DEVICES |
---|
132 | reac as problem; |
---|
133 | |
---|
134 | |
---|
135 | SET |
---|
136 | N = 10; # Number of discrete points |
---|
137 | |
---|
138 | |
---|
139 | EQUATIONS |
---|
140 | "Analytical solution" |
---|
141 | C_ = reac.Co*cosh(reac.L*sqrt(reac.k/reac.D)*(1 - reac.z/reac.L)) |
---|
142 | /cosh(reac.L*sqrt(reac.k/reac.D)); |
---|
143 | |
---|
144 | "Pearson correlation coefficient" # used by softwares like MS Excel |
---|
145 | r_ = (sum((reac.C - Cm)*(C_ - C_m)))/sqrt(sum((reac.C - Cm)^2)*sum((C_ - C_m)^2)); |
---|
146 | |
---|
147 | "Arithmetic mean of C" |
---|
148 | Cm = sum(reac.C)/(N+1); |
---|
149 | |
---|
150 | "Arithmetic mean of C_" |
---|
151 | C_m = sum(C_)/(N+1); |
---|
152 | |
---|
153 | |
---|
154 | SPECIFY |
---|
155 | "Lower boundary" |
---|
156 | reac.z(1) = 0*'m'; |
---|
157 | |
---|
158 | "Upper boundary" |
---|
159 | reac.z(N+2) = reac.L; |
---|
160 | |
---|
161 | |
---|
162 | OPTIONS |
---|
163 | Dynamic = false; |
---|
164 | end |
---|
165 | |
---|
166 | |
---|
167 | FlowSheet analytical_solution |
---|
168 | PARAMETERS |
---|
169 | Co as conc_mol; |
---|
170 | L as length; |
---|
171 | k as Real(Unit='1/s'); |
---|
172 | D as diffusivity; |
---|
173 | |
---|
174 | |
---|
175 | VARIABLES |
---|
176 | C as conc_mol (Default=0.2); |
---|
177 | z as length (Default=1e-3); |
---|
178 | |
---|
179 | |
---|
180 | EQUATIONS |
---|
181 | "Change time in z" |
---|
182 | z = time*'m/s'; |
---|
183 | |
---|
184 | "Analytical solution" |
---|
185 | C = Co*cosh(L*sqrt(k/D)*(1 - z/L))/cosh(L*sqrt(k/D)); |
---|
186 | |
---|
187 | |
---|
188 | SET |
---|
189 | Co= 0.2*'kmol/m^3'; |
---|
190 | D = 1.2e-9*'m^2/s'; |
---|
191 | k = 1e-3/'s'; |
---|
192 | L = 1e-3*'m'; |
---|
193 | |
---|
194 | |
---|
195 | OPTIONS |
---|
196 | TimeStart = 0; |
---|
197 | TimeStep = 1e-6; |
---|
198 | TimeEnd = 1e-3; |
---|
199 | end |
---|