# Untitled

unknown
python
18 days ago
2.1 kB
4
Indexable
Never
```import numpy as np
from math import radians, sqrt, isnan

def GetU(U_inf, R, y_far, theta):
# Placeholder function for GetU, you'll need to define its functionality
# based on your specific use case.
# This function should return u_t and potentially other values as needed.
u_t = U_inf # This is a placeholder, adjust according to your actual GetU function
return u_t, None

def Estimate_BL_D_PFT(U_inf, D, upsilon, theta_end, d_theta, dy):
"""
Determining delta(x) boundary layer thickness and U(x) velocity at the boundary layer
for all x from potential flow theory.

Parameters:
U_inf: Far field velocity
D: Diameter of cylindrical body
upsilon: Kinematic viscosity
theta_end: Calculate the boundary layer from 0 to theta_end in degrees
d_theta: Change in theta angle in degrees
dy: Change in y distance from the wall

Returns:
U_x(theta): Velocity at the boundary layer for angle theta
delta_x(theta): Thickness of boundary layer for angle theta
"""
R = D / 2
x_num = int(np.ceil(theta_end / d_theta))
U_x = np.zeros(x_num)
delta_x = np.zeros(x_num)

for i in range(x_num):
x_curr = radians(i * d_theta) * R
if x_curr == 0:
delta_x_curr = 0
else:
delta_x_curr = x_curr * 5.64 * sqrt(upsilon / U_inf / x_curr)

# Fix division by zero errors
if isnan(delta_x_curr):
delta_x_curr = 0

y_far = delta_x_curr + dy
u_t, _ = GetU(U_inf, R, y_far, i * d_theta)
U_x[i] = u_t
delta_x[i] = delta_x_curr

return U_x, delta_x

# Example usage:
U_inf = 10  # Example far field velocity
D = 2  # Diameter of the cylindrical body
upsilon = 1.5e-5  # Kinematic viscosity
theta_end = 180  # Calculate from 0 to 180 degrees
d_theta = 5  # Change in theta angle in degrees
dy = 0.1  # Change in y distance from the wall

U_x, delta_x = Estimate_BL_D_PFT(U_inf, D, upsilon, theta_end, d_theta, dy)
print("U_x:", U_x)
print("delta_x:", delta_x)
```