diff --git a/CHANGELOG.md b/CHANGELOG.md index 556294d..36dd912 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,24 @@ All notable changes to CableXSec are recorded in this file. The format follows ### Added +- Distributed form of the laid-core law: `core_friction_history(..., + friction_model="distributed" | "auto")` solves the cores and the filler profiles with the + distributed helix model of the armour (the axial force of each core as a field along its + pitch, slip of every helix node in the direction of its own traction, no bending direction); + `"auto"` keeps the direction-tied law on planar paths, as in the fatigue route, and falls back + with `FrictionModelFallbackWarning` on a rigid interface. `compute_neutral_axes` takes + `friction_model="auto"` for the armour and gives the cores the armour's model unless + `core_friction_model` says otherwise; `SectionLaw.from_cable(friction_model="distributed")` + solves the cores with it too. Checks CF-D (targets registered before the run): planar + reduction of `"auto"` 0, lattice rotation 5.7e-15, dissipation and balance, μ = 0 bit for bit, + stick tangent 2.0e-6, compiled kernel 3.4e-16; the full-slip moment misses the continuous + closed form by 1.02e-4 against the registered 1e-4 at the default stations (FAIL, documented: + station quadrature; the model reproduces the station sum to 1e-10). Under non-proportional + curvature the distributed core law takes 1.3 (random walk) to 2.3 (circular orbit) times the + friction work of the direction-tied one on the 66 kV template. +- `core_load_history`: the core and filler-profile contact loads of the contact model over a + tension history (bounded estimate exact, solved model exact up to 33 tensions). + - One exported bending law per friction group, each with its own scale table (`BendingLawExport.slip_group_laws()`, `SlipGroupLaw`, `to_group_csv`), for a global model that sums the group laws `s_g(T) B_g(κ / s_g(T))` instead of carrying one scale. Rows @@ -348,6 +366,14 @@ All notable changes to CableXSec are recorded in this file. The format follows ### Changed +- The laid-core and filler-profile contact loads follow the tension history by default: + `compute_neutral_axes(..., core_loads="follow")` with `tension_N` or `contact_tension_N`, and + `compute_mkappa(..., core_loads="follow")` with `contact_tension_history_N`; before, they were + held at the first sample, which stays available as `core_loads="reference"`. Check CF-T + (registered before the run): a tension cycle of 10–70 kN inside bending cycles now meets the + slip-scaled exported law within 0.49–1.19 times its fixed-tension residual (target 1.25); + with the loads held it missed by up to 20 % of the moment range. + - The default slip-scale table of `export_bending_law(..., slip_scale=True)` starts at zero tension, with the caps of the contact model there (zero without clamping, the clamping caps otherwise; row MX-group-0), so the scale runs to zero instead of ending at the lowest diff --git a/doc/benchmarks.md b/doc/benchmarks.md index a136e9e..0a58614 100644 --- a/doc/benchmarks.md +++ b/doc/benchmarks.md @@ -98,6 +98,7 @@ model) is the full construction. | CIGRE TB880 conductor temperature | MM | PARTIAL | | Global–local consistency, floating-wind application | I | Full-slip results are upper estimates | | Laid-core friction (gap R1b), Ménard and Cartraud (2023) six ranges | M | Stated, not gated (unreliable reference). With the transferred 0.3 MPa the cores raise the work (range (b) +30.2 %); identified on (b) with the full accounting, predictions (a) and (c) outside the registered target (+28.5, +26.2 %), (d)–(f) within 16 % | +| Laid-core law, distributed form and contact loads that follow the tension (CF-D, CF-T) | A, I | PASS except CF-D-slip (1.02e-4 against 1e-4 at the default stations: station quadrature, documented) | | Zeidan (2025) four-point loops, 112 mm three-core cable (Z-EI, Z-ID) | M | Diagnosed on for the shear-stack rule, not independent. Z-EI PASS: measured stick secant 141–240 kN·m² below the no-slip EI_max of 311.1 kN·m² (armour ξ 0.832/1.000; 12.0 kN·m² and ξ 0.009/0.016 before the series stack stopped counting the 8.75 mm EPR of the cores). Z-ID FAIL: P0 759.8 kPa identified on the 40 mm work; predicted work +10.4 to −9.6 %, but branch RMSE 13.7–15.4 % and moment range −33 to −46 % (slip slope near EI_min). Measured curvature axis is the loading-point formula applied to the mid-span deflection (+26 to +29 % on the central curvature of the source's Fig. 18) | | Fretting regime and wear (gap 3.1): Mindlin/Cattaneo closed forms, Fouvry ratios, limits, rotation | A | PASS | | Fretting transition, Fouvry et al. (1995) Table 4 | MM | PASS with the printed shear moduli; 1.6–1.7 × the measurements with G = E/2(1 + ν) (stated) | @@ -377,7 +378,9 @@ transfer rows move with the stiffer stick (before: armour only 2.71 %, 3.88 % and +18.9 %); CF, CFW and MK-Tcyc read FAIL because the stage also switches their armour-only references; MX-scale's tension-cycle check on the Ménard cable reads 2.36 against at most 1.25 (the Ménard core group - then joins the scaled law). No other row moves. The stage stays off by + then joins the scaled law). That run held the core contact loads at the + first sample of the tension history; they now follow it by default + (CF-T-cycle), and the stage has not been rerun. No other row moves. The stage stays off by default. - **Su et al. (2026).** No bending loop is published for the 35 kV cable (axial and torsional results only); not compared. @@ -475,6 +478,49 @@ figures (about ±5 % of full scale): The IEA Wind Task 49 slipping stiffness (Table 13), whose row cites the same source, is likewise reported code to code. +### Distributed laid-core law and tension-following core loads (CF-D, CF-T) + +Registered on 2026-11-19, before any run, in the first commit of the change that adds them. Code +`core_friction_history(..., friction_model=...)` and `core_load_history` +(`cablexsec/mechanics/core_friction.py`), `compute_neutral_axes(..., core_friction_model=..., +core_loads=...)` and `compute_mkappa(..., core_loads=...)`; tests `tests/test_core_friction_distributed.py`. +Case unless stated: the 66 kV IEA Task 49 template, bounded contact, laid cores with the wedged trefoil and the +filler profiles, μ 0.46 on every core and profile contact, 50 kN, default stations and helix nodes. Scale: the +largest core moment magnitude of the history. + +The distributed form solves each helical population of the core law (the cores and the filler profiles) with +the distributed helix model of the armour (`friction_model="distributed"`), its contact pressure and stick +coefficient taken from the core law; `"auto"` keeps the direction-tied law on planar paths and uses the +distributed one otherwise, as for the armour. + +| ID | Check | Target (registered) | Result | Status | +| --- | --- | --- | --- | --- | +| CF-D-planar | `friction_model="auto"` on planar loop histories (two plane azimuths) against the direction-tied core law; `compute_neutral_axes(friction_model="auto")` against `"direction_tied"` on the same path | moment and work ≤ 1e-12 of scale | 0 | PASS | +| CF-D-rot | Biaxial random walk rotated by 7 station pitches (2π·7/n, a multiple of the helix node spacing) and by 0.3 rad: rotated moment and friction work | ≤ 1e-9 of scale (lattice rotation); ≤ 1e-3 of scale (0.3 rad) | 5.7e-15 (work 1.1e-15); 2.2e-4 (work 1.7e-6) | PASS | +| CF-D-diss | Biaxial random walk and a circular orbit: friction work non-decreasing, energy balance residual | increments ≥ −1e-12 of the final work; residual ≤ 1e-9 of it | smallest increment −9.5e-20; residual 4.4e-15. Work 1.29 (walk) and 2.33 (orbit) times the direction-tied core law | PASS | +| CF-D-mu0 | μ = 0 on every core and profile contact: section moment of `compute_neutral_axes(friction_model="distributed")` against the armour-only section | 0 N·m (bit for bit) | 0 | PASS | +| CF-D-stick | μ = 1e3 on every core and profile contact, amplitude 1e-6 1/m: core-law tangent against its stick stiffness `xi (1/2) EA r_c² cos³β` (cores plus profiles) | ≤ 1e-5 rel. (discrete shear-lag factor `(h²/12)(1 − ξ)`, 6e-6 at the default nodes) | 2.0e-6 | PASS | +| CF-D-slip | Planar monotonic loading to full slip: moment of the core population and of the profile population against `(2/π) n q r² cos²β/sin²β · λ C cosh(λπ/2)/(1 + λ²)`, `C = λπ/(2 sinh(λπ/2))`, `λ = μ sin β` (the closed form of the armour distributed model with the core loads) | ≤ 1e-4 rel. | 1.02e-4 (cores), 1.03e-4 (profiles) at the default 60 stations per core | FAIL (documented below) | +| CF-D-numba | Compiled against reference kernel of the distributed core law (biaxial history with a contact-pressure history) | moments and energies ≤ 1e-10 of scale | 3.4e-16; 2.9e-16 | PASS | +| CF-T-const | Constant tension history equal to the reference: `core_loads="follow"` against `"reference"` (direction-tied and distributed) | ≤ 1e-12 of scale | 0 (both laws) | PASS | +| CF-T-level | Constant tension history at 120 kN on a model built at 50 kN, loads following, against the law built at 120 kN; 0 and 20 MPa armour winding stress | direction-tied ≤ 1e-12 of scale; distributed ≤ 2e-3 of scale (its substeps are set by the onset at the reference) | direction-tied 0 and 2.4e-16; distributed 1.7e-4 and 6.7e-5 (0 and 20 MPa) | PASS | +| CF-T-cycle | Tension cycle 10–70 kN inside bending cycles (amplitudes 3e-4 and 3e-3 1/m), 0 and 20 MPa winding stress: slip-scaled exported law (per group) against `compute_mkappa(contact_tension_history_N=..., core_loads="follow")` | deviation ≤ 1.25 times the fixed-tension residual of the same law at 10 and 70 kN, and < 5e-3 of the range (the MX-scale targets); `core_loads="reference"` reported | deviation 9.8e-4, 1.9e-3 (0 MPa; 0.49 and 1.05 times the residual), 7.9e-4, 1.9e-3 (20 MPa; 0.82 and 1.19 times). Loads held at the first sample: 4.1e-2, 0.198, 7.9e-4, 0.118 of the range | PASS | + +**CF-D-slip, the failed target.** The registered 1e-4 compared the model with the continuous integral of +the closed-form field. The model reproduces the sum of that field over its stations to 1e-10 (cores 9e-11, +profiles 5e-10): the field is exact, and the residual is the station quadrature of a field whose slope changes +sign at the extreme fibres, second order in the station spacing (120 stations per core: 2.6e-5). The default +station count of the core law (60 per core) is unchanged; the test pins the documented deviation and the +second-order convergence (`test_cf_d_full_slip_moment_matches_the_closed_form`). The same quadrature is why the +direction-tied CF row carries 5e-3. + +**What the checks show.** Under non-proportional curvature the distributed core law takes 1.29 times +(random walk) and 2.33 times (circular orbit) the friction work of the direction-tied core law on the same +path, the rotation deficit of the direction-tied cap that the armour shows too. With the core loads held at the +first sample of a tension cycle the section misses the slip-scaled law by up to 20 % of the moment range +(0 MPa, 3e-3 1/m); with the loads following the tension the miss is the law's own fixed-tension residual +(CF-T-cycle). + ### Default of the laid-core law The law stays off by default. The Ménard test is no longer a gate (its diff --git a/doc/local_analysis_guide.md b/doc/local_analysis_guide.md index a64de0d..6793266 100644 --- a/doc/local_analysis_guide.md +++ b/doc/local_analysis_guide.md @@ -948,6 +948,27 @@ print(core.loads, core.xi, core.mu_effective, core.stick_EI_Nm2) cores use the same direction-tied Papailiou cap and return map as the armour wires, so biaxial histories work (`cablexsec.mechanics.core_friction.core_friction_history`). +- Friction model of the cores and profiles, as for the armour: + `core_friction_history(..., friction_model="distributed")` solves each + population with the distributed helix model of the armour (the axial force + of a core as a field along its pitch, with the shear-lag interface of `ξ` + and the slip of every helix node in the direction of its own traction, no + bending direction), and `"auto"` keeps the direction-tied law on planar + paths. Under rotating curvature the direction-tied cap turns with the + bending direction and takes too little friction work (66 kV template, cores + and profiles at μ 0.46: the distributed law takes 1.3 times the work on a + random walk and 2.3 times on a circular orbit). `compute_neutral_axes` + gives the cores the armour's `friction_model` (or `core_friction_model`). + The distributed form needs a compliant interface (`ξ < 1`, the default with + the core insulation shear). +- Over a tension history the core and profile contact loads follow the + tension by default (`core_loads="follow"` of `compute_neutral_axes` and of + `compute_mkappa` with `contact_tension_history_N`; the loads per sample from + `core_load_history`), as the armour contact pressure does; `"reference"` + holds them at the first sample. With the loads held, the section missed the + slip-scaled exported law by up to 20 % of the moment range under a 10–70 kN + tension cycle; with them following, by the law's own fixed-tension residual + (rows CF-D and CF-T of the [benchmark register](benchmarks.md)). - Normal loads: the solved trefoil contact forces (`contact_model="solved"`) or a bounded estimate. In the estimate each core carries its capstan load `C` and one third of the line force `R` inside the innermost armour (winding @@ -955,7 +976,7 @@ print(core.loads, core.xi, core.mu_effective, core.stick_EI_Nm2) reacted by the two neighbouring cores of a touching trefoil, whose contact forces sum to `(C + R/3)/sin 60°` (default), or radially by a central filler (`CoreFrictionSpec(central_filler=True)`). The solved model reads the - core support of the solved radial state. The loads are held fixed during + core support of the solved radial state. The loads are not changed by bending. - Filler profiles (`CoreFrictionSpec(filler_profiles=True)`, `mu_filler_profile`): the non-structural interstitial filler annulus (a diff --git a/doc/user_guide.md b/doc/user_guide.md index 22c1ed6..4a89b93 100644 --- a/doc/user_guide.md +++ b/doc/user_guide.md @@ -114,7 +114,8 @@ for screening. wire screen along the {term}`core lay`, and the strain-life of tapes. - **{term}`Neutral axis ` under a load history** (`cx.compute_neutral_axes`): where the armour sticks and slips as the {term}`bending direction` turns, and the biaxial section moment - of the history (armour, optionally with the laid-core law: `core_friction`). + of the history (armour, optionally with the laid-core law: `core_friction`, its friction model + `core_friction_model`, its contact loads following the tension history by default: `core_loads`). ### 2.6 Thermal and electrical diff --git a/src/cablexsec/analysis/beam_test.py b/src/cablexsec/analysis/beam_test.py index 2b9c4a6..22d3dda 100644 --- a/src/cablexsec/analysis/beam_test.py +++ b/src/cablexsec/analysis/beam_test.py @@ -245,9 +245,13 @@ def from_cable( stress by the distributed helix model of :mod:`cablexsec.mechanics.distributed_friction` (the fatigue-path option) and assembles the moment from the wire stresses in the same - way; it substeps internally (``distributed_max_increment``, in units - of the slip-onset curvature, :data:`SECTION_LAW_MAX_INCREMENT` by - default), so its leg property holds to the substep accuracy. + way, and solves the laid cores and filler profiles of + ``core_friction`` with the same model + (:func:`~cablexsec.mechanics.core_friction.core_friction_history`, + ``friction_model="distributed"``); it substeps internally + (``distributed_max_increment``, in units of the slip-onset curvature, + :data:`SECTION_LAW_MAX_INCREMENT` by default), so its leg property + holds to the substep accuracy. The contact pressure is that of the one contact state given here. The pressure and tension histories of @@ -351,7 +355,12 @@ def _distributed(kappa: FloatArray) -> SectionResponse: stored = stored + hist.stored_J_per_m if law.core_model is not None: core = core_friction_history( - law.core_model, kx, ky, initial_bending_angle=phi_bend + law.core_model, + kx, + ky, + friction_model="distributed", + nodes_per_pitch=distributed_nodes_per_pitch, + max_increment=distributed_max_increment, ) moment = moment + core.moment_Nm @ np.array([cos_b, sin_b]) friction = friction + core.work.friction_J_per_m diff --git a/src/cablexsec/analysis/neutral_axis.py b/src/cablexsec/analysis/neutral_axis.py index 4620f01..c056b88 100644 --- a/src/cablexsec/analysis/neutral_axis.py +++ b/src/cablexsec/analysis/neutral_axis.py @@ -63,7 +63,12 @@ assumption. A rate-anchored law ([Dong2015]: friction integrated from the point of zero bending-strain rate) or the distributed law (stick zones along the helix) can give another axis; ``friction_model`` selects the laws of the -fatigue route, and the stick zone is given for the direction-tied law only. +fatigue route (``"auto"``: the direction-tied law on a planar path, the +distributed law on every other path where it applies, as in +:func:`cablexsec.compute_fatigue`), and the stick zone is given for the +direction-tied law only. The laid-core law of ``compute_neutral_axes(..., +core_friction=...)`` takes the same model unless ``core_friction_model`` says +otherwise (:func:`~cablexsec.mechanics.core_friction.core_friction_history`). """ from __future__ import annotations @@ -81,7 +86,11 @@ if TYPE_CHECKING: from cablexsec.cables.schema import CableData - from cablexsec.mechanics.core_friction import CoreFrictionSpec + from cablexsec.mechanics.core_friction import ( + CoreFrictionModelName, + CoreFrictionSpec, + CoreLoadMode, + ) from cablexsec.mechanics.mkappa import HelicalLayerSpec __all__ = [ @@ -95,7 +104,7 @@ FloatArray = NDArray[np.float64] BoolArray = NDArray[np.bool_] -FrictionLaw = Literal["direction_tied", "distributed", "progressive"] +FrictionLaw = Literal["direction_tied", "distributed", "progressive", "auto"] DIRECTION_SHARE = 0.01 """Default share of the largest value below which a direction is not given.""" @@ -308,7 +317,8 @@ def _layer_axes( ) else: raise CableInputError( - "friction_model must be 'direction_tied', 'distributed' or 'progressive'" + "friction_model must be 'direction_tied', 'distributed', 'progressive' " + "or 'auto'" ) stress = np.asarray(stress, dtype=np.float64) resultant = np.asarray((2.0 / spec.n_wires) * (stress.T @ directions)) @@ -327,6 +337,31 @@ def _layer_axes( ) +def _layer_models( + layers: Sequence[tuple[str, HelicalLayerSpec]], + kx: FloatArray, + ky: FloatArray, + friction_model: str, +) -> list[str]: + """Friction model of every layer; ``"auto"`` resolved as in the fatigue route.""" + if friction_model != "auto": + return [friction_model] * len(layers) + from cablexsec.analysis.fatigue import ( # noqa: PLC0415 + _resolve_friction_model, + _warn_auto_fallback, + curvature_path_out_of_plane_ratio, + ) + + 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) + if reason: + _warn_auto_fallback(name, reason, 4) + models.append(model) + return models + + def neutral_axes( layers: Sequence[tuple[str, HelicalLayerSpec]], kappa_x: FloatArray, @@ -340,16 +375,22 @@ def neutral_axes( direction_share: float = DIRECTION_SHARE, core_moment_Nm: FloatArray | None = None, core_stick_EI_Nm2: float = 0.0, + core_description: str | None = None, ) -> NeutralAxisResult: """Neutral axes of a section of armour ``layers`` (name, spec) over a history. ``kappa_x``, ``kappa_y`` are the axial-strain gradient [1/m]; ``axial_strain`` the strain of the cable axis (zero when ``None``); ``contact_pressure_Pa`` the ``P1+P2`` history of each layer by name (the - layer's own clamping when absent). ``core_moment_Nm`` (samples, 2) is the + layer's own clamping when absent). ``friction_model`` ``"auto"`` takes + the direction-tied law on a planar path and the distributed law on every + layer it applies to otherwise (a rigid interface keeps the direction-tied + law and warns, :class:`~cablexsec.provenance.FrictionModelFallbackWarning`); + each layer reports its model. ``core_moment_Nm`` (samples, 2) is the moment of a laid-core law over the same history, added to the section - moment, and ``core_stick_EI_Nm2`` its stick stiffness, added to - ``ei_max_Nm2``. See the module text for the quantities. + moment, ``core_stick_EI_Nm2`` its stick stiffness, added to + ``ei_max_Nm2``, and ``core_description`` names its friction model and + loads in the provenance. See the module text for the quantities. """ kx = np.asarray(kappa_x, dtype=np.float64) ky = np.asarray(kappa_y, dtype=np.float64) @@ -385,9 +426,10 @@ 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) armour = tuple( - _layer_axes(name, spec, kx, ky, pressures.get(name), friction_model, share) - for name, spec in layers + _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) ) curvature = np.column_stack((kx, ky)) theta, threshold = _direction(curvature, share) @@ -410,12 +452,13 @@ def neutral_axes( "core friction of laid power cores is not included" if core is None else "it adds the laid-core law over the same history" + + ("" if not core_description else f" ({core_description})") ), "the stress neutral axis is the diameter of the first circular harmonic; " "after a reversal the stress can change sign more than twice round a " "layer", ] - if friction_model != "direction_tied": + if any(model != "direction_tied" for model in models): limitations.append("the stick zone is given for the direction-tied law only") else: limitations.append( @@ -443,7 +486,7 @@ def neutral_axes( method=( "neutral axes of the section: bending direction, strain neutral " "axis, stress neutral axis of each armour layer (first circular " - f"harmonic of the {friction_model.replace('_', '-')} wire bending " + f"harmonic of the {_models_text(friction_model, models)} wire bending " "stress), moment direction and stick zone" ), citations=CITATIONS, @@ -453,6 +496,14 @@ def neutral_axes( ) +def _models_text(friction_model: str, models: Sequence[str]) -> str: + """The armour friction model of the provenance (``"auto"`` resolved).""" + if friction_model != "auto": + return friction_model.replace("_", "-") + chosen = sorted({model.replace("_", "-") for model in models}) + return f"{' and '.join(chosen) or 'direction-tied'} (auto)" + + def section_radius(cable: CableData) -> float: """Outer radius of the cable's layers [m].""" from cablexsec.cables.schema import HelicalLayer # noqa: PLC0415 @@ -486,6 +537,8 @@ def compute_neutral_axes( direction_share: float = DIRECTION_SHARE, section_radius_m: float | None = None, core_friction: bool | CoreFrictionSpec | None = None, + core_friction_model: CoreFrictionModelName | None = None, + core_loads: CoreLoadMode = "follow", ) -> NeutralAxisResult: """Neutral axes of ``cable`` over a curvature history (module text). @@ -507,13 +560,24 @@ def compute_neutral_axes( filler profiles to the section moment, as ``core_friction`` of :func:`cablexsec.compute_mkappa` does: the biaxial history of :func:`~cablexsec.mechanics.core_friction.core_friction_history` with the - contact loads of the bounded contact model at the reference tension (the - first sample of the tension history, zero without one). As in - :func:`cablexsec.compute_mkappa`, the core contact loads stay at that - reference while the armour contact pressure follows the history. A planar - history at a constant tension then gives, along its plane, the moment of + contact loads of the bounded contact model. ``core_friction_model`` + selects the friction model of the cores and profiles (``"direction_tied"``, + ``"distributed"`` or ``"auto"``, module notes of + :mod:`cablexsec.mechanics.core_friction`); ``None`` (default) takes + ``friction_model`` (the direction-tied law with the progressive armour + law, which the cores do not have). ``core_loads`` sets the core and + profile contact loads: ``"follow"`` (default) evaluates them at every + sample of the tension history that sets the armour contact pressure + (``contact_tension_N``, else ``tension_N``; + :func:`~cablexsec.mechanics.core_friction.core_load_history`), as the + armour pressure does, so that the section agrees with a law whose sliders + all scale with the tension; ``"reference"`` holds them at the first + sample of that history (the earlier behaviour, as in + :func:`cablexsec.compute_mkappa` at one tension). Without a tension + history both hold the loads at zero tension. A planar history at a + constant tension gives, along its plane, the moment of :func:`cablexsec.compute_mkappa` with the same options (direction-tied - armour law). ``None`` (default) keeps the armour-only moment bit for bit. + law). ``None`` (default) keeps the armour-only moment bit for bit. """ from cablexsec.api import armour_contact_histories # noqa: PLC0415 from cablexsec.cable_adapters import ( # noqa: PLC0415 @@ -521,17 +585,32 @@ def compute_neutral_axes( structural_armour_layers, ) from cablexsec.mechanics.core_friction import ( # noqa: PLC0415 + CORE_FRICTION_MODELS, + CORE_LOAD_MODES, build_core_friction, core_friction_history, + core_load_history, resolve_core_friction, ) from cablexsec.mechanics.stiffness import ea_fixed, ei_min_slip # noqa: PLC0415 if tension_N is not None and axial_strain is not None: raise CableInputError("give tension or axial strain, not both") + if core_loads not in CORE_LOAD_MODES: + raise CableInputError( + f"core_loads must be one of {CORE_LOAD_MODES}, got {core_loads!r}" + ) + if core_friction_model is not None and core_friction_model not in ( + CORE_FRICTION_MODELS + ): + raise CableInputError( + f"core_friction_model must be one of {CORE_FRICTION_MODELS} or None, " + f"got {core_friction_model!r}" + ) kx = np.asarray(kappa_x, dtype=np.float64) strain: FloatArray | None = None pressure: dict[str, FloatArray] | None = None + load_tension: FloatArray | None = None reference = 0.0 if tension_N is not None: tension = np.asarray(tension_N, dtype=np.float64) @@ -542,6 +621,7 @@ def compute_neutral_axes( reference = float(tension[0]) strain = tension / ea_fixed(cable) pressure = armour_contact_histories(cable, tension)[0] + load_tension = tension elif axial_strain is not None: strain = np.asarray(axial_strain, dtype=np.float64) if contact_tension_N is not None: @@ -554,21 +634,51 @@ def compute_neutral_axes( raise CableInputError("the contact tension must not be negative") reference = float(contact[0]) pressure = armour_contact_histories(cable, contact)[0] + load_tension = contact specs = cable_to_mkappa_specs(cable, reference, mu=mu, contact_model="bounded") names = [layer.name for layer in structural_armour_layers(cable)] if not specs: raise CableInputError("the cable has no structural armour layer") core_spec = resolve_core_friction(core_friction) + if core_spec is None and core_friction_model is not None: + raise CableInputError("core_friction_model needs core_friction") core_moment: FloatArray | None = None core_stick = 0.0 + core_description: str | None = None if core_spec is not None: model = build_core_friction( cable, core_spec, reference, contact_model="bounded" ) - core_moment = core_friction_history( - model, kx, np.asarray(kappa_y, dtype=np.float64) - ).moment_Nm + loads = ( + core_load_history(cable, model, load_tension, contact_model="bounded") + if core_loads == "follow" and load_tension is not None + else None + ) + if core_friction_model is not None: + core_model: str = core_friction_model + elif friction_model in CORE_FRICTION_MODELS: + core_model = friction_model + else: + core_model = "direction_tied" + history = core_friction_history( + model, + kx, + np.asarray(kappa_y, dtype=np.float64), + friction_model=core_model, # type: ignore[arg-type] + loads=loads, + ) + core_moment = history.moment_Nm core_stick = model.stick_EI_Nm2 + core_description = ( + f"{history.friction_model.replace('_', '-')} core law" + + (", " + core_model if core_model == "auto" else "") + + ", core contact loads " + + ( + "following the tension history" + if loads is not None + else f"at the reference tension {reference:g} N" + ) + ) return neutral_axes( list(zip(names, specs, strict=True)), kx, @@ -583,4 +693,5 @@ def compute_neutral_axes( direction_share=direction_share, core_moment_Nm=core_moment, core_stick_EI_Nm2=core_stick, + core_description=core_description, ) diff --git a/src/cablexsec/api.py b/src/cablexsec/api.py index b8d9cc7..dbc8454 100644 --- a/src/cablexsec/api.py +++ b/src/cablexsec/api.py @@ -169,11 +169,15 @@ ) from cablexsec.mechanics.contact_qp import ContactQPResult, solve_contact_qp from cablexsec.mechanics.core_friction import ( + CORE_LOAD_MODES, CoreFrictionHistory, CoreFrictionModel, CoreFrictionSpec, + CoreLoadHistory, + CoreLoadMode, build_core_friction, core_friction_history, + core_load_history, resolve_core_friction, ) from cablexsec.mechanics.core_kinematics import CoreSlipState @@ -550,10 +554,12 @@ def run( contact_pressure_Pa: Sequence[FloatArray] | None = None, friction_law: FrictionLaw | None = None, time_s: FloatArray | None = None, + core_loads: CoreLoadHistory | None = None, ) -> _MkappaRun: """Evaluate the law; ``contact_pressure_Pa`` is one armour ``P1+P2`` history per layer (order of ``layers``), ``None`` for fixed pressure. - The laid-core model keeps its own fixed contact loads. A non-neutral + The laid-core model keeps its own fixed contact loads unless + ``core_loads`` gives their history. A non-neutral ``friction_law`` (armour wires, direction-tied law) is refused with the progressive law and the laid-core model.""" phi_bend = self.phi_bend @@ -595,6 +601,7 @@ def run( kappa * direction[0], kappa * direction[1], initial_bending_angle=phi_bend, + loads=core_loads, ) moment = res.moment_Nm + core_history.moment_Nm @ direction aw, cw = res.work, core_history.work @@ -677,6 +684,7 @@ def compute_mkappa( contact_tension_history_N: FloatArray | None = None, friction_law: FrictionLaw | None = None, time_s: FloatArray | None = None, + core_loads: CoreLoadMode = "follow", ) -> MkappaResult: r"""Moment-curvature hysteresis of a cable over a curvature history. @@ -697,12 +705,13 @@ def compute_mkappa( sets the friction bound of every wire at every sample, in the same return map as the fatigue path: the slip state is carried across the change, a falling bound clips a wire's friction stress (friction work), - and a rising bound leaves a sticking wire unchanged. What follows the - history is the armour friction bound only. The stick stiffness, - ``EI_min``, ``EI_max``, the laid-core and internal-ring contact loads - (``core_friction``) and the wire-yield range check stay at the reference - state (``tension_N``, ``section_state`` or ``radial_state``; the first - sample of a tension history). + and a rising bound leaves a sticking wire unchanged. With + ``contact_tension_history_N`` the laid-core and filler-profile contact + loads (``core_friction``) follow the same history by default + (``core_loads``). The stick stiffness, ``EI_min``, ``EI_max``, the + pressure-held part of the internal rings and the wire-yield range check + stay at the reference state (``tension_N``, ``section_state`` or + ``radial_state``; the first sample of a tension history). Parameters ---------- @@ -797,6 +806,15 @@ def compute_mkappa( Sample times [s] of ``kappa_history``, required by a law that depends on time (a slip rate or a finite positive healing time); refused otherwise. + core_loads : {"follow", "reference"}, optional + Contact loads of the laid cores and filler profiles under a + ``contact_tension_history_N``. ``"follow"`` (default) evaluates them + at every sample through the same contact model + (:func:`~cablexsec.mechanics.core_friction.core_load_history`), so + that every friction bound of the section follows the tension, as the + slip scale of an exported law assumes; ``"reference"`` holds them at + the first sample (the earlier behaviour). Without a tension history + the loads are those of the reference state either way. Returns ------- @@ -833,6 +851,10 @@ def compute_mkappa( require_finite(phi_bend, "phi_bend") if tension_N < 0.0: raise CableSchemaError("tension_N must be >= 0 for the contact model.") + if core_loads not in CORE_LOAD_MODES: + raise CableSchemaError( + f"core_loads must be one of {CORE_LOAD_MODES}, got {core_loads!r}" + ) if mu is not None: require_finite(mu, "mu") if mu < 0.0: @@ -976,6 +998,18 @@ def compute_mkappa( except (ValueError, KeyError): pass # no yield-strength armour: no curvature bound to check + core_load_states = ( + core_load_history( + cable, + mkappa_law.core_model, + tension_history, + contact_model=contact_model, + ) + if mkappa_law.core_model is not None + and tension_history is not None + and core_loads == "follow" + else None + ) run = mkappa_law.run( kappa, None @@ -983,6 +1017,7 @@ def compute_mkappa( else [pressure_history[name] for name in names], friction_law=law, time_s=time_s, + core_loads=core_load_states, ) res, moment, work, ei_max = run.armour, run.moment_Nm, run.work, run.EI_max_Nm2 w_diss, core_history = run.W_diss_J_per_m, run.core_history @@ -1008,9 +1043,18 @@ def compute_mkappa( () if pressure_history is None else ( - "only the armour friction bound follows the contact-pressure " - "history; the stick stiffness, EI_min, any laid-core and ring " - "contact loads and the wire-yield check use the reference state", + ( + "the armour friction bound and the laid-core and profile " + "contact loads follow the tension history; the stick " + "stiffness, EI_min, the pressure-held part of the internal " + "rings and the wire-yield check use the reference state" + ) + if core_load_states is not None + else ( + "only the armour friction bound follows the contact-pressure " + "history; the stick stiffness, EI_min, any laid-core and ring " + "contact loads and the wire-yield check use the reference state" + ), ) ) model = mkappa_law.core_model @@ -1040,10 +1084,21 @@ def compute_mkappa( ) ) citations_extra = ("[Yun2020] (core xi)", "[KarlsenHusoy2026]") + if core_load_states is not None: + method_extra += ( + f"; the core contact loads follow the tension history through " + f"the {contact_model} contact model" + ) limitations_extra = ( - "core contact loads are the axisymmetric state held fixed in " - "bending; the layers of a core move together; core-core friction " - "acts on the slip of each core relative to the plane-section field", + "core contact loads are the axisymmetric state " + + ( + "of every sample of the tension history" + if core_load_states is not None + else "of the reference" + ) + + ", not changed by bending; the layers of a core move together; " + "core-core friction acts on the slip of each core relative to the " + "plane-section field", "internal rings take the core contact line load by line-force " "conservation (upper estimate) and the cable curvature", ) diff --git a/src/cablexsec/mechanics/core_friction.py b/src/cablexsec/mechanics/core_friction.py index ce2f1e1..5e87ee3 100644 --- a/src/cablexsec/mechanics/core_friction.py +++ b/src/cablexsec/mechanics/core_friction.py @@ -112,11 +112,61 @@ filler outer radius). The profiles carry no share of the cable tension (the filler stays non-structural axially), so they have no capstan load. +Friction models +--------------- +:func:`core_friction_history` takes the friction model of the cores and the +filler profiles as the armour does (``friction_model``): + +* ``"direction_tied"`` (default): every station a spring--slider with the + Papailiou cap of :func:`wire_slip_history`, tied to the current bending + direction. Under rotating curvature the cap turns with the bending + direction and the friction work is too low (see :func:`wire_slip_history`). +* ``"distributed"``: each population (cores, profiles) is the distributed + helix model of the armour + (:func:`~cablexsec.mechanics.distributed_friction.distributed_friction_history`): + the axial force of a core is a field along one pitch of its helix with the + shear-lag interface of the stick coefficient ``xi`` (``k_hat = xi / (1 - + xi)``), the Coulomb bound of its contact pressure and the signed capstan + term ``lam = mu_eff |sin beta|``, and the slip of every helix node in the + direction of its own traction, with no bending direction. The stations + sample that field. The stress unit is the same ``sigma_0`` (the pressure + times the station width is the line load ``q_core`` of a core), so the + planar full-slip field is ``sigma_0 (C exp(lam x) - 1)``, + ``C = lam pi / (2 sinh(lam pi / 2))`` (``x`` the azimuth from the + geometric neutral axis toward tension), and the full-slip moment is that of + the direction-tied law times ``C``. It needs a compliant interface + (``xi < 1``). +* ``"auto"``: the direction-tied law on a planar curvature path (out-of-plane + ratio at most :data:`~cablexsec.analysis.fatigue.PLANAR_PATH_TOLERANCE`, as + in the fatigue route), the distributed law otherwise; a rigid population + keeps the direction-tied law with a + :class:`~cablexsec.provenance.FrictionModelFallbackWarning`. + +The internal rings keep the [KarlsenHusoy2026] operator in every model. + +Contact loads over a tension history +------------------------------------ +:func:`core_load_history` evaluates the core and profile contact loads of the +contact model at every sample of a tension history (the bounded chain is +affine in tension, so two evaluations give it; the solved model is solved at +up to 33 tensions and interpolated beyond, as the armour histories). The +friction bound of each population then follows its own load. The profile +pressure is proportional to its face load. The core pressure is the pressure +of the sample's line load times the ratio of the population's full-slip +friction moment at the sample's load-weighted coefficient to that at the +reference coefficient, so that loading the contact types in another +proportion changes the bound level as it changes the group cap of an +exported law's slip scale +(:class:`~cablexsec.analysis.bending_law.SlipScaleTable`); the coefficient in +the capstan term stays at the reference value. The internal rings take the +tension history; their pressure-held part stays at the reference core load. + Assumptions (stated, not solved) -------------------------------- -* Normal contact loads are those of the axisymmetric state and are held - fixed during bending (as for the armour); the bending redistribution of - core contact is not solved. +* Normal contact loads are those of the axisymmetric state, at the + reference tension or following a tension history + (:func:`core_load_history`), and are not changed by bending (as for the + armour); the bending redistribution of core contact is not solved. * The wedged trefoil assumes touching cores. The outer-face load ``R / n`` of a core and the face loads ``2 R / n`` of a profile are estimates: a profile face is not radial, and part of ``R`` reaches the cores directly. @@ -142,8 +192,10 @@ from __future__ import annotations +import dataclasses import math from dataclasses import dataclass, field +from typing import Literal import numpy as np from numpy.typing import NDArray @@ -157,11 +209,13 @@ from cablexsec.materials import library from cablexsec.mechanics.axisymmetric import AxisymmetricResult, compute_contact_forces from cablexsec.mechanics.core_lay import bending_factor, core_angle +from cablexsec.mechanics.distributed_friction import DEFAULT_MAX_INCREMENT from cablexsec.mechanics.mkappa import HelicalLayerSpec from cablexsec.mechanics.papailiou import ( DIRECTION_HOLD_FRACTION, BendingWork, wire_slip_history, + wire_slip_stress_bounds, ) from cablexsec.mechanics.radial_cable import CableRadialState from cablexsec.mechanics.section_geometry import is_interstitial_filler @@ -180,20 +234,36 @@ ) __all__ = [ + "CORE_FRICTION_MODELS", + "CORE_LOAD_MODES", "CoreContactLoads", "CoreFrictionHistory", "CoreFrictionModel", + "CoreFrictionModelName", "CoreFrictionSpec", + "CoreLoadHistory", + "CoreLoadMode", "FillerProfiles", "StrandRingFriction", "build_core_friction", "core_contact_loads", "core_friction_history", + "core_load_history", "resolve_core_friction", ] FloatArray = NDArray[np.float64] +#: Friction model of the core law (:func:`core_friction_history`). +CoreFrictionModelName = Literal["direction_tied", "distributed", "auto"] +CORE_FRICTION_MODELS: tuple[str, ...] = ("direction_tied", "distributed", "auto") +#: Core contact loads of a route with a tension history: ``"follow"`` the +#: history (:func:`core_load_history`) or hold the ``"reference"`` state. +CoreLoadMode = Literal["follow", "reference"] +CORE_LOAD_MODES: tuple[str, ...] = ("follow", "reference") +#: Solved tensions of a solved-model load history before it is interpolated. +_SOLVED_LOAD_NODES = 33 + #: Default friction coefficient of every core contact: the value Ménard and #: Cartraud (2023, Section 5) adopt for all contacts of a three-core cable. DEFAULT_CORE_MU = 0.2 @@ -881,10 +951,158 @@ def build_core_friction( ) +@dataclass(frozen=True) +class CoreLoadHistory: + """Core and filler-profile contact loads over a tension history. + + ``core_N_per_m`` is the total normal line load of one core and + ``core_mu_effective`` its load-weighted friction coefficient at every + sample; ``core_pressure_Pa`` the friction-setting pressure of the core + population (module notes) and ``core_mu_capstan`` the coefficient of its + capstan term over the history: the model's reference coefficient, or, + when that is zero while later samples carry frictional loads (an + unloaded reference whose filler coefficient is zero), the coefficient of + the most loaded sample. ``filler_profile_N_per_m`` and + ``filler_pressure_Pa`` are those of the filler profiles (``None`` + without them). ``contact_model`` names the model the loads come from. + """ + + tension_N: FloatArray + core_N_per_m: FloatArray + core_mu_effective: FloatArray + core_pressure_Pa: FloatArray + contact_model: str + filler_profile_N_per_m: FloatArray | None = None + filler_pressure_Pa: FloatArray | None = None + core_mu_capstan: float | None = None + + +def _population_cap_per_pressure(spec: HelicalLayerSpec, mu: float) -> float: + """Planar full-slip friction moment of a population per unit pressure, + without the common factor ``A cos(beta) r``.""" + unit = dataclasses.replace(spec, mu=mu, contact_pressure_Pa=1.0) + upper, lower = wire_slip_stress_bounds(unit, 0.0) + c = np.cos(unit.phi_wires) + return float(np.sum(np.where(c > 0.0, upper, lower) * np.abs(c))) + + +def _load_nodes(tension: FloatArray, contact_model: str) -> FloatArray: + """Tensions at which the contact model is evaluated (module notes).""" + if contact_model != "solved": + # Bounded estimate (also the core loads of the qp model): affine. + return np.array([0.0, max(float(np.max(tension)), 1.0)]) + unique = np.unique(tension) + if unique.size <= _SOLVED_LOAD_NODES: + return np.asarray(unique, dtype=np.float64) + return np.linspace(float(unique[0]), float(unique[-1]), _SOLVED_LOAD_NODES) + + +def core_load_history( + cable: CableData, + model: CoreFrictionModel, + tension_N: FloatArray, + *, + contact_model: str = "bounded", +) -> CoreLoadHistory: + """Core and filler-profile contact loads of ``model`` over a tension history. + + The loads of :func:`core_contact_loads` with the model's core support at + every sample of ``tension_N`` [N] (finite, non-negative, 1-D): exact for + the bounded estimate (affine in tension, two evaluations; the ``"qp"`` + model takes the bounded estimate for the cores too), and for the solved + model exact up to 33 distinct tensions and interpolated linearly between + 33 equally spaced solutions beyond. Pass the result to + :func:`core_friction_history` (``loads``) so that the friction bounds of + the cores and profiles follow the history (module notes). + """ + tension = np.asarray(tension_N, dtype=np.float64) + if tension.ndim != 1 or not tension.size or not np.isfinite(tension).all(): + raise CableInputError( + "the tension history must be a finite, non-empty 1-D array" + ) + if np.any(tension < 0.0): + raise CableInputError("the tension history must not be negative") + if contact_model not in {"bounded", "qp", "solved"}: + raise CableSchemaError("contact_model must be 'bounded', 'qp' or 'solved'.") + nodes = _load_nodes(tension, contact_model) + support = None if contact_model == "solved" else model.spec.central_filler + at_nodes = [ + core_contact_loads( + cable, float(value), contact_model=contact_model, central_filler=support + ) + for value in nodes + ] + + def follow(name: str) -> FloatArray: + values = np.array([getattr(item, name) for item in at_nodes]) + if nodes.size == 1: + return np.full(tension.shape, float(values[0])) + return np.asarray(np.interp(tension, nodes, values), dtype=np.float64) + + core_core = follow("core_core_N_per_m") + filler = follow("core_filler_N_per_m") + sheath = follow("core_sheath_N_per_m") + total = core_core + filler + sheath + spec = model.spec + weighted = ( + spec.mu_core_core * core_core + + spec.mu_core_filler * filler + + spec.mu_core_sheath * sheath + ) + positive = total > 0.0 + mu = np.full(total.shape, spec.mu_core_filler) + mu[positive] = weighted[positive] / total[positive] + population = model.population + pressure = model.n_cores * total / (2.0 * math.pi * model.r_offset_m) + reference_mu = float(population.mu) + if reference_mu <= 0.0 and np.any(mu[positive] > 0.0): + # A zero reference coefficient cannot carry the friction of later + # samples: normalise by the coefficient of the most loaded sample. + reference_mu = float(mu[int(np.argmax(total))]) + if np.any(np.abs(mu - reference_mu) > 1e-12 * max(reference_mu, 1e-300)): + # The full-slip friction moment of the population at each sample's + # coefficient over that at the normalising coefficient (positive + # here unless every sample is frictionless). + reference = _population_cap_per_pressure(population, reference_mu) + values, inverse = np.unique(mu, return_inverse=True) + ratio = np.array( + [ + _population_cap_per_pressure(population, float(value)) / reference + if reference > 0.0 + else 0.0 + for value in values + ] + ) + pressure = pressure * ratio[inverse] + profile = profile_pressure = None + if model.fillers is not None: + profile = follow("filler_profile_N_per_m") + r_f = model.fillers.population.r_helix_m + profile_pressure = model.fillers.n_profiles * profile / (2.0 * math.pi * r_f) + return CoreLoadHistory( + tension_N=tension, + core_N_per_m=np.asarray(total, dtype=np.float64), + core_mu_effective=np.asarray(mu, dtype=np.float64), + core_pressure_Pa=np.asarray(pressure, dtype=np.float64), + contact_model=contact_model, + filler_profile_N_per_m=profile, + filler_pressure_Pa=profile_pressure, + core_mu_capstan=reference_mu, + ) + + @dataclass(frozen=True) class CoreFrictionHistory: """Moments ``(samples, 2)`` and work of the cores, internal rings and - filler profiles (``filler_moment_Nm`` zero without profiles).""" + filler profiles (``filler_moment_Nm`` zero without profiles). + + ``friction_model`` is the law the cores and profiles were solved with + (``"direction_tied"`` or ``"distributed"``; ``"auto"`` resolved). + ``core_slip_fraction`` is the fraction of core stations in slip + (direction-tied) or of helix nodes on their bound (distributed). + ``loads`` is the load history the bounds followed (``None``: the + model's reference loads). + """ core_moment_Nm: FloatArray strand_moment_Nm: FloatArray @@ -892,6 +1110,8 @@ class CoreFrictionHistory: work: BendingWork model: CoreFrictionModel filler_moment_Nm: FloatArray | None = None + friction_model: str = "direction_tied" + loads: CoreLoadHistory | None = None @property def moment_Nm(self) -> FloatArray: @@ -902,12 +1122,15 @@ def moment_Nm(self) -> FloatArray: def _strand_history( - model: CoreFrictionModel, kx: FloatArray, ky: FloatArray + model: CoreFrictionModel, + kx: FloatArray, + ky: FloatArray, + tension_N: FloatArray | None = None, ) -> tuple[FloatArray, FloatArray, FloatArray, FloatArray, FloatArray]: count = kx.size moment = np.zeros((count, 2)) stored, friction, endpoint, remainder = (np.zeros(count) for _ in range(4)) - tension = np.full(count, model.tension_N) + tension = np.full(count, model.tension_N) if tension_N is None else tension_N for item in model.strand_rings: ring = item.ring theta = 2.0 * math.pi * np.arange(ring.n_wires) / ring.n_wires @@ -928,56 +1151,193 @@ def _strand_history( return moment, stored, friction, endpoint, remainder +def _resolve_core_model( + model: CoreFrictionModel, + friction_model: str, + kx: FloatArray, + ky: FloatArray, + stacklevel: int, +) -> str: + """Friction model of the core law over this path (``"auto"`` resolved).""" + if friction_model not in CORE_FRICTION_MODELS: + raise CableInputError( + f"the core friction model must be one of {CORE_FRICTION_MODELS}, " + f"got {friction_model!r}" + ) + if friction_model == "direction_tied": + return friction_model + from cablexsec.analysis.fatigue import ( # noqa: PLC0415 + PLANAR_PATH_TOLERANCE, + _warn_auto_fallback, + curvature_path_out_of_plane_ratio, + ) + + if ( + friction_model == "auto" + and curvature_path_out_of_plane_ratio(kx, ky) <= PLANAR_PATH_TOLERANCE + ): + return "direction_tied" + rigid = [ + f"the {name} (xi = {pop.xi:.6g})" + for name, pop in zip( + ("cores", "filler profiles"), model.populations, strict=False + ) + if not (math.isfinite(pop.xi) and 0.0 <= pop.xi < 1.0) + ] + if not rigid: + return "distributed" + reason = f"the interface is rigid for {' and '.join(rigid)}" + if friction_model == "distributed": + raise CableInputError( + f"the distributed core law needs a compliant interface (xi < 1): " + f"{reason}; give a finite interface stiffness or the core shear " + "(CoreFrictionSpec), or use friction_model='direction_tied'" + ) + _warn_auto_fallback("the laid-core law", reason, stacklevel + 1) + return "direction_tied" + + +def _distributed_population( + spec: HelicalLayerSpec, + kx: FloatArray, + ky: FloatArray, + pressure: FloatArray | None, + nodes_per_pitch: int | None, + max_increment: float, +) -> tuple[FloatArray, BendingWork, FloatArray]: + """Moment ``(samples, 2)``, work and node slip fraction of one population + from the distributed helix model.""" + from cablexsec.mechanics.distributed_friction import ( # noqa: PLC0415 + distributed_friction_history, + ) + + history = distributed_friction_history( + spec, + kx, + ky, + contact_pressure_Pa=pressure, + nodes_per_pitch=nodes_per_pitch, + max_increment=max_increment, + ) + phi = np.asarray(spec.phi_wires, dtype=np.float64) + weight = spec.A_wire_m2 * math.cos(spec.lay_angle_rad) * spec.r_helix_m + directions = np.column_stack((np.cos(phi), np.sin(phi))) + moment = weight * (history.stress_Pa.T @ directions) + work = BendingWork( + history.stored_J_per_m, + history.dissipation_J_per_m, + history.endpoint_work_J_per_m, + history.integration_remainder_J_per_m, + history.balance_residual_J_per_m, + ) + return np.asarray(moment, dtype=np.float64), work, history.slip_fraction + + def core_friction_history( model: CoreFrictionModel, kappa_x: FloatArray, kappa_y: FloatArray, *, initial_bending_angle: float = 0.0, + friction_model: CoreFrictionModelName = "direction_tied", + loads: CoreLoadHistory | None = None, + nodes_per_pitch: int | None = None, + max_increment: float = DEFAULT_MAX_INCREMENT, ) -> CoreFrictionHistory: """Biaxial history of the core population, the internal rings and the filler profiles. - The core and profile stations use :func:`wire_slip_history` unchanged - (direction-tied Papailiou cap); the rings use :func:`strand_slip_strain`. - All return moments in the material frame of the curvature components. + ``friction_model`` selects the law of the cores and the profiles (module + notes): ``"direction_tied"`` (default) uses :func:`wire_slip_history` + unchanged (direction-tied Papailiou cap; ``initial_bending_angle`` is its + held direction at the start), ``"distributed"`` the distributed helix + model with ``nodes_per_pitch`` helix nodes per pitch (default four per + station) and substeps of at most ``max_increment`` slip-onset curvatures + (the default of the distributed model), ``"auto"`` the direction-tied + law on a planar path and the distributed law otherwise. The rings use + :func:`strand_slip_strain`. + ``loads`` (:func:`core_load_history`, one sample per curvature sample) + makes the contact loads follow a tension history; ``None`` holds the + model's reference loads. All return moments in the material frame of the + curvature components. """ kx = np.asarray(kappa_x, dtype=np.float64) ky = np.asarray(kappa_y, dtype=np.float64) - history = wire_slip_history( - model.population, - kx, - ky, - initial_bending_angle=initial_bending_angle, - direction_hold_fraction=model.spec.direction_hold_fraction, - ) + core_pressure: FloatArray | None = None + filler_pressure: FloatArray | None = None + tension: FloatArray | None = None + if loads is not None: + if loads.tension_N.shape != kx.shape: + raise CableInputError( + "the core load history must have one sample per curvature sample" + ) + if (loads.filler_pressure_Pa is None) != (model.fillers is None): + raise CableInputError( + "the core load history belongs to another core model " + "(its filler profiles differ)" + ) + core_pressure = loads.core_pressure_Pa + filler_pressure = loads.filler_pressure_Pa + tension = loads.tension_N + population = model.population + if ( + loads is not None + and loads.core_mu_capstan is not None + and loads.core_mu_capstan != population.mu + ): + population = dataclasses.replace(population, mu=loads.core_mu_capstan) + resolved = _resolve_core_model(model, friction_model, kx, ky, stacklevel=2) s_moment, s_stored, s_friction, s_endpoint, s_remainder = _strand_history( - model, kx, ky + model, kx, ky, tension ) - w = history.work + if resolved == "distributed": + core_moment, w, slip = _distributed_population( + population, kx, ky, core_pressure, nodes_per_pitch, max_increment + ) + else: + history = wire_slip_history( + population, + kx, + ky, + contact_pressure_Pa=core_pressure, + initial_bending_angle=initial_bending_angle, + direction_hold_fraction=model.spec.direction_hold_fraction, + ) + core_moment, w = np.asarray(history.moment_Nm), history.work + slip = history.slipping_count / float(model.population.n_wires) stored = w.stored_J_per_m + s_stored friction = w.friction_J_per_m + s_friction endpoint = w.endpoint_work_J_per_m + s_endpoint remainder = w.integration_remainder_J_per_m + s_remainder filler_moment = None if model.fillers is not None: - filler = wire_slip_history( - model.fillers.population, - kx, - ky, - initial_bending_angle=initial_bending_angle, - direction_hold_fraction=model.spec.direction_hold_fraction, - ) - filler_moment = np.asarray(filler.moment_Nm) - fw = filler.work + if resolved == "distributed": + filler_moment, fw, _ = _distributed_population( + model.fillers.population, + kx, + ky, + filler_pressure, + nodes_per_pitch, + max_increment, + ) + else: + filler = wire_slip_history( + model.fillers.population, + kx, + ky, + contact_pressure_Pa=filler_pressure, + initial_bending_angle=initial_bending_angle, + direction_hold_fraction=model.spec.direction_hold_fraction, + ) + filler_moment, fw = np.asarray(filler.moment_Nm), filler.work stored = stored + fw.stored_J_per_m friction = friction + fw.friction_J_per_m endpoint = endpoint + fw.endpoint_work_J_per_m remainder = remainder + fw.integration_remainder_J_per_m return CoreFrictionHistory( - core_moment_Nm=np.asarray(history.moment_Nm), + core_moment_Nm=core_moment, strand_moment_Nm=s_moment, - core_slip_fraction=history.slipping_count / float(model.population.n_wires), + core_slip_fraction=np.asarray(slip, dtype=np.float64), work=BendingWork( stored, friction, @@ -987,4 +1347,6 @@ def core_friction_history( ), model=model, filler_moment_Nm=filler_moment, + friction_model=resolved, + loads=loads, ) diff --git a/tests/test_core_friction_distributed.py b/tests/test_core_friction_distributed.py new file mode 100644 index 0000000..561e4ae --- /dev/null +++ b/tests/test_core_friction_distributed.py @@ -0,0 +1,626 @@ +# SPDX-License-Identifier: Apache-2.0 +# Copyright (c) 2026 Jae Hoon Seo, SMI Lab, Inha University +"""Distributed laid-core law and core contact loads that follow the tension. + +Rows CF-D and CF-T of ``doc/benchmarks.md`` (laid-core friction, gap R1b), +registered before the run. Verification only: limits, closed forms, energy, +invariance and identities of the scaling. +""" + +from __future__ import annotations + +import dataclasses +import math +import warnings + +import numpy as np +import pytest + +import cablexsec as cx +import cablexsec.mechanics.core_friction as core_friction +from cablexsec._numba import kernels_compiled +from cablexsec.analysis.bending_law import export_bending_law +from cablexsec.analysis.neutral_axis import neutral_axes +from cablexsec.api import CoreFrictionSpec +from cablexsec.exceptions import CableInputError, CableSchemaError +from cablexsec.mechanics import distributed_friction as dfm +from cablexsec.mechanics.core_friction import ( + build_core_friction, + core_friction_history, + core_load_history, +) +from cablexsec.mechanics.papailiou import slip_onset_curvature +from cablexsec.provenance import FrictionModelFallbackWarning + +pytestmark = [ + pytest.mark.analytical_sanity, + pytest.mark.filterwarnings( + "ignore::cablexsec.provenance.MissingClampingStateWarning" + ), +] + +PI = math.pi +T = 50.0e3 +SPEC = CoreFrictionSpec( + mu_core_filler=0.46, mu_core_core=0.46, mu_core_sheath=0.46, filler_profiles=True +) +#: Interpreted kernels (no numba) take shorter histories and fewer nodes. +COMPILED = kernels_compiled() +NODES = None if COMPILED else 180 +compiled = pytest.mark.skipif( + not COMPILED, reason="full-slip and fine-node runs need the compiled kernel" +) + + +@pytest.fixture(scope="module") +def iea66(): + return cx.load_cable(cx.iea_task49_66kv_yaml_path(), geometry_override=None) + + +@pytest.fixture(scope="module") +def model(iea66): + return build_core_friction(iea66, SPEC, T) + + +def _wound(cable, sigma_Pa): + layers = tuple( + x.model_copy(update={"winding_stress_Pa": sigma_Pa}) + if x.name in {"inner_armour", "outer_armour"} + else x + for x in cable.layers + ) + return cable.model_copy(update={"layers": layers}) + + +def _walk(seed, size, scale): + rng = np.random.default_rng(seed) + return ( + np.cumsum(rng.normal(scale=scale, size=size)), + np.cumsum(rng.normal(scale=scale, size=size)), + ) + + +def _short_walk(seed=11): + return _walk(seed, 300, 0.01) if COMPILED else _walk(seed, 30, 2e-3) + + +def _loop(amplitude, n=401, cycles=2): + return amplitude * np.sin(np.linspace(0.0, 2 * cycles * PI, n)) + + +def _scale(history): + return float(np.max(np.abs(history.moment_Nm))) + + +# --------------------------------------------------------------------------- # +# CF-D: distributed core law # +# --------------------------------------------------------------------------- # +@pytest.mark.parametrize("azimuth", [0.0, 0.7]) +def test_cf_d_planar_auto_is_the_direction_tied_law(model, iea66, azimuth): + k = _loop(0.05) + kx, ky = k * math.cos(azimuth), k * math.sin(azimuth) + tied = core_friction_history(model, kx, ky, initial_bending_angle=azimuth) + auto = core_friction_history( + model, kx, ky, initial_bending_angle=azimuth, friction_model="auto" + ) + assert auto.friction_model == "direction_tied" + scale = _scale(tied) + assert np.max(np.abs(auto.moment_Nm - tied.moment_Nm)) <= 1e-12 * scale + work = tied.work.friction_J_per_m + assert np.max(np.abs(auto.work.friction_J_per_m - work)) <= 1e-12 * work[-1] + tension = np.full(k.size, T) + section = { + model_name: cx.compute_neutral_axes( + iea66, + kx, + ky, + tension_N=tension, + friction_model=model_name, + core_friction=SPEC, + ) + for model_name in ("direction_tied", "auto") + } + a, b = section["auto"].moment_Nm, section["direction_tied"].moment_Nm + assert np.max(np.abs(a - b)) <= 1e-12 * np.max(np.abs(b)) + assert "(auto)" in section["auto"].provenance.method + + +def test_cf_d_rotation_equivariance(model): + kx, ky = _short_walk() + base = core_friction_history( + model, kx, ky, friction_model="distributed", nodes_per_pitch=NODES + ) + assert base.friction_model == "distributed" + scale = _scale(base) + n_st = model.population.n_wires + for angle, tol in ((2 * PI * 7 / n_st, 1e-9), (0.3, 1e-3)): + c, s = math.cos(angle), math.sin(angle) + rot = core_friction_history( + model, + c * kx - s * ky, + s * kx + c * ky, + friction_model="distributed", + nodes_per_pitch=NODES, + ) + expected = base.moment_Nm @ np.array([[c, s], [-s, c]]) + assert np.max(np.abs(rot.moment_Nm - expected)) <= tol * scale + assert rot.work.friction_J_per_m[-1] == pytest.approx( + base.work.friction_J_per_m[-1], rel=tol + ) + + +def test_cf_d_dissipation_is_nonnegative_and_work_balances(model): + steps = 400 if COMPILED else 40 + t = np.linspace(0.0, 4 * PI, steps) + radius = (0.03 if COMPILED else 3e-3) * np.minimum(1.0, t / PI) + for kx, ky in (_short_walk(3), (radius * np.cos(t), radius * np.sin(t))): + hist = core_friction_history( + model, kx, ky, friction_model="distributed", nodes_per_pitch=NODES + ) + friction = hist.work.friction_J_per_m + assert friction[-1] > 0.0 + assert np.all(np.diff(friction) >= -1e-12 * friction[-1]) + residual = hist.work.balance_residual_J_per_m + assert np.max(np.abs(residual)) <= 1e-9 * friction[-1] + + +def test_cf_d_zero_friction_gives_the_armour_only_section(iea66): + zero = CoreFrictionSpec( + mu_core_filler=0.0, mu_core_core=0.0, mu_core_sheath=0.0, filler_profiles=True + ) + kx, ky = _walk(5, 120, 1e-3) if COMPILED else _walk(5, 12, 1e-4) + tension = np.full(kx.size, T) + options = {"tension_N": tension, "friction_model": "distributed"} + base = cx.compute_neutral_axes(iea66, kx, ky, **options) + cored = cx.compute_neutral_axes(iea66, kx, ky, core_friction=zero, **options) + assert np.array_equal(cored.core_moment_Nm, np.zeros((kx.size, 2))) + assert np.array_equal(cored.moment_Nm, base.moment_Nm) + + +def test_cf_d_large_friction_tangent_is_the_stick_stiffness(iea66): + stuck = CoreFrictionSpec( + mu_core_filler=1e3, mu_core_core=1e3, mu_core_sheath=1e3, filler_profiles=True + ) + model = build_core_friction(iea66, stuck, T) + assert 0.0 < model.xi < 1.0 and 0.0 < model.fillers.xi < 1.0 + t = np.linspace(0.0, 2 * PI, 41)[1:] + kx, ky = 1e-6 * np.cos(t), 1e-6 * np.sin(t) + hist = core_friction_history(model, kx, ky, friction_model="distributed") + tangent = np.hypot(*hist.moment_Nm.T) / np.hypot(kx, ky) + assert np.allclose(tangent, model.stick_EI_Nm2, rtol=1e-5, atol=0.0) + # No slip: the friction work is round-off of the stored energy. + stored = float(np.max(hist.work.stored_J_per_m)) + assert np.max(np.abs(hist.work.friction_J_per_m)) <= 1e-12 * stored + + +def _closed_form(n, q, r, beta, mu): + lam = mu * math.sin(beta) + c = lam * PI / (2.0 * math.sinh(lam * PI / 2.0)) + return ( + 2.0 + / PI + * n + * q + * r + * r + * math.cos(beta) ** 2 + / math.sin(beta) ** 2 + * lam + * c + * math.cosh(lam * PI / 2.0) + / (1.0 + lam * lam) + ) + + +def _station_sum(population, n, q): + """Moment of the closed-form full-slip field summed over the stations.""" + lam = population.mu * math.sin(population.lay_angle_rad) + c = lam * PI / (2.0 * math.sinh(lam * PI / 2.0)) + r, beta = population.r_helix_m, population.lay_angle_rad + area = population.A_wire_m2 * population.n_wires / n + sigma0 = q * math.cos(beta) * r / (area * math.sin(beta) ** 2) + phi = population.phi_wires + x = PI / 2 - np.abs(np.angle(np.exp(1j * phi))) + stress = sigma0 * (c * np.exp(lam * x) - 1.0) + weight = population.A_wire_m2 * math.cos(beta) * r + return float(weight * np.sum(stress * np.cos(phi))) + + +def _full_slip(model): + fillers = model.fillers + onset = max( + slip_onset_curvature(model.population), + slip_onset_curvature(fillers.population), + ) + kappa = np.linspace(0.0, 1000.0 * onset, 301)[1:] + hist = core_friction_history( + model, kappa, np.zeros_like(kappa), friction_model="distributed" + ) + cases = ( + ( + hist.core_moment_Nm[-1, 0], + model.population, + model.n_cores, + model.loads.total_N_per_m, + ), + ( + hist.filler_moment_Nm[-1, 0], + fillers.population, + fillers.n_profiles, + fillers.line_load_N_per_m, + ), + ) + out = [] + for moment, population, n, q in cases: + closed = _closed_form( + n, q, population.r_helix_m, population.lay_angle_rad, population.mu + ) + out.append((moment / closed - 1.0, moment / _station_sum(population, n, q) - 1)) + assert abs(hist.core_moment_Nm[-1, 1]) <= 1e-9 * abs(hist.core_moment_Nm[-1, 0]) + assert hist.core_slip_fraction[-1] == 1.0 + return out + + +@compiled +def test_cf_d_full_slip_moment_matches_the_closed_form(model, iea66): + """Planar monotonic loading to full slip. The distributed full-slip field + is ``sigma_0 (C exp(lam x) - 1)``; its moment integrand ``C exp(lam x) + sin x`` over the pitch gives the closed form, the direction-tied value + ``a cosh(a pi/2) / (1 + a^2)`` times ``C``. + + Registered target 1e-4: FAIL at the default 60 stations per core + (1.02e-4 cores, 1.03e-4 profiles; doc/benchmarks.md, CF-D-slip). The + field is exact (the model reproduces the station sum of the closed-form + field to 1e-9); the residual is the station quadrature of a field with + kinks at the extreme fibres, second order in the station spacing (twice + the stations: 2.6e-5).""" + default = _full_slip(model) + for continuous, stations in default: + assert abs(stations) <= 1e-9 + assert 1.0e-4 < continuous < 1.1e-4 # the documented deviation + finer = _full_slip( + build_core_friction( + iea66, dataclasses.replace(SPEC, n_stations_per_core=120), T + ) + ) + for (coarse, _), (fine, stations) in zip(default, finer, strict=True): + assert abs(stations) <= 1e-9 + assert fine <= 1e-4 + assert coarse / fine == pytest.approx(4.0, rel=0.02) + + +@pytest.mark.parametrize("follow", [False, True]) +def test_cf_d_compiled_kernel_is_the_reference(model, iea66, monkeypatch, follow): + t = np.linspace(0.0, 1.0, 120 if COMPILED else 24) + amplitude = 0.02 if COMPILED else 2e-3 + kx = amplitude * np.sin(6 * PI * t) * (0.4 + t) + ky = 0.6 * amplitude * np.sin(4 * PI * t + 1.0) + loads = ( + core_load_history(iea66, model, T * (1.0 + 0.3 * np.sin(5 * PI * t))) + if follow + else None + ) + runs = [] + for fast in (False, True): + monkeypatch.setattr(dfm, "_FAST_KERNEL", fast) + runs.append( + core_friction_history( + model, + kx, + ky, + friction_model="distributed", + loads=loads, + nodes_per_pitch=NODES, + ) + ) + ref, fast_run = runs + scale = _scale(ref) + assert np.max(np.abs(fast_run.moment_Nm - ref.moment_Nm)) <= 1e-10 * scale + energy = np.max(np.abs(ref.work.endpoint_work_J_per_m)) + for name in ( + "stored_J_per_m", + "friction_J_per_m", + "endpoint_work_J_per_m", + "integration_remainder_J_per_m", + ): + a, b = getattr(fast_run.work, name), getattr(ref.work, name) + assert np.max(np.abs(a - b)) <= 1e-10 * energy, name + + +# --------------------------------------------------------------------------- # +# CF-T: core contact loads over a tension history # +# --------------------------------------------------------------------------- # +@pytest.mark.parametrize("law", ["direction_tied", "distributed"]) +def test_cf_t_constant_reference_tension_changes_nothing(model, iea66, law): + kx, ky = _short_walk(7) + loads = core_load_history(iea66, model, np.full(kx.size, T)) + fixed = core_friction_history( + model, kx, ky, friction_model=law, nodes_per_pitch=NODES + ) + follow = core_friction_history( + model, kx, ky, friction_model=law, loads=loads, nodes_per_pitch=NODES + ) + assert follow.loads is loads and fixed.loads is None + scale = _scale(fixed) + assert np.max(np.abs(follow.moment_Nm - fixed.moment_Nm)) <= 1e-12 * scale + + +@pytest.mark.parametrize("sigma", [0.0, 20.0e6], ids=["0MPa", "20MPa"]) +@pytest.mark.parametrize("law", ["direction_tied", "distributed"]) +def test_cf_t_loads_at_another_level_are_the_law_built_there(iea66, sigma, law): + cable = _wound(iea66, sigma) if sigma else iea66 + at_ref = build_core_friction(cable, SPEC, T) + level = 1.2e5 + at_level = build_core_friction(cable, SPEC, level) + kx, ky = _short_walk(9) + loads = core_load_history(cable, at_ref, np.full(kx.size, level)) + np.testing.assert_allclose( + loads.core_N_per_m, at_level.loads.total_N_per_m, rtol=1e-12 + ) + follow = core_friction_history( + at_ref, kx, ky, friction_model=law, loads=loads, nodes_per_pitch=NODES + ) + direct = core_friction_history( + at_level, kx, ky, friction_model=law, nodes_per_pitch=NODES + ) + tolerance = 1e-12 if law == "direction_tied" else 2e-3 + scale = _scale(direct) + assert np.max(np.abs(follow.moment_Nm - direct.moment_Nm)) <= tolerance * scale + + +def _tension_history(n=1200, amplitude=0.03, phase=0.1): + t = np.arange(n) + kappa = amplitude * np.sin(2.0 * PI * t / 200.0 + phase) + tension = 1.0e4 + 6.0e4 * np.sin(PI * t / 370.0) ** 2 + return kappa, tension + + +@pytest.mark.parametrize("sigma", [0.0, 20.0e6], ids=["0MPa", "20MPa"]) +@pytest.mark.parametrize("amplitude", [3e-4, 3e-3]) +def test_cf_t_tension_cycle_agrees_with_the_slip_scaled_law(iea66, sigma, amplitude): + """The MX-scale tension-cycle check with the laid cores and profiles.""" + cable = _wound(iea66, sigma) if sigma else iea66 + kappa, tension = _tension_history(amplitude=amplitude) + export = export_bending_law( + cable, + tensions_N=[1.0e4, 7.0e4], + kappa_max_1_m=1.2 * amplitude, + n_points=300, + slip_scale=True, + slip_scale_tensions_N=np.linspace(1.0e4, 7.0e4, 7), + core_friction=SPEC, + ) + table = export.slip_scale + + def section(**options): + return np.asarray( + cx.compute_mkappa(cable, kappa, core_friction=SPEC, **options).moment_Nm + ) + + history = section(contact_tension_history_N=tension) + span = np.ptp(history) + residual = [] + for level in (1.0e4, 7.0e4): + fixed = section(tension_N=level) + law = table.moment(kappa, np.full_like(kappa, level)) + residual.append(np.max(np.abs(law - fixed)) / np.ptp(fixed)) + scaled = table.moment(kappa, tension) + deviation = np.max(np.abs(scaled - history)) / span + assert deviation <= 1.25 * max(residual) + assert deviation < 5e-3 + # Reported (doc/benchmarks.md, CF-T-cycle): the loads held at the first + # sample; the comparison is not gated. + held = section(contact_tension_history_N=tension, core_loads="reference") + assert np.isfinite(np.max(np.abs(scaled - held)) / span) + + +# --------------------------------------------------------------------------- # +# Routes, options and checks # +# --------------------------------------------------------------------------- # +def test_neutral_axes_core_options(iea66): + # The direction-tied routes take a walk into slip with either kernel. + kx, ky = _walk(13, 60, 2e-3) + tension = T * (1.0 + 0.2 * np.sin(np.linspace(0.0, 3.0, kx.size))) + base = {"tension_N": tension, "core_friction": SPEC} + follow = cx.compute_neutral_axes(iea66, kx, ky, **base) + held = cx.compute_neutral_axes(iea66, kx, ky, core_loads="reference", **base) + assert not np.array_equal(follow.core_moment_Nm, held.core_moment_Nm) + text = " ".join(follow.provenance.limitations) + assert "direction-tied core law" in text and "following the tension" in text + assert "at the reference tension" in " ".join(held.provenance.limitations) + # Loads held at the first sample: the core law of the reference model. + model = build_core_friction(iea66, SPEC, float(tension[0])) + expected = core_friction_history(model, kx, ky).moment_Nm + np.testing.assert_array_equal(held.core_moment_Nm, expected) + # contact_tension_N sets the loads when given with a direct strain. + contact = cx.compute_neutral_axes( + iea66, + kx, + ky, + axial_strain=np.zeros_like(kx), + contact_tension_N=tension, + core_friction=SPEC, + ) + np.testing.assert_array_equal(contact.core_moment_Nm, follow.core_moment_Nm) + # The core model can differ from the armour model. + count = kx.size if COMPILED else 8 + split = cx.compute_neutral_axes( + iea66, + kx[:count] * (1.0 if COMPILED else 0.1), + ky[:count] * (1.0 if COMPILED else 0.1), + core_friction_model="distributed", + core_friction=SPEC, + tension_N=tension[:count], + ) + assert "distributed core law" in " ".join(split.provenance.limitations) + progressive = cx.compute_neutral_axes( + iea66, kx, ky, friction_model="progressive", **base + ) + np.testing.assert_array_equal(progressive.core_moment_Nm, follow.core_moment_Nm) + with pytest.raises(CableInputError, match="core_loads"): + cx.compute_neutral_axes(iea66, kx, ky, core_loads="frozen", **base) + with pytest.raises(CableInputError, match="core_friction_model must"): + cx.compute_neutral_axes(iea66, kx, ky, core_friction_model="other", **base) + with pytest.raises(CableInputError, match="needs core_friction"): + cx.compute_neutral_axes(iea66, kx, ky, core_friction_model="auto") + + +def test_auto_falls_back_on_a_rigid_interface(iea66): + rigid = CoreFrictionSpec(core_shear=False) + model = build_core_friction(iea66, rigid, T) + assert model.xi == 1.0 + t = np.linspace(0.0, 2 * PI, 60) + kx, ky = 0.01 * np.cos(t), 0.01 * np.sin(t) + with pytest.warns(FrictionModelFallbackWarning, match="laid-core law"): + auto = core_friction_history(model, kx, ky, friction_model="auto") + assert auto.friction_model == "direction_tied" + np.testing.assert_array_equal( + auto.moment_Nm, core_friction_history(model, kx, ky).moment_Nm + ) + with pytest.raises(CableInputError, match="compliant interface"): + core_friction_history(model, kx, ky, friction_model="distributed") + with pytest.raises(CableInputError, match="core friction model"): + core_friction_history(model, kx, ky, friction_model="other") # type: ignore[arg-type] + # The armour route of the neutral axes resolves "auto" per layer. + spec = cx.cable_to_fatigue_layers(iea66, contact_tension_N=T)[0].spec + stiff = dataclasses.replace(spec, xi=1.0) + with pytest.warns(FrictionModelFallbackWarning, match="stiff_layer"): + result = neutral_axes([("stiff_layer", stiff)], kx, ky, friction_model="auto") + assert result.layers[0].friction_model == "direction_tied" + with warnings.catch_warnings(): + warnings.simplefilter("error", FrictionModelFallbackWarning) + planar = neutral_axes( + [("stiff_layer", stiff)], kx, np.zeros_like(kx), friction_model="auto" + ) + assert planar.layers[0].friction_model == "direction_tied" + + +def test_core_load_history_routes_and_checks(iea66, model, monkeypatch): + tension = np.array([1.0e4, 5.0e4, 9.0e4, 5.0e4]) + bounded = core_load_history(iea66, model, tension) + assert bounded.contact_model == "bounded" + for i, value in enumerate(tension): + direct = build_core_friction(iea66, SPEC, float(value)) + assert bounded.core_N_per_m[i] == pytest.approx( + direct.loads.total_N_per_m, rel=1e-12 + ) + assert bounded.filler_profile_N_per_m[i] == pytest.approx( + direct.fillers.line_load_N_per_m, rel=1e-12 + ) + assert bounded.core_pressure_Pa[i] == pytest.approx( + direct.population.contact_pressure_Pa, rel=1e-12 + ) + assert bounded.filler_pressure_Pa[i] == pytest.approx( + direct.fillers.population.contact_pressure_Pa, rel=1e-12 + ) + np.testing.assert_allclose(bounded.core_mu_effective, 0.46, rtol=1e-12) + # Zero tension and no clamping: no load, the filler coefficient. + plain = build_core_friction(iea66, CoreFrictionSpec(mu_core_filler=0.3), T) + zero = core_load_history(iea66, plain, np.zeros(3)) + assert np.all(zero.core_N_per_m == 0.0) and zero.filler_pressure_Pa is None + np.testing.assert_array_equal(zero.core_mu_effective, 0.3) + # Solved model: exact at a few tensions, interpolated beyond the node count. + solved_model = build_core_friction(iea66, SPEC, T, contact_model="solved") + solved = core_load_history( + iea66, solved_model, np.array([T, T]), contact_model="solved" + ) + np.testing.assert_allclose( + solved.core_N_per_m, solved_model.loads.total_N_per_m, rtol=1e-12 + ) + monkeypatch.setattr(core_friction, "_SOLVED_LOAD_NODES", 2) + spread = core_load_history( + iea66, solved_model, np.array([2.0e4, T, 8.0e4]), contact_model="solved" + ) + ends = [ + build_core_friction(iea66, SPEC, x, contact_model="solved").loads + for x in (2.0e4, 8.0e4) + ] + assert spread.core_N_per_m[1] == pytest.approx( + 0.5 * (ends[0].total_N_per_m + ends[1].total_N_per_m), rel=1e-12 + ) + for bad in (np.zeros((2, 2)), np.array([]), np.array([np.nan]), np.array([-1.0])): + with pytest.raises(CableInputError, match="tension history"): + core_load_history(iea66, model, bad) + with pytest.raises(CableSchemaError, match="contact_model"): + core_load_history(iea66, model, tension, contact_model="other") + with pytest.raises(CableInputError, match="one sample per curvature"): + core_friction_history(model, np.zeros(3), np.zeros(3), loads=bounded) + with pytest.raises(CableInputError, match="another core model"): + core_friction_history(plain, np.zeros(4), np.zeros(4), loads=bounded) + + +def test_mixed_coefficients_scale_the_bound_with_the_cap(iea66): + """Contact types loaded in another proportion: the core bound level follows + the population's full-slip friction moment at the sample's coefficient.""" + mixed = CoreFrictionSpec(mu_core_filler=0.4, mu_core_core=0.1, mu_core_sheath=0.2) + wound = _wound(iea66, 20.0e6) + at_ref = build_core_friction(wound, mixed, T) + level = 1.5e5 + at_level = build_core_friction(wound, mixed, level) + assert at_level.mu_effective != pytest.approx(at_ref.mu_effective, rel=1e-6) + loads = core_load_history(wound, at_ref, np.array([level])) + assert loads.core_mu_effective[0] == pytest.approx(at_level.mu_effective, rel=1e-12) + caps = [ + core_friction._population_cap_per_pressure(m.population, m.mu_effective) + * m.population.contact_pressure_Pa + for m in (at_ref, at_level) + ] + ratio = loads.core_pressure_Pa[0] / at_ref.population.contact_pressure_Pa + assert ratio == pytest.approx(caps[1] / caps[0], rel=1e-12) + + +@pytest.mark.parametrize("law", ["direction_tied", "distributed"]) +def test_zero_reference_coefficient_with_frictional_loads_later(iea66, law): + """An unloaded reference (zero tension, no clamping) takes the filler + coefficient, here zero; the core--core loads of the later samples carry + friction all the same, normalised by the coefficient of the most loaded + sample.""" + spec = CoreFrictionSpec(mu_core_filler=0.0, mu_core_core=0.2, mu_core_sheath=0.2) + at_zero = build_core_friction(iea66, spec, 0.0) + assert at_zero.population.mu == 0.0 + level = 8.0e4 + at_level = build_core_friction(iea66, spec, level) + kx, ky = _short_walk(17) + kx, ky = kx - kx[0], ky - ky[0] + tension = np.full(kx.size, level) + tension[0] = 0.0 + loads = core_load_history(iea66, at_zero, tension) + assert loads.core_mu_capstan == pytest.approx(at_level.mu_effective, rel=1e-12) + follow = core_friction_history( + at_zero, kx, ky, friction_model=law, loads=loads, nodes_per_pitch=NODES + ) + direct = core_friction_history( + at_level, kx, ky, friction_model=law, nodes_per_pitch=NODES + ) + assert follow.work.friction_J_per_m[-1] > 0.0 + tolerance = 1e-12 if law == "direction_tied" else 2e-3 + scale = _scale(direct) + assert np.max(np.abs(follow.moment_Nm - direct.moment_Nm)) <= tolerance * scale + + +def test_compute_mkappa_core_loads_option(iea66): + kappa, tension = _tension_history(n=300, amplitude=3e-3) + follow = cx.compute_mkappa( + iea66, kappa, contact_tension_history_N=tension, core_friction=SPEC + ) + held = cx.compute_mkappa( + iea66, + kappa, + contact_tension_history_N=tension, + core_friction=SPEC, + core_loads="reference", + ) + assert follow.core_friction.loads is not None and held.core_friction.loads is None + assert "core contact loads follow the tension history" in (follow.provenance.method) + assert "laid-core and profile contact loads follow" in " ".join( + follow.provenance.limitations + ) + assert not np.array_equal(follow.moment_Nm, held.moment_Nm) + # Without a tension history the option changes nothing. + a = cx.compute_mkappa(iea66, kappa, tension_N=T, core_friction=SPEC) + b = cx.compute_mkappa( + iea66, kappa, tension_N=T, core_friction=SPEC, core_loads="reference" + ) + np.testing.assert_array_equal(a.moment_Nm, b.moment_Nm) + with pytest.raises(CableSchemaError, match="core_loads"): + cx.compute_mkappa(iea66, kappa, core_loads="frozen") # type: ignore[arg-type] diff --git a/validation/validation_report.md b/validation/validation_report.md index f9ee5b9..2b4c982 100644 --- a/validation/validation_report.md +++ b/validation/validation_report.md @@ -80,7 +80,7 @@ Every row is computed from published data or closed-form references in this repo ## Test taxonomy (full gate suite) -- analytical_sanity: `1219 passed` +- analytical_sanity: `1245 passed` - independent_method: `77 passed` - full_scale: `58 passed`