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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1046 - (show annotations) (download) (as text)
Fri Jan 5 11:15:16 2007 UTC (13 years, 8 months ago) by johnpye
File MIME type: text/x-ascend
File size: 4600 byte(s)
Several changes to get BinToken compilation active again from PyGTK interface. Still not working but the problems now are in the C layer.
Tidied doc for slvDOF.h
Changed BinTokenSetOptions to saner use of strings -- no more 'taking ownership' of char arrays passed.
Added Compiler.use_binary_compilation option in PyGTK GUI.
Moved all the bintoken stuff out of class Type and into Compiler, where it should be (C++).
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 :== 3;
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 specify;
85 RUN node[1].specify;
86 FIX qdot_s;
87 FIX D, D_2, L;
88 FIX h_int, c_w, rho_w, h_ext;
89 FIX f, mu_f;
90 FIX T_amb;
91 (* fix derivatives to zero *)
92 FOR i IN [2..n] DO
93 FIX drho_dt[i]; FREE node[i].rho;
94 FIX dmdot_dt[i]; FREE node[i].mdot;
95 FIX drhou_dt[i]; FREE rhou[i];
96 FIX dTw_dt[i]; FREE T_w[i];
97 END FOR;
98 (* FIX node[3].rho; *)
99
100 END specify;
101 METHOD values;
102 node[1].T := 400 {K};
103 node[1].x := 0.1;
104 qdot_s := 0 {W/m};
105 D := 60 {mm}; D_2 := 70 {mm};
106 L := 100 {m};
107 A_w := 1{PI}*D_2^2;
108 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};
109 f := 0.005; mu_f := 4.5e-5 {Pa*s};
110 T_amb := 300 {K};
111 FOR i IN [2..n] DO
112 drho_dt[i] := 0 {kg/m^3/s};
113 dmdot_dt[i] := 0 {kg/s/s};
114 drhou_dt[i] := 0 {kJ/m^3/s};
115 dTw_dt[i] := 0 {K/s};
116 END FOR;
117 END values;
118 METHOD on_load;
119 RUN specify;
120 FOR i IN [1..n] DO
121 RUN node[i].bound_self;
122 END FOR;
123 RUN values;
124 EXTERNAL solvernotes(SELF);
125 (* RUN ode_init;
126 RUN solve; *) (* after fixing the states and freeing the derivatives *)
127 END on_load;
128 METHOD ode_init;
129 (* get the model into the required state for solving as ODE *)
130 t.ode_type := -1;
131 t := 0 {s};
132 qdot_s := 10 {W/m};
133 FOR i IN [2..n] DO
134 FREE drho_dt[i]; FREE node[i].rho;
135 FREE dmdot_dt[i]; FREE node[i].mdot;
136 FREE drhou_dt[i]; FREE rhou[i];
137 FREE dTw_dt[i]; FREE T_w[i];
138 END FOR;
139
140 FOR i IN [2..n] DO
141 drho_dt[i].ode_id := 4*i; node[i].rho.ode_id := 4*i;
142 drho_dt[i].ode_type := 2; node[i].rho.ode_type := 1;
143
144 dmdot_dt[i].ode_id := 4*i+1; node[i].mdot.ode_id := 4*i+1;
145 dmdot_dt[i].ode_type := 2; node[i].mdot.ode_type := 1;
146
147 drhou_dt[i].ode_id := 4*i+2; rhou[i].ode_id := 4*i+2;
148 drhou_dt[i].ode_type := 2; rhou[i].ode_type := 1;
149
150 dTw_dt[i].ode_id := 4*i+3; T_w[i].ode_id := 4*i+3;
151 dTw_dt[i].ode_type := 2; T_w[i].ode_type := 1;
152
153 (*
154 p[i].obs_id := 4*i;
155 x[i].obs_id := 4*i+1;
156 qdot_t[i].obs_id := 4*i+2;
157 T_w[i].obs_id := 4*i+3;
158 *)
159 END FOR;
160
161 FOR i IN [1,n] DO
162 p[i].obs_id := 4*i;
163 x[i].obs_id := 4*i+1;
164 END FOR;
165 FOR i IN [2,n] DO
166 (* qdot_t[i].obs_id := 4*i+2; *)
167 T_w[i].obs_id := 4*i+3;
168 END FOR;
169 END ode_init;
170
171 METHOD fix_outlet_quality;
172 FIX x[n];
173 FREE node[1].mdot;
174 END fix_outlet_quality;
175
176 END dsgsat2;
177 ADD NOTES IN dsgsat2;
178 'QRSlv' iterationlimit {50}
179 END NOTES;

Properties

Name Value
svn:executable *

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