From cadd933db2bb0e908519dfff8c20b458ef650e2b Mon Sep 17 00:00:00 2001 From: Jae Hoon Seo Date: Wed, 11 Nov 2026 15:04:29 +0900 Subject: [PATCH] feat: in-line VIV of finite-EI cables (the VIV section) The synchronisation model carried the cross-flow lift only. A finite-EI line type now takes the in-line shedding force of Ulveseter, Thorsen, Saevik and Larsen (Mar. Struct. 60, 2018), an optional VIV section row TypeName ClX [alpha]: per unit length 1/2 rho D ClX cos(phi_x) U v_n along the relative normal flow, the direction of the drag, with its phase slaved to twice the cross-flow one, d phi_x/dt = 2 (d phi/dt) [1 + alpha sin(phi_xd - phi_x)], phi_xd the phase of the in-line motion from the running RMS values (alpha 0.15 by default). ClX > 0 needs the type's cross-flow Cl > 0. The kernels give the node and per-length forces with exact Jacobians and the in-line motion and phase rate. The Hermite cable integrates the force with the lift at its Gauss points; the phase is explicit with the Heun commit (its end rate from the end cross-flow rate) and sits in the step-recovery, snapshot and HFMF checkpoint state (3 nn more values in the VIV block). Both deck readers take the section and refuse malformed rows, unknown or repeated types, ClX on a type without the lift, alpha outside [0, 1) and in-line VIV on an EI = 0 line, which follows later; the Python builder writes and reads it. Tests: kernel forces and Jacobians against central differences; on the taut line of the lock-in benchmark the in-line response runs at twice the cross-flow frequency (2.000 on the Hermite march, 1.95 through the deck) with A/D 0.19 against 0.03 from the lift alone; ClX 0 reproduces the cross-flow-only run bit for bit; snapshot replay, the recovering step and the mirror round trip are bit-exact. New example viv_taut_cable_inline.dat. Signed-off-by: Jae Hoon Seo --- CHANGELOG.md | 7 + CMakeLists.txt | 12 +- doc/capabilities.rst | 8 +- doc/concepts.rst | 5 +- doc/driver_format.md | 48 +++- doc/examples.rst | 6 + doc/outputs.rst | 3 +- doc/references.rst | 6 + doc/theory.rst | 37 +++ examples/viv_taut_cable_inline.dat | 60 +++++ python/cabledyn/builder.py | 50 +++- python/cabledyn/deck_file.py | 67 ++++- python/tests/test_builder.py | 30 +++ python/tests/test_deck_native_parity.py | 44 ++++ src/CableDyn_DeckDriver.f90 | 152 ++++++++++- src/CableDyn_HermiteCableDynamic.f90 | 229 ++++++++++++++-- src/CableDyn_OpenFAST_HermiteFMF.f90 | 28 +- src/CableDyn_VIV.f90 | 176 ++++++++++++- tests/test_hermite_viv_inline.f90 | 336 ++++++++++++++++++++++++ tests/test_hfmf_mirror.f90 | 48 +++- tests/test_viv_inline_deck.f90 | 254 ++++++++++++++++++ tests/test_viv_kernels.f90 | 84 +++++- 22 files changed, 1625 insertions(+), 65 deletions(-) create mode 100644 examples/viv_taut_cable_inline.dat create mode 100644 tests/test_hermite_viv_inline.f90 create mode 100644 tests/test_viv_inline_deck.f90 diff --git a/CHANGELOG.md b/CHANGELOG.md index c2cde749..79d6a942 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -17,6 +17,13 @@ All notable changes to CableDyn are recorded in this file. The format follows pinned cable match this to 0.05 %. It acts on every dynamic route beside the axial (`BA`) and torsional (`GJ|K|Bt`) damping, with exact Jacobians; the Python deck reader and builder take the same forms. +- In-line VIV of finite-EI cables: an optional `VIV` section row `TypeName ClX [alpha]` adds the + in-line vortex-shedding force of Ulveseter et al. (2018), `1/2 rho D ClX cos(phi_x) U v_n` along + the relative flow, with its phase slaved to twice the cross-flow one in a band `alpha` (default + 0.15). On the taut line of `examples/viv_taut_cable_inline.dat` the in-line response runs at + twice the cross-flow frequency, A/D 0.19 against 0.03 with the lift alone. Exact Jacobians; the + phase is in the step-recovery, snapshot and checkpoint state; the Python deck reader and + builder take the section. `EI = 0` lines refuse it for now. ## [0.4.2] - 2026-11-09 diff --git a/CMakeLists.txt b/CMakeLists.txt index 5379d814..cfd12517 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1321,6 +1321,16 @@ target_link_libraries(test_hermite_viv PRIVATE cabledyn_core) add_test(NAME hermite_viv COMMAND test_hermite_viv) set_tests_properties(hermite_viv PROPERTIES LABELS "fortran;dynamic;viv") +add_executable(test_hermite_viv_inline tests/test_hermite_viv_inline.f90) +target_link_libraries(test_hermite_viv_inline PRIVATE cabledyn_core) +add_test(NAME hermite_viv_inline COMMAND test_hermite_viv_inline) +set_tests_properties(hermite_viv_inline PROPERTIES LABELS "fortran;dynamic;viv") + +add_executable(test_viv_inline_deck tests/test_viv_inline_deck.f90) +target_link_libraries(test_viv_inline_deck PRIVATE cabledyn_core) +add_test(NAME viv_inline_deck COMMAND test_viv_inline_deck WORKING_DIRECTORY ${CMAKE_BINARY_DIR}) +set_tests_properties(viv_inline_deck PROPERTIES LABELS "fortran;integration;dynamic;viv;driver") + add_executable(test_viv_coupled tests/test_viv_coupled.f90) target_link_libraries(test_viv_coupled PRIVATE cabledyn_core) add_test(NAME viv_coupled COMMAND test_viv_coupled WORKING_DIRECTORY ${CMAKE_BINARY_DIR}) @@ -3568,7 +3578,7 @@ foreach(_feature_example IN ITEMS airy_wave_shallow_chain laid_cable_cross_current chain_modes lazy_wave_modes buoy_clamped_cable moordynC_wavekin/chain_wavekin7_currents1 spar_pinned_rods mixed_body_rods_points als_volturnus_line_break_time als_volturnus_line_break_tension - viv_taut_line_crossflow composite_axial_damping_mode1 composite_ve_syrope_jonswap + viv_taut_line_crossflow viv_taut_cable_inline composite_axial_damping_mode1 composite_ve_syrope_jonswap composite_chain_poly_chain_modes shared_cable_two_floaters lazy_wave_modules_stiffener chain_sloped_bathymetry_friction torsion_free_end_armoured_cable moordynC_currents/chain_wavekin3_currents2 moordynC_currents/chain_currents5_grid) diff --git a/doc/capabilities.rst b/doc/capabilities.rst index f2154c4d..a19239c3 100644 --- a/doc/capabilities.rst +++ b/doc/capabilities.rst @@ -143,8 +143,12 @@ Line and constitutive capability - Standalone and coupled - MoorDyn v2's synchronisation model on ``EI = 0`` lines and, as a distributed lift, on finite-EI cables of the Hermite and multibody marches (:ref:`theory-viv`), with the - host's fluid field on the coupled routes and its state in the checkpoint; in-line VIV is - not provided + host's fluid field on the coupled routes and its state in the checkpoint + * - In-line VIV (``VIV`` section ``ClX``, ``alpha``) + - Standalone and coupled + - the in-line shedding force of Ulveseter et al. (2018) at twice the cross-flow frequency, on + finite-EI cables of the Hermite and multibody marches (:ref:`theory-viv-inline`), its state + in the checkpoint; not on ``EI = 0`` lines yet Loads and environment --------------------- diff --git a/doc/concepts.rst b/doc/concepts.rst index 0f9e57c4..f54b1075 100644 --- a/doc/concepts.rst +++ b/doc/concepts.rst @@ -80,9 +80,10 @@ A ``LINE TYPES`` row is the reusable material a section refers to by name: diame metre, axial stiffness ``EA``, axial damping ``BA``, bending stiffness ``EI``, and the four Morison coefficients (``Cd_n``, ``Cd_t``, ``Ca_n``, ``Ca_t``). ``EI`` is the switch between the two solver paths (next section). Axial response can be linear ``EA`` or a stateful constitutive model -(viscoelastic, Syrope) — see :doc:`theory`. An ``EI = 0`` row may end with MoorDyn's cross-flow +(viscoelastic, Syrope) — see :doc:`theory`. A 10-column row may end with MoorDyn's cross-flow VIV columns ``Cl`` or ``Cl dF cF`` (lift coefficient and synchronisation band; see -:ref:`theory-viv`). +:ref:`theory-viv`), and a ``VIV`` section row adds the in-line force of a finite-EI type +(:ref:`theory-viv-inline`). Two solver paths, selected by ``EI`` ------------------------------------ diff --git a/doc/driver_format.md b/doc/driver_format.md index e1dac704..e2c3548f 100644 --- a/doc/driver_format.md +++ b/doc/driver_format.md @@ -133,8 +133,8 @@ except that `SYROPE IC` must come **after** `LINES`, because its rows name lines exist. A conventional layout is: LINE TYPES → BODIES → EXTERNAL LOADS → ROD TYPES → RODS → POINTS → TURBINES → LINES → SYROPE IC → -SECTIONS → END CONNECTIONS / EQUIVALENT BUOYANCY / ATTACHMENTS / STIFFENERS / FAILURE / CONTROL → -OPTIONS → OUTPUTS +SECTIONS → END CONNECTIONS / EQUIVALENT BUOYANCY / ATTACHMENTS / STIFFENERS / VIV / FAILURE / +CONTROL → OPTIONS → OUTPUTS Within LINE TYPES, the header row must precede the data rows because it selects their column order. @@ -210,6 +210,7 @@ are collapsed. It must match one of the spellings below; any other name fails wi | EQUIVALENT BUOYANCY | `EQUIVALENT BUOYANCY`, `EQUIVALENT SECTIONS`, `BUOYANCY SECTIONS` | | ATTACHMENTS | `ATTACHMENTS`, `LINE ATTACHMENTS`, `CLUMPS` | | STIFFENERS | `STIFFENERS`, `STIFFENER`, `BEND STIFFENERS`, `BEND STIFFENER` | +| VIV | `VIV`, `VORTEX-INDUCED VIBRATION`, `VORTEX INDUCED VIBRATION` | | FAILURE | `FAILURE`, `FAILURES` | | CONTROL | `CONTROL`, `CONTROLS` | | TURBINES | `TURBINES`, `TURBINE` | @@ -289,6 +290,14 @@ frequency `f` [Hz], `Bb = ζ EI/(π f)`, set once per line type (it does not dep `EI|0` is the plain `EI`. It needs `EI > 0` and acts in the dynamics only (a static solve has no rates). +**Cross-flow VIV columns (MoorDyn v2).** A 10-column row may end with `Cl` (11 columns) or +`Cl dF cF` (13 columns): the lift coefficient of the vortex-shedding synchronisation model and +the half-range and centre of its band in non-dimensional frequency (MoorDyn's `dF = 0.08` and +`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 14-column row has no VIV columns. The +in-line force of a finite-EI type is a [VIV](#viv-optional-finite-ei-lines) section row. + **Viscoelastic axial stiffness (MoorDyn `ElasticMod`).** The EA and BA columns accept bar-separated parts: @@ -1136,6 +1145,41 @@ Behaviour: `NodeA`) the `End` column follows the written row, so the stiffener stays on the same physical end. Stiffeners run wherever the cubic-Hermite cable does, standalone and coupled. +### VIV (optional, finite-EI lines) + +In-line vortex-induced vibration of a line type: a second vortex-shedding force along the +relative flow, the direction of the drag, at twice the cross-flow frequency (Ulveseter et al. +2018; see [In-line VIV](theory.rst)). One row per line type, which must carry the cross-flow lift +(`Cl > 0` in LINE TYPES), since the in-line phase runs at twice the cross-flow one. + +```text +--------------------- VIV ---------------------------------------------- +TypeName ClX alpha +(-) (-) (-) +cable 0.85 0.15 +``` + +| Column | Meaning | +|--------|---------| +| `TypeName` | an existing LINE TYPES name (case-insensitive), at most one row each | +| `ClX` | in-line shedding coefficient `C_x` >= 0, at most 1e15; `0` is no in-line VIV | +| `alpha` | optional frequency band of the in-line phase about twice the cross-flow one, `0 <= alpha < 1` (default 0.15) | + +Behaviour: + +- Per unit length the force is `1/2 rho D ClX cos(phi_x) U v_n`, with `v_n` the relative normal + flow and `U` its speed; its phase follows `dphi_x/dt = 2 (dphi/dt) [1 + alpha sin(phi_xd - phi_x)]`, + `phi` the cross-flow phase and `phi_xd` the phase of the in-line motion. Ulveseter et al. take + `ClX = 0.85` and `alpha = 0.15` with `Cl = 0.65`. +- The Outputs flag `V` file carries the in-line force with the lift, and the phase is part of + the step-recovery, snapshot and checkpoint state. A row with `ClX = 0` leaves the run exactly as + without it. +- It acts on finite-EI lines (`EI > 0`) on every route the cubic-Hermite cable runs; an `EI = 0` + line of a type with `ClX > 0` stops by name. A row fails if it is not `TypeName ClX [alpha]`, + names an undefined or already named type, or holds a value out of range, and `ClX > 0` fails + on a type without the cross-flow lift. +- See `examples/viv_taut_cable_inline.dat`. + ### 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/examples.rst b/doc/examples.rst index 994bcd4d..7967f217 100644 --- a/doc/examples.rst +++ b/doc/examples.rst @@ -265,6 +265,12 @@ Dynamic environment :ref:`theory-viv` - cable, dynamic - ~2 s + * - ``viv_taut_cable_inline.dat`` + - in-line VIV (the ``VIV`` section, ``ClX`` and ``alpha``): the same line as a finite-EI + cable; the quarter span moves in line at twice the cross-flow frequency, A/D 0.19 against + 0.03 with the cross-flow lift alone — :ref:`theory-viv` + - cable, dynamic + - ~2 s Points, buoys, bodies, and rods ------------------------------- diff --git a/doc/outputs.rst b/doc/outputs.rst index 1fd0325e..b2b106ba 100644 --- a/doc/outputs.rst +++ b/doc/outputs.rst @@ -340,7 +340,8 @@ write. Any other letter is a parse error. Mixed ``EI = 0`` + finite-EI decks rej flag ``V``; a static run carries no lift and writes no file). On an ``EI = 0`` line the end nodes carry none, as in MoorDyn; on a finite-EI line each element's lift is lumped to its two nodes (the translational part of its consistent load), so the end nodes carry - the lift of their half-elements. Zero on a line without VIV (``Cl = 0``) + the lift of their half-elements, and a type with in-line VIV (the ``VIV`` section) adds + its in-line force. Zero on a line without VIV (``Cl = 0``) * - ``r`` - ``.Line.range.out`` - range graph: minimum, maximum and mean over the run of the node tension, curvature, bend diff --git a/doc/references.rst b/doc/references.rst index 9498856b..a4a4db4f 100644 --- a/doc/references.rst +++ b/doc/references.rst @@ -89,6 +89,12 @@ Hydrodynamics and ocean environment vortex-induced vibrations in stationary and oscillating flows. *Journal of Fluids and Structures* **61**, 1–19. https://doi.org/10.1016/j.jfluidstructs.2015.11.006 +.. _ref-ulveseter2018: + +- **Ulveseter, J. V., Thorsen, M. J., Sævik, S. & Larsen, C. M. (2018).** Time domain + simulation of riser VIV in current and irregular waves. *Marine Structures* **60**, 241–260. + https://doi.org/10.1016/j.marstruc.2018.04.001 + .. _ref-morison1950: - **Morison, J. R., O'Brien, M. P., Johnson, J. W. & Schaaf, S. A. (1950).** The force diff --git a/doc/theory.rst b/doc/theory.rst index 47127f01..500779dc 100644 --- a/doc/theory.rst +++ b/doc/theory.rst @@ -1169,6 +1169,43 @@ phases, the running mean squares and the averaging time are part of the checkpoi restart continues the uninterrupted run bit for bit. The OpenFAST correction iterations rewind them with the rest of the state. +.. _theory-viv-inline: + +In-line vortex-induced vibration +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +A finite-EI line type can add the in-line shedding force of the combined cross-flow and in-line +model of :ref:`Ulveseter et al. (2018) `, a ``VIV`` section row +``TypeName ClX [alpha]`` (see :doc:`file_formats`). A second phase :math:`\phi_x` per node drives +a force along the relative normal flow, per unit deformed length + +.. math:: + + \mathbf{f}_x = \tfrac{1}{2}\rho\,d\,C_{x}\cos\phi_x\;U\,\mathbf{v}_n , + +the direction of the drag, at twice the cross-flow frequency. Its phase is slaved to the +cross-flow shedding phase :math:`\phi`, with a band :math:`\alpha` in which it locks onto the +in-line motion :math:`\dot x = \dot{\mathbf{r}}\cdot\mathbf{v}_n/U`: + +.. math:: + + \dot\phi_x = 2\,\dot\phi\,\bigl[1 + \alpha\sin(\phi_{\dot x} - \phi_x)\bigr], \qquad + \phi_{\dot x} = \operatorname{atan2}\!\left(-\frac{\ddot x}{\ddot x_\text{rms}},\, + \frac{\dot x}{\dot x_\text{rms}}\right), + +with the running RMS values of the cross-flow phase (:math:`\phi_{\dot x} = 0` at a node with no +in-line motion). Ulveseter et al. take :math:`C_x = 0.85` and :math:`\alpha = 0.15` (the default +here) with a cross-flow :math:`C_L` of 0.65. The in-line phase starts at twice the cross-flow +one, so the two start locked. The in-line rate is twice the cross-flow one, so ``ClX > 0`` +needs the type's cross-flow :math:`C_L > 0`. The force is integrated with the lift at the same +Gauss points, :math:`\cos\phi_x` interpolated between the element's end nodes, and its exact +position and velocity derivatives enter the tangent. The phase is explicit with the Heun commit, +its end-state rate taken from the end-state cross-flow rate. The phase and the two mean squares +are part of the step-recovery, snapshot and checkpoint state, and a ``ClX`` of zero leaves the +run exactly as without the row. On the taut line of ``viv_taut_cable_inline.dat`` the quarter +span moves in line at twice the cross-flow frequency, A/D 0.19 against 0.03 with the cross-flow +lift alone. ``EI = 0`` lines do not take in-line VIV yet. + .. _theory-dry-buoyancy: Buoyancy and wetting diff --git a/examples/viv_taut_cable_inline.dat b/examples/viv_taut_cable_inline.dat new file mode 100644 index 00000000..187a9ee7 --- /dev/null +++ b/examples/viv_taut_cable_inline.dat @@ -0,0 +1,60 @@ +--------------------- CableDyn Input File ------------------------------------ +CableDyn driver deck -- cross-flow and in-line VIV of a taut cable in a uniform current, 90 s +-- The taut line of viv_taut_line_crossflow.dat as a finite-EI cable (EI 1 N m^2, a string to +-- within 1e-6 of its geometric stiffness): 100 m, D 0.1 m, 10 kg/m, EA 5e7 N, about 50 kN, held +-- at both ends 50 m below the surface in a 0.15 m/s current along +Y. The LINE TYPES columns +-- Cl dF cF give the cross-flow lift (0.8 in MoorDyn's band), which locks the first vertical mode +-- in across the flow (Z). The VIV section adds the in-line shedding force of Ulveseter et al. +-- (Mar. Struct. 60, 2018) along the flow (Y): ClX 0.85 and the band alpha 0.15 of its phase +-- about twice the cross-flow one. Over 60-90 s the quarter span (L1N13py) moves in line at A/D +-- 0.19, at twice the 0.29 Hz cross-flow frequency of the mid span (L1N26pz, A/D 0.82); with the +-- cross-flow lift alone (drop the VIV section) they are 0.03 and 0.66. The Outputs flag V writes +-- the VIV force, lift and in-line, at every node to .Line1.V.out. +--------------------- LINE TYPES --------------------------------------- +TypeName Diam MassDenInAir EA BA/-zeta EI Cd_n Cd_t Ca_n Ca_t Cl dF cF +(-) (m) (kg/m) (N) (N-s/-) (N-m^2) (-) (-) (-) (-) (-) (-) (-) +riser 0.10 10.0 5.0e7 -0.8 1.0 1.2 0.0 1.0 0.0 0.8 0.08 0.18 +--------------------- POINTS ------------------------------------------- +ID Type X Y Z Mass Vol CdA Ca +(-) (-) (m) (m) (m) (kg) (m^3) (m^2) (-) +1 Coupled 0.0 0.0 -50.0 0 0 0 0 +2 Fixed 100.0 0.0 -50.0 0 0 0 0 +--------------------- LINES -------------------------------------------- +ID NodeA NodeB Outputs +(-) (-) (-) (-) +1 1 2 V +--------------------- SECTIONS ----------------------------------------- +-- 99.9 m unstretched: 50 kN stretches it to the 100 m span (EA 5e7 N, strain 0.1 %). +LineID LineType Length NumSegs +(-) (-) (m) (-) +1 riser 99.9001 50 +--------------------- VIV ---------------------------------------------- +-- In-line VIV of a line type: the in-line shedding coefficient ClX (0 = off; it needs the type's +-- cross-flow Cl > 0) and the band alpha (0 <= alpha < 1, default 0.15). Finite-EI lines only. +TypeName ClX alpha +(-) (-) (-) +riser 0.85 0.15 +--------------------- OPTIONS ------------------------------------------ +9.80665 g - Gravitational acceleration (m/s^2) [default: 9.80665] +1025.0 rhoW - Water density (kg/m^3) [default: 1025] +100.0 WtrDpth - Water depth (m) [default: absent standalone; host-owned OpenFAST] +1.0e5 kBot - Seabed penalty stiffness base (Pa/m) [default: 1.0e5] +1.0e4 cBot - Seabed normal damping base (Pa-s/m) [default: 1.0e4] +0.02 dtM - CableDyn internal time step (s) [default: omitted standalone; the glue DT in OpenFAST] +90.0 TMax - Standalone simulation duration (s) [default: omitted standalone; host-owned OpenFAST] +0.25 VIVrmsWindow - Averaging time of the VIV running RMS motion (s) {0=500 steps of dtM} [default: 0] +spread VIVphaseSeed - Initial VIV phases {spread=2 pi i/N, MoorDyn-C; zero=MoorDyn-F} [default: spread] +uniform 0.0 0.15 0.0 current - Current model and X/Y/Z velocity (m/s) {none; uniform; profile} [default: none] +none waves - Wave model, height, period, and direction (m, s, deg) {none; airy; jonswap} [default: none] +0 WaterKin - Water-kinematics source {0/none; 3; 7; file; SEASTATE coupled only} [default: no policy] +0.4 rhoInf - Generalised-alpha spectral radius {0<=rhoInf<=1} [default: 0.4] +False modified_newton - Tangent-reuse mode {False=full Newton; True=guarded reuse} [default: False] +False adaptive_mesh - Automatic finite-EI refinement {False; True} [default: False] +dynamic_solver 1.0e-8 1.0e-14 30 12 - Relative tolerance, absolute tolerance, max iterations, backtracks [defaults shown] +none frictionMu - Seabed friction coefficient {none; value>=0} [default: none] +-- Complete option/default reference: cabledyn_options_reference.dat and doc/options.rst. +--------------------- OUTPUTS ------------------------------------------ +"FairTen1" +"L1N26pz" +"L1N13py" +--------------------- need this line ----------------------------------- diff --git a/python/cabledyn/builder.py b/python/cabledyn/builder.py index 29b37744..0e38138d 100644 --- a/python/cabledyn/builder.py +++ b/python/cabledyn/builder.py @@ -207,6 +207,12 @@ class LineType: coefficient and the half-range and centre of the synchronisation band in non-dimensional frequency). ``cl`` set writes the 13-column row, with MoorDyn's ``df = 0.08`` and ``cf = 0.18`` where they are ``None``. + clx, il_alpha : float | None + Optional in-line VIV of a finite-EI type, a ``VIV`` section row + ``Name ClX [alpha]``: the in-line shedding coefficient (it needs ``cl``, + the in-line phase running at twice the cross-flow one) and the frequency + band of that phase, ``0 <= il_alpha < 1``; ``None`` leaves alpha out of + the row (the solver takes 0.15). """ name: str @@ -226,6 +232,8 @@ class LineType: cl: float | None = None df: float | None = None cf: float | None = None + clx: float | None = None + il_alpha: float | None = None @dataclass(eq=False) @@ -1642,6 +1650,8 @@ def add_line_type( cl: float | None = None, df: float | None = None, cf: float | None = None, + clx: float | None = None, + il_alpha: float | None = None, ) -> LineType: """Add a ``LINE TYPES`` row; see :class:`LineType` for the fields. @@ -1658,7 +1668,25 @@ def add_line_type( _text(name, "line-type name") self._check_new_key(self.line_types, name) item = LineType( - name, diam, mass, ea, ba, ei, cdn, cdt, can, cat, gas, gj, irt, irn, cl, df, cf + name, + diam, + mass, + ea, + ba, + ei, + cdn, + cdt, + can, + cat, + gas, + gj, + irt, + irn, + cl, + df, + cf, + clx, + il_alpha, ) self._line_types.append(item) return item @@ -2549,6 +2577,7 @@ def to_text(self, *, validate: bool = True) -> str: _emit(out, "EQUIVALENT BUOYANCY", *self._equivalent_table()) _emit(out, "ATTACHMENTS", *self._attachment_table()) _emit(out, "STIFFENERS", *self._stiffener_table()) + _emit(out, "VIV", *self._viv_table()) _emit(out, "FAILURE", *self._failure_table()) _emit(out, "CONTROL", *self._control_table()) _emit(out, "EXTERNAL LOADS", *self._external_load_table()) @@ -2912,6 +2941,20 @@ def _stiffener_table(self) -> tuple[str, str, list[list[str]]]: header = "LineID End Length RootOD TipOD InnerD E Density" return header, "(-) (-) (m) (m) (m) (m) (Pa) (kg/m^3)", rows + def _viv_table(self) -> tuple[str, str, list[list[str]]]: + rows: list[list[str]] = [] + for item in self._line_types: + what = f"line type {item.name!r}" + if item.clx is None: + if item.il_alpha is not None: + raise ValueError(f"{what}: il_alpha needs the in-line VIV coefficient clx") + continue + row = [_text(item.name, what), _num(item.clx, what)] + if item.il_alpha is not None: + row.append(_num(item.il_alpha, what)) + rows.append(row) + return "Name ClX alpha", "(-) (-) (-)", 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")] @@ -3110,6 +3153,11 @@ def load(self) -> None: for row in self.rows("STIFFENERS"): t = row.tokens model.add_stiffener(_native_int(t[0]), t[1][-1], *(_f(token) for token in t[2:8])) + for row in self.rows("VIV"): + t = row.tokens + item = model.line_types[t[0]] + item.clx = _f(t[1]) + item.il_alpha = _f(t[2]) if len(t) == 3 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 a69d833c..6e4ca43f 100644 --- a/python/cabledyn/deck_file.py +++ b/python/cabledyn/deck_file.py @@ -76,6 +76,9 @@ "STIFFENER": "STIFFENERS", "BEND STIFFENERS": "STIFFENERS", "BEND STIFFENER": "STIFFENERS", + "VIV": "VIV", + "VORTEX-INDUCED VIBRATION": "VIV", + "VORTEX INDUCED VIBRATION": "VIV", } # Table sections whose rows the native reader takes through a Fortran # list-directed READ. Their descriptive and units rows are recognized by the @@ -98,7 +101,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"} + {"FAILURE", "CONTROL", "SYROPE IC", "ATTACHMENTS", "STIFFENERS", "VIV"} ) _TABLE_SECTIONS = _LIST_DIRECTED_SECTIONS | _WHITESPACE_TABLE_SECTIONS _NATIVE_RECORD_LENGTH = 512 @@ -3175,6 +3178,67 @@ def _check_stiffeners( "(End A and End B stiffeners together)" ) + def _check_viv_section( + self, + line_ids: set[str], + section_types_by_line: dict[str, list[str]], + line_type_meta: dict[str, tuple[float, float, float, float]], + lift_type_names: set[str], + ) -> None: + """Native ``apply_type_viv`` and its finalize check for the VIV section. + + A row ``TypeName ClX [alpha]`` gives a line type in-line VIV: the in-line shedding + coefficient ``ClX >= 0`` (0 = off) and the band ``0 <= alpha < 1`` (default 0.15) of + its phase about twice the cross-flow one, so ``ClX > 0`` needs the type's LINE TYPES + lift ``Cl > 0``. A type takes one row; the in-line force acts on finite-EI lines. + """ + named: set[str] = set() + inline_types: set[str] = set() + for row in self._rows("VIV"): + where = self._at(row) + if len(row.tokens) not in (2, 3): + raise DeckFormatError(f"{where}: VIV rows must be: TypeName ClX [alpha]") + name = row.tokens[0].lower() + if name not in line_type_meta: + raise DeckFormatError( + f'{where}: VIV row names undefined LINE TYPE "{row.tokens[0]}"' + ) + if name in named: + raise DeckFormatError(f'{where}: VIV names LINE TYPE "{row.tokens[0]}" twice') + named.add(name) + try: + clx = _native_float(row.tokens[1]) + alpha = _native_float(row.tokens[2]) if len(row.tokens) == 3 else 0.15 + except ValueError as exc: + raise DeckFormatError(f"{where}: VIV ClX and alpha must be plain numbers") from exc + if not (math.isfinite(clx) and math.isfinite(alpha)): + raise DeckFormatError(f"{where}: VIV ClX and alpha must be finite") + if clx < 0.0 or clx > _NATIVE_MAX_COEFFICIENT: + raise DeckFormatError( + f"{where}: VIV in-line coefficient ClX must be non-negative (0 = in-line VIV " + "off) and at most 1e15" + ) + if not 0.0 <= alpha < 1.0: + raise DeckFormatError( + f"{where}: VIV in-line frequency band alpha must satisfy 0 <= alpha < 1" + ) + if clx > 0.0 and name not in lift_type_names: + raise DeckFormatError( + f'{where}: VIV in-line VIV of LINE TYPE "{row.tokens[0]}" needs its ' + "cross-flow lift (LINE TYPES Cl > 0): the in-line phase runs at twice the " + "cross-flow one" + ) + if clx > 0.0: + inline_types.add(name) + for line_id in sorted(line_ids, key=int): + names = section_types_by_line.get(line_id, []) + finite = any(line_type_meta[name][3] > 0.0 for name in names if name in line_type_meta) + if not finite and inline_types & set(names): + raise DeckFormatError( + f"{self._label}: line {line_id} is an EI = 0 line of a type with in-line VIV " + "(VIV ClX > 0): in-line VIV acts on finite-EI lines (EI > 0)" + ) + def _legacy_rod_type_columns(self, record: DeckRecord) -> bool: """Return whether ``record`` sits under a legacy CableDyn ROD TYPES header. @@ -4345,6 +4409,7 @@ 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_ids, section_types_by_line, line_type_meta, viv_type_names) 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 ea6f0608..2e0abd73 100644 --- a/python/tests/test_builder.py +++ b/python/tests/test_builder.py @@ -1009,6 +1009,36 @@ def test_bending_damping_round_trips_in_the_ei_column( assert next(t for t in loaded.line_types if t.name == "cable").ei == ei +@pytest.mark.parametrize(("clx", "il_alpha"), [(0.85, 0.15), (0.85, None), (0.0, 0.2)]) +def test_inline_viv_round_trips_in_the_viv_section( + tmp_path: Path, clx: float, il_alpha: float | None +) -> None: + model = _chain_model(tmp_path) + cable = model.add_line_type( + "cable", diam=0.2, mass=40.0, ea=5.0e8, ei=1.0e4, cl=0.8, clx=clx, il_alpha=il_alpha + ) + assert (cable.clx, cable.il_alpha) == (clx, il_alpha) + target = model.save(tmp_path / "inline_viv.dat") + deck = DeckFile.read(target) + row = next(r for r in deck._rows("VIV") if r.tokens[0] == "cable") + assert [float(v) for v in row.tokens[1:]] == [clx] + ([] if il_alpha is None else [il_alpha]) + loaded = next(t for t in DeckModel.load(target).line_types if t.name == "cable") + assert (loaded.clx, loaded.il_alpha) == (clx, il_alpha) + + +def test_inline_viv_alpha_needs_the_coefficient(tmp_path: Path) -> None: + model = _chain_model(tmp_path) + model.add_line_type("cable", diam=0.2, mass=40.0, ea=5.0e8, ei=1.0e4, cl=0.8, il_alpha=0.15) + with pytest.raises(ValueError, match="il_alpha needs the in-line VIV coefficient clx"): + model.to_text() + + +def test_no_viv_section_without_inline_viv(tmp_path: Path) -> None: + model = _chain_model(tmp_path) + model.add_line_type("cable", diam=0.2, mass=40.0, ea=5.0e8, ei=1.0e4, cl=0.8) + assert "VIV ---" not in model.to_text() + + def test_bending_damping_ei_tuple_length_is_checked(tmp_path: Path) -> None: model = _chain_model(tmp_path) model.add_line_type("cable", diam=0.2, mass=40.0, ea=5.0e8, ei=(1.0e4, 1.0, 2.0, 3.0)) diff --git a/python/tests/test_deck_native_parity.py b/python/tests/test_deck_native_parity.py index c2c839a0..4a71b909 100644 --- a/python/tests/test_deck_native_parity.py +++ b/python/tests/test_deck_native_parity.py @@ -983,6 +983,50 @@ def test_bending_damping_rows_are_native(ei, message): _rejects(text, re.escape(message)) +_VIV_EI0 = "-0.8 0.0 1.2" +# the cross-flow VIV example as a finite-EI cable (EI 1 N m^2) +_VIV_CABLE = _example("viv_taut_line_crossflow.dat", (_VIV_EI0, "-0.8 1.0 1.2")) + + +@pytest.mark.parametrize( + "rows", [("riser 0.85 0.15",), ("riser 0.85",), ("riser 0",), ("RISER 0.5 0.0",)] +) +def test_inline_viv_rows_are_accepted(rows): + DeckFile.from_text(_section(_VIV_CABLE, "VIV", "TypeName ClX alpha", "(-) (-) (-)", *rows)) + + +@pytest.mark.parametrize( + ("rows", "message"), + [ + (("riser 0.85 0.15 7",), "VIV rows must be: TypeName ClX [alpha]"), + (("cable 0.85",), 'VIV row names undefined LINE TYPE "cable"'), + (("riser 0.85", "riser 0.5"), 'VIV names LINE TYPE "riser" twice'), + (("riser 0.85 x",), "VIV ClX and alpha must be plain numbers"), + (("riser -0.1",), "ClX must be non-negative"), + (("riser 2.0e15",), "ClX must be non-negative"), + (("riser 0.85 1.0",), "alpha must satisfy 0 <= alpha < 1"), + (("riser 0.85 -0.1",), "alpha must satisfy 0 <= alpha < 1"), + ], +) +def test_inline_viv_rows_are_native(rows, message): + _rejects(_section(_VIV_CABLE, "VIV", *rows), re.escape(message)) + + +def test_inline_viv_needs_the_crossflow_lift(): + text = _edit(_VIV_CABLE, ("0.0 0.8 0.08 0.18", "0.0 0.0 0.08 0.18")) + _rejects( + _section(text, "VIV", "riser 0.85"), + re.escape("needs its cross-flow lift (LINE TYPES Cl > 0)"), + ) + + +def test_inline_viv_needs_a_finite_ei_line(): + text = _section(_example("viv_taut_line_crossflow.dat"), "VIV", "riser 0.85") + _rejects(text, re.escape("in-line VIV acts on finite-EI lines (EI > 0)")) + # a zero in-line coefficient is no in-line VIV, which the EI = 0 line takes + DeckFile.from_text(_section(_example("viv_taut_line_crossflow.dat"), "VIV", "riser 0.0")) + + def test_stiffener_needs_a_finite_ei_line(): text = _section(_HELD, "STIFFENERS", "1 A 1.0 0.5 0.5 0.3 5.0e7 1150") _rejects(text, "STIFFENERS name line 1, which is not a finite-EI line") diff --git a/src/CableDyn_DeckDriver.f90 b/src/CableDyn_DeckDriver.f90 index fb420578..c51a2817 100644 --- a/src/CableDyn_DeckDriver.f90 +++ b/src/CableDyn_DeckDriver.f90 @@ -135,7 +135,7 @@ 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 + USE CableDyn_VIV, ONLY: CD_VIV_DEFAULT_DF, CD_VIV_DEFAULT_CF, CD_VIV_NM, CD_VIV_DEFAULT_IL_ALPHA 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, & @@ -445,6 +445,12 @@ MODULE CableDyn_DeckDriver ! non-dimensional shedding frequency. A row with Cl only takes MoorDyn's dF = 0.08 and ! cF = 0.18. REAL(wp) :: cl = CD_ZERO, viv_df = CD_VIV_DEFAULT_DF, viv_cf = CD_VIV_DEFAULT_CF + ! In-line VIV (the optional VIV section, a row per type: TypeName ClX [alpha]; Ulveseter et + ! al., Mar. Struct. 60, 2018): the in-line shedding coefficient C_vx (0 = off) and the + ! frequency band alpha of its phase about twice the cross-flow one; has_viv_row marks a type + ! the section names. + REAL(wp) :: clx = CD_ZERO, il_alpha = CD_VIV_DEFAULT_IL_ALPHA + LOGICAL :: has_viv_row = .FALSE. ! Deck file line of the row (0 when not read from a file), for error messages. INTEGER :: deck_line = 0 END TYPE @@ -1877,7 +1883,7 @@ RECURSIVE SUBROUTINE build_one_hermite_cable(ln, sections, types, points, opts, REAL(wp), ALLOCATABLE :: gas(:), gj(:), rho_a(:), i_rt(:), i_rn(:), w(:), nodes_ref(:, :), q0(:), q_static(:) REAL(wp), ALLOCATABLE :: q_sequence(:) REAL(wp), ALLOCATABLE :: curv(:), cdn(:), cdt(:), can(:), cat(:), catenary_pos(:) - REAL(wp), ALLOCATABLE :: viv_cl(:), viv_cf(:), viv_df(:) + REAL(wp), ALLOCATABLE :: viv_cl(:), viv_cf(:), viv_df(:), viv_clx(:), viv_al(:) REAL(wp), ALLOCATABLE :: ba_raw(:), ba(:), dry_b(:), bb_el(:) REAL(wp) :: mode1_omega REAL(wp), ALLOCATABLE :: contact_kn(:), contact_cn(:) @@ -3273,12 +3279,14 @@ RECURSIVE SUBROUTINE build_one_hermite_cable(ln, sections, types, points, opts, ! property of the original element containing its reference-arc midpoint. ALLOCATE (cdn(SIZE(l0)), cdt(SIZE(l0)), can(SIZE(l0)), cat(SIZE(l0))) CALL finite_hydro_arrays(ln, sections, types, diam, cdn, cdt, can, cat) - ALLOCATE (viv_cl(SIZE(l0)), viv_cf(SIZE(l0)), viv_df(SIZE(l0))) - CALL finite_viv_arrays(ln, sections, types, viv_cl, viv_cf, viv_df) + ALLOCATE (viv_cl(SIZE(l0)), viv_cf(SIZE(l0)), viv_df(SIZE(l0)), viv_clx(SIZE(l0)), viv_al(SIZE(l0))) + CALL finite_viv_arrays(ln, sections, types, viv_cl, viv_cf, viv_df, viv_clx, viv_al) IF (SIZE(l0_am) /= SIZE(l0)) THEN 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) + CALL remap_elem_by_reference_arc(viv_clx, l0, l0_am) + CALL remap_elem_by_reference_arc(viv_al, l0, l0_am) CALL remap_elem_by_reference_arc(rho_a, l0, l0_am) CALL remap_elem_by_reference_arc(diam, l0, l0_am) CALL remap_elem_by_reference_arc(cdn, l0, l0_am) @@ -3591,11 +3599,20 @@ RECURSIVE SUBROUTINE build_one_hermite_cable(ln, sections, types, points, opts, ELSE CALL CD_Deck_VIV_Phase_Seed(cable%line%l0, ln%ends_swapped, seed, zero=opts%viv_phase_zero) END IF - 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) + ! with the in-line VIV of the VIV section where a type has ClX > 0 + 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) + 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) + END IF END BLOCK IF (es /= CD_HCDYN_OK) THEN CALL fail(ErrStat, ErrMsg, 'finite-EI cable VIV wiring failed: '//TRIM(em)); RETURN @@ -11556,13 +11573,13 @@ SUBROUTINE finite_hydro_arrays(ln, sections, types, diam, cdn, cdt, can, cat) cat = cat(SIZE(cat):1:-1) END SUBROUTINE finite_hydro_arrays - SUBROUTINE finite_viv_arrays(ln, sections, types, cl, cf, df) - !! Expand the section VIV columns (Cl dF cF) to finite-EI element arrays, in the element - !! order of finite_hydro_arrays. + SUBROUTINE finite_viv_arrays(ln, sections, types, cl, cf, df, clx, il_alpha) + !! Expand the section VIV columns (Cl dF cF) and the VIV section's in-line ClX and alpha 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) :: cl(:), cf(:), df(:) + REAL(wp), INTENT(OUT) :: cl(:), cf(:), df(:), clx(:), il_alpha(:) INTEGER :: i, j, e, tidx e = 0 @@ -11574,13 +11591,31 @@ SUBROUTINE finite_viv_arrays(ln, sections, types, cl, cf, df) cl(e) = types(tidx)%cl cf(e) = types(tidx)%viv_cf df(e) = types(tidx)%viv_df + clx(e) = types(tidx)%clx + il_alpha(e) = types(tidx)%il_alpha END DO END DO cl = cl(SIZE(cl):1:-1) cf = cf(SIZE(cf):1:-1) df = df(SIZE(df):1:-1) + clx = clx(SIZE(clx):1:-1) + il_alpha = il_alpha(SIZE(il_alpha):1:-1) END SUBROUTINE finite_viv_arrays + LOGICAL FUNCTION line_has_viv_il(ln, types, sections) RESULT(has) + !! Whether a section of the line uses a line type with in-line VIV (VIV ClX > 0). + TYPE(DeckLine), INTENT(IN) :: ln + TYPE(DeckLineType), INTENT(IN) :: types(:) + TYPE(DeckSection), INTENT(IN) :: sections(:) + INTEGER :: j + has = .FALSE. + DO j = 1, SIZE(sections) + 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)%clx > CD_ZERO) has = .TRUE. + END DO + END FUNCTION line_has_viv_il + 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 @@ -13692,6 +13727,9 @@ SUBROUTINE parse_deck(path, types, bodies, rod_types, rods, points, lines, secti CHARACTER(DECK_RECLEN), ALLOCATABLE :: stf_rows(:) INTEGER, ALLOCATABLE :: stf_lines(:) INTEGER :: n_stf + CHARACTER(DECK_RECLEN), ALLOCATABLE :: viv_rows(:) + INTEGER, ALLOCATABLE :: viv_lines(:) + INTEGER :: n_viv 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 @@ -13709,7 +13747,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_STIFF = 18, SEC_VIV = 19 ErrStat = 0; ErrMsg = '' ext_march = .FALSE. @@ -13731,6 +13769,8 @@ SUBROUTINE parse_deck(path, types, bodies, rod_types, rods, points, lines, secti n_att = 0 ALLOCATE (stf_rows(0), stf_lines(0)) n_stf = 0 + ALLOCATE (viv_rows(0), viv_lines(0)) + n_viv = 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)) @@ -13856,6 +13896,15 @@ SUBROUTINE parse_deck(path, types, bodies, rod_types, rods, points, lines, secti END IF stf_rows(n_stf) = line(1:MIN(LEN(line), DECK_RECLEN)) stf_lines(n_stf) = lineno + CASE (SEC_VIV) + IF (.NOT. has_numeric_token(line)) CYCLE + n_viv = n_viv + 1 + IF (n_viv > SIZE(viv_rows)) THEN + viv_rows = [viv_rows, [(REPEAT(' ', DECK_RECLEN), i_ch=1, 8)]] + viv_lines = [viv_lines, [(0, i_ch=1, 8)]] + END IF + viv_rows(n_viv) = line(1:MIN(LEN(line), DECK_RECLEN)) + viv_lines(n_viv) = lineno CASE (SEC_OPTIONS) CALL apply_option(line, opts, ErrStat, ErrMsg) CASE (SEC_OUTPUTS) @@ -13953,6 +14002,13 @@ SUBROUTINE parse_deck(path, types, bodies, rod_types, rods, points, lines, secti RETURN END IF END DO + DO i_ch = 1, n_viv + CALL apply_type_viv(viv_rows(i_ch), types, ErrStat, ErrMsg) + IF (ErrStat /= 0) THEN + CALL add_row_context('deck', viv_lines(i_ch), viv_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 @@ -15619,6 +15675,8 @@ SUBROUTINE set_section(secname, section, ErrStat, ErrMsg) section = 17 CASE ('STIFFENERS', 'STIFFENER', 'BEND STIFFENERS', 'BEND STIFFENER') section = 18 + CASE ('VIV', 'VORTEX-INDUCED VIBRATION', 'VORTEX INDUCED VIBRATION') + section = 19 CASE DEFAULT IF (LEN_TRIM(secname) > NAMELEN) THEN CALL fail(ErrStat, ErrMsg, 'unknown deck section "'//secname(1:NAMELEN)//'..."') @@ -17135,6 +17193,63 @@ SUBROUTINE append_line_attachment(row, lines, ErrStat, ErrMsg) CALL MOVE_ALLOC(grown, lines(li)%att) END SUBROUTINE append_line_attachment + SUBROUTINE apply_type_viv(row, types, ErrStat, ErrMsg) + !! One VIV row: TypeName ClX [alpha] -- the in-line VIV of a line type (Ulveseter et al. 2018): + !! the in-line shedding coefficient C_vx >= 0 (0 = off) and the frequency band 0 <= alpha < 1 + !! of its phase about twice the cross-flow one (default 0.15). The in-line phase rate is + !! slaved to the cross-flow one, so ClX > 0 needs the type's LINE TYPES lift Cl > 0. 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 + REAL(wp) :: clx, alpha + LOGICAL :: found, ok + + ErrStat = 0; ErrMsg = '' + ntok = count_tokens(row) + IF (ntok /= 2 .AND. ntok /= 3) THEN + CALL fail(ErrStat, ErrMsg, 'VIV rows must be: TypeName ClX [alpha]'); 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 row names undefined LINE TYPE "'//TRIM(tok)//'"'); RETURN + END IF + IF (types(it)%has_viv_row) THEN + CALL fail(ErrStat, ErrMsg, 'VIV names LINE TYPE "'//TRIM(types(it)%name)//'" twice'); RETURN + END IF + CALL get_token(row, 2, tok, found) + CALL parse_real_token(tok, clx, ok) + alpha = CD_VIV_DEFAULT_IL_ALPHA + IF (ok .AND. ntok == 3) THEN + CALL get_token(row, 3, tok, found) + CALL parse_real_token(tok, alpha, ok) + END IF + IF (.NOT. ok) THEN + CALL fail(ErrStat, ErrMsg, 'VIV ClX and alpha must be plain numbers'); RETURN + END IF + IF (.NOT. (IEEE_IS_FINITE(clx) .AND. IEEE_IS_FINITE(alpha))) THEN + CALL fail(ErrStat, ErrMsg, 'VIV ClX and alpha must be finite'); RETURN + END IF + IF (clx < CD_ZERO .OR. clx > MAX_COEFFICIENT) THEN + CALL fail(ErrStat, ErrMsg, 'VIV in-line coefficient ClX must be non-negative (0 = in-line VIV off) and at '// & + 'most 1e15'); RETURN + END IF + IF (.NOT. (alpha >= CD_ZERO .AND. alpha < CD_ONE)) THEN + CALL fail(ErrStat, ErrMsg, 'VIV in-line frequency band alpha must satisfy 0 <= alpha < 1'); RETURN + END IF + IF (clx > CD_ZERO .AND. .NOT. (types(it)%cl > CD_ZERO)) THEN + CALL fail(ErrStat, ErrMsg, 'VIV in-line VIV of LINE TYPE "'//TRIM(types(it)%name)//'" needs its '// & + 'cross-flow lift (LINE TYPES Cl > 0): the in-line phase runs at twice the cross-flow one'); RETURN + END IF + types(it)%clx = clx + types(it)%il_alpha = alpha + types(it)%has_viv_row = .TRUE. + END SUBROUTINE apply_type_viv + 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 @@ -19668,6 +19783,15 @@ SUBROUTINE finalize_checks(types, bodies, rod_types, rods, points, lines, sectio END IF END DO + ! VIV in-line rows: the in-line force acts on finite-EI lines + DO j = 1, SIZE(lines) + IF (line_is_finite_ei(lines(j), types, sections)) CYCLE + IF (.NOT. line_has_viv_il(lines(j), types, sections)) CYCLE + at_line = lines(j)%deck_line + CALL fail(ErrStat, ErrMsg, 'line '//TRIM(int_to_str(lines(j)%id))//' is an EI = 0 line of a type with '// & + 'in-line VIV (VIV ClX > 0): in-line VIV acts on finite-EI lines (EI > 0)'); RETURN + END DO + ! STIFFENERS: bend stiffeners sleeving the ends of a finite-EI line DO j = 1, SIZE(lines) IF (.NOT. ALLOCATED(lines(j)%stf)) CYCLE diff --git a/src/CableDyn_HermiteCableDynamic.f90 b/src/CableDyn_HermiteCableDynamic.f90 index 793d61f5..e1bef7bc 100644 --- a/src/CableDyn_HermiteCableDynamic.f90 +++ b/src/CableDyn_HermiteCableDynamic.f90 @@ -66,7 +66,8 @@ MODULE CableDyn_HermiteCableDynamic CD_HCABLE_OK USE CableDyn_Linalg, ONLY: CD_Factor_Banded, CD_Solve_Factored_Banded, CD_LINALG_OK USE CableDyn_VIV, ONLY: CD_VIV_Lift_Per_Length, CD_VIV_Crossflow_Along, CD_VIV_Phase_Rate, CD_VIV_Mean_Square, & - CD_VIV_Wrap_Phase, CD_VIV_TWO_PI, CD_VIV_NM + CD_VIV_Wrap_Phase, CD_VIV_TWO_PI, CD_VIV_NM, CD_VIV_Inline_Per_Length, & + CD_VIV_Inline_Phase_Rate 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, & @@ -126,6 +127,7 @@ MODULE CableDyn_HermiteCableDynamic PUBLIC :: CD_HermiteCable_Dyn_On_Seabed PUBLIC :: CD_HermiteCable_Dyn_Set_Irregular_Waves PUBLIC :: CD_HermiteCable_Drag_Element + PUBLIC :: CD_HermiteCable_VIV_Lift_Element PUBLIC :: CD_HermiteCable_Axial_Damping_Element PUBLIC :: CD_HermiteCable_Axial_Damping_Resultant PUBLIC :: CD_HermiteCable_AddedMass_Element @@ -327,6 +329,16 @@ MODULE CableDyn_HermiteCableDynamic REAL(wp), ALLOCATABLE :: viv_rate(:), viv_ms(:, :), viv_ms_next(:, :) REAL(wp), ALLOCATABLE :: ws_recovery_viv_phi(:), ws_recovery_viv_ms(:, :), snap_viv_phi(:), snap_viv_ms(:, :) LOGICAL, ALLOCATABLE :: viv_node(:) + ! In-line VIV (Set_VIV clx, il_alpha; CableDyn_VIV): vil_k(e) = 1/2 rho D C_vx of each element + ! (0: no in-line force), the frequency band alpha per node (vil_alpha), the in-line shedding + ! phase and the running mean squares of the in-line velocity and acceleration per node, with + ! the cross-flow state's eval, rate, next, recovery and snapshot twins. Its phase rate is + ! twice the cross-flow one, so it lives on cross-flow (viv_node) nodes only. + LOGICAL :: has_viv_il = .FALSE. + REAL(wp), ALLOCATABLE :: vil_cx(:), vil_k(:), vil_alpha(:), vil_phi(:), vil_phi_eval(:), vil_rate(:) + 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(:) REAL(wp), ALLOCATABLE :: Mgb(:, :) ! constant global mass (band) LOGICAL, ALLOCATABLE :: freemask(:), solve_mask(:) INTEGER, ALLOCATABLE :: fmap(:) ! free -> global DOF index @@ -1084,7 +1096,8 @@ SUBROUTINE CD_HermiteCable_Dyn_Set_Friction_Axial(model, mu_axial, ErrStat, ErrM model%tr_valid = .FALSE. 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) + SUBROUTINE CD_HermiteCable_Dyn_Set_VIV(model, cl, cf, df, t_window, ErrStat, ErrMsg, phase_seed, tangent_reversed, & + clx, il_alpha) !! 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 @@ -1099,6 +1112,11 @@ SUBROUTINE CD_HermiteCable_Dyn_Set_VIV(model, cl, cf, df, t_window, ErrStat, Err !! carries any waves); the internal wave families (Set_Waves) are refused with VIV. The !! committed acceleration is refreshed with the new lift; if that fails, the previous VIV !! configuration, its state and the acceleration are restored. + !! + !! In-line VIV (Ulveseter et al. 2018; both or neither): clx, per element, the in-line shedding + !! coefficient C_vx (0: none; > 0 only where cl > 0, the in-line phase rate being twice the + !! cross-flow one) and il_alpha its frequency band (0 <= alpha < 1). The in-line phase of a + !! node starts at twice its cross-flow phase. TYPE(CD_HermiteCableDynType), INTENT(INOUT) :: model REAL(wp), INTENT(IN) :: cl(:), cf(:), df(:), t_window INTEGER, INTENT(OUT) :: ErrStat @@ -1108,14 +1126,17 @@ SUBROUTINE CD_HermiteCable_Dyn_Set_VIV(model, cl, cf, df, t_window, ErrStat, Err !! MoorDyn's node tangent, so a node at rest takes the cross-flow phase pi !! (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(:) INTEGER :: e, k, ne, nn, es REAL(wp) :: wsum, tw_old, rest_old - LOGICAL :: had_viv + LOGICAL :: had_viv, had_il, want_il 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(:, :), & o_snap_phi(:), o_snap_ms(:, :) - LOGICAL, ALLOCATABLE :: o_node(:) + 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(:, :) + LOGICAL, ALLOCATABLE :: o_node(:), x_node(:) ErrStat = CD_HCDYN_OK; ErrMsg = '' IF (.NOT. model%initialized) THEN @@ -1152,8 +1173,33 @@ SUBROUTINE CD_HermiteCable_Dyn_Set_VIV(model, cl, cf, df, t_window, ErrStat, Err ErrMsg = 'CD_HermiteCable_Dyn_Set_VIV: internal waves are configured; VIV takes waves as a held '// & 'host fluid field (CD_HermiteCable_Dyn_Set_Held_Fluid)'; RETURN END IF + IF (PRESENT(clx) .NEQV. PRESENT(il_alpha)) THEN + ErrStat = CD_HCDYN_BADINPUT + ErrMsg = 'CD_HermiteCable_Dyn_Set_VIV: the in-line clx and il_alpha go together'; RETURN + END IF + want_il = .FALSE. + IF (PRESENT(clx)) THEN + IF (SIZE(clx) /= ne .OR. SIZE(il_alpha) /= ne) THEN + ErrStat = CD_HCDYN_BADINPUT + ErrMsg = 'CD_HermiteCable_Dyn_Set_VIV: clx and il_alpha must each have one value per element'; RETURN + END IF + IF (.NOT. (CD_All_Finite(clx) .AND. CD_All_Finite(il_alpha))) THEN + ErrStat = CD_HCDYN_BADINPUT; ErrMsg = 'CD_HermiteCable_Dyn_Set_VIV: clx and il_alpha must be finite'; RETURN + END IF + IF (ANY(clx < CD_ZERO) .OR. ANY(clx > CD_ZERO .AND. .NOT. (il_alpha >= CD_ZERO .AND. il_alpha < CD_ONE))) THEN + ErrStat = CD_HCDYN_BADINPUT + ErrMsg = 'CD_HermiteCable_Dyn_Set_VIV: need clx >= 0 and 0 <= il_alpha < 1 where clx > 0'; RETURN + END IF + IF (ANY(clx > CD_ZERO .AND. .NOT. (cl > CD_ZERO))) THEN + ErrStat = CD_HCDYN_BADINPUT + ErrMsg = 'CD_HermiteCable_Dyn_Set_VIV: in-line VIV (clx > 0) needs the cross-flow lift (cl > 0) on the '// & + 'same element: its phase rate is twice the cross-flow one'; RETURN + END IF + want_il = ANY(clx > CD_ZERO) + END IF ! the previous configuration and state, kept for a rollback had_viv = model%has_viv + had_il = model%has_viv_il tw_old = model%viv_tw rest_old = model%viv_phi_rest a_old = model%a @@ -1194,6 +1240,38 @@ SUBROUTINE CD_HermiteCable_Dyn_Set_VIV(model, cl, cf, df, t_window, ErrStat, Err model%viv_phi(k) = CD_VIV_Wrap_Phase(CD_VIV_TWO_PI*(REAL(nn - k, wp)/REAL(ne, wp) + 0.5_wp)) IF (PRESENT(phase_seed)) model%viv_phi(k) = CD_VIV_TWO_PI*phase_seed(k) END DO + IF (want_il) THEN + ALLOCATE (model%vil_cx(ne), model%vil_k(ne), model%vil_alpha(nn), model%vil_phi(nn), model%vil_phi_eval(nn), & + model%vil_rate(nn), model%vil_ms(2, nn), model%vil_ms_next(2, nn), model%ws_recovery_vil_phi(nn), & + model%ws_recovery_vil_ms(2, nn), model%snap_vil_phi(nn), model%snap_vil_ms(2, nn), & + model%vil_node(nn)) + model%vil_cx = clx + model%vil_alpha = CD_ZERO + model%vil_node = .FALSE. + model%vil_phi = CD_ZERO + model%vil_ms = CD_ZERO + ! node values: the length-weighted average over the node's in-line elements + DO k = 1, nn + wsum = CD_ZERO + DO e = MAX(1, k - 1), MIN(ne, k) + IF (.NOT. (clx(e) > CD_ZERO)) CYCLE + wsum = wsum + model%l0(e) + model%vil_alpha(k) = model%vil_alpha(k) + model%l0(e)*il_alpha(e) + END DO + IF (.NOT. (wsum > CD_ZERO)) CYCLE + model%vil_node(k) = .TRUE. + model%vil_alpha(k) = model%vil_alpha(k)/wsum + model%vil_phi(k) = CD_VIV_Wrap_Phase(2.0_wp*model%viv_phi(k)) + END DO + model%vil_phi_eval = model%vil_phi + model%vil_rate = CD_ZERO + model%vil_ms_next = model%vil_ms + model%ws_recovery_vil_phi = model%vil_phi + model%ws_recovery_vil_ms = model%vil_ms + model%snap_vil_phi = model%vil_phi + model%snap_vil_ms = model%vil_ms + model%has_viv_il = .TRUE. + END IF CALL viv_drag_terms(model) model%viv_phi_eval = model%viv_phi model%viv_rate = CD_ZERO @@ -1216,6 +1294,7 @@ SUBROUTINE refresh_acceleration() CALL clear_viv(model) CALL move_viv(.TRUE.) model%has_viv = had_viv + model%has_viv_il = had_il model%viv_tw = tw_old model%viv_phi_rest = rest_old model%a = a_old @@ -1235,6 +1314,13 @@ SUBROUTINE move_viv(back) CALL MOVE_ALLOC(o_rec_phi, model%ws_recovery_viv_phi); CALL MOVE_ALLOC(o_rec_ms, model%ws_recovery_viv_ms) CALL MOVE_ALLOC(o_snap_phi, model%snap_viv_phi); CALL MOVE_ALLOC(o_snap_ms, model%snap_viv_ms) CALL MOVE_ALLOC(o_node, model%viv_node) + CALL MOVE_ALLOC(x_cx, model%vil_cx); CALL MOVE_ALLOC(x_k, model%vil_k) + CALL MOVE_ALLOC(x_al, model%vil_alpha); CALL MOVE_ALLOC(x_phi, model%vil_phi) + CALL MOVE_ALLOC(x_phi_eval, model%vil_phi_eval); CALL MOVE_ALLOC(x_rate, model%vil_rate) + CALL MOVE_ALLOC(x_ms, model%vil_ms); CALL MOVE_ALLOC(x_ms_next, model%vil_ms_next) + CALL MOVE_ALLOC(x_rec_phi, model%ws_recovery_vil_phi); CALL MOVE_ALLOC(x_rec_ms, model%ws_recovery_vil_ms) + 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) 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) @@ -1244,6 +1330,13 @@ SUBROUTINE move_viv(back) CALL MOVE_ALLOC(model%ws_recovery_viv_phi, o_rec_phi); CALL MOVE_ALLOC(model%ws_recovery_viv_ms, o_rec_ms) CALL MOVE_ALLOC(model%snap_viv_phi, o_snap_phi); CALL MOVE_ALLOC(model%snap_viv_ms, o_snap_ms) CALL MOVE_ALLOC(model%viv_node, o_node) + CALL MOVE_ALLOC(model%vil_cx, x_cx); CALL MOVE_ALLOC(model%vil_k, x_k) + CALL MOVE_ALLOC(model%vil_alpha, x_al); CALL MOVE_ALLOC(model%vil_phi, x_phi) + CALL MOVE_ALLOC(model%vil_phi_eval, x_phi_eval); CALL MOVE_ALLOC(model%vil_rate, x_rate) + CALL MOVE_ALLOC(model%vil_ms, x_ms); CALL MOVE_ALLOC(model%vil_ms_next, x_ms_next) + CALL MOVE_ALLOC(model%ws_recovery_vil_phi, x_rec_phi); CALL MOVE_ALLOC(model%ws_recovery_vil_ms, x_rec_ms) + 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) END IF END SUBROUTINE move_viv END SUBROUTINE CD_HermiteCable_Dyn_Set_VIV @@ -1257,18 +1350,25 @@ SUBROUTINE clear_viv(model) model%viv_ms_next, model%ws_recovery_viv_phi, & model%ws_recovery_viv_ms, model%snap_viv_phi, model%snap_viv_ms, & model%viv_node) + IF (ALLOCATED(model%vil_k)) DEALLOCATE (model%vil_cx, model%vil_k, model%vil_alpha, model%vil_phi, & + model%vil_phi_eval, model%vil_rate, model%vil_ms, model%vil_ms_next, & + model%ws_recovery_vil_phi, model%ws_recovery_vil_ms, & + model%snap_vil_phi, model%snap_vil_ms, model%vil_node) model%has_viv = .FALSE. + model%has_viv_il = .FALSE. model%viv_tw = CD_ZERO END SUBROUTINE clear_viv SUBROUTINE viv_drag_terms(model) !! The VIV quantities taken from the drag configuration, set with VIV and again whenever the !! drag is reconfigured: the lift scale viv_k = 1/2 rho D Cl of each element and the node - !! diameter viv_dn, the length-weighted average over the node's lifting elements. + !! diameter viv_dn, the length-weighted average over the node's lifting elements, and the + !! in-line scale vil_k = 1/2 rho D C_vx. 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 model%viv_dn = CD_ZERO DO k = 1, model%nn IF (.NOT. model%viv_node(k)) CYCLE @@ -1282,20 +1382,27 @@ SUBROUTINE viv_drag_terms(model) END DO END SUBROUTINE viv_drag_terms - SUBROUTINE viv_node_motion(model, k, yd, ydd, un, ok) + 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). + !! tangent (the slope DOFs), in the flow the drag sees there (current plus a held field); + !! optionally (both or neither) the in-line ones. TYPE(CD_HermiteCableDynType), INTENT(IN) :: model INTEGER, INTENT(IN) :: k REAL(wp), INTENT(OUT) :: yd, ydd, un LOGICAL, INTENT(OUT) :: ok + REAL(wp), INTENT(OUT), OPTIONAL :: xd, xdd REAL(wp) :: uu(3) INTEGER :: i0 i0 = 6*(k - 1) uu = model%current IF (model%has_held_field) uu = uu + model%hf_u(:, k) - CALL CD_VIV_Crossflow_Along(model%q(i0 + 4:i0 + 6), model%v(i0 + 1:i0 + 3), model%a(i0 + 1:i0 + 3), uu, & - yd, ydd, un, ok) + IF (PRESENT(xd)) THEN + CALL CD_VIV_Crossflow_Along(model%q(i0 + 4:i0 + 6), model%v(i0 + 1:i0 + 3), model%a(i0 + 1:i0 + 3), uu, & + yd, ydd, un, ok, xd, xdd) + ELSE + CALL CD_VIV_Crossflow_Along(model%q(i0 + 4:i0 + 6), model%v(i0 + 1:i0 + 3), model%a(i0 + 1:i0 + 3), uu, & + yd, ydd, un, ok) + END IF END SUBROUTINE viv_node_motion SUBROUTINE viv_step_begin(model, dt, ErrStat, ErrMsg) @@ -1309,7 +1416,7 @@ 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 + REAL(wp) :: w, frac, yd, ydd, un, xd, xdd LOGICAL :: ok ErrStat = CD_HCDYN_OK; ErrMsg = '' IF (.NOT. (model%viv_tw > CD_ZERO)) model%viv_tw = REAL(CD_VIV_NM, wp)*dt @@ -1319,9 +1426,14 @@ SUBROUTINE viv_step_begin(model, dt, ErrStat, ErrMsg) model%viv_rate = CD_ZERO model%viv_ms_next = model%viv_ms model%viv_phi_eval = model%viv_phi + IF (model%has_viv_il) THEN + model%vil_rate = CD_ZERO + model%vil_ms_next = model%vil_ms + model%vil_phi_eval = model%vil_phi + END IF DO k = 1, model%nn IF (.NOT. model%viv_node(k)) CYCLE - CALL viv_node_motion(model, k, yd, ydd, un, ok) + CALL viv_node_motion(model, k, yd, ydd, un, ok, xd, xdd) IF (.NOT. ok) THEN ErrStat = CD_HCDYN_NOCONVERGE; ErrMsg = 'VIV phase: degenerate node tangent'; RETURN END IF @@ -1331,6 +1443,13 @@ SUBROUTINE viv_step_begin(model, dt, ErrStat, ErrMsg) model%viv_phi(k), un, model%viv_dn(k), model%viv_cf(k), & model%viv_df(k), phi_rest=model%viv_phi_rest) model%viv_phi_eval(k) = model%viv_phi(k) + frac*dt*model%viv_rate(k) + IF (.NOT. model%has_viv_il) CYCLE + IF (.NOT. model%vil_node(k)) CYCLE + model%vil_ms_next(1, k) = CD_VIV_Mean_Square(model%vil_ms(1, k), xd, w) + model%vil_ms_next(2, k) = CD_VIV_Mean_Square(model%vil_ms(2, k), xdd, w) + model%vil_rate(k) = CD_VIV_Inline_Phase_Rate(xd, xdd, model%vil_ms_next(1, k), model%vil_ms_next(2, k), & + model%vil_phi(k), model%viv_rate(k), model%vil_alpha(k)) + model%vil_phi_eval(k) = model%vil_phi(k) + frac*dt*model%vil_rate(k) END DO END SUBROUTINE viv_step_begin @@ -1344,29 +1463,47 @@ 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 - LOGICAL :: ok + REAL(wp) :: w, yd, ydd, un, ms1, ms2, rate_end, xd, xdd, rate_end_x + LOGICAL :: ok, il w = MIN(CD_ONE, dt/model%viv_tw) DO k = 1, model%nn IF (.NOT. model%viv_node(k)) CYCLE + il = .FALSE. + IF (model%has_viv_il) il = model%vil_node(k) rate_end = model%viv_rate(k) - CALL viv_node_motion(model, k, yd, ydd, un, ok) + rate_end_x = CD_ZERO + IF (il) rate_end_x = model%vil_rate(k) + CALL viv_node_motion(model, k, yd, ydd, un, ok, xd, xdd) IF (ok) THEN ms1 = CD_VIV_Mean_Square(model%viv_ms_next(1, k), yd, w) ms2 = CD_VIV_Mean_Square(model%viv_ms_next(2, k), ydd, w) rate_end = CD_VIV_Phase_Rate(yd, ydd, ms1, ms2, model%viv_phi(k) + dt*model%viv_rate(k), un, & model%viv_dn(k), model%viv_cf(k), model%viv_df(k), phi_rest=model%viv_phi_rest) IF (.NOT. CD_Is_Finite(rate_end)) rate_end = model%viv_rate(k) + IF (il) THEN + ! the in-line rate at the end state is slaved to the end cross-flow rate (Eq. 6) + ms1 = CD_VIV_Mean_Square(model%vil_ms_next(1, k), xd, w) + ms2 = CD_VIV_Mean_Square(model%vil_ms_next(2, k), xdd, w) + rate_end_x = CD_VIV_Inline_Phase_Rate(xd, xdd, ms1, ms2, model%vil_phi(k) + dt*model%vil_rate(k), & + rate_end, model%vil_alpha(k)) + IF (.NOT. CD_Is_Finite(rate_end_x)) rate_end_x = model%vil_rate(k) + END IF END IF model%viv_phi(k) = CD_VIV_Wrap_Phase(model%viv_phi(k) + 0.5_wp*dt*(model%viv_rate(k) + rate_end)) + IF (il) model%vil_phi(k) = CD_VIV_Wrap_Phase(model%vil_phi(k) + 0.5_wp*dt*(model%vil_rate(k) + rate_end_x)) END DO model%viv_ms = model%viv_ms_next model%viv_phi_eval = model%viv_phi + IF (model%has_viv_il) THEN + model%vil_ms = model%vil_ms_next + model%vil_phi_eval = model%vil_phi + END IF END SUBROUTINE viv_step_end SUBROUTINE viv_element_lift(model, q_cfg, v_cfg, e, flift, ErrStat, ErrMsg, djq, djv) !! The VIV lift load of element e at the phase viv_phi_eval in the flow the drag sees (current, - !! held field), with its Jacobians djq, djv (both or neither). + !! held field), with its Jacobians djq, djv (both or neither); with in-line VIV it includes the + !! in-line shedding force at the phase vil_phi_eval. TYPE(CD_HermiteCableDynType), INTENT(IN) :: model REAL(wp), INTENT(IN) :: q_cfg(:), v_cfg(:) INTEGER, INTENT(IN) :: e @@ -1374,7 +1511,8 @@ SUBROUTINE viv_element_lift(model, q_cfg, v_cfg, e, flift, ErrStat, ErrMsg, djq, INTEGER, INTENT(OUT) :: ErrStat CHARACTER(*), INTENT(OUT) :: ErrMsg REAL(wp), INTENT(OUT), OPTIONAL :: djq(12, 12), djv(12, 12) - REAL(wp) :: qe(12), ve(12), uu(3), wl, kn(2) + REAL(wp) :: qe(12), ve(12), uu(3), wl, kn(2), knx(2) + LOGICAL :: il flift = CD_ZERO IF (PRESENT(djq)) THEN djq = CD_ZERO; djv = CD_ZERO @@ -1390,7 +1528,18 @@ SUBROUTINE viv_element_lift(model, q_cfg, v_cfg, e, flift, ErrStat, ErrMsg, djq, 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 (PRESENT(djq)) THEN + il = .FALSE. + IF (model%has_viv_il) il = model%vil_k(e) > CD_ZERO + IF (il) THEN + knx = model%vil_k(e)*[COS(model%vil_phi_eval(e)), COS(model%vil_phi_eval(e + 1))] + IF (PRESENT(djq)) THEN + CALL CD_HermiteCable_VIV_Lift_Element(qe, ve, model%l0(e), uu, wl, kn, flift, djq, djv, ErrStat, ErrMsg, & + kx_node=knx) + ELSE + CALL CD_HermiteCable_VIV_Lift_Element(qe, ve, model%l0(e), uu, wl, kn, flift, ErrStat=ErrStat, & + ErrMsg=ErrMsg, kx_node=knx) + END IF + ELSE IF (PRESENT(djq)) THEN CALL CD_HermiteCable_VIV_Lift_Element(qe, ve, model%l0(e), uu, wl, kn, flift, djq, djv, ErrStat, ErrMsg) ELSE CALL CD_HermiteCable_VIV_Lift_Element(qe, ve, model%l0(e), uu, wl, kn, flift, ErrStat=ErrStat, & @@ -1401,7 +1550,8 @@ END SUBROUTINE viv_element_lift SUBROUTINE CD_HermiteCable_Dyn_VIV_Node_Lift(model, lift, ErrStat, ErrMsg) !! The VIV lift on every node at the committed state [N] (3, nn), in the model frame: the !! translational components of the elements' consistent lift loads, summed at the nodes - !! (MoorDyn's nodal lift on a lumped line). Zero on a cable without VIV. + !! (MoorDyn's nodal lift on a lumped line), with the in-line shedding force where it is on. + !! Zero on a cable without VIV. TYPE(CD_HermiteCableDynType), INTENT(IN) :: model REAL(wp), INTENT(OUT) :: lift(:, :) INTEGER, INTENT(OUT) :: ErrStat @@ -3725,6 +3875,7 @@ SUBROUTINE CD_HermiteCable_Dyn_Step(model, dt, max_iter, tol, ErrStat, ErrMsg, i model%tors_use_step = .FALSE. ! 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 END SUBROUTINE CD_HermiteCable_Dyn_Step SUBROUTINE CD_HermiteCable_Dyn_Set_Torsion_Drive(model, ends, phi, ErrStat, ErrMsg) @@ -5582,6 +5733,10 @@ 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%has_viv_il) THEN + model%ws_recovery_vil_phi = model%vil_phi + model%ws_recovery_vil_ms = model%vil_ms + END IF IF (model%has_ctrl) THEN model%ws_recovery_l0_c = model%l0_c model%ws_recovery_l0_dot_c = model%l0_dot_c @@ -5679,6 +5834,10 @@ 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%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 + END IF IF (model%has_ctrl) model%l0_c = model%ws_recovery_l0_c IF (model%has_ctrl) model%l0_dot_c = model%ws_recovery_l0_dot_c model%na_steps_done = na_steps_save; model%na_iter_sum = na_sum_save; model%na_mn_active = na_mn_save @@ -5759,6 +5918,10 @@ 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%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 + END IF IF (model%has_ctrl) model%l0_c = model%ws_recovery_l0_c IF (model%has_ctrl) model%l0_dot_c = model%ws_recovery_l0_dot_c model%na_steps_done = na_steps_save @@ -5809,6 +5972,10 @@ 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%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 + END IF IF (model%has_ctrl) model%l0_c = model%ws_recovery_l0_c IF (model%has_ctrl) model%l0_dot_c = model%ws_recovery_l0_dot_c model%na_steps_done = na_steps_save; model%na_iter_sum = na_sum_save; model%na_mn_active = na_mn_save @@ -8391,6 +8558,10 @@ 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%has_viv_il) THEN + model%snap_vil_phi = model%vil_phi + model%snap_vil_ms = model%vil_ms + END IF ! the cached committed force goes with the state it describes (see fc_clears) model%snap_fc_valid = model%fc_valid .AND. ALLOCATED(model%fc_R) model%snap_fc_clears = model%fc_clears @@ -8473,6 +8644,10 @@ 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%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 + END IF model%na_steps_done = model%snap_na_steps_done model%na_iter_sum = model%snap_na_iter_sum model%na_mn_active = model%snap_na_mn_active @@ -11100,21 +11275,24 @@ SUBROUTINE CD_HermiteCable_Drag_Element(qe, ve, l0, fluid, waterline_z, rho, dia END SUBROUTINE CD_HermiteCable_Drag_Element SUBROUTINE CD_HermiteCable_VIV_Lift_Element(qe, ve, l0, fluid, waterline_z, k_node, flift, djq, djv, & - ErrStat, ErrMsg) + ErrStat, ErrMsg, kx_node) !! Consistent Gauss-integrated cross-flow VIV lift on one cubic-Hermite element: the load !! integral N^T f ds of the per-length lift f = k(xi) U (t x v_r) (CD_VIV_Lift_Per_Length), !! with k = 1/2 rho D Cl cos(phi) interpolated linearly between the element's end nodes !! (k_node), and its force Jacobians djq = d flift/d qe, djv = d flift/d ve (both or neither). !! The interpolation, measure and wet/dry culling are the drag element's (still waterline). + !! kx_node (optional) adds the in-line shedding force k_x U v_n (CD_VIV_Inline_Per_Length), + !! k_x = 1/2 rho D C_vx cos(phi_x) interpolated the same way. REAL(wp), INTENT(IN) :: qe(12), ve(12), l0, fluid(3), waterline_z, k_node(2) REAL(wp), INTENT(OUT) :: flift(12) REAL(wp), INTENT(OUT), OPTIONAL :: djq(12, 12), djv(12, 12) INTEGER, INTENT(OUT) :: ErrStat CHARACTER(*), INTENT(OUT) :: ErrMsg + REAL(wp), INTENT(IN), OPTIONAL :: kx_node(2) INTEGER, PARAMETER :: NGP = 3 REAL(wp), PARAMETER :: G3 = 0.7745966692414834_wp ! sqrt(3/5) REAL(wp) :: gp(NGP), gw(NGP), H(4), dH(4), rpos(3), vvel(3), rp(3), speed, tangent(3), fpl(3) - REAL(wp) :: jrel(3, 3), jtan(3, 3), scale, kg + REAL(wp) :: jrel(3, 3), jtan(3, 3), scale, kg, fx(3), jrx(3, 3), jtx(3, 3) LOGICAL :: want_jac, ok INTEGER :: g, s, c, sp, cp, a, b @@ -11144,6 +11322,17 @@ SUBROUTINE CD_HermiteCable_VIV_Lift_Element(qe, ve, l0, fluid, waterline_z, k_no ErrStat = CD_HCDYN_NOCONVERGE ErrMsg = 'CD_HermiteCable_VIV_Lift_Element: degenerate centreline (|dr/dxi| ~ 0)'; RETURN END IF + IF (PRESENT(kx_node)) THEN + kg = (CD_ONE - gp(g))*kx_node(1) + gp(g)*kx_node(2) + IF (want_jac) THEN + CALL CD_VIV_Inline_Per_Length(fluid - vvel, rp, kg, fx, ok, jrx, jtx) + jrel = jrel + jrx + jtan = jtan + jtx + ELSE + CALL CD_VIV_Inline_Per_Length(fluid - vvel, rp, kg, fx, ok) + END IF + fpl = fpl + fx + END IF speed = SQRT(rp(1)**2 + rp(2)**2 + rp(3)**2) tangent = rp/speed scale = gw(g)*speed diff --git a/src/CableDyn_OpenFAST_HermiteFMF.f90 b/src/CableDyn_OpenFAST_HermiteFMF.f90 index 39a8447f..9c0ab817 100644 --- a/src/CableDyn_OpenFAST_HermiteFMF.f90 +++ b/src/CableDyn_OpenFAST_HermiteFMF.f90 @@ -2249,13 +2249,15 @@ INTEGER FUNCTION CD_HFMF_ForceMirrorSize(self) RESULT(n) END FUNCTION CD_HFMF_ForceMirrorSize INTEGER FUNCTION CD_HFMF_VIVMirrorSize(self) RESULT(n) - !! Mirror slots of the cross-flow VIV state, before the torsion block: the shedding phase + !! 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); zero without VIV. + !! (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. 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 END FUNCTION CD_HFMF_VIVMirrorSize INTEGER FUNCTION CD_HFMF_FrictionMirrorSize(self) RESULT(n) @@ -2338,6 +2340,11 @@ SUBROUTINE CD_HFMF_PackMirror(self, buf, ErrStat, ErrMsg) buf(k + 3*self%line%nn + 1) = self%line%viv_tw k = k + 3*self%line%nn + 1 END IF + IF (self%line%has_viv_il) THEN + buf(k + 1:k + self%line%nn) = self%line%vil_phi + 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%torsion%active) THEN buf(k + 1) = self%line%torsion%theta buf(k + 2) = self%line%torsion%phi @@ -2427,6 +2434,14 @@ SUBROUTINE CD_HFMF_UnpackMirror(self, buf, t, ErrStat, ErrMsg) RETURN END IF END IF + IF (self%line%has_viv_il) THEN + kb = SIZE(buf) - CD_HFMF_TorsionMirrorSize(self) - 2*self%line%nn + IF (ANY(buf(kb + 1:kb + 2*self%line%nn) < CD_ZERO)) THEN + ErrStat = CD_HFMF_BADINPUT + ErrMsg = 'CD_HFMF_UnpackMirror: the in-line VIV mean squares must be non-negative' + RETURN + END IF + END IF k = 0 DO i = 1, self%line%ndof IF (self%line%freemask(i)) THEN @@ -2497,6 +2512,15 @@ SUBROUTINE CD_HFMF_UnpackMirror(self, buf, t, ErrStat, ErrMsg) self%line%ws_recovery_viv_ms = self%line%viv_ms k = k + 3*self%line%nn + 1 END IF + IF (self%line%has_viv_il) THEN + self%line%vil_phi = buf(k + 1:k + self%line%nn) + self%line%vil_ms = RESHAPE(buf(k + self%line%nn + 1:k + 3*self%line%nn), [2, self%line%nn]) + self%line%vil_phi_eval = self%line%vil_phi + self%line%vil_ms_next = self%line%vil_ms + self%line%ws_recovery_vil_phi = self%line%vil_phi + self%line%ws_recovery_vil_ms = self%line%vil_ms + k = k + 3*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 94a60ae0..966d9cd2 100644 --- a/src/CableDyn_VIV.f90 +++ b/src/CableDyn_VIV.f90 @@ -30,6 +30,18 @@ MODULE CableDyn_VIV !! (w_e the submerged fraction of element e): per unit length 1/2 rho D Cl U^2 cos(phi) !! along e, exactly MoorDyn's Lf = 1/2 rho_w d |Vp| Cl cos(phi) (q x Vp) l_node. !! + !! In-line VIV (Ulveseter, Thorsen, Saevik and Larsen, Mar. Struct. 60, 2018, 241-260, + !! Eq. 1, 2, 6 and 7): a second shedding force along the relative normal flow, + !! + !! F_x = C_x cos(phi_x) U v_n , per unit length 1/2 rho D C_vx U v_n cos(phi_x) + !! + !! whose phase is slaved to twice the cross-flow shedding rate with a free band alpha, + !! + !! d phi_x/dt = 2 (d phi/dt) [1 + alpha sin(phi_xd - phi_x)] + !! + !! phi_xd the phase of the in-line velocity x' = r'.v_n/U from x', x'' normalised by their + !! running RMS values, as phi_y. + !! !! Load convention (CableDyn_Hydro, CD_Cable_Dynamic_Load_Proc): `force` is the external !! load; the Jacobians are residual contributions, -dF/d(node velocity) and !! -dF/d(neighbour positions) through the node tangent. The wetted-fraction factor in C is @@ -46,6 +58,9 @@ MODULE CableDyn_VIV PUBLIC :: CD_VIV_Phase_Rate PUBLIC :: CD_VIV_Mean_Square PUBLIC :: CD_VIV_Wrap_Phase + PUBLIC :: CD_VIV_Node_Inline + PUBLIC :: CD_VIV_Inline_Per_Length + PUBLIC :: CD_VIV_Inline_Phase_Rate !> 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. @@ -55,6 +70,8 @@ MODULE CableDyn_VIV REAL(wp), PARAMETER, PUBLIC :: CD_VIV_DEFAULT_DF = 0.08_wp REAL(wp), PARAMETER, PUBLIC :: CD_VIV_DEFAULT_CF = 0.18_wp 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 !> Chord below which a node tangent is undefined (a collapsed pair of neighbours). REAL(wp), PARAMETER :: TINY_CHORD = 1.0e-12_wp @@ -155,23 +172,33 @@ PURE SUBROUTINE CD_VIV_Node_Lift(r_prev, r_next, rd, u, coef, phi, force, ok, ja jac_prev = -jac_next END SUBROUTINE CD_VIV_Node_Lift - PURE SUBROUTINE CD_VIV_Crossflow_Motion(r_prev, r_next, rd, rdd, u, yd, ydd, un, ok) + PURE SUBROUTINE CD_VIV_Crossflow_Motion(r_prev, r_next, rd, rdd, u, yd, ydd, un, ok, xd, xdd) !! Cross-flow velocity y' and acceleration y'' of a node along e = q x v_n / U, and the !! normal relative flow speed U. Both are zero when there is no normal flow (MoorDyn's - !! normalisation of a zero vector). + !! normalisation of a zero vector). Optionally (both or neither) the in-line velocity x' and + !! acceleration x'' along v_n/U, zero in the same cases. REAL(wp), INTENT(IN) :: r_prev(3), r_next(3), rd(3), rdd(3), u(3) REAL(wp), INTENT(OUT) :: yd, ydd, un LOGICAL, INTENT(OUT) :: ok + REAL(wp), INTENT(OUT), OPTIONAL :: xd, xdd REAL(wp) :: q(3), chord, vr(3), vn(3), e(3) yd = CD_ZERO ydd = CD_ZERO + IF (PRESENT(xd)) THEN + xd = CD_ZERO + xdd = CD_ZERO + END IF CALL node_frame(r_prev, r_next, rd, u, q, chord, vr, vn, un, ok) IF (.NOT. ok) RETURN IF (.NOT. (un > CD_ZERO)) RETURN e = cross3(q, vn)/un yd = rd(1)*e(1) + rd(2)*e(2) + rd(3)*e(3) ydd = rdd(1)*e(1) + rdd(2)*e(2) + rdd(3)*e(3) + IF (PRESENT(xd)) THEN + xd = (rd(1)*vn(1) + rd(2)*vn(2) + rd(3)*vn(3))/un + xdd = (rdd(1)*vn(1) + rdd(2)*vn(2) + rdd(3)*vn(3))/un + END IF END SUBROUTINE CD_VIV_Crossflow_Motion PURE SUBROUTINE CD_VIV_Lift_Per_Length(urel, rp, k, f, ok, jrel, jtan) @@ -237,17 +264,23 @@ PURE SUBROUTINE CD_VIV_Lift_Per_Length(urel, rp, k, f, ok, jrel, jtan) jtan = MATMUL(dfdt, proj) END SUBROUTINE CD_VIV_Lift_Per_Length - PURE SUBROUTINE CD_VIV_Crossflow_Along(tdir, rd, rdd, u, yd, ydd, un, ok) + PURE SUBROUTINE CD_VIV_Crossflow_Along(tdir, rd, rdd, u, yd, ydd, un, ok, xd, xdd) !! CD_VIV_Crossflow_Motion with the line tangent given directly (tdir, any length: the - !! slope DOFs of a finite-EI node) instead of the chord of two neighbours. + !! slope DOFs of a finite-EI node) instead of the chord of two neighbours, with the same + !! optional in-line velocity and acceleration (both or neither). REAL(wp), INTENT(IN) :: tdir(3), rd(3), rdd(3), u(3) REAL(wp), INTENT(OUT) :: yd, ydd, un LOGICAL, INTENT(OUT) :: ok + REAL(wp), INTENT(OUT), OPTIONAL :: xd, xdd REAL(wp) :: speed, t(3), vr(3), vn(3), e(3) yd = CD_ZERO ydd = CD_ZERO un = CD_ZERO + IF (PRESENT(xd)) THEN + xd = CD_ZERO + xdd = CD_ZERO + END IF speed = SQRT(tdir(1)*tdir(1) + tdir(2)*tdir(2) + tdir(3)*tdir(3)) ok = speed > TINY_CHORD IF (.NOT. ok) RETURN @@ -259,6 +292,10 @@ PURE SUBROUTINE CD_VIV_Crossflow_Along(tdir, rd, rdd, u, yd, ydd, un, ok) e = cross3(t, vn)/un yd = rd(1)*e(1) + rd(2)*e(2) + rd(3)*e(3) ydd = rdd(1)*e(1) + rdd(2)*e(2) + rdd(3)*e(3) + IF (PRESENT(xd)) THEN + xd = (rd(1)*vn(1) + rd(2)*vn(2) + rd(3)*vn(3))/un + xdd = (rdd(1)*vn(1) + rdd(2)*vn(2) + rdd(3)*vn(3))/un + END IF END SUBROUTINE CD_VIV_Crossflow_Along ELEMENTAL REAL(wp) FUNCTION CD_VIV_Mean_Square(ms_old, sample, weight) RESULT(ms) @@ -276,20 +313,131 @@ PURE REAL(wp) FUNCTION CD_VIV_Phase_Rate(yd, ydd, ms_yd, ms_ydd, phi, un, diamet !! tangent runs against MoorDyn's, which turns the cross-flow axis and so phi_y half a turn. REAL(wp), INTENT(IN) :: yd, ydd, ms_yd, ms_ydd, phi, un, diameter, cf, df REAL(wp), INTENT(IN), OPTIONAL :: phi_rest - REAL(wp) :: phi_y + REAL(wp) :: phi_y, rest - IF (.NOT. (ABS(yd) > CD_ZERO .OR. ABS(ydd) > CD_ZERO)) THEN - phi_y = CD_ZERO - IF (PRESENT(phi_rest)) phi_y = phi_rest - ELSE IF (ms_yd > CD_ZERO .AND. ms_ydd > CD_ZERO) THEN - phi_y = ATAN2(-ydd/SQRT(ms_ydd), yd/SQRT(ms_yd)) - ELSE - phi_y = ATAN2(-ydd, yd) - END IF - IF (phi_y < CD_ZERO) phi_y = phi_y + CD_VIV_TWO_PI + rest = CD_ZERO + IF (PRESENT(phi_rest)) rest = phi_rest + phi_y = motion_phase(yd, ydd, ms_yd, ms_ydd, rest) rate = CD_VIV_TWO_PI*(cf + df*SIN(phi_y - phi))*un/diameter END FUNCTION CD_VIV_Phase_Rate + PURE REAL(wp) FUNCTION CD_VIV_Inline_Phase_Rate(xd, xdd, ms_xd, ms_xdd, phi_x, rate_y, alpha) RESULT(rate) + !! Rate of the in-line shedding phase, d phi_x/dt = 2 rate_y [1 + alpha sin(phi_xd - phi_x)] + !! (Ulveseter et al. 2018, Eq. 6), rate_y the cross-flow shedding rate (CD_VIV_Phase_Rate) and + !! phi_xd the phase of the in-line velocity from x', x'' as the cross-flow one; a node with no + !! in-line motion takes phi_xd = 0. + REAL(wp), INTENT(IN) :: xd, xdd, ms_xd, ms_xdd, phi_x, rate_y, alpha + rate = 2.0_wp*rate_y*(CD_ONE + alpha*SIN(motion_phase(xd, xdd, ms_xd, ms_xdd, CD_ZERO) - phi_x)) + END FUNCTION CD_VIV_Inline_Phase_Rate + + PURE REAL(wp) FUNCTION motion_phase(sd, sdd, ms_sd, ms_sdd, rest) RESULT(ph) + !! The phase of a velocity in [0, 2 pi), atan2(-s''/rms(s''), s'/rms(s')), unnormalised while + !! either mean square is still zero (MoorDyn), and rest for a node with no motion. + REAL(wp), INTENT(IN) :: sd, sdd, ms_sd, ms_sdd, rest + IF (.NOT. (ABS(sd) > CD_ZERO .OR. ABS(sdd) > CD_ZERO)) THEN + ph = rest + ELSE IF (ms_sd > CD_ZERO .AND. ms_sdd > CD_ZERO) THEN + ph = ATAN2(-sdd/SQRT(ms_sdd), sd/SQRT(ms_sd)) + ELSE + ph = ATAN2(-sdd, sd) + END IF + IF (ph < CD_ZERO) ph = ph + CD_VIV_TWO_PI + END FUNCTION motion_phase + + PURE SUBROUTINE CD_VIV_Node_Inline(r_prev, r_next, rd, u, coef, phi_x, force, ok, jac_v, jac_prev, jac_next) + !! In-line shedding force on one node, F = coef cos(phi_x) U v_n, and optionally its residual + !! Jacobians (all three present or none) in CD_VIV_Node_Lift's convention: jac_v = -dF/dr', + !! jac_prev = -dF/dr_prev, jac_next = -dF/dr_next. ok = .FALSE. (and F = 0) when the two + !! neighbours coincide. + REAL(wp), INTENT(IN) :: r_prev(3), r_next(3), rd(3), u(3), coef, phi_x + REAL(wp), INTENT(OUT) :: force(3) + LOGICAL, INTENT(OUT) :: ok + REAL(wp), INTENT(OUT), OPTIONAL :: jac_v(3, 3), jac_prev(3, 3), jac_next(3, 3) + REAL(wp) :: q(3), chord, vr(3), vn(3), un, s, dfdv(3, 3), dfdq(3, 3), proj(3, 3) + INTEGER :: i, j + + force = CD_ZERO + IF (PRESENT(jac_v)) THEN + jac_v = CD_ZERO + jac_prev = CD_ZERO + jac_next = CD_ZERO + END IF + CALL node_frame(r_prev, r_next, rd, u, q, chord, vr, vn, un, ok) + IF (.NOT. ok) RETURN + s = coef*COS(phi_x) + force = (s*un)*vn + IF (.NOT. PRESENT(jac_v)) RETURN + IF (.NOT. (un > CD_ZERO)) RETURN + ! dF/dv_r and dF/dq of F = s U v_n (inline_jacobians); dr' enters v_r with a minus sign + CALL inline_jacobians(s, q, vr, vn, un, dfdv, dfdq) + jac_v = dfdv + DO j = 1, 3 + DO i = 1, 3 + proj(i, j) = -q(i)*q(j)/chord + END DO + proj(j, j) = proj(j, j) + CD_ONE/chord + END DO + jac_next = -MATMUL(dfdq, proj) + jac_prev = -jac_next + END SUBROUTINE CD_VIV_Node_Inline + + PURE SUBROUTINE CD_VIV_Inline_Per_Length(urel, rp, k, f, ok, jrel, jtan) + !! In-line shedding force per unit length of a cable centreline point, f = k U v_n with + !! k = 1/2 rho D C_vx cos(phi_x), the unit tangent t = rp/|rp|, the relative flow v_r = urel, + !! its normal part v_n and speed U; optionally (both or neither) jrel = df/dv_r and + !! jtan = df/drp, as CD_VIV_Lift_Per_Length. ok = .FALSE. (and f = 0) for a degenerate + !! centreline; f and its derivatives vanish with the normal flow. + REAL(wp), INTENT(IN) :: urel(3), rp(3), k + REAL(wp), INTENT(OUT) :: f(3) + LOGICAL, INTENT(OUT) :: ok + REAL(wp), INTENT(OUT), OPTIONAL :: jrel(3, 3), jtan(3, 3) + REAL(wp) :: speed, t(3), vn(3), un, dfdt(3, 3), proj(3, 3) + INTEGER :: i, j + + f = CD_ZERO + IF (PRESENT(jrel)) THEN + jrel = CD_ZERO + jtan = CD_ZERO + END IF + speed = SQRT(rp(1)*rp(1) + rp(2)*rp(2) + rp(3)*rp(3)) + ok = speed > TINY_CHORD + IF (.NOT. ok) RETURN + t = rp/speed + vn = urel - (t(1)*urel(1) + t(2)*urel(2) + t(3)*urel(3))*t + un = SQRT(vn(1)*vn(1) + vn(2)*vn(2) + vn(3)*vn(3)) + f = (k*un)*vn + IF (.NOT. PRESENT(jrel)) RETURN + IF (.NOT. (un > CD_ZERO)) RETURN + CALL inline_jacobians(k, t, urel, vn, un, jrel, dfdt) + DO j = 1, 3 + DO i = 1, 3 + proj(i, j) = -t(i)*t(j)/speed + END DO + proj(j, j) = proj(j, j) + CD_ONE/speed + END DO + jtan = MATMUL(dfdt, proj) + END SUBROUTINE CD_VIV_Inline_Per_Length + + PURE SUBROUTINE inline_jacobians(s, t, vr, vn, un, dfdv, dfdt) + !! Derivatives of F = s U v_n, v_n = (I - t t^T) v_r, U = |v_n| > 0, with respect to the + !! relative flow and the unit tangent: dF/dv_r = s [v_n (x) v_n/U + U (I - t t^T)] and, with + !! alpha = t.v_r (dv_n/dt = -(alpha I + t (x) v_r), dU/dt = -alpha v_n/U as v_n.t = 0), + !! dF/dt = -s [alpha v_n (x) v_n/U + U (alpha I + t (x) v_r)]. + REAL(wp), INTENT(IN) :: s, t(3), vr(3), vn(3), un + REAL(wp), INTENT(OUT) :: dfdv(3, 3), dfdt(3, 3) + REAL(wp) :: alpha + INTEGER :: i, j + alpha = t(1)*vr(1) + t(2)*vr(2) + t(3)*vr(3) + DO j = 1, 3 + DO i = 1, 3 + dfdv(i, j) = s*(vn(i)*vn(j)/un - un*t(i)*t(j)) + dfdt(i, j) = -s*(alpha*vn(i)*vn(j)/un + un*t(i)*vr(j)) + END DO + dfdv(j, j) = dfdv(j, j) + s*un + dfdt(j, j) = dfdt(j, j) - s*un*alpha + END DO + END SUBROUTINE inline_jacobians + 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_hermite_viv_inline.f90 b/tests/test_hermite_viv_inline.f90 new file mode 100644 index 00000000..63acaff8 --- /dev/null +++ b/tests/test_hermite_viv_inline.f90 @@ -0,0 +1,336 @@ +! File: tests/test_hermite_viv_inline.f90 +! SPDX-License-Identifier: Apache-2.0 +! Copyright (c) 2026 Jae Hoon Seo, SMI Lab, Inha University +PROGRAM test_hermite_viv_inline + !! In-line VIV on the cubic-Hermite cable (CD_HermiteCable_Dyn_Set_VIV clx, il_alpha; Ulveseter, + !! Thorsen, Saevik and Larsen, Mar. Struct. 60, 2018): a second shedding force + !! 1/2 rho D C_vx cos(phi_x) U v_n along the relative normal flow, its phase slaved to twice the + !! cross-flow shedding rate, d phi_x/dt = 2 (d phi/dt) [1 + alpha sin(phi_xd - phi_x)]. + !! + !! The line is test_hermite_viv's: 100 m taut, pinned, 20 elements, D 0.1 m, in a 0.15 m/s + !! current along y, so the cross-flow lift acts along z and the in-line force along y. + !! + !! Gates: + !! * I1 the setter refuses clx without il_alpha, mismatched sizes, a negative clx, alpha >= 1 and + !! an in-line coefficient on an element without the cross-flow lift; an all-zero clx installs + !! no in-line state; the in-line phase starts at twice the cross-flow phase; + !! * I2 the element load: a straight element at rest across the current carries + !! U^2 l0 (k_x1 + k_x2)/2 along the flow; the in-line part adds to the cross-flow one; its + !! Jacobians match central differences on a curved, moving element; + !! * I3 an all-zero clx reproduces the cross-flow-only run bit for bit; + !! * I4 at rest the committed node load carries the in-line force along y, absent without it; + !! * I5 in lock-in the in-line response at the quarter span oscillates at twice the cross-flow + !! frequency of the mid span, and is larger than the cross-flow-only run's; + !! * I6 a snapshot taken mid-run and restored replays the following steps bit for bit (state and + !! both phases), and the recovering step equals the plain step. + USE CableDyn_Precision, ONLY: wp + USE CableDyn_HermiteCableDynamic, ONLY: CD_HermiteCableDynType, CD_HermiteCable_Dyn_Init, & + CD_HermiteCable_Dyn_Set_Drag, CD_HermiteCable_Dyn_Set_AddedMass, & + CD_HermiteCable_Dyn_Set_VIV, CD_HermiteCable_Dyn_VIV_Node_Lift, & + CD_HermiteCable_Dyn_Step, CD_HermiteCable_Dyn_Step_Recovering, & + CD_HermiteCable_Dyn_Snapshot, CD_HermiteCable_Dyn_Restore, & + CD_HermiteCable_Dyn_End, CD_HermiteCable_VIV_Lift_Element, CD_HCDYN_OK + IMPLICIT NONE + + REAL(wp), PARAMETER :: PI = 3.141592653589793_wp + REAL(wp), PARAMETER :: RHOW = 1025.0_wp, GACC = 9.80665_wp + REAL(wp), PARAMETER :: D = 0.1_wp, MLIN = 8.10_wp, EA = 5.0e7_wp, EI = 1.0_wp, TENS = 5.0e4_wp + REAL(wp), PARAMETER :: SPAN = 100.0_wp, U = 0.15_wp, DT = 0.02_wp, CVX = 0.85_wp, ALPHA = 0.15_wp + INTEGER, PARAMETER :: NE = 20 + + TYPE(CD_HermiteCableDynType) :: model, twin + REAL(wp), ALLOCATABLE :: cl(:), cf(:), df(:), clx(:), al(:), q_ref(:, :), phi_ref(:, :), phx_ref(:, :) + REAL(wp) :: lift(3, NE + 1) + INTEGER :: es, nfail, k, mid, quarter + CHARACTER(1024) :: em + + nfail = 0 + mid = 6*(NE/2) ! base index of the mid-span node + quarter = 6*(NE/4) ! and of the quarter-span node + ALLOCATE (cl(NE), cf(NE), df(NE), clx(NE), al(NE)) + cl = 0.8_wp; cf = 0.18_wp; df = 0.08_wp; clx = CVX; al = ALPHA + + ! ---- I1 refusals and the start ---- + CALL build(model) + CALL CD_HermiteCable_Dyn_Set_VIV(model, cl, cf, df, 0.25_wp, es, em, clx=clx) + CALL require(es /= CD_HCDYN_OK, 'I1: clx without il_alpha is refused') + CALL CD_HermiteCable_Dyn_Set_VIV(model, cl, cf, df, 0.25_wp, es, em, clx=clx(1:NE - 1), il_alpha=al(1:NE - 1)) + CALL require(es /= CD_HCDYN_OK, 'I1: mismatched in-line arrays are refused') + CALL CD_HermiteCable_Dyn_Set_VIV(model, cl, cf, df, 0.25_wp, es, em, clx=-clx, il_alpha=al) + CALL require(es /= CD_HCDYN_OK, 'I1: a negative clx is refused') + CALL CD_HermiteCable_Dyn_Set_VIV(model, cl, cf, df, 0.25_wp, es, em, clx=clx, il_alpha=al + 1.0_wp) + CALL require(es /= CD_HCDYN_OK, 'I1: alpha >= 1 is refused') + BLOCK + REAL(wp) :: cl2(NE) + cl2 = cl + cl2(3) = 0.0_wp + CALL CD_HermiteCable_Dyn_Set_VIV(model, cl2, cf, df, 0.25_wp, es, em, clx=clx, il_alpha=al) + CALL require(es /= CD_HCDYN_OK .AND. INDEX(em, 'cross-flow') > 0, & + 'I1: an in-line coefficient without the cross-flow lift is refused: '//TRIM(em)) + END BLOCK + CALL require(.NOT. model%has_viv .AND. .NOT. model%has_viv_il, 'I1: a refused call installs nothing') + CALL CD_HermiteCable_Dyn_Set_VIV(model, cl, cf, df, 0.25_wp, es, em, clx=0.0_wp*clx, il_alpha=al) + CALL require(es == CD_HCDYN_OK .AND. model%has_viv .AND. .NOT. model%has_viv_il, & + 'I1: an all-zero clx installs the cross-flow VIV only') + CALL CD_HermiteCable_Dyn_Set_VIV(model, cl, cf, df, 0.25_wp, es, em, clx=clx, il_alpha=al) + CALL require(es == CD_HCDYN_OK .AND. model%has_viv_il, 'I1: in-line VIV installs: '//TRIM(em)) + CALL require(ALL(ABS(model%vil_phi - MODULO(2.0_wp*model%viv_phi, 2.0_wp*PI)) <= 1.0e-12_wp), & + 'I1: the in-line phase starts at twice the cross-flow phase') + CALL require(ALL(ABS(model%vil_k - 0.5_wp*RHOW*D*CVX) <= 1.0e-12_wp), 'I1: the in-line scale is 1/2 rho D C_vx') + + ! ---- I4 the committed node load at rest: in-line along y, cross-flow along z ---- + CALL CD_HermiteCable_Dyn_VIV_Node_Lift(model, lift, es, em) + CALL require(es == CD_HCDYN_OK, 'I4: node lift: '//TRIM(em)) + BLOCK + REAL(wp) :: lift0(3, NE + 1), ref_y, term, scale + INTEGER :: e + ! the in-line force of each (stretched) element at rest: U^2 (SPAN/NE) (k_x1 + k_x2)/2 along y; + ! the spread start phases nearly cancel in the sum, so the tolerance scales with its terms + ref_y = 0.0_wp + scale = 0.0_wp + DO e = 1, NE + term = U*U*(SPAN/REAL(NE, wp))*0.5_wp*model%vil_k(e)*(COS(model%vil_phi(e)) + COS(model%vil_phi(e + 1))) + ref_y = ref_y + term + scale = scale + ABS(term) + END DO + CALL require(ABS(SUM(lift(2, :)) - ref_y) <= 1.0e-12_wp*scale .AND. MAXVAL(ABS(lift(2, :))) > 1.0e-2_wp, & + 'I4: the node load carries the in-line force along the flow') + CALL twin_without_il(twin) + CALL CD_HermiteCable_Dyn_VIV_Node_Lift(twin, lift0, es, em) + CALL require(MAXVAL(ABS(lift0(2, :))) <= 1.0e-12_wp .AND. & + MAXVAL(ABS(lift0(3, :) - lift(3, :))) <= 1.0e-12_wp*MAXVAL(ABS(lift0(3, :))), & + 'I4: without in-line VIV no force along y, the same cross-flow lift') + CALL CD_HermiteCable_Dyn_End(twin) + END BLOCK + + ! ---- I2 element load and Jacobians ---- + CALL check_element() + + ! ---- I3 an all-zero clx is the cross-flow-only run ---- + CALL CD_HermiteCable_Dyn_End(model) + CALL build(model) + CALL CD_HermiteCable_Dyn_Set_VIV(model, cl, cf, df, 0.25_wp, es, em, clx=0.0_wp*clx, il_alpha=al) + CALL twin_without_il(twin) + DO k = 1, 300 + CALL advance(model, 1, .FALSE.) + CALL advance(twin, 1, .FALSE.) + IF (ANY(model%q /= twin%q) .OR. ANY(model%viv_phi /= twin%viv_phi)) EXIT + END DO + CALL require(k > 300, 'I3: an all-zero clx reproduces the cross-flow-only run bit for bit') + CALL CD_HermiteCable_Dyn_End(model) + CALL CD_HermiteCable_Dyn_End(twin) + + ! ---- I5 lock-in: the in-line response at twice the cross-flow frequency ---- + BLOCK + REAL(wp) :: fy, fx, ax_il, ax_cf, ay + CALL build(model) + CALL CD_HermiteCable_Dyn_Set_VIV(model, cl, cf, df, 0.25_wp, es, em, clx=clx, il_alpha=al) + CALL run_response(model, fy, fx, ay, ax_il) + CALL CD_HermiteCable_Dyn_End(model) + CALL twin_without_il(twin) + CALL run_response(twin, fy, fx, ay, ax_cf) + CALL CD_HermiteCable_Dyn_End(twin) + CALL build(model) + CALL CD_HermiteCable_Dyn_Set_VIV(model, cl, cf, df, 0.25_wp, es, em, clx=clx, il_alpha=al) + CALL run_response(model, fy, fx, ay, ax_il) + WRITE (*, '(A,F7.4,A,F7.4,A,F7.3)') ' I5: cross-flow ', fy, ' Hz, in-line ', fx, ' Hz, ratio ', fx/fy + WRITE (*, '(A,F8.4,A,F8.4,A,F8.4)') ' I5: CF amplitude/D ', ay/D, ', IL amplitude/D ', ax_il/D, & + ', IL amplitude/D without in-line VIV ', ax_cf/D + CALL require(ay > 0.3_wp*D, 'I5: the line locks in cross-flow') + CALL require(ABS(fx/fy - 2.0_wp) <= 0.15_wp, 'I5: the in-line response is at twice the cross-flow frequency') + CALL require(ax_il > 2.0_wp*ax_cf, 'I5: the in-line force raises the in-line response') + END BLOCK + + ! ---- I6 snapshot replay and the recovering step ---- + CALL CD_HermiteCable_Dyn_Snapshot(model, es, em) + CALL require(es == CD_HCDYN_OK, 'I6: snapshot: '//TRIM(em)) + ALLOCATE (q_ref(SIZE(model%q), 100), phi_ref(NE + 1, 100), phx_ref(NE + 1, 100)) + DO k = 1, 100 + CALL advance(model, 1, .FALSE.) + q_ref(:, k) = model%q + phi_ref(:, k) = model%viv_phi + phx_ref(:, k) = model%vil_phi + END DO + CALL CD_HermiteCable_Dyn_Restore(model, es, em) + CALL require(es == CD_HCDYN_OK, 'I6: restore: '//TRIM(em)) + DO k = 1, 100 + CALL advance(model, 1, .FALSE.) + IF (ANY(model%q /= q_ref(:, k)) .OR. ANY(model%viv_phi /= phi_ref(:, k)) .OR. & + ANY(model%vil_phi /= phx_ref(:, k))) EXIT + END DO + CALL require(k > 100, 'I6: the restored snapshot replays the state and both phases bit for bit') + CALL CD_HermiteCable_Dyn_Restore(model, es, em) + DO k = 1, 100 + CALL advance(model, 1, .TRUE.) + IF (ANY(model%q /= q_ref(:, k)) .OR. ANY(model%viv_phi /= phi_ref(:, k)) .OR. & + ANY(model%vil_phi /= phx_ref(:, k))) EXIT + END DO + CALL require(k > 100, 'I6: the recovering step equals the plain step') + CALL CD_HermiteCable_Dyn_End(model) + + IF (nfail > 0) THEN + WRITE (*, '(A,I0,A)') 'FAIL: ', nfail, ' assertion(s) failed' + ERROR STOP 1 + END IF + WRITE (*, '(A)') 'PASS: in-line VIV on the cubic-Hermite cable' + +CONTAINS + + SUBROUTINE build(m) + !! The pinned taut line along x, pretensioned through its unstretched length, with the current + !! along y (drag) and the normal added mass. + TYPE(CD_HermiteCableDynType), INTENT(INOUT) :: m + REAL(wp) :: seed(6*(NE + 1)), l0(NE), eav(NE), eiv(NE), wv(NE), rhoa(NE), hd(NE), hn(NE), ht(NE) + INTEGER :: fixed(6), i + seed = 0.0_wp + DO i = 1, NE + 1 + seed(6*(i - 1) + 1) = SPAN*REAL(i - 1, wp)/REAL(NE, wp) + seed(6*(i - 1) + 3) = -50.0_wp + seed(6*(i - 1) + 4) = 1.0_wp + END DO + l0 = SPAN/REAL(NE, wp)/(1.0_wp + TENS/EA) + eav = EA; eiv = EI; rhoa = MLIN + wv = (MLIN - RHOW*0.25_wp*PI*D**2)*GACC + fixed = [1, 2, 3, 6*NE + 1, 6*NE + 2, 6*NE + 3] + CALL CD_HermiteCable_Dyn_Init(m, l0, eav, eiv, rhoa, wv, seed, fixed, -200.0_wp, 0.0_wp, 0.5_wp, es, em) + CALL require(es == CD_HCDYN_OK, 'init: '//TRIM(em)) + hd = D; hn = 1.2_wp; ht = 0.0_wp + CALL CD_HermiteCable_Dyn_Set_Drag(m, RHOW, hd, hn, ht, 0.0_wp, [0.0_wp, U, 0.0_wp], es, em) + CALL require(es == CD_HCDYN_OK, 'drag: '//TRIM(em)) + hn = 1.0_wp + CALL CD_HermiteCable_Dyn_Set_AddedMass(m, RHOW, hd, hn, ht, 0.0_wp, es, em) + CALL require(es == CD_HCDYN_OK, 'added mass: '//TRIM(em)) + END SUBROUTINE build + + SUBROUTINE twin_without_il(m) + !! The same line with the cross-flow VIV only. + TYPE(CD_HermiteCableDynType), INTENT(INOUT) :: m + CALL build(m) + CALL CD_HermiteCable_Dyn_Set_VIV(m, cl, cf, df, 0.25_wp, es, em) + CALL require(es == CD_HCDYN_OK, 'cross-flow VIV: '//TRIM(em)) + END SUBROUTINE twin_without_il + + SUBROUTINE advance(m, n, recovering) + TYPE(CD_HermiteCableDynType), INTENT(INOUT) :: m + INTEGER, INTENT(IN) :: n + LOGICAL, INTENT(IN) :: recovering + INTEGER :: s + DO s = 1, n + IF (recovering) THEN + CALL CD_HermiteCable_Dyn_Step_Recovering(m, DT, 50, 1.0e-8_wp, es, em) + ELSE + CALL CD_HermiteCable_Dyn_Step(m, DT, 50, 1.0e-8_wp, es, em) + END IF + IF (es /= CD_HCDYN_OK) THEN + CALL require(.FALSE., 'step: '//TRIM(em)); RETURN + END IF + END DO + END SUBROUTINE advance + + SUBROUTINE run_response(m, fy, fx, ay, ax) + !! March 100 s and, over 50-100 s, the dominant frequencies of the mid-span cross-flow (z) + !! and quarter-span in-line (y) motions (the peak of a direct Fourier scan of the detrended + !! records) and the amplitudes, half the peak-to-peak excursions. + TYPE(CD_HermiteCableDynType), INTENT(INOUT) :: m + REAL(wp), INTENT(OUT) :: fy, fx, ay, ax + INTEGER, PARAMETER :: NS = NINT(100.0_wp/DT), N0 = NINT(50.0_wp/DT) + REAL(wp) :: zrec(NS - N0), yrec(NS - N0) + INTEGER :: s + DO s = 1, NS + CALL advance(m, 1, .FALSE.) + IF (es /= CD_HCDYN_OK) EXIT + IF (s <= N0) CYCLE + zrec(s - N0) = m%q(mid + 3) + yrec(s - N0) = m%q(quarter + 2) + END DO + ay = 0.5_wp*(MAXVAL(zrec) - MINVAL(zrec)) + ax = 0.5_wp*(MAXVAL(yrec) - MINVAL(yrec)) + fy = peak_frequency(zrec) + fx = peak_frequency(yrec) + END SUBROUTINE run_response + + REAL(wp) FUNCTION peak_frequency(x) RESULT(fpk) + !! The frequency of the largest Fourier amplitude of x - mean(x) on 0.05-2 Hz (0.002 Hz grid). + REAL(wp), INTENT(IN) :: x(:) + REAL(wp) :: xm(SIZE(x)), f, best, re, im, tt + INTEGER :: i, j + xm = x - SUM(x)/REAL(SIZE(x), wp) + best = -1.0_wp + fpk = 0.0_wp + DO j = 0, 975 + f = 0.05_wp + 0.002_wp*REAL(j, wp) + re = 0.0_wp; im = 0.0_wp + DO i = 1, SIZE(x) + tt = REAL(i, wp)*DT + re = re + xm(i)*COS(2.0_wp*PI*f*tt) + im = im + xm(i)*SIN(2.0_wp*PI*f*tt) + END DO + IF (re*re + im*im > best) THEN + best = re*re + im*im + fpk = f + END IF + END DO + END FUNCTION peak_frequency + + SUBROUTINE check_element() + !! I2: the element load at rest across the current, additivity, and the Jacobians against + !! central differences on a curved, moving element. + REAL(wp) :: qe(12), ve(12), fl(12), f_cf(12), f_il(12), djq(12, 12), djv(12, 12), fp(12), fm(12) + REAL(wp) :: fdq(12, 12), fdv(12, 12), kn(2), kx(2), le, h, uu(3) + INTEGER :: j + le = 5.0_wp + uu = [0.0_wp, U, 0.0_wp] + kn = [0.0_wp, 0.0_wp] + kx = [30.0_wp, 50.0_wp] + ! straight along x at rest, unit tangents + qe = 0.0_wp + qe(4) = 1.0_wp; qe(7) = le; qe(10) = 1.0_wp + ve = 0.0_wp + CALL CD_HermiteCable_VIV_Lift_Element(qe, ve, le, uu, 0.0_wp, kn, fl, ErrStat=es, ErrMsg=em, kx_node=kx) + CALL require(es == CD_HCDYN_OK, 'I2: element: '//TRIM(em)) + CALL require(ABS(fl(2) + fl(8) - U*U*le*0.5_wp*(kx(1) + kx(2))) <= 1.0e-12_wp*U*U*le*kx(2) .AND. & + ABS(fl(1) + fl(7)) + ABS(fl(3) + fl(9)) <= 1.0e-12_wp*U*U*le*kx(2), & + 'I2: a straight element at rest carries U^2 l0 (k_x1 + k_x2)/2 along the flow') + ! curved and moving, off the flow plane + qe = [0.1_wp, -0.2_wp, -10.0_wp, 0.9_wp, 0.3_wp, 0.2_wp, 4.8_wp, 0.4_wp, -9.6_wp, 1.0_wp, -0.2_wp, 0.15_wp] + ve = [0.02_wp, -0.05_wp, 0.08_wp, 0.01_wp, 0.02_wp, -0.03_wp, -0.04_wp, 0.06_wp, 0.03_wp, 0.0_wp, -0.01_wp, & + 0.02_wp] + uu = [0.05_wp, U, -0.02_wp] + kn = [20.0_wp, -15.0_wp] + CALL CD_HermiteCable_VIV_Lift_Element(qe, ve, le, uu, 0.0_wp, kn, f_cf, ErrStat=es, ErrMsg=em) + CALL CD_HermiteCable_VIV_Lift_Element(qe, ve, le, uu, 0.0_wp, [0.0_wp, 0.0_wp], f_il, ErrStat=es, ErrMsg=em, & + kx_node=kx) + CALL CD_HermiteCable_VIV_Lift_Element(qe, ve, le, uu, 0.0_wp, kn, fl, djq, djv, es, em, kx_node=kx) + CALL require(MAXVAL(ABS(fl - f_cf - f_il)) <= 1.0e-12_wp*MAXVAL(ABS(fl)), & + 'I2: the in-line load adds to the cross-flow one') + h = 1.0e-6_wp + DO j = 1, 12 + qe(j) = qe(j) + h + CALL CD_HermiteCable_VIV_Lift_Element(qe, ve, le, uu, 0.0_wp, kn, fp, ErrStat=es, ErrMsg=em, kx_node=kx) + qe(j) = qe(j) - 2.0_wp*h + CALL CD_HermiteCable_VIV_Lift_Element(qe, ve, le, uu, 0.0_wp, kn, fm, ErrStat=es, ErrMsg=em, kx_node=kx) + qe(j) = qe(j) + h + fdq(:, j) = (fp - fm)/(2.0_wp*h) + ve(j) = ve(j) + h + CALL CD_HermiteCable_VIV_Lift_Element(qe, ve, le, uu, 0.0_wp, kn, fp, ErrStat=es, ErrMsg=em, kx_node=kx) + ve(j) = ve(j) - 2.0_wp*h + CALL CD_HermiteCable_VIV_Lift_Element(qe, ve, le, uu, 0.0_wp, kn, fm, ErrStat=es, ErrMsg=em, kx_node=kx) + ve(j) = ve(j) + h + fdv(:, j) = (fp - fm)/(2.0_wp*h) + END DO + WRITE (*, '(A,ES10.2,A,ES10.2)') ' I2: Jacobian errors, position ', MAXVAL(ABS(djq - fdq))/MAXVAL(ABS(fdq)), & + ', velocity ', MAXVAL(ABS(djv - fdv))/MAXVAL(ABS(fdv)) + CALL require(MAXVAL(ABS(djq - fdq)) <= 1.0e-6_wp*MAXVAL(ABS(fdq)), 'I2: position Jacobian matches differences') + CALL require(MAXVAL(ABS(djv - fdv)) <= 1.0e-6_wp*MAXVAL(ABS(fdv)), 'I2: velocity Jacobian matches differences') + END SUBROUTINE check_element + + SUBROUTINE require(cond, label) + LOGICAL, INTENT(IN) :: cond + CHARACTER(*), INTENT(IN) :: label + IF (.NOT. cond) THEN + WRITE (*, '(A,A)') 'MISMATCH: ', label + nfail = nfail + 1 + END IF + END SUBROUTINE require + +END PROGRAM test_hermite_viv_inline diff --git a/tests/test_hfmf_mirror.f90 b/tests/test_hfmf_mirror.f90 index b6c67360..be409d82 100644 --- a/tests/test_hfmf_mirror.f90 +++ b/tests/test_hfmf_mirror.f90 @@ -18,13 +18,17 @@ PROGRAM test_hfmf_mirror !! identically built cable, re-pack -- bit-identical buffers, and the line clock !! carries the restart time; !! 4) wrong-sized / non-finite buffers, a non-orthogonal parent orientation and a - !! non-finite time fail closed. + !! non-finite time fail closed; + !! 5) with cross-flow and in-line VIV the VIV block is 6 nn + 1 values (the in-line phase and + !! mean squares after the cross-flow block), it round-trips bit-identically into the twin's + !! in-line state, and a negative in-line mean square fails closed. USE CableDyn_Precision, ONLY: wp USE CableDyn_DeckDriver, ONLY: CD_Init_Deck_HermiteCable, CD_DECKDRV_OK USE CableDyn_OpenFAST_HermiteFMF, ONLY: CD_HFMF_ModuleType, CD_HFMF_MirrorSize, CD_HFMF_PackMirror, & CD_HFMF_UnpackMirror, CD_HFMF_FrictionMirrorSize, CD_HFMF_ForceMirrorSize, & - CD_HFMF_BoundaryMirrorSize, & + CD_HFMF_BoundaryMirrorSize, CD_HFMF_VIVMirrorSize, CD_HFMF_TorsionMirrorSize, & CD_HFMF_End, CD_HFMF_OK, CD_HFMF_BADINPUT + USE CableDyn_HermiteCableDynamic, ONLY: CD_HermiteCable_Dyn_Set_VIV, CD_HCDYN_OK USE, INTRINSIC :: IEEE_ARITHMETIC, ONLY: IEEE_IS_FINITE, IEEE_VALUE, IEEE_QUIET_NAN IMPLICIT NONE INTEGER :: nfail @@ -106,6 +110,46 @@ PROGRAM test_hfmf_mirror CALL CD_HFMF_UnpackMirror(twin, buf, IEEE_VALUE(1.0_wp, IEEE_QUIET_NAN), es, em) CALL require(es == CD_HFMF_BADINPUT, 'non-finite restart time fails closed') + ! (5) the in-line VIV block + BLOCK + REAL(wp), ALLOCATABLE :: cl(:), cf(:), df(:), clx(:), al(:), vb(:), vb2(:) + INTEGER :: ne, nn, kv + buf(1) = 0.0_wp + ne = cable%line%ne + nn = cable%line%nn + ALLOCATE (cl(ne), cf(ne), df(ne), clx(ne), al(ne)) + cl = 0.8_wp; cf = 0.18_wp; df = 0.08_wp; clx = 0.85_wp; al = 0.15_wp + CALL CD_HermiteCable_Dyn_Set_VIV(cable%line, cl, cf, df, 0.25_wp, es, em, clx=clx, il_alpha=al) + CALL require(es == CD_HCDYN_OK, 'in-line VIV on the cable: '//TRIM(em)) + CALL CD_HermiteCable_Dyn_Set_VIV(twin%line, cl, cf, df, 0.25_wp, es, em, clx=clx, il_alpha=al) + CALL require(es == CD_HCDYN_OK, 'in-line VIV on the twin: '//TRIM(em)) + CALL require(CD_HFMF_VIVMirrorSize(cable) == 6*nn + 1, 'VIV block with in-line VIV: 6 nn + 1 values') + ALLOCATE (vb(CD_HFMF_MirrorSize(cable)), vb2(CD_HFMF_MirrorSize(cable))) + CALL CD_HFMF_PackMirror(cable, vb, es, em) + CALL require(es == CD_HFMF_OK, 'pack with in-line VIV: '//TRIM(em)) + ! the in-line block: phase then mean squares, just before the (absent) torsion block + kv = SIZE(vb) - CD_HFMF_TorsionMirrorSize(cable) - 3*nn + CALL require(nan_max_abs(vb(kv + 1:kv + nn) - cable%line%vil_phi) <= 0.0_wp, & + 'the in-line phase follows the cross-flow block') + DO i = 1, 3*nn + vb(kv + i) = vb(kv + i) + 1.0e-3_wp*REAL(i, wp) + END DO + kb = 3*nf + CD_HFMF_FrictionMirrorSize(cable) + 3*(cable%line%ndof - nf) + vb(kb + 7:kb + 15) = [1.0_wp, 0.0_wp, 0.0_wp, 0.0_wp, 1.0_wp, 0.0_wp, 0.0_wp, 0.0_wp, 1.0_wp] + CALL CD_HFMF_UnpackMirror(twin, vb, 3.0_wp, es, em) + CALL require(es == CD_HFMF_OK, 'unpack with in-line VIV: '//TRIM(em)) + CALL require(nan_max_abs(twin%line%vil_phi - vb(kv + 1:kv + nn)) <= 0.0_wp .AND. & + nan_max_abs(twin%line%vil_phi_eval - twin%line%vil_phi) <= 0.0_wp .AND. & + nan_max_abs(twin%line%ws_recovery_vil_ms - twin%line%vil_ms) <= 0.0_wp, & + 'the in-line phase and its step copies reload') + CALL CD_HFMF_PackMirror(twin, vb2, es, em) + CALL require(nan_max_abs(vb2 - vb) <= 0.0_wp, 'the in-line VIV block round-trips bit-identically') + vb(kv + nn + 1) = -1.0_wp + CALL CD_HFMF_UnpackMirror(twin, vb, 3.0_wp, es, em) + CALL require(es == CD_HFMF_BADINPUT .AND. INDEX(em, 'in-line') > 0, & + 'a negative in-line mean square fails closed') + END BLOCK + CALL CD_HFMF_End(cable) CALL CD_HFMF_End(twin) CALL finish() diff --git a/tests/test_viv_inline_deck.f90 b/tests/test_viv_inline_deck.f90 new file mode 100644 index 00000000..a84c40c3 --- /dev/null +++ b/tests/test_viv_inline_deck.f90 @@ -0,0 +1,254 @@ +! File: tests/test_viv_inline_deck.f90 +! SPDX-License-Identifier: Apache-2.0 +! Copyright (c) 2026 Jae Hoon Seo, SMI Lab, Inha University +PROGRAM test_viv_inline_deck + !! In-line VIV on a deck (the optional VIV section, TypeName ClX [alpha]): the taut line of the + !! cross-flow lock-in benchmark (tests/test_viv_lockin.py) as a finite-EI cable, 100 m pinned + !! at 50 m depth in a uniform 0.15 m/s current along y, Cl 0.8 with MoorDyn's band. + !! D1 with ClX 0.85 the quarter-span in-line (y) response oscillates at twice the mid-span + !! cross-flow (z) frequency and is larger than without the VIV section; + !! D2 a VIV row with ClX 0 is the deck without the section, to the printed digits; + !! D3 malformed rows, an unknown or repeated type, ClX on a type without the cross-flow lift, + !! alpha outside [0, 1) and in-line VIV on an EI = 0 line are refused by name. + USE CableDyn_Precision, ONLY: wp + USE CableDyn_DeckDriver, ONLY: CD_Run_Deck_Driver, CD_DECKDRV_OK + IMPLICIT NONE + REAL(wp), PARAMETER :: PI = 3.14159265358979323846_wp, D = 0.1_wp + INTEGER :: nfail = 0 + + CALL write_current('vid_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: in-line VIV 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 in-line VIV 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, viv_rows, tmax, ei, cl) + !! viv_rows: the VIV section's data rows, ';'-separated ('' for no section). + CHARACTER(*), INTENT(IN) :: path, viv_rows + REAL(wp), INTENT(IN) :: tmax + CHARACTER(*), INTENT(IN), OPTIONAL :: ei, cl + CHARACTER(32) :: ei_col, cl_col + INTEGER :: u, i0, i1 + ei_col = '1.0' + IF (PRESENT(ei)) ei_col = ei + 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)') 'in-line VIV 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)') '(name) (m) (kg/m) (N) (N-s/-) (-) (-) (-) (-) (-) (-) (-) (-)' + 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)') '----------------------- POINTS ----------------------------------------------' + WRITE (u, '(A)') 'ID Attachment X Y Z M V CdA CA' + WRITE (u, '(A)') '(#) (-) (m) (m) (m) (kg) (m^3) (m^2) (-)' + 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 LineType AttachA AttachB UnstrLen NumSegs Outputs' + WRITE (u, '(A)') '(#) (name) (#) (#) (m) (-) (-)' + WRITE (u, '(A)') '1 riser 1 2 99.900100 50 -' + IF (LEN_TRIM(viv_rows) > 0) THEN + WRITE (u, '(A)') '----------------------- VIV -------------------------------------------------' + WRITE (u, '(A)') 'TypeName ClX alpha' + WRITE (u, '(A)') '(name) (-) (-)' + i0 = 1 + DO + i1 = INDEX(viv_rows(i0:), ';') + IF (i1 == 0) THEN + WRITE (u, '(A)') TRIM(viv_rows(i0:)) + EXIT + END IF + WRITE (u, '(A)') viv_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)') 'vid_current.dat WaterKin' + WRITE (u, '(A)') '0.25 VIVrmsWindow' + WRITE (u, '(A,F8.3,A)') ' ', tmax, ' TMax' + WRITE (u, '(A)') '---------------------- OUTPUTS -----------------------------------------------' + WRITE (u, '(A)') 'L1N25PZ' + WRITE (u, '(A)') 'L1N12PY' + 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, L1N12PY) 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(3, 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.002 Hz grid). + REAL(wp), INTENT(IN) :: tt(:), x(:) + REAL(wp) :: xm(SIZE(x)), f, best, re, im + INTEGER :: i, j + xm = x - SUM(x)/REAL(SIZE(x), wp) + best = -1.0_wp + fpk = 0.0_wp + DO j = 0, 975 + f = 0.05_wp + 0.002_wp*REAL(j, wp) + re = 0.0_wp; im = 0.0_wp + DO i = 1, SIZE(x) + re = re + xm(i)*COS(2.0_wp*PI*f*tt(i)) + im = im + xm(i)*SIN(2.0_wp*PI*f*tt(i)) + END DO + IF (re*re + im*im > best) THEN + best = re*re + im*im + fpk = f + END IF + END DO + END FUNCTION peak_frequency + + SUBROUTINE window(tab, n, t0, tt, z, y) + !! The rows of tab from time t0 on. + REAL(wp), INTENT(IN) :: tab(:, :), t0 + INTEGER, INTENT(IN) :: n + REAL(wp), ALLOCATABLE, INTENT(OUT) :: tt(:), z(:), y(:) + LOGICAL :: keep(n) + keep = tab(1, 1:n) >= t0 + tt = PACK(tab(1, 1:n), keep) + z = PACK(tab(2, 1:n), keep) + y = PACK(tab(3, 1:n), keep) + END SUBROUTINE window + + SUBROUTINE check_runs() + REAL(wp), ALLOCATABLE :: ti(:, :), tc(:, :), t0(:, :), tt(:), z(:), y(:) + INTEGER :: ni, nc, n0 + REAL(wp) :: fz, fy, ay_il, ay_cf + LOGICAL :: ok + CHARACTER(1024) :: msg + CALL write_deck('vid_il.dat', 'riser 0.85 0.15', 100.0_wp) + CALL run('vid_il.dat', 'vid_il', ok, msg) + CALL require(ok, 'D1: the in-line VIV deck runs: '//TRIM(msg)) + CALL write_deck('vid_cf.dat', '', 100.0_wp) + CALL run('vid_cf.dat', 'vid_cf', ok, msg) + CALL require(ok, 'D1: the cross-flow-only deck runs: '//TRIM(msg)) + CALL write_deck('vid_zero.dat', 'riser 0.0', 100.0_wp) + CALL run('vid_zero.dat', 'vid_zero', ok, msg) + CALL require(ok, 'D2: the ClX 0 deck runs: '//TRIM(msg)) + CALL read_out('vid_il.out', ti, ni) + CALL read_out('vid_cf.out', tc, nc) + CALL read_out('vid_zero.out', t0, n0) + CALL require(ni > 100 .AND. ni == nc .AND. ni == n0, 'D1/D2: the runs wrote matching rows') + IF (.NOT. (ni > 100 .AND. ni == nc .AND. ni == n0)) RETURN + CALL require(ALL(t0(:, 1:n0) == tc(:, 1:nc)), 'D2: a VIV row with ClX 0 is the deck without the section') + CALL window(ti, ni, 50.0_wp, tt, z, y) + fz = peak_frequency(tt, z) + fy = peak_frequency(tt, y) + ay_il = 0.5_wp*(MAXVAL(y) - MINVAL(y)) + WRITE (*, '(A,F7.4,A,F7.4,A,F7.3,A,F7.4)') 'D1: cross-flow ', fz, ' Hz, in-line ', fy, ' Hz, ratio ', fy/fz, & + ', CF amplitude/D ', 0.5_wp*(MAXVAL(z) - MINVAL(z))/D + CALL window(tc, nc, 50.0_wp, tt, z, y) + ay_cf = 0.5_wp*(MAXVAL(y) - MINVAL(y)) + WRITE (*, '(A,F8.4,A,F8.4)') 'D1: quarter-span in-line amplitude/D ', ay_il/D, ', without the VIV section ', & + ay_cf/D + CALL require(ABS(fy/fz - 2.0_wp) <= 0.15_wp, 'D1: the in-line response is at twice the cross-flow frequency') + CALL require(ay_il > 2.0_wp*ay_cf, 'D1: the in-line force raises the in-line response') + END SUBROUTINE check_runs + + SUBROUTINE check_refusals() + CALL refused('riser 0.85 0.15 7', 'TypeName ClX [alpha]', 'a row of four columns') + CALL refused('cable 0.85', 'undefined LINE TYPE', 'an unknown type') + CALL refused('riser 0.85;riser 0.5', 'twice', 'a repeated type') + CALL refused('riser -0.1', 'non-negative', 'a negative ClX') + CALL refused('riser 0.85 1.0', '0 <= alpha < 1', 'alpha = 1') + CALL refused('riser 0.85 x', 'plain numbers', 'a non-numeric alpha') + CALL refused('riser 0.85', 'cross-flow lift', 'ClX on a type without the cross-flow lift', cl='0.0') + CALL refused('riser 0.85', 'finite-EI lines', 'in-line VIV on an EI = 0 line', ei='0.0') + END SUBROUTINE check_refusals + + SUBROUTINE refused(rows, needle, what, ei, cl) + CHARACTER(*), INTENT(IN) :: rows, needle, what + CHARACTER(*), INTENT(IN), OPTIONAL :: ei, cl + LOGICAL :: ok + CHARACTER(1024) :: msg + IF (PRESENT(ei)) THEN + CALL write_deck('vid_bad.dat', rows, 1.0_wp, ei=ei) + ELSE IF (PRESENT(cl)) THEN + CALL write_deck('vid_bad.dat', rows, 1.0_wp, cl=cl) + ELSE + CALL write_deck('vid_bad.dat', rows, 1.0_wp) + END IF + CALL run('vid_bad.dat', 'vid_bad', ok, msg) + CALL require(.NOT. ok .AND. INDEX(msg, needle) > 0, 'D3: '//what//' is refused: '//TRIM(msg)) + END SUBROUTINE refused + +END PROGRAM test_viv_inline_deck diff --git a/tests/test_viv_kernels.f90 b/tests/test_viv_kernels.f90 index e6ddad46..1fc11b77 100644 --- a/tests/test_viv_kernels.f90 +++ b/tests/test_viv_kernels.f90 @@ -11,15 +11,22 @@ PROGRAM test_viv_kernels !! 4) the phase rate is 2 pi (cF + dF sin(phi_y - phi)) U/D, with phi_y from the RMS-normalised !! y', y'' (cF at phase lock, cF + dF a quarter period ahead); !! 5) the running mean square is MoorDyn's ((n_m - 1) old^2 + new^2)/n_m; - !! 6) the phase wraps to [0, 2 pi), and a node whose neighbours coincide fails closed. + !! 6) the phase wraps to [0, 2 pi), and a node whose neighbours coincide fails closed; + !! 7) the per-length lift of a centreline point (the finite-EI Gauss points); + !! 8) in-line VIV (Ulveseter et al. 2018): the node and per-length forces are + !! 1/2 rho D C_vx cos(phi_x) U v_n along the normal flow, their Jacobians match central + !! differences, the in-line motion is the component along v_n/U, and the phase rate is + !! 2 rate_y [1 + alpha sin(phi_xd - phi_x)] (twice the cross-flow rate at phase lock). USE CableDyn_Precision, ONLY: wp USE CableDyn_VIV, ONLY: CD_VIV_Node_Lift, CD_VIV_Crossflow_Motion, CD_VIV_Phase_Rate, CD_VIV_Mean_Square, & - CD_VIV_Wrap_Phase, CD_VIV_TWO_PI, CD_VIV_NM, CD_VIV_Lift_Per_Length + CD_VIV_Wrap_Phase, CD_VIV_TWO_PI, CD_VIV_NM, CD_VIV_Lift_Per_Length, & + CD_VIV_Node_Inline, CD_VIV_Inline_Per_Length, CD_VIV_Inline_Phase_Rate, & + CD_VIV_Crossflow_Along IMPLICIT NONE REAL(wp), PARAMETER :: RHO = 1025.0_wp, DIAM = 0.1_wp, CL = 0.8_wp, L1 = 2.0_wp, L2 = 1.5_wp REAL(wp) :: rp(3), rn(3), rd(3), u(3), coef, phi, f(3), q(3), vr(3), vn(3), un, w(3), ref(3) REAL(wp) :: jv(3, 3), jp(3, 3), jn(3, 3), fd(3, 3), fp(3), fm(3), h, e(3), yd, ydd, un2, rate - REAL(wp) :: ms, ms_md, rpv(3), kk, fl(3), jr(3, 3), jt(3, 3) + REAL(wp) :: ms, ms_md, rpv(3), kk, fl(3), jr(3, 3), jt(3, 3), xd, xdd, yd2, ydd2, un3, rdd(3) LOGICAL :: ok INTEGER :: nfail, j, k @@ -119,6 +126,77 @@ PROGRAM test_viv_kernels CALL CD_VIV_Lift_Per_Length(u - rd, 3.0_wp*rpv, kk, fp, ok) CALL require(NORM2(fp - fl) <= 1.0e-12_wp*NORM2(fl), 'per-length lift does not depend on |dr/dxi|') + ! (8) in-line VIV: the node force along the normal flow and its Jacobians + CALL CD_VIV_Node_Inline(rp, rn, rd, u, coef, phi, f, ok) + ref = 0.25_wp*RHO*DIAM*un*CL*COS(phi)*vn*(L1 + L2) + CALL require(ok .AND. NORM2(f - ref) <= 1.0e-12_wp*NORM2(ref), 'in-line: node force = coef cos(phi_x) U v_n') + CALL require(ABS(DOT_PRODUCT(f, q)) <= 1.0e-12_wp*NORM2(f), 'in-line: node force normal to the tangent') + CALL CD_VIV_Node_Inline(rp, rn, rd, rd + 0.3_wp*q, coef, phi, f, ok) + CALL require(ok .AND. NORM2(f) <= 1.0e-14_wp, 'in-line: no force for flow along the line') + CALL CD_VIV_Node_Inline(rp, rn, rd, u, coef, phi, f, ok, jv, jp, jn) + DO j = 1, 3 + CALL CD_VIV_Node_Inline(rp, rn, rd + h*unit(j), u, coef, phi, fp, ok) + CALL CD_VIV_Node_Inline(rp, rn, rd - h*unit(j), u, coef, phi, fm, ok) + fd(:, j) = -(fp - fm)/(2.0_wp*h) + END DO + CALL require(MAXVAL(ABS(jv - fd)) <= 1.0e-6_wp*MAXVAL(ABS(fd)), 'in-line: velocity Jacobian matches differences') + DO j = 1, 3 + CALL CD_VIV_Node_Inline(rp + h*unit(j), rn, rd, u, coef, phi, fp, ok) + CALL CD_VIV_Node_Inline(rp - h*unit(j), rn, rd, u, coef, phi, fm, ok) + fd(:, j) = -(fp - fm)/(2.0_wp*h) + END DO + CALL require(MAXVAL(ABS(jp - fd)) <= 1.0e-6_wp*MAXVAL(ABS(fd)), 'in-line: previous-node Jacobian matches differences') + DO j = 1, 3 + CALL CD_VIV_Node_Inline(rp, rn + h*unit(j), rd, u, coef, phi, fp, ok) + CALL CD_VIV_Node_Inline(rp, rn - h*unit(j), rd, u, coef, phi, fm, ok) + fd(:, j) = -(fp - fm)/(2.0_wp*h) + END DO + CALL require(MAXVAL(ABS(jn - fd)) <= 1.0e-6_wp*MAXVAL(ABS(fd)), 'in-line: next-node Jacobian matches differences') + CALL CD_VIV_Node_Inline(rp, rp, rd, u, coef, phi, f, ok) + CALL require(.NOT. ok .AND. NORM2(f) <= 0.0_wp, 'in-line: coinciding neighbours fail closed with no force') + + ! in-line force per unit length: the node formula with the exact tangent, independent of |dr/dxi| + CALL CD_VIV_Inline_Per_Length(u - rd, rpv, kk, fl, ok, jr, jt) + CALL CD_VIV_Node_Inline(rp, rn, rd, u, 1.0_wp, phi, f, ok) + CALL require(ok .AND. NORM2(fl - 0.5_wp*RHO*DIAM*CL*f) <= 1.0e-12_wp*NORM2(fl), & + 'in-line: per-length force = 1/2 rho D C_vx cos(phi_x) U v_n') + DO j = 1, 3 + CALL CD_VIV_Inline_Per_Length(u - rd + h*unit(j), rpv, kk, fp, ok) + CALL CD_VIV_Inline_Per_Length(u - rd - h*unit(j), rpv, kk, fm, ok) + fd(:, j) = (fp - fm)/(2.0_wp*h) + END DO +CALL require(MAXVAL(ABS(jr - fd)) <= 1.0e-6_wp*MAXVAL(ABS(fd)), 'in-line: per-length flow Jacobian matches differences') + DO j = 1, 3 + CALL CD_VIV_Inline_Per_Length(u - rd, rpv + h*unit(j), kk, fp, ok) + CALL CD_VIV_Inline_Per_Length(u - rd, rpv - h*unit(j), kk, fm, ok) + fd(:, j) = (fp - fm)/(2.0_wp*h) + END DO + CALL require(MAXVAL(ABS(jt - fd)) <= 1.0e-6_wp*MAXVAL(ABS(fd)), & + 'in-line: per-length tangent Jacobian matches differences') + CALL CD_VIV_Inline_Per_Length(u - rd, 3.0_wp*rpv, kk, fp, ok) + CALL require(NORM2(fp - fl) <= 1.0e-12_wp*NORM2(fl), 'in-line: per-length force does not depend on |dr/dxi|') + + ! in-line motion along v_n/U, from both motion routines; the cross-flow outputs are unchanged + rdd = [1.0_wp, 2.0_wp, -0.5_wp] + CALL CD_VIV_Crossflow_Motion(rp, rn, rd, rdd, u, yd2, ydd2, un3, ok, xd, xdd) + CALL require(ok .AND. yd2 == yd .AND. ydd2 == ydd, 'in-line: the cross-flow motion is unchanged') + CALL require(ABS(xd - DOT_PRODUCT(rd, vn)/un) <= 1.0e-14_wp .AND. ABS(xdd - DOT_PRODUCT(rdd, vn)/un) <= 1.0e-14_wp, & + 'in-line: velocity and acceleration along v_n/U') + CALL CD_VIV_Crossflow_Along(rn - rp, rd, rdd, u, yd2, ydd2, un3, ok, xd, xdd) + CALL require(ok .AND. ABS(yd2 - yd) <= 1.0e-14_wp .AND. ABS(xd - DOT_PRODUCT(rd, vn)/un) <= 1.0e-14_wp .AND. & + ABS(xdd - DOT_PRODUCT(rdd, vn)/un) <= 1.0e-14_wp, 'in-line: motion along a given tangent') + + ! in-line phase rate: twice the cross-flow rate at phase lock, (1 + alpha) times that a quarter + ! period ahead; a node with no in-line motion takes phi_xd = 0 + rate = CD_VIV_Inline_Phase_Rate(COS(2.2_wp), -SIN(2.2_wp), 1.0_wp, 1.0_wp, 2.2_wp, 3.0_wp, 0.15_wp) + CALL require(ABS(rate - 6.0_wp) <= 1.0e-12_wp*rate, 'in-line: rate at phase lock is twice the cross-flow rate') + rate = CD_VIV_Inline_Phase_Rate(COS(2.2_wp), -SIN(2.2_wp), 1.0_wp, 1.0_wp, 2.2_wp - 0.25_wp*CD_VIV_TWO_PI, & + 3.0_wp, 0.15_wp) + CALL require(ABS(rate - 6.0_wp*1.15_wp) <= 1.0e-12_wp*rate, 'in-line: rate a quarter period ahead is 2 (1+alpha) rate_y') + rate = CD_VIV_Inline_Phase_Rate(0.0_wp, 0.0_wp, 0.0_wp, 0.0_wp, 0.5_wp, 3.0_wp, 0.15_wp) + CALL require(ABS(rate - 6.0_wp*(1.0_wp + 0.15_wp*SIN(-0.5_wp))) <= 1.0e-12_wp*rate, & + 'in-line: no in-line motion takes phi_xd = 0') + ! (6) wrap and degenerate frame CALL require(CD_VIV_Wrap_Phase(-1.0e-300_wp) >= 0.0_wp .AND. CD_VIV_Wrap_Phase(-1.0e-300_wp) < CD_VIV_TWO_PI, & 'a tiny negative phase wraps into [0, 2 pi)')