Code covered by the BSD License  

Highlights from
Rainflow Counting Algorithm

4.52632

4.5 | 41 ratings Rate this file 205 Downloads (last 30 days) File Size: 38.99 KB File ID: #3026
image thumbnail

Rainflow Counting Algorithm

by Adam Nieslony

 

17 Feb 2003 (Updated 04 Apr 2010)

Very fast rainflow cycle counting for MATLAB

| Watch this File

File Information
Description

The rainflow algorithm code has been prepared according to the ASTM standard (Standard practices for cycle counting in fatigue analysis) and optimized considering the calculation time.

MATLAB release MATLAB 7.1.0 (R14SP3)
Other requirements The package includes MEX files for Win32 and Win64. For other OS the source code should be compiled.
Tags for This File  
Everyone's Tags
Tags I've Applied
Add New Tags Please login to tag files.
Comments and Ratings (81)
16 Jul 2003 Yu Sang Hui

This is the program that I want to find

24 Jul 2003 marc zbo

helemaal top. Mijn dag is gelijk goed

24 Jul 2003 Zbo Amigo

Lang naar gezocht, maar nu heb ik het dankzij ZBO!

29 Jan 2004 Jim Kay

Program works well; does not produce histograms, you need to extract these yourself (watch out for half-cylcles).
Checked against "Simple rainflow counting algorithms" (1 pass methdo), Downing and Socie; got the same results.

15 Apr 2004 reshu shukla

i want to know that the information about the counting method

01 Jun 2004 abdelkader miloudi  
01 Dec 2004 Steve Grobler

Found teh demo quite informative. Would be helpful if the rainflow results could be arranged in a matrix of cycle counts, with the rows representing the mean, and the columns representing the ranges. Also be helpful if the "leftover" 1/2 cycles could be combined into full cycles and included in the matrix.

19 Dec 2004 muh alat  
14 Jan 2005 Ole Dossing

This is a very fine application, not to mention the latest additions. We have used the the rainflow in a stay bridge for fatigue monitoring on critical structures.

14 Mar 2005 aid abdelkrim

- the version matlab does not go
- I need the module mex.h
 
 

08 Sep 2005 Tomasz Bednarek  
21 Sep 2005 BB shine

This program is perfect to me... thanks..

24 Nov 2005 hh hh  
26 Nov 2005 matt matt

Once the entry vector is too large, it doesn't work. Who can help me?

24 Jan 2006 Joe Quinn

Dr. Nieslony has developed a Rainflow counting application which we used to validate our impemtation of the ASME standard.
Once you know that his cycle size is peak and not peak to peak you can adjust (X2) and then it worked 100%.
Bins boundaries are based on the midpoint between succesive bin midpoints. This caused some juggling to match our method which specifies bin edge directly.
Otherwise, it was accuarate and easy to modify for graphing and printouts.

I am certain that had I been able to read it the Polish comments would have further added to my understanding of the code.

25 Jan 2006 Sarah Hughes

Functionally this program is excellent, and produces results that are consistent with the ASTM standard. As with other users, it took me a while to realise that amplitude means amplitude and not range, but that's my fault for not reading it properly. I would appreciate some more explanation of the meaning of the half-cycles which I haven't encountered in other software, as I'm not sure how best to process these.

10 May 2006 Vikas Gupta

This is very best in lot of applications.

10 Jul 2006 Andy Stevenson

This is an excellent tool. I made a couple of short example problems to understand the output and once I did that I'm using the program at work. The rfdemo2 code is especially cool for showing others how rainflow counting works.

14 Sep 2006 gov raj

good approach

15 Dec 2006 Matthew Hoehler

A very useful tool! It is fast, robust and did just what I needed; no more, no less.

28 Jan 2007 rafiq zulkiffli

need to show the soft code

01 Feb 2007 Adam Nieslony

Hi Rafiq Zulkiffli,

Some years ago I wrote the rainflow function in MATLAB Script (m-file). Unfortunately the function worked very, very slow, because many iterations in the rainflow algorithm appears. So, I decide to create mex function where the time consuming iterations realized faster. Be sure, with ?the soft code? you cant count the cycles in sensible time. Look on the ?rainflow.c? file and try to understand the C code lines.

