-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcalc.py
50 lines (38 loc) · 1.1 KB
/
calc.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
import numpy as np
from iapws import IAPWS97
def calculate_Re(rho, U, L, mu):
return (rho*U*L)/mu
def calculate_skin_friction(Re):
# Schlichting Skin-Friction Coefficient
# Valid for Re_x < 10^9
return (2*np.log10(Re) - 0.65)**(-2.3)
def calculate_wall_shear(cf, U, rho):
return cf*0.5*rho*(U**2)
def calculate_ustar(tw, rho):
return np.sqrt(tw/rho)
def calculate_y(rho, U, L, mu, yPlus):
Re = calculate_Re(rho, U, L, mu)
cf = calculate_skin_friction(Re)
tw = calculate_wall_shear(cf, U, rho)
ustar = calculate_ustar(tw, rho)
return (2*yPlus*mu)/(rho*ustar)
def calculate_smallD(L, ND, bf):
sum = 0
gr = bf**(1.0/(ND-1))
for i in range(ND):
sum += gr**i
L1 = L/sum
return L1
def calculate_y_water(T, P, G, L, yPlus):
state = IAPWS97(P=P/1e6, T=T)
U = G/state.rho
return calculate_y(state.rho, U, L, state.mu, yPlus)
def calculate_BF(L, ND, L1):
test_list = list(np.arange(1, 31, 0.001))
dummy = calculate_smallD(L, ND, np.arange(1, 31, 0.001))
error = abs(dummy - L1)/L1
index = np.where(error == min(error))[0][0]
if test_list[index] < 30:
return test_list[index]
else:
return 0.0