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

Diff of /trunk/models/linear_balance.a4c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1154 by johnpye, Tue May 9 03:42:08 2006 UTC revision 1155 by johnpye, Tue Jan 16 11:33:52 2007 UTC
# Line 1  Line 1 
1    (*  ASCEND modelling environment
2        Copyright (C) 1998  Carnegie Mellon University
3        Copyright (C) 2006 Carnegie Mellon University
4    
5        This program is free software; you can redistribute it and/or modify
6        it under the terms of the GNU General Public License as published by
7        the Free Software Foundation; either version 2, or (at your option)
8        any later version.
9    
10        This program is distributed in the hope that it will be useful,
11        but WITHOUT ANY WARRANTY; without even the implied warranty of
12        MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13        GNU General Public License for more details.
14        
15        You should have received a copy of the GNU General Public License
16        along with this program; if not, write to the Free Software
17        Foundation, Inc., 59 Temple Place - Suite 330,
18        Boston, MA 02111-1307, USA.
19    *)
20  REQUIRE "atoms.a4l";  REQUIRE "atoms.a4l";
 (* => atoms.a4l, measures.a4l, system.a4l, basemodel.a4l *)  
21  PROVIDE "linear_balance.a4c";  PROVIDE "linear_balance.a4c";
22  (*  (*
23   * This file is part of the ASCEND Modeling Library and is released      Model of a linear mass balance as discussed in the PhD thesis of
24   * under the GNU Public License as described at the end of this file.      Vicente Rico-Ramirez, page 84.
25   *      https://pse.cheme.cmu.edu/ascend/ftp/pdfThesis/victhesis.pdf
  * Use of this module is demonstrated by the associated script file  
  * linear_balance.a4s.  
  *)  
26    
27        The problem consists of a six unit operations flowsheet, each unit operation
28        having three possible operation modes. The problem was originally presented by
29    
30  (*      Grossmann and Turkay, Solution of Algebraic Systems of Disjuctive Equations, Comp.
31     Ascend model of the linear mass balance example presented by Grossmann      and Chem. Eng., Vol. 20, Suppl. Part A, s339-44, 1996
32  and Turkay -- Solution of Algebraic Systems of Disjuctive Equations, Comp.  
33  and Chem. Eng., Vol. 20, Suppl. Part A, s339-44, 1996 --. It represent a      It represents a problem which we can represent as a conditional model and
34  problem which we can represent as a conditional model and solve  with the      solve with the ASCEND conditional solver, CMSlv.
35  ascend conditional solver CMSlv. The problem consists of a six unit  
36  operations flowsheet, each unit operation having three possible operation      by Vicente Rico-Ramirez, April 10, 1998
 modes.  
   
 This model requires:  
             "system.a4l"  
                 "atoms.a4l"  
37  *)  *)
38    
39  (* ************************************************* *)  (*-----------------------------------*)
40    
41  MODEL unit_op1;  MODEL unit_op1;
42    
# Line 39  MODEL unit_op1; Line 51  MODEL unit_op1;
51      disjunc :== [1..3];      disjunc :== [1..3];
52      bounds :== [1..2];      bounds :== [1..2];
53    
54  (* Boundaries *)      (* Boundaries *)
   
55      CONDITIONAL      CONDITIONAL
56        cond1: Fmain <= B[1];        cond1: Fmain <= B[1];
57        cond2: Fmain >= B[2];        cond2: Fmain >= B[2];
# Line 49  MODEL unit_op1; Line 60  MODEL unit_op1;
60      bol1 == SATISFIED(cond1,1e-08{lb_mole/hour});      bol1 == SATISFIED(cond1,1e-08{lb_mole/hour});
61      bol2 == SATISFIED(cond2,1e-08{lb_mole/hour});      bol2 == SATISFIED(cond2,1e-08{lb_mole/hour});
62    
63  (* Variant Equations *)      (* Variant Equations *)
   
64      eq1a: Fsub1 = a[1] * Fmain;      eq1a: Fsub1 = a[1] * Fmain;
65      eq1b: Fsub2 = b[1] * Fmain;      eq1b: Fsub2 = b[1] * Fmain;
66    
# Line 60  MODEL unit_op1; Line 70  MODEL unit_op1;
70      eq3a: Fsub1 = a[3] * Fmain;      eq3a: Fsub1 = a[3] * Fmain;
71      eq3b: Fsub2 = b[3] * Fmain;      eq3b: Fsub2 = b[3] * Fmain;
72    
73  (* Disjunctive Statements  *)      (* Disjunctive Statements *)
   
