Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
W
WindEnergyToolbox
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
wtlib
WindEnergyToolbox
Commits
bda75aec
Commit
bda75aec
authored
7 years ago
by
David Verelst
Browse files
Options
Downloads
Patches
Plain Diff
move eq_load test to right place
parent
49773516
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
wetb/fatigue_tools/tests/test_fatigue.py
+32
-2
32 additions, 2 deletions
wetb/fatigue_tools/tests/test_fatigue.py
wetb/prepost/tests/test_Simulations.py
+0
-31
0 additions, 31 deletions
wetb/prepost/tests/test_Simulations.py
with
32 additions
and
33 deletions
wetb/fatigue_tools/tests/test_fatigue.py
+
32
−
2
View file @
bda75aec
...
@@ -23,6 +23,36 @@ testfilepath = os.path.join(os.path.dirname(__file__), 'test_files/') # test fi
...
@@ -23,6 +23,36 @@ testfilepath = os.path.join(os.path.dirname(__file__), 'test_files/') # test fi
class
TestFatigueTools
(
unittest
.
TestCase
):
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
):
def
test_astm1
(
self
):
...
@@ -59,7 +89,7 @@ class TestFatigueTools(unittest.TestCase):
...
@@ -59,7 +89,7 @@ class TestFatigueTools(unittest.TestCase):
# def test_windap3(self):
# def test_windap3(self):
# data = Hawc2io.ReadHawc2(testfilepath + "test").ReadBinary([2]).flatten()
# data = Hawc2io.ReadHawc2(testfilepath + "test").ReadBinary([2]).flatten()
# from wetb.fatigue_tools.rainflowcounting import peak_trough
# 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__))))
# "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.],
# 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.],
# [ 0., 1., 4., 0.],
...
@@ -73,7 +103,7 @@ class TestFatigueTools(unittest.TestCase):
...
@@ -73,7 +103,7 @@ class TestFatigueTools(unittest.TestCase):
[
0.
,
1.
,
4.
,
0.
],
[
0.
,
1.
,
4.
,
0.
],
[
0.
,
0.
,
0.
,
0.
],
[
0.
,
0.
,
0.
,
0.
],
[
0.
,
1.
,
2.
,
0.
]])
/
2
,
0.001
)
[
0.
,
1.
,
2.
,
0.
]])
/
2
,
0.001
)
def
test_astm_weighted
(
self
):
def
test_astm_weighted
(
self
):
data
=
Hawc2io
.
ReadHawc2
(
testfilepath
+
"
test
"
).
ReadBinary
([
2
]).
flatten
()
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.
],
np
.
testing
.
assert_allclose
(
cycle_matrix
([(
1
,
data
),(
1
,
data
)],
4
,
4
,
rainflow_func
=
rainflow_astm
)[
0
],
np
.
array
([[
24.
,
83.
,
53.
,
26.
],
...
...
This diff is collapsed.
Click to expand it.
wetb/prepost/tests/test_Simulations.py
+
0
−
31
View file @
bda75aec
...
@@ -83,37 +83,6 @@ class TestGenerateInputs(Template):
...
@@ -83,37 +83,6 @@ class TestGenerateInputs(Template):
class
TestFatigueLifetime
(
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
):
def
test_leq_life
(
self
):
"""
Verify if prepost.Simulation.Cases.fatigue_lifetime() returns
"""
Verify if prepost.Simulation.Cases.fatigue_lifetime() returns
the expected life time equivalent load.
the expected life time equivalent load.
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment