コード例 #1
0
def test_move_rotor_center():
    bearing = fluid_flow_short_friswell()
    eccentricity = bearing.eccentricity
    attitude_angle = bearing.attitude_angle
    move_rotor_center(bearing, 0.001, 0)
    move_rotor_center(bearing, -0.001, 0)
    assert_allclose(bearing.eccentricity, eccentricity)
    assert_allclose(bearing.attitude_angle, attitude_angle)
    move_rotor_center(bearing, 0, 0.001)
    move_rotor_center(bearing, 0, -0.001)
    assert_allclose(bearing.eccentricity, eccentricity)
    assert_allclose(bearing.attitude_angle, attitude_angle)
    move_rotor_center(bearing, 0, 0.001)
    assert bearing.eccentricity != eccentricity
    assert bearing.attitude_angle != attitude_angle
コード例 #2
0
def calculate_stiffness_matrix(fluid_flow_object, oil_film_force='numerical'):
    """This function calculates the bearing stiffness matrix numerically.
    Parameters
    ----------
    fluid_flow_object: A FluidFlow object.
    oil_film_force: str
        If set, calculates the oil film force analytically considering the chosen type: 'short' or 'long'.
        If set to 'numerical', calculates the oil film force numerically.
    Returns
    -------
    list of floats
        A list of length four including stiffness floats in this order: kxx, kxy, kyx, kyy
    Examples
    --------
    >>> from ross.fluid_flow.fluid_flow import fluid_flow_example
    >>> my_fluid_flow = fluid_flow_example()
    >>> calculate_stiffness_matrix(my_fluid_flow)  # doctest: +ELLIPSIS
    [-0.0...
    """
    [radial_force, tangential_force, force_x, force_y] = \
        calculate_oil_film_force(fluid_flow_object, force_type=oil_film_force)
    delta = fluid_flow_object.difference_between_radius / 100

    move_rotor_center(fluid_flow_object, delta, 0)
    fluid_flow_object.calculate_coefficients()
    fluid_flow_object.calculate_pressure_matrix_numerical()
    [radial_force_x, tangential_force_x, force_x_x, force_y_x] = \
        calculate_oil_film_force(fluid_flow_object, force_type=oil_film_force)

    move_rotor_center(fluid_flow_object, -delta, 0)
    move_rotor_center(fluid_flow_object, 0, delta)
    fluid_flow_object.calculate_coefficients()
    fluid_flow_object.calculate_pressure_matrix_numerical()
    [radial_force_y, tangential_force_y, force_x_y, force_y_y] = \
        calculate_oil_film_force(fluid_flow_object, force_type=oil_film_force)
    move_rotor_center(fluid_flow_object, 0, -delta)

    k_xx = (force_x - force_x_x) / delta
    k_yx = (force_y - force_y_x) / delta
    k_xy = (force_x - force_x_y) / delta
    k_yy = (force_y - force_y_y) / delta

    return [k_xx, k_xy, k_yx, k_yy]
