Skip to content

Commit

Permalink
Merge pull request #20 from Blueprints-org/11-feature-request-add-for…
Browse files Browse the repository at this point in the history
…mulas-3_3_till_3_16

Add formulas 3.3 - 3.10 from 1992-1-1+C2:2011
  • Loading branch information
egarciamendez authored Nov 30, 2023
2 parents a8ae936 + b395373 commit 4642bcb
Show file tree
Hide file tree
Showing 15 changed files with 1,196 additions and 318 deletions.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@


class Form7Dot3CoefficientKc(Formula):
"""Class representing the formula 7.3 for the coefficient kc for flanges of tubular cross-sections and T-sections [-]."""
"""Class representing the formula 7.3 for the coefficient kc for flanges of tubular cross-sections and T-sections."""

label = "7.3"
source_document = NEN_EN_1992_1_1_C2_2011
Expand Down Expand Up @@ -44,7 +44,7 @@ def _evaluate(
a_ct: MM2,
f_ct_eff: MPA,
) -> float:
"""Evaluates the formula, for more infor see the __init__ method"""
"""Evaluates the formula, for more information see the __init__ method"""
if a_ct <= 0:
raise ValueError("The value of a_ct must be greater than zero.")
if f_ct_eff <= 0:
Expand Down
2 changes: 2 additions & 0 deletions blueprints/type_alias.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,5 @@
KN = float
MM2 = float
MPA = float
MM = float
DAYS = float
612 changes: 306 additions & 306 deletions docs/source/codes/eurocode/ec2_1992_1_1_2011/equations.md

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
"""Testing formula 3.10 of NEN-EN 1992-1-1+C2:2011."""
# pylint: disable=arguments-differ
import pytest

from blueprints.codes.eurocode.nen_en_1992_1_1_c2_2011.chapter_3_materials import Form3Dot10CoefficientAgeConcreteDryingShrinkage


class TestForm3Dot10CoefficientAgeConcreteDryingShrinkage:
"""Validation for formula 3.10 from NEN-EN 1992-1-1+C2:2011."""

def test_evaluation(self) -> None:
"""Test the evaluation of the result."""
# Example values
t = 10 # -
t_s = 2 # -
h_0 = 200 # -
form_3_10 = Form3Dot10CoefficientAgeConcreteDryingShrinkage(t=t, t_s=t_s, h_0=h_0)

# Expected result, manually calculated
manually_calculated_result = 0.06604088

assert form_3_10 == pytest.approx(expected=manually_calculated_result, rel=1e-4)

def test_raise_error_when_negative_t_is_given(self) -> None:
"""Test a negative value."""
# Example values
t = -10 # -
t_s = 2 # -
h_0 = 200 # -

with pytest.raises(ValueError):
Form3Dot10CoefficientAgeConcreteDryingShrinkage(t=t, t_s=t_s, h_0=h_0)

def test_raise_error_when_negative_t_s_is_given(self) -> None:
"""Test a negative value."""
# Example values
t = 10 # -
t_s = -2 # -
h_0 = 200 # -

with pytest.raises(ValueError):
Form3Dot10CoefficientAgeConcreteDryingShrinkage(t=t, t_s=t_s, h_0=h_0)

def test_raise_error_when_negative_h_0_is_given(self) -> None:
"""Test a negative value."""
# Example values
t = 10 # -
t_s = 2 # -
h_0 = -200 # -

with pytest.raises(ValueError):
Form3Dot10CoefficientAgeConcreteDryingShrinkage(t=t, t_s=t_s, h_0=h_0)

def test_raise_error_when_t_is_smaller_than_t_s(self) -> None:
"""Test a comparison."""
# Example values
t = 10 # -
t_s = 12 # -
h_0 = 200 # -

with pytest.raises(ValueError):
Form3Dot10CoefficientAgeConcreteDryingShrinkage(t=t, t_s=t_s, h_0=h_0)
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
"""Testing formula 3.3 of NEN-EN 1992-1-1+C2:2011."""
# pylint: disable=arguments-differ
import pytest

from blueprints.codes.eurocode.nen_en_1992_1_1_c2_2011.chapter_3_materials import Form3Dot3AxialTensileStrengthFromTensileSplittingStrength


class TestForm3Dot3AxialTensileStrengthFromTensileSplittingStrength:
"""Validation for formula 3.3 from NEN-EN 1992-1-1+C2:2011."""

