From 631a81751f288a0033f44ab2b555debf1996130c Mon Sep 17 00:00:00 2001 From: Jae Hoon Seo Date: Mon, 16 Nov 2026 06:46:18 +0900 Subject: [PATCH 1/2] fix: a finite-EI step no longer converges to the root with its tangents reversed A finite-EI line with little numerical damping could fail its march a few steps in. Found on the lock-in line of the long-run VIV checks (a taut 20 m line, 10 elements, EA 5e7 N, 3.8 kN, pinned in a 0.3 m/s cross current with the lift) at rho_inf 1 and 50 steps per VIV cycle (dt 0.037 s): step 2 converged in 3 quadratic iterations to a state with every nodal tangent reversed (m_x -1.13 against +1.00015), 2.4e8 J of strain energy against 3.5 J, and step 6 stagnated at 1e-3 through its 50 iterations. The same happened at rho_inf 0.8 and 0.9 (failing at steps 10 and 7), at 25 steps per cycle (steps 5, 13 and 4 at rho_inf 0.8, 0.9 and 1; at 0.5 the run went on through reversed roots to a mid-span A/D of 5.7), and without the lift (step 38). It is not the lift, the force cache or the cross-step factor reuse (the reuse is off under VIV, and the step fails the same with it disabled), and not an instability of the time integration: the energy was steady up to the jump. The cause is the Newton predictor. The line's seed has unit tangents while its elements are stretched by T/EA = 7.6e-5, so the tangents' stretch, the line's stiffest motion (EA against their small consistent mass, omega ~ 8e3 rad/s, omega dt ~ 300), starts 7.6e-5 off its balance. At rho_inf 1 nothing damps it: it rings between 1 and 1 + 2 T/EA with a committed acceleration of 4.9e3 1/s^2 on the tangents, and the constant-acceleration and Newmark guesses (dt^2/2 a_n = 3.4 and dt^2/4 a_n = 1.7 of the tangent's length) carried every tangent across zero, next to the root with each element folded into a Z along its chord. With rho_inf 0.5 the same mode carries a velocity overshoot (dt v_n = 1.7 at 25 steps per cycle). Seeded at its stretch (tangents 1 + T/EA) the line runs at every rho_inf and step. Fix: where either guess would change the length of a free nodal tangent by more than a quarter (a strain change of 0.25 in one step, which no step resolves), that tangent starts at its committed value, from which the stiff mode's true increment is a Newton step away. The test is on the length alone, since a guess that turns a tangent fast is often right: the line-control test's seabed cable turns two tangents 19 degrees in its first 0.01 s step and does not converge from held tangents. Holding only the length and keeping the turn also converged, but took 132 steps over 12 iterations against 31 on the 25-step runs. And a step that ends with a nodal tangent turned by 90 degrees or more is now a failed attempt with its own message (the next attempt or the step recovery re-solves it) instead of a converged step: with the predictor guard disabled, the line stops at step 2 with that message rather than marching on through reversed roots. The line now runs at rho_inf 0.5 to 1 and 25 and 50 steps per cycle. Over 20 cycles its largest mid-span A/D is that of the line seeded at its stretch within 0.75 % and its largest strain energy within 1.2 times; at 50 steps per cycle and rho_inf 1 it runs the 400 cycles of the long-run check (largest A/D 0.568 against 0.567 seeded at the stretch; energy mismatch 7.3e-4 of the VIV work, 8.3e-5 at 100 steps per cycle). The guard changes only a step that would stretch a tangent by a quarter: every example and test-data deck gives bit-identical outputs on the old and new driver (226 files over 115 decks, the console logs equal up to their progress clock), the full test suite passes on the default and the Prescott OpenBLAS kernel (427 tests), and the 66 example decks run on both kernels with no fallback note. Test: test_hermite_tangent_predictor, the taut line seeded with unit tangents against the same line seeded at its stretch, at rho_inf 0.5, 0.8, 0.9 and 1 and 25 and 50 steps per cycle over 20 cycles, and without the lift at rho_inf 1. Before, 7 of the 9 runs failed and one ran through reversed roots (9 assertions); now every step converges (at most 5.9 iterations per step on average, 23 at most), the strain energy stays within 1.5 times the reference's and the largest A/D within 2 %. Signed-off-by: Jae Hoon Seo --- CHANGELOG.md | 13 ++ CMakeLists.txt | 8 + doc/theory.rst | 10 ++ src/CableDyn_HermiteCableDynamic.f90 | 60 +++++++- tests/test_hermite_tangent_predictor.f90 | 177 +++++++++++++++++++++++ 5 files changed, 267 insertions(+), 1 deletion(-) create mode 100644 tests/test_hermite_tangent_predictor.f90 diff --git a/CHANGELOG.md b/CHANGELOG.md index 062478f..bc87f14 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -170,6 +170,19 @@ All notable changes to CableDyn are recorded in this file. The format follows the force scale and the correction moves no free coordinate by more than `16 eps` times its scale. A step that meets the tolerance is unchanged: every example and test deck gives bit-identical outputs. +- A finite-EI step could converge to a spurious root with every nodal tangent reversed, and the + march then failed: a taut 20 m line locked in by the VIV lift, seeded with unit tangents while + its elements were stretched by 7.6e-5, failed within 13 steps at `rho_inf` 0.8 to 1 at 25 and + 50 steps per VIV cycle (and without the lift too). The tangents' stretch is the line's stiffest + motion; with little numerical damping its seed offset rang on with a committed acceleration of + 4.9e3 1/s^2, and the constant-acceleration and Newmark guesses carried every tangent across + zero (by 3.4 and 1.7 of its length), from where Newton converged to the folded root (2.4e8 J of + strain energy against 3.5 J). A guess that changes the length of a free tangent by more than a + quarter now holds that tangent at its committed value, and a step that ends with a tangent + turned by 90 degrees or more fails, so the step recovery re-solves it. The line now runs at + `rho_inf` 0.5 to 1 and 25 and 50 steps per cycle, with the response of the same line seeded + at its stretch (largest A/D within 0.75 %). Every other step starts as before: every example + and test deck gives bit-identical outputs. ## [0.4.2] - 2026-11-09 diff --git a/CMakeLists.txt b/CMakeLists.txt index 072282f..31307a6 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1387,6 +1387,14 @@ target_link_libraries(test_hermite_viv PRIVATE cabledyn_core) add_test(NAME hermite_viv COMMAND test_hermite_viv) set_tests_properties(hermite_viv PROPERTIES LABELS "fortran;dynamic;viv") +# The Newton predictor against the ringing stretch of the nodal tangents: a taut line seeded with +# unit tangents (off the elements' stretch) at rho_inf 0.5 to 1 and 25 and 50 steps per VIV cycle, +# with and without the lift, against the same line seeded at the stretch. +add_executable(test_hermite_tangent_predictor tests/test_hermite_tangent_predictor.f90) +target_link_libraries(test_hermite_tangent_predictor PRIVATE cabledyn_core) +add_test(NAME hermite_tangent_predictor COMMAND test_hermite_tangent_predictor) +set_tests_properties(hermite_tangent_predictor PROPERTIES LABELS "fortran;dynamic;viv") + add_executable(test_hermite_viv_inline tests/test_hermite_viv_inline.f90) target_link_libraries(test_hermite_viv_inline PRIVATE cabledyn_core) add_test(NAME hermite_viv_inline COMMAND test_hermite_viv_inline) diff --git a/doc/theory.rst b/doc/theory.rst index faaab05..a386480 100644 --- a/doc/theory.rst +++ b/doc/theory.rst @@ -2899,6 +2899,16 @@ over the translational free DOFs, and from the Newmark predictor otherwise (and under-resolved mode rings, a loosely converged step would keep the extrapolated acceleration, whereas the zero guess damps it. A failed constant-acceleration attempt is re-solved from the Newmark predictor. The test uses only the committed state, so a restart is exact. +On a Hermite step either guess holds a free nodal tangent at its committed value where it +would change the tangent's length, the stretch, by more than a quarter (a strain change of 0.25 +in one step). The stretch is the line's stiffest motion (:math:`EA` against the tangents' small +consistent mass), and with little numerical damping (:math:`\rho_\infty` near 1) an offset of it +rings on with a committed velocity and acceleration far larger than the motion they make: a +taut line seeded with unit tangents, :math:`7.6\times10^{-5}` off its elements' stretch, had +every tangent carried across zero at 50 steps per VIV cycle, and Newton converged to the root +with every element folded back along its chord. A guess that only turns a tangent is kept (a +line turning fast is often right). A step that still ends with a tangent turned by 90° or more +fails, and the next attempt or the step recovery re-solves it. The ``EI = 0`` path uses an Armijo line search on :math:`\tfrac{1}{2}\lVert\mathbf{G}\rVert^2` and converges when :math:`\lVert\mathbf{G}\rVert_\infty` relative to the larger of the external load and the initial residual falls below the relative tolerance, or below the absolute diff --git a/src/CableDyn_HermiteCableDynamic.f90 b/src/CableDyn_HermiteCableDynamic.f90 index ef74065..cde6555 100644 --- a/src/CableDyn_HermiteCableDynamic.f90 +++ b/src/CableDyn_HermiteCableDynamic.f90 @@ -4878,7 +4878,7 @@ SUBROUTINE dyn_step_core(model, dt, max_iter, tol, ErrStat, ErrMsg, iters_out, r INTEGER :: axial_worst_element, iv, attempt, n_attempt INTEGER :: n_ls_tan ! tangents the step's line searches assembled at their accepted trial REAL(wp) :: c_a, c_v, c_a2, am, af, bt, gm, rnorm, fscale, rnt, lambda, chosen, lam_ok, cw, t_alpha, dth_lin - REAL(wp) :: e_bal, e_ma, tors_theta_new, tors_mt_new + REAL(wp) :: e_bal, e_ma, tors_theta_new, tors_mt_new, t_inc, t_len REAL(wp) :: axial_qe(12), axial_min REAL(wp) :: axial_threshold, axial_margin, axial_worst_margin, axial_worst_force, axial_worst_xi REAL(wp) :: axial_worst_threshold @@ -4901,6 +4901,9 @@ SUBROUTINE dyn_step_core(model, dt, max_iter, tol, ErrStat, ErrMsg, iters_out, r REAL(wp), PARAMETER :: MN_CONTRACT = 0.25_wp ! Constant-acceleration predictor gate: relative force imbalance of the committed state. REAL(wp), PARAMETER :: PRED_BALANCE = 0.5_wp + ! Largest change of the length of a free nodal tangent by the predictor, relative to that + ! length; a larger change holds the tangent at its committed value (see the predictor). + REAL(wp), PARAMETER :: PRED_STRETCH_MAX = 0.25_wp ! Cross-step reuse: at most this many accepted iterations on the carried factor per step; ! a solve still short of the tolerance then refreshes (quadratic convergence from there). INTEGER, PARAMETER :: XS_MAX_STALE = 3 @@ -5229,6 +5232,40 @@ SUBROUTINE dyn_step_core(model, dt, max_iter, tol, ErrStat, ErrMsg, iters_out, r model%ws_qk(iv) = model%ws_qn(iv) + dt*model%ws_vn(iv) + (0.5_wp - bt)*dt*dt*model%ws_an(iv) END DO END IF + ! Both guesses assume a resolved motion. The length of a nodal tangent m = dr/ds is the + ! line's stretch there, its stiffest motion (EA against the tangent's small consistent mass), + ! whose committed velocity and acceleration are those of the generalised-alpha recursion far + ! outside its resolved range: with little or no numerical damping (rho_inf near 1) it keeps + ! ringing about its balance at the offset it started from, and dt v_n or dt^2 a_n along the + ! tangent can exceed the tangent itself. A taut 20 m line of 2 m elements (EA 5e7 N) seeded + ! with unit tangents at a strain of 7.6e-5 started that mode 7.6e-5 off its balance, with + ! a_n = 4.9e3 1/s^2 along the tangents (omega ~ 8e3 rad/s, omega dt ~ 300 at dt 0.037 s, 50 + ! steps per cycle of its VIV); at rho_inf 1 both guesses carried every tangent across zero + ! (dt^2/2 a_n = 3.4, dt^2/4 a_n = 1.7), and Newton converged quadratically to the root with + ! every tangent reversed (each element folded into a Z along its chord, 2.4e8 J of strain + ! energy against 3.5 J), from which the march failed a few steps on. A guess that changes + ! the length of a free tangent by more than PRED_STRETCH_MAX of it (a strain change of 0.25 + ! in one step, which no step resolves) took that tangent's committed velocity and + ! acceleration from the ringing, so the tangent starts at its committed value: the stiff + ! mode's true increment, of the order of the strain, is a Newton step from there. Holding + ! only its length and keeping the turn of the guess converged too, but the turn rings as + ! well (the tangent's rotation is under-resolved at that step): over 20 cycles at 25 steps + ! per cycle and rho_inf 0.9 and 1, 132 steps took more than 12 iterations against 31. The + ! test is on the length alone because a guess that turns a tangent fast is often right: a + ! seabed cable whose span was lengthened 1.3 times turns two tangents 19 degrees in its + ! first 0.01 s step, and does not converge from the held tangents. Every other start is + ! unchanged. + DO i = 1, model%nn + iv = 6*(i - 1) + IF (.NOT. ALL(model%freemask(iv + 4:iv + 6))) CYCLE + t_len = NORM2(model%ws_qn(iv + 4:iv + 6)) + IF (.NOT. (t_len > CD_ZERO)) CYCLE + t_inc = DOT_PRODUCT(model%ws_qk(iv + 4:iv + 6) - model%ws_qn(iv + 4:iv + 6), model%ws_qn(iv + 4:iv + 6))/t_len + IF (ABS(t_inc) <= PRED_STRETCH_MAX*t_len) CYCLE + DO ip = iv + 4, iv + 6 + model%ws_qk(ip) = model%ws_qn(ip) + END DO + END DO ! Hold the prescribed DOFs at their target position for the whole solve (Newton never touches ! them -- they are in fixed_dofs, hence not in fmap). IF (has_pres) THEN @@ -5632,6 +5669,27 @@ SUBROUTINE dyn_step_core(model, dt, max_iter, tol, ErrStat, ErrMsg, iters_out, r IF (model%tw_active) CALL tw_accept() rnorm = rnt END DO + ! A nodal tangent turned by 90 degrees or more over one step is a root of the step's + ! equations with the element folded back on itself (the reversed-tangent root above), not a + ! motion one step resolves: the attempt fails (the next one, or the recovering step's + ! subdivision, re-solves the step). + DO i = 1, model%nn + iv = 6*(i - 1) + IF (.NOT. ANY(model%freemask(iv + 4:iv + 6))) CYCLE + IF (DOT_PRODUCT(model%ws_qk(iv + 4:iv + 6), model%ws_qn(iv + 4:iv + 6)) > CD_ZERO) CYCLE + ErrStat = CD_HCDYN_NOCONVERGE + BLOCK + CHARACTER(1024) :: wbuf + INTEGER :: wios + wbuf = '' + WRITE (wbuf, '(A,I0,A)', IOSTAT=wios) 'CD_HermiteCable_Dyn_Step: Newton converged with the tangent of node ', & + i, ' turned by 90 deg or more in one step (a spurious root with the element folded back); '// & + 'a smaller dt resolves the step' + ErrMsg = wbuf + END BLOCK + IF (attempt < n_attempt) CYCLE predict + RETURN + END DO EXIT predict END DO predict model%ws_stash_solves = nsolve_step diff --git a/tests/test_hermite_tangent_predictor.f90 b/tests/test_hermite_tangent_predictor.f90 new file mode 100644 index 0000000..e92f72c --- /dev/null +++ b/tests/test_hermite_tangent_predictor.f90 @@ -0,0 +1,177 @@ +! File: tests/test_hermite_tangent_predictor.f90 +! SPDX-License-Identifier: Apache-2.0 +! Copyright (c) 2026 Jae Hoon Seo, SMI Lab, Inha University +PROGRAM test_hermite_tangent_predictor + !! The Newton predictor of a finite-EI step and the stretch mode of the nodal tangents + !! (CableDyn_HermiteCableDynamic, dyn_step_core). A nodal tangent m = dr/ds carries the line's + !! stiffest motion, its stretch (EA against the tangent's small consistent mass, here omega ~ + !! 8e3 rad/s, omega dt ~ 300 and 600); with little numerical damping it keeps ringing at the offset + !! it starts from, and the committed velocity and acceleration of that mode are far larger than + !! the motion it makes. The constant-acceleration and Newmark guesses extrapolated them and carried + !! the tangents across zero, and Newton converged to the root with every tangent reversed (each + !! element folded into a Z along its chord, 2.4e8 J of strain energy against 3.5 J), from which the + !! march failed a few steps on. A guess that changes the length of a free tangent by more than a + !! quarter of it now holds that tangent at its committed value, and a step that still ends with a + !! tangent turned by 90 degrees or more fails. + !! + !! The line: a weightless taut line (20 m, 10 elements, D 0.1 m, 8.1 kg/m, EA 5e7 N, EI 1e3 N m^2, + !! 3.8 kN, no added mass), pinned at both ends in a 0.3 m/s cross current, Cd 1.2, and the VIV lift + !! (Cl 0.8, cF 0.18, dF 0.08, running RMS window 0.25 s), under which it locks in at about 0.63 Hz + !! with a mid-span A/D of 0.56-0.57 (the lock-in case of the long-run VIV checks). Its seed is the + !! straight line with unit tangents, while the elements are stretched by T/EA = 7.6e-5: the tangent + !! stretch mode starts 7.6e-5 off its balance (|a| = 4.9e3 1/s^2 on the tangents). The reference + !! is the same line seeded with tangents of length 1 + T/EA (balanced), which every predictor ran + !! before and runs unchanged. 20 cycles of the nominal shedding period D/(cF U) = 1.85 s (37 s). + !! + !! Gates, for rho_inf 0.5, 0.8, 0.9 and 1 at 25 and 50 steps per cycle: + !! * G1 every step of the unit-tangent seed converges (before: at rho_inf 0.8, 0.9 and 1 the run + !! failed at step 5, 13, 4 (25 steps per cycle) and 10, 7, 6 (50), each after steps on the + !! reversed root; at 25 steps per cycle and rho_inf 0.5 it ran through reversed roots to a + !! mid-span A/D of 5.7); + !! * G2 its largest strain energy stays within 1.5 times the reference's (measured at most 1.20, + !! at 25 steps per cycle and rho_inf 1; the reversed root has 3e7 times it); + !! * G3 its largest mid-span cross-flow displacement is the reference's within 2 % (measured at + !! most 0.75 %), so the ringing tangent stretch does not change the response; + !! * G4 it takes at most 8 Newton iterations per step on average and no step more than 30 (the deck + !! default budget; measured at most 5.9 and 23, at 25 steps per cycle and rho_inf 1; before, + !! the first step alone took 21 at 50 steps per cycle and rho_inf 1, now 3); + !! * G5 the same line without the lift at 50 steps per cycle and rho_inf 1 (before: failed at step + !! 38 after steps on the reversed root): every step converges, the largest strain energy is + !! within 1.5 times the reference's (measured 1.09) and the mid-span in-line deflection at the end + !! within 1 % (measured to 4 digits). + USE CableDyn_Precision, ONLY: wp + USE CableDyn_HermiteCableDynamic, ONLY: CD_HermiteCableDynType, CD_HermiteCable_Dyn_Init, & + CD_HermiteCable_Dyn_Set_Drag, CD_HermiteCable_Dyn_Set_VIV, & + CD_HermiteCable_Dyn_Step, CD_HermiteCable_Dyn_Energy, & + CD_HermiteCable_Dyn_End, CD_HCDYN_OK + IMPLICIT NONE + + REAL(wp), PARAMETER :: RHOW = 1025.0_wp, D = 0.1_wp, CF = 0.18_wp, DF = 0.08_wp, U = 0.3_wp + REAL(wp), PARAMETER :: EA = 5.0e7_wp, TENS = 3.8e3_wp + INTEGER, PARAMETER :: NCYC = 20 + + !> One run: whether every step converged, the largest strain energy, the largest mid-span + !> cross-flow displacement, the mid-span in-line deflection at the end, the mean iterations. + TYPE :: run_result + LOGICAL :: ok = .FALSE. + INTEGER :: nstep = 0 + INTEGER :: max_iters = 0 + REAL(wp) :: es_max = 0.0_wp, z_max = 0.0_wp, y_end = 0.0_wp, iters = 0.0_wp + END TYPE run_result + + INTEGER :: nfail = 0, ir, ip + REAL(wp), PARAMETER :: RHOS(4) = [0.5_wp, 0.8_wp, 0.9_wp, 1.0_wp] + INTEGER, PARAMETER :: NPERS(2) = [25, 50] + TYPE(run_result) :: unit, ref + CHARACTER(64) :: lab + + DO ip = 1, SIZE(NPERS) + DO ir = 1, SIZE(RHOS) + WRITE (lab, '(A,F4.2,A,I0,A)') 'rho_inf ', RHOS(ir), ', ', NPERS(ip), ' steps per cycle' + CALL run(NPERS(ip), RHOS(ir), .TRUE., 1.0_wp, unit) + CALL run(NPERS(ip), RHOS(ir), .TRUE., 1.0_wp + TENS/EA, ref) + CALL report(lab, unit, ref) + CALL require(ref%ok, 'reference '//TRIM(lab)//': every step converges') + CALL require(unit%ok, 'G1 '//TRIM(lab)//': every step of the unit-tangent seed converges') + IF (.NOT. (unit%ok .AND. ref%ok)) CYCLE + CALL require(unit%es_max <= 1.5_wp*ref%es_max, 'G2 '//TRIM(lab)//': the strain energy stays bounded') + CALL require(ABS(unit%z_max - ref%z_max) <= 0.02_wp*ref%z_max, & + 'G3 '//TRIM(lab)//': the cross-flow response is the balanced seed''s') + CALL require(unit%iters <= 8.0_wp .AND. unit%max_iters <= 30, & + 'G4 '//TRIM(lab)//': Newton converges in a few iterations') + END DO + END DO + CALL run(50, 1.0_wp, .FALSE., 1.0_wp, unit) + CALL run(50, 1.0_wp, .FALSE., 1.0_wp + TENS/EA, ref) + CALL report('no lift, rho_inf 1.00, 50 steps per cycle', unit, ref) + CALL require(ref%ok .AND. unit%ok, 'G5 no lift: every step converges') + IF (ref%ok .AND. unit%ok) THEN + CALL require(unit%es_max <= 1.5_wp*ref%es_max, 'G5 no lift: the strain energy stays bounded') + CALL require(ABS(unit%y_end - ref%y_end) <= 0.01_wp*ABS(ref%y_end), & + 'G5 no lift: the in-line deflection is the balanced seed''s') + END IF + IF (nfail > 0) THEN + WRITE (*, '(A,I0,A)') 'FAIL: ', nfail, ' assertion(s) failed' + ERROR STOP 1 + END IF + WRITE (*, '(A)') 'PASS: the predictor holds the ringing tangent stretch' + +CONTAINS + + SUBROUTINE require(cond, label) + LOGICAL, INTENT(IN) :: cond + CHARACTER(*), INTENT(IN) :: label + IF (cond) RETURN + nfail = nfail + 1 + WRITE (*, '(A)') 'FAIL: '//TRIM(label) + END SUBROUTINE require + + SUBROUTINE report(label, a, b) + CHARACTER(*), INTENT(IN) :: label + TYPE(run_result), INTENT(IN) :: a, b + WRITE (*, '(2X,A,A,I0,A,L1,A,3ES11.3,F6.2,I4,A,3ES11.3,F6.2,I4)') TRIM(label), ': unit seed steps ', a%nstep, & + ' ok ', a%ok, ' (Es max, z max/D, y end, mean and max iterations) ', a%es_max, a%z_max/D, a%y_end, a%iters, & + a%max_iters, & + '; balanced ', b%es_max, b%z_max/D, b%y_end, b%iters, b%max_iters + END SUBROUTINE report + + SUBROUTINE run(nper, rho_inf, with_lift, m0, res) + !! The taut line from its straight seed with tangents of length m0, over NCYC nominal cycles. + INTEGER, INTENT(IN) :: nper + REAL(wp), INTENT(IN) :: rho_inf, m0 + LOGICAL, INTENT(IN) :: with_lift + TYPE(run_result), INTENT(OUT) :: res + INTEGER, PARAMETER :: NE = 10, NN = NE + 1, MIDN = NE/2 + 1 + REAL(wp), PARAMETER :: SPAN = 20.0_wp, Z0 = -50.0_wp, MLIN = 8.1_wp + TYPE(CD_HermiteCableDynType) :: hm + REAL(wp) :: seed(6*NN), l0(NE), eav(NE), eiv(NE), rhoa(NE), wv(NE), hd(NE), hn(NE), ht(NE) + REAL(wp) :: cl(NE), cfv(NE), dfv(NE), dt, ek, es_ + INTEGER :: i, n, es, its, nit + CHARACTER(1024) :: em + dt = D/(CF*U)/REAL(nper, wp) + l0 = SPAN/REAL(NE, wp)/(1.0_wp + TENS/EA) + eav = EA; rhoa = MLIN; eiv = 1.0e3_wp; wv = 0.0_wp + seed = 0.0_wp + DO i = 1, NN + seed(6*(i - 1) + 1) = SPAN*REAL(i - 1, wp)/REAL(NE, wp) + seed(6*(i - 1) + 3) = Z0 + seed(6*(i - 1) + 4) = m0 + END DO + CALL CD_HermiteCable_Dyn_Init(hm, l0, eav, eiv, rhoa, wv, seed, [1, 2, 3, 6*NE + 1, 6*NE + 2, 6*NE + 3], & + -1.0e4_wp, 0.0_wp, rho_inf, es, em) + IF (es == CD_HCDYN_OK) THEN + hd = D; hn = 1.2_wp; ht = 0.0_wp + CALL CD_HermiteCable_Dyn_Set_Drag(hm, RHOW, hd, hn, ht, 0.0_wp, [0.0_wp, U, 0.0_wp], es, em) + END IF + IF (es == CD_HCDYN_OK .AND. with_lift) THEN + cl = 0.8_wp; cfv = CF; dfv = DF + CALL CD_HermiteCable_Dyn_Set_VIV(hm, cl, cfv, dfv, 0.25_wp, es, em) + END IF + CALL require(es == CD_HCDYN_OK, 'the line sets up: '//TRIM(em)) + IF (es /= CD_HCDYN_OK) RETURN + nit = 0 + res%ok = .TRUE. + DO n = 1, nper*NCYC + CALL CD_HermiteCable_Dyn_Step(hm, dt, 50, 1.0e-8_wp, es, em, iters_out=its) + IF (es /= CD_HCDYN_OK) THEN + res%ok = .FALSE. + WRITE (*, '(A,I0,A)') ' step ', n, ': '//TRIM(em) + EXIT + END IF + res%nstep = n + nit = nit + its + res%max_iters = MAX(res%max_iters, its) + CALL CD_HermiteCable_Dyn_Energy(hm, ek, es_, es, em) + IF (es /= CD_HCDYN_OK) THEN + res%ok = .FALSE. + EXIT + END IF + res%es_max = MAX(res%es_max, es_) + res%z_max = MAX(res%z_max, ABS(hm%q(6*(MIDN - 1) + 3) - Z0)) + END DO + res%y_end = hm%q(6*(MIDN - 1) + 2) + res%iters = REAL(nit, wp)/REAL(MAX(1, res%nstep), wp) + CALL CD_HermiteCable_Dyn_End(hm) + END SUBROUTINE run + +END PROGRAM test_hermite_tangent_predictor From 86194754141964527b48583c458ecdc43850ca8e Mon Sep 17 00:00:00 2001 From: Jae Hoon Seo Date: Mon, 16 Nov 2026 09:06:35 +0900 Subject: [PATCH 2/2] The predictor guard holds the free components of a partly constrained tangent The guard skipped every node with a fixed tangent component, so on a planar model (out-of-plane tangent component fixed at every node) it never acted, and the reversed-tangent check then stopped the run with no guarded predictor to recover from. The guard now acts where any tangent component is free: the length change is that of the free components' increment, and only they are held. Test: G6, the no-lift line of G5 kept in its plane (r_z and m_z fixed at every node), at rho_inf 1 and 50 steps per cycle. It now runs as G5 (1000 steps, the same energy, deflection and iterations); before, it stopped at step 2 on the reversed-tangent check. Signed-off-by: Jae Hoon Seo --- doc/theory.rst | 3 +- src/CableDyn_HermiteCableDynamic.f90 | 16 ++++--- tests/test_hermite_tangent_predictor.f90 | 54 +++++++++++++++++------- 3 files changed, 51 insertions(+), 22 deletions(-) diff --git a/doc/theory.rst b/doc/theory.rst index a386480..eec0d44 100644 --- a/doc/theory.rst +++ b/doc/theory.rst @@ -2901,7 +2901,8 @@ whereas the zero guess damps it. A failed constant-acceleration attempt is re-so Newmark predictor. The test uses only the committed state, so a restart is exact. On a Hermite step either guess holds a free nodal tangent at its committed value where it would change the tangent's length, the stretch, by more than a quarter (a strain change of 0.25 -in one step). The stretch is the line's stiffest motion (:math:`EA` against the tangents' small +in one step). A tangent with some components fixed (a planar model fixes the out-of-plane one) +is held on its free components, by their change of the length. The stretch is the line's stiffest motion (:math:`EA` against the tangents' small consistent mass), and with little numerical damping (:math:`\rho_\infty` near 1) an offset of it rings on with a committed velocity and acceleration far larger than the motion they make: a taut line seeded with unit tangents, :math:`7.6\times10^{-5}` off its elements' stretch, had diff --git a/src/CableDyn_HermiteCableDynamic.f90 b/src/CableDyn_HermiteCableDynamic.f90 index cde6555..7e320ee 100644 --- a/src/CableDyn_HermiteCableDynamic.f90 +++ b/src/CableDyn_HermiteCableDynamic.f90 @@ -5253,17 +5253,23 @@ SUBROUTINE dyn_step_core(model, dt, max_iter, tol, ErrStat, ErrMsg, iters_out, r ! per cycle and rho_inf 0.9 and 1, 132 steps took more than 12 iterations against 31. The ! test is on the length alone because a guess that turns a tangent fast is often right: a ! seabed cable whose span was lengthened 1.3 times turns two tangents 19 degrees in its - ! first 0.01 s step, and does not converge from the held tangents. Every other start is - ! unchanged. + ! first 0.01 s step, and does not converge from the held tangents. A node with some tangent + ! components fixed (a planar model fixes the out-of-plane one) is guarded on its free + ! components: the length change is that of the free components' increment, and only they are + ! held. Every other start is unchanged. DO i = 1, model%nn iv = 6*(i - 1) - IF (.NOT. ALL(model%freemask(iv + 4:iv + 6))) CYCLE + IF (.NOT. ANY(model%freemask(iv + 4:iv + 6))) CYCLE t_len = NORM2(model%ws_qn(iv + 4:iv + 6)) IF (.NOT. (t_len > CD_ZERO)) CYCLE - t_inc = DOT_PRODUCT(model%ws_qk(iv + 4:iv + 6) - model%ws_qn(iv + 4:iv + 6), model%ws_qn(iv + 4:iv + 6))/t_len + t_inc = 0.0_wp + DO ip = iv + 4, iv + 6 + IF (model%freemask(ip)) t_inc = t_inc + (model%ws_qk(ip) - model%ws_qn(ip))*model%ws_qn(ip) + END DO + t_inc = t_inc/t_len IF (ABS(t_inc) <= PRED_STRETCH_MAX*t_len) CYCLE DO ip = iv + 4, iv + 6 - model%ws_qk(ip) = model%ws_qn(ip) + IF (model%freemask(ip)) model%ws_qk(ip) = model%ws_qn(ip) END DO END DO ! Hold the prescribed DOFs at their target position for the whole solve (Newton never touches diff --git a/tests/test_hermite_tangent_predictor.f90 b/tests/test_hermite_tangent_predictor.f90 index e92f72c..dae1eaf 100644 --- a/tests/test_hermite_tangent_predictor.f90 +++ b/tests/test_hermite_tangent_predictor.f90 @@ -38,7 +38,11 @@ PROGRAM test_hermite_tangent_predictor !! * G5 the same line without the lift at 50 steps per cycle and rho_inf 1 (before: failed at step !! 38 after steps on the reversed root): every step converges, the largest strain energy is !! within 1.5 times the reference's (measured 1.09) and the mid-span in-line deflection at the end - !! within 1 % (measured to 4 digits). + !! within 1 % (measured to 4 digits); + !! * G6 the same no-lift line kept in its plane (r_z and m_z fixed at every node, the planar + !! constraint pattern): the guard applies to the free tangent components of a partly + !! constrained node, so it runs as G5 (before: the guard skipped every node with a fixed + !! tangent component, and the reversed-root check stopped the run). USE CableDyn_Precision, ONLY: wp USE CableDyn_HermiteCableDynamic, ONLY: CD_HermiteCableDynType, CD_HermiteCable_Dyn_Init, & CD_HermiteCable_Dyn_Set_Drag, CD_HermiteCable_Dyn_Set_VIV, & @@ -68,8 +72,8 @@ PROGRAM test_hermite_tangent_predictor DO ip = 1, SIZE(NPERS) DO ir = 1, SIZE(RHOS) WRITE (lab, '(A,F4.2,A,I0,A)') 'rho_inf ', RHOS(ir), ', ', NPERS(ip), ' steps per cycle' - CALL run(NPERS(ip), RHOS(ir), .TRUE., 1.0_wp, unit) - CALL run(NPERS(ip), RHOS(ir), .TRUE., 1.0_wp + TENS/EA, ref) + CALL run(NPERS(ip), RHOS(ir), .TRUE., .FALSE., 1.0_wp, unit) + CALL run(NPERS(ip), RHOS(ir), .TRUE., .FALSE., 1.0_wp + TENS/EA, ref) CALL report(lab, unit, ref) CALL require(ref%ok, 'reference '//TRIM(lab)//': every step converges') CALL require(unit%ok, 'G1 '//TRIM(lab)//': every step of the unit-tangent seed converges') @@ -81,15 +85,14 @@ PROGRAM test_hermite_tangent_predictor 'G4 '//TRIM(lab)//': Newton converges in a few iterations') END DO END DO - CALL run(50, 1.0_wp, .FALSE., 1.0_wp, unit) - CALL run(50, 1.0_wp, .FALSE., 1.0_wp + TENS/EA, ref) + CALL run(50, 1.0_wp, .FALSE., .FALSE., 1.0_wp, unit) + CALL run(50, 1.0_wp, .FALSE., .FALSE., 1.0_wp + TENS/EA, ref) CALL report('no lift, rho_inf 1.00, 50 steps per cycle', unit, ref) - CALL require(ref%ok .AND. unit%ok, 'G5 no lift: every step converges') - IF (ref%ok .AND. unit%ok) THEN - CALL require(unit%es_max <= 1.5_wp*ref%es_max, 'G5 no lift: the strain energy stays bounded') - CALL require(ABS(unit%y_end - ref%y_end) <= 0.01_wp*ABS(ref%y_end), & - 'G5 no lift: the in-line deflection is the balanced seed''s') - END IF + CALL no_lift_gates('G5 no lift', unit, ref) + CALL run(50, 1.0_wp, .FALSE., .TRUE., 1.0_wp, unit) + CALL run(50, 1.0_wp, .FALSE., .TRUE., 1.0_wp + TENS/EA, ref) + CALL report('planar, no lift, rho_inf 1.00, 50 steps per cycle', unit, ref) + CALL no_lift_gates('G6 planar no lift', unit, ref) IF (nfail > 0) THEN WRITE (*, '(A,I0,A)') 'FAIL: ', nfail, ' assertion(s) failed' ERROR STOP 1 @@ -106,6 +109,16 @@ SUBROUTINE require(cond, label) WRITE (*, '(A)') 'FAIL: '//TRIM(label) END SUBROUTINE require + SUBROUTINE no_lift_gates(label, a, b) + CHARACTER(*), INTENT(IN) :: label + TYPE(run_result), INTENT(IN) :: a, b + CALL require(b%ok .AND. a%ok, label//': every step converges') + IF (.NOT. (b%ok .AND. a%ok)) RETURN + CALL require(a%es_max <= 1.5_wp*b%es_max, label//': the strain energy stays bounded') + CALL require(ABS(a%y_end - b%y_end) <= 0.01_wp*ABS(b%y_end), & + label//': the in-line deflection is the balanced seed''s') + END SUBROUTINE no_lift_gates + SUBROUTINE report(label, a, b) CHARACTER(*), INTENT(IN) :: label TYPE(run_result), INTENT(IN) :: a, b @@ -115,11 +128,12 @@ SUBROUTINE report(label, a, b) '; balanced ', b%es_max, b%z_max/D, b%y_end, b%iters, b%max_iters END SUBROUTINE report - SUBROUTINE run(nper, rho_inf, with_lift, m0, res) - !! The taut line from its straight seed with tangents of length m0, over NCYC nominal cycles. + SUBROUTINE run(nper, rho_inf, with_lift, planar, m0, res) + !! The taut line from its straight seed with tangents of length m0, over NCYC nominal cycles; + !! planar fixes r_z and m_z at every node (the line moves in the plane of the current). INTEGER, INTENT(IN) :: nper REAL(wp), INTENT(IN) :: rho_inf, m0 - LOGICAL, INTENT(IN) :: with_lift + LOGICAL, INTENT(IN) :: with_lift, planar TYPE(run_result), INTENT(OUT) :: res INTEGER, PARAMETER :: NE = 10, NN = NE + 1, MIDN = NE/2 + 1 REAL(wp), PARAMETER :: SPAN = 20.0_wp, Z0 = -50.0_wp, MLIN = 8.1_wp @@ -127,6 +141,7 @@ SUBROUTINE run(nper, rho_inf, with_lift, m0, res) REAL(wp) :: seed(6*NN), l0(NE), eav(NE), eiv(NE), rhoa(NE), wv(NE), hd(NE), hn(NE), ht(NE) REAL(wp) :: cl(NE), cfv(NE), dfv(NE), dt, ek, es_ INTEGER :: i, n, es, its, nit + INTEGER, ALLOCATABLE :: fixed(:) CHARACTER(1024) :: em dt = D/(CF*U)/REAL(nper, wp) l0 = SPAN/REAL(NE, wp)/(1.0_wp + TENS/EA) @@ -137,8 +152,15 @@ SUBROUTINE run(nper, rho_inf, with_lift, m0, res) seed(6*(i - 1) + 3) = Z0 seed(6*(i - 1) + 4) = m0 END DO - CALL CD_HermiteCable_Dyn_Init(hm, l0, eav, eiv, rhoa, wv, seed, [1, 2, 3, 6*NE + 1, 6*NE + 2, 6*NE + 3], & - -1.0e4_wp, 0.0_wp, rho_inf, es, em) + fixed = [1, 2, 3, 6*NE + 1, 6*NE + 2, 6*NE + 3] + IF (planar) THEN + fixed = [1, 2, 3, 6] + DO i = 2, NN - 1 + fixed = [fixed, 6*(i - 1) + 3, 6*(i - 1) + 6] + END DO + fixed = [fixed, 6*NE + 1, 6*NE + 2, 6*NE + 3, 6*NE + 6] + END IF + CALL CD_HermiteCable_Dyn_Init(hm, l0, eav, eiv, rhoa, wv, seed, fixed, -1.0e4_wp, 0.0_wp, rho_inf, es, em) IF (es == CD_HCDYN_OK) THEN hd = D; hn = 1.2_wp; ht = 0.0_wp CALL CD_HermiteCable_Dyn_Set_Drag(hm, RHOW, hd, hn, ht, 0.0_wp, [0.0_wp, U, 0.0_wp], es, em)