Skip to content

fix: an interface is open when its contact carries no line force - #49

Merged
SMI-Lab-Inha merged 2 commits into
devfrom
fix/open-gap-tolerance
Nov 19, 2026
Merged

SMI-Lab-Inha merged 2 commits into
devfrom
fix/open-gap-tolerance

Conversation

@SMI-Lab-Inha

@SMI-Lab-Inha SMI-Lab-Inha commented Nov 19, 2026 •

Copy link
Copy Markdown
Owner

Summary

tests/test_howto_recipes.py::test_recipe_output_matches_page[howto_02_contact_state.py] failed on macOS only (dev runs 44493046003, Python 3.11, and 44286053398, Python 3.12). The recipe printed open gaps 1 at 100 kN with a sealed 2 MPa, where the page shows open gaps 0. The recipe, and the coiling check, counted an interface as open when its reported gap exceeded a bare 1e-9 m.

The gaps at that load case

66 kV template, 100 kN, solve_cable_radial_state, gaps printed in full precision (Windows, CI wheels NumPy 2.4.6 / SciPy 1.17.1):

Interface p_ext 0: gap [m] line force [N/m] p_ext 2 MPa: gap [m] line force [N/m]
bundle / inner_armour −1.71e-14 33 118 −1.32e-13 1 130 064
inner_armour / ppy_bedding_armour 2.23e-11 12 563 1.47e-10 1 102 193
ppy_bedding_armour / outer_armour −2.23e-11 12 590 −1.47e-10 1 104 119
outer_armour / hdpe_outer_sheath 2.53e-6 0 2.22e-13 1 085 757

At 2 MPa every contact carries more than 1 MN/m: all four are closed. Their reported gaps are the round-off of the linear solve. They are recomputed as gap0 + C u + c r from a displacement solved to about 1e-7 of its millimetre scale, on a stiff wire stack over soft polymer. The contact solver's own complementarity tolerance (solve_lcp: 1e-8 of the scaled problem), converted to metres with the square root of each contact's flexibility, is 1.9e-10 to 4.3e-10 m here. So the 1.47e-10 m gap is inside the solver's tolerance, and only seven times below the 1e-9 m threshold. Another platform's linear algebra (the macOS NumPy wheels link Accelerate) crossed it.

Fix

A gap threshold cannot separate a closed contact from an open one here: the noise of a closed contact's gap is of the same order as any tolerance derived from the solver. A force-based threshold derived from the 1e-8 N/m KKT gate does not work either. Converted with the compliance it gives about 1e-14 m, far below the 1.5e-10 m noise, so it would call the closed contacts open. The solver already decides the state exactly by complementarity: an open contact has a reaction of exactly zero (it is outside the active set), and a closed one has a positive line force (here more than 1e4 N/m).

  • RadialSectionResult.interface_open (array) and open_interfaces (names) report the solver's decision: line force ≤ 0. interface_gap_m is unchanged.
  • The recipe prints len(state.result.open_interfaces). analysis.coiling uses the same rule; its OPEN_GAP_M (1e-9 m) is removed.
  • The page states the rule and why the gap of a closed contact is not a measure of openness.

No validation tolerance, band or result changes; the page output is unchanged.

Tests

tests/test_open_interfaces.py covers both sides of the boundary:

  • At 2 MPa all contacts are closed, though their gaps are nonzero round-off (1e-12 to 1e-9 m) and each carries more than 1e5 N/m.
  • At 0 MPa exactly the outer sheath interface is open: its gap is above 1e-6 m and its force is zero.
  • The classification ignores the gap. Raising the closed gaps by 5e-9 m (past the old threshold) keeps them closed; setting the open gap to zero keeps it open.

Gates

On cd3b657 before the rebase:

  • pytest (full suite, venv with the CI wheels, NUMBA_NUM_THREADS=1): 4584 passed, 4 skipped.
  • With CABLEXSEC_DISABLE_NUMBA=1: 4469 passed, 119 skipped.

After the rebase onto 694331f (dev with #48; only the CHANGELOG conflicted), the affected test files were rerun:

  • The new tests, the how-to recipes and coiling: 38 passed, with and without CABLEXSEC_DISABLE_NUMBA=1.
  • python -m mypy: no issues. ruff check and ruff format --check: clean.
  • Taxonomy: no marked test added; counts unchanged.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 19, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-19T14:47:14.340268Z 8205a2b Manual request
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@SMI-Lab-Inha

Copy link
Copy Markdown
Owner Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 4c719510aa

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread tests/test_open_interfaces.py Resolved
@read-the-docs-community

read-the-docs-community Bot commented Nov 19, 2026 •

Copy link
Copy Markdown

Documentation build overview

📚 CableXSec | 🛠️ Build #36016093 | 📁 Comparing 8205a2b against latest (240bf9c)

  🔍 Preview build  

24 files changed · ± 24 modified

± Modified

@SMI-Lab-Inha

Copy link
Copy Markdown
Owner Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Chef's kiss.

Reviewed commit: ff4a98bb4b

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

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 <jaehoon.seo@inha.ac.kr>
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 <jaehoon.seo@inha.ac.kr>
@SMI-Lab-Inha
SMI-Lab-Inha force-pushed the fix/open-gap-tolerance branch from ff4a98b to 8205a2b Compare November 19, 2026 14:45
@SMI-Lab-Inha

Copy link
Copy Markdown
Owner Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. More of your lovely PRs please.

Reviewed commit: 8205a2b85f

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant