Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1913,6 +1913,17 @@ if(Python3_Interpreter_FOUND)
TIMEOUT 300
ENVIRONMENT "${_cabledyn_python_test_environment}")

# The static balance of a Connect point between a heavy chain and two wires on the seabed does
# not cycle between trial steps, and agrees with the independent catenary balance.
add_test(NAME point_static_cycle
COMMAND ${Python3_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/tests/test_point_static_cycle.py
--exe $<TARGET_FILE:cabledyn>
--output ${CMAKE_BINARY_DIR}/point_static_cycle)
set_tests_properties(point_static_cycle PROPERTIES
LABELS "python;static;points;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.
Expand Down
4 changes: 3 additions & 1 deletion doc/theory.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2676,7 +2676,9 @@ does not converge. At a slack line whose condensed stiffness vanishes, the itera
a central-difference Jacobian of the full residual.

A step is accepted when it lowers the residual, or when the Newton step from the trial point is
at most half the current one. The second test lets an object swing along a curved valley: a
at most half the current one and half the shortest Newton step of the solve so far (a Newton step
that grows again near a slack/taut kink of a line must not reset that measure, or the steps can
cycle). The second test lets an object swing along a curved valley: a
buoy on a stiff taut line moves on a sphere about the anchor, and every straight step
overstretches the line by its sagitta, so the force residual alone would reject any step
longer than a few centimetres. After each accepted step the rotation unknowns are folded into
Expand Down
20 changes: 16 additions & 4 deletions src/CableDyn_DeckDriver.f90
Original file line number Diff line number Diff line change
Expand Up @@ -27571,8 +27571,9 @@ SUBROUTINE solve_body_equilibrium_core(types, bodies, rod_types, rods, points, l
!! whose radius starts at the first Newton step (capped at a quarter of the shortest moving
!! line), widens after a well-predicted step on its boundary and shrinks after a rejected
!! one, with Levenberg-Marquardt steps as the fallback. A trial is accepted when the residual
!! drops or when the Newton step from it is at most half the current one (a taut line
!! swinging about its anchor: every straight step overstretches it by its sagitta). Each
!! drops or when the Newton step from it is at most half the current one and half the shortest
!! of the phase (a taut line swinging about its anchor: every straight step overstretches it
!! by its sagitta). Each
!! step turns an object by at most 0.25 rad, and accepted rotations are folded into the base
!! orientation (rebase_rotations) so the Jacobian stays exact. Converged when the largest
!! scaled residual is below 1e-9 of the force scale (largest net weight or line end force)
Expand Down Expand Up @@ -27655,6 +27656,9 @@ SUBROUTINE solve_body_equilibrium_core(types, bodies, rod_types, rods, points, l
INTEGER :: nobj, n, i, j, k, it, inner, info, worst, jk
LOGICAL :: ok, only_points
REAL(wp) :: sc, rnorm, rnorm_try, mu, step_cap, len_min, dmax, trust, pred
! the shortest Newton step of the phase so far (the natural-level test of a step that grew
! the residual)
REAL(wp) :: dn_min
! the completion line: the deck pose of every point, and the largest turn of a body or rod
REAL(wp), ALLOCATABLE :: pos_deck(:, :)
REAL(wp) :: turn_rot(3, 3), turn_max
Expand Down Expand Up @@ -27868,6 +27872,7 @@ SUBROUTINE solve_body_equilibrium_core(types, bodies, rod_types, rods, points, l
rnorm = NORM2(r)
mu = 1.0e-8_wp
trust = -CD_ONE
dn_min = HUGE(CD_ONE)
DO it = 1, MAX_IT
IF (MAXVAL(ABS(r)) <= 1.0e-9_wp*sc) EXIT
! the analytic Jacobian, and a central-difference one of the full residual when the
Expand Down Expand Up @@ -27913,7 +27918,12 @@ SUBROUTINE solve_body_equilibrium_core(types, bodies, rod_types, rods, points, l
! centimetres although the pose is nearer the equilibrium. The Newton step length
! measures the distance in displacement units, where the overstretch counts only
! as its small length: the step is also accepted when the Newton step from the
! trial point (its own analytic Jacobian) is at most half the current one.
! trial point (its own analytic Jacobian) is at most half the current one, and
! half the shortest Newton step of the phase so far: a Newton step that grows
! again (a near-singular Jacobian at a slack/taut kink, whose long step lands on an
! overstretched line) cannot reset the measure, which the residual then descends
! back from, so the steps could otherwise cycle forever (a Connect point between a
! near-vertical heavy chain and a wire lying nearly taut on the seabed).
IF (.NOT. ok .AND. jk == 1) THEN
CALL analytic_jacobian(x_try, jtry, ok)
IF (ok) THEN
Expand All @@ -27925,7 +27935,7 @@ SUBROUTINE solve_body_equilibrium_core(types, bodies, rod_types, rods, points, l
END IF
ok = info == CD_LINALG_OK
IF (ok) ok = ALL(IEEE_IS_FINITE(dxc))
IF (ok) ok = NORM2(dxc) <= 0.5_wp*NORM2(dxn)
IF (ok) ok = NORM2(dxc) <= 0.5_wp*MIN(NORM2(dxn), dn_min)
END IF
END IF
END IF
Expand Down Expand Up @@ -27970,6 +27980,8 @@ SUBROUTINE solve_body_equilibrium_core(types, bodies, rod_types, rods, points, l
END DO
IF (.NOT. ok) EXIT
mu = MAX(0.25_wp*mu, 1.0e-12_wp)
! the Newton step of the iterate just left (the last solve of dxn, from x)
IF (ALL(IEEE_IS_FINITE(dxn))) dn_min = MIN(dn_min, NORM2(dxn))
x = x_try
r = r_try
rnorm = rnorm_try
Expand Down
105 changes: 105 additions & 0 deletions tests/test_point_static_cycle.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
#!/usr/bin/env python3
# SPDX-License-Identifier: Apache-2.0
# Copyright (c) 2026 Jae Hoon Seo, SMI Lab, Inha University
"""The static balance of a Connect point does not cycle between trial steps.

A massless Connect point hangs from a fairlead on a 383 m heavy chain (4.0 kN/m submerged)
and is held by two wires to anchors on the seabed, 860 and 915 m away, one wire 50 m slack, the
other lying nearly taut. Its balance (independent check: elastic catenaries with a frictionless
seabed) lies 5.6 m above the seabed at (-46.28, -215.17, -385.52) m, the chain hanging almost
straight. The point solve accepted a step that raised the force residual a hundredfold when the
Newton step from it was half the current one; near the wires' slack/taut kinks the Newton step
then grew again, and the steps cycled with period four (4e4 N -> 6e6 N -> ...) until the solve
failed from every seed. The deck, translated by 0, 0.5, 7 and 50 m and on twice its mesh, must
solve, with the point within 1.5 m (deck mesh: 11 to 27 m elements, the lumped weight of a chain
element 43 kN) and 0.5 m (refined mesh) of that balance.

usage: test_point_static_cycle.py --exe <cabledyn> --output <dir>
"""

from __future__ import annotations

import argparse
import math
import os
import subprocess
import sys
from pathlib import Path

DECK = """--------------------- CableDyn Input File ------------------------------------
Connect point between a near-vertical heavy chain and two wires on the seabed
--------------------- LINE TYPES ---------------------------------------
TypeName Diam Mass EA BA EI Cd_n Cd_t Ca_n Ca_t
(-) (m) (kg/m) (N) (N-s) (N-m2) (-) (-) (-) (-)
c1 0.27415669765336415 461.64250243121677 1981119080.7852216 -0.5 0.0 2.4 1.15 1.0 0.5
c2 0.15735867593791983 123.80876446467634 2228557760.3641744 -0.8 0.0 1.2 0.008 1.0 0.0
--------------------- POINTS -------------------------------------------
ID Type X Y Z
(-) (-) (m) (m) (m)
1 Connect {p1} -243.72632411372282
2 Coupled {p2} -3.636762830393616
3 Fixed {p3} -391.1306916880583
4 Fixed {p4} -391.1306916880583
--------------------- LINES --------------------------------------------
ID NodeA NodeB Outputs
(-) (-) (-) (-)
1 2 1 -
2 1 3 -
3 1 4 -
--------------------- SECTIONS -----------------------------------------
LineID LineType Length NumSegs
(-) (-) (m) (-)
1 c1 383.1443798528323 {n1}
2 c2 911.6709117895668 {n2}
3 c2 915.0868828891583 {n3}
--------------------- OPTIONS ------------------------------------------
391.1306916880583 WtrDpth
68564.77991863908 kBot
0.01 dtM
0.02 TMax
--------------------- OUTPUTS ------------------------------------------
Point1px
Point1py
Point1pz
--------------------- need this line -----------------------------------
"""

XY = [(-15.372812272073247, -9.211690291294737), (-33.33826322302139, -226.49112604239878),
(824.7662044985119, -134.65675642308003), (-733.8644971516716, 386.4080560971254)]
BALANCE = (-46.28, -215.17, -385.52)


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 = []
cases = [(dx, 1, 1.5) for dx in (0.0, 0.5, 7.0, 50.0)] + [(0.0, 2, 0.5)]
for dx, f, tol in cases:
pts = {"p%d" % (k + 1): "%r %r" % (x + dx, y) for k, (x, y) in enumerate(XY)}
name = "connect_%g_%d" % (dx, f)
deck = out / (name + ".dat")
deck.write_text(DECK.format(n1=35 * f, n2=34 * f, n3=33 * f, **pts), 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, mesh x%d: exit %d: %s" % (dx, f, p.returncode, (p.stdout + p.stderr)[-300:]))
continue
rows = Path(str(root) + ".out").read_text(encoding="utf-8").splitlines()
x, y, z = [float(v) for v in rows[2].split()[1:4]]
d = math.dist((x - dx, y, z), BALANCE)
if d > tol:
failures.append("shift %g, mesh x%d: point %.3f m from the balance (limit %.1f m)" % (dx, f, d, tol))
print("connect point balance: %d runs, %d failures" % (len(cases), len(failures)))
for m in failures:
print("FAIL:", m)
return 1 if failures else 0


if __name__ == "__main__":
sys.exit(main())
Loading