diff --git a/CHANGELOG.md b/CHANGELOG.md index bd57c68..0ecb723 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,25 @@ All notable changes to CableXSec are recorded in this file. The format follows ## [Unreleased] +### Added + +- `compute_mkappa` can let the armour contact pressure follow the bending history: + `contact_tension_history_N` sets the per-sample `P1+P2` from a tension history through the + contact model (the histories `compute_fatigue` forms from `tension_N`), and + `contact_pressure_Pa` takes the per-sample `P1+P2` of every structural armour layer. Before, + one bending calculation held one contact pressure. The pressure moves only the friction bound + of each wire's return map, with the slip state carried across, so no material-work term + arises: a falling bound releases the elastic energy `A cos α (c0² − c1²)/(2k)` of a slipping + wire as friction work, and a rising bound leaves a sticking wire unchanged. The stick and + full-slip stiffnesses, the laid-core and ring contact loads and the wire-yield range check + stay at the reference state (the first sample of a tension history). A history equal to the + fixed pressure reproduces the fixed-pressure loop bit for bit, and the result returns the + pressures used (`MkappaResult.contact_pressure_Pa`). New validation row MK-Tcyc: a tension + cycle inside the bending cycles gives the fatigue path's friction stress (3.4e-16 of the + moment) and closes the work balance (1.1e-15 of the friction work). `SectionLaw` and the bending-test simulator keep a + fixed pressure (their leg solver evaluates trial curvatures without a sample time), and so + does the exported bending law. + ### Fixed - The frictional heat of `compute_thermal_fatigue` (`frictional_heat_W_m`, `pi2` and diff --git a/VALIDATION.md b/VALIDATION.md index 202314f..084b3fd 100644 --- a/VALIDATION.md +++ b/VALIDATION.md @@ -40,6 +40,7 @@ afterwards: a comparison that misses its target is reported as failed. | **A11** | Moment–curvature energy closure | loop area against closed form | 0.082 % | <0.1 % | Pass | | **σ_B** | Radial-fibre bending stress | Ménard and Cartraud (2023), Eq. 14 | 0 | <1e-6 % | Pass | | **M-rec, M-rec-3core** | Assembled per-wire moment against the section engine | cross-engine | 0.000 % | <2 % | Pass | +| **MK-Tcyc** | Moment–curvature law with tension cycling inside the bending cycles; work balance under the changing friction bound | fatigue-path friction stress, same kernels | 3.4e-16; 1.1e-15 | <1e-12 | Pass | | **slip-onset** | First wire to slip lies at the neutral axis (compression side, ψ ≈ 3λ/2) | Raoof; Papailiou | \|cos\| = 0.156 | \|cos\| < 0.2 | Pass | | **xsec-K** | Coupling tangent bounds | EI_max, EI_min limits | ≤6.3e-13 % | <0.01 % | Pass | | **QP-KKT, QP-Lamé** | Concentric contact complementarity; shrink-fit compliances | KKT conditions; compound cylinder | 1.9e-13 N; 1.3e-16 | <1e-8 N; <1e-6 | Pass | diff --git a/doc/benchmarks.md b/doc/benchmarks.md index faa158f..42c16a1 100644 --- a/doc/benchmarks.md +++ b/doc/benchmarks.md @@ -136,6 +136,7 @@ All rows are verification, not validation. Source: the scorecard | σ_B | A | Radial-fibre bending stress vs Ménard Eq. 14 | < 1e-6% | 0 | PASS | | M-rec | I | Assembled per-wire moment vs `compute_mkappa`, single core | < 2% | 0.000% | PASS | | M-rec-3core | I | As M-rec, offset-core geometry | < 2% | 0.000% | PASS | +| MK-Tcyc | I | `compute_mkappa` with a contact-tension history cycling inside the bending cycles vs the moment of the fatigue-path friction stress on the same history; work-balance residual over the friction work | < 1e-12 rel.; < 1e-12 rel. | 3.4e-16; 1.1e-15 | PASS | | slip-onset | A | First wire to slip lies at the neutral axis (with the signed bound on the compression side, ψ ≈ 3λ/2) | abs(cos) < 0.2 | 0.156 (0.000 with the former bound) | PASS | | xsec-K | A | Tangent bounds EI_max (κ→0) and EI_min (κ→∞) | < 0.01% | 0; 7.4e-12% | PASS | | QP-KKT | A | Concentric contact complementarity | < 1e-8 N | 1.9e-13 N | PASS | diff --git a/doc/concepts.md b/doc/concepts.md index 53c775d..79d6d08 100644 --- a/doc/concepts.md +++ b/doc/concepts.md @@ -189,8 +189,17 @@ Three contact models turn these loads into pressures: | `"solved"` | elastic contact problem of the whole section, three-core bundles included | `solve_cable_radial_state`; [solved radial contact state](radial_model.md) | On the same cable the models can differ by tens of per cent, as Tutorial 1 -shows. The pressure is held fixed within one bending calculation. In a fatigue -calculation it can follow the tension history. +shows. By default a bending calculation holds the pressure of one contact +state. `compute_mkappa` can let it follow a tension history +(`contact_tension_history_N`) or take a per-sample pressure for each armour +layer (`contact_pressure_Pa`), as a fatigue calculation does with its tension +history. The friction bound of each wire then changes from sample to sample in +the same return map, with the slip state carried across. A falling bound clips +a slipping wire's friction stress, and the released elastic energy is friction +work; a rising bound leaves a sticking wire unchanged. Only the armour bound +follows the history: the stick stiffness, the full-slip stiffness and the +contact loads of the laid cores stay at the reference state. The bending-test +simulator and the exported bending law keep a fixed pressure. ## Fatigue is counted at fixed material points diff --git a/doc/global_local_guide.md b/doc/global_local_guide.md index 45dfc09..46de18e 100644 --- a/doc/global_local_guide.md +++ b/doc/global_local_guide.md @@ -399,6 +399,8 @@ backbone at the midpoint is missed by 3.9 % of the moment range (Ménard; regist Limits. The law is planar. CableXSec's biaxial response is per wire and tied to the current bending direction; a global solver that applies an isotropic hysteretic law to the resultant curvature makes an assumption the section -model does not. Tension and annulus state are fixed within one law. Whether a global program's hysteretic bending option +model does not. Tension and annulus state are fixed within one law; the section law itself can follow a tension +history within a bending cycle (`compute_mkappa(..., contact_tension_history_N=...)`), but the exported law has no +rule yet for its slider states when the tension changes. Whether a global program's hysteretic bending option applies Masing's rules to the exported table is target MX-5, open until checked; CableDyn does not yet have a bending-law interface (its stage 2, Section 7). diff --git a/doc/local_analysis_guide.md b/doc/local_analysis_guide.md index 9855784..8b17792 100644 --- a/doc/local_analysis_guide.md +++ b/doc/local_analysis_guide.md @@ -742,6 +742,28 @@ for state in response.states: - `W_diss_J_per_m` is friction work over the whole supplied history, including conditioning cycles. For closed-cycle loss use `loop.work` and `cablexsec.analysis.curve_comparison.insert_cycle_crossings`. +- The contact pressure is that of one contact state unless a history is + given. `contact_tension_history_N` (one tension per curvature sample) sets + the armour `P1+P2` of every sample through the contact model, the same + histories `compute_fatigue` forms from `tension_N` + (`armour_contact_histories`); `contact_pressure_Pa` takes the per-sample + `P1+P2` of every structural armour layer directly, for example from a + sequence of solved section states. The friction bound of each wire follows + the pressure with the slip state carried across, so a tension cycle inside + the bending cycles gives the same friction stress as the fatigue path + (registered check MK-Tcyc). Only that bound follows: the stick and full-slip + stiffnesses, the laid-core and ring contact loads and the wire-yield range + check use the reference state (the first sample of a tension history). + `loop.contact_pressure_Pa` returns the pressures used. `SectionLaw` and the + bending-test simulator keep a fixed pressure, because their leg solver + evaluates trial curvatures that carry no sample time. + + ```python + t = np.arange(1200) + kappa = 0.03 * np.sin(2 * np.pi * t / 200) + tension = 1e4 + 6e4 * np.sin(np.pi * t / 370) ** 2 # N, within the cycles + loop = cx.compute_mkappa(cable, kappa, contact_tension_history_N=tension) + ``` - `compute_stress` is a monotonic result at one curvature, not a cyclic history. - Offset components (laid power cores) are reported in the three core slip states of Section 13.1: `sigma_stick_*` (core held to the cable axis, diff --git a/src/cablexsec/analysis/beam_test.py b/src/cablexsec/analysis/beam_test.py index af41ac6..e9e2faa 100644 --- a/src/cablexsec/analysis/beam_test.py +++ b/src/cablexsec/analysis/beam_test.py @@ -238,6 +238,14 @@ def from_cable( option) and assembles the moment from the wire stresses in the same way; it substeps internally, 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 + :func:`~cablexsec.api.compute_mkappa` (``contact_pressure_Pa``, + ``contact_tension_history_N``) are not offered: a pressure belongs + to a sample time, and the test solver evaluates every station over + trial curvature histories (a reduced history plus sorted trial + curvatures) that carry no time, so the leg property would not hold. """ require_fully_specified(cable, "SectionLaw.from_cable") require_finite(tension_N, "tension_N") diff --git a/src/cablexsec/api.py b/src/cablexsec/api.py index a99c6d8..a23d0e5 100644 --- a/src/cablexsec/api.py +++ b/src/cablexsec/api.py @@ -463,21 +463,30 @@ class MkappaResult: slip_fraction : numpy.ndarray Fraction of wires slipping at each step. tension_N : float - Axial tension the contact forces were evaluated at [N]. + Axial tension the contact forces were evaluated at [N]; with a + contact-tension history, its first sample (the reference state). provenance : Provenance or None Backing citations/gates and active limitations. work : BendingWork or None Cumulative stored energy, frictional work and incremental work balance. Returned by compute_mkappa; optional only for compatibility with manually - constructed result objects. For this fixed-pressure scalar bending law, - mechanical work between two stations is the stored-energy change plus - the frictional-work increment, including within-step yield transitions. + constructed result objects. For this scalar bending law, mechanical + work between two stations is the stored-energy change plus the + frictional-work increment, including within-step yield transitions. + This holds with a contact-pressure history too: the pressure moves + only the friction bound of the return map, and a bound that falls + below a wire's stress releases stored energy as friction work. core_friction : CoreFrictionHistory or None Core and internal-ring contribution when ``core_friction`` was requested (moments in the material frame, contact loads, ``xi``, effective friction); ``None`` for the armour-only law. When present, ``moment_Nm``, ``work``, ``W_diss_J_per_m`` and ``EI_max_Nm2`` include it; ``slip_fraction`` remains the armour-wire fraction. + contact_pressure_Pa : dict[str, numpy.ndarray] or None + Per-sample friction-setting pressure ``P1+P2`` [Pa] of every + structural armour layer when the pressure followed a history + (``contact_pressure_Pa`` or ``contact_tension_history_N`` of + :func:`compute_mkappa`); ``None`` when it was held fixed. """ kappa_1_m: FloatArray @@ -491,6 +500,7 @@ class MkappaResult: provenance: Provenance | None = None work: BendingWork | None = None core_friction: CoreFrictionHistory | None = None + contact_pressure_Pa: dict[str, FloatArray] | None = None @dataclass(frozen=True) @@ -521,11 +531,22 @@ class _MkappaLaw: progressive: ProgressiveFriction | None core_model: CoreFrictionModel | None - def run(self, kappa: FloatArray) -> _MkappaRun: + def run( + self, + kappa: FloatArray, + contact_pressure_Pa: Sequence[FloatArray] | 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.""" phi_bend = self.phi_bend if self.progressive is None: res = compute_mkappa_wire_slip_front( - self.layers, kappa, phi_bend=phi_bend, EI_min_Nm2=self.ei_min + self.layers, + kappa, + phi_bend=phi_bend, + EI_min_Nm2=self.ei_min, + contact_pressure_Pa=contact_pressure_Pa, ) else: res = compute_mkappa_wire_slip_front( @@ -534,6 +555,7 @@ def run(self, kappa: FloatArray) -> _MkappaRun: phi_bend=phi_bend, EI_min_Nm2=self.ei_min, progressive=self.progressive, + contact_pressure_Pa=contact_pressure_Pa, ) model = self.core_model if model is None: @@ -624,6 +646,8 @@ def compute_mkappa( core_friction: bool | CoreFrictionSpec | None = None, friction_model: Literal["direction_tied", "progressive"] = "direction_tied", progressive: ProgressiveFriction | None = None, + contact_pressure_Pa: Mapping[str, FloatArray] | None = None, + contact_tension_history_N: FloatArray | None = None, ) -> MkappaResult: r"""Moment-curvature hysteresis of a cable over a curvature history. @@ -636,6 +660,21 @@ def compute_mkappa( reaction is not substituted for armour pressure. ``EI_min`` is the individual-component full-slip stiffness. + By default the pressure is that of one contact state, held over the + history. ``contact_tension_history_N`` lets it follow a tension history + (the contact histories of :func:`compute_fatigue` and + :func:`armour_contact_histories`), and ``contact_pressure_Pa`` takes the + per-sample pressure of each armour layer directly. The pressure then + 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). + Parameters ---------- cable : CableData @@ -656,15 +695,17 @@ def compute_mkappa( coupled radial contact solution (concentric and three-core, manufacturing residual wire stress included; doc/radial_model.md). section_state : SectionState, optional - Previously solved normal equilibrium. Its layer moduli, shear support - and contact pressures are held fixed over the supplied bending history. - Do not also supply tension or a conflicting contact model. + Previously solved normal equilibrium. Its layer moduli and shear + support are held fixed over the supplied bending history, and so are + its contact pressures unless ``contact_pressure_Pa`` is given. Do not + also supply tension or a conflicting contact model. radial_state : CableRadialState, optional A solved radial state from :func:`solve_cable_radial_state`, which accepts internal/external or flooded pressure, an end-cap thrust, torque or twist, prescribed axial strain and layer temperatures. Its - face pressures and line loads are held fixed over the bending history. - Do not also supply tension, a section state or another contact model. + face pressures and line loads are held fixed over the bending history + unless ``contact_pressure_Pa`` is given. Do not also supply tension, a + section state or another contact model. core_friction : bool or CoreFrictionSpec, optional Add the stick-slip law of the laid power cores against their neighbours, the filler and the surrounding ring, and of resolved @@ -685,11 +726,42 @@ def compute_mkappa( Settings of the progressive law (density, sub-elements, spread); ``None`` uses :class:`ProgressiveFriction` defaults. Only with ``friction_model="progressive"``. + contact_pressure_Pa : dict[str, numpy.ndarray], optional + Per-sample friction-setting pressure ``P1+P2`` [Pa] of every + structural armour layer, keyed by layer name (all of them), each the + shape of ``kappa_history``, finite and non-negative; for example the + histories of :func:`armour_contact_histories` or of a sequence of + solved section states. The reference state (``tension_N``, + ``section_state`` or ``radial_state``) supplies everything else. A + history equal to the fixed pressure at every sample reproduces the + fixed-pressure result bit for bit. + contact_tension_history_N : numpy.ndarray, optional + Tension history [N] that sets the armour contact pressure at every + sample through the selected contact model, as ``tension_N`` does in + :func:`compute_fatigue`: the bounded chain is affine in tension, the + qp model is solved at every distinct tension, and the solved model is + exact up to 33 distinct tensions and interpolated between 33 exact + solutions beyond. Non-negative, the shape of ``kappa_history``. The + reference state is the first sample; the wire-yield range check uses + the largest tension. Not with ``tension_N``, ``section_state``, + ``radial_state`` or ``contact_pressure_Pa``. Returns ------- MkappaResult + Notes + ----- + Energy under a pressure history: the pressure enters only the friction + bound of each spring-slider, not its stiffness, so no material-work term + arises (``wire_slip_history`` keeps that term for a changing stiffness). + A bound that drops from ``c0`` to ``c1`` below a slipping wire's stress + at fixed curvature releases the stored energy ``A cos a (c0^2 - c1^2) / + (2 k)`` as friction work (``k`` the stick modulus); the reported friction + increment of one such step is ``A cos a c1 (c0 - c1) / k`` and the rest + is the integration remainder of ``work``, which vanishes as the change is + resolved in smaller steps. A rising bound does no work. + References ---------- [Kim2020] (friction stress); [Yun2020] (ξ); [MenardCartraud2023] (Eq. 14); @@ -733,6 +805,30 @@ def compute_mkappa( if friction_model == "progressive" else None ) + tension_history = None + if contact_tension_history_N is not None: + if ( + tension_N != 0 + or section_state is not None + or radial_state is not None + or contact_pressure_Pa is not None + ): + raise CableSchemaError( + "contact_tension_history_N sets the contact state: give it " + "without tension_N, a section or radial state or " + "contact_pressure_Pa" + ) + tension_history = real_array( + contact_tension_history_N, "contact_tension_history_N" + ).astype(np.float64) + require_finite(tension_history, "contact_tension_history_N") + if tension_history.shape != kappa.shape: + raise CableSchemaError( + "contact_tension_history_N must match the kappa_history shape" + ) + if np.any(tension_history < 0.0): + raise CableSchemaError("contact_tension_history_N must be >= 0.") + tension_N = float(tension_history[0]) if radial_state is not None: radial_state.require_cable(cable) if ( @@ -760,6 +856,13 @@ def compute_mkappa( contact_model = contact_model or "bounded" if contact_model not in {"bounded", "qp", "solved"}: raise CableSchemaError("contact_model must be 'bounded', 'qp' or 'solved'.") + # Armour layers in the order of the law's specifications. + names = [layer.name for layer in structural_armour_layers(cable)] + pressure_history: dict[str, FloatArray] | None = None + if contact_pressure_Pa is not None: + pressure_history = _mkappa_pressure_history( + contact_pressure_Pa, names, kappa.shape + ) law = _prepare_mkappa_law( cable, tension_N, @@ -771,6 +874,12 @@ def compute_mkappa( core_spec=resolve_core_friction(core_friction), progressive=progressive_settings, ) + if tension_history is not None: + # pressure only: the crossing loads (unused here) refuse some layer stacks + histories, _ = _contact_histories( + cable, tension_history, contact_model, crossing_loads=False + ) + pressure_history = {name: histories[name] for name in names} # Soft guard: the linear-elastic wire-stress assumption holds below the # armour yield curvature (where the capacity envelope's wire-yield mechanism @@ -778,7 +887,11 @@ def compute_mkappa( try: kappa_yield = wire_yield_curvature( cable, - tension_N if section_state is None else 0.0, + float(np.max(tension_history)) + if tension_history is not None + else tension_N + if section_state is None + else 0.0, mu=mu, section_state=section_state, contact_model=contact_model, @@ -797,7 +910,12 @@ def compute_mkappa( except (ValueError, KeyError): pass # no yield-strength armour: no curvature bound to check - run = law.run(kappa) + run = law.run( + kappa, + None + if pressure_history is None + else [pressure_history[name] for name in names], + ) 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 law_extra = ( @@ -806,6 +924,25 @@ def compute_mkappa( else "; progressive (Iwan) armour friction law, " + progressive_settings.describe() ) + history_extra = ( + "" + if pressure_history is None + else "; the armour contact pressure follows the " + + ( + f"tension history through the {contact_model} contact model" + if tension_history is not None + else "supplied per-sample history" + ) + ) + history_limitations: tuple[str, ...] = ( + () + 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", + ) + ) model = law.core_model if model is None: # Armour-only law: the historical path, bitwise unchanged. @@ -848,11 +985,13 @@ def compute_mkappa( tension_N=tension_N, work=work, core_friction=core_history, + contact_pressure_Pa=pressure_history, provenance=Provenance( method="Papailiou slip-front moment-curvature law of the physical " "wires (slip front from the neutral axis); the armour contact " "pressure combines the manufacturing contact with the applied-tension " f"increment of the {contact_model} contact model" + + history_extra + law_extra + method_extra, citations=( @@ -887,11 +1026,42 @@ def compute_mkappa( "published section results (the radial model notes); the " "three-core state depends on the declared filler representation", *limitations_extra, + *history_limitations, ), ), ) +def _mkappa_pressure_history( + contact_pressure_Pa: Mapping[str, FloatArray], + names: Sequence[str], + shape: tuple[int, ...], +) -> dict[str, FloatArray]: + """Check a per-layer ``P1+P2`` history for :func:`compute_mkappa`.""" + if not isinstance(contact_pressure_Pa, Mapping): + raise CableSchemaError( + "contact_pressure_Pa must map armour layer names to pressure histories" + ) + given, expected = set(contact_pressure_Pa), set(names) + if given != expected: + raise CableSchemaError( + "contact_pressure_Pa must give every structural armour layer " + f"{sorted(expected)}; missing {sorted(expected - given)}, " + f"unknown {sorted(given - expected)}" + ) + out: dict[str, FloatArray] = {} + for name in names: + label = f"contact_pressure_Pa[{name!r}]" + values = real_array(contact_pressure_Pa[name], label).astype(np.float64) + require_finite(values, label) + if values.shape != shape: + raise CableSchemaError(f"{label} must match the kappa_history shape") + if np.any(values < 0.0): + raise CableSchemaError(f"{label} must be >= 0.") + out[name] = values + return out + + def _papailiou_slip_fraction( layers: list[PapailiouLayer], kappa: FloatArray ) -> FloatArray: @@ -2363,7 +2533,7 @@ def _fatigue_from_section_states( def _solved_contact_histories( - cable: CableData, tension: FloatArray + cable: CableData, tension: FloatArray, *, crossing_loads: bool = True ) -> tuple[dict[str, FloatArray], dict[str, FloatArray]]: """Solved radial contact over a tension history. @@ -2372,7 +2542,7 @@ def _solved_contact_histories( 33 equally spaced exact solutions, which is exact except within one grid interval of an active-set change. """ - histories = solved_contact_histories(cable, tension) + histories = solved_contact_histories(cable, tension, crossing_loads=crossing_loads) return histories.pressure_Pa, histories.crossing_line_load_N_per_m @@ -2403,10 +2573,18 @@ def armour_contact_histories( def _contact_histories( - cable: CableData, tension_N: FloatArray, contact_model: str + cable: CableData, + tension_N: FloatArray, + contact_model: str, + *, + crossing_loads: bool = True, ) -> tuple[dict[str, FloatArray], dict[str, FloatArray]]: """Evaluate contact state over a non-negative tension history. + ``crossing_loads=False`` returns the pressures only (an empty force map): + the crossed-wire representation refuses a structural layer with two + crossing interfaces, which the pressure does not need. + The bounded equilibrium chain is affine in tension while its non-negative contacts remain active, so two endpoint solves give the exact history. The QP path is piecewise affine; unique tension states are solved and cached to @@ -2414,13 +2592,21 @@ def _contact_histories( """ tension = np.asarray(tension_N, dtype=np.float64) if contact_model == "solved": - return _solved_contact_histories(cable, tension) + return _solved_contact_histories(cable, tension, crossing_loads=crossing_loads) if contact_model == "bounded": scale = max(float(np.max(tension)), 1.0) p0 = armour_contact_pressure(cable, 0.0, contact_model=contact_model) p1 = armour_contact_pressure(cable, scale, contact_model=contact_model) - f0 = armour_crossing_line_loads(cable, 0.0, contact_model=contact_model) - f1 = armour_crossing_line_loads(cable, scale, contact_model=contact_model) + f0 = ( + armour_crossing_line_loads(cable, 0.0, contact_model=contact_model) + if crossing_loads + else {} + ) + f1 = ( + armour_crossing_line_loads(cable, scale, contact_model=contact_model) + if crossing_loads + else {} + ) pressure = { name: np.asarray(p0[name] + (p1[name] - p0[name]) * tension / scale) for name in p0 @@ -2438,10 +2624,14 @@ def _contact_histories( armour_contact_pressure(cable, float(value), contact_model=contact_model) for value in unique ] - f_values = [ - armour_crossing_line_loads(cable, float(value), contact_model=contact_model) - for value in unique - ] + f_values = ( + [ + armour_crossing_line_loads(cable, float(value), contact_model=contact_model) + for value in unique + ] + if crossing_loads + else [] + ) names = p_values[0].keys() if p_values else () pressure = { name: np.asarray([state[name] for state in p_values], dtype=np.float64)[inverse] diff --git a/src/cablexsec/cable_adapters.py b/src/cablexsec/cable_adapters.py index e5ca20f..1b728c0 100644 --- a/src/cablexsec/cable_adapters.py +++ b/src/cablexsec/cable_adapters.py @@ -909,6 +909,8 @@ class SolvedContactHistories: def solved_contact_histories( cable: CableData, tension_N: FloatArray, + *, + crossing_loads: bool = True, **radial_inputs: Any, ) -> SolvedContactHistories: """Solved radial contact over a tension history. @@ -920,6 +922,9 @@ def solved_contact_histories( moduli, reference temperature) are passed to :func:`~cablexsec.mechanics.radial_cable.solve_cable_radial_states`; with none, every state is :func:`solve_cable_radial_state` at its tension. + ``crossing_loads=False`` skips the crossed-wire line loads (an empty + ``force`` map) for callers that need only the pressure; the crossing + representation refuses some geometries the pressure does not. """ tension = np.asarray(tension_N, dtype=np.float64) unique, inverse = np.unique(tension, return_inverse=True) @@ -936,10 +941,16 @@ def solved_contact_histories( armour_contact_pressure(cable, contact_model="solved", radial_state=state) for state in states ] - f_values = [ - armour_crossing_line_loads(cable, contact_model="solved", radial_state=state) - for state in states - ] + f_values = ( + [ + armour_crossing_line_loads( + cable, contact_model="solved", radial_state=state + ) + for state in states + ] + if crossing_loads + else [] + ) def history(samples: list[float]) -> FloatArray: values = np.asarray(samples, dtype=np.float64) @@ -951,7 +962,8 @@ def history(samples: list[float]) -> FloatArray: name: history([state[name] for state in p_values]) for name in p_values[0] } force = { - name: history([state[name][1] for state in f_values]) for name in f_values[0] + name: history([state[name][1] for state in f_values]) + for name in (f_values[0] if f_values else ()) } stress = { name: history([state.result.wire_stress_Pa[name] for state in states]) diff --git a/src/cablexsec/mechanics/papailiou.py b/src/cablexsec/mechanics/papailiou.py index 1b0a3ab..5d49ced 100644 --- a/src/cablexsec/mechanics/papailiou.py +++ b/src/cablexsec/mechanics/papailiou.py @@ -85,6 +85,7 @@ from __future__ import annotations import math +from collections.abc import Sequence from dataclasses import dataclass from typing import TYPE_CHECKING @@ -575,6 +576,7 @@ def compute_mkappa_wire_slip_front( phi_bend: float = 0.0, EI_min_Nm2: float = 0.0, progressive: ProgressiveFriction | None = None, + contact_pressure_Pa: Sequence[FloatArray | None] | None = None, ) -> PapailiouWireResult: """Integrate one shared Papailiou return map over physical cable wires. @@ -585,18 +587,31 @@ def compute_mkappa_wire_slip_front( ``progressive`` selects the optional progressive (Iwan) law of :mod:`cablexsec.mechanics.progressive_friction`; its slip fraction is the share of slipping sub-elements. ``None`` keeps the default law. + + ``contact_pressure_Pa`` gives, per layer and in the order of ``layers``, + a per-sample friction-setting pressure ``P1+P2`` [Pa] for the return map + (the kernels' ``contact_pressure_Pa``), or ``None`` for the layer's own + fixed ``contact_pressure_Pa``. The pressure moves only the friction bound; + stick stiffness and ``EI_min`` stay those of the layer specifications. + ``None`` for the whole argument keeps the fixed-pressure law. """ kappa = np.asarray(kappa_history, dtype=np.float64) moment = np.zeros(kappa.size, dtype=np.float64) slip_fraction = np.zeros(kappa.size, dtype=np.float64) stored, friction, endpoint, remainder = (np.zeros(kappa.size) for _ in range(4)) total_wires = sum(layer.n_wires for layer in layers) or 1 - for layer in layers: + if contact_pressure_Pa is not None and len(contact_pressure_Pa) != len(layers): + raise CableInputError("one contact-pressure history (or None) per layer") + pressures = ( + [None] * len(layers) if contact_pressure_Pa is None else contact_pressure_Pa + ) + for layer, pressure in zip(layers, pressures, strict=True): if progressive is None: history = wire_slip_history( layer, kappa * math.cos(phi_bend), kappa * math.sin(phi_bend), + contact_pressure_Pa=pressure, initial_bending_angle=phi_bend, ) slipping: FloatArray | NDArray[np.int64] = history.slipping_count @@ -610,6 +625,7 @@ def compute_mkappa_wire_slip_front( kappa * math.cos(phi_bend), kappa * math.sin(phi_bend), progressive=progressive, + contact_pressure_Pa=pressure, initial_bending_angle=phi_bend, ) history = progressive_history diff --git a/tests/test_mkappa_pressure_history.py b/tests/test_mkappa_pressure_history.py new file mode 100644 index 0000000..c518234 --- /dev/null +++ b/tests/test_mkappa_pressure_history.py @@ -0,0 +1,491 @@ +# SPDX-License-Identifier: Apache-2.0 +# Copyright (c) 2026 Jae Hoon Seo, SMI Lab, Inha University +"""``compute_mkappa`` with a contact-pressure or tension history (gap a1). + +The armour friction bound of every wire follows a per-sample ``P1+P2``; the +slip state is carried across the change. Checks: a constant history is the +fixed-pressure law; a pressure step inside stick changes nothing; a pressure +cycle at fixed curvature in full slip dissipates the closed-form work of each +wire and then shakes down; a tension history is the fatigue path's friction +stress (same kernels); per-cycle work in full slip follows the closed form at +every tension and rises with tension. +""" + +from __future__ import annotations + +import math +from typing import Any + +import numpy as np +import pytest + +import cablexsec as cx +from cablexsec.analysis.fatigue import wire_stress_field +from cablexsec.cable_adapters import ( + cable_to_fatigue_layers, + cable_to_mkappa_specs, + structural_armour_layers, +) +from cablexsec.exceptions import ( + CableInputError, + CableSchemaError, + PhysicalRangeError, +) +from cablexsec.mechanics.mkappa import HelicalLayerSpec +from cablexsec.mechanics.papailiou import ( + compute_mkappa_wire_slip_front, + full_slip_curvature, + slip_onset_curvature, +) + +pytestmark = pytest.mark.analytical_sanity + + +@pytest.fixture(scope="module") +def cable() -> Any: + return cx.load_cable(cx.menard2023_yaml_path(), geometry_override=None) + + +def _names(cable: Any) -> list[str]: + return [layer.name for layer in structural_armour_layers(cable)] + + +def _bounds(spec: HelicalLayerSpec, pressure: float) -> tuple[Any, Any]: + """Closed-form Papailiou bounds (upper, lower) at ``phi_bend = 0``. + + ``sigma0 = r P (2 pi r / n) cos a / (A sin^2 a)``, ``psi = asin|cos phi|``, + upper ``sigma0 expm1(lam psi)``, lower ``-sigma0 expm1(-lam psi)``. + """ + sin_a = abs(math.sin(spec.lay_angle_rad)) + width = 2.0 * math.pi * spec.r_helix_m / spec.n_wires + sigma0 = ( + spec.r_helix_m + * pressure + * width + * math.cos(spec.lay_angle_rad) + / (spec.A_wire_m2 * sin_a**2) + ) + psi = np.arcsin(np.clip(np.abs(np.cos(spec.phi_wires)), 0.0, 1.0)) + lam = spec.mu * sin_a + return sigma0 * np.expm1(lam * psi), -sigma0 * np.expm1(-lam * psi) + + +def _weight(spec: HelicalLayerSpec) -> float: + return spec.A_wire_m2 * math.cos(spec.lay_angle_rad) + + +# --------------------------------------------------------------------------- # +# Constant history # +# --------------------------------------------------------------------------- # +@pytest.mark.parametrize("friction_model", ["direction_tied", "progressive"]) +def test_constant_pressure_history_is_the_fixed_pressure_law( + cable: Any, friction_model: Any +) -> None: + """The same return map with the same pressure: identical arithmetic.""" + tension = 2.0e4 + kappa = 0.04 * np.sin(np.linspace(0.0, 4.0 * np.pi, 301)) + specs = cable_to_mkappa_specs(cable, tension) + pressure = { + name: np.full(kappa.size, spec.contact_pressure_Pa) + for name, spec in zip(_names(cable), specs, strict=True) + } + ref = cx.compute_mkappa( + cable, kappa, tension_N=tension, friction_model=friction_model + ) + got = cx.compute_mkappa( + cable, + kappa, + tension_N=tension, + friction_model=friction_model, + contact_pressure_Pa=pressure, + ) + assert np.array_equal(got.moment_Nm, ref.moment_Nm) + assert np.array_equal(got.slip_fraction, ref.slip_fraction) + assert got.work is not None and ref.work is not None + assert np.array_equal(got.work.friction_J_per_m, ref.work.friction_J_per_m) + assert np.array_equal(got.work.stored_J_per_m, ref.work.stored_J_per_m) + assert got.W_diss_J_per_m == ref.W_diss_J_per_m + assert ref.contact_pressure_Pa is None + assert got.contact_pressure_Pa is not None + assert set(got.contact_pressure_Pa) == set(_names(cable)) + assert got.provenance is not None + assert "supplied per-sample history" in got.provenance.method + assert any("reference state" in text for text in got.provenance.limitations) + + +def test_constant_tension_history_is_the_fixed_tension_law(cable: Any) -> None: + tension = 3.0e4 + kappa = 0.04 * np.sin(np.linspace(0.0, 4.0 * np.pi, 301)) + ref = cx.compute_mkappa(cable, kappa, tension_N=tension) + got = cx.compute_mkappa( + cable, kappa, contact_tension_history_N=np.full(kappa.size, tension) + ) + scale = float(np.max(np.abs(ref.moment_Nm))) + np.testing.assert_allclose(got.moment_Nm, ref.moment_Nm, rtol=0, atol=1e-12 * scale) + assert got.tension_N == tension + assert got.provenance is not None + assert "tension history through the bounded" in got.provenance.method + + +def _touching_alternate_wires() -> Any: + """Three touching structural armour layers laid alternately: the middle one + has two crossing interfaces, which the crossed-wire line loads refuse.""" + from cablexsec.cables.schema import CableData, CableMeta, HelicalLayer + + layers = tuple( + HelicalLayer( + name=f"wire-{i}", + material="galvanised_steel_armour", + n_wires=12 * (i + 1), + d_wire_m=0.002, + r_helix_m=0.02 + 0.002 * i, + lay_angle_deg=20 + 10 * i, + lay_direction="left_hand" if i == 1 else "right_hand", + ) + for i in range(3) + ) + return CableData(cable=CableMeta(name="touching alternate wires"), layers=layers) + + +def test_tension_history_on_a_stack_the_crossing_loads_refuse() -> None: + # Bounded contact: the qp and solved models do not solve this sheath-free + # synthetic section reliably even at a fixed tension (singular on some + # platforms); the next test covers them on a real cable. + cable = _touching_alternate_wires() + with pytest.raises(CableSchemaError): + cx.armour_contact_histories(cable, np.array([1.0e4])) + tension = 1.0e4 + kappa = 0.05 * np.sin(np.linspace(0.0, 4.0 * np.pi, 121)) + ref = cx.compute_mkappa(cable, kappa, tension_N=tension) + got = cx.compute_mkappa( + cable, kappa, contact_tension_history_N=np.full(kappa.size, tension) + ) + scale = float(np.max(np.abs(ref.moment_Nm))) + np.testing.assert_allclose(got.moment_Nm, ref.moment_Nm, rtol=0, atol=1e-12 * scale) + + +@pytest.mark.parametrize("contact_model", ["bounded", "qp", "solved"]) +def test_tension_history_never_forms_crossing_loads( + contact_model: str, monkeypatch: pytest.MonkeyPatch +) -> None: + import cablexsec.api as api_module + import cablexsec.cable_adapters as adapters + + # concentric, so the coupled radial contact of qp applies + cable = cx.load_cable( + cx.inter_array_single_core_yaml_path(), geometry_override=None + ) + tension = 2.0e4 + kappa = 0.03 * np.sin(np.linspace(0.0, 4.0 * np.pi, 61)) + ref = cx.compute_mkappa( + cable, kappa, tension_N=tension, contact_model=contact_model + ) + + def refuse(*args: Any, **kwargs: Any) -> Any: + raise AssertionError("crossing loads formed on the bending route") + + monkeypatch.setattr(api_module, "armour_crossing_line_loads", refuse) + monkeypatch.setattr(adapters, "armour_crossing_line_loads", refuse) + got = cx.compute_mkappa( + cable, + kappa, + contact_tension_history_N=np.full(kappa.size, tension), + contact_model=contact_model, + ) + scale = float(np.max(np.abs(ref.moment_Nm))) + np.testing.assert_allclose(got.moment_Nm, ref.moment_Nm, rtol=0, atol=1e-12 * scale) + + +def test_core_friction_keeps_its_reference_loads(cable: Any) -> None: + """With laid-core friction only the armour bound follows the history.""" + tension = 2.0e4 + kappa = 0.03 * np.sin(np.linspace(0.0, 4.0 * np.pi, 201)) + specs = cable_to_mkappa_specs(cable, tension) + pressure = { + name: np.full(kappa.size, spec.contact_pressure_Pa) + for name, spec in zip(_names(cable), specs, strict=True) + } + ref = cx.compute_mkappa(cable, kappa, tension_N=tension, core_friction=True) + got = cx.compute_mkappa( + cable, + kappa, + tension_N=tension, + core_friction=True, + contact_pressure_Pa=pressure, + ) + assert np.array_equal(got.moment_Nm, ref.moment_Nm) + assert got.core_friction is not None and ref.core_friction is not None + assert np.array_equal(got.core_friction.moment_Nm, ref.core_friction.moment_Nm) + + +# --------------------------------------------------------------------------- # +# Pressure changes # +# --------------------------------------------------------------------------- # +def test_pressure_steps_inside_stick_change_nothing(cable: Any) -> None: + """Below every wire's slip onset at the lowest pressure the stress is the + trial stress, whatever the bound: moment and work are unchanged.""" + tension = 2.0e4 + specs = cable_to_mkappa_specs(cable, tension) + # Half the compression-side onset (factor <= 1) at the lowest pressure. + onset = min(slip_onset_curvature(spec) for spec in specs) + low, high = 0.6, 1.7 + amplitude = 0.4 * low * onset + kappa = amplitude * np.sin(np.linspace(0.0, 6.0 * np.pi, 601)) + factor = np.ones(kappa.size) + factor[97:233] = high + factor[233:410] = low + factor[410:] = 1.3 + pressure = { + name: factor * spec.contact_pressure_Pa + for name, spec in zip(_names(cable), specs, strict=True) + } + ref = cx.compute_mkappa(cable, kappa, tension_N=tension) + got = cx.compute_mkappa( + cable, kappa, tension_N=tension, contact_pressure_Pa=pressure + ) + assert ref.work is not None and got.work is not None + assert float(np.max(ref.slip_fraction)) == 0.0 + assert float(np.max(got.slip_fraction)) == 0.0 + scale = float(np.max(np.abs(ref.moment_Nm))) + np.testing.assert_allclose(got.moment_Nm, ref.moment_Nm, rtol=0, atol=1e-12 * scale) + assert float(np.max(np.abs(got.work.friction_J_per_m))) == 0.0 + + +@pytest.mark.parametrize("steps", [1, 400]) +def test_pressure_cycle_at_fixed_curvature_in_full_slip(cable: Any, steps: int) -> None: + """Hand calculation per wire. At ``kappa_h = 4 max kappa_fs`` every wire + sits at its bound ``c0``. Lowering the pressure to ``r P0`` in ``n`` equal + steps clips it to ``c1 = r c0``; each step releases stored energy as + friction work, ``w (c0^2 - c1^2) / (2 k)`` in total, of which the + backward-Euler friction increment is all but ``w (c0 - c1)^2 / (2 k n)`` + (integration remainder). Raising it back, and a second cycle to a higher + pressure than ``r P0``, leave every wire inside its bound: no more work + (shakedown).""" + tension = 2.0e4 + specs = cable_to_mkappa_specs(cable, tension) + names = _names(cable) + kappa_h = 4.0 * max(full_slip_curvature(spec) for spec in specs) + ramp, hold = 200, steps + 300 + kappa = np.concatenate([np.linspace(0.0, kappa_h, ramp), np.full(hold, kappa_h)]) + ratio = 0.55 + factor = np.ones(kappa.size) + start = ramp + 50 + factor[start : start + steps] = ( + 1.0 - (1.0 - ratio) * np.arange(1, steps + 1) / steps + ) + end = start + steps + factor[end : end + 50] = ratio + factor[end + 50 : end + 100] = 1.0 + factor[end + 100 : end + 150] = ratio + 0.15 + factor[end + 150 :] = 1.0 + pressure = { + name: factor * spec.contact_pressure_Pa + for name, spec in zip(names, specs, strict=True) + } + res = cx.compute_mkappa( + cable, kappa, tension_N=tension, contact_pressure_Pa=pressure + ) + assert res.work is not None + friction = res.work.friction_J_per_m + remainder = res.work.integration_remainder_J_per_m + released = drop = 0.0 + for spec in specs: + upper0, lower0 = _bounds(spec, spec.contact_pressure_Pa) + c0 = np.where(np.cos(spec.phi_wires) >= 0.0, upper0, lower0) + c1 = ratio * c0 + w, k = _weight(spec), spec.k_f + released += w * float(np.sum(c0**2 - c1**2)) / (2.0 * k) + drop += w * float(np.sum((c0 - c1) ** 2)) / (2.0 * k * steps) + dw = friction[-1] - friction[start - 1] + dr = remainder[-1] - remainder[start - 1] + assert dw > 0.0 + assert dw == pytest.approx(released - drop, rel=1e-12) + assert dw + dr == pytest.approx(released, rel=1e-12) + # No work after the pressure drop: the rise and the second cycle stick. + np.testing.assert_allclose(friction[end:], friction[end - 1], rtol=1e-14) + # Stored energy follows the bound; the work balance closes. + stored = res.work.stored_J_per_m + assert stored[start - 1] - stored[end - 1] == pytest.approx(released, rel=1e-12) + balance = res.work.balance_residual_J_per_m + assert float(np.max(np.abs(balance))) <= 1e-12 * float(np.max(stored)) + + +# --------------------------------------------------------------------------- # +# Tension history against the fatigue path # +# --------------------------------------------------------------------------- # +def _fatigue_path_moment( + cable: Any, + kappa: Any, + tension: Any, + ei_min: float, + friction_model: str = "direction_tied", +) -> Any: + """Armour moment from the fatigue path's friction stress, same history.""" + pressure, _ = cx.armour_contact_histories(cable, tension) + layers = cable_to_fatigue_layers(cable, contact_tension_N=float(tension[0])) + moment = ei_min * kappa + zero = np.zeros_like(kappa) + for layer in layers: + field = wire_stress_field( + layer, + kappa, + zero, + contact_pressure_Pa=pressure[layer.name], + friction_model=friction_model, # type: ignore[arg-type] + keep_friction=True, + ) + assert field.friction_Pa is not None + spec = layer.spec + lever = _weight(spec) * spec.r_helix_m * np.cos(spec.phi_wires) + moment = moment + lever @ field.friction_Pa + return moment + + +@pytest.mark.parametrize("friction_model", ["direction_tied", "progressive"]) +def test_tension_cycle_within_bending_cycles_is_the_fatigue_path( + cable: Any, friction_model: str +) -> None: + """Tension cycling at an incommensurate period inside the bending cycles: + the M-kappa law and the fatigue friction stress are the same kernels + (an identity; the fatigue path may use the compiled recursion).""" + t = np.arange(1200) + kappa = 0.03 * np.sin(2.0 * np.pi * t / 200.0) + tension = 1.0e4 + 6.0e4 * np.sin(np.pi * t / 370.0) ** 2 + res = cx.compute_mkappa( + cable, + kappa, + contact_tension_history_N=tension, + friction_model=friction_model, # type: ignore[arg-type] + ) + expected = _fatigue_path_moment( + cable, kappa, tension, res.EI_min_Nm2, friction_model + ) + scale = float(np.max(np.abs(expected))) + np.testing.assert_allclose(res.moment_Nm, expected, rtol=0, atol=1e-12 * scale) + assert res.work is not None + # Friction work never decreases; the work balance closes. + assert float(np.min(np.diff(res.work.friction_J_per_m))) >= 0.0 + balance = res.work.balance_residual_J_per_m + stored = res.work.stored_J_per_m + assert float(np.max(np.abs(balance))) <= 1e-12 * float(np.max(stored)) + # The pressure is the fatigue path's contact history. + pressure, _ = cx.armour_contact_histories(cable, tension) + assert res.contact_pressure_Pa is not None + for name, values in res.contact_pressure_Pa.items(): + assert np.array_equal(values, pressure[name]) + + +def test_full_slip_cycle_work_follows_tension(cable: Any) -> None: + """Stepped tension, two bending cycles per level, each step one sample + after the positive extreme. In full slip a cycle drives every wire between ``+upper`` and + ``-lower`` of the current pressure, so the second cycle at a level does + the closed-form work ``sum w s (2 r |cos phi| kappa_a - s / k)``, + ``s = upper + lower``, whatever came before: equal on the rising and the + falling leg, increasing with tension while ``s < k r |cos phi| kappa_a``. + The history is also the fatigue path's.""" + levels = [0.0, 2.0e4, 4.0e4, 8.0e4, 4.0e4, 2.0e4, 0.0] + specs_hi = cable_to_mkappa_specs(cable, max(levels)) + kappa_a = 3.0 * max(full_slip_curvature(spec) for spec in specs_hi) + n = 400 + cycle = kappa_a * np.cos(2.0 * np.pi * np.arange(n) / n) + # Load from zero to the first extreme, then whole cycles per level. + lead = np.linspace(0.0, kappa_a, 101)[:-1] + kappa = np.concatenate([lead, np.tile(cycle, 2 * len(levels)), [kappa_a]]) + # A level holds from one sample after its first extreme to its last. + tension = np.concatenate( + [np.full(lead.size + 1, levels[0])] + + [np.full(2 * n, level) for level in levels] + ) + res = cx.compute_mkappa(cable, kappa, contact_tension_history_N=tension) + assert res.work is not None and res.contact_pressure_Pa is not None + friction = res.work.friction_J_per_m + names = _names(cable) + works = [] + for index, level in enumerate(levels): + first = lead.size + (2 * index + 1) * n # start of the second cycle + last = first + n # back at the positive extreme + work = friction[last] - friction[first] + works.append(work) + expected = 0.0 + for name, spec in zip(names, cable_to_mkappa_specs(cable, level), strict=True): + p = float(res.contact_pressure_Pa[name][first]) + assert p == pytest.approx(spec.contact_pressure_Pa, rel=1e-12) + upper, lower = _bounds(spec, p) + s = upper + lower + drive = spec.r_helix_m * np.abs(np.cos(spec.phi_wires)) * kappa_a + assert np.all(s < spec.k_f * drive) # rising part of s (2D - s/k) + expected += _weight(spec) * float(np.sum(s * (2.0 * drive - s / spec.k_f))) + assert work == pytest.approx(expected, rel=1e-10) + assert works[0] < works[1] < works[2] < works[3] + assert works[3] > works[4] > works[5] > works[6] + for rising, falling in ((0, 6), (1, 5), (2, 4)): + assert works[rising] == pytest.approx(works[falling], rel=1e-12) + expected_moment = _fatigue_path_moment(cable, kappa, tension, res.EI_min_Nm2) + scale = float(np.max(np.abs(expected_moment))) + np.testing.assert_allclose( + res.moment_Nm, expected_moment, rtol=0, atol=1e-12 * scale + ) + + +# --------------------------------------------------------------------------- # +# Inputs # +# --------------------------------------------------------------------------- # +def test_pressure_history_inputs_are_checked(cable: Any) -> None: + kappa = np.linspace(0.0, 0.01, 11) + names = _names(cable) + good = {name: np.full(kappa.size, 1.0e6) for name in names} + with pytest.raises(CableSchemaError, match="every structural armour layer"): + cx.compute_mkappa(cable, kappa, contact_pressure_Pa={names[0]: good[names[0]]}) + with pytest.raises(CableSchemaError, match="unknown"): + cx.compute_mkappa( + cable, kappa, contact_pressure_Pa={**good, "sheath": good[names[0]]} + ) + with pytest.raises(CableSchemaError, match="must map"): + cx.compute_mkappa(cable, kappa, contact_pressure_Pa=[1.0]) # type: ignore[arg-type] + for bad, error, match in ( + (np.full(kappa.size - 1, 1.0e6), CableSchemaError, "shape"), + (np.full(kappa.size, -1.0), CableSchemaError, ">= 0"), + (np.full(kappa.size, np.nan), PhysicalRangeError, "finite"), + ): + with pytest.raises(error, match=match): + cx.compute_mkappa(cable, kappa, contact_pressure_Pa={**good, names[0]: bad}) + + +def test_tension_history_inputs_are_checked(cable: Any) -> None: + kappa = np.linspace(0.0, 0.01, 11) + tension = np.full(kappa.size, 1.0e4) + names = _names(cable) + pressure = {name: np.full(kappa.size, 1.0e6) for name in names} + for extra in ( + {"tension_N": 1.0e4}, + {"contact_pressure_Pa": pressure}, + {"section_state": object()}, + {"radial_state": object()}, + ): + with pytest.raises(CableSchemaError, match="sets the contact state"): + cx.compute_mkappa( + cable, + kappa, + contact_tension_history_N=tension, + **extra, # type: ignore[arg-type] + ) + with pytest.raises(CableSchemaError, match="shape"): + cx.compute_mkappa(cable, kappa, contact_tension_history_N=tension[:-1]) + with pytest.raises(CableSchemaError, match=">= 0"): + cx.compute_mkappa(cable, kappa, contact_tension_history_N=-tension) + with pytest.raises(PhysicalRangeError, match="finite"): + cx.compute_mkappa( + cable, kappa, contact_tension_history_N=np.full(kappa.size, np.inf) + ) + + +def test_kernel_needs_one_pressure_entry_per_layer(cable: Any) -> None: + specs = cable_to_mkappa_specs(cable, 0.0) + kappa = np.linspace(0.0, 0.01, 5) + with pytest.raises(CableInputError, match="per layer"): + compute_mkappa_wire_slip_front(specs, kappa, contact_pressure_Pa=[None]) + mixed = compute_mkappa_wire_slip_front( + specs, kappa, contact_pressure_Pa=[None] * len(specs) + ) + plain = compute_mkappa_wire_slip_front(specs, kappa) + assert np.array_equal(mixed.moment_Nm, plain.moment_Nm) diff --git a/validation/scripts/run_validation.py b/validation/scripts/run_validation.py index 7772d9a..622ab49 100644 --- a/validation/scripts/run_validation.py +++ b/validation/scripts/run_validation.py @@ -680,6 +680,52 @@ def _torque_rows() -> list[Row]: ] +def _mkappa_tension_cycle(cable: CableData) -> tuple[float, float]: + """Tension cycling inside the bending cycles: the M-kappa law against + the fatigue path (gap a1). + + Bending at +-0.03 1/m (200 samples per cycle) on the Menard cable with + the tension 10 + 60 sin^2(pi t / 370) kN, incommensurate with the + bending. Returns the largest moment difference over the largest moment + and the largest work-balance residual over the total friction work. + """ + from cablexsec.analysis.fatigue import wire_stress_field # noqa: PLC0415 + from cablexsec.cable_adapters import cable_to_fatigue_layers # noqa: PLC0415 + + t = np.arange(1200) + kappa = 0.03 * np.sin(2.0 * np.pi * t / 200.0) + tension = 1.0e4 + 6.0e4 * np.sin(np.pi * t / 370.0) ** 2 + result = cx.compute_mkappa(cable, kappa, contact_tension_history_N=tension) + pressure, _ = cx.armour_contact_histories(cable, tension) + moment = result.EI_min_Nm2 * kappa + for layer in cable_to_fatigue_layers(cable, contact_tension_N=float(tension[0])): + friction = wire_stress_field( + layer, + kappa, + np.zeros_like(kappa), + contact_pressure_Pa=pressure[layer.name], + keep_friction=True, + ).friction_Pa + assert friction is not None + spec = layer.spec + lever = ( + spec.A_wire_m2 + * math.cos(spec.lay_angle_rad) + * spec.r_helix_m + * np.cos(spec.phi_wires) + ) + moment = moment + lever @ friction + deviation = float( + np.max(np.abs(result.moment_Nm - moment)) / np.max(np.abs(moment)) + ) + assert result.work is not None + balance = float( + np.max(np.abs(result.work.balance_residual_J_per_m)) + / result.work.friction_J_per_m[-1] + ) + return deviation, balance + + def _rows() -> list[Row]: rows: list[Row] = _normal_state_rows() menard = cx.load_cable(cx.menard2023_yaml_path(), geometry_override=None) @@ -977,6 +1023,25 @@ def _rows() -> list[Row]: ) ) + # Tension cycling within the bending cycles: compute_mkappa with a + # contact-tension history against the moment assembled from the fatigue + # path's friction stress on the same tension history (the same kernels; + # the fatigue path may use the compiled recursion), and the incremental + # work balance under the changing friction bound. + mk_dev, mk_balance = _mkappa_tension_cycle(menard) + rows.append( + Row( + "1", + "MK-Tcyc", + "compute_mkappa with a tension history cycling within the bending " + "cycles vs the fatigue-path friction stress on the same history; " + "work balance under the changing friction bound", + "< 1e-12 relative; < 1e-12 relative", + f"{mk_dev:.1e}; {mk_balance:.1e}", + "PASS" if mk_dev < 1e-12 and mk_balance < 1e-12 else "FAIL", + ) + ) + # GATE B (distinguishing physics): slip starts at the NEUTRAL AXIS, per the # Raoof (1989b,1992) strain-gauge observation and Papailiou — not the extreme # fibre (which the retired Coulomb loop predicts). The first-to-slip wire's diff --git a/validation/validation_report.md b/validation/validation_report.md index a8f077c..cc39e70 100644 --- a/validation/validation_report.md +++ b/validation/validation_report.md @@ -25,6 +25,7 @@ Every row is computed from published data or closed-form references in this repo | 1 | σ_B | Radial-fibre bending vs Ménard Eq. 14 (φ=0 from extension side) | < 1e-6% | 0.00e+00% | PASS | | 1 | M-rec | Assembled per-wire moment vs compute_mkappa (cross-engine, single-core) | < 2% | 0.000% | PASS | | 1 | M-rec-3core | Cross-engine moment vs compute_mkappa with offset-core geometry and shared mean armour pressure | < 2% | 0.000% | PASS | +| 1 | MK-Tcyc | compute_mkappa with a tension history cycling within the bending cycles vs the fatigue-path friction stress on the same history; work balance under the changing friction bound | < 1e-12 relative; < 1e-12 relative | 3.4e-16; 1.1e-15 | PASS | | 1 | slip-onset | First-to-slip wire at the neutral axis (|cos| → 0, compression side at psi ≈ 3 lam/2; Raoof/Papailiou, not extreme-fibre loop) | |cos| < 0.2 | |cos|=0.156 | PASS | | 1 | xsec-K | Coupling tangent bounds (κ→0=EI_max, κ→∞=EI_min); slip-front local slope | < 0.01% | κ0:3.16e-14% / κ∞:5.99e-13% | PASS | | 1 | QP-KKT | Concentric contact max|normal line force times gap| (common extension, twist and radial equilibrium) | < 1e-8 N | 1.9e-13 (q>=0: True) | PASS | @@ -60,9 +61,9 @@ Every row is computed from published data or closed-form references in this repo ## Test taxonomy (full gate suite) -- analytical_sanity: `1035 passed, 3111 deselected` -- independent_method: `70 passed, 4076 deselected` -- full_scale: `27 passed, 4119 deselected` +- analytical_sanity: `1052 passed, 3111 deselected` +- independent_method: `70 passed, 4093 deselected` +- full_scale: `27 passed, 4136 deselected` Run `pytest -m ` to reproduce each group.