74      WHEN (bol1,bol2)      WHEN (bol1,bol2)
75        CASE TRUE,FALSE:        CASE TRUE,FALSE:
76          USE eq1a;          USE eq1a;
# Line 93  METHODS Line 102  METHODS
102  END unit_op1;  END unit_op1;
103    
104    
105  (* ************************************************* *)  (*-----------------------------------*)
106    
107  MODEL unit_op2;  MODEL unit_op2;
108    
109      Fmain,Fsub1     IS_A molar_rate;      Fmain,Fsub1     IS_A molar_rate;
110      B[bounds]       IS_A molar_rate;      B[bounds]       IS_A molar_rate;
111      disjunc         IS_A set OF integer_constant;      disjunc         IS_A set OF integer_constant;
112          bounds          IS_A set OF integer_constant;      bounds          IS_A set OF integer_constant;
113      a[disjunc]      IS_A factor_constant;      a[disjunc]      IS_A factor_constant;
114      bol1,bol2       IS_A boolean_var;      bol1,bol2       IS_A boolean_var;
115    
116      disjunc :== [1..3];      disjunc :== [1..3];
117      bounds :== [1..2];      bounds :== [1..2];
118    
119  (* Boundaries *)      (* Boundaries *)
   
120      CONDITIONAL      CONDITIONAL
121        cond1: Fmain <= B[1];        cond1: Fmain <= B[1];
122        cond2: Fmain >= B[2];        cond2: Fmain >= B[2];
# Line 118  MODEL unit_op2; Line 126  MODEL unit_op2;
126      bol2 == SATISFIED(cond2,1e-08{lb_mole/hour});      bol2 == SATISFIED(cond2,1e-08{lb_mole/hour});
127    
128    
129  (* Variant Equations  *)      (* Variant Equations  *)
   
130      eq1: Fsub1 = a[1] * Fmain;      eq1: Fsub1 = a[1] * Fmain;
   
131      eq2: Fsub1 = a[2] * Fmain;      eq2: Fsub1 = a[2] * Fmain;
   
132      eq3: Fsub1 = a[3] * Fmain;      eq3: Fsub1 = a[3] * Fmain;
133    
134  (* Disjunctive Statements  *)      (* Disjunctive Statements  *)
   
135      WHEN (bol1,bol2)      WHEN (bol1,bol2)
136        CASE TRUE,FALSE:        CASE TRUE,FALSE:
137          USE eq1;          USE eq1;
# Line 157  METHODS Line 161  METHODS
161  END unit_op2;  END unit_op2;
162    
163    
164  (* ************************************************* *)  (*-----------------------------------*)
165    
166  MODEL flowsheet;  MODEL flowsheet;
167    
# Line 168  MODEL flowsheet; Line 172  MODEL flowsheet;
172      num_units2  IS_A integer_constant;      num_units2  IS_A integer_constant;
173      num_flow    IS_A set OF integer_constant;      num_flow    IS_A set OF integer_constant;
174    
175  (* wire up flowsheet *)      (* wire up flowsheet *)
   
176      F[2],U[2].Fsub1         ARE_THE_SAME;      F[2],U[2].Fsub1         ARE_THE_SAME;
177      F[3],U[4].Fsub1         ARE_THE_SAME;      F[3],U[4].Fsub1         ARE_THE_SAME;
178      F[4],U[3].Fmain         ARE_THE_SAME;      F[4],U[3].Fmain         ARE_THE_SAME;
# Line 184  MODEL flowsheet; Line 187  MODEL flowsheet;
187      F[13],U[4].Fmain,U[5].Fsub2 ARE_THE_SAME;      F[13],U[4].Fmain,U[5].Fsub2 ARE_THE_SAME;
188      F[14],U[5].Fmain,U2[6].Fsub1    ARE_THE_SAME;      F[14],U[5].Fmain,U2[6].Fsub1    ARE_THE_SAME;
189    
190        (* Set definitions *)
 (* Set definitions *)  
   
191      num_units1 :== [1..5];      num_units1 :== [1..5];
192      num_units2 :== 6;      num_units2 :== 6;
193      num_flow :== [1..14];      num_flow :== [1..14];
194    
195  (* Invariant Equations  *)      (* Invariant Equations  *)
   
196      F[1] = F[6] + F[12];      F[1] = F[6] + F[12];
197      F[9] = F[10] + F[11];      F[9] = F[10] + F[11];
198    
199  (* Constants *)      (* Constants *)
   
