/[ascend]/trunk/models/splitter.a4l
ViewVC logotype

Contents of /trunk/models/splitter.a4l

Parent Directory Parent Directory | Revision Log Revision Log


Revision 576 - (show annotations) (download) (as text)
Tue May 9 03:42:08 2006 UTC (13 years, 7 months ago) by johnpye
File MIME type: text/x-ascend
File size: 9868 byte(s)
Changed all cases of *.fixed := {TRUE,FALSE} to 'FIX' and 'FREE' statements.
1 REQUIRE "stream_holdup.a4l";
2 (* => stream_holdup.a4l, thermodynamics.a4l, components.a4l, phases.a4l,
3 * atoms.a4l, measures.a4l, system.a4l, basemodel.a4l *)
4 PROVIDE "splitter.a4l";
5
6 (*
7 * splitter.a4l
8 * by Ben Allan
9 * Part of the ASCEND Library
10 * $Date: 1998/06/23 15:26:24 $
11 * $Revision: 1.3 $
12 * $Author: ballan $
13 * $Source: /afs/cs.cmu.edu/project/ascend/Repository/models/splitter.a4l,v $
14 *
15 * This file is part of the ASCEND Modeling Library.
16 *
17 * Copyright (C) 1998 Carnegie Mellon University
18 *
19 * The ASCEND Modeling Library is free software; you can redistribute
20 * it and/or modify it under the terms of the GNU General Public
21 * License as published by the Free Software Foundation; either
22 * version 2 of the License, or (at your option) any later version.
23 *
24 * The ASCEND Modeling Library is distributed in hope that it
25 * will be useful, but WITHOUT ANY WARRANTY; without even the implied
26 * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
27 * See the GNU General Public License for more details.
28 *
29 * You should have received a copy of the GNU General Public License
30 * along with the program; if not, write to the Free Software
31 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139 USA. Check
32 * the file named COPYING.
33 *)
34
35
36 (* splitter and splitter_with_shared_state *)
37
38 (* Both model a simple stream splitter, a unit that splits a stream
39 * into n_outs other streams. *)
40
41 (* MODEL splitter *)
42
43 (* In this unit the user should create and pass in the feed and all
44 * output streams. The unit creates equations to set the pressure,
45 * temperature and the mole fractions of the feed equal to the
46 * pressure, temperature and mole fractions of the output streams.
47 * Each stream has it own state and its own physical property
48 * calculation. If there is only one output stream, this unit can be
49 * used to change the option used to compute the mixture physical
50 * properties for the stream. For example, the feed stream could
51 * compute liquid mixture properties using Unifac_liquid_mixture while
52 * the output stream could use Wilson_liquid_mixture. *)
53
54 (* MODEL splitter_with_shared_state *)
55
56 (* In this unit the user should create and pass in only the feed to
57 * the unit. This unit creates its own output streams -- UNLIKE ANY
58 * OTHER UNIT. The output streams are created to share the state of
59 * the feed stream. To make the output streams accessible locally in
60 * the model for which this splitter is a part, the user should include
61 * the statement similar to the following to alias the output streams
62 * to the outer scope: *)
63
64 (* out ALIASES spl1.out; *)
65
66 (* where spl1 is the name of the instance of the splitter. We
67 * consider this to be 'expert behavior' but the splitter is a
68 * difficult unit -- conceptually. *)
69
70
71 (* ****************************************************************** *)
72
73 (* base_splitter. No one should create a model of this type. It is
74 * here only to provide a common ancestry for the two splitter
75 * models. *)
76
77 MODEL base_splitter;
78 END base_splitter;
79
80 (* ****************************************************************** *)
81
82 MODEL splitter(
83 feed WILL_BE stream;
84 n_outs WILL_BE integer_constant;
85 out[1..n_outs] WILL_BE stream;
86 ) WHERE (
87 feed, out[1..n_outs] WILL_NOT_BE_THE_SAME;
88 )
89 REFINES base_splitter;
90
91
92 FOR j IN [1..n_outs] CREATE
93 FOR i IN feed.cd.other_components CREATE
94 y_eqns[i][j]: out[j].y[i] = feed.y[i];
95 END FOR;
96 END FOR;
97
98 FOR j IN [1..n_outs] CREATE
99 P_set[j]: out[j].P = feed.P;
100 T_set[j]: out[j].T = feed.T;
101 END FOR;
102
103 split[1..n_outs] IS_A fraction;
104 sum_splits: SUM[split[1..n_outs]] = 1;
105
106 FOR k IN [1..n_outs] CREATE
107 split_flows[k]: out[k].flow = split[k]*feed.flow;
108 END FOR;
109
110 METHODS
111
112 METHOD check_self;
113 RUN check_all;
114 END check_self;
115
116 METHOD check_all;
117 RUN feed.check_all;
118 RUN out[1..n_outs].check_all;
119 END check_all;
120
121 METHOD default_self;
122 END default_self;
123
124 METHOD default_all;
125 RUN feed.default_all;
126 RUN out[1..n_outs].default_all;
127 END default_all;
128
129 METHOD bound_self;
130 END bound_self;
131
132 METHOD bound_all;
133 RUN feed.bound_all;
134 RUN out[1..n_outs].bound_all;
135 END bound_all;
136
137 METHOD scale_self;
138 END scale_self;
139
140 METHOD scale_all;
141 RUN feed.scale_all;
142 RUN out[1..n_outs].scale_all;
143 END scale_all;
144
145 METHOD seqmod;
146 FIX split[1..n_outs-1];
147 RUN out[1..n_outs].specify;
148 FREE out[1..n_outs].P;
149 FREE out[1..n_outs].T;
150 FREE out[1..n_outs].f[feed.cd.components];
151 END seqmod;
152
153 METHOD specify;
154 RUN seqmod;
155 RUN feed.specify;
156 END specify;
157
158 END splitter;
159
160 (* ****************************************************************** *)
161
162 MODEL splitter_with_shared_state(
163 feed WILL_BE stream;
164 n_outs WILL_BE integer_constant;
165 ) REFINES base_splitter;
166
167 state ALIASES feed.Details.state;
168 out[1..n_outs] IS_A detailed_stream(state);
169 split[1..n_outs] IS_A fraction;
170 sum_splits: SUM[split[1..n_outs]] = 1;
171 FOR k IN [1..n_outs] CREATE
172 split_flows[k]: out[k].flow = split[k]*feed.flow;
173 END FOR;
174
175 METHODS
176 METHOD check_self;
177 RUN check_all;
178 END check_self;
179
180 METHOD check_all;
181 RUN feed.check_all;
182 RUN out[1..n_outs].check_all;
183 END check_all;
184
185 METHOD default_self;
186 RUN out[1..n_outs].default_all;
187 END default_self;
188
189 METHOD default_all;
190 RUN feed.default_all;
191 RUN out[1..n_outs].default_all;
192 END default_all;
193
194 METHOD bound_self;
195 RUN out[1..n_outs].bound_all;
196 END bound_self;
197
198 METHOD bound_all;
199 RUN feed.bound_all;
200 RUN out[1..n_outs].bound_all;
201 END bound_all;
202
203 METHOD scale_self;
204 RUN out[1..n_outs].scale_all;
205 END scale_self;
206
207 METHOD scale_all;
208 RUN feed.scale_all;
209 RUN out[1..n_outs].scale_all;
210 END scale_all;
211
212 METHOD seqmod;
213 FIX split[1..n_outs-1];
214 RUN out[1..n_outs].specify;
215 FREE out[1..n_outs].P;
216 FREE out[1..n_outs].T;
217 FREE out[1..n_outs].f[feed.cd.components];
218 END seqmod;
219
220 METHOD specify;
221 RUN seqmod;
222 RUN feed.specify;
223 END specify;
224
225 END splitter_with_shared_state;
226
227 (* ****************************************************************** *)
228 (* ********************** test splitter models ********************** *)
229 (* ****************************************************************** *)
230
231 MODEL test_splitter;
232
233 cd IS_A components_data(['methanol','ethanol','water'],'water');
234 pdV IS_A phases_data('V', 'Pitzer_vapor_mixture', 'none', 'none');
235 pdL IS_A phases_data('L', 'none', 'UNIFAC_liquid_mixture','none');
236 pdVL IS_A phases_data('VL', 'Pitzer_vapor_mixture',
237 'UNIFAC_liquid_mixture', 'none');
238 equil IS_A boolean;
239
240 spl1_feed IS_A stream(cd, pdVL, equil);
241
242 n_outs IS_A integer_constant;
243 n_outs :== 2;
244 spl1_out[1..n_outs] IS_A stream(cd, pdVL, equil);
245 spl1 IS_A splitter(spl1_feed, n_outs, spl1_out);
246
247 METHODS
248 METHOD check_self;
249 RUN check_all;
250 END check_self;
251
252 METHOD check_all;
253 RUN spl1.check_all;
254 END check_all;
255
256 METHOD default_self;
257 RUN default_all;
258 END default_self;
259
260 METHOD default_all;
261 RUN spl1.default_all;
262 END default_all;
263
264 METHOD bound_self;
265 RUN bound_all;
266 END bound_self;
267
268 METHOD bound_all;
269 RUN spl1.bound_all;
270 END bound_all;
271
272 METHOD scale_self;
273 RUN scale_all;
274 END scale_self;
275
276 METHOD scale_all;
277 RUN spl1.scale_all;
278 END scale_all;
279
280 METHOD specify;
281 RUN spl1.specify;
282 END specify;
283
284 METHOD values;
285 spl1_feed.P := 1 {atm};
286 spl1_feed.T := 350 {K};
287 spl1_feed.f['methanol'] := 0.01 {kmol/s};
288 spl1_feed.f['ethanol'] := 0.015 {kmol/s};
289 spl1_feed.f['water'] := 0.02 {kmol/s};
290 spl1_feed.phase['vapor'].alpha['methanol'] := 2.1;
291 spl1_feed.phase['vapor'].alpha['ethanol'] := 1.6;
292 spl1_feed.phase['vapor'].alpha['water'] := 0.9;
293 spl1_out[1..n_outs].phase['vapor'].alpha['methanol'] := 2.1;
294 spl1_out[1..n_outs].phase['vapor'].alpha['ethanol'] := 1.6;
295 spl1_out[1..n_outs].phase['vapor'].alpha['water'] := 0.9;
296 spl1.split[1] := 0.5;
297 spl1.split[2] := 0.5;
298 equil := FALSE;
299 END values;
300
301 END test_splitter;
302
303 (* ****************************************************************** *)
304
305 MODEL test_splitter_with_shared_state;
306
307 cd IS_A components_data(['methanol','ethanol','water'],'water');
308 pdV IS_A phases_data('V', 'Pitzer_vapor_mixture', 'none', 'none');
309 pdL IS_A phases_data('L', 'none', 'UNIFAC_liquid_mixture','none');
310 pdVL IS_A phases_data('VL', 'Pitzer_vapor_mixture',
311 'UNIFAC_liquid_mixture', 'none');
312 equil IS_A boolean;
313 n_outs IS_A integer_constant;
314 n_outs :== 2;
315
316 spl1_feed IS_A stream(cd, pdVL, equil);
317 spl1 IS_A splitter_with_shared_state(spl1_feed, n_outs);
318 spl1_out ALIASES spl1.out;
319
320 METHODS
321
322 METHOD check_self;
323 RUN spl1_feed.check_all;
324 END check_self;
325
326 METHOD check_all;
327 RUN spl1.check_all;
328 END check_all;
329
330 METHOD default_self;
331 RUN spl1_feed.default_all;
332 END default_self;
333
334 METHOD default_all;
335 RUN spl1.default_all;
336 END default_all;
337
338 METHOD bound_self;
339 RUN spl1_feed.bound_all;
340 END bound_self;
341
342 METHOD bound_all;
343 RUN spl1.bound_all;
344 END bound_all;
345
346 METHOD scale_self;
347 RUN spl1_feed.scale_all;
348 END scale_self;
349
350 METHOD scale_all;
351 RUN spl1.scale_all;
352 END scale_all;
353
354 METHOD specify;
355 RUN spl1.specify;
356 END specify;
357
358 METHOD values;
359 spl1_feed.P := 1 {atm};
360 spl1_feed.T := 365 {K};
361 spl1_feed.f['methanol'] := 0.01 {kmol/s};
362 spl1_feed.f['ethanol'] := 0.015 {kmol/s};
363 spl1_feed.f['water'] := 0.02 {kmol/s};
364 spl1_feed.phase['vapor'].alpha['methanol'] := 2.1;
365 spl1_feed.phase['vapor'].alpha['ethanol'] := 1.6;
366 spl1_feed.phase['vapor'].alpha['water'] := 0.9;
367 spl1.split[1] := 0.5;
368 spl1.split[2] := 0.5;
369 equil := FALSE;
370 END values;
371
372 END test_splitter_with_shared_state;

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