diff --git a/CHANGELOG.md b/CHANGELOG.md index 1b8be54..c2cde74 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,16 @@ All notable changes to CableDyn are recorded in this file. The format follows ## [Unreleased] +### Added + +- Bending damping of finite-EI cables: the LINE TYPES EI column takes `EI|Bb`, a Kelvin-Voigt + damping moment `Bb` [N m^2 s] times the curvature rate (in the frame carried with the tangent), + or `EI|-zeta|f`, the damping ratio of a pure bending mode of frequency `f` (Bb = zeta EI/(pi f)). + A mode is damped in its bending share, `omega Bb/(2 EI) * EI k^2/(EI k^2 + T)`; free decays of a + pinned cable match this to 0.05 %. It acts on every dynamic route beside the axial (`BA`) and + torsional (`GJ|K|Bt`) damping, with exact Jacobians; the Python deck reader and builder take the + same forms. + ## [0.4.2] - 2026-11-09 ### Added diff --git a/CMakeLists.txt b/CMakeLists.txt index d92bc8c..5379d81 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -766,6 +766,19 @@ add_executable(test_hermite_axial_damping tests/test_hermite_axial_damping.f90) target_link_libraries(test_hermite_axial_damping PRIVATE cabledyn_core) add_test(NAME hermite_axial_damping COMMAND test_hermite_axial_damping) set_tests_properties(hermite_axial_damping PROPERTIES LABELS "fortran;unit;dynamic;damping") +add_executable(test_hermite_bending_damping tests/test_hermite_bending_damping.f90) +target_link_libraries(test_hermite_bending_damping PRIVATE cabledyn_core) +add_test(NAME hermite_bending_damping COMMAND test_hermite_bending_damping) +set_tests_properties(hermite_bending_damping PROPERTIES LABELS "fortran;unit;damping") +add_executable(test_hermite_bending_damping_dynamic tests/test_hermite_bending_damping_dynamic.f90) +target_link_libraries(test_hermite_bending_damping_dynamic PRIVATE cabledyn_core) +add_test(NAME hermite_bending_damping_dynamic COMMAND test_hermite_bending_damping_dynamic) +set_tests_properties(hermite_bending_damping_dynamic PROPERTIES LABELS "fortran;unit;dynamic;damping") +# Bending damping on a deck (EI|Bb, EI|-zeta|f): resolution, effect and refusals end to end. +add_executable(test_bending_damping_deck tests/test_bending_damping_deck.f90) +target_link_libraries(test_bending_damping_deck PRIVATE cabledyn_core) +add_test(NAME bending_damping_deck COMMAND test_bending_damping_deck) +set_tests_properties(bending_damping_deck PROPERTIES LABELS "fortran;driver;integration;dynamic;damping") # Active line control of a finite-EI cable: the length update rebuilds the caches a fresh # build carries (bit for bit), is atomic and rewinds exactly; hanging, taut and paid-out @@ -3436,6 +3449,9 @@ if(CABLEDYN_ENABLE_COVERAGE) test_hermite_cable_dynamic test_hermite_drag_dynamics test_hermite_axial_damping + test_hermite_bending_damping + test_hermite_bending_damping_dynamic + test_bending_damping_deck test_hermite_cable_control test_control_torsion test_hermite_added_mass diff --git a/doc/capabilities.rst b/doc/capabilities.rst index eea4aa1..f2154c4 100644 --- a/doc/capabilities.rst +++ b/doc/capabilities.rst @@ -114,6 +114,11 @@ Line and constitutive capability ``Coupled``/``Vessel`` rods, bodies other than Rigid6 and ``False alpha_force_blend``. Modal analysis carries the twist angle of every node. Not modelled: seabed friction against twist, anisotropic sections, self-contact of a loop (see :ref:`theory-torsion`) + * - Bending damping of finite-EI cables (``EI|Bb``, ``EI|-zeta|f``) + - Supported + - a bending Kelvin–Voigt damping on the curvature rate (stiffness-proportional in ``EI``; + a mode is damped in its bending share), on every dynamic route that carries the cable, + beside the axial (``BA``) and torsional (``GJ|K|Bt``) damping (:doc:`theory`) * - Hockling loops, nonlinear cross-section laws - Not provided - the buckling onset and the post-buckled shape are computed, but a loop that closes on diff --git a/doc/driver_format.md b/doc/driver_format.md index dabaf1f..e1dac70 100644 --- a/doc/driver_format.md +++ b/doc/driver_format.md @@ -238,7 +238,7 @@ Inside OUTPUTS, a row whose first token is `END` also closes the channel list. | `MassDenInAir` | dry mass per unstretched metre [kg/m] | submerged weight = (m − ρ_w·πd²/4)·g; its magnitude at most 1e6 where used | | `EA` | axial stiffness [N] | linear (T = EA·ε); at least 1e-3 and at most 1e15 where used; see the viscoelastic and Syrope forms below | | `BA/-zeta` | axial damping: ≥ 0 is BA [N·s], < 0 is −ζ (damping ratio): by default (MoorDyn's convention) of each segment, BA = ζ L0 √(EA m) per element, which damps the line's first axial mode at about ζ π/(2N) on N elements and so depends on the mesh (a run notes the ratio); under `mode1 axialDampingRatio` of the line's first axial mode, on any mesh (see the OPTIONS table) | active in EI = 0 and finite-EI dynamics; ignored in a static-only run | -| `EI` | bending stiffness [N·m²] | finite and ≥ 0; see [EI routing](#ei-routing) | +| `EI` | bending stiffness [N·m²]; `EI|Bb` or `EI|-zeta|f` adds bending damping (below) | finite and ≥ 0; see [EI routing](#ei-routing) | | `Cd_n`, `Cd_t` | normal / tangential drag coefficients | used by EI = 0 dynamic current and Airy-wave runs | | `Ca_n`, `Ca_t` | normal / tangential added-mass coefficients | used by EI = 0 dynamic Froude–Krylov and added-mass runs | @@ -278,6 +278,17 @@ cable or wire rope (`T = EA ε + K τ`, `M = GJ τ + K ε`; see active line control changes keeps its `ζ`). It needs a finite-EI type; `GJ|0|Bt` is damping without coupling. +**Bending damping.** The `EI` column may be written `EI|Bb`, with `Bb` [N·m²·s] the bending +Kelvin–Voigt damping of a finite-EI cable: a damping moment `Bb` times the rate of the curvature +vector, taken in the frame carried with the cable's tangent (see [Bending damping](theory.rst)). It +is stiffness-proportional: a bending mode of frequency `ω` whose strain energy is all bending has +the damping ratio `ω Bb/(2 EI)`, and a mode that tension also stiffens is damped only in its +bending share, `ω Bb/(2 EI) · EI k²/(EI k² + T)` for a uniform cable of wavenumber `k` under +tension `T`. `EI|-zeta|f` gives it as the damping ratio `0 < ζ < 1` of a pure bending mode of +frequency `f` [Hz], `Bb = ζ EI/(π f)`, set once per line type (it does not depend on the mesh). +`EI|0` is the plain `EI`. It needs `EI > 0` and acts in the dynamics only (a static solve has no +rates). + **Viscoelastic axial stiffness (MoorDyn `ElasticMod`).** The EA and BA columns accept bar-separated parts: diff --git a/doc/theory.rst b/doc/theory.rst index ee8f8b6..47127f0 100644 --- a/doc/theory.rst +++ b/doc/theory.rst @@ -837,6 +837,49 @@ viscoelastic or Syrope section has no single ``EA`` that sets the first mode, so and a negative ``BA`` is refused under this option; ``BA`` in N·s is used as given under both conventions. +Bending damping +~~~~~~~~~~~~~~~ + +A finite-EI cable can carry a bending Kelvin–Voigt damping (``EI|Bb`` or ``EI|-zeta|f`` in +LINE TYPES, see :doc:`file_formats`). With :math:`\mathbf{a} = \mathbf{r}_{,s}`, +:math:`\mathbf{b} = \mathbf{r}_{,ss}` and the curvature vector of the elastic energy +:math:`\boldsymbol{\kappa} = \mathbf{a}\times\mathbf{b}/\lvert\mathbf{a}\rvert^3`, the element's +dissipation function is + +.. math:: + + \psi = \int_0^{L_0} \tfrac{1}{2}\,B_b\,\lvert\mathring{\boldsymbol{\kappa}}\rvert^2\,\mathrm{d}s, + \qquad + \mathring{\boldsymbol{\kappa}} = (\mathbf{I} - \mathbf{t}\mathbf{t}^\mathsf{T})\,\dot{\boldsymbol{\kappa}}, + \qquad \mathbf{t} = \mathbf{a}/\lvert\mathbf{a}\rvert , + +and the damping force is :math:`\partial\psi/\partial\mathbf{v}`, with exact position and velocity +Jacobians. Under active line control (``CONTROL``) the curvature rate also carries the change of +the element's unstretched length, on which the shape functions depend, as the axial strain rate +does. Because :math:`\boldsymbol{\kappa}` is normal to :math:`\mathbf{t}`, +:math:`\mathring{\boldsymbol{\kappa}} = \dot{\boldsymbol{\kappa}} - (\mathbf{t}\times\dot{\mathbf{t}}) +\times\boldsymbol{\kappa}`: the curvature rate in the frame carried with the tangent by the smallest +rotation. It vanishes for a rigid motion whose rotation +is normal to the tangent and equals :math:`\dot{\boldsymbol{\kappa}}` in planar bending. Without a +twist state, a curvature that turns about the centreline cannot be told from a whirl and is damped +as one; for a rigid rotation about the tangent of a curved span (the out-of-plane swing of a +catenary) the force is of order :math:`B_b\kappa^2` and negligible against the span's inertia. + +The damping is stiffness-proportional in the bending stiffness alone. A uniform cable of tension +:math:`T` vibrating in a mode of wavenumber :math:`k` and frequency :math:`\omega` has the damping +ratio + +.. math:: + + \zeta = \frac{\omega\,B_b}{2\,EI}\;\frac{EI\,k^2}{EI\,k^2 + T} , + +the pure-bending ratio times the bending share of the modal stiffness: a tension-dominated mode is +damped much less than a bending one. ``EI|-zeta|f`` sets :math:`B_b = \zeta\,EI/(\pi f)`, the ratio +:math:`\zeta` of a pure bending mode of frequency :math:`f`. The free decay of the first mode of a +pinned cable reproduces this ratio to 0.05 % in the bending- and tension-dominated limits +(``test_hermite_bending_damping_dynamic``). The force joins the axial damping as the structural +damping load (it is in the reported end forces, not in the elastic ``BendMom`` output). + Viscoelastic rope (MoorDyn ``ElasticMod`` 2 and 3) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/python/cabledyn/builder.py b/python/cabledyn/builder.py index d73f3f3..29b3774 100644 --- a/python/cabledyn/builder.py +++ b/python/cabledyn/builder.py @@ -188,8 +188,11 @@ class LineType: viscoelastic type, or a :class:`SyropeEA`. ba : float | tuple[float, ...] Axial damping in N s (negative: damping ratio), or ``(Bs, Bd)``. - ei : float - Bending stiffness, in N m^2. + ei : float | tuple[float, ...] + Bending stiffness, in N m^2; ``(EI, Bb)`` adds the bending damping + ``Bb`` in N m^2 s (written ``EI|Bb``), and ``(EI, -zeta, f)`` gives it + as the damping ratio ``zeta`` of a bending mode of frequency ``f`` in Hz + (written ``EI|-zeta|f``; ``Bb = zeta EI / (pi f)``). cdn, cdt, can, cat : float Normal and tangential drag and added-mass coefficients. gas, gj, irt, irn : float | None @@ -211,7 +214,7 @@ class LineType: mass: float ea: float | tuple[float, ...] | SyropeEA ba: float | tuple[float, ...] = 0.0 - ei: float = 0.0 + ei: float | tuple[float, ...] = 0.0 cdn: float = 0.0 cdt: float = 0.0 can: float = 0.0 @@ -1627,7 +1630,7 @@ def add_line_type( mass: float, ea: float | tuple[float, ...] | SyropeEA, ba: float | tuple[float, ...] = 0.0, - ei: float = 0.0, + ei: float | tuple[float, ...] = 0.0, cdn: float = 0.0, cdt: float = 0.0, can: float = 0.0, @@ -2661,7 +2664,9 @@ def _line_type_table(self) -> tuple[str, str, list[list[str]]]: row.append(f'"{_render(ea)}"') else: row.append(_multi(item.ea, what)) - row += [_multi(item.ba, what), _num(item.ei, what)] + if isinstance(item.ei, tuple) and len(item.ei) not in (2, 3): + raise ValueError(f"{what}: ei is EI, (EI, Bb) or (EI, -zeta, f)") + row += [_multi(item.ba, what), _multi(item.ei, what)] extra = (item.gas, item.gj, item.irt, item.irn) if all(value is not None for value in extra): wide = True @@ -3171,7 +3176,7 @@ def line_type(self, row: DeckRecord) -> None: mass=_f(values["mass"]), ea=ea, ba=_fmulti(values["ba"]), - ei=_f(values["ei"]), + ei=_fmulti(values["ei"]), cdn=_f(values["cdn"]), cdt=_f(values["cdt"]), can=_f(values["can"]), diff --git a/python/cabledyn/deck_file.py b/python/cabledyn/deck_file.py index a6ad7d8..a69d833 100644 --- a/python/cabledyn/deck_file.py +++ b/python/cabledyn/deck_file.py @@ -3729,6 +3729,8 @@ def numeric(token: str, row: DeckRecord, field: str) -> float: for index in (1, 2, *range(5, len(row.tokens))): if len(row.tokens) == 14 and index == 7: continue # the GJ column, GJ, GJ|K or GJ|K|Bt, is read below + if index == 5: + continue # the EI column, EI, EI|Bb or EI|-zeta|f, is read below numeric(row.tokens[index], row, f"LINE TYPES column {index + 1}") ea_parts = row.tokens[3].split("|") ba_parts = row.tokens[4].split("|") @@ -3790,7 +3792,43 @@ def numeric(token: str, row: DeckRecord, field: str) -> float: f"{self._at(row)}: LINE TYPES drag and added-mass coefficients " "(Cd_n Cd_t Ca_n Ca_t) must be non-negative" ) - ei = numeric(row.tokens[5], row, "EI") + # native parse_ei_column: EI, EI|Bb (bending damping, N m^2 s) or EI|-zeta|f + ei_parts = row.tokens[5].split("|") + if len(ei_parts) > 3: + raise DeckFormatError( + f'{self._at(row)}: LINE TYPES EI column "{row.tokens[5]}" takes EI, EI|Bb ' + "or EI|-zeta|f" + ) + ei = numeric(ei_parts[0], row, "EI") + bend_damping = 0.0 + if len(ei_parts) == 2: + bend_damping = numeric(ei_parts[1], row, "EI|Bb damping") + if bend_damping < 0.0: + raise DeckFormatError( + f'{self._at(row)}: LINE TYPES EI column "{row.tokens[5]}": a negative ' + "bending damping is -zeta and needs the frequency it holds at, EI|-zeta|f" + ) + elif len(ei_parts) == 3: + ratio = numeric(ei_parts[1], row, "EI|-zeta|f ratio") + frequency = numeric(ei_parts[2], row, "EI|-zeta|f frequency") + if not -1.0 < ratio < 0.0: + raise DeckFormatError( + f'{self._at(row)}: LINE TYPES EI column "{row.tokens[5]}": ' + "EI|-zeta|f takes a damping ratio 0 < zeta < 1, written negative" + ) + if not frequency > 0.0: + raise DeckFormatError( + f'{self._at(row)}: LINE TYPES EI column "{row.tokens[5]}": the frequency f ' + "of EI|-zeta|f must be positive [Hz]" + ) + bend_damping = -ratio * ei / (math.pi * frequency) + # a damping asked for (the ratio form, or Bb > 0) needs a finite EI: on EI = 0 the + # ratio form resolves to Bb = 0 and would pass unnoticed + if (len(ei_parts) == 3 or bend_damping > 0.0) and not ei > 0.0: + raise DeckFormatError( + f"{self._at(row)}: LINE TYPES {row.tokens[0]}: bending damping (EI|Bb) needs " + "a finite-EI cable (EI > 0)" + ) if len(row.tokens) in (11, 13): # Native check_viv_columns: MoorDyn's cross-flow VIV columns Cl [dF cF] cl = numeric(row.tokens[10], row, "Cl") diff --git a/python/tests/test_builder.py b/python/tests/test_builder.py index 8685f60..ea6f060 100644 --- a/python/tests/test_builder.py +++ b/python/tests/test_builder.py @@ -994,6 +994,28 @@ def test_torsional_damping_round_trips_in_the_gj_column(tmp_path: Path) -> None: assert next(t for t in loaded.line_types if t.name == "cable").gj == (1.0e4, 0.0, -0.02) +@pytest.mark.parametrize("ei", [(1.0e4, 250.0), (1.0e4, -0.02, 1.5)]) +def test_bending_damping_round_trips_in_the_ei_column( + tmp_path: Path, ei: tuple[float, ...] +) -> None: + model = _chain_model(tmp_path) + cable = model.add_line_type("cable", diam=0.2, mass=40.0, ea=5.0e8, ei=ei) + assert cable.ei == ei + target = model.save(tmp_path / "bend_damped.dat") + deck = DeckFile.read(target) + row = next(r for r in deck.line_types if r.tokens[0] == "cable") + assert tuple(float(v) for v in row.tokens[5].split("|")) == ei + loaded = DeckModel.load(target) + assert next(t for t in loaded.line_types if t.name == "cable").ei == ei + + +def test_bending_damping_ei_tuple_length_is_checked(tmp_path: Path) -> None: + model = _chain_model(tmp_path) + model.add_line_type("cable", diam=0.2, mass=40.0, ea=5.0e8, ei=(1.0e4, 1.0, 2.0, 3.0)) + with pytest.raises(ValueError, match=r"ei is EI, \(EI, Bb\) or \(EI, -zeta, f\)"): + model.to_text() + + @pytest.mark.parametrize( ("gj", "ei", "message"), [ diff --git a/python/tests/test_deck_native_parity.py b/python/tests/test_deck_native_parity.py index 29f8c80..c2c839a 100644 --- a/python/tests/test_deck_native_parity.py +++ b/python/tests/test_deck_native_parity.py @@ -953,6 +953,36 @@ def test_stiffener_rows_are_native(row, message): _rejects(_example("lazy_wave_bend_stiffener.dat", (_STIFFENER_ROOT, row)), message) +_BARE_ROW = "bare 0.160 36.70 4.69e8 0.0 1.99e4 1.2 0.1 1.0 0.0" + + +@pytest.mark.parametrize( + "ei", + ["1.99e4|250.0", "1.99e4|0", "1.99e4|-0.02|1.5"], +) +def test_bending_damping_forms_are_accepted(ei): + DeckFile.from_text( + _example("lazy_wave_bend_stiffener.dat", (_BARE_ROW, _BARE_ROW.replace("1.99e4", ei, 1))) + ) + + +@pytest.mark.parametrize( + ("ei", "message"), + [ + ("1.99e4|1|2|3", "takes EI, EI|Bb or EI|-zeta|f"), + ("1.99e4|-250.0", "a negative bending damping is -zeta and needs the frequency"), + ("1.99e4|0.02|1.5", "takes a damping ratio 0 < zeta < 1, written negative"), + ("1.99e4|-1.5|1.5", "takes a damping ratio 0 < zeta < 1, written negative"), + ("1.99e4|-0.02|0", "of EI|-zeta|f must be positive"), + ("0.0|250.0", "bending damping (EI|Bb) needs a finite-EI cable"), + ("0.0|-0.05|0.5", "bending damping (EI|Bb) needs a finite-EI cable"), + ], +) +def test_bending_damping_rows_are_native(ei, message): + text = _example("lazy_wave_bend_stiffener.dat", (_BARE_ROW, _BARE_ROW.replace("1.99e4", ei, 1))) + _rejects(text, re.escape(message)) + + def test_stiffener_needs_a_finite_ei_line(): text = _section(_HELD, "STIFFENERS", "1 A 1.0 0.5 0.5 0.3 5.0e7 1150") _rejects(text, "STIFFENERS name line 1, which is not a finite-EI line") diff --git a/src/CableDyn_DeckDriver.f90 b/src/CableDyn_DeckDriver.f90 index ad250b7..fb42057 100644 --- a/src/CableDyn_DeckDriver.f90 +++ b/src/CableDyn_DeckDriver.f90 @@ -122,7 +122,7 @@ MODULE CableDyn_DeckDriver CD_Vessel_RAO_Motion, CD_Vessel_Ramp, CD_VESSEL_OK USE CableDyn_OpenFAST_HermiteFMF, ONLY: CD_HFMF_ModuleType, CD_HFMF_Init, CD_HFMF_Set_Drag, & CD_HFMF_Set_Section_Reference, CD_HFMF_Section_Curvature, & - CD_HFMF_Set_Axial_Damping, & + CD_HFMF_Set_Axial_Damping, CD_HFMF_Set_Bending_Damping, & CD_HFMF_Set_AddedMass, CD_HFMF_Set_ModifiedNewton, & CD_HFMF_Set_Tensile_Monitor, CD_HFMF_Get_Tensile_Diagnostics, & CD_HFMF_Get_Recovery_Diagnostics, & @@ -411,6 +411,10 @@ MODULE CableDyn_DeckDriver ! damping l0 sqrt(GJ Irn), resolved on the final mesh (and again at the lengths active line ! control sets) REAL(wp) :: bt = CD_ZERO + ! bending damping Bb [N m^2 s] of the EI column's second part (EI|Bb): the moment Bb times the + ! curvature rate (CD_HermiteCable_Bending_Damping), resolved from EI|-zeta|f (zeta at the + ! frequency f [Hz] of a bending mode, Bb = zeta EI/(pi f)) when the row gives a ratio + REAL(wp) :: bb = CD_ZERO REAL(wp) :: i_rt = CD_ZERO, i_rn = CD_ZERO REAL(wp) :: cdn = CD_ZERO, cdt = CD_ZERO, can = CD_ZERO, cat = CD_ZERO ! Viscoelastic stiffness (MoorDyn ElasticMod): the EA column's bar-separated @@ -1874,7 +1878,7 @@ RECURSIVE SUBROUTINE build_one_hermite_cable(ln, sections, types, points, opts, REAL(wp), ALLOCATABLE :: q_sequence(:) REAL(wp), ALLOCATABLE :: curv(:), cdn(:), cdt(:), can(:), cat(:), catenary_pos(:) REAL(wp), ALLOCATABLE :: viv_cl(:), viv_cf(:), viv_df(:) - REAL(wp), ALLOCATABLE :: ba_raw(:), ba(:), dry_b(:) + REAL(wp), ALLOCATABLE :: ba_raw(:), ba(:), dry_b(:), bb_el(:) REAL(wp) :: mode1_omega REAL(wp), ALLOCATABLE :: contact_kn(:), contact_cn(:) REAL(wp) :: anchor(3), fairlead(3), res, tvec(3), tnrm, contact_z, seed_z, seed_floor_a, seed_floor_b @@ -2216,6 +2220,8 @@ RECURSIVE SUBROUTINE build_one_hermite_cable(ln, sections, types, points, opts, IF (LEN_TRIM(fine_note) > 0 .AND. standalone_mode) WRITE (error_unit, '(A)') ' Note: '//TRIM(fine_note)//'.' ALLOCATE (ba_raw(SIZE(l0))) CALL finite_raw_ba_array(ln, sections, types, ba_raw) + ALLOCATE (bb_el(SIZE(l0))) + CALL finite_bb_array(ln, sections, types, bb_el) nnode = SIZE(l0) + 1 ndof = 6*nnode ALLOCATE (w(SIZE(l0)), nodes_ref(3, nnode), q0(ndof)) @@ -3280,6 +3286,7 @@ RECURSIVE SUBROUTINE build_one_hermite_cable(ln, sections, types, points, opts, CALL remap_elem_by_reference_arc(can, l0, l0_am) CALL remap_elem_by_reference_arc(cat, l0, l0_am) CALL remap_elem_by_reference_arc(ba_raw, l0, l0_am) + CALL remap_elem_by_reference_arc(bb_el, l0, l0_am) IF (ALLOCATED(ei_cable)) CALL remap_elem_by_reference_arc(ei_cable, l0, l0_am) END IF ! The node output channels read deck nodes: map each onto the final mesh (set on the cable @@ -3454,6 +3461,12 @@ RECURSIVE SUBROUTINE build_one_hermite_cable(ln, sections, types, points, opts, CALL fail(ErrStat, ErrMsg, 'finite-EI cable axial-damping wiring failed: '//TRIM(em)); RETURN END IF END IF + IF (ANY(bb_el > CD_ZERO)) THEN + CALL CD_HFMF_Set_Bending_Damping(cable, bb_el, es, em) + IF (es /= CD_HFMF_OK) THEN + CALL fail(ErrStat, ErrMsg, 'finite-EI cable bending-damping wiring failed: '//TRIM(em)); RETURN + END IF + END IF IF (ANY(endconn_mode /= CD_ENDCONN_PINNED)) THEN ! a connected moving End B is attached to its own parent (end_b_d0_parent), as End A to its IF (moving_b .AND. endconn_mode(1) /= CD_ENDCONN_PINNED .AND. endconn_mode(2) /= CD_ENDCONN_PINNED) THEN @@ -11473,6 +11486,24 @@ SUBROUTINE finite_raw_ba_array(ln, sections, types, ba_raw) ba_raw = ba_raw(SIZE(ba_raw):1:-1) END SUBROUTINE finite_raw_ba_array + SUBROUTINE finite_bb_array(ln, sections, types, bb) + !! The line types' bending damping Bb [N m^2 s] on the deck elements (internal order). + TYPE(DeckLine), INTENT(IN) :: ln + TYPE(DeckSection), INTENT(IN) :: sections(:) + TYPE(DeckLineType), INTENT(IN) :: types(:) + REAL(wp), INTENT(OUT) :: bb(:) + INTEGER :: i, j, e + e = 0 + DO i = 1, SIZE(sections) + IF (sections(i)%line_id /= ln%id) CYCLE + DO j = 1, sections(i)%nsegs + e = e + 1 + bb(e) = types(sections(i)%ltype)%bb + END DO + END DO + bb = bb(SIZE(bb):1:-1) + END SUBROUTINE finite_bb_array + SUBROUTINE finite_line_type_ei(ln, sections, types, ei) !! The line types' own bending stiffness on the deck elements (internal order), without !! any STIFFENERS sleeve. @@ -15615,6 +15646,74 @@ SUBROUTINE sniff_types_header(line, stock_cols) END IF END SUBROUTINE sniff_types_header + SUBROUTINE parse_ei_column(ei_str, t, ErrStat, ErrMsg) + !! The LINE TYPES EI column: EI, EI|Bb with Bb >= 0 the bending damping [N m^2 s] (the moment + !! Bb times the curvature rate), or EI|-zeta|f with 0 < zeta < 1 the damping ratio of a bending + !! mode of frequency f [Hz] whose energy is all bending, Bb = zeta EI/(pi f). Bending damping + !! needs a finite-EI cable (EI > 0). + CHARACTER(*), INTENT(IN) :: ei_str + TYPE(DeckLineType), INTENT(INOUT) :: t + INTEGER, INTENT(OUT) :: ErrStat + CHARACTER(*), INTENT(OUT) :: ErrMsg + INTEGER :: bar, bar2, ios + REAL(wp) :: second, freq + REAL(wp), PARAMETER :: PI_L = 3.14159265358979323846_wp + ErrStat = 0; ErrMsg = '' + t%bb = CD_ZERO + second = CD_ZERO + freq = CD_ZERO + bar = INDEX(ei_str, '|') + bar2 = 0 + IF (bar == 0) THEN + READ (ei_str, *, IOSTAT=ios) t%ei + ELSE + bar2 = INDEX(ei_str(bar + 1:), '|') + IF (bar2 > 0) THEN + bar2 = bar + bar2 + IF (INDEX(ei_str(bar2 + 1:), '|') > 0) THEN + CALL fail(ErrStat, ErrMsg, 'LINE TYPES EI column "'//TRIM(ei_str)//'" takes EI, EI|Bb or EI|-zeta|f'); RETURN + END IF + END IF + READ (ei_str(1:bar - 1), *, IOSTAT=ios) t%ei + IF (bar2 > 0) THEN + IF (ios == 0) READ (ei_str(bar + 1:bar2 - 1), *, IOSTAT=ios) second + IF (ios == 0) READ (ei_str(bar2 + 1:), *, IOSTAT=ios) freq + ELSE + IF (ios == 0) READ (ei_str(bar + 1:), *, IOSTAT=ios) second + END IF + END IF + IF (ios /= 0) THEN + CALL fail(ErrStat, ErrMsg, 'LINE TYPES EI column "'//TRIM(ei_str)//'" is not EI, EI|Bb or EI|-zeta|f'); RETURN + END IF + IF (.NOT. (IEEE_IS_FINITE(t%ei) .AND. IEEE_IS_FINITE(second) .AND. IEEE_IS_FINITE(freq))) THEN + CALL fail(ErrStat, ErrMsg, 'LINE TYPES EI column "'//TRIM(ei_str)//'" must be finite'); RETURN + END IF + IF (bar == 0) RETURN + IF (bar2 == 0) THEN + IF (second < CD_ZERO) THEN + CALL fail(ErrStat, ErrMsg, 'LINE TYPES EI column "'//TRIM(ei_str)//'": a negative bending damping is '// & + '-zeta and needs the frequency it holds at, EI|-zeta|f'); RETURN + END IF + t%bb = second + ELSE + IF (.NOT. (second < CD_ZERO .AND. second > -CD_ONE)) THEN + CALL fail(ErrStat, ErrMsg, 'LINE TYPES EI column "'//TRIM(ei_str)//'": EI|-zeta|f takes a damping '// & + 'ratio 0 < zeta < 1, written negative'); RETURN + END IF + IF (.NOT. (freq > CD_ZERO)) THEN + CALL fail(ErrStat, ErrMsg, 'LINE TYPES EI column "'//TRIM(ei_str)//'": the frequency f of '// & + 'EI|-zeta|f must be positive [Hz]'); RETURN + END IF + t%bb = -second*t%ei/(PI_L*freq) + END IF + ! a damping asked for (a ratio form, or Bb > 0) needs a finite EI: on EI = 0 the ratio form would + ! resolve to Bb = 0 and the request would pass unnoticed + IF ((bar2 > 0 .OR. t%bb > CD_ZERO) .AND. .NOT. (t%ei > CD_ZERO)) THEN + CALL fail(ErrStat, ErrMsg, 'LINE TYPES '//TRIM(t%name)//': bending damping (EI|Bb) needs a '// & + 'finite-EI cable (EI > 0)'); RETURN + END IF + END SUBROUTINE parse_ei_column + SUBROUTINE parse_gj_column(gj_str, t, ErrStat, ErrMsg) !! The 14-column row's GJ column: GJ, GJ|K with K the torque-tension coupling [N m] !! (M = GJ tau + K eps, T = EA eps + K tau; K > 0 when stretching the cable twists it in the @@ -15664,7 +15763,7 @@ SUBROUTINE append_type(line, types, nt, stock_cols, ErrStat, ErrMsg) TYPE(DeckLineType) :: t ! EA may hold SYROPE:|alpha|beta, so it gets a path-length buffer CHARACTER(CD_DECK_PATHLEN) :: ea_str - CHARACTER(NAMELEN) :: ba_str, gj_str + CHARACTER(NAMELEN) :: ba_str, gj_str, ei_str INTEGER :: ios, ntok ErrStat = 0; ErrMsg = '' ntok = count_tokens(line) @@ -15679,25 +15778,25 @@ SUBROUTINE append_type(line, types, nt, stock_cols, ErrStat, ErrMsg) IF (ntok == 10) THEN IF (stock_cols) THEN ! stock MoorDyn header order: Cd Ca CdAx CaAx = (Cd_n, Ca_n, Cd_t, Ca_t) - READ (line, *, IOSTAT=ios) t%name, t%diam, t%mass, ea_str, ba_str, t%ei, t%cdn, t%can, t%cdt, t%cat + READ (line, *, IOSTAT=ios) t%name, t%diam, t%mass, ea_str, ba_str, ei_str, t%cdn, t%can, t%cdt, t%cat ELSE - READ (line, *, IOSTAT=ios) t%name, t%diam, t%mass, ea_str, ba_str, t%ei, t%cdn, t%cdt, t%can, t%cat + READ (line, *, IOSTAT=ios) t%name, t%diam, t%mass, ea_str, ba_str, ei_str, t%cdn, t%cdt, t%can, t%cat END IF ELSE IF (ntok == 11 .OR. ntok == 13) THEN ! MoorDyn v2's optional cross-flow VIV columns after the ten standard ones: Cl, or ! Cl dF cF (MoorDyn.f90 line-type parse; dF and cF default to 0.08 and 0.18) IF (stock_cols) THEN IF (ntok == 11) THEN - READ (line, *, IOSTAT=ios) t%name, t%diam, t%mass, ea_str, ba_str, t%ei, t%cdn, t%can, t%cdt, t%cat, t%cl + READ (line, *, IOSTAT=ios) t%name, t%diam, t%mass, ea_str, ba_str, ei_str, t%cdn, t%can, t%cdt, t%cat, t%cl ELSE - READ (line, *, IOSTAT=ios) t%name, t%diam, t%mass, ea_str, ba_str, t%ei, t%cdn, t%can, t%cdt, t%cat, & + READ (line, *, IOSTAT=ios) t%name, t%diam, t%mass, ea_str, ba_str, ei_str, t%cdn, t%can, t%cdt, t%cat, & t%cl, t%viv_df, t%viv_cf END IF ELSE IF (ntok == 11) THEN - READ (line, *, IOSTAT=ios) t%name, t%diam, t%mass, ea_str, ba_str, t%ei, t%cdn, t%cdt, t%can, t%cat, t%cl + READ (line, *, IOSTAT=ios) t%name, t%diam, t%mass, ea_str, ba_str, ei_str, t%cdn, t%cdt, t%can, t%cat, t%cl ELSE - READ (line, *, IOSTAT=ios) t%name, t%diam, t%mass, ea_str, ba_str, t%ei, t%cdn, t%cdt, t%can, t%cat, & + READ (line, *, IOSTAT=ios) t%name, t%diam, t%mass, ea_str, ba_str, ei_str, t%cdn, t%cdt, t%can, t%cat, & t%cl, t%viv_df, t%viv_cf END IF END IF @@ -15706,12 +15805,14 @@ SUBROUTINE append_type(line, types, nt, stock_cols, ErrStat, ErrMsg) CALL fail(ErrStat, ErrMsg, 'the 14-column LINE TYPES row is a CableDyn form (... Cd_n Cd_t '// & 'Ca_n Ca_t); it does not combine with a stock-order header (Cd Ca CdAx CaAx)'); RETURN END IF - READ (line, *, IOSTAT=ios) t%name, t%diam, t%mass, ea_str, ba_str, t%ei, t%gas, gj_str, t%i_rt, t%i_rn, & + READ (line, *, IOSTAT=ios) t%name, t%diam, t%mass, ea_str, ba_str, ei_str, t%gas, gj_str, t%i_rt, t%i_rn, & t%cdn, t%cdt, t%can, t%cat END IF IF (ios /= 0) THEN CALL fail(ErrStat, ErrMsg, 'malformed LINE TYPES row'); RETURN END IF + CALL parse_ei_column(ei_str, t, ErrStat, ErrMsg) + IF (ErrStat /= 0) RETURN IF (ntok == 14) THEN CALL parse_gj_column(gj_str, t, ErrStat, ErrMsg) IF (ErrStat /= 0) RETURN diff --git a/src/CableDyn_HermiteCable.f90 b/src/CableDyn_HermiteCable.f90 index dc62e17..39c0846 100644 --- a/src/CableDyn_HermiteCable.f90 +++ b/src/CableDyn_HermiteCable.f90 @@ -44,6 +44,7 @@ MODULE CableDyn_HermiteCable PUBLIC :: CD_HermiteCable_Shapes PUBLIC :: CD_HermiteCable_Gauss_Rule PUBLIC :: CD_HermiteCable_Dry_Buoyancy + PUBLIC :: CD_HermiteCable_Bending_Damping INTEGER, PARAMETER, PUBLIC :: CD_HCABLE_OK = 0, CD_HCABLE_BADINPUT = 1 INTEGER, PARAMETER :: NG = 4 !! default Gauss points per element @@ -380,6 +381,240 @@ END SUBROUTINE fail END SUBROUTINE hermite_element_integrated + SUBROUTINE CD_HermiteCable_Bending_Damping(qr, vr, L, Bb, fdamp, Kq, Kv, ErrStat, ErrMsg, quadrature_order, & + l0_dot) + !! Kelvin-Voigt bending damping of one cubic-Hermite element: the dissipation function + !! psi = integral_0^L 1/2 Bb |kdot|^2 ds, kdot = (I - t t^T) d kappa/dt, + !! with kappa = (a x b)/|a|^3 the curvature vector of the elastic energy (a = dr/ds, + !! b = d^2r/ds^2, s the unstretched arc length) and t = a/|a| the unit tangent. kdot is the + !! curvature rate convected with the tangent by the smallest rotation: since kappa is normal + !! to t, (I - t t^T) dkappa/dt = dkappa/dt - (t x dt/dt) x kappa. It is zero for every rigid + !! motion whose rotation is normal to the tangent and equals dkappa/dt in planar bending; a + !! rotation about the tangent itself (a curvature that turns about the centreline) cannot be + !! told from a whirl without a twist state and is damped as one. A bending mode of frequency + !! omega whose energy is all bending has the damping ratio omega Bb / (2 EI). + !! + !! fdamp = d psi / d v is an INTERNAL generalised force (v . fdamp >= 0); Kq = d fdamp/dq + !! and Kv = d fdamp/dv are the exact Jacobians (Kq is not symmetric in general). qr and vr + !! are the element DOFs [r1, m1, r2, m2] and their rates; L the unstretched length; Bb >= 0 + !! [N m^2 s]. + !! + !! l0_dot (optional): the unstretched-length rate of an element under active line control. The + !! shape functions depend on L: a = p/L + g and b = P/L^2 + G/L, with p, P the end-position parts + !! and g, G the tangent-handle parts, so at fixed DOFs a changes at -(L'/L) a_pos and b at + !! -(L'/L)(2 b_pos + b_tan). These join the rates of a and b, and their dependence on the end + !! positions and tangent handles joins Kq; Kv is unchanged. + REAL(wp), INTENT(IN) :: qr(12), vr(12), L, Bb + REAL(wp), INTENT(OUT) :: fdamp(12) + REAL(wp), INTENT(OUT), OPTIONAL :: Kq(12, 12), Kv(12, 12) + INTEGER, INTENT(OUT) :: ErrStat + CHARACTER(*), INTENT(OUT) :: ErrMsg + INTEGER, INTENT(IN), OPTIONAL :: quadrature_order + REAL(wp), INTENT(IN), OPTIONAL :: l0_dot + + REAL(wp) :: gp(MAX_NG), gw(MAX_NG), H(4), dH(4), ddH(4), b1(4), b2(4), rho, ca(4), cb(4) + REAL(wp) :: av(3), bv(3), ad(3), bd(3), xd(6), cr(3), tv(3), s2, sp, g, ga, gaa2 + REAL(wp) :: Dcr(3, 6), Dg(6), J(3, 6), Pm(3, 3), Km(3, 6), kr(3), dK(3, 6, 6), T(3, 6, 6), dP(3, 3, 3) + REAL(wp) :: g6(6), Q6(6, 6), V6(6, 6), a6(6), wgL, w11, w12, w21, w22, acc, dik, dmk + INTEGER :: order, qg, i, jj, k, m, c, dd, ic, jc, kn, mn + INTEGER, PARAMETER :: sd(4) = [0, 3, 6, 9] + LOGICAL :: has_rate + + ErrStat = CD_HCABLE_OK + ErrMsg = '' + fdamp = CD_ZERO + IF (PRESENT(Kq)) Kq = CD_ZERO + IF (PRESENT(Kv)) Kv = CD_ZERO + order = NG + IF (PRESENT(quadrature_order)) order = quadrature_order + IF (.NOT. CD_All_Finite(qr) .OR. .NOT. CD_All_Finite(vr) .OR. .NOT. CD_Is_Finite(L) .OR. & + .NOT. CD_Is_Finite(Bb)) THEN + CALL fail('inputs must be finite'); RETURN + END IF + IF (L <= GEOM_TOL) THEN + CALL fail('element length must be positive'); RETURN + END IF + IF (Bb < CD_ZERO) THEN + CALL fail('Bb must be non-negative'); RETURN + END IF + IF (order < 1 .OR. order > MAX_NG) THEN + CALL fail('quadrature_order must lie in [1,6]'); RETURN + END IF + rho = CD_ZERO + IF (PRESENT(l0_dot)) THEN + IF (.NOT. CD_Is_Finite(l0_dot)) THEN + CALL fail('l0_dot must be finite'); RETURN + END IF + rho = l0_dot/L + END IF + has_rate = ABS(rho) > CD_ZERO + IF (.NOT. (Bb > CD_ZERO)) RETURN + + CALL CD_HermiteCable_Gauss_Rule(order, gp, gw) + V6 = CD_ZERO + Q6 = CD_ZERO + DO qg = 1, order + CALL hermite_shapes(gp(qg), L, H, dH, ddH) + b1 = dH/L + b2 = ddH/(L*L) + DO c = 1, 3 + av(c) = SUM(b1*qr(sd + c)); bv(c) = SUM(b2*qr(sd + c)) + ad(c) = SUM(b1*vr(sd + c)); bd(c) = SUM(b2*vr(sd + c)) + END DO + ! the length-rate weights of the effective rates: d a/dt -= rho sum_k ca(k) q_k and + ! d b/dt -= rho sum_k cb(k) q_k (end positions k = 1, 3; tangent handles k = 2, 4) + ca = [b1(1), CD_ZERO, b1(3), CD_ZERO] + cb = [2.0_wp*b2(1), b2(2), 2.0_wp*b2(3), b2(4)] + IF (has_rate) THEN + DO c = 1, 3 + ad(c) = ad(c) - rho*SUM(ca*qr(sd + c)) + bd(c) = bd(c) - rho*SUM(cb*qr(sd + c)) + END DO + END IF + xd(1:3) = ad; xd(4:6) = bd + s2 = SUM(av*av) + IF (s2 <= GEOM_TOL*GEOM_TOL) THEN + CALL fail('degenerate centreline: |dr/ds| ~ 0 at a Gauss point'); RETURN + END IF + sp = SQRT(s2) + tv = av/sp + g = CD_ONE/(sp*s2) ! |a|^-3 + ga = -3.0_wp/(s2*s2*sp) ! d g/d a = ga a; d2 g/da da = ga I + gaa2 a a^T + gaa2 = 15.0_wp/(s2*s2*s2*sp) + cr = [av(2)*bv(3) - av(3)*bv(2), av(3)*bv(1) - av(1)*bv(3), av(1)*bv(2) - av(2)*bv(1)] + ! first derivatives: d cr/d a = -[b]x, d cr/d b = [a]x + Dcr(:, 1:3) = -skew(bv) + Dcr(:, 4:6) = skew(av) + Dg = CD_ZERO + Dg(1:3) = ga*av + a6 = CD_ZERO + a6(1:3) = av + DO jj = 1, 6 + J(:, jj) = Dcr(:, jj)*g + cr*Dg(jj) + END DO + ! second derivatives of kappa = cr g: T(i,j,k) = d2 kappa_i / dx_j dx_k, x = (a, b) + DO k = 1, 6 + DO jj = 1, 6 + DO i = 1, 3 + acc = Dcr(i, jj)*Dg(k) + Dcr(i, k)*Dg(jj) + IF (jj <= 3 .AND. k >= 4) acc = acc + levi(i, jj, k - 3)*g + IF (jj >= 4 .AND. k <= 3) acc = acc + levi(i, k, jj - 3)*g + IF (jj <= 3 .AND. k <= 3) THEN + acc = acc + cr(i)*gaa2*a6(jj)*a6(k) + IF (jj == k) acc = acc + cr(i)*ga + END IF + T(i, jj, k) = acc + END DO + END DO + END DO + ! projector P = I - t t^T and dP(i,m,k) = d P_im / d a_k (zero for b) + DO m = 1, 3 + DO i = 1, 3 + Pm(i, m) = -tv(i)*tv(m) + END DO + Pm(m, m) = Pm(m, m) + CD_ONE + END DO + DO k = 1, 3 + DO m = 1, 3 + DO i = 1, 3 + dik = CD_ZERO; IF (i == k) dik = CD_ONE + dmk = CD_ZERO; IF (m == k) dmk = CD_ONE + dP(i, m, k) = -(((dik - tv(i)*tv(k))/sp)*tv(m) + tv(i)*((dmk - tv(m)*tv(k))/sp)) + END DO + END DO + END DO + Km = MATMUL(Pm, J) + kr = MATMUL(Km, xd) + ! dK(i,j,k) = d K_ij / d x_k = sum_m dP(i,m,k) J(m,j) + sum_m P(i,m) T(m,j,k) + DO k = 1, 6 + DO jj = 1, 6 + DO i = 1, 3 + acc = SUM(Pm(i, :)*T(:, jj, k)) + IF (k <= 3) acc = acc + SUM(dP(i, :, k)*J(:, jj)) + dK(i, jj, k) = acc + END DO + END DO + END DO + g6 = Bb*MATMUL(TRANSPOSE(Km), kr) + IF (PRESENT(Kv) .OR. (PRESENT(Kq) .AND. has_rate)) V6 = Bb*MATMUL(TRANSPOSE(Km), Km) + IF (PRESENT(Kq)) THEN + ! d (K^T K xd)_j / d x_k = sum_i dK(i,j,k) kr_i + K_ij sum_l dK(i,l,k) xd_l + DO k = 1, 6 + DO jj = 1, 6 + acc = CD_ZERO + DO i = 1, 3 + acc = acc + dK(i, jj, k)*kr(i) + Km(i, jj)*SUM(dK(i, :, k)*xd) + END DO + Q6(jj, k) = Bb*acc + END DO + END DO + END IF + wgL = gw(qg)*L + DO kn = 1, 4 + DO c = 1, 3 + ic = sd(kn) + c + fdamp(ic) = fdamp(ic) + wgL*(b1(kn)*g6(c) + b2(kn)*g6(3 + c)) + END DO + END DO + IF (.NOT. (PRESENT(Kq) .OR. PRESENT(Kv))) CYCLE + DO mn = 1, 4 + DO kn = 1, 4 + w11 = wgL*b1(kn)*b1(mn); w12 = wgL*b1(kn)*b2(mn) + w21 = wgL*b2(kn)*b1(mn); w22 = wgL*b2(kn)*b2(mn) + DO dd = 1, 3 + jc = sd(mn) + dd + DO c = 1, 3 + ic = sd(kn) + c + IF (PRESENT(Kq)) THEN + Kq(ic, jc) = Kq(ic, jc) + w11*Q6(c, dd) + w12*Q6(c, 3 + dd) & + + w21*Q6(3 + c, dd) + w22*Q6(3 + c, 3 + dd) + ! the effective rates' dependence on the DOFs under a length rate + IF (has_rate) Kq(ic, jc) = Kq(ic, jc) - rho*wgL* & + ((b1(kn)*V6(c, dd) + b2(kn)*V6(3 + c, dd))*ca(mn) + & + (b1(kn)*V6(c, 3 + dd) + b2(kn)*V6(3 + c, 3 + dd))*cb(mn)) + END IF + IF (PRESENT(Kv)) Kv(ic, jc) = Kv(ic, jc) + w11*V6(c, dd) + w12*V6(c, 3 + dd) & + + w21*V6(3 + c, dd) + w22*V6(3 + c, 3 + dd) + END DO + END DO + END DO + END DO + END DO + IF (.NOT. CD_All_Finite(fdamp)) THEN + CALL fail('non-finite bending damping force'); RETURN + END IF + IF (PRESENT(Kq)) THEN + IF (.NOT. CD_All_Finite(Kq)) THEN + CALL fail('non-finite bending damping Jacobian'); RETURN + END IF + END IF + + CONTAINS + + PURE FUNCTION skew(v) RESULT(s) + !! [v]x, so that skew(v) u = v x u + REAL(wp), INTENT(IN) :: v(3) + REAL(wp) :: s(3, 3) + s = RESHAPE([CD_ZERO, v(3), -v(2), -v(3), CD_ZERO, v(1), v(2), -v(1), CD_ZERO], [3, 3]) + END FUNCTION skew + + PURE REAL(wp) FUNCTION levi(i, jj, k) + !! Levi-Civita symbol for indices in 1..3 + INTEGER, INTENT(IN) :: i, jj, k + levi = REAL((i - jj)*(jj - k)*(k - i), wp)/2.0_wp + END FUNCTION levi + + SUBROUTINE fail(msg) + CHARACTER(*), INTENT(IN) :: msg + ErrStat = CD_HCABLE_BADINPUT + ErrMsg = 'CD_HermiteCable_Bending_Damping: '//msg + fdamp = CD_ZERO + IF (PRESENT(Kq)) Kq = CD_ZERO + IF (PRESENT(Kv)) Kv = CD_ZERO + END SUBROUTINE fail + + END SUBROUTINE CD_HermiteCable_Bending_Damping + SUBROUTINE CD_HermiteCable_Mass(rho_a, L, M, ErrStat, ErrMsg) !! Consistent (kinetic-energy) mass matrix of the cubic-Hermite bending-cable element. !! diff --git a/src/CableDyn_HermiteCableDynamic.f90 b/src/CableDyn_HermiteCableDynamic.f90 index ff12e0c..793d61f 100644 --- a/src/CableDyn_HermiteCableDynamic.f90 +++ b/src/CableDyn_HermiteCableDynamic.f90 @@ -62,6 +62,7 @@ MODULE CableDyn_HermiteCableDynamic CD_HermiteCable_Gauss_Rule, & CD_HermiteCable_Axial_Resultant, & CD_HermiteCable_Axial_Strain_Lower_Bound, CD_HermiteCable_Dry_Buoyancy, & + CD_HermiteCable_Bending_Damping, & CD_HCABLE_OK USE CableDyn_Linalg, ONLY: CD_Factor_Banded, CD_Solve_Factored_Banded, CD_LINALG_OK USE CableDyn_VIV, ONLY: CD_VIV_Lift_Per_Length, CD_VIV_Crossflow_Along, CD_VIV_Phase_Rate, CD_VIV_Mean_Square, & @@ -93,6 +94,7 @@ MODULE CableDyn_HermiteCableDynamic PUBLIC :: CD_HermiteCable_Dyn_Init PUBLIC :: CD_HermiteCable_Dyn_Set_Drag PUBLIC :: CD_HermiteCable_Dyn_Set_Axial_Damping + PUBLIC :: CD_HermiteCable_Dyn_Set_Bending_Damping PUBLIC :: CD_HermiteCable_Dyn_Set_EndConnection PUBLIC :: CD_HermiteCable_Dyn_Set_Torsion PUBLIC :: CD_HermiteCable_Dyn_Torsion_State @@ -257,6 +259,12 @@ MODULE CableDyn_HermiteCableDynamic ! axial quadrature as the elastic resultant. Off by default. LOGICAL :: has_axial_damping = .FALSE. REAL(wp), ALLOCATABLE :: BA(:) + ! Optional bending Kelvin-Voigt damping (CD_HermiteCable_Bending_Damping): Bb [N m^2 s] per + ! element, the coefficient of the convected curvature rate, integrated over reference arc length + ! with the bending quadrature. It joins the axial damping in the structural-damping load (the + ! element-load column 2 and the Kvel tangent). Off by default. + LOGICAL :: has_bend_damping = .FALSE. + REAL(wp), ALLOCATABLE :: Bb(:) ! Active line control (CD_HermiteCable_Dyn_Set_SegmentLength): a host changes the ! unstretched lengths l0 of chosen elements between steps. has_ctrl is set by the first ! change; from then on l0_dot(ne) holds the unstretched-length rate of every element @@ -2992,6 +3000,141 @@ SUBROUTINE fail(msg) END SUBROUTINE fail END SUBROUTINE CD_HermiteCable_Dyn_Set_Axial_Damping + SUBROUTINE CD_HermiteCable_Dyn_Set_Bending_Damping(model, Bb, ErrStat, ErrMsg) + !! Install the per-element bending Kelvin-Voigt coefficients Bb [N m^2 s]: the damping moment + !! Bb times the curvature rate convected with the tangent (CD_HermiteCable_Bending_Damping). An + !! all-zero array disables the contribution exactly. Transactional, and it refreshes the + !! consistent acceleration, as CD_HermiteCable_Dyn_Set_Axial_Damping. + TYPE(CD_HermiteCableDynType), INTENT(INOUT) :: model + REAL(wp), INTENT(IN) :: Bb(:) + INTEGER, INTENT(OUT) :: ErrStat + CHARACTER(*), INTENT(OUT) :: ErrMsg + + REAL(wp), ALLOCATABLE :: old_Bb(:), new_Bb(:), old_a(:) + LOGICAL :: old_has + INTEGER :: es, istat + CHARACTER(1024) :: em + + ErrStat = CD_HCDYN_OK + model%rc_epoch = model%rc_epoch + 1 + model%fc_valid = .FALSE. + model%fc_clears = model%fc_clears + 1 + model%tr_valid = .FALSE. + ErrMsg = '' + IF (.NOT. model%initialized) THEN + CALL fail('model not initialised'); RETURN + END IF + IF (SIZE(Bb) /= model%ne) THEN + CALL fail('Bb must have length ne'); RETURN + END IF + IF (.NOT. CD_All_Finite(Bb) .OR. ANY(Bb < CD_ZERO)) THEN + CALL fail('Bb must be finite and non-negative'); RETURN + END IF + + ALLOCATE (new_Bb(model%ne), old_a(model%ndof), STAT=istat) + IF (istat /= 0) THEN + CALL fail('workspace allocation failed'); RETURN + END IF + new_Bb = Bb + old_a = model%a + old_has = model%has_bend_damping + CALL MOVE_ALLOC(model%Bb, old_Bb) + IF (ANY(new_Bb > CD_ZERO)) THEN + CALL MOVE_ALLOC(new_Bb, model%Bb) + model%has_bend_damping = .TRUE. + ELSE + model%has_bend_damping = .FALSE. + END IF + + CALL solve_consistent_acceleration(model, es, em) + IF (es /= CD_HCDYN_OK) THEN + IF (ALLOCATED(model%Bb)) DEALLOCATE (model%Bb) + CALL MOVE_ALLOC(old_Bb, model%Bb) + model%has_bend_damping = old_has + model%a = old_a + CALL fail('initial acceleration refresh failed: '//TRIM(em)); RETURN + END IF + + CONTAINS + SUBROUTINE fail(msg) + CHARACTER(*), INTENT(IN) :: msg + ErrStat = CD_HCDYN_BADINPUT + ErrMsg = 'CD_HermiteCable_Dyn_Set_Bending_Damping: '//msg + END SUBROUTINE fail + END SUBROUTINE CD_HermiteCable_Dyn_Set_Bending_Damping + + SUBROUTINE structural_damping_element(model, e, qe, ve, fdamp, ErrStat, ErrMsg, kdq, kdv, fixed_length, & + fbend) + !! The structural (Kelvin-Voigt) damping load of element e: the axial dashpot (BA, with the + !! controlled-length rate) and the bending dashpot (Bb), summed, as an internal generalised + !! force, with their exact Jacobians kdq = d/dq, kdv = d/dv when requested. Without bending + !! damping the axial kernel's output is returned as it stands (bit for bit). Under active line + !! control both rates include the controlled-length rate l0_dot; fixed_length = .TRUE. leaves it + !! out (the node recovery's form). fbend (optional) returns the bending part of fdamp alone. + TYPE(CD_HermiteCableDynType), INTENT(IN) :: model + INTEGER, INTENT(IN) :: e + REAL(wp), INTENT(IN) :: qe(12), ve(12) + REAL(wp), INTENT(OUT) :: fdamp(12) + INTEGER, INTENT(OUT) :: ErrStat + CHARACTER(*), INTENT(OUT) :: ErrMsg + REAL(wp), INTENT(OUT), OPTIONAL :: kdq(12, 12), kdv(12, 12) + LOGICAL, INTENT(IN), OPTIONAL :: fixed_length + REAL(wp), INTENT(OUT), OPTIONAL :: fbend(12) + REAL(wp) :: fb(12), kbq(12, 12), kbv(12, 12) + LOGICAL :: want, ctrl + INTEGER :: es + want = PRESENT(kdq) .AND. PRESENT(kdv) + ctrl = model%has_ctrl + IF (PRESENT(fixed_length)) ctrl = ctrl .AND. .NOT. fixed_length + ErrStat = CD_HCDYN_OK + ErrMsg = '' + fdamp = CD_ZERO + IF (want) THEN + kdq = CD_ZERO; kdv = CD_ZERO + END IF + IF (PRESENT(fbend)) fbend = CD_ZERO + IF (model%has_axial_damping) THEN + IF (want .AND. ctrl) THEN + CALL CD_HermiteCable_Axial_Damping_Element(qe, ve, model%l0(e), model%BA(e), fdamp, kdq, kdv, ErrStat, ErrMsg, & + model%axial_quadrature_order, model%l0_dot(e)) + ELSE IF (want) THEN + CALL CD_HermiteCable_Axial_Damping_Element(qe, ve, model%l0(e), model%BA(e), fdamp, kdq, kdv, ErrStat, ErrMsg, & + model%axial_quadrature_order) + ELSE IF (ctrl) THEN + CALL CD_HermiteCable_Axial_Damping_Element(qe, ve, model%l0(e), model%BA(e), fdamp, ErrStat=ErrStat, & + ErrMsg=ErrMsg, quadrature_order=model%axial_quadrature_order, & + l0_dot=model%l0_dot(e)) + ELSE + CALL CD_HermiteCable_Axial_Damping_Element(qe, ve, model%l0(e), model%BA(e), fdamp, ErrStat=ErrStat, & + ErrMsg=ErrMsg, quadrature_order=model%axial_quadrature_order) + END IF + IF (ErrStat /= CD_HCDYN_OK) RETURN + END IF + IF (.NOT. model%has_bend_damping) RETURN + IF (.NOT. (model%Bb(e) > CD_ZERO)) RETURN + IF (want .AND. ctrl) THEN + CALL CD_HermiteCable_Bending_Damping(qe, ve, model%l0(e), model%Bb(e), fb, kbq, kbv, es, ErrMsg, & + quadrature_order=model%bending_quadrature_order, l0_dot=model%l0_dot(e)) + ELSE IF (want) THEN + CALL CD_HermiteCable_Bending_Damping(qe, ve, model%l0(e), model%Bb(e), fb, kbq, kbv, es, ErrMsg, & + quadrature_order=model%bending_quadrature_order) + ELSE IF (ctrl) THEN + CALL CD_HermiteCable_Bending_Damping(qe, ve, model%l0(e), model%Bb(e), fb, ErrStat=es, ErrMsg=ErrMsg, & + quadrature_order=model%bending_quadrature_order, l0_dot=model%l0_dot(e)) + ELSE + CALL CD_HermiteCable_Bending_Damping(qe, ve, model%l0(e), model%Bb(e), fb, ErrStat=es, ErrMsg=ErrMsg, & + quadrature_order=model%bending_quadrature_order) + END IF + IF (es /= CD_HCABLE_OK) THEN + ErrStat = CD_HCDYN_NOCONVERGE; RETURN + END IF + fdamp = fdamp + fb + IF (PRESENT(fbend)) fbend = fb + IF (want) THEN + kdq = kdq + kbq; kdv = kdv + kbv + END IF + END SUBROUTINE structural_damping_element + SUBROUTINE CD_HermiteCable_Dyn_Set_AddedMass(model, rho_w, diam, can, cat, waterline_z, ErrStat, ErrMsg) !! Enable per-element Morison added mass on the (already initialised) dynamic model: the !! submerged cable accelerates surrounding fluid, adding rho_w A (Can (I - t t^T) + Cat t t^T) @@ -6526,15 +6669,8 @@ SUBROUTINE CD_HermiteCable_Dyn_End_Force(model, node, force, ErrStat, ErrMsg) ErrStat = CD_HCDYN_NOCONVERGE; ErrMsg = 'CD_HermiteCable_Dyn_End_Force: '//TRIM(em2); RETURN END IF r3 = fe(i0 + 1:i0 + 3) - IF (model%has_axial_damping) THEN - IF (model%has_ctrl) THEN - CALL CD_HermiteCable_Axial_Damping_Element(qe, ve, model%l0(e), model%BA(e), fdamp, ErrStat=es, ErrMsg=em2, & - quadrature_order=model%axial_quadrature_order, & - l0_dot=model%l0_dot(e)) - ELSE - CALL CD_HermiteCable_Axial_Damping_Element(qe, ve, model%l0(e), model%BA(e), fdamp, ErrStat=es, ErrMsg=em2, & - quadrature_order=model%axial_quadrature_order) - END IF + IF (model%has_axial_damping .OR. model%has_bend_damping) THEN + CALL structural_damping_element(model, e, qe, ve, fdamp, es, em2) IF (es /= CD_HCDYN_OK) THEN ErrStat = CD_HCDYN_NOCONVERGE; ErrMsg = 'CD_HermiteCable_Dyn_End_Force: '//TRIM(em2); RETURN END IF @@ -6786,7 +6922,8 @@ SUBROUTINE CD_HermiteCable_Dyn_Node_Recovery(model, ErrStat, ErrMsg, tension, cu !! Effective tension, curvature and bend moment at every node (internal order) recovered !! from nodal equilibrium, in one pass over the elements. !! - !! For element e the end residual g_e = f_int + f_damp - f_ext + M_e a_e holds the element's + !! For element e the end residual g_e = f_int + f_damp - f_ext + M_e a_e (without the tangent + !! rows of the bending damping, a viscous moment that is not EI r'') holds the element's !! own distributed loads (consistent submerged weight, dry-part buoyancy, drag, !! Froude-Krylov force, the seabed contact of its end nodes spread over their tributary !! lengths, and the structural and added-mass inertia): it is the generalized force the two @@ -7451,7 +7588,7 @@ SUBROUTINE element_end_residual(model, e, g, ErrStat, ErrMsg) CHARACTER(*), INTENT(OUT) :: ErrMsg REAL(wp), PARAMETER :: PI_L = 3.14159265358979323846_wp INTEGER, PARAMETER :: ZS(4) = [3, 6, 9, 12] - REAL(wp) :: qe(12), ve(12), ae(12), fe(12), fx(12), energy, fdry(4), kdry(4, 4) + REAL(wp) :: qe(12), ve(12), ae(12), fe(12), fx(12), fbd(12), energy, fdry(4), kdry(4, 4) REAL(wp) :: dry_wl, dry_b, dry_r, hf_mid(3), l0, fca(3), fcb(3), c, a4(4), m4(4, 4) REAL(wp) :: support(3), dsupport(3), nin(3), xa, xb, ca(4), cb(4) INTEGER :: es, k, inode @@ -7468,11 +7605,15 @@ SUBROUTINE element_end_residual(model, e, g, ErrStat, ErrMsg) bending_quadrature_order=model%bending_quadrature_order) IF (es /= CD_HCABLE_OK) GOTO 900 g = fe - IF (model%has_axial_damping) THEN - CALL CD_HermiteCable_Axial_Damping_Element(qe, ve, l0, model%BA(e), fx, ErrStat=es, ErrMsg=em2, & - quadrature_order=model%axial_quadrature_order) + IF (model%has_axial_damping .OR. model%has_bend_damping) THEN + CALL structural_damping_element(model, e, qe, ve, fx, es, em2, fixed_length=.TRUE., fbend=fbd) IF (es /= CD_HCDYN_OK) GOTO 900 g = g + fx + ! the viscous bending moment is not elastic: its tangent rows (the section moment the outputs + ! turn into curvature over EI) are left out, its position rows (the shear it carries) stay in + ! the section forces + g(4:6) = g(4:6) - fbd(4:6) + g(10:12) = g(10:12) - fbd(10:12) END IF ! consistent submerged weight (as assemble_residual) g(3) = g(3) + model%w(e)*0.5_wp*l0 @@ -8389,6 +8530,8 @@ SUBROUTINE CD_HermiteCable_Dyn_End(model) IF (ALLOCATED(model%w)) DEALLOCATE (model%w) IF (ALLOCATED(model%BA)) DEALLOCATE (model%BA) model%has_axial_damping = .FALSE. + IF (ALLOCATED(model%Bb)) DEALLOCATE (model%Bb) + model%has_bend_damping = .FALSE. IF (ALLOCATED(model%trib)) DEALLOCATE (model%trib) IF (ALLOCATED(model%contact_kn)) DEALLOCATE (model%contact_kn) IF (ALLOCATED(model%contact_cn)) DEALLOCATE (model%contact_cn) @@ -8823,7 +8966,7 @@ SUBROUTINE assemble_residual(model, q_cfg, v_cfg, t_eval, want_residual, want_ta CALL asm_mark(HC_ASM_CONTACT, asm_t) ! Scatter the element-private hydrodynamic tangents in the same phase and element ! order as the serial formulation, retaining its floating-point accumulation order. - IF (tangent_only .AND. (model%has_drag .OR. model%has_axial_damping)) THEN + IF (tangent_only .AND. (model%has_drag .OR. model%has_axial_damping .OR. model%has_bend_damping)) THEN DO e = 1, ne CALL scatter12_band(Kb, model%ws_elem_Kdrag(:, :, e), e) CALL scatter12_band(Kvb, model%ws_elem_Kv(:, :, e), e) @@ -8843,7 +8986,7 @@ SUBROUTINE assemble_residual(model, q_cfg, v_cfg, t_eval, want_residual, want_ta CALL asm_mark(HC_ASM_SCATTER, asm_t) ! Axial Kelvin-Voigt damping is an internal constitutive force. It uses the same ! reference-arc Hermite interpolation and axial quadrature as the elastic resultant. - IF (model%has_axial_damping .AND. .NOT. tangent_only) THEN + IF ((model%has_axial_damping .OR. model%has_bend_damping) .AND. .NOT. tangent_only) THEN DO e = e_lo, e_hi IF (kept) THEN DO a = 1, 12 @@ -8856,23 +8999,10 @@ SUBROUTINE assemble_residual(model, q_cfg, v_cfg, t_eval, want_residual, want_ta qe(7:9) = q_cfg(6*e + 1:6*e + 3); qe(10:12) = q_cfg(6*e + 4:6*e + 6) ve(1:3) = v_cfg(6*(e - 1) + 1:6*(e - 1) + 3); ve(4:6) = v_cfg(6*(e - 1) + 4:6*(e - 1) + 6) ve(7:9) = v_cfg(6*e + 1:6*e + 3); ve(10:12) = v_cfg(6*e + 4:6*e + 6) - IF (want_tangent .AND. model%has_ctrl) THEN - CALL CD_HermiteCable_Axial_Damping_Element(qe, ve, model%l0(e), model%BA(e), & - fdamp, kdq, kdv, es, em_e, & - model%axial_quadrature_order, model%l0_dot(e)) - ELSE IF (want_tangent) THEN - CALL CD_HermiteCable_Axial_Damping_Element(qe, ve, model%l0(e), model%BA(e), & - fdamp, kdq, kdv, es, em_e, & - model%axial_quadrature_order) - ELSE IF (model%has_ctrl) THEN - CALL CD_HermiteCable_Axial_Damping_Element(qe, ve, model%l0(e), model%BA(e), & - fdamp, ErrStat=es, ErrMsg=em_e, & - quadrature_order=model%axial_quadrature_order, & - l0_dot=model%l0_dot(e)) + IF (want_tangent) THEN + CALL structural_damping_element(model, e, qe, ve, fdamp, es, em_e, kdq, kdv) ELSE - CALL CD_HermiteCable_Axial_Damping_Element(qe, ve, model%l0(e), model%BA(e), & - fdamp, ErrStat=es, ErrMsg=em_e, & - quadrature_order=model%axial_quadrature_order) + CALL structural_damping_element(model, e, qe, ve, fdamp, es, em_e) END IF IF (es /= CD_HCDYN_OK) THEN ErrStat = CD_HCDYN_NOCONVERGE; ErrMsg = TRIM(em_e); RETURN @@ -10468,16 +10598,8 @@ SUBROUTINE evaluate_tangent_element(model, e, q_cfg, v_cfg, t_eval, Kstruct, Kdr ErrStat = CD_HCDYN_NOCONVERGE; ErrMsg = 'element: '//TRIM(em); RETURN END IF - IF (model%has_axial_damping) THEN - IF (model%has_ctrl) THEN - CALL CD_HermiteCable_Axial_Damping_Element(qe, ve, model%l0(e), model%BA(e), & - fload, djq, djv, es, em, & - model%axial_quadrature_order, model%l0_dot(e)) - ELSE - CALL CD_HermiteCable_Axial_Damping_Element(qe, ve, model%l0(e), model%BA(e), & - fload, djq, djv, es, em, & - model%axial_quadrature_order) - END IF + IF (model%has_axial_damping .OR. model%has_bend_damping) THEN + CALL structural_damping_element(model, e, qe, ve, fload, es, em, djq, djv) IF (es /= CD_HCDYN_OK) THEN ErrStat = CD_HCDYN_NOCONVERGE; ErrMsg = TRIM(em); RETURN END IF diff --git a/src/CableDyn_OpenFAST_HermiteFMF.f90 b/src/CableDyn_OpenFAST_HermiteFMF.f90 index 1038c1c..39a8447 100644 --- a/src/CableDyn_OpenFAST_HermiteFMF.f90 +++ b/src/CableDyn_OpenFAST_HermiteFMF.f90 @@ -25,6 +25,7 @@ MODULE CableDyn_OpenFAST_HermiteFMF USE CableDyn_HermiteCableDynamic, ONLY: CD_HermiteCableDynType, CD_HermiteCable_Dyn_Init, & CD_HermiteCable_Dyn_Set_Drag, CD_HermiteCable_Dyn_Set_AddedMass, & CD_HermiteCable_Dyn_Set_Axial_Damping, & + CD_HermiteCable_Dyn_Set_Bending_Damping, & CD_HermiteCable_Dyn_Set_Waves, CD_HermiteCable_Dyn_Set_Held_Fluid, & CD_HermiteCable_Dyn_Set_Contact, CD_HermiteCable_Dyn_Set_Attachments, & CD_HermiteCable_Dyn_Set_EndConnection, & @@ -59,6 +60,7 @@ MODULE CableDyn_OpenFAST_HermiteFMF PUBLIC :: CD_HFMF_Init PUBLIC :: CD_HFMF_Set_Drag PUBLIC :: CD_HFMF_Set_Axial_Damping + PUBLIC :: CD_HFMF_Set_Bending_Damping PUBLIC :: CD_HFMF_Set_ModifiedNewton PUBLIC :: CD_HFMF_Set_Tensile_Safety PUBLIC :: CD_HFMF_Set_Tensile_Monitor @@ -371,6 +373,29 @@ SUBROUTINE CD_HFMF_Set_Axial_Damping(self, BA, ErrStat, ErrMsg) END IF END SUBROUTINE CD_HFMF_Set_Axial_Damping + SUBROUTINE CD_HFMF_Set_Bending_Damping(self, Bb, ErrStat, ErrMsg) + !! Install the per-element bending Kelvin-Voigt coefficients Bb [N m^2 s] on the cable + !! (CD_HermiteCable_Dyn_Set_Bending_Damping). + TYPE(CD_HFMF_ModuleType), INTENT(INOUT) :: self + REAL(wp), INTENT(IN) :: Bb(:) + INTEGER, INTENT(OUT) :: ErrStat + CHARACTER(*), INTENT(OUT) :: ErrMsg + INTEGER :: es + CHARACTER(1024) :: em + ErrStat = CD_HFMF_OK + ErrMsg = '' + IF (.NOT. self%initialized) THEN + ErrStat = CD_HFMF_BADINPUT + ErrMsg = 'CD_HFMF_Set_Bending_Damping: module not initialised' + RETURN + END IF + CALL CD_HermiteCable_Dyn_Set_Bending_Damping(self%line, Bb, es, em) + IF (es /= CD_HCDYN_OK) THEN + ErrStat = CD_HFMF_BADINPUT + ErrMsg = 'CD_HFMF_Set_Bending_Damping: '//TRIM(em) + END IF + END SUBROUTINE CD_HFMF_Set_Bending_Damping + SUBROUTINE CD_HFMF_Set_EndConnection(self, k_rot, d0_global, ErrStat, ErrMsg, & coupled_d0_parent, parent_orientation, connection_mode, & end_b_d0_parent, end_b_parent_orientation) diff --git a/tests/test_bending_damping_deck.f90 b/tests/test_bending_damping_deck.f90 new file mode 100644 index 0000000..0d1389b --- /dev/null +++ b/tests/test_bending_damping_deck.f90 @@ -0,0 +1,184 @@ +! File: tests/test_bending_damping_deck.f90 +! SPDX-License-Identifier: Apache-2.0 +! Copyright (c) 2026 Jae Hoon Seo, SMI Lab, Inha University +PROGRAM test_bending_damping_deck + !! Bending damping on a deck (LINE TYPES EI|Bb and EI|-zeta|f): an 80 m power cable hanging from + !! a clamped hang-off to a seabed anchor, in a regular sea. + !! E1 EI|-zeta|f and the EI|Bb it resolves to (Bb = zeta EI/(pi f)) give the same run, to the + !! printed digits; + !! E2 the damping lowers the hang-off curvature range against the undamped deck, and EI|0 is + !! the undamped deck exactly; + !! E3 bending damping on an EI = 0 type (as Bb or as a ratio) and malformed EI columns are + !! refused by name. + USE CableDyn_Precision, ONLY: wp + USE CableDyn_DeckDriver, ONLY: CD_Run_Deck_Driver, CD_DECKDRV_OK + IMPLICIT NONE + REAL(wp), PARAMETER :: PI = 3.14159265358979323846_wp, EI = 2.0e4_wp, ZETA = 0.05_wp, FREQ = 0.5_wp + INTEGER :: nfail = 0 + + CALL check_runs() + CALL check_refusals() + IF (nfail > 0) THEN + WRITE (*, '(A,I0,A)') 'FAIL: ', nfail, ' assertion(s) failed' + ERROR STOP 1 + END IF + WRITE (*, '(A)') 'PASS: bending-damping deck gates' + +CONTAINS + + SUBROUTINE require(cond, label) + LOGICAL, INTENT(IN) :: cond + CHARACTER(*), INTENT(IN) :: label + IF (cond) RETURN + nfail = nfail + 1 + WRITE (*, '(A)') 'FAIL: '//TRIM(label) + END SUBROUTINE require + + SUBROUTINE write_deck(path, ei_col, tmax, rope) + CHARACTER(*), INTENT(IN) :: path, ei_col + REAL(wp), INTENT(IN) :: tmax + LOGICAL, INTENT(IN), OPTIONAL :: rope + INTEGER :: u + LOGICAL :: on_rope + on_rope = .FALSE. + IF (PRESENT(rope)) on_rope = rope + OPEN (NEWUNIT=u, FILE=path, STATUS='REPLACE', ACTION='WRITE') + WRITE (u, '(A)') '--------------------- CableDyn Input File ------------------------------------' + WRITE (u, '(A)') 'hang-off cable with bending damping' + WRITE (u, '(A)') '--------------------- LINE TYPES ---------------------------------------------' + WRITE (u, '(A)') 'TypeName Diam MassDenInAir EA BA EI Cd_n Cd_t Ca_n Ca_t' + WRITE (u, '(A)') '(-) (m) (kg/m) (N) (-) (N-m2) (-) (-) (-) (-)' + IF (on_rope) THEN + WRITE (u, '(A)') 'pc 0.15 40.0 5.0e8 0.0 2.0e4 1.2 0.1 1.0 0.0' + WRITE (u, '(A)') 'rope 0.10 20.0 5.0e7 0.0 '//TRIM(ei_col)//' 1.2 0.1 1.0 0.0' + ELSE + WRITE (u, '(A)') 'pc 0.15 40.0 5.0e8 0.0 '//TRIM(ei_col)//' 1.2 0.1 1.0 0.0' + END IF + 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 -5.0' + WRITE (u, '(A)') '2 Fixed 60.0 0.0 -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)') '--------------------- SECTIONS -----------------------------------------------' + WRITE (u, '(A)') 'LineID LineType Length NumSegs' + WRITE (u, '(A)') '(-) (-) (m) (-)' + WRITE (u, '(A)') '1 pc 80.0 320' + WRITE (u, '(A)') '--------------------- END CONNECTIONS ----------------------------------------' + WRITE (u, '(A)') 'LineID End Stiffness EzX EzY EzZ' + WRITE (u, '(A)') '(-) (-) (N-m/rad) (-) (-) (-)' + WRITE (u, '(A)') '1 A Rigid 0.3746 0.0 -0.9272' + 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)') '0.02 dtM' + WRITE (u, '(A,F8.3,A)') ' ', tmax, ' TMax' + WRITE (u, '(A)') 'airy 3.0 8.0 0.0 waves' + WRITE (u, '(A)') '5.0 rampTime' + WRITE (u, '(A)') '--------------------- OUTPUTS ------------------------------------------------' + WRITE (u, '(A)') '"FairTen1"' + WRITE (u, '(A)') '"BendMom1N1"' + WRITE (u, '(A)') '"Curv1N1"' + WRITE (u, '(A)') 'END' + CLOSE (u) + END SUBROUTINE write_deck + + SUBROUTINE run(deck, root, ok, msg) + CHARACTER(*), INTENT(IN) :: deck, root + LOGICAL, INTENT(OUT) :: ok + CHARACTER(*), INTENT(OUT) :: msg + LOGICAL :: conv + INTEGER :: es + CALL CD_Run_Deck_Driver(deck, root, conv, es, msg) + ok = es == CD_DECKDRV_OK .AND. conv + END SUBROUTINE run + + SUBROUTINE read_out(path, tab, n) + CHARACTER(*), INTENT(IN) :: path + REAL(wp), ALLOCATABLE, INTENT(OUT) :: tab(:, :) + INTEGER, INTENT(OUT) :: n + CHARACTER(1024) :: rec + INTEGER :: u, ios + ALLOCATE (tab(4, 20000)) + n = 0 + OPEN (NEWUNIT=u, FILE=path, STATUS='OLD', ACTION='READ', IOSTAT=ios) + IF (ios /= 0) RETURN + READ (u, '(A)') rec + READ (u, '(A)') rec + DO + READ (u, '(A)', IOSTAT=ios) rec + IF (ios /= 0) EXIT + IF (LEN_TRIM(rec) == 0) CYCLE + n = n + 1 + READ (rec, *) tab(:, n) + END DO + CLOSE (u) + END SUBROUTINE read_out + + SUBROUTINE check_runs() + REAL(wp), ALLOCATABLE :: tz(:, :), tb(:, :), tp(:, :), t0(:, :) + INTEGER :: nz, nb, np, n0 + REAL(wp) :: bb, rz, rp, r0 + LOGICAL :: ok + CHARACTER(1024) :: msg + CHARACTER(64) :: col + bb = ZETA*EI/(PI*FREQ) + WRITE (col, '(ES22.15)') bb + CALL write_deck('bdd_zeta.dat', '2.0e4|-0.05|0.5', 20.0_wp) + CALL run('bdd_zeta.dat', 'bdd_zeta', ok, msg) + CALL require(ok, 'E1: the EI|-zeta|f deck runs: '//TRIM(msg)) + CALL write_deck('bdd_bb.dat', '2.0e4|'//TRIM(ADJUSTL(col)), 20.0_wp) + CALL run('bdd_bb.dat', 'bdd_bb', ok, msg) + CALL require(ok, 'E1: the EI|Bb deck runs: '//TRIM(msg)) + CALL write_deck('bdd_plain.dat', '2.0e4', 20.0_wp) + CALL run('bdd_plain.dat', 'bdd_plain', ok, msg) + CALL require(ok, 'E2: the undamped deck runs: '//TRIM(msg)) + CALL write_deck('bdd_zero.dat', '2.0e4|0', 20.0_wp) + CALL run('bdd_zero.dat', 'bdd_zero', ok, msg) + CALL require(ok, 'E2: the EI|0 deck runs: '//TRIM(msg)) + CALL read_out('bdd_zeta.out', tz, nz) + CALL read_out('bdd_bb.out', tb, nb) + CALL read_out('bdd_plain.out', tp, np) + CALL read_out('bdd_zero.out', t0, n0) + CALL require(nz > 10 .AND. nz == nb .AND. nz == np .AND. nz == n0, 'E1/E2: the runs wrote matching rows') + IF (.NOT. (nz > 10 .AND. nz == nb .AND. nz == np .AND. nz == n0)) RETURN + WRITE (*, '(A,ES11.4)') 'E1: max |EI|-zeta|f - EI|Bb| over the channels ', MAXVAL(ABS(tz(:, :nz) - tb(:, :nb))) + CALL require(MAXVAL(ABS(tz(:, :nz) - tb(:, :nb))) <= 1.0e-6_wp*MAXVAL(ABS(tz(:, :nz))), & + 'E1: EI|-zeta|f is EI|Bb with Bb = zeta EI/(pi f)') + CALL require(MAXVAL(ABS(t0(:, :n0) - tp(:, :np))) == 0.0_wp, 'E2: EI|0 is the undamped deck exactly') + rz = MAXVAL(tz(4, nz/2:nz)) - MINVAL(tz(4, nz/2:nz)) + rp = MAXVAL(tp(4, np/2:np)) - MINVAL(tp(4, np/2:np)) + r0 = MAXVAL(tz(3, nz/2:nz)) - MINVAL(tz(3, nz/2:nz)) + WRITE (*, '(A,ES11.4,A,ES11.4,A)') 'E2: hang-off curvature range, damped ', rz, ' 1/m, undamped ', rp, ' 1/m' + CALL require(rz < rp, 'E2: the bending damping lowers the hang-off curvature range') + CALL require(r0 > 0.0_wp, 'E2: the hang-off moment varies in the sea') + END SUBROUTINE check_runs + + SUBROUTINE check_refusals() + LOGICAL :: ok + CHARACTER(1024) :: msg + CALL write_deck('bdd_rope.dat', '0.0|250.0', 0.0_wp, rope=.TRUE.) + CALL run('bdd_rope.dat', 'bdd_rope', ok, msg) + WRITE (*, '(A)') 'E3 EI = 0: '//TRIM(msg) + CALL require(.NOT. ok .AND. INDEX(msg, 'bending damping (EI|Bb) needs a finite-EI cable') > 0, & + 'E3: bending damping on an EI = 0 type') + CALL write_deck('bdd_rope_ratio.dat', '0.0|-0.05|0.5', 0.0_wp, rope=.TRUE.) + CALL run('bdd_rope_ratio.dat', 'bdd_rope_ratio', ok, msg) + WRITE (*, '(A)') 'E3 EI = 0, ratio form: '//TRIM(msg) + CALL require(.NOT. ok .AND. INDEX(msg, 'bending damping (EI|Bb) needs a finite-EI cable') > 0, & + 'E3: a damping ratio on an EI = 0 type') + CALL write_deck('bdd_neg.dat', '2.0e4|-250.0', 0.0_wp) + CALL run('bdd_neg.dat', 'bdd_neg', ok, msg) + WRITE (*, '(A)') 'E3 negative without f: '//TRIM(msg) + CALL require(.NOT. ok .AND. INDEX(msg, 'needs the frequency it holds at') > 0, 'E3: negative Bb without f') + CALL write_deck('bdd_four.dat', '2.0e4|1|2|3', 0.0_wp) + CALL run('bdd_four.dat', 'bdd_four', ok, msg) + WRITE (*, '(A)') 'E3 four parts: '//TRIM(msg) + CALL require(.NOT. ok .AND. INDEX(msg, 'takes EI, EI|Bb or EI|-zeta|f') > 0, 'E3: four-part EI column') + END SUBROUTINE check_refusals + +END PROGRAM test_bending_damping_deck diff --git a/tests/test_hermite_bending_damping.f90 b/tests/test_hermite_bending_damping.f90 new file mode 100644 index 0000000..0409ef6 --- /dev/null +++ b/tests/test_hermite_bending_damping.f90 @@ -0,0 +1,253 @@ +! File: tests/test_hermite_bending_damping.f90 +! SPDX-License-Identifier: Apache-2.0 +! Copyright (c) 2026 Jae Hoon Seo, SMI Lab, Inha University +PROGRAM test_hermite_bending_damping + !! Kernel gates of the Kelvin-Voigt bending damping (CD_HermiteCable_Bending_Damping): + !! K1 Kv equals the central difference of fdamp in the rates, Kq that in the positions, on a + !! stretched, twisted 3D element and on a straight one; + !! K2 fdamp is linear in the rates, dissipative (v . fdamp >= 0) and zero for Bb = 0; + !! K3 zero for a rigid translation and for a rigid rotation whose axis is normal to the + !! tangent everywhere (a planar arc spun about the normal of its plane); + !! K4 the planar rate: a straight element bent in its plane at curvature rate kdot dissipates + !! Bb kdot^2 L, the dissipation function's closed form; + !! K5 bad inputs are refused by name; + !! K6 with a length rate l0_dot (active line control) the force is d psi / d v of the + !! dissipation function built independently from the public curvature (kappa_b = t x kvec, + !! CD_HermiteCable_Curvature) with its rate by central differences in the DOFs and the + !! length, and a length change alone (v = 0) is damped; + !! K7 Kq and Kv with a length rate equal the central differences of the force. + USE CableDyn_Precision, ONLY: wp + USE, INTRINSIC :: IEEE_ARITHMETIC, ONLY: IEEE_VALUE, IEEE_POSITIVE_INF + USE CableDyn_HermiteCable, ONLY: CD_HermiteCable_Bending_Damping, CD_HCABLE_OK, CD_HermiteCable_Curvature, & + CD_HermiteCable_Shapes, CD_HermiteCable_Gauss_Rule + IMPLICIT NONE + INTEGER :: nfail = 0 + REAL(wp), PARAMETER :: L = 2.5_wp, BB = 37.0_wp + + CALL check_jacobians() + CALL check_linear_dissipative() + CALL check_rigid_motions() + CALL check_planar_rate() + CALL check_refusals() + CALL check_length_rate() + IF (nfail > 0) THEN + WRITE (*, '(A,I0,A)') 'FAIL: ', nfail, ' assertion(s) failed' + ERROR STOP 1 + END IF + WRITE (*, '(A)') 'PASS: Hermite bending damping kernel' + +CONTAINS + + SUBROUTINE require(cond, label) + LOGICAL, INTENT(IN) :: cond + CHARACTER(*), INTENT(IN) :: label + IF (cond) RETURN + nfail = nfail + 1 + WRITE (*, '(A)') 'FAIL: '//TRIM(label) + END SUBROUTINE require + + SUBROUTINE curved_state(q, v) + !! A stretched, out-of-plane curved element with arbitrary nodal rates. + REAL(wp), INTENT(OUT) :: q(12), v(12) + q = [0.0_wp, 0.0_wp, 0.0_wp, 1.02_wp, 0.3_wp, -0.2_wp, & + 2.4_wp, 0.5_wp, -0.3_wp, 0.9_wp, -0.25_wp, 0.35_wp] + v = [0.11_wp, -0.23_wp, 0.31_wp, 0.4_wp, -0.15_wp, 0.27_wp, & + -0.19_wp, 0.08_wp, 0.42_wp, -0.33_wp, 0.21_wp, 0.12_wp] + END SUBROUTINE curved_state + + SUBROUTINE fd_check(q, v, label) + REAL(wp), INTENT(IN) :: q(12), v(12) + CHARACTER(*), INTENT(IN) :: label + REAL(wp) :: f(12), Kq(12, 12), Kv(12, 12), fp(12), fm(12), Kq_fd(12, 12), Kv_fd(12, 12), dq(12), h + REAL(wp) :: eq, ev + INTEGER :: es, j + CHARACTER(256) :: em + CALL CD_HermiteCable_Bending_Damping(q, v, L, BB, f, Kq, Kv, es, em) + CALL require(es == CD_HCABLE_OK, 'K1 '//label//': evaluation: '//TRIM(em)) + DO j = 1, 12 + h = 1.0e-6_wp*MAX(1.0_wp, ABS(q(j))) + dq = 0.0_wp; dq(j) = h + CALL CD_HermiteCable_Bending_Damping(q + dq, v, L, BB, fp, ErrStat=es, ErrMsg=em) + CALL CD_HermiteCable_Bending_Damping(q - dq, v, L, BB, fm, ErrStat=es, ErrMsg=em) + Kq_fd(:, j) = (fp - fm)/(2.0_wp*h) + h = 1.0e-6_wp*MAX(1.0_wp, ABS(v(j))) + dq = 0.0_wp; dq(j) = h + CALL CD_HermiteCable_Bending_Damping(q, v + dq, L, BB, fp, ErrStat=es, ErrMsg=em) + CALL CD_HermiteCable_Bending_Damping(q, v - dq, L, BB, fm, ErrStat=es, ErrMsg=em) + Kv_fd(:, j) = (fp - fm)/(2.0_wp*h) + END DO + eq = MAXVAL(ABS(Kq - Kq_fd))/MAX(1.0e-12_wp, MAXVAL(ABS(Kq_fd))) + ev = MAXVAL(ABS(Kv - Kv_fd))/MAX(1.0e-12_wp, MAXVAL(ABS(Kv_fd))) + WRITE (*, '(A,2ES11.3)') 'K1 '//label//': relative |Kq - FD|, |Kv - FD| ', eq, ev + CALL require(eq < 1.0e-6_wp, 'K1 '//label//': Kq matches the central difference') + CALL require(ev < 1.0e-6_wp, 'K1 '//label//': Kv matches the central difference') + CALL require(MAXVAL(ABS(Kv - TRANSPOSE(Kv))) <= 1.0e-12_wp*MAXVAL(ABS(Kv)), 'K1 '//label//': Kv symmetric') + END SUBROUTINE fd_check + + SUBROUTINE check_jacobians() + REAL(wp) :: q(12), v(12) + CALL curved_state(q, v) + CALL fd_check(q, v, 'curved 3D') + ! straight, unstretched element along x (the zero-curvature state) + q = [0.0_wp, 0.0_wp, 0.0_wp, 1.0_wp, 0.0_wp, 0.0_wp, L, 0.0_wp, 0.0_wp, 1.0_wp, 0.0_wp, 0.0_wp] + CALL fd_check(q, v, 'straight') + END SUBROUTINE check_jacobians + + SUBROUTINE check_linear_dissipative() + REAL(wp) :: q(12), v(12), f1(12), f2(12) + INTEGER :: es + CHARACTER(256) :: em + CALL curved_state(q, v) + CALL CD_HermiteCable_Bending_Damping(q, v, L, BB, f1, ErrStat=es, ErrMsg=em) + CALL CD_HermiteCable_Bending_Damping(q, 2.0_wp*v, L, BB, f2, ErrStat=es, ErrMsg=em) + CALL require(MAXVAL(ABS(f2 - 2.0_wp*f1)) <= 1.0e-12_wp*MAXVAL(ABS(f1)), 'K2: linear in the rates') + CALL require(DOT_PRODUCT(v, f1) > 0.0_wp, 'K2: dissipative (v . f > 0)') + CALL CD_HermiteCable_Bending_Damping(q, v, L, 0.0_wp, f1, ErrStat=es, ErrMsg=em) + CALL require(es == CD_HCABLE_OK .AND. MAXVAL(ABS(f1)) == 0.0_wp, 'K2: zero for Bb = 0') + END SUBROUTINE check_linear_dissipative + + SUBROUTINE check_rigid_motions() + REAL(wp) :: q(12), v(12), f(12), scale, omega(3) + INTEGER :: es, k + CHARACTER(256) :: em + CALL curved_state(q, v) + ! rigid translation: every node moves with c, tangents fixed + v = [0.3_wp, -0.7_wp, 0.2_wp, 0.0_wp, 0.0_wp, 0.0_wp, 0.3_wp, -0.7_wp, 0.2_wp, 0.0_wp, 0.0_wp, 0.0_wp] + CALL CD_HermiteCable_Bending_Damping(q, v, L, BB, f, ErrStat=es, ErrMsg=em) + CALL require(MAXVAL(ABS(f)) <= 1.0e-12_wp*BB, 'K3: zero for a rigid translation') + ! a planar arc in the x-z plane spun about y (normal to every tangent): v = omega x r, m' = omega x m + q = [0.0_wp, 0.0_wp, 0.0_wp, 1.0_wp, 0.0_wp, 0.4_wp, 2.3_wp, 0.0_wp, 0.6_wp, 0.8_wp, 0.0_wp, -0.3_wp] + omega = [0.0_wp, 0.9_wp, 0.0_wp] + DO k = 0, 3 + v(3*k + 1:3*k + 3) = cross(omega, q(3*k + 1:3*k + 3)) + END DO + CALL CD_HermiteCable_Bending_Damping(q, v, L, BB, f, ErrStat=es, ErrMsg=em) + ! reference: the same element bent at the same rate scale + scale = BB*0.9_wp/L + WRITE (*, '(A,ES11.3)') 'K3: rigid in-plane rotation, max |f| / (Bb omega / L) ', MAXVAL(ABS(f))/scale + CALL require(MAXVAL(ABS(f)) <= 1.0e-12_wp*scale, 'K3: zero for a rigid rotation normal to the tangents') + END SUBROUTINE check_rigid_motions + + SUBROUTINE check_planar_rate() + !! A straight unstretched element along x bent in the x-z plane with rates that give a + !! uniform curvature rate kdot (w(x) = 1/2 kdot x^2 t, end slopes kdot x): the dissipation + !! v . f = 2 psi = Bb kdot^2 L at the straight state. + REAL(wp) :: q(12), v(12), f(12), kdot, d + INTEGER :: es + CHARACTER(256) :: em + kdot = 0.17_wp + q = [0.0_wp, 0.0_wp, 0.0_wp, 1.0_wp, 0.0_wp, 0.0_wp, L, 0.0_wp, 0.0_wp, 1.0_wp, 0.0_wp, 0.0_wp] + v = 0.0_wp + ! w = kdot x^2 / 2: node 2 rate kdot L^2/2, slope handle m = dr/ds -> rate kdot L + v(9) = 0.5_wp*kdot*L*L + v(12) = kdot*L + CALL CD_HermiteCable_Bending_Damping(q, v, L, BB, f, ErrStat=es, ErrMsg=em) + d = DOT_PRODUCT(v, f) + WRITE (*, '(A,ES14.6,A,ES14.6)') 'K4: v . f ', d, ', Bb kdot^2 L ', BB*kdot*kdot*L + CALL require(ABS(d - BB*kdot*kdot*L) <= 1.0e-10_wp*BB*kdot*kdot*L, 'K4: planar dissipation Bb kdot^2 L') + END SUBROUTINE check_planar_rate + + SUBROUTINE check_refusals() + REAL(wp) :: q(12), v(12), f(12) + INTEGER :: es + CHARACTER(256) :: em + CALL curved_state(q, v) + CALL CD_HermiteCable_Bending_Damping(q, v, L, -1.0_wp, f, ErrStat=es, ErrMsg=em) + CALL require(es /= CD_HCABLE_OK .AND. INDEX(em, 'Bb must be non-negative') > 0, 'K5: negative Bb') + CALL CD_HermiteCable_Bending_Damping(q, v, 0.0_wp, BB, f, ErrStat=es, ErrMsg=em) + CALL require(es /= CD_HCABLE_OK .AND. INDEX(em, 'length must be positive') > 0, 'K5: zero length') + q(4:6) = 0.0_wp; q(7:9) = 0.0_wp; q(10:12) = 0.0_wp + CALL CD_HermiteCable_Bending_Damping(q, v, L, BB, f, ErrStat=es, ErrMsg=em) + CALL require(es /= CD_HCABLE_OK .AND. INDEX(em, 'degenerate centreline') > 0, 'K5: collapsed element') + END SUBROUTINE check_refusals + + SUBROUTINE kappa_b(q, el, xi, kb) + !! The binormal curvature vector (a x b)/|a|^3 from the public routines: t x kvec, with + !! kvec = (r' x r'') x r'/|r'|^4 of CD_HermiteCable_Curvature and t from the shape derivatives. + REAL(wp), INTENT(IN) :: q(12), el, xi + REAL(wp), INTENT(OUT) :: kb(3) + REAL(wp) :: H(4), dH(4), a(3), kv(3), cv + INTEGER :: es, c + CHARACTER(256) :: em + CALL CD_HermiteCable_Shapes(xi, el, H, dH) + DO c = 1, 3 + a(c) = (dH(1)*q(c) + dH(2)*q(3 + c) + dH(3)*q(6 + c) + dH(4)*q(9 + c))/el + END DO + CALL CD_HermiteCable_Curvature(q, el, xi, cv, es, em, kvec=kv) + kb = cross(a/NORM2(a), kv) + END SUBROUTINE kappa_b + + REAL(wp) FUNCTION psi_fd(q, v, ldot) RESULT(psi) + !! 1/2 Bb int |(I - t t^T) dkappa_b/dt|^2 ds over the element, the rate by central differences + !! along (v, ldot), with the kernel's Gauss rule (order 4) on the unstretched length. + REAL(wp), INTENT(IN) :: q(12), v(12), ldot + REAL(wp) :: gp(6), gw(6), kp(3), km(3), kd(3), H(4), dH(4), a(3), tv(3), eps + INTEGER :: ig, c + eps = 1.0e-6_wp + CALL CD_HermiteCable_Gauss_Rule(4, gp, gw) + psi = 0.0_wp + DO ig = 1, 4 + CALL kappa_b(q + eps*v, L + eps*ldot, gp(ig), kp) + CALL kappa_b(q - eps*v, L - eps*ldot, gp(ig), km) + kd = (kp - km)/(2.0_wp*eps) + CALL CD_HermiteCable_Shapes(gp(ig), L, H, dH) + DO c = 1, 3 + a(c) = (dH(1)*q(c) + dH(2)*q(3 + c) + dH(3)*q(6 + c) + dH(4)*q(9 + c))/L + END DO + tv = a/NORM2(a) + kd = kd - tv*DOT_PRODUCT(tv, kd) + psi = psi + 0.5_wp*BB*DOT_PRODUCT(kd, kd)*gw(ig)*L + END DO + END FUNCTION psi_fd + + SUBROUTINE check_length_rate() + REAL(wp) :: q(12), v(12), f(12), fx(12), dv(12), h, ldot, scale, Kq(12, 12), Kv(12, 12), fp(12), fm(12) + REAL(wp) :: Kq_fd(12, 12), Kv_fd(12, 12), eq, ev + INTEGER :: es, j + CHARACTER(256) :: em + CALL curved_state(q, v) + ldot = 0.37_wp + CALL CD_HermiteCable_Bending_Damping(q, v, L, BB, f, ErrStat=es, ErrMsg=em, l0_dot=ldot) + CALL require(es == CD_HCABLE_OK, 'K6: evaluation with l0_dot: '//TRIM(em)) + ! d psi / d v by central differences (psi is quadratic in v) + h = 1.0e-2_wp + DO j = 1, 12 + dv = 0.0_wp; dv(j) = h + fx(j) = (psi_fd(q, v + dv, ldot) - psi_fd(q, v - dv, ldot))/(2.0_wp*h) + END DO + scale = MAXVAL(ABS(fx)) + WRITE (*, '(A,ES11.3)') 'K6: max |f - d psi/d v| / max |f| with l0_dot ', MAXVAL(ABS(f - fx))/scale + CALL require(MAXVAL(ABS(f - fx)) <= 1.0e-6_wp*scale, 'K6: the force is d psi/d v with the length rate') + v = 0.0_wp + CALL CD_HermiteCable_Bending_Damping(q, v, L, BB, f, ErrStat=es, ErrMsg=em, l0_dot=ldot) + CALL require(MAXVAL(ABS(f)) > 0.0_wp, 'K6: a length change alone is damped') + ! K7: Jacobians with the length rate + CALL curved_state(q, v) + CALL CD_HermiteCable_Bending_Damping(q, v, L, BB, f, Kq, Kv, es, em, l0_dot=ldot) + DO j = 1, 12 + h = 1.0e-6_wp*MAX(1.0_wp, ABS(q(j))) + dv = 0.0_wp; dv(j) = h + CALL CD_HermiteCable_Bending_Damping(q + dv, v, L, BB, fp, ErrStat=es, ErrMsg=em, l0_dot=ldot) + CALL CD_HermiteCable_Bending_Damping(q - dv, v, L, BB, fm, ErrStat=es, ErrMsg=em, l0_dot=ldot) + Kq_fd(:, j) = (fp - fm)/(2.0_wp*h) + h = 1.0e-6_wp*MAX(1.0_wp, ABS(v(j))) + dv = 0.0_wp; dv(j) = h + CALL CD_HermiteCable_Bending_Damping(q, v + dv, L, BB, fp, ErrStat=es, ErrMsg=em, l0_dot=ldot) + CALL CD_HermiteCable_Bending_Damping(q, v - dv, L, BB, fm, ErrStat=es, ErrMsg=em, l0_dot=ldot) + Kv_fd(:, j) = (fp - fm)/(2.0_wp*h) + END DO + eq = MAXVAL(ABS(Kq - Kq_fd))/MAXVAL(ABS(Kq_fd)) + ev = MAXVAL(ABS(Kv - Kv_fd))/MAXVAL(ABS(Kv_fd)) + WRITE (*, '(A,2ES11.3)') 'K7: relative |Kq - FD|, |Kv - FD| with l0_dot ', eq, ev + CALL require(eq < 1.0e-6_wp .AND. ev < 1.0e-6_wp, 'K7: Jacobians with the length rate') + CALL CD_HermiteCable_Bending_Damping(q, v, L, BB, f, ErrStat=es, ErrMsg=em, l0_dot=IEEE_VALUE(1.0_wp, IEEE_POSITIVE_INF)) + CALL require(es /= CD_HCABLE_OK .AND. INDEX(em, 'l0_dot must be finite') > 0, 'K5: non-finite l0_dot refused') + END SUBROUTINE check_length_rate + + PURE FUNCTION cross(a, b) RESULT(c) + REAL(wp), INTENT(IN) :: a(3), b(3) + REAL(wp) :: c(3) + c = [a(2)*b(3) - a(3)*b(2), a(3)*b(1) - a(1)*b(3), a(1)*b(2) - a(2)*b(1)] + END FUNCTION cross + +END PROGRAM test_hermite_bending_damping diff --git a/tests/test_hermite_bending_damping_dynamic.f90 b/tests/test_hermite_bending_damping_dynamic.f90 new file mode 100644 index 0000000..39ab091 --- /dev/null +++ b/tests/test_hermite_bending_damping_dynamic.f90 @@ -0,0 +1,159 @@ +! File: tests/test_hermite_bending_damping_dynamic.f90 +! SPDX-License-Identifier: Apache-2.0 +! Copyright (c) 2026 Jae Hoon Seo, SMI Lab, Inha University +PROGRAM test_hermite_bending_damping_dynamic + !! Free decay of the first mode of a weightless, pinned-pinned, tensioned finite-EI cable with + !! bending Kelvin-Voigt damping (CD_HermiteCable_Dyn_Set_Bending_Damping), generalised-alpha with + !! rho_inf = 1 (no numerical damping). For mode shape sin(k x), k = pi/L, the bending moment is + !! EI k^2 a and the tension carries T k^2 a, so the mode's damping ratio is + !! zeta_1 = omega_1 Bb / (2 EI) * EI k^2 / (EI k^2 + T), omega_1^2 = (EI k^4 + T k^2)/m: + !! only the bending share of the modal stiffness is damped. + !! B1 a bending-dominated cable (share 0.96) decays at that zeta to 1 %; + !! B2 a tension-dominated cable (share 0.2) decays at that smaller zeta to 1 %; + !! B3 Bb = 0 leaves the undamped decay (|zeta| below 1e-5) and installing an all-zero array + !! keeps the configuration off; + !! B4 a negative coefficient or a wrong length is refused; + !! B5 a straight cable moving in its first bending mode with zero acceleration has no elastic + !! curvature: the node recovery reports none although the bending damping acts (its viscous + !! moment is not EI kappa), while the end force carries the damping. + USE CableDyn_Precision, ONLY: wp + USE CableDyn_HermiteCableDynamic, ONLY: CD_HermiteCableDynType, CD_HermiteCable_Dyn_Init, & + CD_HermiteCable_Dyn_Step, CD_HermiteCable_Dyn_Set_Bending_Damping, & + CD_HermiteCable_Dyn_Node_Recovery, CD_HermiteCable_Dyn_End_Force, & + CD_HCDYN_OK + IMPLICIT NONE + REAL(wp), PARAMETER :: PI = 3.14159265358979323846_wp + REAL(wp), PARAMETER :: LL = 20.0_wp, EA = 1.0e8_wp, EI = 1.0e5_wp, RHOA = 10.0_wp + INTEGER, PARAMETER :: NE = 40, NN = NE + 1, NDOF = 6*NN, MID = NE/2 + 1 + INTEGER :: nfail = 0 + + CALL decay_case('B1 bending-dominated', 1.0e2_wp, 0.02_wp) + CALL decay_case('B2 tension-dominated', 1.0e4_wp, 0.02_wp) + CALL decay_case('B3 undamped', 1.0e4_wp, 0.0_wp) + CALL check_refusals() + CALL check_recovery() + IF (nfail > 0) THEN + WRITE (*, '(A,I0,A)') 'FAIL: ', nfail, ' assertion(s) failed' + ERROR STOP 1 + END IF + WRITE (*, '(A)') 'PASS: Hermite bending damping dynamic decay' + +CONTAINS + + SUBROUTINE require(cond, label) + LOGICAL, INTENT(IN) :: cond + CHARACTER(*), INTENT(IN) :: label + IF (cond) RETURN + nfail = nfail + 1 + WRITE (*, '(A)') 'FAIL: '//TRIM(label) + END SUBROUTINE require + + SUBROUTINE setup(model, tens, a0) + TYPE(CD_HermiteCableDynType), INTENT(OUT) :: model + REAL(wp), INTENT(IN) :: tens, a0 + REAL(wp) :: l0(NE), ea_(NE), ei_(NE), rho(NE), w(NE), q(NDOF), eps, lt, x + INTEGER :: k, es + CHARACTER(512) :: em + eps = tens/EA; lt = (1.0_wp + eps)*LL + l0 = LL/REAL(NE, wp); ea_ = EA; ei_ = EI; rho = RHOA; w = 0.0_wp + DO k = 1, NN + x = lt*REAL(k - 1, wp)/REAL(NE, wp) + q(6*k - 5:6*k) = [x, 0.0_wp, a0*SIN(PI*x/lt), (1.0_wp + eps), 0.0_wp, (1.0_wp + eps)*a0*PI/lt*COS(PI*x/lt)] + END DO + CALL CD_HermiteCable_Dyn_Init(model, l0, ea_, ei_, rho, w, q, [1, 2, 3, 6*NE + 1, 6*NE + 2, 6*NE + 3], & + -1.0e4_wp, 0.0_wp, 1.0_wp, es, em) + CALL require(es == CD_HCDYN_OK, 'init: '//TRIM(em)) + END SUBROUTINE setup + + SUBROUTINE decay_case(label, tens, zeta_ref) + CHARACTER(*), INTENT(IN) :: label + REAL(wp), INTENT(IN) :: tens, zeta_ref + TYPE(CD_HermiteCableDynType) :: model + REAL(wp) :: kk, om1, share, bb, zeta_expect, dt, z, zprev, zprev2, peaks(200), tpk(200), delta, zeta_meas, res + INTEGER :: n, k, np, es, it, nstep + CHARACTER(512) :: em + kk = PI/LL + om1 = SQRT((EI*kk**4 + tens*kk**2)/RHOA) + share = EI*kk**2/(EI*kk**2 + tens) + bb = 2.0_wp*zeta_ref*EI/om1 + zeta_expect = om1*bb/(2.0_wp*EI)*share + CALL setup(model, tens, 1.0e-3_wp) + CALL CD_HermiteCable_Dyn_Set_Bending_Damping(model, [(bb, k=1, NE)], es, em) + CALL require(es == CD_HCDYN_OK, label//': set damping: '//TRIM(em)) + dt = (2.0_wp*PI/om1)/200.0_wp + nstep = 200*12 + np = 0; zprev = model%q(6*(MID - 1) + 3); zprev2 = zprev + DO n = 1, nstep + CALL CD_HermiteCable_Dyn_Step(model, dt, 50, 1.0e-10_wp, es, em, it, res) + IF (es /= CD_HCDYN_OK) THEN + CALL require(.FALSE., label//': step failed: '//TRIM(em)); RETURN + END IF + z = model%q(6*(MID - 1) + 3) + ! a positive peak of the midspan deflection (parabolic refinement of the sampled peak) + IF (n >= 2 .AND. zprev > zprev2 .AND. zprev >= z .AND. zprev > 0.0_wp .AND. np < SIZE(peaks)) THEN + np = np + 1 + peaks(np) = zprev - 0.125_wp*(z - zprev2)**2/(z - 2.0_wp*zprev + zprev2) + tpk(np) = dt*REAL(n - 1, wp) + END IF + zprev2 = zprev; zprev = z + END DO + CALL require(np >= 8, label//': enough peaks') + IF (np < 8) RETURN + delta = LOG(peaks(2)/peaks(np))/REAL(np - 2, wp) + zeta_meas = delta/SQRT(4.0_wp*PI*PI + delta*delta) + WRITE (*, '(A,A,F7.4,A,ES11.4,A,ES11.4,A,F8.3)') label, ': bending share ', share, ', zeta expected ', & + zeta_expect, ', measured ', zeta_meas, ', period ratio ', (tpk(np) - tpk(2))/REAL(np - 2, wp)*om1/(2.0_wp*PI) + IF (zeta_ref > 0.0_wp) THEN + CALL require(ABS(zeta_meas - zeta_expect) <= 0.01_wp*zeta_expect, label//': decay matches zeta to 1 %') + ELSE + CALL require(ABS(zeta_meas) <= 1.0e-5_wp, label//': no damping without Bb') + END IF + END SUBROUTINE decay_case + + SUBROUTINE check_refusals() + TYPE(CD_HermiteCableDynType) :: model + INTEGER :: es, k + CHARACTER(512) :: em + CALL setup(model, 1.0e4_wp, 0.02_wp) + CALL CD_HermiteCable_Dyn_Set_Bending_Damping(model, [(-1.0_wp, k=1, NE)], es, em) + CALL require(es /= CD_HCDYN_OK .AND. INDEX(em, 'finite and non-negative') > 0, 'B4: negative Bb refused') + CALL CD_HermiteCable_Dyn_Set_Bending_Damping(model, [(1.0_wp, k=1, NE - 1)], es, em) + CALL require(es /= CD_HCDYN_OK .AND. INDEX(em, 'length ne') > 0, 'B4: wrong length refused') + CALL CD_HermiteCable_Dyn_Set_Bending_Damping(model, [(0.0_wp, k=1, NE)], es, em) + CALL require(es == CD_HCDYN_OK .AND. .NOT. model%has_bend_damping, 'B3: all-zero Bb keeps it off') + END SUBROUTINE check_refusals + + SUBROUTINE check_recovery() + TYPE(CD_HermiteCableDynType) :: model + REAL(wp) :: curv(NN), bb, v0, lt, x, kdot, f_damped(3), f_plain(3) + INTEGER :: es, k + CHARACTER(512) :: em + v0 = 0.3_wp + bb = 2.0e3_wp + CALL setup(model, 1.0e4_wp, 0.0_wp) + lt = model%q(6*(NN - 1) + 1) + CALL CD_HermiteCable_Dyn_Set_Bending_Damping(model, [(bb, k=1, NE)], es, em) + CALL require(es == CD_HCDYN_OK, 'B5: set damping: '//TRIM(em)) + ! straight line, first-mode velocity z' = v0 sin(pi x/lt) and its slope rate, no acceleration + model%v = 0.0_wp + DO k = 1, NN + x = model%q(6*(k - 1) + 1) + model%v(6*(k - 1) + 3) = v0*SIN(PI*x/lt) + model%v(6*(k - 1) + 6) = v0*PI/lt*COS(PI*x/lt) + END DO + model%v([1, 2, 3, 6*NE + 1, 6*NE + 2, 6*NE + 3]) = 0.0_wp + model%a = 0.0_wp + CALL CD_HermiteCable_Dyn_Node_Recovery(model, es, em, curvature=curv) + CALL require(es == CD_HCDYN_OK, 'B5: node recovery: '//TRIM(em)) + kdot = v0*(PI/lt)**2 + WRITE (*, '(A,ES11.3,A,ES11.3)') 'B5: max recovered curvature ', MAXVAL(ABS(curv)), & + ' 1/m; the viscous moment over EI would read ', bb*kdot/EI + CALL require(MAXVAL(ABS(curv)) <= 1.0e-6_wp*bb*kdot/EI, 'B5: no viscous curvature in the node recovery') + CALL CD_HermiteCable_Dyn_End_Force(model, 1, f_damped, es, em) + model%has_bend_damping = .FALSE. + CALL CD_HermiteCable_Dyn_End_Force(model, 1, f_plain, es, em) + WRITE (*, '(A,ES11.3,A)') 'B5: the bending damping changes the end force by ', NORM2(f_damped - f_plain), ' N' + CALL require(NORM2(f_damped - f_plain) > 0.0_wp, 'B5: the end force carries the damping') + END SUBROUTINE check_recovery + +END PROGRAM test_hermite_bending_damping_dynamic