/[ascend]/trunk/models/libraries/H_S_thermodynamics.lib
ViewVC logotype

Contents of /trunk/models/libraries/H_S_thermodynamics.lib

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2071 - (show annotations) (download)
Fri Aug 28 02:42:47 2009 UTC (11 years, 1 month ago) by jose
File size: 28677 byte(s)
MERGE Jose's branch [2274]:[2584] into trunk
1 (*********************************************************************\
2 H_S_thermodynamics.lib
3 by Joseph J. Zaher
4 Part of the Ascend Library
5
6 This file is part of the Ascend modeling library.
7
8 Copyright (C) 1994
9
10 The Ascend modeling library is free software; you can redistribute
11 it and/or modify it under the terms of the GNU General Public License as
12 published by the Free Software Foundation; either version 2 of the
13 License, or (at your option) any later version.
14
15 The Ascend Language Interpreter is distributed in hope that it will be
16 useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 General Public License for more details.
19
20 You should have received a copy of the GNU General Public License along with
21 the program; if not, write to the Free Software Foundation, Inc., 675
22 Mass Ave, Cambridge, MA 02139 USA. Check the file named COPYING.
23
24 \*********************************************************************)
25
26 (*********************************************************************\
27 $Date: 1997/07/03 14:49:36 $
28 $Revision: 1.6 $
29 $Author: mthomas $
30 $Source: /afs/cs.cmu.edu/project/ascend/Repository/models/libraries/H_S_thermodynamics.lib,v $
31 \*********************************************************************)
32 (**
33 **
34 ** T H E R M O D Y N A M I C S . L I B
35 ** ----------------------------------------------------
36 **
37 ** AUTHOR: Joseph J. Zaher
38 **
39 ** DATES: 07/91 - Original code.
40 ** 02/92 - Made compatible with new set version of ASCEND.
41 ** Scaled equations to enhance convergence, updated
42 ** vapor pressure correlation, added Pitzer extension
43 ** to vapor mixtures and UNIFAC extension to liquid
44 ** mixtures with help of Bob Huss.
45 ** 03/92 - Removed stream model. Library remains purely
46 ** intensive without any assumption to static or
47 ** dynamic modeling.
48 ** 07/92 - Structural changes to provide a common thermodynamic
49 ** properties root model as the library interface.
50 ** Modified the existing phase distribution model
51 ** to incorporate an intensive mass balance over the
52 ** phases. Residual quantities for pure vapor
53 ** components estimate corrections from ideal gas
54 ** behavior while residual quantities for pure liquid
55 ** components estimate corrections from incompressible
56 ** fluid behavior.
57 ** 08/92 - Allowed component names in mixtures to be freely
58 ** specified by user.
59 ** 05/93 - Provided a new root mixture model which is to act as
60 ** the interface to the library. All states start out
61 ** as mixtures consisting of one or more components
62 ** with corresponding mole fractions. When there is
63 ** more information about the phase of the homogeneous
64 ** system (or about what phases are present in the
65 ** heterogeneous system), refinement to incorporate
66 ** thermodynamics can be done.
67 ** 03/94 - Made compatible with gnu-ascend.
68 **
69 ** CONTENTS: ASCEND structure for calculating the basic set of intensive
70 ** thermodynamic properties molar volume, enthalpy, and
71 ** entropy for single and multiple phase streams of pure and
72 ** mixed components. Specify procedures are included which
73 ** have been designed to provide a means of calculating ideal
74 ** approximations when base models are used. For pure
75 ** component vapors, the ideal gas law can be obtained whereas
76 ** for pure component liquids, incompressibility can be
77 ** specified. Ideal vapor and liquid mixtures are maintained
78 ** by setting all partial molar excess properties to zero.
79 ** Distribution of components among multiple phases can be
80 ** ideally computed using constant relative volatilities.
81 **
82 ** For more rigorous non-ideal calculations, some generalized
83 ** refinements of the base models are provided. For pure
84 ** component vapors, a Pitzer correlation of the two term
85 ** virial equation allows a more accurate compressibility and
86 ** residual calculation. The widely used Rackett correlation
87 ** is accurate in estimating the effect of temperature on
88 ** liquid volumes. Non-ideal vapor mixtures are computed using
89 ** an extension of the Pitzer correlation where the exact
90 ** composition dependence of the second virial coefficient is
91 ** given by statistical mechanics. A reliable UNIFAC model
92 ** estimates non-ideal liquid mixtures. Phase equilibrium
93 ** can be enforced rigorously among multiple phases by equating
94 ** expressions for the partial molar gibbs free energy of each
95 ** component written in terms of the available quantities.
96 **
97 ** REQUIRES: "atoms.lib"
98 ** "components.lib"
99 **
100 **)
101
102
103 MODEL thermodynamic_properties;
104
105 T IS_A temperature;
106 P IS_A pressure;
107 V IS_A molar_volume;
108 H IS_A molar_energy;
109 S IS_A molar_entropy;
110 R IS_A molar_gas_constant;
111
112 METHODS
113 METHOD clear;
114 T.fixed := FALSE;
115 P.fixed := FALSE;
116 V.fixed := FALSE;
117 H.fixed := FALSE;
118 S.fixed := FALSE;
119 END clear;
120 METHOD specify;
121 T.fixed := TRUE;
122 P.fixed := TRUE;
123 V.fixed := TRUE;
124 H.fixed := TRUE;
125 S.fixed := TRUE;
126 END specify;
127 METHOD reset;
128 RUN clear;
129 RUN specify;
130 END reset;
131
132 END thermodynamic_properties;
133
134
135 MODEL correction REFINES thermodynamic_properties;
136
137 V := 0.0{cm^3/g_mole};
138 H := 0.0{J/g_mole};
139 S := 0.0{J/g_mole/K};
140
141 V.lower_bound := -1.0e10{cm^3/g_mole};
142 H.nominal := 100.0{J/g_mole};
143 S.nominal := 10.0{J/g_mole/K};
144
145 END correction;
146
147
148 MODEL pure_component REFINES thermodynamic_properties;
149
150 data IS_A component_constants;
151 residual IS_A correction;
152
153 T, residual.T ARE_THE_SAME;
154 P, residual.P ARE_THE_SAME;
155
156 METHODS
157 METHOD clear;
158 RUN residual.clear;
159 V.fixed := FALSE;
160 H.fixed := FALSE;
161 S.fixed := FALSE;
162 END clear;
163 METHOD specify;
164 RUN residual.specify;
165 V.fixed := TRUE;
166 H.fixed := TRUE;
167 S.fixed := TRUE;
168 END specify;
169
170 END pure_component;
171
172
173 MODEL vapor_component REFINES pure_component;
174
175 P*V/R/data.Tc = T/data.Tc + P*residual.V/R/data.Tc;
176 H/R/data.Tc = data.H0/R/data.Tc +
177 data.cpvapa*(T - data.T0)/R/data.Tc +
178 data.cpvapb*(T^2 - data.T0^2)/2/R/data.Tc +
179 data.cpvapc*(T^3 - data.T0^3)/3/R/data.Tc +
180 data.cpvapd*(T^4 - data.T0^4)/4/R/data.Tc +
181 residual.H/R/data.Tc;
182 S/R = data.S0/R +
183 data.cpvapa*ln(T/data.T0)/R +
184 data.cpvapb*(T - data.T0)/R +
185 data.cpvapc*(T^2 - data.T0^2)/2/R +
186 data.cpvapd*(T^3 - data.T0^3)/3/R -
187 ln(P/data.P0) +
188 residual.S/R;
189
190 T.lower_bound := 1.0e-12{K};
191 P.lower_bound := 1.0e-12{atm};
192
193 METHODS
194 METHOD specify;
195 RUN residual.specify;
196 END specify;
197
198 END vapor_component;
199
200
201 MODEL Pitzer_component REFINES vapor_component;
202
203 Z IS_A factor;
204
205 (Z - 1.0)*T/data.Tc = (P/data.Pc)*
206 (0.083 - 0.422*(data.Tc/T)^1.6 + data.omega*
207 (0.139 - 0.172*(data.Tc/T)^4.2));
208 residual.V*P/R/data.Tc = (Z - 1.0)*T/data.Tc;
209 residual.H/R/data.Tc = (P/data.Pc)*
210 (0.083 - 1.097*(data.Tc/T)^1.6 + data.omega*
211 (0.139 - 0.894*(data.Tc/T)^4.2));
212 residual.S*T/R/data.Tc = residual.H/R/data.Tc -
213 (Z - 1.0)*T/data.Tc;
214
215 Z.lower_bound := 0.1;
216
217 METHODS
218 METHOD clear;
219 RUN residual.clear;
220 V.fixed := FALSE;
221 H.fixed := FALSE;
222 S.fixed := FALSE;
223 Z.fixed := FALSE;
224 END clear;
225 METHOD specify;
226 RUN residual.specify;
227 residual.V.fixed := FALSE;
228 residual.H.fixed := FALSE;
229 residual.S.fixed := FALSE;
230 END specify;
231
232 END Pitzer_component;
233
234
235 MODEL liquid_component REFINES pure_component;
236
237 VP IS_A pressure;
238 Sat IS_A vapor_component;
239
240 T, Sat.T ARE_THE_SAME;
241 VP, Sat.P ARE_THE_SAME;
242 data, Sat.data ARE_THE_SAME;
243 ln(VP/data.Pc)*T/data.Tc =
244 data.vpa*(1.0 - T/data.Tc) +
245 data.vpb*(1.0 - T/data.Tc)^1.5 +
246 data.vpc*(1.0 - T/data.Tc)^3.0 +
247 data.vpd*(1.0 - T/data.Tc)^6.0;
248 V/data.Vliq = 1.0 + residual.V/data.Vliq;
249 H/R/data.Tc = Sat.H/R/data.Tc -
250 (data.Hv/R/data.Tc)*((data.Tc-T)/(data.Tc-data.Tb))^0.38 +
251 data.Vliq*(P - VP)/R/data.Tc +
252 residual.H/R/data.Tc;
253 S*T/R/data.Tc = Sat.S*T/R/data.Tc -
254 (data.Hv/R/data.Tc)*((data.Tc-T)/(data.Tc-data.Tb))^0.38 +
255 residual.S*T/R/data.Tc;
256
257 VP := 1.0e-8{atm};
258 VP.lower_bound := 1.0e-12{atm};
259
260 METHODS
261 METHOD clear;
262 RUN residual.clear;
263 RUN Sat.clear;
264 V.fixed := FALSE;
265 H.fixed := FALSE;
266 S.fixed := FALSE;
267 END clear;
268 METHOD specify;
269 RUN residual.specify;
270 RUN Sat.specify;
271 VP.fixed := FALSE;
272 END specify;
273
274 END liquid_component;
275
276
277 MODEL Rackett_component REFINES liquid_component;
278
279 beta IS_A volume_expansivity;
280 Sat IS_REFINED_TO Pitzer_component;
281
282 beta*data.Tc*(1 - T/data.Tc)^0.7143 = -0.2857*ln(data.Zc);
283 residual.V/data.Vliq = exp(-beta*(data.Tc - T)/0.2857)/
284 data.Zc^((1.0 - data.Tliq/data.Tc)^0.2857) - 1.0;
285 residual.H/R/data.Tc = residual.S*T/R/data.Tc + (P - VP)*
286 data.Vliq*(exp(-beta*(data.Tc - T)/0.2857)/
287 data.Zc^((1.0 - data.Tliq/data.Tc)^0.2857) - 1.0)/R/data.Tc;
288 residual.S/R = -beta*(P - VP)*data.Vliq*
289 exp(-beta*(data.Tc - T)/0.2857)/
290 data.Zc^((1.0 - data.Tliq/data.Tc)^0.2857)/R;
291
292 METHODS
293 METHOD clear;
294 RUN residual.clear;
295 RUN Sat.clear;
296 V.fixed := FALSE;
297 H.fixed := FALSE;
298 S.fixed := FALSE;
299 beta.fixed := FALSE;
300 END clear;
301 METHOD specify;
302 RUN residual.specify;
303 RUN Sat.specify;
304 VP.fixed := FALSE;
305 residual.V.fixed := FALSE;
306 residual.H.fixed := FALSE;
307 residual.S.fixed := FALSE;
308 END specify;
309
310 END Rackett_component;
311
312
313 MODEL partial_component REFINES thermodynamic_properties;
314
315 excess IS_A correction;
316
317 T, excess.T ARE_THE_SAME;
318 P, excess.P ARE_THE_SAME;
319
320 METHODS
321 METHOD clear;
322 RUN excess.clear;
323 V.fixed := FALSE;
324 H.fixed := FALSE;
325 S.fixed := FALSE;
326 END clear;
327 METHOD specify;
328 RUN excess.specify;
329 V.fixed := TRUE;
330 H.fixed := TRUE;
331 S.fixed := TRUE;
332 END specify;
333
334 END partial_component;
335
336
337 MODEL mixture;
338
339 components IS_A set OF symbol_constant;
340 y[components] IS_A fraction;
341 T IS_A temperature;
342 P IS_A pressure;
343 V IS_A molar_volume;
344 H IS_A molar_energy;
345 S IS_A molar_entropy;
346 R IS_A molar_gas_constant;
347 data[components] IS_A component_constants;
348
349 SUM[y[i] | i IN components] = 1.0;
350
351 METHODS
352 METHOD clear;
353 T.fixed := FALSE;
354 P.fixed := FALSE;
355 V.fixed := FALSE;
356 H.fixed := FALSE;
357 S.fixed := FALSE;
358 y[components].fixed := FALSE;
359 END clear;
360 METHOD specify;
361 T.fixed := TRUE;
362 P.fixed := TRUE;
363 V.fixed := TRUE;
364 H.fixed := TRUE;
365 S.fixed := TRUE;
366 y[components-[CHOICE[components]]].fixed := TRUE;
367 END specify;
368 METHOD reset;
369 RUN clear;
370 RUN specify;
371 END reset;
372
373 END mixture;
374
375 MODEL homogeneous_mixture REFINES mixture;
376 END homogeneous_mixture;
377
378 MODEL td_homogeneous_mixture REFINES homogeneous_mixture;
379
380 M IS_A molar_mass;
381 pure[components] IS_A pure_component;
382 partial[components] IS_A partial_component;
383
384 M/data[CHOICE[components]].mw =
385 SUM[y[i]*data[i].mw | i IN components]/
386 data[CHOICE[components]].mw;
387
388 T, pure[components].T, partial[components].T ARE_THE_SAME;
389 P, pure[components].P, partial[components].P ARE_THE_SAME;
390 pure[components] ARE_ALIKE;
391 V*data[CHOICE[components]].Pc/R/
392 data[CHOICE[components]].Tc =
393 SUM[y[i]*partial[i].V | i IN components]*
394 data[CHOICE[components]].Pc/R/
395 data[CHOICE[components]].Tc;
396 H/R/data[CHOICE[components]].Tc =
397 SUM[y[i]*partial[i].H | i IN components]/R/
398 data[CHOICE[components]].Tc;
399 S/R = SUM[y[i]*partial[i].S | i IN components]/R;
400 FOR i IN components CREATE
401 data[i], pure[i].data ARE_THE_SAME;
402 END FOR;
403 FOR i IN components CREATE
404 partial[i].excess.V*data[i].Pc/R/data[i].Tc =
405 (partial[i].V - pure[i].V)*data[i].Pc/R/data[i].Tc;
406 partial[i].excess.H/R/data[i].Tc =
407 (partial[i].H - pure[i].H)/R/data[i].Tc;
408 partial[i].excess.S/R =
409 (partial[i].S - pure[i].S + R*ln(y[i]))/R;
410 END FOR;
411 y[components].lower_bound := 1.0e-12;
412
413 METHODS
414 METHOD clear;
415 RUN pure[components].clear;
416 RUN partial[components].clear;
417 y[components].fixed := FALSE;
418 V.fixed := FALSE;
419 H.fixed := FALSE;
420 S.fixed := FALSE;
421 M.fixed := FALSE;
422 END clear;
423 METHOD specify;
424 RUN pure[components].specify;
425 RUN partial[components].specify;
426 y[components].fixed := TRUE;
427 y[CHOICE[components]].fixed := FALSE;
428 partial[components].V.fixed := FALSE;
429 partial[components].H.fixed := FALSE;
430 partial[components].S.fixed := FALSE;
431 END specify;
432
433 END td_homogeneous_mixture;
434
435 MODEL vapor_mixture REFINES td_homogeneous_mixture;
436
437 pure[components] IS_REFINED_TO vapor_component;
438
439 END vapor_mixture;
440
441
442 MODEL Pitzer_mixture REFINES vapor_mixture;
443
444 pure[components] IS_REFINED_TO Pitzer_component;
445
446 FOR i IN components CREATE
447 partial[i].excess.V*P/R/data[i].Tc =
448 -(pure[i].Z - 1.0)*(T/data[i].Tc)*(1.0 - y[i])^2 +
449 SUM[0.50*(1 - y[i])*y[j]*(P*data[i].Vc/R/data[i].Tc)*
450 ((1.0 + (data[j].Vc/data[i].Vc)^(1/3))^3/
451 (data[i].Zc + data[j].Zc))*
452 (0.083 - 0.422*(sqrt(data[i].Tc*data[j].Tc)/T)^1.6 +
453 0.5*(data[i].omega + data[j].omega)*
454 (0.139 - 0.172*(sqrt(data[i].Tc*data[j].Tc)/T)^4.2))
455 | j IN components - [i]];
456 partial[i].excess.H/R/data[i].Tc =
457 -(pure[i].residual.H/R/data[i].Tc)*(1.0 - y[i])^2 +
458 SUM[0.50*(1 - y[i])*y[j]*(P*data[i].Vc/R/data[i].Tc)*
459 ((1.0 + (data[j].Vc/data[i].Vc)^(1/3))^3/
460 (data[i].Zc + data[j].Zc))*
461 (0.083 - 1.097*(sqrt(data[i].Tc*data[j].Tc)/T)^1.6 +
462 0.5*(data[i].omega + data[j].omega)*
463 (0.139 - 0.894*(sqrt(data[i].Tc*data[j].Tc)/T)^4.2))
464 | j IN components - [i]];
465 partial[i].excess.S*T/R/data[i].Tc =
466 partial[i].excess.H/R/data[i].Tc -
467 partial[i].excess.V*P/R/data[i].Tc;
468 END FOR;
469
470 METHODS
471 METHOD specify;
472 RUN pure[components].specify;
473 RUN partial[components].specify;
474 y[components].fixed := TRUE;
475 y[CHOICE[components]].fixed := FALSE;
476 partial[components].V.fixed := FALSE;
477 partial[components].H.fixed := FALSE;
478 partial[components].S.fixed := FALSE;
479 partial[components].excess.V.fixed := FALSE;
480 partial[components].excess.H.fixed := FALSE;
481 partial[components].excess.S.fixed := FALSE;
482 END specify;
483
484 END Pitzer_mixture;
485
486
487 MODEL liquid_mixture REFINES td_homogeneous_mixture;
488
489 pure[components] IS_REFINED_TO liquid_component;
490
491 pure[components].Sat ARE_ALIKE;
492
493 END liquid_mixture;
494
495
496 MODEL UNIFAC_mixture REFINES liquid_mixture;
497
498 subgroups IS_A set OF symbol_constant;
499 groups IS_A set OF integer_constant;
500 comps[subgroups] IS_A set OF symbol_constant;
501 rv[components] IS_A UNIFAC_size;
502 qs[components] IS_A UNIFAC_size;
503 Jv[components] IS_A factor;
504 Ls[components] IS_A factor;
505 theta[subgroups] IS_A factor;
506 eta[subgroups] IS_A factor;
507 uc IS_A UNIFAC_constants;
508 pure[components] IS_REFINED_TO Rackett_component;
509
510 subgroups :== UNION[data[i].subgroups | i IN components];
511 groups :== UNION[data[i].groups | i IN components];
512 FOR k IN subgroups CREATE
513 comps[k] :== [i IN components | k IN data[i].subgroups];
514 END FOR;
515 FOR k IN subgroups CREATE
516 theta[k] = uc.Q[k]*SUM[data[i].nu[k]*y[i] | i IN comps[k]];
517 eta[k] =
518 SUM[theta[m] | m IN subgroups*uc.sub[uc.group[k]]] +
519 SUM[SUM[theta[m]*exp(-uc.a[g][uc.group[k]]/T)
520 | m IN subgroups*uc.sub[g]]
521 | g IN groups - [uc.group[k]]];
522 END FOR;
523
524 FOR i IN components CREATE
525 rv[i] :== SUM[0, data[i].nu[k]*uc.R[k] | k IN data[i].subgroups];
526 qs[i] :== SUM[0, data[i].nu[k]*uc.Q[k] | k IN data[i].subgroups];
527 END FOR;
528
529 FOR i IN components CREATE
530 rv[i] = Jv[i]*SUM[rv[j]*y[j] | j IN components];
531 qs[i] = Ls[i]*SUM[qs[j]*y[j] | j IN components];
532 partial[i].excess.H/R/data[i].Tc =
533 SUM[theta[k]*
534 SUM[SUM[theta[n]*
535 ((uc.a[g][uc.group[k]] -
536 uc.a[uc.group[n]][uc.group[k]])/data[i].Tc)*
537 exp(-(uc.a[g][uc.group[k]] +
538 uc.a[uc.group[n]][uc.group[k]])/T)*
539 SUM[data[i].nu[m]*uc.Q[m]
540 | m IN data[i].subgroups*uc.sub[g]]
541 | g IN data[i].groups - [uc.group[n]]]
542 | n IN subgroups]/eta[k]/eta[k]
543 | k IN subgroups] -
544 SUM[(data[i].nu[k]*uc.Q[k]/(
545 SUM[data[i].nu[m]*uc.Q[m]
546 | m IN data[i].subgroups*uc.sub[uc.group[k]]] +
547 SUM[SUM[data[i].nu[m]*uc.Q[m]*exp(-uc.a[g][uc.group[k]]/T)
548 | m IN data[i].subgroups*uc.sub[g]]
549 | g IN data[i].groups - [uc.group[k]]]))*
550 SUM[SUM[theta[n]*
551 ((uc.a[g][uc.group[k]] -
552 uc.a[uc.group[n]][uc.group[k]])/data[i].Tc)*
553 exp(-(uc.a[g][uc.group[k]] +
554 uc.a[uc.group[n]][uc.group[k]])/T)*
555 SUM[data[i].nu[m]*uc.Q[m]
556 | m IN data[i].subgroups*uc.sub[g]]
557 | g IN data[i].groups - [uc.group[n]]]
558 | n IN subgroups]/eta[k]
559 | k IN data[i].subgroups];
560 partial[i].excess.S*T/R/data[i].Tc =
561 partial[i].excess.H/R/data[i].Tc +
562 (-1.0 + Jv[i] - ln(Jv[i]) +
563 5.0*qs[i]*(1.0 - Jv[i]/Ls[i] + ln(Jv[i]/Ls[i])) -
564 qs[i]*(1 - ln(Ls[i])))*T/data[i].Tc +
565 SUM[theta[k]*(
566 SUM[data[i].nu[m]*uc.Q[m]
567 | m IN data[i].subgroups*uc.sub[uc.group[k]]] +
568 SUM[SUM[data[i].nu[m]*uc.Q[m]*exp(-uc.a[g][uc.group[k]]/T)
569 | m IN data[i].subgroups*uc.sub[g]]
570 | g IN data[i].groups - [uc.group[k]]])/eta[k]
571 | k IN subgroups]*T/data[i].Tc -
572 SUM[data[i].nu[k]*uc.Q[k]*ln((
573 SUM[data[i].nu[m]*uc.Q[m]
574 | m IN data[i].subgroups*uc.sub[uc.group[k]]] +
575 SUM[SUM[data[i].nu[m]*uc.Q[m]*exp(-uc.a[g][uc.group[k]]/T)
576 | m IN data[i].subgroups*uc.sub[g]]
577 | g IN data[i].groups - [uc.group[k]]])/eta[k])
578 | k IN data[i].subgroups]*T/data[i].Tc;
579 END FOR;
580
581 Jv[components].lower_bound := 1.0e-12;
582 Ls[components].lower_bound := 1.0e-12;
583 theta[subgroups].lower_bound := 0.0;
584 eta[subgroups].lower_bound := 0.0;
585
586 METHODS
587 METHOD clear;
588 RUN pure[components].clear;
589 RUN partial[components].clear;
590 y[components].fixed := FALSE;
591 V.fixed := FALSE;
592 H.fixed := FALSE;
593 S.fixed := FALSE;
594 M.fixed := FALSE;
595 Jv[components].fixed := FALSE;
596 Ls[components].fixed := FALSE;
597 theta[subgroups].fixed := FALSE;
598 eta[subgroups].fixed := FALSE;
599 END clear;
600 METHOD specify;
601 RUN pure[components].specify;
602 RUN partial[components].specify;
603 y[components].fixed := TRUE;
604 y[CHOICE[components]].fixed := FALSE;
605 partial[components].V.fixed := FALSE;
606 partial[components].H.fixed := FALSE;
607 partial[components].S.fixed := FALSE;
608 partial[components].excess.H.fixed := FALSE;
609 partial[components].excess.S.fixed := FALSE;
610 END specify;
611
612 END UNIFAC_mixture;
613
614
615 MODEL heterogeneous_mixture REFINES mixture;
616
617 reference IS_A symbol_constant;
618 phases IS_A set OF symbol_constant;
619 mix[phases] IS_A homogeneous_mixture;
620 alpha[phases-[reference]][components] IS_A factor;
621 ave_alpha[phases-[reference]] IS_A factor;
622 phi[phases] IS_A fraction;
623
624 components, mix[phases].components ARE_THE_SAME;
625 FOR i IN components CREATE
626 y[i] = SUM[phi[j]*mix[j].y[i] | j IN phases];
627 FOR j IN phases - [reference] CREATE
628 ave_alpha[j]*mix[j].y[i] =
629 alpha[j][i]*mix[reference].y[i];
630 END FOR;
631 END FOR;
632
633 METHODS
634 METHOD clear;
635 RUN mix[phases].clear;
636 y[components].fixed := FALSE;
637 alpha[phases-[reference]][components].fixed := FALSE;
638 ave_alpha[phases-[reference]].fixed := FALSE;
639 phi[phases].fixed := FALSE;
640 END clear;
641 METHOD specify;
642 RUN mix[phases].specify;
643 alpha[phases - [reference]][components].fixed := TRUE;
644 y[components-[CHOICE[components]]].fixed := TRUE;
645 mix[phases].y[components].fixed := FALSE;
646 phi[phases-[reference]].fixed := TRUE;
647 END specify;
648
649 END heterogeneous_mixture;
650
651
652 MODEL td_heterogeneous_mixture REFINES heterogeneous_mixture;
653
654 M IS_A molar_mass;
655 mix[phases] IS_REFINED_TO td_homogeneous_mixture;
656
657 T, mix[phases].T ARE_THE_SAME;
658 P, mix[phases].P ARE_THE_SAME;
659 FOR i IN components CREATE
660 data[i], mix[phases].data[i] ARE_THE_SAME;
661 END FOR;
662 V*SUM[data[i].Pc | i IN components]/R/
663 SUM[data[i].Tc | i IN components] =
664 SUM[phi[j]*mix[j].V | j IN phases]*
665 SUM[data[i].Pc | i IN components]/R/
666 SUM[data[i].Tc | i IN components];
667 H/R/SUM[data[i].Tc | i IN components] =
668 SUM[phi[j]*mix[j].H | j IN phases]/R/
669 SUM[data[i].Tc | i IN components];
670 S/R = SUM[phi[j]*mix[j].S | j IN phases]/R;
671 M/SUM[data[i].mw | i IN components] =
672 SUM[y[i]*data[i].mw | i IN components]/
673 SUM[data[i].mw | i IN components];
674
675 METHODS
676 METHOD clear;
677 RUN mix[phases].clear;
678 y[components].fixed := FALSE;
679 V.fixed := FALSE;
680 H.fixed := FALSE;
681 S.fixed := FALSE;
682 M.fixed := FALSE;
683 alpha[phases-[reference]][components].fixed := FALSE;
684 ave_alpha[phases-[reference]].fixed := FALSE;
685 phi[phases].fixed := FALSE;
686 END clear;
687
688 END td_heterogeneous_mixture;
689
690 MODEL equilibrium_mixture REFINES td_heterogeneous_mixture;
691
692 FOR i IN components CREATE
693 FOR j IN phases - [reference] CREATE
694 (mix[j].partial[i].H -
695 mix[reference].partial[i].H)/R/data[i].Tc =
696 (mix[j].partial[i].S -
697 mix[reference].partial[i].S)*T/R/data[i].Tc;
698 END FOR;
699 END FOR;
700
701 METHODS
702 METHOD specify;
703 RUN mix[phases].specify;
704 y[components].fixed := TRUE;
705 y[CHOICE[components]].fixed := FALSE;
706 mix[phases].y[components].fixed := FALSE;
707 alpha[phases - [reference]][components].fixed := FALSE;
708 ave_alpha[phases - [reference]] := 1.0;
709 ave_alpha[phases - [reference]].fixed := TRUE;
710 phi[phases].fixed := FALSE;
711 phi[reference].fixed := TRUE;
712 T.fixed := FALSE;
713 END specify;
714
715 END equilibrium_mixture;
716
717
718 MODEL murphree_equilibrium_mixture REFINES td_heterogeneous_mixture;
719
720 (* ASSUMES vapor-liquid pd, with liquid reference *)
721
722 vap_eq IS_A Pitzer_mixture;
723 equil_alpha[components] IS_A factor;
724 ref_y[components] IS_A fraction;
725 murph_eff IS_A factor;
726
727
728 vap_eq, mix['vapor'] ARE_ALIKE;
729
730 T, vap_eq.T ARE_THE_SAME;
731 P, vap_eq.P ARE_THE_SAME;
732 components, vap_eq.components ARE_THE_SAME;
733 FOR i IN components CREATE
734 data[i],
735 vap_eq.data[i] ARE_THE_SAME;
736 END FOR;
737
738 SUM[ref_y[components]] = 1;
739 FOR i IN components CREATE
740
741 vap_eq.y[i] = equil_alpha[i]*mix[reference].y[i];
742 (vap_eq.partial[i].H - mix[reference].partial[i].H)/R/T =
743 (vap_eq.partial[i].S - mix[reference].partial[i].S)/R;
744 END FOR;
745
746 FOR i IN components - [CHOICE[components]] CREATE
747 murph_eff*(vap_eq.y[i] - ref_y[i]) =
748 mix['vapor'].y[i] - ref_y[i];
749 END FOR;
750
751 METHODS
752 METHOD clear;
753 RUN mix[phases].clear;
754 V.fixed := FALSE;
755 H.fixed := FALSE;
756 S.fixed := FALSE;
757 y[components].fixed := FALSE;
758 alpha[phases-[reference]][components].fixed := FALSE;
759 ave_alpha[phases-[reference]].fixed := FALSE;
760 phi[phases].fixed := FALSE;
761 M.fixed := FALSE;
762 RUN vap_eq.clear;
763 equil_alpha[components].fixed := FALSE;
764 ref_y[components].fixed := FALSE;
765 murph_eff.fixed := FALSE;
766 END clear;
767 METHOD specify;
768 RUN mix[phases].specify;
769 y[components].fixed := TRUE;
770 y[CHOICE[components]].fixed := FALSE;
771 mix[phases].y[components].fixed := FALSE;
772 alpha[phases - [reference]][components].fixed := FALSE;
773 ave_alpha[phases - [reference]] := 1.0;
774 ave_alpha[phases - [reference]].fixed := TRUE;
775 phi[phases].fixed := FALSE;
776 phi[reference].fixed := TRUE;
777 RUN vap_eq.specify;
778 vap_eq.y[components].fixed := FALSE;
779 equil_alpha[components].fixed := FALSE;
780 ref_y[components - [CHOICE[components]]].fixed := TRUE;
781 murph_eff.fixed := TRUE;
782 T.fixed := FALSE;
783 END specify;
784
785 END murphree_equilibrium_mixture;

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