1 |
REQUIRE "atoms.a4l"; |
2 |
(* => atoms.a4l, measures.a4l, system.a4l, basemodel.a4l *) |
3 |
PROVIDE "when_demo.a4c"; |
4 |
(* |
5 |
* This file is part of the ASCEND Modeling Library and is released |
6 |
* under the GNU Public License as described at the end of this file. |
7 |
* |
8 |
* Use of this module is demonstrated by the associated script file |
9 |
* when_demo.a4s. |
10 |
*) |
11 |
|
12 |
(* |
13 |
This model is intended to demonstrate the degree of flexibility |
14 |
that the use of conditional statements -when statement- provides |
15 |
to the representation of superstructures. We hope that this |
16 |
application will become clear by looking at the MODEL flowsheet, |
17 |
in which the existence/nonexistence of some of the unit operations |
18 |
is represented by when statements. A particular combination of |
19 |
user defined boolean variables -see method values, configuration2, |
20 |
configuration3- will a define a particular configuration of the |
21 |
problem. |
22 |
|
23 |
This model requires: |
24 |
"system.a4l" |
25 |
"atoms.a4l" |
26 |
*) |
27 |
|
28 |
|
29 |
|
30 |
(* ************************************************* *) |
31 |
|
32 |
MODEL mixture; |
33 |
|
34 |
components IS_A set OF symbol_constant; |
35 |
Cpi[components] IS_A heat_capacity; |
36 |
y[components] IS_A fraction; |
37 |
P IS_A pressure; |
38 |
T IS_A temperature; |
39 |
Cp IS_A heat_capacity; |
40 |
|
41 |
|
42 |
SUM[y[i] | i IN components] = 1.0; |
43 |
Cp = SUM[Cpi[i] * y[i] | i IN components]; |
44 |
|
45 |
METHODS |
46 |
|
47 |
METHOD default_self; |
48 |
END default_self; |
49 |
|
50 |
METHOD specify; |
51 |
Cpi[components].fixed := TRUE; |
52 |
P.fixed := TRUE; |
53 |
T.fixed := TRUE; |
54 |
y[components].fixed := TRUE; |
55 |
y[CHOICE[components]].fixed := FALSE; |
56 |
END specify; |
57 |
|
58 |
END mixture; |
59 |
|
60 |
|
61 |
(* ************************************************* *) |
62 |
|
63 |
|
64 |
MODEL molar_stream; |
65 |
state IS_A mixture; |
66 |
Ftot,f[components] IS_A molar_rate; |
67 |
components IS_A set OF symbol_constant; |
68 |
P IS_A pressure; |
69 |
T IS_A temperature; |
70 |
Cp IS_A heat_capacity; |
71 |
|
72 |
components, state.components ARE_THE_SAME; |
73 |
P, state.P ARE_THE_SAME; |
74 |
T, state.T ARE_THE_SAME; |
75 |
Cp, state.Cp ARE_THE_SAME; |
76 |
|
77 |
FOR i IN components CREATE |
78 |
f_def[i]: f[i] = Ftot*state.y[i]; |
79 |
END FOR; |
80 |
|
81 |
METHODS |
82 |
|
83 |
METHOD default_self; |
84 |
END default_self; |
85 |
|
86 |
METHOD specify; |
87 |
RUN state.specify; |
88 |
state.y[components].fixed := FALSE; |
89 |
f[components].fixed := TRUE; |
90 |
END specify; |
91 |
|
92 |
END molar_stream; |
93 |
|
94 |
|
95 |
|
96 |
(* ************************************************* *) |
97 |
|
98 |
|
99 |
MODEL cheap_feed; |
100 |
stream IS_A molar_stream; |
101 |
cost_factor IS_A cost_per_mole; |
102 |
cost IS_A cost_per_time; |
103 |
|
104 |
stream.f['A'] = 0.060 {kg_mole/s}; |
105 |
stream.f['B'] = 0.025 {kg_mole/s}; |
106 |
stream.f['D'] = 0.015 {kg_mole/s}; |
107 |
stream.f['C'] = 0.00 {kg_mole/s}; |
108 |
stream.T = 300 {K}; |
109 |
stream.P = 5 {bar}; |
110 |
|
111 |
cost = cost_factor * stream.Ftot; |
112 |
METHODS |
113 |
|
114 |
METHOD default_self; |
115 |
END default_self; |
116 |
|
117 |
METHOD specify; |
118 |
RUN stream.specify; |
119 |
stream.f[stream.components].fixed := FALSE; |
120 |
cost_factor.fixed := TRUE; |
121 |
stream.T.fixed := FALSE; |
122 |
stream.P.fixed := FALSE; |
123 |
END specify; |
124 |
|
125 |
END cheap_feed; |
126 |
|
127 |
|
128 |
(* ************************************************* *) |
129 |
|
130 |
|
131 |
MODEL expensive_feed; |
132 |
stream IS_A molar_stream; |
133 |
cost_factor IS_A cost_per_mole; |
134 |
cost IS_A cost_per_time; |
135 |
|
136 |
stream.f['A'] = 0.065 {kg_mole/s}; |
137 |
stream.f['B'] = 0.030 {kg_mole/s}; |
138 |
stream.f['D'] = 0.05 {kg_mole/s}; |
139 |
stream.f['C'] = 0.00 {kg_mole/s}; |
140 |
stream.T = 320 {K}; |
141 |
stream.P = 6 {bar}; |
142 |
|
143 |
cost = 3 * cost_factor * stream.Ftot; |
144 |
|
145 |
METHODS |
146 |
|
147 |
METHOD default_self; |
148 |
END default_self; |
149 |
|
150 |
METHOD specify; |
151 |
RUN stream.specify; |
152 |
stream.f[stream.components].fixed := FALSE; |
153 |
cost_factor.fixed := TRUE; |
154 |
stream.T.fixed := FALSE; |
155 |
stream.P.fixed := FALSE; |
156 |
END specify; |
157 |
|
158 |
END expensive_feed; |
159 |
|
160 |
|
161 |
(* ************************************************* *) |
162 |
|
163 |
|
164 |
MODEL heater; |
165 |
input,output IS_A molar_stream; |
166 |
heat_supplied IS_A energy_rate; |
167 |
components IS_A set OF symbol_constant; |
168 |
cost IS_A cost_per_time; |
169 |
cost_factor IS_A cost_per_energy; |
170 |
|
171 |
components,input.components,output.components ARE_THE_SAME; |
172 |
FOR i IN components CREATE |
173 |
input.state.Cpi[i], output.state.Cpi[i] ARE_THE_SAME; |
174 |
END FOR; |
175 |
|
176 |
FOR i IN components CREATE |
177 |
input.f[i] = output.f[i]; |
178 |
END FOR; |
179 |
|
180 |
input.P = output.P; |
181 |
|
182 |
heat_supplied = input.Cp *(output.T - input.T) * input.Ftot; |
183 |
|
184 |
cost = cost_factor * heat_supplied; |
185 |
|
186 |
METHODS |
187 |
|
188 |
METHOD default_self; |
189 |
END default_self; |
190 |
|
191 |
METHOD specify; |
192 |
RUN input.specify; |
193 |
cost_factor.fixed := TRUE; |
194 |
heat_supplied.fixed := TRUE; |
195 |
END specify; |
196 |
|
197 |
METHOD seqmod; |
198 |
cost_factor.fixed := TRUE; |
199 |
heat_supplied.fixed := TRUE; |
200 |
END seqmod; |
201 |
|
202 |
END heater; |
203 |
|
204 |
|
205 |
|
206 |
(* ************************************************* *) |
207 |
|
208 |
|
209 |
MODEL cooler; |
210 |
|
211 |
input,output IS_A molar_stream; |
212 |
heat_removed IS_A energy_rate; |
213 |
components IS_A set OF symbol_constant; |
214 |
cost IS_A cost_per_time; |
215 |
cost_factor IS_A cost_per_energy; |
216 |
|
217 |
components,input.components,output.components ARE_THE_SAME; |
218 |
FOR i IN components CREATE |
219 |
input.state.Cpi[i],output.state.Cpi[i] ARE_THE_SAME; |
220 |
END FOR; |
221 |
|
222 |
FOR i IN components CREATE |
223 |
input.f[i] = output.f[i]; |
224 |
END FOR; |
225 |
|
226 |
input.P = output.P; |
227 |
heat_removed = input.Cp *(input.T - output.T) * input.Ftot; |
228 |
cost = cost_factor * heat_removed; |
229 |
|
230 |
METHODS |
231 |
|
232 |
METHOD default_self; |
233 |
END default_self; |
234 |
|
235 |
METHOD specify; |
236 |
RUN input.specify; |
237 |
cost_factor.fixed := TRUE; |
238 |
heat_removed.fixed := TRUE; |
239 |
END specify; |
240 |
|
241 |
METHOD seqmod; |
242 |
cost_factor.fixed := TRUE; |
243 |
heat_removed.fixed := TRUE; |
244 |
END seqmod; |
245 |
|
246 |
END cooler; |
247 |
|
248 |
|
249 |
(* ************************************************* *) |
250 |
|
251 |
|
252 |
MODEL single_compressor; (* Adiabatic Compression *) |
253 |
|
254 |
input,output IS_A molar_stream; |
255 |
components IS_A set OF symbol_constant; |
256 |
work_supplied IS_A energy_rate; |
257 |
pressure_rate IS_A factor; |
258 |
R IS_A gas_constant; |
259 |
cost IS_A cost_per_time; |
260 |
cost_factor IS_A cost_per_energy; |
261 |
|
262 |
components,input.components,output.components ARE_THE_SAME; |
263 |
FOR i IN components CREATE |
264 |
input.state.Cpi[i],output.state.Cpi[i] ARE_THE_SAME; |
265 |
END FOR; |
266 |
|
267 |
FOR i IN components CREATE |
268 |
input.f[i] = output.f[i]; |
269 |
END FOR; |
270 |
|
271 |
pressure_rate = output.P / input.P; |
272 |
|
273 |
output.T = input.T * (pressure_rate ^(R/input.Cp) ); |
274 |
|
275 |
work_supplied = input.Ftot * input.Cp * (output.T - input.T); |
276 |
|
277 |
cost = cost_factor * work_supplied; |
278 |
|
279 |
METHODS |
280 |
|
281 |
METHOD default_self; |
282 |
END default_self; |
283 |
|
284 |
METHOD specify; |
285 |
RUN input.specify; |
286 |
cost_factor.fixed := TRUE; |
287 |
pressure_rate.fixed := TRUE; |
288 |
END specify; |
289 |
|
290 |
METHOD seqmod; |
291 |
cost_factor.fixed := TRUE; |
292 |
pressure_rate.fixed := TRUE; |
293 |
END seqmod; |
294 |
|
295 |
END single_compressor; |
296 |
|
297 |
|
298 |
(* ************************************************* *) |
299 |
|
300 |
|
301 |
MODEL staged_compressor; |
302 |
|
303 |
input,output IS_A molar_stream; |
304 |
components IS_A set OF symbol_constant; |
305 |
work_supplied IS_A energy_rate; |
306 |
heat_removed IS_A energy_rate; |
307 |
T_middle IS_A temperature; |
308 |
n_stages IS_A factor; |
309 |
pressure_rate IS_A factor; |
310 |
stage_pressure_rate IS_A factor; |
311 |
R IS_A gas_constant; |
312 |
cost IS_A cost_per_time; |
313 |
cost_factor_work IS_A cost_per_energy; |
314 |
cost_factor_heat IS_A cost_per_energy; |
315 |
|
316 |
components,input.components,output.components ARE_THE_SAME; |
317 |
FOR i IN components CREATE |
318 |
input.state.Cpi[i],output.state.Cpi[i] ARE_THE_SAME; |
319 |
END FOR; |
320 |
|
321 |
FOR i IN components CREATE |
322 |
input.f[i] = output.f[i]; |
323 |
END FOR; |
324 |
|
325 |
output.T = input.T; |
326 |
|
327 |
pressure_rate = output.P / input.P; |
328 |
|
329 |
stage_pressure_rate =(pressure_rate)^(1.0/n_stages); |
330 |
|
331 |
T_middle = input.T * (stage_pressure_rate ^(R/input.Cp)); |
332 |
|
333 |
work_supplied = input.Ftot * n_stages * input.Cp * |
334 |
(T_middle - input.T); |
335 |
|
336 |
heat_removed = input.Ftot * (n_stages - 1.0) * |
337 |
input.Cp * (T_middle - input.T); |
338 |
|
339 |
cost = cost_factor_work * work_supplied + |
340 |
cost_factor_heat * heat_removed; |
341 |
|
342 |
METHODS |
343 |
|
344 |
METHOD default_self; |
345 |
END default_self; |
346 |
|
347 |
METHOD specify; |
348 |
RUN input.specify; |
349 |
n_stages.fixed := TRUE; |
350 |
cost_factor_heat.fixed := TRUE; |
351 |
cost_factor_work.fixed := TRUE; |
352 |
pressure_rate.fixed := TRUE; |
353 |
END specify; |
354 |
|
355 |
METHOD seqmod; |
356 |
n_stages.fixed := TRUE; |
357 |
cost_factor_heat.fixed := TRUE; |
358 |
cost_factor_work.fixed := TRUE; |
359 |
pressure_rate.fixed := TRUE; |
360 |
END seqmod; |
361 |
|
362 |
END staged_compressor; |
363 |
|
364 |
|
365 |
(* ************************************************* *) |
366 |
|
367 |
|
368 |
MODEL mixer; |
369 |
|
370 |
components IS_A set OF symbol_constant; |
371 |
n_inputs IS_A integer_constant; |
372 |
feed[1..n_inputs], out IS_A molar_stream; |
373 |
To IS_A temperature; |
374 |
|
375 |
components,feed[1..n_inputs].components, |
376 |
out.components ARE_THE_SAME; |
377 |
FOR i IN components CREATE |
378 |
feed[1..n_inputs].state.Cpi[i],out.state.Cpi[i] ARE_THE_SAME; |
379 |
END FOR; |
380 |
|
381 |
FOR i IN components CREATE |
382 |
cmb[i]: out.f[i] = SUM[feed[1..n_inputs].f[i]]; |
383 |
END FOR; |
384 |
|
385 |
SUM[(feed[i].Cp *feed[i].Ftot * (feed[i].T - To))|i IN [1..n_inputs]]= |
386 |
out.Cp *out.Ftot * (out.T - To); |
387 |
|
388 |
SUM[( feed[i].Ftot * feed[i].T / feed[i].P )|i IN [1..n_inputs]] = |
389 |
out.Ftot * out.T / out.P; |
390 |
|
391 |
METHODS |
392 |
|
393 |
METHOD default_self; |
394 |
END default_self; |
395 |
|
396 |
METHOD specify; |
397 |
To.fixed := TRUE; |
398 |
RUN feed[1..n_inputs].specify; |
399 |
END specify; |
400 |
|
401 |
METHOD seqmod; |
402 |
To.fixed := TRUE; |
403 |
END seqmod; |
404 |
|
405 |
END mixer; |
406 |
|
407 |
|
408 |
(* ************************************************* *) |
409 |
|
410 |
|
411 |
MODEL splitter; |
412 |
|
413 |
components IS_A set OF symbol_constant; |
414 |
n_outputs IS_A integer_constant; |
415 |
feed, out[1..n_outputs] IS_A molar_stream; |
416 |
split[1..n_outputs] IS_A fraction; |
417 |
|
418 |
components, feed.components, |
419 |
out[1..n_outputs].components ARE_THE_SAME; |
420 |
feed.state, |
421 |
out[1..n_outputs].state ARE_THE_SAME; |
422 |
|
423 |
FOR j IN [1..n_outputs] CREATE |
424 |
out[j].Ftot = split[j]*feed.Ftot; |
425 |
END FOR; |
426 |
|
427 |
SUM[split[1..n_outputs]] = 1.0; |
428 |
|
429 |
METHODS |
430 |
|
431 |
METHOD default_self; |
432 |
END default_self; |
433 |
|
434 |
METHOD specify; |
435 |
RUN feed.specify; |
436 |
split[1..n_outputs-1].fixed:= TRUE; |
437 |
END specify; |
438 |
|
439 |
METHOD seqmod; |
440 |
split[1..n_outputs-1].fixed:= TRUE; |
441 |
END seqmod; |
442 |
|
443 |
END splitter; |
444 |
|
445 |
|
446 |
(* ************************************************* *) |
447 |
|
448 |
|
449 |
MODEL cheap_reactor; |
450 |
components IS_A set OF symbol_constant; |
451 |
input, output IS_A molar_stream; |
452 |
low_turnover IS_A molar_rate; |
453 |
stoich_coef[input.components] IS_A factor; |
454 |
cost_factor IS_A cost_per_mole; |
455 |
cost IS_A cost_per_time; |
456 |
|
457 |
components,input.components, output.components ARE_THE_SAME; |
458 |
FOR i IN components CREATE |
459 |
input.state.Cpi[i], output.state.Cpi[i] ARE_THE_SAME; |
460 |
END FOR; |
461 |
|
462 |
FOR i IN components CREATE |
463 |
output.f[i] = input.f[i] + stoich_coef[i]*low_turnover; |
464 |
END FOR; |
465 |
|
466 |
input.T = output.T; |
467 |
(* ideal gas constant volume *) |
468 |
input.Ftot * input.T / input.P = output.Ftot * output.T/output.P; |
469 |
|
470 |
cost = cost_factor * low_turnover; |
471 |
|
472 |
METHODS |
473 |
|
474 |
METHOD default_self; |
475 |
END default_self; |
476 |
|
477 |
METHOD specify; |
478 |
RUN input.specify; |
479 |
low_turnover.fixed:= TRUE; |
480 |
stoich_coef[input.components].fixed:= TRUE; |
481 |
cost_factor.fixed := TRUE; |
482 |
END specify; |
483 |
|
484 |
METHOD seqmod; |
485 |
low_turnover.fixed:= TRUE; |
486 |
stoich_coef[input.components].fixed:= TRUE; |
487 |
cost_factor.fixed := TRUE; |
488 |
END seqmod; |
489 |
|
490 |
END cheap_reactor; |
491 |
|
492 |
|
493 |
(* ************************************************* *) |
494 |
|
495 |
|
496 |
MODEL expensive_reactor; |
497 |
|
498 |
components IS_A set OF symbol_constant; |
499 |
input, output IS_A molar_stream; |
500 |
high_turnover IS_A molar_rate; |
501 |
stoich_coef[input.components] IS_A factor; |
502 |
cost_factor IS_A cost_per_mole; |
503 |
cost IS_A cost_per_time; |
504 |
|
505 |
components,input.components, output.components ARE_THE_SAME; |
506 |
FOR i IN components CREATE |
507 |
input.state.Cpi[i], output.state.Cpi[i] ARE_THE_SAME; |
508 |
END FOR; |
509 |
|
510 |
FOR i IN components CREATE |
511 |
output.f[i] = input.f[i] + stoich_coef[i]*high_turnover; |
512 |
END FOR; |
513 |
|
514 |
input.T = output.T; |
515 |
(* ideal gas constant volume *) |
516 |
input.Ftot * input.T / input.P = output.Ftot * output.T/output.P; |
517 |
|
518 |
cost = cost_factor * high_turnover; |
519 |
|
520 |
METHODS |
521 |
|
522 |
METHOD default_self; |
523 |
END default_self; |
524 |
|
525 |
METHOD specify; |
526 |
RUN input.specify; |
527 |
high_turnover.fixed:= TRUE; |
528 |
stoich_coef[input.components].fixed:= TRUE; |
529 |
cost_factor.fixed := TRUE; |
530 |
END specify; |
531 |
|
532 |
METHOD seqmod; |
533 |
high_turnover.fixed:= TRUE; |
534 |
stoich_coef[input.components].fixed:= TRUE; |
535 |
cost_factor.fixed := TRUE; |
536 |
END seqmod; |
537 |
|
538 |
END expensive_reactor; |
539 |
|
540 |
|
541 |
(* ************************************************* *) |
542 |
|
543 |
|
544 |
MODEL flash; |
545 |
|
546 |
components IS_A set OF symbol_constant; |
547 |
feed,vap,liq IS_A molar_stream; |
548 |
alpha[feed.components] IS_A factor; |
549 |
ave_alpha IS_A factor; |
550 |
vap_to_feed_ratio IS_A fraction; |
551 |
|
552 |
components,feed.components, |
553 |
vap.components, |
554 |
liq.components ARE_THE_SAME; |
555 |
FOR i IN components CREATE |
556 |
feed.state.Cpi[i], |
557 |
vap.state.Cpi[i], |
558 |
liq.state.Cpi[i] ARE_THE_SAME; |
559 |
END FOR; |
560 |
|
561 |
vap_to_feed_ratio*feed.Ftot = vap.Ftot; |
562 |
|
563 |
FOR i IN components CREATE |
564 |
cmb[i]: feed.f[i] = vap.f[i] + liq.f[i]; |
565 |
eq[i]: vap.state.y[i]*ave_alpha = alpha[i]*liq.state.y[i]; |
566 |
END FOR; |
567 |
|
568 |
feed.T = vap.T; |
569 |
feed.T = liq.T; |
570 |
feed.P = vap.P; |
571 |
feed.P = liq.P; |
572 |
|
573 |
METHODS |
574 |
|
575 |
METHOD default_self; |
576 |
END default_self; |
577 |
|
578 |
METHOD specify; |
579 |
RUN feed.specify; |
580 |
alpha[feed.components].fixed:= TRUE; |
581 |
vap_to_feed_ratio.fixed := TRUE; |
582 |
END specify; |
583 |
|
584 |
METHOD seqmod; |
585 |
alpha[feed.components].fixed:= TRUE; |
586 |
vap_to_feed_ratio.fixed := TRUE; |
587 |
END seqmod; |
588 |
|
589 |
END flash; |
590 |
|
591 |
|
592 |
(* ************************************************* *) |
593 |
|
594 |
|
595 |
MODEL flowsheet; |
596 |
|
597 |
(* units *) |
598 |
|
599 |
f1 IS_A cheap_feed; |
600 |
f2 IS_A expensive_feed; |
601 |
|
602 |
c1 IS_A single_compressor; |
603 |
s1 IS_A staged_compressor; |
604 |
|
605 |
c2 IS_A single_compressor; |
606 |
s2 IS_A staged_compressor; |
607 |
|
608 |
r1 IS_A cheap_reactor; |
609 |
r2 IS_A expensive_reactor; |
610 |
|
611 |
co1,co2 IS_A cooler; |
612 |
h1,h2,h3 IS_A heater; |
613 |
fl1 IS_A flash; |
614 |
sp1 IS_A splitter; |
615 |
m1 IS_A mixer; |
616 |
|
617 |
(* boolean variables *) |
618 |
|
619 |
select_feed1 IS_A boolean_var; |
620 |
select_single1 IS_A boolean_var; |
621 |
select_cheapr1 IS_A boolean_var; |
622 |
select_single2 IS_A boolean_var; |
623 |
|
624 |
(* define sets *) |
625 |
|
626 |
m1.n_inputs :== 2; |
627 |
sp1.n_outputs :== 2; |
628 |
|
629 |
(* wire up flowsheet *) |
630 |
|
631 |
f1.stream, f2.stream, c1.input, s1.input ARE_THE_SAME; |
632 |
c1.output, s1.output, m1.feed[2] ARE_THE_SAME; |
633 |
m1.out,co1.input ARE_THE_SAME; |
634 |
co1.output, h1.input ARE_THE_SAME; |
635 |
h1.output, r1.input, r2.input ARE_THE_SAME; |
636 |
r1.output, r2.output,co2.input ARE_THE_SAME; |
637 |
co2.output, fl1.feed ARE_THE_SAME; |
638 |
fl1.liq, h2.input ARE_THE_SAME; |
639 |
fl1.vap, sp1.feed ARE_THE_SAME; |
640 |
sp1.out[1], h3.input ARE_THE_SAME; |
641 |
sp1.out[2],c2.input, s2.input ARE_THE_SAME; |
642 |
c2.output, s2.output,m1.feed[1] ARE_THE_SAME; |
643 |
|
644 |
|
645 |
(* Conditional statements *) |
646 |
|
647 |
WHEN (select_feed1) |
648 |
CASE TRUE: |
649 |
USE f1; |
650 |
CASE FALSE: |
651 |
USE f2; |
652 |
END WHEN; |
653 |
|
654 |
WHEN (select_single1) |
655 |
CASE TRUE: |
656 |
USE c1; |
657 |
CASE FALSE: |
658 |
USE s1; |
659 |
END WHEN; |
660 |
|
661 |
WHEN (select_cheapr1) |
662 |
CASE TRUE: |
663 |
USE r1; |
664 |
CASE FALSE: |
665 |
USE r2; |
666 |
END WHEN; |
667 |
|
668 |
WHEN (select_single2) |
669 |
CASE TRUE: |
670 |
USE c2; |
671 |
CASE FALSE: |
672 |
USE s2; |
673 |
END WHEN; |
674 |
|
675 |
|
676 |
METHODS |
677 |
|
678 |
METHOD default_self; |
679 |
END default_self; |
680 |
|
681 |
METHOD seqmod; |
682 |
RUN c1.seqmod; |
683 |
RUN c2.seqmod; |
684 |
RUN s1.seqmod; |
685 |
RUN s2.seqmod; |
686 |
RUN co1.seqmod; |
687 |
RUN co2.seqmod; |
688 |
RUN h1.seqmod; |
689 |
RUN h2.seqmod; |
690 |
RUN h3.seqmod; |
691 |
RUN r1.seqmod; |
692 |
RUN r2.seqmod; |
693 |
RUN fl1.seqmod; |
694 |
RUN sp1.seqmod; |
695 |
RUN m1.seqmod; |
696 |
END seqmod; |
697 |
|
698 |
METHOD specify; |
699 |
RUN seqmod; |
700 |
RUN f1.specify; |
701 |
RUN f2.specify; |
702 |
END specify; |
703 |
|
704 |
END flowsheet; |
705 |
|
706 |
|
707 |
(* ************************************************* *) |
708 |
|
709 |
|
710 |
MODEL test_flowsheet REFINES flowsheet; |
711 |
|
712 |
f1.stream.components :== ['A','B','C','D']; |
713 |
|
714 |
METHODS |
715 |
|
716 |
METHOD default_self; |
717 |
END default_self; |
718 |
|
719 |
METHOD values; |
720 |
|
721 |
(* Initial Configuration *) |
722 |
select_feed1 := TRUE; |
723 |
select_single1 := TRUE; |
724 |
select_cheapr1 := TRUE; |
725 |
select_single2 := TRUE; |
726 |
|
727 |
(* Fixed Values *) |
728 |
|
729 |
(* Physical Properties of Components *) |
730 |
|
731 |
f1.stream.state.Cpi['A'] := 0.04 {BTU/mole/K}; |
732 |
f1.stream.state.Cpi['B'] := 0.05 {BTU/mole/K}; |
733 |
f1.stream.state.Cpi['C'] := 0.06 {BTU/mole/K}; |
734 |
f1.stream.state.Cpi['D'] := 0.055 {BTU/mole/K}; |
735 |
|
736 |
(* Feed 1 *) |
737 |
f1.cost_factor := 0.026 {dollar/kg_mole}; |
738 |
|
739 |
(* Feed 2 *) |
740 |
f2.cost_factor := 0.033 {dollar/kg_mole}; |
741 |
|
742 |
(* Cooler 1 *) |
743 |
co1.cost_factor := 0.7e-06 {dollar/kJ}; |
744 |
co1.heat_removed := 100 {BTU/s}; |
745 |
|
746 |
(* Cooler 2 *) |
747 |
co2.heat_removed := 150 {BTU/s}; |
748 |
co2.cost_factor := 0.7e-06 {dollar/kJ}; |
749 |
|
750 |
(* Heater 1 *) |
751 |
h1.heat_supplied := 200 {BTU/s}; |
752 |
h1.cost_factor := 8e-06 {dollar/kJ}; |
753 |
|
754 |
(* Heater 2 *) |
755 |
h2.heat_supplied := 180 {BTU/s}; |
756 |
h2.cost_factor := 8e-06 {dollar/kJ}; |
757 |
|
758 |
(* Heater 3 *) |
759 |
h3.heat_supplied := 190 {BTU/s}; |
760 |
h3.cost_factor := 8e-06 {dollar/kJ}; |
761 |
|
762 |
(* Flash *) |
763 |
fl1.alpha['A'] := 12.0; |
764 |
fl1.alpha['B'] := 10.0; |
765 |
fl1.alpha['C'] := 1.0; |
766 |
fl1.alpha['D'] := 6.0; |
767 |
fl1.vap_to_feed_ratio :=0.9; |
768 |
|
769 |
(* Splitter *) |
770 |
sp1.split[1] := 0.05; |
771 |
|
772 |
(* Mixer *) |
773 |
m1.To := 298 {K}; |
774 |
|
775 |
(* Single Compressor 1 *) |
776 |
c1.cost_factor := 8.33333e-06 {dollar/kJ}; |
777 |
c1.pressure_rate := 2.5; |
778 |
|
779 |
(* Single Compressor 2 *) |
780 |
c2.cost_factor := 8.33333e-06 {dollar/kJ}; |
781 |
c2.pressure_rate := 1.5; |
782 |
|
783 |
(* Staged Compressor 1 *) |
784 |
s1.cost_factor_work := 8.33333e-06 {dollar/kJ}; |
785 |
s1.cost_factor_heat := 0.7e-06 {dollar/kJ}; |
786 |
s1.pressure_rate := 2.5; |
787 |
s1.n_stages := 2.0; |
788 |
|
789 |
(* Staged Compressor 2 *) |
790 |
s2.cost_factor_work := 8.33333e-06 {dollar/kJ}; |
791 |
s2.cost_factor_heat := 0.7e-06 {dollar/kJ}; |
792 |
s2.pressure_rate := 1.5; |
793 |
s2.n_stages := 2.0; |
794 |
|
795 |
(* Reactor 1 *) |
796 |
r1.stoich_coef['A']:= -1; |
797 |
r1.stoich_coef['B']:= -1; |
798 |
r1.stoich_coef['C']:= 1; |
799 |
r1.stoich_coef['D']:= 0; |
800 |
r1.low_turnover := 0.0069 {kg_mole/s}; |
801 |
|
802 |
(* Reactor 2 *) |
803 |
r2.stoich_coef['A']:= -1; |
804 |
r2.stoich_coef['B']:= -1; |
805 |
r2.stoich_coef['C']:= 1; |
806 |
r2.stoich_coef['D']:= 0; |
807 |
r2.high_turnover := 0.00828 {kg_mole/s}; |
808 |
|
809 |
(* Initial Guess *) |
810 |
|
811 |
(* Flash *) |
812 |
fl1.ave_alpha := 5.0; |
813 |
|
814 |
END values; |
815 |
|
816 |
METHOD configuration2; |
817 |
(* alternative configuration *) |
818 |
select_feed1 := FALSE; |
819 |
select_single1 := FALSE; |
820 |
select_cheapr1 := FALSE; |
821 |
select_single2 := FALSE; |
822 |
END configuration2; |
823 |
|
824 |
METHOD configuration3; |
825 |
(* alternative configuration *) |
826 |
select_feed1 := FALSE; |
827 |
select_single1 := TRUE; |
828 |
select_cheapr1 := TRUE; |
829 |
select_single2 := FALSE; |
830 |
END configuration3; |
831 |
|
832 |
END test_flowsheet; |
833 |
|
834 |
|
835 |
(* |
836 |
* when_demo.a4c |
837 |
* by Vicente Rico-Ramirez |
838 |
* Part of the ASCEND Library |
839 |
* $Date: 1998/06/17 19:15:07 $ |
840 |
* $Revision: 1.6 $ |
841 |
* $Author: mthomas $ |
842 |
* $Source: /afs/cs.cmu.edu/project/ascend/Repository/models/when_demo.a4c,v $ |
843 |
* |
844 |
* This file is part of the ASCEND Modeling Library. |
845 |
* |
846 |
* Copyright (C) 1998 Carnegie Mellon University |
847 |
* |
848 |
* The ASCEND Modeling Library is free software; you can redistribute |
849 |
* it and/or modify it under the terms of the GNU General Public |
850 |
* License as published by the Free Software Foundation; either |
851 |
* version 2 of the License, or (at your option) any later version. |
852 |
* |
853 |
* The ASCEND Modeling Library is distributed in hope that it will be |
854 |
* useful, but WITHOUT ANY WARRANTY; without even the implied |
855 |
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
856 |
* See the GNU General Public License for more details. |
857 |
* |
858 |
* You should have received a copy of the GNU General Public License |
859 |
* along with the program; if not, write to the Free Software |
860 |
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139 USA. Check |
861 |
* the file named COPYING. |
862 |
*) |