From 17f6715332c6a715f9869bf3e6f0aa6cb2c4a0e5 Mon Sep 17 00:00:00 2001 From: Jae Hoon Seo Date: Fri, 13 Nov 2026 20:17:22 +0900 Subject: [PATCH] feat: cross-flow damping on finite-EI cables (VIV DAMPING section) An optional VIV DAMPING section row "TypeName a b [c]" splits the normal drag of a finite-EI line type in the frame of the ambient normal flow: Morison's drag in line (with the VIV AMPLITUDE drag factor) and, across it, 1/2 rho D [C_dy |w_y| + c Cdn |w|] w_y with C_dy = a + b y0/D, the cross-flow hydrodynamic damping of Thorsen et al. (2016, Eq. 1; 0.31 0.89 is their fit) at the amplitude estimate y0. Below an ambient normal flow of 0.01 m/s the force blends to Morison's, where the axes are undefined. CD_Morison_Drag_Split_Per_Length_Jac computes the split force with exact Jacobians in the relative velocity and the tangent. The dynamic finite-EI drag element takes it in the residual, the tangent and the element drag load. Statics is unchanged: at rest in the flow the split force is Morison's. Set_VIV takes cdy (2 or 3, n_elem), checks it and rolls it back with the rest of the VIV state. "0 0 1" is Morison's drag with the drag factor on the in-line part alone, so an amplified drag no longer damps the cross-flow VIV motion twice. Thorsen's quadratic form drops the linear U y' part of Morison's cross-flow damping and suits cross-flow-only VIV. The section needs Cl > 0 and a VIV AMPLITUDE table; EI = 0 lines are refused. The Python deck reader and builder take the section, with parity tests against the native reader. Tests: test_viv_cf_damping_kernel (Morison limits, the cross-flow law, the blend, Jacobians against central differences, refusals) and test_viv_cf_damping_deck (0 0 1 equals the line without the row to 1.5e-8, the in-line-only factor gives the Cd 2.4 static offset, Thorsen's form raises A/D 0.68 to 1.02, power balance within 0.2 %, six refusals). Signed-off-by: Jae Hoon Seo --- CHANGELOG.md | 9 + CMakeLists.txt | 13 ++ doc/capabilities.rst | 7 + doc/driver_format.md | 56 +++++- doc/theory.rst | 41 ++++ python/cabledyn/builder.py | 26 +++ python/cabledyn/deck_file.py | 51 ++++- python/tests/test_builder.py | 23 +++ python/tests/test_deck_file.py | 52 +++++ python/tests/test_end_to_end.py | 28 +++ src/CableDyn_DeckDriver.f90 | 119 +++++++++++- src/CableDyn_HermiteCableDynamic.f90 | 148 ++++++++++++-- src/CableDyn_Hydro.f90 | 168 ++++++++++++++++ tests/test_viv_cf_damping_deck.f90 | 280 +++++++++++++++++++++++++++ tests/test_viv_cf_damping_kernel.f90 | 150 ++++++++++++++ 15 files changed, 1143 insertions(+), 28 deletions(-) create mode 100644 tests/test_viv_cf_damping_deck.f90 create mode 100644 tests/test_viv_cf_damping_kernel.f90 diff --git a/CHANGELOG.md b/CHANGELOG.md index e2020632..e9ad96ed 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -50,6 +50,15 @@ All notable changes to CableDyn are recorded in this file. The format follows response inside its falling range, and a table with `Cv = Cl` and `CdAmp = 1` is the line without it, bit for bit. The estimate is in the step-recovery, snapshot and checkpoint state; the Python deck reader and builder take the section. +- Cross-flow damping: an optional `VIV DAMPING` section row `TypeName a b [c]` splits the drag + of a finite-EI line type about the ambient normal flow: Morison's drag in line, and across it + the hydrodynamic damping `C_dy = a + b y0/D` of Thorsen et al. (2016) (Eq. 1, `0.31 0.89`) at + the `VIV AMPLITUDE` estimate `y0`, plus a Morison-form term `c Cdn |w| w_y`, blended to + Morison's drag in still water, with exact Jacobians. `0 0 1` is Morison's drag + with the `CdAmp` drag factor on the in-line part alone (the cross-flow VIV motion is not + damped twice); the quadratic form of Thorsen et al. suits cross-flow-only VIV models. Needs a + `VIV AMPLITUDE` table; `EI = 0` lines refused; the Python deck reader and builder take the + section. - VIV diameter: an optional `VIV DIAMETER` section row `TypeName Dviv` gives the VIV model of a line type (shedding frequency, wake frequency and coupling, VIV forces, amplitude ratio) a diameter apart from the `Diam` its drag, added mass and buoyancy keep, for buoyancy-module zones diff --git a/CMakeLists.txt b/CMakeLists.txt index e1c98930..8b2474f6 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1336,6 +1336,19 @@ target_link_libraries(test_viv_amplitude_kernel PRIVATE cabledyn_core) add_test(NAME viv_amplitude_kernel COMMAND test_viv_amplitude_kernel) set_tests_properties(viv_amplitude_kernel PROPERTIES LABELS "fortran;unit;dynamic;viv") +# The split cross-flow drag of Thorsen et al. (2016) per unit length: Morison at rest, the +# quadratic cross-flow damping across the flow, Morison without ambient flow, exact Jacobians. +add_executable(test_viv_cf_damping_kernel tests/test_viv_cf_damping_kernel.f90) +target_link_libraries(test_viv_cf_damping_kernel PRIVATE cabledyn_core) +add_test(NAME viv_cf_damping_kernel COMMAND test_viv_cf_damping_kernel) +set_tests_properties(viv_cf_damping_kernel PROPERTIES LABELS "fortran;unit;dynamic;viv") +# The split drag on a deck (VIV DAMPING section): Morison recombined, the in-line drag alone +# amplified, Thorsen's quadratic cross-flow damping, the energy ledger and the refusals. +add_executable(test_viv_cf_damping_deck tests/test_viv_cf_damping_deck.f90) +target_link_libraries(test_viv_cf_damping_deck PRIVATE cabledyn_core) +add_test(NAME viv_cf_damping_deck COMMAND test_viv_cf_damping_deck WORKING_DIRECTORY ${CMAKE_BINARY_DIR}) +set_tests_properties(viv_cf_damping_deck PROPERTIES LABELS "fortran;integration;dynamic;viv;driver") + # Amplitude-dependent VIV coefficients on a deck (VIV AMPLITUDE section), both line kinds: the # identity table, the amplitude channel against the response, self-limiting, drag amplification # and the refusals. diff --git a/doc/capabilities.rst b/doc/capabilities.rst index d52124bb..7bcb038e 100644 --- a/doc/capabilities.rst +++ b/doc/capabilities.rst @@ -165,6 +165,13 @@ Line and constitutive capability - Standalone and coupled - a diameter of the VIV model apart from the hydrodynamic one, for buoyancy-module zones and other sections shedding at a larger outer diameter (:ref:`theory-viv-diameter`) + * - Cross-flow damping (``VIV DAMPING`` section ``a``, ``b``, ``c``) + - Standalone and coupled + - the drag split into its in-line and cross-flow parts about the ambient flow, the + cross-flow part ``C_dy = a + b y0/D`` of Thorsen et al. (2016) read at the amplitude + estimate plus a Morison-form term ``c``; ``0 0 1`` keeps Morison's drag and lets the + ``VIV AMPLITUDE`` drag factor act on the in-line part alone; finite-EI cables + (:ref:`theory-viv-cf-damping`) Loads and environment --------------------- diff --git a/doc/driver_format.md b/doc/driver_format.md index 53d5289c..538fb973 100644 --- a/doc/driver_format.md +++ b/doc/driver_format.md @@ -133,8 +133,8 @@ except that `SYROPE IC` must come **after** `LINES`, because its rows name lines exist. A conventional layout is: LINE TYPES → BODIES → EXTERNAL LOADS → ROD TYPES → RODS → POINTS → TURBINES → LINES → SYROPE IC → -SECTIONS → END CONNECTIONS / EQUIVALENT BUOYANCY / ATTACHMENTS / STIFFENERS / VIV / FAILURE / -CONTROL → OPTIONS → OUTPUTS +SECTIONS → END CONNECTIONS / EQUIVALENT BUOYANCY / ATTACHMENTS / STIFFENERS / VIV / WAKE OSCILLATOR / +VIV AMPLITUDE / VIV DIAMETER / VIV DAMPING / FAILURE / CONTROL → OPTIONS → OUTPUTS Within LINE TYPES, the header row must precede the data rows because it selects their column order. @@ -211,6 +211,10 @@ are collapsed. It must match one of the spellings below; any other name fails wi | ATTACHMENTS | `ATTACHMENTS`, `LINE ATTACHMENTS`, `CLUMPS` | | STIFFENERS | `STIFFENERS`, `STIFFENER`, `BEND STIFFENERS`, `BEND STIFFENER` | | VIV | `VIV`, `VORTEX-INDUCED VIBRATION`, `VORTEX INDUCED VIBRATION` | +| WAKE OSCILLATOR | `WAKE OSCILLATOR`, `WAKE OSCILLATORS`, `WAKE` | +| VIV AMPLITUDE | `VIV AMPLITUDE`, `VIV AMPLITUDES` | +| VIV DIAMETER | `VIV DIAMETER`, `VIV DIAMETERS` | +| VIV DAMPING | `VIV DAMPING` | | FAILURE | `FAILURE`, `FAILURES` | | CONTROL | `CONTROL`, `CONTROLS` | | TURBINES | `TURBINES`, `TURBINE` | @@ -299,8 +303,9 @@ the half-range and centre of its band in non-dimensional frequency (MoorDyn's `d finite-EI cables (see [Cross-flow VIV](theory.rst)). The in-line force of a type is a [VIV](#viv-optional) section row; a [WAKE OSCILLATOR](#wake-oscillator-optional) row replaces the lift by a wake oscillator, a [VIV AMPLITUDE](#viv-amplitude-optional) table makes `Cl` (and -`Cd`) depend on the cross-flow amplitude, and a [VIV DIAMETER](#viv-diameter-optional) row gives -the VIV a diameter of its own. +`Cd`) depend on the cross-flow amplitude, a [VIV DIAMETER](#viv-diameter-optional) row gives +the VIV a diameter of its own, and a [VIV DAMPING](#viv-damping-optional-finite-ei-lines) row splits +the drag into an in-line and a cross-flow part with its own law. **Viscoelastic axial stiffness (MoorDyn `ElasticMod`).** The EA and BA columns accept bar-separated parts: @@ -1324,6 +1329,49 @@ Behaviour: finite-EI cables, standalone and coupled. A row fails if it is not `TypeName Dviv`, names an undefined or already named type or one without VIV, or holds a value out of range. +### VIV DAMPING (optional, finite-EI lines) + +Splits the normal Morison drag of a line type into an in-line and a cross-flow part in the frame +of the ambient flow, and gives the cross-flow part its own law: the quadratic damping of +Thorsen et al. (2016) and, optionally, a Morison-form term (see +[Cross-flow damping](theory.rst)). + +```text +--------------------- VIV DAMPING -------------------------------------- +TypeName a b c +(-) (-) (-) (-) +riser 0 0 1 +``` + +| Column | Meaning | +|--------|---------| +| `TypeName` | an existing LINE TYPES name (case-insensitive) with a [VIV AMPLITUDE](#viv-amplitude-optional) table, at most one row each | +| `a`, `b` | the cross-flow damping coefficient `C_dy = a + b y0/D` >= 0, `y0/D` the type's amplitude estimate; Thorsen et al. (2016, Eq. 1) give `0.31 0.89` | +| `c` | optional factor >= 0 of a Morison-form cross-flow term `c Cdn \|w\| w_y`, `Cdn` the type's own (unamplified) normal drag coefficient (default 0) | + +Behaviour: + +- At each point of the line, with `e_x` along the ambient flow normal to the line and `e_y` + across it, the relative normal velocity `w` splits into `w_x` and `w_y`. The normal drag per + unit length becomes `1/2 rho D [Cdn CdAmp |w| w_x e_x + (C_dy |w_y| + c Cdn |w|) w_y e_y]`: + Morison's in-line part, with the drag factor `CdAmp` of the type's amplitude table, and the + cross-flow law of the row. Where the ambient normal flow falls below 0.01 m/s the axes are + undefined and the drag blends smoothly back to Morison's. +- **`0 0 1` amplifies the in-line drag alone.** With an amplitude table's `CdAmp` (for example + Chaplin et al. 2005, Eq. 4), the mean in-line drag of a vibrating cable rises while its + cross-flow drag stays Morison's. A `CdAmp` without this row multiplies the whole normal drag, + the cross-flow damping included. +- **`0.31 0.89` is the published cross-flow-only model** of Thorsen et al. (2016), fitted to + still-water decay tests for `y0/D` up to about 0.6. It removes the linear part of Morison's + cross-flow damping (`1/2 rho D Cdn U y'`), so use it without in-line VIV: with a `VIV` section + row the in-line force turns with the relative flow and can drive a low-frequency cross-flow + motion that nothing damps. +- `0 0 1` with `CdAmp` 1 is Morison's drag (to round-off). The split acts in the dynamics; the + static solve keeps Morison's drag, which is the same at rest. `DragPow` reports the split drag. +- Finite-EI cables only, standalone and coupled; an `EI = 0` line with the row is refused by name. + A row fails if it is not `TypeName a b [c]`, names an undefined or already named type or one + without an amplitude table, or holds a value out of range. + ### FAILURE (optional, EI = 0 decks) A FAILURE row detaches line ends from a point during a dynamic run, with MoorDyn's trigger rules. diff --git a/doc/theory.rst b/doc/theory.rst index d3c09616..19c6a685 100644 --- a/doc/theory.rst +++ b/doc/theory.rst @@ -1360,6 +1360,47 @@ alike; an uncoupled wake oscillator (:math:`A` = 0) drives the cable at 0.149 Hz :math:`\mathrm{St}\,U/D_v` = 0.15 Hz; and :math:`D_v` equal to ``Diam`` is the line without the row, bit for bit. +.. _theory-viv-cf-damping: + +Cross-flow damping +~~~~~~~~~~~~~~~~~~ + +A ``VIV DAMPING`` row splits the normal Morison drag of a finite-EI line type in the frame of the +ambient flow. With :math:`\mathbf t` the tangent, :math:`\mathbf u_n` the ambient flow normal to +it, :math:`\mathbf e_x = \mathbf u_n/|\mathbf u_n|` and :math:`\mathbf e_y = \mathbf t\times\mathbf e_x`, +the relative normal velocity :math:`\mathbf w` splits into :math:`w_x` and :math:`w_y`, and + +.. math:: + + \mathbf f_n = \tfrac12\rho D\left[C_{dn}A_d\,|\mathbf w|\,w_x\,\mathbf e_x + + \left(C_{dy}|w_y| + c\,C_{dn}|\mathbf w|\right)w_y\,\mathbf e_y\right],\qquad + C_{dy} = a + b\,\frac{y_0^*}{D}, + +with :math:`A_d` the drag factor of the type's amplitude table and :math:`y_0^*` its amplitude +estimate (:ref:`theory-viv-amplitude`). The quadratic term is the cross-flow hydrodynamic damping of +:ref:`Thorsen et al. (2016) ` (their Eq. 1, :math:`a = 0.31`, :math:`b = 0.89` +from the still-water decay tests of Vikestad et al. 2000, valid for :math:`y_0/D` up to about +0.6). The :math:`c` term is Morison's own cross-flow drag. Where :math:`|\mathbf u_n|` falls below +:math:`u_{ref} = 0.01` m/s the axes are undefined, and :math:`\mathbf f_n` blends to Morison's as +:math:`\beta\,\mathbf f_s + (1-\beta)\,\mathbf f_M` with :math:`\beta = U^2/(U^2 + u_{ref}^2)`. +The force and its Jacobians in the relative velocity and in the tangent are exact, and the +tangential drag is unchanged. + +The row serves two uses: + +- With :math:`(0, 0, 1)` and the drag factor of :ref:`Chaplin et al. (2005) `, + the amplification acts on the mean in-line drag alone, as measured, while the cross-flow drag + stays Morison's. +- :math:`(0.31, 0.89, 0)` is Thorsen's cross-flow model. It drops the linear part + :math:`\tfrac12\rho D C_{dn}U\dot y` of Morison's cross-flow damping, so it is consistent with + cross-flow VIV alone. An in-line force that turns with the relative flow can then drive an + undamped low-frequency cross-flow motion. + +On the taut gate line, :math:`(0, 0, 1)` with factor 1 is the line without the row to round-off; +with :math:`C_v = 0` and factor 2 the line settles at the static in-line offset of ``Cd`` 2.4 to the +printed digits; Thorsen's form raises the steady cross-flow amplitude from :math:`A/D` 0.68 to 1.02; +and the drag, damping and VIV powers balance within 0.2 %. + .. _theory-dry-buoyancy: Buoyancy and wetting diff --git a/python/cabledyn/builder.py b/python/cabledyn/builder.py index bc61f0d8..4e28bdb3 100644 --- a/python/cabledyn/builder.py +++ b/python/cabledyn/builder.py @@ -236,6 +236,12 @@ class LineType: length, 2 to 32 of them in increasing amplitude ratio ``AD``: ``Cv`` replaces ``cl`` at that amplitude (so ``cl`` must be set) and ``CdAmp`` multiplies the normal drag coefficient ``cdn`` (1 when left out). + viv_damping : tuple[float, float] | tuple[float, float, float] | None + Optional ``VIV DAMPING`` row ``(a, b[, c])``: the cross-flow damping + ``C_dy = a + b y0/D`` of Thorsen et al. (2016) in place of the cross-flow part of the + type's Morison drag, plus a Morison-form term ``c Cdn |w| w_y``; ``(0.31, 0.89)`` is + their published fit, ``(0, 0, 1)`` amplifies the in-line drag alone (with a + ``viv_amplitude`` drag factor). Needs ``viv_amplitude``. viv_diameter : float | None Optional diameter of the type's VIV model, a ``VIV DIAMETER`` section row ``Name Dviv``: the shedding frequency, the VIV forces and the amplitude @@ -269,6 +275,7 @@ class LineType: wake_a: float | None = None viv_amplitude: list[tuple[float, ...]] | None = None viv_diameter: float | None = None + viv_damping: tuple[float, ...] | None = None @dataclass(eq=False) @@ -1694,6 +1701,7 @@ def add_line_type( wake_a: float | None = None, viv_amplitude: list[tuple[float, ...]] | None = None, viv_diameter: float | None = None, + viv_damping: tuple[float, ...] | None = None, ) -> LineType: """Add a ``LINE TYPES`` row; see :class:`LineType` for the fields. @@ -1736,6 +1744,7 @@ def add_line_type( wake_a, None if viv_amplitude is None else [tuple(row) for row in viv_amplitude], viv_diameter, + None if viv_damping is None else tuple(viv_damping), ) self._line_types.append(item) return item @@ -2630,6 +2639,7 @@ def to_text(self, *, validate: bool = True) -> str: _emit(out, "WAKE OSCILLATOR", *self._wake_table()) _emit(out, "VIV AMPLITUDE", *self._viv_amp_table()) _emit(out, "VIV DIAMETER", *self._viv_diam_table()) + _emit(out, "VIV DAMPING", *self._viv_damp_table()) _emit(out, "FAILURE", *self._failure_table()) _emit(out, "CONTROL", *self._control_table()) _emit(out, "EXTERNAL LOADS", *self._external_load_table()) @@ -3050,6 +3060,19 @@ def _viv_amp_table(self) -> tuple[str, str, list[list[str]]]: rows.append([_text(item.name, what), *(_num(value, what) for value in row)]) return "Name AD Cv CdAmp", "(-) (-) (-) (-)", rows + def _viv_damp_table(self) -> tuple[str, str, list[list[str]]]: + rows: list[list[str]] = [] + for item in self._line_types: + if item.viv_damping is None: + continue + what = f"line type {item.name!r}" + if len(item.viv_damping) not in (2, 3): + raise ValueError(f"{what}: viv_damping is (a, b) or (a, b, c)") + if item.viv_amplitude is None: + raise ValueError(f"{what}: viv_damping takes its amplitude from viv_amplitude") + rows.append([_text(item.name, what)] + [_num(v, what) for v in item.viv_damping]) + return "Name a b c", "(-) (-) (-) (-)", rows + def _viv_diam_table(self) -> tuple[str, str, list[list[str]]]: rows: list[list[str]] = [] for item in self._line_types: @@ -3280,6 +3303,9 @@ def load(self) -> None: if item.viv_amplitude is None: item.viv_amplitude = [] item.viv_amplitude.append(tuple(_f(token) for token in t[1:])) + for row in self.rows("VIV DAMPING"): + t = row.tokens + model.line_types[t[0]].viv_damping = tuple(_f(v) for v in t[1:]) for row in self.rows("VIV DIAMETER"): t = row.tokens model.line_types[t[0]].viv_diameter = _f(t[1]) diff --git a/python/cabledyn/deck_file.py b/python/cabledyn/deck_file.py index b01fe0f6..2e0aaa08 100644 --- a/python/cabledyn/deck_file.py +++ b/python/cabledyn/deck_file.py @@ -86,6 +86,7 @@ "VIV AMPLITUDES": "VIV AMPLITUDE", "VIV DIAMETER": "VIV DIAMETER", "VIV DIAMETERS": "VIV DIAMETER", + "VIV DAMPING": "VIV DAMPING", } # Table sections whose rows the native reader takes through a Fortran # list-directed READ. Their descriptive and units rows are recognized by the @@ -118,6 +119,7 @@ "WAKE OSCILLATOR", "VIV AMPLITUDE", "VIV DIAMETER", + "VIV DAMPING", } ) _TABLE_SECTIONS = _LIST_DIRECTED_SECTIONS | _WHITESPACE_TABLE_SECTIONS @@ -3382,6 +3384,45 @@ def _check_viv_diam_section(self, viv_type_names: set[str]) -> None: "VIV: give the type LINE TYPES Cl > 0 or a WAKE OSCILLATOR row" ) + def _check_viv_damp_section(self, amp_type_names: set[str]) -> set[str]: + """Native ``apply_type_viv_damp`` for the VIV DAMPING section; the types it names. + + A row ``TypeName a b [c]`` gives a line type the cross-flow hydrodynamic damping + ``C_dy = a + b y0/D`` of Thorsen et al. (2016) in place of the cross-flow part of its + Morison drag, plus a Morison-form term ``c Cdn |w| w_y`` (default 0); ``a, b, c >= 0``, + each at most 1e15. ``y0`` is the amplitude estimate of the type's VIV AMPLITUDE table, + so the type needs one. A type takes one row. + """ + types = {row.tokens[0].lower(): row.tokens[0] for row in self.line_types} + named: set[str] = set() + for row in self._rows("VIV DAMPING"): + where = self._at(row) + if len(row.tokens) not in (3, 4): + raise DeckFormatError(f"{where}: VIV DAMPING rows must be: TypeName a b [c]") + name = row.tokens[0].lower() + if name not in types: + raise DeckFormatError( + f'{where}: VIV DAMPING row names undefined LINE TYPE "{row.tokens[0]}"' + ) + if name in named: + raise DeckFormatError(f'{where}: VIV DAMPING names LINE TYPE "{types[name]}" twice') + try: + values = [_native_float(token) for token in row.tokens[1:]] + except ValueError as exc: + raise DeckFormatError( + f"{where}: VIV DAMPING a, b and c must be plain numbers" + ) from exc + if not all(math.isfinite(v) and 0.0 <= v <= _NATIVE_MAX_COEFFICIENT for v in values): + raise DeckFormatError(f"{where}: VIV DAMPING needs a, b and c >= 0, at most 1e15") + if name not in amp_type_names: + raise DeckFormatError( + f'{where}: VIV DAMPING of LINE TYPE "{types[name]}" takes the amplitude ' + "estimate of its VIV AMPLITUDE table: give the type Cl > 0 and a VIV " + "AMPLITUDE table" + ) + named.add(name) + return named + def _check_viv_amp_section(self, lift_type_names: set[str]) -> set[str]: """Native ``apply_type_viv_amp`` for the VIV AMPLITUDE section; the types with a table. @@ -4637,15 +4678,21 @@ def end_key(token: str) -> str: wake_type_names = self._check_wake_section(viv_type_names) amp_type_names = self._check_viv_amp_section(viv_type_names) self._check_viv_diam_section(viv_type_names | wake_type_names) + damp_type_names = self._check_viv_damp_section(amp_type_names) amp_lines = { line_id for line_id, section_types in section_types_by_line.items() if {line_type.lower() for line_type in section_types} & amp_type_names } - # native build_one_hermite_cable and the EI = 0 line wiring: the wake oscillator acts - # on finite-EI cables only, and a cable takes one VIV model + # native build_one_hermite_cable and the EI = 0 line wiring: the wake oscillator and the + # cross-flow damping act on finite-EI cables only, and a cable takes one VIV model for line_id, section_types in section_types_by_line.items(): types_used = {line_type.lower() for line_type in section_types} + if types_used & damp_type_names and line_id not in finite_line_ids: + raise DeckFormatError( + f"{self._label}: line {line_id}: the cross-flow damping (VIV DAMPING " + "section) acts on finite-EI cables (EI > 0) only" + ) if not types_used & wake_type_names: continue if line_id not in finite_line_ids: diff --git a/python/tests/test_builder.py b/python/tests/test_builder.py index 520d3be8..99e82805 100644 --- a/python/tests/test_builder.py +++ b/python/tests/test_builder.py @@ -294,6 +294,29 @@ def test_viv_diameter_rows_are_written(tmp_path: Path) -> None: model.to_text(validate=False) +def test_viv_damping_rows_are_written(tmp_path: Path) -> None: + model = _chain_model(tmp_path) + model.add_line_type( + "riser", + diam=0.1, + mass=10.0, + ea=5.0e7, + cl=0.8, + viv_amplitude=[(0.0, 0.8, 1.0), (1.0, 0.4, 2.0)], + viv_damping=(0.0, 0.0, 1.0), + ) + deck = DeckFile.from_text(model.to_text(validate=False), path=tmp_path / "deck.dat") + rows = [row.tokens for row in deck._rows("VIV DAMPING")] + assert rows == [("riser", "0.0", "0.0", "1.0")] + model.line_types["riser"].viv_damping = (0.31,) + with pytest.raises(ValueError, match=r"viv_damping is \(a, b\) or \(a, b, c\)"): + model.to_text(validate=False) + model.line_types["riser"].viv_damping = (0.31, 0.89) + model.line_types["riser"].viv_amplitude = None + with pytest.raises(ValueError, match="takes its amplitude from viv_amplitude"): + model.to_text(validate=False) + + def test_build_spread_mooring_with_multi_section_lines() -> None: import math diff --git a/python/tests/test_deck_file.py b/python/tests/test_deck_file.py index b0d2bfd6..4399e9c3 100644 --- a/python/tests/test_deck_file.py +++ b/python/tests/test_deck_file.py @@ -4991,6 +4991,58 @@ def test_viv_diameter_takes_a_wake_oscillator_type(): DeckFile.from_text(_with_section(text, "VIV DIAMETER", "chain 0.9")) +_DAMP_BASE = _with_section( + _edit(_DYNAMIC, (_LIFT_ROW, _LIFT_ROW + " 0.8")), + "VIV AMPLITUDE", + "chain 0.0 0.8", + "chain 1.0 0.4", +) + + +@pytest.mark.parametrize( + "rows, expected", + [ + (("chain 0.31 0.89",), (0.31, 0.89)), + (("TypeName a b c", "chain 0 0 1"), (0.0, 0.0, 1.0)), + ], +) +def test_viv_damping_rows_are_read_and_kept(tmp_path, rows, expected): + from cabledyn import DeckModel + + text = _with_section(_DAMP_BASE, "VIV DAMPING", *rows) + DeckFile.from_text(text) + path = tmp_path / "damp.dat" + path.write_text(text, encoding="utf-8") + assert DeckModel.load(path).line_types["chain"].viv_damping == expected + saved = tmp_path / "saved.dat" + DeckModel.load(path).save(saved) + assert DeckModel.load(saved).line_types["chain"].viv_damping == expected + + +@pytest.mark.parametrize( + "base, rows, message", + [ + (None, ("chain 0.31",), "rows must be: TypeName a b [c]"), + (None, ("chain 0.31 0.89 0.0 1.0",), "rows must be: TypeName a b [c]"), + (None, ("chain 0.31 x",), "a, b and c must be plain numbers"), + (None, ("cable 0.31 0.89",), 'undefined LINE TYPE "cable"'), + (None, ("chain 0.31 0.89", "chain 0 0 1"), 'names LINE TYPE "chain" twice'), + (None, ("chain -0.1 0.89",), "a, b and c >= 0, at most 1e15"), + (None, ("chain 0.31 0.89 -1",), "a, b and c >= 0, at most 1e15"), + ("no-table", ("chain 0.31 0.89",), "give the type Cl > 0 and a VIV AMPLITUDE table"), + ("ei0", ("chain 0.31 0.89",), "acts on finite-EI cables (EI > 0) only"), + ], +) +def test_viv_damping_rows_follow_the_native_checks(base, rows, message): + text = _DAMP_BASE + if base == "no-table": + text = _edit(_DYNAMIC, (_LIFT_ROW, _LIFT_ROW + " 0.8")) + elif base == "ei0": + text = _edit(text, ("1.674e9 -1.0 1.0e4 1.37", "1.674e9 -1.0 0.0 1.37")) + with pytest.raises(DeckFormatError, match=re.escape(message)): + DeckFile.from_text(_with_section(text, "VIV DAMPING", *rows)) + + def test_viv_amplitude_channel_needs_a_table(): text = _edit(_DYNAMIC, (_LIFT_ROW, _LIFT_ROW + " 0.8")) text = _edit(text, ("FairTen1\n", "FairTen1\nVIVAmp1N2\n")) diff --git a/python/tests/test_end_to_end.py b/python/tests/test_end_to_end.py index bc9f5183..496f4be9 100644 --- a/python/tests/test_end_to_end.py +++ b/python/tests/test_end_to_end.py @@ -345,6 +345,34 @@ def _dia_rows(*rows: str) -> tuple[str, str]: _AMP_PARITY += _DIA_PARITY +def _damp_rows(*rows: str) -> tuple[str, str]: + """The edit that puts a VIV DAMPING section with ``rows`` before OPTIONS.""" + block = "--------------------- VIV DAMPING -----\n" + "".join(f"{row}\n" for row in rows) + return _AMP_OPTIONS, block + _AMP_OPTIONS + + +_DAMP_TABLE = _amp_table("riser 0.0 0.8 1.0", "riser 0.5 0.4 1.5") +_DAMP_PARITY = [ + ("damp-accepted", [_DAMP_TABLE, _damp_rows("riser 0.31 0.89")], True), + ("damp-inline-only", [_DAMP_TABLE, _damp_rows("riser 0 0 1")], True), + ("damp-no-table", [_damp_rows("riser 0.31 0.89")], False), + ("damp-negative", [_DAMP_TABLE, _damp_rows("riser 0.31 -0.89")], False), + ("damp-one-value", [_DAMP_TABLE, _damp_rows("riser 0.31")], False), + ("damp-repeated", [_DAMP_TABLE, _damp_rows("riser 0.31 0.89", "riser 0 0 1")], False), + ( + "damp-ei0-line", + [ + ("-0.8 1.0 1.2", "-0.8 0.0 1.2"), + _DAMP_TABLE, + _damp_rows("riser 0.31 0.89"), + ], + False, + ), +] + +_AMP_PARITY += _DAMP_PARITY + + @pytest.mark.parametrize( ("label", "edits", "accepted"), _AMP_PARITY, ids=[item[0] for item in _AMP_PARITY] ) diff --git a/src/CableDyn_DeckDriver.f90 b/src/CableDyn_DeckDriver.f90 index 22053d30..372f8d0a 100644 --- a/src/CableDyn_DeckDriver.f90 +++ b/src/CableDyn_DeckDriver.f90 @@ -471,6 +471,9 @@ MODULE CableDyn_DeckDriver ! Dviv): 0 takes the type's Diam; has_vivd_row marks a type the section names. REAL(wp) :: viv_dv = CD_ZERO LOGICAL :: has_vivd_row = .FALSE. + ! The cross-flow hydrodynamic damping of Thorsen et al. (2016) (the optional VIV DAMPING section, + ! a row per type: TypeName a b [c]), C_dy = a + b y0/D; cdy_a < 0 without a row. + REAL(wp) :: cdy_a = -1.0_wp, cdy_b = CD_ZERO, cdy_c = CD_ZERO ! Deck file line of the row (0 when not read from a file), for error messages. INTEGER :: deck_line = 0 END TYPE @@ -1904,7 +1907,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(:), viv_clx(:), viv_al(:), viv_hh(:) - REAL(wp), ALLOCATABLE :: viv_tix(:), viv_amp3(:, :, :), viv_dva(:) + 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(:) REAL(wp), ALLOCATABLE :: ba_raw(:), ba(:), dry_b(:), bb_el(:) @@ -3311,9 +3314,14 @@ RECURSIVE SUBROUTINE build_one_hermite_cable(ln, sections, types, points, opts, CALL viv_amp_type_index(ln, sections, types, viv_tix) ALLOCATE (viv_dva(SIZE(l0))) CALL finite_viv_diameters(ln, sections, types, viv_dva) + ALLOCATE (cdy_a(SIZE(l0)), cdy_b(SIZE(l0)), cdy_c(SIZE(l0))) + CALL finite_viv_cdy(ln, sections, types, cdy_a, cdy_b, cdy_c) IF (SIZE(l0_am) /= SIZE(l0)) THEN CALL remap_elem_by_reference_arc(viv_tix, l0, l0_am) CALL remap_elem_by_reference_arc(viv_dva, l0, l0_am) + CALL remap_elem_by_reference_arc(cdy_a, l0, l0_am) + CALL remap_elem_by_reference_arc(cdy_b, l0, l0_am) + CALL remap_elem_by_reference_arc(cdy_c, l0, l0_am) CALL remap_elem_by_reference_arc(wo_cl0, l0, l0_am) CALL remap_elem_by_reference_arc(wo_st, l0, l0_am) CALL remap_elem_by_reference_arc(wo_eps, l0, l0_am) @@ -3659,14 +3667,16 @@ RECURSIVE SUBROUTINE build_one_hermite_cable(ln, sections, types, points, opts, REAL(CD_VIV_NM, wp)*MERGE(opts%dtM, dt, opts%has_dtm), & opts%viv_rms_window > CD_ZERO), es, em, phase_seed=seed, & tangent_reversed=.NOT. ln%ends_swapped, clx=viv_clx, il_alpha=viv_al, & - chh=viv_hh, amp=viv_amp3, amp_n=viv_ampn, dviv=viv_dva) + chh=viv_hh, amp=viv_amp3, amp_n=viv_ampn, dviv=viv_dva, & + cdy=RESHAPE([cdy_a, cdy_b, cdy_c], [3, SIZE(cdy_a)], ORDER=[2, 1])) ELSE CALL CD_HermiteCable_Dyn_Set_VIV(cable%line, viv_cl, viv_cf, viv_df, & MERGE(opts%viv_rms_window, & REAL(CD_VIV_NM, wp)*MERGE(opts%dtM, dt, opts%has_dtm), & opts%viv_rms_window > CD_ZERO), es, em, phase_seed=seed, & tangent_reversed=.NOT. ln%ends_swapped, amp=viv_amp3, amp_n=viv_ampn, & - dviv=viv_dva) + dviv=viv_dva, & + cdy=RESHAPE([cdy_a, cdy_b, cdy_c], [3, SIZE(cdy_a)], ORDER=[2, 1])) END IF END BLOCK IF (es /= CD_HCDYN_OK) THEN @@ -10534,6 +10544,10 @@ RECURSIVE SUBROUTINE init_one_model(ln, sections, types, points, opts, model, Er CALL fail(ErrStat, ErrMsg, 'line '//TRIM(int_to_str(ln%id))//': the wake oscillator (WAKE '// & 'OSCILLATOR section) acts on finite-EI cables (EI > 0) only'); RETURN END IF + IF (types(line_section_type(sections, ln%id, i))%cdy_a >= CD_ZERO) THEN + CALL fail(ErrStat, ErrMsg, 'line '//TRIM(int_to_str(ln%id))//': the cross-flow damping (VIV '// & + 'DAMPING section) acts on finite-EI cables (EI > 0) only'); RETURN + END IF viv_cf(e) = types(line_section_type(sections, ln%id, i))%viv_cf viv_df(e) = types(line_section_type(sections, ln%id, i))%viv_df viv_clx(e) = types(line_section_type(sections, ln%id, i))%clx @@ -11744,6 +11758,29 @@ SUBROUTINE viv_amp_type_index(ln, sections, types, tix) tix = tix(SIZE(tix):1:-1) END SUBROUTINE viv_amp_type_index + SUBROUTINE finite_viv_cdy(ln, sections, types, ca, cb, cc) + !! The VIV DAMPING (a, b, c) of every element's line type (a = -1 where the type has none), in the + !! element order of finite_hydro_arrays (the deck order reversed). + TYPE(DeckLine), INTENT(IN) :: ln + TYPE(DeckSection), INTENT(IN) :: sections(:) + TYPE(DeckLineType), INTENT(IN) :: types(:) + REAL(wp), INTENT(OUT) :: ca(:), cb(:), cc(:) + 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 + ca(e) = types(sections(i)%ltype)%cdy_a + cb(e) = types(sections(i)%ltype)%cdy_b + cc(e) = types(sections(i)%ltype)%cdy_c + END DO + END DO + ca = ca(SIZE(ca):1:-1) + cb = cb(SIZE(cb):1:-1) + cc = cc(SIZE(cc):1:-1) + END SUBROUTINE finite_viv_cdy + SUBROUTINE finite_viv_diameters(ln, sections, types, dv) !! The VIV DIAMETER of every element's line type (0 where the type has none, the drag diameter !! then), in the element order of finite_hydro_arrays (the deck order reversed). @@ -13920,6 +13957,9 @@ SUBROUTINE parse_deck(path, types, bodies, rod_types, rods, points, lines, secti INTEGER, ALLOCATABLE :: vamp_lines(:) INTEGER :: n_vamp CHARACTER(DECK_RECLEN), ALLOCATABLE :: vdia_rows(:) + CHARACTER(DECK_RECLEN), ALLOCATABLE :: vdmp_rows(:) + INTEGER, ALLOCATABLE :: vdmp_lines(:) + INTEGER :: n_vdmp INTEGER, ALLOCATABLE :: vdia_lines(:) INTEGER :: n_vdia CHARACTER(2*NAMELEN), ALLOCATABLE :: channel_keys(:) @@ -13939,7 +13979,8 @@ SUBROUTINE parse_deck(path, types, bodies, rod_types, rods, points, lines, secti SEC_SECTIONS = 5, SEC_OPTIONS = 6, SEC_OUTPUTS = 7, SEC_RODTYPES = 8, SEC_RODS = 9, & SEC_EQUIV = 10, SEC_FAILURE = 11, SEC_CONTROL = 12, SEC_SYROPE_IC = 13, & SEC_ENDCONN = 14, SEC_TURBINES = 15, SEC_EXTLOADS = 16, SEC_ATTACH = 17, & - SEC_STIFF = 18, SEC_VIV = 19, SEC_WAKE = 20, SEC_VIVAMP = 21, SEC_VIVDIA = 22 + SEC_STIFF = 18, SEC_VIV = 19, SEC_WAKE = 20, SEC_VIVAMP = 21, SEC_VIVDIA = 22, & + SEC_VIVDAMP = 23 ErrStat = 0; ErrMsg = '' ext_march = .FALSE. @@ -13967,6 +14008,8 @@ SUBROUTINE parse_deck(path, types, bodies, rod_types, rods, points, lines, secti ALLOCATE (vamp_rows(0), vamp_lines(0)) n_vamp = 0 ALLOCATE (vdia_rows(0), vdia_lines(0)) + ALLOCATE (vdmp_rows(0), vdmp_lines(0)) + n_vdmp = 0 n_vdia = 0 n_wake = 0 nt = 0; nb = 0; nrt = 0; nr = 0; np = 0; nlin = 0; nsec = 0; neq = 0; nch = 0; nfl = 0; nct = 0; nec = 0 @@ -14121,6 +14164,15 @@ SUBROUTINE parse_deck(path, types, bodies, rod_types, rods, points, lines, secti END IF vamp_rows(n_vamp) = line(1:MIN(LEN(line), DECK_RECLEN)) vamp_lines(n_vamp) = lineno + CASE (SEC_VIVDAMP) + IF (.NOT. has_numeric_token(line)) CYCLE + n_vdmp = n_vdmp + 1 + IF (n_vdmp > SIZE(vdmp_rows)) THEN + vdmp_rows = [vdmp_rows, [(REPEAT(' ', DECK_RECLEN), i_ch=1, 8)]] + vdmp_lines = [vdmp_lines, [(0, i_ch=1, 8)]] + END IF + vdmp_rows(n_vdmp) = line(1:MIN(LEN(line), DECK_RECLEN)) + vdmp_lines(n_vdmp) = lineno CASE (SEC_VIVDIA) IF (.NOT. has_numeric_token(line)) CYCLE n_vdia = n_vdia + 1 @@ -14255,6 +14307,13 @@ SUBROUTINE parse_deck(path, types, bodies, rod_types, rods, points, lines, secti RETURN END IF END DO + DO i_ch = 1, n_vdmp + CALL apply_type_viv_damp(vdmp_rows(i_ch), types, ErrStat, ErrMsg) + IF (ErrStat /= 0) THEN + CALL add_row_context('deck', vdmp_lines(i_ch), vdmp_rows(i_ch), ErrMsg) + RETURN + END IF + END DO DO i_ch = 1, SIZE(types) IF (types(i_ch)%amp_n == 1) THEN CALL fail(ErrStat, ErrMsg, 'VIV AMPLITUDE gives LINE TYPE "'//TRIM(types(i_ch)%name)//'" one row: a '// & @@ -15933,6 +15992,8 @@ SUBROUTINE set_section(secname, section, ErrStat, ErrMsg) section = 21 CASE ('VIV DIAMETER', 'VIV DIAMETERS') section = 22 + CASE ('VIV DAMPING') + section = 23 CASE ('WAKE OSCILLATOR', 'WAKE OSCILLATORS', 'WAKE') section = 20 CASE DEFAULT @@ -17662,6 +17723,56 @@ SUBROUTINE apply_type_viv_amp(row, types, ErrStat, ErrMsg) types(it)%amp_tab(:, n + 1) = v END SUBROUTINE apply_type_viv_amp + SUBROUTINE apply_type_viv_damp(row, types, ErrStat, ErrMsg) + !! One VIV DAMPING row: TypeName a b [c] -- the cross-flow hydrodynamic damping of a line type, + !! C_dy = a + b y0/D (Thorsen et al. 2016, Eq. 1: a = 0.31 and b = 0.89, their fit to the + !! still-water decays of Vikestad et al. 2000), which replaces the cross-flow part of the type's + !! Morison drag while the in-line part stays. y0 is the amplitude estimate of the type's VIV + !! AMPLITUDE table, so the type needs one (and so the synchronisation lift, Cl > 0). c adds a + !! Morison-form cross-flow term c Cdn |w| w_y (default 0): (0, 0, 1) amplifies the in-line drag + !! alone. a, b, c >= 0, at most 1e15. A type takes one row. + CHARACTER(*), INTENT(IN) :: row + TYPE(DeckLineType), INTENT(INOUT) :: types(:) + INTEGER, INTENT(OUT) :: ErrStat + CHARACTER(*), INTENT(OUT) :: ErrMsg + CHARACTER(DECK_RECLEN) :: tok + INTEGER :: it, n, k + REAL(wp) :: v(3) + LOGICAL :: found, ok + + ErrStat = 0; ErrMsg = '' + n = count_tokens(row) + IF (n < 3 .OR. n > 4) THEN + CALL fail(ErrStat, ErrMsg, 'VIV DAMPING rows must be: TypeName a b [c]'); RETURN + END IF + CALL get_token(row, 1, tok, found) + it = find_type(types, TRIM(tok)) + IF (it == 0) THEN + CALL fail(ErrStat, ErrMsg, 'VIV DAMPING row names undefined LINE TYPE "'//TRIM(tok)//'"'); RETURN + END IF + IF (types(it)%cdy_a >= CD_ZERO) THEN + CALL fail(ErrStat, ErrMsg, 'VIV DAMPING names LINE TYPE "'//TRIM(types(it)%name)//'" twice'); RETURN + END IF + v = CD_ZERO + DO k = 2, n + CALL get_token(row, k, tok, found) + CALL parse_real_token(tok, v(k - 1), ok) + IF (.NOT. ok) THEN + CALL fail(ErrStat, ErrMsg, 'VIV DAMPING a, b and c must be plain numbers'); RETURN + END IF + END DO + IF (.NOT. (ALL(IEEE_IS_FINITE(v)) .AND. ALL(v >= CD_ZERO) .AND. ALL(v <= MAX_COEFFICIENT))) THEN + CALL fail(ErrStat, ErrMsg, 'VIV DAMPING needs a, b and c >= 0, at most 1e15'); RETURN + END IF + IF (.NOT. (types(it)%cl > CD_ZERO) .OR. types(it)%amp_n <= 0) THEN + CALL fail(ErrStat, ErrMsg, 'VIV DAMPING of LINE TYPE "'//TRIM(types(it)%name)//'" takes the amplitude '// & + 'estimate of its VIV AMPLITUDE table: give the type Cl > 0 and a VIV AMPLITUDE table'); RETURN + END IF + types(it)%cdy_a = v(1) + types(it)%cdy_b = v(2) + types(it)%cdy_c = v(3) + END SUBROUTINE apply_type_viv_damp + SUBROUTINE apply_type_viv_diam(row, types, ErrStat, ErrMsg) !! One VIV DIAMETER row: TypeName Dviv -- the diameter of a line type's VIV model, Dviv > 0 (at !! most 1e15), which the shedding frequency, the lift and in-line forces and the amplitude ratio diff --git a/src/CableDyn_HermiteCableDynamic.f90 b/src/CableDyn_HermiteCableDynamic.f90 index 8ebf5cc7..68c153a5 100644 --- a/src/CableDyn_HermiteCableDynamic.f90 +++ b/src/CableDyn_HermiteCableDynamic.f90 @@ -71,6 +71,7 @@ MODULE CableDyn_HermiteCableDynamic CD_VIV_AMP_MAXP, CD_VIV_Amplitude_Update, CD_VIV_Table, CD_VIV_Check_Amp_Table, & CD_VIV_Ambient_Crossflow_Rate USE CableDyn_Hydro, ONLY: CD_Morison_Drag_Per_Length_Jac, CD_Airy_Wave_Kinematics_Precomputed, & + CD_Morison_Drag_Split_Per_Length_Jac, & CD_Component_Wave_Kinematics, CD_Solve_Dispersion_Wavenumber, CD_HYDRO_OK USE CableDyn_SeabedContact, ONLY: CD_Seabed_Normal_Law, CD_Seabed_Contact_Gate, CD_SEABED_CONTACT_BLEND, & CD_Seabed_Friction_Stick_Slip, CD_Seabed_Friction_Aniso, & @@ -163,6 +164,9 @@ MODULE CableDyn_HermiteCableDynamic PUBLIC :: CD_HermiteCable_Dyn_Reset_Profile, CD_HermiteCable_Dyn_Disable_Profile, & CD_HermiteCable_Dyn_Get_Profile, CD_HermiteCable_Dyn_Get_Assembly_Profile PUBLIC :: CD_HermiteCable_Dyn_Profile_Enabled + ! Ambient normal flow speed [m/s] below which the split cross-flow drag blends to Morison's + ! (CD_Morison_Drag_Split_Per_Length_Jac u_ref): its axes are undefined in still water. + REAL(wp), PARAMETER, PUBLIC :: CD_HCDYN_CDY_UREF = 0.01_wp INTEGER, PARAMETER, PUBLIC :: CD_HCDYN_OK = 0, CD_HCDYN_BADINPUT = 1, CD_HCDYN_NOCONVERGE = 2 INTEGER, PARAMETER, PUBLIC :: CD_HCDYN_TENSILE_OFF = 0 INTEGER, PARAMETER, PUBLIC :: CD_HCDYN_TENSILE_WARN = 1 @@ -369,6 +373,12 @@ MODULE CableDyn_HermiteCableDynamic ! frequency, lift scale and amplitude ratio take viv_dv(e) where it is positive, the drag ! diameter diam(e) elsewhere and when it is unallocated (viv_diam). REAL(wp), ALLOCATABLE :: viv_dv(:) + ! Cross-flow hydrodynamic damping of Thorsen et al. (2016) (Set_VIV cdy; VIV DAMPING section): + ! viv_cdy(:, e) = (a, b, c), the element's normal drag split into Morison in line and the + ! cross-flow damping 1/2 rho D [C_dy |w_y| + c Cdn |w|] w_y, C_dy = a + b y0/D, across the ambient + ! flow (elem_cdy, elem_cdy_lin; c Cdn with the element's unamplified Cdn); a < 0, or the array + ! unallocated, keeps the element's Morison drag. + REAL(wp), ALLOCATABLE :: viv_cdy(:, :) REAL(wp), ALLOCATABLE :: Mgb(:, :) ! constant global mass (band) LOGICAL, ALLOCATABLE :: freemask(:), solve_mask(:) INTEGER, ALLOCATABLE :: fmap(:) ! free -> global DOF index @@ -1127,7 +1137,7 @@ SUBROUTINE CD_HermiteCable_Dyn_Set_Friction_Axial(model, mu_axial, ErrStat, ErrM END SUBROUTINE CD_HermiteCable_Dyn_Set_Friction_Axial SUBROUTINE CD_HermiteCable_Dyn_Set_VIV(model, cl, cf, df, t_window, ErrStat, ErrMsg, phase_seed, tangent_reversed, & - clx, il_alpha, chh, wake, amp, amp_n, dviv) + clx, il_alpha, chh, wake, amp, amp_n, dviv, cdy) !! Install the cross-flow VIV synchronisation model (CableDyn_VIV) on a cable with drag: !! per element the lift coefficient cl (0: no lift) and the band df/cf, and the running-RMS !! averaging time t_window (s; 0 takes 500 steps of the first step). The lift acts on the @@ -1167,6 +1177,14 @@ SUBROUTINE CD_HermiteCable_Dyn_Set_VIV(model, cl, cf, df, t_window, ErrStat, Err !! dviv (optional), per element, the diameter of the VIV model (> 0), which the shedding !! frequency, the lift and in-line scales and the amplitude ratio take in place of the drag !! diameter (0: the drag diameter, also after a later Set_Drag). + !! + !! cdy (optional, (2 or 3, ne)), per element (a, b[, c]) of the cross-flow hydrodynamic damping of + !! Thorsen et al. (2016, Eq. 1), C_dy = a + b y0/D (a < 0: none on that element): the element's + !! normal drag keeps Morison's in-line part (with any amplitude-table drag factor) and takes + !! 1/2 rho D [C_dy |w_y| + c Cdn |w|] w_y across the ambient flow (c = 0 without the third row; + !! CD_Morison_Drag_Split_Per_Length_Jac), y0 the smoothed amplitude estimate, so an element with + !! it needs an amplitude table (amp_n > 0); a, b, c >= 0, finite. (0, 0, 1) amplifies the in-line + !! drag alone and keeps Morison's cross-flow drag. TYPE(CD_HermiteCableDynType), INTENT(INOUT) :: model REAL(wp), INTENT(IN) :: cl(:), cf(:), df(:), t_window INTEGER, INTENT(OUT) :: ErrStat @@ -1181,12 +1199,13 @@ SUBROUTINE CD_HermiteCable_Dyn_Set_VIV(model, cl, cf, df, t_window, ErrStat, Err REAL(wp), INTENT(IN), OPTIONAL :: amp(:, :, :) INTEGER, INTENT(IN), OPTIONAL :: amp_n(:) REAL(wp), INTENT(IN), OPTIONAL :: dviv(:) + REAL(wp), INTENT(IN), OPTIONAL :: cdy(:, :) INTEGER :: e, k, ne, nn, es, nms REAL(wp) :: wsum, tw_old, rest_old LOGICAL :: had_viv, had_il, want_il, had_wake, want_wake, bad_band, had_amp, want_amp CHARACTER(LEN=1024) :: em REAL(wp), ALLOCATABLE :: p_amp(:, :, :) - REAL(wp), ALLOCATABLE :: p_dv(:) + REAL(wp), ALLOCATABLE :: p_dv(:), p_cdy(:, :) INTEGER, ALLOCATABLE :: p_ampn(:) REAL(wp), ALLOCATABLE :: a_old(:), o_cl(:), o_k(:), o_cf(:), o_df(:), o_dn(:), o_phi(:), o_phi_eval(:), & o_rate(:), o_ms(:, :), o_ms_next(:, :), o_rec_phi(:), o_rec_ms(:, :), & @@ -1329,6 +1348,32 @@ SUBROUTINE CD_HermiteCable_Dyn_Set_VIV(model, cl, cf, df, t_window, ErrStat, Err ErrMsg = 'CD_HermiteCable_Dyn_Set_VIV: dviv must be non-negative (0 = the drag diameter)'; RETURN END IF END IF + IF (PRESENT(cdy)) THEN + IF ((SIZE(cdy, 1) /= 2 .AND. SIZE(cdy, 1) /= 3) .OR. SIZE(cdy, 2) /= ne) THEN + ErrStat = CD_HCDYN_BADINPUT + ErrMsg = 'CD_HermiteCable_Dyn_Set_VIV: cdy must have shape (2 or 3, n_elem)'; RETURN + END IF + IF (.NOT. CD_All_Finite(cdy)) THEN + ErrStat = CD_HCDYN_BADINPUT; ErrMsg = 'CD_HermiteCable_Dyn_Set_VIV: cdy must be finite'; RETURN + END IF + DO e = 1, ne + IF (cdy(1, e) < CD_ZERO) CYCLE + IF (ANY(cdy(2:, e) < CD_ZERO)) THEN + ErrStat = CD_HCDYN_BADINPUT + ErrMsg = 'CD_HermiteCable_Dyn_Set_VIV: the cross-flow damping b and c must be non-negative'; RETURN + END IF + IF (.NOT. want_amp) THEN + ErrStat = CD_HCDYN_BADINPUT + ErrMsg = 'CD_HermiteCable_Dyn_Set_VIV: the cross-flow damping takes its amplitude from an amplitude '// & + 'table (amp, amp_n)'; RETURN + END IF + IF (amp_n(e) <= 0) THEN + ErrStat = CD_HCDYN_BADINPUT + ErrMsg = 'CD_HermiteCable_Dyn_Set_VIV: an element with cross-flow damping needs an amplitude table' + RETURN + END IF + END DO + END IF ! the previous configuration and state, kept for a rollback had_viv = model%has_viv had_il = model%has_viv_il @@ -1365,6 +1410,13 @@ SUBROUTINE CD_HermiteCable_Dyn_Set_VIV(model, cl, cf, df, t_window, ErrStat, Err model%viv_dv = dviv END IF END IF + IF (PRESENT(cdy)) THEN + IF (ANY(cdy(1, :) >= CD_ZERO)) THEN + ALLOCATE (model%viv_cdy(3, ne)) + model%viv_cdy = CD_ZERO + model%viv_cdy(1:SIZE(cdy, 1), :) = cdy + END IF + END IF model%viv_cl = cl model%viv_cf = CD_ZERO model%viv_df = CD_ZERO @@ -1512,6 +1564,7 @@ SUBROUTINE move_viv(back) CALL MOVE_ALLOC(w_snap, model%snap_wo_s) CALL MOVE_ALLOC(p_amp, model%viv_amp); CALL MOVE_ALLOC(p_ampn, model%viv_amp_n) CALL MOVE_ALLOC(p_dv, model%viv_dv) + CALL MOVE_ALLOC(p_cdy, model%viv_cdy) ELSE CALL MOVE_ALLOC(model%viv_cl, o_cl); CALL MOVE_ALLOC(model%viv_k, o_k) CALL MOVE_ALLOC(model%viv_cf, o_cf); CALL MOVE_ALLOC(model%viv_df, o_df) @@ -1536,6 +1589,7 @@ SUBROUTINE move_viv(back) CALL MOVE_ALLOC(model%snap_wo_s, w_snap) CALL MOVE_ALLOC(model%viv_amp, p_amp); CALL MOVE_ALLOC(model%viv_amp_n, p_ampn) CALL MOVE_ALLOC(model%viv_dv, p_dv) + CALL MOVE_ALLOC(model%viv_cdy, p_cdy) END IF END SUBROUTINE move_viv END SUBROUTINE CD_HermiteCable_Dyn_Set_VIV @@ -1559,6 +1613,7 @@ SUBROUTINE clear_viv(model) IF (ALLOCATED(model%viv_amp)) DEALLOCATE (model%viv_amp) IF (ALLOCATED(model%viv_amp_n)) DEALLOCATE (model%viv_amp_n) IF (ALLOCATED(model%viv_dv)) DEALLOCATE (model%viv_dv) + IF (ALLOCATED(model%viv_cdy)) DEALLOCATE (model%viv_cdy) model%has_viv_amp = .FALSE. model%has_viv = .FALSE. model%has_viv_il = .FALSE. @@ -1647,6 +1702,28 @@ PURE REAL(wp) FUNCTION elem_cdn(model, e) RESULT(cdn) model%viv_amp(3, 1:n, e)) END FUNCTION elem_cdn + PURE REAL(wp) FUNCTION elem_cdy(model, e) RESULT(cdy) + !! The cross-flow damping coefficient C_dy = a + b y0/D of element e (Thorsen et al. 2016, Eq. 1), + !! at the element's smoothed amplitude over its VIV diameter; -1 where the element keeps the + !! Morison drag (the drag kernel's switch). + TYPE(CD_HermiteCableDynType), INTENT(IN) :: model + INTEGER, INTENT(IN) :: e + cdy = -CD_ONE + IF (.NOT. ALLOCATED(model%viv_cdy)) RETURN + IF (model%viv_cdy(1, e) < CD_ZERO) RETURN + cdy = model%viv_cdy(1, e) + model%viv_cdy(2, e)*viv_elem_amplitude(model, e)/viv_diam(model, e) + END FUNCTION elem_cdy + + PURE REAL(wp) FUNCTION elem_cdy_lin(model, e) RESULT(cl) + !! The Morison-form cross-flow coefficient c Cdn of element e (its unamplified Cdn), 0 without. + TYPE(CD_HermiteCableDynType), INTENT(IN) :: model + INTEGER, INTENT(IN) :: e + cl = CD_ZERO + IF (.NOT. ALLOCATED(model%viv_cdy)) RETURN + IF (model%viv_cdy(1, e) < CD_ZERO) RETURN + cl = model%viv_cdy(3, e)*model%cdn(e) + END FUNCTION elem_cdy_lin + REAL(wp) FUNCTION viv_node_ambient_yd(model, k) RESULT(yd) !! Cross-flow velocity of node k across the ambient flow (current plus a held field) normal to !! its tangent (the slope DOFs) at the committed state, the y' of the amplitude estimate @@ -1921,23 +1998,28 @@ SUBROUTINE element_drag_load(model, e, qe, ve, l0, t_eval, fdrag, ErrStat, ErrMs wv_depth=model%wv_depth, wv_dir=model%wv_dir, wv_t=t_eval, & wvc_amp=model%wv_ampc, wvc_om=model%wv_omc, & wvc_k=model%wv_kc, wvc_ph=model%wv_phc, & - wvc_e2kd=model%wv_e2kd) + wvc_e2kd=model%wv_e2kd, cdy=elem_cdy(model, e), & + cdy_lin=elem_cdy_lin(model, e)) ELSE IF (model%has_wave) THEN CALL CD_HermiteCable_Drag_Element(qe, ve, l0, model%current, model%waterline_z, & model%rho_w, model%diam(e), elem_cdn(model, e), model%cdt(e), & fdrag, ErrStat=es, ErrMsg=ErrMsg, & wv_h=model%wv_h, wv_om=model%wv_om, wv_k=model%wv_k, & - wv_depth=model%wv_depth, wv_dir=model%wv_dir, wv_t=t_eval) + wv_depth=model%wv_depth, wv_dir=model%wv_dir, wv_t=t_eval, & + cdy=elem_cdy(model, e), & + cdy_lin=elem_cdy_lin(model, e)) ELSE IF (model%has_held_field) THEN CALL CD_HermiteCable_Drag_Element(qe, ve, l0, & model%current + 0.5_wp*(model%hf_u(:, e) + model%hf_u(:, e + 1)), & 0.5_wp*(model%hf_wl(e) + model%hf_wl(e + 1)), & model%rho_w, model%diam(e), elem_cdn(model, e), model%cdt(e), & - fdrag, ErrStat=es, ErrMsg=ErrMsg) + fdrag, ErrStat=es, ErrMsg=ErrMsg, cdy=elem_cdy(model, e), & + cdy_lin=elem_cdy_lin(model, e)) ELSE CALL CD_HermiteCable_Drag_Element(qe, ve, l0, model%current, model%waterline_z, & model%rho_w, model%diam(e), elem_cdn(model, e), model%cdt(e), & - fdrag, ErrStat=es, ErrMsg=ErrMsg) + fdrag, ErrStat=es, ErrMsg=ErrMsg, cdy=elem_cdy(model, e), & + cdy_lin=elem_cdy_lin(model, e)) END IF ErrStat = es END SUBROUTINE element_drag_load @@ -9690,13 +9772,16 @@ SUBROUTINE assemble_residual(model, q_cfg, v_cfg, t_eval, want_residual, want_ta wv_depth=model%wv_depth, wv_dir=model%wv_dir, wv_t=t_eval, & wvc_amp=model%wv_ampc, wvc_om=model%wv_omc, & wvc_k=model%wv_kc, wvc_ph=model%wv_phc, & - wvc_e2kd=model%wv_e2kd) + wvc_e2kd=model%wv_e2kd, cdy=elem_cdy(model, e), & + cdy_lin=elem_cdy_lin(model, e)) ELSE IF (model%has_wave) THEN CALL CD_HermiteCable_Drag_Element(qe, ve, model%l0(e), model%current, model%waterline_z, & model%rho_w, model%diam(e), elem_cdn(model, e), model%cdt(e), & fdrag, djq, djv, es, em_e, & wv_h=model%wv_h, wv_om=model%wv_om, wv_k=model%wv_k, & - wv_depth=model%wv_depth, wv_dir=model%wv_dir, wv_t=t_eval) + wv_depth=model%wv_depth, wv_dir=model%wv_dir, wv_t=t_eval, & + cdy=elem_cdy(model, e), & + cdy_lin=elem_cdy_lin(model, e)) ELSE IF (model%has_held_field) THEN ! HELD host field: the element's ambient velocity = the drag config's constant ! current + the two end nodes' held-velocity average; the element waterline = @@ -9705,11 +9790,13 @@ SUBROUTINE assemble_residual(model, q_cfg, v_cfg, t_eval, want_residual, want_ta model%current + 0.5_wp*(model%hf_u(:, e) + model%hf_u(:, e + 1)), & 0.5_wp*(model%hf_wl(e) + model%hf_wl(e + 1)), & model%rho_w, model%diam(e), elem_cdn(model, e), model%cdt(e), & - fdrag, djq, djv, es, em_e) + fdrag, djq, djv, es, em_e, cdy=elem_cdy(model, e), & + cdy_lin=elem_cdy_lin(model, e)) ELSE CALL CD_HermiteCable_Drag_Element(qe, ve, model%l0(e), model%current, model%waterline_z, & model%rho_w, model%diam(e), elem_cdn(model, e), model%cdt(e), & - fdrag, djq, djv, es, em_e) + fdrag, djq, djv, es, em_e, cdy=elem_cdy(model, e), & + cdy_lin=elem_cdy_lin(model, e)) END IF ELSE CALL element_drag_load(model, e, qe, ve, model%l0(e), t_eval, fdrag, es, em_e) @@ -11234,22 +11321,27 @@ SUBROUTINE evaluate_tangent_element(model, e, q_cfg, v_cfg, t_eval, Kstruct, Kdr fload, djq, djv, es, em, wv_depth=model%wv_depth, & wv_dir=model%wv_dir, wv_t=t_eval, wvc_amp=model%wv_ampc, & wvc_om=model%wv_omc, wvc_k=model%wv_kc, wvc_ph=model%wv_phc, & - wvc_e2kd=model%wv_e2kd) + wvc_e2kd=model%wv_e2kd, cdy=elem_cdy(model, e), & + cdy_lin=elem_cdy_lin(model, e)) ELSE IF (model%has_wave) THEN CALL CD_HermiteCable_Drag_Element(qe, ve, model%l0(e), model%current, model%waterline_z, & model%rho_w, model%diam(e), elem_cdn(model, e), model%cdt(e), & fload, djq, djv, es, em, wv_h=model%wv_h, wv_om=model%wv_om, & wv_k=model%wv_k, wv_depth=model%wv_depth, wv_dir=model%wv_dir, & - wv_t=t_eval) + wv_t=t_eval, cdy=elem_cdy(model, e), & + cdy_lin=elem_cdy_lin(model, e)) ELSE IF (model%has_held_field) THEN CALL CD_HermiteCable_Drag_Element(qe, ve, model%l0(e), & model%current + 0.5_wp*(model%hf_u(:, e) + model%hf_u(:, e + 1)), & 0.5_wp*(model%hf_wl(e) + model%hf_wl(e + 1)), model%rho_w, & - model%diam(e), elem_cdn(model, e), model%cdt(e), fload, djq, djv, es, em) + model%diam(e), elem_cdn(model, e), model%cdt(e), fload, djq, djv, es, em, & + cdy=elem_cdy(model, e), & + cdy_lin=elem_cdy_lin(model, e)) ELSE CALL CD_HermiteCable_Drag_Element(qe, ve, model%l0(e), model%current, model%waterline_z, & model%rho_w, model%diam(e), elem_cdn(model, e), model%cdt(e), & - fload, djq, djv, es, em) + fload, djq, djv, es, em, cdy=elem_cdy(model, e), & + cdy_lin=elem_cdy_lin(model, e)) END IF IF (es /= CD_HCDYN_OK) THEN ErrStat = es; ErrMsg = TRIM(em); RETURN @@ -11515,7 +11607,7 @@ END SUBROUTINE CD_HermiteCable_Axial_Damping_Element SUBROUTINE CD_HermiteCable_Drag_Element(qe, ve, l0, fluid, waterline_z, rho, diam, cdn, cdt, & fdrag, djq, djv, ErrStat, ErrMsg, & wv_h, wv_om, wv_k, wv_depth, wv_dir, wv_t, & - wvc_amp, wvc_om, wvc_k, wvc_ph, wvc_e2kd) + wvc_amp, wvc_om, wvc_k, wvc_ph, wvc_e2kd, cdy, cdy_lin) !! Consistent Gauss-integrated Morison quadratic drag on one cubic-Hermite bending-cable element. !! qe(12), ve(12) = [r1, m1, r2, m2] nodal positions and velocities; the interior velocity and !! tangent use the SAME cubic-Hermite interpolation as the geometry, so the material-tangent (m) @@ -11541,6 +11633,13 @@ SUBROUTINE CD_HermiteCable_Drag_Element(qe, ve, l0, fluid, waterline_z, rho, dia !! the standard explicit-field treatment (the residual is exact; the tangent omits a term of !! order k*H*omega, far below the structural stiffness), so Newton convergence is preserved. REAL(wp), INTENT(IN) :: qe(12), ve(12), l0, fluid(3), waterline_z, rho, diam, cdn, cdt + ! cross-flow damping coefficient C_dy >= 0 of Thorsen et al. (2016): the normal drag splits into + ! Morison in line and 1/2 rho D C_dy |w_y| w_y across the ambient flow (fluid plus the waves at the + ! point), CD_Morison_Drag_Split_Per_Length_Jac with u_ref CD_HCDYN_CDY_UREF; absent or negative: + ! Morison's drag + REAL(wp), INTENT(IN), OPTIONAL :: cdy + ! with cdy: the Morison-form cross-flow coefficient (CD_Morison_Drag_Split_Per_Length_Jac cdy_lin) + REAL(wp), INTENT(IN), OPTIONAL :: cdy_lin REAL(wp), INTENT(OUT) :: fdrag(12) ! djq/djv are OPTIONAL as a pair: a residual-only evaluation (a line-search trial, which ! never solves with a tangent) omits both and skips the 12x12 Jacobian accumulation -- @@ -11557,8 +11656,8 @@ SUBROUTINE CD_HermiteCable_Drag_Element(qe, ve, l0, fluid, waterline_z, rho, dia REAL(wp), PARAMETER :: G3 = 0.7745966692414834_wp ! sqrt(3/5) REAL(wp) :: gp(NGP), gw(NGP), H(4), dH(4) REAL(wp) :: rpos(3), vvel(3), rp(3), speed, tangent(3), urel(3), fpl(3), Jrel(3, 3), Jtan(3, 3) - REAL(wp) :: jq3(3, 3), scale, eta_w, uw(3), aw(3) - LOGICAL :: has_wv, has_shared, has_trio, has_cmp, any_wv_arg, want_jac + REAL(wp) :: jq3(3, 3), scale, eta_w, uw(3), aw(3), uamb(3) + LOGICAL :: has_wv, has_shared, has_trio, has_cmp, any_wv_arg, want_jac, split INTEGER :: g, s, c, sp, cp, a, b, es ! the message of a per-Gauss-point CableDyn_Hydro kinematics or Morison call (at most 154 ! characters): a short buffer, as these calls reset it at every Gauss point @@ -11574,6 +11673,9 @@ SUBROUTINE CD_HermiteCable_Drag_Element(qe, ve, l0, fluid, waterline_z, rho, dia IF (want_jac) THEN djq = CD_ZERO; djv = CD_ZERO END IF + split = PRESENT(cdy) + IF (split) split = cdy >= CD_ZERO + uw = CD_ZERO has_shared = PRESENT(wv_depth) .AND. PRESENT(wv_dir) .AND. PRESENT(wv_t) has_trio = PRESENT(wv_h) .AND. PRESENT(wv_om) .AND. PRESENT(wv_k) has_cmp = PRESENT(wvc_amp) .AND. PRESENT(wvc_om) .AND. PRESENT(wvc_k) .AND. PRESENT(wvc_ph) @@ -11663,7 +11765,17 @@ SUBROUTINE CD_HermiteCable_Drag_Element(qe, ve, l0, fluid, waterline_z, rho, dia ! Pass the raw dr/dxi as the tangent vector: the primitive normalises it and returns Jtan = ! d f_perlen / d(dr/dxi), so d f_perlen/d qe folds in through d(dr/dxi)/d qe = dH directly. ! rho, diam, cdn and cdt were validated above, before the Gauss loop. - IF (want_jac) THEN + IF (split) THEN + uamb = fluid + IF (has_wv) uamb = uamb + uw + IF (want_jac) THEN + CALL CD_Morison_Drag_Split_Per_Length_Jac(urel, uamb, rp, rho, diam, cdn, cdy, cdt, CD_HCDYN_CDY_UREF, & + fpl, Jrel, Jtan, es, em2, cdy_lin=cdy_lin) + ELSE + CALL CD_Morison_Drag_Split_Per_Length_Jac(urel, uamb, rp, rho, diam, cdn, cdy, cdt, CD_HCDYN_CDY_UREF, & + fpl, ErrStat=es, ErrMsg=em2, cdy_lin=cdy_lin) + END IF + ELSE IF (want_jac) THEN CALL CD_Morison_Drag_Per_Length_Jac(urel, rp, rho, diam, cdn, cdt, fpl, Jrel, Jtan, es, em2, & scalars_validated=.TRUE.) ELSE diff --git a/src/CableDyn_Hydro.f90 b/src/CableDyn_Hydro.f90 index 45514fc9..6d6f238f 100644 --- a/src/CableDyn_Hydro.f90 +++ b/src/CableDyn_Hydro.f90 @@ -23,6 +23,7 @@ MODULE CableDyn_Hydro PUBLIC :: CD_Split_Normal_Tangential PUBLIC :: CD_Morison_Drag_Per_Length PUBLIC :: CD_Morison_Drag_Per_Length_Jac + PUBLIC :: CD_Morison_Drag_Split_Per_Length_Jac PUBLIC :: CD_Morison_Added_Mass_Per_Length PUBLIC :: CD_Froude_Krylov_Per_Length PUBLIC :: CD_Solve_Dispersion_Wavenumber @@ -1459,6 +1460,167 @@ SUBROUTINE CD_Morison_Drag_Per_Length_Jac(rel_velocity, tangent, rho, diameter, END IF END SUBROUTINE CD_Morison_Drag_Per_Length_Jac + SUBROUTINE CD_Morison_Drag_Split_Per_Length_Jac(rel_velocity, ambient, tangent, rho, diameter, cdn, cdy, cdt, & + u_ref, force, jac_rel, jac_tan, ErrStat, ErrMsg, scalars_validated, & + cdy_lin) + !! Drag per unit length [N/m] with the cross-flow part of Thorsen, Saevik and Larsen (J. Fluids + !! Struct. 61, 2016, Eq. 1): in the frame of the AMBIENT normal flow u_n = P u (P = I - t t^T), + !! e_x = u_n/|u_n| in line and e_y = t x e_x across, the relative normal velocity w = P rel splits + !! into w_x = w . e_x and w_y = w . e_y, and the normal drag + !! + !! f_s = 1/2 rho D [cdn |w| w_x e_x + cdy |w_y| w_y e_y] + !! + !! keeps Morison's in-line part and replaces its cross-flow part by the quadratic cross-flow + !! damping cdy |w_y| w_y (w_y = -y', the node's cross-flow velocity reversed). Where the ambient + !! normal flow vanishes the axes are undefined, so the normal drag blends to Morison's, + !! f_n = beta f_s + (1 - beta) f_M, f_M = 1/2 rho D cdn |w| w, beta = U^2/(U^2 + u_ref^2) with + !! U = |u_n|; below U = 1e-9 u_ref (beta < 1e-18) the result is CD_Morison_Drag_Per_Length_Jac's + !! own, bit for bit. The tangential drag is CD_Morison_Drag_Per_Length_Jac's. ambient is the + !! undisturbed fluid velocity at the point (rel_velocity = ambient - structure velocity). Jacobians as in + !! CD_Morison_Drag_Per_Length_Jac: jac_rel = d force/d rel_velocity at fixed ambient, jac_tan = + !! d force/d tangent (the input vector, normalised inside), both exact; OPTIONAL as a pair, the + !! force identical with or without them. cdy >= 0 and u_ref > 0 are checked with the scalars. + !! cdy_lin (optional, >= 0, default 0) adds a Morison-form cross-flow term 1/2 rho D cdy_lin |w| w_y + !! e_y: with cdy = 0 and cdy_lin the unamplified Morison coefficient, a drag amplification passed + !! in cdn acts on the in-line drag alone while the cross-flow drag stays Morison's. + REAL(wp), INTENT(IN) :: rel_velocity(3), ambient(3), tangent(3), rho, diameter, cdn, cdy, cdt, u_ref + REAL(wp), INTENT(OUT) :: force(3) + REAL(wp), INTENT(OUT), OPTIONAL :: jac_rel(3, 3), jac_tan(3, 3) + INTEGER, INTENT(OUT) :: ErrStat + CHARACTER(*), INTENT(OUT) :: ErrMsg + LOGICAL, INTENT(IN), OPTIONAL :: scalars_validated + REAL(wp), INTENT(IN), OPTIONAL :: cdy_lin + REAL(wp) :: tnorm, tu(3), pm(3, 3), w(3), wm, un(3), ua, ex(3), ey(3), wx, wy, fm(3), fs(3), beta, cn, cy, cl + REAL(wp) :: dfm(3, 3), dfs(3, 3), dt(3), dw(3), dun(3), dua, dex(3), dey(3), dwx, dwy, dwm, dfmv(3), dfsv(3) + REAL(wp) :: dbeta, ft(3), jrt(3, 3), jtt(3, 3) + INTEGER :: k + LOGICAL :: want_jac, check_scalars, split + + want_jac = PRESENT(jac_rel) + force = CD_ZERO + IF (want_jac .NEQV. PRESENT(jac_tan)) THEN + CALL fail(ErrStat, ErrMsg, 'jac_rel and jac_tan must be supplied together (or neither)') + RETURN + END IF + IF (want_jac) THEN + jac_rel = CD_ZERO; jac_tan = CD_ZERO + END IF + ErrStat = CD_HYDRO_OK; ErrMsg = '' + check_scalars = .TRUE. + IF (PRESENT(scalars_validated)) check_scalars = .NOT. scalars_validated + IF (check_scalars) THEN + IF (.NOT. (CD_Is_Finite(cdy) .AND. cdy >= CD_ZERO .AND. CD_Is_Finite(u_ref) .AND. u_ref > CD_ZERO .AND. & + CD_Is_Finite(cdn) .AND. cdn >= CD_ZERO)) THEN + CALL fail(ErrStat, ErrMsg, 'the drag coefficients must be finite and non-negative and u_ref positive') + RETURN + END IF + END IF + IF (.NOT. CD_All_Finite(ambient)) THEN + CALL fail(ErrStat, ErrMsg, 'the ambient fluid velocity must be finite') + RETURN + END IF + ! tangential drag (and every other input check) from the Morison primitive with cdn = 0 + IF (want_jac) THEN + CALL CD_Morison_Drag_Per_Length_Jac(rel_velocity, tangent, rho, diameter, CD_ZERO, cdt, ft, jrt, jtt, & + ErrStat, ErrMsg, scalars_validated) + ELSE + CALL CD_Morison_Drag_Per_Length_Jac(rel_velocity, tangent, rho, diameter, CD_ZERO, cdt, ft, ErrStat=ErrStat, & + ErrMsg=ErrMsg, scalars_validated=scalars_validated) + END IF + IF (ErrStat /= CD_HYDRO_OK) RETURN + tnorm = SQRT(DOT_PRODUCT(tangent, tangent)) + tu = tangent/tnorm + pm = identity3() - outer3(tu, tu) + cn = 0.5_wp*rho*diameter*cdn + cy = 0.5_wp*rho*diameter*cdy + cl = CD_ZERO + IF (PRESENT(cdy_lin)) THEN + IF (.NOT. (CD_Is_Finite(cdy_lin) .AND. cdy_lin >= CD_ZERO)) THEN + CALL fail(ErrStat, ErrMsg, 'the linear cross-flow drag coefficient must be finite and non-negative') + RETURN + END IF + cl = 0.5_wp*rho*diameter*cdy_lin + END IF + un = MATMUL(pm, ambient) + ua = SQRT(DOT_PRODUCT(un, un)) + split = ua > 1.0e-9_wp*u_ref + IF (.NOT. split) THEN + ! no ambient normal flow: Morison's drag, from its own primitive (bit for bit) + IF (want_jac) THEN + CALL CD_Morison_Drag_Per_Length_Jac(rel_velocity, tangent, rho, diameter, cdn, cdt, force, jac_rel, jac_tan, & + ErrStat, ErrMsg, scalars_validated) + ELSE + CALL CD_Morison_Drag_Per_Length_Jac(rel_velocity, tangent, rho, diameter, cdn, cdt, force, ErrStat=ErrStat, & + ErrMsg=ErrMsg, scalars_validated=scalars_validated) + END IF + RETURN + END IF + w = MATMUL(pm, rel_velocity) + wm = SQRT(DOT_PRODUCT(w, w)) + fm = cn*wm*w + beta = CD_ZERO + fs = fm + ex = CD_ZERO; ey = CD_ZERO; wx = CD_ZERO; wy = CD_ZERO + IF (split) THEN + ex = un/ua + ey = cross3(tu, ex) + wx = DOT_PRODUCT(w, ex) + wy = DOT_PRODUCT(w, ey) + fs = cn*wm*wx*ex + cy*ABS(wy)*wy*ey + cl*wm*wy*ey + beta = ua*ua/(ua*ua + u_ref*u_ref) + END IF + force = ft + beta*fs + (CD_ONE - beta)*fm + IF (want_jac) THEN + ! d/d rel at fixed ambient and tangent: d w/d rel = P + dfm = CD_ZERO + dfs = CD_ZERO + IF (wm > MIN_TANGENT_NORM) THEN + dfm = cn*(wm*identity3() + outer3(w, w)/wm) + IF (split) dfs = cn*outer3(ex, wx*w/wm + wm*ex) + cl*outer3(ey, wy*w/wm + wm*ey) + END IF + IF (split) dfs = dfs + cy*2.0_wp*ABS(wy)*outer3(ey, ey) + jac_rel = jrt + MATMUL(beta*dfs + (CD_ONE - beta)*dfm, pm) + ! d/d tangent: directional derivatives along dt = P e_k/|tangent| (the unit-tangent change of + ! the input vector's k-th component), through P (so w and u_n), e_x, e_y and beta + jac_tan = jtt + DO k = 1, 3 + dt = pm(:, k)/tnorm + dw = -(dt*DOT_PRODUCT(tu, rel_velocity) + tu*DOT_PRODUCT(dt, rel_velocity)) + dwm = CD_ZERO + IF (wm > MIN_TANGENT_NORM) dwm = DOT_PRODUCT(w, dw)/wm + dfmv = cn*(dwm*w + wm*dw) + dfsv = dfmv + dbeta = CD_ZERO + IF (split) THEN + dun = -(dt*DOT_PRODUCT(tu, ambient) + tu*DOT_PRODUCT(dt, ambient)) + dua = DOT_PRODUCT(ex, dun) + dex = (dun - ex*dua)/ua + dey = cross3(dt, ex) + cross3(tu, dex) + dwx = DOT_PRODUCT(dw, ex) + DOT_PRODUCT(w, dex) + dwy = DOT_PRODUCT(dw, ey) + DOT_PRODUCT(w, dey) + dfsv = cn*(dwm*wx*ex + wm*dwx*ex + wm*wx*dex) + cy*(2.0_wp*ABS(wy)*dwy*ey + ABS(wy)*wy*dey) + & + cl*(dwm*wy*ey + wm*dwy*ey + wm*wy*dey) + dbeta = 2.0_wp*ua*dua*u_ref*u_ref/(ua*ua + u_ref*u_ref)**2 + END IF + jac_tan(:, k) = jac_tan(:, k) + dbeta*(fs - fm) + beta*dfsv + (CD_ONE - beta)*dfmv + END DO + END IF + IF (.NOT. CD_All_Finite(force)) THEN + force = CD_ZERO + IF (want_jac) THEN + jac_rel = CD_ZERO; jac_tan = CD_ZERO + END IF + CALL fail(ErrStat, ErrMsg, 'split drag result or Jacobian overflowed') + RETURN + END IF + IF (want_jac) THEN + IF (.NOT. CD_All_Finite(jac_rel) .OR. .NOT. CD_All_Finite(jac_tan)) THEN + force = CD_ZERO; jac_rel = CD_ZERO; jac_tan = CD_ZERO + CALL fail(ErrStat, ErrMsg, 'split drag result or Jacobian overflowed') + END IF + END IF + END SUBROUTINE CD_Morison_Drag_Split_Per_Length_Jac + SUBROUTINE CD_Morison_Added_Mass_Per_Length(tangent, rho, diameter, can, cat, M_a, ErrStat, ErrMsg) !! Morison added-mass matrix per unit length [kg/m]: !! M_a = rho A (Can (I - qq^T) + Cat qq^T), A = pi d^2 / 4. @@ -3453,6 +3615,12 @@ PURE FUNCTION outer3(a, b) RESULT(out) END DO END FUNCTION outer3 + PURE FUNCTION cross3(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 cross3 + PURE REAL(wp) FUNCTION deterministic_phase(i) RESULT(phase) INTEGER, INTENT(IN) :: i REAL(wp), PARAMETER :: GOLDEN = 0.618033988749894848204586834365638118_wp diff --git a/tests/test_viv_cf_damping_deck.f90 b/tests/test_viv_cf_damping_deck.f90 new file mode 100644 index 00000000..19447922 --- /dev/null +++ b/tests/test_viv_cf_damping_deck.f90 @@ -0,0 +1,280 @@ +! File: tests/test_viv_cf_damping_deck.f90 +! SPDX-License-Identifier: Apache-2.0 +! Copyright (c) 2026 Jae Hoon Seo, SMI Lab, Inha University +PROGRAM test_viv_cf_damping_deck + !! The split drag of a VIV DAMPING row (TypeName a b [c]: Morison in line, 1/2 rho D [C_dy |w_y| + + !! c Cdn |w|] w_y across the ambient flow, C_dy = a + b y0/D of Thorsen et al. 2016) on the taut + !! finite-EI cable of the VIV amplitude gate (100 m, D 0.1 m, 50 kN, Cl 0.8, 0.15 m/s along y): + !! D1 `0 0 1` with a table of Cv = Cl and drag factor 1 is the deck without the section (the + !! split recombines Morison's drag to round-off, test_viv_cf_damping_kernel K3), to 1e-4 of + !! the response: the VIV phase carries the round-off over 40 s, 1.5e-8 in a Release build and + !! 1.5e-5 in a Debug one; + !! D2 `0 0 1` with Cv 0 and drag factor 2 (no lift, the in-line drag doubled, the cross-flow + !! drag Morison's) settles at the static in-line offset of the deck with Cd 2.4, within 0.5 %; + !! D3 Thorsen's form `0.31 0.89` replaces the cross-flow drag by the quadratic damping, weaker at + !! this amplitude: the steady cross-flow response is larger than with Morison's drag; + !! D4 the energy ledger closes with the split: over the steady window the mean of VIVPow1 + + !! DragPow1 + DampPow1 is within 1 % of the mean VIV power; + !! D5 refusals by name: a row without its table, an EI = 0 line, a malformed row, a negative + !! coefficient, a type named twice, an undefined type. + USE CableDyn_Precision, ONLY: wp + USE CableDyn_DeckDriver, ONLY: CD_Run_Deck_Driver, CD_DECKDRV_OK + IMPLICIT NONE + REAL(wp), PARAMETER :: D = 0.1_wp + CHARACTER(*), PARAMETER :: NEUTRAL = 'riser 0.0 0.8 1.0;riser 1.0 0.8 1.0' + INTEGER :: nfail = 0 + + CALL write_current('vcd_current.dat') + CALL check_identity() + CALL check_inline_amplification() + CALL check_thorsen() + CALL check_refusals() + IF (nfail > 0) THEN + WRITE (*, '(A,I0,A)') 'FAIL: ', nfail, ' assertion(s) failed' + ERROR STOP 1 + END IF + WRITE (*, '(A)') 'PASS: VIV cross-flow 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_current(path) + CHARACTER(*), INTENT(IN) :: path + INTEGER :: u + OPEN (NEWUNIT=u, FILE=path, STATUS='REPLACE', ACTION='WRITE') + WRITE (u, '(A)') 'MoorDyn v2 water kinematics file' + WRITE (u, '(A)') 'uniform current along y for the VIV cross-flow damping deck gate' + WRITE (u, '(A)') '--------------------------- WAVES -------------------------------------' + WRITE (u, '(A)') '0 WaveKinMod - type of wave input' + WRITE (u, '(A)') '"" WaveKinFile - file containing wave elevation time series' + WRITE (u, '(A)') '0.000000E+00 dtWave - time step to use in setting up wave kinematics grid (s)' + WRITE (u, '(A)') '0 WaveDir - wave heading (deg)' + WRITE (u, '(A)') '2 - X wave input type' + WRITE (u, '(A)') '-10, 110, 2 - X wave grid point data' + WRITE (u, '(A)') '2 - Y wave input type' + WRITE (u, '(A)') '-10, 10, 2 - Y wave grid point data' + WRITE (u, '(A)') '2 - Z wave input type' + WRITE (u, '(A)') '-100, 0, 2 - Z wave grid point data' + WRITE (u, '(A)') '--------------------------- CURRENT -------------------------------------' + WRITE (u, '(A)') '1 CurrentMod - type of current input' + WRITE (u, '(A)') 'z-depth x-current y-current' + WRITE (u, '(A)') '(m) (m/s) (m/s)' + WRITE (u, '(A)') '0.0 0.0 0.15' + WRITE (u, '(A)') '-100.0 0.0 0.15' + WRITE (u, '(A)') '--------------------- need this line ------------------' + CLOSE (u) + END SUBROUTINE write_current + + SUBROUTINE write_rows(u, rows) + INTEGER, INTENT(IN) :: u + CHARACTER(*), INTENT(IN) :: rows + INTEGER :: i0, i1 + i0 = 1 + DO + i1 = INDEX(rows(i0:), ';') + IF (i1 == 0) THEN + WRITE (u, '(A)') TRIM(rows(i0:)) + EXIT + END IF + WRITE (u, '(A)') rows(i0:i0 + i1 - 2) + i0 = i0 + i1 + END DO + END SUBROUTINE write_rows + + SUBROUTINE write_deck(path, amp_rows, damp_rows, tmax, ei, cd, power) + !! amp_rows/damp_rows: the VIV AMPLITUDE and VIV DAMPING data rows, ';'-separated ('' for no + !! section); ei the type's EI (default 1.0), cd its Cd (default 1.2); power adds the load-power + !! channels. + CHARACTER(*), INTENT(IN) :: path, amp_rows, damp_rows + REAL(wp), INTENT(IN) :: tmax + CHARACTER(*), INTENT(IN), OPTIONAL :: ei, cd + LOGICAL, INTENT(IN), OPTIONAL :: power + CHARACTER(32) :: ei_col, cd_col + INTEGER :: u + ei_col = '1.0' + IF (PRESENT(ei)) ei_col = ei + cd_col = '1.2' + IF (PRESENT(cd)) cd_col = cd + OPEN (NEWUNIT=u, FILE=path, STATUS='REPLACE', ACTION='WRITE') + WRITE (u, '(A)') '--------------------- CableDyn Input File ---------------------------------' + WRITE (u, '(A)') 'VIV cross-flow damping deck gate: taut cable in a uniform current' + WRITE (u, '(A)') '----------------------- LINE TYPES ------------------------------------------' + WRITE (u, '(A)') 'TypeName Diam Mass/m EA BA/-zeta EI Cd Ca CdAx CaAx Cl dF cF' + WRITE (u, '(A)') 'riser 0.10 10.0 5.0e7 -0.8 '//TRIM(ei_col)//' '//TRIM(cd_col)// & + ' 1.0 0.0 0.0 0.8 0.08 0.18' + WRITE (u, '(A)') '----------------------- POINTS ----------------------------------------------' + WRITE (u, '(A)') 'ID Attachment X Y Z M V CdA CA' + WRITE (u, '(A)') '1 Coupled 0.0 0.0 -50.0 0 0 0 0' + WRITE (u, '(A)') '2 Fixed 100.0 0.0 -50.0 0 0 0 0' + WRITE (u, '(A)') '----------------------- LINES -----------------------------------------------' + WRITE (u, '(A)') 'ID NodeA NodeB Outputs' + WRITE (u, '(A)') '1 1 2 -' + WRITE (u, '(A)') '----------------------- SECTIONS --------------------------------------------' + WRITE (u, '(A)') 'LineID LineType Length NumSegs' + WRITE (u, '(A)') '1 riser 99.900100 50' + IF (LEN_TRIM(amp_rows) > 0) THEN + WRITE (u, '(A)') '----------------------- VIV AMPLITUDE ---------------------------------------' + WRITE (u, '(A)') 'TypeName AD Cv CdAmp' + WRITE (u, '(A)') '(-) (-) (-) (-)' + CALL write_rows(u, amp_rows) + END IF + IF (LEN_TRIM(damp_rows) > 0) THEN + WRITE (u, '(A)') '----------------------- VIV DAMPING -----------------------------------------' + WRITE (u, '(A)') 'TypeName a b c' + WRITE (u, '(A)') '(-) (-) (-) (-)' + CALL write_rows(u, damp_rows) + END IF + WRITE (u, '(A)') '---------------------- OPTIONS ----------------------------------------------' + WRITE (u, '(A)') '0.01 dtM' + WRITE (u, '(A)') '100.0 WtrDpth' + WRITE (u, '(A)') '1025.0 rhoW' + WRITE (u, '(A)') '9.80665 g' + WRITE (u, '(A)') 'vcd_current.dat WaterKin' + WRITE (u, '(A,F8.3,A)') ' ', tmax, ' TMax' + WRITE (u, '(A)') '---------------------- OUTPUTS -----------------------------------------------' + WRITE (u, '(A)') 'L1N26PZ' + WRITE (u, '(A)') 'L1N26PY' + IF (PRESENT(power)) THEN + IF (power) THEN + WRITE (u, '(A)') 'VIVPow1' + WRITE (u, '(A)') 'DragPow1' + WRITE (u, '(A)') 'DampPow1' + END IF + END IF + WRITE (u, '(A)') 'END' + WRITE (u, '(A)') '------------------------- need this line --------------------------------------' + 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, ncol) + CHARACTER(*), INTENT(IN) :: path + REAL(wp), ALLOCATABLE, INTENT(OUT) :: tab(:, :) + INTEGER, INTENT(OUT) :: n + INTEGER, INTENT(IN) :: ncol + CHARACTER(1024) :: rec + INTEGER :: u, ios + ALLOCATE (tab(ncol, 40000)) + 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_identity() + REAL(wp), ALLOCATABLE :: ta(:, :), tb(:, :) + INTEGER :: na, nb + LOGICAL :: ok + CHARACTER(1024) :: msg + REAL(wp) :: dz + CALL write_deck('vcd_morison.dat', NEUTRAL, '', 40.0_wp) + CALL run('vcd_morison.dat', 'vcd_morison', ok, msg) + CALL require(ok, 'D1: the Morison deck runs: '//TRIM(msg)) + CALL write_deck('vcd_split.dat', NEUTRAL, 'riser 0 0 1', 40.0_wp) + CALL run('vcd_split.dat', 'vcd_split', ok, msg) + CALL require(ok, 'D1: the split deck runs: '//TRIM(msg)) + CALL read_out('vcd_morison.out', ta, na, 3) + CALL read_out('vcd_split.out', tb, nb, 3) + IF (na /= nb .OR. na < 100) THEN + CALL require(.FALSE., 'D1: both runs wrote the same rows'); RETURN + END IF + dz = MAXVAL(ABS(ta(2:3, :na) - tb(2:3, :nb)))/MAXVAL(ABS(ta(2, :na) - ta(2, 1))) + WRITE (*, '(A,ES10.2)') 'D1 0 0 1 against Morison: max response difference / CF range ', dz + ! the split and recombined drag differ by round-off, which the VIV phase dynamics carry over 40 s + CALL require(dz <= 1.0e-4_wp, 'D1: the split with c = 1 recombines Morison''s drag') + END SUBROUTINE check_identity + + SUBROUTINE check_inline_amplification() + REAL(wp), ALLOCATABLE :: ta(:, :), tb(:, :) + INTEGER :: na, nb + LOGICAL :: ok + CHARACTER(1024) :: msg + REAL(wp) :: ya, yb + CALL write_deck('vcd_amp2.dat', 'riser 0.0 0.0 2.0;riser 1.0 0.0 2.0', 'riser 0 0 1', 30.0_wp) + CALL run('vcd_amp2.dat', 'vcd_amp2', ok, msg) + CALL require(ok, 'D2: the in-line amplification deck runs: '//TRIM(msg)) + CALL write_deck('vcd_cd24.dat', 'riser 0.0 0.0 1.0;riser 1.0 0.0 1.0', '', 30.0_wp, cd='2.4') + CALL run('vcd_cd24.dat', 'vcd_cd24', ok, msg) + CALL require(ok, 'D2: the Cd 2.4 deck runs: '//TRIM(msg)) + CALL read_out('vcd_amp2.out', ta, na, 3) + CALL read_out('vcd_cd24.out', tb, nb, 3) + IF (na < 10 .OR. nb < 10) RETURN + ya = ta(3, na) - 0.0_wp + yb = tb(3, nb) - 0.0_wp + WRITE (*, '(A,2ES14.6)') 'D2 in-line offset, split with CdAmp 2 and Cd 2.4: ', ya, yb + CALL require(ABS(ya - yb) <= 5.0e-3_wp*ABS(yb), 'D2: the in-line drag alone is amplified') + END SUBROUTINE check_inline_amplification + + SUBROUTINE check_thorsen() + REAL(wp), ALLOCATABLE :: ta(:, :), tb(:, :) + INTEGER :: na, nb, i0 + LOGICAL :: ok + CHARACTER(1024) :: msg + REAL(wp) :: am, aq, pv, ps + CALL write_deck('vcd_q.dat', NEUTRAL, 'riser 0.31 0.89', 90.0_wp, power=.TRUE.) + CALL run('vcd_q.dat', 'vcd_q', ok, msg) + CALL require(ok, 'D3: the Thorsen deck runs: '//TRIM(msg)) + CALL read_out('vcd_q.out', ta, na, 6) + CALL read_out('vcd_morison.out', tb, nb, 3) + IF (na < 100 .OR. nb < 100) RETURN + i0 = na - 2000 + aq = 0.5_wp*(MAXVAL(ta(2, i0:na)) - MINVAL(ta(2, i0:na)))/D + am = 0.5_wp*(MAXVAL(tb(2, nb - 1000:nb)) - MINVAL(tb(2, nb - 1000:nb)))/D + WRITE (*, '(A,F8.4,A,F8.4)') 'D3 steady A/D with Thorsen''s damping ', aq, ', with Morison''s ', am + CALL require(aq > 1.02_wp*am, 'D3: the quadratic cross-flow damping is weaker at this amplitude') + pv = SUM(ta(4, i0:na))/REAL(na - i0 + 1, wp) + ps = SUM(ta(4, i0:na) + ta(5, i0:na) + ta(6, i0:na))/REAL(na - i0 + 1, wp) + WRITE (*, '(A,2ES12.4)') 'D4 mean VIV power and mean VIV + drag + damping power: ', pv, ps + CALL require(pv > 0.0_wp .AND. ABS(ps) <= 1.0e-2_wp*pv, 'D4: the load powers balance with the split drag') + END SUBROUTINE check_thorsen + + SUBROUTINE refuse(label, amp_rows, damp_rows, expect, ei) + CHARACTER(*), INTENT(IN) :: label, amp_rows, damp_rows, expect + CHARACTER(*), INTENT(IN), OPTIONAL :: ei + LOGICAL :: ok + CHARACTER(1024) :: msg + IF (PRESENT(ei)) THEN + CALL write_deck('vcd_refuse.dat', amp_rows, damp_rows, 0.0_wp, ei=ei) + ELSE + CALL write_deck('vcd_refuse.dat', amp_rows, damp_rows, 0.0_wp) + END IF + CALL run('vcd_refuse.dat', 'vcd_refuse', ok, msg) + WRITE (*, '(A)') 'D5 '//label//': '//TRIM(msg) + CALL require(.NOT. ok .AND. INDEX(msg, expect) > 0, 'D5: '//label) + END SUBROUTINE refuse + + SUBROUTINE check_refusals() + CALL refuse('no amplitude table', '', 'riser 0.31 0.89', 'give the type Cl > 0 and a VIV AMPLITUDE table') + CALL refuse('an EI = 0 line', NEUTRAL, 'riser 0.31 0.89', 'acts on finite-EI cables (EI > 0) only', ei='0.0') + CALL refuse('a malformed row', NEUTRAL, 'riser 0.31', 'rows must be: TypeName a b [c]') + CALL refuse('a negative coefficient', NEUTRAL, 'riser -0.1 0.89', 'needs a, b and c >= 0') + CALL refuse('a type named twice', NEUTRAL, 'riser 0.31 0.89;riser 0 0 1', 'twice') + CALL refuse('an undefined type', NEUTRAL, 'cable 0.31 0.89', 'undefined LINE TYPE') + END SUBROUTINE check_refusals + +END PROGRAM test_viv_cf_damping_deck diff --git a/tests/test_viv_cf_damping_kernel.f90 b/tests/test_viv_cf_damping_kernel.f90 new file mode 100644 index 00000000..e23bb4c5 --- /dev/null +++ b/tests/test_viv_cf_damping_kernel.f90 @@ -0,0 +1,150 @@ +! File: tests/test_viv_cf_damping_kernel.f90 +! SPDX-License-Identifier: Apache-2.0 +! Copyright (c) 2026 Jae Hoon Seo, SMI Lab, Inha University +PROGRAM test_viv_cf_damping_kernel + !! The split drag of Thorsen et al. (2016) per unit length (CD_Morison_Drag_Split_Per_Length_Jac): + !! K1 a point at rest in a steady flow: the split force is Morison's, whatever cdy (w = U e_x); + !! K2 a cross-flow velocity y' across the flow: the cross-flow force is + !! 1/2 rho D cdy |w_y| w_y (w_y = -y'), the in-line force Morison's with the full |w|, and + !! the blend beta = U^2/(U^2 + u_ref^2) mixes it with Morison's; + !! K3 no ambient normal flow (still water, or a flow along the tangent): Morison's drag, bit for + !! bit; and with cdy = 0 and cdy_lin = cdn, the split recombines Morison's drag in a flow; + !! K4 the Jacobians against central differences of the force: in the relative velocity and in + !! the (non-unit) tangent vector, with tangential relative flow, cdy /= cdn, a Morison-form + !! cross-flow term (cdy_lin) and U ~ u_ref; + !! K5 bad inputs refused by name. + USE CableDyn_Precision, ONLY: wp + USE CableDyn_Hydro, ONLY: CD_Morison_Drag_Split_Per_Length_Jac, CD_Morison_Drag_Per_Length_Jac, CD_HYDRO_OK + IMPLICIT NONE + REAL(wp), PARAMETER :: RHO = 1025.0_wp, DIAM = 0.1_wp, CDN = 1.2_wp, CDT = 0.3_wp, CDY = 0.55_wp + INTEGER :: nfail = 0 + + CALL check_at_rest() + CALL check_crossflow() + CALL check_no_flow() + CALL check_jacobians() + CALL check_refusals() + IF (nfail > 0) THEN + WRITE (*, '(A,I0,A)') 'FAIL: ', nfail, ' assertion(s) failed' + ERROR STOP 1 + END IF + WRITE (*, '(A)') 'PASS: split cross-flow drag 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 check_at_rest() + REAL(wp) :: amb(3), tg(3), fs(3), fm(3) + INTEGER :: es + CHARACTER(200) :: em + amb = [0.3_wp, 0.8_wp, 0.1_wp] + tg = [1.0_wp, 0.2_wp, -0.1_wp] + CALL CD_Morison_Drag_Split_Per_Length_Jac(amb, amb, tg, RHO, DIAM, CDN, CDY, CDT, 0.01_wp, fs, & + ErrStat=es, ErrMsg=em) + CALL require(es == CD_HYDRO_OK, 'K1: split call: '//TRIM(em)) + CALL CD_Morison_Drag_Per_Length_Jac(amb, tg, RHO, DIAM, CDN, CDT, fm, ErrStat=es, ErrMsg=em) + WRITE (*, '(A,ES10.2)') 'K1 at rest: |split - Morison|/|Morison| ', NORM2(fs - fm)/NORM2(fm) + CALL require(NORM2(fs - fm) <= 1.0e-13_wp*NORM2(fm), 'K1: a point at rest feels Morison drag') + END SUBROUTINE check_at_rest + + SUBROUTINE check_crossflow() + REAL(wp) :: amb(3), tg(3), v(3), rel(3), f(3), ex(3), ey(3), w(3), wm, beta, fy, fx, uref, u + INTEGER :: es + CHARACTER(200) :: em + u = 0.6_wp + amb = [0.0_wp, u, 0.0_wp] + tg = [2.0_wp, 0.0_wp, 0.0_wp] + ex = [0.0_wp, 1.0_wp, 0.0_wp] + ey = [0.0_wp, 0.0_wp, 1.0_wp] ! t x e_x = x x y = z + v = [0.0_wp, 0.1_wp, 0.35_wp] ! in-line 0.1, cross-flow 0.35 + rel = amb - v + uref = 0.2_wp + CALL CD_Morison_Drag_Split_Per_Length_Jac(rel, amb, tg, RHO, DIAM, CDN, CDY, CDT, uref, f, ErrStat=es, ErrMsg=em) + CALL require(es == CD_HYDRO_OK, 'K2: split call: '//TRIM(em)) + w = [0.0_wp, rel(2), rel(3)] + wm = NORM2(w) + beta = u*u/(u*u + uref*uref) + fy = beta*0.5_wp*RHO*DIAM*CDY*ABS(rel(3))*rel(3) + (1.0_wp - beta)*0.5_wp*RHO*DIAM*CDN*wm*rel(3) + fx = 0.5_wp*RHO*DIAM*CDN*wm*rel(2) + WRITE (*, '(A,2ES12.4,A,2ES12.4)') 'K2 cross-flow: force (in line, across) ', DOT_PRODUCT(f, ex), & + DOT_PRODUCT(f, ey), ' expected ', fx, fy + CALL require(ABS(DOT_PRODUCT(f, ey) - fy) <= 1.0e-13_wp*ABS(fy), & + 'K2: the cross-flow force is the blended cdy |w_y| w_y') + CALL require(ABS(DOT_PRODUCT(f, ex) - fx) <= 1.0e-13_wp*ABS(fx), 'K2: the in-line force is Morison''s') + CALL require(ABS(f(1)) <= 1.0e-12_wp, 'K2: no tangential force without tangential flow') + END SUBROUTINE check_crossflow + + SUBROUTINE check_no_flow() + REAL(wp) :: tg(3), rel(3), fs(3), fm(3), amb(3) + INTEGER :: es + CHARACTER(200) :: em + tg = [0.3_wp, -1.0_wp, 0.4_wp] + rel = [0.2_wp, 0.1_wp, -0.3_wp] + amb = 0.0_wp + CALL CD_Morison_Drag_Split_Per_Length_Jac(rel, amb, tg, RHO, DIAM, CDN, CDY, CDT, 0.01_wp, fs, ErrStat=es, ErrMsg=em) + CALL CD_Morison_Drag_Per_Length_Jac(rel, tg, RHO, DIAM, CDN, CDT, fm, ErrStat=es, ErrMsg=em) + CALL require(ALL(fs == fm), 'K3: no ambient flow, Morison drag bit for bit') + amb = 0.7_wp*tg + CALL CD_Morison_Drag_Split_Per_Length_Jac(rel, amb, tg, RHO, DIAM, CDN, CDY, CDT, 0.01_wp, fs, ErrStat=es, ErrMsg=em) + CALL require(ALL(fs == fm), 'K3: a flow along the tangent, Morison drag bit for bit') + amb = [0.1_wp, 0.6_wp, -0.2_wp] + CALL CD_Morison_Drag_Split_Per_Length_Jac(rel, amb, tg, RHO, DIAM, CDN, 0.0_wp, CDT, 0.01_wp, fs, ErrStat=es, & + ErrMsg=em, cdy_lin=CDN) + WRITE (*, '(A,ES10.2)') 'K3 cdy 0, cdy_lin cdn: |split - Morison|/|Morison| ', NORM2(fs - fm)/NORM2(fm) + CALL require(es == CD_HYDRO_OK .AND. NORM2(fs - fm) <= 1.0e-13_wp*NORM2(fm), & + 'K3: cdy 0 and cdy_lin cdn recombine Morison''s drag') + END SUBROUTINE check_no_flow + + SUBROUTINE check_jacobians() + REAL(wp) :: rel(3), amb(3), tg(3), f(3), fp(3), fmn(3), jr(3, 3), jt(3, 3), h, err_r, err_t, scale, d(3) + INTEGER :: es, k + CHARACTER(200) :: em + rel = [0.21_wp, 0.13_wp, -0.37_wp] + amb = [0.05_wp, 0.18_wp, 0.02_wp] + tg = [1.3_wp, -0.4_wp, 0.25_wp] + CALL CD_Morison_Drag_Split_Per_Length_Jac(rel, amb, tg, RHO, DIAM, CDN, CDY, CDT, 0.12_wp, f, jr, jt, es, em, & + cdy_lin=0.7_wp) + CALL require(es == CD_HYDRO_OK, 'K4: split call with Jacobians: '//TRIM(em)) + h = 1.0e-6_wp + err_r = 0.0_wp; err_t = 0.0_wp + scale = MAX(MAXVAL(ABS(jr)), MAXVAL(ABS(jt))) + DO k = 1, 3 + d = 0.0_wp; d(k) = h + CALL CD_Morison_Drag_Split_Per_Length_Jac(rel + d, amb, tg, RHO, DIAM, CDN, CDY, CDT, 0.12_wp, fp, ErrStat=es, & + ErrMsg=em, cdy_lin=0.7_wp) + CALL CD_Morison_Drag_Split_Per_Length_Jac(rel - d, amb, tg, RHO, DIAM, CDN, CDY, CDT, 0.12_wp, fmn, ErrStat=es, & + ErrMsg=em, cdy_lin=0.7_wp) + err_r = MAX(err_r, MAXVAL(ABS((fp - fmn)/(2.0_wp*h) - jr(:, k)))) + CALL CD_Morison_Drag_Split_Per_Length_Jac(rel, amb, tg + d, RHO, DIAM, CDN, CDY, CDT, 0.12_wp, fp, ErrStat=es, & + ErrMsg=em, cdy_lin=0.7_wp) + CALL CD_Morison_Drag_Split_Per_Length_Jac(rel, amb, tg - d, RHO, DIAM, CDN, CDY, CDT, 0.12_wp, fmn, ErrStat=es, & + ErrMsg=em, cdy_lin=0.7_wp) + err_t = MAX(err_t, MAXVAL(ABS((fp - fmn)/(2.0_wp*h) - jt(:, k)))) + END DO + WRITE (*, '(A,2ES10.2,A,ES10.2)') 'K4 Jacobians against central differences: rel, tangent ', err_r, err_t, & + ' (scale ', scale, ')' + CALL require(err_r <= 1.0e-7_wp*scale .AND. err_t <= 1.0e-7_wp*scale, 'K4: exact Jacobians') + END SUBROUTINE check_jacobians + + SUBROUTINE check_refusals() + REAL(wp) :: f(3) + INTEGER :: es + CHARACTER(200) :: em + CALL CD_Morison_Drag_Split_Per_Length_Jac([0.1_wp, 0.0_wp, 0.0_wp], [0.0_wp, 0.5_wp, 0.0_wp], & + [1.0_wp, 0.0_wp, 0.0_wp], & + RHO, DIAM, CDN, -0.1_wp, CDT, 0.01_wp, f, ErrStat=es, ErrMsg=em) + CALL require(es /= CD_HYDRO_OK .AND. INDEX(em, 'non-negative') > 0, 'K5: a negative cdy refused') + CALL CD_Morison_Drag_Split_Per_Length_Jac([0.1_wp, 0.0_wp, 0.0_wp], [0.0_wp, 0.5_wp, 0.0_wp], & + [1.0_wp, 0.0_wp, 0.0_wp], & + RHO, DIAM, CDN, CDY, CDT, 0.0_wp, f, ErrStat=es, ErrMsg=em) + CALL require(es /= CD_HYDRO_OK .AND. INDEX(em, 'u_ref positive') > 0, 'K5: a zero u_ref refused') + END SUBROUTINE check_refusals + +END PROGRAM test_viv_cf_damping_kernel