From 534a7c015c76abc192522ef937914d9118f315e0 Mon Sep 17 00:00:00 2001 From: Sina Zel taat Date: Wed, 3 Apr 2024 14:09:56 +0200 Subject: [PATCH 1/3] add formula 5.8 from NEN-EN 1992-1-1+C2:2011 --- .../formula_5_8.py | 67 +++++++++++++++++++ 1 file changed, 67 insertions(+) create mode 100644 blueprints/codes/eurocode/nen_en_1992_1_1_c2_2011/chapter_5_structural_analysis/formula_5_8.py diff --git a/blueprints/codes/eurocode/nen_en_1992_1_1_c2_2011/chapter_5_structural_analysis/formula_5_8.py b/blueprints/codes/eurocode/nen_en_1992_1_1_c2_2011/chapter_5_structural_analysis/formula_5_8.py new file mode 100644 index 00000000..8e76e93c --- /dev/null +++ b/blueprints/codes/eurocode/nen_en_1992_1_1_c2_2011/chapter_5_structural_analysis/formula_5_8.py @@ -0,0 +1,67 @@ +"""Formula 5.8 from NEN-EN 1992-1-1+C2:2011: Chapter 5 - Structural Analysis.""" + +from blueprints.codes.eurocode.nen_en_1992_1_1_c2_2011 import NEN_EN_1992_1_1_C2_2011 +from blueprints.codes.formula import Formula +from blueprints.codes.latex_formula import LatexFormula +from blueprints.type_alias import M +from blueprints.validations import raise_if_negative + + +class Form5Dot8EffectiveSpan(Formula): + """Class representing formula 5.8 for calculating the effective span of beams and slabs, :math:`l_{eff}`. + + See Figure 5.4 + """ + + label = "5.8" + source_document = NEN_EN_1992_1_1_C2_2011 + + def __init__( + self, + l_n: M, + a_1: M, + a_2: M, + ) -> None: + """[:math:`l_{eff}`] the effective span of a member [:math:`m`]. + + NEN-EN 1992-1-1+C2:2011 art.5.3.2.2(1) - Formula (5.8) + + Parameters + ---------- + l_n : M + [:math:`l_{n}`] clear distance between the faces of the supports [:math:`m`]. + a_1 : M + [: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}` + values in Figure 5.4 where t is the width of the supporting element as shown. [:math:`m`]. + a_2 : M + [: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}` + values in Figure 5.4 where t is the width of the supporting element as shown. [:math:`m`]. + """ + super().__init__() + self.l_n = l_n + self.a_1 = a_1 + self.a_2 = a_2 + + @staticmethod + def _evaluate( + l_n: M, + a_1: M, + a_2: M, + ) -> M: + """Evaluates the formula, for more information see the __init__ method.""" + raise_if_negative( + l_n=l_n, + a_1=a_1, + a_2=a_2, + ) + return l_n + a_1 + a_2 + + def latex(self) -> LatexFormula: + """Returns LatexFormula object for formula 5.8.""" + return LatexFormula( + return_symbol=r"l_{eff}", + result=f"{self:.3f}", + equation=r"l_{n} + a_{1} + a_{2}", + numeric_equation=f"{self.l_n:.3f} + {self.a_1:.3f} + {self.a_2:.3f}", + comparison_operator_label="=", + ) From bbff0094499beafca1dd86b5deb5aa70bc21326e Mon Sep 17 00:00:00 2001 From: Sina Zel taat Date: Wed, 3 Apr 2024 14:42:15 +0200 Subject: [PATCH 2/3] add test for 5.8 of NEN-EN 1992-1-1+C2:2011 --- .../test_formula_5_3b.py | 2 +- .../test_formula_5_8.py | 74 +++++++++++++++++++ 2 files changed, 75 insertions(+), 1 deletion(-) create mode 100644 tests/codes/eurocode/nen_en_1992_1_1_c2_2011/chapter_5_structural_analysis/test_formula_5_8.py diff --git a/tests/codes/eurocode/nen_en_1992_1_1_c2_2011/chapter_5_structural_analysis/test_formula_5_3b.py b/tests/codes/eurocode/nen_en_1992_1_1_c2_2011/chapter_5_structural_analysis/test_formula_5_3b.py index 8ab9d11b..62732d52 100644 --- a/tests/codes/eurocode/nen_en_1992_1_1_c2_2011/chapter_5_structural_analysis/test_formula_5_3b.py +++ b/tests/codes/eurocode/nen_en_1992_1_1_c2_2011/chapter_5_structural_analysis/test_formula_5_3b.py @@ -32,7 +32,7 @@ def test_evaluation(self) -> None: (-0.003, -5), ], ) - def test_raise_error_when_negative_theta_i_is_given(self, theta_i: float, n_axial_force: float) -> None: + def test_raise_error_when_negative_values_are_given(self, theta_i: float, n_axial_force: float) -> None: """Test negative values.""" with pytest.raises(NegativeValueError): Form5Dot3bTransverseForceBracedMembers(theta_i=theta_i, n_axial_force=n_axial_force) diff --git a/tests/codes/eurocode/nen_en_1992_1_1_c2_2011/chapter_5_structural_analysis/test_formula_5_8.py b/tests/codes/eurocode/nen_en_1992_1_1_c2_2011/chapter_5_structural_analysis/test_formula_5_8.py new file mode 100644 index 00000000..9ba55eb9 --- /dev/null +++ b/tests/codes/eurocode/nen_en_1992_1_1_c2_2011/chapter_5_structural_analysis/test_formula_5_8.py @@ -0,0 +1,74 @@ +"""Testing formula 5.8 of NEN-EN 1992-1-1+C2:2011.""" + +import pytest + +from blueprints.codes.eurocode.nen_en_1992_1_1_c2_2011.chapter_5_structural_analysis.formula_5_8 import Form5Dot8EffectiveSpan +from blueprints.validations import NegativeValueError + + +class TestForm5Dot8EffectiveSpan: + """Validation for formula 5.8 from NEN-EN 1992-1-1+C2:2011.""" + + def test_evaluation(self) -> None: + """Test the evaluation of the result.""" + # Example values + l_n = 5 # m + a_1 = 0.5 # m + a_2 = 0.35 # m + + # Object to test + form_5_8 = Form5Dot8EffectiveSpan(l_n=l_n, a_1=a_1, a_2=a_2) + + # Expected result, manually calculated + manually_calculated_result = 5.85 # kN + + assert form_5_8 == pytest.approx(expected=manually_calculated_result, rel=1e-4) + + @pytest.mark.parametrize( + ("l_n", "a_1", "a_2"), + [ + (-5, 0.5, 0.35), + (5, -0.5, 0.35), + (5, 0.5, -0.35), + ], + ) + def test_raise_error_when_negative_values_are_given(self, l_n: float, a_1: float, a_2: float) -> None: + """Test negative values.""" + with pytest.raises(NegativeValueError): + Form5Dot8EffectiveSpan(l_n=l_n, a_1=a_1, a_2=a_2) + + @pytest.mark.parametrize( + ("representation", "expected"), + [ + ( + "complete", + r"l_{eff} = l_{n} + a_{1} + a_{2} = 5.000 + 0.500 + 0.350 = 5.850", + ), + ("short", r"l_{eff} = 5.850"), + ( + "string", + r"l_{eff} = l_{n} + a_{1} + a_{2} = 5.000 + 0.500 + 0.350 = 5.850", + ), + ], + ) + def test_latex(self, representation: str, expected: str) -> None: + """Test the latex representation of the formula.""" + # Example values + l_n = 5 # m + a_1 = 0.5 # m + a_2 = 0.35 # m + + # Object to test + form_5_8_latex = Form5Dot8EffectiveSpan( + l_n=l_n, + a_1=a_1, + a_2=a_2, + ).latex() + + actual = { + "complete": form_5_8_latex.complete, + "short": form_5_8_latex.short, + "string": str(form_5_8_latex), + } + + assert expected == actual[representation], f"{representation} representation failed." From 4ec4c67d0c88780b8ee4768867a10b4f0911899c Mon Sep 17 00:00:00 2001 From: Sina Zel taat Date: Wed, 3 Apr 2024 14:43:51 +0200 Subject: [PATCH 3/3] =?UTF-8?q?Update=20table=20in=20docs=20with=20?= =?UTF-8?q?=E2=9C=94=EF=B8=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/source/codes/eurocode/ec2_1992_1_1_2011/formulas.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/source/codes/eurocode/ec2_1992_1_1_2011/formulas.md b/docs/source/codes/eurocode/ec2_1992_1_1_2011/formulas.md index 91b01902..da445b17 100644 --- a/docs/source/codes/eurocode/ec2_1992_1_1_2011/formulas.md +++ b/docs/source/codes/eurocode/ec2_1992_1_1_2011/formulas.md @@ -53,7 +53,7 @@ Total of 304 formulas present. | 5.7 | :x: | | | | 5.7a | :x: | | | | 5.7b | :x: | | | -| 5.8 | :x: | | | +| 5.8 | :heavy_check_mark: | | Form5Dot8EffectiveSpan | | 5.9 | :x: | | | | 5.10a | :x: | | | | 5.10b | :x: | | |