diff --git a/CHANGELOG.md b/CHANGELOG.md index 4b20c3d..64c5004 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -118,6 +118,20 @@ All notable changes to CableDyn are recorded in this file. The format follows leaves runs unchanged to the bit. The Python deck reader and builder (`viv_frame_tf`) take the section. +- The `VIV FRAME` section on the synchronisation model (LINE TYPES `Cl > 0`): `Tf > 0` takes the + cable's filtered velocity as the frame of the cross-flow and in-line phases (the node's + velocity relative to it; the shedding speed stays the relative normal speed), of the amplitude + estimate (and so `Cv` and `CdAmp`) and of the axes and blend of the `VIV DAMPING` split. A cable + moved through still water had a phase input of zero cross-flow velocity, `y0 = 0`, `Cv(0)`, + `CdAmp(0)` and Morison's drag. A pipe moved at 0.6 m/s amplitude and 40 s period in still water + now gives peak A/D 0.819 against 0.819 for the same pipe held in the moving water with the + amplitude table and damping (0.711 against 0.850 without the row), and 0.713 against 0.714 with + the lift alone (0.711 against 0.736); a cable towed at 0.15 m/s gives the A/D of the cable held + in the current with the same row within 0.01 %. On `EI = 0` lines and finite-EI cables, the + filtered velocity in rows 7-9 of the VIV motion statistics, so in the step-recovery, snapshot + and checkpoint state; `Tf` 0 or no row leaves runs unchanged to the bit. A VIV FRAME row now + needs LINE TYPES `Cl > 0` or a WAKE OSCILLATOR row; the Python deck reader and builder follow. + ### Fixed - The statics of a finite-EI line through the free surface could fail at isolated currents: diff --git a/CMakeLists.txt b/CMakeLists.txt index c0fe0de..072282f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1356,6 +1356,13 @@ add_executable(test_viv_cf_damping_deck tests/test_viv_cf_damping_deck.f90) target_link_libraries(test_viv_cf_damping_deck PRIVATE cabledyn_core) add_test(NAME viv_cf_damping_deck COMMAND test_viv_cf_damping_deck WORKING_DIRECTORY ${CMAKE_BINARY_DIR}) set_tests_properties(viv_cf_damping_deck PROPERTIES LABELS "fortran;integration;dynamic;viv;driver") +# The flow frame (VIV FRAME section) of the synchronisation model on a deck: a Tf 0 row as no +# section, a cable towed through still water against the same cable held in a current, the frame +# leaving the held cable's response on both cores, and the refusals. +add_executable(test_viv_frame_deck tests/test_viv_frame_deck.f90) +target_link_libraries(test_viv_frame_deck PRIVATE cabledyn_core) +add_test(NAME viv_frame_deck COMMAND test_viv_frame_deck WORKING_DIRECTORY ${CMAKE_BINARY_DIR}) +set_tests_properties(viv_frame_deck PROPERTIES LABELS "fortran;integration;dynamic;viv;driver") # Amplitude-dependent VIV coefficients on a deck (VIV AMPLITUDE section), both line kinds: the # identity table, the amplitude channel against the response, self-limiting, drag amplification @@ -1385,6 +1392,15 @@ 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") +# The flow frame of the synchronisation model (Set_VIV tf): a pipe moved through still water +# against the same pipe held in the water moving the other way, with the lift alone and with the +# amplitude tables and the cross-flow damping; the refusals, the all-zero identity and the +# snapshot replay. +add_executable(test_hermite_viv_frame tests/test_hermite_viv_frame.f90) +target_link_libraries(test_hermite_viv_frame PRIVATE cabledyn_core) +add_test(NAME hermite_viv_frame COMMAND test_hermite_viv_frame) +set_tests_properties(hermite_viv_frame PROPERTIES LABELS "fortran;dynamic;viv") + add_executable(test_hermite_load_power tests/test_hermite_load_power.f90) target_link_libraries(test_hermite_load_power PRIVATE cabledyn_core) add_test(NAME hermite_load_power COMMAND test_hermite_load_power) diff --git a/doc/capabilities.rst b/doc/capabilities.rst index b66ba3e..9107067 100644 --- a/doc/capabilities.rst +++ b/doc/capabilities.rst @@ -149,7 +149,10 @@ 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 + host's fluid field on the coupled routes and its state in the checkpoint; a ``VIV FRAME`` + row (``Tf``) takes the cable's filtered motion as the frame of its phases, amplitude + estimate and cross-flow damping (a towed or floater-driven cable, + :ref:`theory-viv-frame`) * - 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, and @@ -168,7 +171,9 @@ Line and constitutive capability - a table over the cross-flow amplitude of the synchronisation coefficient and a drag factor, read at the amplitude estimate of Thorsen et al. (2016) (``VIVAmp`` channel), on ``EI = 0`` lines and finite-EI cables (:ref:`theory-viv-amplitude`), its state in the - checkpoint + checkpoint; a ``VIV FRAME`` row (``Tf``) takes the estimate, and the ``VIV DAMPING`` + axes, relative to the cable's filtered motion (a towed or floater-driven cable, + :ref:`theory-viv-frame`) * - VIV diameter (``VIV DIAMETER`` section ``Dviv``) - Standalone and coupled - a diameter of the VIV model apart from the hydrodynamic one, for buoyancy-module zones and @@ -179,7 +184,8 @@ Line and constitutive capability cross-flow part ``C_dy = a + b y0/D`` of Thorsen et al. (2016) read at the amplitude estimate plus a Morison-form term ``c``; ``0 0 1`` keeps Morison's drag and lets the ``VIV AMPLITUDE`` drag factor act on the in-line part alone; finite-EI cables - (:ref:`theory-viv-cf-damping`) + (:ref:`theory-viv-cf-damping`); with a ``VIV FRAME`` row about the flow relative to the + cable's filtered motion (:ref:`theory-viv-frame`) Loads and environment --------------------- diff --git a/doc/driver_format.md b/doc/driver_format.md index 1867df7..9ab410a 100644 --- a/doc/driver_format.md +++ b/doc/driver_format.md @@ -1301,7 +1301,9 @@ Behaviour: - Each node estimates its cross-flow amplitude as Thorsen et al. do (their Eq. 8 and 9): half the travel of the node across the ambient flow between two zero crossings of its cross-flow - velocity, smoothed by a tenth of the difference at every time step. An element takes the mean of + velocity, smoothed by a tenth of the difference at every time step (with a + [VIV FRAME](#viv-frame-optional) row, the flow and the velocity relative to the cable's filtered + motion). An element takes the mean of its free nodes over its diameter as A/D (the one free node next to a fixed end or anchor), and from its table `Cv` (for the lift) and `CdAmp` (times `Cd`, for the normal Morison drag), linear between rows and held beyond the first and @@ -1358,10 +1360,12 @@ Behaviour: ### VIV FRAME (optional) -The flow frame of the VIV model of a line type: the flow the model takes as its free stream, the -ambient flow by default. A cable moved through the water by a tow or by its floater sees no -ambient flow, so its wake oscillator never shed; with a filter time `Tf` the free stream is the -ambient flow relative to the cable's own slow motion (see [Wake oscillator](theory.rst)). +The flow frame of the VIV model of a line type: the frame the model takes the cable's motion and +the free stream in, the earth and the ambient flow by default. A cable moved through the water by +a tow or by its floater sees no ambient flow, so its wake oscillator never shed, and its +synchronisation phase saw no cross-flow velocity and its amplitude estimate stayed at zero; with a +filter time `Tf` the frame moves with the cable's own slow motion (see +[Wake oscillator](theory.rst) and [Flow frame of the synchronisation model](theory.rst)). ```text --------------------- VIV FRAME ---------------------------------------- @@ -1372,23 +1376,37 @@ cable 10 | Column | Meaning | |--------|---------| -| `TypeName` | an existing LINE TYPES name (case-insensitive) with a WAKE OSCILLATOR row, at most one row each | +| `TypeName` | an existing LINE TYPES name (case-insensitive) with LINE TYPES `Cl > 0` or a WAKE OSCILLATOR row, at most one row each | | `Tf` | filter time >= 0 [s], at most 1e15; `0` is the ambient flow | Behaviour: -- With `Tf > 0` the wake frequency `2 pi St U_a/D` takes `U_a` = the speed normal to the line of - the ambient flow less the node's velocity low-pass filtered over `Tf` (first order, started at - the node's initial velocity). The slow motion then counts as flow; the cable's own VIV - velocity, much faster than `Tf`, does not modulate the frequency. -- Take `Tf` several VIV periods long and short against the motion. A taut cable towed at 0.15 m/s - through still water (VIV at 0.28 Hz) with `Tf` 10 s locks in as the same cable held in a - 0.15 m/s current, A/D within 0.6 % and frequency within 0.001 Hz, where the ambient flow gave it - no lock-in. On a held cable in a current `Tf` changes A/D by 0.03 %. +- The node's velocity is low-pass filtered over `Tf` (first order, started at the node's initial + velocity). The slow motion then counts as flow; the cable's own VIV velocity, much faster than + `Tf`, does not. +- On a wake-oscillator type the wake frequency `2 pi St U_a/D` takes `U_a` = the speed normal to + the line of the ambient flow less the filtered velocity. +- On a synchronisation type (LINE TYPES `Cl > 0`) the cross-flow and in-line phases take the + node's velocity less the filtered velocity, along the axes of the relative flow, so the shedding + speed stays the relative normal speed; with a VIV AMPLITUDE table the amplitude estimate takes + that velocity across the ambient flow less the filtered velocity, and with it the table's `Cv` + and `CdAmp`; on a finite-EI cable with VIV DAMPING the split takes its in-line and cross-flow + axes, and its blend to Morison's drag, from that flow. The lift and drag act on the relative + velocity, unchanged. +- Take `Tf` several VIV periods long and short against the motion: the filter scales the VIV + velocity at `omega` by `omega Tf/sqrt(1 + (omega Tf)^2)` (0.9985 at 0.29 Hz with `Tf` 10 s) and + lags a motion at `omega_m` by `atan(omega_m Tf)`. A taut cable towed at 0.15 m/s through still + water (VIV at 0.28 Hz) with `Tf` 10 s locks in as the same cable held in a 0.15 m/s current: + with the wake oscillator A/D within 0.6 % and frequency within 0.001 Hz, where the ambient flow + gave it no lock-in; with the synchronisation model A/D within 0.01 % of the held cable with the + same row (within 0.25 % without the row), with or without a VIV AMPLITUDE table and VIV DAMPING. On a + held cable in a current `Tf` changes A/D by 0.03 % (wake oscillator) and at most 0.23 % + (synchronisation model). - The filtered velocity is part of the step-recovery, snapshot and checkpoint state. A row with `Tf = 0` leaves the run exactly as without it. It acts on `EI = 0` lines and finite-EI cables, standalone and coupled. A row fails if it is not `TypeName Tf`, names an undefined or already - named type or one without a WAKE OSCILLATOR row, or holds a value out of range. + named type or one without VIV (neither LINE TYPES `Cl > 0` nor a WAKE OSCILLATOR row), or holds + a value out of range. ### VIV DAMPING (optional, finite-EI lines) @@ -1417,7 +1435,8 @@ Behaviour: unit length becomes `1/2 rho D [Cdn CdAmp |w| w_x e_x + (C_dy |w_y| + c Cdn |w|) w_y e_y]`: Morison's in-line part, with the drag factor `CdAmp` of the type's amplitude table, and the cross-flow law of the row. Where the ambient normal flow falls below 0.01 m/s the axes are - undefined and the drag blends smoothly back to Morison's. + undefined and the drag blends smoothly back to Morison's. With a [VIV FRAME](#viv-frame-optional) + row the axes and the blend take the ambient flow relative to the cable's filtered motion. - **`0 0 1` amplifies the in-line drag alone.** With an amplitude table's `CdAmp` (for example Chaplin et al. 2005, Eq. 4), the mean in-line drag of a vibrating cable rises while its cross-flow drag stays Morison's. A `CdAmp` without this row multiplies the whole normal drag, diff --git a/doc/theory.rst b/doc/theory.rst index 401839d..857d5bc 100644 --- a/doc/theory.rst +++ b/doc/theory.rst @@ -1374,9 +1374,10 @@ velocity across the ambient flow normal to the line, :math:`\dot{\mathbf r}\cdot \mathbf u_n)/|\mathbf u_n|`: their :math:`y` is measured across the incoming flow, and the cross-flow axis of the phase, across the relative flow, turns with the node's own velocity, which at a response velocity comparable to the flow would shorten the projected velocity by -:math:`U/|\mathbf v_n|` (16 % at the A/D of 0.68 of the gate below). The travel is integrated by -the trapezoidal rule over each step, with a crossing inside a step placed by linear interpolation; -the error is that of the rule, :math:`(\omega\Delta t)^2/12` relative for a harmonic response. +:math:`U/|\mathbf v_n|` (16 % at the A/D of 0.68 of the gate below); a ``VIV FRAME`` row takes the +flow and the velocity relative to the cable's filtered motion (:ref:`theory-viv-frame`). The +travel is integrated by the trapezoidal rule over each step, with a crossing inside a step +placed by linear interpolation; the error is that of the rule, :math:`(\omega\Delta t)^2/12` relative for a harmonic response. The travel is carried signed, :math:`\int\dot y\,\mathrm{d}t` since the last crossing, whose sign is that of the half cycle: a velocity that reverses through a sample at zero ends the half cycle there, and one that touches zero without a sign change ends none. @@ -1443,7 +1444,8 @@ from the still-water decay tests of Vikestad et al. 2000, valid for :math:`y_0/D :math:`u_{ref} = 0.01` m/s the axes are undefined, and :math:`\mathbf f_n` blends to Morison's as :math:`\beta\,\mathbf f_s + (1-\beta)\,\mathbf f_M` with :math:`\beta = U^2/(U^2 + u_{ref}^2)`. The force and its Jacobians in the relative velocity and in the tangent are exact, and the -tangential drag is unchanged. +tangential drag is unchanged. With a ``VIV FRAME`` row the axes and the blend take the ambient flow +relative to the cable's filtered motion (:ref:`theory-viv-frame`). The row serves two uses: @@ -1460,6 +1462,91 @@ with :math:`C_v = 0` and factor 2 the line settles at the static in-line offset printed digits; Thorsen's form raises the steady cross-flow amplitude from :math:`A/D` 0.68 to 1.02; and the drag, damping and VIV powers balance within 0.2 %. +.. _theory-viv-frame: + +Flow frame of the synchronisation model +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +The synchronisation model takes the node's motion in the earth frame. Its phase reads the +cross-flow velocity :math:`\dot{\mathbf r}\cdot\mathbf e` across the relative flow, which is +:math:`\mathbf u\cdot\mathbf e` and so zero in still water; the amplitude estimate and the +cross-flow damping are defined across the ambient flow, which still water does not have. A cable +moved through still water, by a tow or by its floater, therefore locks its phase on +:math:`\ddot y` alone, keeps :math:`y_0^* = 0`, :math:`C_v(0)` and the drag factor at 0, and its +damping blends to Morison's, while the same problem in the cable's frame (the water moving past +the held cable) does not. A ``VIV FRAME`` row with :math:`T_f > 0` on a synchronisation type +(LINE TYPES ``Cl > 0``) takes these quantities in the frame of the node's filtered velocity +:math:`\bar{\mathbf v}` of :ref:`theory-viv-wake` (the same filter, started at the node's +velocity): + +- the phases (cross-flow, and in-line where it runs) take :math:`\dot{\mathbf r} - + \bar{\mathbf v}` along their axes, which the relative flow sets, so the axes and the shedding + speed :math:`U` stay those of the relative flow; the acceleration stays the node's, since + :math:`\bar{\mathbf v}` changes slowly and its rate :math:`(\mathbf v - \bar{\mathbf v})/T_f` + would carry the VIV velocity; +- the amplitude estimate takes + + .. math:: + + \dot y = (\dot{\mathbf r} - \bar{\mathbf v})\cdot + \frac{\mathbf t\times(\mathbf u - \bar{\mathbf v})_n}{|(\mathbf u - \bar{\mathbf v})_n|}, + + and with it the table's :math:`C_v`, drag factor and :math:`C_{dy}`; +- the damping takes :math:`\mathbf e_x`, :math:`\mathbf e_y` and the blend :math:`\beta` from + :math:`(\mathbf u - \bar{\mathbf v})_n`, an element the mean :math:`\bar{\mathbf v}` of its end + nodes. + +:math:`\bar{\mathbf v}` is held over a step (the step-start value), so the Jacobians are +unchanged, and it is updated at the converged end. The lift and the drag act on the relative +velocity, which does not depend on the frame, and are unchanged. For a frame moving at a constant +velocity (a steady tow) the model is that of the held cable exactly. The velocity relative to +:math:`\bar{\mathbf v}` loses the part of the VIV velocity that passes the filter: for a response +at :math:`\omega` it is scaled by :math:`\omega T_f/\sqrt{1 + \omega^2 T_f^2}` and led by +:math:`\arctan(1/\omega T_f)` (0.9985 and 3.1° at 0.29 Hz with :math:`T_f` 10 s). For a motion at +:math:`\omega_m` the filter lags by :math:`\arctan\omega_m T_f`. :math:`T_f` is therefore taken +several VIV periods long and short against the motion. + +A pipe of the displaced mass (20 m, :math:`D` 0.1 m, ``Cl`` 0.8) moved in still water with +velocity amplitude 0.6 m/s and period 40 s, against the same pipe held in the water moving the +other way (the held fluid field, so the Froude-Krylov load acts; a pipe of another mass would +differ by :math:`(m - \rho A)\dot V`), with :math:`T_f` 0.6 s: + +.. list-table:: + :header-rows: 1 + + * - Pipe + - Frame + - Peak A/D moving / held + - RMS A/D moving / held + * - Amplitude table and Thorsen's damping + - ``Tf`` 0.6 s + - 0.819 / 0.819 + - 0.446 / 0.447 + * - + - none + - 0.711 / 0.850 + - 0.349 / 0.450 + * - ``Cl`` alone + - ``Tf`` 0.6 s + - 0.713 / 0.714 + - 0.372 / 0.371 + * - + - none + - 0.711 / 0.736 + - 0.349 / 0.375 + +With the row the RMS of the two frames agrees within 0.2 % and the peak within 1 % (the moving +pipe's peak, a single extreme, ranges 0.811-0.819 over builds, OpenBLAS kernels and platforms), +the rest being the filter's lag +(:math:`\omega_m T_f` = 0.094). A taut cable towed at 0.15 m/s with :math:`T_f` 10 s gives A/D +0.7905 against 0.7906 held in the current with the same row (0.792 without it; 0.665 towed without +the row) with the table and damping, and 0.6764 against 0.6764 with ``Cl`` alone. On the held +cable :math:`T_f` changes A/D by at most 0.23 % on both line kinds. :math:`\bar{\mathbf v}` takes +rows 7-9 of the node's motion statistics on both line kinds (nine rows; rows 3-6, the amplitude +estimate, stay 0 without a table), so it is part of the step-recovery, snapshot and checkpoint +state; an ``EI = 0`` line filters its smoothed node velocity. :math:`T_f` 0 or no row leaves the +run unchanged to the bit. + .. _theory-viv-coefficients: Published coefficient sets diff --git a/python/cabledyn/builder.py b/python/cabledyn/builder.py index 7efb186..e0bed97 100644 --- a/python/cabledyn/builder.py +++ b/python/cabledyn/builder.py @@ -234,7 +234,10 @@ class LineType: ``Name Tf``: the filter time [s] of the cable velocity the model's free stream is taken relative to (0: the ambient flow; set it for a cable moved through the water by a tow or its floater). It sets the wake - oscillator's frequency, so it needs ``wake_cl0``. ``None`` writes no row. + oscillator's frequency, or on the synchronisation model the motion of + the phases, the amplitude estimate (and so the ``viv_amplitude`` + coefficients) and the ``viv_damping`` split, so it needs ``cl > 0`` or + ``wake_cl0``. ``None`` writes no row. viv_amplitude : list of tuples | None Optional amplitude-dependent VIV coefficients of a type (Thorsen et al. 2016), the rows of a ``VIV AMPLITUDE`` section table ``Name AD Cv @@ -3102,9 +3105,9 @@ def _viv_frame_table(self) -> tuple[str, str, list[list[str]]]: if item.viv_frame_tf is None: continue what = f"line type {item.name!r}" - if item.wake_cl0 is None: + if item.wake_cl0 is None and not (item.cl is not None and item.cl > 0.0): raise ValueError( - f"{what}: viv_frame_tf sets the frame of its wake oscillator, set wake_cl0" + f"{what}: viv_frame_tf sets the frame of its VIV model, set cl > 0 or wake_cl0" ) rows.append([_text(item.name, what), _num(item.viv_frame_tf, what)]) return "Name Tf", "(-) (s)", rows diff --git a/python/cabledyn/deck_file.py b/python/cabledyn/deck_file.py index 48a258e..3b2b5d3 100644 --- a/python/cabledyn/deck_file.py +++ b/python/cabledyn/deck_file.py @@ -3387,14 +3387,15 @@ def _check_viv_diam_section(self, viv_type_names: set[str]) -> None: "VIV: give the type LINE TYPES Cl > 0 or a WAKE OSCILLATOR row" ) - def _check_viv_frame_section(self, wake_type_names: set[str]) -> None: + def _check_viv_frame_section(self, frame_type_names: set[str]) -> None: """Native ``apply_type_viv_frame`` for the VIV FRAME section. A row ``TypeName Tf`` sets the flow frame of a line type's VIV model: with the filter time ``Tf > 0`` [s] the free stream is the ambient flow relative to the cable's velocity low-pass filtered over ``Tf`` (0: the ambient flow), at most 1e15. It sets the wake - oscillator's frequency, so the type needs a WAKE OSCILLATOR row with ``CL0 > 0``; a type - takes one row. + oscillator's frequency, or on the synchronisation model the motion of the phases, the + amplitude estimate and the VIV DAMPING split, so the type needs LINE TYPES ``Cl > 0`` or + a WAKE OSCILLATOR row with ``CL0 > 0`` (``frame_type_names``); a type takes one row. """ types = {row.tokens[0].lower(): row.tokens[0] for row in self.line_types} named: set[str] = set() @@ -3419,10 +3420,10 @@ def _check_viv_frame_section(self, wake_type_names: set[str]) -> None: f"{where}: VIV FRAME filter time Tf must be >= 0 (0 = the ambient flow), " "at most 1e15" ) - if name not in wake_type_names: + if name not in frame_type_names: raise DeckFormatError( f'{where}: VIV FRAME of LINE TYPE "{types[name]}" sets the flow frame of its ' - "wake oscillator: give the type a WAKE OSCILLATOR row" + "VIV model: give the type LINE TYPES Cl > 0 or a WAKE OSCILLATOR row" ) def _check_viv_damp_section(self, amp_type_names: set[str]) -> set[str]: @@ -4824,7 +4825,7 @@ def end_key(token: str) -> str: wake_type_names = self._check_wake_section(viv_type_names) amp_type_names = self._check_viv_amp_section(viv_type_names) self._check_viv_diam_section(viv_type_names | wake_type_names) - self._check_viv_frame_section(wake_type_names) + self._check_viv_frame_section(viv_type_names | wake_type_names) damp_type_names = self._check_viv_damp_section(amp_type_names) amp_lines = { line_id diff --git a/python/tests/test_builder.py b/python/tests/test_builder.py index 556cbf3..7a887fa 100644 --- a/python/tests/test_builder.py +++ b/python/tests/test_builder.py @@ -296,8 +296,24 @@ def test_viv_frame_rows_are_written(tmp_path: Path) -> None: ) deck = DeckFile.from_text(model.to_text(validate=False), path=tmp_path / "deck.dat") assert [row.tokens for row in deck._rows("VIV FRAME")] == [("towed", "8.0")] + model.add_line_type( + "lifted", + diam=0.1, + mass=10.0, + ea=5.0e7, + cl=0.8, + viv_amplitude=[(0.0, 0.8, 1.0), (1.0, 0.4, 1.5)], + viv_frame_tf=6.0, + ) + model.add_line_type("lift", diam=0.1, mass=10.0, ea=5.0e7, cl=0.8, viv_frame_tf=4.0) + deck = DeckFile.from_text(model.to_text(validate=False), path=tmp_path / "deck.dat") + assert [row.tokens for row in deck._rows("VIV FRAME")] == [ + ("towed", "8.0"), + ("lifted", "6.0"), + ("lift", "4.0"), + ] model.add_line_type("plain", diam=0.1, mass=10.0, ea=5.0e7, viv_frame_tf=8.0) - with pytest.raises(ValueError, match="set wake_cl0"): + with pytest.raises(ValueError, match="set cl > 0 or wake_cl0"): model.to_text(validate=False) diff --git a/python/tests/test_deck_file.py b/python/tests/test_deck_file.py index 3e62ec3..8646f13 100644 --- a/python/tests/test_deck_file.py +++ b/python/tests/test_deck_file.py @@ -5016,7 +5016,7 @@ def test_viv_frame_rows_are_read_and_kept(tmp_path): (True, ("cable 8",), 'undefined LINE TYPE "cable"'), (True, ("chain 8", "chain 4"), 'names LINE TYPE "chain" twice'), (True, ("chain -1",), "filter time Tf must be >= 0"), - (False, ("chain 8",), "give the type a WAKE OSCILLATOR row"), + (False, ("chain 8",), "give the type LINE TYPES Cl > 0 or a WAKE OSCILLATOR row"), ], ) def test_viv_frame_rows_follow_the_native_checks(wake, rows, message): @@ -5033,6 +5033,15 @@ def test_viv_frame_rows_follow_the_native_checks(wake, rows, message): ) +def test_viv_frame_takes_a_synchronisation_type(): + # the phases of the lift alone, and with a table its estimate and damping split, take it + lift_only = _edit(_DYNAMIC, (_LIFT_ROW, _LIFT_ROW + " 0.8")) + DeckFile.from_text(_with_section(lift_only, "VIV FRAME", "chain 8")) + DeckFile.from_text(_with_section(_DAMP_BASE, "VIV FRAME", "chain 8")) + damped = _with_section(_DAMP_BASE, "VIV DAMPING", "chain 0.31 0.89") + DeckFile.from_text(_with_section(damped, "VIV FRAME", "chain 8")) + + @pytest.mark.parametrize( "rows, expected", [ diff --git a/python/tests/test_end_to_end.py b/python/tests/test_end_to_end.py index 91c9699..580a079 100644 --- a/python/tests/test_end_to_end.py +++ b/python/tests/test_end_to_end.py @@ -361,7 +361,13 @@ def _frame_rows(*rows: str) -> tuple[str, str]: [_WAKE_LIFT, _WAKE_SECTION, _WAKE_RISER, _frame_rows("riser 8 1")], False, ), - ("frame-sync-type", [_frame_rows("riser 8")], False), + ("frame-sync-type", [_frame_rows("riser 8")], True), + ("frame-no-viv", [_WAKE_LIFT, ("riser 0.85 0.15", ""), _frame_rows("riser 8")], False), + ( + "frame-amp-type", + [_amp_table("riser 0.0 0.8 1.0", "riser 0.5 0.4 1.5"), _frame_rows("riser 8")], + True, + ), ] _AMP_PARITY += _FRAME_PARITY @@ -381,6 +387,7 @@ def _damp_rows(*rows: str) -> tuple[str, str]: ("damp-negative", [_DAMP_TABLE, _damp_rows("riser 0.31 -0.89")], False), ("damp-one-value", [_DAMP_TABLE, _damp_rows("riser 0.31")], False), ("damp-repeated", [_DAMP_TABLE, _damp_rows("riser 0.31 0.89", "riser 0 0 1")], False), + ("damp-frame", [_DAMP_TABLE, _damp_rows("riser 0.31 0.89"), _frame_rows("riser 8")], True), ( "damp-ei0-line", [ diff --git a/src/CableDyn_DeckDriver.f90 b/src/CableDyn_DeckDriver.f90 index 17ce2b7..10a15ce 100644 --- a/src/CableDyn_DeckDriver.f90 +++ b/src/CableDyn_DeckDriver.f90 @@ -3728,7 +3728,8 @@ RECURSIVE SUBROUTINE build_one_hermite_cable(ln, sections, types, points, opts, opts%viv_rms_window > CD_ZERO), es, em, phase_seed=seed, & tangent_reversed=.NOT. ln%ends_swapped, clx=viv_clx, il_alpha=viv_al, & chh=viv_hh, amp=viv_amp3, amp_n=viv_ampn, dviv=viv_dva, & - cdy=RESHAPE([cdy_a, cdy_b, cdy_c], [3, SIZE(cdy_a)], ORDER=[2, 1])) + cdy=RESHAPE([cdy_a, cdy_b, cdy_c], [3, SIZE(cdy_a)], ORDER=[2, 1]), & + tf=wo_tf) ELSE CALL CD_HermiteCable_Dyn_Set_VIV(cable%line, viv_cl, viv_cf, viv_df, & MERGE(opts%viv_rms_window, & @@ -3736,7 +3737,8 @@ RECURSIVE SUBROUTINE build_one_hermite_cable(ln, sections, types, points, opts, opts%viv_rms_window > CD_ZERO), es, em, phase_seed=seed, & tangent_reversed=.NOT. ln%ends_swapped, amp=viv_amp3, amp_n=viv_ampn, & dviv=viv_dva, & - cdy=RESHAPE([cdy_a, cdy_b, cdy_c], [3, SIZE(cdy_a)], ORDER=[2, 1])) + cdy=RESHAPE([cdy_a, cdy_b, cdy_c], [3, SIZE(cdy_a)], ORDER=[2, 1]), & + tf=wo_tf) END IF END BLOCK IF (es /= CD_HCDYN_OK) THEN @@ -10458,6 +10460,8 @@ RECURSIVE SUBROUTINE init_one_model(ln, sections, types, points, opts, model, Er REAL(wp), ALLOCATABLE :: viv_tix(:), viv_amp3(:, :, :), viv_dia(:) ! the WAKE OSCILLATOR rows per element (C_L0, St, eps, A, Tf; C_L0 0 where none) REAL(wp), ALLOCATABLE :: viv_wo(:, :) + ! the VIV FRAME filter time per element (0 where none) + REAL(wp), ALLOCATABLE :: viv_ftf(:) INTEGER, ALLOCATABLE :: viv_ampn(:) LOGICAL, ALLOCATABLE :: syr_el(:) REAL(wp) :: anchor(3), fairlead(3), mode1_omega @@ -10498,9 +10502,10 @@ RECURSIVE SUBROUTINE init_one_model(ln, sections, types, points, opts, model, Er hydro_can(SIZE(l0)), hydro_cat(SIZE(l0)), ve_ead(SIZE(l0)), ve_bas(SIZE(l0)), & ve_bad(SIZE(l0)), ve_ambl(SIZE(l0)), ve_vbet(SIZE(l0)), viv_cl(SIZE(l0)), viv_cf(SIZE(l0)), & viv_df(SIZE(l0)), syr_el(SIZE(l0)), viv_clx(SIZE(l0)), viv_al(SIZE(l0)), viv_hh(SIZE(l0)), & - viv_tix(SIZE(l0)), viv_dia(SIZE(l0)), viv_wo(5, SIZE(l0))) + viv_tix(SIZE(l0)), viv_dia(SIZE(l0)), viv_wo(5, SIZE(l0)), viv_ftf(SIZE(l0))) viv_tix = CD_ZERO viv_wo = CD_ZERO + viv_ftf = CD_ZERO viv_dia = CD_ZERO viv_cl = CD_ZERO viv_cf = CD_ZERO @@ -10586,6 +10591,7 @@ RECURSIVE SUBROUTINE init_one_model(ln, sections, types, points, opts, model, Er viv_dia(e) = MERGE(types(line_section_type(sections, ln%id, i))%viv_dv, hydro_diam(e), & types(line_section_type(sections, ln%id, i))%viv_dv > CD_ZERO) syr_el(e) = types(line_section_type(sections, ln%id, i))%is_syrope + viv_ftf(e) = types(line_section_type(sections, ln%id, i))%viv_tf END DO END DO syr_el = syr_el(SIZE(syr_el):1:-1) @@ -10598,6 +10604,7 @@ RECURSIVE SUBROUTINE init_one_model(ln, sections, types, points, opts, model, Er viv_tix = viv_tix(SIZE(viv_tix):1:-1) viv_dia = viv_dia(SIZE(viv_dia):1:-1) viv_wo = viv_wo(:, SIZE(viv_wo, 2):1:-1) + viv_ftf = viv_ftf(SIZE(viv_ftf):1:-1) IF (ANY(viv_wo(1, :) > CD_ZERO) .AND. ANY(viv_cl > CD_ZERO)) THEN CALL fail(ErrStat, ErrMsg, 'line '//TRIM(int_to_str(ln%id))//': a line takes one VIV model, but its '// & 'types mix the synchronisation lift (LINE TYPES Cl > 0) and the wake oscillator (WAKE '// & @@ -10904,11 +10911,11 @@ RECURSIVE SUBROUTINE init_one_model(ln, sections, types, points, opts, model, Er ELSE IF (ANY(viv_clx > CD_ZERO)) THEN CALL CD_Set_Model_VIV(model, opts%rhoW, viv_cl, viv_dia, viv_cf, viv_df, tw, es, em, & phase_seed=seed, tangent_reversed=.NOT. ln%ends_swapped, clx=viv_clx, & - il_alpha=viv_al, chh=viv_hh, amp=viv_amp3, amp_n=viv_ampn) + il_alpha=viv_al, chh=viv_hh, amp=viv_amp3, amp_n=viv_ampn, tf=viv_ftf) ELSE CALL CD_Set_Model_VIV(model, opts%rhoW, viv_cl, viv_dia, viv_cf, viv_df, tw, es, em, & phase_seed=seed, tangent_reversed=.NOT. ln%ends_swapped, amp=viv_amp3, & - amp_n=viv_ampn) + amp_n=viv_ampn, tf=viv_ftf) END IF END BLOCK IF (es == CD_MODEL_OK) CALL CD_Recompute_Model_Acceleration(model, es, em) @@ -17886,7 +17893,11 @@ SUBROUTINE apply_type_viv_frame(row, types, ErrStat, ErrMsg) !! flow relative to the cable's velocity low-pass filtered over Tf (first order), so that a !! cable moved through the water by a tow or its floater sees that motion as flow, and its own !! VIV velocity, much faster than Tf, does not count; Tf 0 is the ambient flow. It sets the - !! wake oscillator's frequency; the type needs a WAKE OSCILLATOR row. A type takes one row. + !! wake oscillator's frequency, or on the synchronisation model (LINE TYPES Cl > 0) the motion + !! of the phases (the cable's velocity relative to the filtered one) and the ambient-frame + !! quantities: the amplitude estimate (and so the VIV AMPLITUDE coefficients) and the axes of + !! the VIV DAMPING split; the shedding speed stays the relative normal speed. The type needs + !! LINE TYPES Cl > 0 or a WAKE OSCILLATOR row. A type takes one row. CHARACTER(*), INTENT(IN) :: row TYPE(DeckLineType), INTENT(INOUT) :: types(:) INTEGER, INTENT(OUT) :: ErrStat @@ -17917,9 +17928,9 @@ SUBROUTINE apply_type_viv_frame(row, types, ErrStat, ErrMsg) CALL fail(ErrStat, ErrMsg, 'VIV FRAME filter time Tf must be >= 0 (0 = the ambient flow), at most 1e15') RETURN END IF - IF (.NOT. (types(it)%wo_cl0 > CD_ZERO)) THEN + IF (.NOT. (types(it)%wo_cl0 > CD_ZERO .OR. types(it)%cl > CD_ZERO)) THEN CALL fail(ErrStat, ErrMsg, 'VIV FRAME of LINE TYPE "'//TRIM(types(it)%name)//'" sets the flow frame of '// & - 'its wake oscillator: give the type a WAKE OSCILLATOR row'); RETURN + 'its VIV model: give the type LINE TYPES Cl > 0 or a WAKE OSCILLATOR row'); RETURN END IF types(it)%viv_tf = v types(it)%has_vivf_row = .TRUE. diff --git a/src/CableDyn_HermiteCableDynamic.f90 b/src/CableDyn_HermiteCableDynamic.f90 index fb7b558..9937a2d 100644 --- a/src/CableDyn_HermiteCableDynamic.f90 +++ b/src/CableDyn_HermiteCableDynamic.f90 @@ -69,7 +69,7 @@ MODULE CableDyn_HermiteCableDynamic CD_VIV_Wrap_Phase, CD_VIV_TWO_PI, CD_VIV_NM, CD_VIV_Inline_Per_Length, & CD_VIV_Inline_Phase_Rate, CD_VIV_Wake_Advance, CD_VIV_NMS, CD_VIV_NMS_AMP, & CD_VIV_AMP_MAXP, CD_VIV_Amplitude_Update, CD_VIV_Table, CD_VIV_Check_Amp_Table, & - CD_VIV_Ambient_Crossflow_Rate + CD_VIV_Ambient_Crossflow_Rate, CD_VIV_NMS_FRAME USE CableDyn_Hydro, ONLY: CD_Morison_Drag_Per_Length_Jac, CD_Airy_Wave_Kinematics_Precomputed, & CD_Morison_Drag_Split_Per_Length_Jac, & CD_Component_Wave_Kinematics, CD_Solve_Dispersion_Wavenumber, CD_HYDRO_OK @@ -386,6 +386,17 @@ MODULE CableDyn_HermiteCableDynamic ! flow (elem_cdy, elem_cdy_lin; c Cdn with the element's unamplified Cdn); a < 0, or the array ! unallocated, keeps the element's Morison drag. REAL(wp), ALLOCATABLE :: viv_cdy(:, :) + ! The flow frame of the synchronisation model (Set_VIV tf; VIV FRAME section): with a filter + ! time viv_ftfe(e) > 0 on some element (viv_frame) viv_ms has CD_VIV_NMS_FRAME rows, rows 7:9 + ! the node's velocity low-pass filtered over viv_ftf(k) (first order; the length-weighted + ! average over the node's lifting elements), rows 3:6 the amplitude estimate (0 without + ! amplitude tables). The node's velocity relative to it drives the phases (viv_node_motion; + ! the relative flow, and so the shedding speed, unchanged), and the ambient-frame quantities + ! take the ambient flow relative to it: the amplitude estimate (viv_node_ambient_yd) and so the + ! amplitude-table coefficients, and on an element with viv_ftfe(e) > 0 the axes and blend of + ! the cross-flow damping (elem_frame_v, the mean over its end nodes). + LOGICAL :: viv_frame = .FALSE. + REAL(wp), ALLOCATABLE :: viv_ftf(:), viv_ftfe(:) REAL(wp), ALLOCATABLE :: Mgb(:, :) ! constant global mass (band) LOGICAL, ALLOCATABLE :: freemask(:), solve_mask(:) INTEGER, ALLOCATABLE :: fmap(:) ! free -> global DOF index @@ -1151,7 +1162,7 @@ SUBROUTINE CD_HermiteCable_Dyn_Set_Friction_Axial(model, mu_axial, ErrStat, ErrM END SUBROUTINE CD_HermiteCable_Dyn_Set_Friction_Axial SUBROUTINE CD_HermiteCable_Dyn_Set_VIV(model, cl, cf, df, t_window, ErrStat, ErrMsg, phase_seed, tangent_reversed, & - clx, il_alpha, chh, wake, amp, amp_n, dviv, cdy) + clx, il_alpha, chh, wake, amp, amp_n, dviv, cdy, tf) !! 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 @@ -1201,6 +1212,15 @@ SUBROUTINE CD_HermiteCable_Dyn_Set_VIV(model, cl, cf, df, t_window, ErrStat, Err !! CD_Morison_Drag_Split_Per_Length_Jac), y0 the smoothed amplitude estimate, so an element with !! it needs an amplitude table (amp_n > 0); a, b, c >= 0, finite. (0, 0, 1) amplifies the in-line !! drag alone and keeps Morison's cross-flow drag. + !! + !! tf (optional, ne; not with the wake oscillator, which takes it as wake(4, :)), per element the + !! filter time Tf [s] of the flow frame of the synchronisation model (0: the ambient flow; > 0 + !! only where cl > 0, at most 1e15), vbar the node velocity low-pass filtered over Tf (first + !! order): the cross-flow and in-line motion of the phases takes the node's velocity relative + !! to vbar (along the axes of the relative flow); the amplitude estimate takes it across the + !! ambient flow relative to vbar; and the cross-flow damping takes its axes and blend from that + !! flow. A cable moved through the water by a tow or its floater then sees that motion as flow. + !! The shedding speed of the phase rate stays the relative normal speed. TYPE(CD_HermiteCableDynType), INTENT(INOUT) :: model REAL(wp), INTENT(IN) :: cl(:), cf(:), df(:), t_window INTEGER, INTENT(OUT) :: ErrStat @@ -1216,13 +1236,14 @@ SUBROUTINE CD_HermiteCable_Dyn_Set_VIV(model, cl, cf, df, t_window, ErrStat, Err INTEGER, INTENT(IN), OPTIONAL :: amp_n(:) REAL(wp), INTENT(IN), OPTIONAL :: dviv(:) REAL(wp), INTENT(IN), OPTIONAL :: cdy(:, :) + REAL(wp), INTENT(IN), OPTIONAL :: tf(:) INTEGER :: e, k, ne, nn, es, nms, nw - LOGICAL :: had_filter + LOGICAL :: had_filter, had_frame, want_frame REAL(wp) :: wsum, tw_old, rest_old LOGICAL :: had_viv, had_il, want_il, had_wake, want_wake, bad_band, had_amp, want_amp CHARACTER(LEN=1024) :: em REAL(wp), ALLOCATABLE :: p_amp(:, :, :) - REAL(wp), ALLOCATABLE :: p_dv(:), p_cdy(:, :) + REAL(wp), ALLOCATABLE :: p_dv(:), p_cdy(:, :), p_ftf(:), p_ftfe(:) INTEGER, ALLOCATABLE :: p_ampn(:) REAL(wp), ALLOCATABLE :: a_old(:), o_cl(:), o_k(:), o_cf(:), o_df(:), o_dn(:), o_phi(:), o_phi_eval(:), & o_rate(:), o_ms(:, :), o_ms_next(:, :), o_rec_phi(:), o_rec_ms(:, :), & @@ -1400,11 +1421,39 @@ SUBROUTINE CD_HermiteCable_Dyn_Set_VIV(model, cl, cf, df, t_window, ErrStat, Err END IF END DO END IF + want_frame = .FALSE. + IF (PRESENT(tf)) THEN + IF (want_wake) THEN + ErrStat = CD_HCDYN_BADINPUT + ErrMsg = 'CD_HermiteCable_Dyn_Set_VIV: the wake oscillator takes its filter time as wake(4, :), not tf' + RETURN + END IF + IF (SIZE(tf) /= ne) THEN + ErrStat = CD_HCDYN_BADINPUT; ErrMsg = 'CD_HermiteCable_Dyn_Set_VIV: tf must have one value per element' + RETURN + END IF + IF (.NOT. CD_All_Finite(tf)) THEN + ErrStat = CD_HCDYN_BADINPUT; ErrMsg = 'CD_HermiteCable_Dyn_Set_VIV: tf must be finite'; RETURN + END IF + IF (ANY(tf < CD_ZERO) .OR. ANY(tf > 1.0e15_wp)) THEN + ErrStat = CD_HCDYN_BADINPUT + ErrMsg = 'CD_HermiteCable_Dyn_Set_VIV: the flow-frame filter time Tf must be >= 0 (0 = the ambient '// & + 'flow) and at most 1e15' + RETURN + END IF + IF (ANY(tf > CD_ZERO .AND. .NOT. (cl > CD_ZERO))) THEN + ErrStat = CD_HCDYN_BADINPUT + ErrMsg = 'CD_HermiteCable_Dyn_Set_VIV: the flow frame (tf > 0) acts on the VIV model: tf > 0 only where cl > 0' + RETURN + END IF + want_frame = ANY(tf > CD_ZERO) + END IF ! the previous configuration and state, kept for a rollback had_viv = model%has_viv had_il = model%has_viv_il had_wake = model%viv_wake had_filter = model%wo_filter + had_frame = model%viv_frame had_amp = model%has_viv_amp tw_old = model%viv_tw rest_old = model%viv_phi_rest @@ -1420,6 +1469,7 @@ SUBROUTINE CD_HermiteCable_Dyn_Set_VIV(model, cl, cf, df, t_window, ErrStat, Err RETURN END IF nms = MERGE(CD_VIV_NMS_AMP, CD_VIV_NMS, want_amp) + IF (want_frame) nms = CD_VIV_NMS_FRAME ALLOCATE (model%viv_cl(ne), model%viv_k(ne), model%viv_cf(nn), model%viv_df(nn), model%viv_dn(nn), & model%viv_phi(nn), & model%viv_phi_eval(nn), model%viv_rate(nn), model%viv_ms(nms, nn), model%viv_ms_next(nms, nn), & @@ -1466,6 +1516,25 @@ 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_frame) THEN + ! the filter time per element and per node (length-weighted over its lifting elements, as + ! the band); the filtered velocity starts at the node's velocity + ALLOCATE (model%viv_ftfe(ne), model%viv_ftf(nn)) + model%viv_ftfe = tf + model%viv_ftf = CD_ZERO + DO k = 1, nn + IF (.NOT. model%viv_node(k)) CYCLE + wsum = CD_ZERO + DO e = MAX(1, k - 1), MIN(ne, k) + IF (.NOT. (cl(e) > CD_ZERO)) CYCLE + wsum = wsum + model%l0(e) + model%viv_ftf(k) = model%viv_ftf(k) + model%l0(e)*tf(e) + END DO + model%viv_ftf(k) = model%viv_ftf(k)/wsum + model%viv_ms(7:9, k) = model%v(6*(k - 1) + 1:6*(k - 1) + 3) + END DO + model%viv_frame = .TRUE. + END IF 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), & @@ -1576,6 +1645,7 @@ SUBROUTINE refresh_acceleration() model%has_viv_il = had_il model%viv_wake = had_wake model%wo_filter = had_filter + model%viv_frame = had_frame model%has_viv_amp = had_amp model%viv_tw = tw_old model%viv_phi_rest = rest_old @@ -1612,6 +1682,7 @@ SUBROUTINE move_viv(back) CALL MOVE_ALLOC(p_amp, model%viv_amp); CALL MOVE_ALLOC(p_ampn, model%viv_amp_n) CALL MOVE_ALLOC(p_dv, model%viv_dv) CALL MOVE_ALLOC(p_cdy, model%viv_cdy) + CALL MOVE_ALLOC(p_ftf, model%viv_ftf); CALL MOVE_ALLOC(p_ftfe, model%viv_ftfe) 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) @@ -1637,6 +1708,7 @@ SUBROUTINE move_viv(back) CALL MOVE_ALLOC(model%viv_amp, p_amp); CALL MOVE_ALLOC(model%viv_amp_n, p_ampn) CALL MOVE_ALLOC(model%viv_dv, p_dv) CALL MOVE_ALLOC(model%viv_cdy, p_cdy) + CALL MOVE_ALLOC(model%viv_ftf, p_ftf); CALL MOVE_ALLOC(model%viv_ftfe, p_ftfe) END IF END SUBROUTINE move_viv END SUBROUTINE CD_HermiteCable_Dyn_Set_VIV @@ -1663,6 +1735,9 @@ SUBROUTINE clear_viv(model) IF (ALLOCATED(model%viv_amp_n)) DEALLOCATE (model%viv_amp_n) IF (ALLOCATED(model%viv_dv)) DEALLOCATE (model%viv_dv) IF (ALLOCATED(model%viv_cdy)) DEALLOCATE (model%viv_cdy) + IF (ALLOCATED(model%viv_ftf)) DEALLOCATE (model%viv_ftf) + IF (ALLOCATED(model%viv_ftfe)) DEALLOCATE (model%viv_ftfe) + model%viv_frame = .FALSE. model%has_viv_amp = .FALSE. model%has_viv = .FALSE. model%has_viv_il = .FALSE. @@ -1776,7 +1851,8 @@ END FUNCTION elem_cdy_lin REAL(wp) FUNCTION viv_node_ambient_yd(model, k) RESULT(yd) !! Cross-flow velocity of node k across the ambient flow (current plus a held field) normal to !! its tangent (the slope DOFs) at the committed state, the y' of the amplitude estimate - !! (CD_VIV_Ambient_Crossflow_Rate). + !! (CD_VIV_Ambient_Crossflow_Rate). With the flow frame (viv_ftf(k) > 0) the flow and the + !! node's velocity are both taken relative to the node's filtered velocity. TYPE(CD_HermiteCableDynType), INTENT(IN) :: model INTEGER, INTENT(IN) :: k REAL(wp) :: uu(3) @@ -1784,9 +1860,29 @@ REAL(wp) FUNCTION viv_node_ambient_yd(model, k) RESULT(yd) i0 = 6*(k - 1) uu = model%current IF (model%has_held_field) uu = uu + model%hf_u(:, k) + IF (model%viv_frame) THEN + IF (model%viv_ftf(k) > CD_ZERO) THEN + yd = CD_VIV_Ambient_Crossflow_Rate(model%q(i0 + 4:i0 + 6), model%v(i0 + 1:i0 + 3) - model%viv_ms(7:9, k), & + uu - model%viv_ms(7:9, k)) + RETURN + END IF + END IF yd = CD_VIV_Ambient_Crossflow_Rate(model%q(i0 + 4:i0 + 6), model%v(i0 + 1:i0 + 3), uu) END FUNCTION viv_node_ambient_yd + PURE FUNCTION elem_frame_v(model, e) RESULT(vf) + !! The velocity of the flow frame of element e, which the ambient flow of its cross-flow damping + !! is taken relative to: the mean filtered velocity of its end nodes where the element has the + !! flow frame (viv_ftfe(e) > 0), else zero. + TYPE(CD_HermiteCableDynType), INTENT(IN) :: model + INTEGER, INTENT(IN) :: e + REAL(wp) :: vf(3) + vf = CD_ZERO + IF (.NOT. model%viv_frame) RETURN + IF (.NOT. (model%viv_ftfe(e) > CD_ZERO)) RETURN + vf = 0.5_wp*(model%viv_ms(7:9, e) + model%viv_ms(7:9, e + 1)) + END FUNCTION elem_frame_v + REAL(wp) FUNCTION viv_node_ambient_speed(model, k, vslow) RESULT(ua) !! Speed of the ambient flow (current plus a held field) normal to node k's tangent (the slope !! DOFs) at the committed state, relative to the velocity vslow (optional; the node's filtered @@ -1811,7 +1907,11 @@ END FUNCTION viv_node_ambient_speed SUBROUTINE viv_node_motion(model, k, yd, ydd, un, ok, xd, xdd) !! Cross-flow velocity and acceleration of node k at the committed state, along its own !! tangent (the slope DOFs), in the flow the drag sees there (current plus a held field); - !! optionally (both or neither) the in-line ones. + !! optionally (both or neither) the in-line ones. With the flow frame (viv_ftf(k) > 0) the + !! velocity is the node's velocity relative to its filtered velocity vbar (the relative flow, + !! and so the axes and U, unchanged): a cable moved through still water then moves across the + !! flow only by its own VIV, as the held cable in the moving water does. The acceleration stays + !! the node's: vbar changes slowly, and its rate (v - vbar)/Tf would carry the VIV velocity. TYPE(CD_HermiteCableDynType), INTENT(IN) :: model INTEGER, INTENT(IN) :: k REAL(wp), INTENT(OUT) :: yd, ydd, un @@ -1822,6 +1922,14 @@ SUBROUTINE viv_node_motion(model, k, yd, ydd, un, ok, xd, xdd) i0 = 6*(k - 1) uu = model%current IF (model%has_held_field) uu = uu + model%hf_u(:, k) + IF (model%viv_frame) THEN + IF (model%viv_ftf(k) > CD_ZERO) THEN + ! absent xd, xdd pass on absent + CALL CD_VIV_Crossflow_Along(model%q(i0 + 4:i0 + 6), model%v(i0 + 1:i0 + 3) - model%viv_ms(7:9, k), & + model%a(i0 + 1:i0 + 3), uu - model%viv_ms(7:9, k), yd, ydd, un, ok, xd, xdd) + RETURN + END IF + END IF 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) @@ -1967,6 +2075,14 @@ SUBROUTINE viv_step_end(model, dt) CALL CD_VIV_Amplitude_Update(st, yda, dt) model%viv_ms_next(3:6, k) = st END IF + IF (model%viv_frame) THEN + ! the flow frame's filtered velocity, exact for the first-order filter of the converged end + ! velocity held over the step (a non-finite end velocity keeps it); the estimate above took + ! the step-start one + IF (model%viv_ftf(k) > CD_ZERO .AND. CD_All_Finite(model%v(6*(k - 1) + 1:6*(k - 1) + 3))) & + model%viv_ms_next(7:9, k) = model%viv_ms(7:9, k) + (CD_ONE - EXP(-dt/model%viv_ftf(k)))* & + (model%v(6*(k - 1) + 1:6*(k - 1) + 3) - model%viv_ms(7:9, k)) + END IF 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) @@ -2069,7 +2185,8 @@ SUBROUTINE element_drag_load(model, e, qe, ve, l0, t_eval, fdrag, ErrStat, ErrMs wvc_amp=model%wv_ampc, wvc_om=model%wv_omc, & wvc_k=model%wv_kc, wvc_ph=model%wv_phc, & wvc_e2kd=model%wv_e2kd, cdy=elem_cdy(model, e), & - cdy_lin=elem_cdy_lin(model, e)) + cdy_lin=elem_cdy_lin(model, e), & + frame_v=elem_frame_v(model, e)) ELSE IF (model%has_wave) THEN CALL CD_HermiteCable_Drag_Element(qe, ve, l0, model%current, model%waterline_z, & model%rho_w, model%diam(e), elem_cdn(model, e), model%cdt(e), & @@ -2077,19 +2194,22 @@ SUBROUTINE element_drag_load(model, e, qe, ve, l0, t_eval, fdrag, ErrStat, ErrMs wv_h=model%wv_h, wv_om=model%wv_om, wv_k=model%wv_k, & wv_depth=model%wv_depth, wv_dir=model%wv_dir, wv_t=t_eval, & cdy=elem_cdy(model, e), & - cdy_lin=elem_cdy_lin(model, e)) + cdy_lin=elem_cdy_lin(model, e), & + frame_v=elem_frame_v(model, e)) ELSE IF (model%has_held_field) THEN CALL CD_HermiteCable_Drag_Element(qe, ve, l0, & model%current + 0.5_wp*(model%hf_u(:, e) + model%hf_u(:, e + 1)), & 0.5_wp*(model%hf_wl(e) + model%hf_wl(e + 1)), & model%rho_w, model%diam(e), elem_cdn(model, e), model%cdt(e), & fdrag, ErrStat=es, ErrMsg=ErrMsg, cdy=elem_cdy(model, e), & - cdy_lin=elem_cdy_lin(model, e)) + cdy_lin=elem_cdy_lin(model, e), & + frame_v=elem_frame_v(model, e)) ELSE CALL CD_HermiteCable_Drag_Element(qe, ve, l0, model%current, model%waterline_z, & model%rho_w, model%diam(e), elem_cdn(model, e), model%cdt(e), & fdrag, ErrStat=es, ErrMsg=ErrMsg, cdy=elem_cdy(model, e), & - cdy_lin=elem_cdy_lin(model, e)) + cdy_lin=elem_cdy_lin(model, e), & + frame_v=elem_frame_v(model, e)) END IF ErrStat = es END SUBROUTINE element_drag_load @@ -9940,7 +10060,8 @@ SUBROUTINE assemble_residual(model, q_cfg, v_cfg, t_eval, want_residual, want_ta wvc_amp=model%wv_ampc, wvc_om=model%wv_omc, & wvc_k=model%wv_kc, wvc_ph=model%wv_phc, & wvc_e2kd=model%wv_e2kd, cdy=elem_cdy(model, e), & - cdy_lin=elem_cdy_lin(model, e)) + cdy_lin=elem_cdy_lin(model, e), & + frame_v=elem_frame_v(model, e)) ELSE IF (model%has_wave) THEN CALL CD_HermiteCable_Drag_Element(qe, ve, model%l0(e), model%current, model%waterline_z, & model%rho_w, model%diam(e), elem_cdn(model, e), model%cdt(e), & @@ -9948,7 +10069,8 @@ SUBROUTINE assemble_residual(model, q_cfg, v_cfg, t_eval, want_residual, want_ta wv_h=model%wv_h, wv_om=model%wv_om, wv_k=model%wv_k, & wv_depth=model%wv_depth, wv_dir=model%wv_dir, wv_t=t_eval, & cdy=elem_cdy(model, e), & - cdy_lin=elem_cdy_lin(model, e)) + cdy_lin=elem_cdy_lin(model, e), & + frame_v=elem_frame_v(model, e)) ELSE IF (model%has_held_field) THEN ! HELD host field: the element's ambient velocity = the drag config's constant ! current + the two end nodes' held-velocity average; the element waterline = @@ -9958,12 +10080,14 @@ SUBROUTINE assemble_residual(model, q_cfg, v_cfg, t_eval, want_residual, want_ta 0.5_wp*(model%hf_wl(e) + model%hf_wl(e + 1)), & model%rho_w, model%diam(e), elem_cdn(model, e), model%cdt(e), & fdrag, djq, djv, es, em_e, cdy=elem_cdy(model, e), & - cdy_lin=elem_cdy_lin(model, e)) + cdy_lin=elem_cdy_lin(model, e), & + frame_v=elem_frame_v(model, e)) ELSE CALL CD_HermiteCable_Drag_Element(qe, ve, model%l0(e), model%current, model%waterline_z, & model%rho_w, model%diam(e), elem_cdn(model, e), model%cdt(e), & fdrag, djq, djv, es, em_e, cdy=elem_cdy(model, e), & - cdy_lin=elem_cdy_lin(model, e)) + cdy_lin=elem_cdy_lin(model, e), & + frame_v=elem_frame_v(model, e)) END IF ELSE CALL element_drag_load(model, e, qe, ve, model%l0(e), t_eval, fdrag, es, em_e) @@ -11489,26 +11613,30 @@ SUBROUTINE evaluate_tangent_element(model, e, q_cfg, v_cfg, t_eval, Kstruct, Kdr wv_dir=model%wv_dir, wv_t=t_eval, wvc_amp=model%wv_ampc, & wvc_om=model%wv_omc, wvc_k=model%wv_kc, wvc_ph=model%wv_phc, & wvc_e2kd=model%wv_e2kd, cdy=elem_cdy(model, e), & - cdy_lin=elem_cdy_lin(model, e)) + cdy_lin=elem_cdy_lin(model, e), & + frame_v=elem_frame_v(model, e)) ELSE IF (model%has_wave) THEN CALL CD_HermiteCable_Drag_Element(qe, ve, model%l0(e), model%current, model%waterline_z, & model%rho_w, model%diam(e), elem_cdn(model, e), model%cdt(e), & fload, djq, djv, es, em, wv_h=model%wv_h, wv_om=model%wv_om, & wv_k=model%wv_k, wv_depth=model%wv_depth, wv_dir=model%wv_dir, & wv_t=t_eval, cdy=elem_cdy(model, e), & - cdy_lin=elem_cdy_lin(model, e)) + cdy_lin=elem_cdy_lin(model, e), & + frame_v=elem_frame_v(model, e)) ELSE IF (model%has_held_field) THEN CALL CD_HermiteCable_Drag_Element(qe, ve, model%l0(e), & model%current + 0.5_wp*(model%hf_u(:, e) + model%hf_u(:, e + 1)), & 0.5_wp*(model%hf_wl(e) + model%hf_wl(e + 1)), model%rho_w, & model%diam(e), elem_cdn(model, e), model%cdt(e), fload, djq, djv, es, em, & cdy=elem_cdy(model, e), & - cdy_lin=elem_cdy_lin(model, e)) + cdy_lin=elem_cdy_lin(model, e), & + frame_v=elem_frame_v(model, e)) ELSE CALL CD_HermiteCable_Drag_Element(qe, ve, model%l0(e), model%current, model%waterline_z, & model%rho_w, model%diam(e), elem_cdn(model, e), model%cdt(e), & fload, djq, djv, es, em, cdy=elem_cdy(model, e), & - cdy_lin=elem_cdy_lin(model, e)) + cdy_lin=elem_cdy_lin(model, e), & + frame_v=elem_frame_v(model, e)) END IF IF (es /= CD_HCDYN_OK) THEN ErrStat = es; ErrMsg = TRIM(em); RETURN @@ -11855,7 +11983,7 @@ END SUBROUTINE CD_HermiteCable_Point_Immersion SUBROUTINE CD_HermiteCable_Drag_Element(qe, ve, l0, fluid, waterline_z, rho, diam, cdn, cdt, & fdrag, djq, djv, ErrStat, ErrMsg, & wv_h, wv_om, wv_k, wv_depth, wv_dir, wv_t, & - wvc_amp, wvc_om, wvc_k, wvc_ph, wvc_e2kd, cdy, cdy_lin) + wvc_amp, wvc_om, wvc_k, wvc_ph, wvc_e2kd, cdy, cdy_lin, frame_v) !! Consistent Gauss-integrated Morison quadratic drag on one cubic-Hermite bending-cable element. !! qe(12), ve(12) = [r1, m1, r2, m2] nodal positions and velocities; the interior velocity and !! tangent use the SAME cubic-Hermite interpolation as the geometry, so the material-tangent (m) @@ -11888,6 +12016,9 @@ SUBROUTINE CD_HermiteCable_Drag_Element(qe, ve, l0, fluid, waterline_z, rho, dia REAL(wp), INTENT(IN), OPTIONAL :: cdy ! with cdy: the Morison-form cross-flow coefficient (CD_Morison_Drag_Split_Per_Length_Jac cdy_lin) REAL(wp), INTENT(IN), OPTIONAL :: cdy_lin + ! with cdy: the velocity of the flow frame (VIV FRAME), which the ambient flow of the split's axes + ! and blend is taken relative to (the drag itself keeps the flow relative to the cable) + REAL(wp), INTENT(IN), OPTIONAL :: frame_v(3) REAL(wp), INTENT(OUT) :: fdrag(12) ! djq/djv are OPTIONAL as a pair: a residual-only evaluation (a line-search trial, which ! never solves with a tangent) omits both and skips the 12x12 Jacobian accumulation -- @@ -12034,6 +12165,7 @@ SUBROUTINE CD_HermiteCable_Drag_Element(qe, ve, l0, fluid, waterline_z, rho, dia IF (split) THEN uamb = fluid IF (has_wv) uamb = uamb + uw + IF (PRESENT(frame_v)) uamb = uamb - frame_v IF (want_jac) THEN CALL CD_Morison_Drag_Split_Per_Length_Jac(urel, uamb, rp, rho, diam, cdn, cdy, cdt, CD_HCDYN_CDY_UREF, & fpl, Jrel, Jtan, es, em2, cdy_lin=cdy_lin) diff --git a/src/CableDyn_Model.f90 b/src/CableDyn_Model.f90 index 702eed5..4f849d6 100644 --- a/src/CableDyn_Model.f90 +++ b/src/CableDyn_Model.f90 @@ -59,7 +59,8 @@ MODULE CableDyn_Model 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_NM, CD_VIV_TWO_PI, CD_VIV_Node_Inline, CD_VIV_Inline_Phase_Rate, & CD_VIV_NMS, CD_VIV_NMS_AMP, CD_VIV_AMP_MAXP, CD_VIV_Amplitude_Update, CD_VIV_Table, & - CD_VIV_Check_Amp_Table, CD_VIV_Ambient_Crossflow_Rate, CD_VIV_Wake_Advance + CD_VIV_Check_Amp_Table, CD_VIV_Ambient_Crossflow_Rate, CD_VIV_Wake_Advance, & + CD_VIV_NMS_FRAME USE CableDyn_Dynamic, ONLY: GenAlphaConfig, CD_CableGenAlphaWorkspace, CD_Clear_GenAlpha_Workspace, & CD_Cable_Initial_Acceleration, CD_Cable_Gen_Alpha_Step, CD_Cable_Step_Loads, & CD_DYN_OK, CD_DYN_ALLOCFAIL, & @@ -438,6 +439,15 @@ MODULE CableDyn_Model LOGICAL :: has_viv_amp = .FALSE. REAL(wp), ALLOCATABLE :: viv_amp(:, :, :) INTEGER, ALLOCATABLE :: viv_amp_n(:) + ! The flow frame of the synchronisation model (CD_Set_Model_VIV tf; VIV FRAME section): with a + ! filter time viv_ftf(nd) > 0 on some node (viv_frame) viv_ms has CD_VIV_NMS_FRAME rows, rows + ! 7:9 the node's (smoothed) velocity low-pass filtered over viv_ftf (first order; the + ! length-weighted average over its lifting elements), rows 3:6 the amplitude estimate (0 + ! without amplitude tables). The node's velocity relative to it drives the phases (the relative + ! flow, and so the shedding speed, unchanged), and the amplitude estimate takes the node's + ! velocity across the ambient flow both relative to it (frame_node). + LOGICAL :: viv_frame = .FALSE. + REAL(wp), ALLOCATABLE :: viv_ftf(:) ! Wake-oscillator VIV (CD_Set_Model_VIV wake; Facchinetti et al. 2004): the van der Pol wake ! variable q = 2 C_L/C_L0 replaces the synchronisation phase of the whole line, the lift scale ! taking viv_cl = C_L0/2. Per node the Strouhal number, van der Pol eps and coupling A @@ -3960,7 +3970,7 @@ SUBROUTINE CD_Set_Model_Syrope_State(model, slow, tmax, ErrStat, ErrMsg) END SUBROUTINE CD_Set_Model_Syrope_State SUBROUTINE CD_Set_Model_VIV(model, rho, cl, diameter, cf, df, t_window, ErrStat, ErrMsg, phase_seed, & - tangent_reversed, clx, il_alpha, chh, amp, amp_n, wake) + tangent_reversed, clx, il_alpha, chh, amp, amp_n, wake, tf) !! Install the cross-flow VIV model (CableDyn_VIV) on an initialised line. Per element: !! the lift coefficient cl (0 = no lift on that element), hydrodynamic diameter, and the !! synchronisation centre cf and half-range df of the non-dimensional shedding frequency; @@ -3991,7 +4001,15 @@ SUBROUTINE CD_Set_Model_VIV(model, rho, cl, diameter, cf, df, t_window, ErrStat, !! (3, n_elem), per element the Strouhal number St > 0, van der Pol eps > 0 and acceleration !! coupling A >= 0 (each at most 1e15) where cl > 0, with cl then the reference lift !! coefficient C_L0 of a fixed cylinder; cf and df are unused. The wake variable q of a node - !! starts on its limit cycle at the node's start phase, q = 2 cos(phi_0), with dq/dt = 0. + !! starts on its limit cycle at the node's start phase, q = 2 cos(phi_0), with dq/dt = 0. An + !! optional fourth row wake(4, :) = Tf [s] >= 0 takes the flow relative to the node velocity + !! low-pass filtered over Tf (0: the ambient flow). + !! tf (optional, n_elem; not with wake), per element the filter time Tf [s] of the flow frame of + !! the synchronisation model (0: the ambient flow; > 0 only where cl > 0, at most 1e15), vbar + !! the node's smoothed velocity low-pass filtered over Tf (first order): the cross-flow and + !! in-line motion of the phases takes the node's velocity relative to vbar, and the amplitude + !! estimate takes it across the ambient flow relative to vbar, so a line moved through the + !! water sees that motion as flow. The shedding speed stays the relative normal speed. TYPE(CD_ModelType), INTENT(INOUT) :: model REAL(wp), INTENT(IN) :: rho, cl(:), diameter(:), cf(:), df(:), t_window INTEGER, INTENT(OUT) :: ErrStat @@ -4005,9 +4023,10 @@ SUBROUTINE CD_Set_Model_VIV(model, rho, cl, diameter, cf, df, t_window, ErrStat, REAL(wp), INTENT(IN), OPTIONAL :: amp(:, :, :) INTEGER, INTENT(IN), OPTIONAL :: amp_n(:) REAL(wp), INTENT(IN), OPTIONAL :: wake(:, :) + REAL(wp), INTENT(IN), OPTIONAL :: tf(:) INTEGER :: n_nodes, n_elem, e, nd, istat, k, nms REAL(wp) :: wsum - LOGICAL :: want_il, want_amp, want_wake, want_filter + LOGICAL :: want_il, want_amp, want_wake, want_filter, want_frame CHARACTER(160) :: amsg ErrStat = CD_MODEL_OK @@ -4133,6 +4152,27 @@ SUBROUTINE CD_Set_Model_VIV(model, rho, cl, diameter, cf, df, t_window, ErrStat, RETURN END IF END IF + want_frame = .FALSE. + IF (PRESENT(tf)) THEN + IF (PRESENT(wake)) THEN + CALL fail(ErrStat, ErrMsg, 'the VIV wake oscillator takes its filter time as wake(4, :), not tf') + RETURN + END IF + IF (SIZE(tf) /= n_elem .OR. .NOT. CD_All_Finite(tf)) THEN + CALL fail(ErrStat, ErrMsg, 'the VIV flow-frame filter time tf must be finite with shape (n_elem)') + RETURN + END IF + IF (ANY(tf < CD_ZERO) .OR. ANY(tf > 1.0e15_wp)) THEN + CALL fail(ErrStat, ErrMsg, 'the VIV flow-frame filter time Tf must be >= 0 (0 = the ambient flow) and '// & + 'at most 1e15') + RETURN + END IF + IF (ANY(tf > CD_ZERO .AND. .NOT. (cl > CD_ZERO))) THEN + CALL fail(ErrStat, ErrMsg, 'the VIV flow frame (tf > 0) acts on the VIV model: tf > 0 only where cl > 0') + RETURN + END IF + want_frame = ANY(tf > CD_ZERO) + END IF CALL clear_viv(model) IF (.NOT. ANY(cl > CD_ZERO)) RETURN IF (.NOT. (CD_Is_Finite(rho) .AND. rho > CD_ZERO)) THEN @@ -4159,6 +4199,7 @@ SUBROUTINE CD_Set_Model_VIV(model, rho, cl, diameter, cf, df, t_window, ErrStat, END IF END DO nms = MERGE(CD_VIV_NMS_AMP, CD_VIV_NMS, want_amp .OR. (want_wake .AND. want_filter)) + IF (want_frame) nms = CD_VIV_NMS_FRAME ALLOCATE (model%viv_cl(n_elem), model%viv_d(n_elem), model%viv_node(n_nodes), model%viv_cf(n_nodes), & model%viv_df(n_nodes), model%viv_dn(n_nodes), model%viv_phi(n_nodes), model%viv_ms(nms, n_nodes), & model%viv_phi_rollback(n_nodes), model%viv_ms_rollback(nms, n_nodes), & @@ -4212,6 +4253,29 @@ SUBROUTINE CD_Set_Model_VIV(model, rho, cl, diameter, cf, df, t_window, ErrStat, model%viv_phi(nd) = CD_VIV_Wrap_Phase(CD_VIV_TWO_PI*(REAL(n_nodes - nd, wp)/REAL(n_elem, wp) + 0.5_wp)) IF (PRESENT(phase_seed)) model%viv_phi(nd) = CD_VIV_TWO_PI*phase_seed(nd) END DO + IF (want_frame) THEN + ALLOCATE (model%viv_ftf(n_nodes), STAT=istat) + IF (istat /= 0) THEN + CALL clear_viv(model) + CALL alloc_fail(ErrStat, ErrMsg, 'VIV flow frame storage allocation failed') + RETURN + END IF + ! the filter time per node, length-weighted over its lifting elements as the band; the + ! filtered velocity starts at the node's (smoothed) velocity + model%viv_ftf = CD_ZERO + DO nd = 2, n_nodes - 1 + IF (.NOT. model%viv_node(nd)) CYCLE + wsum = CD_ZERO + DO k = nd - 1, nd + IF (.NOT. (cl(k) > CD_ZERO)) CYCLE + wsum = wsum + model%l0(k) + model%viv_ftf(nd) = model%viv_ftf(nd) + model%l0(k)*tf(k) + END DO + model%viv_ftf(nd) = model%viv_ftf(nd)/wsum + model%viv_ms(7:9, nd) = smoothed(model%v, 3*nd - 2) + END DO + model%viv_frame = .TRUE. + END IF model%viv_phi_rollback = model%viv_phi model%viv_ms_rollback = model%viv_ms model%recovery_viv_phi = model%viv_phi @@ -4642,6 +4706,7 @@ PURE INTEGER FUNCTION CD_Model_VIV_NMS(model) RESULT(n) !! wake filter (the filtered velocity in rows 3:5), CD_VIV_NMS otherwise. TYPE(CD_ModelType), INTENT(IN) :: model n = MERGE(CD_VIV_NMS_AMP, CD_VIV_NMS, model%has_viv_amp .OR. model%wo_filter) + IF (model%viv_frame) n = CD_VIV_NMS_FRAME END FUNCTION CD_Model_VIV_NMS SUBROUTINE CD_Get_Model_VIV_Amplitude(model, amp, ErrStat, ErrMsg) @@ -4777,8 +4842,16 @@ SUBROUTINE viv_step_begin(model, dt, ErrStat, ErrMsg) IF (.NOT. model%viv_node(nd)) CYCLE CALL viv_node_coef(model, model%q, nd, coef, uu) ia = 3*nd - 2 - CALL CD_VIV_Crossflow_Motion(model%q(ia - 3:ia - 1), model%q(ia + 3:ia + 5), smoothed(model%v, ia), & - smoothed(model%a, ia), uu, yd, ydd, un, ok, xd, xdd) + IF (frame_node(model, nd)) THEN + ! with the flow frame, the node's velocity relative to its filtered one (the relative flow, + ! and so the axes and the shedding speed, unchanged; viv_frame) + CALL CD_VIV_Crossflow_Motion(model%q(ia - 3:ia - 1), model%q(ia + 3:ia + 5), & + smoothed(model%v, ia) - model%viv_ms(7:9, nd), smoothed(model%a, ia), & + uu - model%viv_ms(7:9, nd), yd, ydd, un, ok, xd, xdd) + ELSE + CALL CD_VIV_Crossflow_Motion(model%q(ia - 3:ia - 1), model%q(ia + 3:ia + 5), smoothed(model%v, ia), & + smoothed(model%a, ia), uu, yd, ydd, un, ok, xd, xdd) + END IF IF (.NOT. ok) THEN CALL fail(ErrStat, ErrMsg, 'VIV phase: the neighbours of a node coincide (no line tangent)') RETURN @@ -4836,9 +4909,16 @@ SUBROUTINE viv_step_end(model, dt, ErrStat, ErrMsg) IF (.NOT. model%viv_node(nd)) CYCLE CALL viv_node_coef(model, model%q_step, nd, coef, uu) ia = 3*nd - 2 - CALL CD_VIV_Crossflow_Motion(model%q_step(ia - 3:ia - 1), model%q_step(ia + 3:ia + 5), & - smoothed(model%v_step, ia), smoothed(model%a_step, ia), uu, yd, ydd, un, ok, & - xd, xdd) + IF (frame_node(model, nd)) THEN + CALL CD_VIV_Crossflow_Motion(model%q_step(ia - 3:ia - 1), model%q_step(ia + 3:ia + 5), & + smoothed(model%v_step, ia) - model%viv_ms(7:9, nd), & + smoothed(model%a_step, ia), uu - model%viv_ms(7:9, nd), yd, ydd, un, ok, & + xd, xdd) + ELSE + CALL CD_VIV_Crossflow_Motion(model%q_step(ia - 3:ia - 1), model%q_step(ia + 3:ia + 5), & + smoothed(model%v_step, ia), smoothed(model%a_step, ia), uu, yd, ydd, un, ok, & + xd, xdd) + END IF IF (model%viv_wake) THEN ! the wake state over the step with the cross-flow acceleration linear from its step-start ! value to the converged end one (held where the end tangent is degenerate), at the @@ -4871,13 +4951,30 @@ SUBROUTINE viv_step_end(model, dt, ErrStat, ErrMsg) END IF IF (model%has_viv_amp) THEN ! the amplitude estimate over the step, from the committed one (repeatable), on the - ! cross-flow velocity across the ambient flow + ! cross-flow velocity across the ambient flow; with the flow frame, the velocity and the + ! flow both relative to the step-start filtered velocity st = model%viv_ms(3:6, nd) - CALL CD_VIV_Amplitude_Update(st, CD_VIV_Ambient_Crossflow_Rate(model%q_step(ia + 3:ia + 5) - & - model%q_step(ia - 3:ia - 1), & - smoothed(model%v_step, ia), uu), dt) + IF (frame_node(model, nd)) THEN + CALL CD_VIV_Amplitude_Update(st, CD_VIV_Ambient_Crossflow_Rate(model%q_step(ia + 3:ia + 5) - & + model%q_step(ia - 3:ia - 1), & + smoothed(model%v_step, ia) - & + model%viv_ms(7:9, nd), & + uu - model%viv_ms(7:9, nd)), dt) + ELSE + CALL CD_VIV_Amplitude_Update(st, CD_VIV_Ambient_Crossflow_Rate(model%q_step(ia + 3:ia + 5) - & + model%q_step(ia - 3:ia - 1), & + smoothed(model%v_step, ia), uu), dt) + END IF model%viv_ms_next(3:6, nd) = st END IF + IF (frame_node(model, nd)) THEN + ! the filtered velocity follows the converged end velocity held over the step (exact for + ! the first-order filter; a non-finite end velocity keeps it) + vsm = smoothed(model%v_step, ia) + IF (CD_All_Finite(vsm)) & + model%viv_ms_next(7:9, nd) = model%viv_ms(7:9, nd) + (CD_ONE - EXP(-dt/model%viv_ftf(nd)))* & + (vsm - model%viv_ms(7:9, nd)) + END IF ms1 = CD_VIV_Mean_Square(model%viv_ms_next(1, nd), yd, w) ms2 = CD_VIV_Mean_Square(model%viv_ms_next(2, nd), ydd, w) rate_end = CD_VIV_Phase_Rate(yd, ydd, ms1, ms2, model%viv_phi(nd) + dt*model%viv_rate(nd), un, & @@ -4910,6 +5007,15 @@ SUBROUTINE viv_step_end(model, dt, ErrStat, ErrMsg) END IF END SUBROUTINE viv_step_end + PURE LOGICAL FUNCTION frame_node(model, nd) RESULT(on) + !! Node nd takes the flow frame of the synchronisation model (viv_frame, viv_ftf(nd) > 0). + TYPE(CD_ModelType), INTENT(IN) :: model + INTEGER, INTENT(IN) :: nd + on = .FALSE. + IF (.NOT. model%viv_frame) RETURN + on = model%viv_ftf(nd) > CD_ZERO + END FUNCTION frame_node + PURE REAL(wp) FUNCTION viv_node_ambient_speed(q, ia, uu) RESULT(ua) !! Speed of the ambient flow uu normal to the tangent of the node whose x component is ia (the !! chord of its two neighbours at positions q); 0 for a degenerate tangent. @@ -4977,6 +5083,8 @@ SUBROUTINE clear_viv(model) IF (ALLOCATED(model%wo_eps)) DEALLOCATE (model%wo_eps) IF (ALLOCATED(model%wo_a)) DEALLOCATE (model%wo_a) IF (ALLOCATED(model%wo_tf)) DEALLOCATE (model%wo_tf) + IF (ALLOCATED(model%viv_ftf)) DEALLOCATE (model%viv_ftf) + model%viv_frame = .FALSE. model%viv_wake = .FALSE. model%wo_filter = .FALSE. model%has_viv_amp = .FALSE. @@ -7748,7 +7856,10 @@ SUBROUTINE CD_Copy_Model(src, dst, ErrStat, ErrMsg) IF (ErrStat /= CD_MODEL_OK) RETURN CALL copy_real1(src%wo_tf, work%wo_tf, 'wo_tf', ErrStat, ErrMsg) IF (ErrStat /= CD_MODEL_OK) RETURN + CALL copy_real1(src%viv_ftf, work%viv_ftf, 'viv_ftf', ErrStat, ErrMsg) + IF (ErrStat /= CD_MODEL_OK) RETURN work%wo_filter = src%wo_filter + work%viv_frame = src%viv_frame work%has_viv_amp = src%has_viv_amp CALL copy_real3(src%viv_amp, work%viv_amp, 'viv_amp', ErrStat, ErrMsg) IF (ErrStat /= CD_MODEL_OK) RETURN @@ -7944,6 +8055,8 @@ SUBROUTINE commit_model_copy(from, to) CALL MOVE_ALLOC(from%wo_eps, to%wo_eps) CALL MOVE_ALLOC(from%wo_a, to%wo_a) CALL MOVE_ALLOC(from%wo_tf, to%wo_tf) + CALL MOVE_ALLOC(from%viv_ftf, to%viv_ftf) + to%viv_frame = from%viv_frame to%wo_filter = from%wo_filter to%has_viv_amp = from%has_viv_amp CALL MOVE_ALLOC(from%viv_amp, to%viv_amp) diff --git a/src/CableDyn_VIV.f90 b/src/CableDyn_VIV.f90 index 8029a5c..6bcf50e 100644 --- a/src/CableDyn_VIV.f90 +++ b/src/CableDyn_VIV.f90 @@ -87,8 +87,11 @@ MODULE CableDyn_VIV !> Rows of the per-node VIV motion statistics: the running mean squares of the cross-flow !> velocity and acceleration (CD_VIV_NMS), and with an amplitude table (VIV AMPLITUDE section) !> the four values of the amplitude estimate after them (CD_VIV_NMS_AMP; CD_VIV_Amplitude_Update). + !> With a flow frame as well (VIV FRAME section, filter time Tf > 0) the node's velocity low-pass + !> filtered over Tf follows them in rows 7:9 (CD_VIV_NMS_FRAME). INTEGER, PARAMETER, PUBLIC :: CD_VIV_NMS = 2 INTEGER, PARAMETER, PUBLIC :: CD_VIV_NMS_AMP = 6 + INTEGER, PARAMETER, PUBLIC :: CD_VIV_NMS_FRAME = 9 !> The smoothing of the amplitude estimate per time step, k_a dt of Thorsen et al. (2016, Eq. 9). REAL(wp), PARAMETER, PUBLIC :: CD_VIV_AMP_KDT = 0.1_wp !> The most rows of one line type's amplitude table. diff --git a/tests/test_hermite_viv_frame.f90 b/tests/test_hermite_viv_frame.f90 new file mode 100644 index 0000000..d472015 --- /dev/null +++ b/tests/test_hermite_viv_frame.f90 @@ -0,0 +1,308 @@ +! File: tests/test_hermite_viv_frame.f90 +! SPDX-License-Identifier: Apache-2.0 +! Copyright (c) 2026 Jae Hoon Seo, SMI Lab, Inha University +PROGRAM test_hermite_viv_frame + !! The flow frame of the synchronisation model on the cubic-Hermite cable + !! (CD_HermiteCable_Dyn_Set_VIV tf): with a filter time Tf > 0 the motion of the phase (the node's + !! velocity relative to its velocity low-pass filtered over Tf), the amplitude estimate and the + !! cross-flow damping split take the cable's filtered motion as their frame, so they are the same + !! in the cylinder's frame and in the water's. + !! + !! The pipe: 20 m, 10 elements, D 0.1 m, EI 1000 N m^2, pinned, about 21 kN, its mass that of the + !! water it displaces (8.05 kg/m, no net weight), Cd 1.2, Ca 1, Cl 0.8, alone or with an + !! amplitude table (Cv 0.8, 0.6, 0.0 and CdAmp 1.0, 1.3, 1.6 at A/D 0, 0.5, 1) and Thorsen's + !! cross-flow damping (a, b) = (0.31, 0.89). The flow along y oscillates with amplitude 0.6 m/s + !! and period 40 s (KC 240), its amplitude ramped up over the first period; the cross-flow axis + !! is z. + !! * moving: still water, both ends moved along y with velocity V(t); + !! * fixed: the ends held, the water moving at -V(t) (a held fluid field with its acceleration, + !! so the Froude-Krylov and added-mass loads act). + !! With the pipe's mass equal to the displaced mass, the in-line inertia of the two problems is + !! the same ((m + Ca rho A) dV/dt against (1 + Ca) rho A dV/dt); for any other mass they differ by + !! the Froude-Krylov term (m - rho A) dV/dt, the inertial force of the moving frame. So the two + !! runs differ only where the model depends on the frame. + !! + !! Gates: + !! * F1 the setter refuses tf of the wrong size, a negative or non-finite tf, tf > 0 on an element + !! without lift and tf with the wake oscillator; tf on the lift alone installs the frame (nine + !! motion statistics, no table); an all-zero tf installs no frame and reproduces the run + !! without tf bit for bit; + !! * F2 with Tf 0.6 s the moving and the fixed pipe agree, with the tables and with the lift + !! alone: the RMS cross-flow response of the mid node over the second period within 1 %, its + !! peak within 2 %. The RMS agrees within 0.2 % on every build and kernel; the peak of the moving + !! pipe ranges 0.811-0.819 D over the Release and Debug builds, the two OpenBLAS kernels and + !! Linux/Windows (fixed pipe 0.819 D), a single extreme of the response. What is left is the + !! filter's lag of the imposed velocity, about omega Tf = 0.094 rad; + !! * F3 without the frame they differ: in still water the moving pipe's phase sees no cross-flow + !! velocity (r'.e = u.e = 0 across the relative flow), and with the tables it takes Cv and CdAmp + !! at A/D 0 and the Morison drag; with the tables the peak response is more than 10 % (measured + !! 16 %) and the RMS more than 15 % (measured 23 %) from the fixed pipe's, with the lift alone + !! the RMS more than 4 % (measured 7 %); + !! * F4 a snapshot taken mid-run and restored replays the following steps bit for bit, the + !! filtered velocity included. + USE, INTRINSIC :: IEEE_ARITHMETIC, ONLY: IEEE_VALUE, IEEE_QUIET_NAN + USE CableDyn_Precision, ONLY: wp + USE CableDyn_VIV, ONLY: CD_VIV_AMP_MAXP, CD_VIV_NMS_FRAME + 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_Set_Held_Fluid, & + CD_HermiteCable_Dyn_Step, CD_HermiteCable_Dyn_Snapshot, & + CD_HermiteCable_Dyn_Restore, CD_HermiteCable_Dyn_End, CD_HCDYN_OK + IMPLICIT NONE + + REAL(wp), PARAMETER :: PI = 3.141592653589793_wp + REAL(wp), PARAMETER :: RHOW = 1025.0_wp, D = 0.1_wp, EA = 5.0e7_wp, EI = 1.0e3_wp, TENS = 2.1e4_wp + REAL(wp), PARAMETER :: SPAN = 20.0_wp, DT = 0.01_wp, U0 = 0.6_wp, TP = 40.0_wp, TF = 0.6_wp + REAL(wp), PARAMETER :: MLIN = RHOW*0.25_wp*PI*D*D + INTEGER, PARAMETER :: NE = 10, NN = NE + 1, MID = 6*(NE/2), NSTEP = NINT(2.0_wp*TP/DT) + ! the agreement of the moving and the fixed pipe with the flow frame (F2) + REAL(wp), PARAMETER :: TOL_F2 = 0.01_wp, TOL_F2_PEAK = 0.02_wp + + TYPE(CD_HermiteCableDynType) :: model, twin + REAL(wp) :: cl(NE), cf(NE), df(NE), amp(3, CD_VIV_AMP_MAXP, NE), cdy(2, NE), tf0(NE), tfv(NE) + INTEGER :: ampn(NE) + REAL(wp) :: pk_mf, rms_mf, pk_ff, rms_ff, pk_m0, rms_m0, pk_f0, rms_f0 + INTEGER :: es, nfail, k, it + LOGICAL :: tables + CHARACTER(12) :: lab + CHARACTER(1024) :: em + + nfail = 0 + cl = 0.8_wp; cf = 0.18_wp; df = 0.08_wp + amp = 0.0_wp + amp(:, 1, :) = SPREAD([0.0_wp, 0.8_wp, 1.0_wp], 2, NE) + amp(:, 2, :) = SPREAD([0.5_wp, 0.6_wp, 1.3_wp], 2, NE) + amp(:, 3, :) = SPREAD([1.0_wp, 0.0_wp, 1.6_wp], 2, NE) + ampn = 3 + cdy(1, :) = 0.31_wp; cdy(2, :) = 0.89_wp + tf0 = 0.0_wp + tfv = TF + + ! ---- F1 refusals; an all-zero tf is no frame ---- + CALL build(model) + CALL CD_HermiteCable_Dyn_Set_VIV(model, cl, cf, df, 2.0_wp, es, em, amp=amp, amp_n=ampn, tf=tfv(1:NE - 1)) + CALL require(es /= CD_HCDYN_OK, 'F1: tf of the wrong size is refused') + CALL CD_HermiteCable_Dyn_Set_VIV(model, cl, cf, df, 2.0_wp, es, em, amp=amp, amp_n=ampn, tf=-tfv) + CALL require(es /= CD_HCDYN_OK .AND. INDEX(em, 'must be >= 0') > 0, 'F1: a negative tf is refused: '//TRIM(em)) + BLOCK + REAL(wp) :: bad(NE) + REAL(wp) :: cl2(NE) + bad = tfv + bad(4) = IEEE_VALUE(1.0_wp, IEEE_QUIET_NAN) + CALL CD_HermiteCable_Dyn_Set_VIV(model, cl, cf, df, 2.0_wp, es, em, amp=amp, amp_n=ampn, tf=bad) + CALL require(es /= CD_HCDYN_OK, 'F1: a non-finite tf is refused') + cl2 = cl + cl2(3) = 0.0_wp + CALL CD_HermiteCable_Dyn_Set_VIV(model, cl2, cf, df, 2.0_wp, es, em, tf=tfv) + CALL require(es /= CD_HCDYN_OK .AND. INDEX(em, 'only where cl > 0') > 0, & + 'F1: tf > 0 on an element without lift is refused: '//TRIM(em)) + CALL CD_HermiteCable_Dyn_Set_VIV(model, cl, cf, df, 2.0_wp, es, em, & + wake=RESHAPE([(0.2_wp, 0.3_wp, 12.0_wp, k=1, NE)], [3, NE]), tf=tf0) + CALL require(es /= CD_HCDYN_OK .AND. INDEX(em, 'wake(4, :)') > 0, 'F1: tf with the wake oscillator is refused: '// & + TRIM(em)) + END BLOCK + CALL require(.NOT. model%has_viv .AND. .NOT. model%viv_frame, 'F1: a refused call installs nothing') + CALL CD_HermiteCable_Dyn_Set_VIV(model, cl, cf, df, 2.0_wp, es, em, tf=tfv) + CALL require(es == CD_HCDYN_OK .AND. model%viv_frame .AND. .NOT. model%has_viv_amp .AND. & + SIZE(model%viv_ms, 1) == CD_VIV_NMS_FRAME, 'F1: the frame installs on the lift alone: '//TRIM(em)) + CALL CD_HermiteCable_Dyn_Set_VIV(model, cl, cf, df, 2.0_wp, es, em, amp=amp, amp_n=ampn, cdy=cdy, tf=tf0) + CALL require(es == CD_HCDYN_OK .AND. .NOT. model%viv_frame .AND. SIZE(model%viv_ms, 1) == 6, & + 'F1: an all-zero tf installs no frame: '//TRIM(em)) + CALL build(twin) + CALL CD_HermiteCable_Dyn_Set_VIV(twin, cl, cf, df, 2.0_wp, es, em, amp=amp, amp_n=ampn, cdy=cdy) + CALL require(es == CD_HCDYN_OK, 'F1: the twin without tf installs: '//TRIM(em)) + DO k = 1, 600 + CALL advance(model, k, .TRUE.) + CALL advance(twin, k, .TRUE.) + IF (es /= CD_HCDYN_OK) EXIT + IF (ANY(model%q /= twin%q) .OR. ANY(model%viv_phi /= twin%viv_phi) .OR. ANY(model%viv_ms /= twin%viv_ms)) EXIT + END DO + CALL require(k > 600, 'F1: an all-zero tf reproduces the run without tf bit for bit') + CALL CD_HermiteCable_Dyn_End(model) + CALL CD_HermiteCable_Dyn_End(twin) + + ! ---- F2 and F3 the two frames, with and without the flow frame, with and without the tables ---- + DO it = 1, 2 + tables = it == 1 + lab = MERGE(' (tables) ', ' (lift only)', tables) + CALL run_case(.TRUE., tfv, tables, pk_mf, rms_mf) + CALL run_case(.FALSE., tfv, tables, pk_ff, rms_ff) + CALL run_case(.TRUE., tf0, tables, pk_m0, rms_m0) + CALL run_case(.FALSE., tf0, tables, pk_f0, rms_f0) + WRITE (*, '(A,2F9.4,A,2F9.4)') ' F2'//lab//' with Tf: moving peak, RMS A/D ', pk_mf/D, rms_mf/D, '; fixed ', & + pk_ff/D, rms_ff/D + WRITE (*, '(A,2F9.4,A,2F9.4)') ' F3'//lab//' without: moving peak, RMS A/D ', pk_m0/D, rms_m0/D, '; fixed ', & + pk_f0/D, rms_f0/D + CALL require(pk_ff > 0.2_wp*D, 'F2: the fixed pipe locks in'//lab) + CALL require(ABS(pk_mf/pk_ff - 1.0_wp) <= TOL_F2_PEAK .AND. ABS(rms_mf/rms_ff - 1.0_wp) <= TOL_F2, & + 'F2: with the flow frame the moving and the fixed pipe agree'//lab) + CALL require(ABS(pk_m0/pk_f0 - 1.0_wp) > MERGE(0.10_wp, 0.0_wp, tables) .AND. & + ABS(rms_m0/rms_f0 - 1.0_wp) > MERGE(0.15_wp, 0.04_wp, tables), & + 'F3: without it the moving pipe responds otherwise'//lab) + END DO + + ! ---- F4 snapshot replay with the filtered velocity ---- + BLOCK + REAL(wp), ALLOCATABLE :: q_ref(:, :), ms_ref(:, :, :) + INTEGER :: s + CALL build(model) + CALL CD_HermiteCable_Dyn_Set_VIV(model, cl, cf, df, 2.0_wp, es, em, amp=amp, amp_n=ampn, cdy=cdy, tf=tfv) + CALL require(es == CD_HCDYN_OK .AND. model%viv_frame .AND. SIZE(model%viv_ms, 1) == CD_VIV_NMS_FRAME, & + 'F4: the frame installs: '//TRIM(em)) + DO s = 1, 1500 + CALL advance(model, s, .TRUE.) + END DO + CALL require(MAXVAL(ABS(model%viv_ms(8, :))) > 0.1_wp*U0, 'F4: the filtered velocity follows the motion') + CALL CD_HermiteCable_Dyn_Snapshot(model, es, em) + CALL require(es == CD_HCDYN_OK, 'F4: snapshot: '//TRIM(em)) + ALLOCATE (q_ref(SIZE(model%q), 200), ms_ref(CD_VIV_NMS_FRAME, NN, 200)) + DO s = 1, 200 + CALL advance(model, 1500 + s, .TRUE.) + q_ref(:, s) = model%q + ms_ref(:, :, s) = model%viv_ms + END DO + CALL CD_HermiteCable_Dyn_Restore(model, es, em) + CALL require(es == CD_HCDYN_OK, 'F4: restore: '//TRIM(em)) + DO s = 1, 200 + CALL advance(model, 1500 + s, .TRUE.) + IF (ANY(model%q /= q_ref(:, s)) .OR. ANY(model%viv_ms /= ms_ref(:, :, s))) EXIT + END DO + CALL require(s > 200, 'F4: the restored snapshot replays the state and the filtered velocity bit for bit') + CALL CD_HermiteCable_Dyn_End(model) + END BLOCK + + IF (nfail > 0) THEN + WRITE (*, '(A,I0,A)') 'FAIL: ', nfail, ' assertion(s) failed' + ERROR STOP 1 + END IF + WRITE (*, '(A)') 'PASS: the flow frame of the synchronisation model on the cubic-Hermite cable' + +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 build(m) + !! The pinned taut pipe along x at 10 m depth in still water, pretensioned through its + !! unstretched length, with drag and the normal added mass. + TYPE(CD_HermiteCableDynType), INTENT(INOUT) :: m + REAL(wp) :: seed(6*NN), l0(NE), eav(NE), eiv(NE), wv(NE), rhoa(NE), hd(NE), hn(NE), ht(NE) + INTEGER :: i + seed = 0.0_wp + DO i = 1, NN + seed(6*(i - 1) + 1) = SPAN*REAL(i - 1, wp)/REAL(NE, wp) + seed(6*(i - 1) + 3) = -10.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 = 0.0_wp + CALL CD_HermiteCable_Dyn_Init(m, l0, eav, eiv, rhoa, wv, seed, end_dofs(), -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, 0.0_wp, 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 + + PURE FUNCTION end_dofs() RESULT(fixed) + INTEGER :: fixed(6) + fixed = [1, 2, 3, 6*NE + 1, 6*NE + 2, 6*NE + 3] + END FUNCTION end_dofs + + SUBROUTINE imposed(t, y, v, a) + !! The imposed motion along y: V = U0 r(t) sin(omega t), r = (1 - cos(pi t/TP))/2 over the + !! first period and 1 after it; y its integral (exact), a its derivative. + REAL(wp), INTENT(IN) :: t + REAL(wp), INTENT(OUT) :: y, v, a + REAL(wp) :: om, p, r, dr + om = 2.0_wp*PI/TP + p = PI/TP + IF (t < TP) THEN + r = 0.5_wp*(1.0_wp - COS(p*t)) + dr = 0.5_wp*p*SIN(p*t) + ! int_0^t (1 - cos(p s)) sin(om s)/2 ds with om = 2 p + y = U0*0.5_wp*((1.0_wp - COS(om*t))/om - (0.5_wp*(1.0_wp - COS(3.0_wp*p*t))/(3.0_wp*p) + & + 0.5_wp*(1.0_wp - COS(p*t))/p)) + ELSE + r = 1.0_wp + dr = 0.0_wp + y = U0*0.5_wp*(-(0.5_wp*(1.0_wp - COS(3.0_wp*PI))/(3.0_wp*p) + 0.5_wp*(1.0_wp - COS(PI))/p)) + & + U0*(COS(om*TP) - COS(om*t))/om + END IF + v = U0*r*SIN(om*t) + a = U0*(dr*SIN(om*t) + r*om*COS(om*t)) + END SUBROUTINE imposed + + SUBROUTINE advance(m, s, moving) + !! Step s (to t = s DT) of the moving pipe (ends prescribed) or of the fixed pipe (the held + !! field at the step's mid time, -V and -dV/dt). + TYPE(CD_HermiteCableDynType), INTENT(INOUT) :: m + INTEGER, INTENT(IN) :: s + LOGICAL, INTENT(IN) :: moving + REAL(wp) :: y, v, a, pq(6), pv(6), pa(6), fu(3, NN), fa(3, NN), wl(NN) + INTEGER :: i + IF (moving) THEN + CALL imposed(REAL(s, wp)*DT, y, v, a) + pq = [0.0_wp, y, -10.0_wp, SPAN, y, -10.0_wp] + pv = [0.0_wp, v, 0.0_wp, 0.0_wp, v, 0.0_wp] + pa = [0.0_wp, a, 0.0_wp, 0.0_wp, a, 0.0_wp] + CALL CD_HermiteCable_Dyn_Step(m, DT, 50, 1.0e-8_wp, es, em, pres_dofs=end_dofs(), pres_q=pq, pres_v=pv, & + pres_a=pa) + ELSE + CALL imposed((REAL(s, wp) - 0.5_wp)*DT, y, v, a) + DO i = 1, NN + fu(:, i) = [0.0_wp, -v, 0.0_wp] + fa(:, i) = [0.0_wp, -a, 0.0_wp] + END DO + wl = 0.0_wp + CALL CD_HermiteCable_Dyn_Set_Held_Fluid(m, fu, fa, wl, es, em) + IF (es /= CD_HCDYN_OK) THEN + CALL require(.FALSE., 'held field: '//TRIM(em)); RETURN + END IF + CALL CD_HermiteCable_Dyn_Step(m, DT, 50, 1.0e-8_wp, es, em) + END IF + IF (es /= CD_HCDYN_OK) CALL require(.FALSE., 'step: '//TRIM(em)) + END SUBROUTINE advance + + SUBROUTINE run_case(moving, tfe, tables, pk, rms) + !! Two periods of the moving or the fixed pipe with the filter times tfe, with the amplitude + !! tables and the cross-flow damping (tables) or the lift Cl alone; over the second period + !! the peak and RMS cross-flow (z) displacement of the mid node from its rest depth. + LOGICAL, INTENT(IN) :: moving, tables + REAL(wp), INTENT(IN) :: tfe(NE) + REAL(wp), INTENT(OUT) :: pk, rms + TYPE(CD_HermiteCableDynType), ALLOCATABLE :: m + REAL(wp) :: z, s2 + INTEGER :: s, n + ALLOCATE (m) + CALL build(m) + IF (tables) THEN + CALL CD_HermiteCable_Dyn_Set_VIV(m, cl, cf, df, 2.0_wp, es, em, amp=amp, amp_n=ampn, cdy=cdy, tf=tfe) + ELSE + CALL CD_HermiteCable_Dyn_Set_VIV(m, cl, cf, df, 2.0_wp, es, em, tf=tfe) + END IF + CALL require(es == CD_HCDYN_OK, 'VIV: '//TRIM(em)) + pk = 0.0_wp + s2 = 0.0_wp + n = 0 + DO s = 1, NSTEP + CALL advance(m, s, moving) + IF (es /= CD_HCDYN_OK) EXIT + IF (s <= NSTEP/2) CYCLE + z = m%q(MID + 3) + 10.0_wp + pk = MAX(pk, ABS(z)) + s2 = s2 + z*z + n = n + 1 + END DO + rms = SQRT(s2/REAL(MAX(n, 1), wp)) + CALL CD_HermiteCable_Dyn_End(m) + END SUBROUTINE run_case + +END PROGRAM test_hermite_viv_frame diff --git a/tests/test_viv_coupled.f90 b/tests/test_viv_coupled.f90 index b18bf10..3b91a04 100644 --- a/tests/test_viv_coupled.f90 +++ b/tests/test_viv_coupled.f90 @@ -40,7 +40,12 @@ PROGRAM test_viv_coupled !! * amplitude tables (a VIV AMPLITUDE table on both types, Cv falling from 0.8 at A/D 0 to 0.4 at !! 1, CdAmp from 1 to 1.5): both checkpoint blocks grow by the amplitude estimate (4 per node), !! the restarted run continues bit for bit with it, a rebuild without the VIV state does not, - !! and a rewound step repeats. + !! and a rewound step repeats; with the flow frame (VIV FRAME Tf 5 s on both types, and VIV + !! DAMPING on the cable) both blocks carry the filtered velocity too (3 more per node, 9 motion + !! statistics), with the same restart and rewind checks; + !! * the flow frame on the lift alone (VIV FRAME Tf 5 s, no tables): both blocks carry the + !! filtered velocity in rows 7-9 of 9 motion statistics (rows 3-6 unused), with the same restart + !! and rewind checks. USE CableDyn_Precision, ONLY: wp USE CableDyn_OpenFAST_Aggregate, ONLY: CD_AGG_ModuleType, CD_AGG_Init_From_Deck, CD_AGG_End, CD_AGG_OK, & CD_AGG_NMovingPoints, CD_AGG_GetMovingPointMesh, CD_AGG_Step_Moving, & @@ -60,7 +65,8 @@ PROGRAM test_viv_coupled INTEGER :: nfail ! the deck of the restart and rewind cases, and whether its lines carry in-line VIV CHARACTER(32) :: deck_name = 'viv_coupled.dat' - LOGICAL :: il_case = .FALSE., wake_case = .FALSE., amp_case = .FALSE., wakef_case = .FALSE. + LOGICAL :: il_case = .FALSE., wake_case = .FALSE., amp_case = .FALSE., wakef_case = .FALSE., ampf_case = .FALSE. + LOGICAL :: frame_case = .FALSE. nfail = 0 CALL write_deck('viv_coupled.dat', 0.8_wp) @@ -69,6 +75,8 @@ PROGRAM test_viv_coupled CALL write_deck('viv_coupled_wake.dat', 0.8_wp, wake=.TRUE.) CALL write_deck('viv_coupled_wakef.dat', 0.8_wp, wake=.TRUE., wake_tf='5.0') CALL write_deck('viv_coupled_amp.dat', 0.8_wp, amp=.TRUE.) + CALL write_deck('viv_coupled_ampf.dat', 0.8_wp, amp=.TRUE., wake_tf='5.0', damp=.TRUE.) + CALL write_deck('viv_coupled_frame.dat', 0.8_wp, wake_tf='5.0') CALL case_lockin() CALL case_restart() CALL case_rewind() @@ -87,12 +95,23 @@ PROGRAM test_viv_coupled wakef_case = .TRUE. CALL case_restart() CALL case_rewind() + deck_name = 'viv_coupled_frame.dat' + wake_case = .FALSE. + wakef_case = .FALSE. + frame_case = .TRUE. + CALL case_restart() + CALL case_rewind() + frame_case = .FALSE. deck_name = 'viv_coupled_amp.dat' wake_case = .FALSE. wakef_case = .FALSE. amp_case = .TRUE. CALL case_restart() CALL case_rewind() + deck_name = 'viv_coupled_ampf.dat' + ampf_case = .TRUE. + CALL case_restart() + CALL case_rewind() IF (nfail > 0) THEN WRITE (*, '(A,I0,A)') 'FAIL: ', nfail, ' coupled VIV check(s) failed' ERROR STOP 1 @@ -380,7 +399,8 @@ LOGICAL FUNCTION rebuild(a, b, with_viv) RESULT(ok) a_interior=aL(4:ndof - 3)) ok = ok .AND. es == CD_SYSTEM_OK nv = CD_System_Line_VIV_MirrorSize(a%sys%fast%system, il) - ok = ok .AND. nv == (MERGE(6, 3, il_case) + MERGE(4, 0, amp_case .OR. wakef_case))*(ndof/3) + 1 + ok = ok .AND. nv == (MERGE(6, 3, il_case) + MERGE(4, 0, amp_case .OR. wakef_case) + & + MERGE(3, 0, ampf_case) + MERGE(7, 0, frame_case))*(ndof/3) + 1 IF (with_viv .AND. nv > 0) THEN ALLOCATE (buf(nv)) CALL CD_Get_System_Line_VIV_State(a%sys%fast%system, il, buf, es, em) @@ -394,7 +414,8 @@ LOGICAL FUNCTION rebuild(a, b, with_viv) RESULT(ok) CALL CD_HFMF_PackMirror(a%cables(1), buf, es, em) nvc = CD_HFMF_VIVMirrorSize(a%cables(1)) ok = ok .AND. nvc == (MERGE(6, 3, il_case) + MERGE(MERGE(5, 2, wakef_case), 0, wake_case) + & - MERGE(4, 0, amp_case))*a%cables(1)%line%nn + 1 + MERGE(4, 0, amp_case) + MERGE(3, 0, ampf_case) + MERGE(7, 0, frame_case))* & + a%cables(1)%line%nn + 1 IF (.NOT. with_viv) THEN ! the cable's VIV block as the fresh build has it (the torsion-free cable ends with it) CALL CD_HFMF_PackMirror(b%cables(1), fresh, es, em) @@ -420,10 +441,21 @@ LOGICAL FUNCTION identical(a, b) RESULT(same) a%sys%fast%system%lines(1)%viv_wake .AND. & MAXVAL(ABS(a%sys%fast%system%lines(1)%viv_ms - & b%sys%fast%system%lines(1)%viv_ms)) <= 0.0_wp + IF (same .AND. frame_case) THEN + ! the filtered velocity in rows 7-9 of the motion statistics on both lines, no tables + same = a%cables(1)%line%viv_frame .AND. .NOT. a%cables(1)%line%has_viv_amp .AND. & + a%sys%fast%system%lines(1)%viv_frame .AND. .NOT. a%sys%fast%system%lines(1)%has_viv_amp .AND. & + SIZE(a%cables(1)%line%viv_ms, 1) == 9 .AND. SIZE(a%sys%fast%system%lines(1)%viv_ms, 1) == 9 .AND. & + MAXVAL(ABS(a%sys%fast%system%lines(1)%viv_ms - b%sys%fast%system%lines(1)%viv_ms)) <= 0.0_wp .AND. & + MAXVAL(ABS(a%cables(1)%line%viv_ms - b%cables(1)%line%viv_ms)) <= 0.0_wp + END IF IF (same .AND. amp_case) THEN ! the motion statistics with the amplitude estimate (rows 3-6) on both lines same = a%sys%fast%system%lines(1)%has_viv_amp .AND. a%cables(1)%line%has_viv_amp .AND. & - SIZE(a%cables(1)%line%viv_ms, 1) == 6 .AND. & + SIZE(a%cables(1)%line%viv_ms, 1) == MERGE(9, 6, ampf_case) .AND. & + SIZE(a%sys%fast%system%lines(1)%viv_ms, 1) == MERGE(9, 6, ampf_case) .AND. & + (a%cables(1)%line%viv_frame .EQV. ampf_case) .AND. & + (a%sys%fast%system%lines(1)%viv_frame .EQV. ampf_case) .AND. & MAXVAL(ABS(a%sys%fast%system%lines(1)%viv_ms - b%sys%fast%system%lines(1)%viv_ms)) <= 0.0_wp .AND. & MAXVAL(ABS(a%cables(1)%line%viv_ms - b%cables(1)%line%viv_ms)) <= 0.0_wp END IF @@ -455,16 +487,17 @@ SUBROUTINE response(z, ad, f) IF (n > 1) f = REAL(n - 1, wp)/(t1 - t0) END SUBROUTINE response - SUBROUTINE write_deck(path, cl, window, dtm, anchor_first, inline, wake, amp, wake_tf) + SUBROUTINE write_deck(path, cl, window, dtm, anchor_first, inline, wake, amp, wake_tf, damp) !! The EI = 0 riser (line 1) and the finite-EI cable (line 2), 20 m apart across the current; !! VIVrmsWindow 0.25 s unless window is given (0: none), and a deck dtM when dtm is given; !! inline adds the in-line VIV of both types (a VIV section, ClX 0.85); wake gives both types !! the wake oscillator instead of their lift (Cl 0 and WAKE OSCILLATOR rows, C_L0 0.3); amp a VIV - !! AMPLITUDE table on both types. + !! AMPLITUDE table on both types; damp Thorsen's cross-flow damping (VIV DAMPING 0.31 0.89) on the + !! cable. CHARACTER(*), INTENT(IN) :: path REAL(wp), INTENT(IN) :: cl REAL(wp), INTENT(IN), OPTIONAL :: window, dtm - LOGICAL, INTENT(IN), OPTIONAL :: anchor_first, inline, wake, amp + LOGICAL, INTENT(IN), OPTIONAL :: anchor_first, inline, wake, amp, damp ! the VIV FRAME filter time Tf of both types (no section without it) CHARACTER(*), INTENT(IN), OPTIONAL :: wake_tf INTEGER :: u @@ -519,12 +552,6 @@ SUBROUTINE write_deck(path, cl, window, dtm, anchor_first, inline, wake, amp, wa WRITE (u, '(A)') 'TypeName CL0 St eps A' WRITE (u, '(A)') 'riser 0.3 0.2 0.3 12' WRITE (u, '(A)') 'cable 0.3 0.2 0.3 12' - IF (PRESENT(wake_tf)) THEN - WRITE (u, '(A)') '--------------------- VIV FRAME ---' - WRITE (u, '(A)') 'TypeName Tf' - WRITE (u, '(A)') 'riser '//wake_tf - WRITE (u, '(A)') 'cable '//wake_tf - END IF END IF IF (PRESENT(amp)) THEN IF (amp) THEN @@ -536,6 +563,19 @@ SUBROUTINE write_deck(path, cl, window, dtm, anchor_first, inline, wake, amp, wa WRITE (u, '(A)') 'cable 1.0 0.4 1.5' END IF END IF + IF (PRESENT(damp)) THEN + IF (damp) THEN + WRITE (u, '(A)') '--------------------- VIV DAMPING ---' + WRITE (u, '(A)') 'TypeName a b' + WRITE (u, '(A)') 'cable 0.31 0.89' + END IF + END IF + IF (PRESENT(wake_tf)) THEN + WRITE (u, '(A)') '--------------------- VIV FRAME ---' + WRITE (u, '(A)') 'TypeName Tf' + WRITE (u, '(A)') 'riser '//wake_tf + WRITE (u, '(A)') 'cable '//wake_tf + END IF WRITE (u, '(A)') '--------------------- OPTIONS ---' WRITE (u, '(A)') '100.0 WtrDpth' WRITE (u, '(A)') '1025.0 rhoW' diff --git a/tests/test_viv_frame_deck.f90 b/tests/test_viv_frame_deck.f90 new file mode 100644 index 0000000..4104930 --- /dev/null +++ b/tests/test_viv_frame_deck.f90 @@ -0,0 +1,353 @@ +! File: tests/test_viv_frame_deck.f90 +! SPDX-License-Identifier: Apache-2.0 +! Copyright (c) 2026 Jae Hoon Seo, SMI Lab, Inha University +PROGRAM test_viv_frame_deck + !! The VIV FRAME section (TypeName Tf) on the synchronisation model: with Tf > 0 the motion of the + !! phases (the cable's velocity relative to its velocity low-pass filtered over Tf), the amplitude + !! estimate (and so the VIV AMPLITUDE coefficients Cv and CdAmp) and the axes and blend of the + !! VIV DAMPING split take the cable's filtered motion as their frame. The cable is the taut cable + !! of the VIV amplitude and damping gates (100 m, D 0.1 m, 50 kN, pinned at 50 m depth, 50 + !! elements, Cl 0.8), its type with the lift alone, or ("tables") with a VIV AMPLITUDE table (Cv + !! 0.8, 0.6, 0.0 and CdAmp 1.0, 1.3, 1.6 at A/D 0, 0.5, 1) and, on the finite-EI cable (EI 1 + !! N m^2), Thorsen's VIV DAMPING (0.31 0.89). + !! G1 a Tf 0 row is the deck without the section, bit for bit, on the finite-EI cable and on the + !! EI = 0 line, with and without the tables; + !! G2 the finite-EI cable towed through still water (both ends at 0.15 m/s against y after a + !! 10 s half-cosine ramp) with Tf 10 s responds as the cable held in a 0.15 m/s current: the + !! A/D over 50-80 s within 1 % of the held cable's (measured 0.24 % with the tables, 0.16 % + !! with the lift alone) and within 0.2 % of the held cable's with Tf 10 s (measured 0.01 %; + !! the frame moves at a constant velocity, so the two are the same problem), the frequency + !! within 0.005 and 0.0015 Hz (the 30 s window resolves 0.033 Hz; the scan peak moves by + !! 0.002 Hz). With the tables the towed cable without the frame takes Cv and CdAmp at A/D 0 + !! and the Morison drag (no ambient flow) and responds otherwise (A/D more than 10 % off; + !! measured 16 %); with the lift alone it is reported (1.9 % off); + !! G3 held in the current, Tf 10 s leaves the response as the ambient flow gives it (A/D within + !! 0.5 %, measured at most 0.23 %, frequency within 0.005 Hz), on both cores, with and without + !! the tables (an EI = 0 line cannot run between two moving points, so the towed case is + !! finite-EI only); + !! G4 refusals by name: a VIV FRAME row on a type without VIV (no Cl, no WAKE OSCILLATOR row). + 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 + CHARACTER(*), PARAMETER :: AMP = 'riser 0.0 0.8 1.0;riser 0.5 0.6 1.3;riser 1.0 0.0 1.6' + REAL(wp), PARAMETER :: TMAX = 80.0_wp, T0 = 50.0_wp + INTEGER :: nfail = 0 + REAL(wp) :: fe_cur(2), fe_cur_tf(2), l_cur(2), l_cur_tf(2), fs_cur(2), fs_cur_tf(2), ls_cur(2), ls_cur_tf(2) + ! the agreement of the towed cable with the held one, without and with Tf (G2) + REAL(wp), PARAMETER :: TOL_TOW = 0.01_wp, TOL_TOW_TF = 0.002_wp + + CALL write_current('vfd_current.dat') + CALL write_tow('vfd_tow.txt') + CALL check_fixed('1.0', AMP, 'riser 0.31 0.89', 'vfd_fe', fe_cur, fe_cur_tf) + CALL check_fixed('0.0', AMP, '', 'vfd_l', l_cur, l_cur_tf) + CALL check_fixed('1.0', '', '', 'vfd_fs', fs_cur, fs_cur_tf) + CALL check_fixed('0.0', '', '', 'vfd_ls', ls_cur, ls_cur_tf) + CALL check_tow('vfd_tow', AMP, 'riser 0.31 0.89', fe_cur, fe_cur_tf, ' (tables)') + CALL check_tow('vfd_tows', '', '', fs_cur, fs_cur_tf, ' (lift only)') + CALL check_refusals() + IF (nfail > 0) THEN + WRITE (*, '(A,I0,A)') 'FAIL: ', nfail, ' assertion(s) failed' + ERROR STOP 1 + END IF + WRITE (*, '(A)') 'PASS: VIV FRAME deck gates' + +CONTAINS + + SUBROUTINE require(cond, label) + LOGICAL, INTENT(IN) :: cond + CHARACTER(*), INTENT(IN) :: label + IF (cond) RETURN + nfail = nfail + 1 + WRITE (*, '(A)') 'FAIL: '//TRIM(label) + END SUBROUTINE require + + SUBROUTINE write_current(path) + CHARACTER(*), INTENT(IN) :: path + INTEGER :: u + OPEN (NEWUNIT=u, FILE=path, STATUS='REPLACE', ACTION='WRITE') + WRITE (u, '(A)') 'MoorDyn v2 water kinematics file' + WRITE (u, '(A)') 'uniform current along y for the VIV FRAME 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_tow(path) + !! Both ends (points 1 and 2) moved along -y at 0.15 m/s after a 10 s half-cosine velocity ramp, + !! every 0.01 s to TMAX: y = -U (t/2 - T sin(pi t/T)/(2 pi)) in the ramp (T 10 s). + CHARACTER(*), INTENT(IN) :: path + REAL(wp), PARAMETER :: U = 0.15_wp, TR = 10.0_wp + INTEGER :: u_, k + REAL(wp) :: t, y, v, a + OPEN (NEWUNIT=u_, FILE=path, STATUS='REPLACE', ACTION='WRITE') + WRITE (u_, '(A)') '# time point x y z vx vy vz ax ay az' + DO k = 0, NINT(100.0_wp*TMAX) + t = 0.01_wp*REAL(k, wp) + IF (t < TR) THEN + y = -U*(0.5_wp*t - TR*SIN(PI*t/TR)/(2.0_wp*PI)) + v = -U*0.5_wp*(1.0_wp - COS(PI*t/TR)) + a = -U*0.5_wp*(PI/TR)*SIN(PI*t/TR) + ELSE + y = -U*(0.5_wp*TR + (t - TR)) + v = -U + a = 0.0_wp + END IF + WRITE (u_, '(F9.3,A,3ES17.9,A,ES17.9,A,ES17.9,A)') t, ' 1 ', 0.0_wp, y, -50.0_wp, ' 0 ', v, ' 0 0 ', a, ' 0' + WRITE (u_, '(F9.3,A,3ES17.9,A,ES17.9,A,ES17.9,A)') t, ' 2 ', 100.0_wp, y, -50.0_wp, ' 0 ', v, ' 0 0 ', a, ' 0' + END DO + CLOSE (u_) + END SUBROUTINE write_tow + + SUBROUTINE write_rows(u, title, header, rows) + INTEGER, INTENT(IN) :: u + CHARACTER(*), INTENT(IN) :: title, header, rows + INTEGER :: i0, i1 + WRITE (u, '(A)') '----------------------- '//title//' ---------------------------------------' + WRITE (u, '(A)') header + i0 = 1 + DO + i1 = INDEX(rows(i0:), ';') + IF (i1 == 0) THEN + WRITE (u, '(A)') TRIM(rows(i0:)) + EXIT + END IF + WRITE (u, '(A)') rows(i0:i0 + i1 - 2) + i0 = i0 + i1 + END DO + END SUBROUTINE write_rows + + SUBROUTINE write_deck(path, ei, amp_rows, damp_rows, tmax_, tow, frame_rows, cl) + !! ei the type's EI; amp_rows/damp_rows: the VIV AMPLITUDE and VIV DAMPING data rows, + !! ';'-separated ('' for no section); tow: no current, both ends Coupled and moved by the motion + !! file vfd_tow.txt; frame_rows: the VIV FRAME data rows (no section without it). + CHARACTER(*), INTENT(IN) :: path, ei, amp_rows, damp_rows + REAL(wp), INTENT(IN) :: tmax_ + LOGICAL, INTENT(IN) :: tow + CHARACTER(*), INTENT(IN), OPTIONAL :: frame_rows, cl + CHARACTER(8) :: cl_col + INTEGER :: u + cl_col = '0.8' + IF (PRESENT(cl)) cl_col = cl + OPEN (NEWUNIT=u, FILE=path, STATUS='REPLACE', ACTION='WRITE') + WRITE (u, '(A)') '--------------------- CableDyn Input File ---------------------------------' + WRITE (u, '(A)') 'VIV FRAME deck gate: taut cable in a uniform current or towed through still water' + WRITE (u, '(A)') '----------------------- LINE TYPES ------------------------------------------' + WRITE (u, '(A)') 'TypeName Diam Mass/m EA BA/-zeta EI Cd Ca CdAx CaAx Cl dF cF' + WRITE (u, '(A)') 'riser 0.10 10.0 5.0e7 -0.8 '//ei//' 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)') '1 Coupled 0.0 0.0 -50.0 0 0 0 0' + IF (tow) THEN + WRITE (u, '(A)') '2 Coupled 100.0 0.0 -50.0 0 0 0 0' + ELSE + WRITE (u, '(A)') '2 Fixed 100.0 0.0 -50.0 0 0 0 0' + END IF + WRITE (u, '(A)') '----------------------- LINES -----------------------------------------------' + WRITE (u, '(A)') 'ID NodeA NodeB Outputs' + WRITE (u, '(A)') '1 1 2 -' + WRITE (u, '(A)') '----------------------- SECTIONS --------------------------------------------' + WRITE (u, '(A)') 'LineID LineType Length NumSegs' + WRITE (u, '(A)') '1 riser 99.900100 50' + IF (LEN_TRIM(amp_rows) > 0) CALL write_rows(u, 'VIV AMPLITUDE', 'TypeName AD Cv CdAmp', amp_rows) + IF (LEN_TRIM(damp_rows) > 0) CALL write_rows(u, 'VIV DAMPING', 'TypeName a b', damp_rows) + IF (PRESENT(frame_rows)) CALL write_rows(u, 'VIV FRAME', 'TypeName Tf', frame_rows) + 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' + IF (tow) THEN + WRITE (u, '(A)') 'vfd_tow.txt motionFile' + ELSE + WRITE (u, '(A)') 'vfd_current.dat WaterKin' + END IF + WRITE (u, '(A,F8.3,A)') ' ', tmax_, ' TMax' + WRITE (u, '(A)') '---------------------- OUTPUTS -----------------------------------------------' + WRITE (u, '(A)') 'L1N25PZ' + 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) of a deck's main output file. + CHARACTER(*), INTENT(IN) :: path + REAL(wp), ALLOCATABLE, INTENT(OUT) :: tab(:, :) + INTEGER, INTENT(OUT) :: n + CHARACTER(1024) :: rec + INTEGER :: u, ios + ALLOCATE (tab(2, 20000)) + n = 0 + OPEN (NEWUNIT=u, FILE=path, STATUS='OLD', ACTION='READ', IOSTAT=ios) + IF (ios /= 0) RETURN + READ (u, '(A)') rec + READ (u, '(A)') rec + DO + READ (u, '(A)', IOSTAT=ios) rec + IF (ios /= 0) EXIT + IF (LEN_TRIM(rec) == 0) CYCLE + IF (n == SIZE(tab, 2)) EXIT + n = n + 1 + READ (rec, *) tab(:, n) + END DO + CLOSE (u) + END SUBROUTINE read_out + + REAL(wp) FUNCTION peak_frequency(tt, x) RESULT(fpk) + !! The frequency of the largest Fourier amplitude of x - mean(x) on 0.05-1 Hz (0.001 Hz grid). + REAL(wp), INTENT(IN) :: tt(:), x(:) + REAL(wp) :: xm(SIZE(x)), f, best, re, im + INTEGER :: j + xm = x - SUM(x)/REAL(SIZE(x), wp) + best = -1.0_wp + fpk = 0.0_wp + DO j = 0, 950 + f = 0.05_wp + 0.001_wp*REAL(j, wp) + re = SUM(xm*COS(2.0_wp*PI*f*tt)) + im = SUM(xm*SIN(2.0_wp*PI*f*tt)) + IF (re*re + im*im > best) THEN + best = re*re + im*im + fpk = f + END IF + END DO + END FUNCTION peak_frequency + + SUBROUTINE stats(root, res, ok) + !! Half the peak-to-peak mid-span cross-flow excursion over D and the dominant frequency over + !! T0-TMAX of the run root. + CHARACTER(*), INTENT(IN) :: root + REAL(wp), INTENT(OUT) :: res(2) + LOGICAL, INTENT(OUT) :: ok + REAL(wp), ALLOCATABLE :: tab(:, :), tt(:), z(:) + INTEGER :: n + LOGICAL, ALLOCATABLE :: keep(:) + res = 0.0_wp + CALL read_out(root//'.out', tab, n) + ok = n > 1000 + IF (.NOT. ok) RETURN + keep = tab(1, 1:n) >= T0 + tt = PACK(tab(1, 1:n), keep) + z = PACK(tab(2, 1:n), keep) + res = [0.5_wp*(MAXVAL(z) - MINVAL(z))/D, peak_frequency(tt, z)] + END SUBROUTINE stats + + LOGICAL FUNCTION same_file(a, b) RESULT(same) + !! The two text files are the same, line for line. + CHARACTER(*), INTENT(IN) :: a, b + CHARACTER(1024) :: ra, rb + INTEGER :: ua, ub, ia, ib + same = .FALSE. + OPEN (NEWUNIT=ua, FILE=a, STATUS='OLD', ACTION='READ', IOSTAT=ia) + IF (ia /= 0) RETURN + OPEN (NEWUNIT=ub, FILE=b, STATUS='OLD', ACTION='READ', IOSTAT=ib) + IF (ib /= 0) THEN + CLOSE (ua); RETURN + END IF + DO + READ (ua, '(A)', IOSTAT=ia) ra + READ (ub, '(A)', IOSTAT=ib) rb + IF (ia /= 0 .OR. ib /= 0) EXIT + IF (ra /= rb) EXIT + END DO + same = ia /= 0 .AND. ib /= 0 + CLOSE (ua) + CLOSE (ub) + END FUNCTION same_file + + SUBROUTINE check_fixed(ei, amp_rows, damp_rows, tag, res, res_tf) + !! G1 and G3 on the cable of EI ei held in the current: without the section, with a Tf 0 row + !! and with Tf 10 s; res and res_tf (A/D, f) without the section and with Tf 10 s. + CHARACTER(*), INTENT(IN) :: ei, amp_rows, damp_rows, tag + REAL(wp), INTENT(OUT) :: res(2), res_tf(2) + LOGICAL :: ok, ok2 + CHARACTER(1024) :: msg + CHARACTER(:), ALLOCATABLE :: lab + lab = ' (EI '//ei//', '//TRIM(MERGE('tables', 'lift ', LEN_TRIM(amp_rows) > 0))//')' + CALL write_deck(tag//'_amb.dat', ei, amp_rows, damp_rows, TMAX, .FALSE.) + CALL run(tag//'_amb.dat', tag//'_amb', ok, msg) + CALL require(ok, 'G1: the deck without the section runs'//lab//': '//TRIM(msg)) + CALL write_deck(tag//'_t0.dat', ei, amp_rows, damp_rows, TMAX, .FALSE., frame_rows='riser 0') + CALL run(tag//'_t0.dat', tag//'_t0', ok, msg) + CALL require(ok, 'G1: the deck with Tf 0 runs'//lab//': '//TRIM(msg)) + CALL require(same_file(tag//'_amb.out', tag//'_t0.out'), 'G1: a Tf 0 row is the deck without it, bit for '// & + 'bit'//lab) + CALL write_deck(tag//'_tf.dat', ei, amp_rows, damp_rows, TMAX, .FALSE., frame_rows='riser 10') + CALL run(tag//'_tf.dat', tag//'_tf', ok, msg) + CALL require(ok, 'G3: the deck with Tf 10 s runs'//lab//': '//TRIM(msg)) + CALL stats(tag//'_amb', res, ok) + CALL stats(tag//'_tf', res_tf, ok2) + CALL require(ok .AND. ok2, 'G3: the runs wrote their rows'//lab) + WRITE (*, '(A,2F8.4,A,2F8.4)') 'G3'//lab//': in the current A/D, f [Hz] with Tf 10 s ', res_tf, & + '; without ', res + CALL require(res(1) > 0.2_wp, 'G3: the cable locks in'//lab) + CALL require(ABS(res_tf(1)/res(1) - 1.0_wp) <= 0.005_wp .AND. ABS(res_tf(2) - res(2)) <= 0.005_wp, & + 'G3: held in the current, Tf leaves the response as the ambient flow gives it'//lab) + END SUBROUTINE check_fixed + + SUBROUTINE check_tow(tag, amp_rows, damp_rows, ref, ref_tf, lab) + !! G2 on the finite-EI cable with the given tables: towed with Tf 10 s and without it, against + !! the cable held in the current without and with Tf 10 s (ref, ref_tf, from check_fixed); + !! without the tables (the lift alone) the towed cable without Tf is only reported. + CHARACTER(*), INTENT(IN) :: tag, amp_rows, damp_rows, lab + REAL(wp), INTENT(IN) :: ref(2), ref_tf(2) + REAL(wp) :: r_tf(2), r_0(2) + LOGICAL :: ok, ok2 + CHARACTER(1024) :: msg + CALL write_deck(tag//'_tf.dat', '1.0', amp_rows, damp_rows, TMAX, .TRUE., frame_rows='riser 10') + CALL run(tag//'_tf.dat', tag//'_tf', ok, msg) + CALL require(ok, 'G2: the towed deck with Tf runs'//lab//': '//TRIM(msg)) + CALL write_deck(tag//'_0.dat', '1.0', amp_rows, damp_rows, TMAX, .TRUE.) + CALL run(tag//'_0.dat', tag//'_0', ok, msg) + CALL require(ok, 'G2: the towed deck without Tf runs'//lab//': '//TRIM(msg)) + CALL stats(tag//'_tf', r_tf, ok) + CALL stats(tag//'_0', r_0, ok2) + CALL require(ok .AND. ok2, 'G2: the towed runs wrote their rows'//lab) + WRITE (*, '(A,2F8.4,A,2F8.4,A,2F8.4,A,2F8.4)') 'G2'//lab//': towed A/D, f [Hz] with Tf 10 s ', r_tf, & + '; without ', r_0, '; held in the current ', ref, ', with Tf ', ref_tf + CALL require(ABS(r_tf(1)/ref(1) - 1.0_wp) <= TOL_TOW .AND. ABS(r_tf(2) - ref(2)) <= 0.005_wp, & + 'G2: towed with Tf, the cable responds as the cable held in the current'//lab) + CALL require(ABS(r_tf(1)/ref_tf(1) - 1.0_wp) <= TOL_TOW_TF .AND. ABS(r_tf(2) - ref_tf(2)) <= 0.0015_wp, & + 'G2: towed with Tf, the cable responds as the cable held in the current with Tf'//lab) + IF (LEN_TRIM(amp_rows) > 0) CALL require(ABS(r_0(1)/ref(1) - 1.0_wp) > 0.10_wp, & + 'G2: towed without Tf, it responds otherwise'//lab) + END SUBROUTINE check_tow + + SUBROUTINE check_refusals() + LOGICAL :: ok + CHARACTER(1024) :: msg + CALL write_deck('vfd_bad.dat', '1.0', '', '', 1.0_wp, .FALSE., frame_rows='riser 10', cl='0.0') + CALL run('vfd_bad.dat', 'vfd_bad', ok, msg) + WRITE (*, '(A)') 'G4 a type without VIV: '//TRIM(msg) + CALL require(.NOT. ok .AND. INDEX(msg, 'give the type LINE TYPES Cl > 0 or a WAKE OSCILLATOR row') > 0, & + 'G4: a VIV FRAME row on a type without VIV is refused') + END SUBROUTINE check_refusals + +END PROGRAM test_viv_frame_deck diff --git a/tests/test_viv_wake_deck.f90 b/tests/test_viv_wake_deck.f90 index 89583ee..dece596 100644 --- a/tests/test_viv_wake_deck.f90 +++ b/tests/test_viv_wake_deck.f90 @@ -29,7 +29,7 @@ PROGRAM test_viv_wake_deck !! VIV velocity: A/D within 2 %, frequency within 0.002 Hz), on both cores, and the two !! cores agree there as in W5 (an EI = 0 line cannot run between two moving points); !! W7 VIV FRAME refusals by name: a malformed row, an unknown or repeated type, - !! a negative Tf, and a type without a WAKE OSCILLATOR row. + !! a negative Tf, and a type without VIV (no Cl, no WAKE OSCILLATOR row). USE CableDyn_Precision, ONLY: wp USE CableDyn_DeckDriver, ONLY: CD_Run_Deck_Driver, CD_DECKDRV_OK IMPLICIT NONE @@ -417,8 +417,8 @@ SUBROUTINE check_refusals() frame_rows='cable 10') CALL refused('riser 0.3', 'VIV FRAME names LINE TYPE', 'W7: a repeated type', frame_rows='riser 10;riser 5') CALL refused('riser 0.3', 'filter time Tf must be >= 0', 'W7: a negative Tf', frame_rows='riser -1') - CALL refused('', 'give the type a WAKE OSCILLATOR row', 'W7: a type without the wake oscillator', & - cl='0.8', frame_rows='riser 10') + CALL refused('', 'give the type LINE TYPES Cl > 0 or a WAKE OSCILLATOR row', 'W7: a type without VIV', & + frame_rows='riser 10') CALL refused('riser 0.3 x', 'plain numbers', 'a non-numeric St') CALL refused('cable 0.3', 'undefined LINE TYPE', 'an unknown type') CALL refused('riser 0.3;riser 0.2', 'twice', 'a repeated type')