-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathh_evaluator.py
385 lines (300 loc) · 10.9 KB
/
h_evaluator.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
import numpy as np
from pyXSteam.XSteam import XSteam
def rho_func(T):
"""Evaluates density of fluid according to temperature T,
sourced from: https://doi.org/10.1016/j.fusengdes.2020.111956
Args:
T (float): temperature of water (K)
Returns:
float: density of fluid (kg/m3)
"""
rho = -1.4226e-2 * T**2 + 14.122 * T - 2693
return rho
def thermal_cond_func(T):
"""Evaluates thermal conductivity of fluid according to temperature T,
sourced from: https://doi.org/10.1016/j.fusengdes.2020.111956
Args:
T (float): temperature of water (K)
Returns:
float: thermal conductivity of fluid (W/m K)
"""
k = -1.2024e-05 * T**2 + 1.1846e-02 * T - 2.2804
return k
def mu_func(T):
"""Evaluates viscosity of fluid according to temperature T,
sourced from: https://doi.org/10.1016/j.fusengdes.2020.111956
Args:
T (float): temperature of water (K)
Returns:
float: viscosity of fluid (Pa s)
"""
mu = (-8.095238e-04 * T**2 + 0.5722429 * T + 29.67213) * 1e-06
return mu
def cp_func(T):
"""Evaluates specific heat capacity of fluid according to temperature T,
sourced from: https://doi.org/10.1016/j.fusengdes.2020.111956
Args:
T (float): temperature of water (K)
Returns:
float: specific heat capacity of fluid (J kg-1 K-1)
"""
cp = 9.8485e-03 * T**3 - 16.39861 * T**2 + 9118.681 * T - 1.6882247 * 1e06
return cp
def Pr_number_func(mu, k, cp):
"""Evaluates Prandtle Number of fluid
Args:
mu (float): viscosity of fluid (Pa s)
k (float): thermal conducivity of fluid (W/ m K)
cp (float): specific heat capacity of fluid (J kg-1 K-1)
Returns:
float: prandtl number
"""
pr = (cp * mu) / k
return pr
def Pr_number_steam_tables(P, T):
"""Evaluates a Pr number for water with a pressure between 150 and 175 bar
and temperature between 250 and 300 C by interpolation
Args:
P (float): pressure of water (bar)
T (float): temperture of water (C)
Returns:
float: Prandle number
"""
pr_150bar_250c = 0.810
pr_150bar_300c = 0.860
pr_175bar_250c = 0.806
pr_175bar_300c = 0.848
if not 150 < pressure < 175:
print("Pressure value out of range")
elif not 250 < temp < 300:
print("Temperature value out of range")
else:
# 150 bar interpolation
pr_150bar_temp_interval = (pr_150bar_300c - pr_150bar_250c) / 50
pr_150 = pr_150bar_250c + (T - 250) * pr_150bar_temp_interval
# 175 bar interpolation
pr_175bar_temp_interval = (pr_175bar_300c - pr_175bar_250c) / 50
pr_175 = pr_175bar_250c + (T - 250) * pr_175bar_temp_interval
# pressure interpolation
pressure_temp_interval = (pr_175 - pr_150) / 25
pr = pr_150 + (P - 150) * pressure_temp_interval
return pr
def Re_number(rho, u, L, mu):
"""Evaluates Reynolds number
Args:
rho (float): density of fluid (kg/m3)
u (float): velocity of fluid (m/s)
length (float): characteristic length (m), diameter for pipe
viscosity (float): viscosity of fluid (Pa s)
Returns:
float: Reynolds number
"""
re = (rho * u * L) / mu
return re
def friction_factor(Re):
"""Evaluates Darcy friction factor according to Reynolds number
Args:
Re (float): Reynolds number
Returns:
float: Darcy friction factor
"""
xi = (0.790 * np.log(Re) - 1.64) ** -2
return xi
def Nu_number(Re, Pr, xi):
"""Evaluates the nusselt number according to the Gnielinski correlation
Args:
Re (float): reynolds number
Pr (float): prandtl number
xi (float): darcy fricion factor
Returns:
float: nusselt number
"""
nu = (
(xi / 8)
* (Re - 1000)
* Pr
/ (1 + (12.7 * (xi / 8) ** 0.5) * ((Pr ** (2 / 3)) - 1))
)
return nu
def heat_transfer_coefficient(d_w, u, L, T, P=1):
"""_summary_
Args:
d_w (float): wetted perimeter (m)
u (float): fluid velocity (m/s)
L (float): characteristi length (m)
P (float, optional): pressure of fluid (bar), only needed if steam table Pr evaluation is used
T (float): Temperature of fluid (K)
Returns:
float: heat transfer coefficient (W/m2 K)
"""
rho = rho_func(T)
k = thermal_cond_func(T)
mu = mu_func(T)
cp = cp_func(T)
# print("Density = {}".format(rho))
# print("Thermal conductivity = {}".format(k))
# print("Viscosity = {}".format(mu))
# print("Specific heat capacity = {}".format(cp))
Reynolds = Re_number(rho=rho, u=u, L=L, mu=mu)
xi = friction_factor(Re=Reynolds)
Prandtl = Pr_number_func(mu=mu, k=k, cp=cp)
Nu = Nu_number(Re=Reynolds, Pr=Prandtl, xi=xi)
# print("Reynolds number = {}".format(Reynolds))
# print("Prandtl number = {}".format(Prandtl))
# print("Nusselt number = {}".format(Nu))
h = (Nu * k) / d_w
return h
def heat_transfer_coefficient_alt(d_w, u, L, T, P=1):
"""_summary_
Args:
d_w (float): wetted perimeter (m)
u (float): fluid velocity (m/s)
L (float): characteristi length (m)
P (float, optional): pressure of fluid (bar), only needed if steam table Pr evaluation is used
T (float): Temperature of fluid (K)
Returns:
float: heat transfer coefficient (W/m2 K)
"""
steamTable = XSteam(XSteam.UNIT_SYSTEM_BARE)
P = 15.5
rho = steamTable.rho_pt(P, T)
k = steamTable.tc_pt(P, T)
cp = steamTable.Cp_pt(P, T) * 1000
mu = steamTable.my_pt(P, T)
mu_w = steamTable.my_pt(P, T + 10)
# print("Density alt = {}".format(rho))
# print("Thermal conductivity alt = {}".format(k))
# print("Viscosity alt = {}".format(mu))
# print("Specific heat capacity alt = {}".format(cp))
Reynolds = Re_number(rho=rho, u=u, L=L, mu=mu)
xi = friction_factor(Re=Reynolds)
Prandtl = Pr_number_func(mu=mu, k=k, cp=cp)
# Nu = Nu_number(Re=Reynolds, Pr=Prandtl, xi=xi)
Nu = 0.027 * (Reynolds ** (4 / 5)) * (Prandtl ** (1 / 3)) * ((mu / mu_w) ** 0.14)
# print("Reynolds number alt = {}".format(Reynolds))
# print("Prandtl number alt = {}".format(Prandtl))
# print("Nusselt number alt = {}".format(Nu))
h = (Nu * k) / d_w
return h
def heat_transfer_coefficient_alt_2(d_w, u, L, T, P=1):
"""_summary_
Args:
d_w (float): wetted perimeter (m)
u (float): fluid velocity (m/s)
L (float): characteristi length (m)
P (float, optional): pressure of fluid (bar), only needed if steam table Pr evaluation is used
T (float): Temperature of fluid (K)
Returns:
float: heat transfer coefficient (W/m2 K)
"""
steamTable = XSteam(XSteam.UNIT_SYSTEM_BARE)
P = 15.5
rho = steamTable.rho_pt(P, T)
k = steamTable.tc_pt(P, T)
cp = steamTable.Cp_pt(P, T) * 1000
mu = steamTable.my_pt(P, T)
mu_w = steamTable.my_pt(P, T + 10)
# print("Density alt = {}".format(rho))
# print("Thermal conductivity alt = {}".format(k))
# print("Viscosity alt = {}".format(mu))
# print("Specific heat capacity alt = {}".format(cp))
Reynolds = Re_number(rho=rho, u=u, L=L, mu=mu)
xi = friction_factor(Re=Reynolds)
Prandtl = Pr_number_func(mu=mu, k=k, cp=cp)
Nu = Nu_number(Re=Reynolds, Pr=Prandtl, xi=xi)
# print("Reynolds number alt = {}".format(Reynolds))
# print("Prandtl number alt = {}".format(Prandtl))
# print("Nusselt number alt = {}".format(Nu))
h = (Nu * k) / d_w
return h
pressure = 155
T = 584.65 # average temp
# T = 568.15 # initial temp
pipe_diameter_bz = 0.008
pipe_width_fw = 0.007
water_density = rho_func(T)
# bz flow
total_mass_flow_rate_bz = 0.85491
n_tubes_bz = 14
mass_flow_rate_bz = total_mass_flow_rate_bz / n_tubes_bz
A_bz = np.pi * (pipe_diameter_bz / 2) ** 2
# mass flow rate m = rho*u*A
u_bz = mass_flow_rate_bz / (water_density * A_bz)
# fw flow
total_mass_flow_rate_fw = 0.63189
n_tubes_fw = 4
mass_flow_rate_fw = total_mass_flow_rate_fw / n_tubes_fw
A_fw = pipe_width_fw**2
# mass flow rate m = rho*u*A
u_fw = mass_flow_rate_fw / (water_density * A_fw)
# h_bz = heat_transfer_coefficient(
# d_w=np.pi * (pipe_diameter_bz),
# u=u_bz,
# L=pipe_diameter_bz,
# T=T,
# )
# h_fw = heat_transfer_coefficient(
# d_w=4 * pipe_width_fw,
# u=u_fw,
# L=pipe_width_fw,
# T=T,
# )
# print("h_bz = {:.3e}".format(h_bz))
# print("h_fw = {:.3e}".format(h_fw))
def para_flow_velocity_bz(mass_flow_bz=0.85491):
total_mass_flow_rate_bz = mass_flow_bz
n_tubes_bz = 14
mass_flow_rate_bz = total_mass_flow_rate_bz / n_tubes_bz
A_bz = np.pi * (pipe_diameter_bz / 2) ** 2
u_bz = mass_flow_rate_bz / (water_density * A_bz)
return u_bz
def para_flow_velocity_fw(mass_flow_fw=0.63189):
total_mass_flow_rate_fw = mass_flow_fw
n_tubes_fw = 4
mass_flow_rate_fw = total_mass_flow_rate_fw / n_tubes_fw
A_fw = pipe_width_fw**2
# mass flow rate m = rho*u*A
u_fw = mass_flow_rate_fw / (water_density * A_fw)
return u_fw
def para_h_bz(T, d_w=np.pi * (pipe_diameter_bz), u=u_bz, L=pipe_diameter_bz):
"""_summary_
Args:
d_w (float): wetted perimeter (m)
u (float): fluid velocity (m/s)
L (float): characteristi length (m)
P (float, optional): pressure of fluid (bar), only needed if steam table Pr evaluation is used
T (float): Temperature of fluid (K)
Returns:
float: heat transfer coefficient (W/m2 K)
"""
rho = rho_func(T)
k = thermal_cond_func(T)
mu = mu_func(T)
cp = cp_func(T)
Reynolds = Re_number(rho=rho, u=u, L=L, mu=mu)
xi = friction_factor(Re=Reynolds)
Prandtl = Pr_number_func(mu=mu, k=k, cp=cp)
Nu = Nu_number(Re=Reynolds, Pr=Prandtl, xi=xi)
h = (Nu * k) / d_w
return h
def para_h_fw(T, d_w=4 * pipe_width_fw, u=u_fw, L=pipe_width_fw):
"""_summary_
Args:
d_w (float): wetted perimeter (m)
u (float): fluid velocity (m/s)
L (float): characteristi length (m)
P (float, optional): pressure of fluid (bar), only needed if steam table Pr evaluation is used
T (float): Temperature of fluid (K)
Returns:
float: heat transfer coefficient (W/m2 K)
"""
rho = rho_func(T)
k = thermal_cond_func(T)
mu = mu_func(T)
cp = cp_func(T)
Reynolds = Re_number(rho=rho, u=u, L=L, mu=mu)
xi = friction_factor(Re=Reynolds)
Prandtl = Pr_number_func(mu=mu, k=k, cp=cp)
Nu = Nu_number(Re=Reynolds, Pr=Prandtl, xi=xi)
h = (Nu * k) / d_w
return h