diff --git a/CMakeLists.txt b/CMakeLists.txt index ad56bfd6..f48807e4 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -2747,7 +2747,8 @@ if(Python3_Interpreter_FOUND) LABELS "python;driver;integration;static" ENVIRONMENT "${_cabledyn_python_test_environment}") # A hang-off through a tapered bend stiffener follows the planar elastica (scipy solve_bvp) - # within 2 % of the root moment and 1 cm; skipped where scipy is not installed. + # within 2 % of the root moment and 1 cm, and node by node on a sweep of element sizes within + # 0.5 % of the local curvature on 0.1 m elements; skipped where scipy is not installed. add_test(NAME driver_bend_stiffener COMMAND ${Python3_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/tests/check_bend_stiffener.py $) diff --git a/VALIDATION.md b/VALIDATION.md index 05a2b0a4..bf92b468 100644 --- a/VALIDATION.md +++ b/VALIDATION.md @@ -78,7 +78,7 @@ article's methods, are compared in | **L3-6d** | Moving-touchdown dynamic contact | OrcaFlex 11.6d installed | curv 0.48/0.58%, tension 0.74/0.90/0.80%, TDP 0.08 m, migration 2–3 m/cycle | curv <3–5%, tension <2–3%, TDP excursion bounds <1.5 m | Pass | | **L3-6e** | Out-of-plane / 3D whirl response | OrcaFlex 11.6d | 3D curv 0.52%, interior Y env ≤1.0 mm, sag ≤22 mm, tension 0.14/0.17/0.12% | curv <3%, env <5 cm, tension <2–3% | Pass | | **L3-7** | 1-hour VolturnUS-S mooring dynamic | OrcaFlex 11.6d | `FairTen` mean 0.27%, std 0.26%, min/max 0.50/0.43%, Fourier 0.27/1.14% | ≤5% | Pass | -| **L3-8** | Bend stiffener at a clamped hang-off (5 m tapered polyurethane) | OrcaFlex 11.6d (stiffener attachment) / planar elastica | curvature 0.74% of root; cable moment 0.74%, section moment 0.18%, deflection angle 0.003° | <1.5% / <2%, 0.05° | Pass | +| **L3-8** | Bend stiffener at a clamped hang-off (5 m tapered polyurethane) | OrcaFlex 11.6d (stiffener attachment) / planar elastica | curvature 0.51% of root; cable moment 0.18%, section moment 0.18%, deflection angle 0.003°; local curvature 0.24% (0.1 m elements) | <1.5% / <2%, 0.05°, <0.5% | Pass | | **L3-H** | Holcombe static lazy-wave experiment | measured marker geometry | position RMSE 1.07–1.89% of suspended length; peak marker-curvature error 0.34–5.54% | end-restraint bracket | Pass | | **L3-B** | Bergdahl chain experiment, 30 orbit conditions | measured upper-end force | RMSE 1.58 N; MAPE 3.11%; Pearson 0.993; Lin concordance 0.989 | full published matrix | Pass | | **L-fig** | Along-arc curvature overlay (CableDyn / OrcaFlex / MoorDyn-F ±4×) | 3-code committed record | CableDyn peak 0.11% from OrcaFlex | <0.5% | Pass | @@ -275,13 +275,19 @@ initialisation. polyurethane stiffener (0.5 m cylinder of 0.60 m, cone to 0.22 m, bore 0.20 m, E 50 MPa; 16 times the cable's EI at the root), on 0.05 m elements. The static curvature over the stiffener and 3 m beyond follows OrcaFlex 11.6d with the stiffener given as a line attachment - within **0.74% of the root curvature** (root 0.4523 against 0.4522 1/m; + within **0.51% of the root curvature** (root 0.4523 against 0.4522 1/m; [`orcaflex_bend_stiffener.py`](https://github.com/SMI-Lab-Inha/CableDyn/blob/main/validation/scripts/orcaflex_bend_stiffener.py)). Against an independent collocation solution of the planar extensible elastica with - `EI(s)` and the sleeve's weight, the cable's own moment follows within **0.74%** of its root + `EI(s)` and the sleeve's weight, the cable's own moment follows within **0.18%** of its root value, cable and sleeve moments add up to the section moment within **0.18%**, the node positions within **0.6 mm**, and the end force's deflection from the clamp axis within - **0.003°** (32.37°). + **0.003°** (32.37°). Node by node, relative to the local value floored at 0.1% of the root + curvature, the curvature follows the elastica within **0.97 / 0.49 / 0.24 / 0.18%** on + 0.2 / 0.15 / 0.1 / 0.05 m elements (gates 1 / 1 / 0.5 / 0.5%), under either output recovery, + and under the stiffener the element peaks of `.elements.out`, read through `bend_check`, + within **the same figures** on the same gates; 0.12% of it at the root is + the order-`T/EA` difference between the elastica's bending law and the element energy's, + not mesh error. - **L-fig curvature overlay**: `l3_lazywave_dynamic` writes each site's along-arc curvature profile. [`validation/scripts/curvature_profile_overlay.py`](https://github.com/SMI-Lab-Inha/CableDyn/blob/main/validation/scripts/curvature_profile_overlay.py) diff --git a/doc/driver_format.md b/doc/driver_format.md index 8da2e336..62cf0508 100644 --- a/doc/driver_format.md +++ b/doc/driver_format.md @@ -1099,7 +1099,10 @@ Behaviour: - The element properties are piecewise constant, one value per deck element, so the deck mesh must resolve the taper: an initialisation note names a stiffener that spans fewer than 10 elements and the element length that resolves it. Split the section at the stiffener tip and - mesh the part under it finely (about 0.1–0.2 m elements for a typical 3–8 m stiffener). + mesh the part under it finely (about 0.1–0.2 m elements for a typical 3–8 m stiffener). The + node outputs and the element peaks of `.elements.out` do not take these element values: they + read `EI(s)` at their own arc, and at a real step of the section (the tip, rows that do not + match, two line types) the softer side's. - The stiffener root takes the moment only where the end is held in rotation: declare the end `Rigid`, or a rotational spring, in [END CONNECTIONS](#end-connections-optional-finite-ei-lines). A stiffener at a pinned end prints a note. diff --git a/doc/modeling.rst b/doc/modeling.rst index 0bf65947..32cbf87e 100644 --- a/doc/modeling.rst +++ b/doc/modeling.rst @@ -91,7 +91,10 @@ sleeve's bending stiffness, mass, buoyancy and drag to the elements it covers the hang-off direction. A pinned end carries no moment, so the stiffener then takes none; - **the mesh under the stiffener.** One stiffness per element: split the section at the stiffener tip and mesh the part under it with elements of about 0.1–0.2 m, at least ten over - the stiffener (the driver notes fewer); + the stiffener (the driver notes fewer). The node outputs and the element peaks of + ``.elements.out`` take the stiffness at their own arc, so on that mesh the curvature follows a + much finer one within about 0.2 % (``lazy_wave_bend_stiffener.dat``), and shortening the + elements further gains little; - **the material.** The sleeve is linear elastic. Polyurethane stiffness depends on temperature and strain rate; use the modulus for the design temperature and check the result at the ends of its range. diff --git a/doc/options.rst b/doc/options.rst index cc59b65b..214185d1 100644 --- a/doc/options.rst +++ b/doc/options.rst @@ -492,7 +492,8 @@ Finite-EI cable controls :math:`\mathbf F\cdot\mathbf t`, the moment the neighbouring elements carry, and curvature = moment / ``EI`` (see :ref:`theory-output-recovery`). ``element`` reports the length-weighted element-mean axial force :math:`EA(\lvert\mathbf r'\rvert - 1)`, the - larger one-sided exact curvature, and the axial resultant at the element midpoint as the + larger one-sided exact curvature (on an element with a bend stiffener sleeve, the recovered + moment over ``EI(s)``), and the axial resultant at the element midpoint as the segment tension, the definitions of the releases before 0.2.0. End forces, positions, ``TDP`` channels and the material-strain checks (``tensile_safety``, compression notes) are the same under both diff --git a/doc/outputs.rst b/doc/outputs.rst index 3229e994..7df0271d 100644 --- a/doc/outputs.rst +++ b/doc/outputs.rst @@ -289,7 +289,9 @@ B)``, header row, units row, data (12 columns): - unstretched arc length of the curvature maximum * - ``PeakCurvature`` - ``(1/m)`` - - maximum curvature over the element + - maximum curvature over the element; under a bend stiffener the curvature of the section, + the moment over the stiffness ``EI(s)`` along the element, not of the interpolation + (:ref:`theory-bend-stiffeners`) * - ``BendMomentAtPeak`` - ``(N.m)`` - ``EI × PeakCurvature``, with the line type's ``EI`` (the cable's share under a bend @@ -684,10 +686,12 @@ Line-node channels - curvature at node ``J``. ``EI = 0`` lines: discrete curvature of the circle through the node and its two neighbours (end nodes take the adjacent interior value). Cubic-Hermite lines: ``BendMomN`` / ``EI``, the larger of the two sides at a - section junction, and the exact geometric curvature where ``EI`` is below - ``max(|w| L0^2)/12`` times 1 m (:ref:`theory-output-recovery`) (``OutputRecovery + section junction (under a bend stiffener the section moment over the stiffness ``EI(s)`` + at the node, :ref:`theory-bend-stiffeners`), and the exact geometric curvature where + ``EI`` is below ``max(|w| L0^2)/12`` times 1 m (:ref:`theory-output-recovery`) (``OutputRecovery element``: exact curvature of the continuous - centreline, the larger of the two one-sided element values at an interior node). The + centreline, the larger of the two one-sided element values at an interior node; the + recovered moment over ``EI(s)`` on an element with a bend stiffener sleeve). The library routines ``CD_HermiteCable_Dyn_Curvature`` and ``CD_HFMF_Curvature`` return the same value; ``CD_HermiteCable_Dyn_Curvature_Exact`` and ``CD_HFMF_Curvature_Exact`` the exact geometric traces @@ -709,8 +713,9 @@ Line-node channels (one-sided at a line end, where it is the end connection moment); ``OutputRecovery element``: ``EI`` times the larger one-sided exact curvature. 0 on ``EI = 0`` lines. Under a bend stiffener (``STIFFENERS``) it is the cable's own share, - the line type's ``EI`` times the curvature; the stiffener's share is ``StfMomN`` - and the two add up to the section moment + the line type's ``EI`` times the curvature, which is the section moment over the + stiffness ``EI(s)`` at the node; the stiffener's share is ``StfMomN`` and the two + add up to the section moment - N·m * - ``StfMomN`` - the share of the section moment a bend stiffener carries at node ``J``, the section diff --git a/doc/theory.rst b/doc/theory.rst index b1be3d2e..907162a5 100644 --- a/doc/theory.rst +++ b/doc/theory.rst @@ -178,11 +178,38 @@ part of the element a segment covers. With these one-per-element values the tape by the mesh, as in a segmented line model; the driver notes a stiffener that spans fewer than ten elements. -The recovered section moment :math:`M` (:ref:`theory-output-recovery`) is shared in proportion -to the stiffnesses, since cable and sleeve take the same curvature :math:`\kappa = M/EI_e`: the -cable carries :math:`EI_c\,\kappa`, reported as ``BendMom``, and the sleeve -:math:`(EI_e - EI_c)\,\kappa`, reported as ``StfMom``. At a node between a covered and a bare -element the side of the larger curvature, the bare one, gives the values. The deflection angle +The node outputs do not use :math:`EI_e`. It stands for the whole element, so under a taper it +steps at every node although the section does not, and the softer side would overstate the +curvature by about :math:`h\lvert EI'\rvert/(2 EI)`, first order in the element length +:math:`h`. A node takes :math:`EI(s)` at its own arc instead, from the stiffener rows, one limit +from either side. The section moment :math:`M` (:ref:`theory-output-recovery`) is continuous and +second-order accurate, so the curvature :math:`\kappa = M/EI(s)` is too. Cable and sleeve take +that curvature and share the moment in proportion to the stiffnesses: the cable carries +:math:`EI_c\,\kappa`, reported as ``BendMom``, and the sleeve +:math:`(EI(s) - EI_c)\,\kappa`, reported as ``StfMom``. + +The two limits differ only at a real step of the section: at the bare tip, between stiffener +rows whose end diameter, bore or modulus do not match, and between line types of different +:math:`EI`. There the side of the larger curvature gives the values, the bare one at the tip; +no threshold on the stiffness ratio is involved. A node past a tip inside an element is bare. + +An element's interpolation bends under :math:`EI_e`, so on an element with a sleeve its curvature +is the curvature of no section: :math:`EI_e` times it is the linear fit of the moment over the +element, so at an element's end it is off by the same first-order step against :math:`EI(s)`, +high where the curvature falls toward the tip and low where it rises, and :math:`EI_e` times it +is low by :math:`h^2 M''/12` against :math:`M`. Two outputs that read the interpolation elsewhere read +the section here. The peak of such an element in ``.elements.out`` is the largest +:math:`\lvert M(u)\rvert/EI(s(u))` along it, with :math:`M(u)` the quadratic through the +recovered moments of the end nodes that keeps the mean of the fit; a row end inside the element, +or the tip, is a step of :math:`EI(s)` that the search keeps. Below the stiffness that resolves +the recovered moment (:ref:`theory-output-recovery`) both the nodes and the peak fall back on +the interpolation's curvature times :math:`EI_e/EI(s)`. ``OutputRecovery element`` reports +the recovered moment over :math:`EI(s)` on such an element, the same value as the equilibrium +recovery, and the exact trace on every other element. The geometric traces themselves stay +available as ``CD_HermiteCable_Dyn_Curvature_Exact``, and the mesh diagnostics +(:math:`h\kappa`) read them. + +The deflection angle ``FairDefl``/``AnchDefl`` is :math:`\arccos(\hat{\mathbf F}\cdot\hat{\mathbf d})` between the end force :math:`\mathbf F` and the direction :math:`\mathbf d` the end connection holds (into the line), the angle through which the stiffener turns the cable. @@ -192,10 +219,17 @@ The planar check ``driver_bend_stiffener`` compares a hang-off clamped through a collocation solution of the extensible elastica :math:`\theta' = M/EI(s)`, :math:`M' = -(1 + \varepsilon)(\cos\theta\,n_z - \sin\theta\,n_x)`, :math:`\mathbf n' = (0, w(s))`: on 0.05 m elements the cable's moment over the stiffener and -3 m beyond follows the elastica within 0.8 % of its root value, cable and sleeve moments add up +3 m beyond follows the elastica within 0.2 % of its root value, cable and sleeve moments add up to the section moment within 0.2 % at the root, the deflection angle agrees within 0.003°, and -the node positions within 1 mm. On the same hang-off, the curvature along the stiffener follows -OrcaFlex 11.6d with its stiffener given as a line attachment within 0.8 % of the root curvature. +the node positions within 1 mm. Node by node, the curvature and the cable's moment follow the +elastica within 0.24 % of their local value on 0.1 m elements and 0.18 % on 0.05 m, 0.97 % on +0.2 m, under either output recovery, and the peaks of ``.elements.out`` under the stiffener +as closely. The local value is floored at 0.1 % of the root curvature, as the curvature changes sign +near the tip, and part of the difference is not mesh error: the elastica takes the moment +proportional to the rotation per unstretched length, the element energy the curvature of the +stretched line, a difference of order :math:`T/EA` that is 0.12 % at this root. On the same +hang-off, the curvature along the stiffener follows OrcaFlex 11.6d with its stiffener given as a +line attachment within 0.6 % of the root curvature. .. _theory-output-recovery: @@ -277,7 +311,8 @@ it, and its tangent rows are :math:`\mathbf{m}` there. An interior node reports \kappa_j = M_j / EI , with :math:`\mathbf{t}_j` the unit nodal tangent, :math:`\mathbf{m}_j` the mean of the two -one-sided values, and at a section junction the larger of :math:`M_j/EI` on the two sides. The +one-sided values, and at a section junction the larger of :math:`M_j/EI` on the two sides (under +a bend stiffener :math:`EI` is the stiffness at the node, :ref:`theory-bend-stiffeners`). The recovered moment carries an error that does not depend on :math:`EI`, of the order of the largest consistent-load moment :math:`w L_0^2/12` of an element (a section junction leaves a jump of that order between the two one-sided moments), so over a soft section dividing by :math:`EI` amplifies @@ -325,7 +360,8 @@ at most 0.45 N of 9.4 kN and moves the bend moment away from :math:`EI\kappa`. ``OPTIONS`` ``OutputRecovery element`` restores the element definitions: the length-weighted mean of the element-mean axial forces :math:`EA(\lvert\mathbf{r}'\rvert - 1)` at an interior -node, the larger one-sided exact curvature, and the midpoint axial resultant as the segment +node, the larger one-sided exact curvature (the section's on an element with a bend stiffener +sleeve, :ref:`theory-bend-stiffeners`), and the midpoint axial resultant as the segment tension. The material-strain checks (``tensile_safety``, the static compression notes) judge :math:`EA\varepsilon` under either setting. diff --git a/src/CableDyn_DeckDriver.f90 b/src/CableDyn_DeckDriver.f90 index c86ee353..0a39645f 100644 --- a/src/CableDyn_DeckDriver.f90 +++ b/src/CableDyn_DeckDriver.f90 @@ -76,7 +76,7 @@ MODULE CableDyn_DeckDriver USE CableDyn_HermiteCable, ONLY: CD_HermiteCable_Curvature, & CD_HermiteCable_Peak_Curvature, CD_HermiteCable_Axial_Resultant, & CD_HermiteCable_Axial_Resultant_Range, CD_HermiteCable_Element, CD_HCABLE_OK, & - CD_HermiteCable_Gauss_Rule + CD_HCABLE_BADINPUT, CD_HermiteCable_Gauss_Rule USE CableDyn_HermiteCableStatic, ONLY: CD_HermiteCable_Static_Solve_AutoMesh, CD_HermiteCable_Static_Solve, & CD_HermiteCable_Prolong_Arc, CD_HermiteCable_Kink_Advice, & CD_HermiteCable_Element_Ratio, CD_HC_OSCILLATION_REL_TOL, & @@ -98,6 +98,7 @@ MODULE CableDyn_DeckDriver CD_HermiteCable_Axial_Damping_Resultant, & CD_HermiteCable_Axial_Damping_Element, CD_HermiteCable_Dyn_End_Force, & CD_HermiteCable_Dyn_Node_Values, CD_HermiteCable_Dyn_Node_Recovery, & + CD_HermiteCable_Dyn_Side_EI, CD_HermiteCable_Dyn_Side_Curvature, & CD_HermiteCable_Dyn_Set_Output_Recovery, & CD_HermiteCable_Dyn_Set_ForceBlend, CD_HC_FORCE_BLEND_DEFAULT, & CD_HermiteCable_Dyn_Set_Friction_Anchors, & @@ -192,6 +193,8 @@ MODULE CableDyn_DeckDriver REAL(wp), PARAMETER :: STATIC_STRAIN_NOTE_DEFAULT = 0.1_wp ! dtM advisor (axial_period_note): the fewest steps of dtM per axial period of a line REAL(wp), PARAMETER :: AXIAL_STEPS_PER_PERIOD = 6.0_wp + ! A point within this share of an element length of a STIFFENERS row end counts as on it. + REAL(wp), PARAMETER :: STF_ARC_TOL = 1.0e-9_wp PUBLIC :: CD_Run_Deck_Driver PUBLIC :: CD_Deck_Equilibrium_Jacobian_Check @@ -200,6 +203,7 @@ MODULE CableDyn_DeckDriver PUBLIC :: CD_Init_Deck_HermiteCable PUBLIC :: CD_Deck_VIV_Phase_Seed PUBLIC :: CD_Stiffener_Overlay + PUBLIC :: CD_Stiffener_Node_EI PUBLIC :: CD_Init_Deck_Aggregate PUBLIC :: CD_Deck_Query_dtM PUBLIC :: CD_End_Deck_Aggregate @@ -3136,8 +3140,18 @@ RECURSIVE SUBROUTINE build_one_hermite_cable(ln, sections, types, points, opts, END IF IF (ALLOCATED(deck_map)) CALL MOVE_ALLOC(deck_map, cable%deck_node) cable%azimuth_signed = ln%azi_signed - ! a stiffened line: the outputs report the cable's own share of the bend moment - IF (ALLOCATED(ei_cable)) cable%line%EI_line = ei_cable + ! a stiffened line: the outputs report the cable's own share of the bend moment, and take + ! the stiffness at the node on the final mesh (public node j is internal node nn + 1 - j, and + ! its End B side the internal element before the node) + IF (ALLOCATED(ei_cable)) THEN + cable%line%EI_line = ei_cable + BLOCK + REAL(wp), ALLOCATABLE :: ei_public(:, :) + ALLOCATE (ei_public(2, SIZE(l0) + 1)) + CALL CD_Stiffener_Node_EI(ln%stf, l0(SIZE(l0):1:-1), ei_cable(SIZE(l0):1:-1), ei_public) + cable%line%EI_node = ei_public(2:1:-1, SIZE(l0) + 1:1:-1) + END BLOCK + END IF IF (ANY(ba > CD_ZERO)) THEN CALL CD_HFMF_Set_Axial_Damping(cable, ba, es, em) IF (es /= CD_HFMF_OK) THEN @@ -11002,6 +11016,184 @@ SUBROUTINE CD_Stiffener_Overlay(stf, l0, diam, ei, mpl) END DO END SUBROUTINE CD_Stiffener_Overlay + SUBROUTINE CD_Stiffener_Node_EI(stf, l0, ei_line, ei_node) + !! The local bending stiffness EI(s) of a line with bend stiffeners (ln%stf columns) at its + !! nodes, in public order (End A first): ei_node(1, j) is the limit of EI(s) at node j from + !! the End A side, on element j - 1, and ei_node(2, j) from the End B side, on element j. + !! Each is the element's line-type stiffness ei_line (no sleeve) plus, where a stiffener row + !! covers the arc next to the node on that side, E pi/64 (OD^4 - ID^4) of that row at the + !! node. The per-element stiffness of CD_Stiffener_Overlay steps at every node of a taper; + !! these limits differ only where the section does: at the bare tip, between stiffener rows + !! of different end diameter, bore or modulus, and between line types of different EI. A + !! node within a billionth of an element length of a row end counts as on it, which absorbs + !! the round-off of summing the element lengths and decides only which row a limit reads. + !! The limit on the missing side of a line end stays 0. + REAL(wp), INTENT(IN) :: stf(:, :), l0(:), ei_line(:) + REAL(wp), INTENT(OUT) :: ei_node(:, :) + REAL(wp) :: arc(SIZE(l0) + 1, 2) + INTEGER :: ne, j, e, side + + ne = SIZE(l0) + ! each node's arc from either end, summed from that end + arc(1, 1) = CD_ZERO + arc(ne + 1, 2) = CD_ZERO + DO j = 1, ne + arc(j + 1, 1) = arc(j, 1) + l0(j) + arc(ne + 1 - j, 2) = arc(ne + 2 - j, 2) + l0(ne + 1 - j) + END DO + ei_node = CD_ZERO + DO j = 1, ne + 1 + DO side = 1, 2 + e = j - 2 + side + IF (e < 1 .OR. e > ne) CYCLE + ei_node(side, j) = ei_line(e) + sleeve_ei_at(stf, arc(j, 1), arc(j, 2), side == 2, STF_ARC_TOL*l0(e)) + END DO + END DO + END SUBROUTINE CD_Stiffener_Node_EI + + PURE FUNCTION sleeve_ei_at(stf, arc_a, arc_b, toward_b, tol) RESULT(ei) + !! The sleeve's share E pi/64 (OD^4 - ID^4) of the bending stiffness at a point arc_a from + !! End A and arc_b from End B, 0 where no stiffener row covers it: the limit from the End B + !! side (toward_b) or the End A side. A point within tol of a row end counts as on it. + REAL(wp), INTENT(IN) :: stf(:, :), arc_a, arc_b, tol + LOGICAL, INTENT(IN) :: toward_b + REAL(wp) :: ei + REAL(wp), PARAMETER :: PI_64 = 0.0490873852123405193_wp ! pi/64 + REAL(wp) :: a, t, od + INTEGER :: k, iend + LOGICAL :: tipward, covers + + ei = CD_ZERO + DO k = 1, SIZE(stf, 2) + iend = NINT(stf(1, k)) + a = MERGE(arc_a, arc_b, iend == 1) + ! does this side of the point look toward the stiffener's tip, or toward its root? + tipward = (iend == 1) .EQV. toward_b + IF (tipward) THEN + covers = a >= stf(2, k) - tol .AND. a < stf(3, k) - tol + ELSE + covers = a > stf(2, k) + tol .AND. a <= stf(3, k) + tol + END IF + IF (.NOT. covers) CYCLE + t = MIN(CD_ONE, MAX(CD_ZERO, (a - stf(2, k))/(stf(3, k) - stf(2, k)))) + od = (CD_ONE - t)*stf(4, k) + t*stf(5, k) + ei = stf(7, k)*PI_64*(od**4 - stf(6, k)**4) + RETURN + END DO + END FUNCTION sleeve_ei_at + + SUBROUTINE stiffened_element_peak(stf, qr, l0, ei_element, ei_line, ei_resolve, arc_a, arc_b, m0, m1, peak, u_peak, & + ErrStat, ErrMsg) + !! Largest curvature of the section along one element under a bend stiffener, |M(u)|/EI(u). + !! The element's interpolation bends under its one stiffness ei_element, so it gives the + !! section neither its curvature nor, at its ends, its moment to second order: ei_element + !! times the interpolation's curvature is the linear fit of the moment over the element. Its + !! mean is the element's mean moment, and with the recovered moments m0 and m1 of the end nodes + !! (u = 0 at End B's side, as the internal element runs) it fixes the quadratic + !! M(u) = (1 - u) m0 + u m1 + 6 u (1 - u) (mean - (m0 + m1)/2). EI(u) is ei_line, the line + !! type's, plus the sleeve; arc_a and arc_b are the arcs of the element's End A side from End + !! A and of its End B side from End B. Where EI(u) is below ei_resolve the recovered moment + !! cannot give the curvature, as at a node (node_values): the section takes the + !! interpolation's curvature times ei_element/EI(u) there. The field is smooth between the row + !! ends inside the element: each such piece is sampled, reading EI(u) from inside the piece up + !! to its ends, and its best sample refined by golden section. + REAL(wp), INTENT(IN) :: stf(:, :), qr(12), l0, ei_element, ei_line, ei_resolve, arc_a, arc_b, m0(3), m1(3) + REAL(wp), INTENT(OUT) :: peak, u_peak + INTEGER, INTENT(OUT) :: ErrStat + CHARACTER(*), INTENT(OUT) :: ErrMsg + INTEGER, PARAMETER :: NSAMPLE = 128, NGOLDEN = 40 + REAL(wp), PARAMETER :: GOLDEN = 0.6180339887498949_wp + REAL(wp) :: knot(2*SIZE(stf, 2) + 2), u, ua, ub, x1, x2, g1, g2, f1, f2, f, best, u_best, kappa, kv(3), bubble(3) + INTEGER :: nk, k, c, i, p + + peak = CD_ZERO + u_peak = CD_ZERO + CALL CD_HermiteCable_Curvature(qr, l0, 0.5_wp, kappa, ErrStat, ErrMsg, kvec=kv) + IF (ErrStat /= CD_HCABLE_OK) RETURN + ! the moment conjugate to the tangent is EI kappa n/|r'|^2, as the recovered ones are; the + ! curvature above has checked that the tangent r' at the midpoint does not vanish + bubble = ei_element*kv/SUM((1.5_wp*(qr(7:9) - qr(1:3))/l0 - 0.25_wp*(qr(4:6) + qr(10:12)))**2) - 0.5_wp*(m0 + m1) + IF (.NOT. ALL(IEEE_IS_FINITE(bubble))) THEN + ErrStat = CD_HCABLE_BADINPUT; ErrMsg = 'stiffened_element_peak: the element moments are not finite'; RETURN + END IF + knot(1) = CD_ZERO + nk = 1 + DO k = 1, SIZE(stf, 2) + DO c = 2, 3 + u = MERGE(CD_ONE - (stf(c, k) - arc_a)/l0, (stf(c, k) - arc_b)/l0, NINT(stf(1, k)) == 1) + IF (.NOT. (u > STF_ARC_TOL .AND. u < CD_ONE - STF_ARC_TOL)) CYCLE + ! in ascending order + i = nk + DO WHILE (knot(i) > u) + knot(i + 1) = knot(i) + i = i - 1 + END DO + knot(i + 1) = u + nk = nk + 1 + END DO + END DO + nk = nk + 1 + knot(nk) = CD_ONE + DO p = 1, nk - 1 + ua = knot(p) + ub = knot(p + 1) + IF (ub - ua <= STF_ARC_TOL) CYCLE + best = -CD_ONE + u_best = ua + DO i = 0, NSAMPLE + u = ua + (ub - ua)*REAL(i, wp)/REAL(NSAMPLE, wp) + f = section_curvature(u, 2*i > NSAMPLE) + IF (ErrStat /= CD_HCABLE_OK) RETURN + IF (f > best) THEN + best = f + u_best = u + END IF + END DO + IF (best > peak) THEN + peak = best + u_peak = u_best + END IF + x1 = MAX(ua, u_best - (ub - ua)/REAL(NSAMPLE, wp)) + x2 = MIN(ub, u_best + (ub - ua)/REAL(NSAMPLE, wp)) + DO i = 1, NGOLDEN + g1 = x2 - GOLDEN*(x2 - x1) + g2 = x1 + GOLDEN*(x2 - x1) + f1 = section_curvature(g1, 2.0_wp*g1 > ua + ub) + f2 = section_curvature(g2, 2.0_wp*g2 > ua + ub) + IF (ErrStat /= CD_HCABLE_OK) RETURN + IF (f1 > peak) THEN + peak = f1 + u_peak = g1 + END IF + IF (f2 > peak) THEN + peak = f2 + u_peak = g2 + END IF + IF (f1 > f2) THEN + x2 = g2 + ELSE + x1 = g1 + END IF + END DO + END DO + + CONTAINS + + REAL(wp) FUNCTION section_curvature(uu, from_b) + REAL(wp), INTENT(IN) :: uu + LOGICAL, INTENT(IN) :: from_b ! the piece lies on the End B side of uu (u runs from End B) + REAL(wp) :: ei + ei = ei_line + sleeve_ei_at(stf, arc_a + (CD_ONE - uu)*l0, arc_b + uu*l0, from_b, STF_ARC_TOL*l0) + IF (.NOT. ei > CD_ZERO) ei = ei_element + IF (ei >= ei_resolve) THEN + section_curvature = NORM2((CD_ONE - uu)*m0 + uu*m1 + 6.0_wp*uu*(CD_ONE - uu)*bubble)/ei + ELSE + CALL CD_HermiteCable_Curvature(qr, l0, uu, section_curvature, ErrStat, ErrMsg) + section_curvature = section_curvature*(ei_element/ei) + END IF + END FUNCTION section_curvature + END SUBROUTINE stiffened_element_peak + SUBROUTINE remap_elem_by_reference_arc(a, l0_parent, l0_child) !! Map a piecewise-constant per-element field from a parent reference mesh to !! any nested child mesh. Child midpoints select the parent, so interfaces are @@ -31622,9 +31814,10 @@ SUBROUTINE write_hermite_static_element_profile(out_root, lines, cables, ErrStat CHARACTER(*), INTENT(OUT) :: ErrMsg INTEGER :: unit, ios, li, public_element, internal_element, ne, es - REAL(wp) :: qr(12), l0, arc_start, arc_end, curvature_peak, u_curvature_internal, & + REAL(wp) :: qr(12), l0, ei_element, arc_start, arc_end, curvature_peak, u_curvature_internal, & u_curvature_public, arc_peak, moment_peak, minimum_resultant, minimum_u_internal, & minimum_u_public, maximum_resultant, maximum_u_internal, maximum_u_public + REAL(wp), ALLOCATABLE :: moments(:, :) CHARACTER(1024) :: em CHARACTER(LEN(out_root) + 20) :: path CHARACTER(1) :: tab @@ -31650,12 +31843,32 @@ SUBROUTINE write_hermite_static_element_profile(out_root, lines, cables, ErrStat DO li = 1, SIZE(lines) ne = cables(li)%line%ne arc_start = CD_ZERO + IF (ALLOCATED(moments)) DEALLOCATE (moments) + IF (ALLOCATED(lines(li)%stf)) THEN + ALLOCATE (moments(3, ne + 1)) + CALL CD_HermiteCable_Dyn_Node_Recovery(cables(li)%line, es, em, moment_vector=moments) + IF (es /= CD_HCDYN_OK) THEN + CLOSE (unit, STATUS='DELETE') + CALL fail_solve(ErrStat, ErrMsg, 'continuous curvature extraction failed: '//TRIM(em)); RETURN + END IF + END IF DO public_element = 1, ne internal_element = ne - public_element + 1 l0 = cables(li)%line%l0(internal_element) qr(1:6) = cables(li)%line%q(6*(internal_element - 1) + 1:6*(internal_element - 1) + 6) qr(7:12) = cables(li)%line%q(6*internal_element + 1:6*internal_element + 6) - CALL CD_HermiteCable_Peak_Curvature(qr, l0, curvature_peak, u_curvature_internal, es, em) + ! an element under a bend stiffener: the section's curvature, not the element's + ei_element = cables(li)%line%EI(internal_element) + IF (ALLOCATED(lines(li)%stf) .AND. ei_element > CD_ZERO .AND. & + ABS(ei_element - cables(li)%line%EI_line(internal_element)) > CD_ZERO) THEN + CALL stiffened_element_peak(lines(li)%stf, qr, l0, ei_element, cables(li)%line%EI_line(internal_element), & + cables(li)%line%ei_resolve, arc_start, & + SUM(cables(li)%line%l0(1:internal_element - 1)), & + moments(:, internal_element), moments(:, internal_element + 1), & + curvature_peak, u_curvature_internal, es, em) + ELSE + CALL CD_HermiteCable_Peak_Curvature(qr, l0, curvature_peak, u_curvature_internal, es, em) + END IF IF (es /= CD_HCABLE_OK) THEN CLOSE (unit, STATUS='DELETE') CALL fail_solve(ErrStat, ErrMsg, 'continuous curvature extraction failed: '//TRIM(em)); RETURN @@ -36634,7 +36847,7 @@ SUBROUTINE range_sample_cable(cable, rl, ErrStat, ErrMsg) SUBROUTINE range_sample_cable_element(ErrStat, ErrMsg) !! OutputRecovery element: end-force tension at the ends and the length-weighted - !! element-mean axial force inside, the larger one-sided exact curvature and EI * curvature. + !! element-mean axial force inside, the larger one-sided element curvature and EI * curvature. INTEGER, INTENT(OUT) :: ErrStat CHARACTER(*), INTENT(OUT) :: ErrMsg ErrStat = CD_DECKDRV_OK @@ -37795,9 +38008,9 @@ SUBROUTINE cable_segment_tensions(cable, tension, ErrStat, ErrMsg) END SUBROUTINE cable_segment_tensions SUBROUTINE cable_nodal_curvature(cable, inode, curvature, ErrStat, ErrMsg) - !! Exact one-sided Hermite curvature traces at an internal line node. Curvature - !! need not be continuous across a material interface because the interpolation - !! is C1, so the public nodal value conservatively retains the larger trace. + !! One-sided element curvatures at an internal line node (cable_element_curvature). + !! Curvature need not be continuous across a material interface because the + !! interpolation is C1, so the public nodal value conservatively retains the larger one. TYPE(CD_HFMF_ModuleType), INTENT(IN) :: cable INTEGER, INTENT(IN) :: inode REAL(wp), INTENT(OUT) :: curvature @@ -37824,10 +38037,10 @@ SUBROUTINE cable_nodal_curvature(cable, inode, curvature, ErrStat, ErrMsg) END SUBROUTINE cable_nodal_curvature SUBROUTINE cable_nodal_bend_moment(cable, inode, bend_moment, ErrStat, ErrMsg, sleeve_moment) - !! Magnitudes of the two one-sided EI*kappa traces at a node. Taking their - !! maximum avoids inventing an averaged EI at a stepped section interface. bend_moment is the - !! cable's own share EI_line kappa; sleeve_moment (optional) the share of a bend stiffener, - !! (EI - EI_line) kappa. + !! Magnitudes of the two one-sided EI*kappa values at a node (cable_element_curvature). Taking + !! their maximum avoids inventing an averaged EI at a stepped section interface. bend_moment is + !! the cable's own share EI_line kappa; sleeve_moment (optional) the share of a bend stiffener, + !! (EI - EI_line) kappa, with the stiffness EI of the section at the node. TYPE(CD_HFMF_ModuleType), INTENT(IN) :: cable INTEGER, INTENT(IN) :: inode REAL(wp), INTENT(OUT) :: bend_moment @@ -37847,33 +38060,35 @@ SUBROUTINE cable_nodal_bend_moment(cable, inode, bend_moment, ErrStat, ErrMsg, s CALL cable_element_curvature(cable, inode - 1, CD_ONE, curvature, ErrStat, ErrMsg) IF (ErrStat /= CD_HCABLE_OK) RETURN bend_moment = MAX(bend_moment, cable%line%EI_line(inode - 1)*curvature) - IF (PRESENT(sleeve_moment)) sleeve_moment = MAX(sleeve_moment, & - (cable%line%EI(inode - 1) - cable%line%EI_line(inode - 1))*curvature) + IF (PRESENT(sleeve_moment)) & + sleeve_moment = MAX(sleeve_moment, (CD_HermiteCable_Dyn_Side_EI(cable%line, inode - 1, inode) - & + cable%line%EI_line(inode - 1))*curvature) END IF IF (inode <= cable%line%ne) THEN CALL cable_element_curvature(cable, inode, CD_ZERO, curvature, ErrStat, ErrMsg) IF (ErrStat /= CD_HCABLE_OK) RETURN bend_moment = MAX(bend_moment, cable%line%EI_line(inode)*curvature) - IF (PRESENT(sleeve_moment)) sleeve_moment = MAX(sleeve_moment, & - (cable%line%EI(inode) - cable%line%EI_line(inode))*curvature) + IF (PRESENT(sleeve_moment)) & + sleeve_moment = MAX(sleeve_moment, (CD_HermiteCable_Dyn_Side_EI(cable%line, inode, inode) - & + cable%line%EI_line(inode))*curvature) END IF END SUBROUTINE cable_nodal_bend_moment SUBROUTINE cable_element_curvature(cable, e, xi, curvature, ErrStat, ErrMsg) + !! The curvature of the section at an end of element e (xi 0 or 1, node e or e + 1) from the + !! element: its exact trace there, or under a bend stiffener the section's curvature + !! (CD_HermiteCable_Dyn_Side_Curvature). TYPE(CD_HFMF_ModuleType), INTENT(IN) :: cable INTEGER, INTENT(IN) :: e REAL(wp), INTENT(IN) :: xi REAL(wp), INTENT(OUT) :: curvature INTEGER, INTENT(OUT) :: ErrStat CHARACTER(*), INTENT(OUT) :: ErrMsg - REAL(wp) :: qr(12) IF (e < 1 .OR. e > cable%line%ne) THEN ErrStat = 1; ErrMsg = 'cable_element_curvature: element index out of range'; curvature = CD_ZERO; RETURN END IF - qr(1:6) = cable%line%q(6*(e - 1) + 1:6*(e - 1) + 6) - qr(7:12) = cable%line%q(6*e + 1:6*e + 6) - CALL CD_HermiteCable_Curvature(qr, cable%line%l0(e), xi, curvature, ErrStat, ErrMsg) + CALL CD_HermiteCable_Dyn_Side_Curvature(cable%line, e, e + NINT(xi), curvature, ErrStat, ErrMsg) END SUBROUTINE cable_element_curvature FUNCTION CD_Channel_Unit(ch) RESULT(unit) diff --git a/src/CableDyn_HermiteCableDynamic.f90 b/src/CableDyn_HermiteCableDynamic.f90 index 6b16ccbe..ca226fe0 100644 --- a/src/CableDyn_HermiteCableDynamic.f90 +++ b/src/CableDyn_HermiteCableDynamic.f90 @@ -141,6 +141,7 @@ MODULE CableDyn_HermiteCableDynamic PUBLIC :: CD_HermiteCable_Dyn_Section_Curvature PUBLIC :: CD_HermiteCable_Dyn_Reaction PUBLIC :: CD_HermiteCable_Dyn_Curvature_Exact + PUBLIC :: CD_HermiteCable_Dyn_Side_EI, CD_HermiteCable_Dyn_Side_Curvature PUBLIC :: CD_HermiteCable_Dyn_Set_Output_Recovery PUBLIC :: CD_HermiteCable_Dyn_Node_Recovery PUBLIC :: CD_HermiteCable_Dyn_Node_Values @@ -238,6 +239,12 @@ MODULE CableDyn_HermiteCableDynamic ! bend stiffener (STIFFENERS), and equal to EI on every element without one. The bend ! moment outputs report the cable's share EI_line kappa and the sleeve's the rest. REAL(wp), ALLOCATABLE :: EI_line(:) + ! On a line with STIFFENERS, the local bending stiffness EI(s) at each node, one value per + ! side: EI_node(1, j) the limit from element j - 1, EI_node(2, j) from element j, the same + ! number where EI(s) is continuous. A one-per-element EI steps at every node of a taper + ! without the section doing so, so the node outputs read these (node_values). Unallocated on + ! a line without a stiffener, whose node outputs read EI per element. + REAL(wp), ALLOCATABLE :: EI_node(:, :) ! Optional axial Kelvin-Voigt damping. BA is the axial constitutive dashpot ! coefficient [N s] after resolving the deck's direct-BA / negative-zeta convention. ! It is integrated over reference arc length with the same Hermite kinematics and @@ -5923,15 +5930,15 @@ END SUBROUTINE CD_HermiteCable_Dyn_Momentum SUBROUTINE CD_HermiteCable_Dyn_Curvature(model, curv_out, ErrStat, ErrMsg) !! Per-node curvature at the current state, the definition of the CurvN channels: the !! bend moment recovered from nodal equilibrium over EI (CD_HermiteCable_Dyn_Node_Recovery), - !! or, under CD_HermiteCable_Dyn_Set_Output_Recovery(.TRUE.), the exact one-sided traces of - !! CD_HermiteCable_Dyn_Curvature_Exact. + !! or, under CD_HermiteCable_Dyn_Set_Output_Recovery(.TRUE.), the larger of the one-sided + !! values of CD_HermiteCable_Dyn_Side_Curvature. TYPE(CD_HermiteCableDynType), INTENT(IN) :: model REAL(wp), INTENT(OUT) :: curv_out(:) INTEGER, INTENT(OUT) :: ErrStat CHARACTER(*), INTENT(OUT) :: ErrMsg ErrStat = CD_HCDYN_OK; ErrMsg = '' IF (model%output_element_recovery) THEN - CALL CD_HermiteCable_Dyn_Curvature_Exact(model, curv_out, ErrStat, ErrMsg) + CALL CD_HermiteCable_Dyn_Curvature_Exact(model, curv_out, ErrStat, ErrMsg, section=.TRUE.) RETURN END IF IF (.NOT. model%initialized) THEN @@ -5943,14 +5950,18 @@ SUBROUTINE CD_HermiteCable_Dyn_Curvature(model, curv_out, ErrStat, ErrMsg) CALL CD_HermiteCable_Dyn_Node_Recovery(model, ErrStat, ErrMsg, curvature=curv_out) END SUBROUTINE CD_HermiteCable_Dyn_Curvature - SUBROUTINE CD_HermiteCable_Dyn_Curvature_Exact(model, curv_out, ErrStat, ErrMsg) + SUBROUTINE CD_HermiteCable_Dyn_Curvature_Exact(model, curv_out, ErrStat, ErrMsg, section) !! Per-node geometric curvature of the cubic-Hermite centreline at the current state: the !! exact curvature of the element interpolation at the node, the larger of the two - !! one-sided traces at an interior node (the curvature is discontinuous there). + !! one-sided traces at an interior node (the curvature is discontinuous there). With section + !! .TRUE. the one-sided values are CD_HermiteCable_Dyn_Side_Curvature's, which differ from the + !! traces only under a bend stiffener. TYPE(CD_HermiteCableDynType), INTENT(IN) :: model REAL(wp), INTENT(OUT) :: curv_out(:) INTEGER, INTENT(OUT) :: ErrStat CHARACTER(*), INTENT(OUT) :: ErrMsg + LOGICAL, INTENT(IN), OPTIONAL :: section + LOGICAL :: to_section INTEGER :: a, es REAL(wp) :: qe(12), kL, kR CHARACTER(1024) :: em2 @@ -5961,22 +5972,32 @@ SUBROUTINE CD_HermiteCable_Dyn_Curvature_Exact(model, curv_out, ErrStat, ErrMsg) IF (SIZE(curv_out) /= model%nn) THEN ErrStat = CD_HCDYN_BADINPUT; ErrMsg = 'CD_HermiteCable_Dyn_Curvature_Exact: curv_out must be nn'; RETURN END IF + to_section = .FALSE. + IF (PRESENT(section)) to_section = section DO a = 1, model%nn curv_out(a) = CD_ZERO ! A degenerate nodal tangent makes the curvature undefined; propagate that failure rather than ! silently reporting zero curvature -- a fatigue assessment reads this channel, so a hidden ! zero at a degenerate state would understate the peak sag-bend curvature. IF (a <= model%ne) THEN - CALL gather_elem(model, a, qe) - CALL CD_HermiteCable_Curvature(qe, model%l0(a), CD_ZERO, kR, es, em2) + IF (to_section) THEN + CALL CD_HermiteCable_Dyn_Side_Curvature(model, a, a, kR, es, em2) + ELSE + CALL gather_elem(model, a, qe) + CALL CD_HermiteCable_Curvature(qe, model%l0(a), CD_ZERO, kR, es, em2) + END IF IF (es /= CD_HCABLE_OK) THEN ErrStat = CD_HCDYN_NOCONVERGE; ErrMsg = 'CD_HermiteCable_Dyn_Curvature_Exact: '//TRIM(em2); RETURN END IF curv_out(a) = kR END IF IF (a >= 2) THEN - CALL gather_elem(model, a - 1, qe) - CALL CD_HermiteCable_Curvature(qe, model%l0(a - 1), CD_ONE, kL, es, em2) + IF (to_section) THEN + CALL CD_HermiteCable_Dyn_Side_Curvature(model, a - 1, a, kL, es, em2) + ELSE + CALL gather_elem(model, a - 1, qe) + CALL CD_HermiteCable_Curvature(qe, model%l0(a - 1), CD_ONE, kL, es, em2) + END IF IF (es /= CD_HCABLE_OK) THEN ErrStat = CD_HCDYN_NOCONVERGE; ErrMsg = 'CD_HermiteCable_Dyn_Curvature_Exact: '//TRIM(em2); RETURN END IF @@ -5985,13 +6006,86 @@ SUBROUTINE CD_HermiteCable_Dyn_Curvature_Exact(model, curv_out, ErrStat, ErrMsg) END DO END SUBROUTINE CD_HermiteCable_Dyn_Curvature_Exact + PURE FUNCTION CD_HermiteCable_Dyn_Side_EI(model, e, node) RESULT(ei) + !! The bending stiffness of the section at node (e or e + 1), on the side of its element e: + !! on a stiffened line the limit of EI(s) there (EI_node), else the element's EI. An element + !! without bending stiffness keeps its zero. + TYPE(CD_HermiteCableDynType), INTENT(IN) :: model + INTEGER, INTENT(IN) :: e, node + REAL(wp) :: ei + ei = model%EI(e) + IF (.NOT. ALLOCATED(model%EI_node) .OR. .NOT. ei > CD_ZERO) RETURN + IF (model%EI_node(MERGE(2, 1, node == e), node) > CD_ZERO) ei = model%EI_node(MERGE(2, 1, node == e), node) + END FUNCTION CD_HermiteCable_Dyn_Side_EI + + PURE FUNCTION trace_scale(model, e, node) RESULT(scale) + !! What turns the curvature of element e's interpolation at node (e or e + 1) into the + !! curvature of the section there: the element bends under one stiffness, so its curvature is + !! the moment over that EI, and the section takes the same moment over its own stiffness. + !! Exactly 1 wherever the two agree, as on every element without a bend stiffener. + TYPE(CD_HermiteCableDynType), INTENT(IN) :: model + INTEGER, INTENT(IN) :: e, node + REAL(wp) :: scale + scale = CD_ONE + IF (ALLOCATED(model%EI_node) .AND. model%EI(e) > CD_ZERO) & + scale = model%EI(e)/CD_HermiteCable_Dyn_Side_EI(model, e, node) + END FUNCTION trace_scale + + SUBROUTINE CD_HermiteCable_Dyn_Side_Curvature(model, e, node, curvature, ErrStat, ErrMsg, kvec) + !! The one-sided curvature of element output recovery at node (e or e + 1), on the side of + !! element e: the exact trace of the element's interpolation. Under a bend stiffener that + !! trace is the moment over the element's one stiffness, which is no section's: the element + !! then reports what the section has there, the recovered moment over EI(s), as the + !! equilibrium recovery does, and its scaled trace on a section too soft to recover the + !! moment. kvec, when asked for, is the curvature vector kappa n. Read-only. + TYPE(CD_HermiteCableDynType), INTENT(IN) :: model + INTEGER, INTENT(IN) :: e, node + REAL(wp), INTENT(OUT) :: curvature + INTEGER, INTENT(OUT) :: ErrStat + CHARACTER(*), INTENT(OUT) :: ErrMsg + REAL(wp), INTENT(OUT), OPTIONAL :: kvec(3) + REAL(wp) :: qe(12), g(12), fm(3), mm(3), fp(3), mp(3), mv(3), kv(3), ei, ten, kap, bend + LOGICAL :: sleeved + + ErrStat = CD_HCDYN_OK; ErrMsg = '' + sleeved = .FALSE. + IF (ALLOCATED(model%EI_node)) sleeved = model%EI(e) > CD_ZERO .AND. ABS(model%EI_line(e) - model%EI(e)) > CD_ZERO + ei = CD_HermiteCable_Dyn_Side_EI(model, e, node) + IF (.NOT. sleeved .OR. ei < model%ei_resolve) THEN + CALL gather_elem(model, e, qe) + CALL CD_HermiteCable_Curvature(qe, model%l0(e), REAL(node - e, wp), curvature, ErrStat, ErrMsg, kvec=kv) + IF (ErrStat /= CD_HCABLE_OK) RETURN + IF (sleeved) THEN + curvature = curvature*trace_scale(model, e, node) + kv = kv*trace_scale(model, e, node) + END IF + IF (PRESENT(kvec)) kvec = kv + RETURN + END IF + fm = CD_ZERO; mm = CD_ZERO; fp = CD_ZERO; mp = CD_ZERO + IF (node > 1) THEN + CALL element_end_residual(model, node - 1, g, ErrStat, ErrMsg) + IF (ErrStat /= CD_HCDYN_OK) RETURN + fm = g(7:9); mm = g(10:12) + END IF + IF (node < model%nn) THEN + CALL element_end_residual(model, node, g, ErrStat, ErrMsg) + IF (ErrStat /= CD_HCDYN_OK) RETURN + fp = -g(1:3); mp = -g(4:6) + END IF + CALL node_values(model, node, fm, mm, fp, mp, ten, kap, bend, ErrStat, ErrMsg, moment_vector=mv) + IF (ErrStat /= CD_HCDYN_OK) RETURN + curvature = NORM2(mv)/ei + IF (PRESENT(kvec)) kvec = mv/ei + END SUBROUTINE CD_HermiteCable_Dyn_Side_Curvature + SUBROUTINE CD_HermiteCable_Dyn_Section_Curvature(model, ref_a, kx, ky, ErrStat, ErrMsg, frame) !! The two components of the nodal curvature vector on the cross-section axes (the channels !! CurvXN, CurvYN), in internal node order (node nn is End A). The curvature !! vector kappa n points to the centre of curvature and its length is the curvature of !! CD_HermiteCable_Dyn_Curvature: the recovered section moment over EI on the side that - !! gives it (CD_HermiteCable_Dyn_Node_Recovery), or the larger exact one-sided trace under - !! element output recovery. + !! gives it (CD_HermiteCable_Dyn_Node_Recovery), or the larger one-sided element curvature + !! under element output recovery (CD_HermiteCable_Dyn_Side_Curvature). !! !! The section axes: d1 at End A is the reference normal -- the End A torsion normal on a !! line restrained in torsion, else ref_a (solve frame) -- made normal to the End A tangent. @@ -6029,13 +6123,12 @@ SUBROUTINE CD_HermiteCable_Dyn_Section_Curvature(model, ref_a, kx, ky, ErrStat, frame = CD_ZERO END IF IF (model%output_element_recovery) THEN - ! the larger exact one-sided trace and its vector (CD_HermiteCable_Dyn_Curvature_Exact) + ! the larger one-sided element curvature and its vector, in section form DO a = 1, model%nn kvec(:, a) = CD_ZERO kl = -CD_ONE IF (a <= model%ne) THEN - CALL gather_elem(model, a, qe) - CALL CD_HermiteCable_Curvature(qe, model%l0(a), CD_ZERO, kr, es, em2, kvec=kv) + CALL CD_HermiteCable_Dyn_Side_Curvature(model, a, a, kr, es, em2, kvec=kv) IF (es /= CD_HCABLE_OK) THEN ErrStat = CD_HCDYN_NOCONVERGE; ErrMsg = 'CD_HermiteCable_Dyn_Section_Curvature: '//TRIM(em2); RETURN END IF @@ -6043,8 +6136,7 @@ SUBROUTINE CD_HermiteCable_Dyn_Section_Curvature(model, ref_a, kx, ky, ErrStat, kl = kr END IF IF (a >= 2) THEN - CALL gather_elem(model, a - 1, qe) - CALL CD_HermiteCable_Curvature(qe, model%l0(a - 1), CD_ONE, kr, es, em2, kvec=kv) + CALL CD_HermiteCable_Dyn_Side_Curvature(model, a - 1, a, kr, es, em2, kvec=kv) IF (es /= CD_HCABLE_OK) THEN ErrStat = CD_HCDYN_NOCONVERGE; ErrMsg = 'CD_HermiteCable_Dyn_Section_Curvature: '//TRIM(em2); RETURN END IF @@ -6570,7 +6662,7 @@ END SUBROUTINE cached_end_residual END SUBROUTINE CD_HermiteCable_Dyn_Node_Values SUBROUTINE CD_HermiteCable_Dyn_Node_Recovery(model, ErrStat, ErrMsg, tension, curvature, bend_moment, & - segment_tension, curvature_vector) + segment_tension, curvature_vector, moment_vector) !! Effective tension, curvature and bend moment at every node (internal order) recovered !! from nodal equilibrium, in one pass over the elements. !! @@ -6588,7 +6680,8 @@ SUBROUTINE CD_HermiteCable_Dyn_Node_Recovery(model, ErrStat, ErrMsg, tension, cu !! !! tension(j) = t_j . F_j (t_j the unit nodal tangent; a line end reports the end force !! magnitude of CD_HermiteCable_Dyn_End_Force), the section moment M_j = |m_j - (m_j . t_j) t_j|, - !! curvature(j) = M_j/EI, the larger of the two sides at a section junction, and + !! curvature(j) = M_j/EI, the larger of the two sides at a section junction (under a bend + !! stiffener EI is the stiffness at the node, not the element's; see node_values), and !! bend_moment(j) the cable's own share EI_line curvature (M_j itself where no bend stiffener !! sleeves the element; see node_values) (the !! exact geometric trace on an element without bending stiffness, or with EI below ei_resolve, @@ -6597,8 +6690,10 @@ SUBROUTINE CD_HermiteCable_Dyn_Node_Recovery(model, ErrStat, ErrMsg, tension, cu !! mean of the axial components of element e's own two end forces. curvature_vector(:, j) !! is the curvature vector kappa n of node j in the solve frame, toward the centre of !! curvature, of length curvature(j): the section moment vector over EI on the side that - !! gives curvature(j), or the exact trace's vector. Every output is optional (node arrays nn, - !! curvature_vector (3, nn), segment_tension ne); the routine allocates nothing. + !! gives curvature(j), or the exact trace's vector. moment_vector(:, j) is the part of the + !! section moment normal to the tangent, of length M_j. Every output is optional (node arrays + !! nn, curvature_vector and moment_vector (3, nn), segment_tension ne); the routine allocates + !! nothing. !! !! The condensed torque of a line restrained in torsion is not part of g_e: it adds a shear !! normal to the tangent and does no work on bending rotations, so tension and bend moment @@ -6609,7 +6704,7 @@ SUBROUTINE CD_HermiteCable_Dyn_Node_Recovery(model, ErrStat, ErrMsg, tension, cu INTEGER, INTENT(OUT) :: ErrStat CHARACTER(*), INTENT(OUT) :: ErrMsg REAL(wp), INTENT(OUT), OPTIONAL :: tension(:), curvature(:), bend_moment(:), segment_tension(:) - REAL(wp), INTENT(OUT), OPTIONAL :: curvature_vector(:, :) + REAL(wp), INTENT(OUT), OPTIONAL :: curvature_vector(:, :), moment_vector(:, :) REAL(wp) :: g(12), fm(3), mm(3), fp(3), mp(3), ta(3), tb(3) INTEGER :: e, nn LOGICAL :: want_nodes @@ -6630,7 +6725,14 @@ SUBROUTINE CD_HermiteCable_Dyn_Node_Recovery(model, ErrStat, ErrMsg, tension, cu ErrMsg = 'CD_HermiteCable_Dyn_Node_Recovery: curvature_vector must be (3, nn)'; RETURN END IF END IF - want_nodes = PRESENT(tension) .OR. PRESENT(curvature) .OR. PRESENT(bend_moment) .OR. PRESENT(curvature_vector) + IF (PRESENT(moment_vector)) THEN + IF (SIZE(moment_vector, 1) /= 3 .OR. SIZE(moment_vector, 2) /= nn) THEN + ErrStat = CD_HCDYN_BADINPUT + ErrMsg = 'CD_HermiteCable_Dyn_Node_Recovery: moment_vector must be (3, nn)'; RETURN + END IF + END IF + want_nodes = PRESENT(tension) .OR. PRESENT(curvature) .OR. PRESENT(bend_moment) .OR. & + PRESENT(curvature_vector) .OR. PRESENT(moment_vector) fm = CD_ZERO; mm = CD_ZERO DO e = 1, model%ne CALL element_end_residual(model, e, g, ErrStat, ErrMsg) @@ -6654,9 +6756,11 @@ SUBROUTINE CD_HermiteCable_Dyn_Node_Recovery(model, ErrStat, ErrMsg, tension, cu SUBROUTINE store_node(node) INTEGER, INTENT(IN) :: node - REAL(wp) :: t_n, k_n, b_n, kv(3) - CALL node_values(model, node, fm, mm, fp, mp, t_n, k_n, b_n, ErrStat, ErrMsg, curvature_vector=kv) + REAL(wp) :: t_n, k_n, b_n, kv(3), mv(3) + CALL node_values(model, node, fm, mm, fp, mp, t_n, k_n, b_n, ErrStat, ErrMsg, curvature_vector=kv, & + moment_vector=mv) IF (PRESENT(curvature_vector)) curvature_vector(:, node) = kv + IF (PRESENT(moment_vector)) moment_vector(:, node) = mv IF (PRESENT(tension)) tension(node) = t_n IF (PRESENT(curvature)) curvature(node) = k_n IF (PRESENT(bend_moment)) bend_moment(node) = b_n @@ -7000,7 +7104,7 @@ SUBROUTINE CD_HermiteCable_Dyn_Twist_Unpack(model, buf, ErrStat, ErrMsg, check_o END SUBROUTINE CD_HermiteCable_Dyn_Twist_Unpack SUBROUTINE node_values(model, node, fm, mm, fp, mp, tension, curvature, bend_moment, ErrStat, ErrMsg, & - sleeve_moment, curvature_vector) + sleeve_moment, curvature_vector, moment_vector) !! Node values from the one-sided section force and moment before (fm, mm) and after !! (fp, mp) the node; a line end uses its only side (see CD_HermiteCable_Dyn_Node_Recovery). !! bend_moment is the cable's own share of the section moment, EI_line kappa on the side of @@ -7008,14 +7112,23 @@ SUBROUTINE node_values(model, node, fm, mm, fp, mp, tension, curvature, bend_mom !! sleeve_moment the rest, the share a stiffener sleeve carries. curvature_vector is the !! curvature vector kappa n (solve frame, toward the centre of curvature) of the side that !! gives curvature: the normal part of the section moment over EI, or the exact trace's. + !! + !! The EI of a side is the element's, or on a stiffened line the limit of EI(s) at the node + !! from that side (EI_node): the element's compliance average stands for its whole length + !! and, under a taper, steps at every node although the section does not, so the softer side + !! would overstate the curvature by about h |EI'|/(2 EI). The two limits differ only at a + !! real step of the section (the bare tip, a junction of two line types, a step between + !! stiffener rows), where the larger-side rule still applies. The exact trace of a side too + !! soft to recover takes the same stiffness (trace_scale). moment_vector is the normal part + !! of the section moment. TYPE(CD_HermiteCableDynType), INTENT(IN) :: model INTEGER, INTENT(IN) :: node REAL(wp), INTENT(IN) :: fm(3), mm(3), fp(3), mp(3) REAL(wp), INTENT(OUT) :: tension, curvature, bend_moment INTEGER, INTENT(OUT) :: ErrStat CHARACTER(*), INTENT(OUT) :: ErrMsg - REAL(wp), INTENT(OUT), OPTIONAL :: sleeve_moment, curvature_vector(3) - REAL(wp) :: t(3), f(3), m(3), fend(3), qe(12), trace, section_moment, cable_moment, m_perp(3), kv(3) + REAL(wp), INTENT(OUT), OPTIONAL :: sleeve_moment, curvature_vector(3), moment_vector(3) + REAL(wp) :: t(3), f(3), m(3), fend(3), qe(12), trace, section_moment, cable_moment, m_perp(3), kv(3), ei_side INTEGER :: e, side CHARACTER(200) :: em2 @@ -7037,20 +7150,22 @@ SUBROUTINE node_values(model, node, fm, mm, fp, mp, tension, curvature, bend_mom END IF m_perp = m - DOT_PRODUCT(m, t)*t section_moment = NORM2(m_perp) + IF (PRESENT(moment_vector)) moment_vector = m_perp curvature = CD_ZERO cable_moment = CD_ZERO IF (PRESENT(curvature_vector)) curvature_vector = CD_ZERO DO side = 0, 1 e = node - 1 + side IF (e < 1 .OR. e > model%ne) CYCLE - IF (model%EI(e) > CD_ZERO .AND. model%EI(e) >= model%ei_resolve) THEN - IF (PRESENT(curvature_vector) .AND. section_moment/model%EI(e) > curvature) & - curvature_vector = m_perp/model%EI(e) - curvature = MAX(curvature, section_moment/model%EI(e)) - IF (ABS(model%EI_line(e) - model%EI(e)) <= CD_ZERO) THEN + ei_side = CD_HermiteCable_Dyn_Side_EI(model, e, node) + IF (model%EI(e) > CD_ZERO .AND. ei_side >= model%ei_resolve) THEN + IF (PRESENT(curvature_vector) .AND. section_moment/ei_side > curvature) & + curvature_vector = m_perp/ei_side + curvature = MAX(curvature, section_moment/ei_side) + IF (ABS(model%EI_line(e) - ei_side) <= CD_ZERO) THEN cable_moment = MAX(cable_moment, section_moment) ELSE - cable_moment = MAX(cable_moment, model%EI_line(e)*(section_moment/model%EI(e))) + cable_moment = MAX(cable_moment, model%EI_line(e)*(section_moment/ei_side)) END IF ELSE CALL gather_elem(model, e, qe) @@ -7058,7 +7173,8 @@ SUBROUTINE node_values(model, node, fm, mm, fp, mp, tension, curvature, bend_mom IF (ErrStat /= CD_HCABLE_OK) THEN ErrStat = CD_HCDYN_NOCONVERGE; ErrMsg = 'CD_HermiteCable_Dyn_Node_Recovery: '//TRIM(em2); RETURN END IF - IF (PRESENT(curvature_vector) .AND. trace > curvature) curvature_vector = kv + trace = trace*trace_scale(model, e, node) + IF (PRESENT(curvature_vector) .AND. trace > curvature) curvature_vector = kv*trace_scale(model, e, node) curvature = MAX(curvature, trace) IF (ABS(model%EI_line(e) - model%EI(e)) <= CD_ZERO) THEN cable_moment = MAX(cable_moment, section_moment) @@ -8075,6 +8191,7 @@ SUBROUTINE CD_HermiteCable_Dyn_End(model) IF (ALLOCATED(model%EA)) DEALLOCATE (model%EA) IF (ALLOCATED(model%EI)) DEALLOCATE (model%EI) IF (ALLOCATED(model%EI_line)) DEALLOCATE (model%EI_line) + IF (ALLOCATED(model%EI_node)) DEALLOCATE (model%EI_node) IF (ALLOCATED(model%rho_a)) DEALLOCATE (model%rho_a) IF (ALLOCATED(model%w)) DEALLOCATE (model%w) IF (ALLOCATED(model%BA)) DEALLOCATE (model%BA) diff --git a/tests/check_bend_stiffener.py b/tests/check_bend_stiffener.py index c1e077a1..60b494d2 100644 --- a/tests/check_bend_stiffener.py +++ b/tests/check_bend_stiffener.py @@ -20,10 +20,29 @@ within 2 % of the root moment; and FairDefl1, the angle between the end force and the clamp axis, must follow the reference within 0.05 deg. +The nodal curvature and the cable's moment are also gated locally: at every node of the first +8 m they must follow the reference within a share of its value at that arc, not of the root +value: 0.5 % on elements of 0.1 and 0.05 m, 1 % on 0.2 and 0.15 m (the tip then inside an +element). The curvature changes sign near the tip, so the value is floored at 0.1 % of the root +curvature. The stiffness at a node is EI(s) there; at the tip the bare side's, the larger +curvature of a real step. The same gate holds under the stiffener, where a sleeve makes the +interpolation's curvature no section's, the node values of OutputRecovery element and the peak of +each element in .elements.out against the largest reference curvature over that element, read +through cabledyn.bend_check where the package imports. + The curvature over the same 8 m must also follow OrcaFlex 11.6d, with the stiffener given as a line attachment (tests/data/orcaflex_bend_stiffener_curvature.csv), within 1.5 % of the root curvature; this part needs no scipy. +At a node inside the cone Curv, CurvX, CurvY, BendMom and StfMom must agree: the components +compose the curvature, the moments are EI_cable and EI(s) - EI_cable times it. At real steps of +the section the side of the larger curvature must give the values: the bare tip, a step between +stiffener rows and a junction of two line types; a junction of two meshes of one line type +under the stiffener is no step. A deck node keeps the rule on a mesh the static solve refined. +A sleeve too soft for the recovered moment, where the moment's error is far above its elastic +moment, must keep its element peaks at the curvature of its nodes. These parts need no scipy +either. + The initialisation notes are checked too: none on this deck; the resolution note when the 5 m stiffener spans 3 elements (2 m elements); the pinned-end note when End A has no END CONNECTIONS row. @@ -45,11 +64,24 @@ except ImportError: # pragma: no cover - environment dependent solve_bvp = None +sys.path.insert(0, str(pathlib.Path(__file__).resolve().parent.parent / "python")) +try: + from cabledyn import bend_check, read_output +except ImportError: # pragma: no cover - environment dependent + bend_check = read_output = None + MOMENT_TOLERANCE = 0.02 POSITION_TOLERANCE = 0.01 ANGLE_TOLERANCE = 0.05 ORCAFLEX_TOLERANCE = 0.015 +IDENTITY_TOLERANCE = 1.0e-5 +# elements over the first 8 m with their local curvature tolerance: 0.2, 0.15 (the stiffener tip +# inside an element), 0.1 and 0.05 m +MESH_SWEEP = ((40, 0.01), (54, 0.01), (80, 0.005), (160, 0.005)) +LOCAL_FLOOR = 1.0e-3 +ELEMENT_RECOVERY = ("9.80665 g\n", "element OutputRecovery\n9.80665 g\n") ORCAFLEX_CSV = pathlib.Path(__file__).resolve().parent / "data" / "orcaflex_bend_stiffener_curvature.csv" +REFINED_DECK = pathlib.Path(__file__).resolve().parent / "data" / "lazy_wave_touchdown_planar_coarse.dat" WINDOW = 8.0 G = 9.80665 @@ -107,6 +139,9 @@ "StfMom1N1" "BendMom1N41" "StfMom1N41" +"Curv1N41" +"CurvX1N41" +"CurvY1N41" END """ @@ -167,6 +202,7 @@ def bc(ya, yb): RESOLUTION_NOTE = "stiffener at End A spans" +FALLBACK_NOTES = ("reached after a failed Newton solve", "stalled", "looser tolerance") PINNED_NOTE = "the stiffener at End A sleeves a pinned end" @@ -218,6 +254,199 @@ def check_orcaflex(arc: np.ndarray, curvature: np.ndarray) -> bool: return ok +def step_deck(sections: str, rows: list[tuple[float, float, float]], channels: list[str]) -> str: + """The deck on 0.1 m elements with other first sections (the last 52 m stay) and stiffener + rows (length, root OD, tip OD), writing the node channels asked for.""" + deck = DECK.replace("1 cable 8.0 160\n", sections) + start = deck.index("1 A ") + deck = deck[:start] + "".join( + f"1 A {length} {od0} {od1} {ID_STF} {E_STF} {RHO_STF}\n" for length, od0, od1 in rows + ) + deck[deck.index("--------------------- END CONNECTIONS"):] + deck = deck.replace( + f"cable {D_CABLE} {M_CABLE} {EA} -1.0 {EI_CABLE} 1.2 0.0 1.0 0.0\n", + f"cable {D_CABLE} {M_CABLE} {EA} -1.0 {EI_CABLE} 1.2 0.0 1.0 0.0\n" + f"stiff {D_CABLE} {M_CABLE} {EA} -1.0 {2 * EI_CABLE} 1.2 0.0 1.0 0.0\n") + return deck[:deck.index('"FairTen1"')] + "".join(f'"{c}"\n' for c in channels) + "END\n" + + +def sleeve(od: float) -> float: + return E_STF * math.pi / 64.0 * (od**4 - ID_STF**4) + + +def check_steps(exe: str, tmp: str) -> bool: + """The section moment BendMom + StfMom over the softer side's stiffness at a real step, and + over EI(s) at a node where only the mesh changes (node 31 at 3 m, node 21 at 2 m, node 51 at + the 5 m tip).""" + cone = [(0.5, 0.60, 0.60), (4.5, 0.60, 0.22)] + od_3m = 0.60 + 2.5 / 4.5 * (0.22 - 0.60) + # name, sections, stiffener rows, node, stiffness giving the curvature, cable stiffness of + # the BendMom share (the larger share, on the side of the larger EI_cable) + cases = [ + ("bare tip", "1 cable 8.0 80\n", cone, 51, EI_CABLE, EI_CABLE), + ("step between rows", "1 cable 8.0 80\n", [(2.0, 0.60, 0.60), (3.0, 0.45, 0.22)], 21, + EI_CABLE + sleeve(0.45), EI_CABLE), + ("junction of two line types", "1 cable 3.0 30\n1 stiff 5.0 50\n", cone, 31, + EI_CABLE + sleeve(od_3m), 2 * EI_CABLE), + ("junction of two meshes", "1 cable 3.0 60\n1 cable 5.0 50\n", cone, 61, + EI_CABLE + sleeve(od_3m), EI_CABLE), + ] + ok = True + for name, sections, rows, node, ei, ei_cable in cases: + channels = [f"{c}1N{node}" for c in ("Curv", "BendMom", "StfMom")] + rc, log, _, out = solve(exe, tmp, "step", step_deck(sections, rows, channels)) + if rc != 0: + print(log[-3000:]) + print(f"FAIL {name}: the driver did not solve the deck") + return False + curvature, bend, stiffener = (out[c] for c in channels) + moment = bend + stiffener + full = ei_cable == ei + if name == "junction of two line types": + # the stiffer type's own share: EI_cable M / (EI_cable + sleeve) + share = ei_cable * moment / (ei_cable + sleeve(od_3m)) + else: + share = moment if full else ei_cable * curvature + error = max(abs(curvature * ei / moment - 1.0), abs(bend / share - 1.0)) + good = error <= IDENTITY_TOLERANCE + print(f"{'ok ' if good else 'FAIL'} {name}: curvature {curvature:.5f} 1/m, " + f"section moment {moment:.1f} N m, largest relative difference {error:.1e}") + ok = ok and good + return ok + + +def check_refined(exe: str, tmp: str) -> bool: + """A stiffener on a line whose static solve refines the deck mesh, the coarse lazy wave with + 20 m elements under a 60 m cone: the stiffness at the deck node 40 m along, on the final mesh, + gives its curvature.""" + deck = REFINED_DECK.read_text().replace("4 bare 80.0 20", "4 bare 80.0 4") + length, od0, od1, bore = 60.0, 0.22, 0.17, 0.16 + deck = deck.replace("--------------------- OPTIONS", ( + "--------------------- STIFFENERS ---------------------------------------------\n" + "LineID End Length RootOD TipOD InnerD E Density\n" + "(-) (-) (m) (m) (m) (m) (Pa) (kg/m^3)\n" + f"4 A {length} {od0} {od1} {bore} {E_STF} {RHO_STF}\n" + "--------------------- OPTIONS"), 1) + deck = deck.replace("FairTen4\n", "Curv4N3\nBendMom4N3\nStfMom4N3\n") + rc, log, rows, out = solve(exe, tmp, "refined", deck) + if rc != 0 or "refined to" not in log: + print(log[-3000:]) + print("FAIL: the driver did not solve and refine the coarse deck") + return False + od = od0 + 40.0 / length * (od1 - od0) + ei = 1.99e4 + E_STF * math.pi / 64.0 * (od**4 - bore**4) + error = abs(out["Curv4N3"] * ei / (out["BendMom4N3"] + out["StfMom4N3"]) - 1.0) + ok = error <= IDENTITY_TOLERANCE + print(f"{'ok ' if ok else 'FAIL'} refined mesh of {len(rows) - 1} elements: curvature at the " + f"deck node within {error:.1e} of the section moment over EI(s)") + return ok + + +def check_soft_sleeve(exe: str, tmp: str) -> bool: + """The coarse lazy wave with EI 100 N m^2 under a 100 m sleeve of 120 N m^2 at most, far below + the stiffness that resolves the recovered moment, max(w L0^2)/12 of about 1300 N m^2 on its + 10 m elements: moment over stiffness would be noise there. The element peaks must stay with + the curvature of their end nodes, which take the interpolation's.""" + length = 100.0 + deck = REFINED_DECK.read_text().replace(" 1.99e4 ", " 100.0 ") + deck = deck.replace("--------------------- OPTIONS", ( + "--------------------- STIFFENERS ---------------------------------------------\n" + "LineID End Length RootOD TipOD InnerD E Density\n" + "(-) (-) (m) (m) (m) (m) (Pa) (kg/m^3)\n" + f"4 A {length} 0.18 0.17 0.16 1.0e6 {RHO_STF}\n" + "--------------------- OPTIONS"), 1) + rc, log, rows, _ = solve(exe, tmp, "soft", deck) + if rc != 0: + print(log[-3000:]) + print("FAIL: the driver did not solve the deck with a soft sleeve") + return False + nodes = np.array([float(r.split()[7]) for r in rows if r.strip()]) + table = (pathlib.Path(tmp) / "soft.elements.out").read_text().splitlines()[3:] + table = np.array([[float(v) for v in r.split()] for r in table if r.strip()]) + covered = int(np.sum(table[:, 3] <= length + 1.0e-9)) + ratio = np.max(table[:covered, 6] / np.maximum(nodes[:covered], nodes[1:covered + 1])) + ok = ratio <= 1.02 + print(f"{'ok ' if ok else 'FAIL'} soft sleeve: element peaks within a factor {ratio:.3f} of the " + f"curvature at their end nodes") + return ok + + +def check_identities(out: dict[str, float], name: str = "node 41") -> bool: + """Curv, CurvX, CurvY, BendMom and StfMom of a node inside the cone (node 41, 2 m).""" + curvature = out["Curv1N41"] + ei = float(section(np.array([2.0]))[0][0]) + error = max(abs(math.hypot(out["CurvX1N41"], out["CurvY1N41"]) / curvature - 1.0), + abs(out["BendMom1N41"] / (EI_CABLE * curvature) - 1.0), + abs(out["StfMom1N41"] / ((ei - EI_CABLE) * curvature) - 1.0)) + ok = error <= IDENTITY_TOLERANCE + print(f"{'ok ' if ok else 'FAIL'} {name}: curvature components and moment shares agree " + f"within {error:.1e}") + return ok + + +def element_peaks(path: pathlib.Path, n: int) -> tuple[np.ndarray, np.ndarray, np.ndarray]: + """Arc start and end of the first n elements of a .elements.out, and their peak curvature, + through bend_check where the package imports.""" + table = np.array([[float(v) for v in r.split()] for r in path.read_text().splitlines()[3:]])[:n] + if bend_check is None: + return table[:, 2], table[:, 3], table[:, 6] + return table[:, 2], table[:, 3], bend_check(read_output(path), 1.0, condition="storage", line_id=1).curvature[:n] + + +def reference_curvature(sol, s: np.ndarray) -> np.ndarray: + return np.abs(sol.sol(s)[3]) * MOMENT_SCALE / section(s)[0] + + +def check_local(exe: str, tmp: str, sol) -> bool: + """Curvature and cable moment over the first WINDOW m against the elastica, each within the + tolerance of MESH_SWEEP of the reference where it is reported, element size swept: at the + nodes, and under the stiffener at the nodes of OutputRecovery element and the peak of each + element.""" + ok = True + root_curvature = float(reference_curvature(sol, np.array([0.0]))[0]) + tip = SEGMENTS[-1][1] + for n, tolerance in MESH_SWEEP: + deck = DECK.replace("1 cable 8.0 160", f"1 cable 8.0 {n}") + s = np.arange(n + 1) * (WINDOW / n) + ei = section(s)[0] + ei[np.abs(s - tip) < 1.0e-9] = EI_CABLE + curvature = np.abs(sol.sol(s)[3]) * MOMENT_SCALE / ei + scale = np.maximum(curvature, LOCAL_FLOOR * root_curvature) + for name, text in (("equilibrium nodes", deck), ("element nodes", deck.replace(*ELEMENT_RECOVERY))): + rc, log, rows, _ = solve(exe, tmp, "local", text) + if rc != 0: + print(log[-3000:]) + print(f"FAIL: the driver did not solve the deck with {n} elements") + return False + if any(note in log for note in FALLBACK_NOTES): + print(log[-3000:]) + print(f"FAIL: the static solve with {n} elements fell back") + return False + data = np.array([[float(v) for v in r.split()[2:9]] for r in rows[:n + 1]]) + # past the tip an element's own curvature is the section's, by definition + covered = s < tip - 1.0e-9 if name == "element nodes" else s < np.inf + error = np.where(covered, np.abs(data[:, 5] - curvature) / scale, 0.0) + moment_error = np.max(np.where(covered, np.abs(np.abs(data[:, 6]) / EI_CABLE - curvature) / scale, 0.0)) + worst = int(np.argmax(error)) + good = max(error[worst], moment_error) <= tolerance + print(f"{'ok ' if good else 'FAIL'} {WINDOW / n:.3f} m elements, {name}: curvature within " + f"{100 * error[worst]:.3f} % locally (at {s[worst]:.3f} m), cable moment within " + f"{100 * moment_error:.3f} %, gate {100 * tolerance:.1f} %") + ok = ok and good + start, stop, peak = element_peaks(pathlib.Path(tmp) / "local.elements.out", n) + # inside each element, so a tip on its end reads the element's own side + inner = start[:, None] + (stop - start)[:, None] * np.linspace(1.0e-6, 1.0 - 1.0e-6, 33) + reference = reference_curvature(sol, inner.ravel()).reshape(inner.shape).max(axis=1) + error = np.abs(peak - reference) / np.maximum(reference, LOCAL_FLOOR * root_curvature) + error[start >= tip - 1.0e-9] = 0.0 + worst = int(np.argmax(error)) + good = error[worst] <= tolerance + print(f"{'ok ' if good else 'FAIL'} {WINDOW / n:.3f} m elements, element peaks: within " + f"{100 * error[worst]:.3f} % locally (element at {start[worst]:.3f} m), gate " + f"{100 * tolerance:.1f} %") + ok = ok and good + return ok + + def main() -> int: exe = sys.argv[1] with tempfile.TemporaryDirectory() as tmp: @@ -227,14 +456,25 @@ def main() -> int: print("FAIL: the driver did not solve the stiffener deck") return 1 notes_ok = check_notes(exe, tmp, log) - data = np.array([[float(v) for v in r.split()[2:9]] for r in rows if r.strip()]) - orcaflex_ok = check_orcaflex(data[:, 0], data[:, 5]) - if solve_bvp is None: - print("SKIP: scipy is not installed (the elastica comparison needs solve_bvp)") - return 77 if notes_ok and orcaflex_ok else 1 - arc, x, z, moment = data[:, 0], data[:, 1], data[:, 3] + 20.0, data[:, 6] - s_nodes = np.cumsum(np.r_[0.0, np.full(160, 8.0 / 160), np.full(52, 1.0)]) - sol = reference(s_nodes, x, z) + notes_ok = check_steps(exe, tmp) and notes_ok + notes_ok = check_refined(exe, tmp) and notes_ok + notes_ok = check_soft_sleeve(exe, tmp) and notes_ok + data = np.array([[float(v) for v in r.split()[2:9]] for r in rows if r.strip()]) + notes_ok = check_identities(out) and notes_ok + rc, log, _, element_out = solve(exe, tmp, "element", DECK.replace(*ELEMENT_RECOVERY)) + if rc != 0: + print(log[-3000:]) + print("FAIL: the driver did not solve the deck under OutputRecovery element") + return 1 + notes_ok = check_identities(element_out, "node 41, OutputRecovery element") and notes_ok + orcaflex_ok = check_orcaflex(data[:, 0], data[:, 5]) + if solve_bvp is None: + print("SKIP: scipy is not installed (the elastica comparison needs solve_bvp)") + return 77 if notes_ok and orcaflex_ok else 1 + arc, x, z, moment = data[:, 0], data[:, 1], data[:, 3] + 20.0, data[:, 6] + s_nodes = np.cumsum(np.r_[0.0, np.full(160, 8.0 / 160), np.full(52, 1.0)]) + sol = reference(s_nodes, x, z) + local_ok = check_local(exe, tmp, sol) ref = sol.sol(s_nodes) ref[3] *= MOMENT_SCALE section_moment = np.abs(ref[3]) @@ -255,7 +495,8 @@ def main() -> int: angle_error = abs(out["FairDefl1"] - deflection) print(f"FairDefl1: driver {out['FairDefl1']:.4f} deg, elastica {deflection:.4f} deg") ok = (cable_error <= MOMENT_TOLERANCE and position_error <= POSITION_TOLERANCE and notes_ok - and total_error <= MOMENT_TOLERANCE and angle_error <= ANGLE_TOLERANCE and orcaflex_ok) + and total_error <= MOMENT_TOLERANCE and angle_error <= ANGLE_TOLERANCE and orcaflex_ok + and local_ok) print("PASS" if ok else "FAIL") return 0 if ok else 1 diff --git a/tests/test_bend_stiffener.f90 b/tests/test_bend_stiffener.f90 index f4fcc374..c7a9b6b6 100644 --- a/tests/test_bend_stiffener.f90 +++ b/tests/test_bend_stiffener.f90 @@ -11,15 +11,21 @@ PROGRAM test_bend_stiffener !! for bit. !! 2. A cone: the element values follow a 20 000-interval midpoint integration of the same !! averages to 1e-10. - !! 3. Deck grammar: malformed rows, a stiffener on an EI = 0 line and stiffeners longer than + !! 3. The stiffness at the nodes (CD_Stiffener_Node_EI) against closed forms: both limits are + !! the same number where EI(s) is continuous (a cone, a junction of rows that match) and + !! differ only at a real step: the bare tip, rows that do not match, two line types. A tip + !! inside an element leaves the node past it bare; End B mirrors End A; a tip on a node + !! whose arc sums off it by round-off is still on it. + !! 4. Deck grammar: malformed rows, a stiffener on an EI = 0 line and stiffeners longer than !! the line fail closed by name; on a stock-order LINES row the stiffener sleeves the same !! physical end, and the static profile is the native deck's; StfMom on a line without a !! stiffener and AnchDefl at a pinned end fail closed, FairDefl at the clamped end runs. - !! 4. Coupled route (the OpenFAST aggregate): the cable carries the stiffened root element, - !! and its initial fairlead load is the standalone static solve's. + !! 5. Coupled route (the OpenFAST aggregate): the cable carries the stiffened root element and + !! the node stiffness on the two sides of the tip, its initial fairlead load is the + !! standalone static solve's, and a line without a stiffener has no node stiffness. !! The static equilibrium against the planar elastica is tests/check_bend_stiffener.py. USE CableDyn_Precision, ONLY: wp - USE CableDyn_DeckDriver, ONLY: CD_Run_Deck_Driver, CD_DECKDRV_OK, CD_Stiffener_Overlay + USE CableDyn_DeckDriver, ONLY: CD_Run_Deck_Driver, CD_DECKDRV_OK, CD_Stiffener_Overlay, CD_Stiffener_Node_EI USE CableDyn_OpenFAST_Aggregate, ONLY: CD_AGG_ModuleType, CD_AGG_Init_From_Deck, CD_AGG_GetMovingPointMesh, & CD_AGG_End, CD_AGG_OK IMPLICIT NONE @@ -30,6 +36,7 @@ PROGRAM test_bend_stiffener CALL case_cylinder() CALL case_cone() + CALL case_node_stiffness() CALL case_grammar() CALL case_coupled() @@ -136,6 +143,65 @@ SUBROUTINE case_cone() 'cone: bare elements unchanged') END SUBROUTINE case_cone + SUBROUTINE case_node_stiffness() + !! Ten 1 m elements, line type EI_C on the first six and 2 EI_C beyond, under a cylinder over + !! 0-2 m (OD 0.6), a cone over 2-5 m (0.6 -> 0.3) and a cone over 5-7.5 m (0.25 -> 0.22), + !! whose tip lies inside element 8. + REAL(wp), PARAMETER :: EI_C = 2.0e4_wp, ID = 0.2_wp, EMOD = 5.0e7_wp, RHO = 1150.0_wp + REAL(wp), PARAMETER :: TOL = 1.0e-13_wp + REAL(wp) :: stf(8, 3), l0(10), eic(10), en(2, 11), eb(2, 11), od7, tip(8, 1), l1(40), e1(40), n1(2, 41) + INTEGER :: j + l0 = 1.0_wp + eic(1:6) = EI_C + eic(7:10) = 2.0_wp*EI_C + stf(:, 1) = [1.0_wp, 0.0_wp, 2.0_wp, 0.6_wp, 0.6_wp, ID, EMOD, RHO] + stf(:, 2) = [1.0_wp, 2.0_wp, 5.0_wp, 0.6_wp, 0.3_wp, ID, EMOD, RHO] + stf(:, 3) = [1.0_wp, 5.0_wp, 7.5_wp, 0.25_wp, 0.22_wp, ID, EMOD, RHO] + CALL CD_Stiffener_Node_EI(stf, l0, eic, en) + CALL require(en(1, 1) == 0.0_wp .AND. en(2, 11) == 0.0_wp, 'node EI: no limit beyond a line end') + CALL require(close_rel(en(2, 1), EI_C + sleeve(0.6_wp), TOL), 'node EI: the root') + CALL require(en(1, 3) == en(2, 3) .AND. close_rel(en(1, 3), EI_C + sleeve(0.6_wp), TOL), & + 'node EI: rows that match are continuous, to the bit') + CALL require(en(1, 4) == en(2, 4) .AND. close_rel(en(1, 4), EI_C + sleeve(0.5_wp), TOL), & + 'node EI: EI(s) at a node inside a cone') + CALL require(close_rel(en(1, 6), EI_C + sleeve(0.3_wp), TOL) .AND. & + close_rel(en(2, 6), EI_C + sleeve(0.25_wp), TOL), & + 'node EI: a step between rows keeps both sides') + od7 = 0.25_wp + 0.4_wp*(0.22_wp - 0.25_wp) + CALL require(close_rel(en(1, 7), EI_C + sleeve(od7), TOL) .AND. & + close_rel(en(2, 7), 2.0_wp*EI_C + sleeve(od7), TOL), & + 'node EI: a junction of line types keeps both sides') + CALL require(en(1, 9) == 2.0_wp*EI_C .AND. en(2, 9) == 2.0_wp*EI_C, & + 'node EI: the node past a tip inside an element is bare') + CALL require(en(1, 11) == 2.0_wp*EI_C, 'node EI: the bare line end') + ! the same stiffener from End B, on the mirrored line: the limits mirror, each side swapping + stf(1, :) = 2.0_wp + CALL CD_Stiffener_Node_EI(stf, l0, eic(10:1:-1), eb) + DO j = 1, 11 + CALL require(close_rel(eb(1, 12 - j), en(2, j), TOL) .AND. close_rel(eb(2, 12 - j), en(1, j), TOL), & + 'node EI: End B mirrors End A') + END DO + ! a section without bending stiffness: the sleeve alone, and nothing past it + CALL CD_Stiffener_Node_EI(stf(:, 1:1), l0, [(0.0_wp, j=1, 10)], eb) + CALL require(close_rel(eb(1, 10), sleeve(0.6_wp), TOL) .AND. eb(1, 9) == 0.0_wp .AND. eb(2, 1) == 0.0_wp, & + 'node EI: an EI = 0 section takes the sleeve alone') + ! a 3 m tip off node 31 of forty 0.1 m elements by round-off, either way, is on the node + l1 = 0.1_wp + e1 = EI_C + DO j = -1, 1, 2 + tip(:, 1) = [1.0_wp, 0.0_wp, 3.0_wp*(1.0_wp + REAL(j, wp)*1.0e-14_wp), 0.5_wp, 0.3_wp, ID, EMOD, RHO] + CALL CD_Stiffener_Node_EI(tip, l1, e1, n1) + CALL require(close_rel(n1(1, 31), EI_C + sleeve(0.3_wp), 1.0e-12_wp) .AND. n1(2, 31) == EI_C, & + 'node EI: a tip on a node is a step there, whatever the round-off of the arc') + END DO + END SUBROUTINE case_node_stiffness + + PURE REAL(wp) FUNCTION sleeve(od) + !! Bending stiffness of the 50 MPa sleeve of case_node_stiffness, bored to 0.2 m. + REAL(wp), INTENT(IN) :: od + sleeve = 5.0e7_wp*PI/64.0_wp*(od**4 - 0.2_wp**4) + END FUNCTION sleeve + SUBROUTINE write_deck(path, stiffener_rows, ei, stock, channel) !! A 60 m cable clamped horizontal at a 20 m deep hang-off and fixed 30 m lower; stock: the !! 7-column LINES row written anchor first, so the parser swaps the ends. @@ -257,6 +323,7 @@ SUBROUTINE case_grammar() CALL require(na == nb .AND. na > 0, 'grammar: both decks write a static profile') IF (na == nb .AND. na > 0) THEN CALL require(MAXVAL(ABS(pa(2:4, :na) - pb(2:4, :nb))) < 1.0e-6_wp .AND. & + MAXVAL(ABS(pa(6, :na) - pb(6, :nb))) < 1.0e-6_wp*MAXVAL(ABS(pa(6, :na))) .AND. & MAXVAL(ABS(pa(7, :na) - pb(7, :nb))) < 1.0e-6_wp*MAXVAL(ABS(pa(7, :na))), & 'grammar: on a stock-order row the stiffener sleeves the same physical end') END IF @@ -309,14 +376,16 @@ END SUBROUTINE case_grammar SUBROUTINE case_coupled() !! The native deck of case_grammar on the coupled route: its root element, wholly inside the - !! 0.5 m cylindrical root (OD 0.6 m, ID 0.2 m), has EI_c + E pi/64 (OD^4 - ID^4), and the - !! initial fairlead load matches the standalone static fairlead tension. + !! 0.5 m cylindrical root (OD 0.6 m, ID 0.2 m), has EI_c + E pi/64 (OD^4 - ID^4), the 5 m tip + !! is a step between its two node limits, and the initial fairlead load matches the + !! standalone static fairlead tension. Without a stiffener the cable has no node stiffness. TYPE(CD_AGG_ModuleType), SAVE :: agg REAL(wp), PARAMETER :: EI_ROOT = 2.0e4_wp + 5.0e7_wp*PI/64.0_wp*(0.6_wp**4 - 0.2_wp**4) + REAL(wp), PARAMETER :: EI_TIP = 2.0e4_wp + 5.0e7_wp*PI/64.0_wp*(0.22_wp**4 - 0.2_wp**4) REAL(wp) :: r0(3, 1), vel(3, 1), acc(3, 1), load(3, 1) REAL(wp), ALLOCATABLE :: prof(:, :) CHARACTER(512) :: em - INTEGER :: es, ne, n + INTEGER :: es, ne, n, tip CALL CD_AGG_Init_From_Deck(agg, 'stf_native.dat', 0.05_wp, es, em) CALL require(es == CD_AGG_OK, 'coupled: the stiffener deck initializes: '//TRIM(em)) IF (es /= CD_AGG_OK) RETURN @@ -324,11 +393,26 @@ SUBROUTINE case_coupled() ne = SIZE(agg%cables(1)%line%EI) CALL require(close_rel(agg%cables(1)%line%EI(ne), EI_ROOT, 1.0e-12_wp), & 'coupled: the root element carries the stiffener') + ! the tip, 5 m from End A on 0.5 m elements: the internal element before the node is bare + tip = ne + 1 - 10 + CALL require(ALLOCATED(agg%cables(1)%line%EI_node), 'coupled: the cable has the node stiffness') + IF (ALLOCATED(agg%cables(1)%line%EI_node)) THEN + CALL require(close_rel(agg%cables(1)%line%EI_node(1, ne + 1), EI_ROOT, 1.0e-12_wp), & + 'coupled: the stiffness at the root node, on its element') + CALL require(agg%cables(1)%line%EI_node(1, tip) == 2.0e4_wp .AND. & + close_rel(agg%cables(1)%line%EI_node(2, tip), EI_TIP, 1.0e-12_wp), & + 'coupled: the two limits at the tip, each on its own side') + END IF CALL CD_AGG_GetMovingPointMesh(agg, r0, vel, acc, load, es, em) CALL read_static('stf_native.static.out', prof, n) IF (n > 0) CALL require(close_rel(NORM2(load(:, 1)), prof(5, 1), 1.0e-6_wp), & 'coupled: the initial fairlead load is the standalone static tension') CALL CD_AGG_End(agg, es, em) + CALL CD_AGG_Init_From_Deck(agg, 'stf_none.dat', 0.05_wp, es, em) + CALL require(es == CD_AGG_OK, 'coupled: the deck without a stiffener initializes: '//TRIM(em)) + IF (es /= CD_AGG_OK) RETURN + CALL require(.NOT. ALLOCATED(agg%cables(1)%line%EI_node), 'coupled: no stiffener, no node stiffness') + CALL CD_AGG_End(agg, es, em) END SUBROUTINE case_coupled END PROGRAM test_bend_stiffener diff --git a/validation/scripts/orcaflex_bend_stiffener.py b/validation/scripts/orcaflex_bend_stiffener.py index 99d9fa3a..627a0bcc 100644 --- a/validation/scripts/orcaflex_bend_stiffener.py +++ b/validation/scripts/orcaflex_bend_stiffener.py @@ -19,7 +19,7 @@ along its first 8 m (arc from End A, curvature in 1/m). Result (OrcFxAPI 11.6d): root curvature 0.4522 /m (CableDyn 0.4523), cable bend moment at the -root 9.04 kN.m; CableDyn's curvature follows the profile within 0.8 % of the root curvature. +root 9.04 kN.m; CableDyn's curvature follows the profile within 0.6 % of the root curvature. OrcaFlex SI (m, te, kN). Usage: python validation/scripts/orcaflex_bend_stiffener.py [output.csv]