/[ascend]/trunk/models/steam/dsgsat3.a4c
ViewVC logotype

Contents of /trunk/models/steam/dsgsat3.a4c

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1328 - (show annotations) (download) (as text)
Thu Mar 8 03:05:27 2007 UTC (13 years, 2 months ago) by jpye
File MIME type: text/x-ascend
File size: 8361 byte(s)
Added stability analysis example in models/steam.
'unattached' icon was created some time ago but is not yet in use
1 REQUIRE "ivpsystem.a4l";
2 REQUIRE "atoms.a4l";
3 REQUIRE "johnpye/thermo_types.a4c";
4
5 (*
6 An attempt to model direct steam generation in pipe flow, limited to the
7 saturated regime, and with constant-valued friction factor. External heat
8 loss is also simplified.
9 *)
10 REQUIRE "steam/satsteamstream.a4c";
11
12 MODEL dsgsat3;
13 n IS_A integer_constant;
14 n :== 11;(* with L = 10m: 5,6,7,8,9,10,11 *)
15 (* with L = 5m: 2,3,4,5,7,9,11,12,13,1415,16 *)
16
17 dz IS_A real_constant;
18 L IS_A real_constant;
19 L :== 10 {m};
20 dz :== L / (n-1);
21
22 nodes,butfirst1,upwind4,central IS_A set OF integer_constant;
23 nodes :== [1..n];
24 butfirst1 :== nodes - [1];
25 upwind4 :== nodes - [1,2,n];
26 central :== nodes - [1,n];
27
28 (* temporal derivatives *)
29 drho_dt[butfirst1] IS_A density_rate;
30 dmdot_dt[butfirst1] IS_A mass_rate_rate;
31 du_dt[butfirst1] IS_A specific_energy_rate;
32 dTw_dt[butfirst1] IS_A temperature_rate;
33
34 (* wall properties *)
35 rho_w IS_A mass_density;
36 D, D_2 IS_A distance;
37 c_w IS_A specific_heat_capacity;
38 A, A_w IS_A area;
39 h_int IS_A heat_transfer_coefficient; (* internal *)
40 h_ext IS_A heat_transfer_coefficient; (* external *)
41 z_A: A = 1{PI}*D^2/4;
42 z_Aw: A_w = 1{PI}*(D_2^2 - D^2)/4;
43
44 (* fluid properties *)
45 node[nodes] IS_A satsteamstream;
46
47 (* flow properties *)
48 vel[nodes] IS_A speed;
49 T_w[butfirst1] IS_A temperature;
50 T[nodes] IS_A temperature;
51
52 (* constant, for the moment: *)
53 f IS_A positive_factor;
54 (* mu_f IS_A viscosity; *)
55 T_amb IS_A temperature;
56
57 (* system dynamics *)
58 qdot_t[butfirst1], qdot_l[butfirst1] IS_A power_per_length;
59 qdot_s IS_A power_per_length;
60
61 FOR i IN nodes CREATE
62 z_vel[i]: vel[i] = v[i]*mdot[i]/A;
63 END FOR;
64
65 (* some aliases just for easier review of the state of the model *)
66 x[nodes] IS_A fraction;
67 mdot[nodes] IS_A mass_rate;
68 p[nodes] IS_A pressure;
69 rho[nodes] IS_A mass_density;
70 u[nodes] IS_A specific_energy;
71 v[nodes] IS_A specific_volume;
72 FOR i IN nodes CREATE
73 x[i], node[i].x ARE_THE_SAME;
74 mdot[i], node[i].mdot ARE_THE_SAME;
75 p[i], node[i].p ARE_THE_SAME;
76 T[i], node[i].T ARE_THE_SAME;
77 rho[i], node[i].rho ARE_THE_SAME;
78 u[i], node[i].u ARE_THE_SAME;
79 v[i], node[i].v ARE_THE_SAME;
80 END FOR;
81
82 en_upwind4,en_central,mom_upwind4,mom_central,mass_upwind4,mass_central IS_A set OF integer_constant;
83
84 (* mass conservation *)
85 mass_upwind4 :== upwind4;
86 mass_central :== central - mass_upwind4;
87 FOR i IN mass_upwind4 CREATE (* 4-pt upwind biased *)
88 z_massbal1[i]: A * drho_dt[i] * dz =
89 - (mdot[i+1] + 6.*mdot[i] - 3.*mdot[i-1] - 2.*mdot[i-2]) / 6.;
90 END FOR;
91 FOR i IN mass_central CREATE
92 z_massbal2[i]: A * drho_dt[i] * dz =
93 - (mdot[i+1] - mdot[i-1]) / 2.;
94 END FOR;
95 FOR i IN butfirst1 - mass_upwind4 - mass_central CREATE
96 z_massbal[i]: A * drho_dt[i] * dz = - (mdot[i] - mdot[i-1]);
97 END FOR;
98
99 (* energy conservation *)
100 en_upwind4 :== [];
101 en_central :== central - en_upwind4;
102 FOR i IN en_upwind4 CREATE
103 z_enbal2[i]: dz * (qdot_t[i] - rho[i] * A * du_dt[i]) =
104 + mdot[i] * (node[i+1].u + 6.*u[i] - 3.*u[i-1] - 2.*u[i-1]) / 6.
105 + (p[i+1]*node[i+1].v*mdot[i+1] - p[i-1]*v[i-1]*mdot[i-1]) / 2.;
106 END FOR;
107 FOR i IN en_central CREATE
108 z_enbal1[i]: dz * (qdot_t[i] - rho[i] * A * du_dt[i]) =
109 + mdot[i] * (u[i] - u[i-1]) (* NOTE: not central *)
110 + (p[i+1]*v[i+1]*mdot[i+1] - p[i-1]*v[i-1]*mdot[i-1]) / 2.;
111 END FOR;
112 FOR i IN butfirst1 - en_upwind4 - en_central CREATE
113 z_enbal[i]: dz * (qdot_t[i] - rho[i] * A * du_dt[i]) =
114 + mdot[i] * (u[i] - u[i-1])
115 + (p[i]*v[i]*mdot[i] - p[i-1]*v[i-1]*mdot[i-1]);
116 END FOR;
117
118 (* momentum conservation *)
119 mom_upwind4 :== [];
120 mom_central :== central - mom_upwind4;
121 FOR i IN mom_upwind4 CREATE
122 z_mombal2[i]: - dz/A * dmdot_dt[i]
123 = (p[i]-p[i-1]) (* backdiff for pressure *)
124 + dz * f/D/2 * rho[i] * vel[i]^2
125 + (rho[i+1]*vel[i+1]^2 + 6.*rho[i]*vel[i]^2 - 3.*rho[i-1]*vel[i-1]^2 - 2.*rho[i-2]*vel[i-2]^2) / 6.;
126 END FOR;
127 FOR i IN mom_central CREATE
128 z_mombal1[i]: - dz/A * dmdot_dt[i]
129 = (p[i+1]-p[i-1]) / 2.
130 + dz * f/D/2 * rho[i] * vel[i]^2
131 + (rho[i+1]*vel[i+1]^2 - rho[i-1]*vel[i-1]^2) / 2.;
132 END FOR;
133 FOR i IN butfirst1 - mom_upwind4 - mom_central CREATE
134 z_mombal[i]: - dz/A * dmdot_dt[i]
135 = (p[i]-p[i-1])
136 + dz * f/D/2 * rho[i] * vel[i]^2
137 + (rho[i]*vel[i]^2 - rho[i-1]*vel[i-1]^2);
138 END FOR;
139
140 (* internal/external convection, and thermal mass of wall -- no spatial derivs here *)
141 FOR i IN butfirst1 CREATE
142 z_wall[i]: rho_w*A_w*c_w*dTw_dt[i] = qdot_s - qdot_l[i] - qdot_t[i];
143 z_loss[i]: qdot_l[i] = h_ext*(1{PI}*D_2)*(T_w[i] - T_amb);
144 z_trans[i]: qdot_t[i] = h_int*(1{PI}*D) *(T_w[i] - T[i]);
145 END FOR;
146
147 t IS_A time;
148 METHODS
149 METHOD bound_self;
150 vel[nodes].upper_bound := 100 {m/s};
151 qdot_l[butfirst1].lower_bound := 0 {W/m};
152 FOR i IN nodes DO
153 RUN node[i].bound_self;
154 END FOR;
155 END bound_self;
156 METHOD default;
157 (* these are initial guesses only; fixed parameters are overwritten by 'values' below *)
158 t := 0 {s};
159 FOR i IN nodes DO
160 T[i] := 298 {K};
161 vel[i] := 1 {m/s};
162 RUN node[i].default_self;
163 END FOR;
164 FOR i IN butfirst1 DO
165 drho_dt[i] := 0 {kg/m^3/s};
166 dmdot_dt[i] := 0 {kg/s/s};
167 du_dt[i] := 0 {kJ/kg/s};
168 dTw_dt[i] := 0 {K/s};
169 qdot_t[i] := 0 {W/m};
170 qdot_l[i] := 0 {W/m};
171 x[i] := x[1];
172 END FOR;
173 END default;
174 METHOD specify;
175 (* change to a proper steady-state problem, with fluid properties FREEd *)
176 FOR i IN nodes DO
177 RUN node[i].specify;
178 FIX dTw_dt[i]; FREE T_w[i];
179 END FOR;
180 FIX p[1];
181 FREE T[1];
182 FIX qdot_s;
183 FIX D, D_2;
184 FIX h_int, c_w, rho_w, h_ext;
185 FIX f;
186 (* FIX mu_f; *)
187 FIX T_amb;
188 (* fix derivatives to zero *)
189 FOR i IN butfirst1 DO
190 FREE x[i]; FIX p[i];
191 FIX drho_dt[i]; FREE p[i];
192 FIX du_dt[i]; FREE T[i];
193 FREE mdot[i]; FIX dmdot_dt[i];
194 END FOR;
195 END specify;
196 METHOD values;
197 D := 0.06 {m};
198 D_2 := 0.07 {m};
199 T_amb := 298 {K};
200 h_int := 100 {W/m^2/K};
201 h_ext := 20 {W/m^2/K};
202 f := 0.03;
203 mdot[1] := 0.26 {kg/s};
204 p[1] := 10 {bar};
205 x[1] := 0.23;
206 rho_w := 1000 {kg/m^3};
207 qdot_s := 1000 {W/m^2} * D_2 * 10;
208 FOR i IN butfirst1 DO
209 T_w[i] := 298 {K};
210 dmdot_dt[i] := 0.0 {kg/s/s};
211 du_dt[i] := 0 {kJ/kg/s};
212 v[i] := 0.2 {L/kg};
213 rho[i] := 6 {kg/L};
214 node[i].dp_dT := +0.5 {kPa/K};
215 p[i] := 5 {bar};
216 END FOR;
217 END values;
218 METHOD on_load;
219 RUN configure_steady;
220 RUN ode_init;
221 END on_load;
222 (*---------------- a physically sensible steady-state configuration-----------*)
223 METHOD configure_steady;
224 RUN default_self;
225 RUN ClearAll;
226 RUN specify;
227 RUN bound_steady;
228 RUN values;
229 END configure_steady;
230 METHOD bound_steady;
231 RUN bound_self;
232 T_w[butfirst1].upper_bound := 1000 {K};
233 END bound_steady;
234 (*------------------------- the dynamic problem ------------------------------*)
235 METHOD configure_dynamic;
236 FOR i IN butfirst1 DO
237 FREE drho_dt[i]; FIX rho[i];
238 FREE dmdot_dt[i]; FIX mdot[i];
239 FREE du_dt[i]; FIX u[i];
240 FREE dTw_dt[i]; FIX T_w[i];
241 FREE x[i];
242 FREE T[i];
243 END FOR;
244 t := 0 {s};
245 END configure_dynamic;
246 METHOD free_states;
247 FOR i IN butfirst1 DO
248 FREE rho[i];
249 FREE mdot[i];
250 FREE u[i];
251 FREE T_w[i];
252 END FOR;
253 END free_states;
254 METHOD ode_init;
255 (* add the necessary meta data to allow solving with the integrator *)
256 t.ode_type := -1;
257
258 FOR i IN butfirst1 DO
259 drho_dt[i].ode_id := 4*i; rho[i].ode_id := 4*i;
260 drho_dt[i].ode_type := 2; rho[i].ode_type := 1;
261
262 dmdot_dt[i].ode_id := 4*i+1; mdot[i].ode_id := 4*i+1;
263 dmdot_dt[i].ode_type := 2; mdot[i].ode_type := 1;
264
265 du_dt[i].ode_id := 4*i+2; u[i].ode_id := 4*i+2;
266 du_dt[i].ode_type := 2; u[i].ode_type := 1;
267
268 dTw_dt[i].ode_id := 4*i+3; T_w[i].ode_id := 4*i+3;
269 dTw_dt[i].ode_type := 2; T_w[i].ode_type := 1;
270 END FOR;
271
272 FOR i IN nodes DO
273 (* p[i].obs_id := 1 + 10*i; *)
274 (* x[i].obs_id := 2 + 10*i; *)
275 (* mdot[i].obs_id := 4 + 10*i; *)
276 (* node[i].h.obs_id := 3 + 10*i; *)
277 END FOR;
278 FOR i IN butfirst1 DO
279 (* qdot_t[i].obs_id := 3 + 10*i; *)
280 (* T_w[i].obs_id := 5 + 10*i; *)
281 (* T[i].obs_id := 6 + 10*i;*)
282 END FOR;
283
284 mdot[n].obs_id := 1;
285 x[n].obs_id := 1;
286 p[n].obs_id := 1;
287 vel[n].obs_id := 1;
288
289 END ode_init;
290 METHOD fix_outlet_quality;
291 FIX x[n];
292 FREE mdot[1];
293 END fix_outlet_quality;
294
295 END dsgsat3;
296 ADD NOTES IN dsgsat2;
297 'QRSlv' iterationlimit {50}
298 END NOTES;

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