From 133c1d9e02e96afe1d1f0dc0508e824be0448049 Mon Sep 17 00:00:00 2001 From: Jae Hoon Seo Date: Fri, 13 Nov 2026 11:48:25 +0900 Subject: [PATCH] feat: diameter of the VIV model apart from the hydrodynamic one (VIV DIAMETER section) A lazy-wave cable's buoyancy modules are ATTACHMENTS rows on the bare cable: their mass, volume and drag are point loads, and the cable's line type keeps its own diameter for its drag, added mass and buoyancy. Its VIV then also took that diameter, while the shedding of a module zone is set by the larger module diameter. An optional VIV DIAMETER section row TypeName Dviv gives the VIV model of a line type a diameter of its own: the shedding frequency and band (or the wake frequency and its coupling A/D), the lift, in-line and higher-harmonic forces and the amplitude ratio of a VIV AMPLITUDE table take Dviv, the drag, added mass, buoyancy and contact keep Diam. A module zone is a section with a copy of the cable's type, Dviv the module diameter and its own coefficients; the docs say how, and that the shedding of alternating modules and bare cable has no established model. The type needs VIV (Cl > 0 or a WAKE OSCILLATOR row); one row a type. EI = 0 lines take it through the diameter CD_Set_Model_VIV already has; finite-EI cables through Set_VIV dviv (per element, 0 = the drag diameter, kept across a later Set_Drag), which viv_drag_terms and the amplitude-table helpers read. The Python deck reader mirrors the checks, the builder writes the row (LineType.viv_diameter). Checks: - tests/test_viv_diameter_deck.f90, on the taut gate line as an EI = 0 line and a finite-EI cable: Dviv = Diam is the deck without the section bit for bit; with the synchronisation lift the line locks in at 0.287 Hz, and with Dviv 0.2 m its band (0.075-0.195 Hz) lies below the mode and the phase runs at its top, 0.196 Hz; an uncoupled wake oscillator drives the cable at 0.149 Hz against St U/Dviv = 0.15 Hz; six refusals; - Python: rows read, kept and refused as natively, the builder writes them, six native/Python parity decks agree. Full ctest under both BLAS kernels, Debug -fcheck=all on the VIV tests, pytest, ruff, mypy, Sphinx -W, pre-commit. Signed-off-by: Jae Hoon Seo --- CHANGELOG.md | 5 + CMakeLists.txt | 7 + doc/capabilities.rst | 4 + doc/driver_format.md | 39 +++- doc/theory.rst | 24 +++ python/cabledyn/builder.py | 25 +++ python/cabledyn/deck_file.py | 39 ++++ python/tests/test_builder.py | 13 ++ python/tests/test_deck_file.py | 40 ++++ python/tests/test_end_to_end.py | 31 +++ src/CableDyn_DeckDriver.f90 | 116 +++++++++++- src/CableDyn_HermiteCableDynamic.f90 | 60 +++++- tests/test_viv_diameter_deck.f90 | 270 +++++++++++++++++++++++++++ 13 files changed, 654 insertions(+), 19 deletions(-) create mode 100644 tests/test_viv_diameter_deck.f90 diff --git a/CHANGELOG.md b/CHANGELOG.md index 6ef04ae..e202063 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -50,6 +50,11 @@ All notable changes to CableDyn are recorded in this file. The format follows response inside its falling range, and a table with `Cv = Cl` and `CdAmp = 1` is the line without it, bit for bit. The estimate is in the step-recovery, snapshot and checkpoint state; the Python deck reader and builder take the section. +- VIV diameter: an optional `VIV DIAMETER` section row `TypeName Dviv` gives the VIV model of a + line type (shedding frequency, wake frequency and coupling, VIV forces, amplitude ratio) a + diameter apart from the `Diam` its drag, added mass and buoyancy keep, for buoyancy-module zones + with ATTACHMENTS, on `EI = 0` lines and finite-EI cables, standalone and coupled. `Dviv` equal to + `Diam` is the type without it, bit for bit; 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 1c134af..e1c9893 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1344,6 +1344,13 @@ target_link_libraries(test_viv_amplitude_deck PRIVATE cabledyn_core) add_test(NAME viv_amplitude_deck COMMAND test_viv_amplitude_deck WORKING_DIRECTORY ${CMAKE_BINARY_DIR}) set_tests_properties(viv_amplitude_deck PROPERTIES LABELS "fortran;integration;dynamic;viv" TIMEOUT 1200) +# The diameter of the VIV model on a deck (VIV DIAMETER section), both line kinds: Dviv = Diam as +# no section, the shedding band and the uncoupled wake frequency following Dviv, and the refusals. +add_executable(test_viv_diameter_deck tests/test_viv_diameter_deck.f90) +target_link_libraries(test_viv_diameter_deck PRIVATE cabledyn_core) +add_test(NAME viv_diameter_deck COMMAND test_viv_diameter_deck WORKING_DIRECTORY ${CMAKE_BINARY_DIR}) +set_tests_properties(viv_diameter_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 28b3690..d52124b 100644 --- a/doc/capabilities.rst +++ b/doc/capabilities.rst @@ -161,6 +161,10 @@ Line and constitutive capability factor, read at the amplitude estimate of Thorsen et al. (2016) (``VIVAmp`` channel), on ``EI = 0`` lines and finite-EI cables (:ref:`theory-viv-amplitude`), its state in the checkpoint + * - VIV diameter (``VIV DIAMETER`` section ``Dviv``) + - Standalone and coupled + - a diameter of the VIV model apart from the hydrodynamic one, for buoyancy-module zones and + other sections shedding at a larger outer diameter (:ref:`theory-viv-diameter`) Loads and environment --------------------- diff --git a/doc/driver_format.md b/doc/driver_format.md index 97d81fb..53d5289 100644 --- a/doc/driver_format.md +++ b/doc/driver_format.md @@ -298,8 +298,9 @@ the half-range and centre of its band in non-dimensional frequency (MoorDyn's `d `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; a [WAKE OSCILLATOR](#wake-oscillator-optional) row replaces the -lift by a wake oscillator, and a [VIV AMPLITUDE](#viv-amplitude-optional) table makes `Cl` (and -`Cd`) depend on the cross-flow amplitude. +lift by a wake oscillator, a [VIV AMPLITUDE](#viv-amplitude-optional) table makes `Cl` (and +`Cd`) depend on the cross-flow amplitude, and a [VIV DIAMETER](#viv-diameter-optional) row gives +the VIV a diameter of its own. **Viscoelastic axial stiffness (MoorDyn `ElasticMod`).** The EA and BA columns accept bar-separated parts: @@ -1289,6 +1290,40 @@ Behaviour: (`Cl = 0`, as a wake-oscillator type), holds a value out of range, does not increase in `AD`, or has other columns than the type's earlier rows; a type takes 2 to 32 rows. +### VIV DIAMETER (optional) + +The diameter of the VIV model of a line type, apart from the hydrodynamic diameter `Diam` that +its drag, added mass and buoyancy keep (see [VIV diameter](theory.rst)). + +```text +--------------------- VIV DIAMETER ------------------------------------- +TypeName Dviv +(-) (m) +zone 0.9 +``` + +| Column | Meaning | +|--------|---------| +| `TypeName` | an existing LINE TYPES name (case-insensitive) with VIV (`Cl > 0`, or a WAKE OSCILLATOR row), at most one row each | +| `Dviv` | diameter > 0 of its VIV model [m], at most 1e15 | + +Behaviour: + +- The VIV of the type takes `Dviv` wherever it takes the diameter: the shedding frequency + `cF U/Dviv` and its band (or the wake frequency `2 pi St U/Dviv` and the coupling `A/Dviv`), the + lift, in-line and higher-harmonic forces `1/2 rho Dviv C U^2`, and the amplitude ratio of a + [VIV AMPLITUDE](#viv-amplitude-optional) table. The drag, added mass, buoyancy and seabed + contact keep `Diam`; so do the stiffener and attachment loads. +- A buoyancy-module zone of a cable whose modules are ATTACHMENTS rows can be given its own VIV: + split the line into SECTIONS at the zone, give the zone a copy of the cable's line type with + `Dviv` the module diameter and its own `Cl`, `dF` and `cF` (or `Cl 0` for no VIV there), and + keep the modules' mass, volume and drag in ATTACHMENTS. CableDyn models no shedding + interaction between modules and bare cable; the coefficients of such a zone are the user's + choice. +- A row with `Dviv` equal to `Diam` runs as the type without it. It acts on `EI = 0` lines and + finite-EI cables, standalone and coupled. A row fails if it is not `TypeName Dviv`, names an + undefined or already named type or one without VIV, or holds a value out of range. + ### FAILURE (optional, EI = 0 decks) A FAILURE row detaches line ends from a point during a dynamic run, with MoorDyn's trigger rules. diff --git a/doc/theory.rst b/doc/theory.rst index cff755e..d3c0961 100644 --- a/doc/theory.rst +++ b/doc/theory.rst @@ -1336,6 +1336,30 @@ at 0.3 holds the response at A/D 0.28; :math:`C_v = 0` with a drag factor 2 sett offset of ``Cd`` 2.4 to six digits; and a table with :math:`C_v` = ``Cl`` and factor 1 is the line without it, bit for bit. +.. _theory-viv-diameter: + +VIV diameter +~~~~~~~~~~~~ + +A ``VIV DIAMETER`` row gives the VIV model of a line type a diameter :math:`D_v` of its own. The +shedding frequency :math:`2\pi(c_F + d_F\sin(\phi_y - \phi))U/D_v` (or the wake frequency +:math:`2\pi\,\mathrm{St}\,U_a/D_v` with the coupling :math:`A/D_v`), the VIV forces +:math:`\tfrac12\rho D_v C U^2` and the amplitude ratio :math:`y_0^*/D_v` of a ``VIV AMPLITUDE`` +table take it, while the drag, added mass, buoyancy and contact keep the type's ``Diam``. It +serves a section whose shedding is set by a larger outer diameter than its hydrodynamic one, as a +buoyancy-module zone whose modules are ATTACHMENTS on the bare cable: a copy of the cable's type +with :math:`D_v` the module diameter and its own synchronisation coefficients. The shedding of +such a zone, where modules and bare cable alternate, has no established model; :math:`D_v` and +the coefficients are the user's. + +On the taut line of the wake-oscillator gate (``Diam`` 0.1 m) the synchronisation model locks in +near the first mode, at 0.287 Hz; with :math:`D_v` = 0.2 m its band, +0.075-0.195 Hz, lies below the mode, where the motion lags the lift by less than a quarter period +and the phase runs at the top of the band, 0.196 Hz, on ``EI = 0`` lines and finite-EI cables +alike; an uncoupled wake oscillator (:math:`A` = 0) drives the cable at 0.149 Hz against +:math:`\mathrm{St}\,U/D_v` = 0.15 Hz; and :math:`D_v` equal to ``Diam`` is the line without the row, +bit for bit. + .. _theory-dry-buoyancy: Buoyancy and wetting diff --git a/python/cabledyn/builder.py b/python/cabledyn/builder.py index 518a3fa..bc61f0d 100644 --- a/python/cabledyn/builder.py +++ b/python/cabledyn/builder.py @@ -236,6 +236,11 @@ class LineType: length, 2 to 32 of them in increasing amplitude ratio ``AD``: ``Cv`` replaces ``cl`` at that amplitude (so ``cl`` must be set) and ``CdAmp`` multiplies the normal drag coefficient ``cdn`` (1 when left out). + viv_diameter : float | None + Optional diameter of the type's VIV model, a ``VIV DIAMETER`` section row + ``Name Dviv``: the shedding frequency, the VIV forces and the amplitude + ratio take it in place of ``diam`` (which the drag, added mass and + buoyancy keep); it needs ``cl`` or ``wake_cl0``. """ name: str @@ -263,6 +268,7 @@ class LineType: wake_eps: float | None = None wake_a: float | None = None viv_amplitude: list[tuple[float, ...]] | None = None + viv_diameter: float | None = None @dataclass(eq=False) @@ -1687,6 +1693,7 @@ def add_line_type( wake_eps: float | None = None, wake_a: float | None = None, viv_amplitude: list[tuple[float, ...]] | None = None, + viv_diameter: float | None = None, ) -> LineType: """Add a ``LINE TYPES`` row; see :class:`LineType` for the fields. @@ -1728,6 +1735,7 @@ def add_line_type( wake_eps, wake_a, None if viv_amplitude is None else [tuple(row) for row in viv_amplitude], + viv_diameter, ) self._line_types.append(item) return item @@ -2621,6 +2629,7 @@ def to_text(self, *, validate: bool = True) -> str: _emit(out, "VIV", *self._viv_table()) _emit(out, "WAKE OSCILLATOR", *self._wake_table()) _emit(out, "VIV AMPLITUDE", *self._viv_amp_table()) + _emit(out, "VIV DIAMETER", *self._viv_diam_table()) _emit(out, "FAILURE", *self._failure_table()) _emit(out, "CONTROL", *self._control_table()) _emit(out, "EXTERNAL LOADS", *self._external_load_table()) @@ -3041,6 +3050,19 @@ def _viv_amp_table(self) -> tuple[str, str, list[list[str]]]: rows.append([_text(item.name, what), *(_num(value, what) for value in row)]) return "Name AD Cv CdAmp", "(-) (-) (-) (-)", rows + def _viv_diam_table(self) -> tuple[str, str, list[list[str]]]: + rows: list[list[str]] = [] + for item in self._line_types: + if item.viv_diameter is None: + continue + what = f"line type {item.name!r}" + if item.cl is None and item.wake_cl0 is None: + raise ValueError( + f"{what}: viv_diameter is the diameter of its VIV, set cl or wake_cl0" + ) + rows.append([_text(item.name, what), _num(item.viv_diameter, what)]) + return "Name Dviv", "(-) (m)", 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")] @@ -3258,6 +3280,9 @@ def load(self) -> None: if item.viv_amplitude is None: item.viv_amplitude = [] item.viv_amplitude.append(tuple(_f(token) for token in t[1:])) + for row in self.rows("VIV DIAMETER"): + t = row.tokens + model.line_types[t[0]].viv_diameter = _f(t[1]) 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 292cd91..b01fe0f 100644 --- a/python/cabledyn/deck_file.py +++ b/python/cabledyn/deck_file.py @@ -84,6 +84,8 @@ "WAKE": "WAKE OSCILLATOR", "VIV AMPLITUDE": "VIV AMPLITUDE", "VIV AMPLITUDES": "VIV AMPLITUDE", + "VIV DIAMETER": "VIV DIAMETER", + "VIV DIAMETERS": "VIV DIAMETER", } # Table sections whose rows the native reader takes through a Fortran # list-directed READ. Their descriptive and units rows are recognized by the @@ -115,6 +117,7 @@ "VIV", "WAKE OSCILLATOR", "VIV AMPLITUDE", + "VIV DIAMETER", } ) _TABLE_SECTIONS = _LIST_DIRECTED_SECTIONS | _WHITESPACE_TABLE_SECTIONS @@ -3344,6 +3347,41 @@ def _check_wake_section(self, lift_type_names: set[str]) -> set[str]: wake.add(name) return wake + def _check_viv_diam_section(self, viv_type_names: set[str]) -> None: + """Native ``apply_type_viv_diam`` for the VIV DIAMETER section. + + A row ``TypeName Dviv`` sets the diameter of a line type's VIV model, ``Dviv > 0`` (at + most 1e15). The type needs VIV (LINE TYPES ``Cl > 0`` or a WAKE OSCILLATOR row with + ``CL0 > 0``); a type takes one row. + """ + types = {row.tokens[0].lower(): row.tokens[0] for row in self.line_types} + named: set[str] = set() + for row in self._rows("VIV DIAMETER"): + where = self._at(row) + if len(row.tokens) != 2: + raise DeckFormatError(f"{where}: VIV DIAMETER rows must be: TypeName Dviv") + name = row.tokens[0].lower() + if name not in types: + raise DeckFormatError( + f'{where}: VIV DIAMETER row names undefined LINE TYPE "{row.tokens[0]}"' + ) + if name in named: + raise DeckFormatError( + f'{where}: VIV DIAMETER names LINE TYPE "{types[name]}" twice' + ) + named.add(name) + try: + value = _native_float(row.tokens[1]) + except ValueError as exc: + raise DeckFormatError(f"{where}: VIV DIAMETER Dviv must be a plain number") from exc + if not (math.isfinite(value) and 0.0 < value <= _NATIVE_MAX_COEFFICIENT): + raise DeckFormatError(f"{where}: VIV DIAMETER needs Dviv > 0, at most 1e15") + if name not in viv_type_names: + raise DeckFormatError( + f'{where}: VIV DIAMETER of LINE TYPE "{types[name]}" sets the diameter of its ' + "VIV: give the type LINE TYPES Cl > 0 or a WAKE OSCILLATOR row" + ) + def _check_viv_amp_section(self, lift_type_names: set[str]) -> set[str]: """Native ``apply_type_viv_amp`` for the VIV AMPLITUDE section; the types with a table. @@ -4598,6 +4636,7 @@ def end_key(token: str) -> str: self._check_viv_section(line_type_meta, viv_type_names) wake_type_names = self._check_wake_section(viv_type_names) amp_type_names = self._check_viv_amp_section(viv_type_names) + self._check_viv_diam_section(viv_type_names | wake_type_names) amp_lines = { line_id for line_id, section_types in section_types_by_line.items() diff --git a/python/tests/test_builder.py b/python/tests/test_builder.py index c46fb84..520d3be 100644 --- a/python/tests/test_builder.py +++ b/python/tests/test_builder.py @@ -281,6 +281,19 @@ def test_viv_amplitude_rows_are_written_with_the_values_given(tmp_path: Path) -> model.to_text(validate=False) +def test_viv_diameter_rows_are_written(tmp_path: Path) -> None: + model = _chain_model(tmp_path) + model.add_line_type( + "zone", diam=0.1, mass=10.0, ea=5.0e7, cdn=1.2, can=1.0, cl=0.4, viv_diameter=0.9 + ) + deck = DeckFile.from_text(model.to_text(validate=False), path=tmp_path / "deck.dat") + rows = [row.tokens for row in deck._rows("VIV DIAMETER")] + assert rows == [("zone", "0.9")] + model.add_line_type("plain", diam=0.1, mass=10.0, ea=5.0e7, viv_diameter=0.9) + with pytest.raises(ValueError, match="set cl or 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 346b105..b0d2bfd 100644 --- a/python/tests/test_deck_file.py +++ b/python/tests/test_deck_file.py @@ -4951,6 +4951,46 @@ def test_viv_amplitude_rows_follow_the_native_checks(lift, rows, message): DeckFile.from_text(_with_section(text, "VIV AMPLITUDE", *rows)) +def test_viv_diameter_rows_are_read_and_kept(tmp_path): + from cabledyn import DeckModel + + text = _with_section( + _edit(_DYNAMIC, (_LIFT_ROW, _LIFT_ROW + " 0.8")), + "VIV DIAMETER", + "TypeName Dviv", + "chain 0.9", + ) + DeckFile.from_text(text) + path = tmp_path / "dia.dat" + path.write_text(text, encoding="utf-8") + assert DeckModel.load(path).line_types["chain"].viv_diameter == 0.9 + saved = tmp_path / "saved.dat" + DeckModel.load(path).save(saved) + assert DeckModel.load(saved).line_types["chain"].viv_diameter == 0.9 + + +@pytest.mark.parametrize( + "lift, rows, message", + [ + (True, ("chain 0.9 1.0",), "rows must be: TypeName Dviv"), + (True, ("cable 0.9",), 'undefined LINE TYPE "cable"'), + (True, ("chain 0.9", "chain 0.8"), 'names LINE TYPE "chain" twice'), + (True, ("chain 0.0",), "Dviv > 0, at most 1e15"), + (True, ("chain -0.9",), "Dviv > 0, at most 1e15"), + (False, ("chain 0.9",), "give the type LINE TYPES Cl > 0 or a WAKE OSCILLATOR row"), + ], +) +def test_viv_diameter_rows_follow_the_native_checks(lift, rows, message): + text = _edit(_DYNAMIC, (_LIFT_ROW, _LIFT_ROW + " 0.8")) if lift else _DYNAMIC + with pytest.raises(DeckFormatError, match=re.escape(message)): + DeckFile.from_text(_with_section(text, "VIV DIAMETER", *rows)) + + +def test_viv_diameter_takes_a_wake_oscillator_type(): + text = _with_section(_DYNAMIC, "WAKE OSCILLATOR", "chain 0.3") + DeckFile.from_text(_with_section(text, "VIV DIAMETER", "chain 0.9")) + + def test_viv_amplitude_channel_needs_a_table(): text = _edit(_DYNAMIC, (_LIFT_ROW, _LIFT_ROW + " 0.8")) text = _edit(text, ("FairTen1\n", "FairTen1\nVIVAmp1N2\n")) diff --git a/python/tests/test_end_to_end.py b/python/tests/test_end_to_end.py index 5ed655d..bc9f518 100644 --- a/python/tests/test_end_to_end.py +++ b/python/tests/test_end_to_end.py @@ -314,6 +314,37 @@ def _amp_table(*rows: str) -> tuple[str, str]: ] +def _dia_rows(*rows: str) -> tuple[str, str]: + """The edit that puts a VIV DIAMETER section with ``rows`` before OPTIONS.""" + block = "--------------------- VIV DIAMETER -----\n" + "".join(f"{row}\n" for row in rows) + return _AMP_OPTIONS, block + _AMP_OPTIONS + + +_DIA_PARITY = [ + ("dia-accepted", [_dia_rows("riser 0.3")], True), + ("dia-zero", [_dia_rows("riser 0.0")], False), + ("dia-repeated", [_dia_rows("riser 0.3", "riser 0.2")], False), + ("dia-three-columns", [_dia_rows("riser 0.3 1.0")], False), + ( + "dia-wake-type", + [ + _WAKE_LIFT, + _WAKE_SECTION, + ("riser 0.85 0.15", "riser 0.3"), + _dia_rows("riser 0.3"), + ], + True, + ), + ( + "dia-no-viv", + [_WAKE_LIFT, ("riser 0.85 0.15", ""), _dia_rows("riser 0.3")], + False, + ), +] + +_AMP_PARITY += _DIA_PARITY + + @pytest.mark.parametrize( ("label", "edits", "accepted"), _AMP_PARITY, ids=[item[0] for item in _AMP_PARITY] ) diff --git a/src/CableDyn_DeckDriver.f90 b/src/CableDyn_DeckDriver.f90 index fa58aca..22053d3 100644 --- a/src/CableDyn_DeckDriver.f90 +++ b/src/CableDyn_DeckDriver.f90 @@ -467,6 +467,10 @@ MODULE CableDyn_DeckDriver ! token count of the type's rows (3 or 4, the drag factor 1 with 3). INTEGER :: amp_n = 0, amp_cols = 0 REAL(wp) :: amp_tab(3, CD_VIV_AMP_MAXP) = CD_ZERO + ! The diameter of the VIV model (the optional VIV DIAMETER section, a row per type: TypeName + ! Dviv): 0 takes the type's Diam; has_vivd_row marks a type the section names. + REAL(wp) :: viv_dv = CD_ZERO + LOGICAL :: has_vivd_row = .FALSE. ! Deck file line of the row (0 when not read from a file), for error messages. INTEGER :: deck_line = 0 END TYPE @@ -1900,7 +1904,7 @@ RECURSIVE SUBROUTINE build_one_hermite_cable(ln, sections, types, points, opts, REAL(wp), ALLOCATABLE :: q_sequence(:) REAL(wp), ALLOCATABLE :: curv(:), cdn(:), cdt(:), can(:), cat(:), catenary_pos(:) REAL(wp), ALLOCATABLE :: viv_cl(:), viv_cf(:), viv_df(:), viv_clx(:), viv_al(:), viv_hh(:) - REAL(wp), ALLOCATABLE :: viv_tix(:), viv_amp3(:, :, :) + REAL(wp), ALLOCATABLE :: viv_tix(:), viv_amp3(:, :, :), viv_dva(:) INTEGER, ALLOCATABLE :: viv_ampn(:) REAL(wp), ALLOCATABLE :: wo_cl0(:), wo_st(:), wo_eps(:), wo_a(:) REAL(wp), ALLOCATABLE :: ba_raw(:), ba(:), dry_b(:), bb_el(:) @@ -3305,8 +3309,11 @@ RECURSIVE SUBROUTINE build_one_hermite_cable(ln, sections, types, points, opts, CALL finite_wake_arrays(ln, sections, types, wo_cl0, wo_st, wo_eps, wo_a) ALLOCATE (viv_tix(SIZE(l0))) CALL viv_amp_type_index(ln, sections, types, viv_tix) + ALLOCATE (viv_dva(SIZE(l0))) + CALL finite_viv_diameters(ln, sections, types, viv_dva) IF (SIZE(l0_am) /= SIZE(l0)) THEN CALL remap_elem_by_reference_arc(viv_tix, l0, l0_am) + CALL remap_elem_by_reference_arc(viv_dva, l0, l0_am) CALL remap_elem_by_reference_arc(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) @@ -3644,20 +3651,22 @@ RECURSIVE SUBROUTINE build_one_hermite_cable(ln, sections, types, points, opts, REAL(CD_VIV_NM, wp)*MERGE(opts%dtM, dt, opts%has_dtm), & opts%viv_rms_window > CD_ZERO), es, em, phase_seed=seed, & tangent_reversed=.NOT. ln%ends_swapped, & - wake=RESHAPE([wo_st, wo_eps, wo_a], [3, SIZE(wo_st)], ORDER=[2, 1])) + wake=RESHAPE([wo_st, wo_eps, wo_a], [3, SIZE(wo_st)], ORDER=[2, 1]), & + dviv=viv_dva) 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), & opts%viv_rms_window > CD_ZERO), es, em, phase_seed=seed, & tangent_reversed=.NOT. ln%ends_swapped, clx=viv_clx, il_alpha=viv_al, & - chh=viv_hh, amp=viv_amp3, amp_n=viv_ampn) + chh=viv_hh, amp=viv_amp3, amp_n=viv_ampn, dviv=viv_dva) ELSE CALL CD_HermiteCable_Dyn_Set_VIV(cable%line, viv_cl, viv_cf, viv_df, & MERGE(opts%viv_rms_window, & REAL(CD_VIV_NM, wp)*MERGE(opts%dtM, dt, opts%has_dtm), & opts%viv_rms_window > CD_ZERO), es, em, phase_seed=seed, & - tangent_reversed=.NOT. ln%ends_swapped, amp=viv_amp3, amp_n=viv_ampn) + tangent_reversed=.NOT. ln%ends_swapped, amp=viv_amp3, amp_n=viv_ampn, & + dviv=viv_dva) END IF END BLOCK IF (es /= CD_HCDYN_OK) THEN @@ -10415,7 +10424,7 @@ RECURSIVE SUBROUTINE init_one_model(ln, sections, types, points, opts, model, Er REAL(wp), ALLOCATABLE :: hydro_diam(:), hydro_cdn(:), hydro_cdt(:), hydro_can(:), hydro_cat(:) REAL(wp), ALLOCATABLE :: ve_ead(:), ve_bas(:), ve_bad(:), ve_ambl(:), ve_vbet(:) REAL(wp), ALLOCATABLE :: viv_cl(:), viv_cf(:), viv_df(:), viv_clx(:), viv_al(:), viv_hh(:) - REAL(wp), ALLOCATABLE :: viv_tix(:), viv_amp3(:, :, :) + REAL(wp), ALLOCATABLE :: viv_tix(:), viv_amp3(:, :, :), viv_dia(:) INTEGER, ALLOCATABLE :: viv_ampn(:) LOGICAL, ALLOCATABLE :: syr_el(:) REAL(wp) :: anchor(3), fairlead(3), mode1_omega @@ -10456,8 +10465,9 @@ RECURSIVE SUBROUTINE init_one_model(ln, sections, types, points, opts, model, Er hydro_can(SIZE(l0)), hydro_cat(SIZE(l0)), ve_ead(SIZE(l0)), ve_bas(SIZE(l0)), & ve_bad(SIZE(l0)), ve_ambl(SIZE(l0)), ve_vbet(SIZE(l0)), viv_cl(SIZE(l0)), viv_cf(SIZE(l0)), & viv_df(SIZE(l0)), syr_el(SIZE(l0)), viv_clx(SIZE(l0)), viv_al(SIZE(l0)), viv_hh(SIZE(l0)), & - viv_tix(SIZE(l0))) + viv_tix(SIZE(l0)), viv_dia(SIZE(l0))) viv_tix = CD_ZERO + viv_dia = CD_ZERO viv_cl = CD_ZERO viv_cf = CD_ZERO viv_df = CD_ZERO @@ -10531,6 +10541,9 @@ RECURSIVE SUBROUTINE init_one_model(ln, sections, types, points, opts, model, Er viv_hh(e) = types(line_section_type(sections, ln%id, i))%chh IF (types(line_section_type(sections, ln%id, i))%amp_n > 0) viv_tix(e) = REAL(line_section_type(sections, & ln%id, i), wp) + ! the VIV DIAMETER of the type, else its Diam + viv_dia(e) = MERGE(types(line_section_type(sections, ln%id, i))%viv_dv, hydro_diam(e), & + types(line_section_type(sections, ln%id, i))%viv_dv > CD_ZERO) syr_el(e) = types(line_section_type(sections, ln%id, i))%is_syrope END DO END DO @@ -10542,6 +10555,7 @@ RECURSIVE SUBROUTINE init_one_model(ln, sections, types, points, opts, model, Er viv_al = viv_al(SIZE(viv_al):1:-1) viv_hh = viv_hh(SIZE(viv_hh):1:-1) viv_tix = viv_tix(SIZE(viv_tix):1:-1) + viv_dia = viv_dia(SIZE(viv_dia):1:-1) ba = ba(SIZE(ba):1:-1) ve_ead = ve_ead(SIZE(ve_ead):1:-1) ve_bas = ve_bas(SIZE(ve_bas):1:-1) @@ -10835,11 +10849,11 @@ RECURSIVE SUBROUTINE init_one_model(ln, sections, types, points, opts, model, Er CALL viv_amp_tables(types, viv_tix, viv_amp3, viv_ampn) ! with the in-line VIV of the VIV section where a type has ClX > 0 IF (ANY(viv_clx > CD_ZERO)) THEN - CALL CD_Set_Model_VIV(model, opts%rhoW, viv_cl, hydro_diam, viv_cf, viv_df, tw, es, em, & + CALL CD_Set_Model_VIV(model, opts%rhoW, viv_cl, viv_dia, viv_cf, viv_df, tw, es, em, & phase_seed=seed, tangent_reversed=.NOT. ln%ends_swapped, clx=viv_clx, & il_alpha=viv_al, chh=viv_hh, amp=viv_amp3, amp_n=viv_ampn) ELSE - CALL CD_Set_Model_VIV(model, opts%rhoW, viv_cl, hydro_diam, viv_cf, viv_df, tw, es, em, & + CALL CD_Set_Model_VIV(model, opts%rhoW, viv_cl, viv_dia, viv_cf, viv_df, tw, es, em, & phase_seed=seed, tangent_reversed=.NOT. ln%ends_swapped, amp=viv_amp3, & amp_n=viv_ampn) END IF @@ -11730,6 +11744,25 @@ SUBROUTINE viv_amp_type_index(ln, sections, types, tix) tix = tix(SIZE(tix):1:-1) END SUBROUTINE viv_amp_type_index + SUBROUTINE finite_viv_diameters(ln, sections, types, dv) + !! The VIV DIAMETER of every element's line type (0 where the type has none, the drag diameter + !! then), in the element order of finite_hydro_arrays (the deck order reversed). + TYPE(DeckLine), INTENT(IN) :: ln + TYPE(DeckSection), INTENT(IN) :: sections(:) + TYPE(DeckLineType), INTENT(IN) :: types(:) + REAL(wp), INTENT(OUT) :: dv(:) + INTEGER :: i, j, e + e = 0 + DO i = 1, SIZE(sections) + IF (sections(i)%line_id /= ln%id) CYCLE + DO j = 1, sections(i)%nsegs + e = e + 1 + dv(e) = types(sections(i)%ltype)%viv_dv + END DO + END DO + dv = dv(SIZE(dv):1:-1) + END SUBROUTINE finite_viv_diameters + SUBROUTINE viv_amp_tables(types, tix, amp, ampn) !! Allocate and fill the per-element amplitude tables (CD_Set_Model_VIV and !! CD_HermiteCable_Dyn_Set_VIV amp, amp_n) from the element type indices of @@ -13886,6 +13919,9 @@ SUBROUTINE parse_deck(path, types, bodies, rod_types, rods, points, lines, secti CHARACTER(DECK_RECLEN), ALLOCATABLE :: vamp_rows(:) INTEGER, ALLOCATABLE :: vamp_lines(:) INTEGER :: n_vamp + CHARACTER(DECK_RECLEN), ALLOCATABLE :: vdia_rows(:) + INTEGER, ALLOCATABLE :: vdia_lines(:) + INTEGER :: n_vdia 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 @@ -13903,7 +13939,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_WAKE = 20, SEC_VIVAMP = 21 + SEC_STIFF = 18, SEC_VIV = 19, SEC_WAKE = 20, SEC_VIVAMP = 21, SEC_VIVDIA = 22 ErrStat = 0; ErrMsg = '' ext_march = .FALSE. @@ -13930,6 +13966,8 @@ SUBROUTINE parse_deck(path, types, bodies, rod_types, rods, points, lines, secti ALLOCATE (wake_rows(0), wake_lines(0)) ALLOCATE (vamp_rows(0), vamp_lines(0)) n_vamp = 0 + ALLOCATE (vdia_rows(0), vdia_lines(0)) + n_vdia = 0 n_wake = 0 nt = 0; nb = 0; nrt = 0; nr = 0; np = 0; nlin = 0; nsec = 0; neq = 0; nch = 0; nfl = 0; nct = 0; nec = 0 section = SEC_NONE @@ -14083,6 +14121,15 @@ SUBROUTINE parse_deck(path, types, bodies, rod_types, rods, points, lines, secti END IF vamp_rows(n_vamp) = line(1:MIN(LEN(line), DECK_RECLEN)) vamp_lines(n_vamp) = lineno + CASE (SEC_VIVDIA) + IF (.NOT. has_numeric_token(line)) CYCLE + n_vdia = n_vdia + 1 + IF (n_vdia > SIZE(vdia_rows)) THEN + vdia_rows = [vdia_rows, [(REPEAT(' ', DECK_RECLEN), i_ch=1, 8)]] + vdia_lines = [vdia_lines, [(0, i_ch=1, 8)]] + END IF + vdia_rows(n_vdia) = line(1:MIN(LEN(line), DECK_RECLEN)) + vdia_lines(n_vdia) = lineno CASE (SEC_OPTIONS) CALL apply_option(line, opts, ErrStat, ErrMsg) CASE (SEC_OUTPUTS) @@ -14201,6 +14248,13 @@ SUBROUTINE parse_deck(path, types, bodies, rod_types, rods, points, lines, secti RETURN END IF END DO + DO i_ch = 1, n_vdia + CALL apply_type_viv_diam(vdia_rows(i_ch), types, ErrStat, ErrMsg) + IF (ErrStat /= 0) THEN + CALL add_row_context('deck', vdia_lines(i_ch), vdia_rows(i_ch), ErrMsg) + RETURN + END IF + END DO DO i_ch = 1, SIZE(types) IF (types(i_ch)%amp_n == 1) THEN CALL fail(ErrStat, ErrMsg, 'VIV AMPLITUDE gives LINE TYPE "'//TRIM(types(i_ch)%name)//'" one row: a '// & @@ -15877,6 +15931,8 @@ SUBROUTINE set_section(secname, section, ErrStat, ErrMsg) section = 19 CASE ('VIV AMPLITUDE', 'VIV AMPLITUDES') section = 21 + CASE ('VIV DIAMETER', 'VIV DIAMETERS') + section = 22 CASE ('WAKE OSCILLATOR', 'WAKE OSCILLATORS', 'WAKE') section = 20 CASE DEFAULT @@ -17606,6 +17662,48 @@ SUBROUTINE apply_type_viv_amp(row, types, ErrStat, ErrMsg) types(it)%amp_tab(:, n + 1) = v END SUBROUTINE apply_type_viv_amp + SUBROUTINE apply_type_viv_diam(row, types, ErrStat, ErrMsg) + !! One VIV DIAMETER row: TypeName Dviv -- the diameter of a line type's VIV model, Dviv > 0 (at + !! most 1e15), which the shedding frequency, the lift and in-line forces and the amplitude ratio + !! take in place of the type's Diam (which the drag, added mass and buoyancy keep). The type + !! needs VIV (LINE TYPES Cl > 0, or a WAKE OSCILLATOR row). 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 + REAL(wp) :: v + LOGICAL :: found, ok + + ErrStat = 0; ErrMsg = '' + IF (count_tokens(row) /= 2) THEN + CALL fail(ErrStat, ErrMsg, 'VIV DIAMETER rows must be: TypeName Dviv'); RETURN + END IF + CALL get_token(row, 1, tok, found) + it = find_type(types, TRIM(tok)) + IF (it == 0) THEN + CALL fail(ErrStat, ErrMsg, 'VIV DIAMETER row names undefined LINE TYPE "'//TRIM(tok)//'"'); RETURN + END IF + IF (types(it)%has_vivd_row) THEN + CALL fail(ErrStat, ErrMsg, 'VIV DIAMETER names LINE TYPE "'//TRIM(types(it)%name)//'" twice'); RETURN + END IF + CALL get_token(row, 2, tok, found) + CALL parse_real_token(tok, v, ok) + IF (.NOT. ok) THEN + CALL fail(ErrStat, ErrMsg, 'VIV DIAMETER Dviv must be a plain number'); RETURN + END IF + IF (.NOT. (IEEE_IS_FINITE(v) .AND. v > CD_ZERO .AND. v <= MAX_COEFFICIENT)) THEN + CALL fail(ErrStat, ErrMsg, 'VIV DIAMETER needs Dviv > 0, at most 1e15'); RETURN + END IF + IF (.NOT. (types(it)%cl > CD_ZERO .OR. types(it)%wo_cl0 > CD_ZERO)) THEN + CALL fail(ErrStat, ErrMsg, 'VIV DIAMETER of LINE TYPE "'//TRIM(types(it)%name)//'" sets the diameter '// & + 'of its VIV: give the type LINE TYPES Cl > 0 or a WAKE OSCILLATOR row'); RETURN + END IF + types(it)%viv_dv = v + types(it)%has_vivd_row = .TRUE. + END SUBROUTINE apply_type_viv_diam + 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 23e309c..8ebf5cc 100644 --- a/src/CableDyn_HermiteCableDynamic.f90 +++ b/src/CableDyn_HermiteCableDynamic.f90 @@ -365,6 +365,10 @@ MODULE CableDyn_HermiteCableDynamic LOGICAL :: has_viv_amp = .FALSE. REAL(wp), ALLOCATABLE :: viv_amp(:, :, :) INTEGER, ALLOCATABLE :: viv_amp_n(:) + ! The diameter of the VIV model per element (Set_VIV dviv; VIV DIAMETER section): the shedding + ! frequency, lift scale and amplitude ratio take viv_dv(e) where it is positive, the drag + ! diameter diam(e) elsewhere and when it is unallocated (viv_diam). + REAL(wp), ALLOCATABLE :: viv_dv(:) REAL(wp), ALLOCATABLE :: Mgb(:, :) ! constant global mass (band) LOGICAL, ALLOCATABLE :: freemask(:), solve_mask(:) INTEGER, ALLOCATABLE :: fmap(:) ! free -> global DOF index @@ -1123,7 +1127,7 @@ SUBROUTINE CD_HermiteCable_Dyn_Set_Friction_Axial(model, mu_axial, ErrStat, ErrM END SUBROUTINE CD_HermiteCable_Dyn_Set_Friction_Axial SUBROUTINE CD_HermiteCable_Dyn_Set_VIV(model, cl, cf, df, t_window, ErrStat, ErrMsg, phase_seed, tangent_reversed, & - clx, il_alpha, chh, wake, amp, amp_n) + clx, il_alpha, chh, wake, amp, amp_n, dviv) !! 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 @@ -1159,6 +1163,10 @@ SUBROUTINE CD_HermiteCable_Dyn_Set_VIV(model, cl, cf, df, t_window, ErrStat, Err !! C_v >= 0 that replaces cl, and the factor > 0 of the element's normal drag coefficient, at !! the smoothed amplitude estimate of Thorsen et al. (2016); piecewise linear, held beyond the !! end rows. + !! + !! dviv (optional), per element, the diameter of the VIV model (> 0), which the shedding + !! frequency, the lift and in-line scales and the amplitude ratio take in place of the drag + !! diameter (0: the drag diameter, also after a later Set_Drag). TYPE(CD_HermiteCableDynType), INTENT(INOUT) :: model REAL(wp), INTENT(IN) :: cl(:), cf(:), df(:), t_window INTEGER, INTENT(OUT) :: ErrStat @@ -1172,11 +1180,13 @@ SUBROUTINE CD_HermiteCable_Dyn_Set_VIV(model, cl, cf, df, t_window, ErrStat, Err REAL(wp), INTENT(IN), OPTIONAL :: wake(:, :) REAL(wp), INTENT(IN), OPTIONAL :: amp(:, :, :) INTEGER, INTENT(IN), OPTIONAL :: amp_n(:) + REAL(wp), INTENT(IN), OPTIONAL :: dviv(:) INTEGER :: e, k, ne, nn, es, nms REAL(wp) :: wsum, tw_old, rest_old LOGICAL :: had_viv, had_il, want_il, had_wake, want_wake, bad_band, had_amp, want_amp CHARACTER(LEN=1024) :: em REAL(wp), ALLOCATABLE :: p_amp(:, :, :) + REAL(wp), ALLOCATABLE :: p_dv(:) INTEGER, ALLOCATABLE :: p_ampn(:) REAL(wp), ALLOCATABLE :: a_old(:), o_cl(:), o_k(:), o_cf(:), o_df(:), o_dn(:), o_phi(:), o_phi_eval(:), & o_rate(:), o_ms(:, :), o_ms_next(:, :), o_rec_phi(:), o_rec_ms(:, :), & @@ -1306,6 +1316,19 @@ SUBROUTINE CD_HermiteCable_Dyn_Set_VIV(model, cl, cf, df, t_window, ErrStat, Err 'wake oscillator'; RETURN END IF END IF + IF (PRESENT(dviv)) THEN + IF (SIZE(dviv) /= ne) THEN + ErrStat = CD_HCDYN_BADINPUT + ErrMsg = 'CD_HermiteCable_Dyn_Set_VIV: dviv must have one value per element'; RETURN + END IF + IF (.NOT. CD_All_Finite(dviv)) THEN + ErrStat = CD_HCDYN_BADINPUT; ErrMsg = 'CD_HermiteCable_Dyn_Set_VIV: dviv must be finite'; RETURN + END IF + IF (ANY(dviv < CD_ZERO)) THEN + ErrStat = CD_HCDYN_BADINPUT + ErrMsg = 'CD_HermiteCable_Dyn_Set_VIV: dviv must be non-negative (0 = the drag diameter)'; RETURN + END IF + END IF ! the previous configuration and state, kept for a rollback had_viv = model%has_viv had_il = model%has_viv_il @@ -1336,6 +1359,12 @@ SUBROUTINE CD_HermiteCable_Dyn_Set_VIV(model, cl, cf, df, t_window, ErrStat, Err model%viv_amp_n = amp_n model%has_viv_amp = .TRUE. END IF + IF (PRESENT(dviv)) THEN + IF (ANY(dviv > CD_ZERO)) THEN + ALLOCATE (model%viv_dv(ne)) + model%viv_dv = dviv + END IF + END IF model%viv_cl = cl model%viv_cf = CD_ZERO model%viv_df = CD_ZERO @@ -1482,6 +1511,7 @@ SUBROUTINE move_viv(back) 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) CALL MOVE_ALLOC(p_amp, model%viv_amp); CALL MOVE_ALLOC(p_ampn, model%viv_amp_n) + CALL MOVE_ALLOC(p_dv, model%viv_dv) 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) @@ -1505,6 +1535,7 @@ SUBROUTINE move_viv(back) 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) CALL MOVE_ALLOC(model%viv_amp, p_amp); CALL MOVE_ALLOC(model%viv_amp_n, p_ampn) + CALL MOVE_ALLOC(model%viv_dv, p_dv) END IF END SUBROUTINE move_viv END SUBROUTINE CD_HermiteCable_Dyn_Set_VIV @@ -1527,6 +1558,7 @@ SUBROUTINE clear_viv(model) model%wo_ydd0, model%wo_om0, model%ws_recovery_wo_s, model%snap_wo_s) IF (ALLOCATED(model%viv_amp)) DEALLOCATE (model%viv_amp) IF (ALLOCATED(model%viv_amp_n)) DEALLOCATE (model%viv_amp_n) + IF (ALLOCATED(model%viv_dv)) DEALLOCATE (model%viv_dv) model%has_viv_amp = .FALSE. model%has_viv = .FALSE. model%has_viv_il = .FALSE. @@ -1542,9 +1574,11 @@ SUBROUTINE viv_drag_terms(model) TYPE(CD_HermiteCableDynType), INTENT(INOUT) :: model INTEGER :: e, k REAL(wp) :: wsum - model%viv_k = 0.5_wp*model%rho_w*model%diam*model%viv_cl - IF (model%has_viv_il) model%vil_k = 0.5_wp*model%rho_w*model%diam*model%vil_cx - IF (model%has_viv_il) model%vhh_k = 0.5_wp*model%rho_w*model%diam*model%vhh_cx + DO e = 1, model%ne + model%viv_k(e) = 0.5_wp*model%rho_w*viv_diam(model, e)*model%viv_cl(e) + IF (model%has_viv_il) model%vil_k(e) = 0.5_wp*model%rho_w*viv_diam(model, e)*model%vil_cx(e) + IF (model%has_viv_il) model%vhh_k(e) = 0.5_wp*model%rho_w*viv_diam(model, e)*model%vhh_cx(e) + END DO model%viv_dn = CD_ZERO DO k = 1, model%nn IF (.NOT. model%viv_node(k)) CYCLE @@ -1552,12 +1586,22 @@ SUBROUTINE viv_drag_terms(model) DO e = MAX(1, k - 1), MIN(model%ne, k) IF (.NOT. (model%viv_cl(e) > CD_ZERO)) CYCLE wsum = wsum + model%l0(e) - model%viv_dn(k) = model%viv_dn(k) + model%l0(e)*model%diam(e) + model%viv_dn(k) = model%viv_dn(k) + model%l0(e)*viv_diam(model, e) END DO model%viv_dn(k) = model%viv_dn(k)/wsum END DO END SUBROUTINE viv_drag_terms + PURE REAL(wp) FUNCTION viv_diam(model, e) RESULT(d) + !! The diameter of the VIV model on element e: viv_dv(e) where it is set (> 0), else the drag + !! diameter. + TYPE(CD_HermiteCableDynType), INTENT(IN) :: model + INTEGER, INTENT(IN) :: e + d = model%diam(e) + IF (.NOT. ALLOCATED(model%viv_dv)) RETURN + IF (model%viv_dv(e) > CD_ZERO) d = model%viv_dv(e) + END FUNCTION viv_diam + PURE REAL(wp) FUNCTION viv_elem_amplitude(model, e) RESULT(y0) !! The smoothed cross-flow amplitude of element e [m]: the mean over its VIV end nodes (zero !! without amplitude tables). @@ -1585,8 +1629,8 @@ PURE REAL(wp) FUNCTION elem_viv_k(model, e) RESULT(k) IF (.NOT. model%has_viv_amp) RETURN n = model%viv_amp_n(e) IF (n == 0) RETURN - k = 0.5_wp*model%rho_w*model%diam(e)*CD_VIV_Table(viv_elem_amplitude(model, e)/model%diam(e), & - model%viv_amp(1, 1:n, e), model%viv_amp(2, 1:n, e)) + k = 0.5_wp*model%rho_w*viv_diam(model, e)*CD_VIV_Table(viv_elem_amplitude(model, e)/viv_diam(model, e), & + model%viv_amp(1, 1:n, e), model%viv_amp(2, 1:n, e)) END FUNCTION elem_viv_k PURE REAL(wp) FUNCTION elem_cdn(model, e) RESULT(cdn) @@ -1599,7 +1643,7 @@ PURE REAL(wp) FUNCTION elem_cdn(model, e) RESULT(cdn) IF (.NOT. model%has_viv_amp) RETURN n = model%viv_amp_n(e) IF (n == 0) RETURN - cdn = cdn*CD_VIV_Table(viv_elem_amplitude(model, e)/model%diam(e), model%viv_amp(1, 1:n, e), & + cdn = cdn*CD_VIV_Table(viv_elem_amplitude(model, e)/viv_diam(model, e), model%viv_amp(1, 1:n, e), & model%viv_amp(3, 1:n, e)) END FUNCTION elem_cdn diff --git a/tests/test_viv_diameter_deck.f90 b/tests/test_viv_diameter_deck.f90 new file mode 100644 index 0000000..c9a6eb4 --- /dev/null +++ b/tests/test_viv_diameter_deck.f90 @@ -0,0 +1,270 @@ +! File: tests/test_viv_diameter_deck.f90 +! SPDX-License-Identifier: Apache-2.0 +! Copyright (c) 2026 Jae Hoon Seo, SMI Lab, Inha University +PROGRAM test_viv_diameter_deck + !! The diameter of the VIV model on a deck (the optional VIV DIAMETER section, rows TypeName + !! Dviv): the taut gate line (100 m, Diam 0.1 m, 50 kN, pinned at 50 m depth, 50 elements) in a + !! uniform 0.15 m/s current along y, as a finite-EI cable + !! (EI 1 N m^2) and as an EI = 0 line: + !! D1 Dviv equal to the type's Diam is the deck without the section, to the printed digits; + !! D2 with the synchronisation lift (Cl 0.8, cF 0.18, dF 0.08) the deck locks in near the first + !! mode (cF U/Diam = 0.27 Hz, the lock-in at 0.287 Hz); with Dviv 0.2 m the shedding band + !! (cF -+ dF) U/Dviv, 0.075-0.195 Hz, lies below that mode, where the motion lags the lift by + !! less than a quarter period and the phase runs at the top of the band, 0.195 Hz (within + !! 0.005 Hz), on both line kinds; + !! D3 a wake oscillator uncoupled from the cable (A 0, St 0.2) drives the finite-EI cable at + !! St U/Dviv = 0.15 Hz with Dviv 0.2 m (within 0.005 Hz), half the 0.30 Hz of Diam; + !! D4 refusals by name: a malformed row, an unknown or repeated type, a value out of range, and a + !! type without VIV (a row with no number is a header row, as in every table section). + 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 + INTEGER :: nfail = 0 + + CALL write_current('vdd_current.dat') + CALL check_kind('1.0', 'finite-EI') + CALL check_kind('0.0', 'EI = 0') + CALL check_wake() + CALL check_refusals() + IF (nfail > 0) THEN + WRITE (*, '(A,I0,A)') 'FAIL: ', nfail, ' assertion(s) failed' + ERROR STOP 1 + END IF + WRITE (*, '(A)') 'PASS: VIV diameter deck gates' + +CONTAINS + + SUBROUTINE require(cond, label) + LOGICAL, INTENT(IN) :: cond + CHARACTER(*), INTENT(IN) :: label + IF (cond) RETURN + nfail = nfail + 1 + WRITE (*, '(A)') 'FAIL: '//TRIM(label) + END SUBROUTINE require + + SUBROUTINE write_current(path) + CHARACTER(*), INTENT(IN) :: path + INTEGER :: u + OPEN (NEWUNIT=u, FILE=path, STATUS='REPLACE', ACTION='WRITE') + WRITE (u, '(A)') 'MoorDyn v2 water kinematics file' + WRITE (u, '(A)') 'uniform current along y for the VIV diameter 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, dia_rows, tmax, ei, cl, wake_row) + !! dia_rows: the VIV DIAMETER section's data rows, ';'-separated ('' for no section); ei the + !! type's EI, cl its LINE TYPES Cl (default 0.8); wake_row a WAKE OSCILLATOR row. + CHARACTER(*), INTENT(IN) :: path, dia_rows, ei + REAL(wp), INTENT(IN) :: tmax + CHARACTER(*), INTENT(IN), OPTIONAL :: cl, wake_row + CHARACTER(32) :: cl_col + INTEGER :: u, i0, i1 + cl_col = '0.8' + IF (PRESENT(cl)) cl_col = cl + OPEN (NEWUNIT=u, FILE=path, STATUS='REPLACE', ACTION='WRITE') + WRITE (u, '(A)') '--------------------- CableDyn Input File ---------------------------------' + WRITE (u, '(A)') 'VIV diameter 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)//' 1.2 1.0 0.0 0.0 '// & + TRIM(cl_col)//' 0.08 0.18' + WRITE (u, '(A)') 'bare 0.10 10.0 5.0e7 -0.8 '//TRIM(ei)//' 1.2 1.0 0.0 0.0 0.0' + WRITE (u, '(A)') '----------------------- POINTS ----------------------------------------------' + WRITE (u, '(A)') 'ID Attachment X Y Z M V CdA CA' + WRITE (u, '(A)') '1 Coupled 0.0 0.0 -50.0 0 0 0 0' + WRITE (u, '(A)') '2 Fixed 100.0 0.0 -50.0 0 0 0 0' + WRITE (u, '(A)') '----------------------- LINES -----------------------------------------------' + WRITE (u, '(A)') 'ID NodeA NodeB Outputs' + WRITE (u, '(A)') '1 1 2 -' + WRITE (u, '(A)') '----------------------- SECTIONS --------------------------------------------' + WRITE (u, '(A)') 'LineID LineType Length NumSegs' + WRITE (u, '(A)') '1 riser 99.900100 50' + IF (PRESENT(wake_row)) THEN + WRITE (u, '(A)') '----------------------- WAKE OSCILLATOR -------------------------------------' + WRITE (u, '(A)') 'TypeName CL0 St eps A' + WRITE (u, '(A)') wake_row + END IF + IF (LEN_TRIM(dia_rows) > 0) THEN + WRITE (u, '(A)') '----------------------- VIV DIAMETER ----------------------------------------' + WRITE (u, '(A)') 'TypeName Dviv' + WRITE (u, '(A)') '(-) (m)' + i0 = 1 + DO + i1 = INDEX(dia_rows(i0:), ';') + IF (i1 == 0) THEN + WRITE (u, '(A)') TRIM(dia_rows(i0:)) + EXIT + END IF + WRITE (u, '(A)') dia_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)') 'vdd_current.dat WaterKin' + WRITE (u, '(A,F8.3,A)') ' ', tmax, ' TMax' + WRITE (u, '(A)') '---------------------- OUTPUTS -----------------------------------------------' + WRITE (u, '(A)') 'L1N26PZ' + 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, L1N26PZ) 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(2, 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-1 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, 950 + 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, ad, f) + !! Half peak-to-peak mid-span cross-flow amplitude over D and dominant frequency from t0 on. + REAL(wp), INTENT(IN) :: tab(:, :), t0 + INTEGER, INTENT(IN) :: n + REAL(wp), INTENT(OUT) :: ad, f + LOGICAL :: keep(n) + REAL(wp), ALLOCATABLE :: tt(:), z(:) + keep = tab(1, 1:n) >= t0 + 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_kind(ei, label) + CHARACTER(*), INTENT(IN) :: ei, label + CHARACTER(16) :: tag + REAL(wp), ALLOCATABLE :: tn(:, :), ts(:, :), tb(:, :) + INTEGER :: nn, ns, nb + REAL(wp) :: ad_n, f_n, ad_b, f_b + LOGICAL :: ok + CHARACTER(1024) :: msg + tag = MERGE('fe', 'e0', ei /= '0.0') + CALL write_deck('vdd_'//TRIM(tag)//'_none.dat', '', 100.0_wp, ei) + CALL run('vdd_'//TRIM(tag)//'_none.dat', 'vdd_'//TRIM(tag)//'_none', ok, msg) + CALL require(ok, 'D1 ('//label//'): the deck without the section runs: '//TRIM(msg)) + CALL write_deck('vdd_'//TRIM(tag)//'_same.dat', 'riser 0.10', 100.0_wp, ei) + CALL run('vdd_'//TRIM(tag)//'_same.dat', 'vdd_'//TRIM(tag)//'_same', ok, msg) + CALL require(ok, 'D1 ('//label//'): the Dviv = Diam deck runs: '//TRIM(msg)) + CALL write_deck('vdd_'//TRIM(tag)//'_big.dat', 'riser 0.2', 100.0_wp, ei) + CALL run('vdd_'//TRIM(tag)//'_big.dat', 'vdd_'//TRIM(tag)//'_big', ok, msg) + CALL require(ok, 'D2 ('//label//'): the Dviv 0.2 deck runs: '//TRIM(msg)) + CALL read_out('vdd_'//TRIM(tag)//'_none.out', tn, nn) + CALL read_out('vdd_'//TRIM(tag)//'_same.out', ts, ns) + CALL read_out('vdd_'//TRIM(tag)//'_big.out', tb, nb) + CALL require(nn > 5000 .AND. ns == nn .AND. nb == nn, 'D1 ('//label//'): the runs wrote matching rows') + IF (.NOT. (nn > 5000 .AND. ns == nn .AND. nb == nn)) RETURN + CALL require(ALL(ts(:, 1:ns) == tn(:, 1:nn)), 'D1 ('//label//'): Dviv = Diam is the deck without the section') + CALL window_stats(tn, nn, 60.0_wp, ad_n, f_n) + CALL window_stats(tb, nb, 60.0_wp, ad_b, f_b) + WRITE (*, '(A,2F8.4,A,2F8.4)') 'D2 ('//label//'): A/D, f [Hz] with Diam ', ad_n, f_n, '; with Dviv 0.2 ', & + ad_b, f_b + CALL require(ABS(f_n - 0.28_wp) <= 0.02_wp, 'D2 ('//label//'): with Diam the line locks in near its first mode') + CALL require(ABS(f_b - 0.195_wp) <= 0.005_wp, 'D2 ('//label//'): with Dviv 0.2 the phase runs at the top of '// & + 'its band, (cF + dF) U/Dviv') + END SUBROUTINE check_kind + + SUBROUTINE check_wake() + REAL(wp), ALLOCATABLE :: tw(:, :) + INTEGER :: nw + REAL(wp) :: ad, f + LOGICAL :: ok + CHARACTER(1024) :: msg + CALL write_deck('vdd_wake.dat', 'riser 0.2', 100.0_wp, '1.0', cl='0.0', wake_row='riser 0.3 0.2 0.3 0.0') + CALL run('vdd_wake.dat', 'vdd_wake', ok, msg) + CALL require(ok, 'D3: the uncoupled wake-oscillator deck with Dviv 0.2 runs: '//TRIM(msg)) + CALL read_out('vdd_wake.out', tw, nw) + CALL require(nw > 5000, 'D3: the run wrote its rows') + IF (nw <= 5000) RETURN + CALL window_stats(tw, nw, 50.0_wp, ad, f) + WRITE (*, '(A,2F8.4)') 'D3: uncoupled wake, Dviv 0.2: A/D, f [Hz] ', ad, f + CALL require(ABS(f - 0.15_wp) <= 0.005_wp, 'D3: the wake drives the cable at St U/Dviv') + END SUBROUTINE check_wake + + SUBROUTINE check_refusals() + CALL refused('riser 0.2 0.3', 'TypeName Dviv', 'a row of three columns') + CALL refused('cable 0.2', 'undefined LINE TYPE', 'an unknown type') + CALL refused('riser 0.2;riser 0.3', 'twice', 'a repeated type') + CALL refused('riser 0.0', 'Dviv > 0', 'a zero Dviv') + CALL refused('riser -0.2', 'Dviv > 0', 'a negative Dviv') + CALL refused('bare 0.2', 'give the type LINE TYPES Cl > 0 or a WAKE OSCILLATOR row', 'a type without VIV') + END SUBROUTINE check_refusals + + SUBROUTINE refused(rows, needle, what) + CHARACTER(*), INTENT(IN) :: rows, needle, what + LOGICAL :: ok + CHARACTER(1024) :: msg + CALL write_deck('vdd_bad.dat', rows, 1.0_wp, '1.0') + CALL run('vdd_bad.dat', 'vdd_bad', ok, msg) + CALL require(.NOT. ok .AND. INDEX(msg, needle) > 0, 'D4: '//what//' is refused: '//TRIM(msg)) + END SUBROUTINE refused + +END PROGRAM test_viv_diameter_deck