Skip to content

Commit

Permalink
Fix code format in bilinear compression law (#219)
Browse files Browse the repository at this point in the history
  • Loading branch information
mortenengen authored Feb 5, 2025
1 parent 156c59a commit c288fa0
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,9 @@ def get_stress(
# If it is a scalar
if np.isscalar(eps):
if eps > 0 or eps < self._eps_cu:
return 0
return 0
return max(self._E * eps, self._fc)

# If it is an array
sig = self._E * eps
sig[sig < self._fc] = self._fc
Expand Down
14 changes: 8 additions & 6 deletions tests/test_materials/test_constitutive_laws.py
Original file line number Diff line number Diff line change
Expand Up @@ -489,7 +489,7 @@ def test_bilinearcompression(fc, eps_c, eps_cu):
"""Test BilinearCompression material."""
law = BilinearCompression(fc=fc, eps_c=eps_c, eps_cu=eps_cu)

eps = np.linspace(-2*eps_cu, eps_c, 20)
eps = np.linspace(-2 * eps_cu, eps_c, 20)

# compute expected
E = fc / eps_c
Expand All @@ -503,23 +503,25 @@ def test_bilinearcompression(fc, eps_c, eps_cu):

# compute from BilinearCompression
sig_computed_array = law.get_stress(eps)
sig_computed_scalar = np.array([law.get_stress(eps_scalar) for eps_scalar in eps])
sig_computed_scalar = np.array(
[law.get_stress(eps_scalar) for eps_scalar in eps]
)
tan_computed_array = law.get_tangent(eps)
tan_computed_scalar = np.array([law.get_tangent(eps_scalar) for eps_scalar in eps])

tan_computed_scalar = np.array(
[law.get_tangent(eps_scalar) for eps_scalar in eps]
)

# Compare the two
assert_allclose(sig_computed_array, sig_expected)
assert_allclose(sig_computed_scalar, sig_expected)
assert_allclose(tan_computed_array, tan_expected)
assert_allclose(tan_computed_scalar, tan_expected)


# Test getting ultimate strain
eps_min, eps_max = law.get_ultimate_strain()
assert math.isclose(eps_min, -eps_cu)
assert math.isclose(eps_max, 100)

eps_min, eps_max = law.get_ultimate_strain(yielding=True)
assert math.isclose(eps_min, -eps_c)
assert math.isclose(eps_max, 100)
assert math.isclose(eps_max, 100)

0 comments on commit c288fa0

Please sign in to comment.