diff --git a/CHANGELOG.md b/CHANGELOG.md index a076e28..7a4c6b0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -187,6 +187,30 @@ All notable changes to CableXSec are recorded in this file. The format follows ### Fixed +- The slip of the distributed friction model over a full-slip increment (every helix node on its + bound) is now unique. The equations fix the forces, the tractions and `u − p` there, but not a + slide common to the displacement `u` and the slip `p` of all nodes; the solver left one node + exactly on its bound, chosen between candidate nodes at round-off, so the kept slip field + (`DistributedFrictionHistory.kinematic_field`) and the armour slip of + `kinematic_history(..., friction_model="distributed")` (`slip_m`, built from `p`; `slipping`, + from the step slip) could move with any round-off change. On a 32-node helix in full slip a + relative change of 1e-15 in the curvature moved the slip by 12 % of the largest step slip + (uniform bound), and the pitch-mean slip jumped by up to 2.7 % of the step slip from one + full-slip step to the next. The increment now takes the slide that gives the step slip a zero + pitch mean, or the admissible slide nearest to it (every node keeps slipping in the direction + of its traction): a uniform curvature puts no net axial force on a wire over a pitch and slides + no wire as a whole, the convention of the pointwise laws in `kinematic_history`, which keep the + pitch mean of the slip over a step in which no station sticks. Partial slip is unchanged (the + stick nodes fix the slide). Measured on the 66 kV template with `kinematic_history` + (`friction_model="distributed"`, planar and rotating bending at 0.01 and 0.05 1/m, 121 and 601 + samples, 0–100 % of the samples in full slip): the armour slip changes by at most 4.9 µm, 0.3 % + of the station slip amplitudes of 0.3–2.0 mm; no `slipping` flag changes; the pitch-mean slip + no longer moves over full-slip steps in planar bending (it moved by up to 0.024 µm per step); + wire stresses and friction work change by at most 1.7e-15 relative (round-off). The Menard + 2023 cable does not reach full slip in these histories and is unchanged. No validation row + and no documentation example output changes (the examples use the direction-tied law). Tests: + tests/test_distributed_slide.py. + - Provenance of the default armour coefficient `mu_on_hdpe = 0.20` (and `mu_on_steel = 0.20` of `steel_saevik2011`); the values are unchanged. The source is Dai, Sævik and Ye, Marine Structures 55 (2017) 137–161, Sec. 4.3.1, p. 156 (cited as Sec. 4.3 before): an estimate diff --git a/release/check_coverage.py b/release/check_coverage.py index ebbc559..18e9f44 100644 --- a/release/check_coverage.py +++ b/release/check_coverage.py @@ -34,6 +34,7 @@ "tests/test_friction_kernels.py", "tests/test_friction_law.py", "tests/test_friction_pressure.py", + "tests/test_distributed_slide.py", ) diff --git a/src/cablexsec/analysis/kinematics.py b/src/cablexsec/analysis/kinematics.py index 852a500..7a86ea2 100644 --- a/src/cablexsec/analysis/kinematics.py +++ b/src/cablexsec/analysis/kinematics.py @@ -62,7 +62,11 @@ The distributed law solves the displacement ``u`` and the slip ``p`` along the helix itself (:mod:`cablexsec.mechanics.distributed_friction`); its nodal slip ``p`` (the Coulomb part of ``u``) is taken as it is, in metres -(``parameters["length_unit_m"]``), with no reconstruction. +(``parameters["length_unit_m"]``), with no reconstruction. Over an increment +in which every node slips, the law itself keeps the pitch mean of the slip +(or comes as near to it as the slip directions allow), as above for the +pointwise laws when no station sticks: its equations leave that slide free +(module notes of the law). A station is slipping at a sample when its slip changed over the step to that sample (the plastic drive, or the distributed nodal slip). diff --git a/src/cablexsec/mechanics/distributed_friction.py b/src/cablexsec/mechanics/distributed_friction.py index 90e0ff4..ce023fa 100644 --- a/src/cablexsec/mechanics/distributed_friction.py +++ b/src/cablexsec/mechanics/distributed_friction.py @@ -63,6 +63,23 @@ interpolation of curvature and pressure; an increment that fails to converge is repeated with twice as many substeps. +Full slip: when every node of an increment is on its bound, the equations fix +the forces, the tractions and ``u - p``, but not a slide ``c`` common to the +displacement and the slip of every node. Any ``c`` that keeps each node +slipping in the direction of its traction is in equilibrium and does the same +friction work (the tractions sum to zero over the pitch, so ``sum h t c = 0``); +the solver alone would leave one node exactly on its bound, a choice made at +round-off between candidate nodes. The increment takes the slide that gives +the step slip a zero pitch mean, or the admissible slide nearest to it. A +uniform curvature, which puts no net axial force on the wire over a pitch, +then slides no wire as a whole; this is the convention of the pointwise laws +in :mod:`cablexsec.analysis.kinematics`, where the pitch mean of the slip keeps +its value over a step in which no station sticks. In partial slip the stick +nodes fix the slide and nothing changes. The kept displacement ``u``, slip +``p`` and step slip are then unique. Forces, stresses and energies do not +depend on the slide, except through the healing of a friction law, where a +node counts as slipping when its traction is on the bound. + Energy (normalised per pitch, per wire): with ``U = h sum n^2/2 + h sum t^2/(2 k_hat)``, the identity ``W_be - D - U - R = 0`` holds every increment, ``W_be = sum h n . de``, @@ -126,6 +143,10 @@ _MAX_NEWTON = 60 _MAX_FIXED_POINT = 100 _MAX_HALVINGS = 12 +#: Relative margin within which a node counts as on its bound for the slide +#: of a full-slip increment (:func:`_full_slip_slide`); the node that takes +#: the stick row in full slip sits on its bound to round-off. +_ON_BOUND = 1e-9 # --------------------------------------------------------------------------- # @@ -537,6 +558,65 @@ def _solve_fixed_bound( return -1 +@njit(cache=True) +def _full_slip_slide( + z0: FloatArray, + v: FloatArray, + nseg: FloatArray, + mfac: FloatArray, + rho: float, + gnode: FloatArray, + khat: float, + lam: float, +) -> None: + """Fix the common slide of ``u`` and ``p`` of a full-slip increment. + + With every node on its bound (none sticks clear of it, by the relative + margin ``_ON_BOUND``) the equations fix the segment forces ``nseg`` and + the tractions, but not a slide ``c`` added to the increment ``v`` (and so + to the step slip ``dp``) at every node: any ``c`` that keeps each node + slipping in the direction of its traction is in equilibrium and does the + same friction work, the tractions summing to zero over the pitch. ``v`` + takes the ``c`` that gives the step slip a zero pitch mean, or the + admissible ``c`` nearest to it (module notes). No change when a node + sticks. + """ + n = z0.size + lo = -math.inf + hi = math.inf + mean = 0.0 + for j in range(n): + jm = j - 1 if j > 0 else n - 1 + bj = mfac[j] * (rho * gnode[j] + lam * 0.5 * (nseg[j] + nseg[jm])) + if bj < 0.0: + bj = 0.0 + r = z0[j] + v[j] + kr = khat * r + if abs(kr) < bj * (1.0 - _ON_BOUND): + return # a node sticks: it fixes the slide + t = kr + if t > bj: + t = bj + elif t < -bj: + t = -bj + dp = r - t / khat + mean += dp + if bj > 0.0: + # Slip in the direction of the traction: dp + c >= 0 where t > 0. + if kr > 0.0: + lo = max(lo, -dp) + else: + hi = min(hi, -dp) + # lo <= 0 <= hi (the solved slide is admissible) to round-off. + c = -mean / n + if c < lo: + c = lo + if c > hi: + c = hi + for j in range(n): + v[j] += c + + @njit(cache=True) def _advance( ax: float, @@ -682,6 +762,7 @@ def _advance( changed = True if not changed: break + _full_slip_slide(z0, v, ncur, meff, rho, gnode, khat, lam) w_be = 0.0 diss = 0.0 rem = 0.0 diff --git a/tests/test_distributed_slide.py b/tests/test_distributed_slide.py new file mode 100644 index 0000000..fd3b85c --- /dev/null +++ b/tests/test_distributed_slide.py @@ -0,0 +1,191 @@ +# SPDX-License-Identifier: Apache-2.0 +# Copyright (c) 2026 Jae Hoon Seo, SMI Lab, Inha University +"""The slide of a full-slip increment of the distributed friction model. + +With every helix node on its bound the equations leave a slide common to the +displacement ``u`` and the slip ``p`` of all nodes free; the increment takes +the one that gives the step slip a zero pitch mean, or the admissible one +nearest to it (module notes of :mod:`cablexsec.mechanics.distributed_friction`). +""" + +from __future__ import annotations + +import math + +import numpy as np +import pytest + +import cablexsec as cx +from cablexsec._numba import kernels_compiled +from cablexsec.mechanics import distributed_friction as dfm + +PI = math.pi +NODES = 32 + + +def _run(ax, ay, lam, *, khat=4.4, max_increment=math.inf): + ax = np.ascontiguousarray(ax, dtype=float) + ay = np.ascontiguousarray(ay, dtype=float) + steps = ax.size + kinematics = np.zeros((steps, 4, NODES)) + out = dfm._distributed_kernel( + ax, + ay, + np.ones(steps), + khat, + lam, + np.ones(NODES), + 0.0, + 1.0, + max_increment, + np.zeros(1, dtype=np.int64), + np.zeros(1), + True, + True, + np.arange(steps, dtype=np.int64), + kinematics, + ) + assert out[3][0] == 0 + return out, kinematics + + +def _cycles(steps=200): + s = np.linspace(0.0, 1.0, steps) + ax = 30.0 * np.sin(4 * PI * s) + return ax, 0.5 * ax + + +@pytest.mark.parametrize("lam", [0.0, 0.127], ids=["uniform", "signed"]) +def test_full_slip_step_slip_has_zero_pitch_mean(lam): + (_o, hist, slip, _s, _f), kin = _run(*_cycles(), lam) + full = slip >= 1.0 + assert full.sum() > 50 # the cycles are mostly in full slip + step = kin[:, 2] + scale = np.abs(step).max() + for i in np.flatnonzero(full)[1:]: + mean = step[i].mean() + # Zero mean, or the admissible slide nearest to it: then one node + # does not slip over the step. + assert abs(mean) <= 1e-12 * scale or np.abs(step[i]).min() <= 1e-12 * scale + # Over consecutive full-slip steps the pitch mean of the slip is kept. + both = full[1:] & full[:-1] + mean_p = kin[:, 1].mean(axis=1) + assert np.abs(np.diff(mean_p)[both]).max() <= 1e-12 * np.abs(kin[:, 1]).max() + # The energy identity is unchanged by the slide. + identity = hist[:, 0] - hist[:, 1] - hist[:, 2] - hist[:, 3] + assert np.abs(identity).max() <= 1e-12 * np.abs(hist[:, 0]).max() + + +@pytest.mark.parametrize("lam", [0.0, 0.127], ids=["uniform", "signed"]) +def test_full_slip_slide_keeps_every_node_slipping_with_its_traction(lam): + (_o, _h, slip, _s, force), kin = _run(*_cycles(), lam) + u, p = kin[:, 0], kin[:, 1] + tau = 4.4 * (u - p) # interface traction + step = kin[:, 2] + full = np.flatnonzero(slip >= 1.0) + # Friction work node by node: t dp >= 0 (round-off aside). + work = tau[full] * step[full] + assert work.min() >= -1e-12 * np.abs(work).max() + # The forces do not depend on the slide: n_j - n_{j-1} = h t_j. + h = 2 * PI / NODES + balance = force - np.roll(force, 1, axis=1) - h * tau + assert np.abs(balance).max() <= 1e-10 * np.abs(force).max() + + +@pytest.mark.parametrize("lam", [0.0, 0.127], ids=["uniform", "signed"]) +def test_full_slip_fields_are_unique(lam): + """Before the slide was fixed, a relative change of 1e-15 in the + curvature moved the full-slip slip field by a sizeable fraction of a step + slip (the solver left one node on its bound, chosen at round-off).""" + ax, ay = _cycles() + _, kin = _run(ax, ay, lam) + _, nudged = _run(ax * (1.0 + 1e-15), ay, lam) + assert np.abs(nudged - kin).max() <= 1e-9 * np.abs(kin).max() + + +def test_partial_slip_stick_nodes_do_not_slip(): + # Below full slip the stick nodes fix the slide: their step slip is zero. + # Steady rotation at 1.3 times the rigid-stick onset (xi = 0.248). + a = 1.3 * (1.0 + 0.33) / 0.33 + ramp = np.linspace(0.0, a, 101)[1:] + th = np.linspace(0.0, 4 * PI, 721)[1:] + ax = np.concatenate([ramp, a * np.cos(th)]) + ay = np.concatenate([np.zeros(ramp.size), a * np.sin(th)]) + (_o, _h, slip, _s, force), kin = _run(ax, ay, 0.127, khat=0.33) + assert 0.0 < slip.max() < 1.0 + tau = 0.33 * (kin[:, 0] - kin[:, 1]) + # Node j joins segments j - 1 and j. + bound = 1.0 + 0.127 * 0.5 * (force + np.roll(force, 1, axis=1)) + stick = np.abs(tau) < bound * (1.0 - 1e-6) + assert stick.any() and (~stick).any() + assert np.abs(kin[:, 2][stick]).max() <= 1e-12 * np.abs(kin[:, 2]).max() + + +def _slide(z0, v, nseg, rho=1.0, lam=0.0, khat=2.0): + v = np.array(v, dtype=float) + n = v.size + dfm._full_slip_slide( + np.array(z0, dtype=float), + v, + np.array(nseg, dtype=float), + np.ones(n), + rho, + np.ones(n), + khat, + lam, + ) + return v + + +def test_slide_rule_cases(): + """The rule on four nodes, k_hat = 2, unit bound (r = z0 + v, + ``t = clip(k_hat r, -b, b)``, step slip ``dp = r - t / k_hat``).""" + zero = np.zeros(4) + # Full slip, step slip (0.5, -0.5, 0.25, -0.25), mean 0: no change. + v = _slide([1.0, -1.0, 0.75, -0.75], zero, zero) + np.testing.assert_allclose(v, zero, atol=1e-15) + # Step slip (1, 0, 0.75, -0.25), mean 0.375, admissible slides + # [-0.75, 0]: shifted by -0.375. + v = _slide([1.5, -0.5, 1.25, -0.75], zero, zero) + np.testing.assert_allclose(v, -0.375, atol=1e-15) + # Step slip (0.05, -0.25, 1, 1), mean 0.45, admissible [-0.05, 0.25]: + # the slide stops at -0.05, where the first node stops slipping. + v = _slide([0.55, -0.75, 1.5, 1.5], zero, zero) + np.testing.assert_allclose(v, -0.05, atol=1e-15) + # ... and from the other side. + v = _slide([-0.55, 0.75, -1.5, -1.5], zero, zero) + np.testing.assert_allclose(v, 0.05, atol=1e-15) + # A node that sticks clear of its bound fixes the slide. + v = _slide([0.1, -1.0, 1.5, 1.5], zero, zero) + np.testing.assert_array_equal(v, zero) + # A floored (zero) bound constrains nothing: segment 3 at -6 with + # lam = 0.5 floors the bound of nodes 3 and 0 (1 - 1.5 < 0); step slip + # (0.3, -0.5, 0.5, 0.2), mean 0.125, admissible [-0.5, 0.5]. + v = _slide([0.3, -1.0, 1.0, 0.2], zero, [0.0, 0.0, 0.0, -6.0], lam=0.5) + np.testing.assert_allclose(v, -0.125, atol=1e-15) + + +@pytest.mark.skipif( + not kernels_compiled(), reason="a 556-node helix over 121 samples needs numba" +) +def test_kinematic_history_slip_keeps_its_mean_in_full_slip(): + """The armour slip of :func:`cablexsec.kinematic_history` with the + distributed law: planar bending at about 40 times the slip onset of the + 66 kV template, most samples in full slip.""" + cable = cx.load_cable(cx.iea_task49_66kv_yaml_path(), geometry_override=None) + t = np.linspace(0.0, 30.0, 121) + kx = 0.01 * np.sin(2 * PI * 0.1 * t) + with pytest.warns(cx.MissingClampingStateWarning): + history = cx.kinematic_history( + cable, + kx, + np.zeros_like(t), + time_s=t, + tension_N=1e5, + friction_model="distributed", + ) + for layer in history.layers: + mean = layer.slip_m.mean(axis=0) + amplitude = 0.5 * np.ptp(layer.slip_m, axis=1).max() + # Planar bending, symmetric about the bending plane: no net slide. + assert np.abs(mean).max() <= 1e-9 * amplitude diff --git a/validation/validation_report.md b/validation/validation_report.md index 0c70a6a..6654bae 100644 --- a/validation/validation_report.md +++ b/validation/validation_report.md @@ -67,9 +67,9 @@ Every row is computed from published data or closed-form references in this repo ## Test taxonomy (full gate suite) -- analytical_sanity: `1153 passed, 3210 deselected` -- independent_method: `76 passed, 4287 deselected` -- full_scale: `31 passed, 4332 deselected` +- analytical_sanity: `1153 passed, 3219 deselected` +- independent_method: `76 passed, 4296 deselected` +- full_scale: `31 passed, 4341 deselected` Run `pytest -m ` to reproduce each group.