コード例 #3
0
def find_equilibrium_position(
    fluid_flow_object,
    print_along=True,
    tolerance=1e-05,
    increment_factor=1e-03,
    max_iterations=10,
    increment_reduction_limit=1e-04,
    return_iteration_map=False,
):
    """This function returns an eccentricity value with calculated forces matching the load applied,
    meaning an equilibrium position of the rotor.
    It first moves the rotor center on x-axis, aiming for the minimum error in the force on x (zero), then
    moves on y-axis, aiming for the minimum error in the force on y (meaning load minus force on y equals zero).
    Parameters
    ----------
    fluid_flow_object: A FluidFlow object.
    print_along: bool, optional
        If True, prints the iteration process.
    tolerance: float, optional
    increment_factor: float, optional
        This number will multiply the first eccentricity found to reach an increment number.
    max_iterations: int, optional
    increment_reduction_limit: float, optional
        The error should always be approximating zero. If it passes zeros (for instance, from a positive error
        to a negative one), the iteration goes back one step and the increment is reduced. This reduction must
        have a limit to avoid long iterations.
    return_iteration_map: bool, optional
        If True, along with the eccentricity found, the function will return a map of position and errors in
        each step of the iteration.
    Returns
    -------
    None, or
    Matrix of floats
        A matrix [4, n], being n the number of iterations. In each line, it contains the x and y of the rotor
        center, followed by the error in force x and force y.
    Examples
    --------
    >>> from ross.fluid_flow.fluid_flow import fluid_flow_example2
    >>> my_fluid_flow = fluid_flow_example2()
    >>> find_equilibrium_position(my_fluid_flow, print_along=False,
    ...                           tolerance=0.1, increment_factor=0.01,
    ...                           max_iterations=5, increment_reduction_limit=1e-03)
    """
    fluid_flow_object.calculate_coefficients()
    fluid_flow_object.calculate_pressure_matrix_numerical()
    r_force, t_force, force_x, force_y = calculate_oil_film_force(
        fluid_flow_object, force_type="numerical"
    )
    increment = increment_factor * fluid_flow_object.eccentricity
    error_x = abs(force_x)
    error_y = abs(force_y - fluid_flow_object.load)
    error = max(error_x, error_y)
    k = 1
    map_vector = []
    while error > tolerance and k <= max_iterations:
        increment_x = increment
        increment_y = increment
        iter_x = 0
        iter_y = 0
        previous_x = fluid_flow_object.xi
        previous_y = fluid_flow_object.yi
        infinite_loop_x_check = False
        infinite_loop_y_check = False
        if print_along:
            print("\nIteration " + str(k) + "\n")
        while error_x > tolerance:
            iter_x += 1
            move_rotor_center(fluid_flow_object, increment_x, 0)
            fluid_flow_object.calculate_coefficients()
            fluid_flow_object.calculate_pressure_matrix_numerical()
            (
                new_r_force,
                new_t_force,
                new_force_x,
                new_force_y,
            ) = calculate_oil_film_force(fluid_flow_object, force_type="numerical")
            new_error_x = abs(new_force_x)
            move_rotor_center(fluid_flow_object, -increment_x, 0)
            if print_along:
                print("Iteration in x axis " + str(iter_x))
                print("Force x: " + str(new_force_x))
                print("Previous force x: " + str(force_x))
                print("Increment x: ", str(increment_x))
                print("Error x: " + str(new_error_x))
                print("Previous error x: " + str(error_x) + "\n")
            if new_force_x * force_x < 0:
                infinite_loop_x_check = False
                increment_x = increment_x / 10
                if print_along:
                    print("Went beyond error 0. Reducing increment. \n")
                if abs(increment_x) < abs(increment * increment_reduction_limit):
                    if print_along:
                        print("Increment too low. Breaking x iteration. \n")
                    break
            elif new_error_x > error_x:
                if print_along:
                    print("Error increased. Changing sign of increment. \n")
                increment_x = -increment_x
                if infinite_loop_x_check:
                    break
                else:
                    infinite_loop_x_check = True
            else:
                infinite_loop_x_check = False
                move_rotor_center(fluid_flow_object, increment_x, 0)
                error_x = new_error_x
                force_x = new_force_x
                force_y = new_force_y
                error_y = abs(new_force_y - fluid_flow_object.load)
                error = max(error_x, error_y)

        while error_y > tolerance:
            iter_y += 1
            move_rotor_center(fluid_flow_object, 0, increment_y)
            fluid_flow_object.calculate_coefficients()
            fluid_flow_object.calculate_pressure_matrix_numerical()
            (
                new_r_force,
                new_t_force,
                new_force_x,
                new_force_y,
            ) = calculate_oil_film_force(fluid_flow_object, force_type="numerical")
            new_error_y = abs(new_force_y - fluid_flow_object.load)
            move_rotor_center(fluid_flow_object, 0, -increment_y)
            if print_along:
                print("Iteration in y axis " + str(iter_y))
                print("Force y: " + str(new_force_y))
                print("Previous force y: " + str(force_y))
                print("Increment y: ", str(increment_y))
                print(
                    "Force y minus load: " + str(new_force_y - fluid_flow_object.load)
                )
                print(
                    "Previous force y minus load: "
                    + str(force_y - fluid_flow_object.load)
                )
                print("Error y: " + str(new_error_y))
                print("Previous error y: " + str(error_y) + "\n")
            if (new_force_y - fluid_flow_object.load) * (
                force_y - fluid_flow_object.load
            ) < 0:
                infinite_loop_y_check = False
                increment_y = increment_y / 10
                if print_along:
                    print("Went beyond error 0. Reducing increment. \n")
                if abs(increment_y) < abs(increment * increment_reduction_limit):
                    if print_along:
                        print("Increment too low. Breaking y iteration. \n")
                    break
            elif new_error_y > error_y:
                if print_along:
                    print("Error increased. Changing sign of increment. \n")
                increment_y = -increment_y
                if infinite_loop_y_check:
                    break
                else:
                    infinite_loop_y_check = True
            else:
                infinite_loop_y_check = False
                move_rotor_center(fluid_flow_object, 0, increment_y)
                error_y = new_error_y
                force_y = new_force_y
                force_x = new_force_x
                error_x = abs(new_force_x)
                error = max(error_x, error_y)
        if print_along:
            print("Iteration " + str(k))
            print("Error x: " + str(error_x))
            print("Error y: " + str(error_y))
            print(
                "Current x, y: ("
                + str(fluid_flow_object.xi)
                + ", "
                + str(fluid_flow_object.yi)
                + ")"
            )
        k += 1
        map_vector.append(
            [fluid_flow_object.xi, fluid_flow_object.yi, error_x, error_y]
        )
        if previous_x == fluid_flow_object.xi and previous_y == fluid_flow_object.yi:
            if print_along:
                print("Rotor center did not move during iteration. Breaking.")
            break

    if print_along:
        print(map_vector)
    if return_iteration_map:
        return map_vector
コード例 #4
0
def calculate_stiffness_and_damping_coefficients(fluid_flow_object):
    """This function calculates the bearing stiffness and damping matrices numerically.
        Parameters
        ----------
        fluid_flow_object: A FluidFlow object.
        Returns
        -------
        Two lists of floats
            A list of length four including stiffness floats in this order: kxx, kxy, kyx, kyy.
            And another list of length four including damping floats in this order: cxx, cxy, cyx, cyy.
            And
        Examples
        --------
        >>> from ross.fluid_flow.fluid_flow import fluid_flow_example
        >>> my_fluid_flow = fluid_flow_example()
        >>> calculate_stiffness_and_damping_coefficients(my_fluid_flow)  # doctest: +ELLIPSIS
        ([428...
        """
    N = 6
    t = np.linspace(0, 2 * np.pi / fluid_flow_object.omegap, N)
    fluid_flow_object.xp = fluid_flow_object.radial_clearance * 0.0001
    fluid_flow_object.yp = fluid_flow_object.radial_clearance * 0.0001
    dx = np.zeros(N)
    dy = np.zeros(N)
    xdot = np.zeros(N)
    ydot = np.zeros(N)
    radial_force = np.zeros(N)
    tangential_force = np.zeros(N)
    force_xx = np.zeros(N)
    force_yx = np.zeros(N)
    force_xy = np.zeros(N)
    force_yy = np.zeros(N)
    X1 = np.zeros([N, 3])
    X2 = np.zeros([N, 3])
    F1 = np.zeros(N)
    F2 = np.zeros(N)
    F3 = np.zeros(N)
    F4 = np.zeros(N)

    for i in range(N):
        fluid_flow_object.t = t[i]

        delta_x = fluid_flow_object.xp * np.sin(
            fluid_flow_object.omegap * fluid_flow_object.t
        )
        move_rotor_center(fluid_flow_object, delta_x, 0)
        dx[i] = delta_x
        xdot[i] = (
            fluid_flow_object.omegap
            * fluid_flow_object.xp
            * np.cos(fluid_flow_object.omegap * fluid_flow_object.t)
        )
        fluid_flow_object.calculate_coefficients(direction="x")
        fluid_flow_object.calculate_pressure_matrix_numerical()
        [
            radial_force[i],
            tangential_force[i],
            force_xx[i],
            force_yx[i],
        ] = calculate_oil_film_force(fluid_flow_object, force_type="numerical")

        delta_y = fluid_flow_object.yp * np.sin(
            fluid_flow_object.omegap * fluid_flow_object.t
        )
        move_rotor_center(fluid_flow_object, -delta_x, 0)
        move_rotor_center(fluid_flow_object, 0, delta_y)
        dy[i] = delta_y
        ydot[i] = (
            fluid_flow_object.omegap
            * fluid_flow_object.yp
            * np.cos(fluid_flow_object.omegap * fluid_flow_object.t)
        )
        fluid_flow_object.calculate_coefficients(direction="y")
        fluid_flow_object.calculate_pressure_matrix_numerical()
        [
            radial_force[i],
            tangential_force[i],
            force_xy[i],
            force_yy[i],
        ] = calculate_oil_film_force(fluid_flow_object, force_type="numerical")
        move_rotor_center(fluid_flow_object, 0, -delta_y)
        fluid_flow_object.calculate_coefficients()
        fluid_flow_object.calculate_pressure_matrix_numerical()

        X1[i] = [1, dx[i], xdot[i]]
        X2[i] = [1, dy[i], ydot[i]]
        F1[i] = -force_xx[i]
        F2[i] = -force_xy[i]
        F3[i] = -force_yx[i]
        F4[i] = -force_yy[i]

    P1 = np.dot(
        np.dot(np.linalg.inv(np.dot(np.transpose(X1), X1)), np.transpose(X1)), F1
    )
    P2 = np.dot(
        np.dot(np.linalg.inv(np.dot(np.transpose(X2), X2)), np.transpose(X2)), F2
    )
    P3 = np.dot(
        np.dot(np.linalg.inv(np.dot(np.transpose(X1), X1)), np.transpose(X1)), F3
    )
    P4 = np.dot(
        np.dot(np.linalg.inv(np.dot(np.transpose(X2), X2)), np.transpose(X2)), F4
    )

    K = [P1[1], P2[1], P3[1], P4[1]]
    C = [P1[2], P2[2], P3[2], P4[2]]

    return K, C
