/[ascend]/branches/jacob/models/johnpye/fprops/jacob_mix_test5--components.a4c
ViewVC logotype

Contents of /branches/jacob/models/johnpye/fprops/jacob_mix_test5--components.a4c

Parent Directory Parent Directory | Revision Log Revision Log


Revision 3082 - (show annotations) (download) (as text)
Fri Aug 21 05:20:36 2015 UTC (4 years ago) by jacob
File MIME type: text/x-ascend
File size: 6873 byte(s)
Edited mixture API to allow properties of individual components to be found across all phases (e.g. the heat capacity of ammonia in all phases).  Added a very large test file to test this functionality, 'jacob_mix_test--comprehensive.a4c'.

1 (* ASCEND multi-component ideal-solution routine
2
3 To perform the simulation, load the file into ASCEND and run 'setup'.
4
5 This file tests those functions which return properties for
6 individual components.
7 *)
8
9 REQUIRE "atoms.a4l";
10 REQUIRE "johnpye/thermo_types.a4c";
11 IMPORT "johnpye/fprops/mixture";
12 REQUIRE "johnpye/fprops/mixtures.a4l";
13
14 (* ---------------------------------------------------------------------
15 The mixture_test model *)
16 MODEL mixture_test;
17 (* -----------------------------------------------------------------
18 Declare variables to hold various mixture properties *)
19 T IS_A temperature; (* mixture temperature *)
20 p IS_A pressure; (* mixture pressure; with 'T' this sets the state *)
21
22 (* -----------------------------------------------------------------
23 Declare variables to hold the densities *)
24 rho, (* whole-mixture *)
25 rho_ph1, (* phase 1 *)
26 rho_ph2, (* phase 2 *)
27 rho_comp1, (* phase 1, component 1 *)
28 rho_comp2 IS_A mass_density; (* phase 1, component 2 *)
29
30 (* -----------------------------------------------------------------
31 Declare enthalpy variables *)
32 h, (* whole-mixture *)
33 h_ph1, (* phase 1 *)
34 h_ph2, (* phase 2 *)
35 h_comp1, (* phase 1, component 1 *)
36 h_comp2 IS_A specific_enthalpy; (* phase 1, component 2 *)
37
38 (* -----------------------------------------------------------------
39 Declare constant-pressure heat capacity variables *)
40 cp, (* whole-mixture *)
41 cp_comp1, (* phase 1, component 1 *)
42 cp_comp2, (* phase 1, component 2 *)
43
44 (* Declare constant-volume heat capacity variables *)
45 cv_ph1, (* phase 1, component 1 *)
46 cv_comp2 IS_A specific_heat_capacity; (* phase 1, component 2 *)
47
48 (* -----------------------------------------------------------------
49 Declare Gibbs energy variables *)
50 g, (* whole-mixture *)
51 g_ph1, (* phase 1 *)
52 g_ph2, (* phase 2 *)
53 g_comp1, (* phase 1, component 1 *)
54 g_comp2 IS_A specific_secondary_energy; (* phase 1, component 2 *)
55
56 (* -----------------------------------------------------------------
57 Declare variables to hold phase-accounting data *)
58 phases, (* number of phases *)
59 comp_num[1..3], (* number of components in each phase *)
60 ph1, ph2, ph3, (* phases 1, 2, 3 *)
61 cmp1, cmp2 IS_A phase_count; (* components 1, 2 *)
62 ph_frac[1..3] IS_A mass_fraction; (* mass fraction of each phase *)
63
64 (* -----------------------------------------------------------------
65 Declare and specify a mixture with its composition *)
66 mixt IS_A mixture_spec;
67 mixt.npure :== 4;
68 mixt.components[1] :== 'ammonia';
69 mixt.components[2] :== 'carbonmonoxide';
70 mixt.components[3] :== 'cyclohexane';
71 mixt.components[4] :== 'benzene';
72 mixt.eos :== 'pengrob';
73 mixt.xs[1] :== 0.3;
74 mixt.xs[2] :== 0.35;
75 mixt.xs[3] :== 0.20;
76 mixt.xs[4] :== 0.15;
77
78 (* -----------------------------------------------------------------
79 Find number of phases, mass fractions of phases, and number of components
80 in each phase *)
81 mix_phases : mixture_count_phases(
82 T, p : INPUT;
83 phases, ph_frac[1], ph_frac[2], ph_frac[3] : OUTPUT;
84 mixt : DATA
85 );
86 mix_phase1_comps : mixture_count_components(
87 T, p, ph1 : INPUT;
88 comp_num[1] : OUTPUT;
89 mixt : DATA
90 );
91 mix_phase2_comps : mixture_count_components(
92 T, p, ph2 : INPUT;
93 comp_num[2] : OUTPUT;
94 mixt : DATA
95 );
96 mix_phase3_comps : mixture_count_components(
97 T, p, ph3 : INPUT;
98 comp_num[3] : OUTPUT;
99 mixt : DATA
100 );
101
102 (* -----------------------------------------------------------------
103 Find phase and component densities *)
104 mix_density : mixture_rho(
105 T, p : INPUT;
106 rho : OUTPUT;
107 mixt : DATA
108 );
109 mix_phase1_density : mixture_phase_rho(
110 T, p, ph1 : INPUT;
111 rho_ph1 : OUTPUT;
112 mixt : DATA
113 );
114 mix_phase2_density : mixture_phase_rho(
115 T, p, ph2 : INPUT;
116 rho_ph2 : OUTPUT;
117 mixt : DATA
118 );
119 mix_comp1_density : mixture_comps_rho(
120 T, p, ph1, cmp1 : INPUT;
121 rho_comp1 : OUTPUT;
122 mixt : DATA
123 );
124 mix_comp2_density : mixture_comps_rho(
125 T, p, ph1, cmp2 : INPUT;
126 rho_comp2 : OUTPUT;
127 mixt : DATA
128 );
129
130 (* -----------------------------------------------------------------
131 Find phase and component enthalpies *)
132 mix_whole_enthalpy : mixture_h(
133 T, p : INPUT;
134 h : OUTPUT;
135 mixt : DATA
136 );
137 mix_phase1_enthalpy : mixture_phase_h(
138 T, p, ph1 : INPUT;
139 h_ph1 : OUTPUT;
140 mixt : DATA
141 );
142 mix_phase2_enthalpy : mixture_phase_h(
143 T, p, ph2 : INPUT;
144 h_ph2 : OUTPUT;
145 mixt : DATA
146 );
147 mix_comp1_enthalpy : mixture_comps_h(
148 T, p, ph1, cmp1 : INPUT;
149 h_comp1 : OUTPUT;
150 mixt : DATA
151 );
152 mix_comp2_enthalpy : mixture_comps_h(
153 T, p, ph1, cmp2 : INPUT;
154 h_comp2 : OUTPUT;
155 mixt : DATA
156 );
157
158 (* -----------------------------------------------------------------
159 Find phase and component heat capacities *)
160 mix_whole_cp : mixture_cp(
161 T, p : INPUT;
162 cp : OUTPUT;
163 mixt : DATA
164 );
165 mix_comp1_cp : mixture_comps_cp(
166 T, p, ph1, cmp1 : INPUT;
167 cp_comp1 : OUTPUT;
168 mixt : DATA
169 );
170 mix_comp2_cp : mixture_comps_cp(
171 T, p, ph1, cmp2 : INPUT;
172 cp_comp2 : OUTPUT;
173 mixt : DATA
174 );
175
176 (* -----------------------------------------------------------------
177 Find phase and component constant-volume heat capacities *)
178 mix_phase1_cv : mixture_phase_cv(
179 T, p, ph1 : INPUT;
180 cv_ph1 : OUTPUT;
181 mixt : DATA
182 );
183 mix_comp2_cv : mixture_comps_cv(
184 T, p, ph1, cmp2 : INPUT;
185 cv_comp2 : OUTPUT;
186 mixt : DATA
187 );
188
189 (* -----------------------------------------------------------------
190 Find phase and component Gibbs energy data *)
191 mix_whole_g : mixture_g(
192 T, p : INPUT;
193 g : OUTPUT;
194 mixt : DATA
195 );
196 mix_phase1_g : mixture_phase_g(
197 T, p, ph1 : INPUT;
198 g_ph1 : OUTPUT;
199 mixt : DATA
200 );
201 mix_phase2_g : mixture_phase_g(
202 T, p, ph2 : INPUT;
203 g_ph2 : OUTPUT;
204 mixt : DATA
205 );
206 mix_comp1_g : mixture_comps_g(
207 T, p, ph1, cmp1 : INPUT;
208 g_comp1 : OUTPUT;
209 mixt : DATA
210 );
211 mix_comp2_g : mixture_comps_g(
212 T, p, ph1, cmp2 : INPUT;
213 g_comp2 : OUTPUT;
214 mixt : DATA
215 );
216
217 METHODS
218 (* Fix the variables that are to be fixed *)
219 METHOD specify;
220 FIX T;
221 FIX p;
222 FIX ph1;
223 FIX ph2;
224 FIX ph3;
225 FIX cmp1;
226 FIX cmp2;
227 END specify;
228 (* Set values of the fixed variables *)
229 METHOD values;
230 T := 150 {K} + 273.15 {K};
231 p := 2 {bar};
232 ph1 := 1;
233 ph2 := 2;
234 ph3 := 3;
235 cmp1 := 1;
236 cmp2 := 2;
237 END values;
238 (* Set solver and other options *)
239 METHOD options;
240 SOLVER QRSlv;
241 OPTION convopt 'RELNOM_SCALE';
242 END options;
243 (* Quick alias for all preceeding methods; readies the model for solving *)
244 METHOD setup;
245 RUN specify;
246 RUN values;
247 RUN options;
248 END setup;
249 END mixture_test;

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