Skip to content

stress_life

Overview

Compute fatigue damage, equivalent loads, and nonlinear damage from stress cycles and an S–N curve.

py_fatigue.damage.stress_life

The module py_fatigue.damage.stress_life contains all the damage models related to the stress-life approach.

Classes

Gassner

Bases: PlotMixin

Accessor for the Gassner shift factor for variable amplitude.

Source code in py_fatigue/damage/stress_life.py
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
@pd.api.extensions.register_dataframe_accessor("gassner")
class Gassner(PlotMixin):
    """Accessor for the Gassner shift factor for variable amplitude."""

    def __init__(self, pandas_obj):
        self._validate(pandas_obj)
        self._obj = pandas_obj
        self.sn_curve = None

    @staticmethod
    def _validate(obj):
        """Validate the input DataFrame. Raise an error if the input
        DataFrame does not contain the right columns.
        """
        if not {"count_cycle", "mean_stress", "stress_range"}.issubset(
            obj.columns
        ):
            e_msg = "Must have 'count_cycle', 'mean_stress' and 'stress_range'."
            raise AttributeError(e_msg)

    def g(self, sn_curve: SNCurve):
        """Calculate the shift factor of the samples.

        The shift factor is a spectrum-dependent factor that allows
        to shift a Wohler curve and avoids having to calculate the
        damage using the Palmgren–Miner ruleevery time.

        Once the shift factor has been calculated, it can be applied
        to the Wohler SN curve. Then, accssing the curve through the
        maximum amplitude value of the spectrum will return the
        expected life for said spectrum.

        The shift factor for each cycle  in the spectrum is:

        $$
        G_j = \\frac{n_j}{N_S} \\,
        \\left({\\frac{\\sigma_{{max}_j} \\, \\sigma_{{alt}_j}}
        {\\max{\\sigma_{alt}} ^ {2}}}\\right)^{2}
        $$

        The shift factor then is:

        $$
        G = \\sum_{j=1}^{N_B} G_j
        $$

        Parameters
        ----------
        sn_curve : SNCurve
            The SNCurve object.

        Returns
        -------
        DataFrame
            The DataFrame with the shift factor per sample.
        """
        if "shift_factor" in self._obj:
            raise AttributeError("'shift_factor' already calculated")
        assert sn_curve.linear, "The SN curve must be linear"
        self._obj.sn_curve = sn_curve
        self.sn_curve = sn_curve
        stress_amp = self._obj.stress_range / 2
        max_amp = max(stress_amp)
        nu = np.divide(self._obj.count_cycle, sum(self._obj.count_cycle))
        self._obj["shift_factor"] = nu * np.power(
            np.divide(stress_amp, max_amp), self.sn_curve.slope
        )
        return self._obj

    def plot(
        self,
        fig: matplotlib.figure.Figure | None = None,
        ax: matplotlib.axes.Axes | None = None,
    ) -> tuple[matplotlib.figure.Figure, matplotlib.axes.Axes]:
        """Plot Gassner shift factor contributions by stress range."""
        if "shift_factor" not in self._obj:
            raise ValueError("Call g(sn_curve) before plotting.")
        fig, ax = make_axes(fig, ax)
        ax.scatter(self._obj.stress_range, self._obj.shift_factor)
        ax.set(xlabel="Stress range", ylabel="Shift factor contribution")
        return fig, ax
Methods:
g
g(sn_curve)

Calculate the shift factor of the samples.

The shift factor is a spectrum-dependent factor that allows to shift a Wohler curve and avoids having to calculate the damage using the Palmgren–Miner ruleevery time.

Once the shift factor has been calculated, it can be applied to the Wohler SN curve. Then, accssing the curve through the maximum amplitude value of the spectrum will return the expected life for said spectrum.

The shift factor for each cycle in the spectrum is:

\[ G_j = \frac{n_j}{N_S} \, \left({\frac{\sigma_{{max}_j} \, \sigma_{{alt}_j}} {\max{\sigma_{alt}} ^ {2}}}\right)^{2} \]

The shift factor then is:

\[ G = \sum_{j=1}^{N_B} G_j \]

Parameters:

Name Type Description Default
sn_curve SNCurve

The SNCurve object.

required

Returns:

Type Description
DataFrame

The DataFrame with the shift factor per sample.

Source code in py_fatigue/damage/stress_life.py
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
def g(self, sn_curve: SNCurve):
    """Calculate the shift factor of the samples.

    The shift factor is a spectrum-dependent factor that allows
    to shift a Wohler curve and avoids having to calculate the
    damage using the Palmgren–Miner ruleevery time.

    Once the shift factor has been calculated, it can be applied
    to the Wohler SN curve. Then, accssing the curve through the
    maximum amplitude value of the spectrum will return the
    expected life for said spectrum.

    The shift factor for each cycle  in the spectrum is:

    $$
    G_j = \\frac{n_j}{N_S} \\,
    \\left({\\frac{\\sigma_{{max}_j} \\, \\sigma_{{alt}_j}}
    {\\max{\\sigma_{alt}} ^ {2}}}\\right)^{2}
    $$

    The shift factor then is:

    $$
    G = \\sum_{j=1}^{N_B} G_j
    $$

    Parameters
    ----------
    sn_curve : SNCurve
        The SNCurve object.

    Returns
    -------
    DataFrame
        The DataFrame with the shift factor per sample.
    """
    if "shift_factor" in self._obj:
        raise AttributeError("'shift_factor' already calculated")
    assert sn_curve.linear, "The SN curve must be linear"
    self._obj.sn_curve = sn_curve
    self.sn_curve = sn_curve
    stress_amp = self._obj.stress_range / 2
    max_amp = max(stress_amp)
    nu = np.divide(self._obj.count_cycle, sum(self._obj.count_cycle))
    self._obj["shift_factor"] = nu * np.power(
        np.divide(stress_amp, max_amp), self.sn_curve.slope
    )
    return self._obj
plot
plot(fig=None, ax=None)

Plot Gassner shift factor contributions by stress range.

Source code in py_fatigue/damage/stress_life.py
307
308
309
310
311
312
313
314
315
316
317
318
def plot(
    self,
    fig: matplotlib.figure.Figure | None = None,
    ax: matplotlib.axes.Axes | None = None,
) -> tuple[matplotlib.figure.Figure, matplotlib.axes.Axes]:
    """Plot Gassner shift factor contributions by stress range."""
    if "shift_factor" not in self._obj:
        raise ValueError("Call g(sn_curve) before plotting.")
    fig, ax = make_axes(fig, ax)
    ax.scatter(self._obj.stress_range, self._obj.shift_factor)
    ax.set(xlabel="Stress range", ylabel="Shift factor contribution")
    return fig, ax

PalmgrenMiner

Bases: PlotMixin

Accessor for the Palmgren-Miner damage model.

