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

Annotation of /trunk/models/thermodynamics_example.a4c

Parent Directory Parent Directory | Revision Log Revision Log


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

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