The rainflow
module¶
Rainflow counting¶
A module performing rainflow counting
-
class
pylife.stress.rainflow.
AbstractRainflowCounter
¶ The common base class for rainflow counters
Subclasses implementing a specific rainflow counting algorithm are supposed to implement a method
process()
that takes the signal samples as a parameter, append all the hysteresis loop limits toself._loops_from
andself.loops_to
and returnself
. Theprocess()
method is supposed to be implemented in a way, that the result is independent of the sample chunksize, sorfc.process(signal)
should be equivalent torfc.process(signal[:n]).process(signal[n:])
for any 0 < n < signal length.Todo
- write a 4 point rainflow counter
- accept the histogram binning upfront so that loop information has not to be stored explicitly. This is important to ensure that the memory consumption remains O(1) rather than O(n).
-
get_rainflow_matrix
¶ Calculates a histogram of the recorded loops
Parameters: bins (int or array_like or [int, int] or [array, array], optional) – The bin specification (see numpy.histogram2d) Returns: - H (ndarray, shape(nx, ny)) – The bi-dimensional histogram of samples (see numpy.histogram2d)
- xedges (ndarray, shape(nx+1,)) – The bin edges along the first dimension.
- yedges (ndarray, shape(ny+1,)) – The bin edges along the second dimension.
-
get_rainflow_matrix_frame
¶ Calculates a histogram of the recorded loops into a pandas.DataFrame.
An interval index is used to index the bins.
Parameters: bins (int or array_like or [int, int] or [array, array], optional) – The bin specification: see numpy.histogram2d Returns: A pandas.DataFrame using a multi interval index in order to index data point for a given from/to value pair. Return type: pandas.DataFrame
-
residuals
¶ Returns the residual turning points of the time signal so far
The residuals are the loops not (yet) closed.
-
class
pylife.stress.rainflow.
RainflowCounterFKM
¶ Implements a rainflow counter as described in FKM non linear
See the here in the demo for an example.
The algorithm has been published by Clormann & Seeger 1985 and has been cited havily since.
-
process
¶ Processes a sample chunk
Parameters: samples (array_like, shape (N, )) – The samples to be processed Returns: self – The self
object so that processing can be chainedReturn type: RainflowCounterFKM Example
>>> rfc = RainflowCounterFKM().process(samples) >>> rfc.get_rainflow_matrix_frame(128)
-
-
class
pylife.stress.rainflow.
RainflowCounterThreePoint
¶ Implements 3 point rainflow counting algorithm
See the here in the demo for an example.
We take three turning points into account to detect closed hysteresis loops.
- start: the point where the loop is starting from
- front: the turning point after the start
- back: the turning point after the front
A loop is considered closed if following conditions are met:
- the load difference between front and back is bigger than or equal the one between start and front. In other words: if the back goes beyond the starting point. For example (A-B-C) and (B-C-D) not closed, whereas (C-D-E) is.
- the loop init has not been a loop front in a prior closed loop. For example F would close the loops (D-E-F) but D is already front of the closed loop (C-D-E).
- the load level of the front has already been covered by a prior turning point. Otherwise it is considered part of the front residuum.
When a loop is closed it is possible that the loop back also closes unclosed loops of the past by acting as loop back for an unclosed start/front pair. For example E closes the loop (C-D-E) and then also (A-B-E).
Load ----------------------------- | x B F x --------/-\-----------------/----- | / \ x D / ------/-----\-/-\---------/------- | / C x \ / --\-/-------------\-----/--------- | x A \ / --------------------\-/----------- | x E ---------------------------------- | Time
-
process
¶ Processes a sample chunk
Parameters: samples (array_like, shape (N, )) – The samples to be processed Returns: self – The self
object so that processing can be chainedReturn type: RainflowCounterThreePoint Example
>>> rfc = RainflowCounterThreePoint().process(samples) >>> rfc.get_rainflow_matrix_frame(128)
-
pylife.stress.rainflow.
get_turns
¶ Finds the turning points in a sample chunk
Parameters: samples (1D numpy.ndarray) – the sample chunk Returns: - positions (1D numpy.ndarray) – the indeces where sample has a turning point
- turns (1D numpy.ndarray) – the values of the turning points