Migrate from v2 to v3¶
Keep your existing analysis code for the common v2 workflows. The
CycleCount, SNCurve, ParisCurve, and WalkerCurve imports remain
available at package level.
Install in a separate environment¶
Py-Fatigue 3.1.0 supports 64-bit CPython 3.10–3.15. A compatible wheel includes the Rust extension. Install Rust if pip needs to build from source.
python -m pip install "py-fatigue==3.1.0"
Run an existing v2 analysis¶
This script uses the same calls in v2.1.1 and v3. It prints the sum of the Palmgren–Miner damage contributions for a short stress history.
from py_fatigue import CycleCount, SNCurve
from py_fatigue.damage.stress_life import calc_pm
cycles = CycleCount.from_timeseries([0, 75, -15, 50, 0])
curve = SNCurve(slope=3, intercept=12)
damage = calc_pm(cycles.stress_range, cycles.count_cycle, curve)
print(float(damage.sum()))
| Existing workflow | v3 entry point |
|---|---|
| Count or combine stress histories | CycleCount.from_timeseries(), count_a + count_b, and solve_lffd() |
| Export and reload a cycle histogram | CycleCount.as_dict() and CycleCount.from_rainflow() |
| Correct for mean stress or calculate stress–life damage | CycleCount.mean_stress_correction(), calc_pm(), or the DataFrame.miner accessor |
Update code that used Numba helpers¶
Remove calls to warmup_numba(). The Rust kernels ship already compiled.
Use ordinary Python or NumPy inputs in place of to_numba_dict().
Replace imports of jit_sn_curve_residuals and other removed
Numba-specific helpers where your own code relied on them. If you call
low-level helpers directly, check their signatures in the API index.
Compare the outputs of a representative workload in both environments before switching a production analysis. Include the counted cycles and residuals, plus the damage or final crack size you use downstream.
Adopt new features when needed¶
- Use
CycleCount.from_sep005()orCycleCount.from_pyexsi()to pass a supported measured or generated stress history directly. - Continue to use Matplotlib through
.plot(). Where available,.echarts()provides an interactive view of the same analysis. - Use crack growth when the inputs are an explicit sequence of load blocks, a material fit, and a supported geometry.
- Open the marimo notebook catalogue for current examples and tutorials.
Move geometry and material imports for 3.1¶
Import crack growth curves from py_fatigue.material.crack_growth_curve.
Import each crack geometry from its structural module. Keep
LoadBlock, result types and both crack growth functions in
py_fatigue.crack_growth.
Previously imported from py_fatigue.crack_growth |
Import from |
|---|---|
NasgroCurve, ParisCurve, WalkerCurve |
py_fatigue.material.crack_growth_curve |
CenterThroughCrack, EdgeThroughCrack, SemiEllipticalSurfaceCrack, HoleBoreSurfaceCrack |
py_fatigue.geometry.plate |
AxialCylinderThroughCrack, CircumferentialCylinderThroughCrack, CircumferentialCylinderSurfaceCrack, RoundBarSurfaceCrack |
py_fatigue.geometry.cylinder |
SphereThroughCrack |
py_fatigue.geometry.sphere |
RolledBoltThreadSurfaceCrack |
py_fatigue.geometry.threaded |
The top-level imports of ParisCurve and WalkerCurve still work.
To migrate trusted pickle files containing moved classes, load them with
3.0.1 and reconstruct the objects from their parameters in the new
version. Use MCP 0.3.0 with Py-Fatigue 3.1.0
or MCP 0.2.0 with Py-Fatigue 3.0.x.
Migrate crack growth to load blocks¶
Replace simulate_crack_growth with calc_crack_growth. The arguments
and GrowthResult are the same. get_crack_growth is another name for
the same function. Both names are also available from py_fatigue.damage.
The cycle-counted solver, CalcCrackGrowth, and the pandas .cg
accessor are removed. Pass a supported geometry, a material curve,
and LoadBlock(minimum, maximum, cycles) values in the order they
occur. Use opening stress or pressure in MPa as defined by the
geometry, and crack dimensions in mm. A binned CycleCount has no load
order. Use the original load record to build the sequence.
InfiniteSurface, TabulatedGeometryFactor, Cylinder and
HollowCylinder are removed. Select the matching
geometry and check its
load and dimension limits. For example, use
CircumferentialCylinderSurfaceCrack for a pipe surface crack under
axial tension, with internal=True for an inner-wall crack.
For a complete example and the solver controls, see
Crack growth analysis.