Best regards, Adam Nieslony

05 Feb 2007 muhd rafiq zulkiffli

show the code for rain flow cycle counting

14 Mar 2007 Muhd rafiq

thanks for the advice..but im still got problem coding in Matlab, because i cannot get the peak and valley reversal first..my data length is 32000 and sampling frequency is 200...can u give me some idea...
 

21 Mar 2007 rafiq zulkiffli

hello,
i have 1 nonlinear equation with 2 unknowns, can u give the example solution using matlab??..this is my equation is
(0.003005*Nf^-0.072)+(0.8419*Nf^-0.56654)-((6.571*10^-7)*0.5)=0

31 May 2007 Kerim Genc

Excellent code, very useful. I validated and understood it through trials with small data sets before moving onto huge force-time curves. Make sure that you understand that amplitude is in terms of a sinusoid, therefore the magnitude of the peaks are actually twice the amplitude indicated. Also, Half cycles can be a bit confusing at first, since this is not a "closed loop" rainflow counting method, you just have to combine the half cycles.

01 Aug 2007 Carmem Miranda

I am taking Master course in Brazil. My research is on fatigue. I have difficulties to understand the input data for your program “Rainflow Couting Method”. I need a tutorial to the program and/or an input file example. Can you help me?
Thanks for attention

11 Aug 2007 arif fahruddin

I'm master student, my thesis about fatigue in variable amplitude, random loaing. Have you a solution. Thank You

11 Sep 2007 Achalesh Pandey  
19 Sep 2007 David Outcalt

Do you have a commented version of the C code? I find it difficult to follow.

27 Oct 2007 Jenyi Liao  
04 Nov 2007 nasri mohamed

methode de rainflow par matlab

11 Dec 2007 Philips Adewuyi

I have been looking for materials that treat the subject of rainflow counting methods for fatigue analysis of structures.

07 Jan 2008 aid Abdelkrim  
08 Apr 2008 syna gupt

I used this toolbox but the result seems not correct....

18 Jun 2008 SENTHILKUMAR C.R  
09 Jul 2008 Félix DORE  
04 Aug 2008 Craig Chang

great tool. Detail doc, easy to use. Excelent.

12 Sep 2008 santosh a  
19 Sep 2008 Filip R

Hello
Does anyone know how to get output data from rfdemo1? Because i noticed that rainflow.m is not accurate with larger amount of data. Thank you

02 Dec 2008 Elena Menéndez

Hello

I have noticed one important difference in the rainflow when compared with the rutine used by the software Bladed. The latter always assigns one full cycle to the range (max-min) of the timeseries. However, your rutine assigns 0.5 cycles to this range. Which one is more accurate?
Thank you

30 Apr 2009 ap1le q

very good

18 Oct 2009 Andreas

I can't get this working. I try the rfdemo1 using the syntax found in the rfdemo1.m, f.ex.
rfdemo1([2 3 2 4 2 5 1 6])

My error output is
>> rfdemo1([2 3 2 4 2 5 1 6])
??? Attempt to execute SCRIPT rainflow as a function:
C:\Users\Andreas\Documents\MATLAB\Rainflow cycle counting\rainflow.m

Error in ==> rfdemo1 at 35
a=rainflow(ext,1);
 
>>

Anyone know why?

18 Oct 2009 Andreas

I found out that my first error came from a conflict caused by a similar filename and function name (Rainflow.m/rainflow) But now my error is:
??? Undefined function or method 'rainflow' for input arguments of type
'double'.

Error in ==> testinterpolasjon at 19
rf = rainflow(ext,exttime);

I'm running Matlab release 2009a

05 Nov 2009 S_Sampathkumar Sampathkumar

On Elena Menéndez's question above, is there an answer. I am finding that amplitude is half the range as well in this method.? Anyone knows why?

"I have noticed one important difference in the rainflow when compared with the rutine used by the software Bladed. The latter always assigns one full cycle to the range (max-min) of the timeseries. However, your rutine assigns 0.5 cycles to this range. Which one is more accurate? "
 

