diff --git a/blueprints/codes/eurocode/nen_en_1993_1_1_c2_a1_2016/chapter_6_ultimate_limit_state/__init__.py b/blueprints/codes/eurocode/nen_en_1993_1_1_c2_a1_2016/chapter_6_ultimate_limit_state/__init__.py new file mode 100644 index 00000000..9dc81d02 --- /dev/null +++ b/blueprints/codes/eurocode/nen_en_1993_1_1_c2_a1_2016/chapter_6_ultimate_limit_state/__init__.py @@ -0,0 +1 @@ +"""Module containing all formulas from 1993-1-1+C2+A1:2016: Chapter 6 - Ultimate limit state.""" diff --git a/blueprints/codes/eurocode/nen_en_1993_1_1_c2_a1_2016/chapter_6_ultimate_limit_state/formula_6_5.py b/blueprints/codes/eurocode/nen_en_1993_1_1_c2_a1_2016/chapter_6_ultimate_limit_state/formula_6_5.py new file mode 100644 index 00000000..79f10ea5 --- /dev/null +++ b/blueprints/codes/eurocode/nen_en_1993_1_1_c2_a1_2016/chapter_6_ultimate_limit_state/formula_6_5.py @@ -0,0 +1,43 @@ +"""Formula 6.5 from NEN-EN 1993-1-1+C2+A1:2016: Chapter 6 - Ultimate limit state.""" +# pylint: disable=arguments-differ +from blueprints.codes.eurocode.nen_en_1993_1_1_c2_a1_2016 import NEN_EN_1993_1_1_C2_A1_2016 +from blueprints.codes.formula import Formula +from blueprints.type_alias import KN, RATIO +from blueprints.validations import raise_if_less_or_equal_to_zero, raise_if_negative + + +class Form6Dot5UnityCheckTensileStrength(Formula): + """Class representing formula 6.5 for the unity check for tensile strength.""" + + label = "6.5" + source_document = NEN_EN_1993_1_1_C2_A1_2016 + + def __init__( + self, + n_ed: KN, + n_t_rd: KN, + ) -> None: + """[N_ed/N_t_rd] Unity check for tensile strength of an element in tension. + + NEN-EN 1993-1-1+C2+A1:2016 art.6.2.3(1) - Formula (6.5) + + Parameters + ---------- + n_ed : KN + [NEd] Design value of the normal tensile force [kN]. + n_t_rd : KN + [Nt,Rd] Design value of the resistance against tenslie force [kN]. + """ + super().__init__() + self.n_ed = n_ed + self.n_t_rd = n_t_rd + + @staticmethod + def _evaluate( + n_ed: KN, + n_t_rd: KN, + ) -> RATIO: + """Evaluates the formula, for more information see the __init__ method.""" + raise_if_less_or_equal_to_zero(n_t_rd=n_t_rd) + raise_if_negative(n_ed=n_ed) + return n_ed / n_t_rd diff --git a/docs/source/codes/eurocode/ec3_1993_1_1_2016/formulas.md b/docs/source/codes/eurocode/ec3_1993_1_1_2016/formulas.md index 9b5b41c8..570fb870 100644 --- a/docs/source/codes/eurocode/ec3_1993_1_1_2016/formulas.md +++ b/docs/source/codes/eurocode/ec3_1993_1_1_2016/formulas.md @@ -29,7 +29,7 @@ Total of 108 equations present. | 6.2 | :x: | | | | 6.3 | :x: | | | | 6.4 | :x: | | | -| 6.5 | :x: | | | +| 6.5 | :heavy_check_mark: | | Form6Dot5UnityCheckTensileStrength | | 6.6 | :x: | | | | 6.7 | :x: | | | | 6.8 | :x: | | | diff --git a/tests/codes/eurocode/nen_en_1993_1_1_c2_a1_2016/chapter_6_ultimate_limit_state/__init__.py b/tests/codes/eurocode/nen_en_1993_1_1_c2_a1_2016/chapter_6_ultimate_limit_state/__init__.py new file mode 100644 index 00000000..1ec97fa0 --- /dev/null +++ b/tests/codes/eurocode/nen_en_1993_1_1_c2_a1_2016/chapter_6_ultimate_limit_state/__init__.py @@ -0,0 +1 @@ +"""Module containing all formulas from NEN_EN_1993_1_1_C2_A1_2016: Chapter 6 - Ultimate limit state.""" diff --git a/tests/codes/eurocode/nen_en_1993_1_1_c2_a1_2016/chapter_6_ultimate_limit_state/test_formula_6_5.py b/tests/codes/eurocode/nen_en_1993_1_1_c2_a1_2016/chapter_6_ultimate_limit_state/test_formula_6_5.py new file mode 100644 index 00000000..41014c8a --- /dev/null +++ b/tests/codes/eurocode/nen_en_1993_1_1_c2_a1_2016/chapter_6_ultimate_limit_state/test_formula_6_5.py @@ -0,0 +1,46 @@ +"""Testing formula 6.5 of NEN-EN 1993-1-1+C2+A1:2016.""" +import pytest + +from blueprints.codes.eurocode.nen_en_1993_1_1_c2_a1_2016.chapter_6_ultimate_limit_state.formula_6_5 import ( + Form6Dot5UnityCheckTensileStrength, +) +from blueprints.validations import LessOrEqualToZeroError, NegativeValueError + + +class TestForm6Dot5UnityCheckTensileStrength: + """Validation for formula 6.5 from NEN-EN 1993-1-1+C2+A1:2016.""" + + def test_evaluation(self) -> None: + """Test the evaluation of the result.""" + # Example values + n_ed = 7 # kN + n_t_rd = 10 # kN + form = Form6Dot5UnityCheckTensileStrength(n_ed=n_ed, n_t_rd=n_t_rd) + + # Expected result, manually calculated + expected = 0.7 + + assert form == pytest.approx(expected) + + @pytest.mark.parametrize( + ("n_ed", "n_t_rd"), + [ + (-7, 10), # n_ed is negative + ], + ) + def test_raise_error_when_negative_n_ed_is_given(self, n_ed: float, n_t_rd: float) -> None: + """Test a negative value for n_ed.""" + with pytest.raises(NegativeValueError): + Form6Dot5UnityCheckTensileStrength(n_ed=n_ed, n_t_rd=n_t_rd) + + @pytest.mark.parametrize( + ("n_ed", "n_t_rd"), + [ + (7, 0), # n_ed is negative + (7, -10), # n_t_rd is negative + ], + ) + def test_raise_error_when_negative_or_zero_n_t_rd_is_given(self, n_ed: float, n_t_rd: float) -> None: + """Test a zero value for n_t_rd.""" + with pytest.raises(LessOrEqualToZeroError): + Form6Dot5UnityCheckTensileStrength(n_ed=n_ed, n_t_rd=n_t_rd)