~jdpipe/ascend/trunk-old

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
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
(*	ASCEND modelling environment
	Copyright (C) 1998, 2006, 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";
(*
	Model of a linear mass balance as discussed in the PhD thesis of 
	Vicente Rico-Ramirez, page 84.
	https://pse.cheme.cmu.edu/ascend/ftp/pdfThesis/victhesis.pdf

	The problem consists of a six unit operations flowsheet, each unit operation
	having three possible operation	modes. The problem was originally presented by

	Grossmann and Turkay, Solution of Algebraic Systems of Disjuctive Equations, Comp.
	and Chem. Eng., Vol. 20, Suppl. Part A, s339-44, 1996

	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 unit_op1;

	Fmain,Fsub1,Fsub2	IS_A molar_rate;
	B[bounds]		IS_A molar_rate;
	disjunc			IS_A set OF integer_constant;
        bounds			IS_A set OF integer_constant;
	a[disjunc]		IS_A factor_constant;
	b[disjunc]		IS_A factor_constant;
	bol1,bol2		IS_A boolean_var;

	disjunc :== [1..3];
	bounds :== [1..2];

	(* Boundaries *)
	CONDITIONAL
	  cond1: Fmain <= B[1];
	  cond2: Fmain >= B[2];
	END CONDITIONAL;

	bol1 == SATISFIED(cond1,1e-08{lb_mole/hour});
	bol2 == SATISFIED(cond2,1e-08{lb_mole/hour});

	(* Variant Equations *)
	eq1a: Fsub1 = a[1] * Fmain;
	eq1b: Fsub2 = b[1] * Fmain;

	eq2a: Fsub1 = a[2] * Fmain;
	eq2b: Fsub2 = b[2] * Fmain;

	eq3a: Fsub1 = a[3] * Fmain;
	eq3b: Fsub2 = b[3] * Fmain;

	(* Disjunctive Statements *)
	WHEN (bol1,bol2)
	  CASE TRUE,FALSE:
		USE eq1a;
		USE eq1b;
	  CASE FALSE,FALSE:
		USE eq2a;
		USE eq2b;
	  CASE FALSE,TRUE:
		USE eq3a;
		USE eq3b;
	END WHEN;

METHODS

   METHOD default_self;
   END default_self;

   METHOD specify;
	FOR i IN bounds DO
	   FIX B[i];
	END FOR;
   END specify;

   METHOD values;
	bol1 := SATISFIED(cond1,1e-08{lb_mole/hour});
	bol2 := SATISFIED(cond2,1e-08{lb_mole/hour});
   END values;

END unit_op1;


(*-----------------------------------*)

MODEL unit_op2;

	Fmain,Fsub1		IS_A molar_rate;
	B[bounds]		IS_A molar_rate;
	disjunc			IS_A set OF integer_constant;
    bounds			IS_A set OF integer_constant;
	a[disjunc]		IS_A factor_constant;
	bol1,bol2		IS_A boolean_var;

	disjunc :== [1..3];
	bounds :== [1..2];

	(* Boundaries *)
	CONDITIONAL
	  cond1: Fmain <= B[1];
	  cond2: Fmain >= B[2];
	END CONDITIONAL;

	bol1 == SATISFIED(cond1,1e-08{lb_mole/hour});
	bol2 == SATISFIED(cond2,1e-08{lb_mole/hour});


	(* Variant Equations  *)
	eq1: Fsub1 = a[1] * Fmain;
	eq2: Fsub1 = a[2] * Fmain;
	eq3: Fsub1 = a[3] * Fmain;

	(* Disjunctive Statements  *)
	WHEN (bol1,bol2)
	  CASE TRUE,FALSE:
		USE eq1;
	  CASE FALSE,FALSE:
		USE eq2;
	  CASE FALSE,TRUE:
		USE eq3;
	END WHEN;


METHODS

   METHOD default_self;
   END default_self;

   METHOD specify;
	FOR i IN bounds DO
	   FIX B[i];
	END FOR;
   END specify;

   METHOD values;
	bol1 := SATISFIED(cond1,1e-08{lb_mole/hour});
	bol2 := SATISFIED(cond2,1e-08{lb_mole/hour});
   END values;

END unit_op2;


(*-----------------------------------*)

(* the flowsheet *)

MODEL linmassbal;

	U[num_units1]	IS_A unit_op1;
	U2[num_units2]	IS_A unit_op2;
	F[num_flow]	IS_A molar_rate;
	num_units1	IS_A set OF integer_constant;
	num_units2	IS_A integer_constant;
	num_flow	IS_A set OF integer_constant;

	(* wire up flowsheet *)
	F[2],U[2].Fsub1			ARE_THE_SAME;
	F[3],U[4].Fsub1			ARE_THE_SAME;
	F[4],U[3].Fmain			ARE_THE_SAME;
	F[5],U2[6].Fmain		ARE_THE_SAME;
	F[6],U[1].Fsub1			ARE_THE_SAME;
	F[7],U[1].Fmain,U[2].Fsub2	ARE_THE_SAME;
	F[8],U[2].Fmain,U[3].Fsub1	ARE_THE_SAME;
	F[9],U[3].Fsub2			ARE_THE_SAME;
	F[10],U[1].Fsub2		ARE_THE_SAME;
	F[11],U[5].Fsub1		ARE_THE_SAME;
	F[12],U[4].Fsub2		ARE_THE_SAME;
	F[13],U[4].Fmain,U[5].Fsub2	ARE_THE_SAME;
	F[14],U[5].Fmain,U2[6].Fsub1	ARE_THE_SAME;

	(* Set definitions *)
	num_units1 :== [1..5];
	num_units2 :== 6;
	num_flow :== [1..14];

	(* Invariant Equations  *)
	F[1] = F[6] + F[12];
	F[9] = F[10] + F[11];

	(* Constants *)
	U[1].a[1] :== 1.1;
	U[1].a[2] :== 1.15;
	U[1].a[3] :== 1.2;
	U[1].b[1] :== 0.05;
	U[1].b[2] :== 0.1;
	U[1].b[3] :== 0.2;

	U[2].a[1] :== 0.5;
	U[2].a[2] :== 0.47;
	U[2].a[3] :== 0.45;
	U[2].b[1] :== 0.8;
	U[2].b[2] :== 0.75;
	U[2].b[3] :== 0.7;

	U[3].a[1] :== 1.7;
	U[3].a[2] :== 1.8;
	U[3].a[3] :== 1.87;
	U[3].b[1] :== 0.67;
	U[3].b[2] :== 0.7;
	U[3].b[3] :== 0.75;

	U[4].a[1] :== 1.18;
	U[4].a[2] :== 1.15;
	U[4].a[3] :== 1.10;
	U[4].b[1] :== 0.23;
	U[4].b[2] :== 0.25;
	U[4].b[3] :== 0.3;

	U[5].a[1] :== 0.37;
	U[5].a[2] :== 0.35;
	U[5].a[3] :== 0.3;
	U[5].b[1] :== 1.2;
	U[5].b[2] :== 1.25;
	U[5].b[3] :== 1.3;

	U2[6].a[1] :== 1.15;
	U2[6].a[2] :== 1.10;
	U2[6].a[3] :== 1.02;

METHODS
	METHOD default_self;
	END default_self;

	METHOD specify;
		FIX F[1];
		FOR i IN num_units1 DO
			RUN U[i].specify;
		END FOR;
		RUN U2[num_units2].specify;
	END specify;

	METHOD bound_all;
		(* Unit 1 *)
		U[1].Fmain.upper_bound := 150 {lb_mole/hour};

		(* Unit 2 *)
		U[2].Fmain.upper_bound := 150 {lb_mole/hour};

		(* Unit 3 *)
		U[3].Fmain.upper_bound := 180 {lb_mole/hour};

		(* Unit 4 *)
		U[4].Fmain.upper_bound := 140 {lb_mole/hour};

		(* Unit 5 *)
		U[5].Fmain.upper_bound := 130 {lb_mole/hour};

		(* Unit 6 *)
		U2[6].Fmain.upper_bound := 75 {lb_mole/hour};

	END bound_all;

	METHOD values;
		RUN bound_all;
		(* Fixed Values*)

		F[1] := 47.5 {lb_mole/hour };

		(* Unit 1 *)
		U[1].B[1] := 50 {lb_mole/hour};
		U[1].B[2] := 80 {lb_mole/hour};

		(* Unit 2 *)
		U[2].B[1] := 50 {lb_mole/hour};
		U[2].B[2] := 100 {lb_mole/hour};

		(* Unit 3 *)
		U[3].B[1] := 50 {lb_mole/hour};
		U[3].B[2] := 110 {lb_mole/hour};

		(* Unit 4 *)
		U[4].B[1] := 50 {lb_mole/hour};
		U[4].B[2] := 90 {lb_mole/hour};

		(* Unit 5 *)
		U[5].B[1] := 40 {lb_mole/hour};
		U[5].B[2] := 80 {lb_mole/hour};

		(* Unit 6 *)
		U2[6].B[1] := 20 {lb_mole/hour};
		U2[6].B[2] := 45 {lb_mole/hour};

		(* Initial Guess *)

		(* Unit 1 *)
		U[1].Fmain := 34 {lb_mole/hour};
		U[1].Fsub1 := 37.5 {lb_mole/hour};
		U[1].Fsub2 := 1.70 {lb_mole/hour};

		(* Unit 2 *)
		U[2].Fmain := 52.5 {lb_mole/hour};
		U[2].Fsub1 := 21.25 {lb_mole/hour};
		U[2].Fsub2 := 60 {lb_mole/hour};

		(* Unit 3 *)
		U[3].Fmain := 25 {lb_mole/hour};
		U[3].Fsub1 := 52.5 {lb_mole/hour};
		U[3].Fsub2 := 16.75 {lb_mole/hour};

		(* Unit 4 *)
		U[4].Fmain := 60.0 {lb_mole/hour};
		U[4].Fsub1 := 69 {lb_mole/hour};
		U[4].Fsub2 := 15 {lb_mole/hour};

		(* Unit 5 *)
		U[5].Fmain := 48 {lb_mole/hour};
		U[5].Fsub1 := 16.8 {lb_mole/hour};
		U[5].Fsub2 := 110 {lb_mole/hour};

		(* Unit 6 *)
		U2[6].Fmain := 50 {lb_mole/hour};
		U2[6].Fsub1 := 48 {lb_mole/hour};

		(* Same initial value as complementarity  *)

		U[2].Fmain := 42.5 {lb_mole/hour};
		U[3].Fsub1 := 42.5 {lb_mole/hour};
		U2[6].Fmain := 43 {lb_mole/hour};

		(* Initialization of boolean variables *)
		FOR i IN num_units1 DO
		   RUN U[i].values;
		END FOR;
		RUN U2[num_units2].values;

	END values;
	
	METHOD on_load;
		RUN default_self; RUN reset; RUN values;
	END on_load;
	
	METHOD self_test;
		(* no tests yet *)
	END self_test;

END linmassbal;
(* :ex: set ts=4: *)