diff --git a/CHANGELOG.md b/CHANGELOG.md index 406d1636..678d4d7e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -73,6 +73,18 @@ All notable changes to CableDyn are recorded in this file. The format follows cable's fairlead to the restored input mesh, whose last bits differ from the boundary the uninterrupted run committed, and the cable's `.CD.out` channels drifted by up to 1e-6 (relative) within seconds. The checkpoint now carries the cable's committed boundary. +- A finite-EI line longer than its span with no net weight, or too little for its bending + stiffness (0.001 N/m on a 120 m line with `EI` 1e4 N m²), failed its static solve: both routes + reached the compressed straight strut or stalled at the round-off of the axial forces. Such a + line is now solved heavier and carried back to its own weight in the vertical plane of its + chord. A weightless line bows as the Euler elastica (end thrust and bow to 3e-5 of the exact + solution); nothing in the deck chooses the side of its bow, so it is solved bowed downward and + a note says so. With its ends one above the other it is still refused, by name. +- A line along +X reported its tangent azimuth (`LNAzi`, the static profile's `Azimuth`) + at 0 or about 360 from one row to the next as it swayed a fraction of a degree to either + side, or by the sign of a round-off component: in OpenFAST about half the rows of a cable in + the x-z plane read 359.9x. A line whose chord heads within 45° of +X now reports its azimuths + in (−180, 180], every other line in [0, 360) as before. ## [0.3.0] - 2026-10-23 diff --git a/CMakeLists.txt b/CMakeLists.txt index a3680b28..db960784 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -2458,9 +2458,14 @@ function(cabledyn_msg_test name deck rc must_match must_not) -P ${CMAKE_CURRENT_SOURCE_DIR}/tests/check_driver_output.cmake) set_tests_properties(driver_msg_${name} PROPERTIES LABELS "fortran;driver;integration;static") endfunction() -# A neutrally buoyant finite-EI line longer than its span has no catenary and no tension-only bow. -cabledyn_msg_test(weightless_finite_ei msg_weightless_finite_ei.dat 2 - "weightless .neutrally buoyant. line is longer than its span;shorten the line to its span, or give it net weight" +# A neutrally buoyant finite-EI line longer than its span has no catenary: it bows under the +# compression its bending stiffness carries, and the run says that nothing chose the bow's side. +cabledyn_msg_test(weightless_finite_ei msg_weightless_finite_ei.dat 0 + "line 1 is weightless and longer than its span, so it bows;solved bowed downward in the vertical plane" + "net-heavy") +# With its ends one above the other nothing chooses the side of the bow either: refused, by name. +cabledyn_msg_test(weightless_finite_ei_vertical msg_weightless_finite_ei_vertical.dat 2 + "weightless .neutrally buoyant. line is longer than its vertical span;nothing chooses the side of the bow;offset its ends horizontally" "net-heavy") # An EI=0 line type rejected as net-buoyant whose mass is a relative 4e-9 below the displaced water # mass is named weightless and slack; one a relative 2e-6 below it keeps the plain message. @@ -2601,6 +2606,21 @@ if(Python3_Interpreter_FOUND) else() message(STATUS "statics_robustness_matrix: skipped (numpy/scipy not importable in ${Python3_EXECUTABLE})") endif() + # A finite-EI line longer than its span with little or no net weight: the weightless bow is the + # pinned-pinned elastica, light lines bow toward their weight, and a march from the bow stays at rest. + if(_statics_matrix_deps_rc EQUAL 0) + add_test( + NAME light_slack_statics + COMMAND ${Python3_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/tests/test_light_slack_statics.py + --exe $ + --output ${CMAKE_CURRENT_BINARY_DIR}/light_slack_statics) + set_tests_properties(light_slack_statics PROPERTIES + LABELS "python;driver;integration;static;validation" + TIMEOUT 600 + ENVIRONMENT "${_cabledyn_python_test_environment}") + else() + message(STATUS "light_slack_statics: skipped (numpy/scipy not importable in ${Python3_EXECUTABLE})") + endif() endif() add_executable(test_driver_channels tests/test_driver_channels.f90) diff --git a/doc/outputs.rst b/doc/outputs.rst index c8cd7872..87d8c0e8 100644 --- a/doc/outputs.rst +++ b/doc/outputs.rst @@ -232,7 +232,7 @@ finite-EI line of the run: - signed inclination below horizontal, ``Declination − 90`` * - ``Azimuth`` - ``(deg)`` - - axial-tangent azimuth from +X toward +Y, in [0, 360) + - axial-tangent azimuth from +X toward +Y, in the line's range (:ref:`outputs-azimuth-range`) * - ``DeckNode`` - ``(-)`` - the deck node of the row, the ```` of the node channels (1 = End A … 1 + the total @@ -486,6 +486,21 @@ fairlead) runs from its fairlead here (:doc:`migrating`), so its ``N`` is Moo ``N``. The per-line files (``Node…`` columns) number the same way. A run whose outputs name line nodes says so in a note, and ``N0`` is rejected rather than read as another node. +.. _outputs-azimuth-range: + +Azimuth range +~~~~~~~~~~~~~ + +The azimuth of a line's tangent (``LNAzi``, the ``Azimuth`` column of the static profile +and the azimuth of the initialisation summary) is reported in **(−180, 180]** on a line whose +chord from End A to End B, at the deck positions, heads within 45° of +X, and in **[0, 360)** on +every other line. The cut of a line's range then lies at least 45° from its heading: a line +swaying about its heading reads continuously, where a line along +X would otherwise jump +between 0 and 360 as it moves a fraction of a degree to either side. The range is fixed for +the run, so the motion of the line cannot switch it. A round-off component across the cut +reads on its included side (0, or 180 in the signed range), and one across +X reads exactly 0. +A line a host builds through the C interface without a deck reports [0, 360). + .. _outputs-refined-nodes: Node channels on a refined line @@ -691,7 +706,8 @@ Line-node channels - declination of the node's axial tangent from +Z (0 = up, 90 = horizontal, 180 = down) - deg * - ``LNAzi`` - - azimuth of the node's axial tangent from +X toward +Y, in [0, 360) + - azimuth of the node's axial tangent from +X toward +Y, in the line's range + (:ref:`outputs-azimuth-range`) - deg * - ``TorqN`` - torque (twisting moment) at node ``J`` of a line restrained in torsion at both ends diff --git a/doc/solver_paths.rst b/doc/solver_paths.rst index 81209a89..0996a2bc 100644 --- a/doc/solver_paths.rst +++ b/doc/solver_paths.rst @@ -94,6 +94,17 @@ Every attempt uses the same physical inputs, tolerance, and acceptance checks. N contact hierarchy are projected to the declared floor before polishing; this changes only the prolonged seed, never the contact law or the final equations. +**Weight continuation** (a light slack line). A line longer than its span with too little net +weight for its bending stiffness (:math:`|w| < 100\,EI/L^3`) has no catenary to start from, and +both routes can end on the compressed straight strut or stall at the round-off of its axial +forces. When both fail, the line is solved heavier, with :math:`100\,EI/L^3` of the sign of its +net weight added (downward for a weightless line), and that equilibrium is carried back to its +own weight in the vertical plane of its chord, accepting the round-off floor of the axial +forces. It applies to a planar line in still water over a level seabed, without attachments or +``tensile_safety True``, whose chord is not vertical. A weightless line bows as the Euler +elastica; nothing in the deck chooses the plane or the side of the bow, and a note says how it +was solved (:doc:`theory`). + **Acceptance checks.** A residual-converged state is rejected when the sampled :math:`\max(L_0\,\kappa)` of any element exceeds 0.7 (an unresolved fold). With ``adaptive_mesh = True``, exhausting the refinement cap while curvature resolution or diff --git a/doc/standalone_driver.rst b/doc/standalone_driver.rst index d79cdecf..67abac60 100644 --- a/doc/standalone_driver.rst +++ b/doc/standalone_driver.rst @@ -142,8 +142,9 @@ force inclination differs slightly from the tangent inclination because the end the end node's share of the distributed load (and, on a finite-EI line, the end shear). ``declination`` is the angle from global ``+Z`` (the convention also used by OrcaFlex): 0 degrees up, 90 degrees -horizontal, and 180 degrees down. ``azimuth`` is measured from global ``+X`` toward ``+Y`` in -``[0, 360)``. Therefore ``inclination = declination - 90 degrees``; the two values are printed +horizontal, and 180 degrees down. ``azimuth`` is measured from global ``+X`` toward ``+Y``, in +``(-180, 180]`` on a line heading within 45 degrees of ``+X`` and in ``[0, 360)`` otherwise +(:ref:`outputs-azimuth-range`). Therefore ``inclination = declination - 90 degrees``; the two values are printed together deliberately so the convention is auditable. For the production Hermite finite-EI route, the reported vector is the complete fairlead reaction, diff --git a/doc/theory.rst b/doc/theory.rst index 9b0e3c0a..215a53f8 100644 --- a/doc/theory.rst +++ b/doc/theory.rst @@ -1479,6 +1479,32 @@ mesh-sequenced route described below first and this route as its fallback): mesh-sequenced solve below, audited alike. On the Lozon cables the two routes give the same equilibrium to the solver tolerance (positions within 2e-5 m, curvature within 1e-6 1/m). +A line longer than its span with little net weight for its bending stiffness has no catenary +to start from. With no weight at all it bows under the axial compression its bending stiffness +carries, the Euler elastica (about :math:`\pi^2 EI/L^2`). Both routes can then end on the +compressed straight strut, a saddle, or stall at the round-off of the axial forces, +:math:`EA\,\varepsilon\,|\mathbf r|/h` (the axial strain is formed from coordinate differences over +an element of length :math:`h`), which a weightless line's unit force scale puts above the +tolerance. When both routes fail on a slack line with :math:`|w| < 100\,EI/L^3` (largest +:math:`EI`), the line is solved with the auxiliary weight :math:`w_a = 100\,EI/L^3` added to every +element, of the sign of its net weight and downward for a weightless one, which the routes +handle. That equilibrium is carried back to the line's own weight by a continuation in the +weight, held in the vertical plane of the chord: steps of a quarter of the remaining +:math:`w_a`, the last from :math:`w_a/256` to none, a failed step halved. The steps accept the +round-off floor :math:`8\,EA\,\varepsilon\,|\mathbf r|_{\max}/h_{\min}` of the axial forces when it +lies above the tolerances of the routes, and a floor above the static tolerance is reported as +for the routes. The result is audited and checked for stability like theirs. The continuation +runs on a planar line in still water over a level seabed, without attachments or +``tensile_safety True``, whose chord is not vertical (the auxiliary weight must have a +component across it). For a weightless line nothing in the deck chooses the plane or the side +of the bow: the limit of a vanishing weight puts it on the lower side in the vertical plane of +the chord, and a note says so. Its tangent there has one zero eigenvalue, the bow turning about +the chord: the planar solve holds that mode, and a dynamic run leaves it free and at rest. On a +pinned 120 m line +with its ends 113 m apart the end thrust and the mid-span bow match the inextensible elastica, +:math:`P = 4K(m)^2EI/L^2` and :math:`\delta = \sqrt{m}\,L/K(m)` with +:math:`\text{chord}/L = 2E(m)/K(m) - 1`, to :math:`3\times10^{-5}` and :math:`10^{-6}` relative. + A deck current loads the line at rest with its steady Morison drag (the relative velocity is the current itself; the element fluid velocity is the mean of the current at its two nodes, as in the dynamics). The drag follows the line and is not a potential force: it is carried diff --git a/doc/troubleshooting.rst b/doc/troubleshooting.rst index 4420f6de..9fe01b00 100644 --- a/doc/troubleshooting.rst +++ b/doc/troubleshooting.rst @@ -488,14 +488,23 @@ but a few geometries are genuinely hard: - **A large grounded touchdown on the** ``EI = 0`` **path.** A long, near-horizontal grounded run can make the linear-Lagrange tangent singular regardless of seed. If the case is a lazy-wave or bending-dominated cable, use the finite-EI path (``EI > 0``), which is built for it. -- **A weightless finite-EI line longer than its span.** ``the weightless (neutrally buoyant) - line is longer than its span`` means every element has zero net weight (to a relative 1e-6 of - its displaced weight, attachments included). Such a line has no catenary: with no weight a - tension-only line is straight, and a longer one could only bow by bending under axial - compression, which a cable does not carry. Shorten the line to its span, or give it net weight - (a larger ``MassDenInAir``, or clumps) or a tension that holds it taut. A line heavier than - water with the same symptom gets ``the net-heavy line is too long for its span to hang as a - catenary`` instead. +- **A weightless finite-EI line longer than its span.** Every element has zero net weight (to a + relative 1e-6 of its displaced weight, attachments included), so the line has no catenary: it + bows under the axial compression its bending stiffness carries (the Euler elastica). It is + solved, with the note ``line N is weightless and longer than its span``: nothing in the deck + chooses the plane or the side of the bow, so it is solved bowed downward in the vertical plane + through its ends, the limit of a vanishing net weight, and the bow can turn about the chord at + no cost. If the line has a net weight, however small, give it (``MassDenInAir``) to settle + the shape; a light line, heavy or buoyant, bows toward its weight + (:doc:`solver_paths`, weight continuation). With its ends one above the other nothing chooses + the side of the bow: ``the weightless (neutrally buoyant) line is longer than its vertical + span`` stops the run. In a current, with attachments, over a non-level seabed, under + ``tensile_safety True`` or with an end connection out of the plane of the chord the + continuation does not apply, and a line the routes cannot solve stops with ``the weightless + (neutrally buoyant) line is longer than its span``. Shorten the line to its span, or give it + net weight (a larger ``MassDenInAir``, or clumps) or a tension that holds it taut. A line + heavier than water that is too long for its span gets ``the net-heavy line is too long for + its span to hang as a catenary`` instead. - **A finite-EI lazy-wave cable at too coarse a mesh.** An under-resolved arch or touchdown carries a large element ``h·κ`` and can stall the dynamic Newton. The resolution metric flags this; the builder can auto-refine a fragile mesh when the deck opts in (``adaptive_mesh True``). diff --git a/python/tests/test_native_model.py b/python/tests/test_native_model.py index bb258212..a742d41d 100644 --- a/python/tests/test_native_model.py +++ b/python/tests/test_native_model.py @@ -373,15 +373,14 @@ def test_home_relative_deck_path_is_expanded(tmp_path, monkeypatch): def test_long_failure_message_is_kept_whole(): - # The weightless-line diagnosis names the cause, three nested solver reasons, and the - # remedy; it is longer than the 1024 characters the handle once retained, and its closing - # advice must reach the caller. - deck = REPO / "tests" / "data" / "msg_weightless_finite_ei.dat" + # A deck path of 1100 characters that does not exist: the diagnosis names the whole path and + # the reason, longer than the 1024 characters the handle once retained, and its closing + # reason must reach the caller. + deck = "missing_" + "d" * 1100 + ".dat" with cabledyn.CableDyn() as m: with pytest.raises(CableDynError) as caught: m.init_deck(deck) detail = caught.value.detail assert len(detail) > 1024 - assert "weightless (neutrally buoyant) line is longer than its span" in detail - assert detail.endswith("or a tension that holds it taut") - assert "net-heavy" not in detail + assert "cannot open deck: " in detail and deck in detail + assert detail.endswith("(file not found)") diff --git a/src/CableDyn_DeckDriver.f90 b/src/CableDyn_DeckDriver.f90 index b539047b..5ddf4743 100644 --- a/src/CableDyn_DeckDriver.f90 +++ b/src/CableDyn_DeckDriver.f90 @@ -170,8 +170,13 @@ MODULE CableDyn_DeckDriver ! of a typed mass (a mass written to seven digits against a diameter does not cancel exactly). ! It only selects the wording of a diagnosis -- an EI=0 line type rejected as net-buoyant ! whose mass lies within it below the displaced water mass, a finite-EI line whose every - ! element weighs within it of nothing -- and changes no acceptance rule. + ! element weighs within it of nothing -- and the side a weightless slack line bows to + ! (light_aux_weight); it changes no acceptance rule. REAL(wp), PARAMETER :: NEUTRAL_BUOYANCY_REL_TOL = 1.0e-6_wp + ! An azimuth within AZI_ROUNDOFF_DEG of 0 (mod 360) is reported as exactly 0 + ! (wrap_azimuth_deg): far above the round-off of a tangent's angle (~1e-12 deg) and far + ! below the output resolution (~4e-5 deg at 360). + REAL(wp), PARAMETER :: AZI_ROUNDOFF_DEG = 1.0e-9_wp ! A section whose segments are longer than COARSE_SECTION_FRACTION of its line (coarser than a ! uniform eight-segment line) is warned about as too coarse (warn_coarse_sections). A static ! strain above STATIC_STRAIN_NOTE_DEFAULT is noted (static_strain_note) when OPTION maxStrain @@ -469,6 +474,9 @@ MODULE CableDyn_DeckDriver LOGICAL :: stock_row = .FALSE. LOGICAL :: has_syrope_ic = .FALSE. REAL(wp) :: syrope_tmax0 = CD_ZERO, syrope_tmean0 = CD_ZERO + ! The range of the line's tangent azimuths: (-180, 180] when set, otherwise [0, 360) + ! (set_azimuth_ranges). + LOGICAL :: azi_signed = .FALSE. ! Public deck order is End A (column 1) then End B (column 2). The no-moment ! Ez vectors follow the A-to-B convention and are expressed in the connected ! parent's reference axes (global axes for fixed/anchored ends). @@ -1651,7 +1659,7 @@ END SUBROUTINE init_one_finite_model RECURSIVE SUBROUTINE build_one_hermite_cable(ln, sections, types, points, opts, dt, cable, coupled_node, & ErrStat, ErrMsg, standalone_controls, bathymetry, & fairlead_orientation, init_note, coarse_pass, fold_support, & - install_viv) + install_viv, aux_weight, fixed_fairlead) !! Build one COUPLED cubic-Hermite lazy-wave cable (CD_HFMF) from a finite-EI deck !! LINE -- the production Hermite bending path shared by the coupled route and !! standalone and coupled finite-EI dynamics, including flat/structured seabed contact. @@ -1685,6 +1693,12 @@ RECURSIVE SUBROUTINE build_one_hermite_cable(ln, sections, types, points, opts, ! Install the cross-flow VIV of the line's Cl > 0 sections (the standalone finite-EI march; ! the other routes refuse such a line before building it). LOGICAL, INTENT(IN), OPTIONAL :: install_viv + ! An auxiliary weight [N/m] added to every element's net weight (light_line_route: the + ! line solved heavier, whose equilibrium is carried back to its own weight). + REAL(wp), INTENT(IN), OPTIONAL :: aux_weight + ! Admit a Fixed End A as a standalone build does (the recursive builds of a standalone + ! line, which run without its standalone controls). + LOGICAL, INTENT(IN), OPTIONAL :: fixed_fairlead INTEGER, ALLOCATABLE :: conn(:, :), fixed_dofs(:), dynamic_fixed_dofs(:) REAL(wp), ALLOCATABLE :: l0(:), ea(:), mpl(:), diam(:), ei(:), gas_in(:), gj_in(:), i_rt_in(:), i_rn_in(:) @@ -1712,6 +1726,7 @@ RECURSIVE SUBROUTINE build_one_hermite_cable(ln, sections, types, points, opts, REAL(wp), PARAMETER :: COUPLED_STATIC_TOL = 1.0e-6_wp ! Newton-iteration budget of one mesh-sequenced fallback solve: a bounded failure path. INTEGER, PARAMETER :: FALLBACK_SEQUENCE_BUDGET = 2000 + LOGICAL :: fixed_fairlead_ok, weightless_bow LOGICAL :: standalone_mode, contact_enabled, used_trivial_seed, anchor_on_flat_bed, allow_extra_sequence LOGICAL :: polish_ready ! Set when the attachment polish needed its fallbacks (attachment_fallback_checks). @@ -1727,7 +1742,7 @@ RECURSIVE SUBROUTINE build_one_hermite_cable(ln, sections, types, points, opts, LOGICAL :: primary_done, primary_inadmissible, tolerance_note, stable, kink_refined, sequence_done LOGICAL :: primary_walked, walk_rejected, primary_walk_planar ! Why the bow behind the fairlead was not reached (bow_route), blank when not tried. - CHARACTER(1024) :: bow_msg, refine_msg + CHARACTER(1024) :: bow_msg, refine_msg, light_msg ! Set when the deck-mesh equilibrium failed the stability test and the refined one passed. LOGICAL :: stability_refined ! Elements of the mesh whose equilibrium failed the stability test before that refinement. @@ -1774,6 +1789,7 @@ RECURSIVE SUBROUTINE build_one_hermite_cable(ln, sections, types, points, opts, step_max_iter = 200 step_tol = 5.0e-3_wp standalone_mode = .FALSE. + weightless_bow = .FALSE. contact_enabled = .FALSE. anchor_on_flat_bed = .FALSE. used_trivial_seed = .FALSE. @@ -1807,6 +1823,8 @@ RECURSIVE SUBROUTINE build_one_hermite_cable(ln, sections, types, points, opts, step_tol = opts%dynamic_rel_tol END IF END IF + fixed_fairlead_ok = standalone_mode + IF (PRESENT(fixed_fairlead)) fixed_fairlead_ok = fixed_fairlead_ok .OR. fixed_fairlead ! Hand the dynamic integrator an equilibrium converged at least as tightly as ! its own Newton stopping criterion. A looser static tolerance can otherwise ! appear as an artificial load impulse on the first nominally stationary step, @@ -1833,7 +1851,7 @@ RECURSIVE SUBROUTINE build_one_hermite_cable(ln, sections, types, points, opts, ! -- ignoring their point mass/load state -- instead of failing closed. (ptype is stored ! lower-case; the aggregator inherits this check since it calls build_one_hermite_cable too.) IF (TRIM(points(pb)%ptype) /= 'coupled' .AND. TRIM(points(pb)%ptype) /= 'vessel' .AND. & - .NOT. (standalone_mode .AND. TRIM(points(pb)%ptype) == 'fixed')) THEN + .NOT. (fixed_fairlead_ok .AND. TRIM(points(pb)%ptype) == 'fixed')) THEN CALL fail(ErrStat, ErrMsg, 'finite-EI coupled cable requires End A (the fairlead) to be a '// & 'Coupled/Vessel point; got "'//TRIM(points(pb)%ptype)//'"'); RETURN END IF @@ -1966,10 +1984,17 @@ RECURSIVE SUBROUTINE build_one_hermite_cable(ln, sections, types, points, opts, CALL attachment_nodes(l0, ln%att(1, :), att_node, att_offset) CALL smear_attachments(w, l0, att_node, ln%att, opts%rhoW, opts%g) END IF + IF (PRESENT(aux_weight)) w = w + aux_weight ! Zero net weight everywhere (to the neutral-buoyancy band, attachments included): the line has ! no catenary, and the net-heavy diagnosis of a line too long for its span does not apply. weightless_line = ALL(ABS(w) <= NEUTRAL_BUOYANCY_REL_TOL*opts%rhoW*opts%g*QUARTER_PI*diam**2) - IF (weightless_line) THEN + IF (weightless_line .AND. .NOT. NORM2(fairlead(1:2) - anchor(1:2)) > 1.0e-6_wp*NORM2(fairlead - anchor)) THEN + geom_cause = 'the weightless (neutrally buoyant) line is longer than its vertical span, so it could only '// & + 'bow by bending under axial compression, and with its ends one above the other nothing chooses '// & + 'the side of the bow' + geom_advice = 'shorten the line to its span, or give it net weight (MassDenInAir above the displaced '// & + 'water mass, or clumps) or a tension that holds it taut, or offset its ends horizontally' + ELSE IF (weightless_line) THEN geom_cause = 'the weightless (neutrally buoyant) line is longer than its span, so it cannot hang as a '// & 'catenary: with no net weight a tension-only line is straight, and a longer one could only bow '// & 'by bending under axial compression' @@ -2792,6 +2817,13 @@ RECURSIVE SUBROUTINE build_one_hermite_cable(ln, sections, types, points, opts, primary_done = .TRUE. saddle_kept = .TRUE. END IF + ! A slack line too light for both routes is solved heavier and carried back to its own + ! weight (light_line_route). + IF (.NOT. (sequence_done .OR. primary_done) .AND. light_line_eligible()) THEN + CALL light_line_route(sequence_done, light_msg) + IF (.NOT. sequence_done) sequence_msg = TRIM(short_message(sequence_msg, 240))// & + '; weight continuation: '//TRIM(light_msg) + END IF IF (.NOT. (sequence_done .OR. primary_done)) THEN ! A mesh below the conditioning limit is the likely cause and is named first. IF (LEN_TRIM(fine_note) > 0) THEN @@ -2846,6 +2878,12 @@ RECURSIVE SUBROUTINE build_one_hermite_cable(ln, sections, types, points, opts, init_note = '' IF (LEN_TRIM(fine_note) > 0) init_note = TRIM(fine_note) END IF + IF (weightless_bow) & + CALL report_note('line '//TRIM(int_to_str(ln%id))//' is weightless and longer than its span, so it '// & + 'bows under the compression its bending stiffness carries. Nothing in the deck chooses '// & + 'the plane or the side of the bow: it is solved bowed downward in the vertical plane '// & + 'through its ends, the limit of a vanishing net weight, and the bow can turn about '// & + 'the chord at no cost. Give the line its net weight (MassDenInAir) to settle its shape') ! "line N carries ..." reads as one clause; the mesh variant is a "line N: ..." note IF (LEN_TRIM(compression_note) > 0) THEN IF (starts_with(compression_note, 'carries')) THEN @@ -3052,6 +3090,7 @@ RECURSIVE SUBROUTINE build_one_hermite_cable(ln, sections, types, points, opts, CALL fail(ErrStat, ErrMsg, 'finite-EI cable coupled-shell init failed: '//TRIM(em)); RETURN 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 IF (ANY(ba > CD_ZERO)) THEN @@ -3551,12 +3590,12 @@ SUBROUTINE still_water_compression(text) opts_sw%has_current_profile = .FALSE. IF (PRESENT(bathymetry)) THEN CALL build_one_hermite_cable(ln, sections, types, points, opts_sw, dt, sw_cable, sw_node, esw, emw, & - standalone_controls=.FALSE., bathymetry=bathymetry, & - fairlead_orientation=fairlead_dcm, init_note=sw_note) + standalone_controls=.FALSE., fixed_fairlead=fixed_fairlead_ok, & + bathymetry=bathymetry, fairlead_orientation=fairlead_dcm, init_note=sw_note) ELSE CALL build_one_hermite_cable(ln, sections, types, points, opts_sw, dt, sw_cable, sw_node, esw, emw, & - standalone_controls=.FALSE., fairlead_orientation=fairlead_dcm, & - init_note=sw_note) + standalone_controls=.FALSE., fixed_fairlead=fixed_fairlead_ok, & + fairlead_orientation=fairlead_dcm, init_note=sw_note) END IF IF (esw == CD_DECKDRV_OK) THEN CALL CD_HermiteCable_Mean_Axial_Extremes(sw_cable%line%l0, sw_cable%line%EA, sw_cable%line%q, t_min, & @@ -3571,6 +3610,204 @@ SUBROUTINE still_water_compression(text) CALL CD_HFMF_End(sw_cable) END SUBROUTINE still_water_compression + REAL(wp) FUNCTION light_aux_weight() RESULT(aux) + !! The auxiliary weight of light_line_route [N/m]: LIGHT_AUX bending-weight ratios + !! w L^3/EI of the stiffest section, heavy enough for the routes. It takes the sign of + !! the line's net weight; a weightless line is made heavy (the bow hangs downward). + REAL(wp), PARAMETER :: LIGHT_AUX = 100.0_wp + aux = LIGHT_AUX*MAXVAL(ei)/SUM(l0)**3 + IF (.NOT. weightless_line .AND. SUM(w*l0) < CD_ZERO) aux = -aux + END FUNCTION light_aux_weight + + LOGICAL FUNCTION light_line_eligible() RESULT(ok) + !! light_line_route applies to a slack, planar line (no current, no attachments, a + !! level seabed, no tensile_safety) whose weight, of one sign along it, is below the + !! auxiliary weight, and whose chord is not vertical (the auxiliary weight then has a + !! component across the chord that chooses the side of the bow). + REAL(wp) :: chord + ok = .FALSE. + IF (PRESENT(aux_weight) .OR. PRESENT(coarse_pass)) RETURN + IF (opts%has_current .OR. ALLOCATED(cur_obj) .OR. require_3d_static .OR. has_att .OR. tensile_error) RETURN + IF (LEN_TRIM(fine_note) > 0) RETURN + IF (PRESENT(bathymetry)) THEN + IF (.NOT. bathymetry_flat) RETURN + END IF + IF (.NOT. (ALL(w >= CD_ZERO) .OR. ALL(w <= CD_ZERO))) RETURN + IF (MAXVAL(ei) <= CD_ZERO) RETURN + chord = NORM2(fairlead - anchor) + IF (.NOT. SUM(l0) > chord) RETURN + IF (.NOT. NORM2(fairlead(1:2) - anchor(1:2)) > 1.0e-6_wp*chord) RETURN + ok = MAXVAL(ABS(w)) < ABS(light_aux_weight()) + END FUNCTION light_line_eligible + + SUBROUTINE light_line_route(done, why) + !! A slack line with too little weight for its bending stiffness: nothing hangs it as a + !! catenary, so it bows under the compression its bending stiffness carries (the + !! elastica, about pi^2 EI/L^2), and the routes' seeds lead to the compressed straight + !! strut (a saddle) or stall at the round-off of its axial forces. The line is solved + !! with the auxiliary weight of light_aux_weight (a recursive build: the routes) and that + !! equilibrium is carried back to the line's own weight by a continuation in the weight + !! (a quarter per step, the last from 1/256 to none, a failed step halved), held in the + !! vertical plane of the chord. Below the tolerances of the routes the continuation also + !! accepts the round-off floor of the axial forces, ROUNDOFF_RUNG EA eps |r|/h on the + !! largest coordinate |r| and shortest element h (EA (|r'| - 1) is formed from + !! coordinate differences). done is set with the audited, stable state in the *_am + !! outputs; otherwise why says what stopped it. + LOGICAL, INTENT(OUT) :: done + CHARACTER(*), INTENT(OUT) :: why + REAL(wp), PARAMETER :: LAST_FRACTION = 1.0_wp/256.0_wp, ROUNDOFF_RUNG = 8.0_wp + INTEGER, PARAMETER :: MAX_HALVINGS = 10 + TYPE(CD_HFMF_ModuleType) :: aux_cable + REAL(wp), ALLOCATABLE :: q_c(:), q_n(:), curv_n(:), w_k(:), knnode(:) + REAL(wp) :: aux, f, f_try, res_n, tol_k(3), tol_used + INTEGER :: aux_node, es_r, it_r, nfail, k, k_tol + LOGICAL :: last, stable_r + CHARACTER(1024) :: em_r + CHARACTER(2048) :: aux_note + done = .FALSE. + why = '' + aux = light_aux_weight() + IF (PRESENT(bathymetry)) THEN + CALL build_one_hermite_cable(ln, sections, types, points, opts, dt, aux_cable, aux_node, es_r, em_r, & + standalone_controls=.FALSE., fixed_fairlead=fixed_fairlead_ok, & + bathymetry=bathymetry, & + fairlead_orientation=fairlead_dcm, init_note=aux_note, aux_weight=aux) + ELSE + CALL build_one_hermite_cable(ln, sections, types, points, opts, dt, aux_cable, aux_node, es_r, em_r, & + standalone_controls=.FALSE., fixed_fairlead=fixed_fairlead_ok, & + fairlead_orientation=fairlead_dcm, init_note=aux_note, aux_weight=aux) + END IF + IF (es_r /= CD_DECKDRV_OK) THEN + WRITE (why, '(A,ES10.3,A)') 'the line with an auxiliary weight of ', aux, ' N/m found no equilibrium: ' + why = TRIM(why)//' '//TRIM(short_message(em_r, 240)) + CALL CD_HFMF_End(aux_cable) + RETURN + END IF + IF (SIZE(aux_cable%line%l0) /= SIZE(l0)) THEN + why = 'the equilibrium with the auxiliary weight was solved on a refined mesh' + CALL CD_HFMF_End(aux_cable) + RETURN + END IF + q_c = aux_cable%line%q + CALL CD_HFMF_End(aux_cable) + ALLOCATE (q_n(ndof), curv_n(nnode), w_k(SIZE(w))) + IF (contact_enabled) THEN + ALLOCATE (knnode(nnode)) + knnode = CD_ZERO + DO k = 1, SIZE(l0) + knnode(k) = knnode(k) + 0.5_wp*opts%kbot*diam(k)*l0(k) + knnode(k + 1) = knnode(k + 1) + 0.5_wp*opts%kbot*diam(k)*l0(k) + END DO + END IF + iters = 0 + f = CD_ONE + f_try = 0.25_wp + nfail = 0 + DO + last = f_try <= CD_ZERO + w_k = w + aux*f_try + tol_k = [static_tol_target, MAX(static_tol_target, COUPLED_STATIC_TOL), & + ROUNDOFF_RUNG*EPSILON(CD_ONE)*MAXVAL(ea)*position_magnitude(q_c)/MINVAL(l0)/ & + MAX(CD_ONE, SUM(ABS(w_k)*l0))] + ! The continuation steps go straight to the loosest tolerance; the last tries each. + IF (.NOT. last) tol_k(1:2) = MAXVAL(tol_k) + es_r = CD_HCSTAT_NOCONVERGE + tol_used = CD_ZERO + DO k_tol = 1, 3 + IF (k_tol > 1) THEN + IF (.NOT. (tol_k(k_tol) > MAXVAL(tol_k(1:k_tol - 1)))) CYCLE + END IF + IF (contact_enabled) THEN + CALL CD_HermiteCable_Static_Solve(l0, ea, ei, w_k, q_c, fixed_dofs, contact_z, CD_ZERO, 1, 80, & + tol_k(k_tol), 0.7_wp, q_n, curv_n, res_n, it_r, es_r, em_r, & + n_buoy_steps=1, contact_kn=knnode, contact_frame_cs=frame_cs, & + axial_quadrature_order=opts%axial_quadrature_order, & + bending_quadrature_order=opts%bending_quadrature_order, & + endconn_stiffness=endconn_k, endconn_direction=endconn_d0_local, & + endconn_mode=endconn_mode, waterline_z=CD_ZERO, & + dry_buoyancy=dry_b, water_weight=opts%rhoW*opts%g) + ELSE + CALL CD_HermiteCable_Static_Solve(l0, ea, ei, w_k, q_c, fixed_dofs, contact_z, CD_ZERO, 1, 80, & + tol_k(k_tol), 0.7_wp, q_n, curv_n, res_n, it_r, es_r, em_r, & + n_buoy_steps=1, & + axial_quadrature_order=opts%axial_quadrature_order, & + bending_quadrature_order=opts%bending_quadrature_order, & + endconn_stiffness=endconn_k, endconn_direction=endconn_d0_local, & + endconn_mode=endconn_mode, waterline_z=CD_ZERO, & + dry_buoyancy=dry_b, water_weight=opts%rhoW*opts%g) + END IF + iters = iters + it_r + IF (es_r == CD_HCSTAT_OK) THEN + tol_used = tol_k(k_tol) + EXIT + END IF + IF (es_r == CD_HCSTAT_BADINPUT) EXIT + END DO + IF (es_r == CD_HCSTAT_OK) THEN + q_c = q_n + f = f_try + IF (last) EXIT + f_try = MERGE(CD_ZERO, 0.25_wp*f, 0.25_wp*f < LAST_FRACTION) + ELSE + nfail = nfail + 1 + IF (nfail > MAX_HALVINGS .OR. es_r == CD_HCSTAT_BADINPUT) THEN + WRITE (why, '(A,ES10.3,A)') 'stopped at ', aux*f, ' N/m above the line''s own weight: ' + why = TRIM(why)//' '//TRIM(short_message(em_r, 240)) + RETURN + END IF + f_try = 0.5_wp*(f + f_try) + END IF + END DO + IF (ALLOCATED(l0_am)) DEALLOCATE (l0_am) + IF (ALLOCATED(ea_am)) DEALLOCATE (ea_am) + IF (ALLOCATED(ei_am)) DEALLOCATE (ei_am) + IF (ALLOCATED(w_am)) DEALLOCATE (w_am) + IF (ALLOCATED(fixed_am)) DEALLOCATE (fixed_am) + IF (ALLOCATED(q_static)) DEALLOCATE (q_static) + IF (ALLOCATED(curv)) DEALLOCATE (curv) + l0_am = l0 + ea_am = ea + ei_am = ei + w_am = w + fixed_am = fixed_dofs + CALL MOVE_ALLOC(q_c, q_static) + CALL MOVE_ALLOC(curv_n, curv) + res = res_n + applied_scale = 1 + compression_note = '' + CALL audit_hermite_static(l0_am, q_static, ea_am, ei_am, w_am, diam, endconn_mode, done, why, & + compression_note) + IF (done) THEN + CALL hermite_static_stable(l0, l0_am, ea_am, ei_am, w_am, diam, dry_b, q_static, fixed_am, & + contact_enabled, contact_z, frame_cs, endconn_k, endconn_d0_local, & + endconn_mode, opts, stable_r, es_r, em_r) + IF (es_r /= CD_DECKDRV_OK) THEN + done = .FALSE. + why = em_r + ELSE IF (.NOT. stable_r) THEN + done = .FALSE. + why = 'the equilibrium at the line''s own weight is an unstable equilibrium (tangent stiffness '// & + 'not positive definite)' + END IF + END IF + IF (.NOT. done) THEN + compression_note = '' + RETURN + END IF + tolerance_note = tol_used > static_tol_target + weightless_bow = weightless_line + END SUBROUTINE light_line_route + + PURE REAL(wp) FUNCTION position_magnitude(q) RESULT(r) + !! The largest node coordinate magnitude of a Hermite state (6 values per node). + REAL(wp), INTENT(IN) :: q(:) + INTEGER :: k + r = CD_ZERO + DO k = 1, SIZE(q)/6 + r = MAX(r, MAXVAL(ABS(q(6*(k - 1) + 1:6*(k - 1) + 3)))) + END DO + END FUNCTION position_magnitude + LOGICAL FUNCTION symmetric_current_retry() RESULT(retry) !! Set up the symmetry-breaking pass (see route_pass): out-of-plane DOFs freed and a !! cross-flow of SYM_BREAK of the horizontal current speed added. Only for an in-plane @@ -4008,12 +4245,13 @@ SUBROUTINE coarse_current_first(done, fail_msg) opts_c%adaptive_mesh = .FALSE. IF (PRESENT(bathymetry)) THEN CALL build_one_hermite_cable(ln, sec_c, types, points, opts_c, dt, c_cable, c_node, esc, emc, & - standalone_controls=.FALSE., bathymetry=bathymetry, & + standalone_controls=.FALSE., fixed_fairlead=fixed_fairlead_ok, & + bathymetry=bathymetry, & fairlead_orientation=fairlead_dcm, init_note=c_note, coarse_pass=.TRUE.) ELSE CALL build_one_hermite_cable(ln, sec_c, types, points, opts_c, dt, c_cable, c_node, esc, emc, & - standalone_controls=.FALSE., fairlead_orientation=fairlead_dcm, & - init_note=c_note, coarse_pass=.TRUE.) + standalone_controls=.FALSE., fixed_fairlead=fixed_fairlead_ok, & + fairlead_orientation=fairlead_dcm, init_note=c_note, coarse_pass=.TRUE.) END IF IF (esc /= CD_DECKDRV_OK) THEN CALL CD_HFMF_End(c_cable) @@ -4144,12 +4382,12 @@ SUBROUTINE still_water_reference(esr, emr) opts_sw%has_current_profile = .FALSE. IF (PRESENT(bathymetry)) THEN CALL build_one_hermite_cable(ln, sections, types, points, opts_sw, dt, sw_cable, sw_node, esr, emr, & - standalone_controls=.FALSE., bathymetry=bathymetry, & - fairlead_orientation=fairlead_dcm, init_note=sw_note) + standalone_controls=.FALSE., fixed_fairlead=fixed_fairlead_ok, & + bathymetry=bathymetry, fairlead_orientation=fairlead_dcm, init_note=sw_note) ELSE CALL build_one_hermite_cable(ln, sections, types, points, opts_sw, dt, sw_cable, sw_node, esr, emr, & - standalone_controls=.FALSE., fairlead_orientation=fairlead_dcm, & - init_note=sw_note) + standalone_controls=.FALSE., fixed_fairlead=fixed_fairlead_ok, & + fairlead_orientation=fairlead_dcm, init_note=sw_note) END IF IF (esr /= CD_DECKDRV_OK) THEN CALL CD_HFMF_End(sw_cable) @@ -8796,6 +9034,7 @@ SUBROUTINE init_one_model(ln, sections, types, points, opts, model, ErrStat, Err IF (ErrStat /= CD_DECKDRV_BADINPUT) ErrStat = CD_DECKDRV_SOLVEFAIL RETURN END IF + model%azimuth_signed = ln%azi_signed ! Cross-flow VIV on the Cl > 0 sections (CableDyn_VIV), installed on the initialised line ! (the static equilibrium carries no lift, as MoorDyn's initial-condition generation), and ! the initial acceleration recomputed with the t = 0 lift. @@ -11532,6 +11771,7 @@ SUBROUTINE parse_deck(path, types, bodies, rod_types, rods, points, lines, secti CALL normalize_stock_endpoint_order(points, lines, sections) CALL finalize_and_validate(types, bodies, rod_types, rods, points, lines, sections, opts, channels, ext_march, & static_finite_ok, ErrStat, ErrMsg, channel_lines) + IF (ErrStat == 0) CALL set_azimuth_ranges(points, lines) IF (ErrStat == 0 .AND. opts%has_motion_file) THEN BLOCK CHARACTER(:), ALLOCATABLE :: resolved_path @@ -15331,6 +15571,25 @@ SUBROUTINE normalize_turbine_points(points, allow_turbine, ErrStat, ErrMsg) END DO END SUBROUTINE normalize_turbine_points + SUBROUTINE set_azimuth_ranges(points, lines) + !! The range of each line's tangent azimuths (DeckLine%azi_signed): a line whose chord from + !! End A to End B, at the deck positions, heads within 45 deg of +X reports them in + !! (-180, 180], every other line in [0, 360). The cut of a line's range then lies at least + !! 45 deg from its heading, so a line swaying about its heading reads continuously (a line + !! along +X no longer jumps between 0 and 360), and the range is fixed for the run: the + !! motion of the line cannot switch it. + TYPE(DeckPoint), INTENT(IN) :: points(:) + TYPE(DeckLine), INTENT(INOUT) :: lines(:) + INTEGER :: i, ia, ib + DO i = 1, SIZE(lines) + ia = find_point(points, lines(i)%nodeA) + ib = find_point(points, lines(i)%nodeB) + IF (ia == 0 .OR. ib == 0) CYCLE + lines(i)%azi_signed = points(ib)%pos(1) - points(ia)%pos(1) > & + ABS(points(ib)%pos(2) - points(ia)%pos(2)) + END DO + END SUBROUTINE set_azimuth_ranges + SUBROUTINE normalize_stock_endpoint_order(points, lines, sections) !! Stock MoorDyn decks write lines anchor (End A) -> fairlead (End B); the CableDyn !! deck convention is the reverse (End A = fairlead side, End B = anchor). When a @@ -16688,7 +16947,7 @@ SUBROUTINE write_static_config_out(out_root, lines, ne, q_all, q_off, ten_all, t END IF curv = line_geom_from_r(5, r_line, nnode, node) dec = line_geom_from_r(7, r_line, nnode, node) - azi = line_geom_from_r(8, r_line, nnode, node) + azi = line_geom_from_r(8, r_line, nnode, node, lines(li)%azi_signed) WRITE (unit, '(I0,A,I0,10(A,ES15.7E3))') lines(li)%id, tab, node, tab, s, tab, r_node(1), & tab, r_node(2), tab, r_node(3), tab, tenv, tab, curv, tab, CD_ZERO, tab, dec, & tab, dec - 90.0_wp, tab, azi @@ -29742,7 +30001,8 @@ SUBROUTINE write_planned_row(unit, time, channels, lines, points, work, label, E CASE (4) ! acceleration val = work%line_a(off + k) CASE DEFAULT ! geometric channels (curvature / EI=0 bend moment / declination / azimuth) - val = line_geom_value(work%ch_aux(i), work%ch_node(i), nnode, work%line_q(off + 1:off + nd), stride) + val = line_geom_value(work%ch_aux(i), work%ch_node(i), nnode, work%line_q(off + 1:off + nd), stride, & + lines(li)%azi_signed) END SELECT END IF END IF @@ -30331,7 +30591,7 @@ SUBROUTINE system_channel_value(ch, lines, points, system, work, val, ErrStat, E CASE (4) ! acceleration val = work%a(3*(inode - 1) + comp) CASE DEFAULT ! curvature (5) / bend moment (6, EI=0 => 0) / declination (7) / azimuth (8) - val = line_geom_value(kind, node, nnode, work%q(1:ndof), 3) + val = line_geom_value(kind, node, nnode, work%q(1:ndof), 3, lines(li)%azi_signed) END SELECT END IF END IF @@ -30471,7 +30731,7 @@ SUBROUTINE finite_model_channel_value(ch, lines, points, models, work, val, ErrS val = nodal_ei_value(models(li)%ei, inode)*NORM2(kc - kr) END BLOCK CASE DEFAULT ! curvature (5) / declination (7) / azimuth (8) -- geometric - val = line_geom_value(kind, node, nnode, work%q(1:6*nnode), 6) + val = line_geom_value(kind, node, nnode, work%q(1:6*nnode), 6, lines(li)%azi_signed) END SELECT END IF END IF @@ -30651,7 +30911,7 @@ SUBROUTINE model_channel_value(ch, lines, points, models, work, val, ErrStat, Er CASE (4) ! acceleration val = work%a(3*(inode - 1) + comp) CASE DEFAULT ! curvature (5) / bend moment (6, EI=0 => 0) / declination (7) / azimuth (8) - val = line_geom_value(kind, node, nnode, work%q(1:ndof), 3) + val = line_geom_value(kind, node, nnode, work%q(1:ndof), 3, lines(li)%azi_signed) END SELECT END IF END IF @@ -32254,7 +32514,7 @@ REAL(wp) FUNCTION channel_value(ch, lines, points, ne, q_all, q_off, ten_all, te CASE (1) ! position v = q_all(q_off(li) + 3*(deck_to_internal_node(node, ne(li)) - 1) + comp) CASE (5, 6, 7, 8) ! curvature / bend moment / declination / azimuth (static EI=0 => bend moment 0) - v = line_geom_value(kind, node, nnode, q_all(q_off(li) + 1:q_off(li + 1)), 3) + v = line_geom_value(kind, node, nnode, q_all(q_off(li) + 1:q_off(li + 1)), 3, lines(li)%azi_signed) CASE DEFAULT ! velocity (2) / acceleration (4): zero in a static configuration v = CD_ZERO END SELECT @@ -32902,17 +33162,42 @@ PURE REAL(wp) FUNCTION tangent_declination_deg(t) RESULT(dec) dec = ACOS(MAX(-CD_ONE, MIN(CD_ONE, t(3)/n)))*CD_RAD2DEG END FUNCTION tangent_declination_deg - PURE REAL(wp) FUNCTION tangent_azimuth_deg(t) RESULT(azi) - !! Azimuth [deg] in [0,360): horizontal-plane angle from +GX toward +GY. A - !! vertical tangent has no defined azimuth and returns 0. + PURE REAL(wp) FUNCTION tangent_azimuth_deg(t, signed) RESULT(azi) + !! Azimuth [deg]: horizontal-plane angle from +GX toward +GY, in [0,360), or in + !! (-180,180] when signed (the line's range, DeckLine%azi_signed). A vertical tangent has + !! no defined azimuth and returns 0. REAL(wp), INTENT(IN) :: t(3) + LOGICAL, INTENT(IN), OPTIONAL :: signed azi = CD_ZERO IF (ABS(t(1)) <= TINY(CD_ONE) .AND. ABS(t(2)) <= TINY(CD_ONE)) RETURN - azi = ATAN2(t(2), t(1))*CD_RAD2DEG - IF (azi < CD_ZERO) azi = azi + 360.0_wp + azi = wrap_azimuth_deg(ATAN2(t(2), t(1))*CD_RAD2DEG, signed) END FUNCTION tangent_azimuth_deg - PURE REAL(wp) FUNCTION line_geom_value(kind, deck_node, nnode, q_flat, stride) RESULT(v) + PURE REAL(wp) FUNCTION wrap_azimuth_deg(a, signed) RESULT(azi) + !! An azimuth [deg] in (-540, 540) wrapped into [0,360), or into (-180,180] when signed. + !! An angle within AZI_ROUNDOFF_DEG of the cut of the range is put on its included side + !! (0, or 180 when signed), and one within it of 0 is exactly 0: a tangent lying on the + !! cut, or along +X, has a round-off component across it whose sign would otherwise + !! report it at either end of the range, or at +-1e-13, from one row to the next. + REAL(wp), INTENT(IN) :: a + LOGICAL, INTENT(IN), OPTIONAL :: signed + LOGICAL :: sgn + sgn = .FALSE. + IF (PRESENT(signed)) sgn = signed + azi = a + IF (sgn) THEN + IF (azi > 180.0_wp) azi = azi - 360.0_wp + IF (azi <= -180.0_wp) azi = azi + 360.0_wp + IF (azi < -180.0_wp + AZI_ROUNDOFF_DEG) azi = 180.0_wp + ELSE + IF (azi < CD_ZERO) azi = azi + 360.0_wp + IF (azi >= 360.0_wp) azi = azi - 360.0_wp + IF (azi > 360.0_wp - AZI_ROUNDOFF_DEG) azi = CD_ZERO + END IF + IF (ABS(azi) < AZI_ROUNDOFF_DEG) azi = CD_ZERO + END FUNCTION wrap_azimuth_deg + + PURE REAL(wp) FUNCTION line_geom_value(kind, deck_node, nnode, q_flat, stride, signed) RESULT(v) !! Shared evaluator for the GEOMETRIC output channels so every writer computes them !! identically. `q_flat` holds the line node positions in INTERNAL order !! (anchor->fairlead) with `stride` reals per node (3 for EI=0, 6 for finite-EI). @@ -32920,9 +33205,10 @@ PURE REAL(wp) FUNCTION line_geom_value(kind, deck_node, nnode, q_flat, stride) R !! the MATERIAL moment EI*(kappa - kappa_0), computed per path (zero on EI=0 lines; !! finite_model_channel_value and range_sample_fmodel on finite-EI lines), so it is not !! handled here and - !! kind = 6 returns 0. + !! kind = 6 returns 0. signed: the line's azimuth range (DeckLine%azi_signed). INTEGER, INTENT(IN) :: kind, deck_node, nnode, stride REAL(wp), INTENT(IN) :: q_flat(:) + LOGICAL, INTENT(IN), OPTIONAL :: signed REAL(wp) :: r(3, nnode) INTEGER :: j, base ! Deck node j (1 = End A) <-> internal node (nnode+1-j); extract deck-ordered positions. @@ -32930,16 +33216,18 @@ PURE REAL(wp) FUNCTION line_geom_value(kind, deck_node, nnode, q_flat, stride) R base = stride*(nnode - j) r(:, j) = q_flat(base + 1:base + 3) END DO - v = line_geom_from_r(kind, r, nnode, deck_node) + v = line_geom_from_r(kind, r, nnode, deck_node, signed) END FUNCTION line_geom_value - PURE REAL(wp) FUNCTION line_geom_from_r(kind, r, nnode, deck_node) RESULT(v) + PURE REAL(wp) FUNCTION line_geom_from_r(kind, r, nnode, deck_node, signed) RESULT(v) !! Geometric channel value (kind: 5 curvature, 7 declination, 8 azimuth) from the !! deck-ordered node positions r(3, nnode). Factored out of line_geom_value so a caller !! that writes EVERY node of a line (the .static.out profile) builds r ONCE per line !! rather than rebuilding it inside each per-node call -- O(nnode) instead of O(nnode^2). + !! signed: the line's azimuth range (DeckLine%azi_signed). INTEGER, INTENT(IN) :: kind, nnode, deck_node REAL(wp), INTENT(IN) :: r(3, nnode) + LOGICAL, INTENT(IN), OPTIONAL :: signed v = CD_ZERO SELECT CASE (kind) CASE (5) ! curvature [1/m] (OrcaFlex "Curvature" is the geometric centreline curvature) @@ -32947,7 +33235,7 @@ PURE REAL(wp) FUNCTION line_geom_from_r(kind, r, nnode, deck_node) RESULT(v) CASE (7) ! declination [deg] v = tangent_declination_deg(deck_node_tangent(r, nnode, deck_node)) CASE (8) ! azimuth [deg] - v = tangent_azimuth_deg(deck_node_tangent(r, nnode, deck_node)) + v = tangent_azimuth_deg(deck_node_tangent(r, nnode, deck_node), signed) END SELECT END FUNCTION line_geom_from_r @@ -34299,7 +34587,7 @@ SUBROUTINE eval_system_line_channel(system, li, ch, val, ErrStat, ErrMsg) CASE (4) ! acceleration val = a(3*(inode - 1) + comp) CASE DEFAULT ! curvature (5) / bend moment (6, EI=0 => 0) / declination (7) / azimuth (8) - val = line_geom_value(kind, node, nnode, q, 3) + val = line_geom_value(kind, node, nnode, q, 3, system%lines(li)%azimuth_signed) END SELECT END BLOCK END SUBROUTINE eval_system_line_channel @@ -34487,9 +34775,10 @@ SUBROUTINE eval_cable_channel(cable, ch, val, ErrStat, ErrMsg, mesh_node) END IF END BLOCK CASE (8) ! azimuth: local-frame azimuth plus the cable's frame heading, wrapped - val = line_geom_value(kind, node, nnode, cable%line%q(1:6*nnode), 6) + val = line_geom_value(kind, node, nnode, cable%line%q(1:6*nnode), 6, cable%azimuth_signed) IF (.NOT. cable_frame_is_identity(cable)) THEN - val = MODULO(val + ATAN2(cable%frame_s, cable%frame_c)*45.0_wp/QUARTER_PI, 360.0_wp) + val = wrap_azimuth_deg(val + ATAN2(cable%frame_s, cable%frame_c)*45.0_wp/QUARTER_PI, & + cable%azimuth_signed) END IF CASE DEFAULT ! declination (7) -- rotation-invariant geometric scalar val = line_geom_value(kind, node, nnode, cable%line%q(1:6*nnode), 6) diff --git a/src/CableDyn_Model.f90 b/src/CableDyn_Model.f90 index a1ca388c..7f80f50b 100644 --- a/src/CableDyn_Model.f90 +++ b/src/CableDyn_Model.f90 @@ -189,6 +189,9 @@ MODULE CableDyn_Model !! Persistent positions-only EI=0 model state and immutable mesh/properties. LOGICAL :: initialized = .FALSE. LOGICAL :: tension_only = .FALSE. + ! The range of the line's tangent azimuth channels: (-180, 180] when set, otherwise + ! [0, 360) (the deck line's, set by the deck driver that builds the model). + LOGICAL :: azimuth_signed = .FALSE. INTEGER :: n_dof = 0 INTEGER :: n_elem = 0 INTEGER, ALLOCATABLE :: elem_conn(:, :) @@ -6473,6 +6476,7 @@ SUBROUTINE CD_Copy_Model(src, dst, ErrStat, ErrMsg) ! released automatically on every early return. The final assignment is the single commit point. work%tension_only = src%tension_only + work%azimuth_signed = src%azimuth_signed work%n_dof = src%n_dof work%n_elem = src%n_elem work%has_seabed = src%has_seabed diff --git a/src/CableDyn_OpenFAST_HermiteFMF.f90 b/src/CableDyn_OpenFAST_HermiteFMF.f90 index c7533c28..4ea5e7d3 100644 --- a/src/CableDyn_OpenFAST_HermiteFMF.f90 +++ b/src/CableDyn_OpenFAST_HermiteFMF.f90 @@ -109,6 +109,9 @@ MODULE CableDyn_OpenFAST_HermiteFMF ! kinematics IN (global -> local) and loads OUT (local -> global), so every caller ! works purely in global coordinates. Identity (1, 0) leaves all paths bit-for-bit. REAL(wp) :: frame_c = 1.0_wp, frame_s = 0.0_wp + ! The range of the cable's tangent azimuth channels: (-180, 180] when set, otherwise + ! [0, 360) (the deck line's, set by the deck driver that builds the cable). + LOGICAL :: azimuth_signed = .FALSE. ! A finite or rigid connection at the coupled endpoint is attached to the host, so its ! no-moment direction is expressed in parent axes and rotates with the input ! mesh orientation. The DCM convention is OpenFAST's global-to-parent matrix. diff --git a/tests/data/msg_weightless_finite_ei_vertical.dat b/tests/data/msg_weightless_finite_ei_vertical.dat new file mode 100644 index 00000000..b0b52c6b --- /dev/null +++ b/tests/data/msg_weightless_finite_ei_vertical.dat @@ -0,0 +1,37 @@ +--------------------- CableDyn Input File --- +msg_weightless_finite_ei_vertical +--------------------- LINE TYPES --- +TypeName Diam MassDenInAir EA BA EI Cd_n Cd_t Ca_n Ca_t +(-) (m) (kg/m) (N) (-) (Nm2) (-) (-) (-) (-) +neut 0.2 32.2013247 100000000 -1 10000 1.2 0.1 1 0 +--------------------- POINTS --- +ID Type X Y Z Mass Vol CdA Ca +(-) (-) (m) (m) (m) (kg) (m3) (m2) (-) +1 Coupled 0 0 -20 0 0 0 0 +2 Fixed 0 0 -100 0 0 0 0 +--------------------- LINES --- +ID NodeA NodeB Outputs +(-) (-) (-) (-) +1 1 2 pt +--------------------- SECTIONS --- +LineID LineType Length NumSegs +(-) (-) (m) (-) +1 neut 120 120 +--------------------- OPTIONS --- +9.80665 g +1025.0 rhoW +200.0 WtrDpth +100000.0 kBot +1.0e4 cBot +0.05 dtM +0.0 TMax +--------------------- OUTPUTS --- +"FairTen1" +"AnchTen1" +"Point1Fx" +"Point1Fy" +"Point1Fz" +"Point2Fx" +"Point2Fy" +"Point2Fz" +--------------------- need this line --- diff --git a/tests/test_driver_channels.f90 b/tests/test_driver_channels.f90 index a938f913..41bba17e 100644 --- a/tests/test_driver_channels.f90 +++ b/tests/test_driver_channels.f90 @@ -38,6 +38,7 @@ PROGRAM test_driver_channels CALL test_finite_straight_bendmom() CALL test_motion_accel_channels() CALL test_fail_closed() + CALL test_azimuth_ranges() IF (nfail > 0) THEN WRITE (*, '(A,I0,A)') 'FAIL: ', nfail, ' assertion(s) failed' @@ -58,6 +59,12 @@ SUBROUTINE require(cond, label) END IF END SUBROUTINE require + LOGICAL FUNCTION exact(a, b) RESULT(same) + !! a equals b bit for bit (order comparisons, which -Wcompare-reals accepts). + REAL(wp), INTENT(IN) :: a, b + same = .NOT. (a < b .OR. a > b) + END FUNCTION exact + ! ---- independent reference geometry (NOT the production code) ---- REAL(wp) FUNCTION ref_curv(p1, p2, p3) RESULT(k) @@ -532,6 +539,128 @@ END SUBROUTINE read_out_table ! ---- deck fixtures ---- + ! ---- Azimuth range of a line: (-180, 180] near +X, [0, 360) otherwise ---- + + SUBROUTINE test_azimuth_ranges() + !! A line whose static chord (End A -> End B) heads within 45 deg of +X reports its tangent + !! azimuths in (-180, 180], every other line in [0, 360), so a line swaying about +X no longer + !! jumps between 0 and 360. A round-off component across the cut of the range reads on its + !! included side, and one across +X reads exactly 0. + INTEGER :: es, ok, u, ios, lineid, node, n1, n2, n3 + LOGICAL :: conv + CHARACTER(256) :: em + CHARACTER(2048) :: hdr, buf + REAL(wp) :: v(6), a3_min, a3_max, s, x, y, z, tn, cv, bm, dc, inc, az, a1_min, a1_max, a2_min, a2_max + REAL(wp), PARAMETER :: HEAD = 2.862405226111748_wp ! ATAN2(20, 400) [deg] + + CALL require(exact(tangent_azimuth_deg([1.0_wp, -1.0e-17_wp, 0.0_wp]), 0.0_wp), & + 'round-off just below +x reads exactly 0, not 360') + CALL require(exact(tangent_azimuth_deg([1.0_wp, -1.0e-17_wp, 0.0_wp], .TRUE.), 0.0_wp), & + 'round-off just below +x reads exactly 0 in the signed range') + CALL require(ABS(tangent_azimuth_deg([1.0_wp, -1.0e-3_wp, 0.0_wp]) - (360.0_wp - 1.0e-3_wp*DEG)) < 1.0e-6_wp, & + 'a heading just below +x is 359.94 deg in [0, 360)') + CALL require(ABS(tangent_azimuth_deg([1.0_wp, -1.0e-3_wp, 0.0_wp], .TRUE.) + 1.0e-3_wp*DEG) < 1.0e-6_wp, & + 'a heading just below +x is -0.057 deg in (-180, 180]') + CALL require(ABS(tangent_azimuth_deg([0.0_wp, -1.0_wp, 0.0_wp], .TRUE.) + 90.0_wp) < 1.0e-10_wp, & + 'signed azimuth -y = -90 deg') + CALL require(exact(tangent_azimuth_deg([-1.0_wp, 0.0_wp, 0.0_wp], .TRUE.), 180.0_wp), 'signed azimuth -x = 180 deg') + CALL require(exact(tangent_azimuth_deg([-1.0_wp, -1.0e-17_wp, 0.0_wp], .TRUE.), 180.0_wp), & + 'round-off just below -x reads 180 in the signed range, not -180') + + ! Three lines, each from a fairlead (End A) to an anchor 400 m away: line 1 heads 2.86 deg + ! below +X (the signed range), line 2 2.86 deg below -X and line 3 at 300 deg (the [0, 360) + ! range: 60 deg from +X). + CALL write_azimuth_deck('chan_azi.dat') + CALL CD_Run_Deck_Driver('chan_azi.dat', 'chan_azi', conv, es, em) + CALL require(es == CD_DECKDRV_OK .AND. conv, 'azimuth-range deck converged: '//TRIM(em)) + IF (es /= CD_DECKDRV_OK) RETURN + CALL read_out_table('chan_azi.out', hdr, v, 6, ok) + CALL require(ok == 0, 'read azimuth-range .out') + IF (ok /= 0) RETURN + CALL require(ABS(v(2) + HEAD) < 1.0e-6_wp, 'L1N3Azi = -2.862 deg on a line heading below +X') + CALL require(ABS(v(3) + HEAD) < 1.0e-6_wp, 'L1N1Azi = -2.862 deg at End A') + CALL require(ABS(v(4) - (180.0_wp + HEAD)) < 2.0e-5_wp, 'L2N3Azi = 182.862 deg on a line heading below -X') + CALL require(ABS(v(5) - (180.0_wp + HEAD)) < 2.0e-5_wp, 'L2N1Azi = 182.862 deg at End A') + CALL require(ABS(v(6) - 300.0_wp) < 2.0e-5_wp, 'L3N3Azi = 300 deg on a line heading 60 deg below +X') + ! The static profile reports every node of each line in the line's range. + a1_min = HUGE(1.0_wp); a1_max = -HUGE(1.0_wp); a2_min = HUGE(1.0_wp); a2_max = -HUGE(1.0_wp) + a3_min = HUGE(1.0_wp); a3_max = -HUGE(1.0_wp) + n1 = 0; n2 = 0; n3 = 0 + OPEN (NEWUNIT=u, FILE='chan_azi.static.out', STATUS='OLD', ACTION='READ', IOSTAT=ios) + CALL require(ios == 0, 'open chan_azi.static.out') + IF (ios /= 0) RETURN + DO lineid = 1, 3 + READ (u, '(A)', IOSTAT=ios) buf + END DO + DO + READ (u, '(A)', IOSTAT=ios) buf + IF (ios /= 0) EXIT + IF (LEN_TRIM(buf) == 0) CYCLE + READ (buf, *, IOSTAT=ios) lineid, node, s, x, y, z, tn, cv, bm, dc, inc, az + IF (ios /= 0) EXIT + IF (lineid == 1) THEN + n1 = n1 + 1; a1_min = MIN(a1_min, az); a1_max = MAX(a1_max, az) + ELSE IF (lineid == 2) THEN + n2 = n2 + 1; a2_min = MIN(a2_min, az); a2_max = MAX(a2_max, az) + ELSE + n3 = n3 + 1; a3_min = MIN(a3_min, az); a3_max = MAX(a3_max, az) + END IF + END DO + CLOSE (u) + CALL require(n1 == 21 .AND. n2 == 21 .AND. n3 == 21, 'static.out lists the three lines') + CALL require(ABS(a3_min - 300.0_wp) < 2.0e-5_wp .AND. ABS(a3_max - 300.0_wp) < 2.0e-5_wp, & + 'static.out Azimuth of line 3 is 300 deg at every node') + CALL require(ABS(a1_min + HEAD) < 1.0e-6_wp .AND. ABS(a1_max + HEAD) < 1.0e-6_wp, & + 'static.out Azimuth of line 1 is -2.862 deg at every node') + CALL require(ABS(a2_min - (180.0_wp + HEAD)) < 2.0e-5_wp .AND. ABS(a2_max - (180.0_wp + HEAD)) < 2.0e-5_wp, & + 'static.out Azimuth of line 2 is 182.862 deg at every node') + WRITE (*, '(A,F10.5,A,F10.5)') 'azimuth ranges: L1N3Azi=', v(2), ' L2N3Azi=', v(4) + END SUBROUTINE test_azimuth_ranges + + SUBROUTINE write_azimuth_deck(path) + !! Three EI = 0 chains on a flat seabed, each from a fairlead at the surface to an anchor 400 m + !! away horizontally: lines 1 and 2 toward +X and -X with the anchor 20 m toward -Y, line 3 + !! at 300 deg. + CHARACTER(*), INTENT(IN) :: path + INTEGER :: u, ios + OPEN (NEWUNIT=u, FILE=path, STATUS='REPLACE', ACTION='WRITE', IOSTAT=ios) + WRITE (u, '(A)') 'azimuth-range deck' + 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)') 'chain 0.252 390.0 1.674e9 -1.0 0.0 1.37 0.64 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 10.0 0.0 0.0' + WRITE (u, '(A)') '2 Fixed 410.0 -20.0 -50.0' + WRITE (u, '(A)') '3 Coupled -10.0 0.0 0.0' + WRITE (u, '(A)') '4 Fixed -410.0 -20.0 -50.0' + WRITE (u, '(A)') '5 Coupled 0.0 10.0 0.0' + WRITE (u, '(A)') '6 Fixed 200.0 -336.41016151377546 -50.0' + WRITE (u, '(A)') '--- LINES ---' + WRITE (u, '(A)') 'ID NodeA NodeB Outputs' + WRITE (u, '(A)') '(-) (-) (-) (-)' + WRITE (u, '(A)') '1 1 2 -' + WRITE (u, '(A)') '2 3 4 -' + WRITE (u, '(A)') '3 5 6 -' + WRITE (u, '(A)') '--- SECTIONS ---' + WRITE (u, '(A)') 'LineID LineType Length NumSegs' + WRITE (u, '(A)') '(-) (-) (m) (-)' + WRITE (u, '(A)') '1 chain 410.0 20' + WRITE (u, '(A)') '2 chain 410.0 20' + WRITE (u, '(A)') '3 chain 410.0 20' + WRITE (u, '(A)') '--- OPTIONS ---' + WRITE (u, '(A)') '9.80665 g' + WRITE (u, '(A)') '1025.0 rhoW' + WRITE (u, '(A)') '50.0 WtrDpth' + WRITE (u, '(A)') '1.0e5 kBot' + WRITE (u, '(A)') '--- OUTPUTS ---' + WRITE (u, '(A)') 'L1N3Azi L1N1Azi L2N3Azi L2N1Azi L3N3Azi' + WRITE (u, '(A)') '--- end ---' + CLOSE (u) + END SUBROUTINE write_azimuth_deck + SUBROUTINE write_static_channels_deck(path, explicit_decl) !! WD0050 grounded chain (EI=0 static) requesting the full geometric channel set. !! explicit_decl requests columns 4-5 by their FairDecl/AnchDecl spelling instead of the diff --git a/tests/test_flagship_compression_note.f90 b/tests/test_flagship_compression_note.f90 index 47ab8401..3b53933a 100644 --- a/tests/test_flagship_compression_note.f90 +++ b/tests/test_flagship_compression_note.f90 @@ -18,6 +18,9 @@ PROGRAM test_flagship_compression_note !! !! A deck whose finite-EI elements are shorter than sqrt(EI/EA) (the conditioning limit !! of the static Newton system) carries the fine-mesh note; the flagship does not. + !! + !! A weightless finite-EI line longer than its span, solved by weight continuation, returns + !! the note that its bow was chosen downward to the aggregate caller, which prints nothing. USE CableDyn_Precision, ONLY: wp USE CableDyn_OpenFAST_Aggregate, ONLY: CD_AGG_ModuleType, CD_AGG_Init_From_Deck, CD_AGG_End, CD_AGG_OK USE CableDyn_HermiteCableStatic, ONLY: CD_HermiteCable_Branch_Audit, CD_HermiteBranchAuditType, CD_HCSTAT_OK @@ -133,6 +136,7 @@ PROGRAM test_flagship_compression_note CALL CD_AGG_End(agg, es, em) CALL case_fine_mesh_note() + CALL case_weightless_bow_note() IF (nfail > 0) THEN WRITE (*, '(A,I0,A)') 'FAIL: ', nfail, ' flagship compression-note check(s) failed' @@ -185,6 +189,51 @@ SUBROUTINE case_fine_mesh_note() CALL CD_AGG_End(small, es_s, em_s) END SUBROUTINE case_fine_mesh_note + SUBROUTINE case_weightless_bow_note() + !! A neutrally buoyant 120 m line, EI 1e4 N m^2, pinned 113 m apart (the elastica of + !! tests/test_light_slack_statics.py). + TYPE(CD_AGG_ModuleType), SAVE :: light + INTEGER :: u, es_l + CHARACTER(512) :: em_l + OPEN (NEWUNIT=u, FILE='weightless_bow_note.dat', STATUS='REPLACE', ACTION='WRITE') + WRITE (u, '(A)') 'weightless finite-EI line longer than its span' + 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)') 'light 0.2 32.2013247 1.0e8 -1 1.0e4 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 0.0 0.0 -20.0' + WRITE (u, '(A)') '2 Fixed 80.0 0.0 -100.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 light 120.0 120' + 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)') '--- need this line ---' + CLOSE (u) + CALL CD_AGG_Init_From_Deck(light, 'weightless_bow_note.dat', 0.025_wp, es_l, em_l) + CALL check(es_l == CD_AGG_OK, 'weightless line initialises in the aggregate: '//TRIM(em_l)) + IF (es_l /= CD_AGG_OK) RETURN + IF (ALLOCATED(light%init_lines)) THEN + WRITE (*, '(2A)') ' note: ', TRIM(light%init_lines(1)%note) + CALL check(INDEX(light%init_lines(1)%note, 'is weightless and longer than its span') > 0 .AND. & + INDEX(light%init_lines(1)%note, 'bowed downward') > 0, & + 'the aggregate caller receives the weightless-bow note') + ELSE + CALL check(.FALSE., 'weightless line records its init summary') + END IF + CALL CD_AGG_End(light, es_l, em_l) + END SUBROUTINE case_weightless_bow_note + SUBROUTINE check(ok, label) LOGICAL, INTENT(IN) :: ok CHARACTER(*), INTENT(IN) :: label diff --git a/tests/test_light_slack_statics.py b/tests/test_light_slack_statics.py new file mode 100644 index 00000000..db446cf6 --- /dev/null +++ b/tests/test_light_slack_statics.py @@ -0,0 +1,201 @@ +#!/usr/bin/env python3 +# SPDX-License-Identifier: Apache-2.0 +# Copyright (c) 2026 Jae Hoon Seo, SMI Lab, Inha University +"""Static equilibrium of a finite-EI line longer than its span with little or no net weight. + +Such a line cannot hang as a catenary: it bows under the axial compression its bending stiffness +carries (the Euler elastica). Gates, each on the driver's own output files, for a 120 m line +pinned at both ends 113 m apart on a chord inclined 45 deg: + +* weightless: the line solves, the run notes that nothing chooses the plane or side of the bow, + the bow lies in the vertical plane of the chord on its lower side, and its end thrust and + mid-span bow are those of the inextensible pinned-pinned elastica (P = 4 K(m)^2 EI/L^2 and + delta = sqrt(m) L/K(m), with chord/L = 2 E(m)/K(m) - 1); so too with both ends Fixed (legal in + a deck with a dynamic point: a weighted Connect point on two chains, well clear of the line); +* light: with a net weight of +1e-3 N/m (heavy) or -1e-3 N/m (buoyant) the line solves with no + such note and bows down or up, its end forces within its whole weight of the elastica's thrust; +* dynamics: a march from the weightless equilibrium stays at rest. + +usage: test_light_slack_statics.py --exe --output +""" + +from __future__ import annotations + +import argparse +import math +import subprocess +import sys +from pathlib import Path + +import numpy as np +from scipy.optimize import brentq +from scipy.special import ellipe, ellipk + +G, RHO = 9.80665, 1025.0 +DIAM, EA, EI, LENGTH, NSEG = 0.2, 1.0e8, 1.0e4, 120.0, 120 +END_A = np.array([0.0, 0.0, -20.0]) +END_B = np.array([80.0, 0.0, -100.0]) +FAILURES: list[str] = [] + + +def check(ok: bool, message: str) -> None: + print(("PASS: " if ok else "FAIL: ") + message) + if not ok: + FAILURES.append(message) + + +def elastica() -> tuple[float, float]: + """End thrust [N] and mid-span bow [m] of the inextensible pinned-pinned elastica.""" + ratio = np.linalg.norm(END_B - END_A) / LENGTH + m = brentq(lambda m: 2.0 * ellipe(m) / ellipk(m) - 1.0 - ratio, 1.0e-12, 0.99) + k = ellipk(m) + return 4.0 * k * k * EI / LENGTH ** 2, math.sqrt(m) * LENGTH / k + + +def write_deck(path: Path, weight: float, tmax: float = 0.0, end_a: str = "Coupled") -> None: + """The line with a net weight [N/m] (0: neutrally buoyant to the 7 digits written).""" + mass = RHO * math.pi * DIAM ** 2 / 4.0 + weight / G + crowfoot = end_a == "Fixed" + if crowfoot: + tmax = max(tmax, 0.05) + outputs = ["FairTen1", "AnchTen1"] + if tmax > 0.0: + outputs += ["L1N61PX", "L1N61PY", "L1N61PZ"] + path.write_text("\n".join([ + "--------------------- CableDyn Input File ---", + "light slack finite-EI line", + "--------------------- LINE TYPES ---", + "TypeName Diam MassDenInAir EA BA EI Cd_n Cd_t Ca_n Ca_t", + "(-) (m) (kg/m) (N) (-) (Nm2) (-) (-) (-) (-)", + f"light {DIAM} {mass:.7f} {EA:.6g} -1 {EI:.6g} 1.2 0.1 1 0", + *(["chain 0.2 250.0 1.0e9 -1 0.0 1.2 0.6 1 0"] if crowfoot else []), + "--------------------- POINTS ---", + "ID Type X Y Z Mass Vol CdA Ca", + "(-) (-) (m) (m) (m) (kg) (m3) (m2) (-)", + "1 {} {:g} {:g} {:g} 0 0 0 0".format(end_a, *END_A), + "2 Fixed {:g} {:g} {:g} 0 0 0 0".format(*END_B), + *(["3 Fixed -100 300 -20 0 0 0 0", "4 Connect 0 300 -80 5000 0 0 0", + "5 Fixed 100 300 -20 0 0 0 0"] if crowfoot else []), + "--------------------- LINES ---", + "ID NodeA NodeB Outputs", + "(-) (-) (-) (-)", + "1 1 2 -", + *(["2 3 4 -", "3 5 4 -"] if crowfoot else []), + "--------------------- SECTIONS ---", + "LineID LineType Length NumSegs", + "(-) (-) (m) (-)", + f"1 light {LENGTH:g} {NSEG}", + *(["2 chain 120 20", "3 chain 120 20"] if crowfoot else []), + "--------------------- OPTIONS ---", + "9.80665 g", + "1025.0 rhoW", + "200.0 WtrDpth", + "100000.0 kBot", + "1.0e4 cBot", + "0.05 dtM", + f"{tmax:g} TMax", + "--------------------- OUTPUTS ---", + *[f'"{c}"' for c in outputs], + "--------------------- need this line ---", + "", + ])) + + +def run(exe: str, workdir: Path, name: str, weight: float, tmax: float = 0.0, end_a: str = "Coupled"): + deck = workdir / f"{name}.dat" + write_deck(deck, weight, tmax, end_a) + proc = subprocess.run([exe, deck.name, name], cwd=workdir, capture_output=True, text=True, timeout=600) + return proc.returncode, proc.stdout + proc.stderr + + +def static_profile(path: Path) -> np.ndarray: + """Rows of the static profile: node, x, y, z, tension.""" + rows = [line.split() for line in path.read_text().splitlines()[3:] if line.strip()] + return np.array([[float(r[1]), float(r[3]), float(r[4]), float(r[5]), float(r[6])] for r in rows]) + + +def time_series(path: Path) -> tuple[list[str], np.ndarray]: + """Channel names and rows of a driver .out file.""" + lines = path.read_text().splitlines() + head = next(i for i, line in enumerate(lines) if line.split() and line.split()[0].startswith("Time")) + data = np.array([[float(v) for v in line.split()] for line in lines[head + 1:] + if line.strip() and not line.lstrip().startswith("(")]) + return lines[head].split(), data + + +def bow(mid: np.ndarray) -> np.ndarray: + """Offset of the mid-span node from the chord.""" + d = (END_B - END_A) / np.linalg.norm(END_B - END_A) + mid = mid - END_A + return mid - np.dot(mid, d) * d + + +def main() -> int: + ap = argparse.ArgumentParser() + ap.add_argument("--exe", required=True) + ap.add_argument("--output", required=True) + args = ap.parse_args() + work = Path(args.output) + work.mkdir(parents=True, exist_ok=True) + thrust, delta = elastica() + print(f"elastica: thrust {thrust:.5f} N, mid-span bow {delta:.5f} m") + + for name, end_a in (("weightless", "Coupled"), ("weightless_fixed", "Fixed")): + rc, log = run(args.exe, work, name, 0.0, end_a=end_a) + check(rc == 0, f"{name} line (End A {end_a}) solves (rc {rc})") + if rc != 0: + print(log) + continue + check("is weightless and longer than its span" in log and "bowed downward" in log, + f"{name}: the run notes the weightless bow and the side it was solved on") + if end_a == "Coupled": + prof = static_profile(work / f"{name}.static.out") + in_plane = np.all(prof[:, 2] == 0.0) + mid, ends = prof[len(prof) // 2, 1:4], (prof[0, 4], prof[-1, 4]) + else: + # the multibody route writes no static profile: its first output row is the equilibrium + names, data = time_series(work / f"{name}.out") + mid = data[0, [names.index("L1N61PX"), names.index("L1N61PY"), names.index("L1N61PZ")]] + in_plane = mid[1] == 0.0 + ends = (data[0, names.index("FairTen1")], data[0, names.index("AnchTen1")]) + b = bow(mid) + check(in_plane, f"{name}: the bow lies in the vertical plane of the chord") + check(b[2] < 0.0, f"{name}: the weightless line bows downward") + check(abs(ends[0] - thrust) < 1.0e-3 * thrust and abs(ends[1] - thrust) < 1.0e-3 * thrust, + f"{name}: end thrust {ends[0]:.5f} / {ends[1]:.5f} N = elastica {thrust:.5f} N") + check(abs(np.linalg.norm(b) - delta) < 1.0e-3 * delta, + f"{name}: mid-span bow {np.linalg.norm(b):.5f} m = elastica {delta:.5f} m") + + for name, weight, down in (("light_heavy", 1.0e-3, True), ("light_buoyant", -1.0e-3, False)): + rc, log = run(args.exe, work, name, weight) + check(rc == 0, f"{name} line ({weight:+g} N/m) solves (rc {rc})") + if rc != 0: + continue + check("is weightless" not in log, f"{name}: no weightless note") + prof = static_profile(work / f"{name}.static.out") + b = bow(prof[len(prof) // 2, 1:4]) + check((b[2] < 0.0) == down, f"{name} line bows {'down' if down else 'up'}ward") + # the end forces differ from the weightless thrust by at most the line's whole weight + check(max(abs(prof[0, 4] - thrust), abs(prof[-1, 4] - thrust)) <= abs(weight) * LENGTH, + f"{name}: end forces {prof[0, 4]:.4f} / {prof[-1, 4]:.4f} N within the line's weight " + f"{abs(weight) * LENGTH:.3f} N of the elastica's thrust") + + rc, log = run(args.exe, work, "weightless_march", 0.0, tmax=2.0) + check(rc == 0, f"march from the weightless equilibrium runs (rc {rc})") + if rc == 0: + names, data = time_series(work / "weightless_march.out") + mid = data[:, [names.index("L1N61PX"), names.index("L1N61PY"), names.index("L1N61PZ")]] + drift = np.max(np.linalg.norm(mid - mid[0], axis=1)) + ten = data[:, names.index("FairTen1")] + check(drift < 1.0e-6, f"the bow stays at rest (mid-span drift {drift:.2e} m)") + check(np.max(np.abs(ten - thrust)) < 1.0e-3 * thrust, "the end thrust stays at the elastica's") + + if FAILURES: + print(f"FAIL: {len(FAILURES)} check(s) failed") + return 1 + print("PASS: light slack finite-EI statics") + return 0 + + +if __name__ == "__main__": + sys.exit(main())