/[ascend]/branches/jacob/models/johnpye/fprops/mix_test/jacob_mix_test8--ideal.a4c
ViewVC logotype

Contents of /branches/jacob/models/johnpye/fprops/mix_test/jacob_mix_test8--ideal.a4c

Parent Directory Parent Directory | Revision Log Revision Log


Revision 3085 - (show annotations) (download) (as text)
Fri Aug 21 19:00:30 2015 UTC (3 years, 10 months ago) by jacob
File MIME type: text/x-ascend
File size: 6577 byte(s)
remove some obsolete functions, and move test functions
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 contains an attempt to test whether the ideal-gas equation
6 of state can be used with the mixture (ideal solution) routines.
7 Also performs further test of calculating one variable provided to
8 external relations as an input (pressure) from another fixed variable
9 that is provided as an output (density).
10
11 Conclusion: the 'mixture_flash' function would have to be modified to
12 accommodate ideal-gas modeling of the components, for ideal-gas
13 solutions to work.
14 *)
15
16 REQUIRE "atoms.a4l";
17 REQUIRE "johnpye/thermo_types.a4c";
18 IMPORT "johnpye/fprops/mixture";
19 REQUIRE "johnpye/fprops/mixtures.a4l";
20
21 (* ---------------------------------------------------------------------
22 First model, which uses the ideal-gas equation of state *)
23 MODEL mixture_test1;
24 (* -----------------------------------------------------------------
25 Declare variables to hold various mixture properties *)
26 T1,
27 T2,
28 T3 IS_A temperature; (* mixture temperatures *)
29
30 p1,
31 p2,
32 p3 IS_A pressure; (* pressures calculated from density *)
33 rho IS_A mass_density; (* mixture density *)
34
35 h1,
36 h2,
37 h3 IS_A specific_enthalpy; (* mixture enthalpies *)
38
39 (* -----------------------------------------------------------------
40 Declare variables to hold phase-accounting data *)
41 phases, (* number of phases *)
42 ph1, ph2 IS_A phase_count; (* phases 1 and 2 *)
43 ph_frac[1..3] IS_A mass_fraction; (* mass fraction of each phase *)
44
45 (* -----------------------------------------------------------------
46 Declare and specify a mixture with its composition *)
47 mixt IS_A mixture_spec;
48 mixt.npure :== 4;
49 mixt.components[1] :== 'ammonia';
50 mixt.components[2] :== 'cyclohexane';
51 mixt.components[3] :== 'water';
52 mixt.components[4] :== 'toluene';
53 mixt.eos :== 'ideal';
54 mixt.xs[1] :== 0.30;
55 mixt.xs[2] :== 0.25;
56 mixt.xs[3] :== 0.35;
57 mixt.xs[4] :== 0.10;
58
59 (* -----------------------------------------------------------------
60 Find pressures from overall density and temperature *)
61 mix_density1 : mixture_rho(
62 T1, p1 : INPUT;
63 rho : OUTPUT;
64 mixt : DATA
65 );
66 mix_density2 : mixture_rho(
67 T2, p2 : INPUT;
68 rho : OUTPUT;
69 mixt : DATA
70 );
71 mix_density3 : mixture_rho(
72 T3, p3 : INPUT;
73 rho : OUTPUT;
74 mixt : DATA
75 );
76
77 (* -----------------------------------------------------------------
78 Find enthalpy from temperature *)
79 mix_enthalpy1 : mixture_h(
80 T1, p1 : INPUT;
81 h1 : OUTPUT;
82 mixt : DATA
83 );
84 mix_enthalpy2 : mixture_h(
85 T2, p2 : INPUT;
86 h2 : OUTPUT;
87 mixt : DATA
88 );
89 mix_enthalpy3 : mixture_h(
90 T3, p3 : INPUT;
91 h3 : OUTPUT;
92 mixt : DATA
93 );
94
95 (* -----------------------------------------------------------------
96 Find number of phases, mass fractions of phases *)
97 mix_phases : mixture_count_phases(
98 T1, p1 : INPUT;
99 phases, ph_frac[1], ph_frac[2], ph_frac[3] : OUTPUT;
100 mixt : DATA
101 );
102
103 METHODS
104 (* Fix the variables that are to be fixed *)
105 METHOD specify;
106 FIX T1;
107 FIX T2;
108 FIX T3;
109 FIX rho;
110 FIX ph1;
111 FIX ph2;
112 END specify;
113 (* Set values of the fixed variables *)
114 METHOD values;
115 T1 := 800 {K};
116 T2 := 2*T1;
117 T3 := 3*T1;
118 rho := 2.055 {kg/m^3};
119 ph1 := 1;
120 ph2 := 2;
121 END values;
122 (* Set solver and other options *)
123 METHOD options;
124 SOLVER QRSlv;
125 OPTION convopt 'RELNOM_SCALE';
126 END options;
127 (* Quick alias for all preceeding methods; readies the model for solving *)
128 METHOD setup;
129 RUN specify;
130 RUN values;
131 RUN options;
132 END setup;
133 END mixture_test1;
134
135
136 (* ---------------------------------------------------------------------
137 Second model, which uses the Peng-Robinson equation of state *)
138 MODEL mixture_test2;
139 (* -----------------------------------------------------------------
140 Declare variables to hold various mixture properties *)
141 T1,
142 T2,
143 T3 IS_A temperature; (* mixture temperatures *)
144
145 p1,
146 p2,
147 p3 IS_A pressure; (* pressures calculated from density *)
148 rho IS_A mass_density; (* mixture density *)
149
150 h1,
151 h2,
152 h3 IS_A specific_enthalpy; (* mixture enthalpies *)
153
154 (* -----------------------------------------------------------------
155 Declare variables to hold phase-accounting data *)
156 phases, (* number of phases *)
157 ph1, ph2 IS_A phase_count; (* phases 1 and 2 *)
158 ph_frac[1..3] IS_A mass_fraction; (* mass fraction of each phase *)
159
160 (* -----------------------------------------------------------------
161 Declare and specify a mixture with its composition *)
162 mixt IS_A mixture_spec;
163 mixt.npure :== 4;
164 mixt.components[1] :== 'ammonia';
165 mixt.components[2] :== 'cyclohexane';
166 mixt.components[3] :== 'water';
167 mixt.components[4] :== 'toluene';
168 mixt.eos :== 'ideal';
169 mixt.xs[1] :== 0.30;
170 mixt.xs[2] :== 0.25;
171 mixt.xs[3] :== 0.35;
172 mixt.xs[4] :== 0.10;
173
174 (* -----------------------------------------------------------------
175 Find pressure from overall density, phase densities from pressure *)
176 mix_density1 : mixture_rho(
177 T1, p1 : INPUT;
178 rho : OUTPUT;
179 mixt : DATA
180 );
181 mix_density2 : mixture_rho(
182 T2, p2 : INPUT;
183 rho : OUTPUT;
184 mixt : DATA
185 );
186 mix_density3 : mixture_rho(
187 T3, p3 : INPUT;
188 rho : OUTPUT;
189 mixt : DATA
190 );
191
192 (* -----------------------------------------------------------------
193 Find enthalpy from temperature *)
194 mix_enthalpy1 : mixture_h(
195 T1, p1 : INPUT;
196 h1 : OUTPUT;
197 mixt : DATA
198 );
199 mix_enthalpy2 : mixture_h(
200 T2, p2 : INPUT;
201 h2 : OUTPUT;
202 mixt : DATA
203 );
204 mix_enthalpy3 : mixture_h(
205 T3, p3 : INPUT;
206 h3 : OUTPUT;
207 mixt : DATA
208 );
209
210 (* -----------------------------------------------------------------
211 Find number of phases, mass fractions of phases *)
212 mix_phases : mixture_count_phases(
213 T1, p1 : INPUT;
214 phases, ph_frac[1], ph_frac[2], ph_frac[3] : OUTPUT;
215 mixt : DATA
216 );
217
218 METHODS
219 (* Fix the variables that are to be fixed *)
220 METHOD specify;
221 FIX T1;
222 FIX T2;
223 FIX T3;
224 FIX rho;
225 FIX ph1;
226 FIX ph2;
227 END specify;
228 (* Set values of the fixed variables *)
229 METHOD values;
230 T1 := 800 {K};
231 T2 := 2*T1;
232 T3 := 3*T1;
233 rho := 2.055 {kg/m^3};
234 ph1 := 1;
235 ph2 := 2;
236 END values;
237 (* Set solver and other options *)
238 METHOD options;
239 SOLVER QRSlv;
240 OPTION convopt 'RELNOM_SCALE';
241 END options;
242 (* Quick alias for all preceeding methods; readies the model for solving *)
243 METHOD setup;
244 RUN specify;
245 RUN values;
246 RUN options;
247 END setup;
248 END mixture_test2;

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