Untitled

 avatar
unknown
python
a year ago
1.4 kB
3
Indexable
import numpy as np

def get_u(U_inf, R, y, theta):
    """
    Get u(theta, y), v(theta, y) field from potential flow theory around a cylinder with radius R.

    Parameters:
    U_inf (float): Far field flow velocity.
    R (float): Radius of the cylinder.
    y (float): Delta distance from the surface of the cylinder.
    theta (float): Angle from separation line parallel to incoming flow direction in degrees.

    Returns:
    U_x (float): Azimuthal component of velocity.
    U_y (float): Normal component of velocity vector.
    """
    # Convert theta from degrees to radians for np trig functions
    theta_rad = np.radians(theta)
    
    # General c velocity around cylinder in polar coordinates
    c = [U_inf * (1 - R**2 / (R + y)**2 * np.cos(2 * theta_rad)),
         -U_inf * R**2 / (R + y)**2 * np.sin(2 * theta_rad)]
    
    # Calculating velocity vector's angle from the tangency vector
    beta = np.arctan(c[1] / c[0]) if c[0] != 0 else 0  # Check to avoid division by zero
    
    gamma = np.degrees(beta) - 90 + theta  # Convert beta back to degrees and adjust gamma
    
    # Calculating velocity components with respect to the moving triad
    U = np.sqrt(c[0]**2 + c[1]**2)
    U_x = abs(U * np.cos(np.radians(gamma)))  # Convert gamma back to radians for cos
    U_y = U * np.sin(np.radians(gamma))  # Convert gamma back to radians for sin
    
    return U_x, U_y
Editor is loading...
Leave a Comment