# Annotation of /trunk/models/heatex.a4c

Revision 576 - (hide annotations) (download) (as text)
Tue May 9 03:42:08 2006 UTC (18 years, 1 month ago) by johnpye
File MIME type: text/x-ascend
File size: 8930 byte(s)
```Changed all cases of *.fixed := {TRUE,FALSE} to 'FIX' and 'FREE' statements.
```
 1 aw0a 1 REQUIRE "atoms.a4l"; 2 (* => atoms.a4l, measures.a4l, system.a4l, basemodel.a4l *) 3 PROVIDE "heatex.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 * heatex.a4s. 10 *) 11 12 13 (* 14 Ascend model of the heat exchanger example presented by 15 Zaher -- Conditional Modeling. Ph.D. Thesis, Carnegie Mellon University, 16 Pittsburgh, PA, 15213. 1995 --. The problem represents the condensation 17 of vapor because the heat transfer between the vapor and cooling water in 18 a heat exchanger. There are two disjunctive statement which represent 19 the possible condensation of vapor in the different sections of the 20 heat exchanger. This example shows how we can represent a conditional model 21 containing differential equations. It represent a problem that we can 22 solve with the ascend conditional solver CMSlv. 23 24 This model requires: 25 "system.a4l" 26 "atoms.a4l" 27 *) 28 29 (* ************************************************* *) 30 31 MODEL heatex; 32 33 points IS_A set OF integer_constant; 34 components IS_A set OF symbol_constant; 35 k_terms IS_A set OF integer_constant; 36 z[components] IS_A fraction; 37 x[points][components] IS_A fraction; 38 y[points][components] IS_A fraction; 39 Tcr[components] IS_A critical_temperature; 40 Pcr[components] IS_A critical_pressure; 41 Hv[components] IS_A molar_energy_constant; 42 B[components][k_terms] IS_A factor_constant; 43 C[k_terms] IS_A factor_constant; 44 D[components][k_terms] IS_A molar_energy_constant; 45 E[k_terms] IS_A factor_constant; 46 phi[points] IS_A fraction; 47 eta[points] IS_A fraction; 48 A IS_A area; 49 Fc IS_A molar_rate; 50 Fh IS_A molar_rate; 51 P IS_A pressure; 52 Tc[points] IS_A temperature; 53 Th[points] IS_A temperature; 54 Hc[points] IS_A molar_energy; 55 Hh[points] IS_A molar_energy; 56 dQ[points] IS_A energy_rate; 57 erscale IS_A energy_rate; 58 entscale IS_A factor; 59 bolphaq[1..2] IS_A boolean_var; 60 61 (* Boundaries *) 62 63 CONDITIONAL 64 cond1: SUM[x[0][i] | i IN components] + phi[0] >= 1.0; 65 cond2: SUM[x[2][i] | i IN components] + phi[1] >= 1.0; 66 END CONDITIONAL; 67 68 bolphaq[1] == SATISFIED(cond1,1e-08); 69 bolphaq[2] == SATISFIED(cond2,1e-08); 70 71 (* Variant Equations *) 72 73 sum0: SUM[x[0][i] | i IN components] = 1.0; 74 frac0: phi[0] = 0.0; 75 76 sum2: SUM[x[2][i] | i IN components] = 1.0; 77 frac1: phi[1] = 0.0; 78 79 p1: eta[1] = 0.5; 80 p2: eta[2] = 0.5; 81 82 sum1: SUM[x[1][i] | i IN components] = 1.0; 83 p12: eta[1] = 0.0; 84 85 (* Disjunctive Statements *) 86 87 WHEN (bolphaq[1]) 88 CASE TRUE: 89 USE sum0; 90 USE sum1; 91 CASE FALSE: 92 USE frac0; 93 USE p12; 94 END WHEN; 95 96 WHEN (bolphaq[2]) 97 CASE TRUE: 98 USE sum2; 99 USE p1; 100 CASE FALSE: 101 USE frac1; 102 USE p2; 103 END WHEN; 104 105 (* Invariant Equations *) 106 107 phi[2] = 0.0; 108 phi[3] = 0.0; 109 110 FOR i IN points CREATE 111 FOR j IN components CREATE 112 phi[i]*x[i][j] + (1 - phi[i])*y[i][j] = z[j]; 113 END FOR; 114 END FOR; 115 116 FOR i IN points CREATE 117 FOR j IN components CREATE 118 ln((y[i][j]*P)/(x[i][j]*Pcr[j])) = (Tcr[j]/Th[i])*( 119 SUM[B[j][k] *(1 - Th[i]/Tcr[j])^C[k] 120 | k IN k_terms] ); 121 END FOR; 122 END FOR; 123 124 FOR i IN points CREATE 125 dQ[i]/erscale = 20{BTU/hour/ft^2/R}*(1 + 10*phi[i])* 126 A*(Th[i] - Tc[i])/erscale; 127 END FOR; 128 129 FOR i IN [0..2] CREATE 130 Fh*(Hh[i+1] - Hh[i])/erscale = 131 Fc*(Hc[i+1] - Hc[i])/erscale; 132 133 Fc*(Hc[i+1] - Hc[i])/erscale = 0.5*(dQ[i] + dQ[i+1])* 134 (eta[i+1] - eta[i])/erscale; 135 END FOR; 136 137 FOR i IN points CREATE 138 Hc[i]/entscale = 9720{BTU/lb_mole}*(Tc[i]/540{R} - 1)/entscale; 139 END FOR; 140 141 FOR j IN points CREATE 142 Hh[j]/entscale = (SUM[ z[i] *( 143 SUM[ D[i][k]*((Th[j]/540{R})^E[k] - 1)|k IN k_terms]) 144 - phi[j]*x[j][i]*Hv[i] | i IN components])/entscale; 145 END FOR; 146 147 (* Definition of sets *) 148 149 components :== ['B','P5','H']; 150 points :== [0..3]; 151 k_terms :== [1..4]; 152 153 (* Constants *) 154 155 Tcr['B'] :== 765.4 {R}; 156 Tcr['P5'] :== 845.3 {R}; 157 Tcr['H'] :== 913.3 {R}; 158 Pcr['B'] :== 37.5 {atm}; 159 Pcr['P5'] :== 33.3 {atm}; 160 Pcr['H'] :== 29.3 {atm}; 161 Hv['B'] :== 9634 {BTU/lb_mole}; 162 Hv['P5'] :== 11088{BTU/lb_mole}; 163 Hv['H'] :== 12413 {BTU/lb_mole}; 164 C[1] :== 1.0; 165 C[2] :== 1.5; 166 C[3] :== 3.0; 167 C[4] :== 6.0; 168 E[1] :== 1.0; 169 E[2] :== 2.0; 170 E[3] :== 3.0; 171 E[4] :== 4.0; 172 B['B'][1]:== -6.88709; 173 B['B'][2]:== 1.15157; 174 B['B'][3]:== -1.99873; 175 B['B'][4]:== -3.13003; 176 B['P5'][1]:== -7.28936; 177 B['P5'][2]:== 1.53679; 178 B['P5'][3]:== -3.08367; 179 B['P5'][4]:== -1.02456; 180 B['H'][1]:== -7.46765; 181 B['H'][2]:== 1.44211; 182 B['H'][3]:== -3.28222; 183 B['H'][4]:== -2.50941; 184 D['B'][1]:== 1224 {BTU/lb_mole}; 185 D['B'][2]:== 6410 {BTU/lb_mole}; 186 D['B'][3]:== -429 {BTU/lb_mole}; 187 D['B'][4]:== -2 {BTU/lb_mole}; 188 D['P5'][1]:== -468 {BTU/lb_mole}; 189 D['P5'][2]:== 9428 {BTU/lb_mole}; 190 D['P5'][3]:== -998 {BTU/lb_mole}; 191 D['P5'][4]:== 46 {BTU/lb_mole}; 192 D['H'][1]:== -569 {BTU/lb_mole}; 193 D['H'][2]:== 11260 {BTU/lb_mole}; 194 D['H'][3]:== -1207 {BTU/lb_mole}; 195 D['H'][4]:== 57 {BTU/lb_mole}; 196 197 METHODS 198 199 METHOD default_self; 200 END default_self; 201 202 METHOD specify; 203 FOR j IN components DO 204 johnpye 576 FIX z[j]; 205 aw0a 1 END FOR; 206 johnpye 576 FIX A; 207 FIX P; 208 FIX Fc; 209 FIX Fh; 210 FIX erscale; 211 FIX entscale; 212 FIX eta[0]; 213 FIX eta[3]; 214 FIX Tc[0]; 215 FIX Th[3]; 216 aw0a 1 END specify; 217 218 METHOD values; 219 (* fixed *) 220 P := 1.0{atm}; 221 z['B'] := 0.2; 222 z['P5'] := 0.5; 223 z['H'] := 0.3; 224 Fh := 250.0{lb_mole/hour}; 225 Tc[0] := 540.0{R}; 226 Th[3] := 600.0{R}; 227 erscale := 1.0e6{BTU/hour}; 228 entscale := 1000.0 ; 229 230 (* initial guess *) 231 A := 379.12{ft^2}; 232 Fc := 1104.13{lb_mole/hour}; 233 x[0]['B'] := 0.04183; 234 x[0]['P5'] := 0.32735; 235 x[0]['H'] := 0.58922; 236 x[1]['B'] := 0.04183; 237 x[1]['P5'] := 0.32735; 238 x[1]['H'] := 0.58922; 239 x[2]['B'] := 0.03558; 240 x[2]['P5'] := 0.27044; 241 x[2]['H'] := 0.47211; 242 x[3]['B'] := 0.03153; 243 x[3]['P5'] := 0.23457; 244 x[3]['H'] := 0.40038; 245 y[0]['B'] := 0.2; 246 y[0]['P5'] := 0.5; 247 y[0]['H'] := 0.3; 248 y[1]['B'] := 0.2; 249 y[1]['P5'] := 0.5; 250 y[1]['H'] := 0.3; 251 y[2]['B'] := 0.2; 252 y[2]['P5'] := 0.5; 253 y[2]['H'] := 0.3; 254 y[3]['B'] := 0.2; 255 y[3]['P5'] := 0.5; 256 y[3]['H'] := 0.3; 257 phi[0] := 0.0; 258 phi[1] := 0.0; 259 phi[2] := 0.0; 260 phi[3] := 0.0; 261 eta[0] := 0.0; 262 eta[1] := 0.0; 263 eta[2] := 0.5; 264 eta[3] := 1.0; 265 Tc[1] := 540.000{R}; 266 Tc[2] := 559.820{R}; 267 Tc[3] := 575.386{R}; 268 Th[0] := 579.932{R}; 269 Th[1] := 579.932{R}; 270 Th[2] := 591.242{R}; 271 Hc[0] := 0000.0{BTU/lb_mole}; 272 Hc[1] := 0000.0{BTU/lb_mole}; 273 Hc[2] := 356.768{BTU/lb_mole}; 274 Hc[3] := 636.948{BTU/lb_mole}; 275 Hh[0] := 1212.93{BTU/lb_mole}; 276 Hh[1] := 1212.93{BTU/lb_mole}; 277 Hh[2] := 1569.7{BTU/lb_mole}; 278 Hh[3] := 1849.88{BTU/lb_mole}; 279 dQ[0] := 199658{BTU/hour}; 280 dQ[1] := 199658{BTU/hour}; 281 dQ[2] := 157110{BTU/hour}; 282 dQ[3] := 123070{BTU/hour}; 283 eta[1].upper_bound := 0.5; 284 eta[2].lower_bound := 0.5; 285 eta[2].upper_bound := 1.0; 286 287 (* Initial value for booleans *) 288 bolphaq[1] := SATISFIED(cond1,1e-08); 289 bolphaq[2] := SATISFIED(cond2,1e-08); 290 END values; 291 292 END heatex; 293 294 295 (* 296 * heatex.a4c 297 * by Vicente Rico-Ramirez 298 * April 10, 1998 299 * Part of the ASCEND Library 300 * \$Date: 1998/06/17 19:08:03 \$ 301 * \$Revision: 1.3 \$ 302 * \$Author: mthomas \$ 303 * \$Source: /afs/cs.cmu.edu/project/ascend/Repository/models/heatex.a4c,v \$ 304 * 305 * This file is part of the ASCEND Modeling Library. 306 * 307 * Copyright (C) 1998 Carnegie Mellon University 308 * 309 * The ASCEND Modeling Library is free software; you can redistribute 310 * it and/or modify it under the terms of the GNU General Public 311 * License as published by the Free Software Foundation; either 312 * version 2 of the License, or (at your option) any later version. 313 * 314 * The ASCEND Modeling Library is distributed in hope that it will be 315 * useful, but WITHOUT ANY WARRANTY; without even the implied 316 * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 317 * See the GNU General Public License for more details. 318 * 319 * You should have received a copy of the GNU General Public License 320 * along with the program; if not, write to the Free Software 321 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139 USA. Check 322 * the file named COPYING. 323 *)

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