/[ascend]/trunk/models/johnpye/thermo_examples_new.a4c
ViewVC logotype

Contents of /trunk/models/johnpye/thermo_examples_new.a4c

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1809 - (show annotations) (download) (as text)
Mon Jul 28 07:47:09 2008 UTC (12 years ago) by jpye
File MIME type: text/x-ascend
File size: 2170 byte(s)
Rewriting the thermodynamics examples so they don't depend on .a4s driver
scripts.
1 (* Simple example for vapour properties of water from ideal gas equation *)
2
3 REQUIRE "thermodynamics.a4l";
4 REQUIRE "johnpye/thermo_types.a4c";
5
6 MODEL my_props;
7 p IS_A pressure;
8 T IS_A temperature;
9 cd IS_A components_data(['water'],'water');
10 props IS_A ideal_vapor_component(p,T,cd.data['water']);
11 v_m ALIASES props.v;
12 v IS_A specific_volume;
13 v = v_m / props.data.mw;
14 rho IS_A mass_density;
15 rho = 1./v;
16 h_m ALIASES props.h;
17 METHODS
18 METHOD on_load;
19 RUN props.default_all;
20 RUN props.specify;
21 p := 1 {atm};
22 T := 400 {K};
23 END on_load;
24 END my_props;
25
26 (* model to calculate change in enthalpy from 125°C to 225 °C at 1 bar. *)
27 MODEL example_1;
28 A, B IS_A my_props;
29 A.p, B.p ARE_THE_SAME;
30 dh_m IS_A molar_energy;
31 dh_m = B.h_m - A.h_m;
32 dh IS_A specific_enthalpy;
33 dh = dh_m / A.props.data.mw;
34 METHODS
35 METHOD on_load;
36 RUN A.on_load;
37 RUN B.on_load;
38 A.T := 273.15 {K} + 125 {K};
39 B.T := 273.15 {K} + 225 {K};
40 END on_load;
41 END example_1;
42
43 (* model to calculate temperature at which vapour pressure of water is 1 atm *)
44 MODEL example_2;
45 p IS_A pressure;
46 T IS_A temperature;
47 cd IS_A components_data(['water'],'water');
48 props IS_A Rackett_liquid_component(p,T,cd.data['water']);
49
50 v_m ALIASES props.v;
51 v IS_A specific_volume;
52 v = v_m / props.data.mw;
53 rho IS_A mass_density;
54 rho = 1./v;
55
56 p_vap ALIASES props.VP;
57 METHODS
58 METHOD on_load;
59 RUN props.default_all;
60 RUN props.specify;
61 p := 1 {atm};
62
63 (* reconfigure the program to solve with fixed VP and free T... *)
64 FREE T;
65 FIX p_vap;
66 p_vap := 1 {atm};
67
68 END on_load;
69 END example_2;
70
71 MODEL water_and_ethanol;
72 cd IS_A components_data(['water','ethanol'], 'water');
73 props IS_A Pitzer_vapor_mixture(cd);
74 p ALIASES props.P;
75 T ALIASES props.T;
76 h_m ALIASES props.h_y;
77 METHODS
78 METHOD on_load;
79 RUN props.default_self;
80 RUN props.specify;
81 RUN props.values;
82 p := 1 {atm};
83 T := 400 {K};
84 props.y['ethanol'] := 0.4;
85 END on_load;
86 END water_and_ethanol;
87
88 MODEL example_3;
89 A, B IS_A water_and_ethanol;
90 dh_m IS_A molar_energy;
91 dh_m = B.h_m - A.h_m;
92
93 METHODS
94 METHOD on_load;
95 RUN A.on_load;
96 RUN B.on_load;
97 A.T := 400 {K};
98 B.T := 500 {K};
99 END on_load;
100 END example_3;

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