def test_evaluation(self) -> None:
"""Test the evaluation of the result."""
# Example values
f_ct_sp = 3.4 # MPa
form_3_3 = Form3Dot3AxialTensileStrengthFromTensileSplittingStrength(f_ct_sp=f_ct_sp)

# Expected result, manually calculated
manually_calculated_result = 3.06

assert form_3_3 == pytest.approx(expected=manually_calculated_result, rel=1e-4)

def test_raise_error_when_negative_f_ct_sp_is_given(self) -> None:
"""Test the evaluation of the result."""
# Example values
f_ct_sp = -3.4 # MPa

with pytest.raises(ValueError):
Form3Dot3AxialTensileStrengthFromTensileSplittingStrength(f_ct_sp=f_ct_sp)
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
"""Testing formula 3.4 of NEN-EN 1992-1-1+C2:2011."""
# pylint: disable=arguments-differ
import pytest

from blueprints.codes.eurocode.nen_en_1992_1_1_c2_2011.chapter_3_materials import Form3Dot4DevelopmentTensileStrength


class TestForm3Dot4DevelopmentTensileStrength:
"""Validation for formula 3.4 from NEN-EN 1992-1-1+C2:2011."""

def test_evaluation(self) -> None:
"""Test the evaluation of the result."""
# Example values
beta_cc_t = 0.32 # -
alpha = 2 / 3 # -
f_ctm = 3.45 # MPa
form_3_4 = Form3Dot4DevelopmentTensileStrength(beta_cc_t=beta_cc_t, alpha=alpha, f_ctm=f_ctm)

# Expected result, manually calculated
manually_calculated_result = 1.614058

assert form_3_4 == pytest.approx(expected=manually_calculated_result, rel=1e-4)

def test_raise_error_when_negative_alpha_is_given(self) -> None:
"""Test that an error is raised when alpha is negative."""
# Example values
beta_cc_t = 0.32 # -> Positive
alpha = -0.4 # -> Negative
f_ctm = 3.45 # MPa -> Positive

with pytest.raises(ValueError):
Form3Dot4DevelopmentTensileStrength(beta_cc_t=beta_cc_t, alpha=alpha, f_ctm=f_ctm)

def test_raise_error_when_negative_beta_cc_t_is_given(self) -> None:
"""Test the evaluation of the result."""
# Example values
beta_cc_t = -0.32 # - -> Negative
alpha = 2 / 3 # - -> Equal to 1 or 2/3
f_ctm = 3.45 # MPa -> Positive

with pytest.raises(ValueError):
Form3Dot4DevelopmentTensileStrength(beta_cc_t=beta_cc_t, alpha=alpha, f_ctm=f_ctm)

def test_raise_error_when_negative_f_ctm_is_given(self) -> None:
"""Test the evaluation of the result."""
# Example values
beta_cc_t = 0.32 # - -> Positive
alpha = 2 / 3 # - -> unequal to 1 or 2/3
f_ctm = -3.45 # MPa -> Negative

with pytest.raises(ValueError):
Form3Dot4DevelopmentTensileStrength(beta_cc_t=beta_cc_t, alpha=alpha, f_ctm=f_ctm)
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
"""Testing formula 3.5 of NEN-EN 1992-1-1+C2:2011."""
# pylint: disable=arguments-differ
import pytest

from blueprints.codes.eurocode.nen_en_1992_1_1_c2_2011.chapter_3_materials import Form3Dot5ApproximationVarianceElasticModulusOverTime


class TestForm3Dot5ApproximationVarianceElasticModulusOverTime:
"""Validation for formula 3.5 from NEN-EN 1992-1-1+C2:2011."""

def test_evaluation(self) -> None:
"""Test the evaluation of the result."""
# Example values
f_cm_t = 2.34 # MPa
f_cm = 3.4 # MPa
e_cm = 2.9 # MPa
form_3_5 = Form3Dot5ApproximationVarianceElasticModulusOverTime(f_cm_t=f_cm_t, f_cm=f_cm, e_cm=e_cm)

# Expected result, manually calculated
manually_calculated_result = 2.592502

assert form_3_5 == pytest.approx(expected=manually_calculated_result, rel=1e-4)

