Skip to content

Commit

Permalink
Apply suggestion
Browse files Browse the repository at this point in the history
Co-authored-by: Johannes Mueller <[email protected]>
  • Loading branch information
maierbn and johannes-mueller authored Oct 13, 2023
1 parent adb698b commit a63efaf
Showing 1 changed file with 17 additions and 15 deletions.
32 changes: 17 additions & 15 deletions src/pylife/stress/rainflow/fkm_nonlinear.py
Original file line number Diff line number Diff line change
Expand Up @@ -980,23 +980,25 @@ def _split_primary_parts(self, previous_point):
self._hcm_point_history = []

for (type, hcm_point, hysteresis_index) in old_hcm_point_history:
if type == "primary":
if previous_point.stress < 0 and hcm_point.stress > 0:
intermediate_point = FKMNonlinearDetector._HCM_Point(strain=largest_abs_strain, stress=largest_abs_stress_seen)
self._hcm_point_history.append(("secondary", intermediate_point, hysteresis_index))
self._hcm_point_history.append(("primary", hcm_point, hysteresis_index))

elif previous_point.stress > 0 and hcm_point.stress < 0:
intermediate_point = FKMNonlinearDetector._HCM_Point(strain=-largest_abs_strain, stress=-largest_abs_stress_seen)
self._hcm_point_history.append(("secondary", intermediate_point, hysteresis_index))
self._hcm_point_history.append(("primary", hcm_point, hysteresis_index))
else:
self._hcm_point_history.append((type, hcm_point, hysteresis_index))
if type != "primary":
self._hcm_point_history.append((type, hcm_point, hysteresis_index))
previous_point = hcm_point
continue

if abs(hcm_point.stress) > largest_abs_stress_seen:
largest_abs_stress_seen = abs(hcm_point.stress)
largest_abs_strain = abs(hcm_point.strain)
if previous_point.stress * hcm_point.stress < 0:
sign = np.sign(hcm_point.stress)
intermediate_point = FKMNonlinearDetector._HCM_Point(
strain=sign*largest_abs_strain, stress=sign*largest_abs_stress_seen
)
self._hcm_point_history.append(("secondary", intermediate_point, hysteresis_index))
self._hcm_point_history.append(("primary", hcm_point, hysteresis_index))
else:
self._hcm_point_history.append((type, hcm_point, hysteresis_index))

if abs(hcm_point.stress) > largest_abs_stress_seen:
largest_abs_stress_seen = abs(hcm_point.stress)
largest_abs_strain = abs(hcm_point.strain)

previous_point = hcm_point


0 comments on commit a63efaf

Please sign in to comment.