From 0193895c53c191d3d06bae7a907e82904cb06c1d Mon Sep 17 00:00:00 2001 From: Jae Hoon Seo Date: Wed, 11 Nov 2026 23:52:32 +0900 Subject: [PATCH 1/2] feat: wake-oscillator VIV on finite-EI cables (WAKE OSCILLATOR section) CableDyn's VIV follows the synchronisation model of Thorsen et al. The other model class in common use is the wake oscillator: a van der Pol oscillator stands for the near wake and drives the lift. A model-form comparison needs both on the same line. An optional WAKE OSCILLATOR section row TypeName CL0 [St [eps [A]]] gives a line type the wake oscillator of Facchinetti, de Langre and Biolley (J. Fluids Struct. 19, 2004), distributed along the line as in Violette et al. (2010): q'' + eps om (q^2 - 1) q' + om^2 q = (A/D) y'', om = 2 pi St U_a/D, lift per unit length 1/4 rho D CL0 q U^2 across the relative flow, with y'' the node's cross-flow acceleration (their acceleration coupling), U_a the ambient flow speed normal to the line (their free stream, so the cable's own cross-flow velocity does not modulate the wake frequency), U the relative normal flow speed of the lift (as the synchronisation lift), and the defaults St 0.2, eps 0.3, A 12 they fix from forced-wake data (checked in the PDF). Their fluid damping gamma om rho D^2 y', gamma = Cd/(4 pi St), is the linearised Morison drag CableDyn applies in full, so the wake adds the lift only. It replaces the synchronisation lift of the type, which keeps Cl 0; a line takes one VIV model. It is a mode of the cable's VIV configuration: Set_VIV takes the per-element (St, eps, A), the lift scale is 1/4 rho D CL0, and the element lift takes q at its end nodes in place of cos(phi), with the exact Jacobians at fixed q. The state (q, q') per node is advanced beside the cable like the phase: a predictor under the step-start acceleration for the step's lift, then from the committed state with the acceleration linear to the converged end one, at the step-start wake frequency (classical Runge-Kutta in sub-steps of om dt <= 0.1, CD_VIV_Wake_Advance). q starts on its limit cycle at the VIV phase seed, q = 2 cos(phi_0). The state is in the step-recovery, snapshot and checkpoint state and the OpenFAST mirror (2 nn values after the in-line block). Finite-EI cables only for now; an EI = 0 line with the wake oscillator is refused by name, as is a line mixing the models. The Python deck reader takes the section with the native checks, the builder writes it (LineType.wake_cl0, wake_st, wake_eps, wake_a). Checks: - tests/test_viv_wake_kernel.f90: the free oscillator settles on q = 2 at its period (the van der Pol shift eps^2/16); forced at its own frequency it follows the lift magnification of Facchinetti's Eq. 17 within 0.2 % at y0 = 0.05 and 1.9 % at 0.5 (the third harmonic their one-harmonic balance leaves out; halving the step changes K by 2e-5), and the sub-stepped advance converges at fourth order; - tests/test_viv_wake_deck.f90: on the taut cable of the in-line VIV gate with Cl 0 and CL0 0.3 the wake locks the cable in at 0.282 Hz, below its own 0.300 Hz, at a steady A/D 0.585; uncoupled (A 0) it drives the cable at 0.298 Hz at A/D 0.099; over the lock-in the drag and damping take out the wake lift's 2.84 W within 0.21 %; CL0 0 is the deck without the section to the printed digits; eleven refusals; - tests/test_viv_coupled.f90: on the coupled route the cable's checkpoint block grows by 2 nn, the restarted run continues bit for bit, a rebuild without the VIV state does not, and a rewound step repeats; - Python: rows read, kept and refused as natively; the builder writes the values given; five native/Python parity decks agree. Full ctest under both BLAS kernels, Debug -fcheck=all on the new tests, pytest, ruff, mypy, Sphinx -W, pre-commit. Signed-off-by: Jae Hoon Seo --- CHANGELOG.md | 8 + CMakeLists.txt | 14 ++ doc/capabilities.rst | 5 + doc/driver_format.md | 41 +++- doc/references.rst | 12 ++ doc/theory.rst | 57 +++++ python/cabledyn/builder.py | 47 +++++ python/cabledyn/deck_file.py | 84 +++++++- python/tests/test_builder.py | 26 +++ python/tests/test_deck_file.py | 55 +++++ python/tests/test_end_to_end.py | 54 +++++ src/CableDyn_DeckDriver.f90 | 156 +++++++++++++- src/CableDyn_HermiteCableDynamic.f90 | 185 ++++++++++++++++- src/CableDyn_OpenFAST_HermiteFMF.f90 | 14 +- src/CableDyn_VIV.f90 | 44 ++++ tests/test_viv_coupled.f90 | 40 +++- tests/test_viv_wake_deck.f90 | 300 +++++++++++++++++++++++++++ tests/test_viv_wake_kernel.f90 | 154 ++++++++++++++ 18 files changed, 1271 insertions(+), 25 deletions(-) create mode 100644 tests/test_viv_wake_deck.f90 create mode 100644 tests/test_viv_wake_kernel.f90 diff --git a/CHANGELOG.md b/CHANGELOG.md index baed491..7cac311 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -33,6 +33,14 @@ All notable changes to CableDyn are recorded in this file. The format follows - The cross-flow VIV columns `Cl [dF cF]` may follow the 14-column finite-EI `LINE TYPES` row (15 or 17 columns), so a line restrained in torsion can carry VIV; such a row free in torsion runs as the 13-column one. The Python deck reader and builder take it. +- Wake-oscillator VIV: an optional `WAKE OSCILLATOR` section row `TypeName CL0 [St [eps [A]]]` + replaces the synchronisation lift of a type (which keeps `Cl` 0) by the van der Pol wake + oscillator of Facchinetti et al. (2004) with acceleration coupling (defaults St 0.2, eps 0.3, + A 12), distributed along finite-EI cables, standalone and coupled. The kernel follows the + published forced-wake lift magnification within 2 %; on the taut example cable the wake locks + the cable in at its first mode (A/D 0.58 against 0.10 uncoupled) and the drag and damping take + out the wake lift's power within 0.3 %. Its state is in the step-recovery, snapshot and + checkpoint state; the Python deck reader and builder take the section. - Load power channels `VIVPow`, `DragPow` and `DampPow` [W], and `N` per unit length about a node [W/m]: the power the VIV loads, the drag and the structural damping (`BA`, `Bb`) deliver to a line at the committed state, on `EI = 0` lines and finite-EI cables, diff --git a/CMakeLists.txt b/CMakeLists.txt index a513c94..6346dd5 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1316,6 +1316,20 @@ target_link_libraries(test_viv_kernels PRIVATE cabledyn_core) add_test(NAME viv_kernels COMMAND test_viv_kernels) set_tests_properties(viv_kernels PROPERTIES LABELS "fortran;unit;dynamic;viv") +# Wake-oscillator kernel (Facchinetti et al. 2004): the free limit cycle, the forced lift +# magnification of their Eq. 17, and the sub-stepped Runge-Kutta advance. +add_executable(test_viv_wake_kernel tests/test_viv_wake_kernel.f90) +target_link_libraries(test_viv_wake_kernel PRIVATE cabledyn_core) +add_test(NAME viv_wake_kernel COMMAND test_viv_wake_kernel) +set_tests_properties(viv_wake_kernel PROPERTIES LABELS "fortran;unit;dynamic;viv") + +# Wake-oscillator VIV on a deck: lock-in against the uncoupled wake, the power balance, CL0 0 as no +# section, and the refusals of the WAKE OSCILLATOR section. +add_executable(test_viv_wake_deck tests/test_viv_wake_deck.f90) +target_link_libraries(test_viv_wake_deck PRIVATE cabledyn_core) +add_test(NAME viv_wake_deck COMMAND test_viv_wake_deck WORKING_DIRECTORY ${CMAKE_BINARY_DIR}) +set_tests_properties(viv_wake_deck PROPERTIES LABELS "fortran;integration;dynamic;viv" TIMEOUT 1200) + add_executable(test_hermite_viv tests/test_hermite_viv.f90) target_link_libraries(test_hermite_viv PRIVATE cabledyn_core) add_test(NAME hermite_viv COMMAND test_hermite_viv) diff --git a/doc/capabilities.rst b/doc/capabilities.rst index 2d95412..16c9d3c 100644 --- a/doc/capabilities.rst +++ b/doc/capabilities.rst @@ -150,6 +150,11 @@ Line and constitutive capability the optional higher-harmonic force of Ulveseter et al. (2019) (``Chh``), on ``EI = 0`` lines and finite-EI cables wherever the cross-flow lift runs (:ref:`theory-viv-inline`), its state in the checkpoint + * - Wake-oscillator VIV (``WAKE OSCILLATOR`` section ``CL0``, ``St``, ``eps``, ``A``) + - Standalone and coupled + - the van der Pol wake oscillator of Facchinetti et al. (2004) with acceleration coupling, + distributed along finite-EI cables in place of the synchronisation model + (:ref:`theory-viv-wake`), its state in the checkpoint Loads and environment --------------------- diff --git a/doc/driver_format.md b/doc/driver_format.md index 956f7b9..919c972 100644 --- a/doc/driver_format.md +++ b/doc/driver_format.md @@ -297,7 +297,8 @@ the half-range and centre of its band in non-dimensional frequency (MoorDyn's `d `cF = 0.18` when only `Cl` is given). `Cl = 0` is no VIV; `Cl > 0` needs `cF > 0` and `0 <= dF < cF`, and the line's drag in water. It acts in the dynamics on `EI = 0` lines and finite-EI cables (see [Cross-flow VIV](theory.rst)). The in-line force of a type is a -[VIV](#viv-optional) section row. +[VIV](#viv-optional) section row; a [WAKE OSCILLATOR](#wake-oscillator-optional) row replaces the +lift by a wake oscillator. **Viscoelastic axial stiffness (MoorDyn `ElasticMod`).** The EA and BA columns accept bar-separated parts: @@ -1200,6 +1201,44 @@ Behaviour: Each was fitted to its experiments by the authors and is a starting point, not a universal set; MoorDyn's band defaults (`dF` 0.08, `cF` 0.18) are those of the first. +### WAKE OSCILLATOR (optional) + +Wake-oscillator vortex-induced vibration of a line type, the model of Facchinetti et al. (2004): +a van der Pol oscillator per node stands for the near wake and drives the cross-flow lift, coupled +to the cable's cross-flow acceleration (see [Wake oscillator](theory.rst)). It replaces the +synchronisation model of the LINE TYPES `Cl` column for that type, so the type keeps `Cl = 0`, and +it acts on finite-EI cables. + +```text +--------------------- WAKE OSCILLATOR ---------------------------------- +TypeName CL0 St eps A +(-) (-) (-) (-) (-) +cable 0.3 0.2 0.3 12 +``` + +| Column | Meaning | +|--------|---------| +| `TypeName` | an existing LINE TYPES name (case-insensitive), at most one row each | +| `CL0` | reference lift coefficient `C_L0` >= 0 of a fixed cylinder, at most 1e15; `0` is off | +| `St` | optional Strouhal number > 0 of the wake frequency `2 pi St U/D` (default 0.2) | +| `eps` | optional van der Pol parameter > 0 (default 0.3) | +| `A` | optional acceleration coupling >= 0 (default 12; `0` uncouples the wake from the cable) | + +Behaviour: + +- Per unit length the lift is `1/4 rho D CL0 q U^2` across the relative flow, the direction of the + `Cl` lift (`U` the relative normal flow speed), with `q'' + eps om (q^2 - 1) q' + om^2 q = (A/D) y''` + at each node, `om = 2 pi St U_a/D` with `U_a` the ambient flow speed normal to the line and `y''` + the node's cross-flow acceleration. The defaults are the values Facchinetti et al. fix + from forced-wake data. The cross-flow damping of the fluid is the Morison drag of the type's + `Cd`, which the paper's `gamma = Cd/(4 pi St)` linearises. +- `q` starts on its limit cycle at the node's VIV phase seed, `q = 2 cos(phi_0)` (`VIVphaseSeed`), + and is part of the step-recovery, snapshot and checkpoint state. The Outputs flag `V` file and + `VIVPow` carry the wake lift. A row with `CL0 = 0` leaves the run exactly as without it. +- A row fails if it is not `TypeName CL0 [St [eps [A]]]`, names an undefined or already named + type, or holds a value out of range; `CL0 > 0` fails on a type with `Cl > 0`. A line whose types + mix the two models fails, and so does an `EI = 0` line with the wake oscillator. + ### 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/references.rst b/doc/references.rst index ad3fda8..5d1f666 100644 --- a/doc/references.rst +++ b/doc/references.rst @@ -223,6 +223,18 @@ Verification and validation references the IEA Wind 15-Megawatt Offshore Reference Wind Turbine.* Technical Report NREL/TP-5000-76773, National Renewable Energy Laboratory. https://doi.org/10.2172/1660012 +.. _ref-facchinetti2004: + +- **Facchinetti, M. L., de Langre, E. & Biolley, F. (2004).** Coupling of structure and wake + oscillators in vortex-induced vibrations. *Journal of Fluids and Structures* **19**\ (2), + 123–140. https://doi.org/10.1016/j.jfluidstructs.2003.12.004 + +.. _ref-violette2010: + +- **Violette, R., de Langre, E. & Szydlowski, J. (2010).** A linear stability approach to + vortex-induced vibrations and waves. *Journal of Fluids and Structures* **26**\ (3), 442–466. + https://doi.org/10.1016/j.jfluidstructs.2010.01.002 + .. _ref-holcombe2025: - **Holcombe, A., Hann, M., Brown, S., et al. (2025).** Experimental–numerical model diff --git a/doc/theory.rst b/doc/theory.rst index 2f23ec5..686cfa3 100644 --- a/doc/theory.rst +++ b/doc/theory.rst @@ -1232,6 +1232,63 @@ at the phase sum, and its derivatives enter the tangent with the lift's. Ulveset in-line example with ``Chh`` 1.0 the quarter-span in-line response at four times the cross-flow frequency grows from A/D 0.002 to 0.007, the same on an ``EI = 0`` line. +.. _theory-viv-wake: + +Wake oscillator +~~~~~~~~~~~~~~~ + +A ``WAKE OSCILLATOR`` row ``TypeName CL0 [St [eps [A]]]`` replaces the synchronisation model of a +line type by the wake oscillator of :ref:`Facchinetti et al. (2004) `, +distributed along the line as in :ref:`Violette et al. (2010) `. At each node a +van der Pol oscillator in the reduced lift coefficient :math:`q = 2C_L/C_{L0}` stands for the +near wake, forced by the node's cross-flow acceleration :math:`\ddot y` (the acceleration +coupling Facchinetti et al. found to reproduce lock-in, the Griffin plot and the effective added +mass): + +.. math:: + + \ddot q + \varepsilon\,\omega_f\,(q^2 - 1)\,\dot q + \omega_f^2\,q = \frac{A}{D}\,\ddot y, + \qquad \omega_f = 2\pi\,\mathrm{St}\,\frac{U_a}{D}, + +with :math:`U_a` the speed of the ambient flow (current and host field) normal to the line, the +free stream of the paper, so that the cable's own cross-flow velocity does not modulate the wake +frequency, and :math:`\ddot y` along the cross-flow axis :math:`\mathbf t\times\mathbf v_n/U` of +the synchronisation model. The lift per unit length acts across the relative normal flow +:math:`\mathbf v_n` of speed :math:`U`, as the synchronisation lift does: + +.. math:: + + \mathbf f = \tfrac{1}{4}\rho\,D\,C_{L0}\,q\;U\,(\mathbf t\times\mathbf v_n) , + +the synchronisation lift with :math:`C_L\cos\phi` replaced by :math:`C_{L0}q/2`: a free wake +settles on the limit cycle :math:`q = 2\cos\omega_f t`, the lift :math:`C_{L0}` of a fixed +cylinder. The defaults St 0.2, :math:`\varepsilon` 0.3 and :math:`A` 12 are theirs, fixed from +forced-wake data with :math:`C_{L0}` 0.3, which the row gives. Their +fluid-added damping :math:`\gamma\,\omega_f\,\rho D^2\dot y` with +:math:`\gamma = C_D/(4\pi\mathrm{St})` is the linearised Morison drag, which CableDyn applies +in full, and their inviscid added mass is the Morison :math:`C_a`; the wake adds the lift only. + +The wake state :math:`(q, \dot q)` of a node is integrated beside the cable, as the phase of the +synchronisation model is. At the start of a step it is advanced under the step-start +acceleration to give the :math:`q` the step's lift takes; at the converged end it is advanced +again from the committed state with the acceleration linear between the step's ends, at the +step-start :math:`\omega_f`, and committed. Both use classical Runge-Kutta in sub-steps of +:math:`\omega_f\,\delta t \le 0.1`. The lift is integrated on a finite-EI cable at the Gauss +points of the synchronisation lift, :math:`q` interpolated between the element's end nodes, with +its exact position and velocity derivatives in the tangent at fixed :math:`q`. :math:`q` starts on +its limit cycle at the node's phase seed, :math:`q = 2\cos\phi_0`, :math:`\dot q = 0`, and the +state is part of the step-recovery, snapshot and checkpoint state. + +The kernel reproduces the limit cycle (amplitude 2.001, the van der Pol period shift of +:math:`\varepsilon^2/16`), and forced at its own frequency by a cylinder moving as +:math:`y_0 D\cos\omega_f t` it follows the lift magnification of their Eq. 17 within 0.2 % at +:math:`y_0 = 0.05` and 1.9 % at :math:`y_0 = 0.5`, the gap growing with the third harmonic their +one-harmonic balance leaves out. On the taut cable of ``viv_taut_cable_inline.dat`` with +``Cl`` 0 and ``CL0`` 0.3 the cable locks in at 0.282 Hz, below the wake's own 0.30 Hz, at a +steady mid-span A/D of 0.58; with :math:`A` = 0 the uncoupled wake drives it at 0.298 Hz at A/D +0.10, and over the lock-in the drag and damping take out the wake lift's power within 0.3 %. The +wake oscillator acts on finite-EI cables, cross-flow only. + .. _theory-dry-buoyancy: Buoyancy and wetting diff --git a/python/cabledyn/builder.py b/python/cabledyn/builder.py index 32d9aab..8eb564e 100644 --- a/python/cabledyn/builder.py +++ b/python/cabledyn/builder.py @@ -219,6 +219,14 @@ class LineType: Optional higher-harmonic coefficient of the ``VIV`` row (``Name ClX alpha Chh``, Ulveseter et al. 2019; it needs ``clx``); ``None`` leaves it out (0). With ``chh`` set and ``il_alpha`` ``None`` the row writes alpha 0.15. + wake_cl0, wake_st, wake_eps, wake_a : float | None + Optional wake-oscillator VIV of a type (Facchinetti et al. 2004), a + ``WAKE OSCILLATOR`` section row ``Name CL0 [St [eps [A]]]``: the + reference lift coefficient, the Strouhal number, the van der Pol + parameter and the acceleration coupling. It replaces the + synchronisation lift, so ``cl`` stays ``None`` or 0, and acts on + finite-EI cables. ``None`` leaves a trailing value out of the row (the + solver takes 0.2, 0.3 and 12); a value given writes the ones before it. """ name: str @@ -241,6 +249,10 @@ class LineType: clx: float | None = None il_alpha: float | None = None chh: float | None = None + wake_cl0: float | None = None + wake_st: float | None = None + wake_eps: float | None = None + wake_a: float | None = None @dataclass(eq=False) @@ -1660,6 +1672,10 @@ def add_line_type( clx: float | None = None, il_alpha: float | None = None, chh: float | None = None, + wake_cl0: float | None = None, + wake_st: float | None = None, + wake_eps: float | None = None, + wake_a: float | None = None, ) -> LineType: """Add a ``LINE TYPES`` row; see :class:`LineType` for the fields. @@ -1696,6 +1712,10 @@ def add_line_type( clx, il_alpha, chh, + wake_cl0, + wake_st, + wake_eps, + wake_a, ) self._line_types.append(item) return item @@ -2587,6 +2607,7 @@ def to_text(self, *, validate: bool = True) -> str: _emit(out, "ATTACHMENTS", *self._attachment_table()) _emit(out, "STIFFENERS", *self._stiffener_table()) _emit(out, "VIV", *self._viv_table()) + _emit(out, "WAKE OSCILLATOR", *self._wake_table()) _emit(out, "FAILURE", *self._failure_table()) _emit(out, "CONTROL", *self._control_table()) _emit(out, "EXTERNAL LOADS", *self._external_load_table()) @@ -2968,6 +2989,25 @@ def _viv_table(self) -> tuple[str, str, list[list[str]]]: rows.append(row) return "Name ClX alpha Chh", "(-) (-) (-) (-)", rows + def _wake_table(self) -> tuple[str, str, list[list[str]]]: + rows: list[list[str]] = [] + defaults = (0.2, 0.3, 12.0) + for item in self._line_types: + what = f"line type {item.name!r}" + rest = (item.wake_st, item.wake_eps, item.wake_a) + if item.wake_cl0 is None: + if any(value is not None for value in rest): + raise ValueError(f"{what}: wake_st, wake_eps and wake_a need wake_cl0") + continue + row = [_text(item.name, what), _num(item.wake_cl0, what)] + # the values up to the last one given, the solver's defaults filling the gaps + last = max((index for index, value in enumerate(rest) if value is not None), default=-1) + for index in range(last + 1): + value = rest[index] + row.append(_num(defaults[index] if value is None else value, what)) + rows.append(row) + return "Name CL0 St eps A", "(-) (-) (-) (-) (-)", rows + def _syrope_table(self) -> tuple[str, str, list[list[str]]]: rows = [ [_line_list(row.lines), _num(row.tmax0, "SYROPE IC"), _num(row.tmean0, "SYROPE IC")] @@ -3172,6 +3212,13 @@ def load(self) -> None: item.clx = _f(t[1]) item.il_alpha = _f(t[2]) if len(t) >= 3 else None item.chh = _f(t[3]) if len(t) == 4 else None + for row in self.rows("WAKE OSCILLATOR"): + t = row.tokens + item = model.line_types[t[0]] + item.wake_cl0 = _f(t[1]) + item.wake_st = _f(t[2]) if len(t) >= 3 else None + item.wake_eps = _f(t[3]) if len(t) >= 4 else None + item.wake_a = _f(t[4]) if len(t) == 5 else None for row in self.rows("ATTACHMENTS"): t = row.tokens arc: float | tuple[float, float, float] diff --git a/python/cabledyn/deck_file.py b/python/cabledyn/deck_file.py index 13f6239..b8b165b 100644 --- a/python/cabledyn/deck_file.py +++ b/python/cabledyn/deck_file.py @@ -79,6 +79,9 @@ "VIV": "VIV", "VORTEX-INDUCED VIBRATION": "VIV", "VORTEX INDUCED VIBRATION": "VIV", + "WAKE OSCILLATOR": "WAKE OSCILLATOR", + "WAKE OSCILLATORS": "WAKE OSCILLATOR", + "WAKE": "WAKE OSCILLATOR", } # Table sections whose rows the native reader takes through a Fortran # list-directed READ. Their descriptive and units rows are recognized by the @@ -101,7 +104,7 @@ # Table sections the native reader splits on whitespace and parses column by # column (their comma-separated line lists are valid there). _WHITESPACE_TABLE_SECTIONS = frozenset( - {"FAILURE", "CONTROL", "SYROPE IC", "ATTACHMENTS", "STIFFENERS", "VIV"} + {"FAILURE", "CONTROL", "SYROPE IC", "ATTACHMENTS", "STIFFENERS", "VIV", "WAKE OSCILLATOR"} ) _TABLE_SECTIONS = _LIST_DIRECTED_SECTIONS | _WHITESPACE_TABLE_SECTIONS _NATIVE_RECORD_LENGTH = 512 @@ -3256,6 +3259,67 @@ def _check_viv_section( "cross-flow one" ) + def _check_wake_section(self, lift_type_names: set[str]) -> set[str]: + """Native ``apply_type_wake`` for the WAKE OSCILLATOR section; the types it switches on. + + A row ``TypeName CL0 [St [eps [A]]]`` gives a line type the wake oscillator of + Facchinetti et al. (2004): the reference lift coefficient ``CL0 >= 0`` (0 = off), the + Strouhal number ``St > 0`` (default 0.2), the van der Pol ``eps > 0`` (0.3) and the + acceleration coupling ``A >= 0`` (12), each at most 1e15. It replaces the synchronisation + model, so a type with ``CL0 > 0`` takes no LINE TYPES lift ``Cl``. A type takes one row. + """ + types = {row.tokens[0].lower() for row in self.line_types} + named: set[str] = set() + wake: set[str] = set() + for row in self._rows("WAKE OSCILLATOR"): + where = self._at(row) + if not 2 <= len(row.tokens) <= 5: + raise DeckFormatError( + f"{where}: WAKE OSCILLATOR rows must be: TypeName CL0 [St [eps [A]]]" + ) + name = row.tokens[0].lower() + if name not in types: + raise DeckFormatError( + f'{where}: WAKE OSCILLATOR row names undefined LINE TYPE "{row.tokens[0]}"' + ) + if name in named: + raise DeckFormatError( + f'{where}: WAKE OSCILLATOR names LINE TYPE "{row.tokens[0]}" twice' + ) + named.add(name) + values = [0.0, 0.2, 0.3, 12.0] + try: + for index, token in enumerate(row.tokens[1:]): + values[index] = _native_float(token) + except ValueError as exc: + raise DeckFormatError( + f"{where}: WAKE OSCILLATOR CL0, St, eps and A must be plain numbers" + ) from exc + if not all(math.isfinite(value) for value in values): + raise DeckFormatError(f"{where}: WAKE OSCILLATOR CL0, St, eps and A must be finite") + cl0, st, eps, a = values + if cl0 < 0.0 or cl0 > _NATIVE_MAX_COEFFICIENT: + raise DeckFormatError( + f"{where}: WAKE OSCILLATOR lift coefficient CL0 must be non-negative (0 = off) " + "and at most 1e15" + ) + if not ( + 0.0 < st <= _NATIVE_MAX_COEFFICIENT + and 0.0 < eps <= _NATIVE_MAX_COEFFICIENT + and 0.0 <= a <= _NATIVE_MAX_COEFFICIENT + ): + raise DeckFormatError( + f"{where}: WAKE OSCILLATOR needs St > 0, eps > 0 and A >= 0, each at most 1e15" + ) + if cl0 > 0.0 and name in lift_type_names: + raise DeckFormatError( + f'{where}: WAKE OSCILLATOR of LINE TYPE "{row.tokens[0]}" replaces its ' + "synchronisation lift: give the type LINE TYPES Cl 0" + ) + if cl0 > 0.0: + wake.add(name) + return wake + def _legacy_rod_type_columns(self, record: DeckRecord) -> bool: """Return whether ``record`` sits under a legacy CableDyn ROD TYPES header. @@ -4433,6 +4497,24 @@ def end_key(token: str) -> str: self._check_stiffeners(line_ids, section_types_by_line, line_type_meta, line_lengths) self._check_viv_section(line_type_meta, viv_type_names) + wake_type_names = self._check_wake_section(viv_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 + for line_id, section_types in section_types_by_line.items(): + types_used = {line_type.lower() for line_type in section_types} + if not types_used & wake_type_names: + continue + if line_id not in finite_line_ids: + raise DeckFormatError( + f"{self._label}: line {line_id}: the wake oscillator (WAKE OSCILLATOR " + "section) acts on finite-EI cables (EI > 0) only" + ) + if types_used & viv_type_names: + raise DeckFormatError( + f"{self._label}: line {line_id}: a line takes one VIV model, but its types mix " + "the synchronisation lift (LINE TYPES Cl > 0) and the wake oscillator (WAKE " + "OSCILLATOR section)" + ) self._check_attachments(line_ids, section_types_by_line, line_type_meta, line_lengths) assigned_end_connections: set[tuple[str, str]] = set() diff --git a/python/tests/test_builder.py b/python/tests/test_builder.py index 8569fdf..5c9e019 100644 --- a/python/tests/test_builder.py +++ b/python/tests/test_builder.py @@ -213,6 +213,32 @@ def test_viv_columns_follow_the_wide_finite_ei_row(tmp_path: Path) -> None: assert loaded.to_text() == text +def test_wake_oscillator_rows_are_written_with_the_values_given(tmp_path: Path) -> None: + model = _chain_model(tmp_path) + model.add_line_type( + "cable", diam=0.1, mass=10.0, ea=5.0e7, ei=1.0, cdn=1.2, can=1.0, wake_cl0=0.3 + ) + model.add_line_type( + "riser", + diam=0.1, + mass=10.0, + ea=5.0e7, + ei=1.0, + cdn=1.2, + can=1.0, + wake_cl0=0.25, + wake_eps=0.2, + ) + deck = DeckFile.from_text(model.to_text(validate=False), path=tmp_path / "deck.dat") + rows = {row.tokens[0].lower(): row.tokens for row in deck._rows("WAKE OSCILLATOR")} + assert rows["cable"] == ("cable", "0.3") + # St is written at the solver's default to keep eps in its column + assert [float(value) for value in rows["riser"][1:]] == [0.25, 0.2, 0.2] + model.add_line_type("bad", diam=0.1, mass=10.0, ea=5.0e7, wake_st=0.2) + with pytest.raises(ValueError, match="need wake_cl0"): + 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 c304a81..aa3ab40 100644 --- a/python/tests/test_deck_file.py +++ b/python/tests/test_deck_file.py @@ -4853,6 +4853,61 @@ def test_finite_ei_row_viv_columns_follow_the_native_checks(columns, message): DeckFile.from_text(_edit(_DYNAMIC, (row, _WIDE_VIV_ROW + columns))) +@pytest.mark.parametrize( + "rows, expected", + [ + (("chain 0.3",), (0.3, None, None, None)), + (("chain 0.3 0.17",), (0.3, 0.17, None, None)), + (("TypeName CL0 St eps A", "chain 0.3 0.2 0.25 10"), (0.3, 0.2, 0.25, 10.0)), + ], +) +def test_wake_oscillator_rows_are_read_and_kept(tmp_path, rows, expected): + from cabledyn import DeckModel + + text = _with_section(_DYNAMIC, "WAKE OSCILLATOR", *rows) + DeckFile.from_text(text) + path = tmp_path / "wake.dat" + path.write_text(text, encoding="utf-8") + item = DeckModel.load(path).line_types["chain"] + assert (item.wake_cl0, item.wake_st, item.wake_eps, item.wake_a) == expected + saved = tmp_path / "saved.dat" + DeckModel.load(path).save(saved) + again = DeckModel.load(saved).line_types["chain"] + assert (again.wake_cl0, again.wake_st, again.wake_eps, again.wake_a) == expected + + +@pytest.mark.parametrize( + "base, rows, message", + [ + (None, ("chain 0.3 0.2 0.3 12 1",), "rows must be: TypeName CL0 [St [eps [A]]]"), + (None, ("chain 0.3 x",), "must be plain numbers"), + (None, ("cable 0.3",), 'undefined LINE TYPE "cable"'), + (None, ("chain 0.3", "chain 0.2"), 'names LINE TYPE "chain" twice'), + (None, ("chain -0.1",), "CL0 must be non-negative"), + (None, ("chain 0.3 0.0",), "St > 0, eps > 0 and A >= 0"), + (None, ("chain 0.3 0.2 0.0",), "St > 0, eps > 0 and A >= 0"), + (None, ("chain 0.3 0.2 0.3 -1",), "St > 0, eps > 0 and A >= 0"), + ("lift", ("chain 0.3",), "give the type LINE TYPES Cl 0"), + ("ei0", ("chain 0.3",), "acts on finite-EI cables (EI > 0) only"), + ], +) +def test_wake_oscillator_rows_follow_the_native_checks(base, rows, message): + text = _DYNAMIC + if base == "lift": + row = "chain 0.252 390.0 1.674e9 -1.0 1.0e4 1.37 0.64 1.0 0.0" + text = _edit(text, (row, 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, "WAKE OSCILLATOR", *rows)) + + +def test_wake_oscillator_cl0_zero_is_off_and_needs_no_finite_line(): + # CL0 0 switches nothing on, so it is accepted on an EI = 0 line and next to a lift type + text = _edit(_DYNAMIC, ("1.674e9 -1.0 1.0e4 1.37", "1.674e9 -1.0 0.0 1.37")) + DeckFile.from_text(_with_section(text, "WAKE OSCILLATOR", "chain 0.0")) + + def test_viv_is_accepted_on_the_coupled_route(): text = _edit(_STATIC, (_VIV_ROW, _VIV_ROW + " 0.8")) DeckFile.from_text(text) diff --git a/python/tests/test_end_to_end.py b/python/tests/test_end_to_end.py index 02cd1ef..ad2548c 100644 --- a/python/tests/test_end_to_end.py +++ b/python/tests/test_end_to_end.py @@ -257,6 +257,60 @@ def test_generated_study_runs_on_the_real_driver(tmp_path): ] +# The in-line VIV example with its type's lift Cl 0.8 and its VIV section turned into a WAKE +# OSCILLATOR section (its row riser 0.85 0.15 then reads CL0 0.85, St 0.15). +_WAKE_LIFT = ("1.0 0.0 0.8 0.08 0.18", "1.0 0.0 0.0 0.08 0.18") +_WAKE_SECTION = ( + "--------------------- VIV -----", + "--------------------- WAKE OSCILLATOR -----", +) +_WAKE_PARITY = [ + ("wake-accepted", [_WAKE_LIFT, _WAKE_SECTION], True), + ("wake-keeps-lift", [_WAKE_SECTION], False), + ( + "wake-st-zero", + [_WAKE_LIFT, _WAKE_SECTION, ("riser 0.85 0.15", "riser 0.85 0.0")], + False, + ), + ( + "wake-row-too-long", + [_WAKE_LIFT, _WAKE_SECTION, ("riser 0.85 0.15", "riser 0.3 0.2 0.3 12 1")], + False, + ), + ( + "wake-ei0-line", + [_WAKE_LIFT, _WAKE_SECTION, ("-0.8 1.0 1.2", "-0.8 0.0 1.2")], + False, + ), +] + + +@pytest.mark.parametrize( + ("label", "edits", "accepted"), _WAKE_PARITY, ids=[item[0] for item in _WAKE_PARITY] +) +def test_wake_oscillator_validator_agrees_with_the_native_reader( + driver, tmp_path, label, edits, accepted +): + text = (EXAMPLES / "viv_taut_cable_inline.dat").read_text(encoding="utf-8") + for old, new in edits: + assert old in text, old + text = text.replace(old, new, 1) + deck = tmp_path / f"{label}.dat" + deck.write_text(text.replace("90.0 TMax", "2.0 TMax"), encoding="utf-8") + try: + DeckFile.read(deck) + python_accepts = True + except DeckFormatError: + python_accepts = False + try: + driver.run(deck, label, timeout=300) + native_accepts = True + except DriverExecutionError as exc: + assert exc.returncode == 1, exc.stderr # a deck error, not a solve failure + native_accepts = False + assert python_accepts == native_accepts == accepted + + @pytest.mark.parametrize( ("label", "example", "old", "new", "accepted"), _PARITY, ids=[item[0] for item in _PARITY] ) diff --git a/src/CableDyn_DeckDriver.f90 b/src/CableDyn_DeckDriver.f90 index 7dbb381..8e8dc73 100644 --- a/src/CableDyn_DeckDriver.f90 +++ b/src/CableDyn_DeckDriver.f90 @@ -136,7 +136,8 @@ MODULE CableDyn_DeckDriver CD_HFMF_SetCoupledKinematics, CD_HFMF_GetCoupledKinematics, & CD_HFMF_Set_Moving_End_B, CD_HFMF_GetEndBKinematics, & CD_HFMF_End, CD_HFMF_OK - USE CableDyn_VIV, ONLY: CD_VIV_DEFAULT_DF, CD_VIV_DEFAULT_CF, CD_VIV_NM, CD_VIV_DEFAULT_IL_ALPHA + USE CableDyn_VIV, ONLY: CD_VIV_DEFAULT_DF, CD_VIV_DEFAULT_CF, CD_VIV_NM, CD_VIV_DEFAULT_IL_ALPHA, & + CD_VIV_WAKE_DEFAULT_ST, CD_VIV_WAKE_DEFAULT_EPS, CD_VIV_WAKE_DEFAULT_A USE CableDyn_Hydro, ONLY: CD_Airy_Wave_Kinematics_Precomputed, CD_Component_Wave_Kinematics, & CD_Current_Profile_Velocity, CD_CurrentGridType, CD_Current_Grid_Resample, & CD_Current_Grid_Velocity, & @@ -452,6 +453,13 @@ MODULE CableDyn_DeckDriver ! the section names. REAL(wp) :: clx = CD_ZERO, il_alpha = CD_VIV_DEFAULT_IL_ALPHA, chh = CD_ZERO LOGICAL :: has_viv_row = .FALSE. + ! Wake-oscillator VIV (the optional WAKE OSCILLATOR section, a row per type: TypeName CL0 + ! [St [eps [A]]]; Facchinetti et al., J. Fluids Struct. 19, 2004): the reference lift + ! coefficient C_L0 (0 = off), Strouhal number, van der Pol eps and acceleration coupling A; + ! has_wake_row marks a type the section names. + REAL(wp) :: wo_cl0 = CD_ZERO, wo_st = CD_VIV_WAKE_DEFAULT_ST, wo_eps = CD_VIV_WAKE_DEFAULT_EPS + REAL(wp) :: wo_a = CD_VIV_WAKE_DEFAULT_A + LOGICAL :: has_wake_row = .FALSE. ! Deck file line of the row (0 when not read from a file), for error messages. INTEGER :: deck_line = 0 END TYPE @@ -1885,6 +1893,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 :: wo_cl0(:), wo_st(:), wo_eps(:), wo_a(:) REAL(wp), ALLOCATABLE :: ba_raw(:), ba(:), dry_b(:), bb_el(:) REAL(wp) :: mode1_omega REAL(wp), ALLOCATABLE :: contact_kn(:), contact_cn(:) @@ -3283,7 +3292,13 @@ RECURSIVE SUBROUTINE build_one_hermite_cable(ln, sections, types, points, opts, ALLOCATE (viv_cl(SIZE(l0)), viv_cf(SIZE(l0)), viv_df(SIZE(l0)), viv_clx(SIZE(l0)), viv_al(SIZE(l0)), & viv_hh(SIZE(l0))) CALL finite_viv_arrays(ln, sections, types, viv_cl, viv_cf, viv_df, viv_clx, viv_al, viv_hh) + ALLOCATE (wo_cl0(SIZE(l0)), wo_st(SIZE(l0)), wo_eps(SIZE(l0)), wo_a(SIZE(l0))) + CALL finite_wake_arrays(ln, sections, types, wo_cl0, wo_st, wo_eps, wo_a) IF (SIZE(l0_am) /= SIZE(l0)) THEN + 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) + CALL remap_elem_by_reference_arc(wo_a, l0, l0_am) CALL remap_elem_by_reference_arc(viv_cl, l0, l0_am) CALL remap_elem_by_reference_arc(viv_cf, l0, l0_am) CALL remap_elem_by_reference_arc(viv_df, l0, l0_am) @@ -3590,7 +3605,12 @@ RECURSIVE SUBROUTINE build_one_hermite_cable(ln, sections, types, points, opts, ! lines do (init_one_model), and of the coupling step dt where the deck gives none: a ! coupled host may step the cable at a dt adjusted from the deck dtM. IF (PRESENT(install_viv)) THEN - IF (install_viv .AND. ANY(viv_cl > CD_ZERO)) THEN + IF (install_viv .AND. ANY(wo_cl0 > CD_ZERO) .AND. ANY(viv_cl > CD_ZERO)) THEN + CALL fail(ErrStat, ErrMsg, 'line '//TRIM(int_to_str(ln%id))//': a line takes one VIV model, but its '// & + 'types mix the synchronisation lift (LINE TYPES Cl > 0) and the wake oscillator (WAKE '// & + 'OSCILLATOR section)'); RETURN + END IF + IF (install_viv .AND. (ANY(viv_cl > CD_ZERO) .OR. ANY(wo_cl0 > CD_ZERO))) THEN ! MoorDyn's phase seed counts the deck nodes from the deck's End A, with its node tangent ! towards the deck's End B; CD_Deck_VIV_Phase_Seed takes it node by node to the model's ! nodes and tangent (a line the reader turned around, a mesh the static solve refined) @@ -3603,7 +3623,15 @@ RECURSIVE SUBROUTINE build_one_hermite_cable(ln, sections, types, points, opts, CALL CD_Deck_VIV_Phase_Seed(cable%line%l0, ln%ends_swapped, seed, zero=opts%viv_phase_zero) END IF ! with the in-line VIV of the VIV section where a type has ClX > 0 - IF (ANY(viv_clx > CD_ZERO)) THEN + IF (ANY(wo_cl0 > CD_ZERO)) THEN + ! the wake oscillator: cl is C_L0, the band unused + CALL CD_HermiteCable_Dyn_Set_VIV(cable%line, wo_cl0, 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, & + wake=RESHAPE([wo_st, wo_eps, wo_a], [3, SIZE(wo_st)], ORDER=[2, 1])) + ELSE IF (ANY(viv_clx > CD_ZERO)) THEN 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), & @@ -7928,7 +7956,8 @@ SUBROUTINE CD_Init_Deck_HermiteCable(deck_path, dt, cable, coupled_node, ErrStat 'use the aggregate facade with its external SeaState field'); RETURN END IF IF (line_has_viv(lines(1), types, sections)) THEN - CALL fail(ErrStat, ErrMsg, 'CD_Init_Deck_HermiteCable: VIV (LINE TYPES Cl > 0) acts with an ambient '// & + CALL fail(ErrStat, ErrMsg, 'CD_Init_Deck_HermiteCable: VIV (LINE TYPES Cl > 0, or a wake oscillator) acts '// & + 'with an ambient '// & 'fluid field, which this single-cable entry does not apply; use the aggregate facade'); RETURN END IF IF (opts%has_bathymetry_file) THEN @@ -10473,6 +10502,10 @@ RECURSIVE SUBROUTINE init_one_model(ln, sections, types, points, opts, model, Er hydro_can(e) = types(line_section_type(sections, ln%id, i))%can hydro_cat(e) = types(line_section_type(sections, ln%id, i))%cat viv_cl(e) = types(line_section_type(sections, ln%id, i))%cl + IF (types(line_section_type(sections, ln%id, i))%wo_cl0 > CD_ZERO) THEN + 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 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 @@ -11624,6 +11657,33 @@ SUBROUTINE finite_viv_arrays(ln, sections, types, cl, cf, df, clx, il_alpha, chh chh = chh(SIZE(chh):1:-1) END SUBROUTINE finite_viv_arrays + SUBROUTINE finite_wake_arrays(ln, sections, types, cl0, st, eps, a) + !! Expand the WAKE OSCILLATOR rows (CL0, St, eps, A) to finite-EI element arrays, in the + !! element order of finite_hydro_arrays. + TYPE(DeckLine), INTENT(IN) :: ln + TYPE(DeckSection), INTENT(IN) :: sections(:) + TYPE(DeckLineType), INTENT(IN) :: types(:) + REAL(wp), INTENT(OUT) :: cl0(:), st(:), eps(:), a(:) + INTEGER :: i, j, e, tidx + + e = 0 + DO i = 1, SIZE(sections) + IF (sections(i)%line_id /= ln%id) CYCLE + tidx = sections(i)%ltype + DO j = 1, sections(i)%nsegs + e = e + 1 + cl0(e) = types(tidx)%wo_cl0 + st(e) = types(tidx)%wo_st + eps(e) = types(tidx)%wo_eps + a(e) = types(tidx)%wo_a + END DO + END DO + cl0 = cl0(SIZE(cl0):1:-1) + st = st(SIZE(st):1:-1) + eps = eps(SIZE(eps):1:-1) + a = a(SIZE(a):1:-1) + END SUBROUTINE finite_wake_arrays + LOGICAL FUNCTION line_has_viv(ln, types, sections) RESULT(has) !! Whether a section of the line uses a line type with a VIV lift coefficient Cl > 0. TYPE(DeckLine), INTENT(IN) :: ln @@ -11635,6 +11695,7 @@ LOGICAL FUNCTION line_has_viv(ln, types, sections) RESULT(has) IF (sections(j)%line_id /= ln%id) CYCLE IF (sections(j)%ltype < 1 .OR. sections(j)%ltype > SIZE(types)) CYCLE IF (types(sections(j)%ltype)%cl > CD_ZERO) has = .TRUE. + IF (types(sections(j)%ltype)%wo_cl0 > CD_ZERO) has = .TRUE. END DO END FUNCTION line_has_viv @@ -13738,6 +13799,9 @@ SUBROUTINE parse_deck(path, types, bodies, rod_types, rods, points, lines, secti CHARACTER(DECK_RECLEN), ALLOCATABLE :: viv_rows(:) INTEGER, ALLOCATABLE :: viv_lines(:) INTEGER :: n_viv + CHARACTER(DECK_RECLEN), ALLOCATABLE :: wake_rows(:) + INTEGER, ALLOCATABLE :: wake_lines(:) + INTEGER :: n_wake CHARACTER(2*NAMELEN), ALLOCATABLE :: channel_keys(:) LOGICAL :: ext_march, types_stock_cols, rodtypes_legacy_cols, turb_ok, static_finite_ok, tors_marched INTEGER :: unit, ios, section, nt, nb, nrt, nr, np, nlin, nsec, neq, nch, nfl, nct, nec, lineno @@ -13755,7 +13819,7 @@ 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_STIFF = 18, SEC_VIV = 19, SEC_WAKE = 20 ErrStat = 0; ErrMsg = '' ext_march = .FALSE. @@ -13779,6 +13843,8 @@ SUBROUTINE parse_deck(path, types, bodies, rod_types, rods, points, lines, secti n_stf = 0 ALLOCATE (viv_rows(0), viv_lines(0)) n_viv = 0 + ALLOCATE (wake_rows(0), wake_lines(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 section = SEC_NONE ALLOCATE (channel_lines(0)) @@ -13913,6 +13979,15 @@ SUBROUTINE parse_deck(path, types, bodies, rod_types, rods, points, lines, secti END IF viv_rows(n_viv) = line(1:MIN(LEN(line), DECK_RECLEN)) viv_lines(n_viv) = lineno + CASE (SEC_WAKE) + IF (.NOT. has_numeric_token(line)) CYCLE + n_wake = n_wake + 1 + IF (n_wake > SIZE(wake_rows)) THEN + wake_rows = [wake_rows, [(REPEAT(' ', DECK_RECLEN), i_ch=1, 8)]] + wake_lines = [wake_lines, [(0, i_ch=1, 8)]] + END IF + wake_rows(n_wake) = line(1:MIN(LEN(line), DECK_RECLEN)) + wake_lines(n_wake) = lineno CASE (SEC_OPTIONS) CALL apply_option(line, opts, ErrStat, ErrMsg) CASE (SEC_OUTPUTS) @@ -14017,6 +14092,13 @@ SUBROUTINE parse_deck(path, types, bodies, rod_types, rods, points, lines, secti RETURN END IF END DO + DO i_ch = 1, n_wake + CALL apply_type_wake(wake_rows(i_ch), types, ErrStat, ErrMsg) + IF (ErrStat /= 0) THEN + CALL add_row_context('deck', wake_lines(i_ch), wake_rows(i_ch), ErrMsg) + RETURN + END IF + END DO ! Caller-supplied environment overrides land HERE -- before equivalent-buoyancy ! conversion and validation -- so both run under the environment the model is @@ -15685,6 +15767,8 @@ SUBROUTINE set_section(secname, section, ErrStat, ErrMsg) section = 18 CASE ('VIV', 'VORTEX-INDUCED VIBRATION', 'VORTEX INDUCED VIBRATION') section = 19 + CASE ('WAKE OSCILLATOR', 'WAKE OSCILLATORS', 'WAKE') + section = 20 CASE DEFAULT IF (LEN_TRIM(secname) > NAMELEN) THEN CALL fail(ErrStat, ErrMsg, 'unknown deck section "'//secname(1:NAMELEN)//'..."') @@ -17284,6 +17368,68 @@ SUBROUTINE apply_type_viv(row, types, ErrStat, ErrMsg) types(it)%has_viv_row = .TRUE. END SUBROUTINE apply_type_viv + SUBROUTINE apply_type_wake(row, types, ErrStat, ErrMsg) + !! One WAKE OSCILLATOR row: TypeName CL0 [St [eps [A]]] -- the wake-oscillator VIV of a line + !! type (Facchinetti et al. 2004; the defaults St 0.2, eps 0.3, A 12 are theirs): the reference + !! lift coefficient C_L0 >= 0 (0 = off; the lift of a fixed cylinder is C_L0 U^2 rho D/2), the + !! Strouhal number St > 0 of the wake frequency 2 pi St U/D, the van der Pol eps > 0 and the + !! acceleration coupling A >= 0. The wake oscillator replaces the synchronisation model, so the + !! type takes no LINE TYPES lift Cl (and so no in-line VIV, which needs it). 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, ntok, i + REAL(wp) :: v(4) + LOGICAL :: found, ok + + ErrStat = 0; ErrMsg = '' + ntok = count_tokens(row) + IF (ntok < 2 .OR. ntok > 5) THEN + CALL fail(ErrStat, ErrMsg, 'WAKE OSCILLATOR rows must be: TypeName CL0 [St [eps [A]]]'); RETURN + END IF + CALL get_token(row, 1, tok, found) + it = find_type(types, TRIM(tok)) + IF (it == 0) THEN + CALL fail(ErrStat, ErrMsg, 'WAKE OSCILLATOR row names undefined LINE TYPE "'//TRIM(tok)//'"'); RETURN + END IF + IF (types(it)%has_wake_row) THEN + CALL fail(ErrStat, ErrMsg, 'WAKE OSCILLATOR names LINE TYPE "'//TRIM(types(it)%name)//'" twice'); RETURN + END IF + v = [CD_ZERO, CD_VIV_WAKE_DEFAULT_ST, CD_VIV_WAKE_DEFAULT_EPS, CD_VIV_WAKE_DEFAULT_A] + ok = .TRUE. + DO i = 2, ntok + IF (.NOT. ok) EXIT + CALL get_token(row, i, tok, found) + CALL parse_real_token(tok, v(i - 1), ok) + END DO + IF (.NOT. ok) THEN + CALL fail(ErrStat, ErrMsg, 'WAKE OSCILLATOR CL0, St, eps and A must be plain numbers'); RETURN + END IF + IF (.NOT. ALL(IEEE_IS_FINITE(v))) THEN + CALL fail(ErrStat, ErrMsg, 'WAKE OSCILLATOR CL0, St, eps and A must be finite'); RETURN + END IF + IF (v(1) < CD_ZERO .OR. v(1) > MAX_COEFFICIENT) THEN + CALL fail(ErrStat, ErrMsg, 'WAKE OSCILLATOR lift coefficient CL0 must be non-negative (0 = off) and at '// & + 'most 1e15'); RETURN + END IF + IF (.NOT. (v(2) > CD_ZERO .AND. v(2) <= MAX_COEFFICIENT .AND. v(3) > CD_ZERO .AND. & + v(3) <= MAX_COEFFICIENT .AND. v(4) >= CD_ZERO .AND. v(4) <= MAX_COEFFICIENT)) THEN + CALL fail(ErrStat, ErrMsg, 'WAKE OSCILLATOR needs St > 0, eps > 0 and A >= 0, each at most 1e15'); RETURN + END IF + IF (v(1) > CD_ZERO .AND. types(it)%cl > CD_ZERO) THEN + CALL fail(ErrStat, ErrMsg, 'WAKE OSCILLATOR of LINE TYPE "'//TRIM(types(it)%name)//'" replaces its '// & + 'synchronisation lift: give the type LINE TYPES Cl 0'); RETURN + END IF + types(it)%wo_cl0 = v(1) + types(it)%wo_st = v(2) + types(it)%wo_eps = v(3) + types(it)%wo_a = v(4) + types(it)%has_wake_row = .TRUE. + END SUBROUTINE apply_type_wake + SUBROUTINE append_line_stiffener(row, lines, ErrStat, ErrMsg) !! One STIFFENERS row: LineID End Length RootOD TipOD InnerD E Density -- a conical segment of !! the bend stiffener sleeving End A or End B of a finite-EI line. The rows of one line end diff --git a/src/CableDyn_HermiteCableDynamic.f90 b/src/CableDyn_HermiteCableDynamic.f90 index 6f40c37..6d4ef5c 100644 --- a/src/CableDyn_HermiteCableDynamic.f90 +++ b/src/CableDyn_HermiteCableDynamic.f90 @@ -67,7 +67,7 @@ MODULE CableDyn_HermiteCableDynamic 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, & CD_VIV_Wrap_Phase, CD_VIV_TWO_PI, CD_VIV_NM, CD_VIV_Inline_Per_Length, & - CD_VIV_Inline_Phase_Rate + CD_VIV_Inline_Phase_Rate, CD_VIV_Wake_Advance USE CableDyn_Hydro, ONLY: CD_Morison_Drag_Per_Length_Jac, CD_Airy_Wave_Kinematics_Precomputed, & 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, & @@ -343,6 +343,16 @@ MODULE CableDyn_HermiteCableDynamic REAL(wp), ALLOCATABLE :: vil_ms(:, :), vil_ms_next(:, :), ws_recovery_vil_phi(:), ws_recovery_vil_ms(:, :) REAL(wp), ALLOCATABLE :: snap_vil_phi(:), snap_vil_ms(:, :) LOGICAL, ALLOCATABLE :: vil_node(:) + ! Wake-oscillator VIV (Set_VIV wake; Facchinetti et al. 2004): viv_wake replaces the + ! synchronisation phase of the whole cable by the van der Pol wake variable q = 2 C_L/C_L0, the + ! lift taking viv_k = 1/2 rho D viv_cl with viv_cl = C_L0/2. Per node the Strouhal number, + ! van der Pol eps and coupling A (length-weighted over its lifting elements), the state + ! wo_s(:, k) = (q, dq/dt), q at the step's evaluation point (wo_q_eval, as viv_phi_eval), the + ! step-start cross-flow acceleration and wake frequency (wo_ydd0, wo_om0) the step end + ! integrates from, and the recovery and snapshot copies of the state. + LOGICAL :: viv_wake = .FALSE. + REAL(wp), ALLOCATABLE :: wo_st(:), wo_eps(:), wo_a(:), wo_s(:, :), wo_q_eval(:), wo_ydd0(:), wo_om0(:) + REAL(wp), ALLOCATABLE :: ws_recovery_wo_s(:, :), snap_wo_s(:, :) REAL(wp), ALLOCATABLE :: Mgb(:, :) ! constant global mass (band) LOGICAL, ALLOCATABLE :: freemask(:), solve_mask(:) INTEGER, ALLOCATABLE :: fmap(:) ! free -> global DOF index @@ -1101,7 +1111,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) + clx, il_alpha, chh, wake) !! 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 @@ -1123,6 +1133,13 @@ SUBROUTINE CD_HermiteCable_Dyn_Set_VIV(model, cl, cf, df, t_window, ErrStat, Err !! node starts at twice its cross-flow phase. chh (optional, with clx), per element, the !! coefficient C_hh >= 0 of the higher-harmonic force of Ulveseter et al. (2019), the lift's !! form at the phase sum phi_y + phi_x (0: none; > 0 only where clx > 0). + !! + !! Wake oscillator (Facchinetti et al. 2004; no in-line VIV): wake(1:3, e) = (St, eps, A) per + !! element selects it for the cable, cl then being the reference lift coefficient C_L0 and cf, + !! df unused. The lift per unit length is 1/4 rho D C_L0 q U^2 along the cross-flow axis, with + !! q'' + eps om (q^2 - 1) q' + om^2 q = (A/D) y'' at each lifting node (om = 2 pi St U/D, y'' + !! its cross-flow acceleration); q starts on its limit cycle at the phase seed, q = 2 cos(phi_0) + !! and q' = 0. TYPE(CD_HermiteCableDynType), INTENT(INOUT) :: model REAL(wp), INTENT(IN) :: cl(:), cf(:), df(:), t_window INTEGER, INTENT(OUT) :: ErrStat @@ -1133,9 +1150,10 @@ SUBROUTINE CD_HermiteCable_Dyn_Set_VIV(model, cl, cf, df, t_window, ErrStat, Err !! (CD_VIV_Phase_Rate phi_rest); .FALSE. on a line the reader turned around LOGICAL, INTENT(IN), OPTIONAL :: tangent_reversed REAL(wp), INTENT(IN), OPTIONAL :: clx(:), il_alpha(:), chh(:) + REAL(wp), INTENT(IN), OPTIONAL :: wake(:, :) INTEGER :: e, k, ne, nn, es REAL(wp) :: wsum, tw_old, rest_old - LOGICAL :: had_viv, had_il, want_il + LOGICAL :: had_viv, had_il, want_il, had_wake, want_wake, bad_band CHARACTER(LEN=1024) :: em 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(:, :), & @@ -1143,6 +1161,8 @@ SUBROUTINE CD_HermiteCable_Dyn_Set_VIV(model, cl, cf, df, t_window, ErrStat, Err REAL(wp), ALLOCATABLE :: x_cx(:), x_k(:), x_al(:), x_phi(:), x_phi_eval(:), x_rate(:), x_ms(:, :), & x_ms_next(:, :), x_rec_phi(:), x_rec_ms(:, :), x_snap_phi(:), x_snap_ms(:, :), & x_hcx(:), x_hk(:) + REAL(wp), ALLOCATABLE :: w_st(:), w_eps(:), w_a(:), w_s(:, :), w_qe(:), w_y0(:), w_om(:), w_rec(:, :), & + w_snap(:, :) LOGICAL, ALLOCATABLE :: o_node(:), x_node(:) ErrStat = CD_HCDYN_OK; ErrMsg = '' @@ -1159,8 +1179,32 @@ SUBROUTINE CD_HermiteCable_Dyn_Set_VIV(model, cl, cf, df, t_window, ErrStat, Err CD_Is_Finite(t_window))) THEN ErrStat = CD_HCDYN_BADINPUT; ErrMsg = 'CD_HermiteCable_Dyn_Set_VIV: inputs must be finite'; RETURN END IF - IF (ANY(cl < CD_ZERO) .OR. t_window < CD_ZERO .OR. & - ANY(cl > CD_ZERO .AND. .NOT. (cf > CD_ZERO .AND. df >= CD_ZERO .AND. df < cf))) THEN + want_wake = PRESENT(wake) + IF (want_wake) THEN + IF (SIZE(wake, 1) /= 3 .OR. SIZE(wake, 2) /= ne) THEN + ErrStat = CD_HCDYN_BADINPUT + ErrMsg = 'CD_HermiteCable_Dyn_Set_VIV: wake must be shaped (3, ne): St, eps, A per element'; RETURN + END IF + IF (.NOT. CD_All_Finite(RESHAPE(wake, [3*ne]))) THEN + ErrStat = CD_HCDYN_BADINPUT; ErrMsg = 'CD_HermiteCable_Dyn_Set_VIV: wake must be finite'; RETURN + END IF + IF (ANY(cl > CD_ZERO .AND. .NOT. (wake(1, :) > CD_ZERO .AND. wake(2, :) > CD_ZERO .AND. & + wake(3, :) >= CD_ZERO))) THEN + ErrStat = CD_HCDYN_BADINPUT + ErrMsg = 'CD_HermiteCable_Dyn_Set_VIV: the wake oscillator needs St > 0, eps > 0 and A >= 0 where cl > 0' + RETURN + END IF + IF (PRESENT(clx)) THEN + IF (ANY(clx > CD_ZERO)) THEN + ErrStat = CD_HCDYN_BADINPUT + ErrMsg = 'CD_HermiteCable_Dyn_Set_VIV: the wake oscillator takes no in-line VIV (clx > 0)'; RETURN + END IF + END IF + END IF + ! the synchronisation band applies to the lift of the synchronisation model only + bad_band = ANY(cl > CD_ZERO .AND. .NOT. (cf > CD_ZERO .AND. df >= CD_ZERO .AND. df < cf)) + IF (want_wake) bad_band = .FALSE. + IF (ANY(cl < CD_ZERO) .OR. t_window < CD_ZERO .OR. bad_band) THEN ErrStat = CD_HCDYN_BADINPUT ErrMsg = 'CD_HermiteCable_Dyn_Set_VIV: need cl >= 0, t_window >= 0 and 0 <= df < cf where cl > 0' RETURN @@ -1225,6 +1269,7 @@ SUBROUTINE CD_HermiteCable_Dyn_Set_VIV(model, cl, cf, df, t_window, ErrStat, Err ! the previous configuration and state, kept for a rollback had_viv = model%has_viv had_il = model%has_viv_il + had_wake = model%viv_wake tw_old = model%viv_tw rest_old = model%viv_phi_rest a_old = model%a @@ -1299,6 +1344,38 @@ SUBROUTINE CD_HermiteCable_Dyn_Set_VIV(model, cl, cf, df, t_window, ErrStat, Err model%snap_vil_ms = model%vil_ms model%has_viv_il = .TRUE. END IF + IF (want_wake) THEN + ALLOCATE (model%wo_st(nn), model%wo_eps(nn), model%wo_a(nn), model%wo_s(2, nn), model%wo_q_eval(nn), & + model%wo_ydd0(nn), model%wo_om0(nn), model%ws_recovery_wo_s(2, nn), model%snap_wo_s(2, nn)) + ! the lift scale 1/2 rho D viv_cl is then 1/4 rho D C_L0, the lift 1/4 rho D C_L0 q U^2 + model%viv_cl = 0.5_wp*cl + model%wo_st = CD_ZERO + model%wo_eps = CD_ZERO + model%wo_a = CD_ZERO + model%wo_s = CD_ZERO + DO k = 1, nn + IF (.NOT. model%viv_node(k)) CYCLE + wsum = CD_ZERO + DO e = MAX(1, k - 1), MIN(ne, k) + IF (.NOT. (cl(e) > CD_ZERO)) CYCLE + wsum = wsum + model%l0(e) + model%wo_st(k) = model%wo_st(k) + model%l0(e)*wake(1, e) + model%wo_eps(k) = model%wo_eps(k) + model%l0(e)*wake(2, e) + model%wo_a(k) = model%wo_a(k) + model%l0(e)*wake(3, e) + END DO + model%wo_st(k) = model%wo_st(k)/wsum + model%wo_eps(k) = model%wo_eps(k)/wsum + model%wo_a(k) = model%wo_a(k)/wsum + ! on the limit cycle at the node's phase seed + model%wo_s(1, k) = 2.0_wp*COS(model%viv_phi(k)) + END DO + model%wo_q_eval = model%wo_s(1, :) + model%wo_ydd0 = CD_ZERO + model%wo_om0 = CD_ZERO + model%ws_recovery_wo_s = model%wo_s + model%snap_wo_s = model%wo_s + model%viv_wake = .TRUE. + END IF CALL viv_drag_terms(model) model%viv_phi_eval = model%viv_phi model%viv_rate = CD_ZERO @@ -1322,6 +1399,7 @@ SUBROUTINE refresh_acceleration() CALL move_viv(.TRUE.) model%has_viv = had_viv model%has_viv_il = had_il + model%viv_wake = had_wake model%viv_tw = tw_old model%viv_phi_rest = rest_old model%a = a_old @@ -1349,6 +1427,11 @@ SUBROUTINE move_viv(back) CALL MOVE_ALLOC(x_snap_phi, model%snap_vil_phi); CALL MOVE_ALLOC(x_snap_ms, model%snap_vil_ms) CALL MOVE_ALLOC(x_node, model%vil_node) CALL MOVE_ALLOC(x_hcx, model%vhh_cx); CALL MOVE_ALLOC(x_hk, model%vhh_k) + CALL MOVE_ALLOC(w_st, model%wo_st); CALL MOVE_ALLOC(w_eps, model%wo_eps) + CALL MOVE_ALLOC(w_a, model%wo_a); CALL MOVE_ALLOC(w_s, model%wo_s) + CALL MOVE_ALLOC(w_qe, model%wo_q_eval); CALL MOVE_ALLOC(w_y0, model%wo_ydd0) + CALL MOVE_ALLOC(w_om, model%wo_om0); CALL MOVE_ALLOC(w_rec, model%ws_recovery_wo_s) + CALL MOVE_ALLOC(w_snap, model%snap_wo_s) 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) @@ -1366,6 +1449,11 @@ SUBROUTINE move_viv(back) CALL MOVE_ALLOC(model%snap_vil_phi, x_snap_phi); CALL MOVE_ALLOC(model%snap_vil_ms, x_snap_ms) CALL MOVE_ALLOC(model%vil_node, x_node) CALL MOVE_ALLOC(model%vhh_cx, x_hcx); CALL MOVE_ALLOC(model%vhh_k, x_hk) + CALL MOVE_ALLOC(model%wo_st, w_st); CALL MOVE_ALLOC(model%wo_eps, w_eps) + CALL MOVE_ALLOC(model%wo_a, w_a); CALL MOVE_ALLOC(model%wo_s, w_s) + CALL MOVE_ALLOC(model%wo_q_eval, w_qe); CALL MOVE_ALLOC(model%wo_ydd0, w_y0) + CALL MOVE_ALLOC(model%wo_om0, w_om); CALL MOVE_ALLOC(model%ws_recovery_wo_s, w_rec) + CALL MOVE_ALLOC(model%snap_wo_s, w_snap) END IF END SUBROUTINE move_viv END SUBROUTINE CD_HermiteCable_Dyn_Set_VIV @@ -1384,8 +1472,11 @@ SUBROUTINE clear_viv(model) model%ws_recovery_vil_phi, model%ws_recovery_vil_ms, & model%snap_vil_phi, model%snap_vil_ms, model%vil_node) IF (ALLOCATED(model%vhh_k)) DEALLOCATE (model%vhh_cx, model%vhh_k) + IF (ALLOCATED(model%wo_s)) DEALLOCATE (model%wo_st, model%wo_eps, model%wo_a, model%wo_s, model%wo_q_eval, & + model%wo_ydd0, model%wo_om0, model%ws_recovery_wo_s, model%snap_wo_s) model%has_viv = .FALSE. model%has_viv_il = .FALSE. + model%viv_wake = .FALSE. model%viv_tw = CD_ZERO END SUBROUTINE clear_viv @@ -1413,6 +1504,24 @@ SUBROUTINE viv_drag_terms(model) END DO END SUBROUTINE viv_drag_terms + REAL(wp) FUNCTION viv_node_ambient_speed(model, k) RESULT(ua) + !! Speed of the ambient flow (current plus a held field) normal to node k's tangent (the slope + !! DOFs) at the committed state; 0 for a degenerate tangent. + TYPE(CD_HermiteCableDynType), INTENT(IN) :: model + INTEGER, INTENT(IN) :: k + REAL(wp) :: uu(3), t(3), un(3), speed + INTEGER :: i0 + i0 = 6*(k - 1) + uu = model%current + IF (model%has_held_field) uu = uu + model%hf_u(:, k) + speed = NORM2(model%q(i0 + 4:i0 + 6)) + ua = CD_ZERO + IF (.NOT. (speed > CD_ZERO)) RETURN + t = model%q(i0 + 4:i0 + 6)/speed + un = uu - DOT_PRODUCT(t, uu)*t + ua = NORM2(un) + END FUNCTION viv_node_ambient_speed + SUBROUTINE viv_node_motion(model, k, yd, ydd, un, ok, xd, xdd) !! Cross-flow velocity and acceleration of node k at the committed state, along its own !! tangent (the slope DOFs), in the flow the drag sees there (current plus a held field); @@ -1447,13 +1556,33 @@ SUBROUTINE viv_step_begin(model, dt, ErrStat, ErrMsg) INTEGER, INTENT(OUT) :: ErrStat CHARACTER(*), INTENT(OUT) :: ErrMsg INTEGER :: k - REAL(wp) :: w, frac, yd, ydd, un, xd, xdd + REAL(wp) :: w, frac, yd, ydd, un, xd, xdd, sw(2) LOGICAL :: ok ErrStat = CD_HCDYN_OK; ErrMsg = '' IF (.NOT. (model%viv_tw > CD_ZERO)) model%viv_tw = REAL(CD_VIV_NM, wp)*dt w = MIN(CD_ONE, dt/model%viv_tw) frac = CD_ONE IF (.NOT. model%force_blend) frac = CD_ONE - model%alpha_f + IF (model%viv_wake) THEN + ! the wake state predicted at the step's evaluation point under the step-start forcing + model%wo_q_eval = model%wo_s(1, :) + DO k = 1, model%nn + IF (.NOT. model%viv_node(k)) CYCLE + CALL viv_node_motion(model, k, yd, ydd, un, ok) + IF (.NOT. ok) THEN + ErrStat = CD_HCDYN_NOCONVERGE; ErrMsg = 'VIV wake oscillator: degenerate node tangent'; RETURN + END IF + ! the wake frequency of the ambient flow normal to the line (the free stream of the + ! paper), not of the relative flow, which the cable's own cross-flow motion modulates + model%wo_om0(k) = CD_VIV_TWO_PI*model%wo_st(k)*viv_node_ambient_speed(model, k)/model%viv_dn(k) + model%wo_ydd0(k) = ydd + sw = model%wo_s(:, k) + CALL CD_VIV_Wake_Advance(sw, model%wo_om0(k), model%wo_eps(k), model%wo_a(k)/model%viv_dn(k), ydd, ydd, & + frac*dt) + model%wo_q_eval(k) = sw(1) + END DO + RETURN + END IF model%viv_rate = CD_ZERO model%viv_ms_next = model%viv_ms model%viv_phi_eval = model%viv_phi @@ -1494,8 +1623,29 @@ SUBROUTINE viv_step_end(model, dt) TYPE(CD_HermiteCableDynType), INTENT(INOUT) :: model REAL(wp), INTENT(IN) :: dt INTEGER :: k - REAL(wp) :: w, yd, ydd, un, ms1, ms2, rate_end, xd, xdd, rate_end_x + REAL(wp) :: w, yd, ydd, un, ms1, ms2, rate_end, xd, xdd, rate_end_x, sw(2) LOGICAL :: ok, il + IF (model%viv_wake) THEN + ! the wake state over the step with the cross-flow acceleration linear from its step-start + ! value to the converged end one (held where the end tangent is degenerate), at the + ! step-start wake frequency; a non-finite result keeps the step-start forcing alone + DO k = 1, model%nn + IF (.NOT. model%viv_node(k)) CYCLE + CALL viv_node_motion(model, k, yd, ydd, un, ok) + IF (.NOT. (ok .AND. CD_Is_Finite(ydd))) ydd = model%wo_ydd0(k) + sw = model%wo_s(:, k) + CALL CD_VIV_Wake_Advance(sw, model%wo_om0(k), model%wo_eps(k), model%wo_a(k)/model%viv_dn(k), & + model%wo_ydd0(k), ydd, dt) + IF (.NOT. (CD_Is_Finite(sw(1)) .AND. CD_Is_Finite(sw(2)))) THEN + sw = model%wo_s(:, k) + CALL CD_VIV_Wake_Advance(sw, model%wo_om0(k), model%wo_eps(k), model%wo_a(k)/model%viv_dn(k), & + model%wo_ydd0(k), model%wo_ydd0(k), dt) + END IF + model%wo_s(:, k) = sw + END DO + model%wo_q_eval = model%wo_s(1, :) + RETURN + END IF w = MIN(CD_ONE, dt/model%viv_tw) DO k = 1, model%nn IF (.NOT. model%viv_node(k)) CYCLE @@ -1559,7 +1709,11 @@ SUBROUTINE viv_element_lift(model, q_cfg, v_cfg, e, flift, ErrStat, ErrMsg, djq, uu = uu + 0.5_wp*(model%hf_u(:, e) + model%hf_u(:, e + 1)) wl = 0.5_wp*(model%hf_wl(e) + model%hf_wl(e + 1)) END IF - kn = model%viv_k(e)*[COS(model%viv_phi_eval(e)), COS(model%viv_phi_eval(e + 1))] + IF (model%viv_wake) THEN + kn = model%viv_k(e)*[model%wo_q_eval(e), model%wo_q_eval(e + 1)] + ELSE + kn = model%viv_k(e)*[COS(model%viv_phi_eval(e)), COS(model%viv_phi_eval(e + 1))] + END IF il = .FALSE. IF (model%has_viv_il) il = model%vil_k(e) > CD_ZERO IF (il) THEN @@ -4036,6 +4190,7 @@ SUBROUTINE CD_HermiteCable_Dyn_Step(model, dt, max_iter, tol, ErrStat, ErrMsg, i ! every evaluation outside a step takes the committed VIV phase IF (model%has_viv) model%viv_phi_eval = model%viv_phi IF (model%has_viv_il) model%vil_phi_eval = model%vil_phi + IF (model%viv_wake) model%wo_q_eval = model%wo_s(1, :) END SUBROUTINE CD_HermiteCable_Dyn_Step SUBROUTINE CD_HermiteCable_Dyn_Set_Torsion_Drive(model, ends, phi, ErrStat, ErrMsg) @@ -5893,6 +6048,7 @@ SUBROUTINE CD_HermiteCable_Dyn_Step_Recovering(model, dt, max_iter, tol, ErrStat model%ws_recovery_viv_phi = model%viv_phi model%ws_recovery_viv_ms = model%viv_ms END IF + IF (model%viv_wake) model%ws_recovery_wo_s = model%wo_s IF (model%has_viv_il) THEN model%ws_recovery_vil_phi = model%vil_phi model%ws_recovery_vil_ms = model%vil_ms @@ -5994,6 +6150,9 @@ SUBROUTINE CD_HermiteCable_Dyn_Step_Recovering(model, dt, max_iter, tol, ErrStat model%viv_phi = model%ws_recovery_viv_phi; model%viv_ms = model%ws_recovery_viv_ms model%viv_phi_eval = model%viv_phi END IF + IF (model%viv_wake) THEN + model%wo_s = model%ws_recovery_wo_s; model%wo_q_eval = model%wo_s(1, :) + END IF IF (model%has_viv_il) THEN model%vil_phi = model%ws_recovery_vil_phi; model%vil_ms = model%ws_recovery_vil_ms model%vil_phi_eval = model%vil_phi @@ -6078,6 +6237,9 @@ SUBROUTINE CD_HermiteCable_Dyn_Step_Recovering(model, dt, max_iter, tol, ErrStat model%viv_phi = model%ws_recovery_viv_phi; model%viv_ms = model%ws_recovery_viv_ms model%viv_phi_eval = model%viv_phi END IF + IF (model%viv_wake) THEN + model%wo_s = model%ws_recovery_wo_s; model%wo_q_eval = model%wo_s(1, :) + END IF IF (model%has_viv_il) THEN model%vil_phi = model%ws_recovery_vil_phi; model%vil_ms = model%ws_recovery_vil_ms model%vil_phi_eval = model%vil_phi @@ -6132,6 +6294,9 @@ SUBROUTINE CD_HermiteCable_Dyn_Step_Recovering(model, dt, max_iter, tol, ErrStat model%viv_phi = model%ws_recovery_viv_phi; model%viv_ms = model%ws_recovery_viv_ms model%viv_phi_eval = model%viv_phi END IF + IF (model%viv_wake) THEN + model%wo_s = model%ws_recovery_wo_s; model%wo_q_eval = model%wo_s(1, :) + END IF IF (model%has_viv_il) THEN model%vil_phi = model%ws_recovery_vil_phi; model%vil_ms = model%ws_recovery_vil_ms model%vil_phi_eval = model%vil_phi @@ -8670,6 +8835,7 @@ SUBROUTINE CD_HermiteCable_Dyn_Snapshot(model, ErrStat, ErrMsg) model%snap_viv_phi = model%viv_phi model%snap_viv_ms = model%viv_ms END IF + IF (model%viv_wake) model%snap_wo_s = model%wo_s IF (model%has_viv_il) THEN model%snap_vil_phi = model%vil_phi model%snap_vil_ms = model%vil_ms @@ -8756,6 +8922,9 @@ SUBROUTINE CD_HermiteCable_Dyn_Restore(model, ErrStat, ErrMsg) model%viv_phi = model%snap_viv_phi; model%viv_ms = model%snap_viv_ms model%viv_phi_eval = model%viv_phi END IF + IF (model%viv_wake) THEN + model%wo_s = model%snap_wo_s; model%wo_q_eval = model%wo_s(1, :) + END IF IF (model%has_viv_il) THEN model%vil_phi = model%snap_vil_phi; model%vil_ms = model%snap_vil_ms model%vil_phi_eval = model%vil_phi diff --git a/src/CableDyn_OpenFAST_HermiteFMF.f90 b/src/CableDyn_OpenFAST_HermiteFMF.f90 index 9c0ab81..4de6294 100644 --- a/src/CableDyn_OpenFAST_HermiteFMF.f90 +++ b/src/CableDyn_OpenFAST_HermiteFMF.f90 @@ -2252,12 +2252,14 @@ INTEGER FUNCTION CD_HFMF_VIVMirrorSize(self) RESULT(n) !! Mirror slots of the VIV state, before the torsion block: the cross-flow shedding phase !! per node, the running mean squares of the cross-flow velocity and acceleration per node !! (interleaved) and the averaging time (3 nn + 1 values); with in-line VIV then the in-line - !! phase and mean squares (3 nn more); zero without VIV. + !! phase and mean squares (3 nn more); with the wake oscillator its state (q, dq/dt) per node + !! (2 nn more); zero without VIV. TYPE(CD_HFMF_ModuleType), INTENT(IN) :: self n = 0 IF (.NOT. self%initialized) RETURN IF (self%line%has_viv) n = 3*self%line%nn + 1 IF (self%line%has_viv_il) n = n + 3*self%line%nn + IF (self%line%viv_wake) n = n + 2*self%line%nn END FUNCTION CD_HFMF_VIVMirrorSize INTEGER FUNCTION CD_HFMF_FrictionMirrorSize(self) RESULT(n) @@ -2345,6 +2347,10 @@ SUBROUTINE CD_HFMF_PackMirror(self, buf, ErrStat, ErrMsg) buf(k + self%line%nn + 1:k + 3*self%line%nn) = RESHAPE(self%line%vil_ms, [2*self%line%nn]) k = k + 3*self%line%nn END IF + IF (self%line%viv_wake) THEN + buf(k + 1:k + 2*self%line%nn) = RESHAPE(self%line%wo_s, [2*self%line%nn]) + k = k + 2*self%line%nn + END IF IF (self%line%torsion%active) THEN buf(k + 1) = self%line%torsion%theta buf(k + 2) = self%line%torsion%phi @@ -2521,6 +2527,12 @@ SUBROUTINE CD_HFMF_UnpackMirror(self, buf, t, ErrStat, ErrMsg) self%line%ws_recovery_vil_ms = self%line%vil_ms k = k + 3*self%line%nn END IF + IF (self%line%viv_wake) THEN + self%line%wo_s = RESHAPE(buf(k + 1:k + 2*self%line%nn), [2, self%line%nn]) + self%line%wo_q_eval = self%line%wo_s(1, :) + self%line%ws_recovery_wo_s = self%line%wo_s + k = k + 2*self%line%nn + END IF IF (self%line%torsion%active) THEN self%line%torsion%theta = buf(k + 1) self%line%torsion%phi = buf(k + 2) diff --git a/src/CableDyn_VIV.f90 b/src/CableDyn_VIV.f90 index 966d9cd..aad06ed 100644 --- a/src/CableDyn_VIV.f90 +++ b/src/CableDyn_VIV.f90 @@ -61,6 +61,7 @@ MODULE CableDyn_VIV PUBLIC :: CD_VIV_Node_Inline PUBLIC :: CD_VIV_Inline_Per_Length PUBLIC :: CD_VIV_Inline_Phase_Rate + PUBLIC :: CD_VIV_Wake_Advance !> MoorDyn's running-RMS window in time steps (Line%n_m): each step updates the stored !> mean square as ((n_m - 1) old + new) / n_m. @@ -72,6 +73,13 @@ MODULE CableDyn_VIV REAL(wp), PARAMETER, PUBLIC :: CD_VIV_TWO_PI = 6.283185307179586476925286766559005768394_wp !> The in-line frequency band alpha of Ulveseter et al. (2018, Table 3) and Thorsen et al. REAL(wp), PARAMETER, PUBLIC :: CD_VIV_DEFAULT_IL_ALPHA = 0.15_wp + !> The wake oscillator of Facchinetti, de Langre and Biolley (J. Fluids Struct. 19, 2004, + !> 123-140, Sec. 3): Strouhal number, reference lift coefficient C_L0, van der Pol parameter + !> epsilon and acceleration coupling A, fixed there from forced-wake data. + REAL(wp), PARAMETER, PUBLIC :: CD_VIV_WAKE_DEFAULT_ST = 0.2_wp + REAL(wp), PARAMETER, PUBLIC :: CD_VIV_WAKE_DEFAULT_CL0 = 0.3_wp + REAL(wp), PARAMETER, PUBLIC :: CD_VIV_WAKE_DEFAULT_EPS = 0.3_wp + REAL(wp), PARAMETER, PUBLIC :: CD_VIV_WAKE_DEFAULT_A = 12.0_wp !> Chord below which a node tangent is undefined (a collapsed pair of neighbours). REAL(wp), PARAMETER :: TINY_CHORD = 1.0e-12_wp @@ -438,6 +446,42 @@ PURE SUBROUTINE inline_jacobians(s, t, vr, vn, un, dfdv, dfdt) END DO END SUBROUTINE inline_jacobians + PURE SUBROUTINE CD_VIV_Wake_Advance(s, om, eps, ad, f0, f1, h) + !! Advance the wake oscillator of Facchinetti et al. (2004, Eq. 5 with the acceleration + !! coupling F = A Y''/D; Violette et al., J. Fluids Struct. 26, 2010, Eq. 3) over a time h: + !! + !! q'' + eps om (q^2 - 1) q' + om^2 q = ad y''(t) + !! + !! s = (q, q'), om the wake frequency 2 pi St U/D, ad = A/D and the cross-flow acceleration + !! y'' of the line, taken linear from f0 at the start of the interval to f1 at its end. + !! Classical Runge-Kutta in equal sub-steps of om dt <= 0.1 (at least one), so the error is + !! that of a resolved oscillation however long h is against the wake period. q = 2 C_L/C_L0: + !! the free oscillator settles on its limit cycle q = 2 cos(om t), the lift of a fixed + !! cylinder. + REAL(wp), INTENT(INOUT) :: s(2) + REAL(wp), INTENT(IN) :: om, eps, ad, f0, f1, h + INTEGER :: n, i + REAL(wp) :: dt, t, k1(2), k2(2), k3(2), k4(2) + IF (.NOT. (h > CD_ZERO)) RETURN + n = MAX(1, CEILING(MIN(ABS(om)*h/0.1_wp, 1.0e6_wp))) + dt = h/REAL(n, wp) + DO i = 0, n - 1 + t = REAL(i, wp)*dt + k1 = rhs(s, t) + k2 = rhs(s + 0.5_wp*dt*k1, t + 0.5_wp*dt) + k3 = rhs(s + 0.5_wp*dt*k2, t + 0.5_wp*dt) + k4 = rhs(s + dt*k3, t + dt) + s = s + (dt/6.0_wp)*(k1 + 2.0_wp*k2 + 2.0_wp*k3 + k4) + END DO + CONTAINS + PURE FUNCTION rhs(x, tau) RESULT(d) + REAL(wp), INTENT(IN) :: x(2), tau + REAL(wp) :: d(2) + d(1) = x(2) + d(2) = ad*(f0 + (f1 - f0)*tau/h) - eps*om*(x(1)*x(1) - CD_ONE)*x(2) - om*om*x(1) + END FUNCTION rhs + END SUBROUTINE CD_VIV_Wake_Advance + ELEMENTAL REAL(wp) FUNCTION CD_VIV_Wrap_Phase(phi) RESULT(wrapped) !! The phase mapped to [0, 2 pi); the model only uses cos(phi) and sin(. - phi). REAL(wp), INTENT(IN) :: phi diff --git a/tests/test_viv_coupled.f90 b/tests/test_viv_coupled.f90 index 1514c5f..bc07883 100644 --- a/tests/test_viv_coupled.f90 +++ b/tests/test_viv_coupled.f90 @@ -29,7 +29,11 @@ PROGRAM test_viv_coupled !! at the deck nodes of a refined mesh (added nodes interpolated in arc length); !! * in-line VIV (a VIV section, ClX 0.85, on both lines): the checkpoint blocks grow by the !! in-line phase and mean squares (3 per node), the restarted run continues bit for bit with - !! both phases, a rebuild without the VIV state does not, and a rewound step repeats. + !! both phases, a rebuild without the VIV state does not, and a rewound step repeats; + !! * wake oscillator (a WAKE OSCILLATOR row, C_L0 0.3, on the cable, whose type has Cl 0; the + !! EI = 0 riser keeps its synchronisation lift): the cable's checkpoint block grows by the wake + !! state (2 per node), the restarted run continues bit for bit with it, a rebuild without the + !! VIV state does not, and a rewound step repeats. USE CableDyn_Precision, ONLY: wp USE CableDyn_OpenFAST_Aggregate, ONLY: CD_AGG_ModuleType, CD_AGG_Init_From_Deck, CD_AGG_End, CD_AGG_OK, & CD_AGG_NMovingPoints, CD_AGG_GetMovingPointMesh, CD_AGG_Step_Moving, & @@ -49,12 +53,13 @@ PROGRAM test_viv_coupled INTEGER :: nfail ! the deck of the restart and rewind cases, and whether its lines carry in-line VIV CHARACTER(32) :: deck_name = 'viv_coupled.dat' - LOGICAL :: il_case = .FALSE. + LOGICAL :: il_case = .FALSE., wake_case = .FALSE. nfail = 0 CALL write_deck('viv_coupled.dat', 0.8_wp) CALL write_deck('viv_coupled_nolift.dat', 0.0_wp) CALL write_deck('viv_coupled_il.dat', 0.8_wp, inline=.TRUE.) + CALL write_deck('viv_coupled_wake.dat', 0.8_wp, wake=.TRUE.) CALL case_lockin() CALL case_restart() CALL case_rewind() @@ -64,6 +69,11 @@ PROGRAM test_viv_coupled il_case = .TRUE. CALL case_restart() CALL case_rewind() + deck_name = 'viv_coupled_wake.dat' + il_case = .FALSE. + wake_case = .TRUE. + CALL case_restart() + CALL case_rewind() IF (nfail > 0) THEN WRITE (*, '(A,I0,A)') 'FAIL: ', nfail, ' coupled VIV check(s) failed' ERROR STOP 1 @@ -364,7 +374,7 @@ LOGICAL FUNCTION rebuild(a, b, with_viv) RESULT(ok) ALLOCATE (buf(CD_HFMF_MirrorSize(a%cables(1))), fresh(CD_HFMF_MirrorSize(b%cables(1)))) CALL CD_HFMF_PackMirror(a%cables(1), buf, es, em) nvc = CD_HFMF_VIVMirrorSize(a%cables(1)) - ok = ok .AND. nvc == MERGE(6, 3, il_case)*a%cables(1)%line%nn + 1 + ok = ok .AND. nvc == (MERGE(6, 3, il_case) + MERGE(2, 0, wake_case))*a%cables(1)%line%nn + 1 IF (.NOT. with_viv) THEN ! the cable's VIV block as the fresh build has it (the torsion-free cable ends with it) CALL CD_HFMF_PackMirror(b%cables(1), fresh, es, em) @@ -382,6 +392,8 @@ LOGICAL FUNCTION identical(a, b) RESULT(same) MAXVAL(ABS(a%sys%fast%system%lines(1)%viv_phi - b%sys%fast%system%lines(1)%viv_phi)) <= 0.0_wp .AND. & MAXVAL(ABS(a%cables(1)%line%q - b%cables(1)%line%q)) <= 0.0_wp .AND. & MAXVAL(ABS(a%cables(1)%line%viv_phi - b%cables(1)%line%viv_phi)) <= 0.0_wp + IF (same .AND. wake_case) same = a%cables(1)%line%viv_wake .AND. & + MAXVAL(ABS(a%cables(1)%line%wo_s - b%cables(1)%line%wo_s)) <= 0.0_wp IF (.NOT. (same .AND. il_case)) RETURN same = a%sys%fast%system%lines(1)%has_viv_il .AND. a%cables(1)%line%has_viv_il .AND. & MAXVAL(ABS(a%sys%fast%system%lines(1)%vil_phi - b%sys%fast%system%lines(1)%vil_phi)) <= 0.0_wp .AND. & @@ -410,20 +422,25 @@ SUBROUTINE response(z, ad, f) IF (n > 1) f = REAL(n - 1, wp)/(t1 - t0) END SUBROUTINE response - SUBROUTINE write_deck(path, cl, window, dtm, anchor_first, inline) + SUBROUTINE write_deck(path, cl, window, dtm, anchor_first, inline, wake) !! The EI = 0 riser (line 1) and the finite-EI cable (line 2), 20 m apart across the current; !! VIVrmsWindow 0.25 s unless window is given (0: none), and a deck dtM when dtm is given; - !! inline adds the in-line VIV of both types (a VIV section, ClX 0.85). + !! inline adds the in-line VIV of both types (a VIV section, ClX 0.85); wake gives the cable + !! the wake oscillator instead of its lift (Cl 0 and a WAKE OSCILLATOR row, C_L0 0.3). CHARACTER(*), INTENT(IN) :: path REAL(wp), INTENT(IN) :: cl REAL(wp), INTENT(IN), OPTIONAL :: window, dtm - LOGICAL, INTENT(IN), OPTIONAL :: anchor_first, inline + LOGICAL, INTENT(IN), OPTIONAL :: anchor_first, inline, wake INTEGER :: u - LOGICAL :: stock + LOGICAL :: stock, wo REAL(wp) :: tw - CHARACTER(32) :: len_txt, cl_txt + CHARACTER(32) :: len_txt, cl_txt, clc_txt WRITE (len_txt, '(F12.6)') 100.0_wp/(1.0_wp + 5.0e4_wp/5.0e7_wp) WRITE (cl_txt, '(F4.2)') cl + wo = .FALSE. + IF (PRESENT(wake)) wo = wake + clc_txt = cl_txt + IF (wo) clc_txt = '0.00' OPEN (NEWUNIT=u, FILE=path, STATUS='REPLACE', ACTION='WRITE') WRITE (u, '(A)') '--------------------- CableDyn Input File ---' WRITE (u, '(A)') 'coupled VIV gate: taut riser and cable in a host cross current' @@ -431,7 +448,7 @@ SUBROUTINE write_deck(path, cl, window, dtm, anchor_first, inline) WRITE (u, '(A)') 'TypeName Diam Mass/m EA BA/-zeta EI Cd Ca CdAx CaAx Cl dF cF' WRITE (u, '(A)') '(name) (m) (kg/m) (N) (N-s/-) (-) (-) (-) (-) (-) (-) (-) (-)' WRITE (u, '(A)') 'riser 0.10 10.0 5.0e7 -0.8 0.0 1.2 1.0 0.0 0.0 '//TRIM(cl_txt)//' 0.08 0.18' - WRITE (u, '(A)') 'cable 0.10 10.0 5.0e7 -0.8 1.0 1.2 1.0 0.0 0.0 '//TRIM(cl_txt)//' 0.08 0.18' + WRITE (u, '(A)') 'cable 0.10 10.0 5.0e7 -0.8 1.0 1.2 1.0 0.0 0.0 '//TRIM(clc_txt)//' 0.08 0.18' WRITE (u, '(A)') '--------------------- POINTS ---' WRITE (u, '(A)') 'ID Attachment X Y Z M V CdA CA' WRITE (u, '(A)') '(#) (-) (m) (m) (m) (kg) (m^3) (m^2) (-)' @@ -461,6 +478,11 @@ SUBROUTINE write_deck(path, cl, window, dtm, anchor_first, inline) WRITE (u, '(A)') 'cable 0.85 0.15' END IF END IF + IF (wo) THEN + WRITE (u, '(A)') '--------------------- WAKE OSCILLATOR ---' + WRITE (u, '(A)') 'TypeName CL0 St eps A' + WRITE (u, '(A)') 'cable 0.3 0.2 0.3 12' + END IF WRITE (u, '(A)') '--------------------- OPTIONS ---' WRITE (u, '(A)') '100.0 WtrDpth' WRITE (u, '(A)') '1025.0 rhoW' diff --git a/tests/test_viv_wake_deck.f90 b/tests/test_viv_wake_deck.f90 new file mode 100644 index 0000000..7546516 --- /dev/null +++ b/tests/test_viv_wake_deck.f90 @@ -0,0 +1,300 @@ +! File: tests/test_viv_wake_deck.f90 +! SPDX-License-Identifier: Apache-2.0 +! Copyright (c) 2026 Jae Hoon Seo, SMI Lab, Inha University +PROGRAM test_viv_wake_deck + !! Wake-oscillator VIV on a deck (the optional WAKE OSCILLATOR section, TypeName CL0 [St [eps + !! [A]]]; Facchinetti et al. 2004): the taut finite-EI cable of the in-line VIV gate (100 m, + !! D 0.1 m, EI 1 N m^2, 50 kN, pinned at 50 m depth) in a uniform 0.15 m/s current along y, its + !! type with no synchronisation lift (Cl 0) and the row riser 0.3 (St 0.2, eps 0.3, A 12). + !! W1 lock-in: with the acceleration coupling A 12 the cross-flow response is captured by the + !! cable's first mode, below the wake's own frequency St U/D = 0.30 Hz by more than + !! 0.01 Hz, at a steady mid-span A/D between 0.4 and 0.8; uncoupled (A 0) the wake drives + !! the cable at its own 0.30 Hz (within 0.005 Hz), and the coupled amplitude is at least + !! three times the uncoupled one; + !! W2 power: over 60-100 s the mean wake-lift power (VIVPow1) is positive and the drag and + !! damping powers (DragPow1, DampPow1) take it out within 0.5 %; + !! W3 a row with CL0 0 is the deck without the section, to the printed digits; + !! W4 refusals by name: a malformed or non-numeric row, an unknown or repeated type, St, eps or + !! A out of range, a type that keeps its synchronisation lift (Cl > 0, which in-line VIV + !! also needs), a line that mixes the two models, and an EI = 0 line. + USE CableDyn_Precision, ONLY: wp + USE CableDyn_DeckDriver, ONLY: CD_Run_Deck_Driver, CD_DECKDRV_OK + IMPLICIT NONE + REAL(wp), PARAMETER :: PI = 3.14159265358979323846_wp, D = 0.1_wp, F_WAKE = 0.2_wp*0.15_wp/0.1_wp + INTEGER :: nfail = 0 + + CALL write_current('wod_current.dat') + CALL check_runs() + CALL check_refusals() + IF (nfail > 0) THEN + WRITE (*, '(A,I0,A)') 'FAIL: ', nfail, ' assertion(s) failed' + ERROR STOP 1 + END IF + WRITE (*, '(A)') 'PASS: wake-oscillator 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 wake-oscillator 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_deck(path, wake_rows, tmax, cl, ei, viv_row, mixed) + !! wake_rows: the WAKE OSCILLATOR section's data rows, ';'-separated ('' for no section); cl the + !! type's LINE TYPES Cl (default 0), ei its EI (default 1), viv_row a VIV section row, mixed: + !! the line in two sections, the second of a type 'lift' with Cl 0.8. + CHARACTER(*), INTENT(IN) :: path, wake_rows + REAL(wp), INTENT(IN) :: tmax + CHARACTER(*), INTENT(IN), OPTIONAL :: cl, ei, viv_row + LOGICAL, INTENT(IN), OPTIONAL :: mixed + CHARACTER(32) :: cl_col, ei_col + INTEGER :: u, i0, i1 + LOGICAL :: two + cl_col = '0.0' + IF (PRESENT(cl)) cl_col = cl + ei_col = '1.0' + IF (PRESENT(ei)) ei_col = ei + two = .FALSE. + IF (PRESENT(mixed)) two = mixed + OPEN (NEWUNIT=u, FILE=path, STATUS='REPLACE', ACTION='WRITE') + WRITE (u, '(A)') '--------------------- CableDyn Input File ---------------------------------' + WRITE (u, '(A)') 'wake-oscillator 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)//' 1.2 1.0 0.0 0.0 '// & + TRIM(cl_col)//' 0.08 0.18' + WRITE (u, '(A)') 'lift 0.10 10.0 5.0e7 -0.8 '//TRIM(ei_col)//' 1.2 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' + IF (two) THEN + WRITE (u, '(A)') '1 riser 49.950050 25' + WRITE (u, '(A)') '1 lift 49.950050 25' + ELSE + WRITE (u, '(A)') '1 riser 99.900100 50' + END IF + IF (PRESENT(viv_row)) THEN + WRITE (u, '(A)') '----------------------- VIV -------------------------------------------------' + WRITE (u, '(A)') 'TypeName ClX alpha' + WRITE (u, '(A)') viv_row + END IF + IF (LEN_TRIM(wake_rows) > 0) THEN + WRITE (u, '(A)') '----------------------- WAKE OSCILLATOR -------------------------------------' + WRITE (u, '(A)') 'TypeName CL0 St eps A' + i0 = 1 + DO + i1 = INDEX(wake_rows(i0:), ';') + IF (i1 == 0) THEN + WRITE (u, '(A)') TRIM(wake_rows(i0:)) + EXIT + END IF + WRITE (u, '(A)') wake_rows(i0:i0 + i1 - 2) + i0 = i0 + i1 + END DO + 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)') 'wod_current.dat WaterKin' + WRITE (u, '(A,F8.3,A)') ' ', tmax, ' TMax' + WRITE (u, '(A)') '---------------------- OUTPUTS -----------------------------------------------' + WRITE (u, '(A)') 'L1N25PZ' + WRITE (u, '(A)') 'VIVPow1' + WRITE (u, '(A)') 'DragPow1' + WRITE (u, '(A)') 'DampPow1' + 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) + !! The rows (time, L1N25PZ, VIVPow1, DragPow1, DampPow1) of a deck's main output file. + CHARACTER(*), INTENT(IN) :: path + REAL(wp), ALLOCATABLE, INTENT(OUT) :: tab(:, :) + INTEGER, INTENT(OUT) :: n + CHARACTER(1024) :: rec + INTEGER :: u, ios + ALLOCATE (tab(5, 20000)) + n = 0 + OPEN (NEWUNIT=u, FILE=path, STATUS='OLD', ACTION='READ', IOSTAT=ios) + IF (ios /= 0) RETURN + READ (u, '(A)') rec + READ (u, '(A)') rec + DO + READ (u, '(A)', IOSTAT=ios) rec + IF (ios /= 0) EXIT + IF (LEN_TRIM(rec) == 0) CYCLE + IF (n == SIZE(tab, 2)) EXIT + n = n + 1 + READ (rec, *) tab(:, n) + END DO + CLOSE (u) + END SUBROUTINE read_out + + REAL(wp) FUNCTION peak_frequency(tt, x) RESULT(fpk) + !! The frequency of the largest Fourier amplitude of x - mean(x) on 0.05-2 Hz (0.001 Hz grid). + REAL(wp), INTENT(IN) :: tt(:), x(:) + REAL(wp) :: xm(SIZE(x)), f, best, re, im + INTEGER :: j + xm = x - SUM(x)/REAL(SIZE(x), wp) + best = -1.0_wp + fpk = 0.0_wp + DO j = 0, 1950 + f = 0.05_wp + 0.001_wp*REAL(j, wp) + re = SUM(xm*COS(2.0_wp*PI*f*tt)) + im = SUM(xm*SIN(2.0_wp*PI*f*tt)) + IF (re*re + im*im > best) THEN + best = re*re + im*im + fpk = f + END IF + END DO + END FUNCTION peak_frequency + + SUBROUTINE window_stats(tab, n, t0, t1, ad, f) + !! Half peak-to-peak mid-span amplitude over D and dominant frequency on [t0, t1]. + REAL(wp), INTENT(IN) :: tab(:, :), t0, t1 + INTEGER, INTENT(IN) :: n + REAL(wp), INTENT(OUT) :: ad, f + LOGICAL :: keep(n) + REAL(wp), ALLOCATABLE :: tt(:), z(:) + keep = tab(1, 1:n) >= t0 .AND. tab(1, 1:n) <= t1 + tt = PACK(tab(1, 1:n), keep) + z = PACK(tab(2, 1:n), keep) + ad = 0.5_wp*(MAXVAL(z) - MINVAL(z))/D + f = peak_frequency(tt, z) + END SUBROUTINE window_stats + + SUBROUTINE check_runs() + REAL(wp), ALLOCATABLE :: tw(:, :), t0(:, :), tn(:, :), tz(:, :) + INTEGER :: nw, n0, nn, nz + REAL(wp) :: ad_w, f_w, ad_w2, f_w2, ad_0, f_0, pv, pd, pb + LOGICAL :: ok, keep(20000) + CHARACTER(1024) :: msg + CALL write_deck('wod_wake.dat', 'riser 0.3', 100.0_wp) + CALL run('wod_wake.dat', 'wod_wake', ok, msg) + CALL require(ok, 'W1: the wake-oscillator deck runs: '//TRIM(msg)) + CALL write_deck('wod_a0.dat', 'riser 0.3 0.2 0.3 0.0', 100.0_wp) + CALL run('wod_a0.dat', 'wod_a0', ok, msg) + CALL require(ok, 'W1: the uncoupled deck (A 0) runs: '//TRIM(msg)) + CALL read_out('wod_wake.out', tw, nw) + CALL read_out('wod_a0.out', t0, n0) + CALL require(nw > 1000 .AND. n0 == nw, 'W1: the runs wrote matching rows') + IF (.NOT. (nw > 1000 .AND. n0 == nw)) RETURN + CALL window_stats(tw, nw, 50.0_wp, 75.0_wp, ad_w, f_w) + CALL window_stats(tw, nw, 75.0_wp, 100.0_wp, ad_w2, f_w2) + CALL window_stats(t0, n0, 50.0_wp, 100.0_wp, ad_0, f_0) + WRITE (*, '(A,2F8.4,A,2F8.4,A,F7.4)') 'W1: coupled A/D, f [Hz] (50-75 s, 75-100 s) ', ad_w, f_w, ', ', ad_w2, & + f_w2, '; wake frequency ', F_WAKE + WRITE (*, '(A,2F8.4)') 'W1: uncoupled (A 0) A/D, f [Hz] ', ad_0, f_0 + CALL require(f_w < F_WAKE - 0.01_wp .AND. ad_w > 0.4_wp .AND. ad_w < 0.8_wp, & + 'W1: the coupled response locks in below the wake frequency at A/D 0.4-0.8') + CALL require(ABS(ad_w2/ad_w - 1.0_wp) <= 0.01_wp .AND. ABS(f_w2 - f_w) <= 0.002_wp, 'W1: and is steady') + CALL require(ABS(f_0 - F_WAKE) <= 0.005_wp, 'W1: uncoupled, the wake drives the cable at its own frequency') + CALL require(ad_w >= 3.0_wp*ad_0, 'W1: lock-in at least triples the uncoupled amplitude') + ! W2: the power balance of the steady lock-in + keep(1:nw) = tw(1, 1:nw) >= 60.0_wp + pv = SUM(PACK(tw(3, 1:nw), keep(1:nw)))/COUNT(keep(1:nw)) + pd = SUM(PACK(tw(4, 1:nw), keep(1:nw)))/COUNT(keep(1:nw)) + pb = SUM(PACK(tw(5, 1:nw), keep(1:nw)))/COUNT(keep(1:nw)) + WRITE (*, '(A,3ES12.4)') 'W2: mean VIVPow, DragPow, DampPow [W] over 60-100 s: ', pv, pd, pb + CALL require(pv > 0.0_wp .AND. ABS(pv + pd + pb) <= 0.005_wp*pv, & + 'W2: the drag and damping take out the wake-lift power within 0.5 %') + ! W3: CL0 0 is no wake oscillator + CALL write_deck('wod_none.dat', '', 20.0_wp) + CALL run('wod_none.dat', 'wod_none', ok, msg) + CALL require(ok, 'W3: the deck without the section runs: '//TRIM(msg)) + CALL write_deck('wod_zero.dat', 'riser 0.0', 20.0_wp) + CALL run('wod_zero.dat', 'wod_zero', ok, msg) + CALL require(ok, 'W3: the CL0 0 deck runs: '//TRIM(msg)) + CALL read_out('wod_none.out', tn, nn) + CALL read_out('wod_zero.out', tz, nz) + CALL require(nn > 100 .AND. nz == nn, 'W3: the runs wrote matching rows') + IF (nn > 100 .AND. nz == nn) CALL require(ALL(tz(:, 1:nz) == tn(:, 1:nn)), & + 'W3: a row with CL0 0 is the deck without the section') + END SUBROUTINE check_runs + + SUBROUTINE check_refusals() + CALL refused('riser 0.3 0.2 0.3 12 1', 'TypeName CL0 [St [eps [A]]]', 'a row of six columns') + CALL refused('riser 0.3 x', 'plain numbers', 'a non-numeric St') + CALL refused('cable 0.3', 'undefined LINE TYPE', 'an unknown type') + CALL refused('riser 0.3;riser 0.2', 'twice', 'a repeated type') + CALL refused('riser -0.1', 'CL0 must be non-negative', 'a negative CL0') + CALL refused('riser 0.3 0.0', 'St > 0, eps > 0 and A >= 0', 'St = 0') + CALL refused('riser 0.3 0.2 0.0', 'St > 0, eps > 0 and A >= 0', 'eps = 0') + CALL refused('riser 0.3 0.2 0.3 -1', 'St > 0, eps > 0 and A >= 0', 'a negative A') + CALL refused('riser 0.3', 'give the type LINE TYPES Cl 0', 'a type that keeps its lift', cl='0.8') + CALL refused('riser 0.3', 'a line takes one VIV model', 'a line mixing the two models', mixed=.TRUE.) + CALL refused('riser 0.3', 'finite-EI cables (EI > 0) only', 'an EI = 0 line', ei='0.0') + END SUBROUTINE check_refusals + + SUBROUTINE refused(rows, needle, what, cl, ei, viv_row, mixed) + CHARACTER(*), INTENT(IN) :: rows, needle, what + CHARACTER(*), INTENT(IN), OPTIONAL :: cl, ei, viv_row + LOGICAL, INTENT(IN), OPTIONAL :: mixed + LOGICAL :: ok + CHARACTER(1024) :: msg + IF (PRESENT(viv_row)) THEN + CALL write_deck('wod_bad.dat', rows, 1.0_wp, cl=cl, viv_row=viv_row) + ELSE IF (PRESENT(cl)) THEN + CALL write_deck('wod_bad.dat', rows, 1.0_wp, cl=cl) + ELSE IF (PRESENT(ei)) THEN + CALL write_deck('wod_bad.dat', rows, 1.0_wp, ei=ei) + ELSE IF (PRESENT(mixed)) THEN + CALL write_deck('wod_bad.dat', rows, 1.0_wp, mixed=mixed) + ELSE + CALL write_deck('wod_bad.dat', rows, 1.0_wp) + END IF + CALL run('wod_bad.dat', 'wod_bad', ok, msg) + CALL require(.NOT. ok .AND. INDEX(msg, needle) > 0, 'W4: '//what//' is refused: '//TRIM(msg)) + END SUBROUTINE refused + +END PROGRAM test_viv_wake_deck diff --git a/tests/test_viv_wake_kernel.f90 b/tests/test_viv_wake_kernel.f90 new file mode 100644 index 0000000..c81cac0 --- /dev/null +++ b/tests/test_viv_wake_kernel.f90 @@ -0,0 +1,154 @@ +! File: tests/test_viv_wake_kernel.f90 +! SPDX-License-Identifier: Apache-2.0 +! Copyright (c) 2026 Jae Hoon Seo, SMI Lab, Inha University +PROGRAM test_viv_wake_kernel + !! The wake-oscillator kernel CD_VIV_Wake_Advance (Facchinetti, de Langre and Biolley, J. Fluids + !! Struct. 19, 2004, 123-140) against its published properties, with eps 0.3 and A 12: + !! K1 the free oscillator (no forcing) from q = 0.1 settles on the limit cycle q = 2 cos(om t): + !! amplitude 2 and period 2 pi/om within 1 %; + !! K2 forced at its own frequency by a structure moving as y0 D cos(om t), the lift + !! magnification K, half the first-harmonic amplitude of q, follows the closed form of their + !! Eq. 17, a one-harmonic balance, for y0 = 0.05-0.5; + !! K3 one call over an interval equals the same interval in two calls with the forcing split + !! at its midpoint, and refining the sub-steps converges at fourth order. + USE CableDyn_Precision, ONLY: wp + USE CableDyn_VIV, ONLY: CD_VIV_Wake_Advance, CD_VIV_WAKE_DEFAULT_EPS, CD_VIV_WAKE_DEFAULT_A + IMPLICIT NONE + REAL(wp), PARAMETER :: PI = 3.14159265358979323846_wp + REAL(wp), PARAMETER :: EPS = CD_VIV_WAKE_DEFAULT_EPS, A = CD_VIV_WAKE_DEFAULT_A + REAL(wp), PARAMETER :: D = 0.1_wp, OM = 2.0_wp*PI ! 1 Hz wake frequency + INTEGER :: nfail = 0 + + CALL check_free() + CALL check_forced() + CALL check_steps() + IF (nfail > 0) THEN + WRITE (*, '(A,I0,A)') 'FAIL: ', nfail, ' assertion(s) failed' + ERROR STOP 1 + END IF + WRITE (*, '(A)') 'PASS: wake-oscillator 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_free() + REAL(wp) :: s(2), dt, qmax, t, t_up(2), q_old + INTEGER :: i, n_up + s = [0.1_wp, 0.0_wp] + dt = 0.01_wp + qmax = 0.0_wp + n_up = 0 + t_up = 0.0_wp + DO i = 1, 8000 ! 80 periods + q_old = s(1) + CALL CD_VIV_Wake_Advance(s, OM, EPS, A/D, 0.0_wp, 0.0_wp, dt) + t = REAL(i, wp)*dt + IF (t < 70.0_wp) CYCLE + qmax = MAX(qmax, ABS(s(1))) + ! upward zero crossings, interpolated + IF (q_old < 0.0_wp .AND. s(1) >= 0.0_wp .AND. n_up < 2) THEN + n_up = n_up + 1 + t_up(n_up) = t - dt*s(1)/(s(1) - q_old) + END IF + END DO + WRITE (*, '(A,F9.5,A,F9.5,A)') 'K1: limit-cycle amplitude ', qmax, ', period ', t_up(2) - t_up(1), ' s' + CALL require(ABS(qmax/2.0_wp - 1.0_wp) <= 0.01_wp, 'K1: the free limit cycle has the amplitude 2') + CALL require(n_up == 2 .AND. ABS(t_up(2) - t_up(1) - 1.0_wp) <= 0.01_wp, 'K1: and the wake period') + END SUBROUTINE check_free + + REAL(wp) FUNCTION eq17(y0) RESULT(k) + !! Facchinetti et al. (2004), Eq. 17: K = (X/36)^(1/3) + (4/(3X))^(1/3), + !! X = 9 (A/eps) y0 + sqrt((9 (A/eps) y0)^2 - 48). + REAL(wp), INTENT(IN) :: y0 + REAL(wp) :: x, b + b = 9.0_wp*(A/EPS)*y0 + x = b + SQRT(b*b - 48.0_wp) + k = (x/36.0_wp)**(1.0_wp/3.0_wp) + (4.0_wp/(3.0_wp*x))**(1.0_wp/3.0_wp) + END FUNCTION eq17 + + SUBROUTINE check_forced() + !! Eq. 17 keeps the first harmonic only; the cubic damping term also makes a third harmonic, + !! so the computed K exceeds it by a share that grows with the forcing (about 2 % at + !! y0 = 0.5). The step is converged: halving it changes K by under 1e-4 of itself. + REAL(wp), PARAMETER :: Y0S(5) = [0.05_wp, 0.1_wp, 0.2_wp, 0.3_wp, 0.5_wp] + REAL(wp) :: k_num, k_ref, worst, k_half + INTEGER :: j + worst = 0.0_wp + DO j = 1, SIZE(Y0S) + k_num = forced_k(Y0S(j), 0.005_wp) + k_ref = eq17(Y0S(j)) + worst = MAX(worst, ABS(k_num/k_ref - 1.0_wp)) + WRITE (*, '(A,F5.2,A,F8.4,A,F8.4)') 'K2: y0 ', Y0S(j), ': K ', k_num, ', Eq. 17 ', k_ref + END DO + k_half = forced_k(0.5_wp, 0.0025_wp) + WRITE (*, '(A,ES10.3)') 'K2: change of K at y0 0.5 with half the step: ', ABS(k_half - k_num) + CALL require(worst <= 0.02_wp, 'K2: the forced lift magnification follows Eq. 17 within 2 %') + CALL require(ABS(k_half - k_num) <= 1.0e-4_wp*k_num, 'K2: with a converged step') + END SUBROUTINE check_forced + + REAL(wp) FUNCTION forced_k(y0, dt) RESULT(k) + !! Half the first-harmonic amplitude of q over periods 91-100 of the forcing y0 D cos(om t). + REAL(wp), INTENT(IN) :: y0, dt + REAL(wp) :: s(2), t, c, sn + INTEGER :: i, n, n_keep + n = NINT(100.0_wp/dt) + n_keep = NINT(10.0_wp/dt) + s = [2.0_wp, 0.0_wp] + c = 0.0_wp + sn = 0.0_wp + DO i = 1, n + t = REAL(i - 1, wp)*dt + CALL CD_VIV_Wake_Advance(s, OM, EPS, A/D, -OM*OM*y0*D*COS(OM*t), -OM*OM*y0*D*COS(OM*(t + dt)), dt) + IF (i > n - n_keep) THEN + c = c + s(1)*COS(OM*(t + dt)) + sn = sn + s(1)*SIN(OM*(t + dt)) + END IF + END DO + k = 0.5_wp*(2.0_wp/REAL(n_keep, wp))*SQRT(c*c + sn*sn) + END FUNCTION forced_k + + SUBROUTINE check_steps() + REAL(wp) :: s1(2), s2(2), sc(2), sf(2), h, e1, e2 + h = 0.4_wp + s1 = [1.3_wp, -4.0_wp] + s2 = s1 + CALL CD_VIV_Wake_Advance(s1, OM, EPS, A/D, 0.2_wp, -0.6_wp, h) + CALL CD_VIV_Wake_Advance(s2, OM, EPS, A/D, 0.2_wp, -0.2_wp, 0.5_wp*h) + CALL CD_VIV_Wake_Advance(s2, OM, EPS, A/D, -0.2_wp, -0.6_wp, 0.5_wp*h) + WRITE (*, '(A,ES10.3)') 'K3: one call against two halves: ', MAXVAL(ABS(s1 - s2)) + CALL require(MAXVAL(ABS(s1 - s2)) <= 1.0e-12_wp*MAXVAL(ABS(s1)), 'K3: an interval in two calls is one call') + ! fourth order: calls short enough for one sub-step each (om h/N <= 0.1) set the step; 32 and + ! 64 of them against 1024 + sf = march(1024, h) + e1 = MAXVAL(ABS(march(32, h) - sf)) + e2 = MAXVAL(ABS(march(64, h) - sf)) + WRITE (*, '(A,2ES11.3,A,F7.2)') 'K3: errors with 32 and 64 steps ', e1, e2, ', ratio ', e1/e2 + CALL require(e1 < 1.0e-5_wp*MAXVAL(ABS(sf)), 'K3: the advance is accurate at om dt = 0.08') + CALL require(e1/e2 > 12.0_wp, 'K3: and converges at fourth order (ratio near 16)') + ! the kernel's own sub-steps in one call match the reference as closely + sc = [1.3_wp, -4.0_wp] + CALL CD_VIV_Wake_Advance(sc, OM, EPS, A/D, 0.2_wp, -0.6_wp, h) + CALL require(MAXVAL(ABS(sc - sf)) < 1.0e-5_wp*MAXVAL(ABS(sf)), 'K3: one call sub-steps as finely') + END SUBROUTINE check_steps + + FUNCTION march(n, h) RESULT(x) + !! The K3 interval in n equal calls, the forcing linear from 0.2 to -0.6 over it. + INTEGER, INTENT(IN) :: n + REAL(wp), INTENT(IN) :: h + REAL(wp) :: x(2) + INTEGER :: k + x = [1.3_wp, -4.0_wp] + DO k = 1, n + CALL CD_VIV_Wake_Advance(x, OM, EPS, A/D, 0.2_wp - 0.8_wp*REAL(k - 1, wp)/REAL(n, wp), & + 0.2_wp - 0.8_wp*REAL(k, wp)/REAL(n, wp), h/REAL(n, wp)) + END DO + END FUNCTION march + +END PROGRAM test_viv_wake_kernel From 4941e4ce5d1dda0a95b5f1f638edf956c4dde117 Mon Sep 17 00:00:00 2001 From: Jae Hoon Seo Date: Fri, 13 Nov 2026 11:58:23 +0900 Subject: [PATCH 2/2] fix: wake sub-steps follow the van der Pol damping rate as well CD_VIV_Wake_Advance chose its RK4 sub-steps from om dt <= 0.1 alone. The van der Pol damping eps om (q^2 - 1) is a faster rate for a large eps, which the deck accepts: with eps 20 and om 1 the unforced oscillator from (2, 0) went non-finite within 0.5 s in 0.1 s calls. The sub-steps now satisfy r dt <= 0.1 with r = om max(1, eps q^2) at the start of the interval, and the interval is redone from its start with twice the sub-steps should the rate exceed 0.2/dt on the way or the result not be finite (up to 1e6 sub-steps). For the default eps 0.3 the count is unchanged until |q| > 1.83, so one call still equals two half calls to round-off; every documented wake result is unchanged at its printed digits. tests/test_viv_wake_kernel.f90 K4: eps 20 from (2, 0) in 0.1 s calls stays finite and matches 1 ms calls within 1e-13 at t = 1 s ((1.967, -0.034)). The theory text gives the new rule. Signed-off-by: Jae Hoon Seo --- doc/theory.rst | 7 +++-- src/CableDyn_VIV.f90 | 52 ++++++++++++++++++++++++---------- tests/test_viv_wake_kernel.f90 | 22 +++++++++++++- 3 files changed, 63 insertions(+), 18 deletions(-) diff --git a/doc/theory.rst b/doc/theory.rst index 686cfa3..bda864e 100644 --- a/doc/theory.rst +++ b/doc/theory.rst @@ -1272,8 +1272,11 @@ The wake state :math:`(q, \dot q)` of a node is integrated beside the cable, as synchronisation model is. At the start of a step it is advanced under the step-start acceleration to give the :math:`q` the step's lift takes; at the converged end it is advanced again from the committed state with the acceleration linear between the step's ends, at the -step-start :math:`\omega_f`, and committed. Both use classical Runge-Kutta in sub-steps of -:math:`\omega_f\,\delta t \le 0.1`. The lift is integrated on a finite-EI cable at the Gauss +step-start :math:`\omega_f`, and committed. Both use classical Runge-Kutta in equal sub-steps of +:math:`r\,\delta t \le 0.1`, :math:`r = \omega_f\max(1, \varepsilon q^2)` the faster of the +oscillation and the van der Pol damping rate at the start of the interval, so a large +:math:`\varepsilon` stays resolved; should the rate exceed :math:`0.2/\delta t` on the way, or the +result not be finite, the interval is redone with twice the sub-steps. The lift is integrated on a finite-EI cable at the Gauss points of the synchronisation lift, :math:`q` interpolated between the element's end nodes, with its exact position and velocity derivatives in the tangent at fixed :math:`q`. :math:`q` starts on its limit cycle at the node's phase seed, :math:`q = 2\cos\phi_0`, :math:`\dot q = 0`, and the diff --git a/src/CableDyn_VIV.f90 b/src/CableDyn_VIV.f90 index aad06ed..f2e1189 100644 --- a/src/CableDyn_VIV.f90 +++ b/src/CableDyn_VIV.f90 @@ -454,26 +454,48 @@ PURE SUBROUTINE CD_VIV_Wake_Advance(s, om, eps, ad, f0, f1, h) !! !! s = (q, q'), om the wake frequency 2 pi St U/D, ad = A/D and the cross-flow acceleration !! y'' of the line, taken linear from f0 at the start of the interval to f1 at its end. - !! Classical Runge-Kutta in equal sub-steps of om dt <= 0.1 (at least one), so the error is - !! that of a resolved oscillation however long h is against the wake period. q = 2 C_L/C_L0: - !! the free oscillator settles on its limit cycle q = 2 cos(om t), the lift of a fixed - !! cylinder. + !! Classical Runge-Kutta in equal sub-steps of r dt <= 0.1 (at least one), r = om max(1, + !! eps q^2) the faster of the oscillation and the van der Pol damping rate eps om (q^2 - 1) at + !! the start of the interval, so the error is that of a resolved oscillation however long h is + !! against the wake period and however large eps is. Should the rate at a sub-step exceed + !! 0.2/dt (q grown on the way) or the result not be finite, the interval is redone from its + !! start with twice the sub-steps. q = 2 C_L/C_L0: the free oscillator settles on its limit + !! cycle q = 2 cos(om t), the lift of a fixed cylinder. REAL(wp), INTENT(INOUT) :: s(2) REAL(wp), INTENT(IN) :: om, eps, ad, f0, f1, h - INTEGER :: n, i - REAL(wp) :: dt, t, k1(2), k2(2), k3(2), k4(2) + INTEGER :: n, i, attempt + REAL(wp) :: dt, t, k1(2), k2(2), k3(2), k4(2), s0(2) + LOGICAL :: ok IF (.NOT. (h > CD_ZERO)) RETURN - n = MAX(1, CEILING(MIN(ABS(om)*h/0.1_wp, 1.0e6_wp))) - dt = h/REAL(n, wp) - DO i = 0, n - 1 - t = REAL(i, wp)*dt - k1 = rhs(s, t) - k2 = rhs(s + 0.5_wp*dt*k1, t + 0.5_wp*dt) - k3 = rhs(s + 0.5_wp*dt*k2, t + 0.5_wp*dt) - k4 = rhs(s + dt*k3, t + dt) - s = s + (dt/6.0_wp)*(k1 + 2.0_wp*k2 + 2.0_wp*k3 + k4) + s0 = s + n = MAX(1, CEILING(MIN(rate(s0)*h/0.1_wp, 1.0e6_wp))) + DO attempt = 1, 24 + s = s0 + dt = h/REAL(n, wp) + ok = .TRUE. + DO i = 0, n - 1 + IF (rate(s)*dt > 0.2_wp .AND. n < 1000000) THEN + ok = .FALSE. + EXIT + END IF + t = REAL(i, wp)*dt + k1 = rhs(s, t) + k2 = rhs(s + 0.5_wp*dt*k1, t + 0.5_wp*dt) + k3 = rhs(s + 0.5_wp*dt*k2, t + 0.5_wp*dt) + k4 = rhs(s + dt*k3, t + dt) + s = s + (dt/6.0_wp)*(k1 + 2.0_wp*k2 + 2.0_wp*k3 + k4) + END DO + IF (ok) ok = ABS(s(1)) <= HUGE(s(1)) .AND. ABS(s(2)) <= HUGE(s(2)) + IF (ok .OR. n >= 1000000) EXIT + n = MIN(2*n, 1000000) END DO CONTAINS + PURE REAL(wp) FUNCTION rate(x) RESULT(r) + !! The faster of the oscillation and the damping rate of state x (finite or not). + REAL(wp), INTENT(IN) :: x(2) + r = ABS(om)*MAX(CD_ONE, eps*x(1)*x(1)) + IF (.NOT. (r <= HUGE(r))) r = HUGE(r) + END FUNCTION rate PURE FUNCTION rhs(x, tau) RESULT(d) REAL(wp), INTENT(IN) :: x(2), tau REAL(wp) :: d(2) diff --git a/tests/test_viv_wake_kernel.f90 b/tests/test_viv_wake_kernel.f90 index c81cac0..418c42e 100644 --- a/tests/test_viv_wake_kernel.f90 +++ b/tests/test_viv_wake_kernel.f90 @@ -10,7 +10,9 @@ PROGRAM test_viv_wake_kernel !! magnification K, half the first-harmonic amplitude of q, follows the closed form of their !! Eq. 17, a one-harmonic balance, for y0 = 0.05-0.5; !! K3 one call over an interval equals the same interval in two calls with the forcing split - !! at its midpoint, and refining the sub-steps converges at fourth order. + !! at its midpoint, and refining the sub-steps converges at fourth order; + !! K4 a large eps (20, om 1) from (2, 0), whose damping rate eps om (q^2 - 1) is sixty times the + !! oscillation, stays finite in 0.1 s calls and matches 0.001 s calls within 1e-6 at t = 1. USE CableDyn_Precision, ONLY: wp USE CableDyn_VIV, ONLY: CD_VIV_Wake_Advance, CD_VIV_WAKE_DEFAULT_EPS, CD_VIV_WAKE_DEFAULT_A IMPLICIT NONE @@ -22,6 +24,7 @@ PROGRAM test_viv_wake_kernel CALL check_free() CALL check_forced() CALL check_steps() + CALL check_stiff() IF (nfail > 0) THEN WRITE (*, '(A,I0,A)') 'FAIL: ', nfail, ' assertion(s) failed' ERROR STOP 1 @@ -151,4 +154,21 @@ FUNCTION march(n, h) RESULT(x) END DO END FUNCTION march + SUBROUTINE check_stiff() + !! The sub-steps follow the damping rate as well as the oscillation (eps 20, om 1). + REAL(wp) :: sc(2), sf(2) + INTEGER :: k + sc = [2.0_wp, 0.0_wp] + sf = sc + DO k = 1, 10 + CALL CD_VIV_Wake_Advance(sc, 1.0_wp, 20.0_wp, 0.0_wp, 0.0_wp, 0.0_wp, 0.1_wp) + END DO + DO k = 1, 1000 + CALL CD_VIV_Wake_Advance(sf, 1.0_wp, 20.0_wp, 0.0_wp, 0.0_wp, 0.0_wp, 0.001_wp) + END DO + WRITE (*, '(A,2ES12.4,A,ES10.3)') 'K4: eps 20 at t = 1 s: ', sc, ', against 1 ms calls ', MAXVAL(ABS(sc - sf)) + CALL require(ALL(ABS(sc) < 10.0_wp) .AND. MAXVAL(ABS(sc - sf)) <= 1.0e-6_wp, 'K4: a large eps stays '// & + 'resolved in long calls') + END SUBROUTINE check_stiff + END PROGRAM test_viv_wake_kernel