1 |
REQUIRE "ivpsystem.a4l"; |
2 |
(* => modified version of system.a4l, basemodel.a4l *) |
3 |
REQUIRE "stream_holdup.a4l"; |
4 |
(* => stream_holdup.a4l, thermodynamics.a4l, components.a4l, phases.a4l, |
5 |
* atoms.a4l, measures.a4l, system.a4l, basemodel.a4l *) |
6 |
REQUIRE "kinetics.a4l"; |
7 |
(* => kinetics,a4l, atoms.a4l, measures.a4l, system.a4l, basemodel.a4l *) |
8 |
PROVIDE "reactor.a4l"; |
9 |
|
10 |
(* |
11 |
* reactor.a4l |
12 |
* by Duncan Coffey |
13 |
* May 1998 |
14 |
* Part of the ASCEND Library |
15 |
* $Date: 1998/06/20 15:12:06 $ |
16 |
* $Revision: 1.3 $ |
17 |
* $Author: ballan $ |
18 |
* $Source: /afs/cs.cmu.edu/project/ascend/Repository/models/reactor.a4l,v $ |
19 |
* |
20 |
* This file is part of the ASCEND Modeling Library. |
21 |
* |
22 |
* Copyright (C) 1998 Duncan Coffey |
23 |
* |
24 |
* The ASCEND Modeling Library is free software; you can redistribute |
25 |
* it and/or modify it under the terms of the GNU General Public |
26 |
* License as published by the Free Software Foundation; either |
27 |
* version 2 of the License, or (at your option) any later version. |
28 |
* |
29 |
* The ASCEND Modeling Library is distributed in hope that it |
30 |
* will be useful, but WITHOUT ANY WARRANTY; without even the implied |
31 |
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
32 |
* See the GNU General Public License for more details. |
33 |
* |
34 |
* You should have received a copy of the GNU General Public License |
35 |
* along with the program; if not, write to the Free Software |
36 |
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139 USA. Check |
37 |
* the file named COPYING. |
38 |
*) |
39 |
|
40 |
(* |
41 |
* Requires an empty ascend system. |
42 |
*) |
43 |
|
44 |
|
45 |
(* ***********************************+************************************ *) |
46 |
(* ******************** Reactor ********************* *) |
47 |
(* ***********************************+************************************ *) |
48 |
|
49 |
MODEL single_phase_cstr( |
50 |
input WILL_BE stream; |
51 |
output WILL_BE stream; |
52 |
kinetics WILL_BE base_kinetics; |
53 |
t WILL_BE solver_var; |
54 |
dynamic WILL_BE boolean; |
55 |
ode_offset WILL_BE ode_counter; |
56 |
obs_offset WILL_BE obs_counter; |
57 |
)WHERE( |
58 |
input.cd, output.cd WILL_BE_THE_SAME; |
59 |
kinetics.reac_T, output.T WILL_BE_THE_SAME; |
60 |
(input.pd.phase_indicator IN ['V','L','VL','VLL']) == TRUE; |
61 |
(output.pd.phase_indicator IN ['V','L']) == TRUE; |
62 |
)REFINES cmumodel; |
63 |
|
64 |
cd ALIASES input.cd; |
65 |
equilibrated ALIASES output.equilibrated; |
66 |
FOR i IN kinetics.nr CREATE |
67 |
rate[i] ALIASES kinetics.rate[i]; |
68 |
END FOR; |
69 |
state ALIASES output.Details.state; |
70 |
|
71 |
dM_dt,dMi_dt[cd.other_components] IS_A molar_rate; |
72 |
M,Mi[cd.components] IS_A mole; |
73 |
dU_dt IS_A energy_rate; |
74 |
U IS_A energy; |
75 |
Qin IS_A energy_rate; |
76 |
FOR i IN cd.components CREATE |
77 |
x[i] ALIASES state.y[i]; |
78 |
conc[i] ALIASES kinetics.conc[i]; |
79 |
END FOR; |
80 |
Volume IS_A volume; |
81 |
vol_rate IS_A volume_rate; |
82 |
res_time IS_A time; |
83 |
flowscale IS_A molar_rate_scale; |
84 |
H_flowscale IS_A energy_rate_scale; |
85 |
|
86 |
(* Define what the differential equations are for the system. *) |
87 |
FOR i IN cd.other_components CREATE |
88 |
dMi_dt[i]/flowscale = (input.f[i]+Volume*kinetics.production[i]-output.f[i]) |
89 |
/flowscale; |
90 |
END FOR; |
91 |
|
92 |
dM_dt/flowscale = (input.flow-output.flow |
93 |
+SUM[Volume*kinetics.production[i] | i IN cd.components])/flowscale; |
94 |
|
95 |
dU_dt/H_flowscale = (input.H_flow + Qin - output.H_flow)/H_flowscale; |
96 |
|
97 |
U/H_flowscale = (state.H-state.P*state.V)*M/H_flowscale; |
98 |
|
99 |
Volume = M*state.V; |
100 |
|
101 |
vol_rate = input.flow*input.state.V; |
102 |
|
103 |
res_time = Volume/vol_rate; |
104 |
|
105 |
FOR i IN cd.components CREATE |
106 |
x[i]=Mi[i]/M; |
107 |
conc[i] = Mi[i]/Volume; |
108 |
END FOR; |
109 |
|
110 |
boundwidth IS_A bound_width; |
111 |
|
112 |
METHODS |
113 |
METHOD check_self; |
114 |
IF (output.flow < 1e-4 {mole/s}) THEN |
115 |
STOP {output flow dried up in reactor}; |
116 |
END IF; |
117 |
IF (input.flow < 1e-4 {mole/s}) THEN |
118 |
STOP {input flow fries up in reactor}; |
119 |
END IF; |
120 |
IF (abs(input.flow+SUM[Volume*kinetics.production[i] | i |
121 |
IN cd.components]-output.flow)/flowscale > 1.0e-4) THEN |
122 |
STOP {reactor violates overall mass-balance}; |
123 |
END IF; |
124 |
RUN state.check_self; |
125 |
END check_self; |
126 |
|
127 |
METHOD check_all; |
128 |
RUN input.check_self; |
129 |
RUN output.check_self; |
130 |
RUN check_self; |
131 |
END check_all; |
132 |
|
133 |
METHOD default_self; |
134 |
boundwidth :=10; |
135 |
flowscale := input.Details.flowscale; |
136 |
H_flowscale := input.Details.H_flowscale; |
137 |
dMi_dt[cd.other_components] :=0 {mole/sec}; |
138 |
dMi_dt[cd.other_components].lower_bound :=-1e100 {mole/sec}; |
139 |
dM_dt :=0 {mole/sec}; |
140 |
dM_dt.lower_bound :=-1e100 {mole/sec}; |
141 |
dU_dt :=0 {J/sec}; |
142 |
equilibrated :=FALSE; |
143 |
dynamic :=FALSE; |
144 |
t :=0 {s}; |
145 |
ode_offset :=1; |
146 |
obs_offset :=1; |
147 |
RUN state.default_self; |
148 |
END default_self; |
149 |
|
150 |
METHOD default_all; |
151 |
Qin := 0 {watt}; |
152 |
RUN input.default_self; |
153 |
RUN output.default_self; |
154 |
RUN kinetics.default_self; |
155 |
RUN default_self; |
156 |
END default_all; |
157 |
|
158 |
METHOD bound_self; |
159 |
state.boundwidth := boundwidth; |
160 |
RUN state.bound_self; |
161 |
END bound_self; |
162 |
|
163 |
METHOD bound_all; |
164 |
input.boundwidth := boundwidth; |
165 |
output.boundwidth := boundwidth; |
166 |
RUN input.bound_self; |
167 |
RUN output.bound_self; |
168 |
RUN bound_self; |
169 |
END bound_all; |
170 |
|
171 |
METHOD scale_self; |
172 |
flowscale := input.flow; |
173 |
H_flowscale := input.H_flow; |
174 |
RUN state.scale_self; |
175 |
END scale_self; |
176 |
|
177 |
METHOD scale_all; |
178 |
RUN input.scale_self; |
179 |
RUN output.scale_self; |
180 |
RUN scale_self; |
181 |
END scale_all; |
182 |
|
183 |
METHOD seqmod; |
184 |
RUN state.specify; |
185 |
state.y[cd.components].fixed := FALSE; |
186 |
dMi_dt[cd.other_components].fixed := TRUE; |
187 |
Mi[cd.other_components].fixed := FALSE; |
188 |
dM_dt.fixed := TRUE; |
189 |
M.fixed := FALSE; |
190 |
dU_dt.fixed := TRUE; |
191 |
U.fixed := FALSE; |
192 |
Volume.fixed := TRUE; |
193 |
IF(dynamic = TRUE) THEN |
194 |
Mi[cd.other_components].fixed := TRUE; |
195 |
dMi_dt[cd.other_components].fixed:= FALSE; |
196 |
M.fixed := TRUE; |
197 |
dM_dt.fixed := FALSE; |
198 |
U.fixed := TRUE; |
199 |
dU_dt.fixed := FALSE; |
200 |
output.flow.fixed := TRUE; |
201 |
Volume.fixed := FALSE; |
202 |
Qin.fixed := TRUE; |
203 |
state.T.fixed := FALSE; |
204 |
ELSE |
205 |
dMi_dt[cd.other_components] :=0 {mole/sec}; |
206 |
dM_dt :=0 {mole/sec}; |
207 |
dU_dt :=0 {J/sec}; |
208 |
END IF; |
209 |
END seqmod; |
210 |
|
211 |
METHOD specify; |
212 |
RUN input.specify; |
213 |
RUN seqmod; |
214 |
END specify; |
215 |
|
216 |
METHOD set_ode; |
217 |
t.ode_type :=-1; |
218 |
FOR i IN cd.other_components DO |
219 |
dMi_dt[i].ode_type :=2; |
220 |
Mi[i].ode_type :=1; |
221 |
dMi_dt[i].ode_id :=ode_offset; |
222 |
Mi[i].ode_id :=ode_offset; |
223 |
ode_offset :=ode_offset+1; |
224 |
END FOR; |
225 |
dM_dt.ode_type :=2; |
226 |
M.ode_type :=1; |
227 |
dM_dt.ode_id :=ode_offset; |
228 |
M.ode_id :=ode_offset; |
229 |
ode_offset :=ode_offset+1; |
230 |
dU_dt.ode_type :=2; |
231 |
U.ode_type :=1; |
232 |
dU_dt.ode_id :=ode_offset; |
233 |
U.ode_id :=ode_offset; |
234 |
ode_offset :=ode_offset+1; |
235 |
END set_ode; |
236 |
|
237 |
METHOD set_obs; |
238 |
Volume.obs_id :=obs_offset+1; |
239 |
state.T.obs_id :=obs_offset+2; |
240 |
state.P.obs_id :=obs_offset+3; |
241 |
input.flow.obs_id :=obs_offset+4; |
242 |
output.flow.obs_id :=obs_offset+5; |
243 |
obs_offset :=obs_offset+6; |
244 |
END set_obs; |
245 |
END single_phase_cstr; |
246 |
|
247 |
MODEL multiple_phase_cstr( |
248 |
vapin WILL_BE stream; |
249 |
liqin WILL_BE stream; |
250 |
vapout WILL_BE stream; |
251 |
liqout WILL_BE stream; |
252 |
kinetics WILL_BE base_kinetics; |
253 |
t WILL_BE solver_var; |
254 |
dynamic WILL_BE boolean; |
255 |
ode_offset WILL_BE ode_counter; |
256 |
obs_offset WILL_BE obs_counter; |
257 |
)WHERE( |
258 |
vapin.cd, vapout.cd, liqin.cd, liqout.cd WILL_BE_THE_SAME; |
259 |
vapin, liqin WILL_NOT_BE_THE_SAME; |
260 |
kinetics.reac_T, liqout.T WILL_BE_THE_SAME; |
261 |
vapin.pd.phase_indicator == 'V'; |
262 |
liqin.pd.phase_indicator == 'L'; |
263 |
vapout.pd.phase_indicator == 'V'; |
264 |
liqout.pd.phase_indicator == 'L'; |
265 |
)REFINES cmumodel; |
266 |
|
267 |
cd ALIASES vapout.cd; |
268 |
P ALIASES liqout.P; |
269 |
T ALIASES liqout.T; |
270 |
equilibrated ALIASES vapout.equilibrated; |
271 |
(* reactor thermo options are derived from product streams *) |
272 |
pdVL IS_A phases_data('VL', vapout.pd.vapor_option, |
273 |
liqout.pd.liquid1_option, 'none'); |
274 |
|
275 |
(* reactor Vapor-Liquid state comes from thermo of product streams. *) |
276 |
phaseVL[VLphases] ALIASES |
277 |
(vapout.phase['vapor'], liqout.phase['liquid1']) |
278 |
WHERE VLphases IS_A set OF symbol_constant |
279 |
WITH_VALUE ('vapor','liquid1'); |
280 |
state IS_A thermodynamics(cd, pdVL, phaseVL, equilibrated); |
281 |
|
282 |
x "liquid product composition" ALIASES liqout.state.y; |
283 |
y "vapor product composition" ALIASES vapout.state.y; |
284 |
|
285 |
|
286 |
dMi_dt[cd.other_components] IS_A molar_rate; |
287 |
M,Mi[cd.components],Ml,Mv IS_A mole; |
288 |
dM_dt IS_A molar_rate; |
289 |
dU_dt IS_A energy_rate; |
290 |
U IS_A energy; |
291 |
Vol,vol_liq,vol_vap IS_A volume; |
292 |
Qin IS_A energy_rate; |
293 |
flowscale IS_A molar_rate_scale; |
294 |
split_fraction[VLphases] IS_A fraction; |
295 |
|
296 |
Liquid_split: (split_fraction['liquid1']*(liqin.flow+vapin.flow |
297 |
+Vol*SUM[kinetics.production[i] | i IN cd.components])-liqout.flow)/flowscale = 0; |
298 |
Vapor_split: (split_fraction['vapor']*(liqin.flow+vapin.flow |
299 |
+Vol*SUM[kinetics.production[i] | i IN cd.components])-vapout.flow)/flowscale = 0; |
300 |
|
301 |
(* component material balances *) |
302 |
FOR i IN cd.other_components CREATE |
303 |
dMi_dt[i]/flowscale=(liqin.f[i]+vapin.f[i]+Vol*kinetics.production[i]-vapout.f[i]-liqout.f[i])/flowscale; |
304 |
END FOR; |
305 |
(* overall material balance *) |
306 |
dM_dt/flowscale=(liqin.flow+vapin.flow-vapout.flow-liqout.flow |
307 |
+Vol*SUM[kinetics.production[i] | i IN cd.components])/flowscale; |
308 |
|
309 |
FOR i IN cd.components CREATE |
310 |
Mi[i]=Ml*x[i]+Mv*y[i]; |
311 |
conc[i] ALIASES kinetics.conc[i]; |
312 |
conc[i]=Mi[i]/Vol; |
313 |
END FOR; |
314 |
M=Ml+Mv; |
315 |
Vol=vol_liq+vol_vap; |
316 |
vol_liq=Ml*state.phase['liquid1'].v_y; |
317 |
vol_vap=Mv*state.phase['vapor'].v_y; |
318 |
|
319 |
state.phase_fraction['vapor']=Mv/M; |
320 |
|
321 |
(* overall energy balance *) |
322 |
H_flowscale IS_A energy_rate_scale; |
323 |
|
324 |
dU_dt/H_flowscale=(liqin.H_flow+vapin.H_flow+Qin-vapout.H_flow |
325 |
-liqout.H_flow)/H_flowscale; |
326 |
|
327 |
U/H_flowscale = (state.phase['vapor'].h_y*Mv+state.phase['liquid1'].h_y*Ml) |
328 |
/H_flowscale; |
329 |
boundwidth IS_A bound_width; |
330 |
|
331 |
METHODS |
332 |
METHOD check_self; |
333 |
IF (vapout.flow < 1e-4 {mole/s}) THEN |
334 |
STOP {vapor output flow dried up in reactor}; |
335 |
END IF; |
336 |
IF (vapin.flow < 1e-4 {mole/s}) THEN |
337 |
STOP {vapor input flow fries up in reactor}; |
338 |
END IF; |
339 |
IF (liqout.flow < 1e-4 {mole/s}) THEN |
340 |
STOP {liquid output flow dried up in reactor}; |
341 |
END IF; |
342 |
IF (liqin.flow < 1e-4 {mole/s}) THEN |
343 |
STOP {liquid input flow fries up in reactor}; |
344 |
END IF; |
345 |
IF (abs(vapin.flow+liqin.flow+SUM[Vol*kinetics.production[i] | i |
346 |
IN cd.components]-vapout.flow-liqout.flow)/flowscale > 1.0e-4) THEN |
347 |
STOP {reactor violates overall mass-balance}; |
348 |
END IF; |
349 |
RUN state.check_self; |
350 |
END check_self; |
351 |
|
352 |
METHOD check_all; |
353 |
RUN vapin.check_self; |
354 |
RUN liqin.check_self; |
355 |
RUN vapout.check_self; |
356 |
RUN liqout.check_self; |
357 |
RUN check_self; |
358 |
END check_all; |
359 |
|
360 |
METHOD default_self; |
361 |
boundwidth :=10; |
362 |
flowscale := vapin.Details.flowscale; |
363 |
H_flowscale := vapin.Details.H_flowscale; |
364 |
dMi_dt[cd.other_components] :=0 {mole/sec}; |
365 |
dMi_dt[cd.other_components].lower_bound :=-1e100 {mole/sec}; |
366 |
dM_dt :=0 {mole/sec}; |
367 |
dM_dt.lower_bound :=-1e100 {mole/sec}; |
368 |
dU_dt :=0 {J/sec}; |
369 |
(* Upper bound of split fraction must be changed to |
370 |
greater than 1 for dynamic simulation *) |
371 |
split_fraction[VLphases].upper_bound :=2; |
372 |
equilibrated :=FALSE; |
373 |
dynamic :=FALSE; |
374 |
t :=0 {s}; |
375 |
RUN state.default_self; |
376 |
END default_self; |
377 |
|
378 |
METHOD default_all; |
379 |
Qin := 0 {watt}; |
380 |
RUN vapin.default_self; |
381 |
RUN liqin.default_self; |
382 |
RUN vapout.default_self; |
383 |
RUN liqout.default_self; |
384 |
RUN kinetics.default_self; |
385 |
RUN default_self; |
386 |
END default_all; |
387 |
|
388 |
METHOD bound_self; |
389 |
state.boundwidth := boundwidth; |
390 |
RUN state.bound_self; |
391 |
END bound_self; |
392 |
|
393 |
METHOD bound_all; |
394 |
vapin.boundwidth := boundwidth; |
395 |
liqin.boundwidth := boundwidth; |
396 |
vapout.boundwidth := boundwidth; |
397 |
liqout.boundwidth := boundwidth; |
398 |
RUN vapin.bound_self; |
399 |
RUN liqin.bound_self; |
400 |
RUN vapout.bound_self; |
401 |
RUN liqout.bound_self; |
402 |
RUN bound_self; |
403 |
END bound_all; |
404 |
|
405 |
METHOD scale_self; |
406 |
flowscale := vapin.flow; |
407 |
H_flowscale := vapin.H_flow; |
408 |
RUN state.scale_self; |
409 |
END scale_self; |
410 |
|
411 |
METHOD scale_all; |
412 |
RUN vapin.scale_self; |
413 |
RUN liqin.scale_self; |
414 |
RUN vapout.scale_self; |
415 |
RUN liqout.scale_self; |
416 |
RUN scale_self; |
417 |
END scale_all; |
418 |
|
419 |
METHOD seqmod; |
420 |
RUN state.specify; |
421 |
state.y[cd.components].fixed := FALSE; |
422 |
IF equilibrated THEN |
423 |
state.T.fixed :=FALSE; |
424 |
ELSE |
425 |
state.T.fixed :=TRUE; |
426 |
END IF; |
427 |
state.phase_fraction['vapor'].fixed :=FALSE; |
428 |
split_fraction['vapor'].fixed :=TRUE; |
429 |
dMi_dt[cd.other_components].fixed :=TRUE; |
430 |
Mi[cd.other_components].fixed :=FALSE; |
431 |
dM_dt.fixed :=TRUE; |
432 |
M.fixed :=FALSE; |
433 |
dU_dt.fixed :=TRUE; |
434 |
U.fixed :=FALSE; |
435 |
Vol.fixed :=TRUE; |
436 |
vol_liq.fixed :=TRUE; |
437 |
IF dynamic THEN |
438 |
dMi_dt[cd.other_components].fixed :=FALSE; |
439 |
Mi[cd.other_components].fixed :=TRUE; |
440 |
dM_dt.fixed :=FALSE; |
441 |
M.fixed :=TRUE; |
442 |
dU_dt.fixed :=FALSE; |
443 |
U.fixed :=TRUE; |
444 |
Qin.fixed :=TRUE; |
445 |
IF equilibrated THEN |
446 |
state.P.fixed :=FALSE; |
447 |
ELSE |
448 |
state.T.fixed :=FALSE; |
449 |
END IF; |
450 |
vol_liq.fixed :=FALSE; |
451 |
liqout.flow.fixed :=TRUE; |
452 |
vapout.flow.fixed :=TRUE; |
453 |
split_fraction['vapor'].fixed :=FALSE; |
454 |
ELSE |
455 |
dMi_dt[cd.other_components] :=0 {mole/sec}; |
456 |
dM_dt :=0 {mole/sec}; |
457 |
dU_dt :=0 {J/sec}; |
458 |
END IF; |
459 |
END seqmod; |
460 |
|
461 |
METHOD specify; |
462 |
RUN vapin.specify; |
463 |
RUN liqin.specify; |
464 |
RUN seqmod; |
465 |
END specify; |
466 |
|
467 |
METHOD set_ode; |
468 |
t.ode_type :=-1; |
469 |
FOR i IN cd.other_components DO |
470 |
dMi_dt[i].ode_type :=2; |
471 |
Mi[i].ode_type :=1; |
472 |
dMi_dt[i].ode_id :=ode_offset; |
473 |
Mi[i].ode_id :=ode_offset; |
474 |
ode_offset :=ode_offset+1; |
475 |
END FOR; |
476 |
dM_dt.ode_type :=2; |
477 |
M.ode_type :=1; |
478 |
dM_dt.ode_id :=ode_offset; |
479 |
M.ode_id :=ode_offset; |
480 |
ode_offset :=ode_offset+1; |
481 |
dU_dt.ode_type :=2; |
482 |
U.ode_type :=1; |
483 |
dU_dt.ode_id :=ode_offset; |
484 |
U.ode_id :=ode_offset; |
485 |
ode_offset :=ode_offset+1; |
486 |
END set_ode; |
487 |
|
488 |
METHOD set_obs; |
489 |
Vol.obs_id :=obs_offset+1; |
490 |
vol_liq.obs_id :=obs_offset+2; |
491 |
state.T.obs_id :=obs_offset+3; |
492 |
state.P.obs_id :=obs_offset+4; |
493 |
vapin.flow.obs_id :=obs_offset+5; |
494 |
liqin.flow.obs_id :=obs_offset+6; |
495 |
vapout.flow.obs_id :=obs_offset+7; |
496 |
liqout.flow.obs_id :=obs_offset+8; |
497 |
obs_offset :=obs_offset+9; |
498 |
END set_obs; |
499 |
END multiple_phase_cstr; |
500 |
|
501 |
(*****************************************************************************) |
502 |
|
503 |
MODEL test_single_phase_cstr() REFINES cmumodel; |
504 |
|
505 |
components IS_A set OF symbol_constant; |
506 |
components :==['n_butane','butene_1','n_octane']; |
507 |
cd IS_A components_data(components,'n_octane'); |
508 |
pdV IS_A phases_data('V', 'Pitzer_vapor_mixture', 'none', 'none'); |
509 |
pdL IS_A phases_data('L', 'none', 'UNIFAC_liquid_mixture', 'none'); |
510 |
equilibrated IS_A boolean; |
511 |
input IS_A stream(cd,pdV,equilibrated); |
512 |
output IS_A stream(cd,pdV,equilibrated); |
513 |
nr IS_A set OF symbol_constant; |
514 |
Kr[nr] IS_A constant; |
515 |
active_energy[nr] IS_A constant; |
516 |
species[nr] IS_A set OF symbol_constant; |
517 |
nu[components][nr] IS_A integer_constant; |
518 |
conc[components] IS_A molar_density; |
519 |
kinetics IS_A element_kinetics(components,nr,Kr,active_energy,output.T, |
520 |
species,nu,conc); |
521 |
dynamic IS_A boolean; |
522 |
t IS_A time; |
523 |
ode_offset IS_A ode_counter; |
524 |
obs_offset IS_A obs_counter; |
525 |
|
526 |
reactor IS_A single_phase_cstr(input,output,kinetics,t,dynamic, |
527 |
ode_offset,obs_offset); |
528 |
|
529 |
nr :==['forward','backward']; |
530 |
Kr['forward'] :== 0.1 {m^3/mol/s}; |
531 |
Kr['backward'] :== 10 {1/s}; |
532 |
active_energy['forward'] :== 50 {J/mol}; |
533 |
active_energy['backward'] :== 50 {J/mol}; |
534 |
|
535 |
species['forward'] :==['n_butane','butene_1','n_octane']; |
536 |
species['backward'] :==['n_butane','butene_1','n_octane']; |
537 |
nu['n_butane']['forward'] :==-1; |
538 |
nu['butene_1']['forward'] :==-1; |
539 |
nu['n_octane']['forward'] :==1; |
540 |
nu['n_butane']['backward'] :==1; |
541 |
nu['butene_1']['backward'] :==1; |
542 |
nu['n_octane']['backward'] :==-1; |
543 |
|
544 |
METHODS |
545 |
METHOD check_self; |
546 |
RUN reactor.check_self; |
547 |
END check_self; |
548 |
|
549 |
METHOD check_all; |
550 |
RUN input.check_self; |
551 |
RUN output.check_self; |
552 |
RUN reactor.check_self; |
553 |
RUN check_self; |
554 |
END check_all; |
555 |
|
556 |
METHOD default_self; |
557 |
RUN default_all; |
558 |
END default_self; |
559 |
|
560 |
METHOD default_all; |
561 |
RUN reactor.default_all; |
562 |
END default_all; |
563 |
|
564 |
METHOD bound_self; |
565 |
END bound_self; |
566 |
|
567 |
METHOD bound_all; |
568 |
RUN reactor.bound_all; |
569 |
END bound_all; |
570 |
|
571 |
METHOD specify; |
572 |
RUN reactor.specify; |
573 |
END specify; |
574 |
|
575 |
METHOD scale_self; |
576 |
RUN reactor.scale_self; |
577 |
END scale_self; |
578 |
|
579 |
METHOD scale_all; |
580 |
RUN reactor.scale_all; |
581 |
END scale_all; |
582 |
|
583 |
METHOD values; |
584 |
input.f['n_butane'] :=100 {kmol/hr}; |
585 |
input.f['butene_1'] :=100 {kmol/hr}; |
586 |
input.f['n_octane'] :=1e-11 {kmol/hr}; |
587 |
input.T :=300 {K}; |
588 |
input.P :=1 {atm}; |
589 |
reactor.state.T :=320 {K}; |
590 |
reactor.state.P :=1 {atm}; |
591 |
END values; |
592 |
END test_single_phase_cstr; |
593 |
|
594 |
MODEL test_multiple_phase_cstr() REFINES cmumodel; |
595 |
|
596 |
components IS_A set OF symbol_constant; |
597 |
components :==['n_butane','butene_1','n_octane']; |
598 |
cd IS_A components_data(components,'n_octane'); |
599 |
pdV IS_A phases_data('V', 'Pitzer_vapor_mixture', 'none', 'none'); |
600 |
pdL IS_A phases_data('L', 'none', 'UNIFAC_liquid_mixture', 'none'); |
601 |
equilibrated IS_A boolean; |
602 |
vapin IS_A stream(cd,pdV,equilibrated); |
603 |
vapout IS_A stream(cd,pdV,equilibrated); |
604 |
liqin IS_A stream(cd,pdL,equilibrated); |
605 |
liqout IS_A stream(cd,pdL,equilibrated); |
606 |
nr IS_A set OF symbol_constant; |
607 |
Kr[nr] IS_A constant; |
608 |
active_energy[nr] IS_A constant; |
609 |
species[nr] IS_A set OF symbol_constant; |
610 |
nu[components][nr] IS_A integer_constant; |
611 |
conc[components] IS_A molar_density; |
612 |
kinetics IS_A element_kinetics(components,nr,Kr,active_energy,liqout.T, |
613 |
species,nu,conc); |
614 |
dynamic IS_A boolean; |
615 |
t IS_A time; |
616 |
ode_offset IS_A ode_counter; |
617 |
obs_offset IS_A obs_counter; |
618 |
|
619 |
reactor IS_A multiple_phase_cstr(vapin, liqin, vapout, liqout, kinetics, |
620 |
t, dynamic, ode_offset, obs_offset); |
621 |
|
622 |
nr :==['forward','backward']; |
623 |
Kr['forward'] :== 0.1 {m^3/mol/s}; |
624 |
Kr['backward'] :== 10 {1/s}; |
625 |
active_energy['forward'] :== 50 {J/mol}; |
626 |
active_energy['backward'] :== 50 {J/mol}; |
627 |
|
628 |
species['forward'] :==['n_butane','butene_1','n_octane']; |
629 |
species['backward'] :==['n_butane','butene_1','n_octane']; |
630 |
nu['n_butane']['forward'] :==-1; |
631 |
nu['butene_1']['forward'] :==-1; |
632 |
nu['n_octane']['forward'] :==1; |
633 |
nu['n_butane']['backward'] :==1; |
634 |
nu['butene_1']['backward'] :==1; |
635 |
nu['n_octane']['backward'] :==-1; |
636 |
|
637 |
METHODS |
638 |
METHOD check_self; |
639 |
RUN reactor.check_self; |
640 |
END check_self; |
641 |
|
642 |
METHOD check_all; |
643 |
RUN reactor.check_all; |
644 |
END check_all; |
645 |
|
646 |
METHOD default_self; |
647 |
RUN default_all; |
648 |
END default_self; |
649 |
|
650 |
METHOD default_all; |
651 |
RUN reactor.default_all; |
652 |
END default_all; |
653 |
|
654 |
METHOD bound_self; |
655 |
RUN bound_all; |
656 |
END bound_self; |
657 |
|
658 |
METHOD bound_all; |
659 |
RUN reactor.bound_all; |
660 |
END bound_all; |
661 |
|
662 |
METHOD specify; |
663 |
RUN reactor.specify; |
664 |
END specify; |
665 |
|
666 |
METHOD scale_self; |
667 |
RUN reactor.scale_self; |
668 |
END scale_self; |
669 |
|
670 |
METHOD scale_all; |
671 |
RUN reactor.scale_all; |
672 |
END scale_all; |
673 |
|
674 |
METHOD values; |
675 |
vapin.f['n_butane'] :=100 {kmol/hr}; |
676 |
vapin.f['butene_1'] :=100 {kmol/hr}; |
677 |
vapin.f['n_octane'] :=1e-10 {kmol/hr}; |
678 |
vapin.T :=300 {K}; |
679 |
vapin.P :=1 {atm}; |
680 |
liqin.f['n_butane'] :=100 {kmol/hr}; |
681 |
liqin.f['butene_1'] :=100 {kmol/hr}; |
682 |
liqin.f['n_octane'] :=1e-10 {kmol/hr}; |
683 |
liqin.T :=300 {K}; |
684 |
liqin.P :=1 {atm}; |
685 |
reactor.state.T :=320 {K}; |
686 |
reactor.state.P :=1 {atm}; |
687 |
reactor.Vol :=25 {m^3}; |
688 |
reactor.vol_liq :=12.5 {m^3}; |
689 |
END values; |
690 |
END test_multiple_phase_cstr; |