Skip to content

Commit

Permalink
Add function to use only highest pure runout level for analysis
Browse files Browse the repository at this point in the history
Signed-off-by: Dominic Olveda <Dominic.Olveda@de.bosch.com>
  • Loading branch information
old2rng committed Sep 27, 2024
1 parent cf03f46 commit ae8145e
Show file tree
Hide file tree
Showing 3 changed files with 63 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/pylife/materialdata/woehler/elementary.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@ def _get_fatigue_data(self, fatigue_data):
params = fatigue_data
else:
raise ValueError("fatigue_data of type {} not understood: {}".format(type(fatigue_data), fatigue_data))
params = params.irrelevant_runouts_dropped()

return params

def analyze(self, **kwargs):
Expand Down
21 changes: 21 additions & 0 deletions src/pylife/materialdata/woehler/fatigue_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,10 @@ def non_fractured_loads(self):
def mixed_loads(self):
return np.intersect1d(self.runout_loads, self.fractured_loads)

@property
def pure_runout_loads(self):
return np.setxor1d(self.runout_loads, self.mixed_loads)

def conservative_fatigue_limit(self):
"""
Sets a lower fatigue limit that what is expected from the algorithm given by Mustafa Kassem.
Expand Down Expand Up @@ -160,6 +164,18 @@ def set_fatigue_limit(self, fatigue_limit):

return self

def irrelevant_runouts_dropped(self):
'''Checks if data has several pure runout load levels and drops all except max pure runout level
'''
if len(self.pure_runout_loads) <= 1:
return self
if self.pure_runout_loads.max() < self.fractured_loads.min():
df = self._obj[~(self._obj.load < self.pure_runout_loads.max())]
return FatigueData(df)
else:
return self

@property
def max_runout_load(self):
return self.runouts.load.max()
Expand Down Expand Up @@ -189,6 +205,10 @@ def _calc_finite_zone_manual(self, limit):
self._infinite_zone = self._obj[self._obj.load <= limit]






def determine_fractures(df, load_cycle_limit=None):
'''Adds a fracture column according to defined load cycle limit
Expand All @@ -213,3 +233,4 @@ def determine_fractures(df, load_cycle_limit=None):
ret = df.copy()
ret['fracture'] = df.cycles < load_cycle_limit
return ret

40 changes: 40 additions & 0 deletions tests/materialdata/woehler/test_analyzer.py
Original file line number Diff line number Diff line change
Expand Up @@ -595,3 +595,43 @@ def test_max_likelihood_one_mixed_horizon():
wc = ml.analyze().sort_index()
bic = ml.bayesian_information_criterion()
pd.testing.assert_series_equal(wc, expected, rtol=1e-1)


def test_irrelevant_runouts_dropped():
fd = woehler.determine_fractures(data_pure_runout_horizon_and_mixed_horizons, 1e7).fatigue_data
num_data_before = len(fd._obj)
num_tests_lowest_pure_runout_load_level = len(fd.load[fd.load==fd.pure_runout_loads.min()])
fd = fd.irrelevant_runouts_dropped()
num_data_after = len(fd._obj)
assert num_data_before-num_tests_lowest_pure_runout_load_level == num_data_after


def test_irrelevant_runouts_dropped_no_change():
data_pure_runout_horizon_and_mixed_horizons
data_extend = data_pure_runout_horizon_and_mixed_horizons.copy(deep=True)
new_row = {'load': 2.75e+02, 'cycles': 1.00e+06}
data_extend = pd.concat([data_extend, pd.DataFrame([new_row])])#, ignore_index=True)
fd = woehler.determine_fractures(data_extend, 1e7).fatigue_data
num_data_before = len(fd._obj)
fd = fd.irrelevant_runouts_dropped()
num_data_after = len(fd._obj)
assert num_data_before == num_data_after


def test_drop_irreverent_pure_runout_levels_no_data_change():
expected = pd.Series({
'SD': 339.23834,
'TS': 1.211044,
'k_1': 9.880429,
'ND': 804501,
'TN': 6.779709,
'failure_probability': 0.5
}).sort_index()

fd = woehler.determine_fractures(data_pure_runout_horizon_and_mixed_horizons, 1e7).fatigue_data
num_data_before = len(fd._obj)
wc = woehler.Probit(fd).analyze().sort_index()
num_data_after = len(fd._obj)
pd.testing.assert_series_equal(wc, expected, rtol=1e-1)
assert num_data_before == num_data_after

0 comments on commit ae8145e

Please sign in to comment.