/[ascend]/branches/ksenija2/models/splitter.a4l
ViewVC logotype

Contents of /branches/ksenija2/models/splitter.a4l

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2835 - (show annotations) (download) (as text)
Tue Feb 17 07:31:55 2015 UTC (4 years, 9 months ago) by jpye
File MIME type: text/x-ascend
File size: 9783 byte(s)
recreating ksenija2 branch from current HEAD, r2824.

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 this program. If not, see <http://www.gnu.org/licenses/>.
31 *)
32
33
34 (* splitter and splitter_with_shared_state *)
35
36 (* Both model a simple stream splitter, a unit that splits a stream
37 * into n_outs other streams. *)
38
39 (* MODEL splitter *)
40
41 (* In this unit the user should create and pass in the feed and all
42 * output streams. The unit creates equations to set the pressure,
43 * temperature and the mole fractions of the feed equal to the
44 * pressure, temperature and mole fractions of the output streams.
45 * Each stream has it own state and its own physical property
46 * calculation. If there is only one output stream, this unit can be
47 * used to change the option used to compute the mixture physical
48 * properties for the stream. For example, the feed stream could
49 * compute liquid mixture properties using Unifac_liquid_mixture while
50 * the output stream could use Wilson_liquid_mixture. *)
51
52 (* MODEL splitter_with_shared_state *)
53
54 (* In this unit the user should create and pass in only the feed to
55 * the unit. This unit creates its own output streams -- UNLIKE ANY
56 * OTHER UNIT. The output streams are created to share the state of
57 * the feed stream. To make the output streams accessible locally in
58 * the model for which this splitter is a part, the user should include
59 * the statement similar to the following to alias the output streams
60 * to the outer scope: *)
61
62 (* out ALIASES spl1.out; *)
63
64 (* where spl1 is the name of the instance of the splitter. We
65 * consider this to be 'expert behavior' but the splitter is a
66 * difficult unit -- conceptually. *)
67
68
69 (* ****************************************************************** *)
70
71 (* base_splitter. No one should create a model of this type. It is
72 * here only to provide a common ancestry for the two splitter
73 * models. *)
74
75 MODEL base_splitter;
76 END base_splitter;
77
78 (* ****************************************************************** *)
79
80 MODEL splitter(
81 feed WILL_BE stream;
82 n_outs WILL_BE integer_constant;
83 out[1..n_outs] WILL_BE stream;
84 ) WHERE (
85 feed, out[1..n_outs] WILL_NOT_BE_THE_SAME;
86 )
87 REFINES base_splitter;
88
89
90 FOR j IN [1..n_outs] CREATE
91 FOR i IN feed.cd.other_components CREATE
92 y_eqns[i][j]: out[j].y[i] = feed.y[i];
93 END FOR;
94 END FOR;
95
96 FOR j IN [1..n_outs] CREATE
97 P_set[j]: out[j].P = feed.P;
98 T_set[j]: out[j].T = feed.T;
99 END FOR;
100
101 split[1..n_outs] IS_A fraction;
102 sum_splits: SUM[split[1..n_outs]] = 1;
103
104 FOR k IN [1..n_outs] CREATE
105 split_flows[k]: out[k].flow = split[k]*feed.flow;
106 END FOR;
107
108 METHODS
109
110 METHOD check_self;
111 RUN check_all;
112 END check_self;
113
114 METHOD check_all;
115 RUN feed.check_all;
116 RUN out[1..n_outs].check_all;
117 END check_all;
118
119 METHOD default_self;
120 END default_self;
121
122 METHOD default_all;
123 RUN feed.default_all;
124 RUN out[1..n_outs].default_all;
125 END default_all;
126
127 METHOD bound_self;
128 END bound_self;
129
130 METHOD bound_all;
131 RUN feed.bound_all;
132 RUN out[1..n_outs].bound_all;
133 END bound_all;
134
135 METHOD scale_self;
136 END scale_self;
137
138 METHOD scale_all;
139 RUN feed.scale_all;
140 RUN out[1..n_outs].scale_all;
141 END scale_all;
142
143 METHOD seqmod;
144 FIX split[1..n_outs-1];
145 RUN out[1..n_outs].specify;
146 FREE out[1..n_outs].P;
147 FREE out[1..n_outs].T;
148 FREE out[1..n_outs].f[feed.cd.components];
149 END seqmod;
150
151 METHOD specify;
152 RUN seqmod;
153 RUN feed.specify;
154 END specify;
155
156 END splitter;
157
158 (* ****************************************************************** *)
159
160 MODEL splitter_with_shared_state(
161 feed WILL_BE stream;
162 n_outs WILL_BE integer_constant;
163 ) REFINES base_splitter;
164
165 state ALIASES feed.Details.state;
166 out[1..n_outs] IS_A detailed_stream(state);
167 split[1..n_outs] IS_A fraction;
168 sum_splits: SUM[split[1..n_outs]] = 1;
169 FOR k IN [1..n_outs] CREATE
170 split_flows[k]: out[k].flow = split[k]*feed.flow;
171 END FOR;
172
173 METHODS
174 METHOD check_self;
175 RUN check_all;
176 END check_self;
177
178 METHOD check_all;
179 RUN feed.check_all;
180 RUN out[1..n_outs].check_all;
181 END check_all;
182
183 METHOD default_self;
184 RUN out[1..n_outs].default_all;
185 END default_self;
186
187 METHOD default_all;
188 RUN feed.default_all;
189 RUN out[1..n_outs].default_all;
190 END default_all;
191
192 METHOD bound_self;
193 RUN out[1..n_outs].bound_all;
194 END bound_self;
195
196 METHOD bound_all;
197 RUN feed.bound_all;
198 RUN out[1..n_outs].bound_all;
199 END bound_all;
200
201 METHOD scale_self;
202 RUN out[1..n_outs].scale_all;
203 END scale_self;
204
205 METHOD scale_all;
206 RUN feed.scale_all;
207 RUN out[1..n_outs].scale_all;
208 END scale_all;
209
210 METHOD seqmod;
211 FIX split[1..n_outs-1];
212 RUN out[1..n_outs].specify;
213 FREE out[1..n_outs].P;
214 FREE out[1..n_outs].T;
215 FREE out[1..n_outs].f[feed.cd.components];
216 END seqmod;
217
218 METHOD specify;
219 RUN seqmod;
220 RUN feed.specify;
221 END specify;
222
223 END splitter_with_shared_state;
224
225 (* ****************************************************************** *)
226 (* ********************** test splitter models ********************** *)
227 (* ****************************************************************** *)
228
229 MODEL test_splitter;
230
231 cd IS_A components_data(['methanol','ethanol','water'],'water');
232 pdV IS_A phases_data('V', 'Pitzer_vapor_mixture', 'none', 'none');
233 pdL IS_A phases_data('L', 'none', 'UNIFAC_liquid_mixture','none');
234 pdVL IS_A phases_data('VL', 'Pitzer_vapor_mixture',
235 'UNIFAC_liquid_mixture', 'none');
236 equil IS_A boolean;
237
238 spl1_feed IS_A stream(cd, pdVL, equil);
239
240 n_outs IS_A integer_constant;
241 n_outs :== 2;
242 spl1_out[1..n_outs] IS_A stream(cd, pdVL, equil);
243 spl1 IS_A splitter(spl1_feed, n_outs, spl1_out);
244
245 METHODS
246 METHOD check_self;
247 RUN check_all;
248 END check_self;
249
250 METHOD check_all;
251 RUN spl1.check_all;
252 END check_all;
253
254 METHOD default_self;
255 RUN default_all;
256 END default_self;
257
258 METHOD default_all;
259 RUN spl1.default_all;
260 END default_all;
261
262 METHOD bound_self;
263 RUN bound_all;
264 END bound_self;
265
266 METHOD bound_all;
267 RUN spl1.bound_all;
268 END bound_all;
269
270 METHOD scale_self;
271 RUN scale_all;
272 END scale_self;
273
274 METHOD scale_all;
275 RUN spl1.scale_all;
276 END scale_all;
277
278 METHOD specify;
279 RUN spl1.specify;
280 END specify;
281
282 METHOD values;
283 spl1_feed.P := 1 {atm};
284 spl1_feed.T := 350 {K};
285 spl1_feed.f['methanol'] := 0.01 {kmol/s};
286 spl1_feed.f['ethanol'] := 0.015 {kmol/s};
287 spl1_feed.f['water'] := 0.02 {kmol/s};
288 spl1_feed.phase['vapor'].alpha['methanol'] := 2.1;
289 spl1_feed.phase['vapor'].alpha['ethanol'] := 1.6;
290 spl1_feed.phase['vapor'].alpha['water'] := 0.9;
291 spl1_out[1..n_outs].phase['vapor'].alpha['methanol'] := 2.1;
292 spl1_out[1..n_outs].phase['vapor'].alpha['ethanol'] := 1.6;
293 spl1_out[1..n_outs].phase['vapor'].alpha['water'] := 0.9;
294 spl1.split[1] := 0.5;
295 spl1.split[2] := 0.5;
296 equil := FALSE;
297 END values;
298
299 END test_splitter;
300
301 (* ****************************************************************** *)
302
303 MODEL test_splitter_with_shared_state;
304
305 cd IS_A components_data(['methanol','ethanol','water'],'water');
306 pdV IS_A phases_data('V', 'Pitzer_vapor_mixture', 'none', 'none');
307 pdL IS_A phases_data('L', 'none', 'UNIFAC_liquid_mixture','none');
308 pdVL IS_A phases_data('VL', 'Pitzer_vapor_mixture',
309 'UNIFAC_liquid_mixture', 'none');
310 equil IS_A boolean;
311 n_outs IS_A integer_constant;
312 n_outs :== 2;
313
314 spl1_feed IS_A stream(cd, pdVL, equil);
315 spl1 IS_A splitter_with_shared_state(spl1_feed, n_outs);
316 spl1_out ALIASES spl1.out;
317
318 METHODS
319
320 METHOD check_self;
321 RUN spl1_feed.check_all;
322 END check_self;
323
324 METHOD check_all;
325 RUN spl1.check_all;
326 END check_all;
327
328 METHOD default_self;
329 RUN spl1_feed.default_all;
330 END default_self;
331
332 METHOD default_all;
333 RUN spl1.default_all;
334 END default_all;
335
336 METHOD bound_self;
337 RUN spl1_feed.bound_all;
338 END bound_self;
339
340 METHOD bound_all;
341 RUN spl1.bound_all;
342 END bound_all;
343
344 METHOD scale_self;
345 RUN spl1_feed.scale_all;
346 END scale_self;
347
348 METHOD scale_all;
349 RUN spl1.scale_all;
350 END scale_all;
351
352 METHOD specify;
353 RUN spl1.specify;
354 END specify;
355
356 METHOD values;
357 spl1_feed.P := 1 {atm};
358 spl1_feed.T := 365 {K};
359 spl1_feed.f['methanol'] := 0.01 {kmol/s};
360 spl1_feed.f['ethanol'] := 0.015 {kmol/s};
361 spl1_feed.f['water'] := 0.02 {kmol/s};
362 spl1_feed.phase['vapor'].alpha['methanol'] := 2.1;
363 spl1_feed.phase['vapor'].alpha['ethanol'] := 1.6;
364 spl1_feed.phase['vapor'].alpha['water'] := 0.9;
365 spl1.split[1] := 0.5;
366 spl1.split[2] := 0.5;
367 equil := FALSE;
368 END values;
369
370 END test_splitter_with_shared_state;

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