Source code in py_fatigue/damage/stress_life.py
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
@pd.api.extensions.register_dataframe_accessor("miner")
class PalmgrenMiner(PlotMixin):
    """Accessor for the Palmgren-Miner damage model."""

    def __init__(self, pandas_obj):
        self._validate(pandas_obj)
        self._obj = pandas_obj
        self.sn_curve = None
        self.des_data = {}
        self.dem_data = {}

    @staticmethod
    def _validate(obj):
        """Validate the input DataFrame. Raise an error if the input
        DataFrame does not contain the right columns.
        """
        if not {"count_cycle", "mean_stress", "stress_range"}.issubset(
            obj.columns
        ):
            e_msg = "Must have 'count_cycle', 'mean_stress' and 'stress_range'."
            raise AttributeError(e_msg)

    def damage(self, sn_curve: SNCurve):
        """Calculate the damage of the samples.

        Parameters
        ----------
        sn_curve : SNCurve
            The SNCurve object.

        Returns
        -------
        DataFrame
            The DataFrame with the damage.
        """
        if self._obj._metadata["unit"] != sn_curve.unit:
            e_msg = (
                f"Units of cycle_count ({self._obj._metadata['unit']}) and "
                f"sn_curve ({sn_curve.unit}) do not match."
            )
            raise ValueError(e_msg)
        if {"cycles_to_failure"}.issubset(self._obj.columns):
            e_msg = "'cycles_to_failure' already calculated"
            raise AttributeError(e_msg)
        self._obj.sn_curve = sn_curve
        self.sn_curve = sn_curve
        self._obj["cycles_to_failure"] = sn_curve.get_cycles(
            self._obj.stress_range
        )
        self._obj["pm_damage"] = np.divide(
            self._obj.count_cycle, self._obj.cycles_to_failure
        )
        return self._obj

    def des(self, slope: float, equivalent_cycles: float = 1e7) -> float:
        """Calculate the damage equivalent stress range (DES).

        Parameters
        ----------
        slope : float
            The SN curve slope.
        equivalent_cycles : float, optional
            The equivalent number of cycles, by default 1e7

        Returns
        -------
        float
            The DES.

        See Also
        --------
        calc_des
        """
        self.des_data["slope"] = slope
        self.des_data["equivalent_cycles"] = equivalent_cycles

        return calc_des(
            self._obj.stress_range,
            self._obj.count_cycle,
            slope,
            equivalent_cycles,
        )

    def dem(
        self,
        outer_radius: float,
        inner_radius: float,
        slope: float,
        equivalent_cycles: float = 1e7,
    ) -> float:
        """Calculate the damage equivalent stress range (DES).

        Parameters
        ----------
        slope : float
            The SN curve slope.
        equivalent_cycles : float, optional
            The equivalent number of cycles, by default 1e7

        Returns
        -------
        float
            The DES.

        See Also
        --------
        calc_des
        """
        self.dem_data["outer_radius"] = outer_radius
        self.dem_data["inner_radius"] = inner_radius
        self.dem_data["slope"] = slope
        self.dem_data["equivalent_cycles"] = equivalent_cycles

        return calc_dem(
            outer_radius,
            inner_radius,
            self._obj.stress_range,
            self._obj.count_cycle,
            slope,
            equivalent_cycles,
        )

    def plot(
        self,
        fig: matplotlib.figure.Figure | None = None,
        ax: matplotlib.axes.Axes | None = None,
    ) -> tuple[matplotlib.figure.Figure, matplotlib.axes.Axes]:
        """Plot calculated Miner damage contributions by stress range."""
        if "pm_damage" not in self._obj:
            raise ValueError("Call damage(sn_curve) before plotting.")
        fig, ax = make_axes(fig, ax)
        ax.scatter(self._obj.stress_range, self._obj.pm_damage)
        metadata = self._obj._metadata
        unit = metadata.get("unit") if isinstance(metadata, dict) else None
        ax.set(
            xlabel=f"Stress range ({unit})" if unit else "Stress range",
            ylabel="Miner damage contribution",
        )
        return fig, ax

    def plot_histogram(
        self,
        fig: Optional[matplotlib.figure.Figure] = None,
        ax: Optional[matplotlib.axes.Axes] = None,
        dens_func: Optional[Callable] = None,
        **kwargs,
    ) -> Tuple[matplotlib.figure.Figure, matplotlib.axes.Axes]:
        """Plot the damage.

        Parameters
        ----------
        fig : matplotlib.figure.Figure, optional
            The figure to plot on, by default None
        ax : matplotlib.collections.PathCollection, optional
            The axes to plot on, by default None
        kwargs
            Additional keyword arguments for the plot.

        Returns
        -------
        matplotlib.figure.Figure, matplotlib.collections.PathCollection
            The figure and axes.
        """
        fig, ax = make_axes(fig, ax)
        im = ax.scatter(
            self._obj.count_cycle,
            self._obj.stress_range,
            # edgecolors="#CCC",
            # linewidths=0.5,
            c=(
                dens_func(self._obj.pm_damage)
                if dens_func is not None
                else self._obj.pm_damage
            ),
            **kwargs,
        )
        cbar_label = (
            "PM damage"
            if dens_func is None
            else "PM damage(" + str(dens_func) + ")"
        )
        ax.set_xlabel("# of cycles")
        ax.set_ylabel("Stress range, MPa")
        cbar = fig.colorbar(im, ax=ax)
        cbar.set_label(cbar_label, rotation=270)
        cbar.ax.get_yaxis().labelpad = 10
        return fig, ax
Methods:
damage
damage(sn_curve)

Calculate the damage of the samples.

Parameters:

Name Type Description Default
sn_curve SNCurve

The SNCurve object.

required

Returns:

Type Description
DataFrame

The DataFrame with the damage.

Source code in py_fatigue/damage/stress_life.py
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
def damage(self, sn_curve: SNCurve):
    """Calculate the damage of the samples.

    Parameters
    ----------
    sn_curve : SNCurve
        The SNCurve object.

    Returns
    -------
    DataFrame
        The DataFrame with the damage.
    """
    if self._obj._metadata["unit"] != sn_curve.unit:
        e_msg = (
            f"Units of cycle_count ({self._obj._metadata['unit']}) and "
            f"sn_curve ({sn_curve.unit}) do not match."
        )
        raise ValueError(e_msg)
    if {"cycles_to_failure"}.issubset(self._obj.columns):
        e_msg = "'cycles_to_failure' already calculated"
        raise AttributeError(e_msg)
    self._obj.sn_curve = sn_curve
    self.sn_curve = sn_curve
    self._obj["cycles_to_failure"] = sn_curve.get_cycles(
        self._obj.stress_range
    )
    self._obj["pm_damage"] = np.divide(
        self._obj.count_cycle, self._obj.cycles_to_failure
    )
    return self._obj
dem
dem(
    outer_radius,
    inner_radius,
    slope,
    equivalent_cycles=10000000.0,
)

Calculate the damage equivalent stress range (DES).

Parameters:

Name Type Description Default
slope float

The SN curve slope.

required
equivalent_cycles float

The equivalent number of cycles, by default 1e7

10000000.0

Returns:

Type Description
float

The DES.

See Also

calc_des

Source code in py_fatigue/damage/stress_life.py
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
def dem(
    self,
    outer_radius: float,
    inner_radius: float,
    slope: float,
    equivalent_cycles: float = 1e7,
) -> float:
    """Calculate the damage equivalent stress range (DES).

    Parameters
    ----------
    slope : float
        The SN curve slope.
    equivalent_cycles : float, optional
        The equivalent number of cycles, by default 1e7

    Returns
    -------
    float
        The DES.

    See Also
    --------
    calc_des
    """
    self.dem_data["outer_radius"] = outer_radius
    self.dem_data["inner_radius"] = inner_radius
    self.dem_data["slope"] = slope
    self.dem_data["equivalent_cycles"] = equivalent_cycles

    return calc_dem(
        outer_radius,
        inner_radius,
        self._obj.stress_range,
        self._obj.count_cycle,
        slope,
        equivalent_cycles,
    )
des
des(slope, equivalent_cycles=10000000.0)

Calculate the damage equivalent stress range (DES).

Parameters:

Name Type Description Default
slope float

The SN curve slope.

required
equivalent_cycles float

The equivalent number of cycles, by default 1e7

10000000.0

Returns:

Type Description
float

The DES.

See Also

calc_des

Source code in py_fatigue/damage/stress_life.py
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
def des(self, slope: float, equivalent_cycles: float = 1e7) -> float:
    """Calculate the damage equivalent stress range (DES).

    Parameters
    ----------
    slope : float
        The SN curve slope.
    equivalent_cycles : float, optional
        The equivalent number of cycles, by default 1e7

    Returns
    -------
    float
        The DES.

    See Also
    --------
    calc_des
    """
    self.des_data["slope"] = slope
    self.des_data["equivalent_cycles"] = equivalent_cycles

    return calc_des(
        self._obj.stress_range,
        self._obj.count_cycle,
        slope,
        equivalent_cycles,
    )
plot
plot(fig=None, ax=None)

Plot calculated Miner damage contributions by stress range.

Source code in py_fatigue/damage/stress_life.py
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
def plot(
    self,
    fig: matplotlib.figure.Figure | None = None,
    ax: matplotlib.axes.Axes | None = None,
) -> tuple[matplotlib.figure.Figure, matplotlib.axes.Axes]:
    """Plot calculated Miner damage contributions by stress range."""
    if "pm_damage" not in self._obj:
        raise ValueError("Call damage(sn_curve) before plotting.")
    fig, ax = make_axes(fig, ax)
    ax.scatter(self._obj.stress_range, self._obj.pm_damage)
    metadata = self._obj._metadata
    unit = metadata.get("unit") if isinstance(metadata, dict) else None
    ax.set(
        xlabel=f"Stress range ({unit})" if unit else "Stress range",
        ylabel="Miner damage contribution",
    )
    return fig, ax
plot_histogram
plot_histogram(fig=None, ax=None, dens_func=None, **kwargs)

Plot the damage.

Parameters:

Name Type Description Default
fig Figure

The figure to plot on, by default None

None
ax PathCollection

The axes to plot on, by default None

None
kwargs

Additional keyword arguments for the plot.

{}

Returns:

Type Description
(Figure, PathCollection)

The figure and axes.

