/[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 1121 by johnpye, Fri Jan 12 01:01:46 2007 UTC revision 1122 by johnpye, Fri Jan 12 02:43:17 2007 UTC
# Line 11  REQUIRE "steam/satsteamstream.a4c"; Line 11  REQUIRE "steam/satsteamstream.a4c";
11    
12  MODEL dsgsat2;  MODEL dsgsat2;
13      n IS_A integer_constant;      n IS_A integer_constant;
14      n :== 3;      n :== 10;
15    
16      (* temporal derivatives *)      (* temporal derivatives *)
17      drho_dt[2..n] IS_A density_rate;      drho_dt[2..n] IS_A density_rate;
# Line 68  MODEL dsgsat2; Line 68  MODEL dsgsat2;
68    
69      (* differential equations *)      (* differential equations *)
70      FOR i IN [2..n] CREATE      FOR i IN [2..n] CREATE
71          z_massbal[i]: A * drho_dt[i] = - (node[i].mdot - node[i-1].mdot)/dz;          z_massbal[i]: A * drho_dt[i] * dz = - (node[i].mdot - node[i-1].mdot);
72          z_mombal[i]:  1/A*dmdot_dt[i] = -(node[i].p-node[i-1].p)/dz          z_mombal[i]:  dz/A*dmdot_dt[i] = -(node[i].p-node[i-1].p)
73                          - f/D/2*node[i].rho*node[i].v^2*(                          - f/D/2*node[i].rho*node[i].v^2*(
74                              node[i].rho*vel[i]^2 - node[i-1].rho*vel[i-1]^2                              node[i].rho*vel[i]^2 - node[i-1].rho*vel[i-1]^2
75                          )/dz;                          );
76          z_enbal[i]: A * drhou_dt[i] = qdot_t[i] - (node[i].Hdot - node[i-1].Hdot)/dz;          z_enbal[i]: dz * (A * drhou_dt[i] - qdot_t[i]) = - (node[i].Hdot - node[i-1].Hdot);
77          z_wall[i]:  rho_w*A_w*c_w*dTw_dt[i] = qdot_s - qdot_l[i] - qdot_t[i];          z_wall[i]:  rho_w*A_w*c_w*dTw_dt[i] = qdot_s - qdot_l[i] - qdot_t[i];
78          z_loss[i]:  qdot_l[i] = h_ext*(1{PI}*D_2)*(T_w[i] - T_amb);          z_loss[i]:  qdot_l[i] = h_ext*(1{PI}*D_2)*(T_w[i] - T_amb);
79          z_trans[i]: qdot_t[i] = h_int*(1{PI}*D)  *(T_w[i] - node[i].T);          z_trans[i]: qdot_t[i] = h_int*(1{PI}*D)  *(T_w[i] - node[i].T);
# Line 81  MODEL dsgsat2; Line 81  MODEL dsgsat2;
81    
82      t IS_A time;      t IS_A time;
83  METHODS  METHODS
 METHOD on_load;  
     RUN configure_steady;  
 END on_load;  
 (*----------- a reliable on-load configuration that we can solve--------------*)  
 (* question: is there any point? *)  
 METHOD configure_reliable;  
     RUN default_self;  
     RUN reset;  
     RUN bound_self;  
     RUN values;  
     RUN ode_init;  
 END configure_reliable;  
 METHOD default_self;  
     A := 5 {cm^2};  
     FOR i IN [1..n] DO  
         RUN node[i].default_self;  
         mdot[i] := 0.05 {kg/s};  
         vel[i] := 0.01 {m/s};  
         x[i] := 0.1;  
         node[i].T := (300 {K}) (* - (20.0 {K})*(1.0 / n * i) *);  
     END FOR;  
 END default_self;  
 METHOD specify;  
     (* put the model in a state that we are sure it will solve: no big blocks, etc *)  
     RUN ClearAll;  
     FOR i IN [1..n] DO  
         RUN node[i].specify;  
         FIX dTw_dt[i]; FREE T_w[i];  
         FREE rhou[i];  
     END FOR;  
     FIX qdot_s;  
     FIX D, D_2, L;  
     FIX h_int, c_w, rho_w, h_ext;  
     FIX f, mu_f;  
     FIX T_amb;  
 END specify;  
 METHOD values;  
     node[1].T := 424.98 {K};  
     node[1].x := 0.001;  
     qdot_s := 1000 {W/m^2} * D_2 * 1;  
     D := 60 {mm}; D_2 := 70 {mm};  
     L := 100 {m};  
     A_w := 1{PI}*D_2^2;  
     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};  
     f := 0.005; mu_f := 4.5e-5 {Pa*s};  
     T_amb := 300 {K};  
     FOR i IN [2..n] DO  
         drho_dt[i] := 0 {kg/m^3/s};  
         dmdot_dt[i] := 0 {kg/s/s};  
         drhou_dt[i] := 0 {kJ/m^3/s};  
         dTw_dt[i] := 0 {K/s};  
     END FOR;  
     t := 0 {s};  
 END values;  
