/[ascend]/trunk/models/when_demo.a4c
ViewVC logotype

Annotation of /trunk/models/when_demo.a4c

Parent Directory Parent Directory | Revision Log Revision Log


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

john.pye@anu.edu.au
ViewVC Help
Powered by ViewVC 1.1.22