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
947f493d
Commit
947f493d
authored
6 years ago
by
David Verelst
Browse files
Options
Downloads
Patches
Plain Diff
add tests for different fatigue signal amplitudes
parent
fd10e246
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
wetb/fatigue_tools/tests/test_fatigue.py
+44
-22
44 additions, 22 deletions
wetb/fatigue_tools/tests/test_fatigue.py
with
44 additions
and
22 deletions
wetb/fatigue_tools/tests/test_fatigue.py
+
44
−
22
View file @
947f493d
...
@@ -14,8 +14,8 @@ standard_library.install_aliases()
...
@@ -14,8 +14,8 @@ standard_library.install_aliases()
import
unittest
import
unittest
import
numpy
as
np
import
numpy
as
np
from
wetb.fatigue_tools.fatigue
import
eq_load
,
rainflow_astm
,
rainflow_windap
,
\
from
wetb.fatigue_tools.fatigue
import
(
eq_load
,
rainflow_astm
,
cycle_matrix
rainflow_windap
,
cycle_matrix
)
from
wetb.hawc2
import
Hawc2io
from
wetb.hawc2
import
Hawc2io
import
os
import
os
...
@@ -31,28 +31,50 @@ class TestFatigueTools(unittest.TestCase):
...
@@ -31,28 +31,50 @@ class TestFatigueTools(unittest.TestCase):
m
=
1
m
=
1
point_per_deg
=
100
point_per_deg
=
100
# sine signal with 10 periods (20 peaks)
for
amplitude
in
[
1
,
2
,
3
]:
peak2peak
=
amplitude
*
2
# 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 should be independent of the length of the signal
np
.
testing
.
assert_allclose
(
r_eq_1hz
,
r_eq_1hz2
)
def
test_rainflow_combi
(
self
):
"""
Signal with two frequencies and amplitudes
"""
amplitude
=
1
# peak2peak = amplitude * 2
m
=
1
point_per_deg
=
100
nr_periods
=
10
nr_periods
=
10
time
=
np
.
linspace
(
0
,
nr_periods
*
2
*
np
.
pi
,
point_per_deg
*
180
)
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
+
(
amplitude
*
0.2
*
np
.
cos
(
5
*
time
))
signal
=
amplitude
*
np
.
sin
(
time
)
+
5
cycles
,
ampl_bin_mean
,
ampl_edges
,
mean_bin_mean
,
mean_edges
=
\
r_eq_1hz
=
eq_load
(
signal
,
no_bins
=
1
,
m
=
m
,
neq
=
neq
)[
0
]
cycle_matrix
(
signal
,
ampl_bins
=
10
,
mean_bins
=
5
)
r_eq_1hz_expected
=
((
2
*
nr_periods
*
amplitude
**
m
)
/
neq
)
**
(
1
/
m
)
np
.
testing
.
assert_allclose
(
r_eq_1hz
,
r_eq_1hz_expected
)
cycles
.
sum
()
# 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
):
...
...
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