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

Contents of /trunk/models/phaseq.a4c

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1 - (show annotations) (download) (as text)
Fri Oct 29 20:54:12 2004 UTC (19 years, 10 months ago) by aw0a
File MIME type: text/x-ascend
File size: 5977 byte(s)
Setting up web subdirectory in repository
1 REQUIRE "atoms.a4l";
2 (* => atoms.a4l, measures.a4l, system.a4l, basemodel.a4l *)
3 PROVIDE "phaseq.a4c";
4 (*
5 * This file is part of the ASCEND Modeling Library and is released
6 * under the GNU Public License as described at the end of this file.
7 *
8 * Use of this module is demonstrated by the associated script file
9 * phaseq.a4s.
10 *)
11
12 (*
13 Ascend model of the phase Equilibrium example presented by Zaher
14 -- Conditional Modeling. Ph.D. Thesis, Carnegie Mellon University,
15 Pittsburgh, PA, 15213. 1995 --. The problem consists of a phase equilibrium
16 calculation of a multicomponent mixture. For each of the phases (3 phases
17 are possible: organic-liquid, inorganic-liquid, and vapor) there is a
18 disjunctive statement which represents whether the phase exists or not.
19 It represent a problem which we can represent as a conditional model and
20 solve with the ascend conditional solver CMSlv.
21
22 This model requires:
23 "system.a4l"
24 "atoms.a4l"
25 *)
26
27 (* ************************************************* *)
28
29 MODEL phaseq;
30
31 phases IS_A set OF symbol_constant;
32 components IS_A set OF symbol_constant;
33 k_terms IS_A set OF integer_constant;
34 z[components] IS_A fraction;
35 y[phases][components] IS_A fraction;
36 phi[phases] IS_A fraction;
37 exist[phases] IS_A boolean_var;
38 P IS_A pressure;
39 T IS_A temperature;
40 Pcr[components] IS_A critical_pressure;
41 Tcr[components] IS_A critical_temperature;
42 B[components][k_terms] IS_A factor_constant;
43 C[k_terms] IS_A factor_constant;
44 A[components][components] IS_A temperature_constant;
45
46 (* Definition os sets *)
47
48 components :== ['B','E','W'];
49 phases :== ['A','O','V'];
50 k_terms :== [1..4];
51
52 (* Boundaries *)
53 CONDITIONAL
54 FOR i IN phases CREATE
55 cond[i]: SUM[y[i][j] | j IN components ]+ phi[i] >= 1.0;
56 END FOR;
57 END CONDITIONAL;
58
59
60 FOR i IN phases CREATE
61 (* Variant Equations *)
62 sum[i]: SUM[y[i][j] | j IN components ] = 1.0;
63 frac[i]: phi[i] = 0.0;
64 exist[i] == SATISFIED(cond[i],1e-08);
65 (* Disjunctive statement *)
66 WHEN (exist[i])
67 CASE TRUE:
68 USE sum[i];
69 CASE FALSE:
70 USE frac[i];
71 END WHEN;
72
73 END FOR;
74
75 (* Invariant Equations *)
76
77 FOR i IN components CREATE
78 y['V'][i] = y['A'][i] * (Pcr[i]/P) * exp(
79 ((1/T) *
80 SUM[ ( A[i][j] - (0.5*
81 SUM[ A[j][k] * y['A'][k] | k IN components]
82 ) ) * y['A'][j]
83 | j IN components ]) +
84 ((Tcr[i]/T) *
85 SUM[ B[i][k] * ( (1 - (T/Tcr[i]))^C[k] ) | k IN k_terms] ) );
86
87 y['V'][i] = y['O'][i] * (Pcr[i]/P) * exp(
88 ((1/T) *
89 SUM[ ( A[i][j] - (0.5*
90 SUM[ A[j][k] * y['O'][k] | k IN components]
91 ) ) * y['O'][j]
92 | j IN components ]) +
93 ((Tcr[i]/T) *
94 SUM[ B[i][k] * ( (1 - (T/Tcr[i]))^C[k] ) | k IN k_terms] ) );
95 END FOR;
96
97 FOR i IN components CREATE
98 SUM[phi[j]*y[j][i] | j IN phases] = z[i];
99 END FOR;
100
101 (* Constants *)
102 Tcr['B'] :== 562.2 {K};
103 Tcr['E'] :== 516.2 {K};
104 Tcr['W'] :== 647.4 {K};
105 Pcr['B'] :== 48.3 {atm};
106 Pcr['E'] :== 63.0 {atm};
107 Pcr['W'] :== 217.6 {atm};
108 C[1] :== 1.0;
109 C[2] :== 1.5;
110 C[3] :== 3.0;
111 C[4] :== 6.0;
112 A['B']['B'] :== 0.0{K};
113 A['B']['E'] :== 576.3 {K};
114 A['B']['W'] :== 1074.5 {K};
115 A['E']['B'] :== 576.3 {K};
116 A['E']['E'] :== 0.0 {K};
117 A['E']['W'] :== 351.8 {K};
118 A['W']['B'] :== 1074.5 {K};
119 A['W']['E'] :== 351.8 {K};
120 A['W']['W'] :== 0.0 {K};
121 B['B'][1] :== -6.98273;
122 B['B'][2] :== 1.33213;
123 B['B'][3] :== -2.62863;
124 B['B'][4] :== -3.33399;
125 B['E'][1] :== -8.51838;
126 B['E'][2] :== 0.34163;
127 B['E'][3] :== -5.73683;
128 B['E'][4] :== 8.32581;
129 B['W'][1] :== -7.76451;
130 B['W'][2] :== 1.45838;
131 B['W'][3] :== -2.77580;
132 B['W'][4] :== -1.23303;
133
134 METHODS
135
136 METHOD default_self;
137 END default_self;
138
139 METHOD specify;
140 P.fixed := TRUE;
141 T.fixed := TRUE;
142 FOR i IN components DO
143 z[i].fixed := TRUE;
144 END FOR;
145 END specify;
146
147 METHOD values;
148 (* fixed *)
149 T := 340.0 {K};
150 P := 1.0 {atm};
151 z['B'] := 0.50;
152 z['E'] := 0.15;
153 z['W'] := 0.35;
154 (* initial values for reals *)
155 y['A']['B'] := 0.02;
156 y['A']['E'] := 0.03;
157 y['A']['W'] := 0.95;
158
159 y['O']['B'] := 0.95;
160 y['O']['E'] := 0.03;
161 y['O']['W'] := 0.02;
162
163 y['V']['B'] := 0.50;
164 y['V']['E'] := 0.15;
165 y['V']['W'] := 0.35;
166
167 phi['A'] := 0.0;
168 phi['O'] := 0.0;
169 phi['V'] := 0.0;
170
171 (* initial values for booleans *)
172 FOR i IN phases DO
173 exist[i] := SATISFIED(cond[i],1e-08);
174 END FOR;
175 END values;
176
177 END phaseq;
178
179
180 (*
181 * phaseq.a4c
182 * by Vicente Rico-Ramirez
183 * April 10, 1998
184 * Part of the ASCEND Library
185 * $Date: 1998/06/17 19:13:16 $
186 * $Revision: 1.3 $
187 * $Author: mthomas $
188 * $Source: /afs/cs.cmu.edu/project/ascend/Repository/models/phaseq.a4c,v $
189 *
190 * This file is part of the ASCEND Modeling Library.
191 *
192 * Copyright (C) 1998 Carnegie Mellon University
193 *
194 * The ASCEND Modeling Library is free software; you can redistribute
195 * it and/or modify it under the terms of the GNU General Public
196 * License as published by the Free Software Foundation; either
197 * version 2 of the License, or (at your option) any later version.
198 *
199 * The ASCEND Modeling Library is distributed in hope that it will be
200 * useful, but WITHOUT ANY WARRANTY; without even the implied
201 * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
202 * See the GNU General Public License for more details.
203 *
204 * You should have received a copy of the GNU General Public License
205 * along with the program; if not, write to the Free Software
206 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139 USA. Check
207 * the file named COPYING.
208 *)

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