-
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.
- Loading branch information
1 parent
be84fc6
commit 8598f76
Showing
3 changed files
with
102 additions
and
1 deletion.
There are no files selected for viewing
47 changes: 47 additions & 0 deletions
47
...ints/codes/eurocode/nen_en_1992_1_1_c2_2011/chapter_5_structural_analysis/formula_5_20.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,47 @@ | ||
"""Formula 5.20 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 | ||
from blueprints.type_alias import DIMENSIONLESS, MPA | ||
from blueprints.validations import raise_if_less_or_equal_to_zero | ||
|
||
|
||
class Form5Dot20DesignModulusElasticity(Formula): | ||
"""Class representing formula 5.20 for the calculation of the design modulus of elasticity, Ecd.""" | ||
|
||
label = "5.20" | ||
source_document = NEN_EN_1992_1_1_C2_2011 | ||
|
||
def __init__(self, e_cm: MPA, gamma_ce: DIMENSIONLESS = 1.2) -> None: | ||
r"""[:math:`E_{cd}`] Design modulus of elasticity. | ||
NEN-EN 1992-1-1+C2:2011 art.5.8.6(3) - Formula (5.20) | ||
Parameters | ||
---------- | ||
e_cm : MPA | ||
[:math:`E_{cm}`] is the characteristic modulus of elasticity of concrete. | ||
gamma_ce : DIMENSIONLESS, optional | ||
[:math:`\gamma_{CE}`] is the factor for the design value of the modulus of elasticity. Default is 1.2. | ||
""" | ||
super().__init__() | ||
self.e_cm = e_cm | ||
self.gamma_ce = gamma_ce | ||
raise_if_less_or_equal_to_zero(e_cm=e_cm, gamma_ce=gamma_ce) | ||
|
||
@staticmethod | ||
def _evaluate(e_cm: MPA, gamma_ce: DIMENSIONLESS) -> MPA: | ||
"""Evaluates the formula, for more information see the __init__ method.""" | ||
raise_if_less_or_equal_to_zero(gamma_ce=gamma_ce) | ||
return e_cm / gamma_ce | ||
|
||
def latex(self) -> LatexFormula: | ||
"""Returns LatexFormula object for formula 5.20.""" | ||
return LatexFormula( | ||
return_symbol=r"E_{cd}", | ||
result=f"{self:.3f}", | ||
equation=r"\frac{E_{cm}}{\gamma_{CE}}", | ||
numeric_equation=rf"\frac{{{self.e_cm}}}{{{self.gamma_ce}}}", | ||
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
54 changes: 54 additions & 0 deletions
54
...codes/eurocode/nen_en_1992_1_1_c2_2011/chapter_5_structural_analysis/test_formula_5_20.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,54 @@ | ||
"""Testing formula 5.20 from 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_20 import Form5Dot20DesignModulusElasticity | ||
from blueprints.validations import LessOrEqualToZeroError | ||
|
||
|
||
class TestForm5Dot20DesignModulusElasticity: | ||
"""Validation for formula 5.20 from NEN-EN 1992-1-1+C2:2011.""" | ||
|
||
@pytest.fixture | ||
def form_5_20(self) -> Form5Dot20DesignModulusElasticity: | ||
"""Setup and teardown for test.""" | ||
return Form5Dot20DesignModulusElasticity(e_cm=30000, gamma_ce=1.2) | ||
|
||
def test_evaluation(self, form_5_20: Form5Dot20DesignModulusElasticity) -> None: | ||
"""Test the evaluation of the result.""" | ||
# Expected result, manually calculated | ||
manually_calculated_result = 30000 / 1.2 | ||
assert form_5_20 == pytest.approx(manually_calculated_result, rel=1e-4) | ||
|
||
@pytest.mark.parametrize( | ||
("e_cm", "gamma_ce"), | ||
[ | ||
(30000, 0), | ||
], | ||
) | ||
def test_raise_error_when_zero_pars_are_given(self, e_cm: float, gamma_ce: float) -> None: | ||
"""Test zero values for e_cm, gamma_ce.""" | ||
with pytest.raises(LessOrEqualToZeroError): | ||
Form5Dot20DesignModulusElasticity(e_cm=e_cm, gamma_ce=gamma_ce) | ||
|
||
@pytest.mark.parametrize( | ||
("e_cm", "gamma_ce", "expected"), | ||
[ | ||
(30000, 1.2, 25000), | ||
(35000, 1.2, 29166.67), | ||
], | ||
) | ||
def test_properties(self, e_cm: float, gamma_ce: float, expected: float) -> None: | ||
"""Test the properties of the formula.""" | ||
form_5_20 = Form5Dot20DesignModulusElasticity(e_cm=e_cm, gamma_ce=gamma_ce) | ||
assert form_5_20 == pytest.approx(expected, rel=1e-4) | ||
|
||
def test_latex(self, form_5_20: Form5Dot20DesignModulusElasticity) -> None: | ||
"""Test the latex representation of the formula.""" | ||
# Object to test | ||
form_5_20_latex = form_5_20.latex() | ||
expected_complete = r"E_{cd} = \frac{E_{cm}}{\gamma_{CE}} = \frac{30000}{1.2} = 25000.000" | ||
expected_short = r"E_{cd} = 25000.000" | ||
|
||
assert form_5_20_latex.complete == expected_complete, "Complete representation failed." | ||
assert form_5_20_latex.short == expected_short, "Short representation failed." |