From b173b794cab2c20a6f20dcee06c56ea45b730fcf Mon Sep 17 00:00:00 2001 From: Jae Hoon Seo Date: Mon, 9 Nov 2026 00:06:46 +0900 Subject: [PATCH 1/2] fix(statics): a residual cycling inside the round-off floor is converged The EI = 0 static Newton solve converges a residual that is inside the round-off floor of its nodal forces but above the relative tolerance only when the residual stays flat over the stall window. Inside the floor the iterates can also alternate between two values (the rounding of the last digits), which the flat test never sees: the Levenberg-Marquardt stages then ran out of iterations and the line had no admissible equilibrium. Whether a deck solved depended on the last digits of its coordinates: 13 of 32 small translations of a suspended three-section line in a 0.67 m/s current failed (the residual alternating between 9.49e-5 and 8.77e-5 N, with a floor of 3.1e-3 N and a tolerance of 2.6e-5 N), and translated copies of point systems failed in their line solves. A residual inside the floor that sets no new minimum over the stall window is now converged as a flat one is. Every example deck gives the same output as before. The new ei0_static_floor_cycle test solves the 32 translated decks and requires the same end tensions from each to 1e-7. Signed-off-by: Jae Hoon Seo --- CHANGELOG.md | 6 ++ CMakeLists.txt | 11 +++ doc/theory.rst | 3 +- src/CableDyn_Static.f90 | 9 +++ tests/test_ei0_static_floor_cycle.py | 102 +++++++++++++++++++++++++++ 5 files changed, 130 insertions(+), 1 deletion(-) create mode 100644 tests/test_ei0_static_floor_cycle.py diff --git a/CHANGELOG.md b/CHANGELOG.md index e3549554..74aa33ee 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -18,6 +18,12 @@ All notable changes to CableDyn are recorded in this file. The format follows The touchdown element now takes the reaction of its grounded stretch, from the grounded node to the touchdown point located from the two nodes' clearances: the error falls at the second order (2.1, 0.7, 0.2 N) and the outputs vary continuously. +- `EI = 0` statics: a residual inside the round-off floor of the nodal forces but above the + relative tolerance was converged only when it stayed flat. Iterates that alternated between two + values there ran every stage out of iterations, so a line could fail to find its equilibrium or + find it depending on the last digits of its coordinates (13 of 32 small translations of a + suspended three-section line in a current failed, as did translated copies of point systems). A + residual inside the floor that sets no new minimum over three iterations is now converged. ## [0.4.1] - 2026-11-08 diff --git a/CMakeLists.txt b/CMakeLists.txt index 96dcf84c..a78a6788 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1828,6 +1828,17 @@ if(Python3_Interpreter_FOUND) TIMEOUT 600 ENVIRONMENT "${_cabledyn_python_test_environment}") + # EI = 0 statics: a residual that cycles inside its round-off floor is converged, so a line in + # a current solves the same under every small translation of its deck. + add_test(NAME ei0_static_floor_cycle + COMMAND ${Python3_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/tests/test_ei0_static_floor_cycle.py + --exe $ + --output ${CMAKE_BINARY_DIR}/ei0_static_floor_cycle) + set_tests_properties(ei0_static_floor_cycle PROPERTIES + LABELS "python;static;robustness" + TIMEOUT 300 + ENVIRONMENT "${_cabledyn_python_test_environment}") + # The note on grounded lines that a current moves over a seabed without friction: once per run # on every standalone route, and never without a grounded node, a current, or a march, or # with friction. diff --git a/doc/theory.rst b/doc/theory.rst index a16eb76b..438a042e 100644 --- a/doc/theory.rst +++ b/doc/theory.rst @@ -1652,7 +1652,8 @@ beyond a :math:`10^{-6}` relative round-off band; a slack element reports zero t :math:`\lVert\mathbf{R}\rVert_\infty < 10^{-14}`, where :math:`s` is the largest of the infinity norms of the external load, the seabed reaction, and any current drag; a residual that stops decreasing inside the round-off floor - :math:`16\,\epsilon\,\max(EA/L_0)\max(\lvert q\rvert, L_0)` of the nodal forces is converged. + :math:`16\,\epsilon\,\max(EA/L_0)\max(\lvert q\rvert, L_0)` of the nodal forces is converged, + whether it stays flat or cycles between values (three iterations without a new minimum). A line with no admissible equilibrium fails closed, naming the line, the seeds and stages tried, and the reason. diff --git a/src/CableDyn_Static.f90 b/src/CableDyn_Static.f90 index 5afd5b3e..2ee5aa5a 100644 --- a/src/CableDyn_Static.f90 +++ b/src/CableDyn_Static.f90 @@ -726,6 +726,15 @@ SUBROUTINE CD_Static_Cable_Solve(q0, elem_conn, l0, ea, tension_only, f_ext, fix RETURN END IF END IF + ! Inside the round-off floor a residual can also cycle between two or more values (the + ! rounding of the last digits alternating), which the flat test above never sees: when + ! the last stall_window samples set no new minimum, there is no digit left to gain either + IF (k > cfg%stall_window .AND. hist(k) <= r_floor) THEN + IF (lo >= MINVAL(hist(1:k - cfg%stall_window))) THEN + converged = .TRUE. + RETURN + END IF + END IF END IF END DO ! exhausted max_iter without converging or stalling diff --git a/tests/test_ei0_static_floor_cycle.py b/tests/test_ei0_static_floor_cycle.py new file mode 100644 index 00000000..f45c97dd --- /dev/null +++ b/tests/test_ei0_static_floor_cycle.py @@ -0,0 +1,102 @@ +#!/usr/bin/env python3 +# SPDX-License-Identifier: Apache-2.0 +# Copyright (c) 2026 Jae Hoon Seo, SMI Lab, Inha University +"""An EI = 0 static solve whose residual cycles inside its round-off floor is converged. + +A suspended three-section line (wire, then two polyester sections, 1151 m, 316 elements) hangs +between a fairlead and an anchor 693 m below it in a 0.67 m/s uniform current. The slack-capable +static stages bring the residual to about 1e-4 N, inside the round-off floor of its nodal forces +(3e-3 N) and above the relative tolerance (2.6e-5 N). Depending on the last digits of the +coordinates the iterates then settle on one value (flat, converged) or alternate between two +(9.49e-5 and 8.77e-5 N), which the flat-stall test never saw: every stage ran out of iterations +and no equilibrium was found. The deck is translated by 32 small offsets, every one of which must +solve and give the same fairlead and anchor tensions to 1e-7. + +usage: test_ei0_static_floor_cycle.py --exe --output +""" + +from __future__ import annotations + +import argparse +import os +import subprocess +import sys +from pathlib import Path + +DECK = """--------------------- CableDyn Input File ------------------------------------ +Suspended three-section line in a uniform current +--------------------- LINE TYPES --------------------------------------- +TypeName Diam Mass EA BA EI Cd_n Cd_t Ca_n Ca_t +(-) (m) (kg/m) (N) (N-s) (N-m2) (-) (-) (-) (-) +t1 0.16489335960471715 135.94910020865282 2447083803.755751 -1.0 0.0 1.2 0.008 1.0 0.0 +t2 0.07370991400051977 7.052224668855406 11019101.045086572 -0.8 0.0 2.0 0.4 1.1 0.15 +t3 0.10037023217840212 13.076279295895747 20431686.399837103 -0.8 0.0 2.0 0.4 1.1 0.15 +--------------------- POINTS ------------------------------------------- +ID Type X Y Z +(-) (-) (m) (m) (m) +1 Coupled {xa!r} {ya!r} -67.45321271085669 +2 Fixed {xb!r} {yb!r} -761.0028936967904 +--------------------- LINES -------------------------------------------- +ID NodeA NodeB Outputs +(-) (-) (-) (-) +1 1 2 - +--------------------- SECTIONS ----------------------------------------- +LineID LineType Length NumSegs +(-) (-) (m) (-) +1 t1 296.3708154484327 127 +1 t2 120.1220550938935 55 +1 t3 734.2263766070876 134 +--------------------- OPTIONS ------------------------------------------ +uniform -0.6393706682921939 -0.20430951085352095 0.0 current +0.01 dtM +0.0 TMax +--------------------- OUTPUTS ------------------------------------------ +FairTen1 +AnchTen1 +--------------------- need this line ----------------------------------- +""" + +A = (-239.01858425733275, -260.87547371415656) +B = (-732.1643435012232, -617.3791587315022) +DX = [0.0, 0.25, 0.5, 1.0, 2.0, 4.0, 8.0, 16.0] +DY = [0.0, 0.3, 3.0, 30.0] + + +def main() -> int: + ap = argparse.ArgumentParser() + ap.add_argument("--exe", required=True) + ap.add_argument("--output", required=True) + a = ap.parse_args() + out = Path(a.output) + out.mkdir(parents=True, exist_ok=True) + env = dict(os.environ) + env.setdefault("OPENBLAS_NUM_THREADS", "1") + failures = [] + ref = None + for dx in DX: + for dy in DY: + name = "shift_%g_%g" % (dx, dy) + deck = out / (name + ".dat") + deck.write_text(DECK.format(xa=A[0] + dx, ya=A[1] + dy, xb=B[0] + dx, yb=B[1] + dy), encoding="utf-8", + newline="\n") + root = out / name + p = subprocess.run([a.exe, str(deck), str(root)], capture_output=True, text=True, env=env, + cwd=str(out)) + if p.returncode != 0: + failures.append("shift (%g, %g): exit %d: %s" % (dx, dy, p.returncode, (p.stdout + p.stderr)[-300:])) + continue + rows = Path(str(root) + ".out").read_text(encoding="utf-8").splitlines() + vals = [float(v) for v in rows[2].split()[1:3]] + if ref is None: + ref = vals + for v, r, ch in zip(vals, ref, ("FairTen1", "AnchTen1")): + if abs(v - r) > 1.0e-7 * abs(ref[0]): + failures.append("shift (%g, %g): %s %.8e differs from %.8e" % (dx, dy, ch, v, r)) + print("translated line in a current: %d runs, %d failures" % (len(DX) * len(DY), len(failures))) + for f in failures: + print("FAIL:", f) + return 1 if failures else 0 + + +if __name__ == "__main__": + sys.exit(main()) From 5f905bceb6a5bfd0dd873a9cbbb8fd9c769d2ced Mon Sep 17 00:00:00 2001 From: Jae Hoon Seo Date: Mon, 9 Nov 2026 00:13:33 +0900 Subject: [PATCH 2/2] chore(changelog): the entry moves to the batch changelog change The [Unreleased] entries of the open changes are added together in one change, so that they do not conflict with each other. Signed-off-by: Jae Hoon Seo --- CHANGELOG.md | 6 ------ 1 file changed, 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 74aa33ee..e3549554 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -18,12 +18,6 @@ All notable changes to CableDyn are recorded in this file. The format follows The touchdown element now takes the reaction of its grounded stretch, from the grounded node to the touchdown point located from the two nodes' clearances: the error falls at the second order (2.1, 0.7, 0.2 N) and the outputs vary continuously. -- `EI = 0` statics: a residual inside the round-off floor of the nodal forces but above the - relative tolerance was converged only when it stayed flat. Iterates that alternated between two - values there ran every stage out of iterations, so a line could fail to find its equilibrium or - find it depending on the last digits of its coordinates (13 of 32 small translations of a - suspended three-section line in a current failed, as did translated copies of point systems). A - residual inside the floor that sets no new minimum over three iterations is now converged. ## [0.4.1] - 2026-11-08