Skip to content

Commit efbfbba

Browse files
authored
fix: a finite-EI dynamic step on the inertia's round-off floor converges (#168)
A finite-EI cable could fail its first dynamic step at a small time step: Newton stagnated just above the tolerance, and the step recovery's smaller steps only raised it. Found on a 13 m riser (64 elements) at rest in a 0.95 m/s current taking the VIV lift at dtM 1.25e-4 s: the residual stopped at 1.06 times the tolerance, and each 4-fold smaller substep raised the stagnant residual about 16-fold (3.8e-8, 6.2e-7, 8.6e-6, 1.3e-4, 2.6e-3, 4.7e-2 N), to 3.4e4 times the tolerance at 1024 substeps. The 16-fold growth per 4-fold step is the inertia's 1/dt^2, not the 1/dt of a velocity-coupled force (drag, VIV lift): the inertia takes the acceleration (q - q_n)/(beta dt^2) - ... from coordinates stored to their last bits, so its residual cannot be settled below about eps sum_j |M_ij| |q_j| / (beta dt^2). The rows that stalled were the axial rows of nodes 8.5 to 12 m deep, not the cross-flow rows the lift loads: the Newton correction they needed, a few 1e-16 m, is below the 1.8e-15 m spacing of those coordinates. Without the lift the step starts at the static equilibrium and converges at its predictor; with it the line near rest sets no inertial force scale, and tol times the force scale (here its axial round-off floor) lies below the inertia's floor. A floor of the force scale built from that bound, where it binds, would accept residuals up to 16 times the bound, some 60 times the floor Newton reaches (the bound sits about 4 times above it: 1.7e-7 against 3.8e-8 N on the riser, 4.7e-3 against 1.2e-3 N in the test below). The fix is therefore a stall test, as on the EI = 0 route: when no step length of a fresh Newton correction reduces the residual, the residual is below 1e-4 of the force scale, and the correction moves no free coordinate by more than 16 eps times its scale (the largest coordinate magnitude or element length; 1 or the largest tangent or twist magnitude for those DOFs), the iterate is converged. The riser now runs at dtM 1.25e-4 s, and over 2 s its node positions and fairlead tension continue the time-step sequence of dtM 5e-4 and 2.5e-4 s (differences 1.3 mm and 0.55 mm, 5.5 N and 2.9 N). A step that meets the tolerance is unchanged: every example and test-data deck gives bit-identical outputs on the old and new driver (229 files over 118 decks), and through the C API five coupled steps of every deck give bit-identical line arrays (1685 arrays over 70 decks), and the full test suite (424 tests; 426 after the rebase onto 6c469fe) passes on the default and the Prescott OpenBLAS kernel, where the 66 example decks also run with no fallback note. Test: test_hermite_viv round-off floor, the test's 100 m line hung vertically from 50 to 150 m depth, from rest with the lift at dt 2.5e-5 s. Before, the first step stagnated at 2.4 times the tolerance through its 50-iteration budget and failed; now each step stops on the floor after two iterations, and the cross-flow displacement at 0.02 s matches the same line's at dt 1e-3 s within 1 % (to 5 digits). Signed-off-by: Jae Hoon Seo <jaehoon.seo@inha.ac.kr>
1 parent 6c469fe commit efbfbba

4 files changed

Lines changed: 143 additions & 2 deletions

File tree

‎CHANGELOG.md‎

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,19 @@ All notable changes to CableDyn are recorded in this file. The format follows
157157
height in the march, and rides 1.5 m waves. A module deeper than its sphere's radius is
158158
unchanged to the bit. In deck waves a node above the instantaneous surface takes the wave
159159
kinematics at the surface (they were zero there), as a cable's internal waves already did.
160+
- A finite-EI dynamic step at a small time step could fail on a line near rest: the Newton
161+
residual stagnated just above the tolerance, and the step recovery's smaller steps only raised
162+
it (a 13 m riser, 64 elements, at rest in a 0.95 m/s current, took the VIV lift at dtM
163+
1.25e-4 s and stopped at 1.06 times the tolerance; each 4-fold smaller substep raised the
164+
stagnant residual about 16-fold, to 3.4e4 times the tolerance at 1024 substeps). The inertia
165+
takes the acceleration `(q - q_n)/(beta dt^2) - ...` from coordinates stored to their last
166+
bits, so its residual cannot be settled below about `eps sum_j |M_ij| |q_j| / (beta dt^2)`, a
167+
floor that grows like `dt^-2` and, where the line's inertia sets no force scale, stands above
168+
the tolerance. As on the `EI = 0` route, an iterate on that floor is now converged: when no
169+
step length of a fresh Newton correction reduces the residual, the residual is below 1e-4 of
170+
the force scale and the correction moves no free coordinate by more than `16 eps` times its
171+
scale. A step that meets the tolerance is unchanged: every example and test deck gives
172+
bit-identical outputs.
160173