11 Nov 2009 Jinsuk Lee

I have temperature data over time and derive a fatigue model. Using this rainflow counting, I want to get data with three parameters, which are Max_termperature, each cycle time, amplitude (max-min). Is anyone knowing if this package can provide this kind of data? I appreciate.

22 Dec 2009 Ray Beale

Sampathkumar- Amplitude is always half the range, by definition.

I am finding many half-cycles in my rfc output of a long time history. Another method I've used produces full cycles. When comparing the two methods for the same time history, the histograms have the exact same shape but your method is shifted to the right due to the unpaired half cycles. Both claim to be ASTM standard. Any idea why?

27 Jan 2010 Claudio Pedrazzi

First of all, let me compliment for this excellent piece of software!!

The ASTM standard E 1049 -85 (2005) defines two distinct rainflow algorithms:
A) 5.4.4 "Rainflow counting" (that produces half-cycles)
B) 5.4.5 "Simplified rainflow counting for repeating histories" (that never produces half-cycles)

this is probably the answer to questions like the one of Ray Beale. Now I am interested in the "B" method, and I am asking the author: which algorithm is implemented here? my guess is the "A" method, with half cycles.
Second question: is there some hope to extend this function to be able to compute, optionalyy, also the B way?
If necessary I would be glad to provide more info (namely the text of the ASTM standard).
Best regards and thaks a lot for sharing!
Claudio

27 Feb 2010 Badrinath Veluri

It is very good work

28 Apr 2010 Ahmed Farag

I have a problem running the rfdemo1 file , i got this error message
?? Attempt to execute SCRIPT rainflow as a function.

Error in ==> rfdemo1 at 35
a=rainflow(ext,1);

Any solution for that

30 Apr 2010 Ahmed Farag

Thanks Adam for your effort and you response to my enquiry, i really appreciate such an awesome routine

30 Apr 2010 Ahmed Farag  
05 Jul 2010 massimo

how to import data in rfdemo2?
Lesson 2 from the html guide works, but what is the syntaz for
s=my_signal
Great work

05 Sep 2010 upna fruit

Hi everone,
I'm working on fatigue testing and I'm using the rainflow algorithm with long and quite complex signals.
reading thought rfdemo2 I've noticed that the function
sig2ext is called twice. Is that necesary?
I will be gratefull of any help

21 Sep 2010 upna fruit

Hi everyone,
First of all, thanks for your quick response in the previous comment I made. I'va keep on working on fatigue testing and I've found another problem.
I am analysing some test data with this algorithm but another research center is analysing the same data and they are reaching diferent results. They are using the algorithm of Downing and Socie "Simplified Rainflow Counting method".
Is it normal that we obtain different results because of that?

Thanks in advance

09 Oct 2010 Scott Richardson

Hello, my question is regarding the example provided. It's an example, I realize, but I need to know if we're talking about the same thing because it's SO different from what I am used to seeing.

Namely, the slope used is 'm=8', and I am used to seeing slopes for steel of like -0.07. so that makes no sense.

Can someone please provide some clarification of what is meant there.

Thank you.

10 Oct 2010 Adam Nieslony

According message from Scott Richardson, 09 Oct 2010.

There are more than one equation for stress-life characteristics. Probably you are working with the Basquin model:

    Sa=Sf*(2*Nf)^b

where b is understood as the curve slope. In my example the Wohler model is used. It is possible, with some restriction, compute the 'm' slope on the basis of Basquin model:

    m=-1/b

But remember that the first step is clarifying which kind of curve you are using. The Miner rule n/N=1 is used anyway.

Best regards, Adam Niesłony

10 Oct 2010 Scott Richardson

Thank you very much Mr. Nieslony.

12 Oct 2010 Scott Richardson

Might someone have a data set, with a known answer, to be able to run and understand clearly what the concerns cited above are. Or at least to help understand the nature of what has some concerned about. I want to be sure to not misunderstand something and I don't have data that can help me get to that point. Thanks very much in advance.

18 Nov 2010 Andrew Greaser

Hello, My question is, how is it determined in the rainflow algorithm what stress ranges and cycle counts are put into each bin to create a rainflow histogram?

