-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcalcUstar.py
More file actions
70 lines (55 loc) · 3.89 KB
/
Copy pathcalcUstar.py
File metadata and controls
70 lines (55 loc) · 3.89 KB
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
import numpy as np
from .uniqueFinder import uniqueFinder
from .Rxy import Rxy
from .outlierRemove import outlierRemove
from .velocityProfile import velocityProfile
def calcUstar(data, Hs=None, bottomWall=None, topWall=None, vonKarman=None):
'''
This function is to calculate the friction velocity using output of Rxy(data).
Inspired by Nezu's book on Turbulence. This method should not be used for finding the shear stress at the carpet. An alternative way is to find the slope using log-wall by keeping kappa = 0.412.
Input : measurement data
Output : U* - friction velocity
hs - water depth at which the shear stress is zero (R. N. Parthasarathy and M. Muste (1995))
topWall - If it is True, Method of (R. N. Parthasarathy and M. Muste (1995)) is used here to calcuate the friction velocity at the carpet.
'''
if vonKarman==None:
data = Rxy(data)
dataWithoutOutliers = outlierRemove(data,'Rxy')
# Fitting line
slope, intercept = np.polyfit(dataWithoutOutliers['depth[cm]'], dataWithoutOutliers['uv_prime'], 1)
Ustar = np.sqrt(intercept) ## Ref. paper of R. N. Parthasarathy (1995)
hs = -1*intercept/slope ## hs = water depth at which the shear stress is zero.
#y=np.linspace(0,data[-2])
#Ustar = np.sqrt(np.abs(slope)*data[-2])
print('U* = ', Ustar)
if topWall: ## Method of (R. N. Parthasarathy and M. Muste (1995)) is used here to calcuate the friction velocity at the carpet.
depthUnderCarpet = data[1]-0.02 # average water depth - particle's diameter
## See eq.3 of paper of R. N. Parthasarathy (1995)
Ustar_topWall = np.sqrt(Ustar**2 * depthUnderCarpet/hs) ## friction velocity at the top wall
print("U* at wall", Ustar_topWall)
return Ustar_topWall
if bottomWall == True and vonKarman == True:
U = velocityProfile(data) # Use velocityProfile function to calcuate the velocity profile in the vertical direction
cutoffPoint = np.argmax(U[0].reset_index()['U']) ## To find the depth of maximum velocity
logZ = np.log(U[0].reset_index()['depth[cm]'][:cutoffPoint]/100/1e-6) # log(y/nu)
slope, intercept = np.polyfit(logZ, U[0].reset_index()['U'][:cutoffPoint], 1) ## Use polyfit of numpy to find the best fitting line
kappa = 0.412 # von Karman's constant
Ustar = kappa*slope # m/sec
A = (intercept-Ustar/kappa*np.log(Ustar))/Ustar
return Ustar, A
if vonKarman: ## To calcuate shear stress at the carpet by using log-wall law by using von Karman's constant = 0.412. We used fitting line method to find out the shear stress.
U = velocityProfile(data) # Use velocityProfile function to calcuate the velocity profile in the vertical direction
ks = 0.01 # half of the diameter 0.02/2 [meter]
cutoffPoint = np.argmax(U[0].reset_index()['U'])-1 ## To find the depth of maximum velocity, we first find the index of maximum velocity. It is subtracted with -1 for later purpose.
depthUnderCarpet = U[1]-1 ## Water depth under the carpet = average water depth - radius of the particle (1 cm). My vertical coordinate is pointing downwards from the half of the carpet thickness.
newDepth = depthUnderCarpet-U[0].reset_index()['depth[cm]'][:cutoffPoint:-1] ## Since we changed vertical refernce line, we calculated the new water levels up to the point of max; vel.
logZ = np.log(newDepth)
slope, intercept = np.polyfit(logZ, U[0].reset_index()['U'][:cutoffPoint:-1], 1) ## Use polyfit of numpy to find the best fitting line
kappa = 0.412 # von Karman's constant
Ustar = kappa*slope # shear velocity
y0 = np.exp(-intercept*kappa/Ustar) # roughness characteristic height
B = 1/kappa*np.log(ks/(y0/100)) # 0.02 is diameter of the particle. It is 'k' roughness height.
return Ustar, B
if Hs:
return Ustar, hs
return Ustar