161174
## [0.4.2] - 2026-11-09
162175

‎doc/theory.rst‎

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2918,7 +2918,17 @@ of the axial and bending forces (:math:`x_\text{ref}` the largest coordinate mag
29182918
length; the axial and bending damping take the strain and curvature rates from the Newmark
29192919
velocity, whose rounding is :math:`\gamma/(\beta\,\Delta t)` times that of the coordinates). The
29202920
bending term is the larger on a soft line (a tensioner in series, a fine mesh) with bending
2921-
damping at a small time step. The
2921+
damping at a small time step. The inertia takes the acceleration
2922+
:math:`(\mathbf q - \mathbf q_n)/(\beta\,\Delta t^2) - \dots` from the coordinates, so a row's
2923+
inertial force cannot be resolved finer than about
2924+
:math:`\epsilon\,\sum_j \lvert M_{ij}\rvert\,\lvert q_j\rvert/(\beta\,\Delta t^2)`, a floor that grows
2925+
like :math:`\Delta t^{-2}` and stands above the tolerance on a line near rest at a small time step
2926+
(its inertia then sets no force scale), where a smaller step only raises it. As on the
2927+
:math:`EI = 0` path, a residual on it is converged: when no step length of a fresh Newton
2928+
correction reduces the residual, the residual is below :math:`10^{-4}` of the force scale, and
2929+
the correction moves no free coordinate by more than :math:`16\,\epsilon` times its scale
2930+
(:math:`x_\text{ref}` for the positions, the largest of 1 and the tangent or twist magnitudes for
2931+
the tangents and twist angles), the iterate is accepted. The
29222932
deck defaults are relative tolerance :math:`10^{-8}`, absolute tolerance :math:`10^{-14}`, 30
29232933
iterations, and 12 backtracks (option ``dynamic_solver``). Option ``modified_newton`` reuses the
29242934
factorised tangent within a step while each iterate reduces the residual to at most a quarter

