From 0ac685a077793fea9c71d190781e2af5ac77c605 Mon Sep 17 00:00:00 2001 From: Jae Hoon Seo Date: Thu, 19 Nov 2026 20:43:41 +0900 Subject: [PATCH 1/2] fix: an interface is open when its contact carries no line force The how-to recipe and the coiling check counted a radial-section interface as open when its reported gap exceeded 1e-9 m. A closed contact reports the round-off of the linear solve as its gap: on the 66 kV template at 100 kN and a sealed 2 MPa, about 1.5e-10 m on two interfaces carrying 1.1 MN/m, within the contact solver's own complementarity tolerance in metres (1e-8 of the scaled problem times the square root of the contact flexibility, 2e-10 to 4e-10 m there). macOS runs crossed 1e-9 m and printed "open gaps 1" against the page's 0 (CI runs 44493046003 and 44286053398). The open or closed state is now the contact solver's decision, an exactly zero reaction: RadialSectionResult.interface_open and open_interfaces. The recipe and coiling use them; interface_gap_m keeps the reported gaps. Signed-off-by: Jae Hoon Seo --- CHANGELOG.md | 8 +++ doc/howto.md | 5 +- doc/howto/scripts/howto_02_contact_state.py | 4 +- src/cablexsec/analysis/coiling.py | 15 ++---- src/cablexsec/mechanics/radial_solution.py | 27 ++++++++++ tests/test_open_interfaces.py | 59 +++++++++++++++++++++ 6 files changed, 102 insertions(+), 16 deletions(-) create mode 100644 tests/test_open_interfaces.py diff --git a/CHANGELOG.md b/CHANGELOG.md index 68daa36..e9b4c9c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -484,6 +484,14 @@ All notable changes to CableXSec are recorded in this file. The format follows the next free slots, and a worker without a free slot or a writable folder gets a temporary cache. Results are unchanged, and runs go to whichever worker is free, as before. +- An interface of the radial section is open when its contact carries no line force, as the + contact solver decides it (`RadialSectionResult.interface_open`, `open_interfaces`); the + how-to recipe and the coiling check counted gaps above 1e-9 m. A closed contact reports + the round-off of the linear solve as its gap: about 1.5e-10 m on two interfaces carrying + 1.1 MN/m of the 66 kV template at 100 kN and a sealed 2 MPa, within the solver's own + complementarity tolerance in metres (2e-10 to 4e-10 m there). macOS runs crossed 1e-9 m and + printed "open gaps 1" against the page's 0. + - `SectionLaw.from_cable` reads the cable's own materials (its `materials:` block) when the law is built and every time it is evaluated. Outside `simulate_bending_test` it read the library instead, and a layer whose material the library lacks silently dropped out of the stiffness diff --git a/doc/howto.md b/doc/howto.md index c77f08b..f41b6cf 100644 --- a/doc/howto.md +++ b/doc/howto.md @@ -89,7 +89,10 @@ twist free: strain 378 ue, twist 6.91 mrad/m, torque 0.0 N m ``` `solve_cable_radial_state` takes trefoil cores and the declared manufacturing -clamping. Here the external pressure acts on the outer sheath with the +clamping. An interface is open when its contact carries no line force +(`result.open_interfaces`), as the contact solver decides it: the reported gap +of a closed contact is the round-off of the linear solve (about 1e-10 m here), +not a measure of openness. Here the external pressure acts on the outer sheath with the {term}`annulus` sealed; `flooded_pressure_Pa` floods it. `solve_contact_qp` and `solve_concentric_section` accept concentric layers only and leave out the {term}`manufacturing clamping`. All three solve a state of tension, twist, diff --git a/doc/howto/scripts/howto_02_contact_state.py b/doc/howto/scripts/howto_02_contact_state.py index ad2c974..a08da3d 100644 --- a/doc/howto/scripts/howto_02_contact_state.py +++ b/doc/howto/scripts/howto_02_contact_state.py @@ -10,8 +10,6 @@ import math -import numpy as np - import cablexsec as cx # 1. Full cable, trefoil cores included: tension and external pressure. @@ -23,7 +21,7 @@ print( f"T {tension / 1e3:.0f} kN, sealed p_ext {pressure / 1e6:.0f} MPa: " f"strain {state.result.axial_strain * 1e6:.0f} ue, " - f"open gaps {int(np.count_nonzero(state.result.interface_gap_m > 1e-9))}" + f"open gaps {len(state.result.open_interfaces)}" ) for name in contact: print( diff --git a/src/cablexsec/analysis/coiling.py b/src/cablexsec/analysis/coiling.py index 4afa393..9b24030 100644 --- a/src/cablexsec/analysis/coiling.py +++ b/src/cablexsec/analysis/coiling.py @@ -126,9 +126,6 @@ #: and screens lie at 10-50 deg. NEAR_HOOP_LAY_ANGLE_DEG = 75.0 -#: Gap [m] above which a contact of the twisted section counts as open. -OPEN_GAP_M = 1.0e-9 - _PROVENANCE = Provenance( method="coiling: twisted radial-axial-torsional section (free axial) with " "rotating bending, slip-front friction and local wire bending on fixed fibres; " @@ -509,15 +506,9 @@ def compute_coiling( ) else: layers_out[layer.name] = replace(partial, utilisation=buckling) - # A contact that carries a load reports a gap of round-off size (1e-18 to - # 1e-15 m); an open one a gap of a solved size (0.1 mm and more here). - open_ifaces = tuple( - "/".join(name) - for name, gap in zip( - result.interface_names, result.interface_gap_m, strict=True - ) - if gap > OPEN_GAP_M - ) + # Open or closed as the contact solver decides it (no line force), not by + # the reported gap, whose round-off follows the linear algebra. + open_ifaces = tuple("/".join(name) for name in result.open_interfaces) from cablexsec.analysis.components import ( # noqa: PLC0415 capacity_utilisation, compute_component_response, diff --git a/src/cablexsec/mechanics/radial_solution.py b/src/cablexsec/mechanics/radial_solution.py index 60068da..ccf3d30 100644 --- a/src/cablexsec/mechanics/radial_solution.py +++ b/src/cablexsec/mechanics/radial_solution.py @@ -275,6 +275,33 @@ def p1_plus_p2(self, name: str) -> float: inner, outer = self.helical_face_pressure_Pa[name] return inner + outer + @property + def interface_open(self) -> NDArray[np.bool_]: + """Whether each interface is open: its contact carries no line force. + + The contact solver decides it (the complementarity of + :func:`solve_lcp`): an open contact has exactly zero reaction, a + closed one a positive line force. The reported gap of a closed + contact is the round-off of the linear solve, of the order of the + solver's complementarity tolerance in metres, ``1e-8`` of the scaled + problem times the square root of the contact flexibility (1e-10 to + 4e-10 m on the 66 kV template), and it moves with the platform's + linear algebra; so a gap threshold would classify a closed contact by + its noise. ``interface_gap_m`` keeps the reported gaps. + """ + return np.asarray(self.interface_line_force_N_per_m <= 0.0) + + @property + def open_interfaces(self) -> tuple[tuple[str, str], ...]: + """Names of the open interfaces (:attr:`interface_open`).""" + return tuple( + name + for name, is_open in zip( + self.interface_names, self.interface_open, strict=True + ) + if is_open + ) + class RadialSection: """Assembled section; solve repeatedly for different load states. diff --git a/tests/test_open_interfaces.py b/tests/test_open_interfaces.py new file mode 100644 index 0000000..b8a4da3 --- /dev/null +++ b/tests/test_open_interfaces.py @@ -0,0 +1,59 @@ +# SPDX-License-Identifier: Apache-2.0 +# Copyright (c) 2026 Jae Hoon Seo, SMI Lab, Inha University +"""Open and closed contacts of the radial section, as the solver decides them. + +The how-to recipe counted gaps above 1e-9 m as open. A closed contact reports +a gap that is the round-off of the linear solve: on the 66 kV template at +100 kN and a sealed 2 MPa it is about 1.5e-10 m on two interfaces that carry +1.1 MN/m, within the solver's own complementarity tolerance in metres +(1e-8 of the scaled problem times the square root of the contact +flexibility: 2e-10 to 4e-10 m here) and close enough to 1e-9 m that another +platform's linear algebra crossed it (one macOS run printed "open gaps 1"). +""" + +from __future__ import annotations + +import numpy as np +import pytest + +import cablexsec as cx + + +@pytest.fixture(scope="module") +def states(): + cable = cx.load_cable(cx.iea_task49_66kv_yaml_path()) + return { + p: cx.solve_cable_radial_state(cable, 100e3, external_pressure_Pa=p).result + for p in (0.0, 2e6) + } + + +def test_closed_contacts_are_closed_whatever_their_round_off_gap(states): + closed = states[2e6] + assert closed.open_interfaces == () + assert not closed.interface_open.any() + # Their reported gaps are round-off, of either sign, not zero. + assert 1e-12 < float(np.max(np.abs(closed.interface_gap_m))) < 1e-9 + assert float(np.min(closed.interface_line_force_N_per_m)) > 1e5 + + +def test_open_contact_carries_no_force(states): + result = states[0.0] + assert result.open_interfaces == (("outer_armour", "hdpe_outer_sheath"),) + gap = result.interface_gap_m[result.interface_open] + assert gap.size == 1 and gap[0] > 1e-6 # a solved gap, far above round-off + assert result.interface_line_force_N_per_m[result.interface_open][0] == 0.0 + + +def test_classification_ignores_the_gap_round_off(states): + """Either side of a gap threshold: a closed contact whose round-off gap is + raised past 1e-9 m stays closed; an open one whose gap is lowered stays + open. Only the line force decides.""" + import dataclasses + + closed = states[2e6] + noisy = dataclasses.replace(closed, interface_gap_m=closed.interface_gap_m + 5e-9) + assert noisy.open_interfaces == () + opened = states[0.0] + tight = dataclasses.replace(opened, interface_gap_m=opened.interface_gap_m * 0.0) + assert tight.open_interfaces == opened.open_interfaces From 8205a2b85f4185f5f006e337493bb7c32d23a439 Mon Sep 17 00:00:00 2001 From: Jae Hoon Seo Date: Thu, 19 Nov 2026 20:50:03 +0900 Subject: [PATCH 2/2] test: no platform-dependent gap bound in the open-interface test The closed-contact gap at the recipe load case is round-off that macOS places above 1e-9 m; the test asserted it below. The force-based classification and the gap perturbation checks stay. Signed-off-by: Jae Hoon Seo --- tests/test_open_interfaces.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/tests/test_open_interfaces.py b/tests/test_open_interfaces.py index b8a4da3..9503826 100644 --- a/tests/test_open_interfaces.py +++ b/tests/test_open_interfaces.py @@ -32,8 +32,6 @@ def test_closed_contacts_are_closed_whatever_their_round_off_gap(states): closed = states[2e6] assert closed.open_interfaces == () assert not closed.interface_open.any() - # Their reported gaps are round-off, of either sign, not zero. - assert 1e-12 < float(np.max(np.abs(closed.interface_gap_m))) < 1e-9 assert float(np.min(closed.interface_line_force_N_per_m)) > 1e5