1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
|
(* ASCEND modelling environment
Copyright (C) 1998, 2007 Carnegie Mellon University
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*)
REQUIRE "atoms.a4l";
(*
The following the conditional model is discussed in the PhD thesis of
Vicente Rico-Ramirez,
https://pse.cheme.cmu.edu/ascend/ftp/pdfThesis/victhesis.pdf
The original problem was presented by Joe Zaher
Zaher, Conditional Modeling. Ph.D. Thesis, Carnegie Mellon University,
Pittsburgh, PA. 1995.
The problem consists of a phase equilibrium calculation of a
multicomponent mixture. For each of the phases (3 phases are possible:
organic-liquid, inorganic-liquid, and vapor) there is a disjunctive
statement which represents whether the phase exists or not. It represents
a problem which we can represent as a conditional model and solve with
the ASCEND conditional solver, CMSlv.
by Vicente Rico-Ramirez, April 10, 1998
*)
MODEL phaseq;
phases IS_A set OF symbol_constant;
components IS_A set OF symbol_constant;
k_terms IS_A set OF integer_constant;
z[components] IS_A fraction;
y[phases][components] IS_A fraction;
phi[phases] IS_A fraction;
exist[phases] IS_A boolean_var;
P IS_A pressure;
T IS_A temperature;
Pcr[components] IS_A critical_pressure;
Tcr[components] IS_A critical_temperature;
B[components][k_terms] IS_A factor_constant;
C[k_terms] IS_A factor_constant;
A[components][components] IS_A temperature_constant;
(* Definition os sets *)
components :== ['B','E','W'];
phases :== ['A','O','V'];
k_terms :== [1..4];
(* Boundaries *)
CONDITIONAL
FOR i IN phases CREATE
cond[i]: SUM[y[i][j] | j IN components ]+ phi[i] >= 1.0;
END FOR;
END CONDITIONAL;
FOR i IN phases CREATE
(* Variant Equations *)
sum[i]: SUM[y[i][j] | j IN components ] = 1.0;
frac[i]: phi[i] = 0.0;
exist[i] == SATISFIED(cond[i],1e-08);
(* Disjunctive statement *)
WHEN (exist[i])
CASE TRUE:
USE sum[i];
CASE FALSE:
USE frac[i];
END WHEN;
END FOR;
(* Invariant Equations *)
FOR i IN components CREATE
y['V'][i] = y['A'][i] * (Pcr[i]/P) * exp(
((1/T) *
SUM[ ( A[i][j] - (0.5*
SUM[ A[j][k] * y['A'][k] | k IN components]
) ) * y['A'][j]
| j IN components ]) +
((Tcr[i]/T) *
SUM[ B[i][k] * ( (1 - (T/Tcr[i]))^C[k] ) | k IN k_terms] ) );
y['V'][i] = y['O'][i] * (Pcr[i]/P) * exp(
((1/T) *
SUM[ ( A[i][j] - (0.5*
SUM[ A[j][k] * y['O'][k] | k IN components]
) ) * y['O'][j]
| j IN components ]) +
((Tcr[i]/T) *
SUM[ B[i][k] * ( (1 - (T/Tcr[i]))^C[k] ) | k IN k_terms] ) );
END FOR;
FOR i IN components CREATE
SUM[phi[j]*y[j][i] | j IN phases] = z[i];
END FOR;
(* Constants *)
Tcr['B'] :== 562.2 {K};
Tcr['E'] :== 516.2 {K};
Tcr['W'] :== 647.4 {K};
Pcr['B'] :== 48.3 {atm};
Pcr['E'] :== 63.0 {atm};
Pcr['W'] :== 217.6 {atm};
C[1] :== 1.0;
C[2] :== 1.5;
C[3] :== 3.0;
C[4] :== 6.0;
A['B']['B'] :== 0.0{K};
A['B']['E'] :== 576.3 {K};
A['B']['W'] :== 1074.5 {K};
A['E']['B'] :== 576.3 {K};
A['E']['E'] :== 0.0 {K};
A['E']['W'] :== 351.8 {K};
A['W']['B'] :== 1074.5 {K};
A['W']['E'] :== 351.8 {K};
A['W']['W'] :== 0.0 {K};
B['B'][1] :== -6.98273;
B['B'][2] :== 1.33213;
B['B'][3] :== -2.62863;
B['B'][4] :== -3.33399;
B['E'][1] :== -8.51838;
B['E'][2] :== 0.34163;
B['E'][3] :== -5.73683;
B['E'][4] :== 8.32581;
B['W'][1] :== -7.76451;
B['W'][2] :== 1.45838;
B['W'][3] :== -2.77580;
B['W'][4] :== -1.23303;
METHODS
METHOD default_self;
END default_self;
METHOD specify;
FIX P;
FIX T;
FOR i IN components DO
FIX z[i];
END FOR;
END specify;
METHOD values;
(* fixed *)
T := 340.0 {K};
P := 1.0 {atm};
z['B'] := 0.50;
z['E'] := 0.15;
z['W'] := 0.35;
(* initial values for reals *)
y['A']['B'] := 0.02;
y['A']['E'] := 0.03;
y['A']['W'] := 0.95;
y['O']['B'] := 0.95;
y['O']['E'] := 0.03;
y['O']['W'] := 0.02;
y['V']['B'] := 0.50;
y['V']['E'] := 0.15;
y['V']['W'] := 0.35;
phi['A'] := 0.0;
phi['O'] := 0.0;
phi['V'] := 0.0;
(* initial values for booleans *)
FOR i IN phases DO
exist[i] := SATISFIED(cond[i],1e-08);
END FOR;
END values;
METHOD on_load;
RUN default_self;
RUN reset;
RUN values;
END on_load;
METHOD self_test;
(* not tests yet *)
END self_test;
END phaseq;
|