Source code in py_fatigue/damage/stress_life.py
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
def plot_histogram(
    self,
    fig: Optional[matplotlib.figure.Figure] = None,
    ax: Optional[matplotlib.axes.Axes] = None,
    dens_func: Optional[Callable] = None,
    **kwargs,
) -> Tuple[matplotlib.figure.Figure, matplotlib.axes.Axes]:
    """Plot the damage.

    Parameters
    ----------
    fig : matplotlib.figure.Figure, optional
        The figure to plot on, by default None
    ax : matplotlib.collections.PathCollection, optional
        The axes to plot on, by default None
    kwargs
        Additional keyword arguments for the plot.

    Returns
    -------
    matplotlib.figure.Figure, matplotlib.collections.PathCollection
        The figure and axes.
    """
    fig, ax = make_axes(fig, ax)
    im = ax.scatter(
        self._obj.count_cycle,
        self._obj.stress_range,
        # edgecolors="#CCC",
        # linewidths=0.5,
        c=(
            dens_func(self._obj.pm_damage)
            if dens_func is not None
            else self._obj.pm_damage
        ),
        **kwargs,
    )
    cbar_label = (
        "PM damage"
        if dens_func is None
        else "PM damage(" + str(dens_func) + ")"
    )
    ax.set_xlabel("# of cycles")
    ax.set_ylabel("Stress range, MPa")
    cbar = fig.colorbar(im, ax=ax)
    cbar.set_label(cbar_label, rotation=270)
    cbar.ax.get_yaxis().labelpad = 10
    return fig, ax

Functions:

calc_dem

calc_dem(
    outer_radius,
    inner_radius,
    stress_range,
    count_cycle,
    slope,
    equivalent_cycles=10000000.0,
)

Calculate the damage equivalent moment (DEM) in Nm.

\[ DEM = DES * I_c / r_o = DES * S \]

with \(I_c\) the area moment of inertia and \(r_i\) the inner radius, or \(S\) the Section modulus. The Damage Equivalent Stress Range (DES) is calculated using calc_des

Parameters:

Name Type Description Default
outer_radius float

The outer radius to calculate the DEM. Must be provided in m

required
inner_radius float

The inner radius to calculate the DEM. Must be provided in m

required
stress_range Union[float, Series, ndarray]

The stress range

required
count_cycle Union[float, Series, ndarray]

The number of cycles

required
slope float

The SN curve slope

required
equivalent_cycles float

The equivalent number of cycles, by default 1e7

10000000.0

Raises:

Type Description
ValueError

If the inner radius is larger than the outer radius.

Returns:

Type Description
float

The DEM in Nm.

Source code in py_fatigue/damage/stress_life.py
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
def calc_dem(
    outer_radius: float,
    inner_radius: float,
    stress_range: Union[float, pd.Series, np.ndarray],
    count_cycle: Union[float, pd.Series, np.ndarray],
    slope: float,
    equivalent_cycles: float = 1e7,
) -> float:
    """Calculate the damage equivalent moment (DEM) in Nm.

    $$
    DEM = DES * I_c / r_o = DES * S
    $$

    with $I_c$ the area moment of inertia and $r_i$ the
    inner radius, or $S$ the Section modulus. The Damage
    Equivalent Stress Range (DES) is calculated using
    [`calc_des`][py_fatigue.damage.stress_life.calc_des]

    Parameters
    ----------
    outer_radius : float
        The outer radius to calculate the DEM. Must be provided in m
    inner_radius : float
        The inner radius to calculate the DEM. Must be provided in m
    stress_range : Union[float, pd.Series, np.ndarray]
        The stress range
    count_cycle : Union[float, pd.Series, np.ndarray]
        The number of cycles
    slope : float
        The SN curve slope
    equivalent_cycles : float, optional
        The equivalent number of cycles, by default 1e7

    Raises
    ------
    ValueError
        If the inner radius is larger than the outer radius.

    Returns
    -------
    float
        The DEM in Nm.
    """
    if outer_radius <= inner_radius:
        raise ValueError("outer_radius must be greater than inner_radius")
    stress_range, count_cycle = _check_param_couple_types(
        stress_range, count_cycle
    )
    area_inertia = np.pi / 4 * (outer_radius**4 - inner_radius**4)
    des = calc_des(stress_range, count_cycle, slope, equivalent_cycles)

    return area_inertia * des * 1e6 / outer_radius

calc_des

calc_des(
    stress_range,
    count_cycle,
    slope,
    equivalent_cycles=10000000.0,
)

Calculate the damage equivalent stress range (DES).

Parameters:

Name Type Description Default
stress_range Union[float, Series, ndarray]

The stress range

required
count_cycle Union[float, Series, ndarray]

The number of cycles

required
slope float

The SN curve slope

required
equivalent_cycles float

The equivalent number of cycles, by default 1e7

10000000.0

Returns:

Type Description
float

The DES.

Source code in py_fatigue/damage/stress_life.py
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
def calc_des(
    stress_range: Union[float, pd.Series, np.ndarray],
    count_cycle: Union[float, pd.Series, np.ndarray],
    slope: float,
    equivalent_cycles: float = 1e7,
) -> float:
    """Calculate the damage equivalent stress range (DES).

    Parameters
    ----------
    stress_range : Union[float, pd.Series, np.ndarray]
        The stress range
    count_cycle : Union[float, pd.Series, np.ndarray]
        The number of cycles
    slope : float
        The SN curve slope
    equivalent_cycles : float, optional
        The equivalent number of cycles, by default 1e7

    Returns
    -------
    float
        The DES.
    """
    stress_range, count_cycle = _check_param_couple_types(
        stress_range, count_cycle
    )
    des = np.power(
        np.sum(
            np.multiply(
                np.power(stress_range, float(slope)),
                count_cycle,
            )
            / equivalent_cycles
        ),
        1 / slope,
    )
    return des

calc_manson_halford_exponents

calc_manson_halford_exponents(
    cycles_to_failure, exponent=0.4
)

Calculate the Mannson-Halford exponents \(e_{j, j+1}\).

\[ e{j, j+1} = \left(\frac{N_{j}}{N_{j+1}}\right)^{exponent} \]

Parameters:

Name Type Description Default
cycles_to_failure ndarray

The number of cycles to failure.

required
exponent float

The exponent, by default 0.4

0.4

Returns:

Type Description
ndarray

The Mannson-Halford exponents.

Source code in py_fatigue/damage/stress_life.py
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
def calc_manson_halford_exponents(
    cycles_to_failure: np.ndarray, exponent: float = 0.4
) -> np.ndarray:
    """Calculate the Mannson-Halford exponents $e_{j, j+1}$.

    $$
    e{j, j+1} = \\left(\\frac{N_{j}}{N_{j+1}}\\right)^{exponent}
    $$

    Parameters
    ----------
    cycles_to_failure : np.ndarray
        The number of cycles to failure.
    exponent : float, optional
        The exponent, by default 0.4

    Returns
    -------
    np.ndarray
        The Mannson-Halford exponents.
    """
    return (
        np.hstack([cycles_to_failure[:-1] / cycles_to_failure[1:], [1]])
        ** exponent
    )

calc_nonlinear_damage

calc_nonlinear_damage(
    damage_rule,
    stress_range,
    count_cycle,
    sn_curve,
    **kwargs
)

Calculate the fatigue damage using a nonlinear damage rule among the allowed ones:

  • 'Pavlou': Pavlou damage rule
  • 'Manson-Halford': Mannson-Halford damage rule
  • 'Si-Jian': Si-Jian et al damage rule
  • 'Leve': Leve damage rule

Warning

This function is not suited for variable amplitude loading. For variable amplitude loading, use calc_nonlinear_damage_with_dca, as the fluctiations of the nonlinear damage exponent are controlled by the Damage Curve.

The generic form of a nonlinear damage rule is:

\[ D = \left( \left( \dots \left( \left( \left(\frac{n_1}{N_1}\right)^{e_{1, 2}} + \frac{n_2}{N_2} \right)^{e_{2, 3}} + \frac{n_3}{N_3} \right)^{e_{3, 4}} + \dots + \frac{n_{M-1}}{N_{M-1}} \right)^{e_{M-1, M}} + \dots + \frac{n_M}{N_M} \right)^{e_M} \]

where \(n_j\) is the number of cycles in the fatigue histogram at the \(j\)-th cycle, \(N_j\) is the number of cycles to failure at the \(j\)-th cycle, \(e_{j, j+1}\) is the exponent for the \(j\)-th and \(j+1\)-th cycles, \(M\) is the number of load blocks in the fatigue spectrum.

The formula is conveniently rewritten as pseudocode:

# retrieve N_j using the fatigue histogram and SN curve
# retrieve the exponents e_{j, j+1}
#  calculate the damage
D = 0
for j in range(1, M+1):
    D = (D + n_j / N_j) ^ e_{j, j+1}

Parameters:

Name Type Description Default
damage_rule str

The damage rule to use. Must be one of the following: 'Pavlou', 'Manson-Halford', 'Si-Jian', 'Leve'.

required
stress_range ndarray

The stress range.

required
count_cycle ndarray

The number of cycles.

required
sn_curve SNCurve

The SN curve.

required
kwargs dict

The keyword arguments for the damage rule. The following keyword arguments are allowed:

  • 'base_exponent': The exponent for the damage rule.
  • 'ultimate_stress': The ultimate stress.
{}

Returns:

