Skip to content
This repository was archived by the owner on Nov 27, 2023. It is now read-only.

Commit 7d69fe2

Browse files
committed
Fatigue: update of interface for equivalent_load function
1 parent e71a43a commit 7d69fe2

File tree

2 files changed

+18
-11
lines changed

2 files changed

+18
-11
lines changed

pyFAST/postpro/examples/Example_EquivalentLoad.py

+3-4
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,10 @@
1818

1919

2020
# Compute equivalent load for one signal and Wohler slope
21-
T = df['Time_[s]'].values[-1] # number of 1Hz load cycles (time series length in second)
22-
m = 10 # Wohler slope
23-
Leq = equivalent_load(df['RootMyc1_[kN-m]'], Teq=T, m=1)
21+
m = 1 # Wohler slope
22+
Leq = equivalent_load(df['Time_[s]'], df['RootMyc1_[kN-m]'], m=m)
2423
print('Leq ',Leq)
25-
# Leq = equivalent_load(df['RootMyc1_[kN-m]'], Teq=T, m=1, method='fatpack') # requires package fatpack
24+
# Leq = equivalent_load(df['Time_[s]'], df['RootMyc1_[kN-m]'], m=m, method='fatpack') # requires package fatpack
2625

2726

2827
if __name__ == '__main__':

pyFAST/tools/fatigue.py

+15-7
Original file line numberDiff line numberDiff line change
@@ -31,38 +31,46 @@
3131
__all__ = ['rainflow_astm', 'rainflow_windap','eq_load','eq_load_and_cycles','cycle_matrix','cycle_matrix2']
3232

3333

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'):
3535
"""Equivalent load calculation
3636
3737
Calculate the equivalent loads for a list of Wohler exponent
3838
3939
Parameters
4040
----------
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
4243
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)
4445
nBins : Number of bins in rainflow count histogram
4546
method: 'rainflow_windap, rainflow_astm, fatpack
4647
4748
Returns
4849
-------
4950
Leq : the equivalent load for given m and Tea
5051
"""
52+
time = np.asarray(time)
5153
signal = np.asarray(signal)
54+
T = time[-1]-time[0] # time length of signal (s)
55+
neq = T/Teq # number of equivalent periods
5256

5357
rainflow_func_dict = {'rainflow_windap':rainflow_windap, 'rainflow_astm':rainflow_astm}
5458
if method in rainflow_func_dict.keys():
5559
# 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]
5761

5862
elif method=='fatpack':
5963
import fatpack
6064
# 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
6270
# find range count and bin
6371
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
6674
Leq = DELs.sum() ** (1/m)
6775

6876
else:

0 commit comments

Comments
 (0)