def test_basic_math(types):
    for x in types["all"]:
        for y in types["all"]:
            ### Arithmetic
            x + y
            x - y
            x * y
            x / y
            np.sum(x)  # Sum of all entries of array-like object x

            ### Exponentials & Powers
            x**y
            np.power(x, y)
            np.exp(x)
            np.log(x)
            np.log10(x)
            np.sqrt(x)  # Note: do x ** 0.5 rather than np.sqrt(x).

            ### Trig
            np.sin(x)
            np.cos(x)
            np.tan(x)
            np.arcsin(x)
            np.arccos(x)
            np.arctan(x)
            np.arctan2(y, x)
            np.sinh(x)
            np.cosh(x)
            np.tanh(x)
            np.arcsinh(x)
            np.arccosh(x)
            np.arctanh(x - 0.5)  # `- 0.5` to give valid argument
Exemplo n.º 2
0
def haack_series(
        x_over_L: np.ndarray,
        C=1 / 3
):
    theta = np.arccos(1 - 2 * x_over_L)
    radius = ((
                      theta - np.sin(2 * theta) / 2 + C * np.sin(theta) ** 3
              ) / np.pi) ** 0.5
    return radius
Exemplo n.º 3
0
def length_day(latitude, day_of_year):
    """
    For what length of time is the sun above the horizon on a given day?

    :param latitude: Latitude [degrees]
    :param day_of_year: Julian day (1 == Jan. 1, 365 == Dec. 31)
    :return: Seconds of sunlight in a given day
    """
    dec = declination_angle(day_of_year)

    constant = -np.sind(dec) * np.sind(latitude) / (np.cosd(dec) * np.cosd(latitude))
    constant = np.clip(constant, -1, 1)

    sun_time_nondim = 2 * np.arccos(constant)
    sun_time = sun_time_nondim / (2 * np.pi) * 86400

    return sun_time
Exemplo n.º 4
0
    ### Define velocity triangle components
    U_a = airspeed #+ u_a # Axial velocity w/o induced eff. assuming u_a = 0
    U_t = omega * radial_loc  # Tangential velocity w/o induced eff.
    U = (U_a ** 2 + U_t ** 2) ** 0.5  # Velocity magnitude
    W_a = 0.5 * U_a + 0.5 * U * np.sin(Psi)  # Axial velocity w/ induced eff.
    W_t = 0.5 * U_t + 0.5 * U * np.cos(Psi)  # Tangential velocity w/ induced eff.
    v_a = W_a - U_a  # Axial induced velocity
    v_t = U_t - W_t  # Tangential induced velocity
    W = (W_a ** 2 + W_t ** 2) ** 0.5
    Re = air_density * W * chord_local / mu
    Ma = W / speed_of_sound
    v = (v_a ** 2 + v_t ** 2) ** 0.5
    loc_wake_adv_ratio = (radial_loc / tip_radius) * (W_a / W_t)
    f = (n_blades / 2) * (1 - radial_loc / tip_radius) * 1 / loc_wake_adv_ratio
    F = 2 / pi * np.arccos(np.exp(-f))


    ## Compute local blade quantities
    phi_rad = np.arctan2(W_a, W_t) #local flow angle
    phi_deg = phi_rad * 180 / pi
    alpha_rad = twist_local_rad - phi_rad
    alpha_deg = alpha_rad * 180 / pi

    ### Compute sectional lift and drag
    cl = airfoil_CL(alpha_deg, Re, Ma)
    cd = airfoil_CDp(alpha_deg, Re, Ma, cl)
    gamma = 0.5 * W * chord_local * cl

    ### Add governing equations
    opti.subject_to([