From 798e1d0b81d13ee15418a57b8d15d70af883d61c Mon Sep 17 00:00:00 2001 From: Jae Hoon Seo Date: Wed, 25 Nov 2026 17:47:08 +0900 Subject: [PATCH] fix: one slow strain at a Syrope rope's running maximum The Syrope kernel recovered the mean tension on the OWC by interpolating the slow strains of the table rows, while the working curve's top sample used the exact fast-spring strain at the running maximum. Between the two (up to 9e-7 of strain on the shipped 30-row table) the recovered tension did not change, so every slow strain of that band was a rest point of a rope at its running maximum. A static start took the one its rounding chose: two starts of the composite example whose tensions agreed to 1e-10 put all elements at one edge of the band, or half of them at each, and the runs differed by 3.8e-5 to 2.3e-4 of the channel maxima, more at finer time steps. The OWC recovery is now the exact inverse of eps_owc(T) - eps_fast(T) (Newton from the row's upper end, monotone because the residual is convex in T), and the working curve's top sample is the divider to the bit. Two starts then agree to 4e-8 at every step size, and the result no longer depends on the spacing of the OWC rows. The former program converges to it as its table is refined: 1.4e-4, 5.2e-6, 9.5e-7 and 9.5e-8 at 1, 4, 16 and 64 times the rows. On the OWC the recovery differs from MoorDyn's, which interpolates the rows; on the working curve and for a length change at rest the kernel keeps MoorDyn's tension. The inverse needs the slow strain to rise along the whole row. The check at init compared the row ends only, so a row steeper than the fast spring at its start now stops with a named error. Signed-off-by: Jae Hoon Seo --- CHANGELOG.md | 10 ++++ src/CableDyn_Syrope.f90 | 105 ++++++++++++++++++++++++++-------- tests/test_syrope.f90 | 99 +++++++++++++++++++++++++++----- tests/test_syrope_control.f90 | 22 ++++--- 4 files changed, 191 insertions(+), 45 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7eec942a..3281a24c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,16 @@ All notable changes to CableDyn are recorded in this file. The format follows ### Fixed +- A Syrope rope at its running maximum had a band of slow strains, up to 9e-7 wide on the shipped table, + over which its recovered mean tension did not change, so every one of them was a rest point and rounding + chose the one a static start took. Two starts of the composite example that agreed to 1e-10 gave runs + that differed by up to 2.3e-4 of the channel maxima. The OWC recovery is now the exact inverse of + `eps_owc(T) - eps_fast(T)`, where it interpolated the slow strains of the table rows, and the working + curve meets it at one slow strain. Results of a rope loaded along its OWC change by about the size of + the former interpolation error (1.4e-4 on the composite example) and no longer depend on the spacing + of the OWC rows. On the OWC the recovery differs from MoorDyn's, which interpolates the rows. + A table with a row steeper than the fast spring at the row's start stops with a named error. + - A Syrope line whose rest tension is a small part of its past one (a `SYROPE IC` `Tmax0` well above the installed tension, as of a polyester mooring line after a storm that loaded it) failed to start when its static secants, far below the working curve's tangent along the whole line, did not settle in 50 diff --git a/src/CableDyn_Syrope.f90 b/src/CableDyn_Syrope.f90 index 3fd1718c..bd2bf203 100644 --- a/src/CableDyn_Syrope.f90 +++ b/src/CableDyn_Syrope.f90 @@ -188,10 +188,16 @@ SUBROUTINE CD_Syrope_Init(td, owc_strain, owc_tension, wc_mod, p1, p2, alpha, be RETURN END IF DO i = 2, n - IF (td%owc_slow(i) <= td%owc_slow(i - 1)) THEN + ! Within a row the slow strain is convex in the tension, so it increases throughout where it + ! does at the row's start: the row's slope dT/deps must lie below the fast spring's stiffness + ! alpha + beta T there (a row that falls first and then rises has increasing ends, and no + ! inverse). + IF (td%owc_slow(i) <= td%owc_slow(i - 1) .OR. & + .NOT. (owc_tension(i) - owc_tension(i - 1) < (alpha + beta*owc_tension(i - 1))* & + (owc_strain(i) - owc_strain(i - 1)))) THEN CALL CD_Syrope_End(td) CALL fail(ErrStat, ErrMsg, 'the OWC slow-spring static strain must be strictly increasing '// & - '(the alpha/beta fast spring is too soft for this table)') + 'along every row (the alpha/beta fast spring is too soft for this table)') RETURN END IF END DO @@ -335,6 +341,9 @@ SUBROUTINE CD_Syrope_Working_Curve(td, t_max, wc_strain, wc_tension, wc_slow, Er END SELECT wc_slow(i) = wc_strain(i) - CD_Syrope_Fast_Strain(td, wc_tension(i)) END DO + ! the top sample is the OWC's slow strain at t_max, to the bit: the branches join at one slow + ! strain, the divider (the sampled value differs from it by rounding) + wc_slow(CD_SYROPE_NWC) = CD_Syrope_Branch_Divider(td, t_max) IF (.NOT. (CD_All_Finite(wc_tension) .AND. CD_All_Finite(wc_slow))) THEN CALL fail(ErrStat, ErrMsg, 'the working curve has non-finite samples at this T_max (degenerate '// & 'shape parameters)') @@ -379,10 +388,11 @@ SUBROUTINE CD_Syrope_Find_Strains(td, on_wc, wc_strain, wc_tension, t_mean, & !! The static strain split at a mean tension: !! total curve strain, the fast-spring share, and the slow-spring share. !! on_wc selects the working curve (t_mean below the running max) vs the - !! OWC frontier. This is MoorDyn's exact-log partition; the kernel recovers - !! T_mean by interpolating the node-sampled slow table, so seeding a state - !! from slow_strain misses the rest point by the fast spring's interpolation - !! error. CD_Syrope_Slow_At_Mean returns the exact rest-point slow strain. + !! OWC frontier. This is MoorDyn's exact-log partition. On the working curve + !! the kernel recovers T_mean by interpolating the node-sampled slow table, so + !! seeding a state from slow_strain misses the rest point there by the fast + !! spring's interpolation error. CD_Syrope_Slow_At_Mean returns the exact + !! rest-point slow strain. TYPE(CD_SyropeType), INTENT(IN) :: td LOGICAL, INTENT(IN) :: on_wc REAL(wp), INTENT(IN) :: wc_strain(CD_SYROPE_NWC), wc_tension(CD_SYROPE_NWC), t_mean @@ -398,8 +408,8 @@ END SUBROUTINE CD_Syrope_Find_Strains PURE REAL(wp) FUNCTION CD_Syrope_Slow_At_Mean(td, on_wc, wc_tension, wc_slow, t_mean) RESULT(slow) !! The slow-spring strain whose kernel recovery returns exactly t_mean: the - !! inverse of the piecewise-linear T_mean(eps_slow) interpolation on the - !! selected branch table. With it, eps = eps_curve(t_mean) and zero strain + !! inverse of the working curve's piecewise-linear T_mean(eps_slow) + !! interpolation, or of the OWC's exact recovery. With it, eps = eps_curve(t_mean) and zero strain !! rate is an exact rest point (tension t_mean, zero slow-strain rate). TYPE(CD_SyropeType), INTENT(IN) :: td LOGICAL, INTENT(IN) :: on_wc @@ -407,7 +417,7 @@ PURE REAL(wp) FUNCTION CD_Syrope_Slow_At_Mean(td, on_wc, wc_tension, wc_slow, t_ IF (on_wc) THEN slow = interp(t_mean, wc_tension, wc_slow) ELSE - slow = interp(t_mean, td%owc_tension, td%owc_slow) + slow = CD_Syrope_Slow_At_Tmax(td, t_mean) END IF END FUNCTION CD_Syrope_Slow_At_Mean @@ -490,7 +500,7 @@ SUBROUTINE CD_Syrope_Rate_And_Tension(td, on_wc, wc_strain, wc_tension, wc_slow, t_mean = interp(slow_eps, wc_slow, wc_tension) eps_static = interp(t_mean, wc_tension, wc_strain) ELSE - t_mean = interp(slow_eps, td%owc_slow, td%owc_tension) + t_mean = owc_tension_at_slow(td, slow_eps) eps_static = interp(t_mean, td%owc_tension, td%owc_strain) END IF k1 = td%alpha + td%beta*t_mean @@ -601,8 +611,8 @@ SUBROUTINE CD_Syrope_State_Advance(td, on_wc, wc_strain, wc_tension, wc_slow, sl END DO ! The safeguarded Newton step can creep along one side of the bracket when the root lies ! closer to a kink of the rate than its difference interval h, where the slope of - ! T_mean(eps_slow) changes (the top sample of the working curve, beyond which its - ! interpolation clamps at T_max, as when a rope rests on its OWC at its running maximum): + ! T_mean(eps_slow) changes (the top sample of the working curve, where the OWC takes over, + ! as when a rope rests on its OWC at its running maximum): ! the difference quotient straddles the kink, and every step lands inside the bracket and ! moves only that end. Finish then by bisection, which halves the bracket every iteration ! (R is continuous on it, so the bracket closes on its root) until the residual test is met. @@ -657,13 +667,12 @@ END SUBROUTINE CD_Syrope_State_Advance PURE REAL(wp) FUNCTION CD_Syrope_Branch_Divider(td, t_max) RESULT(divider) !! The slow strain dividing the working-curve and OWC branches at the running - !! maximum t_max: the OWC recovery's exact inverse at t_max, so the recovered - !! mean tension is continuous across the switch (the working curve clamps at - !! t_max up to the divider, the OWC returns t_max at it). It lies at or above - !! CD_Syrope_Slow_At_Tmax (the exact-log value; equal at table rows). + !! maximum t_max: the OWC's slow strain at t_max (CD_Syrope_Slow_At_Tmax), which + !! is also the top sample of the working curve's slow strains, so the recovered + !! mean tension is continuous across the switch. TYPE(CD_SyropeType), INTENT(IN) :: td REAL(wp), INTENT(IN) :: t_max - divider = interp(t_max, td%owc_tension, td%owc_slow) + divider = CD_Syrope_Slow_At_Tmax(td, t_max) END FUNCTION CD_Syrope_Branch_Divider SUBROUTINE CD_Syrope_Static_Tension(td, t_max, eps, tension, ErrStat, ErrMsg) @@ -751,9 +760,7 @@ END SUBROUTINE CD_Syrope_Slow_For_Tension PURE REAL(wp) FUNCTION CD_Syrope_Slow_At_Tmax(td, t_max) RESULT(slow_at) !! The exact-log slow-spring static strain at the running maximum tension: !! eps_owc(t_max) minus the fast-spring strain at t_max (the regenerated working - !! curve and the OWC coincide at t_max). It is not the branch divider the model - !! uses, which is CD_Syrope_Branch_Divider (the interpolated inverse, at or above - !! this value). + !! curve and the OWC coincide at t_max). TYPE(CD_SyropeType), INTENT(IN) :: td REAL(wp), INTENT(IN) :: t_max slow_at = interp(t_max, td%owc_tension, td%owc_strain) - CD_Syrope_Fast_Strain(td, t_max) @@ -918,8 +925,9 @@ PURE SUBROUTINE rate_slow_partial(td, on_wc, wc_strain, wc_tension, wc_slow, slo r_s, dtm_ds) !! Partial derivatives, at fixed (eps, deps), of the slow-strain rate !! r = (K1*(eps - eps_static(T_mean)) + c2*deps)/(c1 + c2) and of T_mean with - !! respect to the slow strain, on the same piecewise-linear segments the - !! kernel interpolates (zero slope where the interpolation clamps). + !! respect to the slow strain, of the kernel's own recovery: the piecewise-linear + !! segments of the working curve or the OWC's exact inverse (zero slope where + !! the recovery clamps). TYPE(CD_SyropeType), INTENT(IN) :: td LOGICAL, INTENT(IN) :: on_wc REAL(wp), INTENT(IN) :: wc_strain(CD_SYROPE_NWC), wc_tension(CD_SYROPE_NWC), wc_slow(CD_SYROPE_NWC) @@ -931,13 +939,64 @@ PURE SUBROUTINE rate_slow_partial(td, on_wc, wc_strain, wc_tension, wc_slow, slo de_dtm = interp_slope(t_mean, wc_tension, wc_strain) eps_static = interp(t_mean, wc_tension, wc_strain) ELSE - dtm_ds = interp_slope(slow_eps, td%owc_slow, td%owc_tension) + dtm_ds = owc_tension_slope(td, slow_eps, t_mean) de_dtm = interp_slope(t_mean, td%owc_tension, td%owc_strain) eps_static = interp(t_mean, td%owc_tension, td%owc_strain) END IF r_s = (td%beta*dtm_ds*(eps - eps_static) - (td%alpha + td%beta*t_mean)*de_dtm*dtm_ds)/(td%c1 + td%c2) END SUBROUTINE rate_slow_partial + PURE REAL(wp) FUNCTION owc_tension_at_slow(td, slow) RESULT(t_mean) + !! The OWC tension at a slow-spring strain: the exact inverse of eps_owc(T) - eps_fast(T), with + !! eps_owc linear between the table rows, constant beyond the first and last one. A straight + !! line between the rows' slow strains would reach a running maximum above its exact slow + !! strain by up to the fast spring's curvature over the row (about 1e-6): between the two, the + !! recovered tension would not change and every slow strain would be a rest point of a rope at + !! its running maximum, the rounding of a static start choosing one. The row's residual is + !! convex in T (the fast strain is concave) and its chord rises, so Newton from the row's upper + !! end falls monotonically to the root. + TYPE(CD_SyropeType), INTENT(IN) :: td + REAL(wp), INTENT(IN) :: slow + REAL(wp) :: de_dt, t, dt_ + INTEGER :: i, n, it + n = SIZE(td%owc_slow) + IF (slow <= td%owc_slow(1)) THEN + t_mean = td%owc_tension(1) + RETURN + END IF + IF (slow >= td%owc_slow(n)) THEN + t_mean = td%owc_tension(n) + RETURN + END IF + DO i = 2, n - 1 + IF (slow <= td%owc_slow(i)) EXIT + END DO + de_dt = (td%owc_strain(i) - td%owc_strain(i - 1))/(td%owc_tension(i) - td%owc_tension(i - 1)) + t = td%owc_tension(i) + DO it = 1, 60 + dt_ = (td%owc_strain(i - 1) + de_dt*(t - td%owc_tension(i - 1)) - CD_Syrope_Fast_Strain(td, t) - slow)/ & + (de_dt - CD_ONE/(td%alpha + td%beta*t)) + t = t - dt_ + IF (.NOT. (ABS(dt_) > 8.0_wp*EPSILON(CD_ONE)*ABS(t))) EXIT + END DO + t_mean = MIN(MAX(t, td%owc_tension(i - 1)), td%owc_tension(i)) + END FUNCTION owc_tension_at_slow + + PURE REAL(wp) FUNCTION owc_tension_slope(td, slow, t_mean) RESULT(dtm_ds) + !! d T_mean/d eps_slow of owc_tension_at_slow (zero on the clamped ends), t_mean its value at slow. + TYPE(CD_SyropeType), INTENT(IN) :: td + REAL(wp), INTENT(IN) :: slow, t_mean + INTEGER :: i, n + n = SIZE(td%owc_slow) + dtm_ds = CD_ZERO + IF (slow <= td%owc_slow(1) .OR. slow >= td%owc_slow(n)) RETURN + DO i = 2, n - 1 + IF (slow <= td%owc_slow(i)) EXIT + END DO + dtm_ds = CD_ONE/((td%owc_strain(i) - td%owc_strain(i - 1))/(td%owc_tension(i) - td%owc_tension(i - 1)) - & + CD_ONE/(td%alpha + td%beta*t_mean)) + END FUNCTION owc_tension_slope + PURE REAL(wp) FUNCTION interp_slope(x, xp, fp) RESULT(dydx) !! The slope of the segment interp uses at x (zero on the clamped ends). REAL(wp), INTENT(IN) :: x, xp(:), fp(:) diff --git a/tests/test_syrope.f90 b/tests/test_syrope.f90 index c9a658ce..637e01af 100644 --- a/tests/test_syrope.f90 +++ b/tests/test_syrope.f90 @@ -69,6 +69,7 @@ PROGRAM test_syrope CALL case_quadratic() CALL case_exp() CALL case_owc_branch_and_running_max() + CALL case_branches_join() CALL case_interp_clamps() CALL case_projected_state_advance() CALL case_state_advance_at_wc_top() @@ -150,6 +151,12 @@ SUBROUTINE case_fail_closed() CALL require(es /= CD_SYROPE_OK .AND. INDEX(em, 'non-finite') > 0, 'fail:owc-nonfinite-slow') END BLOCK CALL CD_Syrope_End(td) + ! a row whose slow strain falls at its start and rises at its end: its ends increase, yet it + ! has no inverse (row slope 1.6e8 N, fast stiffness 1.53e8 N at the start and 1.76e8 N at the end) + CALL CD_Syrope_Init(td, [0.0_wp, 6.25e-3_wp], [0.0_wp, 1.0e6_wp], CD_SYROPE_WC_LINEAR, 0.5_wp, 0.0_wp, & + ALPHA, BETA, C1, C2, es, em) + CALL require(6.25e-3_wp > LOG(1.0_wp + BETA/ALPHA*1.0e6_wp)/BETA, 'fail:the row ends increase') + CALL require(es /= CD_SYROPE_OK .AND. INDEX(em, 'along every row') > 0, 'fail:a row without an inverse') END SUBROUTINE case_fail_closed SUBROUTINE case_degenerate_wc() @@ -275,7 +282,9 @@ END SUBROUTINE write_reference_row SUBROUTINE case_owc_branch_and_running_max() !! Committed mean tension AT/ABOVE the running max selects the OWC branch, !! and the recovered mean tension above T_max is the caller's regeneration - !! event: the regenerated curve matches the production formula. + !! event: the regenerated curve matches the production formula. The recovery is the + !! exact inverse of eps_owc(T) - eps_fast(T) (values by bisection in Python), where + !! MoorDyn interpolates the slow strains of the table rows. TYPE(CD_SyropeType) :: td REAL(wp) :: ws(CD_SYROPE_NWC), wt(CD_SYROPE_NWC), wsl(CD_SYROPE_NWC) REAL(wp) :: st, fa, sl, dsl, ten, tm @@ -291,18 +300,78 @@ SUBROUTINE case_owc_branch_and_running_max() CALL CD_Syrope_Rate_And_Tension(td, .FALSE., ws, wt, wsl, sl, 0.045_wp, 5.0e-5_wp, & dsl, ten, tm, es, em) CALL require(es == CD_SYROPE_OK, 'owc:rate-ok') - CALL require(close_rel(dsl, 1.2606308143959109e-05_wp), 'owc:rate') - CALL require(close_rel(ten, 3130162.871313756_wp), 'owc:tension') - CALL require(close_rel(tm, 2499847.4641158003_wp), 'owc:tmean-recovered') + CALL require(close_rel(dsl, 1.2597923741103403e-05_wp), 'owc:rate') + CALL require(close_rel(ten, 3129896.18705517_wp), 'owc:tension') + CALL require(close_rel(tm, 2.5e6_wp), 'owc:tmean-recovered') ! the running-max event: t_mean exceeded the 2.0e6 T_max -> regenerate CALL require(tm > 2.0e6_wp, 'owc:event-detected') CALL CD_Syrope_Working_Curve(td, tm, ws, wt, wsl, es, em) CALL require(es == CD_SYROPE_OK, 'owc:regenerated') - CALL require(close_rel(ws(1), 0.022011076961851315_wp), 'owc:regen-eps-min') - CALL require(close_rel(wt(23), 1896436.0072602627_wp), 'owc:regen-T23') + CALL require(close_rel(ws(1), 0.022011895413436695_wp), 'owc:regen-eps-min') + CALL require(close_rel(wt(23), 1896551.724137931_wp), 'owc:regen-T23') CALL CD_Syrope_End(td) END SUBROUTINE case_owc_branch_and_running_max + SUBROUTINE case_branches_join() + !! The working curve and the OWC meet at one slow strain for any running maximum: its top + !! sample is the divider to the bit, the OWC returns T_max there, and the recovered mean + !! tension changes on both sides of it (no band of slow strains that are all rest points of + !! a rope at its running maximum). And the recovery does not depend on the spacing of the + !! OWC rows: the same curve on eight times as many rows gives the same tension. + TYPE(CD_SyropeType) :: td, tf + INTEGER, PARAMETER :: NSUB = 8, NF = 29*NSUB + 1, NT = 200 + REAL(wp) :: ws(CD_SYROPE_NWC), wt(CD_SYROPE_NWC), wsl(CD_SYROPE_NWC), ef(NF), tnf(NF) + REAL(wp) :: tmax, d, dp, rate, ten, t_at, t_below, t_above, t_fine, off_at, off_fine, rise + INTEGER :: es, i, k, j, n_curve + LOGICAL :: joined + CHARACTER(200) :: em + CALL CD_Syrope_Init(td, OWC_EPS, OWC_TEN, CD_SYROPE_WC_EXP, 0.2_wp, 1.5_wp, ALPHA, BETA, C1, C2, es, em) + CALL require(es == CD_SYROPE_OK, 'join:init') + DO i = 1, 29 + DO j = 1, NSUB + k = (i - 1)*NSUB + j + ef(k) = OWC_EPS(i) + (OWC_EPS(i + 1) - OWC_EPS(i))*REAL(j - 1, wp)/REAL(NSUB, wp) + tnf(k) = OWC_TEN(i) + (OWC_TEN(i + 1) - OWC_TEN(i))*REAL(j - 1, wp)/REAL(NSUB, wp) + END DO + END DO + ef(NF) = OWC_EPS(30) + tnf(NF) = OWC_TEN(30) + CALL CD_Syrope_Init(tf, ef, tnf, CD_SYROPE_WC_EXP, 0.2_wp, 1.5_wp, ALPHA, BETA, C1, C2, es, em) + CALL require(es == CD_SYROPE_OK, 'join:init fine table') + joined = .TRUE. + off_at = 0.0_wp + off_fine = 0.0_wp + rise = HUGE(1.0_wp) + n_curve = 0 + DO i = 1, NT + tmax = 0.8e6_wp + (4.2e6_wp - 0.8e6_wp)*REAL(i - 1, wp)/REAL(NT - 1, wp) + CALL CD_Syrope_Working_Curve(td, tmax, ws, wt, wsl, es, em) + IF (es /= CD_SYROPE_OK) CYCLE ! an inadmissible running maximum has no curve + n_curve = n_curve + 1 + d = CD_Syrope_Branch_Divider(td, tmax) + joined = joined .AND. bits_same(wsl(CD_SYROPE_NWC), d) + CALL CD_Syrope_Rate_And_Tension(td, .FALSE., ws, wt, wsl, d, 0.0_wp, 0.0_wp, rate, ten, t_at, es, em) + off_at = MAX(off_at, ABS(t_at - tmax)/tmax) + dp = d - 1.0e-9_wp + CALL CD_Syrope_Rate_And_Tension(td, .TRUE., ws, wt, wsl, dp, 0.0_wp, 0.0_wp, rate, ten, t_below, es, em) + dp = d + 1.0e-9_wp + CALL CD_Syrope_Rate_And_Tension(td, .FALSE., ws, wt, wsl, dp, 0.0_wp, 0.0_wp, rate, ten, t_above, es, em) + rise = MIN(rise, t_at - t_below, t_above - t_at) + dp = d + 1.0e-4_wp + CALL CD_Syrope_Rate_And_Tension(tf, .FALSE., ws, wt, wsl, dp, 0.0_wp, 0.0_wp, rate, ten, t_fine, es, em) + CALL CD_Syrope_Rate_And_Tension(td, .FALSE., ws, wt, wsl, dp, 0.0_wp, 0.0_wp, rate, ten, t_above, es, em) + off_fine = MAX(off_fine, ABS(t_fine - t_above)/t_above) + END DO + WRITE (*, '(A,I0,A,ES9.2,A,ES9.2,A,ES9.2)') ' branches join at ', n_curve, ' running maxima: OWC off T_max by ', & + off_at, ', smallest rise over 1e-9 of slow strain ', rise, ' N, eight times the rows differ by ', off_fine + CALL require(n_curve > NT/2, 'join:most running maxima have a curve') + CALL require(joined .AND. off_at <= 1.0e-13_wp, 'join:one slow strain at the running maximum') + CALL require(rise > 1.0e-3_wp, 'join:no band of rest points') + CALL require(off_fine <= 1.0e-12_wp, 'join:independent of the row spacing') + CALL CD_Syrope_End(td) + CALL CD_Syrope_End(tf) + END SUBROUTINE case_branches_join + SUBROUTINE case_interp_clamps() !! Piecewise-linear interpolation clamps at both table ends. TYPE(CD_SyropeType) :: td @@ -359,13 +428,12 @@ SUBROUTINE case_projected_state_advance() END SUBROUTINE case_projected_state_advance SUBROUTINE case_state_advance_at_wc_top() - !! A rope held at rest on its OWC at its running maximum: the backward-Euler root lies just - !! above the top sample of the working curve's slow strains, where T_mean(eps_slow) stops - !! rising (it clamps at T_max up to the branch divider), closer to it than the Newton - !! step's difference interval. The state of a run (LINEAR, k1 = 0.5, BA_s|BA_d = 1e6|1e5, - !! a line hauled in and held) on which the safeguarded Newton step crept 80 iterations - !! along that kink and the solve failed; the bisection that finishes the solve meets the - !! residual test, between the kink and the divider, at the curve's top tension. + !! A rope held at rest on its OWC at its running maximum: the backward-Euler root lies at the + !! top sample of the working curve's slow strains, where the slope of T_mean(eps_slow) + !! changes, closer to it than the Newton step's difference interval. The state of a run + !! (LINEAR, k1 = 0.5, BA_s|BA_d = 1e6|1e5, a line hauled in and held) on which the + !! safeguarded Newton step crept 80 iterations along that kink and the solve failed; the + !! solve meets the residual test there, at the curve's top tension. TYPE(CD_SyropeType) :: td REAL(wp), PARAMETER :: TMAX = 1.7790941510791376e6_wp, SLOW0 = 2.0004433178640910e-2_wp, & EPS = 3.0303024894996432e-2_wp, DEPS = -1.4208693414705444e-13_wp, DT = 5.0e-2_wp @@ -387,8 +455,9 @@ SUBROUTINE case_state_advance_at_wc_top() residual = slow_next - SLOW0 - DT*rate WRITE (*, '(A,ES16.9,A,ES10.3,A,ES12.5,A)') ' wc-top: slow strain ', slow_next, ', residual ', residual, & ', mean tension ', mean, ' N' - CALL require(ABS(residual) <= 5.0e-13_wp .AND. slow_next > wsl(CD_SYROPE_NWC) .AND. slow_next < divider .AND. & - bits_same(mean, wt(CD_SYROPE_NWC)) .AND. bits_same(mean, t_mean), 'wc-top:root at the curve top') + CALL require(ABS(residual) <= 5.0e-13_wp .AND. ABS(slow_next - divider) <= 1.0e-8_wp .AND. & + ABS(mean - wt(CD_SYROPE_NWC)) <= 1.0e-6_wp*wt(CD_SYROPE_NWC) .AND. bits_same(mean, t_mean), & + 'wc-top:root at the curve top') CALL CD_Syrope_End(td) END SUBROUTINE case_state_advance_at_wc_top diff --git a/tests/test_syrope_control.f90 b/tests/test_syrope_control.f90 index db15c97e..f0f39091 100644 --- a/tests/test_syrope_control.f90 +++ b/tests/test_syrope_control.f90 @@ -366,16 +366,14 @@ END FUNCTION kernel_tension SUBROUTINE kernel_rate(slow, eps, deps, tmax, rate, ten) !! MoorDyn's Syrope segment law (MoorDyn-C Line::getStateDeriv, MoorDyn-F Line_GetStateDeriv, !! ElasticMod 4) in strain form: the mean tension from the slow strain on the working curve - !! of tmax (30 samples) below the OWC's slow strain at tmax and on the OWC from it, + !! of tmax (30 samples) below the OWC's slow strain at tmax and on the OWC from it (there the + !! exact inverse of eps_owc(T) - eps_fast(T), by bisection; MoorDyn interpolates its rows), !! K1 = alpha + beta T_mean, d(eps_slow)/dt = (K1 (eps - eps_curve(T_mean)) + BA_d deps)/(BA_s + !! BA_d) and T = T_mean (eps >= 0) + BA_s d(eps_slow)/dt, clamped at zero (a line cannot push). REAL(wp), INTENT(IN) :: slow, eps, deps, tmax REAL(wp), INTENT(OUT) :: rate, ten - REAL(wp) :: we(NWC), wt(NWC), ws(NWC), os(NOWC), e_max, e_min, t_mean, e_curve + REAL(wp) :: we(NWC), wt(NWC), ws(NWC), e_max, e_min, t_mean, e_curve, lo, hi INTEGER :: k - DO k = 1, NOWC - os(k) = OWC_EPS(k) - fast_strain(OWC_TEN(k)) - END DO e_max = owc_e(tmax) e_min = OWC_EPS(1) + K1W*(e_max - OWC_EPS(1)) DO k = 1, NWC @@ -383,11 +381,21 @@ SUBROUTINE kernel_rate(slow, eps, deps, tmax, rate, ten) wt(k) = tmax*(we(k) - e_min)/(e_max - e_min) ws(k) = we(k) - fast_strain(wt(k)) END DO - IF (slow < lin(tmax, OWC_TEN, os)) THEN + IF (slow < e_max - fast_strain(tmax)) THEN t_mean = lin(slow, ws, wt) e_curve = lin(t_mean, wt, we) ELSE - t_mean = lin(slow, os, OWC_TEN) + lo = OWC_TEN(1) + hi = OWC_TEN(NOWC) + DO k = 1, 200 + t_mean = 0.5_wp*(lo + hi) + IF (owc_e(t_mean) - fast_strain(t_mean) < slow) THEN + lo = t_mean + ELSE + hi = t_mean + END IF + END DO + t_mean = 0.5_wp*(lo + hi) e_curve = lin(t_mean, OWC_TEN, OWC_EPS) END IF rate = ((ALPHA + BETA*t_mean)*(eps - e_curve) + BA_D*deps)/(BA_S + BA_D)