The FourPointDetector class#

class pylife.stress.rainflow.FourPointDetector(recorder=None)[source]#

Count rainflow cycles with the four-point criterion.

Use this detector for general load collectives when the four-point hysteresis criterion is appropriate. The detector reports loop start and end loads to pylife.stress.rainflow.LoopValueRecorder or, when sample indices are needed, to pylife.stress.rainflow.FullRecorder. The recorder collective can then be transformed to load amplitude, load range, mean load, and number of cycles for fatigue assessment in pylife.strength.fatigue.

Parameters:

recorder (pylife.stress.rainflow.AbstractRecorder, optional) – Recorder receiving detected loop loads in MPa. If not given, a new pylife.stress.rainflow.LoopValueRecorder is created. Use pylife.stress.rainflow.FullRecorder to store the sample indices of the two turning points in addition to the load values.

See also

pylife.stress.rainflow.ThreePointDetector

Count cycles with the classic three-point criterion.

pylife.stress.rainflow.FKMDetector

Count cycles by the classic FKM procedure.

pylife.stress.rainflow.FullRecorder

Store loop loads and sample indices.

Notes

The four-point detector evaluates four consecutive turning points \(A\), \(B\), \(C\), and \(D\). A closed loop from \(B\) to \(C\) is counted when the inner range is enclosed by both neighboring ranges:

\[|D - C| \ge |C - B| \quad \text{and} \quad |B - A| \ge |C - B|.\]

The closed loop is removed from the residual turning-point sequence and the algorithm continues with the joined path from \(A\) to \(D\). The recorded loop values are reversal loads in MPa; their peak-to-peak load range is \(L_R = |L_C - L_B|\) and their load amplitude is \(L_a = L_R / 2\).

The detector supports chunked processing. Repeated calls to process() continue the count across chunk boundaries; set flush=True only for the final chunk if the last sample shall be considered a turning point.

Examples

>>> from pylife.stress.rainflow import FourPointDetector
>>> detector = FourPointDetector()
>>> detector.process([0.0, 3.0, -1.0, 2.0, -2.0, 0.0], flush=True) is detector
True
>>> detector.recorder.collective
   from   to
0  -1.0  2.0
__init__(recorder=None)[source]#

Instantiate a four-point detector.

Parameters:

recorder (pylife.stress.rainflow.AbstractRecorder, optional) – Recorder receiving detected loop loads in MPa. The recorder must implement record_values(); recorders that also implement record_index() receive sample indices. If not given, a new pylife.stress.rainflow.LoopValueRecorder is created.

process(samples, flush=False)[source]#

Process a chunk of load samples.

Parameters:
  • samples (array_like) – Load samples in MPa. The detector extracts turning points and combines them with residual turning points from previous chunks.

  • flush (bool, optional) – Force processing of the last value as a turning point. Default is False. If False, the last value is cached for a subsequent call because only the next data point can decide whether it is a turning point. If True, the last value is processed now; a following chunk may therefore introduce two monotonic values in a row.

Returns:

The detector itself, so that repeated process() calls can be chained.

Return type:

FourPointDetector

Examples

>>> from pylife.stress.rainflow import FourPointDetector, FullRecorder
>>> detector = FourPointDetector(recorder=FullRecorder())
>>> detector.process([1.0, 2.0], flush=False).process([3.0, 1.0]).recorder.collective
Empty DataFrame
Columns: [from, to, index_from, index_to]
Index: []
>>> detector = FourPointDetector(recorder=FullRecorder())
>>> detector.process([1.0, 2.0], flush=True).process([3.0, 1.0]).recorder.collective
   from   to  index_from  index_to
0   2.0  3.0           1         2