18 Nov 2010 Adam Nieslony

Hi Andrew Greaser,
The RFHIST counts cycle amplitudes and not ranges. You can also make an histogram for cycles mean, frequency and period. See help lines included in RFHIST function.

18 Nov 2010 Andrew Greaser

Thanks Adam,
I didn't phrase my question correctly, I understand the RFHIST counts cycle amplitudes and not stress ranges now, but what I am trying to figure out is if my rainflow function outputs - rf(3,:) Number of cycles (0.5 or 1.0) and my RFHIST syntax is [no,xo]=rfhist(rf,30) how does the program determine the bin locations or is rf evenly distributed over 30 bins or are the bin locations associated with the number of extracted cycles? Can you please elaborate on this.

Thanks

24 Nov 2010 Chris McCorquodale

Hi,
I am quite new to matlab but can anyone tell me if this algorithm can give an output of number of cycles to failure? I am interested to know when a component (modelled in FEA) is going to fail.

Regards,
Chris

26 Nov 2010 Dilip Rao  
26 Nov 2010 Dilip Rao

I would like to know if I have a lot of rainflow matrices,how do I add them.
ex. I have data from 3 axes of a sensor and from 3 sensors and I just need one rainflow matrix for all this data.The data for each axis and each sensor is huge.so I would like to know how do I get just one rainflow matrix for all the data?

26 Nov 2010 Adam Nieslony

Hi Dilip Rao,
You can add the matrices without problems if they have the same size: m=m1+m2+m3. I don't know what you need exactly to do, but be careful while adding matrices from different sensors - maybe you have multiaxial fatigue problem? I this case use some theoretical criteria for obtaining equivalent uniaxial fatigue loading/matrix.

26 Nov 2010 Dilip Rao

HI Adam,
The problem is the matrices are of different sizes and are really huge.Like I have 5 test cycles and x axis data from each cycle of different durations.I cannot add all the cycles as it is huge amount of data,so now can you suggest me how do I take a rainflow of all the cycles combined in one result?

13 Jan 2011 Dilip Rao

Thank you Adam.I did add the rainflow matrices from every axis separately.

31 Jan 2011 Ahmed

Hi,
 I downloaded the files and tried to run some numbers.
My input was [4 12 7 14 -5 4 -9 7 -1 16].
According to the rainflow method I am familiar with, I expected to get somthing similar to
[4 14 7 12 -5 4 -7 16 -1 7].
Instead, I got the matrix rf with Mean, Amp. , Half/full cycle, begining time and cycle period.

My question is, is it possible to get the result I expected,
i.e. [4 14 7 12 -5 4 -7 16 -1 7].

Thanks in advance,
Ahmed

23 Feb 2011 Shashank Chauhan

Dear Adam

I am getting the problem as some have previously posted.

?? Attempt to execute SCRIPT rainflow as a function.

Error in ==> rfdemo1 at 35
a=rainflow(ext,1);

Can you suggest how should I overcome this.

Thanks

Shashank

07 Mar 2011 Benjamin

First of all, thanks for sharing this awesome tool!

I have a similar problem on my linux pc running Matlab R201b:
??? Attempt to execute SCRIPT rainflow as a function:

Any help on that? :)

Ben

10 Mar 2011 Ramon

Dear Adam

I have the same issue of Shashank (23Feb2011). And seems that rfdemo1 calls to rainflow.m that is the description.

Furthermore folloing the instructions I cannot check a simple input like b in the example below. I cannot run the rainflow. I'm not skilled yet on matlab maybe I miss something. Please could orientate us a little bit? thanks
>> rfdemo1
??? Attempt to execute SCRIPT rainflow as a function.

Error in ==> rfdemo1 at 35
a=rainflow(ext,1);

>> b

b =

    -2 1 -3 5 -1 3 -4 4 -2

>> rf=rainflow(b)
??? Attempt to execute SCRIPT rainflow as a function.

>>

I'm using matlab V7.0.1.24704 R14

10 Mar 2011 Shashank Chauhan

I got it working.

The idea lies in renaming the rainflow.m to rainflow_1.m or any other name. The demo script rfdemo1 then executes the rainflow.mex which is what is intended.

