You are on page 1of 6

IntJ Fatigue9 No 3 (1987) pp 223-228

Rainflow counting algorithm for


very long stress histories
G. Glinka and J. C. P. K a m

A computer algorithm for rainflow cycle counting of very long stress histories is
presented. The procedure enables the rainflow counting to be performed without prior
knowledge of the whole stress history being analysed. The stress history can be read
and analysed by the computer one block at a time without reading the whole history
at once. This will enable small computers to analyse very long stress histories because
the length of one block can be adjusted to the computer capabilities. The algorithm
does not require any rearrangement of the stress history before the start of counting
and the peaks and troughs can be analysed as they were recorded in service.

Keywords: rainflow counting; computer algorithms; stress history analysis

Notation NI current number of elements belonging to the


identified 'rainflow cycles' among the current
A,B,C peaks and troughs of the analysed stress element of vector S(N)
history k elements of vector S(N) NOP total number of elements (peaks and troughs)
DS stress range of the identified 'rainflow cycle' to be analysed
I number of the current initial element of the NP current total number of elements belonging
disk to be read into thevector S(N) to the identified 'rainflow cycles'
II number of the current last element on the NSTART number of the first element on the disc to
disc to be read into the vector S(N) be analysed
IREC record number in external direct access file NR length of vector S(N), k number of elements
N number of the current element in vector S(N) in vector S(N)
to be analysed SM mean stress of the identified 'rainflow cycle'
NEND number of the last element on the disc to X previous stress range adjacent to the range Y
be analysed Y stress range under consideration

Damage cumulation procedures are usually employed to trains do not contain any distinct, short repetitive blocks
estimate fatigue life of engineering components and stru- or segments.
tures. 1'2 These procedures allow the component life to be Procedures described in References 6 and 7 do not re-
related to the life of simple laboratory specimens tested under quire the entire load history to be known before the counting
constant stress amplitude. However, real structures usually process starts but the algorithm given in Reference 6 requires
experience an irregular stress history and therefore a cycle reading and analysing the stress history point by point. This
counting procedure has to be employed to decompose the was suitable for 'on-line' data processing s but it would be
complex irregular history into a series of simple events very time consuming and inconvenient if a long stress history
equivalent to individual cycles in a constant amplitude stress had to be read from a floppy disc or other external memory
history. The procedure called 'rainflow counting '1 has gained device. Very often the entire stress history which has to
wide recognition and it defines individual cycles as closed be counted cannot be read from the disc into the computer
stress/strain hysteresis loops. There are several algorithms at once because of limitations of the computer memory.
available to perform the counting 3'4 but most of them require Therefore it is more convenient to divide the stress history
that the entire load/stress history be known before the count- into blocks which can be read and analsyed at one time.
ing process starts. In addition, stress history has to be The results of the count are independent of block length.
rearranged before counting so that the absolute maximum The length of a 'block', NR, will depend on the maximum
in the history can be placed at the second and the last point length of the vector, S(N), which can be handled by the
in the history. This rearrangement is justified in the case computer. Not only will this reduce the number of readings
of stress histories with distinct and repetitive blocks which from the disc down to (NOP/NR + 1) times and therefore
are relatively short, as happens in the case of earth moving reduce the computing time, but also the stress history need
and lifting machines) However, the characteristic stress not be known or rearranged before the counting starts.
histories of offshore structures and some elements of railway Therefore it allows computation to be conducted on small

0142-1123/87/040223-06 $3.00 © 1987 Butterworth & Co (Publishers) Ltd


Int J Fatigue October 1987 223
~_ NOP = 15
NR=9 =.j
6 F H i Read data from the file
B A ^ I J starting from element A until
4 D = L 'NR' elements are found in
~2 vector S(N) or until the last
element 'NEND' is read in
A Time
/
//0
-2 V• V PI"
a NSTART G M ,
NEND
F

B A 1. Move indicator 'N' point by point and


identify ranges X and Y until relation Y/> X
~ ~ .'-~
,.- : I ~ D/ I is true
ABS(C- B) <ABS(B- A)
ABS(D- C)<ABS(C- B)

" V
G
ii Time ABS(F- E)>ABS(E- D)
I
2. Calculate DS=X=ABS(E - D)
b SM = (E+D)/2
3. Discard reversal 'D- E'

