Skip to content

Commit 650b4e8

Browse files
Change some docstring quotes from ''' to """
Signed-off-by: Johannes Mueller <[email protected]>
1 parent 94a0c8e commit 650b4e8

File tree

1 file changed

+33
-34
lines changed

1 file changed

+33
-34
lines changed

src/pylife/materiallaws/notch_approximation_law.py

+33-34
Original file line numberDiff line numberDiff line change
@@ -39,28 +39,28 @@ def __init__(self, E, K, n, K_p=None):
3939

4040
@property
4141
def E(self):
42-
'''Young's Modulus'''
42+
"""Young's Modulus"""
4343
return self._E
4444

4545
@property
4646
def K(self):
47-
'''the strength coefficient'''
47+
"""the strength coefficient"""
4848
return self._K
4949

5050
@property
5151
def n(self):
52-
'''the strain hardening coefficient'''
52+
"""the strain hardening coefficient"""
5353
return self._n
5454

5555
@property
5656
def K_p(self):
57-
'''the shape factor (de: Traglastformzahl)'''
57+
"""the shape factor (de: Traglastformzahl)"""
5858
return self._K_p
5959

6060
@property
6161
def ramberg_osgood_relation(self):
62-
'''the Ramberg-Osgood relation object, i.e., an object of type RambergOsgood
63-
'''
62+
"""the Ramberg-Osgood relation object, i.e., an object of type RambergOsgood
63+
"""
6464
return self._ramberg_osgood_relation
6565

6666
@K_p.setter
@@ -81,7 +81,7 @@ def K(self, value):
8181

8282

8383
class ExtendedNeuber(NotchApproximationLawBase):
84-
r'''Implementation of the extended Neuber notch approximation material relation.
84+
r"""Implementation of the extended Neuber notch approximation material relation.
8585
8686
This notch approximation law is used for the P_RAM damage parameter in the FKM
8787
nonlinear guideline (2019). Given an elastic-plastic stress (and strain) from a linear FE
@@ -106,13 +106,10 @@ class ExtendedNeuber(NotchApproximationLawBase):
106106
-----
107107
The equation implemented is described in the FKM nonlinear reference, chapter 2.5.7.
108108
109-
'''
109+
"""
110110

111111
def stress(self, load, *, rtol=1e-4, tol=1e-4):
112-
'''Calculate the stress of the primary path in the stress-strain diagram at a given
113-
elastic-plastic stress (load), from a FE computation.
114-
This is done by solving for the root of f(sigma) in eq. 2.5-45 of FKM nonlinear.
115-
112+
r"""Calculate the stress of the primary path in the stress-strain diagram at a given
116113
117114
Parameters
118115
----------
@@ -132,7 +129,7 @@ def stress(self, load, *, rtol=1e-4, tol=1e-4):
132129
-------
133130
stress : array-like float
134131
The resulting elastic-plastic stress according to the notch-approximation law.
135-
'''
132+
"""
136133
stress = optimize.newton(
137134
func=self._stress_implicit,
138135
x0=load,
@@ -143,7 +140,7 @@ def stress(self, load, *, rtol=1e-4, tol=1e-4):
143140
return stress
144141

145142
def strain(self, stress, load):
146-
'''Calculate the strain of the primary path in the stress-strain diagram at a given stress and load.
143+
"""Calculate the strain of the primary path in the stress-strain diagram at a given stress and load.
147144
The formula is given by eq. 2.5-42 of FKM nonlinear.
148145
load / stress * self._K_p * e_star
149146
@@ -158,12 +155,12 @@ def strain(self, stress, load):
158155
-------
159156
strain : array-like float
160157
The resulting strain
161-
'''
158+
"""
162159

163160
return self._ramberg_osgood_relation.strain(stress)
164161

