-
Notifications
You must be signed in to change notification settings - Fork 6
233 Formula 5.8 from NEN-EN 1993-1-1 #519
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -165,4 +165,5 @@ cython_debug/ | |
.vscode/ | ||
|
||
# ENV file | ||
.ENV | ||
.ENV | ||
/local/ |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
"""Module containing all formulas from 1993-1-1+C2+A1:2016: Chapter 5 - Structural analysis.""" |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
"""Formula 5.8 from NEN-EN 1993-1-1+C2+A1:2016: Chapter 5 - Structural Analysis.""" | ||
|
||
import numpy as np | ||
|
||
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.codes.latex_formula import LatexFormula, latex_replace_symbols | ||
from blueprints.type_alias import DIMENSIONLESS, MM2, MPA, N | ||
from blueprints.validations import raise_if_less_or_equal_to_zero | ||
|
||
|
||
class Form5Dot8CheckSlenderness(Formula): | ||
r"""Class representing formula 5.8 for check of slenderness.""" | ||
|
||
label = "5.8" | ||
source_document = NEN_EN_1993_1_1_C2_A1_2016 | ||
|
||
def __init__( | ||
self, | ||
lambda_bar: DIMENSIONLESS, | ||
a: MM2, | ||
f_y: MPA, | ||
n_ed: N, | ||
) -> None: | ||
r"""Check the slenderness ratio. | ||
|
||
NEN-EN 1993-1-1+C2+A1:2016 art.5.3.2(6) - Formula (5.8) | ||
|
||
Parameters | ||
---------- | ||
lambda_bar : DIMENSIONLESS | ||
[$\lambda_{bar}$] Non-dimensional slenderness [-]. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. is the in-plane non-dimensional slenderness calculated for the member considered as hinged at |
||
a : MM2 | ||
[$A$] Cross-sectional area [$mm^2$]. | ||
f_y : MPA | ||
[$f_y$] Yield strength [$MPa$]. | ||
n_ed : N | ||
[$N_{Ed}$] Design value of the compression force [$N$]. | ||
""" | ||
super().__init__() | ||
self.lambda_bar = lambda_bar | ||
self.a = a | ||
self.f_y = f_y | ||
self.n_ed = n_ed | ||
|
||
@staticmethod | ||
def _evaluate( | ||
lambda_bar: DIMENSIONLESS, | ||
a: MM2, | ||
f_y: MPA, | ||
n_ed: N, | ||
) -> bool: | ||
"""Evaluates the formula, for more information see the __init__ method.""" | ||
raise_if_less_or_equal_to_zero(lambda_bar=lambda_bar, A=a, f_y=f_y, N_Ed=n_ed) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. lambda_bar and A and fy can be zero. use raise_if_negative instead. |
||
|
||
return lambda_bar > 0.5 * np.sqrt(a * f_y / n_ed) | ||
|
||
def latex(self) -> LatexFormula: | ||
"""Returns LatexFormula object for formula 5.8.""" | ||
n = 2 | ||
_equation: str = r"\left( \lambda_{bar} > 0.5 \sqrt{\frac{A \cdot f_{y}}{N_{Ed}}} \right)" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. i personally prefer a \cdot after the 0.5, but its up to you. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. \overline{\lambda} |
||
_numeric_equation: str = latex_replace_symbols( | ||
_equation, | ||
{ | ||
r"\lambda_{bar}": f"{self.lambda_bar:.{n}f}", | ||
"A": f"{self.a:.{n}f}", | ||
"f_{y}": f"{self.f_y:.{n}f}", | ||
"N_{Ed}": f"{self.n_ed:.{n}f}", | ||
}, | ||
False, | ||
) | ||
return LatexFormula( | ||
return_symbol=r"CHECK", | ||
result="OK" if self.__bool__() else "\\text{Not OK}", | ||
equation=_equation, | ||
numeric_equation=_numeric_equation, | ||
comparison_operator_label="\\to", | ||
unit="", | ||
) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
"""Tests for the module `nen_en_1993_1_1_c2_a1_2016.chapter_5_structural_analysis`.""" |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
"""Testing formula 5.8 of NEN-EN 1993-1-1+C2+A1:2016.""" | ||
|
||
import pytest | ||
|
||
from blueprints.codes.eurocode.nen_en_1993_1_1_c2_a1_2016.chapter_5_structural_analysis.formula_5_8 import Form5Dot8CheckSlenderness | ||
from blueprints.validations import LessOrEqualToZeroError | ||
|
||
|
||
class TestForm5Dot8CheckSlenderness: | ||
"""Validation for formula 5.8 from NEN-EN 1993-1-1+C2+A1:2016.""" | ||
|
||
def test_evaluation(self) -> None: | ||
"""Tests the evaluation of the result.""" | ||
# Example values | ||
lambda_bar = 1.0 | ||
a = 1000.0 | ||
f_y = 355.0 | ||
n_ed = 100000.0 | ||
|
||
# Object to test | ||
formula = Form5Dot8CheckSlenderness(lambda_bar=lambda_bar, a=a, f_y=f_y, n_ed=n_ed) | ||
|
||
# Expected result, manually calculated | ||
expected_result = True | ||
|
||
assert formula == expected_result | ||
|
||
@pytest.mark.parametrize( | ||
("lambda_bar", "a", "f_y", "n_ed"), | ||
[ | ||
(-1.0, 1000.0, 355.0, 100000.0), # lambda_bar is negative | ||
(1.0, -1000.0, 355.0, 100000.0), # a is negative | ||
(1.0, 1000.0, -355.0, 100000.0), # f_y is negative | ||
(1.0, 1000.0, 355.0, -100000.0), # n_ed is negative | ||
(0.0, 1000.0, 355.0, 100000.0), # lambda_bar is zero | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. line 35-37 not needed for tests, as they can be zero. |
||
(1.0, 0.0, 355.0, 100000.0), # a is zero | ||
(1.0, 1000.0, 0.0, 100000.0), # f_y is zero | ||
(1.0, 1000.0, 355.0, 0.0), # n_ed is zero | ||
], | ||
) | ||
def test_raise_error_when_invalid_values_are_given(self, lambda_bar: float, a: float, f_y: float, n_ed: float) -> None: | ||
"""Test invalid values.""" | ||
with pytest.raises(LessOrEqualToZeroError): | ||
Form5Dot8CheckSlenderness(lambda_bar, a, f_y, n_ed) | ||
|
||
def test_latex(self) -> None: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this test is not in line with all other formula latex tests. could you add the full short and complete result? |
||
"""Test the latex representation of the formula.""" | ||
# Example values | ||
lambda_bar = 1.0 | ||
a = 1000.0 | ||
f_y = 355.0 | ||
n_ed = 100000.0 | ||
|
||
# Object to test | ||
formula = Form5Dot8CheckSlenderness(lambda_bar=lambda_bar, a=a, f_y=f_y, n_ed=n_ed) | ||
latex = formula.latex() | ||
|
||
expected_equation = r"\left( \lambda_{bar} > 0.5 \sqrt{\frac{A \cdot f_{y}}{N_{Ed}}} \right)" | ||
expected_numeric_equation = r"\left( 1.00 > 0.5 \sqrt{\frac{1000.00 \cdot 355.00}{100000.00}} \right)" | ||
expected_result = "OK" | ||
|
||
assert latex.equation == expected_equation | ||
assert latex.numeric_equation == expected_numeric_equation | ||
assert latex.result == expected_result |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
\overline{\lambda}