200      U[1].a[1] :== 1.1;      U[1].a[1] :== 1.1;
201      U[1].a[2] :== 1.15;      U[1].a[2] :== 1.15;
202      U[1].a[3] :== 1.2;      U[1].a[3] :== 1.2;
# Line 238  MODEL flowsheet; Line 237  MODEL flowsheet;
237      U2[6].a[3] :== 1.02;      U2[6].a[3] :== 1.02;
238    
239  METHODS  METHODS
240        METHOD default_self;
241        END default_self;
242    
243     METHOD default_self;      METHOD specify;
244     END default_self;          FIX F[1];
245            FOR i IN num_units1 DO
246                RUN U[i].specify;
247     METHOD specify;          END FOR;
248      FIX F[1];          RUN U2[num_units2].specify;
249          FOR i IN num_units1 DO      END specify;
        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};  
250    
251  (* Unit 4 *)      METHOD bound_all;
252      U[4].Fmain.upper_bound := 140 {lb_mole/hour};          (* Unit 1 *)
253            U[1].Fmain.upper_bound := 150 {lb_mole/hour};
254    
255  (* Unit 5 *)          (* Unit 2 *)
256      U[5].Fmain.upper_bound := 130 {lb_mole/hour};          U[2].Fmain.upper_bound := 150 {lb_mole/hour};
257    
258  (* Unit 6 *)          (* Unit 3 *)
259      U2[6].Fmain.upper_bound := 75 {lb_mole/hour};          U[3].Fmain.upper_bound := 180 {lb_mole/hour};
260    
261     END bound_all;          (* Unit 4 *)
262            U[4].Fmain.upper_bound := 140 {lb_mole/hour};
263    
264     METHOD values;          (* Unit 5 *)
265            U[5].Fmain.upper_bound := 130 {lb_mole/hour};
     RUN bound_all;  
266    
267          (* Fixed Values*)          (* Unit 6 *)
268            U2[6].Fmain.upper_bound := 75 {lb_mole/hour};
269    
270      F[1] := 47.5 {lb_mole/hour };      END bound_all;
271    
272  (* Unit 1 *)      METHOD values;
273      U[1].B[1] := 50 {lb_mole/hour};          RUN bound_all;
274      U[1].B[2] := 80 {lb_mole/hour};          (* Fixed Values*)
275    
276  (* Unit 2 *)          F[1] := 47.5 {lb_mole/hour };
     U[2].B[1] := 50 {lb_mole/hour};  
     U[2].B[2] := 100 {lb_mole/hour};  
277    
278  (* Unit 3 *)          (* Unit 1 *)
279      U[3].B[1] := 50 {lb_mole/hour};          U[1].B[1] := 50 {lb_mole/hour};
280      U[3].B[2] := 110 {lb_mole/hour};          U[1].B[2] := 80 {lb_mole/hour};
281    
282  (* Unit 4 *)          (* Unit 2 *)
283      U[4].B[1] := 50 {lb_mole/hour};          U[2].B[1] := 50 {lb_mole/hour};
284      U[4].B[2] := 90 {lb_mole/hour};          U[2].B[2] := 100 {lb_mole/hour};
285    
286  (* Unit 5 *)          (* Unit 3 *)
287      U[5].B[1] := 40 {lb_mole/hour};          U[3].B[1] := 50 {lb_mole/hour};
288      U[5].B[2] := 80 {lb_mole/hour};          U[3].B[2] := 110 {lb_mole/hour};
289    
290  (* Unit 6 *)          (* Unit 4 *)
291      U2[6].B[1] := 20 {lb_mole/hour};          U[4].B[1] := 50 {lb_mole/hour};
292      U2[6].B[2] := 45 {lb_mole/hour};          U[4].B[2] := 90 {lb_mole/hour};
293    
294            (* Unit 5 *)
295            U[5].B[1] := 40 {lb_mole/hour};
296            U[5].B[2] := 80 {lb_mole/hour};
297    
298      (* Initial Guess *)          (* Unit 6 *)
299            U2[6].B[1] := 20 {lb_mole/hour};
300            U2[6].B[2] := 45 {lb_mole/hour};
301    
302            (* Initial Guess *)
303    
304  (* Unit 1 *)          (* Unit 1 *)
305      U[1].Fmain := 34 {lb_mole/hour};          U[1].Fmain := 34 {lb_mole/hour};
306      U[1].Fsub1 := 37.5 {lb_mole/hour};          U[1].Fsub1 := 37.5 {lb_mole/hour};
307      U[1].Fsub2 := 1.70 {lb_mole/hour};          U[1].Fsub2 := 1.70 {lb_mole/hour};
308    
309  (* Unit 2 *)          (* Unit 2 *)
310            U[2].Fmain := 52.5 {lb_mole/hour};
311            U[2].Fsub1 := 21.25 {lb_mole/hour};
312            U[2].Fsub2 := 60 {lb_mole/hour};
313    
314      U[2].Fmain := 52.5 {lb_mole/hour};          (* Unit 3 *)
315      U[2].Fsub1 := 21.25 {lb_mole/hour};          U[3].Fmain := 25 {lb_mole/hour};
316      U[2].Fsub2 := 60 {lb_mole/hour};          U[3].Fsub1 := 52.5 {lb_mole/hour};
317            U[3].Fsub2 := 16.75 {lb_mole/hour};
318    
319  (* Unit 3 *)          (* Unit 4 *)
320      (* initial *)          U[4].Fmain := 60.0 {lb_mole/hour};
321      U[3].Fmain := 25 {lb_mole/hour};          U[4].Fsub1 := 69 {lb_mole/hour};
322      U[3].Fsub1 := 52.5 {lb_mole/hour};          U[4].Fsub2 := 15 {lb_mole/hour};
     U[3].Fsub2 := 16.75 {lb_mole/hour};  
