Skip to content

Commit

Permalink
Merge pull request #348 from Blueprints-org/324-feature-request-add-l…
Browse files Browse the repository at this point in the history
…atex-to-existing-formulas-from-1992-1-1-chapter-3

324 feature request add latex to existing formulas from 1992 1 1 chapter 3
  • Loading branch information
egarciamendez authored Sep 8, 2024
2 parents 3ff05f6 + d37a842 commit eb2c6f3
Show file tree
Hide file tree
Showing 65 changed files with 1,330 additions and 190 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

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 MPA
from blueprints.validations import raise_if_negative

Expand Down Expand Up @@ -46,3 +47,13 @@ def _evaluate(
"""Evaluates the formula, for more information see the __init__ method."""
raise_if_negative(beta_cc_t=beta_cc_t, f_cm=f_cm)
return beta_cc_t * f_cm

def latex(self) -> LatexFormula:
"""Returns LatexFormula object for formula 3.1."""
return LatexFormula(
return_symbol=r"f_{cm}(t)",
result=f"{self:.3f}",
equation=r"\beta_{cc}(t) \cdot f_{cm}",
numeric_equation=rf"{self.beta_cc_t:.3f} \cdot {self.f_cm:.3f}",
comparison_operator_label="=",
)
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

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 DAYS, MM, MM2


Expand Down Expand Up @@ -60,6 +61,16 @@ def _evaluate(
raise ValueError(f"Invalid h_0: {h_0}. h_0 cannot be negative or zero")
return (t - t_s) / ((t - t_s) + 0.04 * np.sqrt(h_0**3))

def latex(self) -> LatexFormula:
"""Returns LatexFormula object for formula 3.10 formula."""
return LatexFormula(
return_symbol=r"\beta_{ds}(t,t_s)",
result=f"{self:.3f}",
equation=r"\frac{(t - t_s)}{(t - t_s) + 0.04 \sqrt{h_0^3}}",
numeric_equation=rf"\frac{{({self.t:.2f} - {self.t_s:.2f})}}{{({self.t:.2f} - {self.t_s:.2f}) + 0.04 \sqrt{{{self.h_0:.2f}^3}}}}",
comparison_operator_label="=",
)


class SubForm3Dot10FictionalCrossSection(Formula):
"""Class representing sub-formula for formula 3.10 for the calculation of fictional thickness of the cross-section."""
Expand Down Expand Up @@ -98,3 +109,13 @@ def _evaluate(
if u <= 0:
raise ValueError(f"Invalid u: {u}. u cannot be negative or zero")
return 2 * a_c / u

def latex(self) -> LatexFormula:
"""Returns LatexFormula object for formula 3.10 subformula."""
return LatexFormula(
return_symbol=r"h_0",
result=f"{self:.2f}",
equation=r"2 \cdot A_c / u",
numeric_equation=rf"2 \cdot {self.a_c:.2f} / {self.u:.2f}",
comparison_operator_label="=",
)
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

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


class Form3Dot11AutogeneShrinkage(Formula):
Expand Down Expand Up @@ -47,3 +48,13 @@ def _evaluate(
if beta_as_t < 0:
raise ValueError(f"Invalid beta_as_t: {beta_as_t}. beta_as_t cannot be negative")
return beta_as_t * epsilon_ca_inf

def latex(self) -> LatexFormula:
"""Returns LatexFormula object for formula 3.11."""
return LatexFormula(
return_symbol=r"\epsilon_{ca}(t)",
result=f"{self:.3f}",
equation=r"\beta_{as}(t) \cdot \epsilon_{ca}(\infty)",
numeric_equation=rf"{self.beta_as_t:.3f} \cdot {self.epsilon_ca_inf:.3f}",
comparison_operator_label="=",
)
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

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 MPA


Expand Down Expand Up @@ -39,3 +40,13 @@ def _evaluate(
if f_ck < 0:
raise ValueError(f"Invalid f_ck: {f_ck}. f_ck cannot be negative")
return 2.5 * (f_ck - 10) * 10**-6

def latex(self) -> LatexFormula:
"""Returns LatexFormula object for formula 3.12."""
return LatexFormula(
return_symbol=r"\epsilon_{ca}(\infty)",
result=f"{self:.6f}",
equation=r"2.5 \cdot (f_{ck} - 10) \cdot 10^{-6}",
numeric_equation=rf"2.5 \cdot ({self.f_ck:.3f} - 10) \cdot 10^{{-6}}",
comparison_operator_label="=",
)
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

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 DAYS


Expand Down Expand Up @@ -41,3 +42,13 @@ def _evaluate(
if t < 0:
raise ValueError(f"Invalid t: {t}. t cannot be negative")
return 1 - np.exp(-0.2 * t**0.5)

def latex(self) -> LatexFormula:
"""Returns LatexFormula object for formula 3.13."""
return LatexFormula(
return_symbol=r"\beta_{as}(t)",
result=f"{self:.3f}",
equation=r"1 - \exp(-0.2 \cdot t^{0.5})",
numeric_equation=rf"1 - \exp(-0.2 \cdot {self.t:.2f}^{{0.5}})",
comparison_operator_label="=",
)
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

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 MPA


Expand Down Expand Up @@ -51,6 +52,16 @@ def _evaluate(
raise ValueError(f"Invalid eta: {eta}. eta cannot be negative")
return (k * eta - eta**2) / (1 + (k - 2) * eta)

def latex(self) -> LatexFormula:
"""Returns LatexFormula object for formula 3.14."""
return LatexFormula(
return_symbol=r"\frac{\sigma_c}{f_{cm}}",
result=f"{self:.3f}",
equation=r"\frac{k \cdot \eta - \eta^2}{1 + (k-2) \cdot \eta}",
numeric_equation=rf"\frac{{{self.k:.3f} \cdot {self.eta:.3f} - {self.eta:.3f}^2}}{{1 + ({self.k:.3f}-2) \cdot {self.eta:.3f}}}",
comparison_operator_label="=",
)


class SubForm3Dot14Eta(Formula):
"""Class representing sub-formula 1 for formula 3.14, which calculates eta."""
Expand Down Expand Up @@ -86,6 +97,16 @@ def _evaluate(
"""Evaluates the formula, for more information see the __init__ method."""
return epsilon_c / epsilon_c1

def latex(self) -> LatexFormula:
"""Returns LatexFormula object for formula 3.14 sub 1."""
return LatexFormula(
return_symbol=r"\eta",
result=f"{self:.3f}",
equation=r"\epsilon_c / \epsilon_{c1}",
numeric_equation=rf"{self.epsilon_c:.3f} / {self.epsilon_c1:.3f}",
comparison_operator_label="=",
)


class SubForm3Dot14K(Formula):
"""Class representing sub-formula 2 for formula 3.14, which calculates k."""
Expand Down Expand Up @@ -124,3 +145,13 @@ def _evaluate(
if f_cm <= 0:
raise ValueError(f"Invalid f_cm: {f_cm}. f_cm cannot be negative or zero")
return 1.05 * e_cm * abs(epsilon_c1) / f_cm

def latex(self) -> LatexFormula:
"""Returns LatexFormula object for formula 3.14 sub 2."""
return LatexFormula(
return_symbol=r"k",
result=f"{self:.3f}",
equation=r"1.05 \cdot E_{cm} \cdot |\epsilon_{c1}| / f_{cm}",
numeric_equation=rf"1.05 \cdot {self.e_cm:.3f} \cdot |{self.epsilon_c1:.3f}| / {self.f_cm:.3f}",
comparison_operator_label="=",
)
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

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 MPA


Expand Down Expand Up @@ -54,3 +55,13 @@ def _evaluate(
if gamma_c <= 0:
raise ValueError(f"Invalid gamma_c: {gamma_c}. gamma_c cannot be negative or zero")
return alpha_cc * f_ck / gamma_c

def latex(self) -> LatexFormula:
"""Returns LatexFormula object for formula 3.15."""
return LatexFormula(
return_symbol=r"f_{cd}",
result=f"{self:.3f}",
equation=r"\alpha_{cc} \cdot f_{ck} / \gamma_C",
numeric_equation=rf"{self.alpha_cc:.3f} \cdot {self.f_ck:.3f} / {self.gamma_c:.3f}",
comparison_operator_label="=",
)
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

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 MPA


Expand Down Expand Up @@ -54,3 +55,13 @@ def _evaluate(
if gamma_c <= 0:
raise ValueError(f"Invalid gamma_c: {gamma_c}. gamma_c cannot be negative or zero")
return alpha_ct * f_ctk_0_05 / gamma_c

def latex(self) -> LatexFormula:
"""Returns LatexFormula object for formula 3.16."""
return LatexFormula(
return_symbol=r"f_{ctd}",
result=f"{self:.3f}",
equation=r"\alpha_{ct} \cdot f_{ctk,0.05} / \gamma_C",
numeric_equation=rf"{self.alpha_ct:.3f} \cdot {self.f_ctk_0_05:.3f} / {self.gamma_c:.3f}",
comparison_operator_label="=",
)
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

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 MPA


Expand Down Expand Up @@ -58,3 +59,16 @@ def _evaluate(
if epsilon_c > epsilon_c2:
raise ValueError(f"epsilon_c: {epsilon_c} > epsilon_c2: {epsilon_c2}. Try using Form3Dot18CompressiveStressConcrete class.")
return f_cd * (1 - (1 - (epsilon_c / epsilon_c2)) ** n)

def latex(self) -> LatexFormula:
"""Returns LatexFormula object for formula 3.17."""
return LatexFormula(
return_symbol=r"\sigma_c",
result=f"{self:.3f}",
equation=r"f_{cd} \cdot \left[ 1 - \left( 1 - \frac{\epsilon_c}{\epsilon_{c2}} \right)^n \right]",
numeric_equation=(
rf"{self.f_cd:.3f} \cdot \left[ 1 - \left( 1 - \frac{{{self.epsilon_c:.3f}}}"
rf"{{{self.epsilon_c2:.3f}}} \right)^{{{self.n:.2f}}} \right]"
),
comparison_operator_label="=",
)
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

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 MPA


Expand Down Expand Up @@ -39,3 +40,13 @@ def _evaluate(
if f_cd < 0:
raise ValueError(f"Invalid f_cd: {f_cd}. f_cd cannot be negative")
return f_cd

def latex(self) -> LatexFormula:
"""Returns LatexFormula object for formula 3.18."""
return LatexFormula(
return_symbol=r"\sigma_c",
result=f"{self:.3f}",
equation=r"f_{cd}",
numeric_equation=rf"{self.f_cd:.3f}",
comparison_operator_label="=",
)
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

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 MPA


Expand Down Expand Up @@ -42,3 +43,13 @@ def _evaluate(
if f_ck <= 90:
return 0.8 - (f_ck - 50) / 400
raise ValueError(f"Invalid f_ck: {f_ck}. Maximum of f_ck is 90 MPa")

def latex(self) -> LatexFormula:
"""Returns LatexFormula object for formula 3.19 and 3.20."""
return LatexFormula(
return_symbol=r"\lambda",
result=f"{self:.3f}",
equation=r"0.8" if self.f_ck <= 50 else r"0.8 - (f_{ck} - 50) / 400",
numeric_equation=r"0.8" if self.f_ck <= 50 else rf"0.8 - ({self.f_ck:.3f} - 50) / 400",
comparison_operator_label="=",
)
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

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 DAYS


Expand All @@ -18,7 +19,7 @@ def __init__(
s: float,
t: DAYS,
) -> None:
"""Calculates beta_cc(t) coefficient which is dependent of the age of concrete in days [-].
"""[:math:`β_{cc}(t)`] Coefficient which is dependent of the age of concrete in days [-].
NEN-EN 1992-1-1+C2:2011 art.3.1.2(6) - Formula (3.2)
Expand Down Expand Up @@ -53,6 +54,16 @@ def _evaluate(
raise ValueError(f"Invalid t: {t}. t cannot be negative or zero")
return np.exp(s * (1 - (28 / t) ** (1 / 2)))

def latex(self) -> LatexFormula:
"""Returns LatexFormula object for formula 3.2."""
return LatexFormula(
return_symbol=r"\beta_{cc}(t)",
result=f"{self:.3f}",
equation=r"\exp \left( s \cdot \left( 1 - \left( \frac{28}{t} \right) ^{1/2} \right) \right)",
numeric_equation=rf"\exp \left( {self.s:.3f} \cdot \left( 1 - \left( \frac{{28}}{{{self.t:.2f}}} \right) ^{{1/2}} \right) \right)",
comparison_operator_label="=",
)


class SubForm3Dot2CoefficientTypeOfCementS(Formula):
"""Class representing sub-formula for formula 3.2, which calculates the coefficient 's' which is dependent on the cement class."""
Expand Down Expand Up @@ -94,3 +105,13 @@ def _evaluate(
return 0.38
case _:
raise ValueError(f"Invalid cement class: {cement_class}. Options: 'R', 'N' or 'S'")

def latex(self) -> LatexFormula:
"""Returns LatexFormula object for formula 3.2s."""
return LatexFormula(
return_symbol=r"s",
result=f"{self:.3f}",
equation=r"\text{cement class}",
numeric_equation=rf"{self.cement_class}",
comparison_operator_label=r"\rightarrow",
)
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@

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 MPA


class Form3Dot21And22EffectiveStrength(Formula):
"""Class representing formula 3.21 and 3.22 for the calculation of the η factor for the effective strength."""
"""[:math:`η`] Class representing formula 3.21 and 3.22 for the calculation of the factor for the effective strength [:math:`-`]."""

label = "3.21 - 3.22"
source_document = NEN_EN_1992_1_1_C2_2011
Expand All @@ -15,15 +16,15 @@ def __init__(
self,
f_ck: MPA,
) -> None:
"""[η] Factor effective strength [-].
r"""[:math:`η`] Factor effective strength [:math:`-`].
NEN-EN 1992-1-1+C2:2011 art.3.1.7(3) - Formula (3.21) and (3.22)
Parameters
----------
f_ck : MPA
[fck] Characteristic compressive strength concrete [MPa].
Valid range: f_ck <= 90.
[:math:`f_{ck}`] Characteristic compressive strength concrete [:math:`MPa`].
Valid range: :math:`f_{ck} \leq 90 MPa`.
Returns
-------
Expand All @@ -42,3 +43,13 @@ def _evaluate(
if f_ck <= 90:
return 1.0 - (f_ck - 50) / 200
raise ValueError(f"Invalid f_ck: {f_ck}. Maximum of f_ck is 90 MPa")

def latex(self) -> LatexFormula:
"""Returns LatexFormula object for formula 3.21 and 3.22."""
return LatexFormula(
return_symbol=r"\eta",
result=f"{self:.3f}",
equation=r"1.0" if self.f_ck <= 50 else r"1.0 - (f_{ck} - 50) / 200",
numeric_equation=r"1.0" if self.f_ck <= 50 else rf"1.0 - ({self.f_ck:.3f} - 50) / 200",
comparison_operator_label="=",
)
Loading

0 comments on commit eb2c6f3

Please sign in to comment.