Type Description
ndarray

The cumulated damage.

Source code in py_fatigue/damage/stress_life.py
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
def calc_nonlinear_damage(
    damage_rule: str,
    stress_range: np.ndarray,
    count_cycle: np.ndarray,
    sn_curve: SNCurve,
    **kwargs,
) -> float:
    """Calculate the fatigue damage using a nonlinear damage rule
    among the allowed ones:

    - 'Pavlou': Pavlou damage rule
    - 'Manson-Halford': Mannson-Halford damage rule
    - 'Si-Jian': Si-Jian et al damage rule
    - 'Leve': Leve damage rule

    !!! warning

        This function is not suited for variable amplitude loading.
        For variable amplitude loading, use
        [`calc_nonlinear_damage_with_dca`]
        [py_fatigue.damage.stress_life.calc_nonlinear_damage_with_dca], as the
        fluctiations of the
        nonlinear damage exponent are controlled by the Damage Curve.

    The generic form of a nonlinear damage rule is:

    $$
    D = \\left(
        \\left( \\dots
            \\left(
                \\left(
                    \\left(\\frac{n_1}{N_1}\\right)^{e_{1, 2}} +
                    \\frac{n_2}{N_2}
                \\right)^{e_{2, 3}} +
                \\frac{n_3}{N_3}
            \\right)^{e_{3, 4}} + \\dots + \\frac{n_{M-1}}{N_{M-1}}
        \\right)^{e_{M-1, M}} + \\dots + \\frac{n_M}{N_M}
    \\right)^{e_M}
    $$

    where $n_j$ is the number of cycles in the fatigue histogram
    at the $j$-th cycle, $N_j$ is the number of cycles to
    failure at the $j$-th cycle, $e_{j, j+1}$ is the exponent
    for the $j$-th and $j+1$-th cycles, $M$ is the
    number of load blocks in the fatigue spectrum.

    The formula is conveniently rewritten as pseudocode:

    ```python
    # retrieve N_j using the fatigue histogram and SN curve
    # retrieve the exponents e_{j, j+1}
    #  calculate the damage
    D = 0
    for j in range(1, M+1):
        D = (D + n_j / N_j) ^ e_{j, j+1}
    ```

    Parameters
    ----------
    damage_rule : str
        The damage rule to use. Must be one of the following:
        'Pavlou', 'Manson-Halford', 'Si-Jian', 'Leve'.
    stress_range : np.ndarray
        The stress range.
    count_cycle : np.ndarray
        The number of cycles.
    sn_curve : SNCurve
        The SN curve.
    kwargs : dict
        The keyword arguments for the damage rule. The following
        keyword arguments are allowed:

        - 'base_exponent': The exponent for the damage rule.
        - 'ultimate_stress': The ultimate stress.

    Returns
    -------
    np.ndarray
        The cumulated damage.
    """
    damage_per_cycle = calc_pm(
        stress_range,
        count_cycle,
        sn_curve,
    )

    kwargs["use_dca"] = False
    damage_exp = _calc_damage_exponents(
        damage_rule, stress_range, sn_curve, **kwargs
    )

    total_damage = 0
    damage_array = np.empty(len(damage_per_cycle))
    for i, (d_i, e_i) in enumerate(zip(damage_per_cycle, damage_exp)):
        # total_damage = (total_damage + d_i) ** e_i - total_damage
        total_damage = (total_damage + d_i) ** e_i
        damage_array[i] = total_damage

    return damage_array  # type: ignore

calc_nonlinear_damage_with_dca

calc_nonlinear_damage_with_dca(
    damage_rule,
    stress_range,
    count_cycle,
    sn_curve,
    damage_bands=array(
        [
            0,
            0.025,
            0.05,
            0.1,
            0.2,
            0.3,
            0.4,
            0.5,
            0.6,
            0.7,
            0.8,
            1,
        ]
    ),
    limit_damage=1,
    logger=None,
    plot=False,
    **kwargs
)

Calculate the fatigue damage using a nonlinear damage rule based on the Damage Curve Approach (DCA) among the allowed ones:

  • 'Pavlou': Pavlou damage rule
  • 'Theil': Theil damage rule

The DCA discreties the damage curve in multiple Damage bands \(\Delta D_j\) and calculates the damage for each band, depending on the damage value at the previous cycle. The damage is calculated as:

\[ D = \sum_{j=1}^{n_b} \Delta D_j \]

where \(n_b\) is the number of damage bands. In each damage band, the damage follows a weighted Palmgren-Miner sum, i.e.:

\[ \Delta D_j = \sum_{i=1}^{n_j} w_{i, j} \frac{n_i}{N_i} \]

where \(n_j\) is the number of cycles in the fatigue histogram at the \(j\)-th cycle, \(N_j\) is the number of cycles to failure at the \(j\)-th cycle, \(w_{i, j}\) is the weight for the \(i\)-th cycle in the \(j\)-th damage band.

Using the generic nonlinear damage accumulation formula:

\[ D(\sigma) = \left(\frac{n}{N(\sigma)}\right)^{e(\sigma)} \]

and substituting it inside the weighted Palmgren-Miner sum, the equation of the weights can be extracted as:

\[ w_{i, j} = \frac{D_j - D_{j-1}}{ D_{j}^{1/e_{i, i}} - D_{j-1}^{1/e_{i, i}} } \]

In the case of Pavlou's model, the exponents are:

\[ e_{j, j} = \left(\frac{\Delta \sigma_j / 2} {\sigma_U}\right)^{exponent} \]

While for Theil's method, the weights can be directly approximated as:

\[ w_j = 1 + \frac{\Delta\sigma_j}{N_{f,j}} \]

Warning

If you want to use Theil's method in a production environment, it is recommended to use the calc_theil_cycles_to_failure function, as it adheres to the original SN Cuve-based method.

The formula is conveniently rewritten as pseudocode:

# retrieve n_i, N_i using the fatigue histogram and SN curve
# retrieve the exponents e_{j, j+1}
# define the damage bands DB
# calculate the damage
D = 0
for j in range(1, M+1):
    DB_j = np.digitize(D, DB, right=False)
    for i in range(1, n_j+1):
        if damage_rule == 'Pavlou':
            w_ij = (DB[DB_j] - DB[DB_j - 1]) /                        ((DB[DB_j] ** (1 / e_i)) -
                    (DB[DB_j - 1] ** (1 / e_i)))
        elif damage_rule == 'Theil':
            w_ij = stress_range_i / N_i + 1
        D += w_ij * n_i / N_i

Parameters:

Name Type Description Default
damage_rule str

The damage rule to use. Must be one of the following: 'Pavlou', 'Theil'.

required
stress_range ndarray

The stress range.

required
count_cycle ndarray

The number of cycles.

required
sn_curve SNCurve

The SN curve.

required
damage_bands ndarray

Damage bands for the Pavlou damage calculation, by default [0, 0.025, 0.05, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 1]

array([0, 0.025, 0.05, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 1])
limit_damage float

Limit damage value, by default 1

1
logger Logger | None

If a logger is defined, attach output to it

None
plot bool

Whether to plot or not the cumulated damage

False
kwargs dict

The keyword arguments for the damage rule. The following keyword arguments are allowed:

  • 'base_exponent': The exponent for the damage rule.
  • 'ultimate_stress': The ultimate stress.
{}

Returns:

Type Description
tuple[ndarray, ndarray, Figure | None, Axes | None]

The cycle-to-cycle damage and the cumulated damage.

Source code in py_fatigue/damage/stress_life.py
 880
 881
 882
 883
 884
 885
 886
 887
 888
 889
 890
 891
 892
 893
 894
 895
 896
 897
 898
 899
 900
 901
 902
 903
 904
 905
 906
 907
 908
 909
 910
 911
 912
 913
 914
 915
 916
 917
 918
 919
 920
 921
 922
 923
 924
 925
 926
 927
 928
 929
 930
 931
 932
 933
 934
 935
 936
 937
 938
 939
 940
 941
 942
 943
 944
 945
 946
 947
 948
 949
 950
 951
 952
 953
 954
 955
 956
 957
 958
 959
 960
 961
 962
 963
 964
 965
 966
 967
 968
 969
 970
 971
 972
 973
 974
 975
 976
 977
 978
 979
 980
 981
 982
 983
 984
 985
 986
 987
 988
 989
 990
 991
 992
 993
 994
 995
 996
 997
 998
 999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
