Skip to content

Commit 6f00805

Browse files
Merge pull request #405 from Blueprints-org/403-feature-request-add-formulas-from-chapter-59-from-nen_en_1992_1_1
403 feature request add formulas from chapter 5.9 from nen-en-1992-1-1
2 parents 82d5a24 + 4fa24be commit 6f00805

File tree

5 files changed

+266
-2
lines changed

5 files changed

+266
-2
lines changed
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
"""Formula 5.40a from NEN-EN 1992-1-1+C2:2011: Chapter 5 - Structural Analysis."""
2+
3+
from blueprints.codes.eurocode.nen_en_1992_1_1_c2_2011 import NEN_EN_1992_1_1_C2_2011
4+
from blueprints.codes.formula import Formula
5+
from blueprints.codes.latex_formula import LatexFormula
6+
from blueprints.type_alias import M
7+
from blueprints.validations import raise_if_less_or_equal_to_zero, raise_if_negative
8+
9+
10+
class Form5Dot40aCheckLateralInstability(Formula):
11+
r"""Class representing formula 5.40a for checking lateral instability in persistent situations."""
12+
13+
label = "5.40a"
14+
source_document = NEN_EN_1992_1_1_C2_2011
15+
16+
def __init__(
17+
self,
18+
l_0t: M,
19+
b: M,
20+
h: M,
21+
) -> None:
22+
r"""Check the conditions to ignore second order effects in connection with lateral instability.
23+
24+
NEN-EN 1992-1-1+C2:2011 art.5.9(3) - Formula (5.40a)
25+
26+
Parameters
27+
----------
28+
l_0t : M
29+
[:math:`l_{0t}`] is the distance between torsional restraints [m].
30+
b : M
31+
[:math:`b`] is the width of compression flange [m].
32+
h : M
33+
[:math:`h`] is the total depth of beam in central part of l_0t [m].
34+
"""
35+
super().__init__()
36+
self.l_0t = l_0t
37+
self.b = b
38+
self.h = h
39+
40+
@staticmethod
41+
def _evaluate(
42+
l_0t: float,
43+
b: float,
44+
h: float,
45+
) -> bool:
46+
"""Evaluates the formula, for more information see the __init__ method."""
47+
raise_if_less_or_equal_to_zero(b=b, h=h)
48+
raise_if_negative(l_0t=l_0t)
49+
50+
return (l_0t / b <= 50 / (h / b) ** (1 / 3)) and (h / b <= 2.5)
51+
52+
def latex(self) -> LatexFormula:
53+
"""Returns LatexFormula object for formula 5.40a."""
54+
return LatexFormula(
55+
return_symbol=r"CHECK",
56+
result="OK" if self.__bool__() else "\\text{Not OK}",
57+
equation=r"\left( \frac{l_{0t}}{b} \leq \frac{50}{\left( h/b \right)^{1/3}} \text{ and } \frac{h}{b} \leq 2.5 \right)",
58+
numeric_equation=rf"\left( \frac{{{self.l_0t:.3f}}}{{{self.b:.3f}}} \leq \frac{{50}}{{\left("
59+
rf" {self.h:.3f}/{self.b:.3f} \right)^{{1/3}}}} \text{{ and }} "
60+
rf"\frac{{{self.h:.3f}}}{{{self.b:.3f}}} \leq 2.5 \right)",
61+
comparison_operator_label="\\to",
62+
unit="",
63+
)
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
"""Formula 5.40b from NEN-EN 1992-1-1+C2:2011: Chapter 5 - Structural Analysis."""
2+
3+
from blueprints.codes.eurocode.nen_en_1992_1_1_c2_2011 import NEN_EN_1992_1_1_C2_2011
4+
from blueprints.codes.formula import Formula
5+
from blueprints.codes.latex_formula import LatexFormula
6+
from blueprints.type_alias import M
7+
from blueprints.validations import raise_if_less_or_equal_to_zero, raise_if_negative
8+
9+
10+
class Form5Dot40bCheckLateralInstability(Formula):
11+
r"""Class representing formula 5.40b for checking lateral instability in transient situations."""
12+
13+
label = "5.40b"
14+
source_document = NEN_EN_1992_1_1_C2_2011
15+
16+
def __init__(
17+
self,
18+
l_0t: M,
19+
b: M,
20+
h: M,
21+
) -> None:
22+
r"""Check the conditions to ignore second order effects in connection with lateral instability.
23+
24+
NEN-EN 1992-1-1+C2:2011 art.5.9(3) - Formula (5.40b)
25+
26+
Parameters
27+
----------
28+
l_0t : M
29+
[:math:`l_{0t}`] is the distance between torsional restraints [m].
30+
b : M
31+
[:math:`b`] is the width of compression flange [m].
32+
h : M
33+
[:math:`h`] is the total depth of beam in central part of l_0t [m].
34+
"""
35+
super().__init__()
36+
self.l_0t = l_0t
37+
self.b = b
38+
self.h = h
39+
40+
@staticmethod
41+
def _evaluate(
42+
l_0t: float,
43+
b: float,
44+
h: float,
45+
) -> bool:
46+
"""Evaluates the formula, for more information see the __init__ method."""
47+
raise_if_less_or_equal_to_zero(b=b, h=h)
48+
raise_if_negative(l_0t=l_0t)
49+
50+
return (l_0t / b <= 70 / (h / b) ** (1 / 3)) and (h / b <= 3.5)
51+
52+
def latex(self) -> LatexFormula:
53+
"""Returns LatexFormula object for formula 5.40b."""
54+
return LatexFormula(
55+
return_symbol=r"CHECK",
56+
result="OK" if self.__bool__() else "\\text{Not OK}",
57+
equation=r"\left( \frac{l_{0t}}{b} \leq \frac{70}{\left( h/b \right)^{1/3}} \text{ and } \frac{h}{b} \leq 3.5 \right)",
58+
numeric_equation=rf"\left( \frac{{{self.l_0t:.3f}}}{{{self.b:.3f}}} \leq \frac{{70}}{{\left("
59+
rf" {self.h:.3f}/{self.b:.3f} \right)^{{1/3}}}} \text{{ and }} "
60+
rf"\frac{{{self.h:.3f}}}{{{self.b:.3f}}} \leq 3.5 \right)",
61+
comparison_operator_label="\\to",
62+
unit="",
63+
)

docs/source/codes/eurocode/ec2_1992_1_1_2011/formulas.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,8 +89,8 @@ Total of 304 formulas present.
8989
| 5.38a | :heavy_check_mark: | | Form5Dot38aCheckRelativeSlendernessRatio |
9090
| 5.38b | :heavy_check_mark: | | Form5Dot38bCheckRelativeEccentricityRatio |
9191
| 5.39 | :heavy_check_mark: | | Form5Dot39SimplifiedCriterionBiaxialBending |
92-
| 5.40a | :x: | | |
93-
| 5.40b | :x: | | |
92+
| 5.40a | :x: | | Form5Dot40aCheckLateralInstability |
93+
| 5.40b | :x: | | Form5Dot40bCheckLateralInstability |
9494
| 5.41 | :x: | | |
9595
| 5.42 | :x: | | |
9696
| 5.43 | :x: | | |
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
"""Testing formula 5.40a of NEN-EN 1992-1-1+C2:2011."""
2+
3+
import pytest
4+
5+
from blueprints.codes.eurocode.nen_en_1992_1_1_c2_2011.chapter_5_structural_analysis.formula_5_40a import Form5Dot40aCheckLateralInstability
6+
from blueprints.validations import LessOrEqualToZeroError, NegativeValueError
7+
8+
9+
class TestForm5Dot40aCheckLateralInstability:
10+
"""Validation for formula 5.40a from NEN-EN 1992-1-1+C2:2011."""
11+
12+
def test_evaluation(self) -> None:
13+
"""Tests the evaluation of the result."""
14+
# Example values
15+
l_0t = 6.0 # m
16+
b = 0.3 # m
17+
h = 0.5 # m
18+
19+
# Object to test
20+
formula = Form5Dot40aCheckLateralInstability(l_0t=l_0t, b=b, h=h)
21+
22+
# Expected result, manually calculated
23+
expected_result = True
24+
25+
assert formula == expected_result
26+
27+
@pytest.mark.parametrize(
28+
("l_0t", "b", "h"),
29+
[
30+
(-6.0, 0.3, 0.5), # l_0t is negative
31+
(6.0, -0.3, 0.5), # b is negative
32+
(6.0, 0.3, -0.5), # h is negative
33+
(6.0, 0.0, 0.5), # b is zero
34+
(6.0, 0.3, 0.0), # h is zero
35+
],
36+
)
37+
def test_raise_error_when_invalid_values_are_given(self, l_0t: float, b: float, h: float) -> None:
38+
"""Test invalid values."""
39+
with pytest.raises((NegativeValueError, LessOrEqualToZeroError)):
40+
Form5Dot40aCheckLateralInstability(l_0t=l_0t, b=b, h=h)
41+
42+
@pytest.mark.parametrize(
43+
("representation", "expected"),
44+
[
45+
(
46+
"complete",
47+
r"CHECK \to \left( \frac{l_{0t}}{b} \leq \frac{50}{\left( h/b \right)^{1/3}} \text{ and } \frac{h}{b} \leq 2.5 \right) \to "
48+
r"\left( \frac{6.000}{0.300} \leq \frac{50}{\left( 0.500/0.300 \right)^{1/3}} \text{ and } "
49+
r"\frac{0.500}{0.300} \leq 2.5 \right) \to OK",
50+
),
51+
("short", r"CHECK \to OK"),
52+
],
53+
)
54+
def test_latex(self, representation: str, expected: str) -> None:
55+
"""Test the latex representation of the formula."""
56+
# Example values
57+
l_0t = 6.0 # m
58+
b = 0.3 # m
59+
h = 0.5 # m
60+
61+
# Object to test
62+
latex = Form5Dot40aCheckLateralInstability(l_0t=l_0t, b=b, h=h).latex()
63+
64+
actual = {
65+
"complete": latex.complete,
66+
"short": latex.short,
67+
}
68+
69+
assert expected == actual[representation], f"{representation} representation failed."
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
"""Testing formula 5.40b of NEN-EN 1992-1-1+C2:2011."""
2+
3+
import pytest
4+
5+
from blueprints.codes.eurocode.nen_en_1992_1_1_c2_2011.chapter_5_structural_analysis.formula_5_40b import Form5Dot40bCheckLateralInstability
6+
from blueprints.validations import LessOrEqualToZeroError, NegativeValueError
7+
8+
9+
class TestForm5Dot40bCheckLateralInstability:
10+
"""Validation for formula 5.40b from NEN-EN 1992-1-1+C2:2011."""
11+
12+
def test_evaluation(self) -> None:
13+
"""Tests the evaluation of the result."""
14+
# Example values
15+
l_0t = 6.0 # m
16+
b = 0.3 # m
17+
h = 0.5 # m
18+
19+
# Object to test
20+
formula = Form5Dot40bCheckLateralInstability(l_0t=l_0t, b=b, h=h)
21+
22+
# Expected result, manually calculated
23+
expected_result = True
24+
25+
assert formula == expected_result
26+
27+
@pytest.mark.parametrize(
28+
("l_0t", "b", "h"),
29+
[
30+
(-6.0, 0.3, 0.5), # l_0t is negative
31+
(6.0, -0.3, 0.5), # b is negative
32+
(6.0, 0.3, -0.5), # h is negative
33+
(6.0, 0.0, 0.5), # b is zero
34+
(6.0, 0.3, 0.0), # h is zero
35+
],
36+
)
37+
def test_raise_error_when_invalid_values_are_given(self, l_0t: float, b: float, h: float) -> None:
38+
"""Test invalid values."""
39+
with pytest.raises((NegativeValueError, LessOrEqualToZeroError)):
40+
Form5Dot40bCheckLateralInstability(l_0t=l_0t, b=b, h=h)
41+
42+
@pytest.mark.parametrize(
43+
("representation", "expected"),
44+
[
45+
(
46+
"complete",
47+
r"CHECK \to \left( \frac{l_{0t}}{b} \leq \frac{70}{\left( h/b \right)^{1/3}} \text{ and } \frac{h}{b} \leq 3.5 \right) \to "
48+
r"\left( \frac{6.000}{0.300} \leq \frac{70}{\left( 0.500/0.300 \right)^{1/3}} \text{ and } "
49+
r"\frac{0.500}{0.300} \leq 3.5 \right) \to OK",
50+
),
51+
("short", r"CHECK \to OK"),
52+
],
53+
)
54+
def test_latex(self, representation: str, expected: str) -> None:
55+
"""Test the latex representation of the formula."""
56+
# Example values
57+
l_0t = 6.0 # m
58+
b = 0.3 # m
59+
h = 0.5 # m
60+
61+
# Object to test
62+
latex = Form5Dot40bCheckLateralInstability(l_0t=l_0t, b=b, h=h).latex()
63+
64+
actual = {
65+
"complete": latex.complete,
66+
"short": latex.short,
67+
}
68+
69+
assert expected == actual[representation], f"{representation} representation failed."

0 commit comments

Comments
 (0)