fatpy
¶
FatPy - A Python package for fatigue life evaluation of materials.
core
¶
Core fatigue analysis methods and functionality.
damage_cumulation
¶
Damage cumulation module.
This module contains the classes and functions for damage cumulation methods.
decompositions
¶
Decompositions module.
This module contains the classes and functions for decomposition methods.
energy_life
¶
Energy-based fatigue life analysis methods.
This package provides implementations of energy-based approaches for fatigue life prediction and analysis.
plane_based_methods
¶
Plane-based methods module.
This module contains the classes and functions for plane-based methods.
strain_life
¶
Strain-based fatigue life analysis methods.
This package provides implementations of strain-based approaches for fatigue life prediction and analysis.
stress_life
¶
Stress-based fatigue life analysis methods.
This package provides implementations of stress-based approaches for fatigue life prediction and analysis.
data_parsing
¶
examples
¶
This module contains an example function with a detailed docstring.
docstring_example_tmp
¶
This module contains an example function with a detailed docstring.
ExampleClass
¶
An example class to demonstrate docstring formatting.
Source code in src/fatpy/examples/docstring_example_tmp.py
__init__(value)
¶
Initialize the ExampleClass with a value.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
value
|
int
|
The initial value for the class instance. |
required |
increment(amount)
¶
Increment the stored value by a specified amount.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
amount
|
int
|
The amount to increment the value by. |
required |
Returns:
Name | Type | Description |
---|---|---|
int |
int
|
The new value after incrementing. |
Source code in src/fatpy/examples/docstring_example_tmp.py
example_method_with_docstring(a, b)
¶
Docstring with a cross-reference to the example function.
This method demonstrates how to reference another function's docstring.
It calls example_function_with_docstring
with sample arguments.
Cross-reference
Parameters:
Name | Type | Description | Default |
---|---|---|---|
a
|
int
|
The first integer value. |
required |
b
|
int
|
The second integer value. |
required |
Returns:
Name | Type | Description |
---|---|---|
int |
int
|
The result of the example function. |
Source code in src/fatpy/examples/docstring_example_tmp.py
example_function_with_docstring(a, b)
¶
This docstring highlights Mermaid diagrams, math expressions, and code examples.
This function takes two integers and returns their sum. It demonstrates various mkdocs-material features:
Information
This is an informational admonition block.
Important Note
Make sure both parameters are integers.
Mermaid Diagram¶
graph TD
A[Start] --> B{Is it a number?}
B -- Yes --> C[Process the number]
B -- No --> D[Throw an error]
C --> E[End]
D --> E
Mathematical Expression¶
Inline math: \(E = mc^2\)
Code Examples¶
Expandable Example
This is a collapsible content section that shows more detailed usage:
Table Example¶
Input A | Input B | Result |
---|---|---|
1 | 2 | 3 |
5 | 7 | 12 |
0 | 0 | 0 |
Args:¶
a
(int): The first integer.b
(int): The second integer.
Returns:¶
- int: The sum of the two integers.
Raises:¶
TypeError
: If inputs are not integers.
Examples:¶
Source code in src/fatpy/examples/docstring_example_tmp.py
material_laws
¶
Material laws module.
Contains the classes and functions for defining and working with material laws.
struct_mech
¶
Structural mechanics module.
This module contains the classes and functions for structural mechanics analysis.
stress
¶
Calculate fundamental stress metrics and invariants.
These functions provide principal stresses, maximum shear (Tresca) stress, hydrostatic stress, von Mises equivalent stress, and invariants of the stress tensor. They are essential for strength, fatigue, and fracture analyses under both uniaxial and multiaxial loading conditions.
Conventions: - Vectors use Voigt notation with shape (..., 6), where the last dimension contains the six Voigt components and leading dimensions are preserved:
(σ_11, σ_22, σ_33, σ_23, σ_13, σ_12)
(σ_xx, σ_yy, σ_zz, σ_yz, σ_xz, σ_xy)
-
Principal stresses are ordered in descending order throughout the module (σ_1 ≥ σ_2 ≥ σ_3).
-
Principal directions (eigenvectors) are aligned to this ordering (columns correspond to σ_1, σ_2, σ_3).
calc_principal_stresses_and_directions(stress_vector_voigt)
¶
Calculate principal stresses and principal directions for each state.
Math Equations
Principal stresses and directions are found by solving the eigenvalue problem for the stress tensor:
Parameters:
Name | Type | Description | Default |
---|---|---|---|
stress_vector_voigt
|
NDArray[float64]
|
Array of shape (..., 6). The last dimension contains the Voigt stress components. Leading dimensions are preserved. |
required |
Returns:
Name | Type | Description |
---|---|---|
Tuple |
(eigvals, eigvecs)
|
|
NDArray[float64]
|
|
|
tuple[NDArray[float64], NDArray[float64]]
|
(descending: σ_1 ≥ σ_2 ≥ σ_3) with leading dimensions preserved. |
|
tuple[NDArray[float64], NDArray[float64]]
|
|
|
tuple[NDArray[float64], NDArray[float64]]
|
eigenvectors) aligned with eigvals in the same order. The last two |
|
tuple[NDArray[float64], NDArray[float64]]
|
dimensions are the 3x3 eigenvector matrix for each input. |
Raises:
Type | Description |
---|---|
ValueError
|
If the last dimension is not of size 6. |
Source code in src/fatpy/struct_mech/stress.py
calc_principal_stresses(stress_vector_voigt)
¶
Calculate principal stresses for each stress state.
Math Equations
Principal stresses are found by solving the eigenvalue problem for the stress tensor:
Parameters:
Name | Type | Description | Default |
---|---|---|---|
stress_vector_voigt
|
NDArray[float64]
|
Array of shape (..., 6). The last dimension contains the Voigt stress components. Leading dimensions are preserved. |
required |
Returns:
Type | Description |
---|---|
NDArray[float64]
|
Array of shape (..., 3). Principal stresses (descending: σ1 ≥ σ2 ≥ σ3). |
Raises:
Type | Description |
---|---|
ValueError
|
If the last dimension is not of size 6. |
Source code in src/fatpy/struct_mech/stress.py
calc_stress_invariants(stress_vector_voigt)
¶
Calculate the first, second, and third invariants for each stress state.
Math Equations
Parameters:
Name | Type | Description | Default |
---|---|---|---|
stress_vector_voigt
|
NDArray[float64]
|
Array of shape (..., 6). The last dimension contains the Voigt stress components. Leading dimensions are preserved. |
required |
Returns:
Type | Description |
---|---|
NDArray[float64]
|
Array of shape (..., 3). The last dimension contains (I1, I2, I3) for each entry. |
Raises:
Type | Description |
---|---|
ValueError
|
If the last dimension is not of size 6. |
Source code in src/fatpy/struct_mech/stress.py
calc_hydrostatic_stress(stress_vector_voigt)
¶
Calculate the hydrostatic (mean normal) stress for each stress state.
Math Equations
Parameters:
Name | Type | Description | Default |
---|---|---|---|
stress_vector_voigt
|
NDArray[float64]
|
Array of shape (..., 6). The last dimension contains the Voigt stress components. Leading dimensions are preserved. |
required |
Returns:
Type | Description |
---|---|
NDArray[float64]
|
Array of shape (...). Hydrostatic stress for each input state. Tensor rank is reduced by one. |
Raises:
Type | Description |
---|---|
ValueError
|
If the last dimension is not of size 6. |
Source code in src/fatpy/struct_mech/stress.py
calc_stress_deviator(stress_vector_voigt)
¶
Calculate stress deviator for each stress state.
Math Equations
Parameters:
Name | Type | Description | Default |
---|---|---|---|
stress_vector_voigt
|
NDArray[float64]
|
Array of shape (..., 6). The last dimension contains the Voigt stress components. Leading dimensions are preserved. |
required |
Returns:
Type | Description |
---|---|
NDArray[float64]
|
Array of shape (..., 6). Stress deviator for each entry. |
Raises:
Type | Description |
---|---|
ValueError
|
If the last dimension is not of size 6. |
Source code in src/fatpy/struct_mech/stress.py
calc_von_mises_stress(stress_vector_voigt)
¶
Calculate von Mises equivalent stress for each stress state.
Math Equations
Parameters:
Name | Type | Description | Default |
---|---|---|---|
stress_vector_voigt
|
NDArray[float64]
|
Array of shape (..., 6). The last dimension contains the Voigt stress components. Leading dimensions are preserved. |
required |
Returns:
Type | Description |
---|---|
NDArray[float64]
|
Array of shape (...). Von Mises equivalent stress for each entry. Tensor rank is reduced by one. |
Raises:
Type | Description |
---|---|
ValueError
|
If the last dimension is not of size 6. |
Source code in src/fatpy/struct_mech/stress.py
calc_signed_von_mises_by_hydrostatic(stress_vector_voigt, rtol=1e-05, atol=1e-08)
¶
Calculate signed von Mises stress for each stress state.
Sign is determined by the hydrostatic stress.
The sign assignment follows these rules: - Positive (+): When hydrostatic stress > 0 (tensile dominant state) - Negative (-): When hydrostatic stress < 0 (compressive dominant state) - Positive (+): When hydrostatic stress ≈ 0 (within tolerance, default fallback)
Tolerance parameters ensure numerical stability in edge cases where the determining value is very close to zero, preventing erratic sign changes that could occur due to floating-point precision limitations.
Math Equations
Parameters:
Name | Type | Description | Default |
---|---|---|---|
stress_vector_voigt
|
NDArray[float64]
|
Array of shape (..., 6). The last dimension contains the Voigt stress components. Leading dimensions are preserved. |
required |
rtol
|
float
|
Relative tolerance for comparing hydrostatic stress to zero. Default is 1e-5. |
1e-05
|
atol
|
float
|
Absolute tolerance for comparing hydrostatic stress to zero. Default is 1e-8. |
1e-08
|
Returns:
Type | Description |
---|---|
NDArray[float64]
|
Array of shape (...). Signed von Mises stress for each entry. Tensor rank is reduced by one. |
Raises:
Type | Description |
---|---|
ValueError
|
If the last dimension is not of size 6. |
Source code in src/fatpy/struct_mech/stress.py
calc_signed_von_mises_by_max_abs_principal(stress_voigt, rtol=1e-05, atol=1e-08)
¶
Calculate signed von Mises stress for each stress state.
Sign is determined by average of the maximum and minimum principal stresses.
The sign assignment follows these rules: - Positive (+): When (σ₁ + σ₃)/2 > 0 (tension dominant) - Negative (-): When (σ₁ + σ₃)/2 < 0 (compression dominant) - Positive (+): When (σ₁ + σ₃)/2 ≈ 0 (within tolerance, default fallback)
Tolerance parameters ensure numerical stability in edge cases where the determining value is very close to zero, preventing erratic sign changes that could occur due to floating-point precision limitations.
Math Equations
Parameters:
Name | Type | Description | Default |
---|---|---|---|
stress_voigt
|
NDArray[float64]
|
Array of shape (..., 6). The last dimension contains the Voigt stress components. Leading dimensions are preserved. |
required |
rtol
|
float
|
Relative tolerance for comparing the average of maximum and minimum principal stresses to zero. Default is 1e-5. |
1e-05
|
atol
|
float
|
Absolute tolerance for comparing the average of maximum and minimum principal stresses to zero. Default is 1e-8. |
1e-08
|
Returns:
Type | Description |
---|---|
NDArray[float64]
|
Array of shape (...). Signed von Mises stress for each entry. Tensor rank is reduced by one. |
Raises:
Type | Description |
---|---|
ValueError
|
If the last dimension is not of size 6. |
Source code in src/fatpy/struct_mech/stress.py
calc_signed_von_mises_by_first_invariant(stress_vector_voigt, rtol=1e-05, atol=1e-08)
¶
Calculate signed von Mises stress for each stress state.
Sign is determined by the first invariant of the stress tensor.
The sign assignment follows these rules: - Positive (+): When tr(σ) > 0 (tensile volumetric stress) - Negative (-): When tr(σ) < 0 (compressive volumetric stress) - Positive (+): When tr(σ) ≈ 0 (within tolerance, default fallback)
Tolerance parameters ensure numerical stability in edge cases where the determining value is very close to zero, preventing erratic sign changes that could occur due to floating-point precision limitations.
Math Equations
Parameters:
Name | Type | Description | Default |
---|---|---|---|
stress_vector_voigt
|
NDArray[float64]
|
Array of shape (..., 6). The last dimension contains the Voigt stress components. Leading dimensions are preserved. |
required |
rtol
|
float
|
Relative tolerance for comparing the first invariant to zero. Default is 1e-5. |
1e-05
|
atol
|
float
|
Absolute tolerance for comparing the first invariant to zero. Default is 1e-8. |
1e-08
|
Returns:
Type | Description |
---|---|
NDArray[float64]
|
Array of shape (...). Signed von Mises stress for each entry. Tensor rank is reduced by one. |
Raises:
Type | Description |
---|---|
ValueError
|
If the last dimension is not of size 6. |
Source code in src/fatpy/struct_mech/stress.py
calc_tresca_stress(stress_vector_voigt)
¶
Calculate Tresca (maximum shear) stress for each stress state.
Math Equations
Parameters:
Name | Type | Description | Default |
---|---|---|---|
stress_vector_voigt
|
NDArray[float64]
|
Array of shape (..., 6). The last dimension contains the Voigt stress components. Leading dimensions are preserved. |
required |
Returns:
Type | Description |
---|---|
NDArray[float64]
|
Array of shape (...). Tresca stress for each entry. For principal stresses σ1 ≥ σ2 ≥ σ3, Tresca = (σ1 − σ3)/2. Tensor rank is reduced by one. |
Raises:
Type | Description |
---|---|
ValueError
|
If the last dimension is not of size 6. |
Source code in src/fatpy/struct_mech/stress.py
calc_signed_tresca_by_hydrostatic(stress_vector_voigt, rtol=1e-05, atol=1e-08)
¶
Calculate signed Tresca stress for each stress state.
Sign is determined by the hydrostatic stress.
The sign assignment follows these rules: - Positive (+): When hydrostatic stress > 0 (tensile dominant state) - Negative (-): When hydrostatic stress < 0 (compressive dominant state) - Positive (+): When hydrostatic stress ≈ 0 (within tolerance, default fallback)
Tolerance parameters ensure numerical stability in edge cases where the determining value is very close to zero, preventing erratic sign changes that could occur due to floating-point precision limitations.
Math Equations
Parameters:
Name | Type | Description | Default |
---|---|---|---|
stress_vector_voigt
|
NDArray[float64]
|
Array of shape (..., 6). The last dimension contains the Voigt stress components. Leading dimensions are preserved. |
required |
rtol
|
float
|
Relative tolerance for comparing hydrostatic stress to zero. Default is 1e-5. |
1e-05
|
atol
|
float
|
Absolute tolerance for comparing hydrostatic stress to zero. Default is 1e-8. |
1e-08
|
Returns:
Type | Description |
---|---|
NDArray[float64]
|
Array of shape (...). Signed Tresca stress for each entry. Tensor rank is reduced by one. |
Raises:
Type | Description |
---|---|
ValueError
|
If the last dimension is not of size 6. |
Source code in src/fatpy/struct_mech/stress.py
calc_signed_tresca_by_max_abs_principal(stress_vector_voigt, rtol=1e-05, atol=1e-08)
¶
Calculate signed Tresca stress for each stress state.
Sign is determined by the maximum absolute principal stress value.
The sign assignment follows these rules: - Positive (+): When (σ₁ + σ₃)/2 > 0 (tension dominant) - Negative (-): When (σ₁ + σ₃)/2 < 0 (compression dominant) - Positive (+): When (σ₁ + σ₃)/2 ≈ 0 (within tolerance, default fallback)
Tolerance parameters ensure numerical stability in edge cases where the determining value is very close to zero, preventing erratic sign changes that could occur due to floating-point precision limitations.
Math Equations
Parameters:
Name | Type | Description | Default |
---|---|---|---|
stress_vector_voigt
|
NDArray[float64]
|
Array of shape (..., 6). The last dimension contains the Voigt stress components. Leading dimensions are preserved. |
required |
rtol
|
float
|
Relative tolerance for comparing the average of maximum and minimum principal stresses to zero. Default is 1e-5. |
1e-05
|
atol
|
float
|
Absolute tolerance for comparing the average of maximum and minimum principal stresses to zero. Default is 1e-8. |
1e-08
|
Returns:
Type | Description |
---|---|
NDArray[float64]
|
Array of shape (...). Signed Tresca stress for each entry. Tensor rank is reduced by one. |
Raises:
Type | Description |
---|---|
ValueError
|
If the last dimension is not of size 6. |
Source code in src/fatpy/struct_mech/stress.py
transformations
¶
Contains the functions for tensor and other transformations.
utils
¶
Utility functions for the fatigue analysis package.
mesh
¶
Mesh processing utilities module.
This module provides various functions and classes for mesh processing tasks.
post_processing
¶
Utilities for post-processing fatigue analysis results.
pre_processing
¶
Utilities for pre-processing fatigue analysis results.
signal
¶
Signal processing utilities module.
This module provides various functions and classes for signal processing tasks.
voigt
¶
Tools for working with Voigt notation in continuum mechanics.
Overview
This module provides general utilities for handling vectors and tensors represented in Voigt notation. Voigt notation is widely used to express symmetric 3x3 tensors, such as stress and strain, in a compact vector form.
Input Shape Convention
- Arrays are expected to have shape (..., 6), where the last dimension contains the six Voigt components: (σ_11, σ_22, σ_33, σ_23, σ_13, σ_12) (σ_xx, σ_yy, σ_zz, σ_yz, σ_xz, σ_xy) Leading dimensions (the '...' part) are preserved and can be arbitrary, allowing batch processing of multiple vectors or tensors.
check_shape(vector)
¶
Validate the Voigt vector shape.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
vector
|
NDArray[float64]
|
Array with shape (..., 6) where the last dimension has length 6. |
required |
Raises:
Type | Description |
---|---|
ValueError
|
If the last dimension is not of size 6. |
Source code in src/fatpy/utils/voigt.py
voigt_to_tensor(vector)
¶
Convert Voigt vectors to symmetric 3x3 tensors.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
vector
|
NDArray[float64]
|
Array of shape (..., 6) where the last dimension contains the stress/strain components in order according to Voigt notation: (σ_11, σ_22, σ_33, σ_23, σ_13, σ_12) (σ_xx, σ_yy, σ_zz, σ_yz, σ_xz, σ_xy) |
required |
Returns:
Type | Description |
---|---|
NDArray[float64]
|
Array with shape (..., 3, 3). The last two axes are the symmetric |
NDArray[float64]
|
3x3 tensor for each input index. Leading dimensions are preserved. |
Raises:
Type | Description |
---|---|
ValueError
|
If the last dimension is not of size 6. |
Source code in src/fatpy/utils/voigt.py
tensor_to_voigt(tensor)
¶
Convert symmetric 3x3 tensors to Voigt vectors.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
tensor
|
NDArray[float64]
|
Array of shape (..., 3, 3) where the last two dimensions represent symmetric 3x3 tensors. |
required |
Returns:
Type | Description |
---|---|
NDArray[float64]
|
Array with shape (..., 6). The last dimension contains the stress/strain |
NDArray[float64]
|
components in order according to Voigt notation: (σ_11, σ_22, σ_33, σ_23, σ_13, σ_12) (σ_xx, σ_yy, σ_zz, σ_yz, σ_xz, σ_xy) |
NDArray[float64]
|
Leading dimensions are preserved. |
Raises:
Type | Description |
---|---|
ValueError
|
If the last two dimensions are not of size (3, 3). |