1 |
REQUIRE "ivpsystem.a4l"; |
2 |
REQUIRE "atoms.a4l"; |
3 |
REQUIRE "johnpye/thermo_types.a4c"; |
4 |
IMPORT "freesteam"; |
5 |
IMPORT "dsg"; |
6 |
|
7 |
(* |
8 |
This model requires the 'freesteam' library be installed on your system. |
9 |
You must compile it with the 'ASCEND_CONFIG=`which ascend-config`' flag |
10 |
to ensure that the required external library is installed where ASCEND |
11 |
can find it. Alternatively, you can specify the location by adding to the |
12 |
ASCENDLIBRARY path variable. See http://freesteam.sf.net/ |
13 |
|
14 |
This model also requires the 'dsg' library for Direct Steam Generation |
15 |
calculations, available on request from http://pye.dyndns.org/ |
16 |
|
17 |
For example (assuming you already have the source code for the above): |
18 |
export $ASCENDLIBRARY=$HOME/src/ascend/models |
19 |
cd $HOME/src/freesteam |
20 |
scons -j2 ascend |
21 |
export ASCENDLIBRARY=$HOME/src/freesteam/ascend:$ASCENDLIBRARY |
22 |
cd $HOME/src/dsg-transient |
23 |
scons -j2 ascend |
24 |
export ASCENDLIBRARY=$HOME/src/dsg-transient/ascend:$ASCENDLIBRARY |
25 |
export PATH=$PATH:$HOME/src/ascend/pygtk |
26 |
ascdev johnpye/dsg.a4c |
27 |
*) |
28 |
|
29 |
MODEL dsg; |
30 |
(* temporal derivatives *) |
31 |
drho_dt IS_A density_rate; |
32 |
dmdot_dt IS_A mass_rate_rate; |
33 |
drhou_dt IS_A power_per_volume; |
34 |
dTw_dt IS_A temperature_rate; |
35 |
|
36 |
(* spatial derivatives *) |
37 |
dmdot_dz IS_A mass_rate_per_length; |
38 |
dmdoth_dz IS_A solver_var; |
39 |
dekdot_dz IS_A solver_var; |
40 |
dp_dz IS_A pressure_per_length; |
41 |
drhovel2_dz IS_A pressure_per_length; |
42 |
|
43 |
(* wall properties *) |
44 |
rhow IS_A mass_density; |
45 |
D2 IS_A distance; |
46 |
cw IS_A specific_heat_capacity; |
47 |
Aw IS_A area; |
48 |
hw IS_A heat_transfer_coefficient; |
49 |
|
50 |
Aw = 1{PI}*(D2^2 - D^2)/4; |
51 |
|
52 |
(* conservation equations *) |
53 |
massbal: drho_dt = -1/A * dmdot_dz; |
54 |
mombal: 1/A * dmdot_dt = -dp_dz - f/D/2*rho*vel^2 - drhovel2_dz; |
55 |
enerbal: drhou_dt = 1/A * ( qdott - dmdoth_dz + mdot * dekdot_dz ); |
56 |
pipebal: dTw_dt = 1/rhow/Aw/cw * (qdots - qdotl - qdott); |
57 |
|
58 |
rho IS_A mass_density; |
59 |
mdot IS_A mass_rate; |
60 |
p IS_A pressure; |
61 |
f IS_A positive_factor; (* pipe friction factor *) |
62 |
f_LO IS_A positive_factor; (* liquid-only friction factor *) |
63 |
u IS_A specific_energy; |
64 |
h IS_A specific_enthalpy; |
65 |
vel IS_A speed; |
66 |
qdott, qdotl,qdots IS_A power_per_length; |
67 |
mu IS_A viscosity; |
68 |
v IS_A specific_volume; |
69 |
T, Tw, Tamb IS_A temperature; |
70 |
ekdot IS_A specific_power; |
71 |
|
72 |
rhou IS_A energy_per_volume; |
73 |
rhou = rho * u; |
74 |
|
75 |
rho * v = 1; |
76 |
ekdot = 0.5 * rho * vel^2; |
77 |
|
78 |
thermo_props: iapws97_uvTxmu_ph( |
79 |
p,h : INPUT; |
80 |
u,v,T,x,mu : OUTPUT |
81 |
); |
82 |
|
83 |
vel = rho*mdot/A; |
84 |
|
85 |
Re IS_A positive_factor; |
86 |
Re_rel: Re = rho*vel*D/mu; |
87 |
eps_on_D IS_A factor; |
88 |
eps_on_D_rel: eps_on_D = eps/D; |
89 |
|
90 |
D IS_A distance; |
91 |
eps IS_A distance; |
92 |
A IS_A area; |
93 |
A = 1{PI}* D^2 / 4; |
94 |
|
95 |
friction: dsg_friction_factor( |
96 |
Re, eps_on_D : INPUT; |
97 |
f_LO : OUTPUT |
98 |
); |
99 |
|
100 |
phi2 IS_A positive_factor; |
101 |
x IS_A fraction; |
102 |
twophmult: dsg_phi2_martinelli_nelson( |
103 |
p,x : INPUT; |
104 |
phi2 : OUTPUT |
105 |
); |
106 |
(* TODO: compute LIQUID ONLY reynolds number when in the two-phase region... |
107 |
that's a bit tricky and needs conditional modelling, so maybe try putting |
108 |
it in the external code. *) |
109 |
|
110 |
f = f_LO*rho2; |
111 |
|
112 |
cavity_losses: dsg_ext_heat_loss( |
113 |
Tw,Tamb,D2,hw : INPUT; |
114 |
qdotl : OUTPUT |
115 |
); |
116 |
|
117 |
mdoth IS_A energy_rate; |
118 |
mdoth = mdot * h; |
119 |
|
120 |
rhovel2 IS_A solver_var; |
121 |
rhovel2 = rho * vel^2; |
122 |
|
123 |
(* internal heat transfer *) |
124 |
|
125 |
h1 IS_A heat_transfer_coefficient; |
126 |
|
127 |
qdott = h1 * 1{PI} * D * (Tw - T); |
128 |
|
129 |
twophconv: dsg_conv_coeff_two_phase( |
130 |
p, h, mdot, D, f : INPUT; |
131 |
h1 : OUTPUT |
132 |
); |
133 |
|
134 |
t IS_A time; |
135 |
|
136 |
METHODS |
137 |
|
138 |
METHOD specify; |
139 |
RUN fix_design; |
140 |
RUN fix_states; |
141 |
RUN fix_spatials; |
142 |
RUN ode_init; |
143 |
END specify; |
144 |
|
145 |
METHOD fix_states; |
146 |
FIX Tw, p, h, mdot; |
147 |
END fix_states; |
148 |
|
149 |
METHOD fix_design; |
150 |
(* design parameters, geometry, materials of construction *) |
151 |
FIX rhow,D2,cw,hw; |
152 |
FIX D, eps; |
153 |
FIX qdots; |
154 |
FIX Tamb; |
155 |
END fix_design; |
156 |
|
157 |
METHOD fix_spatials; |
158 |
(* for use when tinkering about with a single node only *) |
159 |
FIX dmdot_dz, dmdoth_dz, dekdot_dz, dp_dz, drhovel2_dz; |
160 |
END fix_spatials; |
161 |
|
162 |
METHOD fix_temporals; |
163 |
(* for steady-state solution *) |
164 |
FIX drho_dt; |
165 |
FIX dmdot_dt; |
166 |
FIX drhou_dt; |
167 |
FIX dTw_dt; |
168 |
END fix_temporals; |
169 |
|
170 |
METHOD values; |
171 |
(* design parameters *) |
172 |
D := 60 {mm}; |
173 |
D2 := 70 {mm}; |
174 |
eps := 0.05 {mm}; |
175 |
rhow := 7.8 {g/cm^3}; |
176 |
cw := 0.47 {J/g/K}; |
177 |
hw := 10 {W/m^2/K}; |
178 |
Tamb := 300 {K}; |
179 |
|
180 |
(* states *) |
181 |
Tw := 600 {K}; |
182 |
p := 10 {bar}; |
183 |
h := 4000 {kJ/kg}; |
184 |
mdot := 0.001 {kg/s}; |
185 |
|
186 |
(* spatial derivs *) |
187 |
dp_dz := -200 {Pa/m}; |
188 |
dmdot_dz := 0 {kg/s/m}; |
189 |
drhovel2_dz := (0 {kg/m^3}) * (0 {m/s})^2 / (1 {m}); |
190 |
dekdot_dz := 0 {W/m}; |
191 |
dmdoth_dz := dmdot_dz * 0 {kJ/kg}; |
192 |
|
193 |
(* derivative variables *) |
194 |
drho_dt := 0 {kg/m^3/s}; |
195 |
dmdot_dt := 0 {kg/s/s}; |
196 |
drhou_dt := 0 {kg/m^3*kJ/kg/s}; |
197 |
dTw_dt := 0 {K/s}; |
198 |
|
199 |
drhou_dt.nominal := rhou.nominal / 60 {s}; |
200 |
|
201 |
v := 0.2 {m^3/kg}; |
202 |
|
203 |
(* bounds *) |
204 |
f.lower_bound := 0.008; |
205 |
v.lower_bound := 0.00999 {m^3/kg}; |
206 |
v.upper_bound := 1/(0.0202 {kg/m^3}); |
207 |
u.lower_bound := 0 {kJ/kg}; |
208 |
u.upper_bound := 3663 {kJ/kg}; |
209 |
|
210 |
(* starting guesses *) |
211 |
Re := 10000; |
212 |
END values; |
213 |
|
214 |
METHOD ode_init; |
215 |
t.ode_type := -1; |
216 |
t := 0 {s}; |
217 |
|
218 |
rho.ode_id := 1; drho_dt.ode_id := 1; |
219 |
rho.ode_type := 1; drho_dt.ode_type := 2; |
220 |
|
221 |
mdot.ode_id := 2; dmdot_dt.ode_id := 2; |
222 |
mdot.ode_type := 1; dmdot_dt.ode_type := 2; |
223 |
|
224 |
rhou.ode_id := 3; drhou_dt.ode_id := 3; |
225 |
rhou.ode_type := 1; drhou_dt.ode_type := 2; |
226 |
|
227 |
Tw.ode_id := 4; dTw_dt.ode_id := 4; |
228 |
Tw.ode_type := 1; dTw_dt.ode_type := 2; |
229 |
|
230 |
rho.obs_id := 1; |
231 |
mdot.obs_id := 2; |
232 |
rhou.obs_id := 3; |
233 |
Tw.obs_id := 4; |
234 |
|
235 |
END ode_init; |
236 |
|
237 |
METHOD on_load; |
238 |
RUN reset; |
239 |
RUN values; |
240 |
END on_load; |
241 |
|
242 |
END dsg; |