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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1107 - (hide annotations) (download) (as text)
Wed Jan 10 13:21:45 2007 UTC (13 years, 8 months ago) by johnpye
File MIME type: text/x-ascend
File size: 5544 byte(s)
Make dsgsat2.a4c load without EXTERNAL method calls.
1 johnpye 923 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 johnpye 1046 REQUIRE "steam/satsteamstream.a4c";
16 johnpye 923
17     MODEL dsgsat2;
18     n IS_A integer_constant;
19 johnpye 1107 n :== 70;
20 johnpye 923
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 johnpye 1106 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 johnpye 1107 FREE rhou[i];
97 johnpye 1106 END FOR;
98     FIX qdot_s;
99     FIX D, D_2, L;
100     FIX h_int, c_w, rho_w, h_ext;
101     FIX f, mu_f;
102     FIX T_amb;
103     END specify_easy;
104 johnpye 923 METHOD specify;
105     RUN node[1].specify;
106     FIX qdot_s;
107     FIX D, D_2, L;
108     FIX h_int, c_w, rho_w, h_ext;
109     FIX f, mu_f;
110     FIX T_amb;
111     (* fix derivatives to zero *)
112     FOR i IN [2..n] DO
113     FIX drho_dt[i]; FREE node[i].rho;
114     FIX dmdot_dt[i]; FREE node[i].mdot;
115     FIX drhou_dt[i]; FREE rhou[i];
116     FIX dTw_dt[i]; FREE T_w[i];
117     END FOR;
118     (* FIX node[3].rho; *)
119     END specify;
120     METHOD values;
121     node[1].T := 400 {K};
122     node[1].x := 0.1;
123     qdot_s := 0 {W/m};
124     D := 60 {mm}; D_2 := 70 {mm};
125     L := 100 {m};
126     A_w := 1{PI}*D_2^2;
127     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};
128     f := 0.005; mu_f := 4.5e-5 {Pa*s};
129     T_amb := 300 {K};
130     FOR i IN [2..n] DO
131     drho_dt[i] := 0 {kg/m^3/s};
132     dmdot_dt[i] := 0 {kg/s/s};
133     drhou_dt[i] := 0 {kJ/m^3/s};
134     dTw_dt[i] := 0 {K/s};
135     END FOR;
136 johnpye 1055 t := 0 {s};
137 johnpye 923 END values;
138 johnpye 1106 METHOD bound_self;
139     vel[1..n].upper_bound := 100 {m/s};
140 johnpye 923 FOR i IN [1..n] DO
141     RUN node[i].bound_self;
142     END FOR;
143 johnpye 1106 END bound_self;
144     METHOD on_load;
145     RUN default_self;
146     RUN ClearAll;
147     RUN specify_easy;
148 johnpye 1107 (* EXTERNAL solvernotes(SELF); *)
149     (* EXTERNAL solve(SELF); *)
150 johnpye 1106 RUN bound_self;
151 johnpye 923 RUN values;
152 johnpye 1107 (* RUN ode_init;
153 johnpye 1046 EXTERNAL solvernotes(SELF);
154 johnpye 1055 EXTERNAL solve(SELF);
155 johnpye 1107 RUN fixed_states; *)
156 johnpye 923 END on_load;
157 johnpye 1049 METHOD fixed_states;
158 johnpye 1046 qdot_s := 10 {W/m};
159 johnpye 923 FOR i IN [2..n] DO
160 johnpye 1049 FREE drho_dt[i]; FIX node[i].rho;
161     FREE dmdot_dt[i]; FIX node[i].mdot;
162     FREE drhou_dt[i]; FIX rhou[i];
163     FREE dTw_dt[i]; FIX T_w[i];
164 johnpye 923 END FOR;
165 johnpye 1106 END fixed_states;
166 johnpye 1049 METHOD fixed_derivs;
167     FOR i IN [2..n] DO
168     FIX drho_dt[i]; FREE node[i].rho;
169     FIX dmdot_dt[i]; FREE node[i].mdot;
170     FIX drhou_dt[i]; FREE rhou[i];
171     FIX dTw_dt[i]; FREE T_w[i];
172     END FOR;
173 johnpye 1106 END fixed_derivs;
174 johnpye 1049 METHOD ode_init;
175     (* get the model into the required state for solving as ODE *)
176     t.ode_type := -1;
177 johnpye 1050 t.obs_id := 1;
178 johnpye 923
179     FOR i IN [2..n] DO
180     drho_dt[i].ode_id := 4*i; node[i].rho.ode_id := 4*i;
181     drho_dt[i].ode_type := 2; node[i].rho.ode_type := 1;
182    
183     dmdot_dt[i].ode_id := 4*i+1; node[i].mdot.ode_id := 4*i+1;
184     dmdot_dt[i].ode_type := 2; node[i].mdot.ode_type := 1;
185    
186     drhou_dt[i].ode_id := 4*i+2; rhou[i].ode_id := 4*i+2;
187     drhou_dt[i].ode_type := 2; rhou[i].ode_type := 1;
188    
189     dTw_dt[i].ode_id := 4*i+3; T_w[i].ode_id := 4*i+3;
190     dTw_dt[i].ode_type := 2; T_w[i].ode_type := 1;
191    
192     (*
193     p[i].obs_id := 4*i;
194     x[i].obs_id := 4*i+1;
195     qdot_t[i].obs_id := 4*i+2;
196     T_w[i].obs_id := 4*i+3;
197     *)
198     END FOR;
199    
200 johnpye 1055 FOR i IN [1..n] DO
201 johnpye 1050 p[i].obs_id := 1 + 4*i;
202     x[i].obs_id := 2 + 4*i+1;
203 johnpye 923 END FOR;
204 johnpye 1055 FOR i IN [] DO
205 johnpye 1050 (* qdot_t[i].obs_id := 3 + 4*i; *)
206 johnpye 1055 node[i].mdot.obs_id := 3 + 4*i;
207 johnpye 1050 T_w[i].obs_id := 4 + 4*i;
208 johnpye 923 END FOR;
209     END ode_init;
210    
211     METHOD fix_outlet_quality;
212     FIX x[n];
213     FREE node[1].mdot;
214     END fix_outlet_quality;
215    
216 johnpye 1049 METHOD reinit;
217     RUN on_load;
218     EXTERNAL solve(SELF);
219     RUN fixed_states;
220     END reinit;
221    
222 johnpye 923 END dsgsat2;
223     ADD NOTES IN dsgsat2;
224     'QRSlv' iterationlimit {50}
225     END NOTES;
226    
227    

Properties

Name Value
svn:executable *

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