Skip to content
Snippets Groups Projects
Commit 8003cc91 authored by Mads M. Pedersen's avatar Mads M. Pedersen
Browse files

Merge branch 'eq_load_test' into 'master'

move eq_load test to right place

See merge request !31
parents 6bdcbf0d bda75aec
No related branches found
No related tags found
1 merge request!31move eq_load test to right place
Pipeline #
......@@ -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.],
......
......@@ -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.
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment