Skip to content

Commit

Permalink
Merge pull request #109 from boschresearch/100-consider-highest-pure-…
Browse files Browse the repository at this point in the history
…runout-level

100 consider highest pure runout level
  • Loading branch information
johannes-mueller authored Oct 1, 2024
2 parents cf03f46 + 36fc5ad commit 1d65dcc
Show file tree
Hide file tree
Showing 3 changed files with 60 additions and 1 deletion.
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
15 changes: 14 additions & 1 deletion 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,16 @@ def set_fatigue_limit(self, fatigue_limit):

return self

def irrelevant_runouts_dropped(self):
'''Make a copy of the instance with irrelevant pure runout levels dropped. '''
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 @@ -188,7 +202,6 @@ def _calc_finite_zone_manual(self, limit):
self._finite_zone = self.fractures[self.fractures.load > 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 Down
44 changes: 44 additions & 0 deletions tests/materialdata/woehler/test_analyzer.py
Original file line number Diff line number Diff line change
Expand Up @@ -595,3 +595,47 @@ 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 = 48
num_tests_lowest_pure_runout_load_level = 9
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])])
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_for_evaluation():
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
wc = woehler.Probit(fd).analyze().sort_index()
pd.testing.assert_series_equal(wc, expected, rtol=1e-1)


def test_drop_irreverent_pure_runout_levels_no_data_change():
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()
num_data_after = len(fd._obj)
assert num_data_before == num_data_after

0 comments on commit 1d65dcc

Please sign in to comment.