/[ascend]/trunk/models/ben/benstream.a4l
ViewVC logotype

Contents of /trunk/models/ben/benstream.a4l

Parent Directory Parent Directory | Revision Log Revision Log


Revision 576 - (show annotations) (download) (as text)
Tue May 9 03:42:08 2006 UTC (18 years, 1 month ago) by johnpye
File MIME type: text/x-ascend
File size: 11928 byte(s)
Changed all cases of *.fixed := {TRUE,FALSE} to 'FIX' and 'FREE' statements.
1 REQUIRE "ben/benHGthermo.a4l";
2 (* --> measures,system,atoms,components, propertyoptions *)
3 PROVIDE "benstream.a4l";
4 (*********************************************************************\
5 stream.lib
6 by Robert S. Huss
7 Part of the Ascend Library
8
9 This file is part of the Ascend modeling library.
10
11 Copyright (C) 1993-1997 Carnegie Mellon University
12
13 The Ascend modeling library is free software; you can redistribute
14 it and/or modify it under the terms of the GNU General Public License as
15 published by the Free Software Foundation; either version 2 of the
16 License, or (at your option) any later version.
17
18 The Ascend Language Interpreter is distributed in hope that it will be
19 useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
20 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
21 General Public License for more details.
22
23 You should have received a copy of the GNU General Public License along with
24 the program; if not, write to the Free Software Foundation, Inc., 675
25 Mass Ave, Cambridge, MA 02139 USA. Check the file named COPYING.
26
27 \*********************************************************************)
28
29 (*********************************************************************\
30 $Date: 1998/06/01 15:43:30 $
31 $Revision: 1.1 $
32 $Author: ballan $
33 $Source: /afs/cs.cmu.edu/project/ascend/Repository/models/ben/benstream.a4l,v $
34 \*********************************************************************)
35 (*
36 S T R E A M . L I B
37 -------------------
38
39 AUTHOR: Robert S. Huss
40
41 DATES: 5/93 - Original code.
42 9/93 - Slight changes to original code,
43 added vapor_liquid_stream model.
44 6/94 - Made compatible with ASCEND3C
45 8/94 - Made compatible with H_G_thermodynamics.lib.
46 Can still be used with H_S_thermodynamics.lib
47 3/95 - Added relation scaling for absolute convergence
48
49 CONTENTS: Stream definitions, ranging from a simple molar
50 stream to a thermodynamic multiphase stream.
51 Molar stream can be refined to include
52 thermodynamic models, if data are available
53 for each component.
54
55 *)
56
57
58 (* ***********************************+************************************ *)
59 (* ******************** Stream definitions ********************* *)
60 (* ***********************************+************************************ *)
61 MODEL stream_base(
62 ) REFINES cmumodel();
63 (*
64 NOTES inline SELF {
65 Provides common ancestor FOR streams.
66 NEVER CREATE one OF these
67 }
68 END NOTES;
69 *)
70 END stream_base;
71
72 (* ***********************************+************************************ *)
73 (* ******************** homogeneous_molar_stream ********************* *)
74 (* ***********************************+************************************ *)
75
76
77 MODEL homogeneous_molar_stream(
78 state WILL_BE homogeneous_mixture;
79 ) REFINES stream_base;
80
81 components ALIASES state.options.ds.components;
82 Ftot, f[components] IS_A molar_rate;
83 boundwidth IS_A bound_width;
84 Ftot_scale IS_A real;
85
86
87 FOR i IN components CREATE
88 f_def[i]: f[i]/Ftot_scale = Ftot*state.y[i]/Ftot_scale;
89 END FOR;
90
91 METHODS
92 METHOD defaults;
93 Ftot_scale := 1000 {mole/s};
94 (* horrible scaling method - global var, ack! *)
95 END defaults;
96
97 METHOD clear;
98 RUN state.clear;
99 FREE Ftot;
100 FREE f[components];
101 f_def[components].included:= TRUE;
102 END clear;
103
104 METHOD seqmod;
105 RUN state.specify;
106 FREE state.y[components];
107 END seqmod;
108
109 METHOD specify;
110 RUN seqmod;
111 FIX f[components];
112 END specify;
113
114 METHOD reset;
115 RUN clear;
116 RUN specify;
117 END reset;
118
119 METHOD scale;
120 RUN state.scale;
121 FOR i IN components DO
122 f[i].nominal := f[i] + 0.1{mol/s};
123 f[i].upper_bound := f[i] + boundwidth*f[i].nominal;
124 END FOR;
125 Ftot.nominal := Ftot + 0.1{mol/s};
126 Ftot.upper_bound := Ftot + boundwidth*Ftot.nominal;
127 Ftot_scale := Ftot.nominal;
128 END scale;
129 END homogeneous_molar_stream;
130
131
132 (* ***********************************+************************************ *)
133 (* ********************homogeous_thermodynamic_stream ********************* *)
134 (* ***********************************+************************************ *)
135
136 MODEL homogeneous_td_stream(
137 state WILL_BE homogeneous_mixture;
138 ) REFINES homogeneous_molar_stream;
139 (*
140 NOTES inline SELF {
141 td_stream here does NOT denote that the state is a td_homo or td_hetero
142 mixture. It merely indicates that total H is computed so that certain
143 thermodynamic principles may be applied using this type of stream.
144 state.H may be an arbitrary number if the state does not compute
145 it from some correlation.
146 }
147 END NOTES;
148 *)
149
150 H ALIASES state.H;
151 Htot IS_A energy_rate;
152 Htot_scale IS_A real;
153
154 Htot_def: Htot/Htot_scale = H*Ftot/Htot_scale;
155
156
157 METHODS
158 METHOD defaults;
159 RUN homogeneous_molar_stream::defaults;
160 Htot_scale := 1{MW};
161 END defaults;
162 METHOD clear;
163 RUN state.clear;
164 FREE Ftot;
165 FREE f[components];
166 FREE Htot;
167 FREE H;
168 f_def[components].included := TRUE;
169 Htot_def.included := TRUE;
170 END clear;
171 METHOD seqmod;
172 RUN state.specify;
173 FREE state.y[components];
174 FIX H;
175 END seqmod;
176
177
178 METHOD scale;
179 RUN state.scale;
180 FOR i IN components DO
181 f[i].nominal := f[i] + 0.1{mol/s};
182 f[i].upper_bound := f[i] + boundwidth*f[i].nominal;
183 END FOR;
184 Ftot.nominal := Ftot + 0.1{mol/s};
185 Ftot.upper_bound := Ftot + boundwidth*Ftot.nominal;
186 Htot.nominal := abs(Htot) + 1{kW};
187 Htot.lower_bound := Htot - boundwidth*Htot.nominal;
188 Htot.upper_bound := Htot + boundwidth*Htot.nominal;
189 Ftot_scale := Ftot.nominal;
190 Htot_scale := Htot.nominal;
191
192 END scale;
193
194 END homogeneous_td_stream;
195
196
197
198 (* ***********************************+************************************ *)
199 (* ******************** two_phase_molar_stream ********************* *)
200 (* ***********************************+************************************ *)
201
202
203 MODEL two_phase_molar_stream(
204 state WILL_BE two_phase_mixture;
205 ) REFINES stream_base;
206
207 components ALIASES state.components;
208 Ftot,
209 f[components] IS_A molar_rate;
210 boundwidth IS_A bound_width;
211 Ftot_scale IS_A real;
212
213
214 FOR i IN components CREATE
215 f_def[i]: f[i]/Ftot_scale = Ftot*state.y[i]/Ftot_scale;
216 END FOR;
217
218
219 METHODS
220 METHOD defaults;
221 Ftot_scale := 1000 {mole/s};
222 (* horrible scaling method - global var, ack! *)
223 END defaults;
224 METHOD clear;
225 RUN state.clear;
226 FREE Ftot;
227 FREE f[components];
228 f_def[components].included:= TRUE;
229 END clear;
230
231 METHOD seqmod;
232 RUN state.specify;
233 FREE state.y[components];
234 END seqmod;
235
236 METHOD specify;
237 RUN seqmod;
238 FIX f[components];
239 END specify;
240
241 METHOD reset;
242 RUN clear;
243 RUN specify;
244 END reset;
245
246 METHOD scale;
247 RUN state.scale;
248 FOR i IN components DO
249 f[i].nominal := f[i] + 0.1{mol/s};
250 f[i].upper_bound := f[i] + boundwidth*f[i].nominal;
251 END FOR;
252 Ftot.nominal := Ftot + 0.1{mol/s};
253 Ftot.upper_bound := Ftot + boundwidth*Ftot.nominal;
254 Ftot_scale := Ftot.nominal;
255 END scale;
256 END two_phase_molar_stream;
257
258
259 (* ***********************************+************************************ *)
260 (* ******************** thermodynamic_stream ********************* *)
261 (* ***********************************+************************************ *)
262
263 MODEL two_phase_td_stream(
264 state WILL_BE two_phase_mixture;
265 ) REFINES two_phase_molar_stream;
266 (*
267 NOTES inline SELF {
268 td_stream here does NOT denote that the state is a td_homo or td_hetero
269 mixture. It merely indicates that total H is computed so that certain
270 thermodynamic principles may be applied using this type of stream.
271 state.H may be an arbitrary number if the state does not compute
272 it from some correlation.
273 }
274 END NOTES;
275 *)
276
277 H ALIASES state.H;
278 Htot IS_A energy_rate;
279 Htot_scale IS_A real;
280
281 Htot_def: Htot/Htot_scale = H*Ftot/Htot_scale;
282
283
284 METHODS
285 METHOD defaults;
286 RUN two_phase_molar_stream::defaults;
287 Htot_scale := 1{MW};
288 END defaults;
289 METHOD clear;
290 RUN state.clear;
291 FREE Ftot;
292 FREE f[components];
293 FREE Htot;
294 FREE H;
295 f_def[components].included := TRUE;
296 Htot_def.included := TRUE;
297 END clear;
298 METHOD seqmod;
299 RUN state.specify;
300 FREE state.y[components];
301 FIX H;
302 END seqmod;
303
304
305 METHOD scale;
306 RUN state.scale;
307 FOR i IN components DO
308 f[i].nominal := f[i] + 0.1{mol/s};
309 f[i].upper_bound := f[i] + boundwidth*f[i].nominal;
310 END FOR;
311 Ftot.nominal := Ftot + 0.1{mol/s};
312 Ftot.upper_bound := Ftot + boundwidth*Ftot.nominal;
313 Htot.nominal := abs(Htot) + 1{kW};
314 Htot.lower_bound := Htot - boundwidth*Htot.nominal;
315 Htot.upper_bound := Htot + boundwidth*Htot.nominal;
316 Ftot_scale := Ftot.nominal;
317 Htot_scale := Htot.nominal;
318
319 END scale;
320
321 END two_phase_td_stream;
322
323 (* ***********************************+************************************ *)
324 (* ******************** vapor_stream ********************* *)
325 (* ***********************************+************************************ *)
326
327 MODEL vapor_stream (
328 state WILL_BE vapor_mixture;
329 ) REFINES homogeneous_td_stream;
330
331 METHODS
332
333 METHOD seqmod;
334 RUN state.specify;
335 FREE state.y[components];
336 END seqmod;
337
338 END vapor_stream;
339
340
341 (* ***********************************+************************************ *)
342 (* ******************** liquid_stream ********************* *)
343 (* ***********************************+************************************ *)
344
345 MODEL liquid_stream(
346 state WILL_BE liquid_mixture;
347 ) REFINES homogeneous_td_stream;
348
349 manual IS_A boolean_start_false; (* Set to TRUE to get Ken behavior *)
350 saturated IS_A boolean_start_false;
351
352 bubble_point: state.P = state.pure[CHOICE[components]].VP *
353 SUM[ state.y[i] * state.pure[i].VP /
354 state.pure[CHOICE[components]].VP | i IN components];
355 WHEN (manual)
356 CASE TRUE:
357 USE bubble_point;
358 (* user may diddle bubble_point.included flag *)
359 CASE FALSE:
360 WHEN (saturated)
361 CASE TRUE:
362 USE bubble_point;
363 CASE FALSE:
364 (* ignore bubble_point *)
365 END WHEN;
366 END WHEN;
367
368 METHODS
369
370 METHOD defaults;
371 saturated := FALSE;
372 RUN homogeneous_td_stream::defaults;
373 END defaults;
374
375 METHOD seqmod;
376 RUN state.specify; (* fixes T, among others *)
377 FREE state.y[components];
378 IF (saturated) THEN
379 FREE state.T;
380 END IF;
381 IF (manual) THEN
382 IF (saturated) THEN
383 bubble_point.included := TRUE;
384 ELSE
385 bubble_point.included := FALSE;
386 END IF;
387 END IF;
388 END seqmod;
389
390 END liquid_stream;
391
392
393 (* ***********************************+************************************ *)
394 (* ******************** multiphase_stream ********************* *)
395 (* ***********************************+************************************ *)
396
397 MODEL multiphase_stream(
398 state WILL_BE td_two_phase_mixture;
399 ) REFINES two_phase_td_stream;
400
401 phases ALIASES state.phases;
402 phase_flow[phases] IS_A molar_rate;
403
404 FOR k IN phases CREATE
405 phase_flow_def[k]: phase_flow[k]/Ftot_scale =
406 state.phi[k]*Ftot/Ftot_scale;
407 END FOR;
408
409 METHODS
410
411 METHOD clear;
412 RUN state.clear;
413 FREE Ftot;
414 FREE f[components];
415 FREE Htot;
416 FREE phase_flow[phases];
417 Htot_def.included := TRUE;
418 f_def[components].included := TRUE;
419 phase_flow_def[phases].included := TRUE;
420 END clear;
421
422 METHOD scale;
423 RUN state.scale;
424 FOR i IN components DO
425 f[i].nominal := f[i] + 0.1{mol/s};
426 f[i].upper_bound := f[i] + boundwidth*f[i].nominal;
427 END FOR;
428 Ftot.nominal := Ftot + 0.1{mol/s};
429 Ftot.upper_bound := Ftot + boundwidth*Ftot.nominal;
430 Htot.nominal := abs(Htot) + 1{kW};
431 Htot.lower_bound := Htot - boundwidth*Htot.nominal;
432 Htot.upper_bound := Htot + boundwidth*Htot.nominal;
433
434 FOR j IN phases DO
435 phase_flow[j].nominal := phase_flow[j] + 0.1{mol/s};
436 phase_flow[j].upper_bound :=
437 phase_flow[j] + boundwidth*phase_flow[j].nominal;
438 END FOR;
439 Ftot_scale := Ftot.nominal;
440 Htot_scale := Htot.nominal;
441 END scale;
442
443 METHOD seqmod;
444 RUN state.specify;
445 FREE state.y[components];
446 END seqmod;
447
448 END multiphase_stream;
449
450
451 MODEL vapor_liquid_stream(
452 state WILL_BE td_VLE_mixture;
453 ) REFINES multiphase_stream;
454 (* nobody *)
455 END vapor_liquid_stream;

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