Skip to content

Commit 0074821

Browse files
Merge pull request #141 from boschresearch/140-missing-unit-tests-for-notch-approximation-methods
140 missing unit tests for notch approximation methods
2 parents f21304d + e19ab28 commit 0074821

File tree

2 files changed

+70
-0
lines changed

2 files changed

+70
-0
lines changed

tests/materiallaws/test_notch_approximation_law.py

+23
Original file line numberDiff line numberDiff line change
@@ -170,3 +170,26 @@ def test_derivatives(stress, load):
170170
derivative = notch_approximation_law._d_stress_secondary_implicit(stress, load)
171171

172172
assert np.isclose(numeric_derivative, derivative)
173+
174+
@pytest.mark.parametrize('E, K, n, L', [
175+
(260e3, 1184, 0.187, pd.Series([100, -200, 100, -250, 200, 100, 200, -200])),
176+
(100e3, 1500, 0.4, pd.Series([-100, 100, -200])),
177+
(200e3, 1000, 0.2, pd.Series([100, 10])),
178+
])
179+
def test_load(E, K, n, L):
180+
c = 1.4
181+
gamma_L = (250+6.6)/250
182+
L = c * gamma_L * L
183+
184+
# initialize notch approximation law and damage parameter
185+
notch_approximation_law = ExtendedNeuber(E, K, n, K_p=3.5)
186+
187+
# The "load" method is the inverse operation of "stress",
188+
# i.e., ``L = load(stress(L))`` and ``S = stress(load(stress))``.
189+
stress = notch_approximation_law.stress(L)
190+
load = notch_approximation_law.load(stress)
191+
stress2 = notch_approximation_law.stress(load)
192+
193+
np.testing.assert_allclose(L, load, rtol=1e-3)
194+
np.testing.assert_allclose(stress, stress2, rtol=1e-3)
195+

tests/materiallaws/test_notch_approximation_law_seegerbeste.py

+47
Original file line numberDiff line numberDiff line change
@@ -162,3 +162,50 @@ def test_derivatives(stress, load):
162162

163163
assert np.isclose(numeric_derivative, derivative.values[0])
164164

165+
166+
@pytest.mark.parametrize('E, K, n, L', [
167+
(260e3, 1184, 0.187, pd.Series([100, -200, 100, -250, 200, 100, 200, -200])),
168+
(100e3, 1500, 0.4, pd.Series([-100, 100, -200])),
169+
(200e3, 1000, 0.2, pd.Series([100, 10])),
170+
])
171+
def test_seeger_beste_load(E, K, n, L):
172+
c = 1.4
173+
gamma_L = (250+6.6)/250
174+
L = c * gamma_L * L
175+
176+
# initialize notch approximation law and damage parameter
177+
notch_approximation_law = SeegerBeste(E, K, n, K_p=3.5)
178+
179+
# The "load" method is the inverse operation of "stress",
180+
# i.e., ``L = load(stress(L))`` and ``S = stress(load(stress))``.
181+
stress = notch_approximation_law.stress(L)
182+
load = notch_approximation_law.load(stress)
183+
stress2 = notch_approximation_law.stress(load)
184+
185+
np.testing.assert_allclose(L, load, rtol=1e-3)
186+
np.testing.assert_allclose(stress, stress2, rtol=1e-3)
187+
188+
189+
190+
@pytest.mark.parametrize('E, K, n, L', [
191+
(260e3, 1184, 0.187, pd.Series([100, -200, 100, -250, 200, 100, 200, -200])),
192+
(100e3, 1500, 0.4, pd.Series([-100, 100, -200])),
193+
(200e3, 1000, 0.2, pd.Series([100, 10])),
194+
])
195+
def test_seeger_beste_load_secondary_branch(E, K, n, L):
196+
c = 1.4
197+
gamma_L = (250+6.6)/250
198+
L = c * gamma_L * L
199+
200+
# initialize notch approximation law and damage parameter
201+
notch_approximation_law = SeegerBeste(E, K, n, K_p=3.5)
202+
203+
# The "load" method is the inverse operation of "stress",
204+
# i.e., ``L = load(stress(L))`` and ``S = stress(load(stress))``.
205+
stress = notch_approximation_law.stress_secondary_branch(L)
206+
load = notch_approximation_law.load_secondary_branch(stress)
207+
stress2 = notch_approximation_law.stress_secondary_branch(load)
208+
209+
np.testing.assert_allclose(L, load, rtol=1e-3)
210+
np.testing.assert_allclose(stress, stress2, rtol=1e-3)
211+

0 commit comments

Comments
 (0)