165162
def load(self, stress, *, rtol=1e-4, tol=1e-4):
166-
'''Apply the notch-approximation law "backwards", i.e., compute the linear-elastic stress (called "load" or "L" in FKM nonlinear)
163+
"""Apply the notch-approximation law "backwards", i.e., compute the linear-elastic stress (called "load" or "L" in FKM nonlinear)
167164
from the elastic-plastic stress as from the notch approximation.
168165
This backward step is needed for the pfp FKM nonlinear surface layer & roughness.
169166
@@ -185,7 +182,7 @@ def load(self, stress, *, rtol=1e-4, tol=1e-4):
185182
load : array-like float
186183
The resulting load or lienar-elastic stress.
187184
188-
'''
185+
"""
189186

190187
# self._stress_implicit(stress) = 0
191188
# f(sigma) = sigma/E + (sigma/K')^(1/n') - (L/sigma * K_p * e_star) = 0
@@ -203,7 +200,7 @@ def load(self, stress, *, rtol=1e-4, tol=1e-4):
203200
return load
204201

205202
def stress_secondary_branch(self, delta_load, *, rtol=1e-4, tol=1e-4):
206-
'''Calculate the stress on secondary branches in the stress-strain diagram at a given
203+
"""Calculate the stress on secondary branches in the stress-strain diagram at a given
207204
elastic-plastic stress (load), from a FE computation.
208205
This is done by solving for the root of f(sigma) in eq. 2.5-46 of FKM nonlinear.
209206
@@ -222,18 +219,18 @@ def stress_secondary_branch(self, delta_load, *, rtol=1e-4, tol=1e-4):
222219
-------
223220
delta_stress : array-like float
224221
The resulting stress increment within the hysteresis
225-
'''
222+
"""
226223
delta_stress = optimize.newton(
227224
func=self._stress_secondary_implicit,
228225
x0=delta_load,
229226
fprime=self._d_stress_secondary_implicit,
230-
args=([delta_load]),
227+
args=([np.asarray(delta_load, dtype=np.float64)]),
231228
rtol=rtol, tol=tol, maxiter=20
232229
)
233230
return delta_stress
234231

235232
def strain_secondary_branch(self, delta_stress, delta_load):
236-
'''Calculate the strain on secondary branches in the stress-strain diagram at a given stress and load.
233+
"""Calculate the strain on secondary branches in the stress-strain diagram at a given stress and load.
237234
The formula is given by eq. 2.5-46 of FKM nonlinear.
238235
239236
Parameters
@@ -247,12 +244,12 @@ def strain_secondary_branch(self, delta_stress, delta_load):
247244
-------
248245
strain : array-like float
249246
The resulting strain
250-
'''
247+
"""
251248

252249
return self._ramberg_osgood_relation.delta_strain(delta_stress)
253250