コード例 #5
0
def calculate_stiffness_matrix(
    fluid_flow_object, force_type=None, oil_film_force="numerical"
):
    """This function calculates the bearing stiffness matrix numerically.
    Parameters
    ----------
    fluid_flow_object: A FluidFlow object.
    oil_film_force: str
        If set, calculates the oil film force analytically considering the chosen type: 'short' or 'long'.
        If set to 'numerical', calculates the oil film force numerically.
    force_type: str
        If set, calculates the stiffness matrix analytically considering the chosen type: 'short'.
        If set to 'numerical', calculates the stiffness matrix numerically.
    Returns
    -------
    list of floats
        A list of length four including stiffness floats in this order: kxx, kxy, kyx, kyy
    Examples
    --------
    >>> from ross.fluid_flow.fluid_flow import fluid_flow_example
    >>> my_fluid_flow = fluid_flow_example()
    >>> calculate_stiffness_matrix(my_fluid_flow)  # doctest: +ELLIPSIS
    [417...
    """
    if force_type != "numerical" and (
        force_type == "short" or fluid_flow_object.bearing_type == "short_bearing"
    ):
        h0 = 1.0 / (
            (
                (np.pi ** 2) * (1 - fluid_flow_object.eccentricity_ratio ** 2)
                + 16 * fluid_flow_object.eccentricity_ratio ** 2
            )
            ** 1.5
        )
        a = fluid_flow_object.load / fluid_flow_object.radial_clearance
        kxx = (
            a
            * h0
            * 4
            * (
                (np.pi ** 2) * (2 - fluid_flow_object.eccentricity_ratio ** 2)
                + 16 * fluid_flow_object.eccentricity_ratio ** 2
            )
        )
        kxy = (
            a
            * h0
            * np.pi
            * (
                (np.pi ** 2) * (1 - fluid_flow_object.eccentricity_ratio ** 2) ** 2
                - 16 * fluid_flow_object.eccentricity_ratio ** 4
            )
            / (
                fluid_flow_object.eccentricity_ratio
                * np.sqrt(1 - fluid_flow_object.eccentricity_ratio ** 2)
            )
        )
        kyx = (
            -a
            * h0
            * np.pi
            * (
                (np.pi ** 2)
                * (1 - fluid_flow_object.eccentricity_ratio ** 2)
                * (1 + 2 * fluid_flow_object.eccentricity_ratio ** 2)
                + (32 * fluid_flow_object.eccentricity_ratio ** 2)
                * (1 + fluid_flow_object.eccentricity_ratio ** 2)
            )
            / (
                fluid_flow_object.eccentricity_ratio
                * np.sqrt(1 - fluid_flow_object.eccentricity_ratio ** 2)
            )
        )
        kyy = (
            a
            * h0
            * 4
            * (
                (np.pi ** 2) * (1 + 2 * fluid_flow_object.eccentricity_ratio ** 2)
                + (
                    (32 * fluid_flow_object.eccentricity_ratio ** 2)
                    * (1 + fluid_flow_object.eccentricity_ratio ** 2)
                )
                / (1 - fluid_flow_object.eccentricity_ratio ** 2)
            )
        )
    else:

        [radial_force, tangential_force, force_x, force_y] = calculate_oil_film_force(
            fluid_flow_object, force_type=oil_film_force
        )
        delta = fluid_flow_object.radial_clearance / 100

        move_rotor_center(fluid_flow_object, delta, 0)
        fluid_flow_object.calculate_coefficients()
        fluid_flow_object.calculate_pressure_matrix_numerical()
        [
            radial_force_x,
            tangential_force_x,
            force_x_x,
            force_y_x,
        ] = calculate_oil_film_force(fluid_flow_object, force_type=oil_film_force)

        move_rotor_center(fluid_flow_object, -delta, 0)
        move_rotor_center(fluid_flow_object, 0, delta)
        fluid_flow_object.calculate_coefficients()
        fluid_flow_object.calculate_pressure_matrix_numerical()
        [
            radial_force_y,
            tangential_force_y,
            force_x_y,
            force_y_y,
        ] = calculate_oil_film_force(fluid_flow_object, force_type=oil_film_force)
        move_rotor_center(fluid_flow_object, 0, -delta)

        kxx = (force_x - force_x_x) / delta
        kyx = (force_y - force_y_x) / delta
        kxy = (force_x - force_x_y) / delta
        kyy = (force_y - force_y_y) / delta

    return [kxx, kxy, kyx, kyy]