def test_raise_error_when_negative_f_cm_t_is_given(self) -> None:
"""Test a negative value."""
# Example values
f_cm_t = -2.34 # MPa
f_cm = 3.4 # MPa
e_cm = 2.9 # MPa

with pytest.raises(ValueError):
Form3Dot5ApproximationVarianceElasticModulusOverTime(f_cm_t=f_cm_t, f_cm=f_cm, e_cm=e_cm)

def test_raise_error_when_negative_f_cm_is_given(self) -> None:
"""Test a negative value."""
# Example values
f_cm_t = 2.34 # MPa
f_cm = -3.4 # MPa
e_cm = 2.9 # MPa

with pytest.raises(ValueError):
Form3Dot5ApproximationVarianceElasticModulusOverTime(f_cm_t=f_cm_t, f_cm=f_cm, e_cm=e_cm)

def test_raise_error_when_negative_e_cm_is_given(self) -> None:
"""Test a negative value."""
# Example values
f_cm_t = 2.34 # MPa
f_cm = 3.4 # MPa
e_cm = -2.9 # MPa

with pytest.raises(ValueError):
Form3Dot5ApproximationVarianceElasticModulusOverTime(f_cm_t=f_cm_t, f_cm=f_cm, e_cm=e_cm)
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
"""Testing formula 3.6 of NEN-EN 1992-1-1+C2:2011."""
# pylint: disable=arguments-differ
import pytest

from blueprints.codes.eurocode.nen_en_1992_1_1_c2_2011.chapter_3_materials import Form3Dot6CreepDeformationOfConcrete


class TestForm3Dot6CreepDeformationOfConcrete:
"""Validation for formula 3.6 from NEN-EN 1992-1-1+C2:2011."""

def test_evaluation(self) -> None:
"""Test the evaluation of the result."""
# Example values
phi_inf_t0 = 0.34 # -
sigma_c = 0.75 # MPa
e_c = 2.45 # MPa
form_3_6 = Form3Dot6CreepDeformationOfConcrete(phi_inf_t0=phi_inf_t0, sigma_c=sigma_c, e_c=e_c)

# Expected result, manually calculated
manually_calculated_result = 0.1040816

assert form_3_6 == pytest.approx(expected=manually_calculated_result, rel=1e-4)

def test_raise_error_when_negative_phi_inf_t0_is_given(self) -> None:
"""Test the evaluation of the result."""
# Example values
phi_inf_t0 = -0.34 # -
sigma_c = 0.75 # MPa
e_c = 2.45 # MPa

with pytest.raises(ValueError):
Form3Dot6CreepDeformationOfConcrete(phi_inf_t0=phi_inf_t0, sigma_c=sigma_c, e_c=e_c)

def test_raise_error_when_negative_sigma_c_is_given(self) -> None:
"""Test the evaluation of the result."""
# Example values
phi_inf_t0 = 0.34 # -
sigma_c = -0.75 # MPa
e_c = 2.45 # MPa

with pytest.raises(ValueError):
Form3Dot6CreepDeformationOfConcrete(phi_inf_t0=phi_inf_t0, sigma_c=sigma_c, e_c=e_c)

def test_raise_error_when_negative_e_c_is_given(self) -> None:
"""Test the evaluation of the result."""
# Example values
phi_inf_t0 = 0.34 # -
sigma_c = 0.75 # MPa
e_c = -2.45 # MPa

with pytest.raises(ValueError):
Form3Dot6CreepDeformationOfConcrete(phi_inf_t0=phi_inf_t0, sigma_c=sigma_c, e_c=e_c)
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
"""Testing formula 3.7 of NEN-EN 1992-1-1+C2:2011."""
# pylint: disable=arguments-differ
import pytest

from blueprints.codes.eurocode.nen_en_1992_1_1_c2_2011.chapter_3_materials import Form3Dot7NonLinearCreepCoefficient


class TestForm3Dot7NonLinearCreepCoefficient:
"""Validation for formula 3.7 from NEN-EN 1992-1-1+C2:2011."""

def test_evaluation(self) -> None:
"""Test the evaluation of the result."""
# Example values
phi_inf_t0 = 0.25 # -
k_sigma = 2.47 # days
form_3_7 = Form3Dot7NonLinearCreepCoefficient(phi_inf_t0=phi_inf_t0, k_sigma=k_sigma)

