/[ascend]/trunk/models/simpleFS.V1.a4c
ViewVC logotype

Contents of /trunk/models/simpleFS.V1.a4c

Parent Directory Parent Directory | Revision Log Revision Log


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

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