323    
324  (* Unit 4 *)          (* Unit 5 *)
325      (* initial *)          U[5].Fmain := 48 {lb_mole/hour};
326      U[4].Fmain := 60.0 {lb_mole/hour};          U[5].Fsub1 := 16.8 {lb_mole/hour};
327      U[4].Fsub1 := 69 {lb_mole/hour};          U[5].Fsub2 := 110 {lb_mole/hour};
     U[4].Fsub2 := 15 {lb_mole/hour};  
328    
329  (* Unit 5 *)          (* Unit 6 *)
330      (* initial *)          U2[6].Fmain := 50 {lb_mole/hour};
331      U[5].Fmain := 48 {lb_mole/hour};          U2[6].Fsub1 := 48 {lb_mole/hour};
     U[5].Fsub1 := 16.8 {lb_mole/hour};  
     U[5].Fsub2 := 110 {lb_mole/hour};  
332    
333  (* Unit 6 *)          (* Same initial value as complementarity  *)
     (* initial *)  
     U2[6].Fmain := 50 {lb_mole/hour};  
     U2[6].Fsub1 := 48 {lb_mole/hour};  
334    
335  (* Same initial value as complementarity  *)          U[2].Fmain := 42.5 {lb_mole/hour};
336            U[3].Fsub1 := 42.5 {lb_mole/hour};
337            U2[6].Fmain := 43 {lb_mole/hour};
338    
339      U[2].Fmain := 42.5 {lb_mole/hour};          (* Initialization of boolean variables *)
340      U[3].Fsub1 := 42.5 {lb_mole/hour};          FOR i IN num_units1 DO
341      U2[6].Fmain := 43 {lb_mole/hour};             RUN U[i].values;
342            END FOR;
343  (* Initialization of boolean variables *)          RUN U2[num_units2].values;
         FOR i IN num_units1 DO  
        RUN U[i].values;  
     END FOR;  
     RUN U2[num_units2].values;  
   
    END values;  
344    
345        END values;
346        
347  END flowsheet;  END flowsheet;
348    (* :ex: set ts=4: *)
   
 (*  
  *  linear_balance.a4c  
  *  by Vicente Rico-Ramirez  
  *  April 10, 1998  
  *  Part of the ASCEND Library  
  *  $Date: 1998/06/17 19:11:17 $  
  *  $Revision: 1.3 $  
  *  $Author: mthomas $  
  *  $Source: /afs/cs.cmu.edu/project/ascend/Repository/models/linear_balance.a4c,v $  
  *  
  *  This file is part of the ASCEND Modeling Library.  
  *  
  *  Copyright (C) 1998  Carnegie Mellon University  
  *  
  *  The ASCEND Modeling Library 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 of the License, or (at your option) any later version.  
  *  
  *  The ASCEND Modeling Library is distributed in 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 the program; if not, write to the Free Software  
  *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139 USA.  Check  
  *  the file named COPYING.  
  *)  

Legend:
Removed from v.1154  
changed lines
  Added in v.1155

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