Skip to content

Commit f39b270

Browse files
Merge pull request #216 from Blueprints-org/159-feature-request-add-formula-58-from-nen_en_1992_1_1_c2_2011
159 feature request add formula 58 from nen en 1992 1 1 c2 2011
2 parents ba31b70 + b59a829 commit f39b270

File tree

4 files changed

+143
-2
lines changed

4 files changed

+143
-2
lines changed
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
"""Formula 5.8 from NEN-EN 1992-1-1+C2:2011: Chapter 5 - Structural Analysis."""
2+
3+
from blueprints.codes.eurocode.nen_en_1992_1_1_c2_2011 import NEN_EN_1992_1_1_C2_2011
4+
from blueprints.codes.formula import Formula
5+
from blueprints.codes.latex_formula import LatexFormula
6+
from blueprints.type_alias import M
7+
from blueprints.validations import raise_if_negative
8+
9+
10+
class Form5Dot8EffectiveSpan(Formula):
11+
"""Class representing formula 5.8 for calculating the effective span of beams and slabs, :math:`l_{eff}`.
12+
13+
See Figure 5.4
14+
"""
15+
16+
label = "5.8"
17+
source_document = NEN_EN_1992_1_1_C2_2011
18+
19+
def __init__(
20+
self,
21+
l_n: M,
22+
a_1: M,
23+
a_2: M,
24+
) -> None:
25+
"""[:math:`l_{eff}`] the effective span of a member [:math:`m`].
26+
27+
NEN-EN 1992-1-1+C2:2011 art.5.3.2.2(1) - Formula (5.8)
28+
29+
Parameters
30+
----------
31+
l_n : M
32+
[:math:`l_{n}`] clear distance between the faces of the supports [:math:`m`].
33+
a_1 : M
34+
[:math:`a_{1}`] values for :math:`a_{1}` and :math:`a_{2}` at each end of the span, may be determined from the appropriate :math:`a_{i}`
35+
values in Figure 5.4 where t is the width of the supporting element as shown. [:math:`m`].
36+
a_2 : M
37+
[:math:`a_{2}`] values for :math:`a_{1}` and :math:`a_{2}` at each end of the span, may be determined from the appropriate :math:`a_{i}`
38+
values in Figure 5.4 where t is the width of the supporting element as shown. [:math:`m`].
39+
"""
40+
super().__init__()
41+
self.l_n = l_n
42+
self.a_1 = a_1
43+
self.a_2 = a_2
44+
45+
@staticmethod
46+
def _evaluate(
47+
l_n: M,
48+
a_1: M,
49+
a_2: M,
50+
) -> M:
51+
"""Evaluates the formula, for more information see the __init__ method."""
52+
raise_if_negative(
53+
l_n=l_n,
54+
a_1=a_1,
55+
a_2=a_2,
56+
)
57+
return l_n + a_1 + a_2
58+
59+
def latex(self) -> LatexFormula:
60+
"""Returns LatexFormula object for formula 5.8."""
61+
return LatexFormula(
62+
return_symbol=r"l_{eff}",
63+
result=f"{self:.3f}",
64+
equation=r"l_{n} + a_{1} + a_{2}",
65+
numeric_equation=f"{self.l_n:.3f} + {self.a_1:.3f} + {self.a_2:.3f}",
66+
comparison_operator_label="=",
67+
)

docs/source/codes/eurocode/ec2_1992_1_1_2011/formulas.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ Total of 304 formulas present.
5353
| 5.7 | :x: | | |
5454
| 5.7a | :x: | | |
5555
| 5.7b | :x: | | |
56-
| 5.8 | :x: | | |
56+
| 5.8 | :heavy_check_mark: | | Form5Dot8EffectiveSpan |
5757
| 5.9 | :x: | | |
5858
| 5.10a | :x: | | |
5959
| 5.10b | :x: | | |

tests/codes/eurocode/nen_en_1992_1_1_c2_2011/chapter_5_structural_analysis/test_formula_5_3b.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ def test_evaluation(self) -> None:
3232
(-0.003, -5),
3333
],
3434
)
35-
def test_raise_error_when_negative_theta_i_is_given(self, theta_i: float, n_axial_force: float) -> None:
35+
def test_raise_error_when_negative_values_are_given(self, theta_i: float, n_axial_force: float) -> None:
3636
"""Test negative values."""
3737
with pytest.raises(NegativeValueError):
3838
Form5Dot3bTransverseForceBracedMembers(theta_i=theta_i, n_axial_force=n_axial_force)
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
"""Testing formula 5.8 of NEN-EN 1992-1-1+C2:2011."""
2+
3+
import pytest
4+
5+
from blueprints.codes.eurocode.nen_en_1992_1_1_c2_2011.chapter_5_structural_analysis.formula_5_8 import Form5Dot8EffectiveSpan
6+
from blueprints.validations import NegativeValueError
7+
8+
9+
class TestForm5Dot8EffectiveSpan:
10+
"""Validation for formula 5.8 from NEN-EN 1992-1-1+C2:2011."""
11+
12+
def test_evaluation(self) -> None:
13+
"""Test the evaluation of the result."""
14+
# Example values
15+
l_n = 5 # m
16+
a_1 = 0.5 # m
17+
a_2 = 0.35 # m
18+
19+
# Object to test
20+
form_5_8 = Form5Dot8EffectiveSpan(l_n=l_n, a_1=a_1, a_2=a_2)
21+
22+
# Expected result, manually calculated
23+
manually_calculated_result = 5.85 # kN
24+
25+
assert form_5_8 == pytest.approx(expected=manually_calculated_result, rel=1e-4)
26+
27+
@pytest.mark.parametrize(
28+
("l_n", "a_1", "a_2"),
29+
[
30+
(-5, 0.5, 0.35),
31+
(5, -0.5, 0.35),
32+
(5, 0.5, -0.35),
33+
],
34+
)
35+
def test_raise_error_when_negative_values_are_given(self, l_n: float, a_1: float, a_2: float) -> None:
36+
"""Test negative values."""
37+
with pytest.raises(NegativeValueError):
38+
Form5Dot8EffectiveSpan(l_n=l_n, a_1=a_1, a_2=a_2)
39+
40+
@pytest.mark.parametrize(
41+
("representation", "expected"),
42+
[
43+
(
44+
"complete",
45+
r"l_{eff} = l_{n} + a_{1} + a_{2} = 5.000 + 0.500 + 0.350 = 5.850",
46+
),
47+
("short", r"l_{eff} = 5.850"),
48+
(
49+
"string",
50+
r"l_{eff} = l_{n} + a_{1} + a_{2} = 5.000 + 0.500 + 0.350 = 5.850",
51+
),
52+
],
53+
)
54+
def test_latex(self, representation: str, expected: str) -> None:
55+
"""Test the latex representation of the formula."""
56+
# Example values
57+
l_n = 5 # m
58+
a_1 = 0.5 # m
59+
a_2 = 0.35 # m
60+
61+
# Object to test
62+
form_5_8_latex = Form5Dot8EffectiveSpan(
63+
l_n=l_n,
64+
a_1=a_1,
65+
a_2=a_2,
66+
).latex()
67+
68+
actual = {
69+
"complete": form_5_8_latex.complete,
70+
"short": form_5_8_latex.short,
71+
"string": str(form_5_8_latex),
72+
}
73+
74+
assert expected == actual[representation], f"{representation} representation failed."

0 commit comments

Comments
 (0)