def calc_nonlinear_damage_with_dca(
    damage_rule: str,
    stress_range: np.ndarray,
    count_cycle: np.ndarray,
    sn_curve: SNCurve,
    damage_bands: np.ndarray = np.array(
        [0, 0.025, 0.05, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 1]
    ),
    limit_damage: Union[float, int] = 1,
    logger: logging.Logger | None = None,
    plot: bool = False,
    **kwargs,
) -> tuple[
    np.ndarray,
    np.ndarray,
    matplotlib.figure.Figure | None,
    matplotlib.axes.Axes | None,
]:
    """Calculate the fatigue damage using a nonlinear damage rule based on the
    Damage Curve Approach (DCA) among the allowed ones:

    - 'Pavlou': Pavlou damage rule
    - 'Theil': Theil damage rule

    The DCA discreties the damage curve in multiple Damage bands
    $\\Delta D_j$ and calculates the damage for each band, depending
    on the damage value at the previous cycle. The damage is calculated
    as:

    $$
    D = \\sum_{j=1}^{n_b} \\Delta D_j
    $$

    where $n_b$ is the number of damage bands. In each damage band,
    the damage follows a weighted Palmgren-Miner sum, i.e.:

    $$
    \\Delta D_j = \\sum_{i=1}^{n_j} w_{i, j} \\frac{n_i}{N_i}
    $$

    where $n_j$ is the number of cycles in the fatigue histogram
    at the $j$-th cycle, $N_j$ is the number of cycles to
    failure at the $j$-th cycle, $w_{i, j}$ is the weight
    for the $i$-th cycle in the $j$-th damage band.

    Using the generic nonlinear damage accumulation formula:

    $$
    D(\\sigma) = \\left(\\frac{n}{N(\\sigma)}\\right)^{e(\\sigma)}
    $$

    and substituting it inside the weighted Palmgren-Miner sum, the
    equation of the weights can be extracted as:

    $$
    w_{i, j} = \\frac{D_j - D_{j-1}}{
        D_{j}^{1/e_{i, i}} - D_{j-1}^{1/e_{i, i}}
    }
    $$

    In the case of Pavlou's model, the exponents are:

    $$
    e_{j, j} = \\left(\\frac{\\Delta \\sigma_j / 2}
                            {\\sigma_U}\\right)^{exponent}
    $$

    While for Theil's method, the weights can be directly
    approximated as:

    $$
    w_j = 1 + \\frac{\\Delta\\sigma_j}{N_{f,j}}
    $$

    !!! warning

        If you want to use Theil's method in a production
        environment, it is recommended to use the
        [`calc_theil_cycles_to_failure`]
        [py_fatigue.damage.stress_life.calc_theil_cycles_to_failure] function,
        as it adheres
        to the original SN Cuve-based method.

    The formula is conveniently rewritten as pseudocode:

    ```python
    # retrieve n_i, N_i using the fatigue histogram and SN curve
    # retrieve the exponents e_{j, j+1}
    # define the damage bands DB
    # calculate the damage
    D = 0
    for j in range(1, M+1):
        DB_j = np.digitize(D, DB, right=False)
        for i in range(1, n_j+1):
            if damage_rule == 'Pavlou':
                w_ij = (DB[DB_j] - DB[DB_j - 1]) / \
                       ((DB[DB_j] ** (1 / e_i)) -
                        (DB[DB_j - 1] ** (1 / e_i)))
            elif damage_rule == 'Theil':
                w_ij = stress_range_i / N_i + 1
            D += w_ij * n_i / N_i
    ```

    Parameters
    ----------
    damage_rule : str
        The damage rule to use. Must be one of the following:
        'Pavlou', 'Theil'.
    stress_range : np.ndarray
        The stress range.
    count_cycle : np.ndarray
        The number of cycles.
    sn_curve : SNCurve
        The SN curve.
    damage_bands : np.ndarray
        Damage bands for the Pavlou damage calculation, by default
        [0, 0.025, 0.05, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 1]
    limit_damage : float, optional
        Limit damage value, by default 1
    logger: logging.Logger, optional
        If a logger is defined, attach output to it
    plot: bool, by default False
        Whether to plot or not the cumulated damage
    kwargs : dict
        The keyword arguments for the damage rule. The following
        keyword arguments are allowed:

        - 'base_exponent': The exponent for the damage rule.
        - 'ultimate_stress': The ultimate stress.

    Returns
    -------
    tuple[np.ndarray, np.ndarray, mpl.Figure | None, mpl.Axes | None]
        The cycle-to-cycle damage and the cumulated damage.
    """

    allowed_damage_rules = ["pavlou", "theil"]
    if damage_rule.lower() not in allowed_damage_rules:
        raise ValueError(
            f"Unknown damage rule: {damage_rule}. "
            f"Allowed damage rules are: {allowed_damage_rules}"
        )
    stress_range = np.asarray(stress_range, dtype=np.float64)
    count_cycle = np.asarray(count_cycle, dtype=np.float64)
    damage_bands = np.asarray(damage_bands, dtype=np.float64)
    pm_damage = calc_pm(
        stress_range,
        count_cycle,
        sn_curve,
    )

    if damage_rule.lower() == "theil":
        weights = calc_theil_weights(stress_range, sn_curve)
        nl_damage = (1 + weights) * pm_damage
        if not plot:
            return nl_damage, np.cumsum(nl_damage), None, None
        fig, ax = _plot_damage_accumulation(
            np.cumsum(nl_damage), np.cumsum(pm_damage), limit_damage
        )
        return nl_damage, np.cumsum(nl_damage), fig, ax

    kwargs["use_dca"] = True
    dmg_exp = _calc_damage_exponents(
        damage_rule, stress_range, sn_curve, **kwargs
    )

    nl_damage = pm_damage.copy()
    cumsum_nl_dmg = np.zeros_like(nl_damage)
    cur_dmg_band = 0
    for i in range(len(pm_damage)):  # pylint: disable=C0200
        prev_dmg_band = cur_dmg_band if i >= 1 else 0
        # fmt: off
        cur_dmg_band = np.digitize(cumsum_nl_dmg[i - 1], damage_bands,
                                   right=False) if i >= 1 else 0
        cur_dmg_band = min(cur_dmg_band, len(damage_bands) - 1)
        if (
            cur_dmg_band != prev_dmg_band
            and len(damage_bands) < 20
            and logger is not None
        ):
            if cur_dmg_band == 1:
                logger.info("Damage band change")
            logger.info(f"‣ at cycle {i}:\n"
                        f"                • from {prev_dmg_band} to "
                        f"{cur_dmg_band} ({damage_bands[cur_dmg_band - 1]}"
                        f" < D ≤ {damage_bands[cur_dmg_band]})\n"
                        f"                • current damage value: "
                        f"{cumsum_nl_dmg[i - 1]}\033[0m")

        # Damage weight for the current cycle
        w_ij: float = (
            (damage_bands[cur_dmg_band] - damage_bands[cur_dmg_band - 1])
            / ((damage_bands[cur_dmg_band] ** (1 / dmg_exp[i]))
                - (damage_bands[cur_dmg_band - 1] ** (1 / dmg_exp[i])))
        )
        # Update the damage value for the current cycle
        nl_damage[i] = w_ij * pm_damage[i] if i >= 1 else pm_damage[0]
        cumsum_nl_dmg[i] = (
            nl_damage[i] + cumsum_nl_dmg[i - 1] if i >= 1 else nl_damage[0]
        )
        if i >= 1 and cumsum_nl_dmg[i] > limit_damage:
            w_msg = f"Damage value exceeds {limit_damage} at index {i}"
            warnings.warn(w_msg, UserWarning)
            break
        # fmt: on

    # Edit nl_damage and cumsum_nl_dmg so that all the valus of nldamage[i+1:]
    # are 0 and all the value of cumsum_nl_dmg[i+1:] = cumsum_nl_dmg[i]
    nl_damage[i + 1 :] = 0
    cumsum_nl_dmg[i + 1 :] = cumsum_nl_dmg[i]
    if not plot:
        return nl_damage, cumsum_nl_dmg, None, None
    fig, ax = make_axes()
    cumsum_pm_dmg = np.cumsum(pm_damage)
    fig, ax = _plot_damage_accumulation(
        cumsum_nl_dmg, cumsum_pm_dmg, limit_damage, fig, ax
    )
    return nl_damage, cumsum_nl_dmg, fig, ax

calc_pavlou_exponents

calc_pavlou_exponents(
    stress_range,
    ultimate_stress=900,
    exponent=-0.75,
    use_dca=False,
)

Calculate the Pavlou exponents \(q(\sigma_j)=e_{j, j+1}\).

\[ e_{j, j+1} = \left(\frac{\Delta \sigma_j / 2}{\sigma_U}\right) ^{exponent} \]

where \(\Delta \sigma_j\) is the stress amplitude, \(\sigma_U\) is the ultimate stress, \(\Delta \sigma\) is the stress range and \(exponent\) is the exponent.

Parameters:

Name Type Description Default
stress_range ndarray

The stress range.

required
ultimate_stress float

The ultimate stress, by default 900

900
exponent float

The exponent, by default -0.75

-0.75

Returns:

Type Description
ndarray

The Pavlou exponents.