‎src/CableDyn_HermiteCableDynamic.f90‎

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4915,6 +4915,10 @@ SUBROUTINE dyn_step_core(model, dt, max_iter, tol, ErrStat, ErrMsg, iters_out, r
49154915
! XS_TOL_FACTOR*tol, which keeps the outputs as close to the converged solution as full
49164916
! Newton's.
49174917
REAL(wp), PARAMETER :: XS_TOL_FACTOR = 0.3_wp
4918+
! Round-off acceptance of a stalled iterate (see at_roundoff_floor): the Newton correction
4919+
! is within STALL_ROUNDOFF units of eps times the coordinate scale, and the residual within
4920+
! STALL_SANITY of the force scale (the EI = 0 route's bound).
4921+
REAL(wp), PARAMETER :: STALL_ROUNDOFF = 16.0_wp, STALL_SANITY = 1.0e-4_wp
49184922
INTEGER(INT64) :: pc0, pc1, pcr, pt0, pt1
49194923
CHARACTER(1024) :: em2
49204924

@@ -5537,6 +5541,21 @@ SUBROUTINE dyn_step_core(model, dt, max_iter, tol, ErrStat, ErrMsg, iters_out, r
55375541
END IF
55385542
EXIT mn_retry
55395543
END DO mn_retry
5544+
! A fresh correction that no step length improves and that would move no coordinate beyond
5545+
! its last bits: the iterate is on the residual's round-off floor and is converged.
5546+
IF (chosen < CD_ZERO) THEN
5547+
IF (at_roundoff_floor()) THEN
5548+
! the rejected trials overwrote the staged states: restage the iterate's
5549+
CALL eval_res(model%ws_qk, .FALSE., rnorm, es, em2)
5550+
IF (es /= CD_HCDYN_OK) THEN
5551+
ErrStat = es; ErrMsg = 'CD_HermiteCable_Dyn_Step: '//TRIM(em2)
5552+
IF (attempt < n_attempt) CYCLE predict
5553+
RETURN
5554+
END IF
5555+
IF (PRESENT(res_out)) res_out = rnorm
5556+
EXIT
5557+
END IF
5558+
END IF
55405559
IF (chosen < CD_ZERO) THEN
55415560
! No step length reduced the residual (with a usable tangent): fall back to the
55425561
! SMALLEST step that at least gave a finite evaluation (a safe damped step). Using
@@ -6234,6 +6253,47 @@ SUBROUTINE eval_res(qcur, use_trial, rn, esx, emx, stash)
62346253
END IF
62356254
END SUBROUTINE eval_res
62366255

6256+
LOGICAL FUNCTION at_roundoff_floor() RESULT(at_floor)
6257+
!! The iterate sits on the residual's round-off floor: a fresh Newton correction (ws_dq,
6258+
!! tw_dp) that no step length improves moves no free coordinate by more than
6259+
!! STALL_ROUNDOFF eps times its scale (the largest coordinate magnitude or element length,
6260+
!! and for the tangents and twist angles the largest of their magnitudes and 1), and the
6261+
!! residual is within STALL_SANITY of the force scale. Each coordinate is stored to its
6262+
!! last bit, and the inertia takes the acceleration c_a (q - q_n) from it, c_a =
6263+
!! 1/(beta dt^2): a row's inertial force cannot be resolved finer than about c_a M eps |q|,
6264+
!! which grows like 1/dt^2 and stands above tol*fscale on a line near rest at a small time
6265+
!! step (its inertia then sets no force scale). The residual test alone then never passes:
6266+
!! a 13 m riser at rest in a 0.95 m/s current (64 elements, dt 1.25e-4 s) took the VIV
6267+
!! lift and stagnated at 1.06 times the tolerance on its axial rows, and each 4-fold
6268+
!! smaller substep of the step recovery raised the stagnation about 16-fold. The criterion
6269+
!! is the EI = 0 route's (the residual within the operator's backward error of the
6270+
!! coordinates, eps max|q| ||A||), applied through the correction A^-1 G.
6271+
INTEGER :: ii
6272+
REAL(wp) :: xs, ts, ps
6273+
at_floor = .FALSE.
6274+
IF (.NOT. (rnorm <= STALL_SANITY)) RETURN
6275+
xs = MAXVAL(model%l0); ts = CD_ONE
6276+
DO ii = 1, ndof
6277+
IF (MOD(ii - 1, 6) < 3) THEN
6278+
xs = MAX(xs, ABS(model%ws_qk(ii)))
6279+
ELSE
6280+
ts = MAX(ts, ABS(model%ws_qk(ii)))
6281+
END IF
6282+
END DO
6283+
DO ii = 1, ndof
6284+
IF (.NOT. model%solve_mask(ii)) CYCLE
6285+
IF (.NOT. (ABS(model%ws_dq(ii)) <= STALL_ROUNDOFF*EPSILON(CD_ONE)*MERGE(xs, ts, MOD(ii - 1, 6) < 3))) RETURN
6286+
END DO
6287+
IF (model%tw_active) THEN
6288+
ps = MAX(CD_ONE, MAXVAL(ABS(model%tw_pk)))
6289+
DO ii = 1, model%nn
6290+
IF (.NOT. model%tw_free(ii)) CYCLE
6291+
IF (.NOT. (ABS(model%tw_dp(ii)) <= STALL_ROUNDOFF*EPSILON(CD_ONE)*ps)) RETURN
6292+
END DO
6293+
END IF
6294+
at_floor = .TRUE.
6295+
END FUNCTION at_roundoff_floor
6296+
62376297
SUBROUTINE impose_step_rigid_kinematics(q_state, v_state, a_state)
62386298
!! Eliminate the two prescribed rotational tangent components while leaving
62396299
!! the axial magnitude as the single solved coordinate. The scalar magnitude

‎tests/test_hermite_viv.f90‎

Lines changed: 59 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,14 @@ PROGRAM test_hermite_viv
1919
!! * at 60 s the mid-span cross-flow amplitude is above 0.3 D with the lift and below 0.01 D
2020
!! without it;
2121
!! * a snapshot taken mid-run and restored replays the following steps bit for bit (state and
22-
!! phase), and the recovering step equals the plain step when no step fails.
22+
!! phase), and the recovering step equals the plain step when no step fails;
23+
!! * the residual's round-off floor: the same line hung vertically from 50 m to 150 m depth,
24+
!! from rest with the lift, at dt 2.5e-5 s. The inertia takes the acceleration
25+
!! (q - q_n)/(beta dt^2) - ... from coordinates stored to their last bits, so its residual
26+
!! cannot be settled below their rounding, which grows like 1/dt^2: the first step stagnated
27+
!! at 2.4 times the tolerance 1e-8 through its 50-iteration budget and failed. Each step stops
28+
!! on that floor, and the cross-flow displacement at 0.02 s matches the same line's at
29+
!! dt 1e-3 s within 1 %.
2330
USE CableDyn_Precision, ONLY: wp
2431
USE CableDyn_HermiteCableDynamic, ONLY: CD_HermiteCableDynType, CD_HermiteCable_Dyn_Init, &
2532
CD_HermiteCable_Dyn_Set_Drag, CD_HermiteCable_Dyn_Set_AddedMass, &
@@ -132,6 +139,9 @@ PROGRAM test_hermite_viv
132139
CALL require(k > 100, 'the recovering step equals the plain step')
133140
CALL CD_HermiteCable_Dyn_End(model)
134141

