diff --git a/wetb/fatigue_tools/tests/test_fatigue.py b/wetb/fatigue_tools/tests/test_fatigue.py index 0ef2fef2e7c85b38b02b63123e48067c30832df5..a25745e157215dc1666b40e66dee3bfb4d5247dc 100644 --- a/wetb/fatigue_tools/tests/test_fatigue.py +++ b/wetb/fatigue_tools/tests/test_fatigue.py @@ -23,6 +23,36 @@ testfilepath = os.path.join(os.path.dirname(__file__), 'test_files/') # test fi class TestFatigueTools(unittest.TestCase): + def test_leq_1hz(self): + """Simple test of wetb.fatigue_tools.fatigue.eq_load using a sine + signal. + """ + amplitude = 1 + m = 1 + point_per_deg = 100 + + # sine signal with 10 periods (20 peaks) + nr_periods = 10 + time = np.linspace(0, nr_periods*2*np.pi, point_per_deg*180) + neq = time[-1] + # mean value of the signal shouldn't matter + signal = amplitude * np.sin(time) + 5 + r_eq_1hz = eq_load(signal, no_bins=1, m=m, neq=neq)[0] + r_eq_1hz_expected = ((2*nr_periods*amplitude**m)/neq)**(1/m) + np.testing.assert_allclose(r_eq_1hz, r_eq_1hz_expected) + + # sine signal with 20 periods (40 peaks) + nr_periods = 20 + time = np.linspace(0, nr_periods*2*np.pi, point_per_deg*180) + neq = time[-1] + # mean value of the signal shouldn't matter + signal = amplitude * np.sin(time) + 9 + r_eq_1hz2 = eq_load(signal, no_bins=1, m=m, neq=neq)[0] + r_eq_1hz_expected2 = ((2*nr_periods*amplitude**m)/neq)**(1/m) + np.testing.assert_allclose(r_eq_1hz2, r_eq_1hz_expected2) + + # 1hz equivalent load should be independent of the length of the signal + np.testing.assert_allclose(r_eq_1hz, r_eq_1hz2) def test_astm1(self): @@ -59,7 +89,7 @@ class TestFatigueTools(unittest.TestCase): # def test_windap3(self): # data = Hawc2io.ReadHawc2(testfilepath + "test").ReadBinary([2]).flatten() # from wetb.fatigue_tools.rainflowcounting import peak_trough -# self.assertTrue(peak_trough.__file__.lower()[-4:] == ".pyd" or peak_trough.__file__.lower()[-3:] == ".so", +# self.assertTrue(peak_trough.__file__.lower()[-4:] == ".pyd" or peak_trough.__file__.lower()[-3:] == ".so", # "not compiled, %s, %s\n%s"%(sys.executable, peak_trough.__file__, os.listdir(os.path.dirname(peak_trough.__file__)))) # np.testing.assert_array_equal(cycle_matrix(data, 4, 4, rainflow_func=rainflow_windap)[0], np.array([[ 14., 65., 39., 24.], # [ 0., 1., 4., 0.], @@ -73,7 +103,7 @@ class TestFatigueTools(unittest.TestCase): [ 0., 1., 4., 0.], [ 0., 0., 0., 0.], [ 0., 1., 2., 0.]]) / 2, 0.001) - + def test_astm_weighted(self): data = Hawc2io.ReadHawc2(testfilepath + "test").ReadBinary([2]).flatten() np.testing.assert_allclose(cycle_matrix([(1, data),(1,data)], 4, 4, rainflow_func=rainflow_astm)[0], np.array([[ 24., 83., 53., 26.], diff --git a/wetb/prepost/tests/test_Simulations.py b/wetb/prepost/tests/test_Simulations.py index 00a7c4d3aa600f7f966a6aa70bae25ed400b084b..f4da4ea23c6525a0c67d265a92e495b2fd63cd54 100644 --- a/wetb/prepost/tests/test_Simulations.py +++ b/wetb/prepost/tests/test_Simulations.py @@ -83,37 +83,6 @@ class TestGenerateInputs(Template): class TestFatigueLifetime(Template): - def test_leq_1hz(self): - """Simple test of wetb.fatigue_tools.fatigue.eq_load using a sine - signal. - """ - amplitude = 1 - m = 1 - point_per_deg = 100 - - # sine signal with 10 periods (20 peaks) - nr_periods = 10 - time = np.linspace(0, nr_periods*2*np.pi, point_per_deg*180) - neq = time[-1] - # mean value of the signal shouldn't matter - signal = amplitude * np.sin(time) + 5 - r_eq_1hz = eq_load(signal, no_bins=1, m=m, neq=neq)[0] - r_eq_1hz_expected = ((2*nr_periods*amplitude**m)/neq)**(1/m) - np.testing.assert_allclose(r_eq_1hz, r_eq_1hz_expected) - - # sine signal with 20 periods (40 peaks) - nr_periods = 20 - time = np.linspace(0, nr_periods*2*np.pi, point_per_deg*180) - neq = time[-1] - # mean value of the signal shouldn't matter - signal = amplitude * np.sin(time) + 9 - r_eq_1hz2 = eq_load(signal, no_bins=1, m=m, neq=neq)[0] - r_eq_1hz_expected2 = ((2*nr_periods*amplitude**m)/neq)**(1/m) - np.testing.assert_allclose(r_eq_1hz2, r_eq_1hz_expected2) - - # 1hz equivalent load should be independent of the length of the signal - np.testing.assert_allclose(r_eq_1hz, r_eq_1hz2) - def test_leq_life(self): """Verify if prepost.Simulation.Cases.fatigue_lifetime() returns the expected life time equivalent load.