Пример #1
0
def test_rainflow_partial_signals_splitturn():
    tsgen = TimeSignalGenerator(
        10, {
            'number': 50,
            'amplitude_median': 1.0,
            'amplitude_std_dev': 0.5,
            'frequency_median': 4,
            'frequency_std_dev': 3,
            'offset_median': 0,
            'offset_std_dev': 0.4
        }, None, None)

    signal_tot = tsgen.query(10000)

    rfc_tot = RF.RainflowCounterThreePoint().process(signal_tot)
    turn_points, _ = RF.get_turns(signal_tot)
    turn_points = np.insert(turn_points, 0, 0)
    turn_num = turn_points.shape[0]
    split_points = [
        int(np.ceil(turn_num * x)) for x in [0.0, 0.137, 0.23, 0.42, 1.0]
    ]
    rfc_partial = RF.RainflowCounterThreePoint()
    for i in range(len(split_points) - 1):
        lower = turn_points[split_points[i]]
        upper = 10000 if split_points[
            i + 1] == turn_points.shape[0] else turn_points[split_points[i +
                                                                         1]]
        _, tot_turns = RF.get_turns(signal_tot[:upper])
        rfc_partial.process(signal_tot[lower:upper])

    np.testing.assert_array_almost_equal(rfc_tot.loops_from,
                                         rfc_partial.loops_from)
    np.testing.assert_array_almost_equal(rfc_tot.loops_to,
                                         rfc_partial.loops_to)
Пример #2
0
def test_rainflow_hits():
    r'''
                                                                                                 1   2   3   4   5   6
    --------------------------------------------------------------------------------------------------------------------
    6                x                                                                         |   |   |   |   |   |   |
    ----------------/-\-------------------------------------------------------------------------------------------------
    5              /   \                   x                                   x               | 1 |   |   |   |   |   |
    --------------/-----\-----------------/-\---------------------------------/-\---------------------------------------
    4            /       \           x   /   \           x   x           x   /   \             | 1 |   |   | 3 |   |   |
    ------------/---------\---------/-\-/-----\---------/-\-/-\---------/-\-/-----\-/-----------------------------------
    3                      \       /   x       \       /   x   \       /   x       x           |   |   |   |   |   |   |
    ------------------------\-----/-------------\-----/---------\-----/-------------------------------------------------
    2                        \   /               \   /           \   /                         |   |   |   |   |   |   |
    --------------------------\-/-----------------\-/-------------\-/---------------------------------------------------
    1                          x                   x               x                           |   |   |   |   |   |   |
    --------------------------------------------------------------------------------------------------------------------
    '''
    signal = np.array([3, 6, 1, 4, 3, 5, 1, 4, 3, 4, 1, 4, 3, 5, 3, 4]) - 0.5
    rfc = RF.RainflowCounterThreePoint()
    res = rfc.process(signal).get_rainflow_matrix_frame(
        (np.linspace(0, 6, 7), np.linspace(0, 6, 7)))

    expected = make_empty_rainflow_matrix(0, 6, 0, 6, 6)
    expected.loc[(1, 5)] = 1
    expected.loc[(4, 3)] = 3
    expected.loc[(1, 4)] = 1

    print(np.flipud(res.values.reshape(res.index.levshape).T))
    print(np.ceil(rfc.loops_from))
    print(np.ceil(rfc.loops_to))

    pd.testing.assert_frame_equal(res, expected)
