Skip to content

Commit

Permalink
Move private functions at the end for every class
Browse files Browse the repository at this point in the history
Signed-off-by: Benjamin Maier <[email protected]>
  • Loading branch information
maierbn committed Oct 10, 2023
1 parent 900ecc2 commit f7f10dc
Show file tree
Hide file tree
Showing 9 changed files with 1,116 additions and 1,119 deletions.
554 changes: 276 additions & 278 deletions src/pylife/materiallaws/notch_approximation_law.py

Large diffs are not rendered by default.

393 changes: 196 additions & 197 deletions src/pylife/materiallaws/notch_approximation_law_seegerbeste.py

Large diffs are not rendered by default.

22 changes: 11 additions & 11 deletions src/pylife/strength/damage_parameter.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,10 @@ def __init__(self, collective, assessment_parameters):

self._compute_values()

@property
def collective(self):
return self._collective

def _compute_values(self):
"""Compute the P_RAM damage parameter according to FKM nonlinear.
"""
Expand Down Expand Up @@ -78,11 +82,7 @@ def _compute_values(self):

# delete temporary columns
self._collective.drop(columns = ["discriminant", "k"], inplace=True)

@property
def collective(self):
return self._collective


class P_RAJ:

def __init__(self, collective, assessment_parameters, component_woehler_curve_P_RAJ):
Expand Down Expand Up @@ -160,7 +160,10 @@ def __init__(self, collective, assessment_parameters, component_woehler_curve_P_
self._P_RAJ_D_0.reset_index(drop=True, inplace=True)

self._compute_values()


@property
def collective(self):

def _compute_values(self):
"""Compute the P_RAJ damage parameter according to FKM nonlinear.
"""
Expand Down Expand Up @@ -262,8 +265,7 @@ def _calculate_fatigue_limit_variables(self, D_akt):
#P_RAJ_D = pd.Series(self._P_RAJ_D_0)

return a_0, delta_J_eff_th, P_RAJ_D



def _compute_crack_opening_loop(self):
"""compute crack opening strain with history (chapter 2.8.9.3, chapter 2.9.8.1 is better)"""

Expand Down Expand Up @@ -553,7 +555,5 @@ def optimize(row):
self._assessment_parameters.P_RAJ_klass_max = self._calculate_P_RAJ(delta_stress, delta_strain)



@property
def collective(self):

return self._collective
120 changes: 60 additions & 60 deletions src/pylife/strength/fkm_load_distribution.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,66 +94,6 @@ class FKMLoadSequence(PylifeSignal):
mesh.fkm_load_sequence.scaled_by_constant(2)
'''

def _validate(self):
if len(self._obj) == 0:
raise AttributeError("Load series is empty.")

def _validate_parameters(self, input_parameters, required_parameters):

for required_parameter in required_parameters:
if required_parameter not in input_parameters:
raise ValueError(f"Given parameters have to include \"{required_parameter}\".")

def _get_beta(self, input_parameters):
"""
Compute a scaling factor for assessing a load sequence for a given failure probability,
for details, refer to the FKM nonlinear document.
The beta factors are also described in "A. Fischer. Bestimmung modifizierter Teilsicherheitsbeiwerte zur semiprobabilistischen
Bemessung von Stahlbetonkonstruktionen im Bestand. TU Kaiserslautern, 2010"
Parameters
----------
input_parameters : pd.Series
The set of assessment parameters, has to contain the assessment failure probability ``input_parameters.P_A``.
This variable has to be one of {1e-7, 1e-6, 1e-5, 7.2e-5, 1e-3, 2.3e-1, 0.5}.
Raises
------
ValueError
If the given failure probability has an invalid value.
Returns
-------
float
The value of the beta parameter.
"""

if np.isclose(input_parameters.P_A, 1e-7):
return 5.20

elif np.isclose(input_parameters.P_A, 1e-6):
return 4.75

elif np.isclose(input_parameters.P_A, 1e-5):
return 4.27

elif np.isclose(input_parameters.P_A, 7.2e-5):
return 3.8

elif np.isclose(input_parameters.P_A, 1e-3):
return 3.09

elif np.isclose(input_parameters.P_A, 2.3e-1):
return 0.739

elif np.isclose(input_parameters.P_A, 0.5):
return 0

else:
raise ValueError(f"P_A={input_parameters.P_A} has to be one of "+"{1e-7, 1e-6, 1e-5, 7.2e-5, 1e-3, 2.3e-1, 0.5}.")

def scaled_by_constant(self, gamma_L):
"""
Scales the load sequence by the given constant gamma_L. This method basically computes
Expand Down Expand Up @@ -243,6 +183,66 @@ def maximum_absolute_load(self, max_load_independently_for_nodes=False):

return float(L_max)

def _validate(self):
if len(self._obj) == 0:
raise AttributeError("Load series is empty.")

def _validate_parameters(self, input_parameters, required_parameters):

for required_parameter in required_parameters:
if required_parameter not in input_parameters:
raise ValueError(f"Given parameters have to include \"{required_parameter}\".")

def _get_beta(self, input_parameters):
"""
Compute a scaling factor for assessing a load sequence for a given failure probability,
for details, refer to the FKM nonlinear document.
The beta factors are also described in "A. Fischer. Bestimmung modifizierter Teilsicherheitsbeiwerte zur semiprobabilistischen
Bemessung von Stahlbetonkonstruktionen im Bestand. TU Kaiserslautern, 2010"
Parameters
----------
input_parameters : pd.Series
The set of assessment parameters, has to contain the assessment failure probability ``input_parameters.P_A``.
This variable has to be one of {1e-7, 1e-6, 1e-5, 7.2e-5, 1e-3, 2.3e-1, 0.5}.
Raises
------
ValueError
If the given failure probability has an invalid value.
Returns
-------
float
The value of the beta parameter.
"""

if np.isclose(input_parameters.P_A, 1e-7):
return 5.20

elif np.isclose(input_parameters.P_A, 1e-6):
return 4.75

elif np.isclose(input_parameters.P_A, 1e-5):
return 4.27

elif np.isclose(input_parameters.P_A, 7.2e-5):
return 3.8

elif np.isclose(input_parameters.P_A, 1e-3):
return 3.09

elif np.isclose(input_parameters.P_A, 2.3e-1):
return 0.739

elif np.isclose(input_parameters.P_A, 0.5):
return 0

else:
raise ValueError(f"P_A={input_parameters.P_A} has to be one of "+"{1e-7, 1e-6, 1e-5, 7.2e-5, 1e-3, 2.3e-1, 0.5}.")


@pd.api.extensions.register_dataframe_accessor("fkm_safety_normal_from_stddev")
@pd.api.extensions.register_series_accessor("fkm_safety_normal_from_stddev")
Expand Down
Loading

0 comments on commit f7f10dc

Please sign in to comment.