F 1. Shift elements A, B, C forward by two places


6

4
B B A 2. Check relation Y ~ X starting from element F
- ^ ~ ? \ / \ I ABS(F- C)>ABS(C- B)
~ 2 ,, 3. Calculate DS=ABS(C-B)
SM = (C+B)/2
0

-2
A A V Time
4. Discard reversal 'B-C'
C G

B
^ ,A
F
H ] 1. Shift element A forward by two places
I \ 2. Check relationY /> X starting from element H
~ 2 / \ I \
ABS(H- G)<ABS(G- F)
/ \1 I
0 v ABS(I- H)<ABS(H- G) and N=NR
T I
Time
-2
d G I

NR ~j
. Move elements A,F,G,H,I to the beginning of
vector S(N) and read further data from the file
6 until 'NR' elements are found in vector S(N)
4 J ~ k . Check relation Y/> X starting from element H
until it is true
P 2 ABS(M- L)>ABS(L-- K)
i

0 3. Calculate DS=ABS(L- K)
Time SM=(L+K)/2
-2
e G M 4. Discard reversal 'K- L'

Fig. 1 Illustration of the rainflow counting algorithm

224 Int J Fatigue October 1987


1. Shift elements A through J forward by two
F F
6 places

4 ;', A ! 2. Check relation Y >/ X starting from element H


ABS(M--J)>ABS(J-I)
2
0
A
/ ',/\ / g\i
A V ~Time
3. Calculate DS=ABS(J-I)
SM=(J+I)/2
4. Discard reversal '1- J'
-2
G U~

F F F
1. Shift elements A through H forward by two
places
4

2
,,' '\ ,,' ", / %::::ii::Ti::ii;i~i7
2. Check relation Y ~> X starting from element M
ABS(M- H)>ABS(H- G)

0 ,' \7 ',/ ,!J\ 3. Calculate DS=ABS(H-G)


SM=(H+G)/2
Time
-2 4. Discard reversal ' G - H'
g G M

F F F F
6
l
'
~
/\ l
1. Shift elements A,F forward by two places
4
ii ~ I ~ I 2. ( N - N I ) < 3 a n d N=NR
P
2 lI ~ I 3. Read in next block of elements until I I=NEND
0
A A Time
h -2
M

F N'
6 ~::~.,~..~
1, Close the last loop N'=F
4. .~i~.~..::::~.
m 4 2. Check relation Y >/ X starting from element N'
P
2 ::~.,'.~..-..'
3. Calculate DS=ABS(N'--M), SM=(N'+M)/2
0 4. Discard reversal 'M- N'
Time
-2
M

F F=N'
6

4-
A A 1. Shift elements A,F forward by two places

P
2-
i",/\ 2. N - N l < 3 a n d N = N R a n d II=NEND
3. STOP
0 " V\
--2--
A A \ Time
P

computers because the length of block, NR, can be chosen E, F, G . . . corresponding to the S(1), S(2), S(3), S(4), S(5),
according to computer capability while there is no limitation S(6), S(7)... elements of the vector S(N) in the computer
on the length, NOP, of the stress history to be analysed. memory. The range under consideration is represented by
Y. Thus for N -- 6 the range Y will be calculated as (Fig. la)"
Basic rules and n o t a t i o n
Let the peaks and troughs be identified as A, B, C, D, Y = ABS ( S ( N ) - S ( N - 1 ) ) = ABS(F-E) (1)

Int J Fatigue October 1987 225


