|
| 1 | +# -*- coding: utf-8 -*- |
| 2 | +""" |
| 3 | +Implementation of the racetrack amplitude filter. The implementation is |
| 4 | +based on the following resources: |
| 5 | +
|
| 6 | + `H. O. Fuchs et al. Shortcuts in cumulative damage analysis. |
| 7 | + SAE Automobile engineering meeting paper 730565. (1973)` |
| 8 | +
|
| 9 | + `H. Wu et. al. Validation of the multiaxial racetrack amplitude filter. |
| 10 | + International Journal of Fatigue, 87 (2016) 167–179` |
| 11 | +
|
| 12 | +""" |
| 13 | +from __future__ import (division, print_function, absolute_import, |
| 14 | + unicode_literals) |
| 15 | +import numpy as np |
| 16 | +from math import fabs |
| 17 | +from .rainflow import find_reversals |
| 18 | + |
| 19 | +__all__ = ["racetrack_filter", "find_reversals_racetrack_filtered"] |
| 20 | + |
| 21 | + |
| 22 | +def racetrack_filter(reversals, h): |
| 23 | + """Racetrack filter for accelerated fatigue testing. |
| 24 | +
|
| 25 | + The racetrack amplitude filter removes low amplitude cycles from the |
| 26 | + reversals without altering the sequence of the remaining cycles. The |
| 27 | + racetrack filter therefore allows to accelerate variable amplitude |
| 28 | + fatigue testing by removing low amplitude cycles which does not |
| 29 | + significantly affect the overall fatigue damage and at the same time |
| 30 | + preserves sequence effects inherent in the original sequence. |
| 31 | +
|
| 32 | + Arguments |
| 33 | + --------- |
| 34 | + reversals : ndarray |
| 35 | + An 1D-array of reversals. |
| 36 | + h : float |
| 37 | + Racetrack width, cycles with range lower than width are filtered out. |
| 38 | +
|
| 39 | + Returns |
| 40 | + ------- |
| 41 | + signal : ndarray |
| 42 | + Signal after applying racetrack filter. |
| 43 | + indices : ndarray |
| 44 | + Indices of racetrack filtered signal. |
| 45 | + """ |
| 46 | + y = reversals |
| 47 | + yprev = None |
| 48 | + ix = [] |
| 49 | + for n, yn in enumerate(y): |
| 50 | + if (n == 0) or (n == y.size-1): |
| 51 | + yprev = yn |
| 52 | + ix.append(n) |
| 53 | + continue |
| 54 | + dy = yn - yprev |
| 55 | + if fabs(dy) > h / 2.: |
| 56 | + yprev = yn - dy/fabs(dy) * h/2. |
| 57 | + ix.append(n) |
| 58 | + ix = np.array(ix, dtype=np.int) |
| 59 | + return y[ix], ix |
| 60 | + |
| 61 | + |
| 62 | +def find_reversals_racetrack_filtered(y, h, k=64): |
| 63 | + """Return reversals (peaks and valleys) and indices of reversals in `y`. |
| 64 | +
|
| 65 | + The data points in the dataseries `y` are classified into `k` constant |
| 66 | + sized intervals and then peak-valley filtered to yield the successive |
| 67 | + extremas of the dataseries `y`. The reversals are then filtered with the |
| 68 | + racetrack amplitude filter and then peak-valley filtered again to find |
| 69 | + the racetrack filtered reversals. |
| 70 | +
|
| 71 | + Arguments |
| 72 | + --------- |
| 73 | + y : ndarray |
| 74 | + Dataseries containing the signal to find the reversals for. |
| 75 | + h : float |
| 76 | + Racetrack width, cycles with range lower than width are filtered out. |
| 77 | + k : int |
| 78 | + The number of intervals to divide the min-max range of the dataseries |
| 79 | + into. |
| 80 | +
|
| 81 | + Returns |
| 82 | + ------- |
| 83 | + reversals : ndarray |
| 84 | + Reversals of the initial data series `y` after racetrack filtering. |
| 85 | + indices : ndarray |
| 86 | + The indices of the initial data series `y` which corresponds to the |
| 87 | + reversals. |
| 88 | + """ |
| 89 | + _, ix = find_reversals(y, k=k) |
| 90 | + z, ixz = racetrack_filter(y[ix], h) |
| 91 | + ix = ix[ixz] |
| 92 | + rev, ixr = find_reversals(z, k=k) |
| 93 | + return y[ix[ixr]], ix[ixr] |
0 commit comments