Simple rainflow counting algorithms
S. D. Downing and D. F. Socie
Two simple algorithms for performing rainflow counting are presented in this paper. The second algorithm is suitable for microcomputer devices that are placed in vehicles to record field data. Key words: fatigue tests; rainflow counting; algorithms; load monitoring; ground vehicles
In the landvehicle industry, cumulative damage fatigue analysis procedures are usually employed to estimate endurance.13 They allow the engineer to relate the endurance of actual components to simple laboratory specimens. Fatigue lives of specimens are determined from constant amplitude tests. Real structures seldom, if ever, experience constant amplitude loading. Therefore, some type of cycle counting scheme must be employed to reduce a complex irregular loading history into a series of constant amplitude events. The most accurate fatigue life estimates are obtained using an analysis based on the strain at the most highly stressed/strained location. Rainflow counting 4 is an essential part of these procedures. This method defines cycles as closed stress/strain hysteresis loops as illustrated in Fig. 1. Four cycles (bc, ed, fg, ad) are identified by the method.
Several algorithms are available to perform the counting, however, they all require that the entire load history be known before the counting process starts. 57 As a result, they are not suitable for 'onboard' data processing since the entire load history isn't known until the end of the test. The first algorithm described in this paper has this same limitation;that is, the load history must be rearranged to begin and end with the maximum peak (or minimum valley). It is presented because of its simplicity and because it is useful as a control program for determining stress/ strain response under variable amplitude loading. The 'onepass' rainflow counting algorithm described later overcomes this hmitation and identifies the same cycles as the first algorithm. Thus, it can operate in 'realtime' and has been successfully implemented in a histogram recorder. 8
Strain
,o
.ts
4
,o"
B
D
i
C Time E A
B
D
07
Fig. 1 Stress/strain response and rainflow counting
01421123/82/01003110 $03.00 ? 1982 Butterworth & Co (Publishers) Ltd
INT. J. FATIGUE January 1982 31
PREVIOUS WORK
Most practical rainflow counting algorithms are based on either the 'availability matrix' or the 'vector' mathematical concepts. The 'availability matrix' algorithm developed by Wetzel 9 requires that the input signal be divided into a finite number of bands which are used to define the numerical value of the range and mean of each reversal. Corresponding to each band is an element in the availability matrix. Simply speaking, this matrix is used to determine when a rainflow counted cycle is formed. 'Vector' based rainflow counting algorithms use a one dimensional array to keep track of those peaks and valleys which have not formed a closed loop. In other words, once a closed loop has been determined, the peak and valley associated with it can be eliminated from the vector. This technique was first demonstrated by Downing et al 2 and was modified by Okamura et al IO to account for half cycles. Both algorithms described in this paper use the 'vector' concept. 4 5
6
7
8
9
b. If X = Y and Y contains S, go to Step 1 c. If X > Y a n d Y containsS, go to Step 4 d. If X ~> Y and Y does not contain S, go to Step 5  Move S to the next point in the vector Go to Step 1  Count range Y Discard the peak and valley of Y Go to Step 2 Read the next peak or valley from the beginning of the vector E(n) (if the starting point, S, has already been reread, STOP)  Form ranges X and Y (if the vector contains less than 2 points past the starting point, go to Step 6)  Compare ranges X and Y a. I f X < Y , g o t o S t e p 6 b. I f X l > Y , g o t o S t e p 9  Count range Y Discard the peak and valley of Y Go to Step 7
RULES FOR BOTH ALGORITHMS
Let the range of each peak and valley be identified as follows: X = range under consideration Y ; previous range adjacent to X As each peak or valley is encountered, it is put in a vector E(n). In addition, the starting peak or valley is designated S.
EXAMPLES
Both algorithms will be illustrated by rainflow counting the strain/time history shown in Fig. 2. Fig. S shows the same history after it has been rearranged to begin and end with the maximum peak, point C. Also given is the resulting stress/strain response which shows a number of closed hysteresis loops. Rainflow counting should identify the ranges of strain which correspond to these closed hysteresis loops. Rainflow Algorithm I is illustrated in conjunction with Figs 4  1 6 . In each figure, the strain/time history shown corresponds to the contents of the vector E(n). Also shown is the stress/strain plot, the values of ranges X and Y, and the decisions which correspond to Step 3 of the rules for this algorithm. The history to be rainflow counted is given in Fig. S. In Fig 4, the first peak has been read into the vector. This establishes the origin of the stress/strain plot since either the maximum peak or the minimum valley lies on the cyclic stress/strain curve. Since there are less than 3 points in the vector, ranges X and Y are undetermined and the next peak or valley must be read. In Fig. 5,
RAINFLOW ALGORITHM I
This algorithm rainflow counts a history of peaks and valleys in sequence which has been rearranged to begin and end with the maximum peak (or minimum valley). Rainflow counting then proceeds according to the following steps: I  Read the next peak or valley (if out of data, STOP) 2  Form ranges X and Y (if the vector contains less than S points, go to Step i ) 3  Compare ranges X and Y a. I f X < Y , g o t o S t e p l b. I f X > / Y , g o t o S t e p 4 4  Count range Y Discard the peak and valley of Y Go to Step 2
m
8 RAINFLOW A L G O R I T H M II (ONEPASS)
This algorithm rainflow counts a history of peaks and valleys in sequence as they occur. It calculates the same ranges and means as Rainflow Algorithm I which required that the history be rearranged to begin and end with the maximum peak (or minimum valley). Rainflow counting then proceeds according to the foUowing steps: I  Read the next peak or valley (if out of data, go to Step 6) 2  F o r m ranges X and Y (if the vector contains less than 2 points past the starting point, go to Step I ) S  Compare ranges X and Y a. If X ' ( Y , go to Step I
C D E
T
:]:

