# rainflow

Rainflow counting fatigue analysis.

## Syntax

C = rainflow(signal)

C = rainflow(signal,numbins)

C = rainflow(signal,numbins,method)

[C,H,R,M] = rainflow(...)

## Inputs

signal
The stress history.
Type: double
Dimension: vector
numbins
The number of range/mean bins to create(default: 64 when omitted or []).
Type: integer
Dimension: scalar
method
The rainflow cycle counting method.
The available options are as follows:
• '3pt-ASTM': ASTM 3 point algorithm (default). ∙ Serial processing. ∙ Does not perform maxumum rearrangement. ∙ Identifies half cycles.
• '3pt-serial': Traditional serial 3 point algorithm. ∙ Serial processing. ∙ Performs maxumum rearrangement. ∙ Does not identify half cycles. ∙ This method is used in Altair HyperGraph.
• '4pt-serial': Serial 4 point algorithm. ∙ Serial processing. ∙ Does not perform maxumum rearrangement. ∙ Identifies half cycles.
• '3pt-recursive': Recursive 3 point algorithm. ∙ Same method as '3pt-serial'. ∙ Parallel processing for faster execution. ∙ Recursion may lead to differences that should be only minor for large data sets.
• '4pt-recursive': Recursive 4 point algorithm. ∙ Same method as '4pt-serial'. ∙ Parallel processing for faster execution. ∙ Recursion may lead to differences that should be only minor for large data sets.
Type: string

## Outputs

C
The cycle count history.
Each row contains data for a counted cycle. The data is stored by column as follows:
1. The cycle count (0.5 for half, 1.0 for whole).
2. The range of the cycle.
3. The mean of the cycle.
4. The start element index.
5. The end element index.
Type: matrix
H
The histogram matrix of cycle counts for each (mean, range) bin.
Type: matrix
R
The range bin centers associated with the columns of H.
Type: vector
M
The mean bin centers associated with the rows of H.
Type: vector

## Example

Compute the rainflow output of a stress history.


signal = [-79.3 -220.4 -210.7 90.2 -28.6 -15.9 -174.1 -36.9 90.4 144.7 158.7 64.9 209.0 ...
264.9 77.9 139.3 110.9 61.3 161.7 117.5 -96.6 -17.7 -35.5 -63.2 -132.9 -148.6 ...
-53.7 -67.8 -52.5 -64.0 -21.1 49.7 37.5 84.2 20.5 56.0 114.4 105.8  1.0 91.8];
[C, H, R, M] = rainflow(signal, 10, '3pt-ASTM')

C = [Matrix] 16 x 5
0.50000  141.10000  -149.85000   1.00000   2.00000
1.00000   12.70000   -22.25000   5.00000   6.00000
1.00000  264.30000   -41.95000   4.00000   7.00000
1.00000   93.80000   111.80000  11.00000  12.00000
1.00000   61.40000   108.60000  15.00000  16.00000
1.00000  100.40000   111.50000  18.00000  19.00000
1.00000   78.90000   -57.15000  21.00000  22.00000
1.00000   14.10000   -60.75000  27.00000  28.00000
1.00000   11.50000   -58.25000  29.00000  30.00000
1.00000   12.20000    43.60000  32.00000  33.00000
1.00000   63.70000    52.35000  34.00000  35.00000
0.50000  485.30000    22.25000   2.00000  14.00000
0.50000  413.50000    58.15000  14.00000  26.00000
0.50000  263.00000   -17.10000  26.00000  37.00000
0.50000  113.40000    57.70000  37.00000  39.00000
0.50000   90.80000    46.40000  39.00000  40.00000
H = [Matrix] 10 x 10
0.00000  0.00000  0.00000  0.00000  0.00000  0.00000  0.00000  0.00000  0.00000  0.00000
0.00000  0.00000  0.50000  0.00000  0.00000  0.00000  0.00000  0.00000  0.00000  0.00000
0.00000  0.00000  0.00000  0.00000  0.00000  0.00000  0.00000  0.00000  0.00000  0.00000
2.00000  1.00000  0.00000  0.00000  0.00000  1.00000  0.00000  0.00000  0.00000  0.00000
1.00000  0.00000  0.00000  0.00000  0.00000  0.50000  0.00000  0.00000  0.00000  0.00000
1.00000  1.50000  0.50000  0.00000  0.00000  0.00000  0.00000  0.00000  0.50000  0.50000
0.00000  2.00000  1.00000  0.00000  0.00000  0.00000  0.00000  0.00000  0.00000  0.00000
0.00000  0.00000  0.00000  0.00000  0.00000  0.00000  0.00000  0.00000  0.00000  0.00000
0.00000  0.00000  0.00000  0.00000  0.00000  0.00000  0.00000  0.00000  0.00000  0.00000
0.00000  0.00000  0.00000  0.00000  0.00000  0.00000  0.00000  0.00000  0.00000  0.00000
R = [Matrix] 1 x 10
24.26500  72.79500  121.32500  169.85500  218.38500  266.91500  315.44500  363.97500  412.50500  461.03500
M = [Matrix] 10 x 1
-196.13500
-147.60500
-99.07500
-50.54500
-2.01500
46.51500
95.04500
143.57500
192.10500
240.63500


