|
31 | 31 | __all__ = ['rainflow_astm', 'rainflow_windap','eq_load','eq_load_and_cycles','cycle_matrix','cycle_matrix2'] |
32 | 32 |
|
33 | 33 |
|
34 | | -def equivalent_load(signal, m=3, Teq=1, nBins=46, method='rainflow_windap'): |
| 34 | +def equivalent_load(time, signal, m=3, Teq=1, nBins=100, method='rainflow_windap'): |
35 | 35 | """Equivalent load calculation |
36 | 36 |
|
37 | 37 | Calculate the equivalent loads for a list of Wohler exponent |
38 | 38 |
|
39 | 39 | Parameters |
40 | 40 | ---------- |
41 | | - signals : array-like, the signal |
| 41 | + time : array-like, the time values corresponding to the signal (s) |
| 42 | + signals : array-like, the load signal |
42 | 43 | m : Wohler exponent (default is 3) |
43 | | - Teq : The equivalent number of load cycles (default is 1, but normally the time duration in seconds is used) |
| 44 | + Teq : The equivalent period (Default 1Hz) |
44 | 45 | nBins : Number of bins in rainflow count histogram |
45 | 46 | method: 'rainflow_windap, rainflow_astm, fatpack |
46 | 47 |
|
47 | 48 | Returns |
48 | 49 | ------- |
49 | 50 | Leq : the equivalent load for given m and Tea |
50 | 51 | """ |
| 52 | + time = np.asarray(time) |
51 | 53 | signal = np.asarray(signal) |
| 54 | + T = time[-1]-time[0] # time length of signal (s) |
| 55 | + neq = T/Teq # number of equivalent periods |
52 | 56 |
|
53 | 57 | rainflow_func_dict = {'rainflow_windap':rainflow_windap, 'rainflow_astm':rainflow_astm} |
54 | 58 | if method in rainflow_func_dict.keys(): |
55 | 59 | # Call wetb function for one m |
56 | | - Leq = eq_load(signal, m=[m], neq=Teq, no_bins=nBins, rainflow_func=rainflow_func_dict[method])[0][0] |
| 60 | + Leq = eq_load(signal, m=[m], neq=neq, no_bins=nBins, rainflow_func=rainflow_func_dict[method])[0][0] |
57 | 61 |
|
58 | 62 | elif method=='fatpack': |
59 | 63 | import fatpack |
60 | 64 | # find rainflow ranges |
61 | | - ranges = fatpack.find_rainflow_ranges(signal) |
| 65 | + try: |
| 66 | + ranges = fatpack.find_rainflow_ranges(signal) |
| 67 | + except IndexError: |
| 68 | + # Currently fails for constant signal |
| 69 | + return np.nan |
62 | 70 | # find range count and bin |
63 | 71 | Nrf, Srf = fatpack.find_range_count(ranges, nBins) |
64 | | - # get DEL |
65 | | - DELs = Srf**m * Nrf / Teq |
| 72 | + # get DEL |
| 73 | + DELs = Srf**m * Nrf / neq |
66 | 74 | Leq = DELs.sum() ** (1/m) |
67 | 75 |
|
68 | 76 | else: |
|
0 commit comments