N E

H
m
L I I I I Fig. 2 Variable amplitude history
!
I
I
I
I
32
INT. J. F A T I G U E January 1982
i
I I
i
C
the same cycles (DC, GF, BA, HE) have been identified as in the previous algorithm. Again, the reader should carefully follow Figs 1731 to fully understand this algorithm.
T
m
FORTRAN PROGRAM LISTINGS
A Fortran listing for Rainflow Algorithm I is contained in Appendix I. The reader needs to write his own version of Subroutine Data (P, K) compatible with his data files. The variable, P, is the value of the data point. The variable, K, should be defined as follows:
I
B
I
?
m
[
1
i
I
I
I
I
I
I
I
K = 0 when the data is valid; K = 1 when the history is finished. The data returned from this subroutine must be peaks and valleys in sequence and must begin and end with the maximum peak (or minimum valley). The maximum size of the vector, E(n), is equal to the number of counting ranges. Appendix II gives the Fortran listing for Rainflow Algorithm II (OnePass). This program checks for data sequence so that the variable, P, in Subroutine Data (P, K ) may be timed data samples. The meaning of variable, K, remains the same as above. For this algorithm the maximum size of the vector E(n) is equal to twice the number of counting ranges.
Rainflow Algorithm I is illustrated in conjunction with Figs 4  1 6
"C
smJu]
Fig. 3 Stress/strain response
point D has been read into the vector and the stress is unloaded from C to D along the outer loop curve. Range Y is still undetermined so the next peak or valley must be read. In Fig. 6, point E has been read and the stress increases from D to E along the outer loop curve. A closed hysteresis loop has been formed and, according to the counting rules, range Y should be counted and its points discarded since they have no bearing on future events. The counting algorithm identified the same cycle, DC, as was determined from the stress/strain response. In Fig. 7, points D and C have been eliminated from the contents of the vector. It is left to the reader to follow Figs 7  1 6 along with the counting rules to see that the algorithm identifies the same cycles (DC, GF, BA, HE) as were determined from the stress/strain response. Rainflow Algorithm II (OnePass) will be used to count the strain/time history given in Fig. 2. It should identify the same cycles as the previous algorithm without the restriction that history be rearranged to begin and end with the maximum peak. Figs 1731 show the contents of the vector E(n) and the counting decisions for each step in the counting process. It should be noted that the starting point, S, is always the first occurrence of either the maximum peak or the minimum valley at that point in the history. When all the peaks and valleys of the history have been read, we begin reading points from the beginning of the vector as seen in Fig. 17. The counting procedure continues until all the points up to and including the starting point have been reread. When we try to read a point beyond the starting point, the counting procedure stops and all the cycles have been determined. Fig. 31 shows that
I m
[
I
I
I
I
I
I
I
I
I
00QQ000 IB0000010
S T
R
E S S
I I I I I I I I
X = tleET Y = LICET REAl) NEXT PEAKOR VALLEY FIB. 4
INT. J. FATIGUE January 1982 33
D J C
"E
C i
i
i
i
I I 1 1 1
E
i
i
i
i
I I I I I
[
i
n
i
i
I I I I I
......... ..... o .'°""/
J
i
l
l
I
l
J
l
I
I
I
I
I
I
I
I
I l l /
Ill!
STRAIN
STP.A.~
X = ABS@C)
Y : LN)E'TER~I}I~ REAP NEXT PEAKOR VALLEY FIG. 5
STRAIN
X = ABS(ED)
CYCLES = DC
Y  AB~(1)O X = UNDETE~
Y = UN)EI'ERItINED
X=Y,COUNTY AND DISCLRI)IT'S POINTS FIG. 6
REAl) NEXTPEAKOR VALLEY
FIG. 7
J E Fj T 
I E
H~
G ~~ E F
I
M
E

