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

Annotation of /trunk/models/thermodynamics_example.a4c

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2649 - (hide annotations) (download) (as text)
Wed Dec 12 12:39:25 2012 UTC (11 years, 7 months ago) by jpye
File MIME type: text/x-ascend
File size: 12164 byte(s)
Fixing GPL header, removing postal address (rpmlint incorrect-fsf-address)
1 jpye 1731 (* ASCEND modelling environment
2     * Copyright (C) 1999 Carnegie Mellon University
3     *
4     * The ASCEND Modeling Library is free software; you can redistribute
5     * it and/or modify it under the terms of the GNU General Public
6     * License as published by the Free Software Foundation; either
7     * version 2 of the License, or (at your option) any later version.
8     *
9     * The ASCEND Modeling Library is distributed in hope that it
10     * will be useful, but WITHOUT ANY WARRANTY; without even the implied
11     * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
12     * See the GNU General Public License for more details.
13     *
14 jpye 2649 * You should have received a copy of the GNU General Public License
15     * along with this program. If not, see <http://www.gnu.org/licenses/>.
16 jpye 1731 *)
17     REQUIRE "thermodynamics.a4l";
18     REQUIRE "stream_holdup.a4l";
19     (*
20     This file includes a range of examples that show how to use ASCEND
21     for thermodynamics calculations with physical property data from the
22     ASCEND 'thermodynamics.a4l' library.
23    
24     You can read a HOW TO document that describes these models in detail at
25     http://ascendwiki.cheme.cmu.edu/Thermodynamics_with_ASCEND
26     *)
27    
28     (*
29     -----------------------------------------
30     Example 1 - Ideal Vapor Component
31     -----------------------------------------
32     *)
33    
34    
35     MODEL howto_thermo_ex1 REFINES cmumodel;
36     cd IS_A components_data(['water'], 'water');
37     P IS_A pressure;
38     T IS_A temperature;
39     ivc IS_A ideal_vapor_component(P, T, cd.data['water']);
40    
41     METHODS
42     METHOD default_self;
43     RUN ivc.default_self;
44     END default_self;
45    
46     METHOD scale_self;
47     RUN ivc.scale_self;
48     END scale_self;
49    
50     METHOD specify;
51     RUN ivc.specify;
52     END specify;
53    
54     METHOD values;
55     P := 1 {atm};
56     T := 400 {K};
57     END values;
58    
59     END howto_thermo_ex1;
60    
61     (*
62     -----------------------------------------
63     Example 2 - Liquid Component
64     -----------------------------------------
65     *)
66    
67     MODEL howto_thermo_ex2 REFINES cmumodel;
68     cd IS_A components_data(['water'], 'water');
69     P IS_A pressure;
70     T IS_A temperature;
71     ivc IS_A Rackett_liquid_component(P, T, cd.data['water']);
72    
73     METHODS
74     METHOD default_self;
75     RUN ivc.default_self;
76     END default_self;
77    
78     METHOD scale_self;
79     RUN ivc.scale_self;
80     END scale_self;
81    
82     METHOD specify;
83     RUN ivc.specify;
84     END specify;
85    
86     METHOD reset_VP_problem;
87     RUN ivc.specify;
88     ivc.T.fixed := FALSE;
89     ivc.VP.fixed := TRUE;
90     ivc.VP := 1 {atm};
91     END reset_VP_problem;
92    
93     METHOD values;
94     P := 1 {atm};
95     T := 300 {K};
96     END values;
97    
98     END howto_thermo_ex2;
99    
100     (*
101     -----------------------------------------
102     Example 3 - Ideal Vapor Mixture
103     -----------------------------------------
104     *)
105    
106     MODEL howto_thermo_ex3 REFINES cmumodel;
107     cd IS_A components_data(['water','ethanol'], 'water');
108     ivm IS_A ideal_vapor_mixture(cd);
109    
110     METHODS
111     METHOD default_self;
112     RUN ivm.default_self;
113     END default_self;
114    
115     METHOD scale_self;
116     RUN ivm.scale_self;
117     END scale_self;
118    
119     METHOD specify;
120     RUN ivm.specify;
121     END specify;
122    
123     METHOD values;
124     ivm.P := 1 {atm};
125     ivm.T := 400 {K};
126     ivm.y['ethanol'] := 0.4;
127     END values;
128    
129     END howto_thermo_ex3;
130    
131    
132     (*
133     -----------------------------------------
134     Example 4 - Pitzer Vapor Mixture
135     -----------------------------------------
136     *)
137    
138     MODEL howto_thermo_ex4 REFINES cmumodel;
139     cd IS_A components_data(['water','ethanol'], 'water');
140     ivm IS_A Pitzer_vapor_mixture(cd);
141    
142     METHODS
143     METHOD default_self;
144     RUN ivm.default_self;
145     END default_self;
146    
147     METHOD scale_self;
148     RUN ivm.scale_self;
149     END scale_self;
150    
151     METHOD specify;
152     RUN ivm.specify;
153     END specify;
154    
155     METHOD values;
156     ivm.P := 1 {atm};
157     ivm.T := 400 {K};
158     ivm.y['ethanol'] := 0.4;
159     END values;
160    
161     END howto_thermo_ex4;
162    
163     (*
164     -----------------------------------------
165     Example 4b - UNIFAC Liquid Mixture
166     -----------------------------------------
167     *)
168    
169     MODEL howto_thermo_ex4b REFINES cmumodel;
170     cd IS_A components_data(['water','ethanol'], 'water');
171     ulm IS_A UNIFAC_liquid_mixture(cd);
172    
173     METHODS
174     METHOD default_self;
175     RUN ulm.default_self;
176     END default_self;
177    
178     METHOD scale_self;
179     RUN ulm.scale_self;
180     END scale_self;
181    
182     METHOD specify;
183     RUN ulm.specify;
184     END specify;
185    
186     METHOD values;
187     ulm.P := 1 {atm};
188     ulm.T := 300 {K};
189     ulm.y['ethanol'] := 0.4;
190     END values;
191    
192     END howto_thermo_ex4b;
193    
194    
195     (*
196     -----------------------------------------
197     Example 5 - Ideal Vapor Mixture
198     (general interface)
199     -----------------------------------------
200     *)
201    
202     MODEL howto_thermo_ex5 REFINES cmumodel;
203     cd IS_A components_data(['water','ethanol'], 'water');
204     pd IS_A phases_data('V', 'ideal_vapor_mixture', 'none', 'none');
205     equilibrated IS_A boolean;
206     phases ALIASES pd.phases;
207    
208     FOR j IN phases CREATE
209     smt[j] IS_A select_mixture_type(cd, pd.phase_type[j]);
210     END FOR;
211    
212     FOR j IN phases CREATE
213     phase[j] ALIASES smt[j].phase;
214     END FOR;
215    
216     state IS_A thermodynamics(cd, pd, phase, equilibrated);
217    
218     METHODS
219     METHOD default_self;
220     RUN state.default_self;
221     END default_self;
222    
223     METHOD scale_self;
224     RUN state.scale_self;
225     END scale_self;
226    
227     METHOD specify;
228     RUN state.specify;
229     END specify;
230    
231     METHOD values;
232     state.P := 1 {atm};
233     state.T := 450 {K};
234     state.y['ethanol'] := 0.4;
235     equilibrated := TRUE;
236     END values;
237    
238     END howto_thermo_ex5;
239    
240    
241     (*
242     -----------------------------------------
243     Example 6 - Unifac Liquid Mixture
244     (general interface)
245     -----------------------------------------
246     *)
247    
248     MODEL howto_thermo_ex6 REFINES cmumodel;
249     cd IS_A components_data(['water','ethanol'], 'water');
250     pd IS_A phases_data('L', 'none', 'UNIFAC_liquid_mixture', 'none');
251     equilibrated IS_A boolean;
252     phases ALIASES pd.phases;
253    
254     FOR j IN phases CREATE
255     smt[j] IS_A select_mixture_type(cd, pd.phase_type[j]);
256     END FOR;
257    
258     FOR j IN phases CREATE
259     phase[j] ALIASES smt[j].phase;
260     END FOR;
261    
262     state IS_A thermodynamics(cd, pd, phase, equilibrated);
263    
264     METHODS
265     METHOD default_self;
266     RUN state.default_self;
267     END default_self;
268    
269     METHOD scale_self;
270     RUN state.scale_self;
271     END scale_self;
272    
273     METHOD specify;
274     RUN state.specify;
275     END specify;
276    
277     METHOD values;
278     state.P := 1 {atm};
279     state.T := 300 {K};
280     state.y['ethanol'] := 0.4;
281     equilibrated := TRUE;
282     END values;
283    
284     END howto_thermo_ex6;
285    
286     (*
287     ---------------------------------------------
288     Example 7 - VL Mixture
289     (relative volatility equilibrium)
290     ---------------------------------------------
291     *)
292    
293     MODEL howto_thermo_ex7 REFINES cmumodel;
294     cd IS_A components_data(['water','ethanol'], 'water');
295     pd IS_A phases_data('VL', 'ideal_vapor_mixture', 'UNIFAC_liquid_mixture',
296     'none');
297     equilibrated IS_A boolean;
298     phases ALIASES pd.phases;
299    
300     FOR j IN phases CREATE
301     smt[j] IS_A select_mixture_type(cd, pd.phase_type[j]);
302     END FOR;
303    
304     FOR j IN phases CREATE
305     phase[j] ALIASES smt[j].phase;
306     END FOR;
307    
308     state IS_A thermodynamics(cd, pd, phase, equilibrated);
309    
310     METHODS
311     METHOD default_self;
312     RUN state.default_self;
313     END default_self;
314    
315     METHOD scale_self;
316     RUN state.scale_self;
317     END scale_self;
318    
319     METHOD specify;
320     RUN state.specify;
321     END specify;
322    
323     METHOD values;
324     state.P := 1 {atm};
325     state.T := 360 {K};
326     state.y['ethanol'] := 0.4;
327     state.phase['vapor'].alpha['ethanol'] := 2;
328     state.phase['vapor'].alpha['water'] := 1;
329     equilibrated := TRUE;
330     END values;
331    
332     END howto_thermo_ex7;
333    
334    
335     (*
336     --------------------------------------------
337     Example 8 - VL Component
338 jpye 2066 (chemical potential equilibrium)
339 jpye 1731 --------------------------------------------
340     *)
341    
342     MODEL howto_thermo_ex8 REFINES cmumodel;
343     cd IS_A components_data(['water','ethanol'], 'water');
344     pd IS_A phases_data('VL', 'ideal_vapor_mixture', 'UNIFAC_liquid_mixture',
345     'none');
346     equilibrated IS_A boolean;
347     phases ALIASES pd.phases;
348    
349     FOR j IN phases CREATE
350     smt[j] IS_A select_mixture_type(cd, pd.phase_type[j]);
351     END FOR;
352    
353     FOR j IN phases CREATE
354     phase[j] ALIASES smt[j].phase;
355     END FOR;
356    
357     state IS_A thermodynamics(cd, pd,phase, equilibrated);
358    
359     METHODS
360     METHOD default_self;
361     RUN state.default_self;
362     END default_self;
363    
364     METHOD scale_self;
365     RUN state.scale_self;
366     END scale_self;
367    
368     METHOD specify;
369     RUN state.specify;
370     END specify;
371    
372     METHOD values;
373     state.P := 1 {atm};
374     state.T := 300 {K};
375     state.y['ethanol'] := 0.5;
376     equilibrated := TRUE;
377     END values;
378    
379     METHOD reset_Px;
380     equilibrated := TRUE;
381     RUN state.specify;
382     state.T.fixed := FALSE;
383     state.phase['liquid1'].y['water'].fixed := TRUE;
384     state.P := 1 {atm};
385     state.y['ethanol'] := 0.5;
386     state.phase['liquid1'].y['water'] := 0.6;
387     END reset_Px;
388    
389     END howto_thermo_ex8;
390    
391    
392     (*
393     --------------------------------------------
394     Example 9 - VL Equilibrim Chart
395     --------------------------------------------
396     *)
397    
398     MODEL howto_thermo_ex9 REFINES cmumodel;
399     cd IS_A components_data(['water','ethanol'], 'water');
400     pd IS_A phases_data('VL', 'Pitzer_vapor_mixture', 'UNIFAC_liquid_mixture',
401     'none');
402     equilibrated IS_A boolean;
403     phases ALIASES pd.phases;
404    
405     FOR j IN phases CREATE
406     smt[j] IS_A select_mixture_type(cd, pd.phase_type[j]);
407     END FOR;
408    
409     FOR j IN phases CREATE
410     phase[j] ALIASES smt[j].phase;
411     END FOR;
412    
413     state IS_A thermodynamics(cd, pd,phase, equilibrated);
414    
415     METHODS
416     METHOD default_self;
417     RUN state.default_self;
418     END default_self;
419    
420     METHOD scale_self;
421     RUN state.scale_self;
422     END scale_self;
423    
424     METHOD specify;
425     RUN state.specify;
426     END specify;
427    
428     METHOD values;
429     state.P := 1 {atm};
430     state.T := 300 {K};
431     state.y['ethanol'] := 0.5;
432     equilibrated := TRUE;
433     END values;
434    
435     METHOD reset_Px;
436     equilibrated := TRUE;
437     RUN state.specify;
438     state.T.fixed := FALSE;
439     state.phase['liquid1'].y['water'].fixed := TRUE;
440     state.P := 1 {atm};
441     state.y['ethanol'] := 0.5;
442     state.phase['liquid1'].y['water'] := 0.6;
443     END reset_Px;
444    
445     END howto_thermo_ex9;
446 jose 2071 (*
447     --------------------------------------------
448     Example 8 - VL Component
449     (chemical potencial equilibrium)
450     --------------------------------------------
451     *)
452    
453     MODEL howto_thermo_ex10 REFINES cmumodel;
454     cd IS_A components_data(['water'], 'water');
455     pd IS_A phases_data('VL', 'ideal_vapor_mixture', 'UNIFAC_liquid_mixture',
456     'none');
457     equilibrated IS_A boolean;
458     phases ALIASES pd.phases;
459    
460     FOR j IN phases CREATE
461     smt[j] IS_A select_mixture_type(cd, pd.phase_type[j]);
462     END FOR;
463    
464     FOR j IN phases CREATE
465     phase[j] ALIASES smt[j].phase;
466     END FOR;
467    
468     state IS_A thermodynamics(cd, pd,phase, equilibrated);
469    
470     METHODS
471     METHOD default_self;
472     RUN state.default_self;
473     END default_self;
474    
475     METHOD scale_self;
476     RUN state.scale_self;
477     END scale_self;
478    
479     METHOD specify;
480     RUN state.specify;
481     END specify;
482    
483     METHOD values;
484     state.P := 1 {atm};
485     state.T := 300 {K};
486     state.y['water'] := 1;
487     equilibrated := TRUE;
488     END values;
489    
490     METHOD reset_Px;
491     equilibrated := TRUE;
492     RUN state.specify;
493     state.T.fixed := FALSE;
494     state.phase_fraction['liquid1'].fixed := TRUE;
495     state.P := 1 {atm};
496     state.y['water'] := 1;
497     state.phase_fraction['liquid1']:= 0.7;
498     END reset_Px;
499    
500     END howto_thermo_ex10;
501 jpye 1731

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