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

Contents of /trunk/models/phaseq.a4c

Parent Directory Parent Directory | Revision Log Revision Log


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

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