The purpose of rainflow is to identify the simple hysteresis loops (or cycles) within a complicated stress-strain diagram. The identification is performed by creating an accounting of the peaks of a stress or strain vs. time history that resequences the stress-strain paths to make the loops easily distinguishable. The rainflow output records the ranges and means of the simple loops, which can also be presented as a histogram. Rainflow counting is often a preparation step for damage assessment using an S-N fatigue curve and Miner’s rule.

Outputs H, R and M are typically used to plot the hisogram.

A gate input to control hysteresis slope reversal and remove points due to external noise is currently unsupported.

When rainflow counting begins at the start of the time history a group of 4 peak points are required to identify a closed loop in the stress-strain diagram. The 4 peaks define 3 segments. The middle segment corresponds to a closed loop if it is shorter than the first and third segments. The analysis divides the time history into 4 groups of points:
1. The 4 peaks currently being considered.
2. Peaks from a previous group 1 that were assigned to a loop, whose analysis has been completed.
3. Peaks from a previous group 1 that were not assigned to a loop, that will be reconsidered later.
4. Peaks that have not yet entered into a group 1.
When no closed loop is identified in group 1, its oldest point is moved to group 3, and a new point is added from group 4. When a closed loop is identified in group 1, the peaks from the middle segment endpoints are moved to group 2. A new group 1 is then constructed from its remaining two peaks, recent additions to group 3 (if any), and the next point(s) from group 4 (if needed). The analysis of the current group 1 identifies closed loops from the stress-strain diagram that reside inside other closed loops, iterating until the outermost closed loop is identified. Remaining peaks from the time history are identified as half-cycles. This analysis is the basis of what is called the serial four-point algorithm."

Another approach is to perform a circular shift so that the peak with greatest absolute magnitude is repositioned at the start of the history data. When this is done the with the four-point algorithm, the middle segment will always be shorter than the first segment. This allows the algorithm to be reduced to a serial three-point algorithm. Additional sophistication is need to detect half-cycles, which not all three-point algorithms include.

The four-point algorithms are designed for real-time applications. The circular shift in three-point algorithms requires all of the data to be collected prior to identifying the loops.

The recursive three-point and four-point algorithms process all of the segment length comparisons as a batch prior to loop identification to obtain faster processing. Occasional output differences when compared the serial algorithms are possible.

References:

Standard practices for cycle counting in fatigue analysis. ASTM E 1049-85. ASTM International. 2005.

Equivalence of four-point and three-point rainflow cycle counting algorithms. C.H. McInnes and P.A. Meehan. International Journal of Fatigue 30 (2008) 547–559.

Simple rainflow counting algorithms. S. D. Downing and D. F. Socie. International Journal of Fatigue 4 (1982) 31-40.