From a global time history to armour fatigue
Goal: read the curvature and tension history of a cable section from a global analysis export, recover the stress of every armour wire at fixed material fibres, count the cycles of every fibre and sum the Miner damage, and find the governing wire and fibre with its damage-equivalent stress range.
Script:
doc/tutorials/scripts/tutorial_03_global_to_fatigue.py
· Run time: about ten seconds
Run it from a source checkout:
python doc/tutorials/scripts/tutorial_03_global_to_fatigue.py
The code blocks below are taken from the script and the output blocks are what
it prints. tests/test_tutorials_03_04.py runs the script and checks that the
two still agree.
Imports
import csv
import sys
import tempfile
import warnings
from pathlib import Path
import matplotlib.pyplot as plt
import numpy as np
import cablexsec as cx
from cablexsec.analysis.fast_rainflow import fibre_fatigue
from cablexsec.analysis.fatigue import rainflow_cycles, wire_stress_field
from cablexsec.cable_adapters import cable_to_fatigue_layers
REPOSITORY = Path(__file__).resolve().parents[3]
FIGURES = (
Path(sys.argv[1])
if len(sys.argv) > 1
else Path(__file__).resolve().parents[1] / "figures"
)
fibre_fatigue, rainflow_cycles, wire_stress_field and
cable_to_fatigue_layers are the building blocks of compute_fatigue. The
tutorial calls them directly to show the stresses behind the damage.
1. A time-history export
The script first writes a section history in the layout of a time-history CSV export: one header row of named columns, then one row per time sample.
The record is synthetic. cx.jonswap_series shapes the curvature with a
JONSWAP spectrum (significant wave height 3 m, peak period 9 s) and
scales it to a chosen RMS. The script adds a static sag-bend curvature of
0.05 1/m, an out-of-plane component with 30 % of the in-plane RMS, and a
tension that follows the in-plane curvature. It illustrates the route; it is
not the response of a global model.
# A synthetic sag-bend record: JONSWAP-shaped in-plane and out-of-plane
# curvature about a static sag curvature, and a dynamic tension that follows
# the in-plane curvature. It stands in for the export of a global analysis.
duration_s = 600.0
record = cx.jonswap_series(
hs_m=3.0,
tp_s=9.0,
duration_s=duration_s,
dt_s=0.2,
rms_curvature_1_m=0.01,
dynamic_tension_rms_N=8.0e3,
tension_phase_deg=30.0,
out_of_plane_fraction=0.3,
seed=7,
)
# Rotation components as a global program writes them: the sag bend of a line
# in a vertical plane is a negative rotation about e2 (y curvature).
y_curvature = -(0.05 + record.curvature_x_1_m)
x_curvature = record.curvature_y_1_m
tension_kn = (60.0e3 + record.tension_N) / 1.0e3
work = tempfile.TemporaryDirectory()
export = Path(work.name) / "sag_bend_history.csv"
with export.open("w", newline="", encoding="utf-8") as stream:
writer = csv.writer(stream)
writer.writerow(
[
"Time (s)",
"x curvature (rad/m)",
"y curvature (rad/m)",
"Effective tension (kN)",
]
)
for row in zip(record.time_s, x_curvature, y_curvature, tension_kn, strict=True):
writer.writerow([f"{value:.6g}" for value in row])
print("".join(export.read_text(encoding="utf-8").splitlines(keepends=True)[:3]), end="")
Time (s),x curvature (rad/m),y curvature (rad/m),Effective tension (kN)
0,-0.000958504,-0.0483883,59.2063
0.2,-0.00121411,-0.0488292,59.5659
The curvature columns are the components of the rotation curvature
vector t × dt/ds on the section axes e1 and e2, as global line programs
write them. A line hanging in the vertical x–z plane bends about e2, so its
sag bend has a negative y curvature. The tension is effective tension in kN.
2. The reader picks columns by their headings
series = cx.read_time_history_csv(
export,
time_col="Time",
curvature_x_col="x curvature",
curvature_y_col="y curvature",
tension_col="Effective tension",
curvature_convention="rotation",
tension_scale_to_N=1.0e3,
)
work.cleanup()
kx, ky = series.curvature_x_1_m, series.curvature_y_1_m
print(f"samples {series.n_steps}, step {series.dt_s:.2f} s")
print(f"tension kind: {series.tension_kind}")
print(f"strain gradient x {kx.min():+.4f} to {kx.max():+.4f} 1/m")
print(f"strain gradient y {ky.min():+.4f} to {ky.max():+.4f} 1/m")
print(
f"tension {series.tension_N.min() / 1e3:.1f} to "
f"{series.tension_N.max() / 1e3:.1f} kN"
)
samples 3000, step 0.20 s
tension kind: effective
strain gradient x +0.0232 to +0.0784 1/m
strain gradient y -0.0089 to +0.0082 1/m
tension 36.8 to 82.3 kN
read_time_history_csv selects each column by a piece of its heading:
Argument |
Default |
Meaning |
|---|---|---|
|
|
time [s] |
|
|
the two signed curvature components; |
|
|
axial force |
|
|
optional direct tensile strain and temperature |
|
|
multiplier to 1/m ( |
|
|
multiplier to N (the default reads kN) |
|
|
|
|
inferred |
|
A selector matches a heading that contains it, without regard to case, so
"Effective tension" finds Effective tension (kN). A selector that matches
no heading, or more than one, stops the read with a CableSchemaError that
names the headings. Units are never read from the heading. The scale
arguments convert them, so a file in N needs tension_scale_to_N=1.0.
The reader converts the rotation components to the strain gradient that CableXSec uses everywhere:
(g_x, g_y) = (−y curvature, x curvature)
A fibre at (x, y) = r (cos φ, sin φ) then has the bending strain
g_x x + g_y y, and the gradient points to the most tensile fibre. The sag
curvature of the record appears as a positive g_x throughout: the tensile
side of the bend is at φ = 0, on e1, the downward side of the section. A
curvature magnitude column is refused, because it cannot show the reversals
of the bending direction. Section 4.3 of the
local analysis guide and Section 2 of the
global–local guide give the sign checks behind
this mapping.
The tension kind comes from the heading. Wall tension and
True tension are read as true tension, Effective tension as effective
tension. Any other heading gives the kind unspecified, which the fatigue
routes refuse, so declare it with tension_kind=. An explicit kind that
contradicts a recognised heading is refused.
The bundled demonstration history
The repository holds a short history from a global time-domain analysis of the
public 220 kV representative export cable, at the most curved section of its
line (validation/paper_data/global_demo/). The file is in CableXSec’s own
exchange format, with SI units and strain-gradient columns, so the same reader
needs other selectors, another unit scale and another convention:
demo = REPOSITORY / "validation/paper_data/global_demo/global_history_si.csv"
demo_series = cx.read_time_history_csv(
demo,
time_col="time_s",
curvature_x_col="curvature_x_1_m",
curvature_y_col="curvature_y_1_m",
tension_col="effective_tension_N",
curvature_convention="strain_gradient",
tension_kind="effective",
tension_scale_to_N=1.0,
)
same = cx.read_series_csv(demo)
print(
f"demo history: {demo_series.n_steps} samples, step {demo_series.dt_s:.1f} s, "
f"largest curvature "
f"{np.hypot(demo_series.curvature_x_1_m, demo_series.curvature_y_1_m).max():.4f}"
f" 1/m, tension {demo_series.tension_N.min() / 1e3:.1f} to "
f"{demo_series.tension_N.max() / 1e3:.1f} kN"
)
print(
"same arrays as read_series_csv:",
all(
np.array_equal(getattr(demo_series, name), getattr(same, name))
for name in ("time_s", "curvature_x_1_m", "curvature_y_1_m", "tension_N")
),
)
demo history: 201 samples, step 0.1 s, largest curvature 0.0349 1/m, tension 25.1 to 25.4 kN
same arrays as read_series_csv: True
read_series_csv reads the exchange format directly, and both routes give the
same arrays. The demonstration record is 20 s long and nearly static, so the
rest of the tutorial uses the synthetic record.
3. The annulus decides which force loads the armour
cable = cx.load_cable(cx.iea_task49_66kv_yaml_path())
print(cable.cable.name)
print(f"armour annulus: {cable.water_ingress.armour_annulus}")
try:
cx.fatigue_from_series(cable, series)
except cx.CableSchemaError as error:
print(f"fatigue_from_series: {str(error).split(';')[0]}")
IEA Task 49 / Janocha 2024 66 kV three-core (public template)
armour annulus: flooded
fatigue_from_series: effective tension is not a material force
The cable is the public 66 kV three-core design of Janocha et al. (2024) and
IEA Wind Task 49 (template page). The wire stress needs
the force that the armour carries. fatigue_from_series accepts only true
force, so it refuses the effective tension of the export. The right force
depends on the armour annulus.
In a flooded annulus, as on this cable, seawater reaches the armour and the
hydrostatic pressure acts on every face of the layers, so the effective
tension loads the armour. Pass it to compute_fatigue as tension_N, as the
sea-state batch does with tension_basis="effective".
In a sealed annulus, convert first with
series.with_true_tension(external_pressure_Pa, external_area_m2), which
gives T_e − p_o A_o, and use fatigue_from_series.
4. Every wire gets its own damage
with warnings.catch_warnings(record=True) as caught:
warnings.simplefilter("always")
fatigue = cx.compute_fatigue(cable, kx, ky, tension_N=series.tension_N)
print("warnings:", ", ".join(sorted({item.category.__name__ for item in caught})))
for name, damage in fatigue.D_total_per_wire.items():
layer = cable.get_layer(name)
wire = int(np.argmax(damage))
print(
f"{name}: {layer.n_wires} wires, damage {damage.min():.3e} to "
f"{damage.max():.3e}, largest on wire {wire} at "
f"{360.0 * wire / layer.n_wires:.1f} deg, fibre "
f"{fatigue.fibre_critical_deg_per_wire[name][wire]:.2f} deg"
)
print(
f"governing: {fatigue.critical_layer}, wire at {fatigue.phi_critical_deg:.1f} deg, "
f"fibre {fatigue.fibre_critical_deg:.2f} deg ({fatigue.governing} damage)"
)
warnings: DirectionTiedFrictionWarning, MissingClampingStateWarning
inner_armour: 139 wires, damage 7.715e-09 to 1.383e-08, largest on wire 70 at 181.3 deg, fibre 180.00 deg
outer_armour: 145 wires, damage 7.428e-09 to 8.886e-09, largest on wire 73 at 181.2 deg, fibre 180.00 deg
governing: inner_armour, wire at 181.3 deg, fibre 180.00 deg (bulk damage)
compute_fatigue follows the stick and slip of every wire through the whole
record, with the armour contact pressure following the tension history. It
then rainflow-counts the stress at 32 fixed fibres round each wire and sums
the Miner damage against the layer’s S–N curve (bulk_sn in the cable
file).
D_bulk_per_fibre[layer] keeps the damage at every wire and fibre, and
D_bulk_per_wire[layer] the largest fibre damage of each wire.
D_total_per_wire[layer] adds the contact and termination terms. Both are
zero here: the two armour layers declare fretting_sn: "", bulk fatigue only,
and no termination is requested.
Wire k of a layer of n wires sits at the azimuth 360 k / n degrees from
e1. Fibre angles are measured round the wire from its outward radial fibre,
so fibre 180° is the inward fibre.
The 66 kV template declares zero manufacturing clamping because its source
publishes none, and the run says so with MissingClampingStateWarning. The
armour friction then comes from the tension alone, so the friction stresses
and damages sit at their low end (Section 4.4 of the local analysis guide).
DirectionTiedFrictionWarning announces a change of default: the record
bends the cable in more than one plane, and a later release will solve such
records with friction_model="auto", the distributed helix friction model,
instead of the direction-tied law used here (Section 9 of the local analysis
guide). Pass friction_model explicitly to choose the law and silence it.
Damage of every wire over the 600 s record. The dashed line marks the governing wire.
The inner armour damage is largest on the wires in the plane of the sag bend, near 0° and 180°, and smallest near the neutral axis, at 90° and 270°. The wire on the concave side, at 181°, governs, at its inward fibre. The outer armour damage changes little round the section.
5. The stresses behind the damage can be recovered
wire_stress_field gives, for every wire and sample, the stress of the wire
axis from tension and friction, and the two components of the bending of the
wire about its own axes. at_fibre(angle) combines them at any fibre.
fibre_fatigue counts every fibre in one pass and returns the damage and the
1 Hz damage-equivalent stress range.
warnings.simplefilter("ignore", cx.MissingClampingStateWarning) # reported above
layers = cable_to_fatigue_layers(cable, contact_tension_N=float(series.tension_N[0]))
pressure, _ = cx.armour_contact_histories(cable, series.tension_N)
ea_fixed = cx.compute_stiffness(cable).ea_fixed_N
angles = np.radians(fatigue.fibre_angles_deg)
fields = {}
for layer in layers:
field = wire_stress_field(
layer,
kx,
ky,
series.tension_N,
ea_fixed,
contact_pressure_Pa=pressure[layer.name],
)
damage, equivalent_1hz, _, _ = fibre_fatigue(
field.mean_Pa,
field.radial_Pa,
field.tangential_Pa,
angles,
layer.sn_bulk,
duration_s,
)
fields[layer.name] = field
wire, fibre = np.unravel_index(np.argmax(damage), damage.shape)
print(
f"{layer.name}: same damage as compute_fatigue "
f"{np.allclose(damage, fatigue.D_bulk_per_fibre[layer.name], rtol=1e-10)}, "
f"1 Hz equivalent range {equivalent_1hz.min():.2f} to "
f"{equivalent_1hz.max():.2f} MPa"
)
inner_armour: same damage as compute_fatigue True, 1 Hz equivalent range 2.18 to 12.39 MPa
outer_armour: same damage as compute_fatigue True, 1 Hz equivalent range 2.11 to 11.10 MPa
With the contact pressure history of armour_contact_histories and the
reference tension of the first sample, the recovered fields reproduce the
damage of compute_fatigue at every wire and fibre. A recovery started this
way can also drop a lead-in from the count; see Step 3 in Section 5 of the
local analysis guide, and the count_from_sample argument of
compute_fatigue.
6. One range stands for the whole history
name = fatigue.critical_layer
layer = next(item for item in layers if item.name == name)
wire = int(np.argmax(fatigue.D_total_per_wire[name]))
fibre_deg = fatigue.fibre_critical_deg_per_wire[name][wire]
stress = fields[name].at_fibre(np.radians(fibre_deg))[wire]
cycles = list(rainflow_cycles(stress))
ranges_mpa = np.array([cycle[0] for cycle in cycles]) / 1e6
counts = np.array([cycle[2] for cycle in cycles])
m = layer.sn_bulk.m1
counted = counts.sum()
equivalent_mpa = (np.sum(counts * ranges_mpa**m) / counted) ** (1.0 / m)
equivalent_1hz_mpa = (np.sum(counts * ranges_mpa**m) / duration_s) ** (1.0 / m)
print(f"S-N curve {layer.sn_bulk.name}: slope m = {m:g}, {layer.sn_bulk.reference}")
print(
f"stress at the governing fibre: {stress.min() / 1e6:.1f} to "
f"{stress.max() / 1e6:.1f} MPa"
)
print(f"rainflow: {counted:.1f} cycles, largest range {ranges_mpa.max():.2f} MPa")
print(f"equivalent range over the counted cycles {equivalent_mpa:.2f} MPa")
print(f"equivalent range at 1 Hz, {duration_s:.0f} cycles {equivalent_1hz_mpa:.2f} MPa")
print(
f"damage from the equivalent range "
f"{counted / layer.sn_bulk.cycles_to_failure(equivalent_mpa):.4e}, "
f"from compute_fatigue {fatigue.D_total_per_wire[name][wire]:.4e}"
)
S-N curve saevik_2011_flat_steel: slope m = 4, [Saevik2011] Eq. (89)
stress at the governing fibre: 16.1 to 48.8 MPa
rainflow: 153.0 cycles, largest range 32.74 MPa
equivalent range over the counted cycles 17.44 MPa
equivalent range at 1 Hz, 600 cycles 12.39 MPa
damage from the equivalent range 1.3829e-08, from compute_fatigue 1.3829e-08
For an S–N curve of a single slope m, the damage-equivalent stress range
over N_eq cycles is
with n_i the rainflow counts (half cycles count 0.5) and Δσ_i their ranges.
With N_eq equal to the counted cycles, it is the constant range that does the
same damage in the same number of cycles. With one cycle per second, it is the
1 Hz range that fibre_fatigue reports. N_eq / N_f(Δσ_eq) returns the Miner
damage of the fibre.
A curve with a knee or a cut-off has no single slope. The equivalent range
then belongs to one slope only, and the damage must be summed cycle by cycle,
as compute_fatigue does.
Stress at the governing fibre over the first 120 s of the record.
7. Figures
fig, ax = plt.subplots(figsize=(6.4, 3.4), layout="constrained")
for name, damage in fatigue.D_total_per_wire.items():
count = damage.size
ax.plot(360.0 * np.arange(count) / count, damage, label=name.replace("_", " "))
ax.axvline(fatigue.phi_critical_deg, color="0.5", linewidth=0.8, linestyle="--")
ax.set_xlabel("wire azimuth from e1 [deg]")
ax.set_ylabel("Miner damage over the record")
ax.set_xlim(0.0, 360.0)
ax.set_xticks(np.arange(0, 361, 45))
ax.set_ylim(bottom=0.0)
ax.ticklabel_format(axis="y", style="sci", scilimits=(0, 0))
ax.legend(frameon=False, loc="lower center")
fig.savefig(FIGURES / "tutorial_03_damage_circumference.png", dpi=150)
plt.close(fig)
print("wrote tutorial_03_damage_circumference.png")
fig, ax = plt.subplots(figsize=(6.4, 3.0), layout="constrained")
window = series.time_s <= 120.0
ax.plot(series.time_s[window], stress[window] / 1e6, linewidth=0.9)
ax.set_xlabel("time [s]")
ax.set_ylabel("fibre stress [MPa]")
ax.set_xlim(0.0, 120.0)
ax.set_title(
f"{fatigue.critical_layer.replace('_', ' ')}, wire at "
f"{fatigue.phi_critical_deg:.0f} deg, fibre {fatigue.fibre_critical_deg:.0f} deg",
fontsize=10,
)
fig.savefig(FIGURES / "tutorial_03_governing_fibre_stress.png", dpi=150)
plt.close(fig)
print("wrote tutorial_03_governing_fibre_stress.png")
wrote tutorial_03_damage_circumference.png
wrote tutorial_03_governing_fibre_stress.png
Where next
A design life combines many sea states. compute_long_term_fatigue sums the
damage of a scatter of records at every fixed fibre (Step 5 in Section 5 of
the local analysis guide). For CableDyn runs, run_sea_state_batch and the
cablexsec-batch command read each section and sum over the sea states, as
the global–local guide describes.
Sections near an end fitting or a clamped bend-stiffener root need the
termination correction, given through termination= of
compute_fatigue.
The contact side of the same armour, with slip, fretting regimes and critical-plane indicators, is the subject of Tutorial 4. The column layouts that every reader accepts are on the file formats page.