Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

counting_cycles does not produce correct results #4

Closed
SaetreS opened this issue May 26, 2017 · 1 comment
Closed

counting_cycles does not produce correct results #4

SaetreS opened this issue May 26, 2017 · 1 comment

Comments

@SaetreS
Copy link

SaetreS commented May 26, 2017

The rainflow counting does not produce the same results as per the example given in ASTM E1049:85 - 2011.

The ASTM example uses the follow series:
y = [-2, 1, -3, 5, -1, 3, -4, 4, -2]

which results into:
count = [(1.0, 0.0), (2.0, 0.0), (3.0, 0.5), (4.0, 1.5), (5.0, 0.0), (6.0, 0.5), (7.0, 0.0), (8.0, 1.0), (9.0, 0.5), (10.0, 0)]

the count_cycles function should therefore produce:
count = [(3, 0.5), (4, 1.5), (6, 0.5), (8, 1.0), (9, 0.5)]

the current result from the count_cycles function:
count = [(4, 1.5), (8, 1.0), (9, 0.5)]

below is a simple unittest which reproduces the error.

import unittest
import rainflow

class Test_rainflow(unittest.TestCase):
    def setUp(self):
        pass

    def test_astm_example(self):
        self.y = [-2, 1, -3, 5, -1, 3, -4, 4, -2]
        astm_result = [(3, 0.5), (4, 1.5), (6, 0.5), (8, 1.0), (9, 0.5)]
        self.assertEqual(rainflow.count_cycles(self.y), astm_result)


if __name__ == '__main__':
    unittest.main()
@iamlikeme
Copy link
Owner

Hi, this behavior is by design and has to do with how load reversals are detected (see rainflow.reversals). By definition, load reversal occurs at a point if the load gradients before and after that point change sign. Since we don't know the load gradient before the first point in a series and after the last point in the series, we cannot classify these two points as reversals.

This is an interpretation of the ASTM standard which is not very clear on this issue.

In order to produce the correct cycle counts for the ASTM example, we have to prepend and append points, like so (see also tests/test_rainflow.py):

>>> y = [-2, 1, -3, 5, -1, 3, -4, 4, -2]  # ASME example load series
>>> rainflow.count_cycles([0] + y + [0])  # This produces expected cycle counts
[(3, 0.5), (4, 1.5), (6, 0.5), (8, 1.0), (9, 0.5)]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants