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

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

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1108 by johnpye, Wed Jan 10 13:21:45 2007 UTC revision 1109 by johnpye, Thu Jan 11 04:07:02 2007 UTC
# Line 16  REQUIRE "steam/satsteamstream.a4c"; Line 16  REQUIRE "steam/satsteamstream.a4c";
16    
17  MODEL dsgsat2;  MODEL dsgsat2;
18      n IS_A integer_constant;      n IS_A integer_constant;
19      n :== 70;      n :== 5;
20    
21      (* temporal derivatives *)      (* temporal derivatives *)
22      drho_dt[2..n] IS_A density_rate;      drho_dt[2..n] IS_A density_rate;
# Line 71  MODEL dsgsat2; Line 71  MODEL dsgsat2;
71    
72      (* differential equations *)      (* differential equations *)
73      FOR i IN [2..n] CREATE      FOR i IN [2..n] CREATE
74          A * drho_dt[i] = - (node[i].mdot - node[i-1].mdot)/dz;          z_massbal[i]: 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;          z_mombal[i]:  1/A*dmdot_dt[i] = -(node[i].p-node[i-1].p)/dz
76          A * drhou_dt[i] = qdot_t[i] - (node[i].Hdot - node[i-1].Hdot)/dz;                          - f/D/2*node[i].rho*node[i].v^2*(
77          rho_w*A_w*c_w*dTw_dt[i] = qdot_s - qdot_l[i] - qdot_t[i];                              node[i].rho*vel[i]^2 - node[i-1].rho*vel[i-1]^2
78          qdot_l[i] = h_ext*(1{PI}*D_2)*(T_w[i] - T_amb);                          )/dz;
79          qdot_t[i] = h_int*(1{PI}*D)  *(T_w[i] - node[i].T);          z_enbal[i]: A * drhou_dt[i] = qdot_t[i] - (node[i].Hdot - node[i-1].Hdot)/dz;
80            z_wall[i]:  rho_w*A_w*c_w*dTw_dt[i] = qdot_s - qdot_l[i] - qdot_t[i];
81            z_loss[i]:  qdot_l[i] = h_ext*(1{PI}*D_2)*(T_w[i] - T_amb);
82            z_trans[i]: qdot_t[i] = h_int*(1{PI}*D)  *(T_w[i] - node[i].T);
83      END FOR;      END FOR;
84    
85      t IS_A time;      t IS_A time;
86  METHODS  METHODS
87    METHOD on_load;
88        RUN configure_onload;
89        EXTERNAL solve(SELF);
90        RUN configure_steady;
91    END on_load;
92    (*----------------------- a reliable on-load configuration -------------------*)
93    METHOD configure_onload;
94        RUN default_self;
95        RUN reset;
96        RUN bound_self;
97        RUN values;
98        RUN ode_init;
99        EXTERNAL solve(SELF);
100    END configure_onload;  
101  METHOD default_self;  METHOD default_self;
102      A := 5 {cm^2};      A := 5 {cm^2};
103      FOR i IN [1..n] DO      FOR i IN [1..n] DO
104          RUN node[i].default_self;          RUN node[i].default_self;
105          mdot[i] := 0.001 {kg/s};          mdot[i] := 0.001 {kg/s};
106          vel[i] := 0.01 {m/s};          vel[i] := 0.01 {m/s};
107            x[i] := 0.1;
108      END FOR;      END FOR;
109  END default_self;  END default_self;
110  METHOD specify_easy;  METHOD specify;
111        (* put the model in a state that we are sure it will solve: no big blocks, etc *)
112        RUN ClearAll;
113      FOR i IN [1..n] DO      FOR i IN [1..n] DO
114          RUN node[i].specify;          RUN node[i].specify;
115          FIX dTw_dt[i];   FREE T_w[i];          FIX dTw_dt[i]; FREE T_w[i];
116          FREE rhou[i];          FREE rhou[i];
117      END FOR;      END FOR;
118      FIX qdot_s;      FIX qdot_s;
# Line 100  METHOD specify_easy; Line 120  METHOD specify_easy;
120      FIX h_int, c_w, rho_w, h_ext;      FIX h_int, c_w, rho_w, h_ext;
121      FIX f, mu_f;      FIX f, mu_f;
122      FIX T_amb;      FIX T_amb;
 END specify_easy;    
 METHOD specify;  
     RUN node[1].specify;  
     FIX qdot_s;  
     FIX D, D_2, L;  
     FIX h_int, c_w, rho_w, h_ext;  
     FIX f, mu_f;  
     FIX T_amb;  
     (* fix derivatives to zero *)  
     FOR i IN [2..n] DO  
         FIX drho_dt[i];  FREE node[i].rho;  
         FIX dmdot_dt[i]; FREE node[i].mdot;  
         FIX drhou_dt[i]; FREE rhou[i];  
         FIX dTw_dt[i];   FREE T_w[i];  
     END FOR;  
     (* FIX node[3].rho; *)  
123  END specify;  END specify;
124  METHOD values;  METHOD values;
125      node[1].T := 400 {K};      node[1].T := 424.98 {K};
126      node[1].x := 0.1;      node[1].x := 0.1;
127      qdot_s := 0 {W/m};      qdot_s := 0 {W/m};
128      D := 60 {mm}; D_2 := 70 {mm};      D := 60 {mm}; D_2 := 70 {mm};
# Line 134  METHOD values; Line 138  METHOD values;
138          dTw_dt[i] := 0 {K/s};          dTw_dt[i] := 0 {K/s};
139      END FOR;      END FOR;
140      t := 0 {s};      t := 0 {s};
141  END values;  END values;
142  METHOD bound_self;  METHOD bound_self;
143      vel[1..n].upper_bound := 100 {m/s};      vel[1..n].upper_bound := 100 {m/s};
144      FOR i IN [1..n] DO      FOR i IN [1..n] DO
145          RUN node[i].bound_self;          RUN node[i].bound_self;
146      END FOR;      END FOR;
147  END bound_self;  END bound_self;
148  METHOD on_load;  (*---------------- a physically sensible steady-state configuration-----------*)
149      RUN default_self;  METHOD configure_steady;
150      RUN ClearAll;      RUN ClearAll;
151      RUN specify_easy;      RUN specify_steady;
152      (* EXTERNAL solvernotes(SELF); *)      RUN values_steady;
153      (* EXTERNAL solve(SELF); *)  END configure_steady;
154      RUN bound_self;  METHOD specify_steady;
155      RUN values;      (* change to a proper steady-state problem, with fluid properties FREEd *)
156      (* RUN ode_init;      FOR i IN [1..n] DO
157      EXTERNAL solvernotes(SELF);          RUN node[i].specify;
158      EXTERNAL solve(SELF);          FIX dTw_dt[i];   FREE T_w[i];
159      RUN fixed_states; *)          FREE rhou[i];
160  END on_load;      END FOR;
161        FIX node[1].p;
162        FREE node[1].T;
163        FIX qdot_s;
164        FIX D, D_2, L;
165        FIX h_int, c_w, rho_w, h_ext;
166        FIX f, mu_f;
167        FIX T_amb;
168        (* fix derivatives to zero *)
169        FOR i IN [2..n] DO
170            (* FIX dmdot_dt[i]; FREE node[i].mdot; *)
171            FREE node[i].x; FIX node[i].p;
172            FIX drho_dt[i];  FREE node[i].p;
173            FIX drhou_dt[i]; FREE node[i].T;
174            FREE mdot[i]; FIX dmdot_dt[i];
175        END FOR;
176    END specify_steady;
177    METHOD values_steady;
178        node[1].p := 5 {bar};
179        FOR i IN [2..n] DO
180            dmdot_dt[i] := 0.0 {kg/s/s};
181            node[i].v := 0.2 {L/kg};
182            node[i].rho := 6 {kg/L};
183        END FOR;
184        (* nothing atm *)
185    END values_steady;
186    (*------------------------- the dynamic problem ------------------------------*)
187    METHOD fixed_pressures;
188        RUN ClearAll;
189        RUN specify;
190        FOR i IN [1..n] DO
191            FREE node[i].T;
192            FIX node[i].p;
193            node[i].p := 5 {bar};
194            FREE node[i].x;
195            FIX dmdot_dt[i];
196    (*
197            FIX dmdot_dt[i];
198            FREE node[i].x;
199            dmdot_dt[i] := 0 {kg/s/s};*)
200        END FOR;
201    END fixed_pressures;
202  METHOD fixed_states;  METHOD fixed_states;
203      qdot_s := 10 {W/m};      qdot_s := 10 {W/m};
204      FOR i IN [2..n] DO      FOR i IN [2..n] DO
# Line 172  METHOD fixed_derivs; Line 217  METHOD fixed_derivs;
217      END FOR;      END FOR;
218  END fixed_derivs;  END fixed_derivs;
219  METHOD ode_init;  METHOD ode_init;
220      (* get the model into the required state for solving as ODE *)      (* add the necessary meta data to allow solving with the integrator *)
221      t.ode_type := -1;      t.ode_type := -1;
222      t.obs_id := 1;      t.obs_id := 1;
223    
# Line 188  METHOD ode_init; Line 233  METHOD ode_init;
233    
234          dTw_dt[i].ode_id := 4*i+3;    T_w[i].ode_id := 4*i+3;          dTw_dt[i].ode_id := 4*i+3;    T_w[i].ode_id := 4*i+3;
235          dTw_dt[i].ode_type := 2;      T_w[i].ode_type := 1;          dTw_dt[i].ode_type := 2;      T_w[i].ode_type := 1;
   
         (*  
         p[i].obs_id := 4*i;  
         x[i].obs_id := 4*i+1;  
         qdot_t[i].obs_id := 4*i+2;  
         T_w[i].obs_id := 4*i+3;  
         *)  
236      END FOR;      END FOR;
237    
238      FOR i IN [1..n] DO      FOR i IN [1..n] DO

Legend:
Removed from v.1108  
changed lines
  Added in v.1109

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