-
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
f852164
commit 3db50e5
Showing
5 changed files
with
77 additions
and
0 deletions.
There are no files selected for viewing
1 change: 1 addition & 0 deletions
1
...ints/codes/eurocode/nen_9997_1_c2_2017/chapter_2_basic_of_geotechnical_design/__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 @@ | ||
"""Package contains the formulas from chapter 2: Basic of geotechnical design of NEN 9997-1+C2:2017.""" |
36 changes: 36 additions & 0 deletions
36
...codes/eurocode/nen_9997_1_c2_2017/chapter_2_basic_of_geotechnical_design/formula_2_1_b.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,36 @@ | ||
""""Formula 2.1b from NEN 9997-1+C2:2017: Chapter 2: Basis of geotechnical design.""" | ||
from blueprints.codes.formula import Formula | ||
from blueprints.type_alias import DIMENSIONLESS | ||
from blueprints.validations import raise_if_negative | ||
|
||
|
||
class Form2Dot1BRepresentativeValue(Formula): | ||
"""Class representing formula 2.1b for the calculation of the representative value :math:`F_{rep}` of actions.""" | ||
|
||
label = "2.1b" | ||
source_document = "NEN 9997-1+C2:2017" | ||
|
||
def __init__(self, psi: DIMENSIONLESS, f_k: float) -> None: | ||
"""[:math:`F_{rep}`] Representative value of actions. | ||
NEN 9997-1+C2:2017 art.2.4.6.1(2) - Formula (2.1b) | ||
Parameters | ||
---------- | ||
psi : DIMENSIONLESS | ||
[:math:`Ψ`] factor for converting the characteristic value to the representative value [-]. | ||
f_k : float | ||
[:math:`F_{k}`] Characteristic value of actions. | ||
""" | ||
super().__init__() | ||
self.psi = psi | ||
self.f_k = f_k | ||
|
||
@staticmethod | ||
def _evaluate( | ||
psi: DIMENSIONLESS, | ||
f_k: float, | ||
) -> float: | ||
"""Evaluates the formula, for more information see the __init__ method.""" | ||
raise_if_negative(psi=psi, f_k=f_k) | ||
return psi * f_k |
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 @@ | ||
"""Package contains tests for the formulas of NEN 9997-1-C2:2017.""" |
1 change: 1 addition & 0 deletions
1
tests/codes/eurocode/nen_9997_1_c2_2017/chapter_2_basic_of_geotechnical_design/__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 @@ | ||
"""Package contains the tests for the formulas from chapter 2: Basic of geotechnical design of NEN 9997-1+C2:2017.""" |
38 changes: 38 additions & 0 deletions
38
.../eurocode/nen_9997_1_c2_2017/chapter_2_basic_of_geotechnical_design/test_formula_2_1_b.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,38 @@ | ||
""""Testing Formula 2.1b from NEN 9997-1+C2:2017: Chapter 2: Basis of geotechnical design.""" | ||
import pytest | ||
|
||
from blueprints.codes.eurocode.nen_9997_1_c2_2017.chapter_2_basic_of_geotechnical_design.formula_2_1_b import Form2Dot1BRepresentativeValue | ||
from blueprints.validations import NegativeValueError | ||
|
||
|
||
class TestForm2Dot1BRepresentativeValue: | ||
"""Validation for formula 2.1b from NEN 9997-1+C2:2017.""" | ||
|
||
def test_evaluation(self) -> None: | ||
"""Test the evaluation of the result.""" | ||
# example values | ||
psi = 1.2 # [-] | ||
f_k = 100 # kN | ||
|
||
form_2_1_b = Form2Dot1BRepresentativeValue(psi=psi, f_k=f_k) | ||
|
||
# manually calculated result | ||
manually_calculated_result = 120 | ||
|
||
assert form_2_1_b == pytest.approx(expected=manually_calculated_result, rel=1e-9) | ||
|
||
def test_raise_error_if_negative_psi(self) -> None: | ||
"""Test that a NegativeValueError is raised when a negative value is passed for psi.""" | ||
psi = -1 | ||
f_k = 100 | ||
|
||
with pytest.raises(NegativeValueError): | ||
Form2Dot1BRepresentativeValue(psi=psi, f_k=f_k) | ||
|
||
def test_raise_error_if_negative_f_k(self) -> None: | ||
"""Test that a NegativeValueError is raised when a negative value is passed for f_k.""" | ||
psi = 1.2 | ||
f_k = -100 | ||
|
||
with pytest.raises(NegativeValueError): | ||
Form2Dot1BRepresentativeValue(psi=psi, f_k=f_k) |