-
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.
Add formula 6.5 for NEN-EN 1993-1-1_c2_a1_2016 including init files a…
…nd test files
- Loading branch information
1 parent
352c880
commit 9fea11f
Showing
4 changed files
with
96 additions
and
0 deletions.
There are no files selected for viewing
1 change: 1 addition & 0 deletions
1
...ints/codes/eurocode/nen_en_1993_1_1_c2_a1_2016/chapter_6_ultimate_limit_state/__init__.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 @@ | ||
"""Module containing all formulas from 1993-1-1+C2+A1:2016: Chapter 6 - Ultimate limit state.""" |
44 changes: 44 additions & 0 deletions
44
...s/codes/eurocode/nen_en_1993_1_1_c2_a1_2016/chapter_6_ultimate_limit_state/formula_6_5.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,44 @@ | ||
"""Formula 6.5 from NEN-EN 1993-1-1+C2+A1:2016: Chapter 6 - Ultimate limit state.""" | ||
# pylint: disable=arguments-differ | ||
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.type_alias import KN | ||
|
||
|
||
class Form6Dot5UnityCheckTensileStrength(Formula): | ||
"""Class representing formula 6.5 for the unity check for tensile strength.""" | ||
|
||
label = "6.5" | ||
source_document = NEN_EN_1993_1_1_C2_A1_2016 | ||
|
||
def __init__( | ||
self, | ||
n_ed: KN, | ||
n_t_rd: KN, | ||
) -> None: | ||
"""[N_ed/N_t_rd] Unity check for tensile strength of an element in tension. | ||
NEN-EN 1993-1-1+C2+A1:2016 art.6.2.3(1) - Formula (6.5) | ||
Parameters | ||
---------- | ||
n_ed : KN | ||
[NEd] Design value of the normal tensile force [kN]. | ||
n_t_rd : KN | ||
[Nt,Rd] Design value of the resistance against tenslie force [kN]. | ||
""" | ||
super().__init__() | ||
self.n_ed = n_ed | ||
self.n_t_rd = n_t_rd | ||
|
||
@staticmethod | ||
def _evaluate( | ||
n_ed: KN, | ||
n_t_rd: KN, | ||
) -> None: | ||
"""Evaluates the formula, for more information see the __init__ method""" | ||
if n_t_rd <= 0: | ||
raise ValueError(f"Negative or zero n_t_rd: {n_t_rd}. n_t_rd cannot zero or be negative") | ||
if n_ed < 0: | ||
raise ValueError(f"Negative n_ed: {n_ed}. n_ed cannot be negative (that would be compression).") | ||
return n_ed / n_t_rd |
1 change: 1 addition & 0 deletions
1
tests/codes/eurocode/nen_en_1993_1_1_c2_a1_2016/chapter_6_ultimate_limit_state/__init__.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 @@ | ||
"""Module containing all formulas from NEN_EN_1993_1_1_C2_A1_2016: Chapter 6 - Ultimate limit state.""" |
50 changes: 50 additions & 0 deletions
50
...es/eurocode/nen_en_1993_1_1_c2_a1_2016/chapter_6_ultimate_limit_state/test_formula_6_5.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,50 @@ | ||
"""Testing formula 6.5 of NEN-EN 1993-1-1+C2+A1:2016.""" | ||
# pylint: disable=arguments-differ | ||
import pytest | ||
|
||
from blueprints.codes.eurocode.nen_en_1993_1_1_c2_a1_2016.chapter_6_ultimate_limit_state.formula_6_5 import Form6Dot5UnityCheckTensileStrength | ||
|
||
# pylint: disable=arguments-differ | ||
|
||
|
||
class TestForm6Dot5UnityCheckTensileStrength: | ||
"""Validation for formula 6.5 from NEN-EN 1993-1-1+C2+A1:2016.""" | ||
|
||
def test_evaluation(self): | ||
"""Test the evaluation of the result.""" | ||
# Example values | ||
n_ed = 7 # kN | ||
n_t_rd = 10 # kN | ||
form = Form6Dot5UnityCheckTensileStrength(n_ed=n_ed, n_t_rd=n_t_rd) | ||
|
||
# Expected result, manually calculated | ||
expected = 0.7 | ||
|
||
assert form == expected | ||
|
||
def test_raise_error_when_negative_n_ed_is_given(self): | ||
"""Test a negative value for v_rd_s.""" | ||
# Example values | ||
n_ed = -7 | ||
n_t_rd = 10 | ||
|
||
with pytest.raises(ValueError): | ||
Form6Dot5UnityCheckTensileStrength(n_ed=n_ed, n_t_rd=n_t_rd) | ||
|
||
def test_raise_error_when_negative_n__t_rd_is_given(self): | ||
"""Test a negative value for v_ccd.""" | ||
# Example values | ||
n_ed = 7 | ||
n_t_rd = -10 | ||
|
||
with pytest.raises(ValueError): | ||
Form6Dot5UnityCheckTensileStrength(n_ed=n_ed, n_t_rd=n_t_rd) | ||
|
||
def test_raise_error_when_zero_n_t_rd_is_given(self): | ||
"""Test a negative value for v_td.""" | ||
# Example values | ||
n_ed = 10 | ||
n_t_rd = 0 | ||
|
||
with pytest.raises(ValueError): | ||
Form6Dot5UnityCheckTensileStrength(n_ed=n_ed, n_t_rd=n_t_rd) |