Source code in py_fatigue/damage/stress_life.py
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
def calc_pavlou_exponents(
    stress_range: np.ndarray,
    ultimate_stress: float = 900,
    exponent: float = -0.75,
    use_dca: bool = False,
) -> np.ndarray:
    """Calculate the Pavlou exponents $q(\\sigma_j)=e_{j, j+1}$.

    $$
    e_{j, j+1} = \\left(\\frac{\\Delta \\sigma_j / 2}{\\sigma_U}\\right)
    ^{exponent}
    $$

    where $\\Delta \\sigma_j$ is the stress amplitude, $\\sigma_U$
    is the ultimate stress, $\\Delta \\sigma$ is the stress range and
    $exponent$ is the exponent.


    Parameters
    ----------
    stress_range : np.ndarray
        The stress range.
    ultimate_stress : float, optional
        The ultimate stress, by default 900
    exponent : float, optional
        The exponent, by default -0.75

    Returns
    -------
    np.ndarray
        The Pavlou exponents.
    """
    q_exp = (stress_range / 2 / ultimate_stress) ** exponent
    if use_dca:
        return q_exp
    return np.hstack([q_exp[1:] / q_exp[:-1], [1]])

calc_pm

calc_pm(stress_range, count_cycle, sn_curve)

Calculates the damage using the Palmgren-Miner rule, i.e. the linear damage accumulation rule:

\[ D = \sum_{j=1}^{N_{\text{blocks}}} \frac{n_j}{N_j} \leq 1 \]

Parameters:

Name Type Description Default
count_cycle Union[Series, ndarray]

The number of cycles

required
sn_curve SNCurve

The SNCurve object.

required

Returns:

Type Description
Union[float, ndarray]

The damage according to the Palmgren-Miner rule.

Source code in py_fatigue/damage/stress_life.py
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
def calc_pm(
    stress_range: Union[float, pd.Series, np.ndarray],
    count_cycle: Union[float, pd.Series, np.ndarray],
    sn_curve: SNCurve,
) -> np.ndarray:
    """Calculates the damage using the Palmgren-Miner rule, i.e. the
    linear damage accumulation rule:

    $$
    D = \\sum_{j=1}^{N_{\\text{blocks}}} \\frac{n_j}{N_j} \\leq 1
    $$

    Parameters
    ----------
     stress_range : Union[pd.Series, np.ndarray]
        The stress range
    count_cycle : Union[pd.Series, np.ndarray]
        The number of cycles
    sn_curve : SNCurve
        The SNCurve object.

    Returns
    -------
    Union[float, np.ndarray]
        The damage according to the Palmgren-Miner rule.
    """
    stress_range, count_cycle = _check_param_couple_types(
        stress_range, count_cycle
    )
    return count_cycle / sn_curve.get_cycles(stress_range)

calc_si_jian_exponents

calc_si_jian_exponents(stress_range)

Calculate the Si-Jian et al. exponents as

\[ e_{j, j+1} = \sigma_{j+1} / \sigma_{j} \]

where \(\sigma_{j+1}\) is the stress amplitude for the \(j\)-th cycle.

Parameters:

Name Type Description Default
stress_range ndarray

The stress range.

required

Returns:

Type Description
ndarray

The Si-Jian et al. exponents.

Source code in py_fatigue/damage/stress_life.py
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
def calc_si_jian_exponents(
    stress_range: np.ndarray,
) -> np.ndarray:
    """Calculate the Si-Jian et al. exponents as

    $$
    e_{j, j+1} = \\sigma_{j+1} / \\sigma_{j}
    $$

    where $\\sigma_{j+1}$ is the stress amplitude for the
    $j$-th cycle.

    Parameters
    ----------
    stress_range : np.ndarray
        The stress range.

    Returns
    -------
    np.ndarray
        The Si-Jian et al. exponents.
    """
    return np.hstack([stress_range[1:] / stress_range[:-1], [1]])

calc_theil_cycles_to_failure

calc_theil_cycles_to_failure(
    stress_range, count_cycle, sn_curve, to_failure=False
)

Backwards-compatible alias for the current Theil SN helper.

Source code in py_fatigue/damage/stress_life.py
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
def calc_theil_cycles_to_failure(
    stress_range,
    count_cycle,
    sn_curve: SNCurve,
    to_failure: bool = False,
):
    """Backwards-compatible alias for the current Theil SN helper."""

    return calc_theil_sn_damage(
        stress_range,
        count_cycle,
        sn_curve,
        to_failure=to_failure,
    )

calc_theil_sn_damage

calc_theil_sn_damage(
    stress_range, count_cycle, sn_curve, to_failure=False
)

Calculate the cycles to failure using the Theil's method for variable amplitude loading. Perform a fatigue life prediction under a sequence of stress range blocks, taking into account the interaction between different stress levels. It uses Theil's method to determine the effective stress range and accumulated damage, and an S-N curve to predict the number of cycles to failure.

Mathematically, the method can be described as follows. Provided a sequence of stress range blocks \(\Delta\sigma_i\) and the corresponding number of cycles \(n_i\), after initializing all the cumulative variables to zero, the effective stress range is calculated as:

\[ \begin{aligned} N_i & = \text{SN Curve}\left(\Delta\sigma_i \right) \\ w_i & = \frac{\Delta\sigma_i}{N_i} \\ \Delta\sigma_{eff,i} & = \Delta\sigma_{cumsum,i-1} - w_i \cdot n_{cumsum, i-1} \\ n_{cumsum,i} & = n_{cumsum,i-1} + n_i \\ \Delta\sigma_{cumsum,i} & = w_i \cdot n_{cumsum,i} + \Delta\sigma_{eff,i} \end{aligned} \]

where:

  • \(\Delta\sigma_{eff}\) is the effective stress range,
  • \(\Delta\sigma_{cumsum}\) is the cumulative stress range,
  • \(w\) is the damage weight for the current cycle,
  • \(n_{cumsum}\) is the cumulative number of cycles,
  • \(n\) is the number of cycles for the current block.

The method is applied to each block in the sequence, and the cumulative number of cycles is updated at the end of each block. The process continues until the number of cycles to failure is determined. If failure does not occur until the end of the sequence, the number of cycles to failure is estimated by "extrapolating" the last block, i.e., by calculating the intersection of the S-N curve with the effective stress range of the last block through the bisection method.

Parameters:

Name Type Description Default
stress_range ndarray

A numpy array containing the stress range for each block (MPa).

required
count_cycle ndarray

A numpy array containing the number of cycles for each block.

required
sn_curve SNCurve

An object representing the S-N curve of the material. It must have attributes intercept (float) and slope (float).

required

Returns:

Type Description
tuple

A tuple containing:

  • n_to_failure (float): The number of cycles to failure. If failure occurs within a block, the cumulative number of cycles at the end of that block is returned.
  • history (list): A list of tuples, where each tuple contains:

  • n_segment (np.ndarray): An array of cycle numbers for the segment.

  • stress_range_segment (np.ndarray): An array of corresponding stress ranges for the segment.
  • label (str): A label for the segment, indicating the block number and stress range.

Raises:

Type Description
ValueError

If the fatigue life solver fails to find a solution within a block, indicating that failure has occurred within that block.

Notes
  • The function assumes that the stress range and count cycle arrays have the same length.
  • The Theil's method is used to calculate the effective stress range, which takes into account the sequence of stress levels.
  • The S-N curve is used to relate the stress range to the number of cycles to failure.
