source: branches/gui/sample/miscellaneous/tenprobs/prob07.mso @ 574

Last change on this file since 574 was 574, checked in by Rafael de Pelegrini Soares, 14 years ago

Updated the models to work with some language constraints

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