From e2c636d574a0426a8f484af459deaffa61596084 Mon Sep 17 00:00:00 2001 From: Jae Hoon Seo Date: Thu, 15 Oct 2026 02:34:32 +0900 Subject: [PATCH 1/4] fix: carry the end weight moment at an anchor resting on the seabed A one-hour coupled OpenFAST run of the IEA-15 MW mixed deck showed the power cable's anchor tension jump from 1.22 kN to 3.1 kN about 25 s in and stay there while the platform drifted toward the anchor; without seabed friction it declined to 0.6 kN. The friction law is not at fault. The seabed contact acts at the nodes, which carry no moment, so at a held anchor end resting on the floor the consistent end moment of the end element's weight (w L^2 / 12) had nothing to react it: the free end tangent turned 1.9 deg into the floor, the element dipped 27 mm below the seabed between its nodes, and membrane locking put -47 kN to +127 kN of axial force in it about a 1.2 kN line tension. The compressed part buckles sideways once the hang-off sways; the bowing element pulls its neighbours toward the anchor and friction locks them there. Without friction the end nodes wandered by up to 0.18 m. The seabed now carries the end element's weight moment at a held line end resting on the floor, along the floor normal on a slope, in the statics and the dynamics (a constant load; the tangent is unchanged). The static near-anchor tension is uniform (1218.204 N) and the anchor curvature drops from 1.5e-2 to 9e-7 1/m; the coupled anchor tension stays at 1.22-1.38 kN. Lines whose held end is off the floor are byte-identical; the shipped finite-EI examples with a grounded anchor change by at most 0.7 N. A regression test sways the hang-off of that cable for 30 s. Two decks of the statics matrix change outcome, with the evidence in the matrix: LW_1015__cur_fr fails closed (its old hairpin is reachable only through compression, which its tension-only deck rules out), and CUR_1013 now finds the equilibrium with the grounded run turned sideways, because a refinement stopped on compression in a current now names the current limit and the driver retries out of the plane. Signed-off-by: Jae Hoon Seo --- CHANGELOG.md | 23 +++++++ doc/theory.rst | 6 +- src/CableDyn_HermiteCableDynamic.f90 | 56 ++++++++++++++++- src/CableDyn_HermiteCableStatic.f90 | 51 ++++++++++++++- src/CableDyn_SeabedContact.f90 | 17 +++++ tests/data/cable_statics_matrix.json | 12 ++-- tests/test_cable_statics_matrix.py | 11 +++- tests/test_deck_hermite_cable.f90 | 94 ++++++++++++++++++++++++++++ tests/test_hermite_cable_static.f90 | 11 +++- 9 files changed, 269 insertions(+), 12 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3d552ce6..b38c992e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -75,6 +75,29 @@ All notable changes to CableDyn are recorded in this file. The format follows routines and a 4 × 4 eigensolve, none of which passes DGEMM an inner dimension above 128, and the released Windows executables use reference LAPACK, so results are unchanged. An existing environment takes the exclusion with `conda env update -f environment.yml`, followed by a fresh build directory. +- The anchor tension of a finite-EI cable laid on the seabed no longer jumps when the line moves + out of its plane. The seabed contact acts at the nodes, which carry no moment, so at an + anchor resting on the floor the end moment of the end element's weight turned the free end + tangent into the floor: the element dipped below the seabed between its nodes (27 mm for the + power cable of `examples/iea15mw_umaine_mixed_cabledyn.dat`) and carried axial forces from + −47 kN to +127 kN about a line tension of 1.2 kN. Once the hang-off swayed, the element + buckled sideways; with seabed friction the anchor tension then locked at about 2.5 times its + static value for the rest of the run (1.22 kN to 3.1 kN in a coupled OpenFAST run while the + platform drifted toward the anchor), and without friction the end nodes wandered by up to + 0.18 m. The seabed now carries the end element's weight with its end moment at a held line end + resting on the floor (along the floor normal on a sloped bathymetry), in the statics and the + dynamics alike. Lines whose held end does not rest on the seabed are unchanged. In the + shipped finite-EI examples with an anchor on the seabed the end tensions change by at most + 0.7 N (0.05 %). Two decks of the statics robustness matrix change outcome. A lazy wave + in a 1 m/s current on a frictional bed (`LW_1015__cur_fr`) had been reported as a hairpin + past its anchor only at its exact seabed stiffness. It now fails closed: the friction-held + touchdown goes into compression at about 0.33 m/s, before any tension-only equilibrium is + reached from the still-water layout, and a slow current ramp in the dynamics with + `tensile_safety` stops at the same point. A short line in a 1.9 m/s current on a + frictionless bed (`CUR_1013`) had failed closed. It now finds the equilibrium with the + grounded run turned sideways on the seabed: when the refinement of the catenary + continuation stops on a compression in a current, its failure now names the current limit, + so the driver retries out of the plane. ## [0.1.1] - 2026-10-09 diff --git a/doc/theory.rst b/doc/theory.rst index ef2b08c8..bf1cd0b4 100644 --- a/doc/theory.rst +++ b/doc/theory.rst @@ -1031,7 +1031,11 @@ The fallback and the dynamic Hermite path use - **continuation in** ``EI``, and, for a net-buoyant line, **continuation in buoyancy**, which tracks the smooth branch of the buoyant arch from the seed; - the **consistent Hermite self-weight**, :math:`wL_0/2` on each end :math:`r_z` and - :math:`\pm wL_0^2/12` on the end :math:`m_z`; + :math:`\pm wL_0^2/12` on the end :math:`m_z`. At a held line end resting on the seabed the + floor carries the end element's weight with this end moment (its normal share + :math:`\cos\theta\,\mathbf{n}` on a floor of slope :math:`\theta` and upward normal + :math:`\mathbf{n}`): the nodal contact carries no moment, and the unbalanced end moment + would otherwise turn the end tangent into the floor; - **mesh sequencing**: the equilibrium is selected on a coarse mesh that preserves section, load, and contact-diameter interfaces, prolonged through the Hermite interpolant, and polished on each finer level and finally on the exact user mesh with the same residual test. Deterministic diff --git a/src/CableDyn_HermiteCableDynamic.f90 b/src/CableDyn_HermiteCableDynamic.f90 index f0ae7584..0f3d9ae5 100644 --- a/src/CableDyn_HermiteCableDynamic.f90 +++ b/src/CableDyn_HermiteCableDynamic.f90 @@ -67,7 +67,7 @@ MODULE CableDyn_HermiteCableDynamic CD_Component_Wave_Kinematics, CD_Solve_Dispersion_Wavenumber, CD_HYDRO_OK USE CableDyn_SeabedContact, ONLY: CD_Seabed_Normal_Law, CD_Seabed_Contact_Gate, CD_SEABED_CONTACT_BLEND, & CD_Seabed_Friction_Stick_Slip, CD_Seabed_Friction_Aniso, & - CD_Seabed_Friction_Mu_Dir, CD_FRICTION_STICK_SLIP + CD_Seabed_Friction_Mu_Dir, CD_FRICTION_STICK_SLIP, CD_Seabed_End_Support USE CableDyn_Bathymetry, ONLY: CD_BathymetryType, CD_Bathymetry_Is_Initialized, & CD_Bathymetry_Floor_Gradient, CD_End_Bathymetry, CD_BATHY_OK USE CableDyn_HermiteTorsion, ONLY: CD_HermiteTorsionType, CD_HermiteTorsion_Line, CD_HermiteTorsion_Unwrap, & @@ -5278,7 +5278,7 @@ SUBROUTINE assemble_residual(model, q_cfg, v_cfg, t_eval, want_residual, want_ta REAL(wp) :: fdry(4), kdry(4, 4), dry_wl, dry_b, dry_r INTEGER :: zdof(4), b LOGICAL :: dry - REAL(wp) :: endconn_d0_eval(3, 2) + REAL(wp) :: endconn_d0_eval(3, 2), support(3) CHARACTER(200) :: em2 ErrStat = CD_HCDYN_OK; ErrMsg = '' @@ -5356,6 +5356,14 @@ SUBROUTINE assemble_residual(model, q_cfg, v_cfg, t_eval, want_residual, want_ta R(6*e + 3) = R(6*e + 3) + model%w(e)*0.5_wp*model%l0(e) R(6*e + 6) = R(6*e + 6) - model%w(e)*model%l0(e)*model%l0(e)/12.0_wp END DO + ! A held end resting on the floor: the seabed carries the end element's weight with + ! its consistent end moment (CD_Seabed_End_Support), which the nodal contact cannot. + IF (model%has_contact .OR. model%kn > CD_ZERO) THEN + IF (held_end_floor_support(model, q_cfg, 1, support)) & + R(4:6) = R(4:6) - (model%w(1)*model%l0(1)*model%l0(1)/12.0_wp)*support + IF (held_end_floor_support(model, q_cfg, 2, support)) & + R(6*ne + 4:6*ne + 6) = R(6*ne + 4:6*ne + 6) + (model%w(ne)*model%l0(ne)*model%l0(ne)/12.0_wp)*support + END IF END IF IF (model%has_attach) THEN CALL assemble_attachments(model, q_cfg, v_cfg, want_residual, want_tangent, R, Kb, Kvb, es, em2) @@ -5871,6 +5879,50 @@ SUBROUTINE assemble_contact(model, q_cfg, v_cfg, want_residual, want_tangent, Er END DO END SUBROUTINE assemble_contact + LOGICAL FUNCTION held_end_floor_support(model, q_cfg, iend, support) RESULT(held) + !! Floor reaction carrying the weight of the end element at line end iend (1: node 1, + !! 2: node nn) of a model with seabed contact, per unit weight: CD_Seabed_End_Support + !! times the floor's normal share of the weight, cos(slope) n, n the upward floor + !! normal (e_z on a flat bed). Its consistent end moment cancels the weight's on a + !! grounded end element; the along-floor part of the weight stays with the line. False + !! (support zero) unless the end node's translations are all held (not free), its end + !! element is net-heavy and the end rests on the floor the contact assembly uses there. + TYPE(CD_HermiteCableDynType), INTENT(IN) :: model + REAL(wp), INTENT(IN) :: q_cfg(:) + INTEGER, INTENT(IN) :: iend + REAL(wp), INTENT(OUT) :: support(3) + INTEGER :: node, e, ix, es + REAL(wp) :: xg, yg, z_floor, gxg, gyg, gx, gy, sfac, share + CHARACTER(200) :: em + support = CD_ZERO + held = .FALSE. + IF (iend == 1) THEN + node = 1; e = 1 + ELSE + node = model%nn; e = model%ne + END IF + IF (.NOT. (model%w(e) > CD_ZERO)) RETURN + ix = 6*node - 5 + IF (ANY(model%freemask(ix:ix + 2))) RETURN + gx = CD_ZERO + gy = CD_ZERO + z_floor = model%seabed_z + IF (model%has_contact .AND. model%has_contact_bathymetry) THEN + xg = model%contact_frame_c*q_cfg(ix) - model%contact_frame_s*q_cfg(ix + 1) + yg = model%contact_frame_s*q_cfg(ix) + model%contact_frame_c*q_cfg(ix + 1) + CALL CD_Bathymetry_Floor_Gradient(model%contact_bathymetry, xg, yg, z_floor, gxg, gyg, es, em) + ! A failed query fails closed in the contact assembly at the same point. + IF (es /= CD_BATHY_OK) RETURN + gx = model%contact_frame_c*gxg + model%contact_frame_s*gyg + gy = -model%contact_frame_s*gxg + model%contact_frame_c*gyg + END IF + sfac = SQRT(CD_ONE + gx*gx + gy*gy) + share = CD_Seabed_End_Support((z_floor - q_cfg(ix + 2))/sfac) + IF (.NOT. (share > CD_ZERO)) RETURN + held = .TRUE. + support = (share/(sfac*sfac))*[-gx, -gy, CD_ONE] + END FUNCTION held_end_floor_support + SUBROUTINE commit_friction_anchors(model) !! Return mapping of the elastic-plastic friction springs at the committed state: a !! spring stretched beyond the capacity mu*normal moves its anchor to the capacity diff --git a/src/CableDyn_HermiteCableStatic.f90 b/src/CableDyn_HermiteCableStatic.f90 index aa56c90e..c096a5b1 100644 --- a/src/CableDyn_HermiteCableStatic.f90 +++ b/src/CableDyn_HermiteCableStatic.f90 @@ -43,7 +43,7 @@ MODULE CableDyn_HermiteCableStatic CD_ENDCONN_RIGID USE CableDyn_SeabedContact, ONLY: CD_Seabed_Normal_Law, CD_SEABED_CONTACT_BLEND, CD_Seabed_Friction_Spring, & CD_Seabed_Friction_Aniso, CD_Seabed_Friction_Mu_Dir, CD_FRICTION_SPRING, & - CD_Seabed_Normal_Contact + CD_Seabed_Normal_Contact, CD_Seabed_End_Support USE CableDyn_Bathymetry, ONLY: CD_BathymetryType, CD_Bathymetry_Is_Initialized, & CD_Bathymetry_Floor, CD_Bathymetry_Floor_Gradient, CD_BATHY_OK USE CableDyn_HermiteCableDynamic, ONLY: CD_HermiteCable_Drag_Element, CD_HCDYN_OK @@ -475,7 +475,9 @@ SUBROUTINE CD_HermiteCable_Static_Solve(l0, EA, EI, w, seed, fixed_dofs, seabed_ REAL(wp), ALLOCATABLE :: tors_g(:), tors_gr(:), tors_h(:, :), tors_v(:), tors_rhs(:), tors_q(:), tors_gs(:) REAL(wp), ALLOCATABLE :: tors_grs(:), tors_gt(:) REAL(wp), ALLOCATABLE :: tors_rhs2(:, :) - REAL(wp) :: contact_cs(2) + REAL(wp) :: contact_cs(2), end_support(3, 2), end_floor(3), end_g(2), end_sfac + INTEGER :: end_es + CHARACTER(200) :: end_em ErrStat = CD_HCSTAT_OK ErrMsg = '' @@ -784,6 +786,32 @@ SUBROUTINE CD_HermiteCable_Static_Solve(l0, EA, EI, w, seed, fixed_dofs, seabed_ trib(i) = trib(i) + 0.5_wp*l0(i) trib(i + 1) = trib(i + 1) + 0.5_wp*l0(i) END DO + ! A held end resting on the floor: the seabed carries the end element's weight with its + ! consistent end moment (CD_Seabed_End_Support; per unit weight, the floor's normal + ! share cos(slope) n of the weight), which the nodal contact cannot. Held translations + ! keep their seed, so the support is fixed for the solve. + end_support = CD_ZERO + IF (use_nodal_contact .OR. kn > CD_ZERO) THEN + DO i = 1, 2 + c = MERGE(1, nn, i == 1) + b = 6*(c - 1) + IF (ANY(freemask(b + 1:b + 3)) .OR. .NOT. (w(MERGE(1, ne, i == 1)) > CD_ZERO)) CYCLE + end_floor(1) = seabed_z + end_g = CD_ZERO + IF (use_bathymetry) THEN + CALL CD_Bathymetry_Floor_Gradient(bathymetry, contact_cs(1)*q(b + 1) - contact_cs(2)*q(b + 2), & + contact_cs(2)*q(b + 1) + contact_cs(1)*q(b + 2), & + end_floor(1), end_floor(2), end_floor(3), end_es, end_em) + ! A failed query fails closed in the contact assembly at the same point. + IF (end_es /= CD_BATHY_OK) CYCLE + end_g = [contact_cs(1)*end_floor(2) + contact_cs(2)*end_floor(3), & + -contact_cs(2)*end_floor(2) + contact_cs(1)*end_floor(3)] + END IF + end_sfac = SQRT(CD_ONE + end_g(1)*end_g(1) + end_g(2)*end_g(2)) + end_support(:, i) = (CD_Seabed_End_Support((end_floor(1) - q(b + 3))/end_sfac)/(end_sfac*end_sfac))* & + [-end_g(1), -end_g(2), CD_ONE] + END DO + END IF use_friction = .FALSE. fr_frozen = .FALSE. fr_mu = CD_ZERO @@ -1084,6 +1112,19 @@ RECURSIVE SUBROUTINE newton_step(rnorm, es, em, do_update) pi_total = pi_total + e_term pi_abs = pi_abs + ABS(e_term) END DO + ! the floor-carried end moments of held ends resting on the seabed + IF (end_support(3, 1) > CD_ZERO) THEN + R(4:6) = R(4:6) - (w_cur(1)*l0(1)*l0(1)/12.0_wp)*end_support(:, 1) + e_term = -(w_cur(1)*l0(1)*l0(1)/12.0_wp)*DOT_PRODUCT(end_support(:, 1), q(4:6)) + pi_total = pi_total + e_term + pi_abs = pi_abs + ABS(e_term) + END IF + IF (end_support(3, 2) > CD_ZERO) THEN + R(6*ne + 4:6*ne + 6) = R(6*ne + 4:6*ne + 6) + (w_cur(ne)*l0(ne)*l0(ne)/12.0_wp)*end_support(:, 2) + e_term = (w_cur(ne)*l0(ne)*l0(ne)/12.0_wp)*DOT_PRODUCT(end_support(:, 2), q(6*ne + 4:6*ne + 6)) + pi_total = pi_total + e_term + pi_abs = pi_abs + ABS(e_term) + END IF ! ---- dry-part buoyancy recovery above the optional free surface ---- ! Configuration-dependent through the waterline crossings, so it adds the crossing @@ -6168,6 +6209,12 @@ SUBROUTINE CD_HermiteCable_Static_Solve_AutoMesh(l0, EA, EI, w, seed, fixed_dofs diag_out%axial_strain_min_elem, ', xi=', diag_out%axial_strain_min_xi, & ', strain=', diag_out%axial_strain_min END IF + ! In a current, name the limit the compression of this state shows (the grounded run + ! pushed into its end, or into a friction-held touchdown): the driver's out-of-plane + ! retry of a planar current needs it, as for the other routes' failures. + IF (PRESENT(current)) wbuf = TRIM(current_compression_note(l0_out, EA_out, q_out, seabed_z, & + .NOT. PRESENT(bathymetry), & + ALLOCATED(current%friction)))//TRIM(wbuf) ErrMsg = wbuf RETURN END IF diff --git a/src/CableDyn_SeabedContact.f90 b/src/CableDyn_SeabedContact.f90 index 6562ddb3..b42c9fe6 100644 --- a/src/CableDyn_SeabedContact.f90 +++ b/src/CableDyn_SeabedContact.f90 @@ -16,6 +16,7 @@ MODULE CableDyn_SeabedContact PUBLIC :: CD_Seabed_Normal_Law PUBLIC :: CD_Seabed_Normal_Contact PUBLIC :: CD_Seabed_Contact_Gate + PUBLIC :: CD_Seabed_End_Support PUBLIC :: CD_Seabed_Friction_Spring PUBLIC :: CD_Seabed_Friction_Stick_Slip PUBLIC :: CD_Seabed_Friction_Aniso, CD_Seabed_Friction_Mu_Dir @@ -99,6 +100,22 @@ PURE SUBROUTINE CD_Seabed_Contact_Gate(gap, gate, dgate_dgap) END IF END SUBROUTINE CD_Seabed_Contact_Gate + PURE REAL(wp) FUNCTION CD_Seabed_End_Support(gap) RESULT(support) + !! Share of the consistent end moment w l0^2/12 of a net-heavy end element that the + !! seabed carries at a HELD line end (translations fixed or prescribed) at signed normal + !! penetration gap = z_floor - z. The nodal penalty is the end-point (Lobatto) + !! integration of the floor reaction and carries no moment, so on a grounded end + !! element the weight's end moment would otherwise turn the free end tangent into the + !! floor: the element dips below the seabed between its nodes and, on a high-EA line, + !! carries large spurious axial forces of both signs. One for an end on or below the + !! floor, zero above the contact blend, linear in between (CD_Seabed_Contact_Gate + !! shifted by one blend length, so that an anchor placed exactly on the floor rests on + !! it). The end is held, so the share is constant within a solve and adds no tangent. + REAL(wp), INTENT(IN) :: gap + REAL(wp) :: dgate_dgap + CALL CD_Seabed_Contact_Gate(gap + CD_SEABED_CONTACT_BLEND, support, dgate_dgap) + END FUNCTION CD_Seabed_End_Support + PURE SUBROUTINE CD_Seabed_Friction_Spring(d, stiffness, capacity, force, dforce_dd, dforce_dcap) !! Static seabed friction spring: the resisting force of a horizontal spring of !! stiffness k stretched by d from its reference, capped smoothly at the capacity C, diff --git a/tests/data/cable_statics_matrix.json b/tests/data/cable_statics_matrix.json index 74077f8e..9dbfcde3 100644 --- a/tests/data/cable_statics_matrix.json +++ b/tests/data/cable_statics_matrix.json @@ -1292,7 +1292,8 @@ }, { "id": "LW_1015__cur_fr", - "expect": "admissible", + "expect": "current_friction_compression", + "why": "A seabed-friction current deck: the tension-only branch from the still-water layout ends near drag fraction 0.11 (about 0.33 m/s), where the friction-held touchdown goes into compression; a slow current ramp in the dynamics with tensile_safety stops there too (0.37 m/s). A hairpin past the anchor is reached only through that compression. Earlier releases reported it as an equilibrium through the mesh-sequenced coarse levels, whose anchor element dipped below the floor, and only at this exact kBot (not at kBot 1e5 +/- 0.001 % or at currents of 0.3 to 0.7 m/s).", "deck": "--------------------- CableDyn Input File ---------------------------\nLW_1015__cur_fr\n--------------------- LINE TYPES ------------------------------------\nTypeName Diam MassDenInAir EA BA EI Cd_n Cd_t Ca_n Ca_t\n(-) (m) (kg/m) (N) (-) (N-m2) (-) (-) (-) (-)\nbare 0.100445767 11.22757908 177452628.2 0 8881.762177 1.2 0.1 1 0\nbuoy 0.2900604656 65.36363376 177452628.2 0 11763.70697 1.2 0.1 1 0\n--------------------- POINTS ----------------------------------------\nID Type X Y Z\n(-) (-) (m) (m) (m)\n1 Coupled 0 0 -21.032628\n2 Fixed 515.799336 0 -439.732\n--------------------- LINES -----------------------------------------\nID NodeA NodeB Outputs\n(-) (-) (-) (-)\n1 1 2 -\n--------------------- SECTIONS --------------------------------------\nLineID LineType Length NumSegs\n(-) (-) (m) (-)\n1 bare 231.9579 123\n1 buoy 115.9305 61\n1 bare 480.7763 255\n--------------------- OPTIONS ---------------------------------------\n0.5 frictionMu\n9.80665 g\n1025.0 rhoW\n439.732 WtrDpth\n100000 kBot\n1.0e4 cBot\n0.05 dtM\n0.0 TMax\nFalse adaptive_mesh\nTrue tensile_safety\nuniform 1.0 0.0 0.0 current\n--------------------- OUTPUTS ---------------------------------------\n\"FairTen1\"\n\"AnchTen1\"\n--------------------- need this line --------------------------------\n", "lines": { "1": { @@ -1303,7 +1304,8 @@ }, { "id": "LW_1015__cur_fr__rest", - "expect": "admissible", + "expect": "current_friction_compression", + "why": "The at-rest twin of LW_1015__cur_fr, which has no tension-only static equilibrium (see there).", "deck": "--------------------- CableDyn Input File ---------------------------\nLW_1015__cur_fr__rest\n--------------------- LINE TYPES ------------------------------------\nTypeName Diam MassDenInAir EA BA EI Cd_n Cd_t Ca_n Ca_t\n(-) (m) (kg/m) (N) (-) (N-m2) (-) (-) (-) (-)\nbare 0.100445767 11.22757908 177452628.2 0 8881.762177 1.2 0.1 1 0\nbuoy 0.2900604656 65.36363376 177452628.2 0 11763.70697 1.2 0.1 1 0\n--------------------- POINTS ----------------------------------------\nID Type X Y Z\n(-) (-) (m) (m) (m)\n1 Coupled 0 0 -21.032628\n2 Fixed 515.799336 0 -439.732\n--------------------- LINES -----------------------------------------\nID NodeA NodeB Outputs\n(-) (-) (-) (-)\n1 1 2 -\n--------------------- SECTIONS --------------------------------------\nLineID LineType Length NumSegs\n(-) (-) (m) (-)\n1 bare 231.9579 123\n1 buoy 115.9305 61\n1 bare 480.7763 255\n--------------------- OPTIONS ---------------------------------------\n0.5 frictionMu\n9.80665 g\n1025.0 rhoW\n439.732 WtrDpth\n100000 kBot\n1.0e4 cBot\n0.05 dtM\n1.0 TMax\nFalse adaptive_mesh\nTrue tensile_safety\nuniform 1.0 0.0 0.0 current\n--------------------- OUTPUTS ---------------------------------------\n\"FairTen1\"\n\"AnchTen1\"\n--------------------- need this line --------------------------------\n", "lines": { "1": { @@ -1475,14 +1477,16 @@ }, { "id": "CUR_1013", - "expect": "current_compression", + "expect": "admissible", + "why": "The planar route stops with the grounded run pushed into its anchor; the out-of-plane retry then finds the run turned sideways on the seabed (tension at least 0.48 kN, no self-contact). Earlier releases did not run that retry for this deck because the catenary-continuation failure did not name the current limit.", "deck": "--------------------- CableDyn Input File ---------------------------\nCUR_1013\n--------------------- LINE TYPES ------------------------------------\nTypeName Diam MassDenInAir EA BA EI Cd_n Cd_t Ca_n Ca_t\n(-) (m) (kg/m) (N) (-) (N-m2) (-) (-) (-) (-)\nbare 0.1784650716 82.63060908 255233842 0 25945.91551 1.2 0.1 1 0\nbuoy 0.4710966462 88.94142595 255233842 0 40205.41756 1.2 0.1 1 0\n--------------------- POINTS ----------------------------------------\nID Type X Y Z\n(-) (-) (m) (m) (m)\n1 Coupled 0 0 -13.08348484\n2 Fixed 41.77649681 0 -42.543\n--------------------- LINES -----------------------------------------\nID NodeA NodeB Outputs\n(-) (-) (-) (-)\n1 1 2 -\n--------------------- SECTIONS --------------------------------------\nLineID LineType Length NumSegs\n(-) (-) (m) (-)\n1 bare 20.5504 2\n1 buoy 7.3589 1\n1 bare 35.1167 4\n--------------------- OPTIONS ---------------------------------------\n9.80665 g\n1025.0 rhoW\n42.543 WtrDpth\n3e+06 kBot\n1.0e4 cBot\n0.05 dtM\n0.0 TMax\nFalse adaptive_mesh\nTrue tensile_safety\nuniform 1.906 0.0 0.0 current\n--------------------- OUTPUTS ---------------------------------------\n\"FairTen1\"\n\"AnchTen1\"\n--------------------- need this line --------------------------------\n", "lines": { "1": { "oracle_tfair": [], "lambda_over_length": 0.0 } - } + }, + "note": "past its anchor, where it folds back" }, { "id": "LWM_1002", diff --git a/tests/test_cable_statics_matrix.py b/tests/test_cable_statics_matrix.py index 16697d3f..7ebbb1b6 100644 --- a/tests/test_cable_statics_matrix.py +++ b/tests/test_cable_statics_matrix.py @@ -25,6 +25,10 @@ naming the axial compression; * ``current_compression`` decks (a current pushing the grounded run along the frictionless seabed into compression: no tension-only equilibrium) must fail closed with that diagnosis; +* ``current_friction_compression`` decks (on a frictional seabed the current pushes the + suspended span into the friction-held touchdown before any tension-only equilibrium is + reached from the still-water layout) must fail closed with that diagnosis; a deck's ``why`` + records the evidence; * an admissible deck with a ``note`` must print it: a very strong current on a frictionless seabed folds the line back past its anchor (a hairpin), a stable equilibrium the driver keeps and names; @@ -221,6 +225,10 @@ def check_case(case: dict, res: dict) -> list: if res["rc"] == 0 or "run on the seabed is in axial compression" not in log: errs.append("expected the grounded-run compression diagnosis, rc=%s" % res["rc"]) return errs + if exp == "current_friction_compression": + if res["rc"] == 0 or "the friction holds the grounded run" not in log: + errs.append("expected the friction-held touchdown compression diagnosis, rc=%s" % res["rc"]) + return errs if res["rc"] != 0: tail = [ln for ln in log.splitlines() if "CableDyn_DeckDriver" in ln] errs.append("admissible deck failed rc=%s: %s" % (res["rc"], (tail[-1] if tail else "")[:300])) @@ -321,7 +329,8 @@ def main() -> int: errs.append("CPU time %.1f s beyond the %.0f s per-deck bound" % ( res["cpu"], case.get("cpu_limit", DECK_CPU_LIMIT) * a.cpu_limit / DECK_CPU_LIMIT)) rest = case.get("rest_of") - if rest and not errs: + # an at-rest twin of a deck expected to fail closed fails closed itself (checked above) + if rest and not errs and case["expect"] == "admissible": pr = byid.get(rest) if pr is None or pr["rc"] != 0 or "forces" not in pr: errs.append("static parent %s did not converge" % rest) diff --git a/tests/test_deck_hermite_cable.f90 b/tests/test_deck_hermite_cable.f90 index a0ce238e..8d6e6a7c 100644 --- a/tests/test_deck_hermite_cable.f90 +++ b/tests/test_deck_hermite_cable.f90 @@ -16,6 +16,7 @@ PROGRAM test_deck_hermite_cable CD_HFMF_MinSpanZ, CD_HFMF_Snapshot, CD_HFMF_Restore, & CD_HFMF_End, CD_HFMF_OK USE CableDyn_EndConnection, ONLY: CD_ENDCONN_RIGID + USE CableDyn_HermiteCableDynamic, ONLY: CD_HermiteCable_Dyn_End_Force, CD_HCDYN_OK USE, INTRINSIC :: IEEE_ARITHMETIC, ONLY: IEEE_IS_NAN IMPLICIT NONE INTEGER :: nfail @@ -31,6 +32,7 @@ PROGRAM test_deck_hermite_cable CALL case_azimuthal_frame_objectivity() CALL case_reject_motionfile() CALL case_coupled_seabed_contact() + CALL case_grounded_anchor_end() IF (nfail > 0) THEN WRITE (*, '(A,I0,A)') 'FAIL: ', nfail, ' assertion(s) failed' ERROR STOP 1 @@ -550,6 +552,98 @@ SUBROUTINE case_coupled_seabed_contact() CALL CD_HFMF_End(cable) END SUBROUTINE case_coupled_seabed_contact + SUBROUTINE case_grounded_anchor_end() + !! A lazy-wave power cable laid on a frictional flat bed up to its pinned anchor on the + !! floor (Line 4 of examples/iea15mw_umaine_mixed_cabledyn.dat: 200 m depth, kBot 3e6, + !! frictionMu 0.35, 10 m grounded elements). The seabed carries the weight of the anchor + !! element, so its free end tangent stays along the floor; turned into the floor by the + !! unbalanced end moment of the weight, the element dipped about 27 mm below the bed, + !! carried axial forces from -47 kN to +127 kN about the 1.2 kN line tension, and + !! buckled sideways once the hang-off swayed, after which the friction locked the anchor + !! tension at about 2.5 times its static value while the line slackened. + TYPE(CD_HFMF_ModuleType), ALLOCATABLE :: cable + INTEGER :: cn, es, base, k + CHARACTER(256) :: em + REAL(wp) :: u0(3), u_pos(3), u_vel(3), u_acc(3), f(3), t, r, rd, rdd, s, c, ten0, ten_max, tz + REAL(wp), PARAMETER :: DT = 0.025_wp, AMP = 2.0_wp, PER = 10.0_wp, RAMP = 5.0_wp, TEND = 30.0_wp + REAL(wp), PARAMETER :: PI = 3.141592653589793_wp + INTEGER :: u, ios + OPEN (NEWUNIT=u, FILE='hcab_deck_grounded_anchor.dat', STATUS='REPLACE', ACTION='WRITE', IOSTAT=ios) + WRITE (u, '(A)') 'lazy-wave power cable laid on a frictional bed up to its anchor' + WRITE (u, '(A)') '--- LINE TYPES ---' + WRITE (u, '(A)') 'Name Diam Mass EA BA EI Cdn Cdt Can Cat' + WRITE (u, '(A)') '(-) (m) (kg/m) (N) (-) (Nm2) (-) (-) (-) (-)' + WRITE (u, '(A)') 'bare 0.16 36.70 4.69e8 0.0 1.99e4 1.2 0.1 1.0 0.0' + WRITE (u, '(A)') 'buoy 0.29 59.53 4.69e8 0.0 1.99e4 1.2 0.1 1.0 0.0' + WRITE (u, '(A)') '--- POINTS ---' + WRITE (u, '(A)') 'ID Type X Y Z' + WRITE (u, '(A)') '(-) (-) (m) (m) (m)' + WRITE (u, '(A)') '1 Coupled 30.0 0.0 -20.0' + WRITE (u, '(A)') '2 Fixed 500.0 0.0 -200.0' + WRITE (u, '(A)') '--- LINES ---' + WRITE (u, '(A)') 'ID NodeA NodeB Outputs' + WRITE (u, '(A)') '(-) (-) (-) (-)' + WRITE (u, '(A)') '1 1 2 -' + WRITE (u, '(A)') '--- SECTIONS ---' + WRITE (u, '(A)') 'LineID LineType Length NumSegs' + WRITE (u, '(A)') '(-) (-) (m) (-)' + WRITE (u, '(A)') '1 bare 80.0 20' + WRITE (u, '(A)') '1 buoy 100.0 25' + WRITE (u, '(A)') '1 bare 420.0 42' + WRITE (u, '(A)') '--- OPTIONS ---' + WRITE (u, '(A)') '9.80665 g' + WRITE (u, '(A)') '1025.0 rhoW' + WRITE (u, '(A)') '200.0 WtrDpth' + WRITE (u, '(A)') '3.0e6 kBot' + WRITE (u, '(A)') '3.0e5 cBot' + WRITE (u, '(A)') '0.35 frictionMu' + WRITE (u, '(A)') '0.4 rhoInf' + WRITE (u, '(A)') '--- need this line ---' + CLOSE (u) + ALLOCATE (cable) + CALL CD_Init_Deck_HermiteCable('hcab_deck_grounded_anchor.dat', DT, cable, cn, es, em) + CALL require(es == CD_DECKDRV_OK, 'grounded-anchor cable initializes: '//TRIM(em)) + IF (es /= CD_DECKDRV_OK) RETURN + CALL require(cable%line%fr_active, 'grounded-anchor cable carries seabed friction') + ! The anchor is model node 1: its end tangent lies along the floor in the static state. + tz = ABS(cable%line%q(6))/NORM2(cable%line%q(4:6)) + CALL require(tz <= 1.0e-3_wp, 'anchor end tangent stays along the floor') + IF (tz > 1.0e-3_wp) WRITE (*, '(A,ES12.4)') ' anchor tangent z share ', tz + CALL CD_HermiteCable_Dyn_End_Force(cable%line, 1, f, es, em) + CALL require(es == CD_HCDYN_OK, 'static anchor force: '//TRIM(em)) + ten0 = NORM2(f) + ! Sway the hang-off sideways (2 m, 10 s, C2 quintic start): the in-plane line is then + ! perturbed out of its plane, which seeds the end-element buckling within ~25 s. + base = 6*(cn - 1) + u0 = cable%line%q(base + 1:base + 3) + ten_max = ten0 + DO k = 1, NINT(TEND/DT) + t = k*DT + IF (t < RAMP) THEN + s = t/RAMP + r = 10.0_wp*s**3 - 15.0_wp*s**4 + 6.0_wp*s**5 + rd = (30.0_wp*s**2 - 60.0_wp*s**3 + 30.0_wp*s**4)/RAMP + rdd = (60.0_wp*s - 180.0_wp*s**2 + 120.0_wp*s**3)/RAMP**2 + ELSE + r = 1.0_wp; rd = 0.0_wp; rdd = 0.0_wp + END IF + s = SIN(2.0_wp*PI*t/PER) + c = COS(2.0_wp*PI*t/PER) + u_pos = u0 + [0.0_wp, AMP*r*s, 0.0_wp] + u_vel = [0.0_wp, AMP*(rd*s + r*(2.0_wp*PI/PER)*c), 0.0_wp] + u_acc = [0.0_wp, AMP*(rdd*s + 2.0_wp*rd*(2.0_wp*PI/PER)*c - r*(2.0_wp*PI/PER)**2*s), 0.0_wp] + CALL CD_HFMF_UpdateStates(cable, u_pos, u_vel, u_acc, es, em) + IF (es /= CD_HFMF_OK) EXIT + CALL CD_HermiteCable_Dyn_End_Force(cable%line, 1, f, es, em) + IF (es /= CD_HCDYN_OK) EXIT + ten_max = MAX(ten_max, NORM2(f)) + END DO + CALL require(es == CD_HFMF_OK, 'swayed grounded-anchor march converges: '//TRIM(em)) + CALL require(ten_max <= 1.1_wp*ten0, 'friction does not ratchet the anchor tension up') + IF (ten_max > 1.1_wp*ten0) WRITE (*, '(A,2ES12.4)') ' anchor tension static / peak ', ten0, ten_max + CALL CD_HFMF_End(cable) + END SUBROUTINE case_grounded_anchor_end + SUBROUTINE write_cable_deck(path, extra_option, fairlead_y, omit_time, endpoints, second_extra_option, & endconn_row, second_endconn_row, stock_order, ba_value) !! A realistic dynamic power cable in the LAZY-WAVE configuration -- the flagship regime and diff --git a/tests/test_hermite_cable_static.f90 b/tests/test_hermite_cable_static.f90 index 16e654f5..1554328c 100644 --- a/tests/test_hermite_cable_static.f90 +++ b/tests/test_hermite_cable_static.f90 @@ -348,11 +348,18 @@ SUBROUTINE check_scalar_contact_on_slope() qs(6*i - 5) = qs(6*i - 5) + 0.03_wp*SIN(REAL(i, wp)) qs(6*i - 3) = qs(6*i - 3) + 0.02_wp*COS(REAL(i, wp)) END DO + ! Both polishes backtrack: the anchor (0, -100) rests on the slope, so the floor carries + ! the anchor element's weight moment (CD_Seabed_End_Support) and the grounded run lies + ! straight along the slope instead of dipping into it element by element; from this + ! perturbation full Newton steps then leave that equilibrium's basin (a 0.25-scaled + ! perturbation fails, a 0.5-scaled one converges). The test compares the two contact + ! paths under identical solver options, which backtracking keeps (same count, same state). CALL CD_HermiteCable_Static_Solve(l0, EA, EI, w, qs, fixed(1:nfix), -100.0_wp, 0.0_wp, 1, 60, 1.0e-10_wp, & - 1.0_wp, q1, curv, res, it1, es, em, contact_kn=kn*trib, bathymetry=bed) + 1.0_wp, q1, curv, res, it1, es, em, contact_kn=kn*trib, bathymetry=bed, & + backtracking=.TRUE.) CALL require(es == CD_HCSTAT_OK, 'slope nodal polish: '//TRIM(em)) CALL CD_HermiteCable_Static_Solve(l0, EA, EI, w, qs, fixed(1:nfix), -100.0_wp, kn, 1, 60, 1.0e-10_wp, & - 1.0_wp, q2, curv, res, it2, es, em, bathymetry=bed) + 1.0_wp, q2, curv, res, it2, es, em, bathymetry=bed, backtracking=.TRUE.) CALL require(es == CD_HCSTAT_OK, 'slope scalar polish converges: '//TRIM(em)) CALL require(it2 <= it1 + 2, 'slope scalar polish converges as fast as the nodal path') CALL require(nan_max_abs(q2 - q1) < 1.0e-5_wp, 'slope scalar and nodal paths reach the same equilibrium') From 63c130f129650e5ca1121b1dfb473d68c9197c47 Mon Sep 17 00:00:00 2001 From: Jae Hoon Seo Date: Thu, 15 Oct 2026 04:43:54 +0900 Subject: [PATCH 2/4] test: record the full-turbine touchdown run of the power cable The coupled finite-EI touchdown record rested on a 20 s aggregate trajectory and said it was not a full-turbine DLC. A one-hour run of the IEA-15 MW mixed model (normal turbulence at 10.6 m/s, JONSWAP Hs 8 m, AeroDyn with the rotor held, a SeaState grid covering the lines) completes without recoveries; the hang-off tension, grounded length and mesh-converged hog curvature are recorded, with the touchdown curvature that the deck's 10 m laid elements under-resolve, and the chain-only twin matches stock MoorDyn to 0.3 %. With the anchor-end correction the laid cable's anchor tension stays at a median of 1.39 kN with sub-second stick-slip peaks; before it, it locked at about 2.75 kN. Signed-off-by: Jae Hoon Seo --- VALIDATION.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/VALIDATION.md b/VALIDATION.md index 04b223b7..2fcc76c8 100644 --- a/VALIDATION.md +++ b/VALIDATION.md @@ -734,7 +734,7 @@ stop with a named error. | Active tension (`CtrlChan`) | Pass verified | CONTROL parsing, last-segment length/rate modulation, and exact unit tests; coupled A/B in which a ServoDyn cable-control DLL drives the same pay-out/haul-in `DeltaL` schedule into `=5` (CableDyn) and `=3` (stock MoorDyn) in one binary: hold tensions agree to <0.03% and the tension responses to <0.6% (controlled fairleads) / <0.7% (anchors) ([`validation/scripts/activetension/`](https://github.com/SMI-Lab-Inha/CableDyn/tree/main/validation/scripts/activetension), [`validation/scripts/openfast_activetension_ab.py`](https://github.com/SMI-Lab-Inha/CableDyn/blob/main/validation/scripts/openfast_activetension_ab.py)) | | Coupled `Rigid6` bodies + `Point3` buoys | Pass verified | 6-DOF `Rigid6` motion with hydrostatic (`C33`/`C44`/`C55`) restoring, checkpoint state (bit-identical `openfast -restart` of a 13.9 MN-swinging tethered body), and SeaState drag / Froude–Krylov / added mass. `Point3` buoys take buoyancy and drag/added-mass/FK; a submerged volume-only buoy takes FK. Tests: `case_coupled_rigid6`/`_mirror`/`_fluid`, `case_coupled_point3_buoy`/`_fluid` | | Coupled rigid rods | Pass verified | host-driven `RodA/B` endpoints, correction rewind, bit-identical 24-scalar-per-rod checkpoint state, and two Gauss fluid nodes per rod with SeaState drag/Froude–Krylov/added mass; `case_coupled_rod`, `_mirror`, and `_fluid` pass, and the OpenFAST module compiles with rod decks enabled | -| Coupled finite-EI touchdown/contact | Pass verified | flat `WtrDpth` and equivalent constant structured bathymetry initialise and step with matching loads; friction and checkpoint restore are tested. The IEA-15 mixed example has 38 grounded nodes and completes a 20 s aggregate trajectory at `dtM=0.025 s` with 2 m surge, 1 m heave, and 0.5 m/s host current, without fallback or stall recovery, at most 14 Newton iterations. This is an aggregate integration test, not a full-turbine touchdown DLC | +| Coupled finite-EI touchdown/contact | Pass verified | flat `WtrDpth` and equivalent constant structured bathymetry initialise and step with matching loads; friction and checkpoint restore are tested. The IEA-15 mixed example has 38 grounded nodes and completes a 20 s aggregate trajectory at `dtM=0.025 s` with 2 m surge, 1 m heave, and 0.5 m/s host current, without fallback or stall recovery, at most 14 Newton iterations. A full-turbine run of the same model (one hour after a 200 s transient; TurbSim normal turbulence, 10.6 m/s, 17 % TI; JONSWAP Hs 8 m, Tp 12 s, aligned with the wind and the cable; AeroDyn with the rotor held at 7.55 rpm, no controller, rigid blades and tower; SeaState grid covering the lines) completes without recoveries or non-finite values. The cable's hang-off tension is 11.5 ± 1.1 kN (static 11.9 kN, maximum 17.9 kN), the same 38 nodes stay grounded, and the peak curvature, 0.160 1/m at the hog bend, is mesh-converged (0.156 1/m on a refined mesh); the 10 m elements of the laid section under-resolve the touchdown curvature by about 30 %. The chain-only twin of the run matches stock MoorDyn over 1200 s to 0.3 % in platform motion and fairlead tension statistics. The anchor tension of the laid cable is 1.39 kN (median, static 1.22 kN) with wave-frequency stick-slip peaks up to 4.1 kN lasting under 1 s; before the anchor-end correction of this release it locked at about 2.75 kN for the whole run | | `WaterKin` from file | Pass verified | See [WaterKin and SeaState modes](#waterkin-and-seastate-modes) | | Syrope polyester (`SYROPE:` syntax; [Falkenberg et al., 2017](https://cabledyn.readthedocs.io/en/latest/references.html#ref-falkenberg2017)) | Pass verified | MoorDyn-F/C `BA_s|BA_d` rate and force equations; analytic position/velocity tangents with finite-difference checks; projected, bracketed backward-Euler slow-state update with a strong-unloading boundary test; OWC running maximum; `SYROPE IC` `Tmax0/Tmean0` history with range/order checks; both states carried through every lifecycle stage and the coupled checkpoint. `BA_s` is kept separate from line axial damping (`BA`) and tested against double counting. Composite, hydrodynamic, finite-EI, current, and wave combinations stop with a named error | | VIV (`compVIV`) | Not supported | outside CableDyn's scope | From c747e7e357dde9341445ea88f8bd0a3ff5e99d01 Mon Sep 17 00:00:00 2001 From: Jae Hoon Seo Date: Thu, 15 Oct 2026 07:11:56 +0900 Subject: [PATCH 3/4] fix: support the end moment only where the end element is laid Review found that the floor carried the end element's weight moment whenever the held end node touched the seabed, so a taut line anchored on the floor whose first element rises into the water lost the end moment of that element's weight: the floor does not support it. The support now also needs the element to lie on the floor: it is scaled by a C1 smoothstep S(r) of r = N_in / (w l0 / 2), the elastic normal force of the element's inner node from the contact law the assembly uses over its half share of the element weight. A laid element (r about 2) keeps the full support; an element whose inner node is clear of the floor gets none, and its line is bit-identical to the same line without a seabed; in between the term is smooth and its tangent is assembled in the statics and the dynamics. A test checks the taut line anchored on the floor against the line without a seabed, statics and held dynamic steps, bit for bit. The slope-polish test of hermite_cable_static failed on Linux: its layout touched down at a node with neighbouring equilibria 3 cm apart, and under some BLAS kernels even its reference state was unstable. The fairlead now sits at x = 200 m, where every kernel reaches the same stable reference, every clear node stands 0.3 m above the floor, and both polishes return to it from four times the perturbation the test uses (default, Prescott, Haswell and SkylakeX kernels; Release and Debug). The shipped finite-EI examples with a grounded anchor now change by at most 0.34 N from dev. Signed-off-by: Jae Hoon Seo --- CHANGELOG.md | 8 +- doc/theory.rst | 7 +- src/CableDyn_HermiteCableDynamic.f90 | 127 ++++++++++++++++++++------- src/CableDyn_HermiteCableStatic.f90 | 85 +++++++++++++++--- src/CableDyn_SeabedContact.f90 | 33 ++++++- tests/test_hermite_cable_static.f90 | 116 ++++++++++++++++++++---- 6 files changed, 305 insertions(+), 71 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b38c992e..d54a8406 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -86,9 +86,13 @@ All notable changes to CableDyn are recorded in this file. The format follows platform drifted toward the anchor), and without friction the end nodes wandered by up to 0.18 m. The seabed now carries the end element's weight with its end moment at a held line end resting on the floor (along the floor normal on a sloped bathymetry), in the statics and the - dynamics alike. Lines whose held end does not rest on the seabed are unchanged. In the + dynamics alike, in the share in which the element lies on the floor: the contact force of + its inner node against half the element's weight, through a smooth step that is zero when + that node is clear of the floor and one from half the weight up. Lines whose held end does + not rest on the seabed, or whose end element rises from it (a taut line anchored on the + floor), are unchanged. In the shipped finite-EI examples with an anchor on the seabed the end tensions change by at most - 0.7 N (0.05 %). Two decks of the statics robustness matrix change outcome. A lazy wave + 0.34 N (0.004 %). Two decks of the statics robustness matrix change outcome. A lazy wave in a 1 m/s current on a frictional bed (`LW_1015__cur_fr`) had been reported as a hairpin past its anchor only at its exact seabed stiffness. It now fails closed: the friction-held touchdown goes into compression at about 0.33 m/s, before any tension-only equilibrium is diff --git a/doc/theory.rst b/doc/theory.rst index bf1cd0b4..e19b426e 100644 --- a/doc/theory.rst +++ b/doc/theory.rst @@ -1034,8 +1034,11 @@ The fallback and the dynamic Hermite path use :math:`\pm wL_0^2/12` on the end :math:`m_z`. At a held line end resting on the seabed the floor carries the end element's weight with this end moment (its normal share :math:`\cos\theta\,\mathbf{n}` on a floor of slope :math:`\theta` and upward normal - :math:`\mathbf{n}`): the nodal contact carries no moment, and the unbalanced end moment - would otherwise turn the end tangent into the floor; + :math:`\mathbf{n}`), in the share :math:`3r^2 - 2r^3` (:math:`0 \le r \le 1`) in which the + element lies on the floor, :math:`r` the elastic contact force of its inner node over half the + element's weight: the nodal contact carries no moment, and the unbalanced end moment would + otherwise turn the end tangent of a laid element into the floor, while an element rising + from an anchor on the floor (:math:`r = 0`) keeps it; - **mesh sequencing**: the equilibrium is selected on a coarse mesh that preserves section, load, and contact-diameter interfaces, prolonged through the Hermite interpolant, and polished on each finer level and finally on the exact user mesh with the same residual test. Deterministic diff --git a/src/CableDyn_HermiteCableDynamic.f90 b/src/CableDyn_HermiteCableDynamic.f90 index 0f3d9ae5..006360ff 100644 --- a/src/CableDyn_HermiteCableDynamic.f90 +++ b/src/CableDyn_HermiteCableDynamic.f90 @@ -67,7 +67,8 @@ MODULE CableDyn_HermiteCableDynamic CD_Component_Wave_Kinematics, CD_Solve_Dispersion_Wavenumber, CD_HYDRO_OK USE CableDyn_SeabedContact, ONLY: CD_Seabed_Normal_Law, CD_Seabed_Contact_Gate, CD_SEABED_CONTACT_BLEND, & CD_Seabed_Friction_Stick_Slip, CD_Seabed_Friction_Aniso, & - CD_Seabed_Friction_Mu_Dir, CD_FRICTION_STICK_SLIP, CD_Seabed_End_Support + CD_Seabed_Friction_Mu_Dir, CD_FRICTION_STICK_SLIP, CD_Seabed_End_Support, & + CD_Seabed_End_Element_Share USE CableDyn_Bathymetry, ONLY: CD_BathymetryType, CD_Bathymetry_Is_Initialized, & CD_Bathymetry_Floor_Gradient, CD_End_Bathymetry, CD_BATHY_OK USE CableDyn_HermiteTorsion, ONLY: CD_HermiteTorsionType, CD_HermiteTorsion_Line, CD_HermiteTorsion_Unwrap, & @@ -5278,7 +5279,8 @@ SUBROUTINE assemble_residual(model, q_cfg, v_cfg, t_eval, want_residual, want_ta REAL(wp) :: fdry(4), kdry(4, 4), dry_wl, dry_b, dry_r INTEGER :: zdof(4), b LOGICAL :: dry - REAL(wp) :: endconn_d0_eval(3, 2), support(3) + REAL(wp) :: endconn_d0_eval(3, 2), support(3), dsupport(3), nin(3), mend + INTEGER :: inode, jr, jc CHARACTER(200) :: em2 ErrStat = CD_HCDYN_OK; ErrMsg = '' @@ -5356,12 +5358,13 @@ SUBROUTINE assemble_residual(model, q_cfg, v_cfg, t_eval, want_residual, want_ta R(6*e + 3) = R(6*e + 3) + model%w(e)*0.5_wp*model%l0(e) R(6*e + 6) = R(6*e + 6) - model%w(e)*model%l0(e)*model%l0(e)/12.0_wp END DO - ! A held end resting on the floor: the seabed carries the end element's weight with - ! its consistent end moment (CD_Seabed_End_Support), which the nodal contact cannot. + ! A held end whose end element lies on the floor: the seabed carries the element's + ! weight with its consistent end moment (CD_Seabed_End_Support and + ! CD_Seabed_End_Element_Share), which the nodal contact cannot. IF (model%has_contact .OR. model%kn > CD_ZERO) THEN - IF (held_end_floor_support(model, q_cfg, 1, support)) & + IF (held_end_floor_support(model, q_cfg, 1, support, dsupport, inode, nin)) & R(4:6) = R(4:6) - (model%w(1)*model%l0(1)*model%l0(1)/12.0_wp)*support - IF (held_end_floor_support(model, q_cfg, 2, support)) & + IF (held_end_floor_support(model, q_cfg, 2, support, dsupport, inode, nin)) & R(6*ne + 4:6*ne + 6) = R(6*ne + 4:6*ne + 6) + (model%w(ne)*model%l0(ne)*model%l0(ne)/12.0_wp)*support END IF END IF @@ -5424,6 +5427,26 @@ SUBROUTINE assemble_residual(model, q_cfg, v_cfg, t_eval, want_residual, want_ta END IF END DO END IF + ! The floor-carried end moment of a held end follows the contact of the end element's + ! inner node (inode, floor normal nin): its tangent couples the end tangent to that node. + IF (want_tangent .AND. (model%has_contact .OR. model%kn > CD_ZERO)) THEN + IF (held_end_floor_support(model, q_cfg, 1, support, dsupport, inode, nin)) THEN + mend = model%w(1)*model%l0(1)*model%l0(1)/12.0_wp + DO jc = 1, 3 + DO jr = 1, 3 + CALL scatter_contact_band(Kb, 3 + jr, 6*inode - 6 + jc, mend*dsupport(jr)*nin(jc)) + END DO + END DO + END IF + IF (held_end_floor_support(model, q_cfg, 2, support, dsupport, inode, nin)) THEN + mend = model%w(ne)*model%l0(ne)*model%l0(ne)/12.0_wp + DO jc = 1, 3 + DO jr = 1, 3 + CALL scatter_contact_band(Kb, 6*ne + 3 + jr, 6*inode - 6 + jc, -mend*dsupport(jr)*nin(jc)) + END DO + END DO + END IF + END IF ! Scatter the element-private hydrodynamic tangents in the same phase and element ! order as the serial formulation, retaining its floating-point accumulation order. @@ -5879,48 +5902,88 @@ SUBROUTINE assemble_contact(model, q_cfg, v_cfg, want_residual, want_tangent, Er END DO END SUBROUTINE assemble_contact - LOGICAL FUNCTION held_end_floor_support(model, q_cfg, iend, support) RESULT(held) + LOGICAL FUNCTION held_end_floor_support(model, q_cfg, iend, support, dsupport, inode, nin) RESULT(held) !! Floor reaction carrying the weight of the end element at line end iend (1: node 1, - !! 2: node nn) of a model with seabed contact, per unit weight: CD_Seabed_End_Support - !! times the floor's normal share of the weight, cos(slope) n, n the upward floor - !! normal (e_z on a flat bed). Its consistent end moment cancels the weight's on a - !! grounded end element; the along-floor part of the weight stays with the line. False - !! (support zero) unless the end node's translations are all held (not free), its end - !! element is net-heavy and the end rests on the floor the contact assembly uses there. + !! 2: node nn) of a model with seabed contact, per unit weight: the floor's normal share + !! cos(slope) n of the weight (n the upward floor normal at the end, e_z on a flat bed) + !! times the share of the element lying on the floor. Its consistent end moment cancels + !! the weight's on a grounded end element; the along-floor part of the weight stays with + !! the line. The share is CD_Seabed_End_Support of the end node (on or below the floor) + !! times CD_Seabed_End_Element_Share of the element's inner node inode (the normal force + !! of its elastic contact law against half the element's weight): zero for an element + !! rising from an anchor on the floor, one for a laid element, smooth in between. + !! dsupport is d(support)/d(gap) of the inner node, whose gap gradient is -nin (nin its + !! floor normal). False (support zero) unless the end node's translations are all held + !! (not free), its end element is net-heavy and the share is positive. TYPE(CD_HermiteCableDynType), INTENT(IN) :: model REAL(wp), INTENT(IN) :: q_cfg(:) INTEGER, INTENT(IN) :: iend - REAL(wp), INTENT(OUT) :: support(3) + REAL(wp), INTENT(OUT) :: support(3), dsupport(3), nin(3) + INTEGER, INTENT(OUT) :: inode INTEGER :: node, e, ix, es - REAL(wp) :: xg, yg, z_floor, gxg, gyg, gx, gy, sfac, share + REAL(wp) :: gap, sfac, share, nvec(3), sfac_in, gap_in, normal, normal_gap, elem, delem CHARACTER(200) :: em support = CD_ZERO + dsupport = CD_ZERO + nin = [CD_ZERO, CD_ZERO, CD_ONE] held = .FALSE. IF (iend == 1) THEN - node = 1; e = 1 + node = 1; e = 1; inode = 2 ELSE - node = model%nn; e = model%ne + node = model%nn; e = model%ne; inode = model%nn - 1 END IF IF (.NOT. (model%w(e) > CD_ZERO)) RETURN ix = 6*node - 5 IF (ANY(model%freemask(ix:ix + 2))) RETURN - gx = CD_ZERO - gy = CD_ZERO - z_floor = model%seabed_z - IF (model%has_contact .AND. model%has_contact_bathymetry) THEN - xg = model%contact_frame_c*q_cfg(ix) - model%contact_frame_s*q_cfg(ix + 1) - yg = model%contact_frame_s*q_cfg(ix) + model%contact_frame_c*q_cfg(ix + 1) - CALL CD_Bathymetry_Floor_Gradient(model%contact_bathymetry, xg, yg, z_floor, gxg, gyg, es, em) - ! A failed query fails closed in the contact assembly at the same point. - IF (es /= CD_BATHY_OK) RETURN - gx = model%contact_frame_c*gxg + model%contact_frame_s*gyg - gy = -model%contact_frame_s*gxg + model%contact_frame_c*gyg - END IF - sfac = SQRT(CD_ONE + gx*gx + gy*gy) - share = CD_Seabed_End_Support((z_floor - q_cfg(ix + 2))/sfac) + CALL floor_gap(node, gap, nvec, sfac, es) + IF (es /= CD_BATHY_OK) RETURN + share = CD_Seabed_End_Support(gap) IF (.NOT. (share > CD_ZERO)) RETURN + CALL floor_gap(inode, gap_in, nin, sfac_in, es) + IF (es /= CD_BATHY_OK) RETURN + IF (model%has_contact) THEN + CALL CD_Seabed_Normal_Law(gap_in, model%contact_kn(inode), normal, normal_gap) + ELSE IF (gap_in > CD_ZERO) THEN + normal = model%kn*model%trib(inode)*gap_in + normal_gap = model%kn*model%trib(inode) + ELSE + normal = CD_ZERO + normal_gap = CD_ZERO + END IF + CALL CD_Seabed_End_Element_Share(normal, normal_gap, 0.5_wp*model%w(e)*model%l0(e), elem, delem) + IF (.NOT. (elem > CD_ZERO)) RETURN held = .TRUE. - support = (share/(sfac*sfac))*[-gx, -gy, CD_ONE] + support = (share*elem/sfac)*nvec + dsupport = (share*delem/sfac)*nvec + + CONTAINS + + SUBROUTINE floor_gap(k, gap_k, n_k, sfac_k, es_k) + !! Normal penetration gap_k, upward floor normal n_k and slope factor of node k, on the + !! floor the contact assembly uses (structured bathymetry or the flat seabed plane). A + !! failed bathymetry query (es_k) fails closed in the contact assembly at the same point. + INTEGER, INTENT(IN) :: k + REAL(wp), INTENT(OUT) :: gap_k, n_k(3), sfac_k + INTEGER, INTENT(OUT) :: es_k + REAL(wp) :: xg, yg, z_floor, gxg, gyg, gx, gy + INTEGER :: kx + kx = 6*k - 5 + es_k = CD_BATHY_OK + gx = CD_ZERO + gy = CD_ZERO + z_floor = model%seabed_z + IF (model%has_contact .AND. model%has_contact_bathymetry) THEN + xg = model%contact_frame_c*q_cfg(kx) - model%contact_frame_s*q_cfg(kx + 1) + yg = model%contact_frame_s*q_cfg(kx) + model%contact_frame_c*q_cfg(kx + 1) + CALL CD_Bathymetry_Floor_Gradient(model%contact_bathymetry, xg, yg, z_floor, gxg, gyg, es_k, em) + IF (es_k /= CD_BATHY_OK) RETURN + gx = model%contact_frame_c*gxg + model%contact_frame_s*gyg + gy = -model%contact_frame_s*gxg + model%contact_frame_c*gyg + END IF + sfac_k = SQRT(CD_ONE + gx*gx + gy*gy) + n_k = [-gx, -gy, CD_ONE]/sfac_k + gap_k = (z_floor - q_cfg(kx + 2))/sfac_k + END SUBROUTINE floor_gap END FUNCTION held_end_floor_support SUBROUTINE commit_friction_anchors(model) diff --git a/src/CableDyn_HermiteCableStatic.f90 b/src/CableDyn_HermiteCableStatic.f90 index c096a5b1..f38c924e 100644 --- a/src/CableDyn_HermiteCableStatic.f90 +++ b/src/CableDyn_HermiteCableStatic.f90 @@ -43,7 +43,7 @@ MODULE CableDyn_HermiteCableStatic CD_ENDCONN_RIGID USE CableDyn_SeabedContact, ONLY: CD_Seabed_Normal_Law, CD_SEABED_CONTACT_BLEND, CD_Seabed_Friction_Spring, & CD_Seabed_Friction_Aniso, CD_Seabed_Friction_Mu_Dir, CD_FRICTION_SPRING, & - CD_Seabed_Normal_Contact, CD_Seabed_End_Support + CD_Seabed_Normal_Contact, CD_Seabed_End_Support, CD_Seabed_End_Element_Share USE CableDyn_Bathymetry, ONLY: CD_BathymetryType, CD_Bathymetry_Is_Initialized, & CD_Bathymetry_Floor, CD_Bathymetry_Floor_Gradient, CD_BATHY_OK USE CableDyn_HermiteCableDynamic, ONLY: CD_HermiteCable_Drag_Element, CD_HCDYN_OK @@ -786,10 +786,11 @@ SUBROUTINE CD_HermiteCable_Static_Solve(l0, EA, EI, w, seed, fixed_dofs, seabed_ trib(i) = trib(i) + 0.5_wp*l0(i) trib(i + 1) = trib(i + 1) + 0.5_wp*l0(i) END DO - ! A held end resting on the floor: the seabed carries the end element's weight with its + ! A held end resting on the floor: the seabed can carry the end element's weight with its ! consistent end moment (CD_Seabed_End_Support; per unit weight, the floor's normal ! share cos(slope) n of the weight), which the nodal contact cannot. Held translations - ! keep their seed, so the support is fixed for the solve. + ! keep their seed, so this factor is fixed for the solve; the share of the element lying + ! on the floor (end_element_share) follows the iterate. end_support = CD_ZERO IF (use_nodal_contact .OR. kn > CD_ZERO) THEN DO i = 1, 2 @@ -1112,18 +1113,15 @@ RECURSIVE SUBROUTINE newton_step(rnorm, es, em, do_update) pi_total = pi_total + e_term pi_abs = pi_abs + ABS(e_term) END DO - ! the floor-carried end moments of held ends resting on the seabed - IF (end_support(3, 1) > CD_ZERO) THEN - R(4:6) = R(4:6) - (w_cur(1)*l0(1)*l0(1)/12.0_wp)*end_support(:, 1) - e_term = -(w_cur(1)*l0(1)*l0(1)/12.0_wp)*DOT_PRODUCT(end_support(:, 1), q(4:6)) - pi_total = pi_total + e_term - pi_abs = pi_abs + ABS(e_term) + ! the floor-carried end moments of held ends whose end element lies on the seabed + es2 = CD_HCSTAT_OK + IF (end_support(3, 1) > CD_ZERO) CALL add_end_support(1, 1, 2, -CD_ONE, es2, em2) + IF (es2 /= CD_HCSTAT_OK) THEN + es = CD_HCSTAT_NOCONVERGE; em = TRIM(em2); RETURN END IF - IF (end_support(3, 2) > CD_ZERO) THEN - R(6*ne + 4:6*ne + 6) = R(6*ne + 4:6*ne + 6) + (w_cur(ne)*l0(ne)*l0(ne)/12.0_wp)*end_support(:, 2) - e_term = (w_cur(ne)*l0(ne)*l0(ne)/12.0_wp)*DOT_PRODUCT(end_support(:, 2), q(6*ne + 4:6*ne + 6)) - pi_total = pi_total + e_term - pi_abs = pi_abs + ABS(e_term) + IF (end_support(3, 2) > CD_ZERO) CALL add_end_support(2, ne, nn - 1, CD_ONE, es2, em2) + IF (es2 /= CD_HCSTAT_OK) THEN + es = CD_HCSTAT_NOCONVERGE; em = TRIM(em2); RETURN END IF ! ---- dry-part buoyancy recovery above the optional free surface ---- @@ -2425,6 +2423,65 @@ SUBROUTINE add_end_connection(node, k_rot, d0, ec_stat, ec_msg) END DO END SUBROUTINE add_end_connection + SUBROUTINE add_end_support(iend, e, inode, sgn, sp_stat, sp_msg) + !! Scatter the floor-carried end moment of held end iend (end element e, inner node + !! inode; sgn = -1 at node 1, +1 at node nn) into the residual and the band tangent: + !! the element's consistent weight moment w l0^2/12 along end_support(:, iend) times + !! the share of the element lying on the floor (CD_Seabed_End_Element_Share of the + !! inner node's elastic normal force, the same contact law as the assembly below). The + !! share couples the end tangent to the inner node's translations. The potential takes + !! the share at the iterate: exact where it is 0 or 1, first order in between. + INTEGER, INTENT(IN) :: iend, e, inode + REAL(wp), INTENT(IN) :: sgn + INTEGER, INTENT(OUT) :: sp_stat + CHARACTER(*), INTENT(OUT) :: sp_msg + REAL(wp) :: z_fl, gxg_s, gyg_s, g_s(2), sf, n_in(3), pen_s, normal_s, normal_gap_s, elem, delem, mom + INTEGER :: base, bin, i, j + CHARACTER(200) :: em_s + sp_stat = CD_HCSTAT_OK + sp_msg = '' + base = MERGE(3, 6*(nn - 1) + 3, iend == 1) ! end tangent DOFs are base+1 .. base+3 + bin = 6*(inode - 1) ! inner-node translations bin+1 .. bin+3 + z_fl = seabed_z + g_s = CD_ZERO + IF (use_bathymetry) THEN + CALL CD_Bathymetry_Floor_Gradient(bathymetry, contact_cs(1)*q(bin + 1) - contact_cs(2)*q(bin + 2), & + contact_cs(2)*q(bin + 1) + contact_cs(1)*q(bin + 2), & + z_fl, gxg_s, gyg_s, sp_stat, em_s) + IF (sp_stat /= CD_BATHY_OK) THEN + sp_stat = CD_HCSTAT_NOCONVERGE; sp_msg = 'bathymetry query failed: '//TRIM(em_s); RETURN + END IF + g_s = [contact_cs(1)*gxg_s + contact_cs(2)*gyg_s, -contact_cs(2)*gxg_s + contact_cs(1)*gyg_s] + END IF + sf = SQRT(CD_ONE + g_s(1)*g_s(1) + g_s(2)*g_s(2)) + n_in = [-g_s(1), -g_s(2), CD_ONE]/sf + pen_s = (z_fl - q(bin + 3))/sf + IF (use_nodal_contact) THEN + CALL CD_Seabed_Normal_Law(pen_s, contact_kn(inode), normal_s, normal_gap_s) + ELSE IF (pen_s > CD_ZERO) THEN + normal_s = kn*trib(inode)*pen_s + normal_gap_s = kn*trib(inode) + ELSE + normal_s = CD_ZERO + normal_gap_s = CD_ZERO + END IF + CALL CD_Seabed_End_Element_Share(normal_s, normal_gap_s, 0.5_wp*w_cur(e)*l0(e), elem, delem) + IF (.NOT. (elem > CD_ZERO)) RETURN + mom = sgn*w_cur(e)*l0(e)*l0(e)/12.0_wp + R(base + 1:base + 3) = R(base + 1:base + 3) + (mom*elem)*end_support(:, iend) + pi_total = pi_total + mom*elem*DOT_PRODUCT(end_support(:, iend), q(base + 1:base + 3)) + pi_abs = pi_abs + ABS(mom*elem*DOT_PRODUCT(end_support(:, iend), q(base + 1:base + 3))) + ! d(gap)/d(r_inner) = -n_in (floor gradient held over the node) + IF (delem /= CD_ZERO) THEN + DO j = 1, 3 + DO i = 1, 3 + ab(KL_H + KU_H + 1 + base + i - bin - j, bin + j) = ab(KL_H + KU_H + 1 + base + i - bin - j, bin + j) - & + mom*delem*end_support(i, iend)*n_in(j) + END DO + END DO + END IF + END SUBROUTINE add_end_support + PURE REAL(wp) FUNCTION residual_merit(residual) RESULT(value) !! Half the squared two-norm of the scaled residual over free DOFs. The !! common force scale is omitted because it does not change descent. diff --git a/src/CableDyn_SeabedContact.f90 b/src/CableDyn_SeabedContact.f90 index b42c9fe6..301647a1 100644 --- a/src/CableDyn_SeabedContact.f90 +++ b/src/CableDyn_SeabedContact.f90 @@ -16,7 +16,7 @@ MODULE CableDyn_SeabedContact PUBLIC :: CD_Seabed_Normal_Law PUBLIC :: CD_Seabed_Normal_Contact PUBLIC :: CD_Seabed_Contact_Gate - PUBLIC :: CD_Seabed_End_Support + PUBLIC :: CD_Seabed_End_Support, CD_Seabed_End_Element_Share PUBLIC :: CD_Seabed_Friction_Spring PUBLIC :: CD_Seabed_Friction_Stick_Slip PUBLIC :: CD_Seabed_Friction_Aniso, CD_Seabed_Friction_Mu_Dir @@ -102,20 +102,45 @@ END SUBROUTINE CD_Seabed_Contact_Gate PURE REAL(wp) FUNCTION CD_Seabed_End_Support(gap) RESULT(support) !! Share of the consistent end moment w l0^2/12 of a net-heavy end element that the - !! seabed carries at a HELD line end (translations fixed or prescribed) at signed normal - !! penetration gap = z_floor - z. The nodal penalty is the end-point (Lobatto) + !! seabed can carry at a HELD line end (translations fixed or prescribed) at signed normal + !! penetration gap = z_floor - z, before the element's own contact + !! (CD_Seabed_End_Element_Share) is weighed in. The nodal penalty is the end-point (Lobatto) !! integration of the floor reaction and carries no moment, so on a grounded end !! element the weight's end moment would otherwise turn the free end tangent into the !! floor: the element dips below the seabed between its nodes and, on a high-EA line, !! carries large spurious axial forces of both signs. One for an end on or below the !! floor, zero above the contact blend, linear in between (CD_Seabed_Contact_Gate !! shifted by one blend length, so that an anchor placed exactly on the floor rests on - !! it). The end is held, so the share is constant within a solve and adds no tangent. + !! it). The end is held, so this factor is constant within a solve and adds no tangent. REAL(wp), INTENT(IN) :: gap REAL(wp) :: dgate_dgap CALL CD_Seabed_Contact_Gate(gap + CD_SEABED_CONTACT_BLEND, support, dgate_dgap) END FUNCTION CD_Seabed_End_Support + PURE SUBROUTINE CD_Seabed_End_Element_Share(normal, normal_gap, weight_share, share, dshare_dgap) + !! Share of an end element lying on the floor, from the contact of its inner node: the + !! ratio r of that node's elastic normal force to the element's weight share it would + !! carry laid on the floor (half the element's weight), through the C1 smoothstep + !! 3 r^2 - 2 r^3 on 0 <= r <= 1 (zero at r <= 0, one at r >= 1). A laid element (r near + !! 2, the node also carrying its other element) is fully on the floor, an element rising + !! from its end into the water (node clear of the floor) not at all, and the share is + !! continuous with a continuous derivative through touchdown and lift-off of the node. + !! normal_gap is d(normal)/d(gap); dshare_dgap the derivative of the share in that gap. + REAL(wp), INTENT(IN) :: normal, normal_gap, weight_share + REAL(wp), INTENT(OUT) :: share, dshare_dgap + REAL(wp) :: r + share = CD_ZERO + dshare_dgap = CD_ZERO + IF (.NOT. (weight_share > CD_ZERO)) RETURN + r = normal/weight_share + IF (r >= CD_ONE) THEN + share = CD_ONE + ELSE IF (r > CD_ZERO) THEN + share = r*r*(3.0_wp - 2.0_wp*r) + dshare_dgap = 6.0_wp*r*(CD_ONE - r)*normal_gap/weight_share + END IF + END SUBROUTINE CD_Seabed_End_Element_Share + PURE SUBROUTINE CD_Seabed_Friction_Spring(d, stiffness, capacity, force, dforce_dd, dforce_dcap) !! Static seabed friction spring: the resisting force of a horizontal spring of !! stiffness k stretched by d from its reference, capped smoothly at the capacity C, diff --git a/tests/test_hermite_cable_static.f90 b/tests/test_hermite_cable_static.f90 index 1554328c..6a192cb3 100644 --- a/tests/test_hermite_cable_static.f90 +++ b/tests/test_hermite_cable_static.f90 @@ -19,7 +19,8 @@ PROGRAM test_hermite_cable_static CD_HermiteCable_Dyn_Set_Drag, CD_HermiteCable_Dyn_Reaction, & CD_HermiteCable_Dyn_End, CD_HCDYN_OK, CD_HermiteCable_Dyn_End_Force, & CD_HermiteCable_Drag_Element, CD_HermiteCable_Dyn_Step - USE CableDyn_SeabedContact, ONLY: CD_HermiteCable_Friction_Spring => CD_Seabed_Friction_Spring + USE CableDyn_SeabedContact, ONLY: CD_HermiteCable_Friction_Spring => CD_Seabed_Friction_Spring, & + CD_Seabed_End_Element_Share USE CableDyn_Line, ONLY: CD_Nodal_Seabed_Stiffness, CD_LINE_OK USE CableDyn_Bathymetry, ONLY: CD_BathymetryType, CD_Init_Bathymetry USE, INTRINSIC :: IEEE_ARITHMETIC, ONLY: IEEE_IS_FINITE @@ -39,6 +40,7 @@ PROGRAM test_hermite_cable_static CALL check_dry_buoyancy_static() CALL check_seabed_mesh_jump() CALL check_scalar_contact_on_slope() + CALL check_taut_line_anchored_on_floor() CALL check_frictionless_slope_run() CALL check_long_sequence_hierarchy() CALL check_current_static() @@ -309,17 +311,100 @@ SUBROUTINE check_seabed_mesh_jump() CALL require(dev < 0.1_wp*pen0, 'mesh-jump penetration stays near w/(kBot d)') END SUBROUTINE check_seabed_mesh_jump + SUBROUTINE check_taut_line_anchored_on_floor() + !! The floor carries the end element's weight moment only where the element lies on it. + !! A taut line anchored on the floor rises into the water from its anchor: its end element + !! is clear of the floor beyond the anchor node, the seabed supports none of it, and the + !! line takes the bending of the same line without a seabed. Its static state (with the + !! curvature at the pinned anchor) and its held dynamic march must equal those of the + !! line with no seabed bit for bit. With the floor support decided by the anchor alone, + !! the cancelled end moment w l0^2/12 moved the line by 7 mm and raised the anchor + !! curvature by half (2.9e-3 to 4.3e-3 1/m). The element share itself is zero clear of + !! the floor, one laid, and C1 through touchdown. + INTEGER, PARAMETER :: NE = 20, NN = NE + 1 + REAL(wp) :: l0(NE), EA(NE), EI(NE), w(NE), rho_a(NE), seed(6*NN), qa(6*NN), qb(6*NN), ca(NN), cb(NN), res + REAL(wp) :: trib(NN), kn, share, dshare, share_p, share_m, dsh_p, dsh_m, r + REAL(wp), PARAMETER :: RATIOS(3) = [1.0e-3_wp, 0.5_wp, 0.999_wp] + INTEGER :: fixed(6 + 2*NN), nfix, i, es, it, k + TYPE(CD_HermiteCableDynType) :: dyn_a, dyn_b + CHARACTER(512) :: em + l0 = 100.2_wp/NE; EA = 5.0e8_wp; EI = 2.0e4_wp; w = 800.0_wp; rho_a = 120.0_wp; kn = 2.0e5_wp + trib = 0.0_wp + DO i = 1, NE + trib(i) = trib(i) + 0.5_wp*l0(i); trib(i + 1) = trib(i + 1) + 0.5_wp*l0(i) + END DO + ! anchor on the 100 m floor, fairlead 60 m away and 80 m up: chord 100 m, length 100.2 m + CALL CD_HermiteCable_Trivial_Seed([0.0_wp, 0.0_wp, -100.0_wp], [60.0_wp, 0.0_wp, -20.0_wp], l0, -100.0_wp, & + seed, es, em) + CALL require(es == CD_HCSTAT_OK, 'taut anchored seed: '//TRIM(em)) + fixed(1:6) = [1, 2, 3, 6*NE + 1, 6*NE + 2, 6*NE + 3] + nfix = 6 + DO i = 1, NN + fixed(nfix + 1:nfix + 2) = [6*i - 4, 6*i - 1] + nfix = nfix + 2 + END DO + CALL CD_HermiteCable_Static_Solve(l0, EA, EI, w, seed, fixed(1:nfix), -100.0_wp, 0.0_wp, 4, 200, 1.0e-10_wp, & + 1.0_wp, qa, ca, res, it, es, em, contact_kn=kn*trib) + CALL require(es == CD_HCSTAT_OK, 'taut anchored line on the floor: '//TRIM(em)) + CALL CD_HermiteCable_Static_Solve(l0, EA, EI, w, seed, fixed(1:nfix), -1.0e4_wp, 0.0_wp, 4, 200, 1.0e-10_wp, & + 1.0_wp, qb, cb, res, it, es, em) + CALL require(es == CD_HCSTAT_OK, 'taut anchored line without seabed: '//TRIM(em)) + CALL require(qa(6*2 - 3) + 100.0_wp > 1.0_wp, 'taut anchored line rises from its anchor') + CALL require(ALL(qa == qb), 'taut anchored line: the floor carries none of the rising end element') + CALL require(ALL(ca == cb), 'taut anchored line keeps the bending of the line without seabed') + ! The held dynamics with the scalar floor at the anchor height equal those without a floor. + CALL CD_HermiteCable_Dyn_Init(dyn_a, l0, EA, EI, rho_a, w, qa, fixed(1:nfix), -100.0_wp, kn, 0.8_wp, es, em) + CALL require(es == CD_HCDYN_OK, 'taut anchored dynamics with floor: '//TRIM(em)) + CALL CD_HermiteCable_Dyn_Init(dyn_b, l0, EA, EI, rho_a, w, qa, fixed(1:nfix), -1.0e4_wp, 0.0_wp, 0.8_wp, es, em) + CALL require(es == CD_HCDYN_OK, 'taut anchored dynamics without floor: '//TRIM(em)) + DO k = 1, 5 + CALL CD_HermiteCable_Dyn_Step(dyn_a, 0.05_wp, 30, 1.0e-9_wp, es, em) + CALL require(es == CD_HCDYN_OK, 'taut anchored step with floor: '//TRIM(em)) + CALL CD_HermiteCable_Dyn_Step(dyn_b, 0.05_wp, 30, 1.0e-9_wp, es, em) + CALL require(es == CD_HCDYN_OK, 'taut anchored step without floor: '//TRIM(em)) + END DO + CALL require(ALL(dyn_a%q == dyn_b%q) .AND. ALL(dyn_a%v == dyn_b%v), & + 'taut anchored dynamics: the floor carries none of the rising end element') + CALL CD_HermiteCable_Dyn_End(dyn_a) + CALL CD_HermiteCable_Dyn_End(dyn_b) + ! the element share: ratio r of the inner node's normal force to half the element weight + CALL CD_Seabed_End_Element_Share(0.0_wp, 0.0_wp, 100.0_wp, share, dshare) + CALL require(share == 0.0_wp .AND. dshare == 0.0_wp, 'end element share: clear of the floor') + CALL CD_Seabed_End_Element_Share(200.0_wp, 1.0e4_wp, 100.0_wp, share, dshare) + CALL require(share == 1.0_wp .AND. dshare == 0.0_wp, 'end element share: laid') + DO k = 1, 3 + r = RATIOS(k) + ! normal = 100 r with d(normal)/d(gap) = 1e4: central difference of the share in the gap + CALL CD_Seabed_End_Element_Share(100.0_wp*r, 1.0e4_wp, 100.0_wp, share, dshare) + CALL CD_Seabed_End_Element_Share(100.0_wp*r + 1.0e-4_wp, 1.0e4_wp, 100.0_wp, share_p, dsh_p) + CALL CD_Seabed_End_Element_Share(100.0_wp*r - 1.0e-4_wp, 1.0e4_wp, 100.0_wp, share_m, dsh_m) + CALL require(ABS((share_p - share_m)/2.0e-8_wp - dshare) <= 1.0e-5_wp*MAX(1.0_wp, ABS(dshare)), & + 'end element share: derivative matches its difference quotient') + CALL require(ABS(share - r*r*(3.0_wp - 2.0_wp*r)) <= 1.0e-15_wp, 'end element share: smoothstep') + END DO + END SUBROUTINE check_taut_line_anchored_on_floor + SUBROUTINE check_scalar_contact_on_slope() !! The scalar-kn contact path on a structured (sloped) bathymetry includes the slope !! terms of the penetration in its tangent: from a perturbed equilibrium it converges - !! quadratically to the same state as the nodal path with the equivalent stiffness. - !! The perturbation is a few centimetres: the frictionless reaction is normal to the - !! slope, so it couples x and z at every grounded node on this coarse mesh (elements - !! longer than the bending length), and the full-step Newton basin is that small. + !! as fast as, and to the same state as, the nodal path with the equivalent stiffness. + !! The frictionless reaction is normal to the slope, so it couples x and z at every + !! grounded node of this coarse mesh (elements longer than the bending length). The + !! layout is chosen so that the problem is well posed on every platform: the line, held + !! taut by a fairlead 200 m from the anchor, lies on the slope from its anchor + !! (on the floor) to a touchdown between nodes, every clear node stands at least 0.3 m + !! above the floor (no node in the contact blend), and the equilibrium is a stable one. + !! A slacker layout (fairlead at 150 m) touched down at a node and admitted neighbouring + !! equilibria within 3 cm that the polish reached or not depending on round-off (the + !! OpenBLAS kernel, the platform). The perturbation (7.5 mm in x, 5 mm in z) is a quarter + !! of the largest one from which both backtracking polishes return to the reference + !! under the Prescott, Haswell and SkylakeX kernels and the default one; backtracking + !! (the same option on both paths) keeps each Newton update a residual decrease. INTEGER, PARAMETER :: NE = 20, NN = NE + 1 - REAL(wp) :: l0(NE), EA(NE), EI(NE), w(NE), seed(6*NN), q1(6*NN), q2(6*NN), qs(6*NN), curv(NN), res + REAL(wp) :: l0(NE), EA(NE), EI(NE), w(NE), seed(6*NN), q1(6*NN), q2(6*NN), qs(6*NN), qr(6*NN), curv(NN), res REAL(wp) :: trib(NN), kn, xg(2), yg(2), dep(2, 2) INTEGER :: fixed(6 + 2*NN), nfix, i, es, it1, it2 + LOGICAL :: stable TYPE(CD_BathymetryType) :: bed CHARACTER(512) :: em xg = [-50.0_wp, 300.0_wp]; yg = [-50.0_wp, 50.0_wp] @@ -331,7 +416,7 @@ SUBROUTINE check_scalar_contact_on_slope() DO i = 1, NE trib(i) = trib(i) + 6.5_wp; trib(i + 1) = trib(i + 1) + 6.5_wp END DO - CALL CD_HermiteCable_Trivial_Seed([0.0_wp, 0.0_wp, -100.0_wp], [150.0_wp, 0.0_wp, -20.0_wp], l0, -100.0_wp, & + CALL CD_HermiteCable_Trivial_Seed([0.0_wp, 0.0_wp, -100.0_wp], [200.0_wp, 0.0_wp, -20.0_wp], l0, -100.0_wp, & seed, es, em) CALL require(es == CD_HCSTAT_OK, 'slope seed: '//TRIM(em)) fixed(1:6) = [1, 2, 3, 6*NE + 1, 6*NE + 2, 6*NE + 3] @@ -341,23 +426,20 @@ SUBROUTINE check_scalar_contact_on_slope() nfix = nfix + 2 END DO CALL CD_HermiteCable_Static_Solve(l0, EA, EI, w, seed, fixed(1:nfix), -100.0_wp, 0.0_wp, 8, 200, 1.0e-9_wp, & - 0.7_wp, q1, curv, res, it1, es, em, contact_kn=kn*trib, bathymetry=bed) + 0.7_wp, qr, curv, res, it1, es, em, contact_kn=kn*trib, bathymetry=bed, & + stable=stable) CALL require(es == CD_HCSTAT_OK, 'slope nodal reference: '//TRIM(em)) - qs = q1 + CALL require(stable, 'slope nodal reference is a stable equilibrium') + qs = qr DO i = 2, NE - qs(6*i - 5) = qs(6*i - 5) + 0.03_wp*SIN(REAL(i, wp)) - qs(6*i - 3) = qs(6*i - 3) + 0.02_wp*COS(REAL(i, wp)) + qs(6*i - 5) = qs(6*i - 5) + 0.0075_wp*SIN(REAL(i, wp)) + qs(6*i - 3) = qs(6*i - 3) + 0.005_wp*COS(REAL(i, wp)) END DO - ! Both polishes backtrack: the anchor (0, -100) rests on the slope, so the floor carries - ! the anchor element's weight moment (CD_Seabed_End_Support) and the grounded run lies - ! straight along the slope instead of dipping into it element by element; from this - ! perturbation full Newton steps then leave that equilibrium's basin (a 0.25-scaled - ! perturbation fails, a 0.5-scaled one converges). The test compares the two contact - ! paths under identical solver options, which backtracking keeps (same count, same state). CALL CD_HermiteCable_Static_Solve(l0, EA, EI, w, qs, fixed(1:nfix), -100.0_wp, 0.0_wp, 1, 60, 1.0e-10_wp, & 1.0_wp, q1, curv, res, it1, es, em, contact_kn=kn*trib, bathymetry=bed, & backtracking=.TRUE.) CALL require(es == CD_HCSTAT_OK, 'slope nodal polish: '//TRIM(em)) + CALL require(nan_max_abs(q1 - qr) < 1.0e-6_wp, 'slope nodal polish returns to the reference') CALL CD_HermiteCable_Static_Solve(l0, EA, EI, w, qs, fixed(1:nfix), -100.0_wp, kn, 1, 60, 1.0e-10_wp, & 1.0_wp, q2, curv, res, it2, es, em, bathymetry=bed, backtracking=.TRUE.) CALL require(es == CD_HCSTAT_OK, 'slope scalar polish converges: '//TRIM(em)) From 16e3a27d350647b95fa4bb52178522cd9f07e4f8 Mon Sep 17 00:00:00 2001 From: Jae Hoon Seo Date: Thu, 15 Oct 2026 08:51:49 +0900 Subject: [PATCH 4/4] fix: hold the end-element share in the energy line search Review found that inside the transition of the end support (0 < S < 1) the energy-minimisation potential varied with the inner node through S, while the residual carries the support load only on the end tangent, so the potential was not a potential of the residual and the Armijo test compared R.dq with the derivative of a different function. Each energy line search now holds the share S0 of its starting point; with S fixed, the gradient of the support energy is exactly the residual's support load at every trial point. The hold is released when a step is accepted or the search stalls, and the torsion descent, which compares energies the same way, holds it too. The alternative, a conjugate force on the inner node (about 0.9 MN here), is a contact force the floor does not exert and would have changed every equilibrium and the dynamics; the support load stays non-conservative like current drag. A new check compares central differences of the held-share potential with R.d along four directions with the inner node mid touchdown (agreement 1e-5; with the share free the inner-node term is off by 8.9e5). Every example output is unchanged. Signed-off-by: Jae Hoon Seo --- src/CableDyn_HermiteCableStatic.f90 | 70 ++++++++++++++++++-- tests/test_hermite_cable_static.f90 | 99 ++++++++++++++++++++++++++++- 2 files changed, 161 insertions(+), 8 deletions(-) diff --git a/src/CableDyn_HermiteCableStatic.f90 b/src/CableDyn_HermiteCableStatic.f90 index f38c924e..ff182a3b 100644 --- a/src/CableDyn_HermiteCableStatic.f90 +++ b/src/CableDyn_HermiteCableStatic.f90 @@ -271,7 +271,8 @@ SUBROUTINE CD_HermiteCable_Static_Solve(l0, EA, EI, w, seed, fixed_dofs, seabed_ endconn_stiffness, endconn_direction, endconn_mode, & waterline_z, dry_buoyancy, merit_line_search, pseudo_transient, & energy_minimization, stable, water_weight, current, residual_out, & - tangent_out, friction, residual_unmet, torsion) + tangent_out, friction, residual_unmet, torsion, energy_out, & + end_share_hold) !! Solve the finite-EI static equilibrium of a Hermite bending-cable line. !! !! l0(ne), EA(ne), EI(ne), w(ne) : per-element rest length, axial/bending stiffness, @@ -396,6 +397,15 @@ SUBROUTINE CD_HermiteCable_Static_Solve(l0, EA, EI, w, seed, fixed_dofs, seabed_ !! iters_out and res_out include the twist stages. Not !! combined with pseudo_transient, !! equilibrate_linear_system or tangent_out. + !! energy_out (optional, out) : the total potential energy of energy_minimization at + !! the returned state (with residual_out, a check that + !! the residual is its gradient). + !! end_share_hold (optional, 2) : shares in [0, 1] of the end elements lying on the + !! floor (node 1 end, node nn end) at which the potential + !! takes the floor-carried end moments of held ends + !! resting on the seabed; the residual keeps the shares of + !! each iterate (CD_Seabed_End_Element_Share). Omitted, an + !! energy line search holds the shares of its start. REAL(wp), INTENT(IN) :: l0(:), EA(:), EI(:), w(:), seed(:) INTEGER, INTENT(IN) :: fixed_dofs(:) REAL(wp), INTENT(IN) :: seabed_z, kn, tol, damping @@ -430,6 +440,8 @@ SUBROUTINE CD_HermiteCable_Static_Solve(l0, EA, EI, w, seed, fixed_dofs, seabed_ ! NOCONVERGE, "Newton did not converge"): the state is a finite best iterate a caller ! may continue from. LOGICAL, INTENT(OUT), OPTIONAL :: residual_unmet + REAL(wp), INTENT(OUT), OPTIONAL :: energy_out + REAL(wp), INTENT(IN), OPTIONAL :: end_share_hold(2) TYPE(CD_HermiteTorsionType), INTENT(INOUT), OPTIONAL :: torsion INTEGER :: ne, nn, ndof, c, it, es, i, b, nci, n_buoy, omp_threads, axial_order, bending_order @@ -476,6 +488,10 @@ SUBROUTINE CD_HermiteCable_Static_Solve(l0, EA, EI, w, seed, fixed_dofs, seabed_ REAL(wp), ALLOCATABLE :: tors_grs(:), tors_gt(:) REAL(wp), ALLOCATABLE :: tors_rhs2(:, :) REAL(wp) :: contact_cs(2), end_support(3, 2), end_floor(3), end_g(2), end_sfac + ! Floor-carried end moments in the potential: the end element shares of the last + ! evaluation, and the shares held (end_share_held) by an energy line search or the caller. + REAL(wp) :: end_share_last(2), end_share_pi(2) + LOGICAL :: end_share_held, end_share_caller INTEGER :: end_es CHARACTER(200) :: end_em @@ -792,6 +808,17 @@ SUBROUTINE CD_HermiteCable_Static_Solve(l0, EA, EI, w, seed, fixed_dofs, seabed_ ! keep their seed, so this factor is fixed for the solve; the share of the element lying ! on the floor (end_element_share) follows the iterate. end_support = CD_ZERO + end_share_last = CD_ZERO + end_share_pi = CD_ZERO + end_share_caller = PRESENT(end_share_hold) + IF (end_share_caller) THEN + IF (.NOT. CD_All_Finite(end_share_hold) .OR. ANY(end_share_hold < CD_ZERO) .OR. & + ANY(end_share_hold > CD_ONE)) THEN + CALL fail('end_share_hold must lie in [0, 1]'); RETURN + END IF + end_share_pi = end_share_hold + END IF + end_share_held = end_share_caller IF (use_nodal_contact .OR. kn > CD_ZERO) THEN DO i = 1, 2 c = MERGE(1, nn, i == 1) @@ -944,6 +971,7 @@ SUBROUTINE CD_HermiteCable_Static_Solve(l0, EA, EI, w, seed, fixed_dofs, seabed_ res_out = rnorm IF (PRESENT(residual_out)) residual_out = R IF (PRESENT(tangent_out)) tangent_out = ab + IF (PRESENT(energy_out)) energy_out = pi_total IF (PRESENT(stable)) THEN ! A seabed friction capacity mu*N follows the normal force, so a sliding node's ! friction row depends on its vertical position with no reciprocal term: a @@ -1499,7 +1527,7 @@ RECURSIVE SUBROUTINE energy_update(es, em) REAL(wp), PARAMETER :: ARMIJO = 1.0e-4_wp INTEGER, PARAMETER :: MAX_SHIFTS = 60, MAX_HALVINGS = 30 REAL(wp), PARAMETER :: NEWTON_MERIT = 1.0e-4_wp, NEWTON_MU = 1.0e-6_wp - REAL(wp) :: pi0, pi_abs0, merit0, dmax, gd, alpha, trial_norm, sc + REAL(wp) :: pi0, pi_abs0, merit0, dmax, gd, alpha, trial_norm, sc, share0(2) INTEGER :: shift, bt, j, i, es_trial, info LOGICAL :: accepted CHARACTER(200) :: em_trial @@ -1516,6 +1544,10 @@ RECURSIVE SUBROUTINE energy_update(es, em) pi0 = pi_total pi_abs0 = pi_abs merit0 = rmerit + ! The floor-carried end moments enter the energy at the end element shares of q_energy, + ! held over the line search below: along it the residual's end-support load is then the + ! gradient of the energy the Armijo test uses (gd = R.dq), at the start and at every trial. + share0 = end_share_last ! Close to equilibrium (small residual, and the energy steps needing at most a ! negligible shift, i.e. a positive definite tangent), a plain Newton step on the ! full (possibly nonsymmetric) tangent with a residual-merit line search comes first. The energy is only a @@ -1562,6 +1594,10 @@ RECURSIVE SUBROUTINE energy_update(es, em) DO j = 1, ndof IF (solve_mask(j)) dmax = MAX(dmax, ABS(ab_energy(KL_H + KU_H + 1, j))) END DO + IF (.NOT. end_share_caller) THEN + end_share_pi = share0 + end_share_held = .TRUE. + END IF DO shift = 1, MAX_SHIFTS ! Symmetric part of K + mu*D in LAPACK lower band storage; fixed DOFs decoupled. sym = CD_ZERO @@ -1624,6 +1660,7 @@ RECURSIVE SUBROUTINE energy_update(es, em) END IF IF (accepted) THEN skip_tangent = .FALSE. + end_share_held = end_share_caller IF (tors_on) tors_theta_acc = tors_theta_eval IF (bt == 0) THEN lm_mu = 0.25_wp*lm_mu @@ -1638,6 +1675,7 @@ RECURSIVE SUBROUTINE energy_update(es, em) IF (lm_mu > 1.0e12_wp) EXIT END DO skip_tangent = .FALSE. + end_share_held = end_share_caller q = q_energy stalled = .TRUE. END SUBROUTINE energy_update @@ -1997,6 +2035,11 @@ SUBROUTINE torsion_descent(ok, why) RETURN END IF e0 = pi_total + ! the energies compared below take the end element shares of this state (energy_update) + IF (.NOT. end_share_caller) THEN + end_share_pi = end_share_last + end_share_held = .TRUE. + END IF tors_rhs = tors_v IF (use_rigid) CALL rigid_increment_to_global(tors_rhs) vscale = CD_ZERO @@ -2008,6 +2051,7 @@ SUBROUTINE torsion_descent(ok, why) END IF END DO IF (.NOT. (vscale > CD_ZERO)) THEN + end_share_held = end_share_caller why = 'the unstable mode vanishes on the free DOFs' RETURN END IF @@ -2033,6 +2077,7 @@ SUBROUTINE torsion_descent(ok, why) EXIT END IF END DO + end_share_held = end_share_caller IF (.NOT. moved) THEN q = tors_q tors_theta_acc = th0 @@ -2429,13 +2474,19 @@ SUBROUTINE add_end_support(iend, e, inode, sgn, sp_stat, sp_msg) !! the element's consistent weight moment w l0^2/12 along end_support(:, iend) times !! the share of the element lying on the floor (CD_Seabed_End_Element_Share of the !! inner node's elastic normal force, the same contact law as the assembly below). The - !! share couples the end tangent to the inner node's translations. The potential takes - !! the share at the iterate: exact where it is 0 or 1, first order in between. + !! share couples the end tangent to the inner node's translations. The load is not + !! conservative where the share is between 0 and 1 (its conjugate force on the inner + !! node, mom (dS/dgap) (d.m) n, would be a contact force the floor does not exert), so + !! the potential takes the share end_share_pi (the share at the iterate, or the share + !! held by an energy line search, see energy_update): the residual is then the gradient + !! of the potential along a search, as for the other non-potential loads (current drag, + !! friction). The share at the iterate is recorded in end_share_last. INTEGER, INTENT(IN) :: iend, e, inode REAL(wp), INTENT(IN) :: sgn INTEGER, INTENT(OUT) :: sp_stat CHARACTER(*), INTENT(OUT) :: sp_msg REAL(wp) :: z_fl, gxg_s, gyg_s, g_s(2), sf, n_in(3), pen_s, normal_s, normal_gap_s, elem, delem, mom + REAL(wp) :: elem_pi INTEGER :: base, bin, i, j CHARACTER(200) :: em_s sp_stat = CD_HCSTAT_OK @@ -2466,11 +2517,16 @@ SUBROUTINE add_end_support(iend, e, inode, sgn, sp_stat, sp_msg) normal_gap_s = CD_ZERO END IF CALL CD_Seabed_End_Element_Share(normal_s, normal_gap_s, 0.5_wp*w_cur(e)*l0(e), elem, delem) - IF (.NOT. (elem > CD_ZERO)) RETURN + end_share_last(iend) = elem + elem_pi = elem + IF (end_share_held) elem_pi = end_share_pi(iend) mom = sgn*w_cur(e)*l0(e)*l0(e)/12.0_wp + IF (elem_pi > CD_ZERO) THEN + pi_total = pi_total + mom*elem_pi*DOT_PRODUCT(end_support(:, iend), q(base + 1:base + 3)) + pi_abs = pi_abs + ABS(mom*elem_pi*DOT_PRODUCT(end_support(:, iend), q(base + 1:base + 3))) + END IF + IF (.NOT. (elem > CD_ZERO)) RETURN R(base + 1:base + 3) = R(base + 1:base + 3) + (mom*elem)*end_support(:, iend) - pi_total = pi_total + mom*elem*DOT_PRODUCT(end_support(:, iend), q(base + 1:base + 3)) - pi_abs = pi_abs + ABS(mom*elem*DOT_PRODUCT(end_support(:, iend), q(base + 1:base + 3))) ! d(gap)/d(r_inner) = -n_in (floor gradient held over the node) IF (delem /= CD_ZERO) THEN DO j = 1, 3 diff --git a/tests/test_hermite_cable_static.f90 b/tests/test_hermite_cable_static.f90 index 6a192cb3..c1b6d44e 100644 --- a/tests/test_hermite_cable_static.f90 +++ b/tests/test_hermite_cable_static.f90 @@ -20,7 +20,7 @@ PROGRAM test_hermite_cable_static CD_HermiteCable_Dyn_End, CD_HCDYN_OK, CD_HermiteCable_Dyn_End_Force, & CD_HermiteCable_Drag_Element, CD_HermiteCable_Dyn_Step USE CableDyn_SeabedContact, ONLY: CD_HermiteCable_Friction_Spring => CD_Seabed_Friction_Spring, & - CD_Seabed_End_Element_Share + CD_Seabed_End_Element_Share, CD_Seabed_Normal_Law USE CableDyn_Line, ONLY: CD_Nodal_Seabed_Stiffness, CD_LINE_OK USE CableDyn_Bathymetry, ONLY: CD_BathymetryType, CD_Init_Bathymetry USE, INTRINSIC :: IEEE_ARITHMETIC, ONLY: IEEE_IS_FINITE @@ -41,6 +41,7 @@ PROGRAM test_hermite_cable_static CALL check_seabed_mesh_jump() CALL check_scalar_contact_on_slope() CALL check_taut_line_anchored_on_floor() + CALL check_end_support_energy_gradient() CALL check_frictionless_slope_run() CALL check_long_sequence_hierarchy() CALL check_current_static() @@ -384,6 +385,102 @@ SUBROUTINE check_taut_line_anchored_on_floor() END DO END SUBROUTINE check_taut_line_anchored_on_floor + SUBROUTINE check_end_support_energy_gradient() + !! The energy line search (energy_minimization) tests the potential against R.dq, so the + !! residual must be the gradient of the potential it evaluates. With the end element's + !! inner node half way through its touchdown (share S = 1/2), the floor-carried end + !! moment depends on that node's height; the potential then takes the share held at the + !! search's start (end_share_hold), and central differences of it along several + !! directions reproduce R.d. With the share left to follow the trial states, the + !! difference along the inner node's height misses the end-support term by about + !! (w l0^2/12) (dS/dgap) m_z, here near 1 MN: no potential of R. + INTEGER, PARAMETER :: NE = 20, NN = NE + 1, NDIR = 4 + REAL(wp), PARAMETER :: H = 1.0e-5_wp + REAL(wp) :: l0(NE), EA(NE), EI(NE), w(NE), seed(6*NN), qa(6*NN), q(6*NN), c(NN), res, r0(6*NN) + REAL(wp) :: trib(NN), kn, floor_z, gap, normal, normal_gap, share, dshare, ep, em_, rd, fd, fd_free, d(6*NN) + INTEGER :: fixed(6 + 2*NN), nfix, i, es, it, k + CHARACTER(512) :: em + l0 = 100.2_wp/NE; EA = 5.0e8_wp; EI = 2.0e4_wp; w = 800.0_wp; kn = 2.0e5_wp + trib = 0.0_wp + DO i = 1, NE + trib(i) = trib(i) + 0.5_wp*l0(i); trib(i + 1) = trib(i + 1) + 0.5_wp*l0(i) + END DO + CALL CD_HermiteCable_Trivial_Seed([0.0_wp, 0.0_wp, -100.0_wp], [60.0_wp, 0.0_wp, -20.0_wp], l0, -100.0_wp, & + seed, es, em) + fixed(1:6) = [1, 2, 3, 6*NE + 1, 6*NE + 2, 6*NE + 3] + nfix = 6 + DO i = 1, NN + fixed(nfix + 1:nfix + 2) = [6*i - 4, 6*i - 1] + nfix = nfix + 2 + END DO + ! the taut line without a seabed, then a floor placed just above its node 2 (the anchor + ! is held below it): node 2 carries a quarter of its share, r = 1/2 of half the element + CALL CD_HermiteCable_Static_Solve(l0, EA, EI, w, seed, fixed(1:nfix), -1.0e4_wp, 0.0_wp, 4, 200, 1.0e-10_wp, & + 1.0_wp, qa, c, res, it, es, em) + CALL require(es == CD_HCSTAT_OK, 'energy-gradient line: '//TRIM(em)) + floor_z = qa(9) + 0.5_wp*(0.5_wp*w(1)*l0(1))/(kn*trib(2)) + gap = floor_z - qa(9) + CALL CD_Seabed_Normal_Law(gap, kn*trib(2), normal, normal_gap) + CALL CD_Seabed_End_Element_Share(normal, normal_gap, 0.5_wp*w(1)*l0(1), share, dshare) + CALL require(share > 0.4_wp .AND. share < 0.6_wp, 'energy-gradient: inner node inside the touchdown') + CALL end_support_evaluation(l0, EA, EI, w, fixed(1:nfix), floor_z, kn*trib, qa, ep, [share, 0.0_wp], r0) + DO k = 1, NDIR + d = 0.0_wp + SELECT CASE (k) + CASE (1) + d(9) = 1.0_wp ! the inner node's height + CASE (2) + d(4) = 0.6_wp; d(6) = -0.8_wp ! the anchor's end tangent + CASE (3) + d(7) = 0.3_wp; d(9) = -0.5_wp; d(4) = 0.2_wp; d(15) = 0.4_wp + CASE (4) + DO i = 2, NE + d(6*i - 5) = 0.1_wp*SIN(REAL(i, wp)); d(6*i - 3) = 0.1_wp*COS(REAL(i, wp)) + d(6*i - 2) = 0.01_wp*SIN(2.0_wp*i); d(6*i) = 0.01_wp*COS(2.0_wp*i) + END DO + d(4) = 0.01_wp; d(6) = 0.01_wp + END SELECT + rd = DOT_PRODUCT(r0, d) + CALL end_support_evaluation(l0, EA, EI, w, fixed(1:nfix), floor_z, kn*trib, qa + H*d, ep, [share, 0.0_wp]) + CALL end_support_evaluation(l0, EA, EI, w, fixed(1:nfix), floor_z, kn*trib, qa - H*d, em_, [share, 0.0_wp]) + fd = (ep - em_)/(2.0_wp*H) + CALL require(ABS(fd - rd) <= 1.0e-5_wp*MAX(ABS(rd), 1.0e3_wp), & + 'energy-gradient: the held-share potential differentiates to R') + IF (ABS(fd - rd) > 1.0e-5_wp*MAX(ABS(rd), 1.0e3_wp)) WRITE (*, '(A,I2,2ES16.8)') ' direction, FD, R.d', k, fd, rd + IF (k == 1) THEN + CALL end_support_evaluation(l0, EA, EI, w, fixed(1:nfix), floor_z, kn*trib, qa + H*d, ep) + CALL end_support_evaluation(l0, EA, EI, w, fixed(1:nfix), floor_z, kn*trib, qa - H*d, em_) + fd_free = (ep - em_)/(2.0_wp*H) + CALL require(ABS(fd_free - rd) > 1.0e5_wp, 'energy-gradient: a share following the state is no potential') + END IF + END DO + + END SUBROUTINE check_end_support_energy_gradient + + SUBROUTINE end_support_evaluation(l0, EA, EI, w, fixed, floor_z, contact_kn, qx, energy, hold, residual) + !! Potential (energy_minimization's) and residual of a Hermite line at qx: an evaluation + !! only (a tolerance no state misses), with the end element shares held at hold if given. + REAL(wp), INTENT(IN) :: l0(:), EA(:), EI(:), w(:), floor_z, contact_kn(:), qx(:) + INTEGER, INTENT(IN) :: fixed(:) + REAL(wp), INTENT(OUT) :: energy + REAL(wp), INTENT(IN), OPTIONAL :: hold(2) + REAL(wp), INTENT(OUT), OPTIONAL :: residual(:) + REAL(wp) :: qo(SIZE(qx)), co(SIZE(l0) + 1), ro(SIZE(qx)), rs + INTEGER :: ito, eso + CHARACTER(512) :: emo + IF (PRESENT(hold)) THEN + CALL CD_HermiteCable_Static_Solve(l0, EA, EI, w, qx, fixed, floor_z, 0.0_wp, 1, 1, HUGE(1.0_wp), & + 1.0_wp, qo, co, rs, ito, eso, emo, contact_kn=contact_kn, & + residual_out=ro, energy_out=energy, end_share_hold=hold) + ELSE + CALL CD_HermiteCable_Static_Solve(l0, EA, EI, w, qx, fixed, floor_z, 0.0_wp, 1, 1, HUGE(1.0_wp), & + 1.0_wp, qo, co, rs, ito, eso, emo, contact_kn=contact_kn, & + residual_out=ro, energy_out=energy) + END IF + CALL require(eso == CD_HCSTAT_OK, 'energy-gradient evaluation: '//TRIM(emo)) + IF (PRESENT(residual)) residual = ro + END SUBROUTINE end_support_evaluation + SUBROUTINE check_scalar_contact_on_slope() !! The scalar-kn contact path on a structured (sloped) bathymetry includes the slope !! terms of the penetration in its tangent: from a perturbed equilibrium it converges