Пример #3
0
def test_rainflow_dampening_closed():
    r'''
                                                                                    1   2   3   4   5   6
    -------------------------------------------------------------------------------------------------------
    6           6                                                                 |   |   |   |   |   |   |
    -----------/-\-----------------------------------------------------------------------------------------
    5         /   \           5                                                   |   |   |   |   |   |   |
    ---------/-----\---------/-\---------------------------------------------------------------------------
    4       /       \       /   \   4                                             |   |   | 1 |   |   |   |
    -------/---------\-----/-----\-/-\---------------------------------------------------------------------
    3     /           \   /       3   \                                           |   | 1 |   |   |   |   |
    -----/-------------\-/-------------\-------------------------------------------------------------------
    2   /               2               \                                         |   |   |   |   |   |   |
    ---/---------------------------------\-----------------------------------------------------------------
    1 1                                   1                                       |   |   |   |   |   |   |
    -------------------------------------------------------------------------------------------------------
    '''
    signal = np.array([1, 6, 2, 5, 3, 4, 1]) - 0.5
    rfc = RF.RainflowCounterThreePoint()
    res = rfc.process(signal).get_rainflow_matrix_frame(
        (np.linspace(0., 6., 7), np.linspace(0., 6., 7)))

    expected = make_empty_rainflow_matrix(0, 6, 0, 6, 6)
    expected.loc[(3, 4)] = 1
    expected.loc[(2, 5)] = 1

    expected_residuals = np.array([1, 6, 1])

    print(np.flipud(res.values.reshape(res.index.levshape).T))
    print(np.ceil(rfc.loops_from))
    print(np.ceil(rfc.loops_to))

    pd.testing.assert_frame_equal(res, expected)
    np.testing.assert_array_equal(
        np.ceil(rfc.residuals()).astype(int), expected_residuals)
Пример #4
0
def test_rainflow_lower_after_main():
    r'''
                                                 1   2   3   4   5   6
    ---------------------------------------------------------------------
    6        x                                 |   |   |   |   |   |   |
    --------/-\----------------------------------------------------------
    5      /   \   x           x               |   |   |   | 1 |   |   |
    ------/-----\-/-\---------/-\----------------------------------------
    4    /       x   \       /   \             |   |   |   |   |   |   |
    --\-/-------------\-----/-----\--------------------------------------
    3  x               \   /       \           |   |   |   |   |   |   |
    --------------------\-/----------------------------------------------
    2                    x                     |   |   |   |   |   |   |
    ---------------------------------------------------------------------
    1                                          |   |   |   |   |   |   |
    ---------------------------------------------------------------------
    '''
    signal = np.array([4, 3, 6, 4, 5, 2, 5, 3]) - 0.5
    rfc = RF.RainflowCounterThreePoint()
    res = rfc.process(signal).get_rainflow_matrix_frame(
        (np.linspace(0., 6., 7), np.linspace(0., 6., 7)))

    expected = make_empty_rainflow_matrix(0, 6, 0, 6, 6)
    expected.loc[(4, 5)] = 1

    expected_residuals = np.array([4, 3, 6, 2, 5, 3])

    print(np.flipud(res.values.reshape(res.index.levshape).T))
    print(np.ceil(rfc.loops_from))
    print(np.ceil(rfc.loops_to))

    pd.testing.assert_frame_equal(res, expected)
    np.testing.assert_array_equal(
        np.ceil(rfc.residuals()).astype(int), expected_residuals)
Пример #5
0
def test_rainflow_lecture_example():
    r'''
                                                                         1   2   3   4   5   6
    -------------------/\------------------------------------------------------------------------
    6                 /  \                           x                 |   | 1 |   |   |   |   |
    -----------------/----\-------------------------/-\------------------------------------------
    5               /      \               x       /   \               |   |   |   |   |   |   |
    ---------------/--------\-------------/-\-----/-----\----------------------------------------
    4             /          \   x       /   \   /       \             |   |   | 1 |   |   |   |
    -------------/------------\-/-\-----/-----\-/---------\--------------------------------------
    3           /              x   \   /       x           \           |   |   |   |   | 1 |   |
    -----------/--------------------\-/---------------------\------------------------------------
    2         /                      x                       \         |   |   |   |   |   |   |
    ---------/------------------------------------------------\-/--------------------------------
    1                                                          x       |   |   |   |   |   |   |
    ---------------------------------------------------------------------------------------------
    '''
    signal = np.array([1, 7, 4, 3, 4, 2, 5, 3, 6, 1, 2]) - 0.5
    rfc = RF.RainflowCounterThreePoint()
    res = rfc.process(signal).get_rainflow_matrix_frame(
        (np.linspace(0., 6., 7), np.linspace(0., 6., 7)))

    expected = make_empty_rainflow_matrix(0, 6, 0, 6, 6)
    expected.loc[(2, 6)] = 1
    expected.loc[(3, 4)] = 1
    expected.loc[(5, 3)] = 1
    expected_residuals = np.array([1, 7, 1, 2])

    print(np.flipud(res.values.reshape(res.index.levshape).T))
    print(np.ceil(rfc.loops_from))
    print(np.ceil(rfc.loops_to))

    pd.testing.assert_frame_equal(res, expected)
    np.testing.assert_array_equal(
        np.ceil(rfc.residuals()).astype(int), expected_residuals)