2

I
L
I
I
I
I l l l
[
t
i
i
i
....y
l l i l
l i l l l
[
I
l
I
L
l i l l
:y
J /
I I I I
J i l l
l l l l
I I I I
STRAIN
1 I 1 I
STI~L~
STRAIN
CYCLES = DC X : ABS(FD
Y = UNDEIE~ READNEXTPEAKOR VALLEY
FIG. 8
CYCLES = PC X = AB~(GF) Y = ABS(FE) X<Y,READNEXTPEAKOR VALLEY FIG. 9
CYCLES = DC
X =/~(l+G) Y =/85(64) # f , CSl~ Y AND DISO~ .FI"S R)]]~I'S
FIG. 18
34
INT. J. F A T I G U E January 1982
/
I E
~
E
/
I E

II/
~ A
~ A
C i
i
i
i
I
I
I
I
I
r
i
I
1
I
I
I
I
I
I
[
n
I
I
I
I
I
I
I
I
J
I I I
J
I
l
I
I
I
I
I
I
I
I
I
I
I
I
I
I
I
I
I
I
l
STRAIN
STI~
CYCLES= DC,GF
STR~
CYCLES = DC,GF Y = ABSCAH)
CYCLES = I~,GF X = ~OFE) ND(T PEAKOR WLLEY FIG. II
X =/~CA~)
Y = ~(1~) X<Y,RF_~ NEXT~ FIG. 12 ~ V~J/Y
X =/~S(I}A)
Xq,RE~) IIEXT ~ FIG. 13 OR VALLEY
. . ~ E
~
E
H
E
[ I I I I I
I I I I
i" I I I I I I I I I
E
[ I I I I I I I I I
.......°" . ,.."
Y
I 1 I I I I I I I I I I I I I I 1 I I I I 1 I l
S/RAIN CYCLES = DC,GF
STP,/~I CYCLES = ~,~,E~ X =/~(Ctt) Y = Jl~(lt?) X=Y,COLIfT Y All) DIrNdl) IT'S POINTS FIG. 15
STRAZH CYCLES = DC, GF,~,IE lie ARE FIKISlEI) FI6 16
X =/8S(C8)
Y = AI~(BA) X>Y,COLNT Y ~ DISCJLRI)I"r'S POINTS FIG. 14
INT. J FATIGUE
January
1982
35
Rainflow
Algorithm
II is illustrated
in conjunction
with
Figs 1731
ACT~FIy TA~(.ING DATA
AC'TIYE1YTAIC]]4G DATA
ACTIVELY TAKING DATA
"A~
B~k'S ~ C
L
I
I
I
I
I
I
I
I
L
I
I
I
I
I
I
1
L
I
I
1
I
I
I
1
I
X  I.II)~'T~
X = AB~CI}.A)
Y = LII)ETE]~It]]E]) REAP NEXT PEAl(OR VAU.EY
Y = Lal)ETEIWd)O READNI3C[ PEAKOR VALLEY
X = ASS(C.B) Y = ABS(BA) bY AND Y CONTAINSS HOVEUP ST~RIIHGPOINT
REAPNEXTPE.q(ORVALLE'Y
F][G. 17
FIG. 18
FIG. 19
A~I]/F'I Y TAJC]]IG DATA
ACTIVELY TAY,.ING DATA
ACT]]/E].YTAI(]]4G DATA
D 2c
~~~C
I
I
I
I
I
I
I
I
I
I I I I
I
I
I
I
1
I
CYCLES= DC X = ABS(DC) Y =/~CC.6) X(Y I E ~ llg(T PEAl( OR V/CJ.L~ X = ABSCEP) Y = ABS(PC) X:Y AND Y BeES NOT CONTAINS COUNT Y ~ DISrJ~ IT'S PO]]iTS X = AliCEB) Y = BNDETE1~ READNE](TPEAKOR V~LL~
FIG. 29
~6. 21
FIG. 22
3G
INT. J. FATIGUE January T982
ACl'lIIFl Y TAKINGDATA
ACTIVELYTAE,]]WG DATA
A~IVEI.YTAI(.I)?O DATA
B_s
A
T
F.~IG ~E
I
M
H
E
L
I
I
I
I
I
I
I
I
L
I
I
1
I
I
I
I
I
L
I
1
I
i
I
1
I
I
I
CYCLES = DC
X = ABS(FE)
CYCLES= DC X = ABS(GF) Y = ABS(FE) XCY READNEXTPEAKOR VALLEY
CYCLES = PC
X = ADS(HG) Y = ABe(GF) X>Y AND Y DOESNOT CONTAINS C O U N TY AND DISCARDIT'S POINTS
Y = ABS(EB) X=Y AND Y CONTAINSS REAl) NEXTPEAKOR VALLEY
FIG.
FIG.
24
FIG. 25
ACTr/E].YTAI(])CGDATA
OUl" OF DATA
OUI'OFDATA
B
"A
B
A
~
E
J
~
"~~E=S
A
~
I I I I
L I
1
A
I
I
i
I
I
I