Consequently the previous range X adjacent to Y will be SM = [S(N - 1) + S(N - 2)1/2
calculated as: NI = NI + 2
X = ABS(S(N-l)- S(N-2))-- ABS(E-D) 9. Store and discard from vector already counted range
(2) X and move remaining elements S(1) to S(N - 3)
by two places up in the vector S(N) such that
It is also known that reversals X and Y create rainflow S ( N - 1) = S ( N - 3)
counted cycles or a closed loop in the stress/strain plane S ( N - 2) = S ( N - 4)
if the following relationship is true: •.. etc...and

Y i> X (3) go to step 5


10. STOP
The range, DS, and mean stress, SM, of the identified cycle
can be calculated as follows: The procedure described above is illustrated step by
DS = X = A B S ( S ( N - 1) - S ( N - 2 ) ) step in Fig. 1. The programme, written in F O R T R A N 77
= ABS ( E - D ) (4) language, is listed in Table 1. It should also be noted that
the programme listed in Table 1 has been given additional
SM = ( S ( N - 2 ) + S ( N - 1)) / 2 features regarding the first and last values of the load/stress
= (E+D)/2 (5) history. Namely, after reading in the first block, NR, the
Then the identified range X has to be stored and then dis- first element in vector S(N) is set to S(1) = 0 as the history
carded from the vector S(N), and new adjacent ranges B-C always has to start from this value. Consequently the last
(Fig. lb) and C-F should be analysed by means of relation element, or the adjacent element to the last one, take the
(3). If relation (3) is not true the next element, S( N + 1 ), value of the absolute maximum contained within the vector
should be taken for analysis and new ranges X and Y identi- during the last run, including element S(NOP). The results
fied (Fig. lc): of the count can be output directly (Table 2) or accumulated
as counts in a two-dimensional matrix relating stress ranges
Y= ABS(G- F) with mean stress•
X = ABS(F- C) (6)
This procedure needs to be repeated until all elements in Summary and conclusions
the vector S(N) are analysed.
Thus the analysis consists of the following steps. A simple rainflow algorithm has been presented which
enables long stress histories to be counted using small
1. Choose the number of peaks and troughs, NOP, to computers• The main feature of the algorithm is counting
be analysed by choosing the starting and final elements, the stress history in segments, called blocks. Thus only one
N S T A R T and N E N D respectively, and read NR relatively short stress block is required to be read into the
elements into vector S(N). Care must be taken so that computer memory each time. The size of one block depends
every block of NR elements contains at least one rain- on the computer capability but the length of the stress history
flow cycle. This is not an unreasonable restriction can consist of a large number of segments depending on
because NR will usually be large enough (say, above particular situations• The program reads and analyses the
50). Initialize the parameters NP = 1, NI = 1. peaks and troughs as they were recorded in service. It is
2. Calculate number of cycles identified to date: not necessary to rearrange the stress history before the count-
NP = NP + NI- 1 ing starts. The whole history only needs to be analysed
once without any changes of the remaining part of the
Read further data from the disc until NR elements history. This also saves a lot of computing time in
are found in the vector S(N) or until the last element, comparison to some earlier rainflow counting algorithms•
N E N D , is read in. The programme is written in F O R T R A N 77 language
3. Initialize parameters: and it can be easily linked with models simulating cyclic
N= 1, N I = 1 elasto-plastic stress strain behaviour of engineering materials
and predicting fatigue life of notched elements.
4. Increase number of the current element in vector S(N):
N=N+I
If NP + N > N O P go to step 10 (all N O P elements
References
analysed).
I f N < NR go to step 5. 1. Wetzel, R• M• (ed.) Fatigue Under Complex Loading:
I f N > NR go to step 2. Analyses and Experiments (The Society of Automative
5. Check if there are enough elements to create a cycle. Engineers,Warrendale, PA, USA, 1977)
I f N - NI < 3 go to step 4. 2. Fuchs, H. O. and Stephene, R. I. Metal Fatigue in
Engineering (John Wiley & Sons, New York, 1980)
If N - NI > 3 go to step 6.
6. Identify ranges X and Y: 3. Wetzel, R. N. 'A method of fatigue damage analysis' PhD
Thesis (Department of Civil Engineering, University of
Y = ABS [S(N) - S(N - 1)1
Waterloo, Canada, 1971 )
X = ABS [S(N - 1) - S ( N - 2 ) ]
4• Downing, S•, Galiart, D. and Berenyi, T• 'A Neuber's
7• Check if Equation (3), Y > X, is true. rule fatigue analysisprocedurefor use with a mobile computer'
I f Y > X go to step 8. in R. M. Wetzel (ed) Fatigue under Complex Loading:
I f Y < X go to step 4. Analyses and Experiments (The Society of Automotive
8. Calculate stress range DS, mean stress SM and para- Engineers,Warrendale, PA, USA, 1977) pp 189-201
meter NI: 5. Glinka, G. and Sobczylkiewicz, W• 'Fatigue analysis of
DS = ABS [S(N - 1) - S(N - 2)1 excavator service loading spectra' in J. Tunna (ad)

226 Int J Fatigue October 1987


T a b l e 1. Listing o f r a i n f l o w c o u n t i n g p r o g r a m

PROGRAM RAINFLOW--COUNTING
DIMENSION S(4001 ) IDECLARATION
READ(5,') NSTART, N EN D,N R IREAD IN CONTROL PARAMETERS
NOP = NEND - NSTART + 1 IINITIATION
NP = NSTART
I = NSTART
II = NSTART + N R - 1
IF(II .GT. NEND) II=NEND
K=I
100 OPEN (U NIT = 10,FI LE = 'LOAD.S PL',ACCESS = 'DIR ECT',RECL-- 1,TYPE = 'OLD')
IREC= I IREAD IN ONE BLOCK
110 READ(10'IREC)S(K)
IF (IREC .LT. II) THEN
IREC=IREC+I
K=K+I
GOTO 110
ENDIF
CLOSE(UNIT= 10)
IF (I .EQ. NSTART) THEN 1FIRST POINT GENERATION
IF ( S ( 1 ) / ( S ( 2 ) - S ( 1 ) ) ) 120,130,130
120 DO J1 = NR,1,- 1
S(J1 + 1 )S(J1 )
END DO
NR=NR+I
NP = NSTART- 1
C
130 s(1)=o.
ENDIF
NI=I ICOUNTING STARTS
N=4
140 IF((N-NI) .LT. 3) GOTO 180
IF(II .EQ. NEND .AND. N .EQ. K) THEN IFINAL CYCLE
IF(S(2)/(S(N) - (N-1)))150,160,160
150 S(N-1) =S(N-3)
N=N°I
GOTO 140
160 S(N) = S(N-2)
END IF
170 IF(ABS(S(N)-S(N-1)) .GE. ABS(S(N-1)-S(N-2))) GOTO 190
180 N=N+I
IF(NP+ N - l ) .GT. II) THEN 1NEXT PEAK
GOTO 210
ELSE
GOTO 140
END IF
190 DS = ABS(S(N-1)-S(N-2)) IOUTPUT GATEWAY
SM = (S(N-1) + S(N-2))/2.
WRITE(6,1000) DS,SM
1000 FORMAT(5X,'Stress range = ',F10.5,' Mean Stress --',F10.5)
NI = NI + 2 !NEXT RANGE
DO 200 L = I , N - N I
S(N-1) = S(N-2-L)
200 CONTINUE
GOTO 140
210 IF(II .GE. NEND) GOTO 230 ISHIFTING THE REMAINING
DO 220 J = 1, N-NI-1 I PEAKSIN THE BLOCK
S(J+I)=S(NI+J)
220 CONTINUE
NP=NP+NI-1 INEXT SET OF DATA
I=11+1
II=II+NI-1
IF(II .GT. NEND) II=NEND
K=NR-NI+2
GOTO 100
230 CONTINUE
STOP
END 1END

Int J Fatigue October 1987 227


T a b l e 2. R a i n f l o w c o u n t i n g o u t p u t f o r t h e 7. Clormann, V. H. and 8eeger, T. 'Rainflow HCM ein
s a m p l e history s h o w n in Figure l ( a ) : N R = 9 , Zahlverfahren fur Batriebsfestigkeitsnechweise auf
NOP=15 werkstoffmechanischer Grundlage' Stahlbau 55 (1986) pp
65-71
Stress range = 1.00000 Mean Stress = 2.50000 8. Socie, D. F., Shifflet, G. and Berne, H. 'A field recording
system with applications to fatigue analysis" Int J Fatigue
Stress range = 3.00000 Mean Stress = 2.50000 1 (April 1979) pp 103-111
Stress range = 1.00000 Mean Stress = 2.50000
Stress range = 3.00000 Mean Stress = 2.50000
Stress range = 7.00000 Mean Stress = 1.50000
Stress range = 9.00000 Mean Stress = 1.50000 Authors
Measurement and Fatigue, EIS 86 (Engineering Materials The authors are with the London Centre for Marine
Advisory Services,Warley, UK, 1986) pp 385-397 Technology, Department of Mechanical Engineering,
6. Downing, S. end Socie, D.F. 'Simple rainflow counting University College London, Torrington Place, London
algorithms' IntJ Fatigue4 (January 1982) pp 31-40 WC1E 7JE, UK.

228 int J Fatigue October 1987

You might also like