diff --git a/CHANGELOG.md b/CHANGELOG.md index bc87f14..3fd2c67 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,15 @@ All notable changes to CableDyn are recorded in this file. The format follows ### Added +- Rayleigh damping of finite-EI cables: the LINE TYPES EI column takes `EI|-zeta|f1|f2`, the + damping ratio `zeta` at the two frequencies `f1` and `f2` [Hz]. Beside the bending damping + `Bb = zeta EI/(pi (f1 + f2))` it adds a mass-proportional transverse damping + `alpha = 4 pi zeta f1 f2/(f1 + f2)` [1/s], the force `alpha m` on the velocity normal to the + tangent, so a mode has `zeta(omega) = alpha/(2 omega) + omega Bb/(2 EI)` times its bending share + for `Bb`: `zeta` at `f1` and `f2` and less between them. Free decays of modes 1 to 3 of a pinned + cable match this to 0.06 %. The velocity is absolute, so rigid transverse and pendulum motion is + damped as well (more below `f1`). No new state; exact Jacobians; the work is in `DampPow`; the + Python deck reader and builder take the form. Existing decks give bit-identical outputs. - A finite-EI line may end on a `Free` point: the line's free End B, its position free in the static equilibrium and the dynamics, with the point's Mass/Vol/CdA/Ca acting on the end node as an attachment (a free-hanging cable or riser with a clump). The static solve holds the end on diff --git a/CMakeLists.txt b/CMakeLists.txt index 31307a6..6f36ba4 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -774,7 +774,15 @@ add_executable(test_hermite_bending_damping_dynamic tests/test_hermite_bending_d 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_hermite_mass_damping tests/test_hermite_mass_damping.f90) +target_link_libraries(test_hermite_mass_damping PRIVATE cabledyn_core) +add_test(NAME hermite_mass_damping COMMAND test_hermite_mass_damping) +set_tests_properties(hermite_mass_damping PROPERTIES LABELS "fortran;unit;damping") +add_executable(test_hermite_mass_damping_dynamic tests/test_hermite_mass_damping_dynamic.f90) +target_link_libraries(test_hermite_mass_damping_dynamic PRIVATE cabledyn_core) +add_test(NAME hermite_mass_damping_dynamic COMMAND test_hermite_mass_damping_dynamic) +set_tests_properties(hermite_mass_damping_dynamic PROPERTIES LABELS "fortran;unit;dynamic;damping") +# Bending damping on a deck (EI|Bb, EI|-zeta|f, EI|-zeta|f1|f2): 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) @@ -3554,6 +3562,8 @@ if(CABLEDYN_ENABLE_COVERAGE) test_hermite_axial_damping test_hermite_bending_damping test_hermite_bending_damping_dynamic + test_hermite_mass_damping + test_hermite_mass_damping_dynamic test_bending_damping_deck test_hermite_cable_control test_control_torsion diff --git a/doc/capabilities.rst b/doc/capabilities.rst index 9107067..6cca977 100644 --- a/doc/capabilities.rst +++ b/doc/capabilities.rst @@ -119,6 +119,11 @@ Line and constitutive capability - 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`) + * - Rayleigh damping of finite-EI cables (``EI|-zeta|f1|f2``) + - Supported + - the bending damping plus a mass-proportional transverse damping ``alpha m`` on the + velocity normal to the tangent, holding a damping ratio at two frequencies; absolute + velocity, so rigid transverse and pendulum motion is damped too (: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 9ab410a..ea2569d 100644 --- a/doc/driver_format.md +++ b/doc/driver_format.md @@ -244,7 +244,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²]; `EI|Bb` or `EI|-zeta|f` adds bending damping (below) | finite and ≥ 0; see [EI routing](#ei-routing) | +| `EI` | bending stiffness [N·m²]; `EI|Bb` or `EI|-zeta|f` adds bending damping, `EI|-zeta|f1|f2` Rayleigh 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 | @@ -295,6 +295,17 @@ frequency `f` [Hz], `Bb = ζ EI/(π f)`, set once per line type (it does not dep `EI|0` is the plain `EI`. It needs `EI > 0` and acts in the dynamics only (a static solve has no rates). +**Rayleigh damping.** `EI|-zeta|f1|f2` gives the ratio `0 < ζ < 1` at two frequencies `f1` and `f2` +[Hz]: beside the bending damping `Bb = ζ EI/(π (f1 + f2))` it adds a mass-proportional transverse +damping `α = 4π ζ f1 f2/(f1 + f2)` [1/s], the force `α m` (`m` the line's mass per metre) on the +velocity normal to the cable's tangent (see [Mass-proportional damping](theory.rst)). A mode then +has `ζ(ω) = α/(2ω) + ω Bb/(2 EI) · EI k²/(EI k² + T)`: `ζ` at `f1` and `f2` for a mode whose +stiffness is all bending, less between them and more outside. In water the `α` share falls with +the added mass, `m/(m + m_a)`. The velocity is absolute, so the term also damps the rigid +transverse motion and pendulum swing of a span, increasingly below `f1` (`α/(2ω)`): set `f1` at +the lowest frequency of interest. It needs `EI > 0`, is set once per line type and acts in the +dynamics only. + **Cross-flow VIV columns (MoorDyn v2).** A 10-column row may end with `Cl` (11 columns) or `Cl dF cF` (13 columns), and a 14-column row likewise (15 or 17 columns, so a line restrained in torsion can carry VIV): the lift coefficient of the vortex-shedding synchronisation model and @@ -1924,7 +1935,7 @@ bending moment. None of these channels is mandatory. | `Twist` | line L total twist `Phi − Theta = M C`, end-spring windup included; on a line free at one end the twist of its elements, the free end's turn. Only on a line solved in torsion | deg | | `VIVPow` | line L power of the VIV loads (cross-flow lift, and the in-line force of a `VIV` section row) at the committed state, positive into the line ([Outputs](outputs.rst)); 0 in static runs | W | | `DragPow` | line L power of the Morison drag (and, on a finite-EI line, its ATTACHMENTS' drag) | W | -| `DampPow` | line L power of the structural damping (`BA`, and `EI|Bb` on a finite-EI line); never positive | W | +| `DampPow` | line L power of the structural damping (`BA`, and `EI|Bb` and the mass-proportional part of `EI|-zeta|f1|f2` on a finite-EI line); never positive | W | | `VIVPowN`, `DragPowN`, `DampPowN` | the same per unit unstretched length about node J (node J's share: half of each of its elements' power and its own node loads', over half their unstretched length) | W/m | | `VIVAmpN` | line L smoothed cross-flow amplitude estimate at node J (Thorsen et al. 2016, Eq. 9), which a [VIV AMPLITUDE](#viv-amplitude-optional) table reads; only on a line with such a table; 0 at a node without VIV | m | diff --git a/doc/outputs.rst b/doc/outputs.rst index 988ff65..613ba74 100644 --- a/doc/outputs.rst +++ b/doc/outputs.rst @@ -890,7 +890,8 @@ committed state, positive when the load puts energy into the line: - W * - ``DampPow`` - power of the structural damping: the axial dashpot ``BA`` and, on a finite-EI line, the - bending dashpot (``EI|Bb``); never positive + bending dashpot (``EI|Bb``) and the mass-proportional damping (``EI|-zeta|f1|f2``); never + positive - W * - ``VIVPowN``, ``DragPowN``, ``DampPowN`` - the same per unit unstretched length about node ``J`` diff --git a/doc/theory.rst b/doc/theory.rst index eec0d44..7c6d70f 100644 --- a/doc/theory.rst +++ b/doc/theory.rst @@ -916,6 +916,78 @@ pinned cable reproduces this ratio to 0.05 % in the bending- and tension-dominat (``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). +.. _theory-mass-damping: + +Mass-proportional (Rayleigh) damping +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +The bending damping alone gives :math:`\zeta \propto \omega`: a ratio set at one frequency is too +low below it and too high above it, so a broad VIV band cannot hold one :math:`\zeta`. The form +``EI|-zeta|f1|f2`` (LINE TYPES) adds a mass-proportional term, which makes the pair a Rayleigh +damping :math:`\alpha\,\mathbf M + \beta\,\mathbf K_b` with :math:`\beta = B_b/EI`. With +:math:`\mathbf v = \dot{\mathbf r}` the velocity interpolated by the shape functions of the +consistent mass and :math:`m` the line's mass per unstretched length (``MassDenInAir``, with a +stiffener sleeve's where ``STIFFENERS`` adds one), the +element's dissipation function is + +.. math:: + + \psi_\alpha = \int_0^{L_0} \tfrac{1}{2}\,\alpha\,m\, + \lvert(\mathbf{I} - \mathbf{t}\mathbf{t}^\mathsf{T})\,\mathbf v\rvert^2\,\mathrm{d}s , + +and the damping force is :math:`\mathbf f_\alpha = \partial\psi_\alpha/\partial\dot{\mathbf q} = +\int_0^{L_0} \alpha\,m\,\mathbf N^\mathsf{T}(\mathbf I - \mathbf t\mathbf t^\mathsf{T})\,\mathbf v\,\mathrm ds` +(:math:`\mathbf N` the cubic-Hermite position shape functions, four-point Gauss rule as the mass). +Its velocity Jacobian :math:`\int \alpha m\,\mathbf N^\mathsf{T}(\mathbf I - \mathbf t\mathbf t^\mathsf{T}) +\mathbf N\,\mathrm ds` is symmetric; its position Jacobian follows from +:math:`\partial\mathbf t/\partial\mathbf r' = (\mathbf I - \mathbf t\mathbf t^\mathsf{T})/\lvert\mathbf r'\rvert`, + +.. math:: + + \frac{\partial \mathbf f_\alpha}{\partial \mathbf q} = -\int_0^{L_0} \frac{\alpha\,m}{\lvert\mathbf r'\rvert}\, + \mathbf N^\mathsf{T}\Big[(\mathbf I - \mathbf t\mathbf t^\mathsf{T})(\mathbf t\cdot\mathbf v) + + \mathbf t\,\big((\mathbf I - \mathbf t\mathbf t^\mathsf{T})\mathbf v\big)^\mathsf{T}\Big]\, + \mathbf N_{,s}\,\mathrm ds , + +so the Newton tangent stays exact. On a straight span the force is :math:`\alpha\,\mathbf M\,\mathbf v` +in the two transverse directions and zero along the axis: axial motion is left to ``BA``. A +transverse mode whose modal mass is the line's own is damped at :math:`\alpha/(2\omega)`, and with +the bending damping the ratio is + +.. math:: + + \zeta(\omega) = \frac{\alpha}{2\,\omega} + \frac{\omega\,B_b}{2\,EI}\;\frac{EI\,k^2}{EI\,k^2 + T} . + +``EI|-zeta|f1|f2`` sets + +.. math:: + + B_b = \frac{\zeta\,EI}{\pi\,(f_1 + f_2)}, \qquad \alpha = \frac{4\pi\,\zeta\,f_1 f_2}{f_1 + f_2} , + +so a mode whose stiffness is all bending has the ratio :math:`\zeta` at :math:`f_1` and +:math:`f_2`, less between them (at least :math:`2\zeta\sqrt{f_1 f_2}/(f_1 + f_2)`, at +:math:`\sqrt{f_1 f_2}`) and more outside. Free decays of modes 1, 2 and 3 of a pinned cable +reproduce :math:`\zeta(\omega)` for :math:`\alpha` alone, :math:`B_b` alone and both to 0.06 %, and +the target at :math:`f_1` and :math:`f_2` to 0.03 % (``test_hermite_mass_damping_dynamic``). +The +ratio is lower in two cases: :math:`B_b` damps a mode with tension in its bending share only, and +:math:`\alpha` damps a mode in water in the share :math:`m/(m + m_a)` of its modal mass, since the +added mass :math:`m_a` (and an attachment's mass) is not in :math:`\alpha\,\mathbf M`. + +The velocity is absolute (the earth frame), as in the usual Rayleigh model. The term therefore +damps a rigid transverse translation and the pendulum swing of a span, and it opposes the +transverse motion a moving fairlead imposes, as a linear drag :math:`\alpha m\,\mathbf v_n` would in +still water. Its ratio :math:`\alpha/(2\omega)` grows as the frequency falls, so motions well below +:math:`f_1` (slow drift, a moored line's pendulum and the low-frequency response of a coupled +floater) are damped more than the target; set :math:`f_1` at the lowest frequency the analysis +must resolve and compare the low-frequency response against the run without the pair. A velocity +relative to the cable's filtered motion (the frame :ref:`theory-viv-frame` uses) would exempt +slow motions, but it adds a filter state, lags the damping and replaces :math:`\alpha/(2\omega)` +by a factor that depends on the filter, so the pair would no longer hold :math:`\zeta` at +:math:`f_1`; CableDyn keeps the absolute velocity and no state. The force joins the structural +damping load beside ``BA`` and :math:`B_b` (the end forces and ``DampPow`` carry it). ``EI = 0`` +lines have no counterpart: the form needs a finite-EI cable, as the bending damping does. + Viscoelastic rope (MoorDyn ``ElasticMod`` 2 and 3) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/python/cabledyn/builder.py b/python/cabledyn/builder.py index e0bed97..672c70f 100644 --- a/python/cabledyn/builder.py +++ b/python/cabledyn/builder.py @@ -195,7 +195,9 @@ class LineType: 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)``). + (written ``EI|-zeta|f``; ``Bb = zeta EI / (pi f)``); ``(EI, -zeta, f1, f2)`` + adds the mass-proportional damping ``alpha`` beside ``Bb``, the Rayleigh + pair that holds ``zeta`` at ``f1`` and ``f2`` (written ``EI|-zeta|f1|f2``). cdn, cdt, can, cat : float Normal and tangential drag and added-mass coefficients. gas, gj, irt, irn : float | None @@ -2768,8 +2770,10 @@ def _line_type_table(self) -> tuple[str, str, list[list[str]]]: row.append(f'"{_render(ea)}"') else: row.append(_multi(item.ea, 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)") + if isinstance(item.ei, tuple) and len(item.ei) not in (2, 3, 4): + raise ValueError( + f"{what}: ei is EI, (EI, Bb), (EI, -zeta, f) or (EI, -zeta, f1, f2)" + ) 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): diff --git a/python/cabledyn/deck_file.py b/python/cabledyn/deck_file.py index 3b2b5d3..bec0fbb 100644 --- a/python/cabledyn/deck_file.py +++ b/python/cabledyn/deck_file.py @@ -4195,7 +4195,7 @@ def numeric(token: str, row: DeckRecord, field: str) -> float: 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 + continue # the EI column (EI, EI|Bb, EI|-zeta|f, EI|-zeta|f1|f2) 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("|") @@ -4257,12 +4257,13 @@ 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" ) - # native parse_ei_column: EI, EI|Bb (bending damping, N m^2 s) or EI|-zeta|f + # native parse_ei_column: EI, EI|Bb (bending damping, N m^2 s), EI|-zeta|f or + # EI|-zeta|f1|f2 (the Rayleigh pair of Bb and the mass-proportional alpha) ei_parts = row.tokens[5].split("|") - if len(ei_parts) > 3: + if len(ei_parts) > 4: raise DeckFormatError( - f'{self._at(row)}: LINE TYPES EI column "{row.tokens[5]}" takes EI, EI|Bb ' - "or EI|-zeta|f" + f'{self._at(row)}: LINE TYPES EI column "{row.tokens[5]}" takes EI, EI|Bb, ' + "EI|-zeta|f or EI|-zeta|f1|f2" ) ei = numeric(ei_parts[0], row, "EI") bend_damping = 0.0 @@ -4287,9 +4288,24 @@ def numeric(token: str, row: DeckRecord, field: str) -> float: "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 + elif len(ei_parts) == 4: + ratio = numeric(ei_parts[1], row, "EI|-zeta|f1|f2 ratio") + f_one = numeric(ei_parts[2], row, "EI|-zeta|f1|f2 frequency f1") + f_two = numeric(ei_parts[3], row, "EI|-zeta|f1|f2 frequency f2") + if not -1.0 < ratio < 0.0: + raise DeckFormatError( + f'{self._at(row)}: LINE TYPES EI column "{row.tokens[5]}": ' + "EI|-zeta|f1|f2 takes a damping ratio 0 < zeta < 1, written negative" + ) + if not (f_one > 0.0 and f_two > 0.0): + raise DeckFormatError( + f'{self._at(row)}: LINE TYPES EI column "{row.tokens[5]}": the ' + "frequencies f1 and f2 of EI|-zeta|f1|f2 must be positive [Hz]" + ) + bend_damping = -ratio * ei / (math.pi * (f_one + f_two)) + # a damping asked for (a 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: + 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)" diff --git a/python/tests/test_builder.py b/python/tests/test_builder.py index 7a887fa..d1caf63 100644 --- a/python/tests/test_builder.py +++ b/python/tests/test_builder.py @@ -1155,7 +1155,7 @@ 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)]) +@pytest.mark.parametrize("ei", [(1.0e4, 250.0), (1.0e4, -0.02, 1.5), (1.0e4, -0.02, 0.5, 2.0)]) def test_bending_damping_round_trips_in_the_ei_column( tmp_path: Path, ei: tuple[float, ...] ) -> None: @@ -1232,8 +1232,10 @@ def test_no_viv_section_without_inline_viv(tmp_path: Path) -> None: 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.add_line_type("cable", diam=0.2, mass=40.0, ea=5.0e8, ei=(1.0e4, -0.02, 1.0, 2.0, 3.0)) + with pytest.raises( + ValueError, match=r"ei is EI, \(EI, Bb\), \(EI, -zeta, f\) or \(EI, -zeta, f1, f2\)" + ): model.to_text() diff --git a/python/tests/test_deck_native_parity.py b/python/tests/test_deck_native_parity.py index 47bfe11..3f02b2f 100644 --- a/python/tests/test_deck_native_parity.py +++ b/python/tests/test_deck_native_parity.py @@ -958,7 +958,7 @@ def test_stiffener_rows_are_native(row, message): @pytest.mark.parametrize( "ei", - ["1.99e4|250.0", "1.99e4|0", "1.99e4|-0.02|1.5"], + ["1.99e4|250.0", "1.99e4|0", "1.99e4|-0.02|1.5", "1.99e4|-0.02|0.5|2.0"], ) def test_bending_damping_forms_are_accepted(ei): DeckFile.from_text( @@ -969,7 +969,10 @@ def test_bending_damping_forms_are_accepted(ei): @pytest.mark.parametrize( ("ei", "message"), [ - ("1.99e4|1|2|3", "takes EI, EI|Bb or EI|-zeta|f"), + ("1.99e4|-0.02|1|2|3", "takes EI, EI|Bb, EI|-zeta|f or EI|-zeta|f1|f2"), + ("1.99e4|0.02|0.5|2.0", "EI|-zeta|f1|f2 takes a damping ratio 0 < zeta < 1"), + ("1.99e4|-0.02|0.5|0", "frequencies f1 and f2 of EI|-zeta|f1|f2 must be positive"), + ("0.0|-0.02|0.5|2.0", "bending damping (EI|Bb) needs a finite-EI cable"), ("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"), diff --git a/src/CableDyn_DeckDriver.f90 b/src/CableDyn_DeckDriver.f90 index 10a15ce..ec8a5e2 100644 --- a/src/CableDyn_DeckDriver.f90 +++ b/src/CableDyn_DeckDriver.f90 @@ -79,7 +79,7 @@ MODULE CableDyn_DeckDriver USE CableDyn_HermiteCable, ONLY: CD_HermiteCable_Curvature, & CD_HermiteCable_Peak_Curvature, CD_HermiteCable_Axial_Resultant, & CD_HermiteCable_Axial_Resultant_Range, CD_HermiteCable_Element, CD_HCABLE_OK, & - CD_HCABLE_BADINPUT, CD_HermiteCable_Gauss_Rule + CD_HCABLE_BADINPUT, CD_HermiteCable_Gauss_Rule, CD_HermiteCable_Rayleigh_Pair USE CableDyn_HermiteCableStatic, ONLY: CD_HermiteCable_Static_Solve_AutoMesh, CD_HermiteCable_Static_Solve, & CD_HermiteCable_Prolong_Arc, CD_HermiteCable_Kink_Advice, & CD_HermiteCable_Element_Ratio, CD_HC_OSCILLATION_REL_TOL, & @@ -127,6 +127,7 @@ MODULE CableDyn_DeckDriver 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_Bending_Damping, & + CD_HFMF_Set_Mass_Damping, & CD_HFMF_Set_AddedMass, CD_HFMF_Set_ModifiedNewton, & CD_HFMF_Set_Tensile_Monitor, CD_HFMF_Get_Tensile_Diagnostics, & CD_HFMF_Get_Recovery_Diagnostics, & @@ -420,6 +421,10 @@ MODULE CableDyn_DeckDriver ! 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 + ! mass-proportional (Rayleigh alpha) transverse damping [1/s] of a finite-EI cable, the force + ! ralpha m on the velocity normal to the tangent (CD_HermiteCable_Mass_Damping); with bb, resolved + ! from EI|-zeta|f1|f2 (zeta at f1 and f2 [Hz], CD_HermiteCable_Rayleigh_Pair) + REAL(wp) :: ralpha = 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 @@ -1923,7 +1928,7 @@ RECURSIVE SUBROUTINE build_one_hermite_cable(ln, sections, types, points, opts, REAL(wp), ALLOCATABLE :: viv_tix(:), viv_amp3(:, :, :), viv_dva(:), cdy_a(:), cdy_b(:), cdy_c(:) INTEGER, ALLOCATABLE :: viv_ampn(:) REAL(wp), ALLOCATABLE :: wo_cl0(:), wo_st(:), wo_eps(:), wo_a(:), wo_tf(:) - REAL(wp), ALLOCATABLE :: ba_raw(:), ba(:), dry_b(:), bb_el(:) + REAL(wp), ALLOCATABLE :: ba_raw(:), ba(:), dry_b(:), bb_el(:), ra_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 @@ -2265,8 +2270,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) + ALLOCATE (bb_el(SIZE(l0)), ra_el(SIZE(l0))) + CALL finite_bb_array(ln, sections, types, bb_el, ra_el) nnode = SIZE(l0) + 1 ndof = 6*nnode ALLOCATE (w(SIZE(l0)), nodes_ref(3, nnode), q0(ndof)) @@ -3354,6 +3359,7 @@ RECURSIVE SUBROUTINE build_one_hermite_cable(ln, sections, types, points, opts, 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) + CALL remap_elem_by_reference_arc(ra_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 @@ -3579,6 +3585,12 @@ RECURSIVE SUBROUTINE build_one_hermite_cable(ln, sections, types, points, opts, CALL fail(ErrStat, ErrMsg, 'finite-EI cable bending-damping wiring failed: '//TRIM(em)); RETURN END IF END IF + IF (ANY(ra_el > CD_ZERO)) THEN + CALL CD_HFMF_Set_Mass_Damping(cable, ra_el, es, em) + IF (es /= CD_HFMF_OK) THEN + CALL fail(ErrStat, ErrMsg, 'finite-EI cable mass-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 @@ -11654,12 +11666,13 @@ 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). + SUBROUTINE finite_bb_array(ln, sections, types, bb, ralpha) + !! The line types' bending damping Bb [N m^2 s] and mass-proportional damping alpha [1/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(:) + REAL(wp), INTENT(OUT) :: bb(:), ralpha(:) INTEGER :: i, j, e e = 0 DO i = 1, SIZE(sections) @@ -11667,9 +11680,11 @@ SUBROUTINE finite_bb_array(ln, sections, types, bb) DO j = 1, sections(i)%nsegs e = e + 1 bb(e) = types(sections(i)%ltype)%bb + ralpha(e) = types(sections(i)%ltype)%ralpha END DO END DO bb = bb(SIZE(bb):1:-1) + ralpha = ralpha(SIZE(ralpha):1:-1) END SUBROUTINE finite_bb_array SUBROUTINE finite_line_type_ei(ln, sections, types, ei) @@ -16097,54 +16112,69 @@ 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). + !! Bb times the curvature rate), 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), or EI|-zeta|f1|f2, + !! the Rayleigh pair of the bending damping Bb and the mass-proportional damping alpha [1/s] + !! that holds zeta at f1 and f2 (CD_HermiteCable_Rayleigh_Pair). 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 + INTEGER :: bars(3), nbar, k, ios + REAL(wp) :: second, freq, freq2 REAL(wp), PARAMETER :: PI_L = 3.14159265358979323846_wp + CHARACTER(*), PARAMETER :: FORMS = 'EI, EI|Bb, EI|-zeta|f or EI|-zeta|f1|f2' ErrStat = 0; ErrMsg = '' t%bb = CD_ZERO + t%ralpha = CD_ZERO second = CD_ZERO freq = CD_ZERO - bar = INDEX(ei_str, '|') - bar2 = 0 - IF (bar == 0) THEN + freq2 = CD_ZERO + ! the bar positions; a fourth bar is refused + nbar = 0 + bars = 0 + DO k = 1, LEN_TRIM(ei_str) + IF (ei_str(k:k) /= '|') CYCLE + IF (nbar == 3) THEN + CALL fail(ErrStat, ErrMsg, 'LINE TYPES EI column "'//TRIM(ei_str)//'" takes '//FORMS); RETURN + END IF + nbar = nbar + 1 + bars(nbar) = k + END DO + SELECT CASE (nbar) + CASE (0) 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 + CASE (1) + READ (ei_str(1:bars(1) - 1), *, IOSTAT=ios) t%ei + IF (ios == 0) READ (ei_str(bars(1) + 1:), *, IOSTAT=ios) second + CASE (2) + READ (ei_str(1:bars(1) - 1), *, IOSTAT=ios) t%ei + IF (ios == 0) READ (ei_str(bars(1) + 1:bars(2) - 1), *, IOSTAT=ios) second + IF (ios == 0) READ (ei_str(bars(2) + 1:), *, IOSTAT=ios) freq + CASE DEFAULT + READ (ei_str(1:bars(1) - 1), *, IOSTAT=ios) t%ei + IF (ios == 0) READ (ei_str(bars(1) + 1:bars(2) - 1), *, IOSTAT=ios) second + IF (ios == 0) READ (ei_str(bars(2) + 1:bars(3) - 1), *, IOSTAT=ios) freq + IF (ios == 0) READ (ei_str(bars(3) + 1:), *, IOSTAT=ios) freq2 + END SELECT 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 + CALL fail(ErrStat, ErrMsg, 'LINE TYPES EI column "'//TRIM(ei_str)//'" is not '//FORMS); RETURN END IF - IF (.NOT. (IEEE_IS_FINITE(t%ei) .AND. IEEE_IS_FINITE(second) .AND. IEEE_IS_FINITE(freq))) THEN + IF (.NOT. (IEEE_IS_FINITE(t%ei) .AND. IEEE_IS_FINITE(second) .AND. IEEE_IS_FINITE(freq) .AND. & + IEEE_IS_FINITE(freq2))) 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 + SELECT CASE (nbar) + CASE (0) + RETURN + CASE (1) 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 + CASE (2) 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 @@ -16154,10 +16184,20 @@ SUBROUTINE parse_ei_column(ei_str, t, ErrStat, ErrMsg) 'EI|-zeta|f must be positive [Hz]'); RETURN END IF t%bb = -second*t%ei/(PI_L*freq) - END IF + CASE DEFAULT + IF (.NOT. (second < CD_ZERO .AND. second > -CD_ONE)) THEN + CALL fail(ErrStat, ErrMsg, 'LINE TYPES EI column "'//TRIM(ei_str)//'": EI|-zeta|f1|f2 takes a '// & + 'damping ratio 0 < zeta < 1, written negative'); RETURN + END IF + IF (.NOT. (freq > CD_ZERO .AND. freq2 > CD_ZERO)) THEN + CALL fail(ErrStat, ErrMsg, 'LINE TYPES EI column "'//TRIM(ei_str)//'": the frequencies f1 and f2 of '// & + 'EI|-zeta|f1|f2 must be positive [Hz]'); RETURN + END IF + CALL CD_HermiteCable_Rayleigh_Pair(-second, freq, freq2, t%ei, t%bb, t%ralpha) + END SELECT ! 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 + IF ((nbar >= 2 .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 diff --git a/src/CableDyn_HermiteCable.f90 b/src/CableDyn_HermiteCable.f90 index 39c0846..f3b32c6 100644 --- a/src/CableDyn_HermiteCable.f90 +++ b/src/CableDyn_HermiteCable.f90 @@ -45,6 +45,8 @@ MODULE CableDyn_HermiteCable PUBLIC :: CD_HermiteCable_Gauss_Rule PUBLIC :: CD_HermiteCable_Dry_Buoyancy PUBLIC :: CD_HermiteCable_Bending_Damping + PUBLIC :: CD_HermiteCable_Mass_Damping + PUBLIC :: CD_HermiteCable_Rayleigh_Pair INTEGER, PARAMETER, PUBLIC :: CD_HCABLE_OK = 0, CD_HCABLE_BADINPUT = 1 INTEGER, PARAMETER :: NG = 4 !! default Gauss points per element @@ -615,6 +617,129 @@ END SUBROUTINE fail END SUBROUTINE CD_HermiteCable_Bending_Damping + SUBROUTINE CD_HermiteCable_Mass_Damping(qr, vr, L, cm, fdamp, Kq, Kv, ErrStat, ErrMsg) + !! Mass-proportional (Rayleigh alpha) transverse damping of one cubic-Hermite element: the + !! dissipation function + !! psi = integral_0^L 1/2 cm |(I - t t^T) v|^2 ds, cm = alpha rho_a [N s/m^2], + !! with v = dr/dt the interpolated velocity (the shape functions of the consistent mass), t = + !! a/|a| the unit tangent (a = dr/ds) and s the unstretched arc length. The force is alpha + !! times the line's own mass on the velocity normal to the tangent: on a straight element it is + !! alpha M v in the two transverse directions (M the consistent mass, CD_HermiteCable_Mass) and + !! zero along the axis, so a transverse mode whose mass is the line's own has the damping + !! ratio alpha/(2 omega) and axial sliding is not damped. The velocity is absolute: a rigid + !! transverse translation or a pendulum swing of the line is damped as well. + !! + !! fdamp = d psi / d v is an INTERNAL generalised force (v . fdamp = 2 psi >= 0); Kq = d fdamp/dq + !! and Kv = d fdamp/dv are the exact Jacobians (Kv symmetric, Kq not). qr and vr are the element + !! DOFs [r1, m1, r2, m2] and their rates; L the unstretched length; cm >= 0. Four-point Gauss + !! quadrature, as the consistent mass. + REAL(wp), INTENT(IN) :: qr(12), vr(12), L, cm + 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 + + REAL(wp) :: gp(MAX_NG), gw(MAX_NG), H(4), dH(4), ddH(4), b1(4), av(3), vv(3), tv(3), un(3) + REAL(wp) :: Pm(3, 3), Dm(3, 3), s2, sp, st, wc, wkm + INTEGER :: qg, c, dd, kn, mn, ic, jc + INTEGER, PARAMETER :: sd(4) = [0, 3, 6, 9] + + ErrStat = CD_HCABLE_OK + ErrMsg = '' + fdamp = CD_ZERO + IF (PRESENT(Kq)) Kq = CD_ZERO + IF (PRESENT(Kv)) Kv = CD_ZERO + IF (.NOT. CD_All_Finite(qr) .OR. .NOT. CD_All_Finite(vr) .OR. .NOT. CD_Is_Finite(L) .OR. & + .NOT. CD_Is_Finite(cm)) 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 (cm < CD_ZERO) THEN + CALL fail('the damping coefficient must be non-negative'); RETURN + END IF + IF (.NOT. (cm > CD_ZERO)) RETURN + + CALL CD_HermiteCable_Gauss_Rule(NG, gp, gw) + DO qg = 1, NG + CALL hermite_shapes(gp(qg), L, H, dH, ddH) + b1 = dH/L + DO c = 1, 3 + av(c) = SUM(b1*qr(sd + c)); vv(c) = SUM(H*vr(sd + c)) + END DO + 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 + st = SUM(tv*vv) + un = vv - st*tv ! (I - t t^T) v + wc = gw(qg)*L*cm + DO kn = 1, 4 + DO c = 1, 3 + fdamp(sd(kn) + c) = fdamp(sd(kn) + c) + wc*H(kn)*un(c) + END DO + END DO + IF (.NOT. (PRESENT(Kq) .OR. PRESENT(Kv))) CYCLE + ! P = I - t t^T; D(c, k) = d (P v)_c / d a_k = -((I - t t^T)_ck (t . v) + t_c (P v)_k)/|a| + DO dd = 1, 3 + DO c = 1, 3 + Pm(c, dd) = -tv(c)*tv(dd) + END DO + Pm(dd, dd) = Pm(dd, dd) + CD_ONE + END DO + DO dd = 1, 3 + DO c = 1, 3 + Dm(c, dd) = -(Pm(c, dd)*st + tv(c)*un(dd))/sp + END DO + END DO + DO mn = 1, 4 + DO kn = 1, 4 + wkm = wc*H(kn) + DO dd = 1, 3 + jc = sd(mn) + dd + DO c = 1, 3 + ic = sd(kn) + c + IF (PRESENT(Kv)) Kv(ic, jc) = Kv(ic, jc) + wkm*H(mn)*Pm(c, dd) + IF (PRESENT(Kq)) Kq(ic, jc) = Kq(ic, jc) + wkm*b1(mn)*Dm(c, dd) + END DO + END DO + END DO + END DO + END DO + IF (.NOT. CD_All_Finite(fdamp)) THEN + CALL fail('non-finite mass damping force'); RETURN + END IF + + CONTAINS + + SUBROUTINE fail(msg) + CHARACTER(*), INTENT(IN) :: msg + ErrStat = CD_HCABLE_BADINPUT + ErrMsg = 'CD_HermiteCable_Mass_Damping: '//msg + fdamp = CD_ZERO + IF (PRESENT(Kq)) Kq = CD_ZERO + IF (PRESENT(Kv)) Kv = CD_ZERO + END SUBROUTINE fail + + END SUBROUTINE CD_HermiteCable_Mass_Damping + + PURE SUBROUTINE CD_HermiteCable_Rayleigh_Pair(zeta, f1, f2, EI, Bb, alpha) + !! The bending damping Bb [N m^2 s] and the mass-proportional coefficient alpha [1/s] that give + !! the damping ratio zeta(omega) = alpha/(2 omega) + (Bb/EI) omega/2 the value zeta at the two + !! frequencies f1 and f2 [Hz] (omega = 2 pi f): Bb = zeta EI/(pi (f1 + f2)) and + !! alpha = 4 pi zeta f1 f2/(f1 + f2). Between f1 and f2 the ratio is lower, at least + !! 2 zeta sqrt(f1 f2)/(f1 + f2) at sqrt(f1 f2); outside it is higher. The caller checks + !! 0 < zeta and f1, f2 > 0. + REAL(wp), INTENT(IN) :: zeta, f1, f2, EI + REAL(wp), INTENT(OUT) :: Bb, alpha + REAL(wp), PARAMETER :: PI_L = 3.14159265358979323846_wp + Bb = zeta*EI/(PI_L*(f1 + f2)) + alpha = 4.0_wp*PI_L*zeta*f1*f2/(f1 + f2) + END SUBROUTINE CD_HermiteCable_Rayleigh_Pair + 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 7e320ee..1574aa4 100644 --- a/src/CableDyn_HermiteCableDynamic.f90 +++ b/src/CableDyn_HermiteCableDynamic.f90 @@ -62,7 +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_HermiteCable_Bending_Damping, CD_HermiteCable_Mass_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, & @@ -99,6 +99,7 @@ MODULE CableDyn_HermiteCableDynamic 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_Mass_Damping PUBLIC :: CD_HermiteCable_Dyn_Set_EndConnection PUBLIC :: CD_HermiteCable_Dyn_Set_Torsion PUBLIC :: CD_HermiteCable_Dyn_Torsion_State @@ -277,6 +278,11 @@ MODULE CableDyn_HermiteCableDynamic ! element-load column 2 and the Kvel tangent). Off by default. LOGICAL :: has_bend_damping = .FALSE. REAL(wp), ALLOCATABLE :: Bb(:) + ! Optional mass-proportional (Rayleigh alpha) transverse damping (CD_HermiteCable_Mass_Damping): + ! ray_alpha [1/s] per element, the force ray_alpha rho_a on the velocity normal to the tangent. + ! It joins the structural-damping load (not its bending part). No state. Off by default. + LOGICAL :: has_mass_damping = .FALSE. + REAL(wp), ALLOCATABLE :: ray_alpha(:) ! 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 @@ -2292,7 +2298,7 @@ SUBROUTINE CD_HermiteCable_Dyn_Load_Power(model, p_viv, p_drag, p_damp, ErrStat, DO e = 1, model%ne qe(1:6) = model%q(6*(e - 1) + 1:6*e); qe(7:12) = model%q(6*e + 1:6*(e + 1)) ve(1:6) = model%v(6*(e - 1) + 1:6*e); ve(7:12) = model%v(6*e + 1:6*(e + 1)) - IF (model%has_axial_damping .OR. model%has_bend_damping) THEN + IF (model%has_axial_damping .OR. model%has_bend_damping .OR. model%has_mass_damping) THEN ! an internal force: the load on the nodes is -fe CALL structural_damping_element(model, e, qe, ve, fe, ErrStat, ErrMsg) IF (ErrStat /= CD_HCDYN_OK) THEN @@ -4067,14 +4073,80 @@ SUBROUTINE fail(msg) END SUBROUTINE fail END SUBROUTINE CD_HermiteCable_Dyn_Set_Bending_Damping + SUBROUTINE CD_HermiteCable_Dyn_Set_Mass_Damping(model, alpha, ErrStat, ErrMsg) + !! Install the per-element mass-proportional (Rayleigh alpha) coefficients alpha [1/s]: the + !! damping force alpha rho_a on the velocity normal to the tangent (CD_HermiteCable_Mass_Damping), + !! the alpha M part of a Rayleigh damping alpha M + beta K beside the bending damping Bb = beta EI. + !! An all-zero array disables the contribution exactly. Transactional, and it refreshes the + !! consistent acceleration, as CD_HermiteCable_Dyn_Set_Bending_Damping. + TYPE(CD_HermiteCableDynType), INTENT(INOUT) :: model + REAL(wp), INTENT(IN) :: alpha(:) + INTEGER, INTENT(OUT) :: ErrStat + CHARACTER(*), INTENT(OUT) :: ErrMsg + + REAL(wp), ALLOCATABLE :: old_alpha(:), new_alpha(:), 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(alpha) /= model%ne) THEN + CALL fail('alpha must have length ne'); RETURN + END IF + IF (.NOT. CD_All_Finite(alpha) .OR. ANY(alpha < CD_ZERO)) THEN + CALL fail('alpha must be finite and non-negative'); RETURN + END IF + + ALLOCATE (new_alpha(model%ne), old_a(model%ndof), STAT=istat) + IF (istat /= 0) THEN + CALL fail('workspace allocation failed'); RETURN + END IF + new_alpha = alpha + old_a = model%a + old_has = model%has_mass_damping + CALL MOVE_ALLOC(model%ray_alpha, old_alpha) + IF (ANY(new_alpha > CD_ZERO)) THEN + CALL MOVE_ALLOC(new_alpha, model%ray_alpha) + model%has_mass_damping = .TRUE. + ELSE + model%has_mass_damping = .FALSE. + END IF + + CALL solve_consistent_acceleration(model, es, em) + IF (es /= CD_HCDYN_OK) THEN + IF (ALLOCATED(model%ray_alpha)) DEALLOCATE (model%ray_alpha) + CALL MOVE_ALLOC(old_alpha, model%ray_alpha) + model%has_mass_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_Mass_Damping: '//msg + END SUBROUTINE fail + END SUBROUTINE CD_HermiteCable_Dyn_Set_Mass_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. + !! The structural damping load of element e: the axial dashpot (BA, with the controlled-length + !! rate), the bending dashpot (Bb) and the mass-proportional transverse damping (ray_alpha), + !! summed in that order, as an internal generalised force, with their exact Jacobians + !! kdq = d/dq, kdv = d/dv when requested. Without bending and mass damping the axial kernel's + !! output is returned as it stands (bit for bit). Under active line control the axial and + !! bending rates include the controlled-length rate l0_dot; fixed_length = .TRUE. leaves it out + !! (the node recovery's form). The mass damping takes the interpolated velocity, as the inertia. + !! 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) @@ -4087,6 +4159,7 @@ SUBROUTINE structural_damping_element(model, e, qe, ve, fdamp, ErrStat, ErrMsg, REAL(wp) :: fb(12), kbq(12, 12), kbv(12, 12) LOGICAL :: want, ctrl INTEGER :: es + CHARACTER(160) :: emk want = PRESENT(kdq) .AND. PRESENT(kdv) ctrl = model%has_ctrl IF (PRESENT(fixed_length)) ctrl = ctrl .AND. .NOT. fixed_length @@ -4114,26 +4187,47 @@ SUBROUTINE structural_damping_element(model, e, qe, ve, fdamp, ErrStat, ErrMsg, 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)) + IF (model%has_bend_damping) THEN + IF (model%Bb(e) > CD_ZERO) THEN + 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 IF + END IF + IF (.NOT. model%has_mass_damping) RETURN + IF (.NOT. (model%ray_alpha(e) > CD_ZERO)) RETURN + ! alpha times the line's own mass rho_a: a transverse mode of the bare cable has alpha/(2 omega) + IF (want) THEN + CALL CD_HermiteCable_Mass_Damping(qe, ve, model%l0(e), model%ray_alpha(e)*model%rho_a(e), fb, kbq, kbv, & + es, emk) 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) + CALL CD_HermiteCable_Mass_Damping(qe, ve, model%l0(e), model%ray_alpha(e)*model%rho_a(e), fb, ErrStat=es, & + ErrMsg=emk) END IF IF (es /= CD_HCABLE_OK) THEN - ErrStat = CD_HCDYN_NOCONVERGE; RETURN + ErrStat = CD_HCDYN_NOCONVERGE; ErrMsg = TRIM(emk); RETURN END IF fdamp = fdamp + fb - IF (PRESENT(fbend)) fbend = fb IF (want) THEN kdq = kdq + kbq; kdv = kdv + kbv END IF @@ -7836,7 +7930,7 @@ 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 .OR. model%has_bend_damping) THEN + IF (model%has_axial_damping .OR. model%has_bend_damping .OR. model%has_mass_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 @@ -8750,7 +8844,7 @@ 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 .OR. model%has_bend_damping) THEN + IF (model%has_axial_damping .OR. model%has_bend_damping .OR. model%has_mass_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 @@ -9668,6 +9762,8 @@ SUBROUTINE CD_HermiteCable_Dyn_End(model) model%has_axial_damping = .FALSE. IF (ALLOCATED(model%Bb)) DEALLOCATE (model%Bb) model%has_bend_damping = .FALSE. + IF (ALLOCATED(model%ray_alpha)) DEALLOCATE (model%ray_alpha) + model%has_mass_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) @@ -10102,7 +10198,8 @@ 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 .OR. model%has_bend_damping)) THEN + IF (tangent_only .AND. (model%has_drag .OR. model%has_axial_damping .OR. model%has_bend_damping .OR. & + model%has_mass_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) @@ -10122,7 +10219,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 .OR. model%has_bend_damping) .AND. .NOT. tangent_only) THEN + IF ((model%has_axial_damping .OR. model%has_bend_damping .OR. model%has_mass_damping) .AND. .NOT. tangent_only) THEN DO e = e_lo, e_hi IF (kept) THEN DO a = 1, 12 @@ -11719,7 +11816,7 @@ 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 .OR. model%has_bend_damping) THEN + IF (model%has_axial_damping .OR. model%has_bend_damping .OR. model%has_mass_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 diff --git a/src/CableDyn_OpenFAST_HermiteFMF.f90 b/src/CableDyn_OpenFAST_HermiteFMF.f90 index 95749dd..4c96d00 100644 --- a/src/CableDyn_OpenFAST_HermiteFMF.f90 +++ b/src/CableDyn_OpenFAST_HermiteFMF.f90 @@ -26,6 +26,7 @@ MODULE CableDyn_OpenFAST_HermiteFMF 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_Mass_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, & @@ -61,6 +62,7 @@ MODULE CableDyn_OpenFAST_HermiteFMF PUBLIC :: CD_HFMF_Set_Drag PUBLIC :: CD_HFMF_Set_Axial_Damping PUBLIC :: CD_HFMF_Set_Bending_Damping + PUBLIC :: CD_HFMF_Set_Mass_Damping PUBLIC :: CD_HFMF_Set_ModifiedNewton PUBLIC :: CD_HFMF_Set_Tensile_Safety PUBLIC :: CD_HFMF_Set_Tensile_Monitor @@ -398,6 +400,29 @@ SUBROUTINE CD_HFMF_Set_Bending_Damping(self, Bb, ErrStat, ErrMsg) END IF END SUBROUTINE CD_HFMF_Set_Bending_Damping + SUBROUTINE CD_HFMF_Set_Mass_Damping(self, alpha, ErrStat, ErrMsg) + !! Install the per-element mass-proportional (Rayleigh alpha) coefficients alpha [1/s] on the + !! cable (CD_HermiteCable_Dyn_Set_Mass_Damping). + TYPE(CD_HFMF_ModuleType), INTENT(INOUT) :: self + REAL(wp), INTENT(IN) :: alpha(:) + 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_Mass_Damping: module not initialised' + RETURN + END IF + CALL CD_HermiteCable_Dyn_Set_Mass_Damping(self%line, alpha, es, em) + IF (es /= CD_HCDYN_OK) THEN + ErrStat = CD_HFMF_BADINPUT + ErrMsg = 'CD_HFMF_Set_Mass_Damping: '//TRIM(em) + END IF + END SUBROUTINE CD_HFMF_Set_Mass_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 index 0d1389b..c1cff53 100644 --- a/tests/test_bending_damping_deck.f90 +++ b/tests/test_bending_damping_deck.f90 @@ -2,13 +2,17 @@ ! 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 + !! Bending damping on a deck (LINE TYPES EI|Bb, EI|-zeta|f and EI|-zeta|f1|f2): 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; + !! E4 EI|-zeta|f1|f2 runs; its mass-proportional half acts (the run differs from the EI|Bb deck + !! of the same Bb = zeta EI/(pi (f1 + f2))) and lowers the hang-off curvature range further; + !! E5 the two-frequency form with a positive ratio, a zero frequency or on an EI = 0 type is !! refused by name. USE CableDyn_Precision, ONLY: wp USE CableDyn_DeckDriver, ONLY: CD_Run_Deck_Driver, CD_DECKDRV_OK @@ -17,6 +21,7 @@ PROGRAM test_bending_damping_deck INTEGER :: nfail = 0 CALL check_runs() + CALL check_pair() CALL check_refusals() IF (nfail > 0) THEN WRITE (*, '(A,I0,A)') 'FAIL: ', nfail, ' assertion(s) failed' @@ -175,10 +180,59 @@ SUBROUTINE check_refusals() 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') + CALL write_deck('bdd_five.dat', '2.0e4|-0.05|1|2|3', 0.0_wp) + CALL run('bdd_five.dat', 'bdd_five', ok, msg) + WRITE (*, '(A)') 'E3 five parts: '//TRIM(msg) + CALL require(.NOT. ok .AND. INDEX(msg, 'takes EI, EI|Bb, EI|-zeta|f or EI|-zeta|f1|f2') > 0, & + 'E3: five-part EI column') + CALL write_deck('bdd_pair_pos.dat', '2.0e4|0.05|0.5|2.0', 0.0_wp) + CALL run('bdd_pair_pos.dat', 'bdd_pair_pos', ok, msg) + WRITE (*, '(A)') 'E5 positive ratio: '//TRIM(msg) + CALL require(.NOT. ok .AND. INDEX(msg, 'EI|-zeta|f1|f2 takes a damping ratio 0 < zeta < 1') > 0, & + 'E5: a positive ratio in the two-frequency form') + CALL write_deck('bdd_pair_f0.dat', '2.0e4|-0.05|0.5|0', 0.0_wp) + CALL run('bdd_pair_f0.dat', 'bdd_pair_f0', ok, msg) + WRITE (*, '(A)') 'E5 zero frequency: '//TRIM(msg) + CALL require(.NOT. ok .AND. INDEX(msg, 'frequencies f1 and f2 of EI|-zeta|f1|f2 must be positive') > 0, & + 'E5: a zero frequency in the two-frequency form') + CALL write_deck('bdd_rope_pair.dat', '0.0|-0.05|0.5|2.0', 0.0_wp, rope=.TRUE.) + CALL run('bdd_rope_pair.dat', 'bdd_rope_pair', ok, msg) + WRITE (*, '(A)') 'E5 EI = 0, two-frequency form: '//TRIM(msg) + CALL require(.NOT. ok .AND. INDEX(msg, 'bending damping (EI|Bb) needs a finite-EI cable') > 0, & + 'E5: the two-frequency form on an EI = 0 type') END SUBROUTINE check_refusals + SUBROUTINE check_pair() + REAL(wp), PARAMETER :: F1 = 0.5_wp, F2 = 2.0_wp + REAL(wp), ALLOCATABLE :: tr(:, :), tb(:, :), tp(:, :) + INTEGER :: nr, nb, np + REAL(wp) :: bb, rr, rb, rp + LOGICAL :: ok + CHARACTER(1024) :: msg + CHARACTER(64) :: col + bb = ZETA*EI/(PI*(F1 + F2)) + WRITE (col, '(ES22.15)') bb + CALL write_deck('bdd_pair.dat', '2.0e4|-0.05|0.5|2.0', 20.0_wp) + CALL run('bdd_pair.dat', 'bdd_pair', ok, msg) + CALL require(ok, 'E4: the EI|-zeta|f1|f2 deck runs: '//TRIM(msg)) + CALL write_deck('bdd_pair_bb.dat', '2.0e4|'//TRIM(ADJUSTL(col)), 20.0_wp) + CALL run('bdd_pair_bb.dat', 'bdd_pair_bb', ok, msg) + CALL require(ok, 'E4: the EI|Bb deck of its Bb runs: '//TRIM(msg)) + CALL read_out('bdd_pair.out', tr, nr) + CALL read_out('bdd_pair_bb.out', tb, nb) + CALL read_out('bdd_plain.out', tp, np) + CALL require(nr > 10 .AND. nr == nb .AND. nr == np, 'E4: the runs wrote matching rows') + IF (.NOT. (nr > 10 .AND. nr == nb .AND. nr == np)) RETURN + rr = MAXVAL(tr(4, nr/2:nr)) - MINVAL(tr(4, nr/2:nr)) + rb = MAXVAL(tb(4, nb/2:nb)) - MINVAL(tb(4, nb/2:nb)) + rp = MAXVAL(tp(4, np/2:np)) - MINVAL(tp(4, np/2:np)) + WRITE (*, '(A,ES11.4,A)') 'E4: max |EI|-zeta|f1|f2 - EI|Bb| over the channels ', & + MAXVAL(ABS(tr(:, :nr) - tb(:, :nb))), ' (the alpha share)' + WRITE (*, '(A,3ES11.4,A)') 'E4: hang-off curvature range, Rayleigh pair, its Bb alone, undamped ', rr, rb, rp, & + ' 1/m' + CALL require(MAXVAL(ABS(tr(:, :nr) - tb(:, :nb))) > 1.0e-6_wp*MAXVAL(ABS(tb(:, :nb))), & + 'E4: the mass-proportional half acts') + CALL require(rr < rb .AND. rb < rp, 'E4: the mass-proportional half lowers the curvature range further') + END SUBROUTINE check_pair + END PROGRAM test_bending_damping_deck diff --git a/tests/test_hermite_load_power.f90 b/tests/test_hermite_load_power.f90 index e97efcd..d2adb34 100644 --- a/tests/test_hermite_load_power.f90 +++ b/tests/test_hermite_load_power.f90 @@ -15,6 +15,8 @@ PROGRAM test_hermite_load_power !! L4 a cable starting straight in a 0.5 m/s current with the cross-flow, in-line and !! higher-harmonic (Chh 1) VIV loads, !! the drag and the bending dashpot; + !! L6 the bending decay with the Rayleigh pair, the mass-proportional transverse damping alpha + !! beside the bending dashpot (its work is in the damping power); !! each within 0.5 % of the largest work; the damping power is never positive at any node, and !! the VIV and drag powers are zero without those loads. L5 power arrays of the wrong size are !! refused. @@ -23,19 +25,21 @@ PROGRAM test_hermite_load_power CD_HermiteCable_Dyn_Step, CD_HermiteCable_Dyn_Set_Bending_Damping, & CD_HermiteCable_Dyn_Set_Axial_Damping, CD_HermiteCable_Dyn_Set_Drag, & CD_HermiteCable_Dyn_Set_VIV, CD_HermiteCable_Dyn_Energy, & - CD_HermiteCable_Dyn_Load_Power, CD_HCDYN_OK + CD_HermiteCable_Dyn_Load_Power, CD_HermiteCable_Dyn_Set_Mass_Damping, & + 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, TENS = 1.0e4_wp REAL(wp), PARAMETER :: DIAM = 0.1_wp, RHOW = 1025.0_wp INTEGER, PARAMETER :: NE = 40, NN = NE + 1, NDOF = 6*NN - INTEGER, PARAMETER :: BENDING = 1, AXIAL = 2, DRAG = 3, VIV = 4 + INTEGER, PARAMETER :: BENDING = 1, AXIAL = 2, DRAG = 3, VIV = 4, RAYLEIGH = 5 INTEGER :: nfail = 0 CALL balance_case('L1 bending dashpot decay', BENDING) CALL balance_case('L2 axial dashpot decay', AXIAL) CALL balance_case('L3 still-water drag decay', DRAG) CALL balance_case('L4 VIV in a current', VIV) + CALL balance_case('L6 Rayleigh decay', RAYLEIGH) CALL check_refusals() IF (nfail > 0) THEN WRITE (*, '(A,I0,A)') 'FAIL: ', nfail, ' assertion(s) failed' @@ -100,7 +104,11 @@ SUBROUTINE balance_case(label, what) CALL CD_HermiteCable_Dyn_Set_Axial_Damping(model, [(2.0e4_wp, k=1, NE)], es, em) CALL require(es == CD_HCDYN_OK, label//': axial damping: '//TRIM(em)) END IF - IF (what == BENDING .OR. what == VIV) THEN + IF (what == RAYLEIGH) THEN + CALL CD_HermiteCable_Dyn_Set_Mass_Damping(model, [(0.3_wp, k=1, NE)], es, em) + CALL require(es == CD_HCDYN_OK, label//': mass damping: '//TRIM(em)) + END IF + IF (what == BENDING .OR. what == VIV .OR. what == RAYLEIGH) THEN CALL CD_HermiteCable_Dyn_Set_Bending_Damping(model, [(2.0e2_wp, k=1, NE)], es, em) CALL require(es == CD_HCDYN_OK, label//': bending damping: '//TRIM(em)) END IF @@ -142,7 +150,8 @@ SUBROUTINE balance_case(label, what) CALL require(pm_max <= 0.0_wp, label//': the damping power is never positive at a node') CALL require(zero_viv .EQV. what /= VIV, label//': VIV power only with VIV') CALL require(zero_drag .EQV. (what /= DRAG .AND. what /= VIV), label//': drag power only with drag') - IF (what == BENDING .OR. what == AXIAL) CALL require(work(3) < 0.0_wp, label//': the dashpot dissipates') + IF (what == BENDING .OR. what == AXIAL .OR. what == RAYLEIGH) & + CALL require(work(3) < 0.0_wp, label//': the dashpot dissipates') IF (what == DRAG) CALL require(work(2) < 0.0_wp, label//': still-water drag dissipates') IF (what == VIV) CALL require(work(1) > 0.0_wp, label//': the VIV loads put energy in') END SUBROUTINE balance_case diff --git a/tests/test_hermite_mass_damping.f90 b/tests/test_hermite_mass_damping.f90 new file mode 100644 index 0000000..1e3902c --- /dev/null +++ b/tests/test_hermite_mass_damping.f90 @@ -0,0 +1,203 @@ +! File: tests/test_hermite_mass_damping.f90 +! SPDX-License-Identifier: Apache-2.0 +! Copyright (c) 2026 Jae Hoon Seo, SMI Lab, Inha University +PROGRAM test_hermite_mass_damping + !! Kernel gates of the mass-proportional (Rayleigh alpha) transverse damping + !! (CD_HermiteCable_Mass_Damping) and of the two-frequency Rayleigh pair: + !! M1 Kv equals the central difference of fdamp in the rates, Kq that in the positions, on a + !! stretched 3D curved element and on a straight one; Kv is symmetric; + !! M2 fdamp is d psi / d v of the dissipation function 1/2 cm |v|^2 - 1/2 cm (t . v)^2 built + !! independently from the public shape functions, v . fdamp = 2 psi >= 0, and fdamp is + !! linear in the rates and zero for cm = 0; + !! M3 on a straight element along x the force is cm M v in y and z with M the consistent mass + !! matrix (CD_HermiteCable_Mass, per unit mass), zero in x, and an axial sliding is not + !! damped; a rigid transverse translation is (the absolute-velocity convention); + !! M4 bad inputs are refused by name; + !! M5 CD_HermiteCable_Rayleigh_Pair: alpha/(2 omega) + (Bb/EI) omega/2 equals zeta at f1 and + !! f2, and its minimum 2 zeta sqrt(f1 f2)/(f1 + f2) lies at sqrt(f1 f2). + USE CableDyn_Precision, ONLY: wp + USE, INTRINSIC :: IEEE_ARITHMETIC, ONLY: IEEE_VALUE, IEEE_QUIET_NAN + USE CableDyn_HermiteCable, ONLY: CD_HermiteCable_Mass_Damping, CD_HermiteCable_Rayleigh_Pair, CD_HCABLE_OK, & + CD_HermiteCable_Mass, CD_HermiteCable_Shapes, CD_HermiteCable_Gauss_Rule + IMPLICIT NONE + INTEGER :: nfail = 0 + REAL(wp), PARAMETER :: L = 2.5_wp, CM = 13.0_wp, PI = 3.14159265358979323846_wp + + CALL check_jacobians() + CALL check_dissipation() + CALL check_straight() + CALL check_refusals() + CALL check_pair() + IF (nfail > 0) THEN + WRITE (*, '(A,I0,A)') 'FAIL: ', nfail, ' assertion(s) failed' + ERROR STOP 1 + END IF + WRITE (*, '(A)') 'PASS: Hermite mass-proportional 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_Mass_Damping(q, v, L, CM, f, Kq, Kv, es, em) + CALL require(es == CD_HCABLE_OK, 'M1 '//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_Mass_Damping(q + dq, v, L, CM, fp, ErrStat=es, ErrMsg=em) + CALL CD_HermiteCable_Mass_Damping(q - dq, v, L, CM, 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_Mass_Damping(q, v + dq, L, CM, fp, ErrStat=es, ErrMsg=em) + CALL CD_HermiteCable_Mass_Damping(q, v - dq, L, CM, 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)') 'M1 '//label//': relative |Kq - FD|, |Kv - FD| ', eq, ev + CALL require(eq < 1.0e-7_wp, 'M1 '//label//': Kq matches the central difference') + CALL require(ev < 1.0e-7_wp, 'M1 '//label//': Kv matches the central difference') + CALL require(MAXVAL(ABS(Kv - TRANSPOSE(Kv))) <= 1.0e-13_wp*MAXVAL(ABS(Kv)), 'M1 '//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') + 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 + + REAL(wp) FUNCTION psi(q, v) + !! 1/2 cm integral (|v|^2 - (t . v)^2) ds on the four-point rule, from the public shapes + REAL(wp), INTENT(IN) :: q(12), v(12) + REAL(wp) :: gp(6), gw(6), H(4), dH(4), rp(3), vv(3), t(3) + INTEGER :: g, c + CALL CD_HermiteCable_Gauss_Rule(4, gp, gw) + psi = 0.0_wp + DO g = 1, 4 + CALL CD_HermiteCable_Shapes(gp(g), L, H, dH) + DO c = 1, 3 + rp(c) = dH(1)*q(c) + dH(2)*q(3 + c) + dH(3)*q(6 + c) + dH(4)*q(9 + c) + vv(c) = H(1)*v(c) + H(2)*v(3 + c) + H(3)*v(6 + c) + H(4)*v(9 + c) + END DO + t = rp/NORM2(rp) + psi = psi + 0.5_wp*CM*gw(g)*L*(DOT_PRODUCT(vv, vv) - DOT_PRODUCT(t, vv)**2) + END DO + END FUNCTION psi + + SUBROUTINE check_dissipation() + REAL(wp) :: q(12), v(12), f(12), f2(12), fd(12), dv(12), h, p0 + INTEGER :: es, j + CHARACTER(256) :: em + CALL curved_state(q, v) + CALL CD_HermiteCable_Mass_Damping(q, v, L, CM, f, ErrStat=es, ErrMsg=em) + CALL require(es == CD_HCABLE_OK, 'M2: evaluation: '//TRIM(em)) + DO j = 1, 12 + h = 1.0e-5_wp + dv = 0.0_wp; dv(j) = h + fd(j) = (psi(q, v + dv) - psi(q, v - dv))/(2.0_wp*h) + END DO + p0 = psi(q, v) + WRITE (*, '(A,ES11.3,A,ES11.3)') 'M2: relative |f - d psi/dv| ', MAXVAL(ABS(f - fd))/MAXVAL(ABS(fd)), & + ', |v . f - 2 psi|/psi ', ABS(DOT_PRODUCT(v, f) - 2.0_wp*p0)/p0 + CALL require(MAXVAL(ABS(f - fd)) <= 1.0e-8_wp*MAXVAL(ABS(fd)), 'M2: the force is d psi / d v') + CALL require(ABS(DOT_PRODUCT(v, f) - 2.0_wp*p0) <= 1.0e-12_wp*p0 .AND. p0 > 0.0_wp, & + 'M2: v . f = 2 psi > 0 (dissipative)') + CALL CD_HermiteCable_Mass_Damping(q, 2.0_wp*v, L, CM, f2, ErrStat=es, ErrMsg=em) + CALL require(MAXVAL(ABS(f2 - 2.0_wp*f)) <= 1.0e-14_wp*MAXVAL(ABS(f)), 'M2: linear in the rates') + CALL CD_HermiteCable_Mass_Damping(q, v, L, 0.0_wp, f2, ErrStat=es, ErrMsg=em) + CALL require(es == CD_HCABLE_OK .AND. ALL(f2 == 0.0_wp), 'M2: zero for cm = 0') + END SUBROUTINE check_dissipation + + SUBROUTINE check_straight() + REAL(wp) :: q(12), v(12), f(12), Mm(12, 12), fm(12) + INTEGER :: es, k + CHARACTER(256) :: em + q = [0.0_wp, 0.0_wp, 0.0_wp, 1.01_wp, 0.0_wp, 0.0_wp, 1.01_wp*L, 0.0_wp, 0.0_wp, 1.01_wp, 0.0_wp, 0.0_wp] + v = [0.3_wp, -0.2_wp, 0.5_wp, 0.1_wp, 0.4_wp, -0.3_wp, -0.2_wp, 0.6_wp, 0.1_wp, 0.2_wp, -0.1_wp, 0.25_wp] + CALL CD_HermiteCable_Mass_Damping(q, v, L, CM, f, ErrStat=es, ErrMsg=em) + CALL CD_HermiteCable_Mass(1.0_wp, L, Mm, es, em) + fm = CM*MATMUL(Mm, v) + DO k = 0, 3 + fm(3*k + 1) = 0.0_wp + END DO + WRITE (*, '(A,ES11.3)') 'M3: straight element, relative |f - cm M v_transverse| ', & + MAXVAL(ABS(f - fm))/MAXVAL(ABS(fm)) + CALL require(MAXVAL(ABS(f - fm)) <= 1.0e-13_wp*MAXVAL(ABS(fm)), 'M3: cm M v in y and z, zero in x') + ! axial sliding: every node moves along x, the handles still + v = [0.7_wp, 0.0_wp, 0.0_wp, 0.0_wp, 0.0_wp, 0.0_wp, 0.7_wp, 0.0_wp, 0.0_wp, 0.0_wp, 0.0_wp, 0.0_wp] + CALL CD_HermiteCable_Mass_Damping(q, v, L, CM, f, ErrStat=es, ErrMsg=em) + CALL require(ALL(f == 0.0_wp), 'M3: an axial sliding is not damped') + ! rigid transverse translation: damped as cm M v (the absolute-velocity convention) + v = [0.0_wp, 0.4_wp, 0.0_wp, 0.0_wp, 0.0_wp, 0.0_wp, 0.0_wp, 0.4_wp, 0.0_wp, 0.0_wp, 0.0_wp, 0.0_wp] + CALL CD_HermiteCable_Mass_Damping(q, v, L, CM, f, ErrStat=es, ErrMsg=em) + WRITE (*, '(A,ES11.3,A,ES11.3)') 'M3: rigid transverse translation, total force ', f(2) + f(8), & + ' N against cm L v ', CM*L*0.4_wp + CALL require(ABS(f(2) + f(8) - CM*L*0.4_wp) <= 1.0e-13_wp*CM*L*0.4_wp, & + 'M3: a rigid transverse translation is damped at cm L v') + END SUBROUTINE check_straight + + SUBROUTINE check_refusals() + REAL(wp) :: q(12), v(12), f(12) + INTEGER :: es + CHARACTER(256) :: em + CALL curved_state(q, v) + CALL CD_HermiteCable_Mass_Damping(q, v, L, -1.0_wp, f, ErrStat=es, ErrMsg=em) + CALL require(es /= CD_HCABLE_OK .AND. INDEX(em, 'non-negative') > 0, 'M4: negative cm refused') + CALL CD_HermiteCable_Mass_Damping(q, v, 0.0_wp, CM, f, ErrStat=es, ErrMsg=em) + CALL require(es /= CD_HCABLE_OK .AND. INDEX(em, 'length must be positive') > 0, 'M4: zero length refused') + v(3) = IEEE_VALUE(1.0_wp, IEEE_QUIET_NAN) + CALL CD_HermiteCable_Mass_Damping(q, v, L, CM, f, ErrStat=es, ErrMsg=em) + CALL require(es /= CD_HCABLE_OK .AND. INDEX(em, 'finite') > 0 .AND. ALL(f == 0.0_wp), 'M4: NaN rate refused') + q = 0.0_wp + v = 0.0_wp + CALL CD_HermiteCable_Mass_Damping(q, v, L, CM, f, ErrStat=es, ErrMsg=em) + CALL require(es /= CD_HCABLE_OK .AND. INDEX(em, 'degenerate') > 0, 'M4: degenerate centreline refused') + END SUBROUTINE check_refusals + + SUBROUTINE check_pair() + REAL(wp), PARAMETER :: ZETA = 0.015_wp, F1 = 0.4_wp, F2 = 3.0_wp, EI = 2.0e4_wp + REAL(wp) :: bb, alpha, z1, z2, zm, fmid + CALL CD_HermiteCable_Rayleigh_Pair(ZETA, F1, F2, EI, bb, alpha) + z1 = rayleigh_zeta(alpha, bb/EI, F1) + z2 = rayleigh_zeta(alpha, bb/EI, F2) + fmid = SQRT(F1*F2) + zm = rayleigh_zeta(alpha, bb/EI, fmid) + WRITE (*, '(A,2ES11.3,A,2ES12.4,A,ES12.4)') 'M5: Bb, alpha ', bb, alpha, '; zeta at f1, f2 ', z1, z2, & + '; at sqrt(f1 f2) ', zm + CALL require(ABS(z1 - ZETA) <= 1.0e-14_wp .AND. ABS(z2 - ZETA) <= 1.0e-14_wp, 'M5: zeta at f1 and f2') + CALL require(ABS(zm - 2.0_wp*ZETA*fmid/(F1 + F2)) <= 1.0e-14_wp, 'M5: the minimum between them') + CALL require(rayleigh_zeta(alpha, bb/EI, 0.99_wp*fmid) > zm .AND. rayleigh_zeta(alpha, bb/EI, 1.01_wp*fmid) > zm, & + 'M5: sqrt(f1 f2) is the minimum') + END SUBROUTINE check_pair + + PURE REAL(wp) FUNCTION rayleigh_zeta(alpha, beta, f) + !! alpha/(2 omega) + beta omega/2 at omega = 2 pi f + REAL(wp), INTENT(IN) :: alpha, beta, f + rayleigh_zeta = alpha/(4.0_wp*PI*f) + beta*PI*f + END FUNCTION rayleigh_zeta + +END PROGRAM test_hermite_mass_damping diff --git a/tests/test_hermite_mass_damping_dynamic.f90 b/tests/test_hermite_mass_damping_dynamic.f90 new file mode 100644 index 0000000..955d09c --- /dev/null +++ b/tests/test_hermite_mass_damping_dynamic.f90 @@ -0,0 +1,170 @@ +! File: tests/test_hermite_mass_damping_dynamic.f90 +! SPDX-License-Identifier: Apache-2.0 +! Copyright (c) 2026 Jae Hoon Seo, SMI Lab, Inha University +PROGRAM test_hermite_mass_damping_dynamic + !! Free decays of modes 1, 2 and 3 of a weightless, pinned-pinned finite-EI cable with Rayleigh + !! damping: the mass-proportional transverse damping alpha (CD_HermiteCable_Dyn_Set_Mass_Damping) + !! and the bending damping Bb (CD_HermiteCable_Dyn_Set_Bending_Damping), generalised-alpha with + !! rho_inf = 1 (no numerical damping), 200 steps a period over 12 periods. For the mode + !! sin(k x), k = n pi/L, of frequency omega^2 = (EI k^4 + T k^2)/m the damping ratio is + !! zeta = alpha/(2 omega) + omega Bb/(2 EI) * EI k^2/(EI k^2 + T), + !! alpha acting on the whole modal mass (the cable's own) and Bb on the bending share. + !! R1 alpha alone on a tensioned cable: modes 1 and 3 decay at alpha/(2 omega) to 0.25 %; + !! R2 Bb alone on the same cable: modes 1 and 3 at the bending-share ratio to 0.25 %; + !! R3 both: the sum, to 0.25 %; + !! R4 the two-frequency pair (CD_HermiteCable_Rayleigh_Pair, the EI|-zeta|f1|f2 deck form) on + !! a cable without tension, f1 and f2 the frequencies of modes 1 and 3: both decay at the + !! target zeta to 0.25 %, and mode 2, between them, at the lower Rayleigh ratio to 0.25 %; + !! R5 a negative coefficient or a wrong length is refused, and an all-zero array keeps the + !! configuration off. + USE CableDyn_Precision, ONLY: wp + USE CableDyn_HermiteCable, ONLY: CD_HermiteCable_Rayleigh_Pair + USE CableDyn_HermiteCableDynamic, ONLY: CD_HermiteCableDynType, CD_HermiteCable_Dyn_Init, & + CD_HermiteCable_Dyn_Step, CD_HermiteCable_Dyn_Set_Bending_Damping, & + CD_HermiteCable_Dyn_Set_Mass_Damping, 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, TENS = 1.0e4_wp + REAL(wp), PARAMETER :: ZT = 0.02_wp + INTEGER, PARAMETER :: NE = 40, NN = NE + 1, NDOF = 6*NN, MID = NE/2 + 1, QUARTER = NE/4 + 1 + INTEGER :: nfail = 0 + REAL(wp) :: alpha, bb, f1, f3 + + ! R1-R3: the tensioned cable; alpha and Bb each give zeta ZT to mode 1 in their own share + alpha = 2.0_wp*ZT*omega(1, TENS) + bb = 2.0_wp*ZT*EI/omega(1, TENS) + CALL decay_case('R1 alpha alone', TENS, 1, alpha, 0.0_wp) + CALL decay_case('R1 alpha alone', TENS, 3, alpha, 0.0_wp) + CALL decay_case('R2 Bb alone', TENS, 1, 0.0_wp, bb) + CALL decay_case('R2 Bb alone', TENS, 3, 0.0_wp, bb) + CALL decay_case('R3 alpha and Bb', TENS, 1, alpha, bb) + CALL decay_case('R3 alpha and Bb', TENS, 3, alpha, bb) + ! R4: the pair holding ZT at the frequencies of modes 1 and 3 of the cable without tension + f1 = omega(1, 0.0_wp)/(2.0_wp*PI) + f3 = omega(3, 0.0_wp)/(2.0_wp*PI) + CALL CD_HermiteCable_Rayleigh_Pair(ZT, f1, f3, EI, bb, alpha) + CALL decay_case('R4 zeta at f1 and f3', 0.0_wp, 1, alpha, bb, ZT) + CALL decay_case('R4 zeta at f1 and f3', 0.0_wp, 3, alpha, bb, ZT) + CALL decay_case('R4 zeta at f1 and f3', 0.0_wp, 2, alpha, bb) + CALL check_refusals() + IF (nfail > 0) THEN + WRITE (*, '(A,I0,A)') 'FAIL: ', nfail, ' assertion(s) failed' + ERROR STOP 1 + END IF + WRITE (*, '(A)') 'PASS: Hermite Rayleigh 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 + + PURE REAL(wp) FUNCTION omega(n, tens) + INTEGER, INTENT(IN) :: n + REAL(wp), INTENT(IN) :: tens + REAL(wp) :: k + k = REAL(n, wp)*PI/LL + omega = SQRT((EI*k**4 + tens*k**2)/RHOA) + END FUNCTION omega + + SUBROUTINE setup(model, tens, n, a0) + !! The cable along x, pinned at both ends, at rest in its mode n of amplitude a0 (z). + TYPE(CD_HermiteCableDynType), INTENT(OUT) :: model + REAL(wp), INTENT(IN) :: tens, a0 + INTEGER, INTENT(IN) :: n + REAL(wp) :: l0(NE), ea_(NE), ei_(NE), rho(NE), w(NE), q(NDOF), eps, lt, x, kn + INTEGER :: k, es + CHARACTER(512) :: em + eps = tens/EA; lt = (1.0_wp + eps)*LL + kn = REAL(n, wp)*PI/lt + 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(kn*x), (1.0_wp + eps), 0.0_wp, (1.0_wp + eps)*a0*kn*COS(kn*x)] + 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, n, alpha_c, bb_c, zeta_target) + CHARACTER(*), INTENT(IN) :: label + REAL(wp), INTENT(IN) :: tens, alpha_c, bb_c + INTEGER, INTENT(IN) :: n + REAL(wp), INTENT(IN), OPTIONAL :: zeta_target + TYPE(CD_HermiteCableDynType) :: model + REAL(wp) :: kk, om, share, zeta_expect, dt, z, zprev, zprev2, peaks(200), tpk(200), delta, zeta_meas, res, sgn + INTEGER :: m, k, np, es, it, node + CHARACTER(512) :: em + CHARACTER(16) :: tag + kk = REAL(n, wp)*PI/LL + om = omega(n, tens) + share = EI*kk**2/(EI*kk**2 + tens) + zeta_expect = alpha_c/(2.0_wp*om) + om*bb_c/(2.0_wp*EI)*share + WRITE (tag, '(A,I0)') ', mode ', n + CALL setup(model, tens, n, 1.0e-3_wp) + IF (alpha_c > 0.0_wp) THEN + CALL CD_HermiteCable_Dyn_Set_Mass_Damping(model, [(alpha_c, k=1, NE)], es, em) + CALL require(es == CD_HCDYN_OK, label//TRIM(tag)//': set alpha: '//TRIM(em)) + END IF + IF (bb_c > 0.0_wp) THEN + CALL CD_HermiteCable_Dyn_Set_Bending_Damping(model, [(bb_c, k=1, NE)], es, em) + CALL require(es == CD_HCDYN_OK, label//TRIM(tag)//': set Bb: '//TRIM(em)) + END IF + ! an antinode of the mode: midspan for modes 1 and 3 (sign -1 for mode 3), the quarter for mode 2 + node = MID + IF (n == 2) node = QUARTER + sgn = SIGN(1.0_wp, SIN(kk*model%q(6*(node - 1) + 1))) + dt = (2.0_wp*PI/om)/200.0_wp + np = 0; zprev = sgn*model%q(6*(node - 1) + 3); zprev2 = zprev + DO m = 1, 200*12 + 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//TRIM(tag)//': step failed: '//TRIM(em)); RETURN + END IF + z = sgn*model%q(6*(node - 1) + 3) + ! a positive peak of the antinode deflection (parabolic refinement of the sampled peak) + IF (m >= 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(m - 1, wp) + END IF + zprev2 = zprev; zprev = z + END DO + CALL require(np >= 8, label//TRIM(tag)//': 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,ES10.2,A,F8.5)') label//TRIM(tag), ': bending share ', share, & + ', zeta expected ', zeta_expect, ', measured ', zeta_meas, ', rel. error ', & + (zeta_meas - zeta_expect)/zeta_expect, ', period ratio ', (tpk(np) - tpk(2))/REAL(np - 2, wp)*om/(2.0_wp*PI) + CALL require(ABS(zeta_meas - zeta_expect) <= 2.5e-3_wp*zeta_expect, & + label//TRIM(tag)//': decay matches zeta to 0.25 %') + IF (PRESENT(zeta_target)) THEN + WRITE (*, '(A,ES11.4,A,ES10.2)') label//TRIM(tag)//': target zeta ', zeta_target, ', measured rel. error ', & + (zeta_meas - zeta_target)/zeta_target + CALL require(ABS(zeta_meas - zeta_target) <= 2.5e-3_wp*zeta_target, & + label//TRIM(tag)//': the target zeta to 0.25 %') + END IF + END SUBROUTINE decay_case + + SUBROUTINE check_refusals() + TYPE(CD_HermiteCableDynType) :: model + INTEGER :: es, k + CHARACTER(512) :: em + CALL setup(model, TENS, 1, 0.02_wp) + CALL CD_HermiteCable_Dyn_Set_Mass_Damping(model, [(-1.0_wp, k=1, NE)], es, em) + CALL require(es /= CD_HCDYN_OK .AND. INDEX(em, 'finite and non-negative') > 0, 'R5: negative alpha refused') + CALL CD_HermiteCable_Dyn_Set_Mass_Damping(model, [(1.0_wp, k=1, NE - 1)], es, em) + CALL require(es /= CD_HCDYN_OK .AND. INDEX(em, 'length ne') > 0, 'R5: wrong length refused') + CALL CD_HermiteCable_Dyn_Set_Mass_Damping(model, [(0.5_wp, k=1, NE)], es, em) + CALL require(es == CD_HCDYN_OK .AND. model%has_mass_damping, 'R5: a positive alpha switches it on') + CALL CD_HermiteCable_Dyn_Set_Mass_Damping(model, [(0.0_wp, k=1, NE)], es, em) + CALL require(es == CD_HCDYN_OK .AND. .NOT. model%has_mass_damping, 'R5: all-zero alpha keeps it off') + END SUBROUTINE check_refusals + +END PROGRAM test_hermite_mass_damping_dynamic