27 Apr 2011 Ramon

Dear Adam,

at the end works fine. I didn't read properly the help file to compile the Mex funtion to get the rainflow.dll. So for everyone that may have the same problem please read the help carefully.

I made some checks with my working current signals and works fine. It helps a lot to my work thank you very much for sharing it.

Best regards
Ramón

14 Jun 2011 pietro

This function is great, the only bad point is the lack of a message, when overflow or underflow occour

Best regards

Pietro

08 Nov 2011 Abhishek Modi

dear Adam,
I have a small question. I am currently working on a suspension model made in solidworks and i have translated it to simmechanics.i need to calculate the amount of fatigue present .i have been given a load cycle vs time and want to implement it .How can i do it here?

28 Nov 2011 kai

dear Adam
thank you for your sharing, and there is a question that how can I get the "cycle_begin_time, cycle_period_time" in the "rainflow.c". And how can I make a 'rfhist' input, the format of 'rfhist'.

10 Jan 2012 JAEWOO PARK

dear Adam,

hi~ I started to study MATLAB just before. I got a problem that I can't input a data to your algorithm. Can you give me an example with inputing some numbers?

Thank you

Jay Park

10 Jan 2012 JAEWOO PARK

Fanally, I found it.

10 Jan 2012 JAEWOO PARK

it was wrong......

17 Jan 2012 JAEWOO PARK

Dear Adam,

Thank you for your advice, I got the results I wanted from rfdemo1. But I don't know how to get similar results like 'amplitude, mean, number of cycles (cycle or half cycle), begin time of extracted cycle or half cycle, period of a cycle' using rfdemo2. I need to input a lot of data and get the results like list in rfdemo1 using input data like vibrations. Thank you a lot.

Best regards

Jay Park

Please login to add a comment or rating.
Updates
24 Oct 2003

I add new functions: rfhist and rfmatrix.

12 Nov 2009

Revised for use with latest version of MATLAB.

04 Apr 2010

Added support for Win64.

Tag Activity for this File
Tag Applied By Date/Time
turning points Adam Nieslony 16 Nov 2009 09:56:40
fatigue Adam Nieslony 16 Nov 2009 09:56:41
rain flow Adam Nieslony 16 Nov 2009 09:56:41
rainflow Adam Nieslony 16 Nov 2009 09:56:41
turning points Badrinath Veluri 25 Feb 2010 07:18:22
rainflow Badrinath Veluri 25 Feb 2010 07:18:26
rain flow Badrinath Veluri 25 Feb 2010 07:18:30
fatigue Badrinath Veluri 25 Feb 2010 07:18:33
fatigue Sylvain MIOT 05 Aug 2010 09:37:57
fatigue Yaxin Song 08 Sep 2010 13:35:40
rainflow Chad Stillinger 19 Jan 2011 16:16:53
fatigue Amir Sharifi 11 Mar 2011 20:03:22
fatigue BEAUM 17 May 2011 03:55:18
fatigue Yu 06 Jun 2011 16:47:25
fatigue zhao xuemei 21 Jun 2011 10:08:04
rainflow zhao xuemei 21 Jun 2011 10:08:22
fatigue Mihaela Eliza 28 Jun 2011 10:59:42
rainflow for linux Yohannes Hailu 29 Jun 2011 05:32:47
fatigue Nagaraj 19 Jul 2011 04:12:20
rain flow A.J. Geissler 09 Sep 2011 07:30:45
rainflow Alberto 21 Sep 2011 10:21:30
rain flow Felipe 30 Sep 2011 19:51:28
fatigue Sreten Simovic 06 Oct 2011 04:14:31
fatigue Sebastian 21 Oct 2011 08:25:50
fatigue Roland Franz 10 Nov 2011 10:14:14
fatigue Pavan 24 Nov 2011 03:08:14
rain flow Mihaela Eliza 25 Nov 2011 04:51:46
rain flow Jimmy Sun 04 Dec 2011 22:48:58
fatige wu 05 Dec 2011 00:32:53
fatigue Haining zheng 05 Feb 2012 23:29:33

Contact us at files@mathworks.com