-
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 #220 from Blueprints-org/163--feature-request-add-…
…formula-511n-from-nen_en_1992_1_1_c2_2011
- Loading branch information
Showing
3 changed files
with
112 additions
and
1 deletion.
There are no files selected for viewing
51 changes: 51 additions & 0 deletions
51
...nts/codes/eurocode/nen_en_1992_1_1_c2_2011/chapter_5_structural_analysis/formula_5_11n.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,51 @@ | ||
"""Formula 5.11N 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, latex_fraction | ||
from blueprints.type_alias import DIMENSIONLESS | ||
from blueprints.validations import raise_if_less_or_equal_to_zero | ||
|
||
|
||
class Form5Dot11nShearSlendernessCorrectionFactor(Formula): | ||
"""Class representing formula 5.11N for the calculation of the shear slenderness correction factor [:math:`k_{λ}`].""" | ||
|
||
label = "5.11N" | ||
source_document = NEN_EN_1992_1_1_C2_2011 | ||
|
||
def __init__( | ||
self, | ||
lambda_factor: DIMENSIONLESS, | ||
) -> None: | ||
"""[:math:`k_{λ}`] Shear slenderness correction factor. | ||
NEN-EN 1992-1-1+C2:2011 art.5.6.3(4) - Formula (5.11N) | ||
Parameters | ||
---------- | ||
lambda_factor : DIMENSIONLESS | ||
[:math:`λ`] ratio of the distance between point of zero and maximum moment after redistribution and | ||
effective depth, d [:math:`-`] | ||
Use your own implementation for this value or use :class:`Form5Dot12nRatioDistancePointZeroAndMaxMoment`. | ||
""" | ||
super().__init__() | ||
self.lambda_factor = lambda_factor | ||
|
||
@staticmethod | ||
def _evaluate( | ||
lambda_factor: DIMENSIONLESS, | ||
) -> DIMENSIONLESS: | ||
"""Evaluates the formula, for more information see the __init__ method.""" | ||
raise_if_less_or_equal_to_zero(lambda_factor=lambda_factor) | ||
return (lambda_factor / 3) ** 0.5 | ||
|
||
def latex(self) -> LatexFormula: | ||
"""Returns LatexFormula object for formula 5.11N.""" | ||
return LatexFormula( | ||
return_symbol=r"k_{λ}", | ||
result=f"{self:.3f}", | ||
equation=r"\sqrt{\frac{λ}{3}}", | ||
numeric_equation=rf"\sqrt{latex_fraction(numerator=self.lambda_factor, denominator=3)}", | ||
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
60 changes: 60 additions & 0 deletions
60
...odes/eurocode/nen_en_1992_1_1_c2_2011/chapter_5_structural_analysis/test_formula_5_11n.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,60 @@ | ||
"""Testing formula 5.11n 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_11n import Form5Dot11nShearSlendernessCorrectionFactor | ||
from blueprints.validations import LessOrEqualToZeroError | ||
|
||
|
||
class TestForm5Dot11nShearSlendernessCorrectionFactor: | ||
"""Validation for formula 5.11N from NEN-EN 1992-1-1+C2:2011.""" | ||
|
||
def test_evaluation(self) -> None: | ||
"""Test the evaluation of the result.""" | ||
# Example values | ||
lambda_factor = 0.5 # - | ||
|
||
# Object to test | ||
form_5_11n = Form5Dot11nShearSlendernessCorrectionFactor(lambda_factor=lambda_factor) | ||
|
||
# Expected result, manually calculated | ||
manually_calculated_result = 0.40824 # - | ||
|
||
assert form_5_11n == pytest.approx(expected=manually_calculated_result, rel=1e-4) | ||
|
||
@pytest.mark.parametrize( | ||
"lambda_factor", | ||
[ | ||
0, | ||
-0.3, | ||
], | ||
) | ||
def test_raise_error_when_negative_values_or_zero_are_given( | ||
self, | ||
lambda_factor: float, | ||
) -> None: | ||
"""Test negative or zero values.""" | ||
with pytest.raises(LessOrEqualToZeroError): | ||
Form5Dot11nShearSlendernessCorrectionFactor(lambda_factor=lambda_factor) | ||
|
||
@pytest.mark.parametrize( | ||
("representation", "expected_result"), | ||
[ | ||
("complete", r"k_{λ} = \sqrt{\frac{λ}{3}} = \sqrt\frac{0.3}{3} = 0.316"), | ||
("short", "k_{λ} = 0.316"), | ||
], | ||
) | ||
def test_latex(self, representation: str, expected_result: str) -> None: | ||
"""Test the latex representation of the formula.""" | ||
# Example values | ||
lambda_factor = 0.3 # - | ||
|
||
# Object to test | ||
latex = Form5Dot11nShearSlendernessCorrectionFactor(lambda_factor=lambda_factor).latex() | ||
|
||
actual = { | ||
"complete": latex.complete, | ||
"short": latex.short, | ||
} | ||
|
||
assert actual[representation] == expected_result, f"{representation} representation failed." |