L I
I
I
I
I
I
I
I
I
1
I
I
CYCLES = DC,GF
X = ABS(HE) Y = ABe(EB) X>Y AND Y CONTAINSS HOVEUP STARTINGPO11q READNEXTPEAKOR VALLEY
CYCLES= DC,GF
CYCLES =
DC, GF
X = AB~(A.H) Y = ABS(IIE) XCY REAl)NEXT PEAK OR VALLEY
X  ABS(BA) Y = ABS(AH) X<Y READNEXTPEAKOR VALLEY
FIG. 26
FIG. 21
FIG. 28
I N T . J. F A T I G U E
January 1982
37
~DATA
ACTI"I/FIYT ~
DATA
B
m m
A
m m
m
m m
E
m
m
m
m
m
m
L
I
I
I
I
i
I
I
1
I
CYCLES= DC,GF
X = ABSCEB) Y = ABS(BA) bY AND Y DOES NOT CONTAIN S COUNT Y AND DISCARD IT'S POINTS
L
I
I
I
I
I
I
I
I
I
FIG. 29
X = kBS(ED) Y = ABS(DC) X=Y AND Y DOESNOT CONTAIN S COLITT Y AND DISCARDIT'S POINTS FIG. 31
OF DATA
SUMMA R Y
Two simple rainflow counting algorithms for processing field data have been presented. The first is useful as a control program for following stress/response under irregular loading. The second algorithm gives identical results as the first and has the advantage that the counting can begin before the entire history is known.
B
A
T I M E
REFERENCES
1. Dabell, B. J., Hill, S. J., Eaton, D. E. and Watson, P. 'Fatigue life predictions for notched components' J Soc Environmental Engrs (December 1977)
Downing, S., Galliart, D. and Bereyni, T. 'A Neubers rule fatigue analysis procedure for use with a mobile computer' SAE Paper 760317 presented at: SAE Automotove Engineering Congress (Detroit, Michigan, 1976) Fatigue Under Complex Loading: Analysis and Experiment Edited by: R. M. Wetzel (SAE Inc, Warrendale, Pennsylvania, 1977)
iatsuishi, i . a n d E n d o , T. 'Fatigue of metals subjected to varying stress' paper presented to Japan Soc Mech Engrs (Jukvoka, Japan, 1968) Richards, F., LaPointe, N. and Wetzel, R. 'A cycle counting algorithm for fatigue damage analysis' Paper No 74(3278 presented at: SAE Automotive Engineering Congress (Detroit, Michigan, 1974) Nelson, D. V. a n d F u c h s , H. O. 'Predictions of cumulative damage using condensed load histories' Paper 750045 presented at : SA E Automotive Engineering Congress (Detroi t, Mich igan, 1975)
~
E
2.
3.
L
I
I
i
I
I
1
i
I
i
4.
CYCLES = DC, GF,BA X = ABS(EH) Y = ABS(IFE) X"f AND Y CONTAINS S Y AND DISCARDl"l"S PO.T.NTS
5.
6.
F[G. 38
38
I N T . J. F A T I G U E January 1982
7. Socie, D. F. 'Fatiguelife prediction using local stress/strain concept' Experimental Mech 17 No 2 (1977) pp 5 0  5 6 6. Socie, D. F., Shifflet, G. and Berns, H. 'A field recording system with applications to fatigue analysis' Int d Fatigue 1 No 2 (April 1979) pp 103111 9. Wetzel, R. M. 'A method of fatigue damage analysis' PhD Thesis (Department of Civil Engineering, University of Waterloo, Ontario, Canada, 1971 ) 10. Okamura, H., Sakai, S. and Susuki, I. 'Cumulative fatigue damage under random loads' Fatigue Engng Mater and Struct 1 (1979) pp 4 0 9  4 1 9
A UTHORS
Stephen Downing is with Deere and Company's Engineering Mechanics Group in Moline and Darrell Socie is with the Department of Mechanical and Industrial Engineering in the University of Illinois at UrbanaChampaign. In the first instance inquiries should be addressed to: Mr S. D. Downing, Engineering Mechanics, Deere and Company, 3300 River Drive, Moline, Illinois 61265, USA.
Appendix 1
RFI ) NILOH lql_(l(~ I 1 ~ I
THIS P R t K ~ f~INI'LDW COtlNI.~ Fl HI%IOI,~Y uF I'ERKS RNI) VALLEYS IN .SEQUENCE WHICH HfIS I~FEN RF_HI,~kHNGED 10 BEG]N fIND ENI> WllH ]HI_ MRXIMUM PI~HK (OR MINIM~IM VRLI.FV>. SIRIEMF_NI I_R~I_I.S CI~,tRI__~~ONI> 1 u 1H~ SIE.P5 IN IHF_ RRINFL.OW C O I ~ N l l N G RULES.
D I M~ N . ~ I O N E ( 5 @ ) N=O N=:N+~. CRI.L I ~ R I H ( E ( N ) , K ) I F ( K EQ. : ! ) .t,lOP 2 IF(N l.l..'?) ((I 1(: l X=RfYS ( E ( N )   E ( N  l . ) ) VHBS(E ( N  ~ )   ~ ( N  2 ) ) 3 ] F ( X L I . Y) GI) I u 'I 4 RHNGE= V XM~_FIN= ( E ( N  1 ) + E ( N  z ) ) / 2 N=,N;, E(N)=F.(N+2) G~) T{) 2 END
Appendix 2
llfll~L{~l,l fILGOf~ITI~M ]I (,C~NFPH~ '~, )
1 H I S PROGRftM RflIN~L.(~N [ : O U N I ~ A H ] S I [ ~ t Y R~ 11 OCCLN,Ch RN[, ] D E N ] I F ] E _(', ]FIE..~~MF ['YC;L.E~ H~ ~Ia]NFI..UW RLO[HK,]]HM I I~H}IH K~QUIkE.% I H F l l ] H F H I . ~ I I ~ Y NE I,t[rFI~tHNGFI) .~.THIFMr.NI I Fl~PI ~9 CLW~kESPOND 1 0 lHfr 51b.PS ] N 1HE R f l I N P I O W C(JUNIING ktllIIFS )1M~NS] ON E(~.OB ~ N:='./ J =e~ CRI_L. D R I R ( F ( . ~ ) , K ) CRI_L. D ~ I R ( E ( ; : ) , K ) IF(E(1). E&I. E ( 2 ' > ) GO 1 0 ~ e ~ SLOPE= "1. ] F ( E ( ~ > . G1 E ( 2 ) ) SI.C~k=I. {;ALl_ [ J ~ l l R ( f ~, K ) } F ( K F.(~ 1 ) GU ILI 6 N=:N*~. .St O P F . = S I _ O P E * (  J ) E (N).'=P
I N T . J. F A T I G U E January 1982
39
Appendix ?, (ctd)
~' I F ( N . L.1. I S I R R I + ~ > [~0 1 0 X=SI OPI:~,(I_(N)E ( N  I ) ) ] F ( X LE.. i}. ) {iO TO ~'_~ } F ( N 1.1. ]Slfff, C l ÷ 2 ) GO 1 0 Y: SI.(IPEW,(E(N2)E (.N~) ) :~ ] F ( X . I_l. Y ) G(I l(i I F ( X . [.(,L Y. FINi) l . % . l R W l . ~.(~ I F ( X . (;1. Y. FW~[). I.~TF4W1 F~. I F ( X . GE. Y. FIN[) } S I H W 1 Ni4 } S l Mr, c1 := ] S l f~Rl +d 0 0 1 0 :t 5 RRNKiE=Y XMEFIN= ( E ( N  i ) ~_ ( N  ~  ) ) / ; t N=N2 E (N):~ ( N + 2 ~ GO I 0 2 6 J:=J+l I F ( J . [~I. ) S I F I R I ) STOP N='N+3 .SL O~F=~I. C ~ ' . * (  : I . ) F_(N)=:E(J ) 7 ] F ( N LT. I S I R I ~ I + . 1 ) OtJ I t ) X=.~LOPE,~ (I: ( N )  h ~N~.) ) I F ( X . LE. e. ) Or; l~J 3e~4 ] F ( . N I.T I S T F W I ÷ ~ ) (iO l(J Y=:SL.( IPE,k ( E ( N.~. )  f f ~N  ~ ) ) B I F ( X . L1. Y) OO I O (I F ( X . GE. Y> (30 l O .~ .9 f<fINGh=:Y XMERN= ( E ( N   ~ ) + ~ ( N  2 ) ) 7;::. N=.N;.~ E ( N ) ='IE( N + 2 ) GO l O Y 2e(,, N=N:I E (N)==E ( N + : I ) SL.( IPE'.Si.LIPE, r,.1.. ) 00 l O 2 :(ele N=I41 E(N)=E(N+I) SI. C'PE =:SL( IPE'=' ( .1.. ) GO 1 0 ~ EN[) :I
:I
NP) N2) N~)
{wU l O .1 (jo~ l 0 4 fj(1 Ttl
6
e~
40
I N T . J. F A T I G U E January 1982