254251
def load_secondary_branch(self, delta_stress, *, rtol=1e-4, tol=1e-4):
255-
'''Apply the notch-approximation law "backwards", i.e., compute the linear-elastic stress (called "load" or "L" in FKM nonlinear)
252+
"""Apply the notch-approximation law "backwards", i.e., compute the linear-elastic stress (called "load" or "L" in FKM nonlinear)
256253
from the elastic-plastic stress as from the notch approximation.
257254
This backward step is needed for the pfp FKM nonlinear surface layer & roughness.
258255
@@ -274,7 +271,7 @@ def load_secondary_branch(self, delta_stress, *, rtol=1e-4, tol=1e-4):
274271
delta_load : array-like float
275272
The resulting load or lienar-elastic stress.
276273
277-
'''
274+
"""
278275

279276
# self._stress_implicit(stress) = 0
280277
# f(sigma) = sigma/E + (sigma/K')^(1/n') - (L/sigma * K_p * e_star) = 0
@@ -466,6 +463,7 @@ def _d_load_secondary_implicit(self, delta_load, delta_stress):
466463
return -1/delta_stress * self.K_p * self._delta_e_star(delta_load) \
467464
- delta_load/delta_stress * self.K_p * self._d_delta_e_star(delta_load)
468465

466+
469467
class Binned:
470468
"""Binning for notch approximation laws, as described in FKM nonlinear 2.5.8.2, p.55.
471469
The implicitly defined stress function of the notch approximation law is precomputed
@@ -493,12 +491,12 @@ def __init__(self, notch_approximation_law, maximum_absolute_load, number_of_bin
493491

494492
@property
495493
def ramberg_osgood_relation(self):
496-
'''The ramberg osgood relation object
497-
'''
494+
"""The ramberg osgood relation object
495+
"""
498496
return self._notch_approximation_law.ramberg_osgood_relation
499497

500498
def stress(self, load, *, rtol=1e-5, tol=1e-6):
501-
'''The stress of the primary path in the stress-strain diagram at a given load
499+
"""The stress of the primary path in the stress-strain diagram at a given load
502500
by using the value of the look-up table.
503501
504502
.. note::
@@ -520,7 +518,7 @@ def stress(self, load, *, rtol=1e-5, tol=1e-6):
520518
-------
521519
stress : array-like float
522520
The resulting stress
523-
'''
521+
"""
524522

525523

526524
# FIXME consolidate theese methods (duplicated code)
@@ -569,6 +567,7 @@ def stress(self, load, *, rtol=1e-5, tol=1e-6):
569567

570568
# if the assessment is done only for one value, i.e. load is a scalar
571569
else:
570+
572571
index = self._lut_primary_branch.load.searchsorted(np.abs(load))-1 # "-1", transform to zero-based indices
573572

574573
# raise error if requested load is higher than initialized maximum absolute load
@@ -579,7 +578,7 @@ def stress(self, load, *, rtol=1e-5, tol=1e-6):
579578
return sign * self._lut_primary_branch.iloc[index+1].stress # "+1", because the next higher class is used
580579

581580
def strain(self, stress, load):
582-
'''Get the strain of the primary path in the stress-strain diagram at a given stress and load
581+
"""Get the strain of the primary path in the stress-strain diagram at a given stress and load
583582
by using the value of the look-up table.
584583
585584
This method performs the task for for multiple points at once,
@@ -594,7 +593,7 @@ def strain(self, stress, load):
594593
-------
595594
strain : array-like float
596595
The resulting strain
597-
'''
596+
"""
598597
sign = np.sign(load)
599598

600599
# if the assessment is performed for multiple points at once, i.e. load is a DataFrame with values for every node
@@ -651,7 +650,7 @@ def strain(self, stress, load):
651650
return sign * self._lut_primary_branch.iloc[index+1].strain # "+1", because the next higher class is used
652651

653652
def stress_secondary_branch(self, delta_load, *, rtol=1e-5, tol=1e-6):
654-
'''Get the stress on secondary branches in the stress-strain diagram at a given load
653+
"""Get the stress on secondary branches in the stress-strain diagram at a given load
655654
by using the value of the look-up table (lut).
656655
657656
This method performs the task for for multiple points at once,
@@ -672,7 +671,7 @@ def stress_secondary_branch(self, delta_load, *, rtol=1e-5, tol=1e-6):
672671
-------
673672
delta_stress : array-like float
674673
The resulting stress increment within the hysteresis
675-
'''
674+
"""
676675

677676
sign = np.sign(delta_load)
678677

@@ -730,7 +729,7 @@ def stress_secondary_branch(self, delta_load, *, rtol=1e-5, tol=1e-6):
730729
return sign * self._lut_secondary_branch.iloc[index+1].delta_stress # "+1", because the next higher class is used
731730

732731
def strain_secondary_branch(self, delta_stress, delta_load):
733-
'''Get the strain on secondary branches in the stress-strain diagram at a given stress and load
732+
"""Get the strain on secondary branches in the stress-strain diagram at a given stress and load
734733
by using the value of the look-up table (lut).
735734
The lut is a DataFrame with MultiIndex with levels class_index and node_id.
736735
@@ -746,7 +745,7 @@ def strain_secondary_branch(self, delta_stress, delta_load):
746745
-------
747746
strain : array-like float
748747
The resulting strain
749-
'''
748+
"""
750749
#return self._notch_approximation_law.strain_secondary_branch(delta_stress, delta_load)
751750

752751
sign = np.sign(delta_load)

0 commit comments

Comments
 (0)