84  METHOD bound_self;  METHOD bound_self;
85      vel[1..n].upper_bound := 100 {m/s};      vel[1..n].upper_bound := 100 {m/s};
86      qdot_l[2..n].lower_bound := 0 {W/m};      qdot_l[2..n].lower_bound := 0 {W/m};
# Line 142  METHOD bound_self; Line 88  METHOD bound_self;
88          RUN node[i].bound_self;          RUN node[i].bound_self;
89      END FOR;      END FOR;
90  END bound_self;  END bound_self;
91    METHOD on_load;
92        RUN configure_steady;
93    END on_load;
94  (*---------------- a physically sensible steady-state configuration-----------*)  (*---------------- a physically sensible steady-state configuration-----------*)
95  METHOD configure_steady;  METHOD configure_steady;
96      RUN ClearAll;      RUN ClearAll;
# Line 177  METHOD specify_steady; Line 126  METHOD specify_steady;
126      END FOR;      END FOR;
127  END specify_steady;  END specify_steady;
128  METHOD values_steady;  METHOD values_steady;
129        L := 50 {m};
130        h_int := 5 {W/m^2/K};
131        h_ext := 10 {W/m^2/K};
132        node[1].mdot := 0.3 {kg/s};
133      node[1].p := 5 {bar};      node[1].p := 5 {bar};
134        node[1].x := 0.2;
135        qdot_s := 1000 {W/m^2} * D_2 * 10;
136      FOR i IN [2..n] DO      FOR i IN [2..n] DO
137          dmdot_dt[i] := 0.0 {kg/s/s};          dmdot_dt[i] := 0.0 {kg/s/s};
138          drhou_dt[i] := 0 {kJ/m^3/s};          drhou_dt[i] := 0 {kJ/m^3/s};
# Line 189  METHOD values_steady; Line 144  METHOD values_steady;
144  END values_steady;  END values_steady;
145  (*------------------------- the dynamic problem ------------------------------*)  (*------------------------- the dynamic problem ------------------------------*)
146  METHOD configure_dynamic;  METHOD configure_dynamic;
     RUN ClearAll;  
     RUN specify;  
     RUN fixed_states;  
147      RUN ode_init;      RUN ode_init;
 END configure_dynamic;  
   
 METHOD fixed_states;  
     qdot_s := 10 {W/m};  
148      FOR i IN [2..n] DO      FOR i IN [2..n] DO
149          FREE drho_dt[i];  FIX node[i].rho;          FREE drho_dt[i];  FIX node[i].rho;
150          FREE dmdot_dt[i]; FIX node[i].mdot;          FREE dmdot_dt[i]; FIX node[i].mdot;
# Line 205  METHOD fixed_states; Line 153  METHOD fixed_states;
153          FREE node[i].x;          FREE node[i].x;
154          FREE node[i].T;          FREE node[i].T;
155      END FOR;      END FOR;
156  END fixed_states;      t := 0 {s};
157  METHOD fixed_derivs;  END configure_dynamic;
158      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;  
 END fixed_derivs;  
159  METHOD ode_init;  METHOD ode_init;
160      (* add the necessary meta data to allow solving with the integrator *)      (* add the necessary meta data to allow solving with the integrator *)
161      t.ode_type := -1;      t.ode_type := -1;

Legend:
Removed from v.1121  
changed lines
  Added in v.1122

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