From 4704ee04e50f1206e7e58efb56ae4c9dfbf3e8d7 Mon Sep 17 00:00:00 2001 From: Jae Hoon Seo Date: Fri, 4 Dec 2026 16:49:00 +0900 Subject: [PATCH] fix(friction): no endless distributed solve at near-zero contact pressure The distributed friction model subdivides every sample step in units of the slip-onset curvature, which is proportional to the reference contact pressure. An unclamped layer at zero tension (the 66 kV template under the solved contact model) returns a pressure of round-off size, about 5e-10 Pa, and a 50-sample biaxial record then needed some 1e17 substeps: compute_fatigue with friction_model="distributed", or "auto" on a non-planar path, never returned. A reference pressure at or below PRESSURE_ROUNDOFF_FRACTION (1e-14) of the wire modulus now counts as zero, as an exact zero already did (no friction, as the direction-tied law). A record that would take more substeps than its budget, MAX_SUBSTEPS_PER_SAMPLE (10 000) per sample and at least MIN_SUBSTEP_BUDGET (1 000 000), is refused with a CableInputError naming the slip-onset curvature, and "auto" (fatigue, wire stress field, neutral axes) keeps the direction-tied law for such a layer with FrictionModelFallbackWarning. distributed_substep_count and distributed_substep_budget give the kernels' count and the budget. Records within their budget give the same results as before, bit for bit. Signed-off-by: Jae Hoon Seo --- CHANGELOG.md | 16 ++ doc/local_analysis_guide.md | 11 +- src/cablexsec/analysis/fatigue.py | 56 +++++- src/cablexsec/analysis/neutral_axis.py | 18 +- .../mechanics/distributed_friction.py | 154 +++++++++++++++- tests/test_distributed_near_zero_pressure.py | 169 ++++++++++++++++++ validation/validation_report.md | 2 +- 7 files changed, 416 insertions(+), 10 deletions(-) create mode 100644 tests/test_distributed_near_zero_pressure.py diff --git a/CHANGELOG.md b/CHANGELOG.md index 089be85..2871a89 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,22 @@ All notable changes to CableXSec are recorded in this file. The format follows ## [Unreleased] +### Fixed + +- The distributed friction model (`friction_model="distributed"`, and `"auto"` on a non-planar + path) no longer runs without end at a contact pressure near zero. It subdivides every sample + step in units of the slip-onset curvature, which is proportional to the reference pressure; + an unclamped layer at zero tension (the 66 kV template, which has no manufacturing clamping, + under the solved contact model) returns a pressure of round-off size (about 5e-10 Pa), and + a 50-sample record would have taken some 1e17 substeps. A reference pressure at or below + `PRESSURE_ROUNDOFF_FRACTION` (1e-14) of the wire modulus now counts as zero (no friction, as + an exact zero and the direction-tied law); a record that would take more substeps than its + budget, `MAX_SUBSTEPS_PER_SAMPLE` (10 000) per sample and at least `MIN_SUBSTEP_BUDGET` + (1 000 000), is refused with a `CableInputError` that names the slip-onset curvature, and + `"auto"` keeps the direction-tied law for such a layer with a `FrictionModelFallbackWarning`. + `distributed_substep_count` and `distributed_substep_budget` return the count and the budget. + Every record within its budget gives the same result as before, bit for bit. + ## [0.2.4] - 2026-12-04 The Python interfaces are versioned but may change before `1.0.0`. The evidence for diff --git a/doc/local_analysis_guide.md b/doc/local_analysis_guide.md index 8df6659..59e5b24 100644 --- a/doc/local_analysis_guide.md +++ b/doc/local_analysis_guide.md @@ -1808,7 +1808,16 @@ cable, `examples/demo_05_fatigue_damage.py`, the long-term examples and the release profile) and 13 to 16 times on the 66 kV template (an hour sampled at 10 Hz at 0.004 1/m: 43.6 s against 3.2 s; the 2000 s record of [template_66kv.md](template_66kv.md): 36 s against 2.2 s). Planar records keep -the direction-tied cost under `"auto"`. +the direction-tied cost under `"auto"`. `κ_on` is proportional to the contact +pressure, so a layer with almost no pressure has almost no slip onset. A +reference pressure at round-off (at most `1e-14` of the wire modulus, as an +unclamped layer at zero tension returns) is zero pressure: no friction, as in +the direction-tied law. A record that would need more substeps than its +budget, 10 000 per sample (`MAX_SUBSTEPS_PER_SAMPLE`) and at least a million +(`MIN_SUBSTEP_BUDGET`), is refused (its wires slide in gross slip over the +record), and `"auto"` keeps the direction-tied law for that layer with a +`FrictionModelFallbackWarning`; `distributed_substep_count` and +`distributed_substep_budget` give the count and the budget of a record. **Rotating curvature.** The direction-tied cap is the friction stress accumulated from the current neutral axis, so it turns with the bending diff --git a/src/cablexsec/analysis/fatigue.py b/src/cablexsec/analysis/fatigue.py index 3d0c64f..9468700 100644 --- a/src/cablexsec/analysis/fatigue.py +++ b/src/cablexsec/analysis/fatigue.py @@ -96,6 +96,8 @@ DEFAULT_MAX_INCREMENT, DEFAULT_NODES_PER_WIRE, FRICTION_MODELS, + distributed_substep_budget, + distributed_substep_count, distributed_wire_friction_stress, ) from cablexsec.mechanics.fast_slip import wire_friction_stress @@ -314,8 +316,21 @@ def _resolve_friction_model( out_of_plane: float, stick_modulus_Pa: FloatArray | None, friction_law: FrictionLaw | None, + kappa_x: FloatArray, + kappa_y: FloatArray, + contact_pressure_Pa: FloatArray | None, + max_increment: float, ) -> tuple[str, str]: - """Friction model of one layer and, for ``"auto"``, why it fell back.""" + """Friction model of one layer and, for ``"auto"``, why it fell back. + + The distributed model is not taken for a record whose curvature steps + are too large against its slip-onset curvature (a contact pressure near + zero): it would take more substeps than + :func:`~cablexsec.mechanics.distributed_friction.distributed_substep_budget` + allows, which + :func:`~cablexsec.mechanics.distributed_friction.distributed_friction_history` + refuses. + """ _check_friction_model(friction_model) if friction_model != "auto": return friction_model, "" @@ -324,6 +339,22 @@ def _resolve_friction_model( usable, reason = _distributed_spec(spec, stick_modulus_Pa, friction_law) if usable is None: return "direction_tied", reason + substeps = distributed_substep_count( + usable, + kappa_x, + kappa_y, + contact_pressure_Pa=contact_pressure_Pa, + max_increment=max_increment, + friction_law=friction_law, + ) + samples = max(int(np.asarray(kappa_x).size), 1) + budget = distributed_substep_budget(samples) + if substeps > budget: + return "direction_tied", ( + "its slip-onset curvature is too small for the curvature steps of the " + f"record (a contact pressure near zero): {substeps:.3g} substeps, " + f"{substeps / samples:.3g} per sample, above the budget {budget:.3g}" + ) return "distributed", "" @@ -981,6 +1012,10 @@ def _wire_stress_parts( else 0.0, stick_modulus_Pa, friction_law, + kappa_x, + kappa_y, + contact_pressure_Pa, + distributed_max_increment, ) if progressive is not None and friction_model != "progressive": raise CableInputError( @@ -1324,6 +1359,10 @@ def wire_stress_field( curvature_path_out_of_plane_ratio(kx, ky), stick_modulus_Pa, friction_law, + kx, + ky, + contact_pressure_Pa, + distributed_max_increment, ) if reason: _warn_auto_fallback(layer.name, reason, stacklevel=2) @@ -2093,8 +2132,19 @@ def compute_fatigue( spec = layer.spec name = layer.name layer_stick = None if stick_modulus_Pa is None else stick_modulus_Pa[name] + layer_pressure = ( + None if contact_pressure_Pa is None else contact_pressure_Pa.get(name) + ) model, reason = _resolve_friction_model( - friction_model, spec, out_of_plane, layer_stick, friction_law + friction_model, + spec, + out_of_plane, + layer_stick, + friction_law, + kx, + ky, + layer_pressure, + distributed_max_increment, ) chosen_model[name] = model if reason: @@ -2112,7 +2162,7 @@ def compute_fatigue( tension_N, EA_full_N, None if thermal_stress_Pa is None else thermal_stress_Pa.get(name), - None if contact_pressure_Pa is None else contact_pressure_Pa.get(name), + layer_pressure, axial_strain=axial_strain, normal_stress_Pa=None if normal_stress_Pa is None diff --git a/src/cablexsec/analysis/neutral_axis.py b/src/cablexsec/analysis/neutral_axis.py index ef54b9a..3c9002f 100644 --- a/src/cablexsec/analysis/neutral_axis.py +++ b/src/cablexsec/analysis/neutral_axis.py @@ -343,6 +343,7 @@ def _layer_models( kx: FloatArray, ky: FloatArray, friction_model: str, + pressures: Mapping[str, FloatArray], ) -> list[str]: """Friction model of every layer; ``"auto"`` resolved as in the fatigue route.""" if friction_model != "auto": @@ -352,11 +353,24 @@ def _layer_models( _warn_auto_fallback, curvature_path_out_of_plane_ratio, ) + from cablexsec.mechanics.distributed_friction import ( # noqa: PLC0415 + DEFAULT_MAX_INCREMENT, + ) ratio = curvature_path_out_of_plane_ratio(kx, ky) models = [] for name, spec in layers: - model, reason = _resolve_friction_model("auto", spec, ratio, None, None) + model, reason = _resolve_friction_model( + "auto", + spec, + ratio, + None, + None, + kx, + ky, + pressures.get(name), + DEFAULT_MAX_INCREMENT, + ) if reason: _warn_auto_fallback(name, reason, 4) models.append(model) @@ -427,7 +441,7 @@ def neutral_axes( if strain.shape != kx.shape or not np.isfinite(strain).all(): raise CableInputError("axial strain must be finite and match the curvature") pressures = dict(contact_pressure_Pa or {}) - models = _layer_models(layers, kx, ky, friction_model) + models = _layer_models(layers, kx, ky, friction_model, pressures) armour = tuple( _layer_axes(name, spec, kx, ky, pressures.get(name), model, share) # type: ignore[arg-type] for (name, spec), model in zip(layers, models, strict=True) diff --git a/src/cablexsec/mechanics/distributed_friction.py b/src/cablexsec/mechanics/distributed_friction.py index 295e52e..14e1e6b 100644 --- a/src/cablexsec/mechanics/distributed_friction.py +++ b/src/cablexsec/mechanics/distributed_friction.py @@ -132,8 +132,13 @@ "DEFAULT_NODES_PER_WIRE", "FRICTION_MODELS", "HAVE_NUMBA", + "MAX_SUBSTEPS_PER_SAMPLE", + "MIN_SUBSTEP_BUDGET", + "PRESSURE_ROUNDOFF_FRACTION", "DistributedFrictionHistory", "distributed_friction_history", + "distributed_substep_budget", + "distributed_substep_count", "distributed_wire_friction_stress", ] @@ -150,6 +155,23 @@ DEFAULT_NODES_PER_WIRE = 4 #: Default largest curvature increment per substep, in units of ``kappa_on``. DEFAULT_MAX_INCREMENT = 0.1 +#: A reference contact pressure at or below this fraction of the wire modulus +#: (2 mPa for steel) is the round-off of a contact solve, not a clamping: an +#: unclamped layer at zero tension returns about 1e-9 Pa. The model treats it +#: as zero pressure (no friction), as it treats an exact zero, instead of +#: scaling the record by a slip-onset curvature of round-off size. +PRESSURE_ROUNDOFF_FRACTION = 1e-14 +#: Substep budget of a record: ``MAX_SUBSTEPS_PER_SAMPLE`` per sample (a record +#: of moderate curvature steps takes about a hundred at the default +#: ``max_increment``), and never less than ``MIN_SUBSTEP_BUDGET`` in all (a +#: few coarse samples, such as a rig-test load path, may take more per +#: sample; a million substeps take about ten seconds per layer). A slip-onset +#: curvature so small against the record's curvature steps that the +#: subdivision would exceed the budget (a contact pressure near zero) is +#: refused: :func:`distributed_friction_history` raises, and +#: ``friction_model="auto"`` keeps the direction-tied law for the layer. +MAX_SUBSTEPS_PER_SAMPLE = 10_000 +MIN_SUBSTEP_BUDGET = 1_000_000 _MAX_NEWTON = 60 _MAX_FIXED_POINT = 100 @@ -2097,6 +2119,118 @@ def _validated_increment(max_increment: float) -> float: return value +def _reference_pressure(spec: HelicalLayerSpec, pressure: FloatArray) -> float: + """Reference clamping ``P_ref`` [Pa]: the layer's, else the largest of the + history; zero when both are at round-off (``PRESSURE_ROUNDOFF_FRACTION`` + of the wire modulus).""" + floor = PRESSURE_ROUNDOFF_FRACTION * float(spec.E_wire_Pa) + p_ref = float(spec.contact_pressure_Pa) + if p_ref <= floor: + p_ref = float(pressure.max()) if pressure.size else 0.0 + return p_ref if p_ref > floor else 0.0 + + +def _onset_scales(spec: HelicalLayerSpec, p_ref: float) -> tuple[float, float]: + """Stress unit ``sigma_0 lam`` [Pa] and slip-onset curvature ``kappa_on`` + [1/m]; ``(0, inf)`` where the bound is zero (no interface stiffness, no + friction coefficient, a lay angle of zero or no reference pressure).""" + xi = float(spec.xi) + alpha = float(spec.lay_angle_rad) + sin_a = abs(math.sin(alpha)) + mu = float(spec.mu) + if xi == 0.0 or mu == 0.0 or sin_a < 1.0e-12 or p_ref <= 0.0: + return 0.0, math.inf + width = 2.0 * math.pi * spec.r_helix_m / int(spec.n_wires) + sigma0 = ( + spec.r_helix_m * p_ref * width * math.cos(alpha) / (spec.A_wire_m2 * sin_a**2) + ) + stress_unit = sigma0 * (mu * sin_a) + if stress_unit == 0.0: + return 0.0, math.inf + return stress_unit, stress_unit / (float(spec.k_f) * spec.r_helix_m) + + +def _substep_count( + kx: FloatArray, + ky: FloatArray, + rho: FloatArray, + kappa_on: float, + xi: float, + increment: float, + solve_repeats: bool, +) -> int: + """Substeps of the kernels' rule: each sample step (the first from zero), + in units of ``kappa_on``, split into ``ceil(step / increment)`` when it + exceeds ``increment``; a sample that repeats the last one (curvature and + pressure ratio ``rho``) takes none unless a friction law is active + (``solve_repeats``). The step is formed as the kernels form it, so the + count is theirs (a lower bound only where an increment fails to converge + and is halved).""" + if not math.isfinite(kappa_on) or xi <= 0.0: + return 0 + kappa_c = xi * kappa_on + with np.errstate(over="ignore", invalid="ignore"): + ax = kx / kappa_c + ay = ky / kappa_c + dx = np.diff(ax, prepend=0.0) + dy = np.diff(ay, prepend=0.0) + step = np.sqrt(dx**2 + dy**2) * xi + split = np.where(step > increment, np.ceil(step / increment), 1.0) + if not solve_repeats: + still = ( + (ax == np.r_[0.0, ax[:-1]]) + & (ay == np.r_[0.0, ay[:-1]]) + & (rho == np.r_[rho[:1], rho[:-1]]) + ) + split = np.where(still, 0.0, split) + total = float(split.sum()) + return int(total) if total < 2.0**62 else 2**62 + + +def distributed_substep_budget(samples: int) -> int: + """Largest substep count the model takes for a record of ``samples``: + ``max(MAX_SUBSTEPS_PER_SAMPLE * samples, MIN_SUBSTEP_BUDGET)``.""" + return max(MAX_SUBSTEPS_PER_SAMPLE * int(samples), MIN_SUBSTEP_BUDGET) + + +def distributed_substep_count( + spec: HelicalLayerSpec, + kappa_x: FloatArray, + kappa_y: FloatArray, + *, + contact_pressure_Pa: FloatArray | None = None, + max_increment: float = DEFAULT_MAX_INCREMENT, + friction_law: FrictionLaw | None = None, +) -> int: + """Substeps that :func:`distributed_friction_history` takes for a record. + + The count of the kernels' subdivision rule (a lower bound: an increment + that fails to converge is halved). Zero where the bound is zero, which + the model returns without solving. A count above + :func:`distributed_substep_budget` is refused by the model. + """ + kx = np.asarray(kappa_x, dtype=np.float64) + ky = np.asarray(kappa_y, dtype=np.float64) + pressure = ( + np.full(kx.size, float(spec.contact_pressure_Pa)) + if contact_pressure_Pa is None + else np.asarray(contact_pressure_Pa, dtype=np.float64) + ) + p_ref = _reference_pressure(spec, pressure) + _unit, kappa_on = _onset_scales(spec, p_ref) + if not math.isfinite(kappa_on): + return 0 + return _substep_count( + kx, + ky, + pressure / p_ref, + kappa_on, + float(spec.xi), + _validated_increment(max_increment), + active_friction_law(friction_law) is not None, + ) + + def distributed_friction_history( spec: HelicalLayerSpec, kappa_x: FloatArray, @@ -2226,9 +2360,8 @@ def distributed_friction_history( alpha = float(spec.lay_angle_rad) sin_a = abs(math.sin(alpha)) mu = float(spec.mu) - p_ref = float(spec.contact_pressure_Pa) - if p_ref <= 0.0: - p_ref = float(pressure.max()) if pressure.size else 0.0 + # Round-off pressures count as zero (PRESSURE_ROUNDOFF_FRACTION). + p_ref = _reference_pressure(spec, pressure) n_w = int(spec.n_wires) width = 2.0 * math.pi * spec.r_helix_m / n_w lam = mu * sin_a @@ -2276,6 +2409,21 @@ def distributed_friction_history( k_f = float(spec.k_f) kappa_on = stress_unit / (k_f * spec.r_helix_m) kappa_c = xi * kappa_on + substeps = _substep_count( + kx, ky, pressure / p_ref, kappa_on, xi, increment, law is not None + ) + budget = distributed_substep_budget(count) + if substeps > budget: + raise CableInputError( + f"the slip-onset curvature {kappa_on:.3g} 1/m (reference contact " + f"pressure {p_ref:.3g} Pa) is too small for the curvature steps of " + f"this record: the distributed model would take {substeps:.3g} " + f"substeps, {substeps / count:.3g} per sample (budget {budget:.3g}: " + f"{MAX_SUBSTEPS_PER_SAMPLE} per sample, at least " + f"{MIN_SUBSTEP_BUDGET:.0e}); the wires slide in gross slip over the " + "record. Use friction_model='direction_tied' (friction_model='auto' " + "keeps it for such a layer)" + ) shape = np.ones(n_w) if spec.shape_g is None else np.asarray(spec.shape_g, float) if shape.shape != (n_w,) or not np.isfinite(shape).all() or np.any(shape < 0): raise CableInputError("shape_g must be finite, nonnegative and one per wire") diff --git a/tests/test_distributed_near_zero_pressure.py b/tests/test_distributed_near_zero_pressure.py new file mode 100644 index 0000000..7aa4412 --- /dev/null +++ b/tests/test_distributed_near_zero_pressure.py @@ -0,0 +1,169 @@ +# SPDX-License-Identifier: Apache-2.0 +# Copyright (c) 2026 Jae Hoon Seo, SMI Lab, Inha University +"""The distributed friction model at a contact pressure near zero. + +The model scales the record by the slip-onset curvature, which is proportional +to the reference contact pressure, and subdivides every sample step in units of +it. An unclamped layer at zero tension returns a contact pressure of round-off +size (about 1e-9 Pa); scaled by it, a record of a few samples would take some +1e17 substeps. A reference pressure at round-off now counts as zero (no +friction, as an exact zero and the direction-tied law), a record that would +take more substeps than its budget (``MAX_SUBSTEPS_PER_SAMPLE`` per sample, at +least ``MIN_SUBSTEP_BUDGET``) is refused, and ``friction_model="auto"`` keeps +the direction-tied law for such a layer. +""" + +from __future__ import annotations + +import math +import time +import warnings +from dataclasses import replace + +import numpy as np +import pytest + +import cablexsec as cx +from cablexsec.analysis.fatigue import compute_fatigue +from cablexsec.cable_adapters import cable_to_fatigue_layers +from cablexsec.exceptions import CableInputError +from cablexsec.mechanics.distributed_friction import ( + MAX_SUBSTEPS_PER_SAMPLE, + MIN_SUBSTEP_BUDGET, + PRESSURE_ROUNDOFF_FRACTION, + distributed_friction_history, + distributed_substep_budget, + distributed_substep_count, +) +from cablexsec.mechanics.papailiou import slip_onset_curvature +from cablexsec.provenance import FrictionModelFallbackWarning + + +@pytest.fixture(scope="module") +def inner(): + cable = cx.load_cable(cx.iea_task49_66kv_yaml_path(), geometry_override=None) + with warnings.catch_warnings(): + warnings.simplefilter("ignore") + return cable_to_fatigue_layers(cable, contact_tension_N=100e3)[0] + + +def _rotation(radius: float, n: int = 48) -> tuple[np.ndarray, np.ndarray]: + th = np.linspace(0.0, 2.0 * math.pi, n) + return radius * np.cos(th), radius * np.sin(th) + + +def _unclamped(layer): + return replace(layer, spec=replace(layer.spec, contact_pressure_Pa=0.0)) + + +@pytest.mark.analytical_sanity +def test_roundoff_pressure_is_zero_pressure(inner): + spec = _unclamped(inner).spec + kx, ky = _rotation(2.0 * slip_onset_curvature(inner.spec)) + floor = PRESSURE_ROUNDOFF_FRACTION * spec.E_wire_Pa + exact = distributed_friction_history( + spec, kx, ky, contact_pressure_Pa=np.zeros(kx.size) + ) + for level in (5.3e-10, floor): + start = time.perf_counter() + roundoff = distributed_friction_history( + spec, kx, ky, contact_pressure_Pa=np.full(kx.size, level) + ) + assert time.perf_counter() - start < 5.0 + assert not np.any(roundoff.stress_Pa) + assert np.array_equal(roundoff.stress_Pa, exact.stress_Pa) + assert roundoff.parameters["reference_pressure_Pa"] == 0.0 + assert roundoff.parameters["substeps"] == 0 + assert ( + distributed_substep_count( + spec, kx, ky, contact_pressure_Pa=np.full(kx.size, level) + ) + == 0 + ) + + +@pytest.mark.analytical_sanity +def test_substep_count_is_the_kernel_count(inner): + on = slip_onset_curvature(inner.spec) + kx, ky = _rotation(3.0 * on, 60) + for increment in (0.1, 0.5, math.inf): + history = distributed_friction_history( + inner.spec, kx, ky, max_increment=increment + ) + assert history.parameters["substeps"] == distributed_substep_count( + inner.spec, kx, ky, max_increment=increment + ) + + +@pytest.mark.analytical_sanity +def test_tiny_pressure_is_refused_not_solved(inner): + spec = _unclamped(inner).spec + kx, ky = _rotation(2.0 * slip_onset_curvature(inner.spec)) + # Real but tiny (above the round-off floor): the slip onset is about 1e-7 + # of the clamped layer's, far below the record's curvature steps. + tiny = np.full(kx.size, 1.0e-7 * inner.spec.contact_pressure_Pa) + count = distributed_substep_count(spec, kx, ky, contact_pressure_Pa=tiny) + assert count > distributed_substep_budget(kx.size) + start = time.perf_counter() + with pytest.raises(CableInputError, match="slip-onset curvature"): + distributed_friction_history(spec, kx, ky, contact_pressure_Pa=tiny) + assert time.perf_counter() - start < 5.0 + + +@pytest.mark.analytical_sanity +def test_a_coarse_record_within_the_budget_floor_is_solved(inner): + """Few samples with large steps (a rig-test load path) may take more than + MAX_SUBSTEPS_PER_SAMPLE per sample; the floor of the budget admits them.""" + on = slip_onset_curvature(inner.spec) + kx = np.array([0.0, 1500.0 * on, -1500.0 * on]) + ky = np.array([0.0, 300.0 * on, 0.0]) + count = distributed_substep_count(inner.spec, kx, ky) + assert MAX_SUBSTEPS_PER_SAMPLE * kx.size < count <= MIN_SUBSTEP_BUDGET + assert distributed_substep_budget(kx.size) == MIN_SUBSTEP_BUDGET + history = distributed_friction_history(inner.spec, kx, ky) + assert history.parameters["substeps"] == count + assert np.isfinite(history.stress_Pa).all() and np.any(history.stress_Pa) + + +@pytest.mark.analytical_sanity +def test_auto_keeps_the_direction_tied_law_at_tiny_pressure(inner): + layer = _unclamped(inner) + kx, ky = _rotation(2.0 * slip_onset_curvature(inner.spec)) + tiny = {layer.name: np.full(kx.size, 1.0e-7 * inner.spec.contact_pressure_Pa)} + with pytest.warns(FrictionModelFallbackWarning, match="slip-onset curvature"): + auto = compute_fatigue( + [layer], kx, ky, contact_pressure_Pa=tiny, friction_model="auto" + ) + explicit = compute_fatigue( + [layer], kx, ky, contact_pressure_Pa=tiny, friction_model="direction_tied" + ) + for name, damage in explicit.D_total_per_wire.items(): + assert np.array_equal(auto.D_total_per_wire[name], damage) + assert "inner_armour: direction_tied" in auto.provenance.method + with pytest.raises(CableInputError, match="slip-onset curvature"): + compute_fatigue( + [layer], kx, ky, contact_pressure_Pa=tiny, friction_model="distributed" + ) + + +@pytest.mark.analytical_sanity +def test_unclamped_cable_at_zero_tension_completes(): + """The case that hung: the 66 kV template (no manufacturing clamping) at + zero tension under the solved contact model, biaxial curvature.""" + cable = cx.load_cable(cx.iea_task49_66kv_yaml_path(), geometry_override=None) + t = np.arange(50, dtype=float) + rng = np.random.default_rng(7) + kx = 0.004 * np.sin(2 * np.pi * t / 10) + 4e-4 * rng.standard_normal(t.size) + ky = 0.002 * np.sin(2 * np.pi * t / 13 + 0.4) + with warnings.catch_warnings(): + warnings.simplefilter("ignore") + start = time.perf_counter() + auto = cx.compute_fatigue( + cable, kx, ky, contact_model="solved", friction_model="auto" + ) + assert time.perf_counter() - start < 60.0 + tied = cx.compute_fatigue( + cable, kx, ky, contact_model="solved", friction_model="direction_tied" + ) + for name, damage in tied.D_total_per_wire.items(): + assert np.allclose(auto.D_total_per_wire[name], damage, rtol=1e-9, atol=0.0) diff --git a/validation/validation_report.md b/validation/validation_report.md index 737957a..0e35ebb 100644 --- a/validation/validation_report.md +++ b/validation/validation_report.md @@ -86,7 +86,7 @@ Every row is computed from published data or closed-form references in this repo ## Test taxonomy (full gate suite) -- analytical_sanity: `1426 passed` +- analytical_sanity: `1432 passed` - independent_method: `105 passed` - full_scale: `63 passed`