Source code in py_fatigue/damage/stress_life.py
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
def calc_theil_sn_damage(
    stress_range, count_cycle, sn_curve: SNCurve, to_failure: bool = False
) -> tuple[tuple[str, Any, Any], ...]:
    """
    Calculate the cycles to failure using the Theil's method for variable
    amplitude loading.
    Perform a fatigue life prediction under a sequence of stress range blocks,
    taking into account the interaction between different stress levels. It
    uses Theil's method to determine the effective stress range and accumulated
    damage, and an S-N curve to predict the number of cycles to failure.

    Mathematically, the method can be described as follows. Provided a sequence
    of stress range blocks $\\Delta\\sigma_i$ and the corresponding
    number of cycles $n_i$, after initializing all the cumulative
    variables to zero, the effective stress range is calculated as:

    $$
    \\begin{aligned}
    N_i & = \\text{SN Curve}\\left(\\Delta\\sigma_i \\right) \\\\
    w_i & = \\frac{\\Delta\\sigma_i}{N_i} \\\\
    \\Delta\\sigma_{eff,i} & = \\Delta\\sigma_{cumsum,i-1}
                             - w_i \\cdot n_{cumsum, i-1} \\\\
    n_{cumsum,i} & = n_{cumsum,i-1} + n_i \\\\
    \\Delta\\sigma_{cumsum,i} & = w_i \\cdot n_{cumsum,i}
                                + \\Delta\\sigma_{eff,i}
    \\end{aligned}
    $$

    where:

    - $\\Delta\\sigma_{eff}$ is the effective stress range,
    - $\\Delta\\sigma_{cumsum}$ is the cumulative stress range,
    - $w$ is the damage weight for the current cycle,
    - $n_{cumsum}$ is the cumulative number of cycles,
    - $n$ is the number of cycles for the current block.

    The method is applied to each block in the sequence, and the cumulative
    number of cycles is updated at the end of each block. The process continues
    until the number of cycles to failure is determined. If failure does not
    occur until the end of the sequence, the number of cycles to failure is
    estimated by "extrapolating" the last block, i.e., by calculating the
    intersection of the S-N curve with the effective stress range of the last
    block through the bisection method.

    Parameters
    ----------
    stress_range : np.ndarray
        A numpy array containing the stress range for each block (MPa).
    count_cycle : np.ndarray
        A numpy array containing the number of cycles for each block.
    sn_curve : SNCurve
        An object representing the S-N curve of the material.
        It must have attributes `intercept` (float) and `slope` (float).
    Returns
    -------
    tuple
        A tuple containing:

        - n_to_failure (float): The number of cycles to failure. If failure
          occurs within a block, the cumulative number of cycles at the end
          of that block is returned.
        - history (list): A list of tuples, where each tuple contains:

          - n_segment (np.ndarray): An array of cycle numbers for the
            segment.
          - stress_range_segment (np.ndarray): An array of corresponding
            stress ranges for the segment.
          - label (str): A label for the segment, indicating the block
            number and stress range.

    Raises
    ------
    ValueError
        If the fatigue life solver fails to find a solution within a block,
        indicating that failure has occurred within that block.
    Notes
    -----
    - The function assumes that the stress range and count cycle arrays have
      the same length.
    - The Theil's method is used to calculate the effective stress range, which
      takes into account the sequence of stress levels.
    - The S-N curve is used to relate the stress range to the number of cycles
      to failure.
    """
    history, stress_range_cumsum, n_cumsum = _calc_theil_sn_damage(
        count_cycle=count_cycle,
        stress_range=stress_range,
        cycles_to_failure=sn_curve.get_cycles(stress_range),
    )

    labels = [
        f"Block {i + 1} (r={stress_range[i]} MPa)"
        for i in range(len(stress_range))
    ]
    # tuple([(label, *tup) for tup, label in zip(history, labels)])
    hist_dict = {
        label: (n_segment, stress_range_segment)
        for (n_segment, stress_range_segment), label in zip(history, labels)
    }
    if to_failure:
        w_final = stress_range[-1] / sn_curve.get_cycles(stress_range[-1])
        # print("w_final", w_final)
        current_stress_range = stress_range_cumsum - w_final * n_cumsum
        # print("current_stress_range", current_stress_range)
        # Solve modified Basquin for total cycles at final block:
        n_final = find_sn_curve_intersection(
            sn_curve.slope,
            sn_curve.intercept,
            sn_curve.endurance,
            current_stress_range,
            w_final,
            n_min=n_cumsum,
            n_max=1e15,
        )
        n_final_array = np.logspace(np.log10(n_cumsum), np.log10(n_final), 20)
        stress_range_final = w_final * n_final_array + current_stress_range
        # n_cumsum += n_final
        # stress_range_cumsum = w_final * n_cumsum + current_stress_range
        # Append to the last label block
        hist_dict[labels[-1]] = (
            np.append(history[-1][0], n_final_array),
            np.append(history[-1][1], stress_range_final),
        )
    # fmt: off
    return tuple((label, *tup) for tup, label in zip(hist_dict.values(),
                                                      hist_dict.keys()))

calc_theil_weights

calc_theil_weights(stress_range, sn_curve)

Calculate the Theil weights for the Damage Curve Approach (DCA).

\[ w_j = \frac{\Delta\sigma_j}{N_{f,j}} \]

Parameters:

Name Type Description Default
stress_range ndarray

The stress range.

required
sn_curve SNCurve

The py-fatigue SN Curve

required

Returns:

Type Description
ndarray

Theil's model weights

Source code in py_fatigue/damage/stress_life.py
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
def calc_theil_weights(
    stress_range: np.ndarray,
    sn_curve: SNCurve,
) -> np.ndarray:
    """Calculate the Theil weights for the Damage Curve Approach
    (DCA).

    $$
    w_j = \\frac{\\Delta\\sigma_j}{N_{f,j}}
    $$

    Parameters
    ----------
    stress_range : np.ndarray
        The stress range.
    sn_curve : SNCurve
        The py-fatigue SN Curve

    Returns
    -------
    np.ndarray
        Theil's model weights
    """
    return np.divide(stress_range, sn_curve.get_cycles(stress_range))

find_sn_curve_intersection

find_sn_curve_intersection(
    slope,
    intercept,
    endurance,
    weight,
    res_stress,
    n_min=1.0,
    n_max=10000000000.0,
    tol=1e-06,
)

Solve the following nonlinear equation:

\[ \left(\frac{a}{N}\right)^{\frac{1}{m}} = w \cdot N + b \]

where:

  • a is the intercept of the S-N curve,
  • m is the slope of the S-N curve,
  • w is the weight for the stress range,
  • b is the residual stress range,
  • N is the number of cycles to failure,

for N in the range [\(n_{min}\), \(n_{max}\)]. The equation is linked to the S-N curve definition, therefore it can be as complex as the S-N curve itself, i.e. log-linear, log-bilinear, etc.

Parameters:

Name Type Description Default
intercept float

The intercept of the S-N curve.

required
slope float

The slope of the S-N curve.

required
endurance float

The endurance limit.

required
weight float

The weight for the stress range.

required
res_stress float

The residual stress range.

required
n_min float

The minimum number of cycles to failure, by default 1e0.

1.0
n_max float

The maximum number of cycles to failure, by default 1e10.

10000000000.0
tol float

The tolerance for the bisection method, by default 1e-6.

1e-06

Returns:

Type Description
float

The number of cycles to failure.

Raises:

Type Description
ValueError

If the bisection method fails to find a solution.

Source code in py_fatigue/damage/stress_life.py
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
def find_sn_curve_intersection(
    slope: np.ndarray,
    intercept: np.ndarray,
    endurance: float,
    weight: float,
    res_stress: float,
    n_min: float = 1e0,
    n_max: float = 1e10,
    tol=1e-6,
):
    """
    Solve the following nonlinear equation:

    $$
    \\left(\\frac{a}{N}\\right)^{\\frac{1}{m}} = w \\cdot N + b
    $$

    where:

    - a is the intercept of the S-N curve,
    - m is the slope of the S-N curve,
    - w is the weight for the stress range,
    - b is the residual stress range,
    - N is the number of cycles to failure,

    for N in the range [$n_{min}$, $n_{max}$].
    The equation is linked to the S-N curve definition, therefore it can be
    as complex as the S-N curve itself, i.e. log-linear, log-bilinear, etc.

    Parameters
    ----------
    intercept : float
        The intercept of the S-N curve.
    slope : float
        The slope of the S-N curve.
    endurance : float
        The endurance limit.
    weight : float
        The weight for the stress range.
    res_stress : float
        The residual stress range.
    n_min : float, optional
        The minimum number of cycles to failure, by default 1e0.
    n_max : float, optional
        The maximum number of cycles to failure, by default 1e10.
    tol : float, optional
        The tolerance for the bisection method, by default 1e-6.

    Returns
    -------
    float
        The number of cycles to failure.

    Raises
    ------
    ValueError
        If the bisection method fails to find a solution.
    """
    return solve_sn_curve_residuals(
        n_min,
        n_max,
        tol,
        1000,
        slope,
        intercept,
        endurance,
        weight,
        res_stress,
    )

find_sn_curve_intersection_2

find_sn_curve_intersection_2(*args, **kwargs)

Backwards-compatible alias for the current SN intersection solver.

Source code in py_fatigue/damage/stress_life.py
1291
1292
1293
1294
def find_sn_curve_intersection_2(*args, **kwargs):
    """Backwards-compatible alias for the current SN intersection solver."""

    return find_sn_curve_intersection(*args, **kwargs)

get_dem

get_dem(
    outer_radius,
    inner_radius,
    cycle_count,
    slope,
    equivalent_cycles=10000000.0,
)

Calculate the damage equivalent moment (DEM) in Nm.

\[ DEM = DES * I_c / r_o = DES * S \]

with \(I_c\) the area moment of inertia and \(r_i\) the inner radius, or \(S\) the Section modulus. The Damage Equivalent Stress Range (DES) is calculated using calc_des

Parameters:

Name Type Description Default
outer_radius float

The outer radius to calculate the DEM. Must be provided in m

required
inner_radius float

The inner radius to calculate the DEM. Must be provided in m

required
stress_range Union[Series, ndarray]

The stress range

required
count_cycle Union[Series, ndarray]

The number of cycles

required
slope float

The SN curve slope

