Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

100 consider highest pure runout level #109

Merged
merged 2 commits into from
Oct 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading