Skip to content

Commit 59d0073

Browse files
Merge pull request #524 from Blueprints-org/523-formula-516-from-nen-en-1993-52008
523 formula 516 from nen en 1993 52008
2 parents 0fcc91c + 47ad302 commit 59d0073

File tree

3 files changed

+128
-1
lines changed
  • blueprints/codes/eurocode/nen_en_1993_5_2008/chapter_5_ultimate_limit_states
  • docs/objects_overview/eurocode/nen_en_1993_5_2008
  • tests/codes/eurocode/nen_en_1993_5_2008/chapter_5_ultimate_limit_states

3 files changed

+128
-1
lines changed
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
"""Formula 5.16 from NEN-EN 1993-5:2008 Chapter 5 - Ultimate limit state."""
2+
3+
from blueprints.codes.eurocode.nen_en_1993_5_2008 import NEN_EN_1993_5_2008
4+
from blueprints.codes.formula import Formula
5+
from blueprints.codes.latex_formula import LatexFormula
6+
from blueprints.type_alias import DIMENSIONLESS, MM2, MPA, N
7+
from blueprints.validations import raise_if_less_or_equal_to_zero, raise_if_negative
8+
9+
10+
class Form5Dot16PlasticDesignResistance(Formula):
11+
"""Class representing formula 5.16 for the calculation of the plastic design resistance of the cross-section, [$N_{pl,Rd}$]."""
12+
13+
label = "5.16"
14+
source_document = NEN_EN_1993_5_2008
15+
16+
def __init__(
17+
self,
18+
a: MM2,
19+
f_y: MPA,
20+
gamma_m0: DIMENSIONLESS,
21+
) -> None:
22+
r"""[$N_{pl,Rd}$] Plastic design resistance of the cross-section [$N$].
23+
24+
NEN-EN 1993-5:2008 art.5.2.3 (9) - Formula (5.16)
25+
26+
Parameters
27+
----------
28+
a : MM2
29+
[$A$] Area of the cross-section [$mm^2$].
30+
f_y : MPA
31+
[$f_y$] Yield strength [$MPa$].
32+
gamma_m0 : DIMENSIONLESS
33+
[$\gamma_{M0}$] Partial factor according to 5.1.1 (4) [$-$].
34+
"""
35+
super().__init__()
36+
self.a = a
37+
self.f_y = f_y
38+
self.gamma_m0 = gamma_m0
39+
40+
@staticmethod
41+
def _evaluate(
42+
a: MM2,
43+
f_y: MPA,
44+
gamma_m0: DIMENSIONLESS,
45+
) -> N:
46+
"""Evaluates the formula, for more information see the __init__ method."""
47+
raise_if_less_or_equal_to_zero(gamma_m0=gamma_m0)
48+
raise_if_negative(f_y=f_y, a=a)
49+
50+
return (a * f_y) / gamma_m0
51+
52+
def latex(self) -> LatexFormula:
53+
"""Returns LatexFormula object for formula 5.16."""
54+
return LatexFormula(
55+
return_symbol=r"N_{pl,Rd}",
56+
result=f"{self:.3f}",
57+
equation=r"\frac{A \cdot f_y}{\gamma_{M0}}",
58+
numeric_equation=rf"\frac{{{self.a:.3f} \cdot {self.f_y:.3f}}}{{{self.gamma_m0:.3f}}}",
59+
comparison_operator_label="=",
60+
unit="N",
61+
)

docs/objects_overview/eurocode/nen_en_1993_5_2008/formulas.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ Total of 63 formulas present.
2424
| 5.13 | :heavy_check_mark: | | Form5Dot13SimplifiedBucklingCheck |
2525
| 5.14 | :x: | | |
2626
| 5.15 | :x: | | |
27-
| 5.16 | :x: | | |
27+
| 5.16 | :heavy_check_mark: | | Form5Dot16PlasticDesignResistance |
2828
| 5.17 | :x: | | |
2929
| 5.18 | :x: | | |
3030
| 5.19 | :x: | | |
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
"""Testing formula 5.16 of NEN-EN 1993-5:2008."""
2+
3+
import pytest
4+
5+
from blueprints.codes.eurocode.nen_en_1993_5_2008.chapter_5_ultimate_limit_states.formula_5_16 import Form5Dot16PlasticDesignResistance
6+
from blueprints.validations import LessOrEqualToZeroError, NegativeValueError
7+
8+
9+
class TestForm5Dot16PlasticDesignResistance:
10+
"""Validation for formula 5.16 from NEN-EN 1993-5:2008."""
11+
12+
def test_evaluation(self) -> None:
13+
"""Test the evaluation of the result."""
14+
# Example values
15+
a = 5000 # MM2
16+
f_y = 355 # MPA
17+
gamma_m0 = 1.0 # DIMENSIONLESS
18+
19+
# Object to test
20+
formula = Form5Dot16PlasticDesignResistance(a=a, f_y=f_y, gamma_m0=gamma_m0)
21+
22+
# Expected result, manually calculated
23+
manually_calculated_result = 1775000.0 # N
24+
25+
assert formula == pytest.approx(manually_calculated_result, rel=1e-4)
26+
27+
@pytest.mark.parametrize(
28+
("a", "f_y", "gamma_m0"),
29+
[
30+
(-5000, 355, 1.0), # a is negative
31+
(5000, -355, 1.0), # f_y is negative
32+
(5000, 355, -1.0), # gamma_m0 is negative
33+
(5000, 355, 0), # gamma_m0 is zero
34+
],
35+
)
36+
def test_raise_error_when_invalid_values_are_given(self, a: float, f_y: float, gamma_m0: float) -> None:
37+
"""Test invalid values."""
38+
with pytest.raises((LessOrEqualToZeroError, NegativeValueError)):
39+
Form5Dot16PlasticDesignResistance(a=a, f_y=f_y, gamma_m0=gamma_m0)
40+
41+
@pytest.mark.parametrize(
42+
("representation", "expected"),
43+
[
44+
(
45+
"complete",
46+
r"N_{pl,Rd} = \frac{A \cdot f_y}{\gamma_{M0}} = \frac{5000.000 \cdot 355.000}{1.000} = 1775000.000 N",
47+
),
48+
("short", r"N_{pl,Rd} = 1775000.000 N"),
49+
],
50+
)
51+
def test_latex(self, representation: str, expected: str) -> None:
52+
"""Test the latex representation of the formula."""
53+
# Example values
54+
a = 5000 # MM2
55+
f_y = 355 # MPA
56+
gamma_m0 = 1.0 # DIMENSIONLESS
57+
58+
# Object to test
59+
latex = Form5Dot16PlasticDesignResistance(a=a, f_y=f_y, gamma_m0=gamma_m0).latex()
60+
61+
actual = {
62+
"complete": latex.complete,
63+
"short": latex.short,
64+
}
65+
66+
assert expected == actual[representation], f"{representation} representation failed."

0 commit comments

Comments
 (0)