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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1306 - (show annotations) (download) (as text)
Sat Mar 3 11:50:47 2007 UTC (15 years, 3 months ago) by johnpye
File MIME type: text/x-ascend
File size: 8050 byte(s)
Added and performed basic tests of integrator_ida_write_matrix. Generalised the write_matrix
routine so that *any* requested output can be retrieved from the integrator (for the case
of IDA this is y and y', but it could equally be more complicated stuff.)
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 :== 50;(* 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 :== 5 {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 (* mass conservation *)
83 FOR i IN upwind4 CREATE (* 4-pt upwind biased *)
84 z_massbal1[i]: A * drho_dt[i] * dz =
85 - (mdot[i+1] + 6.*mdot[i] - 3.*mdot[i-1] - 2.*mdot[i-2]) / 6.;
86 END FOR;
87 FOR i IN [] CREATE
88 z_massbal2[i]: A * drho_dt[i] * dz =
89 - (mdot[i+1] - mdot[i-1]) / 2.;
90 END FOR;
91 FOR i IN [2,n] CREATE
92 z_massbal[i]: A * drho_dt[i] * dz = - (mdot[i] - mdot[i-1]);
93 END FOR;
94
95 (* energy conservation *)
96 FOR i IN [] CREATE
97 z_enbal2[i]: dz * (qdot_t[i] - rho[i] * A * du_dt[i]) =
98 + mdot[i] * (node[i+1].u + 6.*u[i] - 3.*u[i-1] - 2.*u[i-1]) / 6.
99 + (p[i+1]*node[i+1].v*mdot[i+1] - p[i-1]*v[i-1]*mdot[i-1]) / 2.;
100 END FOR;
101 FOR i IN central CREATE
102 z_enbal1[i]: dz * (qdot_t[i] - rho[i] * A * du_dt[i]) =
103 + mdot[i] * (u[i] - u[i-1]) (* NOTE: not central *)
104 + (p[i+1]*v[i+1]*mdot[i+1] - p[i-1]*v[i-1]*mdot[i-1]) / 2.;
105 END FOR;
106 FOR i IN [n] CREATE
107 z_enbal[i]: dz * (qdot_t[i] - rho[i] * A * du_dt[i]) =
108 + mdot[i] * (u[i] - u[i-1])
109 + (p[i]*v[i]*mdot[i] - p[i-1]*v[i-1]*mdot[i-1]);
110 END FOR;
111
112 (* momentum conservation *)
113 FOR i IN upwind4 CREATE
114 z_mombal2[i]: - dz/A * dmdot_dt[i]
115 = (p[i]-p[i-1]) (* backdiff for pressure *)
116 + dz * f/D/2 * rho[i] * vel[i]^2
117 + (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.;
118 END FOR;
119 FOR i IN [] CREATE
120 z_mombal1[i]: - dz/A * dmdot_dt[i]
121 = (p[i+1]-p[i-1]) / 2.
122 + dz * f/D/2 * rho[i] * vel[i]^2
123 + (rho[i+1]*vel[i+1]^2 - rho[i-1]*vel[i-1]^2) / 2.;
124 END FOR;
125 FOR i IN [2,n] CREATE
126 z_mombal[i]: - dz/A * dmdot_dt[i]
127 = (p[i]-p[i-1])
128 + dz * f/D/2 * rho[i] * vel[i]^2
129 + (rho[i]*vel[i]^2 - rho[i-1]*vel[i-1]^2);
130 END FOR;
131
132 (* internal/external convection, and thermal mass of wall -- no spatial derivs here *)
133 FOR i IN butfirst1 CREATE
134 z_wall[i]: rho_w*A_w*c_w*dTw_dt[i] = qdot_s - qdot_l[i] - qdot_t[i];
135 z_loss[i]: qdot_l[i] = h_ext*(1{PI}*D_2)*(T_w[i] - T_amb);
136 z_trans[i]: qdot_t[i] = h_int*(1{PI}*D) *(T_w[i] - T[i]);
137 END FOR;
138
139 t IS_A time;
140 METHODS
141 METHOD bound_self;
142 vel[nodes].upper_bound := 100 {m/s};
143 qdot_l[butfirst1].lower_bound := 0 {W/m};
144 FOR i IN nodes DO
145 RUN node[i].bound_self;
146 END FOR;
147 END bound_self;
148 METHOD default;
149 (* these are initial guesses only; fixed parameters are overwritten by 'values' below *)
150 D := 0.06 {m};
151 D_2 := 0.07 {m};
152 A_w := 0.25{PI}*D_2^2 -0.25{PI}*D^2;
153 A := 1 {m^2};
154 T_amb := 298 {K};
155 f := 0.0;
156 h_ext := 10 {W/m^2/K};
157 h_int := 100 {W/m^2/K};
158 qdot_s := 1000 {W/m};
159 rho_w := 1000 {kg/m^3};
160 t := 0 {s};
161 FOR i IN nodes DO
162 T[i] := 298 {K};
163 vel[i] := 1 {m/s};
164 RUN node[i].default_self;
165 END FOR;
166 FOR i IN butfirst1 DO
167 T_w[i] := 298 {K};
168 drho_dt[i] := 0 {kg/m^3/s};
169 dmdot_dt[i] := 0 {kg/s/s};
170 du_dt[i] := 0 {kJ/kg/s};
171 dTw_dt[i] := 0 {K/s};
172 qdot_t[i] := 0 {W/m};
173 qdot_l[i] := 0 {W/m};
174 x[i] := x[1];
175 END FOR;
176 END default;
177 METHOD specify;
178 (* change to a proper steady-state problem, with fluid properties FREEd *)
179 FOR i IN nodes DO
180 RUN node[i].specify;
181 FIX dTw_dt[i]; FREE T_w[i];
182 END FOR;
183 FIX p[1];
184 FREE T[1];
185 FIX qdot_s;
186 FIX D, D_2;
187 FIX h_int, c_w, rho_w, h_ext;
188 FIX f;
189 (* FIX mu_f; *)
190 FIX T_amb;
191 (* fix derivatives to zero *)
192 FOR i IN [2..n] DO
193 FREE x[i]; FIX p[i];
194 FIX drho_dt[i]; FREE p[i];
195 FIX du_dt[i]; FREE T[i];
196 FREE mdot[i]; FIX dmdot_dt[i];
197 END FOR;
198 END specify;
199 METHOD values;
200 h_int := 100 {W/m^2/K};
201 h_ext := 20 {W/m^2/K};
202 f := 0.0;
203 mdot[1] := 0.26 {kg/s};
204 p[1] := 10 {bar};
205 x[1] := 0.1;
206 qdot_s := 1000 {W/m^2} * D_2 * 10;
207 FOR i IN [2..n] DO
208 dmdot_dt[i] := 0.0 {kg/s/s};
209 du_dt[i] := 0 {kJ/kg/s};
210 v[i] := 0.2 {L/kg};
211 rho[i] := 6 {kg/L};
212 node[i].dp_dT := +0.5 {kPa/K};
213 p[i] := 5 {bar};
214 END FOR;
215 END values;
216 METHOD on_load;
217 RUN configure_steady;
218 RUN ode_init;
219 END on_load;
220 (*---------------- a physically sensible steady-state configuration-----------*)
221 METHOD configure_steady;
222 RUN default_self;
223 RUN ClearAll;
224 RUN specify;
225 RUN bound_steady;
226 RUN values;
227 END configure_steady;
228 METHOD bound_steady;
229 RUN bound_self;
230 T_w[2..n].upper_bound := 1000 {K};
231 END bound_steady;
232 (*------------------------- the dynamic problem ------------------------------*)
233 METHOD configure_dynamic;
234 FOR i IN [2..n] DO
235 FREE drho_dt[i]; FIX rho[i];
236 FREE dmdot_dt[i]; FIX mdot[i];
237 FREE du_dt[i]; FIX u[i];
238 FREE dTw_dt[i]; FIX T_w[i];
239 FREE x[i];
240 FREE T[i];
241 END FOR;
242 t := 0 {s};
243 END configure_dynamic;
244 METHOD free_states;
245 FOR i IN [2..n] DO
246 FREE rho[i];
247 FREE mdot[i];
248 FREE u[i];
249 FREE T_w[i];
250 END FOR;
251 END free_states;
252 METHOD ode_init;
253 (* add the necessary meta data to allow solving with the integrator *)
254 t.ode_type := -1;
255
256 FOR i IN [2..n] DO
257 drho_dt[i].ode_id := 4*i; rho[i].ode_id := 4*i;
258 drho_dt[i].ode_type := 2; rho[i].ode_type := 1;
259
260 dmdot_dt[i].ode_id := 4*i+1; mdot[i].ode_id := 4*i+1;
261 dmdot_dt[i].ode_type := 2; mdot[i].ode_type := 1;
262
263 du_dt[i].ode_id := 4*i+2; u[i].ode_id := 4*i+2;
264 du_dt[i].ode_type := 2; u[i].ode_type := 1;
265
266 dTw_dt[i].ode_id := 4*i+3; T_w[i].ode_id := 4*i+3;
267 dTw_dt[i].ode_type := 2; T_w[i].ode_type := 1;
268 END FOR;
269
270 FOR i IN nodes DO
271 (* p[i].obs_id := 1 + 10*i; *)
272 (* x[i].obs_id := 2 + 10*i; *)
273 (* mdot[i].obs_id := 4 + 10*i; *)
274 (* node[i].h.obs_id := 3 + 10*i; *)
275 END FOR;
276 FOR i IN [2..n] DO
277 (* qdot_t[i].obs_id := 3 + 10*i; *)
278 (* T_w[i].obs_id := 5 + 10*i; *)
279 (* T[i].obs_id := 6 + 10*i;*)
280 END FOR;
281
282 mdot[n].obs_id := 1;
283 x[n].obs_id := 1;
284 p[n].obs_id := 1;
285 vel[n].obs_id := 1;
286
287 END ode_init;
288 METHOD fix_outlet_quality;
289 FIX x[n];
290 FREE mdot[1];
291 END fix_outlet_quality;
292
293 END dsgsat3;
294 ADD NOTES IN dsgsat2;
295 'QRSlv' iterationlimit {50}
296 END NOTES;

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