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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1106 - (show annotations) (download) (as text)
Wed Jan 10 13:07:45 2007 UTC (13 years, 8 months ago) by johnpye
File MIME type: text/x-ascend
File size: 5509 byte(s)
Fixed a bug introduced into slvDOF_structsing.
Fixed an LD_LIBRARY_PATH problem with test.py
1 REQUIRE "ivpsystem.a4l";
2 REQUIRE "atoms.a4l";
3 REQUIRE "johnpye/thermo_types.a4c";
4
5 IMPORT "johnpye/extpy/extpy";
6 IMPORT "johnpye/solve";
7 IMPORT "johnpye/solvernotes";
8
9 (*
10 This model uses some ASCEND models from the freesteam library. See
11 http://freesteam.sf.net/ for more information. This model doesn't actually
12 require compiled binaries of freesteam, so you can just download the .a4c
13 files if you wish.
14 *)
15 REQUIRE "steam/satsteamstream.a4c";
16
17 MODEL dsgsat2;
18 n IS_A integer_constant;
19 n :== 5;
20
21 (* temporal derivatives *)
22 drho_dt[2..n] IS_A density_rate;
23 dmdot_dt[2..n] IS_A mass_rate_rate;
24 drhou_dt[2..n] IS_A power_per_volume;
25 dTw_dt[2..n] IS_A temperature_rate;
26
27 (* wall properties *)
28 rho_w IS_A mass_density;
29 D, D_2 IS_A distance;
30 c_w IS_A specific_heat_capacity;
31 A, A_w IS_A area;
32 h_int IS_A heat_transfer_coefficient; (* internal *)
33 h_ext IS_A heat_transfer_coefficient; (* external *)
34 A = 1{PI}*D^2/4;
35 A_w = 1{PI}*(D_2^2 - D^2)/4;
36 dz IS_A distance;
37 L IS_A distance;
38 dz = L / n;
39
40 (* fluid properties *)
41 node[1..n] IS_A satsteamstream;
42
43 (* flow properties *)
44 vel[1..n] IS_A speed;
45 T_w[1..n] IS_A temperature;
46
47 (* constants, for the moment: *)
48 f IS_A positive_factor;
49 mu_f IS_A viscosity;
50 T_amb IS_A temperature;
51
52 (* system dynamics *)
53 qdot_t[2..n], qdot_l[2..n] IS_A power_per_length;
54 qdot_s IS_A power_per_length;
55 rhou[1..n] IS_A energy_per_volume;
56
57 FOR i IN [1..n] CREATE
58 vel[i] = node[i].v*node[i].mdot/A;
59 rhou[i] = node[i].rho * node[i].u;
60 END FOR;
61
62 (* some aliases just for easier review of the state of the model *)
63 x[1..n] IS_A fraction;
64 mdot[1..n] IS_A mass_rate;
65 p[1..n] IS_A pressure;
66 FOR i IN [1..n] CREATE
67 x[i], node[i].x ARE_THE_SAME;
68 mdot[i], node[i].mdot ARE_THE_SAME;
69 p[i], node[i].p ARE_THE_SAME;
70 END FOR;
71
72 (* differential equations *)
73 FOR i IN [2..n] CREATE
74 A * drho_dt[i] = - (node[i].mdot - node[i-1].mdot)/dz;
75 1/A*dmdot_dt[i] = -(node[i].p-node[i-1].p)/dz - f/D/2*node[i].rho*node[i].v^2* (node[i].rho*vel[i]^2 - node[i-1].rho*vel[i-1]^2)/dz;
76 A * drhou_dt[i] = qdot_t[i] - (node[i].Hdot - node[i-1].Hdot)/dz;
77 rho_w*A_w*c_w*dTw_dt[i] = qdot_s - qdot_l[i] - qdot_t[i];
78 qdot_l[i] = h_ext*(1{PI}*D_2)*(T_w[i] - T_amb);
79 qdot_t[i] = h_int*(1{PI}*D) *(T_w[i] - node[i].T);
80 END FOR;
81
82 t IS_A time;
83 METHODS
84 METHOD default_self;
85 A := 5 {cm^2};
86 FOR i IN [1..n] DO
87 RUN node[i].default_self;
88 mdot[i] := 0.001 {kg/s};
89 vel[i] := 0.01 {m/s};
90 END FOR;
91 END default_self;
92 METHOD specify_easy;
93 FOR i IN [1..n] DO
94 RUN node[i].specify;
95 FIX dTw_dt[i]; FREE T_w[i];
96 END FOR;
97 FIX qdot_s;
98 FIX D, D_2, L;
99 FIX h_int, c_w, rho_w, h_ext;
100 FIX f, mu_f;
101 FIX T_amb;
102 END specify_easy;
103 METHOD specify;
104 RUN node[1].specify;
105 FIX qdot_s;
106 FIX D, D_2, L;
107 FIX h_int, c_w, rho_w, h_ext;
108 FIX f, mu_f;
109 FIX T_amb;
110 (* fix derivatives to zero *)
111 FOR i IN [2..n] DO
112 FIX drho_dt[i]; FREE node[i].rho;
113 FIX dmdot_dt[i]; FREE node[i].mdot;
114 FIX drhou_dt[i]; FREE rhou[i];
115 FIX dTw_dt[i]; FREE T_w[i];
116 END FOR;
117 (* FIX node[3].rho; *)
118 END specify;
119 METHOD values;
120 node[1].T := 400 {K};
121 node[1].x := 0.1;
122 qdot_s := 0 {W/m};
123 D := 60 {mm}; D_2 := 70 {mm};
124 L := 100 {m};
125 A_w := 1{PI}*D_2^2;
126 h_int := 10 {W/m^2/K}; c_w := 0.47 {J/g/K}; rho_w := 7.8 {g/cm^3}; h_ext := 10 {W/m^2/K};
127 f := 0.005; mu_f := 4.5e-5 {Pa*s};
128 T_amb := 300 {K};
129 FOR i IN [2..n] DO
130 drho_dt[i] := 0 {kg/m^3/s};
131 dmdot_dt[i] := 0 {kg/s/s};
132 drhou_dt[i] := 0 {kJ/m^3/s};
133 dTw_dt[i] := 0 {K/s};
134 END FOR;
135 t := 0 {s};
136 END values;
137 METHOD bound_self;
138 vel[1..n].upper_bound := 100 {m/s};
139 FOR i IN [1..n] DO
140 RUN node[i].bound_self;
141 END FOR;
142 END bound_self;
143 METHOD on_load;
144 RUN default_self;
145 RUN ClearAll;
146 RUN specify_easy;
147 EXTERNAL solvernotes(SELF);
148 EXTERNAL solve(SELF);
149 RUN bound_self;
150 RUN values;
151 RUN ode_init;
152 EXTERNAL solvernotes(SELF);
153 EXTERNAL solve(SELF);
154 RUN fixed_states;
155 END on_load;
156 METHOD fixed_states;
157 qdot_s := 10 {W/m};
158 FOR i IN [2..n] DO
159 FREE drho_dt[i]; FIX node[i].rho;
160 FREE dmdot_dt[i]; FIX node[i].mdot;
161 FREE drhou_dt[i]; FIX rhou[i];
162 FREE dTw_dt[i]; FIX T_w[i];
163 END FOR;
164 END fixed_states;
165 METHOD fixed_derivs;
166 FOR i IN [2..n] DO
167 FIX drho_dt[i]; FREE node[i].rho;
168 FIX dmdot_dt[i]; FREE node[i].mdot;
169 FIX drhou_dt[i]; FREE rhou[i];
170 FIX dTw_dt[i]; FREE T_w[i];
171 END FOR;
172 END fixed_derivs;
173 METHOD ode_init;
174 (* get the model into the required state for solving as ODE *)
175 t.ode_type := -1;
176 t.obs_id := 1;
177
178 FOR i IN [2..n] DO
179 drho_dt[i].ode_id := 4*i; node[i].rho.ode_id := 4*i;
180 drho_dt[i].ode_type := 2; node[i].rho.ode_type := 1;
181
182 dmdot_dt[i].ode_id := 4*i+1; node[i].mdot.ode_id := 4*i+1;
183 dmdot_dt[i].ode_type := 2; node[i].mdot.ode_type := 1;
184
185 drhou_dt[i].ode_id := 4*i+2; rhou[i].ode_id := 4*i+2;
186 drhou_dt[i].ode_type := 2; rhou[i].ode_type := 1;
187
188 dTw_dt[i].ode_id := 4*i+3; T_w[i].ode_id := 4*i+3;
189 dTw_dt[i].ode_type := 2; T_w[i].ode_type := 1;
190
191 (*
192 p[i].obs_id := 4*i;
193 x[i].obs_id := 4*i+1;
194 qdot_t[i].obs_id := 4*i+2;
195 T_w[i].obs_id := 4*i+3;
196 *)
197 END FOR;
198
199 FOR i IN [1..n] DO
200 p[i].obs_id := 1 + 4*i;
201 x[i].obs_id := 2 + 4*i+1;
202 END FOR;
203 FOR i IN [] DO
204 (* qdot_t[i].obs_id := 3 + 4*i; *)
205 node[i].mdot.obs_id := 3 + 4*i;
206 T_w[i].obs_id := 4 + 4*i;
207 END FOR;
208 END ode_init;
209
210 METHOD fix_outlet_quality;
211 FIX x[n];
212 FREE node[1].mdot;
213 END fix_outlet_quality;
214
215 METHOD reinit;
216 RUN on_load;
217 EXTERNAL solve(SELF);
218 RUN fixed_states;
219 END reinit;
220
221 END dsgsat2;
222 ADD NOTES IN dsgsat2;
223 'QRSlv' iterationlimit {50}
224 END NOTES;

Properties

Name Value
svn:executable *

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