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

Contents of /trunk/models/simpleflowsheet01.a4c

Parent Directory Parent Directory | Revision Log Revision Log


Revision 457 - (show annotations) (download) (as text)
Wed Apr 5 14:19:41 2006 UTC (18 years, 2 months ago) by aw0a
File MIME type: text/x-ascend
File size: 9120 byte(s)
modified 2_cis_hexene data in components.a4l, updated simpleflowsheetrigorous.a4c
1 REQUIRE "atoms.a4l";
2 (* => atoms.a4l, measures.a4l, system.a4l, basemodel.a4l *)
3 PROVIDE "simpleflowsheet01.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 * simpleflowsheet.a4s.
10 *)
11
12 (*
13
14 The following example illustrates equation based modeling using the
15 ASCEND system. The process is a simple recycle process.
16
17
18
19 -------
20 | |
21 ----------------------| split |----> purge
22 | | |
23 | -------
24 | ^
25 v |
26 ----- --------- -------
27 | | | | | |
28 ----->| mix |--->| reactor |--->| flash |
29 | | | | | |
30 ----- --------- -------
31 |
32 |
33 -----> C
34
35 This model requires: "system.a4l"
36 "atoms.a4l"
37 *)
38
39
40 (* ************************************************* *)
41
42
43 MODEL mixture;
44
45 components IS_A set OF symbol_constant;
46 y[components] IS_A fraction;
47
48 SUM[y[i] | i IN components] = 1.0;
49
50 METHODS
51
52 METHOD default_self;
53 END default_self;
54
55 METHOD specify;
56 y[components].fixed := TRUE;
57 y[CHOICE[components]].fixed := FALSE;
58 END specify;
59
60 METHOD reset;
61 RUN ClearAll;
62 RUN specify;
63 END reset;
64
65 END mixture;
66
67 (* ************************************************* *)
68
69
70 MODEL molar_stream;
71
72 components IS_A set OF symbol_constant;
73 state IS_A mixture;
74 Ftot,f[components] IS_A molar_rate;
75
76 components, state.components ARE_THE_SAME;
77
78
79 FOR i IN components CREATE
80 f_def[i]: f[i] = Ftot*state.y[i];
81 END FOR;
82
83 METHODS
84
85 METHOD default_self;
86 END default_self;
87
88 METHOD seqmod;
89 RUN state.specify;
90 state.y[components].fixed := FALSE;
91 END seqmod;
92
93 METHOD specify;
94 RUN seqmod;
95 f[components].fixed := TRUE;
96 END specify;
97
98 METHOD reset;
99 RUN ClearAll;
100 RUN specify;
101 END reset;
102
103 METHOD scale;
104 FOR i IN components DO
105 f[i].nominal := f[i] + 0.1{mol/s};
106 END FOR;
107 Ftot.nominal := Ftot + 0.1{mol/s};
108 END scale;
109
110 END molar_stream;
111
112 (* ************************************************* *)
113
114
115 MODEL mixer;
116
117 n_inputs IS_A integer_constant;
118 feed[1..n_inputs], out IS_A molar_stream;
119
120 feed[1..n_inputs].components,
121 out.components ARE_THE_SAME;
122
123 FOR i IN out.components CREATE
124 cmb[i]: out.f[i] = SUM[feed[1..n_inputs].f[i]];
125 END FOR;
126
127 METHODS
128
129 METHOD default_self;
130 END default_self;
131
132 METHOD seqmod;
133 END seqmod;
134
135 METHOD specify;
136 RUN seqmod;
137 RUN feed[1..n_inputs].specify;
138 END specify;
139
140 METHOD reset;
141 RUN ClearAll;
142 RUN specify;
143 END reset;
144
145 METHOD scale;
146 RUN feed[1..n_inputs].scale;
147 RUN out.scale;
148 END scale;
149
150 END mixer;
151
152 (* ************************************************* *)
153
154
155 MODEL reactor;
156
157 feed, out IS_A molar_stream;
158 feed.components, out.components ARE_THE_SAME;
159
160 turnover IS_A molar_rate;
161 stoich_coef[feed.components] IS_A factor;
162
163 FOR i IN feed.components CREATE
164 out.f[i] = feed.f[i] + stoich_coef[i]*turnover;
165 END FOR;
166
167 METHODS
168
169 METHOD default_self;
170 END default_self;
171
172 METHOD seqmod;
173 turnover.fixed := TRUE;
174 stoich_coef[feed.components].fixed := TRUE;
175 END seqmod;
176
177 METHOD specify;
178 RUN seqmod;
179 RUN feed.specify;
180 END specify;
181
182 METHOD reset;
183 RUN ClearAll;
184 RUN specify;
185 END reset;
186
187 METHOD scale;
188 RUN feed.scale;
189 RUN out.scale;
190 turnover.nominal := turnover.nominal+0.0001 {kg_mole/s};
191 END scale;
192
193 END reactor;
194
195 (* ************************************************* *)
196
197
198 MODEL flash;
199
200 feed,vap,liq IS_A molar_stream;
201
202 feed.components,
203 vap.components,
204 liq.components ARE_THE_SAME;
205
206 alpha[feed.components],
207 ave_alpha IS_A factor;
208
209 vap_to_feed_ratio IS_A fraction;
210
211 vap_to_feed_ratio*feed.Ftot = vap.Ftot;
212
213 FOR i IN feed.components CREATE
214 cmb[i]: feed.f[i] = vap.f[i] + liq.f[i];
215 eq[i]: vap.state.y[i]*ave_alpha = alpha[i]*liq.state.y[i];
216 END FOR;
217
218 METHODS
219
220 METHOD default_self;
221 END default_self;
222
223 METHOD seqmod;
224 alpha[feed.components].fixed := TRUE;
225 vap_to_feed_ratio.fixed := TRUE;
226 END seqmod;
227
228 METHOD specify;
229 RUN seqmod;
230 RUN feed.specify;
231 END specify;
232
233 METHOD reset;
234 RUN ClearAll;
235 RUN specify;
236 END reset;
237
238 METHOD scale;
239 RUN feed.scale;
240 RUN vap.scale;
241 RUN liq.scale;
242 END scale;
243
244 END flash;
245
246 (* ************************************************* *)
247
248
249 MODEL splitter;
250
251 n_outputs IS_A integer_constant;
252 feed, out[1..n_outputs] IS_A molar_stream;
253 split[1..n_outputs] IS_A fraction;
254
255 feed.components, out[1..n_outputs].components ARE_THE_SAME;
256
257 feed.state,
258 out[1..n_outputs].state ARE_THE_SAME;
259
260 FOR j IN [1..n_outputs] CREATE
261 out[j].Ftot = split[j]*feed.Ftot;
262 END FOR;
263
264 SUM[split[1..n_outputs]] = 1.0;
265
266 METHODS
267
268 METHOD default_self;
269 END default_self;
270
271 METHOD seqmod;
272 split[1..n_outputs-1].fixed := TRUE;
273 END seqmod;
274
275 METHOD specify;
276 RUN seqmod;
277 RUN feed.specify;
278 END specify;
279
280 METHOD reset;
281 RUN ClearAll;
282 RUN specify;
283 END reset;
284
285 METHOD scale;
286 RUN feed.scale;
287 RUN out[1..n_outputs].scale;
288 END scale;
289
290 END splitter;
291
292 (* ************************************************* *)
293
294
295 MODEL flowsheet;
296
297 m1 IS_A mixer;
298 r1 IS_A reactor;
299 fl1 IS_A flash;
300 sp1 IS_A splitter;
301
302 (* define sets *)
303
304 m1.n_inputs :== 2;
305 sp1.n_outputs :== 2;
306
307 (* wire up flowsheet *)
308
309 m1.out, r1.feed ARE_THE_SAME;
310 r1.out, fl1.feed ARE_THE_SAME;
311 fl1.vap, sp1.feed ARE_THE_SAME;
312 sp1.out[2], m1.feed[2] ARE_THE_SAME;
313
314 METHODS
315
316 METHOD default_self;
317 END default_self;
318
319 METHOD seqmod;
320 RUN m1.seqmod;
321 RUN r1.seqmod;
322 RUN fl1.seqmod;
323 RUN sp1.seqmod;
324 END seqmod;
325
326 METHOD specify;
327 RUN seqmod;
328 RUN m1.feed[1].specify;
329 END specify;
330
331 METHOD reset;
332 RUN ClearAll;
333 RUN specify;
334 END reset;
335
336 METHOD scale;
337 RUN m1.scale;
338 RUN r1.scale;
339 RUN fl1.scale;
340 RUN sp1.scale;
341 END scale;
342
343 END flowsheet;
344
345 (* ************************************************* *)
346
347
348 MODEL controller;
349
350 fs IS_A flowsheet;
351 conv IS_A fraction;
352 key_components IS_A symbol_constant;
353 fs.r1.out.f[key_components] = (1 - conv)*fs.r1.feed.f[key_components];
354
355 METHODS
356
357 METHOD default_self;
358 END default_self;
359
360 METHOD specify;
361 RUN fs.specify;
362 fs.r1.turnover.fixed := FALSE;
363 conv.fixed := TRUE;
364 END specify;
365
366 METHOD reset;
367 RUN ClearAll;
368 RUN specify;
369 END reset;
370
371 METHOD scale;
372 RUN fs.scale;
373 END scale;
374
375 END controller;
376
377 (* ************************************************* *)
378
379
380 MODEL test_flowsheet REFINES flowsheet;
381
382 m1.out.components :== ['A','B','C'];
383
384 METHODS
385
386 METHOD default_self;
387 (* no-op. here to avoid STOP statement. *)
388 END default_self;
389
390 METHOD values;
391 m1.feed[1].f['A'] := 0.005 {kg_mole/s};
392 m1.feed[1].f['B'] := 0.095 {kg_mole/s};
393 m1.feed[1].f['C'] := 0.0 {kg_mole/s};
394
395 r1.stoich_coef['A'] := 0;
396 r1.stoich_coef['B'] := -1;
397 r1.stoich_coef['C'] := 1;
398
399 fl1.alpha['A'] := 12.0;
400 fl1.alpha['B'] := 10.0;
401 fl1.alpha['C'] := 1.0;
402 fl1.vap_to_feed_ratio := 0.9;
403 fl1.ave_alpha := 5.0;
404
405 sp1.split[1] := 0.01;
406
407 fl1.liq.Ftot := m1.feed[1].f['B'];
408 END values;
409
410 END test_flowsheet;
411
412 (* ************************************************* *)
413
414
415 MODEL test_controller REFINES controller;
416
417 fs IS_REFINED_TO test_flowsheet;
418 key_components :== 'B';
419
420 METHODS
421
422 METHOD default_self;
423 (* no-op. here to avoid STOP statement. *)
424 END default_self;
425
426 METHOD values;
427 RUN fs.values;
428 conv := 0.07;
429 END values;
430
431 END test_controller;
432
433
434 (*
435 * simpleflowsheet01.a4c
436 * by Arthur W. Westerberg
437 * Part of the ASCEND Library
438 * $Date: 2006.03.03 10:29:34
439 *
440 * This file is part of the ASCEND Modeling Library.
441 *
442 * Copyright (C) 1994 - 1998 Carnegie Mellon University
443 *
444 * The ASCEND Modeling Library is free software; you can redistribute
445 * it and/or modify it under the terms of the GNU General Public
446 * License as published by the Free Software Foundation; either
447 * version 2 of the License, or (at your option) any later version.
448 *
449 * The ASCEND Modeling Library is distributed in hope that it
450 * will be useful, but WITHOUT ANY WARRANTY; without even the implied
451 * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
452 * See the GNU General Public License for more details.
453 *
454 * You should have received a copy of the GNU General Public License
455 * along with the program; if not, write to the Free Software
456 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139 USA. Check
457 * the file named COPYING.
458 *)

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