Пример #1
0
def plot_isherwood(frontal_area, lateral_area, superstructure_area, Loa, breadth, S, s_L, masts, plot_surge=True,
                   plot_sway=True, plot_yaw=True, subplots=False):
    """Plot the wind coefficients calculated by Isherwood's formulas.

    Args:
        frontal_area (float)          -- frontal area of the vessel in m^2
        lateral_area (float)          -- lateral area of the vessel in m^2
        superstructure_area (float)   -- lateral area of the superstructure in m^2
        Loa (float)                   -- length over all in m
        breadth (float)               -- breadth in m
        S (float)                     -- length of the lateral projection
        s_L (float)                   -- centroid of the wind area in the lateral direction, ahead of Lpp/2, in m
        masts (int)                   -- number of distinct groups of masts
        plot_surge (bool)             -- plot C_X (default: True)
        plot_sway (bool)              -- plot C_Y (default: True)
        plot_yaw (bool)               -- plot C_N (default: True)
        subplots (bool)               -- plot subplots if True, everything together if False (default: False)

    Returns:
        N/A
    """

    # These values in degrees.
    start = 0.0
    stop = 180.0
    step = 0.1

    angles_deg = np.arange(start, stop, step)
    angles_rad = np.arange(radians(start), radians(stop), radians(step))

    # Find the coefficients.
    C_Xs, C_Ys, C_Ns = [], [], []
    for angle in angles_rad:
        C_X, C_Y, C_N = wc.isherwood(frontal_area, lateral_area, superstructure_area, Loa, breadth, S, s_L, masts, angle)
        C_Xs.append(C_X)
        C_Ys.append(C_Y)
        C_Ns.append(C_N)

    # Start plotting.
    number_of_plots = int(plot_surge + plot_sway + plot_yaw)

    if subplots == True and plot_surge == True:
        plt.subplot(number_of_plots, 1, int(plot_surge))
        plt.title("Isherwood coefficient in surge")

    if plot_surge == True:
        plt.plot(angles_deg, C_Xs, 'b', label = "C_X")
        plt.legend()

    if subplots == True and plot_sway == True:
        plt.subplot(number_of_plots, 1, int(plot_surge + plot_sway))
        plt.title("Isherwood coefficient in sway")

    if plot_sway == True:
        plt.plot(angles_deg, C_Ys, 'r', label = "C_Y")
        plt.legend()

    if subplots == True and plot_yaw == True:
        plt.subplot(number_of_plots, 1, number_of_plots)
        plt.title("Isherwood coefficient in yaw")

    if plot_yaw == True:
        plt.plot(angles_deg, C_Ns, 'k', label = "C_N")
        plt.legend()

    if subplots == False:
        plt.title("Isherwood wind coefficients")

    plt.ylim([-1.0, 1.0])
    plt.show()
Пример #2
0
def wind_forces_and_moment(wind_speed, wind_direction, frontal_area, lateral_area, Loa, s_L, coeffs=
                           CoefficientType.blendermann, vessel_type=None, superstructure_area=None, breadth=None,
                           S=None, masts=None, temperature=20.0, vessel_heading=0.0, vessel_speed_surge=0.0,
                           vessel_speed_sway=0.0):
    """Return the wind force (surge and sway) and moment (yaw) acting
    on the vessel.

    Args:
        wind_speed (float)                  -- wind speed in m/s
        wind_direction (float)              -- wind direction in radians
        frontal_area (float)                -- frontal area of the vessel in m^2
        lateral_area (float)                -- lateral area of the vessel in m^2
        Loa (float)                         -- vessel length over all in m
        s_L (float)                         -- centroid of the wind area in the lateral direction, ahead of Lpp/2, in m
        coeffs (CoefficientType)            -- how to determine the wind coefficients
        vessel_type (string)                -- vessel type to use with Blendermann (default: None)
        superstructure_area (float)         -- lateral superstructure area in m^2 for use with Isherwood (default: None)
        breadth (float)                     -- vessel breadth in m (default: None)
        S (float)                           -- length of the lateral proj. in m for use with Isherwood (default: None)
        masts (int)                         -- number of masts or king posts for use with Isherwood (default: None)
        temperature (float)                 -- temperature in degrees C (default: 20)
        vessel_heading (float)              -- vessel heading in radians (default: 0.0)
        vessel_speed_surge (float)          -- vessel speed in surge in m/s (default: 0.0)
        vessel_speed_sway (float)           -- vessel speed in sway in m/s (default: 0.0)

    Returns:
        wind_forces_and_moment (np.matrix)  -- the wind forces and moment in kN/kNm
    """

    rho_w = calculate_rho_w(temperature)

    # Relative velocities
    wind_speed_surge = wind_speed * np.cos(wind_direction - vessel_heading)
    wind_speed_sway  = wind_speed * np.sin(wind_direction - vessel_heading)
    relative_velocity_surge = vessel_speed_surge - wind_speed_surge
    relative_velocity_sway  = vessel_speed_sway  - wind_speed_sway
    relative_wind_speed = np.sqrt(relative_velocity_surge**2 + relative_velocity_sway**2)

    # The wind is coming from the angle of attack
    angle_of_attack = np.arctan2(relative_velocity_sway, relative_velocity_surge) + pi

    # Calculate coefficients depending on coefficient calculation method
    if coeffs is CoefficientType.blendermann:
        if vessel_type == None:
            print("Please enter the correct parameters for Blendermann.\n")
            C_X, C_Y, C_N = 0, 0, 0
        else:
            C_X, C_Y, C_N = wc.blendermann(vessel_type, frontal_area, lateral_area, Loa, s_L, angle_of_attack)
    elif coeffs is CoefficientType.isherwood:
        if superstructure_area == None or breadth == None or S == None or masts == None:
            print("Please enter the correct parameters for Isherwood.\n")
            C_X, C_Y, C_N = 0, 0, 0
        else:
            C_X, C_Y, C_N = wc.isherwood(frontal_area, lateral_area, superstructure_area, Loa, breadth, S, s_L, masts,
                angle_of_attack)

    q = 0.5 * rho_w * relative_wind_speed**2
    wind_force_surge = 10**-3 * q * C_X * frontal_area
    wind_force_sway  = 10**-3 * q * C_Y * lateral_area 
    wind_moment_yaw  = 10**-3 * q * C_N * lateral_area * Loa

    wind_forces_and_moment = np.matrix([[wind_force_surge],
                                        [wind_force_sway],
                                        [wind_moment_yaw]])

    return wind_forces_and_moment