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

Contents of /trunk/models/pipeline.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: 8531 byte(s)
Setting up web subdirectory in repository
1 REQUIRE "atoms.a4l";
2 (* => atoms.a4l, measures.a4l, system.a4l, basemodel.a4l *)
3 PROVIDE "pipeline.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 * pipeline.a4s.
10 *)
11
12 (*
13 Ascend model of the pipeline network example presented by Bullard
14 and Biegler -- Iterated Linear Programming Strategies for Nonsmooth
15 Simulation: Continuous and Mixed Integer Approaches. Comp. Chem. Eng.
16 Vol. 16, 949-961, 1992 --. The problem consists of a network of 38 pipes,
17 5 of them including a check valve (so that the flow in those pipes is
18 possible only in one direction). Each pipe is represented by a set of
19 algebraic disjunctive equations. It represent a problem
20 which we can represent as a conditional model and solve with the
21 ascend conditional solver CMSlv.
22
23 This model requires:
24 "system.a4l"
25 "atoms.a4l"
26 *)
27
28 (* ************************************************* *)
29
30 (* Base model of a pipe *)
31 MODEL arc;
32 k IS_A k_constant;
33 Q IS_A volume_rate;
34 H IS_A distance;
35 METHODS
36 END arc;
37
38
39 (* ************************************************* *)
40
41 (* Pipe without check valve *)
42 MODEL arc_w_no_valve REFINES arc;
43
44 bol IS_A boolean_var;
45
46 (* Boundary *)
47
48 CONDITIONAL
49 cond: Q >= 0.0 {gpm};
50 END CONDITIONAL;
51
52 bol == SATISFIED(cond,1e-08 {gpm});
53
54 (* Variant Equations *)
55
56 eq1: H = k * sqr(Q);
57 eq2: H = -k * sqr(Q);
58
59 (* Disjunctive Statement *)
60
61 WHEN (bol)
62 CASE TRUE:
63 USE eq1;
64 CASE FALSE:
65 USE eq2;
66 END WHEN;
67
68 METHODS
69
70 METHOD default_self;
71 END default_self;
72
73 METHOD specify;
74 k.fixed := TRUE;
75 END specify;
76
77 METHOD bound_self;
78 Q.lower_bound := -1e50{gpm};
79 H.lower_bound := -1e50{ft};
80 END bound_self;
81
82 METHOD values;
83 H := 0 {ft};
84 bol := SATISFIED(cond,1e-08 {gpm});
85 END values;
86
87 END arc_w_no_valve;
88
89 (* ************************************************* *)
90
91 (* Pipe with check valve *)
92 MODEL arc_w_valve REFINES arc;
93
94 bol IS_A boolean_var;
95
96 (* Boundary *)
97
98 CONDITIONAL
99 cond: H >= 0.0 {ft};
100 END CONDITIONAL ;
101
102 bol == SATISFIED(cond,1e-08{ft});
103
104 (* Variant Equations *)
105
106 eq1: sqr(Q) = H/k;
107 eq2: Q = 0.0 {gpm};
108
109 (* Disjunctive Statement *)
110
111 WHEN (bol)
112 CASE TRUE:
113 USE eq1;
114 CASE FALSE:
115 USE eq2;
116 END WHEN;
117
118 METHODS
119
120 METHOD default_self;
121 END default_self;
122
123 METHOD specify;
124 k.fixed := TRUE;
125 END specify;
126
127 METHOD bound_self;
128 H.lower_bound := -1e50{ft};
129 END bound_self;
130
131 METHOD values;
132 H := 1.0 {ft};
133 bol := SATISFIED(cond,1e-08{ft});
134 END values;
135 END arc_w_valve;
136
137 (* ************************************************* *)
138
139 (* Pipeline Network *)
140 MODEL pipeline;
141
142 nodes IS_A set OF integer_constant;
143 arcs IS_A set OF integer_constant;
144 Pipe[arcs] IS_A arc;
145 P[nodes] IS_A distance;
146 W[nodes] IS_A volume_rate;
147 Q[arcs] IS_A volume_rate;
148 H[arcs] IS_A distance;
149 k IS_A k_constant;
150
151 (* Sets definition *)
152
153 nodes :== [1..22];
154 arcs :== [1..38];
155
156 (* Wire up network *)
157
158 Pipe[15],Pipe[19],Pipe[23],Pipe[32],
159 Pipe[34] IS_REFINED_TO arc_w_valve;
160
161 FOR i IN [1..14] CREATE
162 Pipe[i] IS_REFINED_TO arc_w_no_valve;
163 END FOR;
164 FOR i IN [16..18] CREATE
165 Pipe[i] IS_REFINED_TO arc_w_no_valve;
166 END FOR;
167 FOR i IN [20..22] CREATE
168 Pipe[i] IS_REFINED_TO arc_w_no_valve;
169 END FOR ;
170 FOR i IN [24..31] CREATE
171 Pipe[i] IS_REFINED_TO arc_w_no_valve;
172 END FOR;
173 Pipe[33] IS_REFINED_TO arc_w_no_valve;
174 FOR i IN [35..38] CREATE
175 Pipe[i] IS_REFINED_TO arc_w_no_valve;
176 END FOR;
177
178 FOR i IN arcs CREATE
179 Q[i],Pipe[i].Q ARE_THE_SAME;
180 H[i],Pipe[i].H ARE_THE_SAME;
181 k,Pipe[i].k ARE_THE_SAME;
182 END FOR;
183
184 (* Invariant Equations *)
185
186 (* Pressure Drops at each arc *)
187 P[1] - P[6] = H[1];
188 P[2] - P[1] = H[2];
189 P[2] - P[3] = H[3];
190 P[3] - P[11] = H[4];
191 P[13] - P[11] = H[5];
192 P[14] - P[12] = H[6];
193 P[12] - P[16] = H[7];
194 P[16] - P[17] = H[8];
195 P[19] - P[20] = H[9];
196 P[21] - P[19] = H[10];
197 P[7] - P[6] = H[11];
198 P[10] - P[9] = H[12];
199 P[7] - P[9] = H[13];
200 P[21] - P[18] = H[14];
201 P[14] - P[10] = H[15];
202 P[22] - P[10] = H[16];
203 P[21] - P[22] = H[17];
204 P[1] - P[5] = H[18];
205 P[5] - P[4] = H[19];
206 P[4] - P[2] = H[20];
207 P[3] - P[4] = H[21];
208 P[11] - P[4] = H[22];
209 P[11] - P[12] = H[23];
210 P[12] - P[13] = H[24];
211 P[13] - P[14] = H[25];
212 P[12] - P[15] = H[26];
213 P[16] - P[15] = H[27];
214 P[18] - P[15] = H[28];
215 P[17] - P[18] = H[29];
216 P[19] - P[15] = H[30];
217 P[15] - P[20] = H[31];
218 P[20] - P[21] = H[32];
219 P[9] - P[22] = H[33];
220 P[9] - P[8] = H[34];
221 P[5] - P[8] = H[35];
222 P[5] - P[10] = H[36];
223 P[8] - P[7] = H[37];
224 P[6] - P[5] = H[38];
225
226 (* Flow balance around each node *)
227
228 W[1] = Q[2] - Q[1] - Q[18];
229 W[2] = Q[20] - Q[2] - Q[3];
230 W[3] = Q[3] - Q[4] - Q[21];
231 W[4] = Q[19] + Q[21] + Q[22] - Q[20];
232 W[5] = Q[18] + Q[38] - Q[19] - Q[35] - Q[36];
233 W[6] = Q[1] + Q[11] - Q[38];
234 W[7] = Q[37] - Q[11] - Q[13];
235 W[8] = Q[34] + Q[35] - Q[37];
236 W[9] = Q[12] + Q[13] - Q[33] - Q[34];
237 W[10] = Q[15] + Q[16] + Q[36] - Q[12];
238 W[11] = Q[4] + Q[5] - Q[22] - Q[23];
239 W[12] = Q[6] + Q[23] - Q[7] - Q[24] - Q[26];
240 W[13] = Q[24] - Q[5] - Q[25];
241 W[14] = Q[25] - Q[6] - Q[15];
242 W[15] = Q[26] + Q[27] + Q[28] + Q[30] - Q[31];
243 W[16] = Q[7] - Q[8] - Q[27];
244 W[17] = Q[8] - Q[29];
245 W[18] = Q[14] + Q[29] - Q[28];
246 W[19] = Q[10] - Q[9] - Q[30];
247 W[20] = Q[9] + Q[31] - Q[32];
248 W[21] = Q[32] - Q[10] - Q[14] - Q[17];
249 W[22] = Q[17] + Q[33] - Q[16];
250
251
252 METHODS
253
254 METHOD default_self;
255 END default_self;
256
257 METHOD specify;
258 k.fixed := TRUE;
259 FOR i IN nodes DO
260 W[i].fixed := TRUE;
261 END FOR;
262 W[18].fixed := FALSE;
263 P[17].fixed := TRUE;
264 END specify;
265
266 METHOD bound_self;
267 FOR i IN nodes DO
268 W[i].lower_bound := -1e50 {gpm};
269 END FOR;
270 FOR i IN nodes DO
271 P[i].lower_bound := 0 {ft};
272 END FOR ;
273 END bound_self;
274
275 METHOD bound_all;
276 FOR i IN arcs DO
277 RUN Pipe[i].bound_self;
278 END FOR;
279 RUN bound_self;
280 END bound_all;
281
282 METHOD values;
283
284 RUN bound_all;
285
286 FOR i IN arcs DO
287 RUN Pipe[i].values;
288 END FOR;
289
290 (* fixed *)
291 k := 0.36412197 {s^2/ft^5};
292
293 FOR i IN nodes DO
294 W[i] := 0 {gpm};
295 END FOR;
296 W[1] := -897.6 {gpm};
297 W[7] := -1570.9 {gpm};
298 W[11] := 897.6 {gpm};
299 W[17] := 1795.3 {gpm};
300 W[20] := 448.8 {gpm};
301 W[22] := -673.2 {gpm};
302
303 (* Initial guess *)
304
305 (* Pressure head *)
306 FOR i IN nodes DO
307 P[i] := 0 {ft};
308 END FOR ;
309 P[17] := 0 {ft};
310
311 (* volume rates *)
312 Q[1] := -48.5 {gpm};
313 Q[2] := -640.7 {gpm};
314 Q[3] := 393.2 {gpm};
315 Q[4] := 538.9 {gpm};
316 Q[5] := -32.3 {gpm};
317 Q[6] := 490.2 {gpm};
318 Q[7] := 649.9 {gpm};
319 Q[8] := 904.7 {gpm};
320 Q[9] := 112.2 {gpm};
321 Q[10] := 232.5 {gpm};
322 Q[11] := 402.3 {gpm};
323 Q[12] := -420.4 {gpm};
324 Q[13] := 687.3 {gpm};
325 Q[14] := 621.7 {gpm};
326 Q[15] := -719.2 {gpm};
327 Q[16] := 52.7 {gpm};
328 Q[17] := 1199 {gpm};
329 Q[18] := 305.4 {gpm};
330 Q[19] := 582.8 {gpm};
331 Q[20] := -247.5 {gpm};
332 Q[21] := -145.7 {gpm};
333 Q[22] := -684.6 {gpm};
334 Q[23] := 293.6 {gpm};
335 Q[24] := -261.3 {gpm};
336 Q[25] := -229 {gpm};
337 Q[26] := -395.1 {gpm};
338 Q[27] := -254.8 {gpm};
339 Q[28] := -268.9 {gpm};
340 Q[29] := -890.6 {gpm};
341 Q[30] := 120.3 {gpm};
342 Q[31] := -8.1{gpm};
343 Q[32] := -344.7 {gpm};
344 Q[33] := 473.1 {gpm};
345 Q[34] := -206.2 {gpm};
346 Q[35] := -275 {gpm};
347 Q[36] := 351.5 {gpm};
348 Q[37] := -481.2 {gpm};
349 Q[38] := 353.9 {gpm};
350 END values;
351
352 END pipeline;
353
354
355 (*
356 * pipeline.a4c
357 * by Vicente Rico-Ramirez
358 * April 10, 1998
359 * Part of the ASCEND Library
360 * $Date: 1998/06/17 19:15:04 $
361 * $Revision: 1.3 $
362 * $Author: mthomas $
363 * $Source: /afs/cs.cmu.edu/project/ascend/Repository/models/pipeline.a4c,v $
364 *
365 * This file is part of the ASCEND Modeling Library.
366 *
367 * Copyright (C) 1998 Carnegie Mellon University
368 *
369 * The ASCEND Modeling Library is free software; you can redistribute
370 * it and/or modify it under the terms of the GNU General Public
371 * License as published by the Free Software Foundation; either
372 * version 2 of the License, or (at your option) any later version.
373 *
374 * The ASCEND Modeling Library is distributed in hope that it will be
375 * useful, but WITHOUT ANY WARRANTY; without even the implied
376 * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
377 * See the GNU General Public License for more details.
378 *
379 * You should have received a copy of the GNU General Public License
380 * along with the program; if not, write to the Free Software
381 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139 USA. Check
382 * the file named COPYING.
383 *)

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