-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #216 from Blueprints-org/159-feature-request-add-f…
…ormula-58-from-nen_en_1992_1_1_c2_2011 159 feature request add formula 58 from nen en 1992 1 1 c2 2011
- Loading branch information
Showing
4 changed files
with
143 additions
and
2 deletions.
There are no files selected for viewing
67 changes: 67 additions & 0 deletions
67
...rints/codes/eurocode/nen_en_1992_1_1_c2_2011/chapter_5_structural_analysis/formula_5_8.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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="=", | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
74 changes: 74 additions & 0 deletions
74
.../codes/eurocode/nen_en_1992_1_1_c2_2011/chapter_5_structural_analysis/test_formula_5_8.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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." |