1 |
aw0a |
1 |
REQUIRE "atoms.a4l"; |
2 |
|
|
(* => atoms.a4l, measures.a4l, system.a4l, basemodel.a4l *) |
3 |
|
|
PROVIDE "phaseq_comp.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_comp.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 |
|
|
Each disjunctive statement is represented by using a complementarity |
20 |
|
|
formulation, in such a way that we can solve the problem by using a |
21 |
|
|
conventional nonlinear solver. |
22 |
|
|
|
23 |
|
|
This model requires: |
24 |
|
|
"system.a4l" |
25 |
|
|
"atoms.a4l" |
26 |
|
|
*) |
27 |
|
|
|
28 |
|
|
(* ************************************************* *) |
29 |
|
|
|
30 |
|
|
MODEL phaseq; |
31 |
|
|
|
32 |
|
|
phases IS_A set OF symbol_constant; |
33 |
|
|
components IS_A set OF symbol_constant; |
34 |
|
|
k_terms IS_A set OF integer_constant; |
35 |
|
|
z[components] IS_A fraction; |
36 |
|
|
y[phases][components] IS_A fraction; |
37 |
|
|
phi[phases] IS_A fraction; |
38 |
|
|
exist[phases] IS_A boolean_var; |
39 |
|
|
P IS_A pressure; |
40 |
|
|
T IS_A temperature; |
41 |
|
|
Pcr[components] IS_A pressure; |
42 |
|
|
Tcr[components] IS_A temperature; |
43 |
|
|
B[components][k_terms] IS_A factor; |
44 |
|
|
C[k_terms] IS_A factor; |
45 |
|
|
A[components][components] IS_A temperature; |
46 |
|
|
h1[phases],h2[phases] IS_A fraction; |
47 |
|
|
|
48 |
|
|
(* Definition of sets *) |
49 |
|
|
|
50 |
|
|
components :== ['B','E','W']; |
51 |
|
|
phases :== ['A','O','V']; |
52 |
|
|
k_terms :== [1..4]; |
53 |
|
|
|
54 |
|
|
(* Complementarity Equations *) |
55 |
|
|
|
56 |
|
|
FOR i IN phases CREATE |
57 |
|
|
SUM[y[i][j] | j IN components ] = 1.0 - h1[i]; |
58 |
|
|
phi[i] = h2[i]; |
59 |
|
|
h1[i] * h2[i] = 0; |
60 |
|
|
END FOR; |
61 |
|
|
|
62 |
|
|
(* Invariant Equations *) |
63 |
|
|
|
64 |
|
|
FOR i IN components CREATE |
65 |
|
|
y['V'][i] = y['A'][i] * (Pcr[i]/P) * exp( |
66 |
|
|
((1/T) * |
67 |
|
|
SUM[ ( A[i][j] - (0.5* |
68 |
|
|
SUM[ A[j][k] * y['A'][k] | k IN components] |
69 |
|
|
) ) * y['A'][j] |
70 |
|
|
| j IN components ]) + |
71 |
|
|
((Tcr[i]/T) * |
72 |
|
|
SUM[ B[i][k] * ( (1 - (T/Tcr[i]))^C[k] ) | k IN k_terms] ) ); |
73 |
|
|
|
74 |
|
|
y['V'][i] = y['O'][i] * (Pcr[i]/P) * exp( |
75 |
|
|
((1/T) * |
76 |
|
|
SUM[ ( A[i][j] - (0.5* |
77 |
|
|
SUM[ A[j][k] * y['O'][k] | k IN components] |
78 |
|
|
) ) * y['O'][j] |
79 |
|
|
| j IN components ]) + |
80 |
|
|
((Tcr[i]/T) * |
81 |
|
|
SUM[ B[i][k] * ( (1 - (T/Tcr[i]))^C[k] ) | k IN k_terms] ) ); |
82 |
|
|
END FOR; |
83 |
|
|
|
84 |
|
|
FOR i IN components CREATE |
85 |
|
|
SUM[phi[j]*y[j][i] | j IN phases] = z[i]; |
86 |
|
|
END FOR; |
87 |
|
|
|
88 |
|
|
|
89 |
|
|
METHODS |
90 |
|
|
|
91 |
|
|
METHOD specify; |
92 |
johnpye |
576 |
FIX P; |
93 |
|
|
FIX T; |
94 |
aw0a |
1 |
FOR i IN components DO |
95 |
johnpye |
576 |
FIX z[i]; |
96 |
|
|
FIX Pcr[i]; |
97 |
|
|
FIX Tcr[i]; |
98 |
aw0a |
1 |
FOR j IN components DO |
99 |
johnpye |
576 |
FIX A[i][j]; |
100 |
aw0a |
1 |
END FOR; |
101 |
|
|
FOR j IN k_terms DO |
102 |
johnpye |
576 |
FIX B[i][j]; |
103 |
aw0a |
1 |
END FOR; |
104 |
|
|
END FOR; |
105 |
|
|
FOR j IN k_terms DO |
106 |
johnpye |
576 |
FIX C[j]; |
107 |
aw0a |
1 |
END FOR; |
108 |
|
|
END specify; |
109 |
|
|
|
110 |
|
|
METHOD bound_self; |
111 |
|
|
FOR i IN components DO |
112 |
|
|
FOR j IN components DO |
113 |
|
|
A[i][j].lower_bound := 0 {K}; |
114 |
|
|
END FOR; |
115 |
|
|
END FOR; |
116 |
|
|
END bound_self; |
117 |
|
|
|
118 |
|
|
METHOD default_self; |
119 |
|
|
(* Constants *) |
120 |
|
|
Tcr['B'] := 562.2 {K}; |
121 |
|
|
Tcr['E'] := 516.2 {K}; |
122 |
|
|
Tcr['W'] := 647.4 {K}; |
123 |
|
|
Pcr['B'] := 48.3 {atm}; |
124 |
|
|
Pcr['E'] := 63.0 {atm}; |
125 |
|
|
Pcr['W'] := 217.6 {atm}; |
126 |
|
|
C[1] := 1.0; |
127 |
|
|
C[2] := 1.5; |
128 |
|
|
C[3] := 3.0; |
129 |
|
|
C[4] := 6.0; |
130 |
|
|
A['B']['B'] := 0.0{K}; |
131 |
|
|
A['B']['E'] := 576.3 {K}; |
132 |
|
|
A['B']['W'] := 1074.5 {K}; |
133 |
|
|
A['E']['B'] := 576.3 {K}; |
134 |
|
|
A['E']['E'] := 0.0 {K}; |
135 |
|
|
A['E']['W'] := 351.8 {K}; |
136 |
|
|
A['W']['B'] := 1074.5 {K}; |
137 |
|
|
A['W']['E'] := 351.8 {K}; |
138 |
|
|
A['W']['W'] := 0.0 {K}; |
139 |
|
|
B['B'][1] := -6.98273; |
140 |
|
|
B['B'][2] := 1.33213; |
141 |
|
|
B['B'][3] := -2.62863; |
142 |
|
|
B['B'][4] := -3.33399; |
143 |
|
|
B['E'][1] := -8.51838; |
144 |
|
|
B['E'][2] := 0.34163; |
145 |
|
|
B['E'][3] := -5.73683; |
146 |
|
|
B['E'][4] := 8.32581; |
147 |
|
|
B['W'][1] := -7.76451; |
148 |
|
|
B['W'][2] := 1.45838; |
149 |
|
|
B['W'][3] := -2.77580; |
150 |
|
|
B['W'][4] := -1.23303; |
151 |
|
|
|
152 |
|
|
RUN bound_self; |
153 |
|
|
END default_self; |
154 |
|
|
|
155 |
|
|
METHOD values; |
156 |
|
|
(* fixed *) |
157 |
|
|
T := 340.0 {K}; |
158 |
|
|
P := 1.0 {atm}; |
159 |
|
|
z['B'] := 0.50; |
160 |
|
|
z['E'] := 0.15; |
161 |
|
|
z['W'] := 0.35; |
162 |
|
|
(* initial values *) |
163 |
|
|
y['A']['B'] := 0.02; |
164 |
|
|
y['A']['E'] := 0.03; |
165 |
|
|
y['A']['W'] := 0.95; |
166 |
|
|
|
167 |
|
|
y['O']['B'] := 0.95; |
168 |
|
|
y['O']['E'] := 0.03; |
169 |
|
|
y['O']['W'] := 0.02; |
170 |
|
|
|
171 |
|
|
y['V']['B'] := 0.50; |
172 |
|
|
y['V']['E'] := 0.15; |
173 |
|
|
y['V']['W'] := 0.35; |
174 |
|
|
|
175 |
|
|
phi['A'] := 0.0; |
176 |
|
|
phi['O'] := 0.0; |
177 |
|
|
phi['V'] := 0.0; |
178 |
|
|
END values; |
179 |
|
|
|
180 |
|
|
END phaseq; |
181 |
|
|
|
182 |
|
|
|
183 |
|
|
(* |
184 |
|
|
* phaseq_comp.a4c |
185 |
|
|
* by Vicente Rico-Ramirez |
186 |
|
|
* April 10, 1998 |
187 |
|
|
* Part of the ASCEND Library |
188 |
|
|
* $Date: 1998/06/17 19:13:37 $ |
189 |
|
|
* $Revision: 1.3 $ |
190 |
|
|
* $Author: mthomas $ |
191 |
|
|
* $Source: /afs/cs.cmu.edu/project/ascend/Repository/models/phaseq_comp.a4c,v $ |
192 |
|
|
* |
193 |
|
|
* This file is part of the ASCEND Modeling Library. |
194 |
|
|
* |
195 |
|
|
* Copyright (C) 1998 Carnegie Mellon University |
196 |
|
|
* |
197 |
|
|
* The ASCEND Modeling Library is free software; you can redistribute |
198 |
|
|
* it and/or modify it under the terms of the GNU General Public |
199 |
|
|
* License as published by the Free Software Foundation; either |
200 |
|
|
* version 2 of the License, or (at your option) any later version. |
201 |
|
|
* |
202 |
|
|
* The ASCEND Modeling Library is distributed in hope that it will be |
203 |
|
|
* useful, but WITHOUT ANY WARRANTY; without even the implied |
204 |
|
|
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
205 |
|
|
* See the GNU General Public License for more details. |
206 |
|
|
* |
207 |
|
|
* You should have received a copy of the GNU General Public License |
208 |
jpye |
2649 |
* along with this program. If not, see <http://www.gnu.org/licenses/>. |
209 |
aw0a |
1 |
*) |