# Expected result, manually calculated
manually_calculated_result = 5.174308

assert form_3_7 == pytest.approx(expected=manually_calculated_result, rel=1e-4)

def test_raise_error_when_negative_phi_inf_t0_is_given(self) -> None:
"""Test the evaluation of the result."""
# Example values
phi_inf_t0 = -0.25 # -
k_sigma = 2.47 # days

with pytest.raises(ValueError):
Form3Dot7NonLinearCreepCoefficient(phi_inf_t0=phi_inf_t0, k_sigma=k_sigma)

def test_raise_error_when_negative_k_sigma_is_given(self) -> None:
"""Test the evaluation of the result."""
# Example values
phi_inf_t0 = 0.25 # -
k_sigma = -2.47 # days

with pytest.raises(ValueError):
Form3Dot7NonLinearCreepCoefficient(phi_inf_t0=phi_inf_t0, k_sigma=k_sigma)
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
"""Testing formula 3.8 of NEN-EN 1992-1-1+C2:2011."""
# pylint: disable=arguments-differ
import pytest

from blueprints.codes.eurocode.nen_en_1992_1_1_c2_2011.chapter_3_materials import Form3Dot8TotalShrinkage


class TestForm3Dot8TotalShrinkage:
"""Validation for formula 3.8 from NEN-EN 1992-1-1+C2:2011."""

def test_evaluation(self) -> None:
"""Test the evaluation of the result."""
# Example values
epsilon_cd = 0.25 # -
epsilon_ca = 0.33 # -
form_3_8 = Form3Dot8TotalShrinkage(epsilon_cd=epsilon_cd, epsilon_ca=epsilon_ca)

# Expected result, manually calculated
manually_calculated_result = 0.58

assert form_3_8 == pytest.approx(expected=manually_calculated_result, rel=1e-4)

def test_evaluation_2(self) -> None:
"""Test the evaluation of the result."""
# Example values
epsilon_cd = -0.25 # -
epsilon_ca = 0.33 # -
form_3_8 = Form3Dot8TotalShrinkage(epsilon_cd=epsilon_cd, epsilon_ca=epsilon_ca)

# Expected result, manually calculated
manually_calculated_result = 0.08

assert form_3_8 == pytest.approx(expected=manually_calculated_result, rel=1e-4)
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
"""Testing formula 3.9 of NEN-EN 1992-1-1+C2:2011."""
# pylint: disable=arguments-differ
import pytest

from blueprints.codes.eurocode.nen_en_1992_1_1_c2_2011.chapter_3_materials import Form3Dot9DryingShrinkage


class TestForm3Dot9DryingShrinkage:
"""Validation for formula 3.9 from NEN-EN 1992-1-1+C2:2011."""

def test_evaluation(self) -> None:
"""Test the evaluation of the result."""
# Example values
beta_ds_tt_s = 0.25 # -
k_h = 0.75 # -
epsilon_cd_0 = 0.44 # -
form_3_9 = Form3Dot9DryingShrinkage(beta_ds_tt_s=beta_ds_tt_s, k_h=k_h, epsilon_cd_0=epsilon_cd_0)

# Expected result, manually calculated
manually_calculated_result = 0.0825

assert form_3_9 == pytest.approx(expected=manually_calculated_result, rel=1e-4)

def test_raise_error_when_negative_beta_ds_tt_s_is_given(self) -> None:
"""Test that an error is raised when beta_ds_tt_s is negative"""
# Example values
beta_ds_tt_s = -0.25 # -
k_h = 0.75 # -
epsilon_cd_0 = 0.44 # -

with pytest.raises(ValueError):
Form3Dot9DryingShrinkage(beta_ds_tt_s=beta_ds_tt_s, k_h=k_h, epsilon_cd_0=epsilon_cd_0)

def test_raise_error_when_negative_k_h_is_given(self) -> None:
"""Test that an error is raised when k_h is negative"""
# Example values
beta_ds_tt_s = 0.25 # -
k_h = -0.75 # -
epsilon_cd_0 = 0.44 # -

with pytest.raises(ValueError):
Form3Dot9DryingShrinkage(beta_ds_tt_s=beta_ds_tt_s, k_h=k_h, epsilon_cd_0=epsilon_cd_0)
Loading

0 comments on commit 4642bcb

Please sign in to comment.