required
equivalent_cycles float

The equivalent number of cycles, by default 1e7

10000000.0

Returns:

Type Description
float

The DEM in Nm.

Source code in py_fatigue/damage/stress_life.py
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
def get_dem(
    outer_radius: float,
    inner_radius: float,
    cycle_count: CycleCount,
    slope: float,
    equivalent_cycles: float = 1e7,
) -> float:
    """Calculate the damage equivalent moment (DEM) in Nm.

    $$
    DEM = DES * I_c / r_o = DES * S
    $$

    with $I_c$ the area moment of inertia and $r_i$ the
    inner radius, or $S$ the Section modulus. The Damage
    Equivalent Stress Range (DES) is calculated using
    [`calc_des`][py_fatigue.damage.stress_life.calc_des]

    Parameters
    ----------
    outer_radius : float
        The outer radius to calculate the DEM. Must be provided in m
    inner_radius : float
        The inner radius to calculate the DEM. Must be provided in m
    stress_range : Union[pd.Series, np.ndarray]
        The stress range
    count_cycle : Union[pd.Series, np.ndarray]
        The number of cycles
    slope : float
        The SN curve slope
    equivalent_cycles : float, optional
        The equivalent number of cycles, by default 1e7

    Returns
    -------
    float
        The DEM in Nm.
    """
    return calc_dem(
        outer_radius,
        inner_radius,
        cycle_count.stress_range,
        cycle_count.count_cycle,
        slope,
        equivalent_cycles,
    )

get_des

get_des(cycle_count, slope, equivalent_cycles=10000000.0)

Calculate the damage equivalent stress range (DES).

Parameters:

Name Type Description Default
cycle_count CycleCount

The CycleCount object.

required
slope float

The SN curve slope

required
equivalent_cycles float

The equivalent number of cycles, by default 1e7

10000000.0

Returns:

Type Description
float

The DES.

Source code in py_fatigue/damage/stress_life.py
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
def get_des(
    cycle_count: CycleCount, slope: float, equivalent_cycles: float = 1e7
) -> float:
    """Calculate the damage equivalent stress range (DES).

    Parameters
    ----------
    cycle_count : CycleCount
        The CycleCount object.
    slope : float
        The SN curve slope
    equivalent_cycles : float, optional
        The equivalent number of cycles, by default 1e7

    Returns
    -------
    float
        The DES.
    """
    return calc_des(
        cycle_count.stress_range,
        cycle_count.count_cycle,
        slope,
        equivalent_cycles,
    )

get_nonlinear_damage

get_nonlinear_damage(
    damage_rule, cycle_count, sn_curve, **kwargs
)

Calculate the fatigue damage using a nonlinear damage rule.

Parameters:

Name Type Description Default
damage_rule str

The damage rule to use. Must be one of the following: 'Pavlou', 'Manson-Halford', 'Si-Jian', 'Leve'.

required
cycle_count CycleCount

The cycle count object.

required
sn_curve SNCurve

The SN curve object.

required
kwargs dict

The keyword arguments for the damage rule. The following keyword arguments are allowed:

  • 'base_exponent': The exponent for the damage rule.
  • 'ultimate_stress': The ultimate stress.
{}

Returns:

Type Description
float

The cumulated damage.

Source code in py_fatigue/damage/stress_life.py
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
def get_nonlinear_damage(
    damage_rule: str,
    cycle_count: CycleCount,
    sn_curve: SNCurve,
    **kwargs,
) -> float:
    """Calculate the fatigue damage using a nonlinear damage rule.

    Parameters
    ----------
    damage_rule : str
        The damage rule to use. Must be one of the following:
        'Pavlou', 'Manson-Halford', 'Si-Jian', 'Leve'.
    cycle_count : CycleCount
        The cycle count object.
    sn_curve : SNCurve
        The SN curve object.
    kwargs : dict
        The keyword arguments for the damage rule. The following
        keyword arguments are allowed:

        - 'base_exponent': The exponent for the damage rule.
        - 'ultimate_stress': The ultimate stress.

    Returns
    -------
    float
        The cumulated damage.
    """
    if cycle_count.unit != sn_curve.unit:
        e_msg = "The units of the cycle count and SN curve must be the same."
        raise ValueError(e_msg)
    return calc_nonlinear_damage(
        damage_rule,
        cycle_count.stress_range,
        cycle_count.count_cycle,
        sn_curve,
        **kwargs,
    )

get_nonlinear_damage_with_dca

get_nonlinear_damage_with_dca(
    damage_rule,
    cycle_count,
    sn_curve,
    damage_bands,
    limit_damage=1,
    logger=None,
    plot=False,
    **kwargs
)

Calculate the fatigue damage using a nonlinear damage rule based on the Damage Curve Approach (DCA) among the allowed ones:

  • 'Pavlou': Pavlou damage rule
  • 'Theil': Theil damage rule

Refer to calc_nonlinear_damage_with_dca for the complete documentation with mathematical details.

Parameters:

Name Type Description Default
damage_rule str

The damage rule to use. Must be one of the following: 'Pavlou', 'Theil'.

required
cycle_count CycleCount

The cycle count object.

required
sn_curve SNCurve

The SN curve object.

required
damage_bands ndarray

The damage bands.

required
limit_damage Union[float, int]

The limit damage, by default 1

1
logger Logger

The logger object, by default None

None
kwargs dict

The keyword arguments for the damage rule. The following keyword arguments are allowed:

  • 'base_exponent': The exponent for the damage rule.
  • 'ultimate_stress': The ultimate stress.
{}

Returns:

Type Description
tuple[ndarray, ndarray]

The cycle-to-cycle damage and the cumulated damage.

Source code in py_fatigue/damage/stress_life.py
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
def get_nonlinear_damage_with_dca(
    damage_rule: str,
    cycle_count: CycleCount,
    sn_curve: SNCurve,
    damage_bands: np.ndarray,
    limit_damage: Union[float, int] = 1,
    logger: logging.Logger | None = None,
    plot: bool = False,
    **kwargs,
) -> tuple[
    np.ndarray,
    np.ndarray,
    matplotlib.figure.Figure | None,
    matplotlib.axes.Axes | None,
]:
    """Calculate the fatigue damage using a nonlinear damage rule based on the
    Damage Curve Approach (DCA) among the allowed ones:

    - 'Pavlou': Pavlou damage rule
    - 'Theil': Theil damage rule

    Refer to [`calc_nonlinear_damage_with_dca`]
    [py_fatigue.damage.stress_life.calc_nonlinear_damage_with_dca] for the
    complete documentation with mathematical details.

    Parameters
    ----------
    damage_rule : str
        The damage rule to use. Must be one of the following:
        'Pavlou', 'Theil'.
    cycle_count : CycleCount
        The cycle count object.
    sn_curve : SNCurve
        The SN curve object.
    damage_bands : np.ndarray
        The damage bands.
    limit_damage : Union[float, int], optional
        The limit damage, by default 1
    logger : logging.Logger, optional
        The logger object, by default None
    kwargs : dict
        The keyword arguments for the damage rule. The following
        keyword arguments are allowed:

        - 'base_exponent': The exponent for the damage rule.
        - 'ultimate_stress': The ultimate stress.

    Returns
    -------
    tuple[np.ndarray, np.ndarray]
        The cycle-to-cycle damage and the cumulated damage.
    """
    if cycle_count.unit != sn_curve.unit:
        e_msg = "The units of the cycle count and SN curve must be the same."
        raise ValueError(e_msg)
    kwargs["use_dca"] = True
    return calc_nonlinear_damage_with_dca(
        damage_rule,
        cycle_count.stress_range,
        cycle_count.count_cycle,
        sn_curve,
        damage_bands,
        limit_damage,
        logger,
        plot=plot,
        **kwargs,
    )

get_pm

get_pm(cycle_count, sn_curve)

Calculates the damage using the Palmgren-Miner rule.

Parameters:

Name Type Description Default
cycle_count CycleCount

The CycleCount object.

required
sn_curve SNCurve

The SNCurve object.

required

Returns:

Type Description
ndarray

The damage according to the Palmgren-Miner rule.

Source code in py_fatigue/damage/stress_life.py
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
def get_pm(cycle_count: CycleCount, sn_curve: SNCurve) -> np.ndarray:
    """Calculates the damage using the Palmgren-Miner rule.

    Parameters
    ----------
    cycle_count : CycleCount
        The CycleCount object.
    sn_curve : SNCurve
        The SNCurve object.

    Returns
    -------
    np.ndarray
        The damage according to the Palmgren-Miner rule.
    """
    if cycle_count.unit != sn_curve.unit:
        raise ValueError(
            f"Units of cycle_count ({cycle_count.unit}) and "
            f"sn_curve ({sn_curve.unit}) do not match."
        )
    return calc_pm(cycle_count.stress_range, cycle_count.count_cycle, sn_curve)