Пример #6
0
def test_rainflow_partial_signals_general_three_point():
    tsgen = TimeSignalGenerator(
        10, {
            'number': 50,
            'amplitude_median': 1.0,
            'amplitude_std_dev': 0.5,
            'frequency_median': 4,
            'frequency_std_dev': 3,
            'offset_median': 0,
            'offset_std_dev': 0.4
        }, None, None)

    signal_tot = tsgen.query(10000)

    rfc_tot = RF.RainflowCounterThreePoint().process(signal_tot)
    rfc_partial = RF.RainflowCounterThreePoint().process(
        signal_tot[:3424]).process(signal_tot[3424:])

    np.testing.assert_array_almost_equal(rfc_tot.loops_from,
                                         rfc_partial.loops_from)
    np.testing.assert_array_almost_equal(rfc_tot.loops_to,
                                         rfc_partial.loops_to)
Пример #7
0
def test_rainflow_simple_sine():
    signal = np.array([0., 1., -1., 1., -1., 0])
    rfc = RF.RainflowCounterThreePoint()
    res = rfc.process(signal).get_rainflow_matrix_frame(
        (np.linspace(-1.5, 1.5, 5), np.linspace(-0.25, 1.25, 5)))

    expected = make_empty_rainflow_matrix(-1.5, 1.5, -0.25, 1.25, 4)
    expected.loc[(-1, 1)] = 1

    print(np.flipud(res.values.reshape(res.index.levshape).T))
    print(rfc.loops_from)
    print(rfc.loops_to)

    pd.testing.assert_frame_equal(res, expected)
Пример #8
0
def test_rainflow_haibach_example():
    r'''
    Example from fig 3.3-30 of E. Haibach "Betriebsfestigkeit"

                                                                                               1   2   3   4   5   6
    ------------------------------------------------------------------------------------------------------------------
    6                6                   6                                                   | 1 |   |   |   |   |   |
    ----------------/-\-----------------/-\---------------------------------------------------------------------------
    5      5       /   \                | |                                    5             |   |   |   |   |   |   |
    ------/-\-----/-----\--------------/---\----------------------------------/-\-------------------------------------
    4    /   \   /       \             |   |         4               4       /   \   4       | 1 |   | 1 |   |   |   |
    ----/-----\-/---------\-----------/-----\-------/-\-------------/-\-----/-----\-/-\-------------------------------
    3  /       3           \   3      |     |      /   \   3       /   \   /       3   \     |   | 2 |   |   | 1 |   |
    --/---------------------\-/-\----/-------\----/-----\-/-\-----/-----\-/-------------\-----------------------------
    2                        2   \   |       |   /       2   \   /       2               2   |   |   |   | 1 |   |   |
    ------------------------------\-/---------\-/-------------\-/-----------------------------------------------------
    1                              1           1               1                             |   |   |   |   |   |   |
    ------------------------------------------------------------------------------------------------------------------
    '''
    signal = np.array(
        [2, 5, 3, 6, 2, 3, 1, 6, 1, 4, 2, 3, 1, 4, 2, 5, 3, 4, 2]) - 0.5
    rfc = RF.RainflowCounterThreePoint()
    res = rfc.process(signal).get_rainflow_matrix_frame(
        (np.linspace(0, 6, 7), np.linspace(0, 6, 7)))

    expected = make_empty_rainflow_matrix(0, 6, 0, 6, 6)
    expected.loc[(1, 6)] = 1
    expected.loc[(1, 4)] = 1
    expected.loc[(2, 3)] = 2
    expected.loc[(3, 4)] = 1
    expected.loc[(4, 2)] = 1
    expected.loc[(5, 3)] = 1

    expected_residuals = np.array([2, 6, 1, 5, 2])

    print(np.flipud(res.values.reshape(res.index.levshape).T))
    print(np.ceil(rfc.loops_from))
    print(np.ceil(rfc.loops_to))

    pd.testing.assert_frame_equal(res, expected)
    np.testing.assert_array_equal(
        np.ceil(rfc.residuals()).astype(int), expected_residuals)