Skip to content

Commit 94a0c8e

Browse files
Merge pull request #133 from boschresearch/128-runtimeerror-in-seegerbeste
Fix bug where SeegerBeste.stress call with scalar fails.
2 parents a3a86ac + 66be277 commit 94a0c8e

File tree

2 files changed

+17
-2
lines changed

2 files changed

+17
-2
lines changed

src/pylife/materiallaws/notch_approximation_law_seegerbeste.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ def stress(self, load, *, rtol=1e-4, tol=1e-4):
9797
# or (value, converged, zero_der) for vector-valued invocation
9898

9999
# only for multiple points at once, if some points diverged
100-
if sum(stress[1]) < len(stress[1]):
100+
if len(stress) == 3 and sum(stress[1]) < len(stress[1]):
101101
stress = self._stress_fix_not_converged_values(stress, load, x0, rtol, tol)
102102

103103
return stress[0]
@@ -209,7 +209,7 @@ def stress_secondary_branch(self, delta_load, *, rtol=1e-4, tol=1e-4):
209209
# or (value, converged, zero_der) for vector-valued invocation
210210

211211
# only for multiple points at once, if some points diverged
212-
if sum(delta_stress[1]) < len(delta_stress[1]):
212+
if len(delta_stress) == 3 and sum(delta_stress[1]) < len(delta_stress[1]):
213213
delta_stress = self._stress_secondary_fix_not_converged_values(delta_stress, delta_load, x0, rtol, tol)
214214

215215
return delta_stress[0]

tests/materiallaws/test_notch_approximation_law_seegerbeste.py

+15
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,21 @@ def test_seeger_beste_example_2():
111111
binned_notch_approximation_law._lut_secondary_branch, expected_matrix_AST_171_seeger_beste, rtol=2e-3, atol=1e-5)
112112

113113

114+
def test_seeger_beste_example_no_binning():
115+
E = 206e3 # [MPa] Young's modulus
116+
K = 1184 # [MPa]
117+
n = 0.187 # [-]
118+
K_p = 3.5 # [-] (de: Traglastformzahl) K_p = F_plastic / F_yield (3.1.1)
119+
120+
notch_approximation_law = SeegerBeste(E, K, n, K_p)
121+
122+
stress = notch_approximation_law.stress(150.0)
123+
stress_secondary_branch = notch_approximation_law.stress_secondary_branch(150.0)
124+
125+
assert np.isclose(stress, 147.1, rtol=1e-3)
126+
assert np.isclose(stress_secondary_branch, 149.8, rtol=1e-3)
127+
128+
114129
@pytest.mark.skip(reason="Derivatives not implemented at the moment, left in the code because it might be useful in the future for performance optimization with gradient-based root finding algorithms.")
115130
@pytest.mark.parametrize('stress, load', [
116131
(4, 9),

0 commit comments

Comments
 (0)