142+
! ---- the inertia's round-off floor at a small time step ----
143+
CALL check_inertia_floor()
144+
135145
IF (nfail > 0) THEN
136146
WRITE (*, '(A,I0,A)') 'FAIL: ', nfail, ' assertion(s) failed'
137147
ERROR STOP 1
@@ -200,6 +210,54 @@ REAL(wp) FUNCTION run_amplitude(m) RESULT(amp)
200210
amp = 0.5_wp*(zmax - zmin)
201211
END FUNCTION run_amplitude
202212

213+
SUBROUTINE check_inertia_floor()
214+
!! The line hung vertically from 50 m to 150 m depth in the cross current along y (its lift
215+
!! along x), from rest: 800 steps of 2.5e-5 s against 20 of 1e-3 s, the mid-span cross-flow
216+
!! displacement at 0.02 s.
217+
REAL(wp), PARAMETER :: T_END = 0.02_wp
218+
REAL(wp) :: dx(2), step_dt(2), res, seed(6*(NE + 1)), l0(NE), eav(NE), eiv(NE), wv(NE), rhoa(NE), &
219+
hd(NE), hn(NE), ht(NE)
220+
INTEGER :: run, n, it, i, xmid
221+
step_dt = [2.5e-5_wp, 1.0e-3_wp]
222+
xmid = 6*(NE/2) + 1 ! r_x of the mid-span node
223+
seed = 0.0_wp
224+
DO i = 1, NE + 1
225+
seed(6*(i - 1) + 3) = -50.0_wp - SPAN*REAL(i - 1, wp)/REAL(NE, wp)
226+
seed(6*(i - 1) + 6) = -1.0_wp
227+
END DO
228+
l0 = SPAN/REAL(NE, wp)/(1.0_wp + TENS/EA)
229+
eav = EA; eiv = EI; rhoa = MLIN
230+
wv = (MLIN - RHOW*0.25_wp*PI*D**2)*GACC
231+
hd = D; ht = 0.0_wp
232+
DO run = 1, 2
233+
CALL CD_HermiteCable_Dyn_Init(model, l0, eav, eiv, rhoa, wv, seed, [1, 2, 3, 6*NE + 1, 6*NE + 2, 6*NE + 3], &
234+
-200.0_wp, 0.0_wp, 0.5_wp, es, em)
235+
CALL require(es == CD_HCDYN_OK, 'round-off floor, init: '//TRIM(em))
236+
hn = 1.2_wp
237+
CALL CD_HermiteCable_Dyn_Set_Drag(model, RHOW, hd, hn, ht, 0.0_wp, [0.0_wp, U, 0.0_wp], es, em)
238+
CALL require(es == CD_HCDYN_OK, 'round-off floor, drag: '//TRIM(em))
239+
hn = 1.0_wp
240+
CALL CD_HermiteCable_Dyn_Set_AddedMass(model, RHOW, hd, hn, ht, 0.0_wp, es, em)
241+
CALL require(es == CD_HCDYN_OK, 'round-off floor, added mass: '//TRIM(em))
242+
CALL CD_HermiteCable_Dyn_Set_VIV(model, cl, cf, df, 0.25_wp, es, em)
243+
CALL require(es == CD_HCDYN_OK, 'round-off floor, VIV: '//TRIM(em))
244+
dx(run) = model%q(xmid)
245+
DO n = 1, NINT(T_END/step_dt(run))
246+
CALL CD_HermiteCable_Dyn_Step(model, step_dt(run), 50, 1.0e-8_wp, es, em, it, res)
247+
IF (es /= CD_HCDYN_OK) THEN
248+
CALL require(.FALSE., 'round-off floor: step failed: '//TRIM(em))
249+
CALL CD_HermiteCable_Dyn_End(model)
250+
RETURN
251+
END IF
252+
END DO
253+
dx(run) = model%q(xmid) - dx(run)
254+
CALL CD_HermiteCable_Dyn_End(model)
255+
END DO
256+
WRITE (*, '(A,ES11.4,A,ES11.4,A)') ' round-off floor: mid-span cross-flow displacement at 0.02 s ', dx(1), &
257+
' m at dt 2.5e-5 s, ', dx(2), ' m at dt 1e-3 s'
258+
CALL require(ABS(dx(1) - dx(2)) <= 0.01_wp*ABS(dx(2)), 'round-off floor: the small steps follow the large ones')
259+
END SUBROUTINE check_inertia_floor
260+
203261
SUBROUTINE require(cond, label)
204262
LOGICAL, INTENT(IN) :: cond
205263
CHARACTER(*), INTENT(IN) :: label

0 commit comments

Comments
 (0)