diff --git a/CHANGELOG.md b/CHANGELOG.md index fbe1f1b6..02657bfa 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -17,6 +17,13 @@ All notable changes to CableDyn are recorded in this file. The format follows and frequency to two to three digits through mode-1 and mode-3 lock-in, at any `dtM` from 5e-4 to 1e-2 s. The Python deck tools read and keep the columns. The coupled and mixed routes refuse `Cl > 0` by name. +- Cross-flow VIV of finite-EI cables in the standalone driver: the same LINE TYPES columns on an + `EI > 0` type give a distributed lift, Gauss-integrated over each cubic-Hermite element with + exact tangents, and a shedding phase at each node driven along the node's own tangent. A taut + line with `EI` near zero reproduces the `EI = 0` lock-in to three digits, at any `dtM` from + 5e-4 to 1e-2 s without smoothing; a bending-stiff line matches the string of equal first-mode + frequency in mode-1 lock-in and stays in mode 1 where that string jumps to mode 2. A finite-EI + line with two moving ends, or beside bodies, rods or free points, refuses `Cl > 0`. - Bend stiffeners (`STIFFENERS` table): a tapered polyurethane sleeve over an end of a finite-EI line, given as conical segments from the root outward (outer diameters, bore, modulus, density). Each element it covers takes the compliance average of the cable-plus-sleeve diff --git a/CMakeLists.txt b/CMakeLists.txt index 22d27f5d..5911ec2c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1175,6 +1175,11 @@ target_link_libraries(test_viv_kernels PRIVATE cabledyn_core) add_test(NAME viv_kernels COMMAND test_viv_kernels) set_tests_properties(viv_kernels PROPERTIES LABELS "fortran;unit;dynamic;viv") +add_executable(test_hermite_viv tests/test_hermite_viv.f90) +target_link_libraries(test_hermite_viv PRIVATE cabledyn_core) +add_test(NAME hermite_viv COMMAND test_hermite_viv) +set_tests_properties(hermite_viv PROPERTIES LABELS "fortran;dynamic;viv") + add_executable(test_hfmf_mirror tests/test_hfmf_mirror.f90) target_link_libraries(test_hfmf_mirror PRIVATE cabledyn_core) add_test(NAME hfmf_mirror COMMAND test_hfmf_mirror WORKING_DIRECTORY ${CMAKE_BINARY_DIR}) @@ -1627,9 +1632,17 @@ if(Python3_Interpreter_FOUND) COMMAND ${Python3_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/tests/test_viv_lockin.py --exe $ --output ${CMAKE_BINARY_DIR}/viv_lockin) + # eight benchmark runs, four at a time (PROCESSORS reserves them, so no other test shares + # the cores); a checked Debug build is about ten times slower than Release + if(CMAKE_BUILD_TYPE STREQUAL "Debug") + set(_viv_lockin_timeout 2400) + else() + set(_viv_lockin_timeout 600) + endif() set_tests_properties(viv_lockin PROPERTIES LABELS "python;integration;dynamic;viv;validation" - TIMEOUT 600 + PROCESSORS 4 + TIMEOUT ${_viv_lockin_timeout} ENVIRONMENT "${_cabledyn_python_test_environment}") else() message(STATUS "viv_lockin: skipped (numpy not importable in ${Python3_EXECUTABLE})") diff --git a/VALIDATION.md b/VALIDATION.md index fe21a1f6..a025c0a3 100644 --- a/VALIDATION.md +++ b/VALIDATION.md @@ -63,6 +63,7 @@ article's methods, are compared in | **L2-80** | Lozon 80 m all-chain mooring | catenary (H) / MoorDyn-F (fairlead) | 0.03% / 1.8% | <2% / <5% | Pass | | **L2-arb** | Closed-form catenary reference check | OrcaFlex VolturnUS-S ref | 0.69% | <2% | Pass | | **L2-VIV** | Cross-flow VIV lock-in of a taut 100 m line, U = 0.06–0.42 m/s | MoorDyn-F (OpenFAST v5 `moordyn_driver`, `dtM` 5e-4 s) | mode-1 and mode-3 lock-in (U ≤ 0.18 and ≥ 0.36 m/s): mid-span A/D within 1.2%, frequency within one spectral bin; same response at `dtM` 5e-4 to 1e-2 s; at 0.21–0.33 m/s the codes settle on different modes (MoorDyn-F mode 1, CableDyn mode 2) | A/D <3%, frequency within one spectral bin (`viv_lockin`) | Pass scoped | +| **L2-VIV-EI** | Cross-flow VIV of a finite-EI cable: the L2-VIV line with EI = 1 N m², and a bending-stiff line (EA 5e9 N, EI 5e7 N m², β = π²EI/(TL²) ≈ 1, neutrally buoyant) against the EI = 0 string of equal first-mode frequency, U = 0.10–0.36 m/s | CableDyn `EI = 0` line (verification) | EI = 1: mid/quarter A/D 0.662/0.421 against 0.663/0.421, same frequency, at `dtM` 5e-4 to 1e-2 s; stiff line: mode-1 lock-in A/D within 2.5% of the string's at the same frequency for U ≤ 0.24 m/s; for U ≥ 0.27 m/s the string jumps to mode 2 while the stiff line stays in mode 1 (bending raises f₂/f₁ to 3.15) | EI = 1: A/D within 1% at `dtM` 0.01 and 0.002 s (5e-4 s run once over 200 s); stiff line at U 0.21 m/s: A/D within 3%; frequency within one spectral bin; at U 0.30 m/s stiff line A/D > 0.6, string < 0.15 (`viv_lockin`, `hermite_viv`) | Pass | | **L3-1** | WD0050 static | OrcaFlex | 0.15 / 0.85% | <2% | Pass | | **L3-2** | Regular-wave dynamic | OrcaFlex (pinned, dt-converged) | mean 0.30%, swing 8.4% | <2% / <15% | Pass | | **L3-3** | Current-deflected static | OrcaFlex | 0.07–0.67% | <2% | Pass | diff --git a/doc/capabilities.rst b/doc/capabilities.rst index 450b8b01..68335dcb 100644 --- a/doc/capabilities.rst +++ b/doc/capabilities.rst @@ -115,9 +115,11 @@ Line and constitutive capability torsion is rejected * - Cross-flow VIV (LINE TYPES ``Cl``, ``dF``, ``cF``) - Standalone only - - MoorDyn v2's synchronisation model on ``EI = 0`` lines (:ref:`theory-viv`); in-line VIV - and finite-EI cables are not provided; the coupled OpenFAST and FAST.Farm routes and - mixed ``EI = 0`` / finite-EI decks refuse ``Cl > 0`` by name + - MoorDyn v2's synchronisation model on ``EI = 0`` lines and, as a distributed lift, on + finite-EI cables of the Hermite march (:ref:`theory-viv`); in-line VIV is not provided; + the coupled OpenFAST and FAST.Farm routes, mixed ``EI = 0`` / finite-EI decks, finite-EI + lines with two moving ends and finite-EI lines beside bodies, rods or free points refuse + ``Cl > 0`` by name Loads and environment --------------------- diff --git a/doc/migrating.rst b/doc/migrating.rst index 9a851f77..66cf82f4 100644 --- a/doc/migrating.rst +++ b/doc/migrating.rst @@ -93,8 +93,9 @@ Keyword map - same row; the native order is ``Cd_n Cd_t Ca_n Ca_t`` and the header decides which is meant. ``EI > 0`` switches the line to the bending element. * - ``LINE TYPES`` VIV columns ``Cl`` or ``Cl dF cF`` - - same columns and the same synchronisation model on ``EI = 0`` types in the standalone - driver (:ref:`theory-viv`); the running-RMS window is ``VIVrmsWindow`` seconds, by default + - same columns and the same synchronisation model in the standalone driver, on ``EI = 0`` + types and as a distributed lift on finite-EI types (:ref:`theory-viv`); the running-RMS + window is ``VIVrmsWindow`` seconds, by default 500 steps of ``dtM`` as MoorDyn's * - ``ElasticMod 2/3`` viscoelastic ``EA``/``BA`` - ``Es|Ed`` / ``Es|alphaMBL|vbeta`` in ``EA`` and ``BA_s|BA_d`` in ``BA`` diff --git a/doc/options.rst b/doc/options.rst index e5accfcf..936b05ac 100644 --- a/doc/options.rst +++ b/doc/options.rst @@ -683,7 +683,8 @@ Ambient fluid and prescribed motion of the VIV synchronisation model (:ref:`theory-viv`). ``0`` takes MoorDyn's 500 steps of ``dtM`` (of the first step when the deck has no ``dtM``); set it to compare runs at different ``dtM`` with the same averaging time - - standalone ``EI = 0`` lines with a LINE TYPES ``Cl > 0`` + - standalone lines (``EI = 0``, or finite-EI on the Hermite march) with a LINE TYPES + ``Cl > 0`` - ``0.25 VIVrmsWindow`` * - ``motionFile`` - path, or ``0``/``none`` diff --git a/doc/theory.rst b/doc/theory.rst index 9b96cc7e..9b0e3c0a 100644 --- a/doc/theory.rst +++ b/doc/theory.rst @@ -720,10 +720,10 @@ The fluid acceleration is the local (Eulerian) acceleration of the wave field. Cross-flow vortex-induced vibration ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -``EI = 0`` lines can carry the cross-flow lift of the synchronisation model of +Lines can carry the cross-flow lift of the synchronisation model of :ref:`Thorsen et al. (2014) ` and :ref:`(2016) ` in the form MoorDyn v2 implements it: a LINE TYPES row with a lift coefficient :math:`C_L > 0` (see -:doc:`file_formats`). At an interior node with unit tangent :math:`\mathbf{q}` (the chord of its +:doc:`file_formats`). On an ``EI = 0`` line, at an interior node with unit tangent :math:`\mathbf{q}` (the chord of its neighbours) and normal relative flow :math:`\mathbf{v}_n` of speed :math:`U = \lvert\mathbf{v}_n\rvert`, each node carries a vortex-shedding phase :math:`\phi` and the lift @@ -757,8 +757,30 @@ the phase and the velocity in the lift are the node values averaged with the nei wavenumber :math:`k` to :math:`\cos^2(k l_0/2)` and removes the mesh-scale zig-zag mode exactly. With the node's own kinematics, a step that resolves the zig-zag mode lets the synchronisation loop pump it until the line loses lock-in; a coarse step only hides this behind the -integrator's numerical damping. VIV runs in the standalone driver; the coupled and mixed -aggregate routes refuse a deck with :math:`C_L > 0`. +integrator's numerical damping. + +On a finite-EI (cubic-Hermite) cable the lift is a distributed load per unit deformed length, + +.. math:: + + \mathbf{f}_L = \tfrac{1}{2}\rho\,d\,C_L\cos\phi\;U\;\mathbf{t}\times\mathbf{v}_r , + +with :math:`\mathbf{t}` the unit tangent of the centreline, :math:`\mathbf{v}_r` the relative flow +(its normal part has speed :math:`U`) and :math:`\cos\phi` interpolated linearly between the +element's end nodes. It is integrated against the Hermite shape functions at the three Gauss +points of the drag (a point above the surface carries none), and its exact position and +velocity derivatives enter the tangent. Each node carries a phase, driven as above by the +node's cross-flow motion along its own tangent, the slope degrees of freedom; :math:`d`, +:math:`c_F` and :math:`d_F` at a node are the length-weighted averages over its lifting +elements. The phase is explicit with the Heun commit as on ``EI = 0`` lines, and no smoothing is +needed: the Hermite tangent and the integrated lift leave no mesh-scale mode for the loop to +pump, and the response is the same from ``dtM`` 5e-4 to 1e-2 s. A finite-EI line with +:math:`EI \to 0` reproduces the ``EI = 0`` line's lock-in. The standalone Hermite march +carries it, including deck waves and current through its held fluid field; a finite-EI line +with two moving ends, or beside bodies, rods or free points, refuses :math:`C_L > 0`. + +VIV runs in the standalone driver; the coupled and mixed aggregate routes refuse a deck with +:math:`C_L > 0`. Buoyancy and wetting ~~~~~~~~~~~~~~~~~~~~ diff --git a/doc/troubleshooting.rst b/doc/troubleshooting.rst index 5d80a286..4420f6de 100644 --- a/doc/troubleshooting.rst +++ b/doc/troubleshooting.rst @@ -839,8 +839,12 @@ aborts with a CableDyn fatal error, check whether the deck uses one of these com * - a ``Rigid`` end-connection direction reversed by exactly 180 degrees in one host update - drive the platform through intermediate orientations * - VIV on the coupled or mixed route (``VIV (LINE TYPES Cl > 0) runs in the standalone driver - of an EI = 0 deck``) - - run the VIV study on a standalone ``EI = 0`` deck, or set ``Cl = 0`` for the coupled run + of an EI = 0 or finite-EI deck``) + - run the VIV study on a standalone ``EI = 0`` or finite-EI deck, or set ``Cl = 0`` for the + coupled run + * - VIV on a finite-EI line with two moving ends (``needs its End B fixed``) or beside + bodies, rods or free points (``does not run with bodies, rods or free points yet``) + - fix End B of the line, or set ``Cl = 0`` for its line type * - a host/file fluid combination named as inseparable - select host wave/current and file wave/current independently as documented, or place the whole field in SeaState diff --git a/python/cabledyn/builder.py b/python/cabledyn/builder.py index 1aa415b3..17d8e717 100644 --- a/python/cabledyn/builder.py +++ b/python/cabledyn/builder.py @@ -194,7 +194,7 @@ class LineType: inertias). All four set writes the 14-column row; all ``None`` writes the 10-column row. cl, df, cf : float | None - Optional cross-flow VIV columns of an ``EI = 0`` type (MoorDyn's lift + Optional cross-flow VIV columns of a type (MoorDyn's lift coefficient and the half-range and centre of the synchronisation band in non-dimensional frequency). ``cl`` set writes the 13-column row, with MoorDyn's ``df = 0.08`` and ``cf = 0.18`` where they are ``None``. diff --git a/python/cabledyn/deck_file.py b/python/cabledyn/deck_file.py index 343667df..a3d1fe0d 100644 --- a/python/cabledyn/deck_file.py +++ b/python/cabledyn/deck_file.py @@ -2615,6 +2615,7 @@ def numeric(token: str, row: DeckRecord, field: str) -> float: # (native init_one_model, which needs the line's Morison drag in water) has_viv = False has_viv_ei0 = False + viv_type_names: set[str] = set() for row in self.line_types: for index in (1, 2, *range(5, len(row.tokens))): numeric(row.tokens[index], row, f"LINE TYPES column {index + 1}") @@ -2697,10 +2698,6 @@ def numeric(token: str, row: DeckRecord, field: str) -> float: f"{self._at(row)}: LINE TYPES VIV synchronisation band needs cF > 0 " "and 0 <= dF < cF" ) - if cl > 0.0 and ei > 0.0: - raise DeckFormatError( - f"{self._at(row)}: VIV (Cl > 0) is implemented for EI = 0 line types only" - ) if cl > 0.0 and is_syrope: raise DeckFormatError( f"{self._at(row)}: VIV (Cl > 0) does not combine with the Syrope " @@ -2708,6 +2705,8 @@ def numeric(token: str, row: DeckRecord, field: str) -> float: ) has_viv = has_viv or cl > 0.0 has_viv_ei0 = has_viv_ei0 or (cl > 0.0 and not ei > 0.0) + if cl > 0.0: + viv_type_names.add(row.tokens[0].lower()) if ei > 0.0 and (is_syrope or len(ea_parts) > 1): model = "Syrope" if is_syrope else "viscoelastic stiffness" raise DeckFormatError(f"{self._at(row)}: {model} is not supported with EI > 0") @@ -3494,8 +3493,8 @@ def end_key(token: str) -> str: if has_viv: raise DeckFormatError( f"{self._label}: VIV (LINE TYPES Cl > 0) runs in the standalone driver of an " - "EI = 0 deck; the coupled OpenFAST and FAST.Farm routes and mixed EI = 0 / " - "finite-EI decks do not carry it yet. Set Cl = 0 for this run" + "EI = 0 or finite-EI deck; the coupled OpenFAST and FAST.Farm routes and mixed " + "EI = 0 / finite-EI decks do not carry it yet. Set Cl = 0 for this run" ) if self.caller_driven: # native CD_Init_Deck_Aggregate: nothing on the coupled route evaluates deck @@ -3600,6 +3599,18 @@ def is_body_kind(kind: str, pinned: bool) -> bool: ) elif has_rigid6: needs_multibody = non_rigid6_points + if deck_driver_route and viv_type_names: + # native run_deck_driver: the finite-EI lift runs on the cubic-Hermite march, which + # builds no bodies, rods or Free/Connect points (a moving End B is refused above) + for line_id in finite_line_ids: + if not viv_type_names.intersection(section_types_by_line[line_id]): + continue + if needs_multibody: + raise DeckFormatError( + f"{self._label}: VIV (LINE TYPES Cl > 0) of a finite-EI line does not run " + "with bodies, rods or free points yet; set Cl = 0 for the finite-EI lines " + "of this deck" + ) if failures and deck_driver_route: # native CD_Run_Deck_Driver: FAILURE runs on the point-system object graph only if not has_dtm: diff --git a/python/tests/test_deck_file.py b/python/tests/test_deck_file.py index 9f8e7825..c9fc05ed 100644 --- a/python/tests/test_deck_file.py +++ b/python/tests/test_deck_file.py @@ -4591,11 +4591,16 @@ def test_line_type_viv_columns_follow_the_native_checks(columns, message): DeckFile.from_text(_edit(_STATIC, (_VIV_ROW, _VIV_ROW + columns))) -def test_line_type_viv_needs_an_ei0_line_type(): +def test_line_type_viv_is_accepted_on_a_finite_ei_line_type(tmp_path): + from cabledyn import DeckModel + row = "chain 0.252 390.0 1.674e9 -1.0 1.0e4 1.37 0.64 1.0 0.0" text = _edit(_DYNAMIC, (row, row + " 0.8")) - with pytest.raises(DeckFormatError, match="implemented for EI = 0 line types only"): - DeckFile.from_text(text) + DeckFile.from_text(text) + path = tmp_path / "viv_ei.dat" + path.write_text(text, encoding="utf-8") + line_type = DeckModel.load(path).line_types["chain"] + assert (line_type.ei, line_type.cl) == (1.0e4, 0.8) def test_viv_is_refused_on_the_coupled_route(): @@ -4613,6 +4618,13 @@ def test_viv_needs_water_on_an_ei0_line(): DeckFile.from_text(_edit(_STATIC, ("50.0 WtrDpth\n", ""))) +def test_finite_ei_viv_is_refused_beside_free_points(): + row = "chain 0.252 390.0 1.674e9 -1.0 1.0e4 1.37 0.64 1.0 0.0" + base = _edit(_DYNAMIC, ("2 Coupled 0.0 0.0 0.0 0 0 0 0", "2 Free 0.0 0.0 0.0 1000 0 0 0")) + with pytest.raises(DeckFormatError, match="does not run with bodies, rods or free points"): + DeckFile.from_text(_edit(base, (row, row + " 0.8"))) + + def test_viv_rms_window_option_is_non_negative(): base = _edit(_STATIC, (_VIV_ROW, _VIV_ROW + " 0.8")) DeckFile.from_text(_edit(base, ("50.0 WtrDpth\n", "50.0 WtrDpth\n0.25 VIVrmsWindow\n"))) diff --git a/src/CableDyn_DeckDriver.f90 b/src/CableDyn_DeckDriver.f90 index fbeca086..49aaf8e7 100644 --- a/src/CableDyn_DeckDriver.f90 +++ b/src/CableDyn_DeckDriver.f90 @@ -103,7 +103,7 @@ MODULE CableDyn_DeckDriver CD_HermiteCable_Dyn_Set_Output_Recovery, & CD_HermiteCable_Dyn_Set_ForceBlend, CD_HC_FORCE_BLEND_DEFAULT, & CD_HermiteCable_Dyn_Set_Friction_Anchors, & - CD_HermiteCable_Dyn_Set_Friction_Axial, & + CD_HermiteCable_Dyn_Set_Friction_Axial, CD_HermiteCable_Dyn_Set_VIV, & CD_HermiteCable_Dyn_Set_Control_Seabed, & CD_HermiteCable_Dyn_Max_Step_Rotation, CD_HermiteCable_Dyn_Energy, & CD_HermiteCable_Attachment_Drag, CD_HermiteCable_Dyn_Torsion_State @@ -1641,7 +1641,8 @@ END SUBROUTINE init_one_finite_model RECURSIVE SUBROUTINE build_one_hermite_cable(ln, sections, types, points, opts, dt, cable, coupled_node, & ErrStat, ErrMsg, standalone_controls, bathymetry, & - fairlead_orientation, init_note, coarse_pass, fold_support) + fairlead_orientation, init_note, coarse_pass, fold_support, & + install_viv) !! Build one COUPLED cubic-Hermite lazy-wave cable (CD_HFMF) from a finite-EI deck !! LINE -- the production Hermite bending path shared by the coupled route and !! standalone and coupled finite-EI dynamics, including flat/structured seabed contact. @@ -1672,12 +1673,16 @@ RECURSIVE SUBROUTINE build_one_hermite_cable(ln, sections, types, points, opts, ! The static seabed friction the calling route accepts (FOLD_FRICTION_*, default ! FOLD_FRICTION_FULL), for the remedy of the note on a run past the anchor. INTEGER, INTENT(IN), OPTIONAL :: fold_support + ! Install the cross-flow VIV of the line's Cl > 0 sections (the standalone finite-EI march; + ! the other routes refuse such a line before building it). + LOGICAL, INTENT(IN), OPTIONAL :: install_viv INTEGER, ALLOCATABLE :: conn(:, :), fixed_dofs(:), dynamic_fixed_dofs(:) REAL(wp), ALLOCATABLE :: l0(:), ea(:), mpl(:), diam(:), ei(:), gas_in(:), gj_in(:), i_rt_in(:), i_rn_in(:) REAL(wp), ALLOCATABLE :: gas(:), gj(:), rho_a(:), i_rt(:), i_rn(:), w(:), nodes_ref(:, :), q0(:), q_static(:) REAL(wp), ALLOCATABLE :: q_sequence(:) REAL(wp), ALLOCATABLE :: curv(:), cdn(:), cdt(:), can(:), cat(:), catenary_pos(:) + REAL(wp), ALLOCATABLE :: viv_cl(:), viv_cf(:), viv_df(:) REAL(wp), ALLOCATABLE :: ba_raw(:), ba(:), dry_b(:) REAL(wp), ALLOCATABLE :: contact_kn(:), contact_cn(:) REAL(wp) :: anchor(3), fairlead(3), res, tvec(3), tnrm, contact_z, seed_z, seed_floor_a, seed_floor_b @@ -2921,7 +2926,12 @@ RECURSIVE SUBROUTINE build_one_hermite_cable(ln, sections, types, points, opts, ! property of the original element containing its reference-arc midpoint. ALLOCATE (cdn(SIZE(l0)), cdt(SIZE(l0)), can(SIZE(l0)), cat(SIZE(l0))) CALL finite_hydro_arrays(ln, sections, types, diam, cdn, cdt, can, cat) + ALLOCATE (viv_cl(SIZE(l0)), viv_cf(SIZE(l0)), viv_df(SIZE(l0))) + CALL finite_viv_arrays(ln, sections, types, viv_cl, viv_cf, viv_df) IF (SIZE(l0_am) /= SIZE(l0)) THEN + CALL remap_elem_by_reference_arc(viv_cl, l0, l0_am) + CALL remap_elem_by_reference_arc(viv_cf, l0, l0_am) + CALL remap_elem_by_reference_arc(viv_df, l0, l0_am) CALL remap_elem_by_reference_arc(rho_a, l0, l0_am) CALL remap_elem_by_reference_arc(diam, l0, l0_am) CALL remap_elem_by_reference_arc(cdn, l0, l0_am) @@ -3123,6 +3133,18 @@ RECURSIVE SUBROUTINE build_one_hermite_cable(ln, sections, types, points, opts, IF (es /= CD_HFMF_OK) THEN CALL fail(ErrStat, ErrMsg, 'finite-EI cable drag wiring failed: '//TRIM(em)); RETURN END IF + ! Cross-flow VIV on the Cl > 0 sections, with the drag's diameters (CableDyn_VIV); an + ! OPTION VIVrmsWindow of 0 takes MoorDyn's 500 time steps. + IF (PRESENT(install_viv)) THEN + IF (install_viv .AND. ANY(viv_cl > CD_ZERO)) THEN + CALL CD_HermiteCable_Dyn_Set_VIV(cable%line, viv_cl, viv_cf, viv_df, & + MERGE(opts%viv_rms_window, REAL(CD_VIV_NM, wp)*dt, & + opts%viv_rms_window > CD_ZERO), es, em) + IF (es /= CD_HCDYN_OK) THEN + CALL fail(ErrStat, ErrMsg, 'finite-EI cable VIV wiring failed: '//TRIM(em)); RETURN + END IF + END IF + END IF CALL CD_HFMF_Set_AddedMass(cable, opts%rhoW, diam, can, cat, CD_ZERO, es, em) IF (es /= CD_HFMF_OK) THEN CALL fail(ErrStat, ErrMsg, 'finite-EI cable added-mass wiring failed: '//TRIM(em)); RETURN @@ -6484,6 +6506,10 @@ SUBROUTINE CD_Init_Deck_HermiteCable(deck_path, dt, cable, coupled_node, ErrStat CALL fail(ErrStat, ErrMsg, 'CD_Init_Deck_HermiteCable cannot consume WaveKinMod 2/SEASTATE; '// & 'use the aggregate facade with its external SeaState field'); RETURN END IF + IF (line_has_viv(lines(1), types, sections)) THEN + CALL fail(ErrStat, ErrMsg, 'CD_Init_Deck_HermiteCable: VIV (LINE TYPES Cl > 0) runs in the standalone '// & + 'deck driver; set Cl = 0 for this entry'); RETURN + END IF IF (opts%has_bathymetry_file) THEN CALL load_bathymetry_file(path_join(deck_dir(deck_path), opts%bathymetry_file), bathymetry, ErrStat, ErrMsg, & points=points) @@ -6711,11 +6737,12 @@ SUBROUTINE CD_Init_Deck_Aggregate(deck_path, dt, agg, ErrStat, ErrMsg, env_gravi 'EI=0/finite-EI decks reject deck water kinematics)') RETURN END IF - ! Cross-flow VIV runs in the standalone EI = 0 driver: the aggregate route (OpenFAST, FAST.Farm, - ! mixed EI = 0 / finite-EI decks) neither checkpoints its shedding phase nor feeds it the host's - ! fluid field yet. + ! Cross-flow VIV runs in the standalone driver (EI = 0 decks and finite-EI decks): the aggregate + ! route (OpenFAST, FAST.Farm, mixed EI = 0 / finite-EI decks) neither checkpoints its shedding + ! phase nor feeds it the host's fluid field yet. IF (ANY(types%cl > CD_ZERO)) THEN - CALL fail(ErrStat, ErrMsg, 'VIV (LINE TYPES Cl > 0) runs in the standalone driver of an EI = 0 deck; '// & + CALL fail(ErrStat, ErrMsg, 'VIV (LINE TYPES Cl > 0) runs in the standalone driver of an EI = 0 or '// & + 'finite-EI deck; '// & 'the coupled OpenFAST and FAST.Farm routes and mixed EI = 0 / finite-EI decks do not carry it '// & 'yet. Set Cl = 0 for this run') RETURN @@ -8054,16 +8081,26 @@ SUBROUTINE run_deck_driver(deck_path, out_root, converged, ErrStat, ErrMsg) ! dynamic deck, including flat/structured contact, damping, friction, motion, ! and deck-owned fluid fields. The compatibility route remains only for the ! two-moving-end topology that the HFMF boundary cannot represent. + IF (.NOT. hermite_standalone_eligible) THEN + DO li = 1, SIZE(lines) + IF (.NOT. line_has_viv(lines(li), types, sections)) CYCLE + IF (opts%has_bathymetry_file) CALL CD_End_Bathymetry(bathymetry) + CALL fail(ErrStat, ErrMsg, 'VIV (LINE TYPES Cl > 0) of a finite-EI line needs its End B fixed '// & + '(the cubic-Hermite march); set Cl = 0 for a line with two moving ends') + RETURN + END DO + END IF IF (hermite_standalone_eligible) THEN ALLOCATE (hermite_models(SIZE(lines))) DO li = 1, SIZE(lines) IF (opts%has_bathymetry_file) THEN CALL build_one_hermite_cable(lines(li), sections, types, points, opts, opts%dtM, & hermite_models(li), j, ErrStat, ErrMsg, standalone_controls=.TRUE., & - bathymetry=bathymetry) + bathymetry=bathymetry, install_viv=.TRUE.) ELSE CALL build_one_hermite_cable(lines(li), sections, types, points, opts, opts%dtM, & - hermite_models(li), j, ErrStat, ErrMsg, standalone_controls=.TRUE.) + hermite_models(li), j, ErrStat, ErrMsg, standalone_controls=.TRUE., & + install_viv=.TRUE.) END IF IF (ErrStat /= CD_DECKDRV_OK) EXIT END DO @@ -9289,6 +9326,45 @@ SUBROUTINE finite_hydro_arrays(ln, sections, types, diam, cdn, cdt, can, cat) cat = cat(SIZE(cat):1:-1) END SUBROUTINE finite_hydro_arrays + SUBROUTINE finite_viv_arrays(ln, sections, types, cl, cf, df) + !! Expand the section VIV columns (Cl dF cF) to finite-EI element arrays, in the element + !! order of finite_hydro_arrays. + TYPE(DeckLine), INTENT(IN) :: ln + TYPE(DeckSection), INTENT(IN) :: sections(:) + TYPE(DeckLineType), INTENT(IN) :: types(:) + REAL(wp), INTENT(OUT) :: cl(:), cf(:), df(:) + INTEGER :: i, j, e, tidx + + e = 0 + DO i = 1, SIZE(sections) + IF (sections(i)%line_id /= ln%id) CYCLE + tidx = sections(i)%ltype + DO j = 1, sections(i)%nsegs + e = e + 1 + cl(e) = types(tidx)%cl + cf(e) = types(tidx)%viv_cf + df(e) = types(tidx)%viv_df + END DO + END DO + cl = cl(SIZE(cl):1:-1) + cf = cf(SIZE(cf):1:-1) + df = df(SIZE(df):1:-1) + END SUBROUTINE finite_viv_arrays + + LOGICAL FUNCTION line_has_viv(ln, types, sections) RESULT(has) + !! Whether a section of the line uses a line type with a VIV lift coefficient Cl > 0. + TYPE(DeckLine), INTENT(IN) :: ln + TYPE(DeckLineType), INTENT(IN) :: types(:) + TYPE(DeckSection), INTENT(IN) :: sections(:) + INTEGER :: j + has = .FALSE. + DO j = 1, SIZE(sections) + IF (sections(j)%line_id /= ln%id) CYCLE + IF (sections(j)%ltype < 1 .OR. sections(j)%ltype > SIZE(types)) CYCLE + IF (types(sections(j)%ltype)%cl > CD_ZERO) has = .TRUE. + END DO + END FUNCTION line_has_viv + SUBROUTINE CD_Stiffener_Overlay(stf, l0, diam, ei, mpl) !! Add the bend stiffeners of a finite-EI line (ln%stf columns) to its element properties, !! in public element order (End A first). A stiffener is a polyurethane sleeve bonded to the @@ -12653,7 +12729,7 @@ END SUBROUTINE append_type SUBROUTINE check_viv_columns(t, ErrStat, ErrMsg) !! The VIV columns of a LINE TYPES row: a finite, non-negative Cl; with Cl > 0 a positive - !! shedding frequency band (cF > 0, 0 <= dF < cF) on an EI = 0, non-Syrope line type. + !! shedding frequency band (cF > 0, 0 <= dF < cF) on a non-Syrope line type. TYPE(DeckLineType), INTENT(IN) :: t INTEGER, INTENT(OUT) :: ErrStat CHARACTER(*), INTENT(OUT) :: ErrMsg @@ -12668,10 +12744,6 @@ SUBROUTINE check_viv_columns(t, ErrStat, ErrMsg) IF (.NOT. (t%viv_cf > CD_ZERO .AND. t%viv_df >= CD_ZERO .AND. t%viv_df < t%viv_cf)) THEN CALL fail(ErrStat, ErrMsg, 'LINE TYPES VIV synchronisation band needs cF > 0 and 0 <= dF < cF'); RETURN END IF - IF (t%ei > CD_ZERO) THEN - CALL fail(ErrStat, ErrMsg, 'LINE TYPES "'//TRIM(t%name)//'": VIV (Cl > 0) is implemented for EI = 0 '// & - 'line types only; set EI = 0 or Cl = 0 (VIV of finite-EI cables is not available)'); RETURN - END IF IF (t%is_syrope) THEN CALL fail(ErrStat, ErrMsg, 'LINE TYPES "'//TRIM(t%name)//'": VIV (Cl > 0) does not combine with the '// & 'Syrope working-curve model'); RETURN @@ -19542,6 +19614,11 @@ SUBROUTINE write_multibody_dynamic_out(deck_path, out_root, channels, types, bod pc = points pa = find_point(points, cab_lines(c)%nodeA) IF (TRIM(pc(pa)%ptype) /= 'fixed') pc(pa)%ptype = 'coupled' + IF (line_has_viv(cab_lines(c), types, sections)) THEN + CALL fail(ErrStat, ErrMsg, 'VIV (LINE TYPES Cl > 0) of a finite-EI line does not run with bodies, rods '// & + 'or free points yet; set Cl = 0 for the finite-EI lines of this deck') + GOTO 900 + END IF mb%cab_clamp(c) = (cab_lines(c)%endconn_mode(1) /= CD_ENDCONN_PINNED .OR. line_torsion_active(cab_lines(c))) & .AND. TRIM(points(pa)%ptype) /= 'fixed' IF (mb%cab_clamp(c)) THEN diff --git a/src/CableDyn_HermiteCableDynamic.f90 b/src/CableDyn_HermiteCableDynamic.f90 index 60bcb3ad..1d6682df 100644 --- a/src/CableDyn_HermiteCableDynamic.f90 +++ b/src/CableDyn_HermiteCableDynamic.f90 @@ -63,6 +63,8 @@ MODULE CableDyn_HermiteCableDynamic CD_HermiteCable_Axial_Strain_Lower_Bound, CD_HermiteCable_Dry_Buoyancy, & CD_HCABLE_OK USE CableDyn_Linalg, ONLY: CD_Factor_Banded, CD_Solve_Factored_Banded, CD_LINALG_OK + USE CableDyn_VIV, ONLY: CD_VIV_Lift_Per_Length, CD_VIV_Crossflow_Along, CD_VIV_Phase_Rate, CD_VIV_Mean_Square, & + CD_VIV_Wrap_Phase, CD_VIV_TWO_PI, CD_VIV_NM USE CableDyn_Hydro, ONLY: CD_Morison_Drag_Per_Length_Jac, CD_Airy_Wave_Kinematics_Precomputed, & CD_Component_Wave_Kinematics, CD_Solve_Dispersion_Wavenumber, CD_HYDRO_OK USE CableDyn_SeabedContact, ONLY: CD_Seabed_Normal_Law, CD_Seabed_Contact_Gate, CD_SEABED_CONTACT_BLEND, & @@ -121,6 +123,7 @@ MODULE CableDyn_HermiteCableDynamic PUBLIC :: CD_HermiteCable_Dyn_Snapshot PUBLIC :: CD_HermiteCable_Dyn_Set_Friction_Anchors PUBLIC :: CD_HermiteCable_Dyn_Set_Friction_Axial + PUBLIC :: CD_HermiteCable_Dyn_Set_VIV PUBLIC :: CD_HermiteCable_Dyn_Restore PUBLIC :: CD_HermiteCable_Dyn_Energy PUBLIC :: CD_HermiteCable_Dyn_Curvature @@ -269,6 +272,18 @@ MODULE CableDyn_HermiteCableDynamic ! the recovering step, snap_fr_anchor the aggregate snapshot. LOGICAL :: fr_active = .FALSE. REAL(wp), ALLOCATABLE :: fr_anchor(:, :), fr_k(:), ws_recovery_fr(:, :), snap_fr_anchor(:, :) + ! Cross-flow VIV (CD_HermiteCable_Dyn_Set_VIV, CableDyn_VIV): viv_k(e) = 1/2 rho D Cl of each + ! element (0: no lift), the synchronisation band and diameter per node, the shedding phase + ! and the running mean squares of the cross-flow velocity and acceleration per node. The lift + ! of a step takes viv_phi_eval (the committed phase for F_n, the step's predicted phase in + ! the Newton iterations); viv_rate/viv_ms_next hold the step-start rate and mean squares. + ! ws_recovery_viv_* is the step-start copy of the recovering step, snap_viv_* the snapshot. + LOGICAL :: has_viv = .FALSE. + REAL(wp) :: viv_tw = CD_ZERO + REAL(wp), ALLOCATABLE :: viv_cl(:), viv_k(:), viv_cf(:), viv_df(:), viv_dn(:), viv_phi(:), viv_phi_eval(:) + REAL(wp), ALLOCATABLE :: viv_rate(:), viv_ms(:, :), viv_ms_next(:, :) + REAL(wp), ALLOCATABLE :: ws_recovery_viv_phi(:), ws_recovery_viv_ms(:, :), snap_viv_phi(:), snap_viv_ms(:, :) + LOGICAL, ALLOCATABLE :: viv_node(:) REAL(wp), ALLOCATABLE :: Mgb(:, :) ! constant global mass (band) LOGICAL, ALLOCATABLE :: freemask(:), solve_mask(:) INTEGER, ALLOCATABLE :: fmap(:) ! free -> global DOF index @@ -950,6 +965,299 @@ SUBROUTINE CD_HermiteCable_Dyn_Set_Friction_Axial(model, mu_axial, ErrStat, ErrM model%tr_valid = .FALSE. END SUBROUTINE CD_HermiteCable_Dyn_Set_Friction_Axial + SUBROUTINE CD_HermiteCable_Dyn_Set_VIV(model, cl, cf, df, t_window, ErrStat, ErrMsg) + !! 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 + !! wetted Gauss points of every element with cl > 0, its phase lives on the nodes of those + !! elements; the phases start at 2 pi i/N with node i counted from End A (the model's last + !! node), as MoorDyn's. The phase follows the drag's current and a held host field (which + !! carries any waves); the internal wave families (Set_Waves) are refused with VIV. The + !! committed acceleration is refreshed with the new lift; if that fails, the previous VIV + !! configuration, its state and the acceleration are restored. + TYPE(CD_HermiteCableDynType), INTENT(INOUT) :: model + REAL(wp), INTENT(IN) :: cl(:), cf(:), df(:), t_window + INTEGER, INTENT(OUT) :: ErrStat + CHARACTER(*), INTENT(OUT) :: ErrMsg + INTEGER :: e, k, ne, nn, es + REAL(wp) :: wsum, tw_old + LOGICAL :: had_viv + CHARACTER(LEN=1024) :: em + REAL(wp), ALLOCATABLE :: a_old(:), o_cl(:), o_k(:), o_cf(:), o_df(:), o_dn(:), o_phi(:), o_phi_eval(:), & + o_rate(:), o_ms(:, :), o_ms_next(:, :), o_rec_phi(:), o_rec_ms(:, :), & + o_snap_phi(:), o_snap_ms(:, :) + LOGICAL, ALLOCATABLE :: o_node(:) + + ErrStat = CD_HCDYN_OK; ErrMsg = '' + IF (.NOT. model%initialized) THEN + ErrStat = CD_HCDYN_BADINPUT; ErrMsg = 'CD_HermiteCable_Dyn_Set_VIV: model not initialised'; RETURN + END IF + ne = model%ne + nn = model%nn + IF (SIZE(cl) /= ne .OR. SIZE(cf) /= ne .OR. SIZE(df) /= ne) THEN + ErrStat = CD_HCDYN_BADINPUT + ErrMsg = 'CD_HermiteCable_Dyn_Set_VIV: cl, cf and df must each have one value per element'; RETURN + END IF + IF (.NOT. (CD_All_Finite(cl) .AND. CD_All_Finite(cf) .AND. CD_All_Finite(df) .AND. & + CD_Is_Finite(t_window))) THEN + ErrStat = CD_HCDYN_BADINPUT; ErrMsg = 'CD_HermiteCable_Dyn_Set_VIV: inputs must be finite'; RETURN + END IF + IF (ANY(cl < CD_ZERO) .OR. t_window < CD_ZERO .OR. & + ANY(cl > CD_ZERO .AND. .NOT. (cf > CD_ZERO .AND. df >= CD_ZERO .AND. df < cf))) THEN + ErrStat = CD_HCDYN_BADINPUT + ErrMsg = 'CD_HermiteCable_Dyn_Set_VIV: need cl >= 0, t_window >= 0 and 0 <= df < cf where cl > 0' + RETURN + END IF + IF (.NOT. model%has_drag) THEN + ErrStat = CD_HCDYN_BADINPUT + ErrMsg = 'CD_HermiteCable_Dyn_Set_VIV: VIV needs the cable''s drag in water (set the drag first)'; RETURN + END IF + IF (model%has_wave) THEN + ErrStat = CD_HCDYN_BADINPUT + ErrMsg = 'CD_HermiteCable_Dyn_Set_VIV: internal waves are configured; VIV takes waves as a held '// & + 'host fluid field (CD_HermiteCable_Dyn_Set_Held_Fluid)'; RETURN + END IF + ! the previous configuration and state, kept for a rollback + had_viv = model%has_viv + tw_old = model%viv_tw + a_old = model%a + CALL move_viv(.FALSE.) + CALL clear_viv(model) + model%rc_epoch = model%rc_epoch + 1 + model%fc_valid = .FALSE. + model%fc_clears = model%fc_clears + 1 + model%tr_valid = .FALSE. + IF (.NOT. ANY(cl > CD_ZERO)) THEN + IF (had_viv) CALL refresh_acceleration() + RETURN + END IF + 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(2, nn), model%viv_ms_next(2, nn), & + model%ws_recovery_viv_phi(nn), model%ws_recovery_viv_ms(2, nn), model%snap_viv_phi(nn), & + model%snap_viv_ms(2, nn), model%viv_node(nn)) + model%viv_cl = cl + model%viv_cf = CD_ZERO + model%viv_df = CD_ZERO + model%viv_node = .FALSE. + model%viv_phi = CD_ZERO + model%viv_ms = CD_ZERO + ! node values: the length-weighted average over the node's lifting elements + DO k = 1, nn + 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_cf(k) = model%viv_cf(k) + model%l0(e)*cf(e) + model%viv_df(k) = model%viv_df(k) + model%l0(e)*df(e) + END DO + IF (.NOT. (wsum > CD_ZERO)) CYCLE + model%viv_node(k) = .TRUE. + model%viv_cf(k) = model%viv_cf(k)/wsum + model%viv_df(k) = model%viv_df(k)/wsum + model%viv_phi(k) = CD_VIV_TWO_PI*REAL(nn - k, wp)/REAL(ne, wp) + END DO + CALL viv_drag_terms(model) + model%viv_phi_eval = model%viv_phi + model%viv_rate = CD_ZERO + model%viv_ms_next = model%viv_ms + model%ws_recovery_viv_phi = model%viv_phi + model%ws_recovery_viv_ms = model%viv_ms + model%snap_viv_phi = model%viv_phi + model%snap_viv_ms = model%viv_ms + model%viv_tw = t_window + model%has_viv = .TRUE. + ! the lift is part of the committed load: the first step's predictor and phase rate need it + CALL refresh_acceleration() + + CONTAINS + SUBROUTINE refresh_acceleration() + CALL solve_consistent_acceleration(model, es, em) + IF (es == CD_HCDYN_OK) RETURN + CALL clear_viv(model) + CALL move_viv(.TRUE.) + model%has_viv = had_viv + model%viv_tw = tw_old + model%a = a_old + ErrStat = es + ErrMsg = 'CD_HermiteCable_Dyn_Set_VIV: acceleration refresh failed: '//TRIM(em) + END SUBROUTINE refresh_acceleration + + SUBROUTINE move_viv(back) + !! Move the VIV arrays from the model into the o_ copies (back = .FALSE.) or back. + LOGICAL, INTENT(IN) :: back + IF (back) THEN + CALL MOVE_ALLOC(o_cl, model%viv_cl); CALL MOVE_ALLOC(o_k, model%viv_k) + CALL MOVE_ALLOC(o_cf, model%viv_cf); CALL MOVE_ALLOC(o_df, model%viv_df) + CALL MOVE_ALLOC(o_dn, model%viv_dn); CALL MOVE_ALLOC(o_phi, model%viv_phi) + CALL MOVE_ALLOC(o_phi_eval, model%viv_phi_eval); CALL MOVE_ALLOC(o_rate, model%viv_rate) + CALL MOVE_ALLOC(o_ms, model%viv_ms); CALL MOVE_ALLOC(o_ms_next, model%viv_ms_next) + CALL MOVE_ALLOC(o_rec_phi, model%ws_recovery_viv_phi); CALL MOVE_ALLOC(o_rec_ms, model%ws_recovery_viv_ms) + CALL MOVE_ALLOC(o_snap_phi, model%snap_viv_phi); CALL MOVE_ALLOC(o_snap_ms, model%snap_viv_ms) + CALL MOVE_ALLOC(o_node, model%viv_node) + 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) + CALL MOVE_ALLOC(model%viv_dn, o_dn); CALL MOVE_ALLOC(model%viv_phi, o_phi) + CALL MOVE_ALLOC(model%viv_phi_eval, o_phi_eval); CALL MOVE_ALLOC(model%viv_rate, o_rate) + CALL MOVE_ALLOC(model%viv_ms, o_ms); CALL MOVE_ALLOC(model%viv_ms_next, o_ms_next) + CALL MOVE_ALLOC(model%ws_recovery_viv_phi, o_rec_phi); CALL MOVE_ALLOC(model%ws_recovery_viv_ms, o_rec_ms) + CALL MOVE_ALLOC(model%snap_viv_phi, o_snap_phi); CALL MOVE_ALLOC(model%snap_viv_ms, o_snap_ms) + CALL MOVE_ALLOC(model%viv_node, o_node) + END IF + END SUBROUTINE move_viv + END SUBROUTINE CD_HermiteCable_Dyn_Set_VIV + + SUBROUTINE clear_viv(model) + !! Release the VIV storage; the model then carries no lift. + TYPE(CD_HermiteCableDynType), INTENT(INOUT) :: model + IF (ALLOCATED(model%viv_k)) DEALLOCATE (model%viv_cl, model%viv_k) + IF (ALLOCATED(model%viv_cf)) DEALLOCATE (model%viv_cf, model%viv_df, model%viv_dn, model%viv_phi, & + model%viv_phi_eval, model%viv_rate, model%viv_ms, & + model%viv_ms_next, model%ws_recovery_viv_phi, & + model%ws_recovery_viv_ms, model%snap_viv_phi, model%snap_viv_ms, & + model%viv_node) + model%has_viv = .FALSE. + model%viv_tw = CD_ZERO + END SUBROUTINE clear_viv + + SUBROUTINE viv_drag_terms(model) + !! The VIV quantities taken from the drag configuration, set with VIV and again whenever the + !! drag is reconfigured: the lift scale viv_k = 1/2 rho D Cl of each element and the node + !! diameter viv_dn, the length-weighted average over the node's lifting elements. + TYPE(CD_HermiteCableDynType), INTENT(INOUT) :: model + INTEGER :: e, k + REAL(wp) :: wsum + model%viv_k = 0.5_wp*model%rho_w*model%diam*model%viv_cl + model%viv_dn = CD_ZERO + DO k = 1, model%nn + IF (.NOT. model%viv_node(k)) CYCLE + wsum = CD_ZERO + DO e = MAX(1, k - 1), MIN(model%ne, k) + IF (.NOT. (model%viv_cl(e) > CD_ZERO)) CYCLE + wsum = wsum + model%l0(e) + model%viv_dn(k) = model%viv_dn(k) + model%l0(e)*model%diam(e) + END DO + model%viv_dn(k) = model%viv_dn(k)/wsum + END DO + END SUBROUTINE viv_drag_terms + + SUBROUTINE viv_node_motion(model, k, yd, ydd, un, ok) + !! 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). + TYPE(CD_HermiteCableDynType), INTENT(IN) :: model + INTEGER, INTENT(IN) :: k + REAL(wp), INTENT(OUT) :: yd, ydd, un + LOGICAL, INTENT(OUT) :: ok + REAL(wp) :: uu(3) + INTEGER :: i0 + i0 = 6*(k - 1) + uu = model%current + IF (model%has_held_field) uu = uu + model%hf_u(:, k) + CALL CD_VIV_Crossflow_Along(model%q(i0 + 4:i0 + 6), model%v(i0 + 1:i0 + 3), model%a(i0 + 1:i0 + 3), uu, & + yd, ydd, un, ok) + END SUBROUTINE viv_node_motion + + SUBROUTINE viv_step_begin(model, dt, ErrStat, ErrMsg) + !! Step-start VIV quantities from the committed state (q, v, a, phi): the mean squares with + !! the step-start cross-flow sample (viv_ms_next), the phase rate (viv_rate) and the phase the + !! step's lift takes (viv_phi_eval): the explicit phase at t_{n+1} under the force blend, + !! whose in-step force is R(q_{n+1}, v_{n+1}) (F_n keeps phi_n), and at the generalised-alpha + !! level under the configuration blend. + TYPE(CD_HermiteCableDynType), INTENT(INOUT) :: model + REAL(wp), INTENT(IN) :: dt + INTEGER, INTENT(OUT) :: ErrStat + CHARACTER(*), INTENT(OUT) :: ErrMsg + INTEGER :: k + REAL(wp) :: w, frac, yd, ydd, un + LOGICAL :: ok + ErrStat = CD_HCDYN_OK; ErrMsg = '' + IF (.NOT. (model%viv_tw > CD_ZERO)) model%viv_tw = REAL(CD_VIV_NM, wp)*dt + w = MIN(CD_ONE, dt/model%viv_tw) + frac = CD_ONE + IF (.NOT. model%force_blend) frac = CD_ONE - model%alpha_f + model%viv_rate = CD_ZERO + model%viv_ms_next = model%viv_ms + model%viv_phi_eval = model%viv_phi + DO k = 1, model%nn + IF (.NOT. model%viv_node(k)) CYCLE + CALL viv_node_motion(model, k, yd, ydd, un, ok) + IF (.NOT. ok) THEN + ErrStat = CD_HCDYN_NOCONVERGE; ErrMsg = 'VIV phase: degenerate node tangent'; RETURN + END IF + model%viv_ms_next(1, k) = CD_VIV_Mean_Square(model%viv_ms(1, k), yd, w) + model%viv_ms_next(2, k) = CD_VIV_Mean_Square(model%viv_ms(2, k), ydd, w) + model%viv_rate(k) = CD_VIV_Phase_Rate(yd, ydd, model%viv_ms_next(1, k), model%viv_ms_next(2, k), & + model%viv_phi(k), un, model%viv_dn(k), model%viv_cf(k), & + model%viv_df(k)) + model%viv_phi_eval(k) = model%viv_phi(k) + frac*dt*model%viv_rate(k) + END DO + END SUBROUTINE viv_step_begin + + SUBROUTINE viv_step_end(model, dt) + !! Commit the VIV state at the converged end state (q, v, a just committed): the phase by + !! Heun's rule phi_n + dt/2 (rate_n + rate(state_n+1, phi_n + dt rate_n)), with the end-state + !! sample added to the mean squares for that rate only, and the step-start mean squares. The + !! lift then takes the committed phase again. It cannot fail, so the step it ends is never + !! left half committed: a node whose end tangent is degenerate, or whose end rate is not + !! finite, takes the step-start rate over the step (phi_n + dt rate_n). + TYPE(CD_HermiteCableDynType), INTENT(INOUT) :: model + REAL(wp), INTENT(IN) :: dt + INTEGER :: k + REAL(wp) :: w, yd, ydd, un, ms1, ms2, rate_end + LOGICAL :: ok + w = MIN(CD_ONE, dt/model%viv_tw) + DO k = 1, model%nn + IF (.NOT. model%viv_node(k)) CYCLE + rate_end = model%viv_rate(k) + CALL viv_node_motion(model, k, yd, ydd, un, ok) + IF (ok) THEN + ms1 = CD_VIV_Mean_Square(model%viv_ms_next(1, k), yd, w) + ms2 = CD_VIV_Mean_Square(model%viv_ms_next(2, k), ydd, w) + rate_end = CD_VIV_Phase_Rate(yd, ydd, ms1, ms2, model%viv_phi(k) + dt*model%viv_rate(k), un, & + model%viv_dn(k), model%viv_cf(k), model%viv_df(k)) + IF (.NOT. CD_Is_Finite(rate_end)) rate_end = model%viv_rate(k) + END IF + model%viv_phi(k) = CD_VIV_Wrap_Phase(model%viv_phi(k) + 0.5_wp*dt*(model%viv_rate(k) + rate_end)) + END DO + model%viv_ms = model%viv_ms_next + model%viv_phi_eval = model%viv_phi + END SUBROUTINE viv_step_end + + SUBROUTINE viv_element_lift(model, q_cfg, v_cfg, e, flift, ErrStat, ErrMsg, djq, djv) + !! The VIV lift load of element e at the phase viv_phi_eval in the flow the drag sees (current, + !! held field), with its Jacobians djq, djv (both or neither). + TYPE(CD_HermiteCableDynType), INTENT(IN) :: model + REAL(wp), INTENT(IN) :: q_cfg(:), v_cfg(:) + INTEGER, INTENT(IN) :: e + REAL(wp), INTENT(OUT) :: flift(12) + INTEGER, INTENT(OUT) :: ErrStat + CHARACTER(*), INTENT(OUT) :: ErrMsg + REAL(wp), INTENT(OUT), OPTIONAL :: djq(12, 12), djv(12, 12) + REAL(wp) :: qe(12), ve(12), uu(3), wl, kn(2) + flift = CD_ZERO + IF (PRESENT(djq)) THEN + djq = CD_ZERO; djv = CD_ZERO + END IF + ErrStat = CD_HCDYN_OK; ErrMsg = '' + IF (.NOT. (model%viv_k(e) > CD_ZERO)) RETURN + qe(1:6) = q_cfg(6*(e - 1) + 1:6*e); qe(7:12) = q_cfg(6*e + 1:6*(e + 1)) + ve(1:6) = v_cfg(6*(e - 1) + 1:6*e); ve(7:12) = v_cfg(6*e + 1:6*(e + 1)) + uu = model%current + wl = model%waterline_z + IF (model%has_held_field) THEN + uu = uu + 0.5_wp*(model%hf_u(:, e) + model%hf_u(:, e + 1)) + wl = 0.5_wp*(model%hf_wl(e) + model%hf_wl(e + 1)) + END IF + kn = model%viv_k(e)*[COS(model%viv_phi_eval(e)), COS(model%viv_phi_eval(e + 1))] + IF (PRESENT(djq)) THEN + CALL CD_HermiteCable_VIV_Lift_Element(qe, ve, model%l0(e), uu, wl, kn, flift, djq, djv, ErrStat, ErrMsg) + ELSE + CALL CD_HermiteCable_VIV_Lift_Element(qe, ve, model%l0(e), uu, wl, kn, flift, ErrStat=ErrStat, & + ErrMsg=ErrMsg) + END IF + END SUBROUTINE viv_element_lift + SUBROUTINE CD_HermiteCable_Dyn_Set_Friction_Anchors(model, anchors, ErrStat, ErrMsg) !! Switch the seabed friction of a contact model with mu > 0 to elastic-plastic friction !! springs anchored at anchors(1:2, node) (x, y in the solve frame). The spring stiffness @@ -2380,6 +2688,8 @@ SUBROUTINE CD_HermiteCable_Dyn_Set_Drag(model, rho_w, diam, cdn, cdt, waterline_ model%rho_w = rho_w; model%waterline_z = waterline_z; model%current = current model%gravity = grav_new model%has_drag = .TRUE. + ! the lift scale and the shedding diameter follow the drag's density and diameters + IF (model%has_viv) CALL viv_drag_terms(model) ! Refresh the consistent acceleration now that the load set includes drag: at v = 0 a current ! exerts a non-zero rest drag, so the predictor for the first step must see it. @@ -2395,6 +2705,8 @@ SUBROUTINE CD_HermiteCable_Dyn_Set_Drag(model, rho_w, diam, cdn, cdt, waterline_ DEALLOCATE (model%diam, model%cdn, model%cdt) END IF model%has_drag = had_drag + ! VIV needs drag, so a VIV model had it: back to the restored configuration + IF (model%has_viv) CALL viv_drag_terms(model) END IF END SUBROUTINE CD_HermiteCable_Dyn_Set_Drag @@ -2593,6 +2905,11 @@ SUBROUTINE CD_HermiteCable_Dyn_Set_Waves(model, height, period, direction_deg, d IF (.NOT. model%initialized) THEN ErrStat = CD_HCDYN_BADINPUT; ErrMsg = 'CD_HermiteCable_Dyn_Set_Waves: model not initialised'; RETURN END IF + IF (model%has_viv) THEN + ErrStat = CD_HCDYN_BADINPUT + ErrMsg = 'CD_HermiteCable_Dyn_Set_Waves: VIV is configured; its phase follows the current and a held host '// & + 'fluid field, so waves reach a VIV cable as a held field'; RETURN + END IF IF (model%has_held_field) THEN ErrStat = CD_HCDYN_BADINPUT ErrMsg = 'CD_HermiteCable_Dyn_Set_Waves: a held host fluid field is configured; an internal '// & @@ -2715,6 +3032,11 @@ SUBROUTINE CD_HermiteCable_Dyn_Set_Irregular_Waves(model, amplitude, period, pha ErrStat = CD_HCDYN_BADINPUT ErrMsg = 'CD_HermiteCable_Dyn_Set_Irregular_Waves: model not initialised'; RETURN END IF + IF (model%has_viv) THEN + ErrStat = CD_HCDYN_BADINPUT + ErrMsg = 'CD_HermiteCable_Dyn_Set_Irregular_Waves: VIV is configured; its phase follows the current and a held host '// & + 'fluid field, so waves reach a VIV cable as a held field'; RETURN + END IF IF (model%has_held_field) THEN ErrStat = CD_HCDYN_BADINPUT ErrMsg = 'CD_HermiteCable_Dyn_Set_Irregular_Waves: a held host fluid field is configured; '// & @@ -3038,6 +3360,8 @@ SUBROUTINE CD_HermiteCable_Dyn_Step(model, dt, max_iter, tol, ErrStat, ErrMsg, i pres_a, residual_history, history_count, endconn_direction, endconn_direction_rate, & endconn_direction_acceleration, tensile_failed) model%tors_use_step = .FALSE. + ! every evaluation outside a step takes the committed VIV phase + IF (model%has_viv) model%viv_phi_eval = model%viv_phi END SUBROUTINE CD_HermiteCable_Dyn_Step SUBROUTINE CD_HermiteCable_Dyn_Set_Torsion_Drive(model, ends, phi, ErrStat, ErrMsg) @@ -3392,6 +3716,13 @@ SUBROUTINE dyn_step_core(model, dt, max_iter, tol, ErrStat, ErrMsg, iters_out, r model%fc_d0 = model%endconn_d0 model%fc_valid = .TRUE. END IF + ! VIV: F_n above took the committed phase; the step's evaluations take its predicted phase. + IF (model%has_viv) THEN + CALL viv_step_begin(model, dt, es, em2) + IF (es /= CD_HCDYN_OK) THEN + ErrStat = es; ErrMsg = 'CD_HermiteCable_Dyn_Step: '//TRIM(em2); RETURN + END IF + END IF ! Condensed torsion: F_n above used the committed end frames and Phi; every evaluation of the ! step from here on uses the step's target (set by CD_HermiteCable_Dyn_Step). model%tors_use_step = model%torsion%active @@ -4000,6 +4331,7 @@ SUBROUTINE dyn_step_core(model, dt, max_iter, tol, ErrStat, ErrMsg, iters_out, r END IF IF (has_endconn_motion) CALL impose_step_rigid_kinematics(model%q, model%v, model%a) IF (model%fr_active) CALL commit_friction_anchors(model) + IF (model%has_viv) CALL viv_step_end(model, dt) model%t = model%t + dt IF (has_endconn_motion) model%endconn_d0 = step_endconn_target IF (model%torsion%active) THEN @@ -4031,8 +4363,11 @@ SUBROUTINE dyn_step_core(model, dt, max_iter, tol, ErrStat, ErrMsg, iters_out, r END IF model%tr_dt = dt ! The converged iterate's unblended force is F at the committed state: cache it, keyed - ! on that state, as the next step's F_n. - IF (model%force_blend) THEN + ! on that state, as the next step's F_n. With VIV it took the step's predicted phase, not + ! the committed one, so the next step evaluates F_n afresh. + IF (model%has_viv) THEN + model%fc_valid = .FALSE. + ELSE IF (model%force_blend) THEN DO iv = 1, SIZE(model%fc_R) model%fc_R(iv) = model%ws_Rk(iv) END DO @@ -4573,6 +4908,10 @@ SUBROUTINE CD_HermiteCable_Dyn_Step_Recovering(model, dt, max_iter, tol, ErrStat model%ws_recovery_v0 = model%v model%ws_recovery_a0 = model%a IF (model%fr_active) model%ws_recovery_fr = model%fr_anchor + IF (model%has_viv) THEN + model%ws_recovery_viv_phi = model%viv_phi + model%ws_recovery_viv_ms = model%viv_ms + END IF IF (model%has_ctrl) THEN model%ws_recovery_l0_c = model%l0_c model%ws_recovery_l0_dot_c = model%l0_dot_c @@ -4664,6 +5003,10 @@ SUBROUTINE CD_HermiteCable_Dyn_Step_Recovering(model, dt, max_iter, tol, ErrStat model%q = q_save; model%v = v_save; model%a = a_save; model%t = t_save model%endconn_d0 = d0_save IF (model%fr_active) model%fr_anchor = model%ws_recovery_fr + IF (model%has_viv) THEN + model%viv_phi = model%ws_recovery_viv_phi; model%viv_ms = model%ws_recovery_viv_ms + model%viv_phi_eval = model%viv_phi + END IF IF (model%has_ctrl) model%l0_c = model%ws_recovery_l0_c IF (model%has_ctrl) model%l0_dot_c = model%ws_recovery_l0_dot_c model%na_steps_done = na_steps_save; model%na_iter_sum = na_sum_save; model%na_mn_active = na_mn_save @@ -4740,6 +5083,10 @@ SUBROUTINE CD_HermiteCable_Dyn_Step_Recovering(model, dt, max_iter, tol, ErrStat model%q = q_save; model%v = v_save; model%a = a_save; model%t = t_save model%endconn_d0 = d0_save IF (model%fr_active) model%fr_anchor = model%ws_recovery_fr + IF (model%has_viv) THEN + model%viv_phi = model%ws_recovery_viv_phi; model%viv_ms = model%ws_recovery_viv_ms + model%viv_phi_eval = model%viv_phi + END IF IF (model%has_ctrl) model%l0_c = model%ws_recovery_l0_c IF (model%has_ctrl) model%l0_dot_c = model%ws_recovery_l0_dot_c model%na_steps_done = na_steps_save @@ -4784,6 +5131,10 @@ SUBROUTINE CD_HermiteCable_Dyn_Step_Recovering(model, dt, max_iter, tol, ErrStat model%q = q_save; model%v = v_save; model%a = a_save; model%t = t_save model%endconn_d0 = d0_save IF (model%fr_active) model%fr_anchor = model%ws_recovery_fr + IF (model%has_viv) THEN + model%viv_phi = model%ws_recovery_viv_phi; model%viv_ms = model%ws_recovery_viv_ms + model%viv_phi_eval = model%viv_phi + END IF IF (model%has_ctrl) model%l0_c = model%ws_recovery_l0_c IF (model%has_ctrl) model%l0_dot_c = model%ws_recovery_l0_dot_c model%na_steps_done = na_steps_save; model%na_iter_sum = na_sum_save; model%na_mn_active = na_mn_save @@ -5427,6 +5778,13 @@ SUBROUTINE CD_HermiteCable_Dyn_End_Force(model, node, force, ErrStat, ErrMsg) END IF r3 = r3 - fdrag(i0 + 1:i0 + 3) END IF + IF (model%has_viv) THEN + CALL viv_element_lift(model, model%q, model%v, e, fdrag, es, em2) + IF (es /= CD_HCDYN_OK) THEN + ErrStat = es; ErrMsg = 'CD_HermiteCable_Dyn_End_Force: '//TRIM(em2); RETURN + END IF + r3 = r3 - fdrag(i0 + 1:i0 + 3) + END IF IF (model%has_attach) THEN ! A clump or buoy on the end node loads the point holding it, exactly as it loads the ! end node in the residual (assemble_attachments). @@ -5908,6 +6266,11 @@ SUBROUTINE element_end_residual(model, e, g, ErrStat, ErrMsg) IF (es /= CD_HCDYN_OK) GOTO 900 g = g - fx END IF + IF (model%has_viv) THEN + CALL viv_element_lift(model, model%q, model%v, e, fx, es, em2) + IF (es /= CD_HCDYN_OK) GOTO 900 + g = g - fx + END IF IF (model%has_am .AND. (model%has_wave .OR. model%has_held_field)) THEN IF (model%has_held_field) THEN hf_mid = 0.5_wp*(model%hf_ud(:, e) + model%hf_ud(:, e + 1)) @@ -6485,6 +6848,10 @@ SUBROUTINE CD_HermiteCable_Dyn_Snapshot(model, ErrStat, ErrMsg) model%snap_torsion_phi = model%torsion%phi model%snap_torsion_ends = model%torsion%ends IF (model%fr_active) model%snap_fr_anchor = model%fr_anchor + IF (model%has_viv) THEN + model%snap_viv_phi = model%viv_phi + model%snap_viv_ms = model%viv_ms + END IF ! the cached committed force goes with the state it describes (see fc_clears) model%snap_fc_valid = model%fc_valid .AND. ALLOCATED(model%fc_R) model%snap_fc_clears = model%fc_clears @@ -6562,6 +6929,10 @@ SUBROUTINE CD_HermiteCable_Dyn_Restore(model, ErrStat, ErrMsg) model%tors_drive_set = .FALSE. model%tors_use_step = .FALSE. IF (model%fr_active) model%fr_anchor = model%snap_fr_anchor + IF (model%has_viv) THEN + model%viv_phi = model%snap_viv_phi; model%viv_ms = model%snap_viv_ms + model%viv_phi_eval = model%viv_phi + END IF model%na_steps_done = model%snap_na_steps_done model%na_iter_sum = model%snap_na_iter_sum model%na_mn_active = model%snap_na_mn_active @@ -6622,6 +6993,7 @@ SUBROUTINE CD_HermiteCable_Dyn_End(model) IF (ALLOCATED(model%fr_anchor)) DEALLOCATE (model%fr_anchor, model%fr_k, model%ws_recovery_fr, & model%snap_fr_anchor) model%fr_active = .FALSE. + CALL clear_viv(model) CALL CD_End_Bathymetry(model%contact_bathymetry) model%has_contact = .FALSE.; model%has_contact_bathymetry = .FALSE. IF (ALLOCATED(model%Mgb)) DEALLOCATE (model%Mgb) @@ -7106,6 +7478,29 @@ SUBROUTINE assemble_residual(model, q_cfg, v_cfg, t_eval, want_residual, want_ta END IF END DO END IF + ! Cross-flow VIV lift (an external load like the drag, at the step's phase viv_phi_eval). + IF (model%has_viv .AND. .NOT. tangent_only) THEN + DO e = e_lo, e_hi + IF (want_tangent) THEN + CALL viv_element_lift(model, q_cfg, v_cfg, e, fdrag, es, em_e, djq, djv) + ELSE + CALL viv_element_lift(model, q_cfg, v_cfg, e, fdrag, es, em_e) + END IF + IF (es /= CD_HCDYN_OK) THEN + ErrStat = es; ErrMsg = TRIM(em_e); RETURN + END IF + IF (want_residual) THEN + DO a = 1, 12 + gi = elem_gdof(e, a) + R(gi) = R(gi) - fdrag(a) + END DO + END IF + IF (want_tangent) THEN + CALL scatter12_band(Kb, -djq, e) + CALL scatter12_band(Kvb, -djv, e) + END IF + END DO + END IF CALL asm_mark(HC_ASM_DRAG, asm_t) ! ---- rotational line-end connections ---- @@ -7704,6 +8099,15 @@ SUBROUTINE evaluate_tangent_element(model, e, q_cfg, v_cfg, t_eval, Kstruct, Kdr Kvel = Kvel - djv END IF + IF (model%has_viv) THEN + CALL viv_element_lift(model, q_cfg, v_cfg, e, fload, es, em, djq, djv) + IF (es /= CD_HCDYN_OK) THEN + ErrStat = es; ErrMsg = TRIM(em); RETURN + END IF + Kdrag = Kdrag - djq + Kvel = Kvel - djv + END IF + IF (model%has_wave .AND. model%has_am) THEN IF (model%wv_ncomp > 0) THEN CALL CD_HermiteCable_FK_Element(qe, model%l0(e), model%am_wl, model%am_rho, model%am_diam(e), & @@ -8133,6 +8537,79 @@ SUBROUTINE CD_HermiteCable_Drag_Element(qe, ve, l0, fluid, waterline_z, rho, dia END IF END SUBROUTINE CD_HermiteCable_Drag_Element + SUBROUTINE CD_HermiteCable_VIV_Lift_Element(qe, ve, l0, fluid, waterline_z, k_node, flift, djq, djv, & + ErrStat, ErrMsg) + !! Consistent Gauss-integrated cross-flow VIV lift on one cubic-Hermite element: the load + !! integral N^T f ds of the per-length lift f = k(xi) U (t x v_r) (CD_VIV_Lift_Per_Length), + !! with k = 1/2 rho D Cl cos(phi) interpolated linearly between the element's end nodes + !! (k_node), and its force Jacobians djq = d flift/d qe, djv = d flift/d ve (both or neither). + !! The interpolation, measure and wet/dry culling are the drag element's (still waterline). + REAL(wp), INTENT(IN) :: qe(12), ve(12), l0, fluid(3), waterline_z, k_node(2) + REAL(wp), INTENT(OUT) :: flift(12) + REAL(wp), INTENT(OUT), OPTIONAL :: djq(12, 12), djv(12, 12) + INTEGER, INTENT(OUT) :: ErrStat + CHARACTER(*), INTENT(OUT) :: ErrMsg + INTEGER, PARAMETER :: NGP = 3 + REAL(wp), PARAMETER :: G3 = 0.7745966692414834_wp ! sqrt(3/5) + REAL(wp) :: gp(NGP), gw(NGP), H(4), dH(4), rpos(3), vvel(3), rp(3), speed, tangent(3), fpl(3) + REAL(wp) :: jrel(3, 3), jtan(3, 3), scale, kg + LOGICAL :: want_jac, ok + INTEGER :: g, s, c, sp, cp, a, b + + ErrStat = CD_HCDYN_OK; ErrMsg = '' + want_jac = PRESENT(djq) + flift = CD_ZERO + IF (want_jac) THEN + djq = CD_ZERO; djv = CD_ZERO + END IF + gp = [0.5_wp*(CD_ONE - G3), 0.5_wp, 0.5_wp*(CD_ONE + G3)] + gw = [5.0_wp/18.0_wp, 8.0_wp/18.0_wp, 5.0_wp/18.0_wp] + DO g = 1, NGP + CALL CD_HermiteCable_Shapes(gp(g), l0, H, dH) + DO c = 1, 3 + rpos(c) = H(1)*qe(c) + H(2)*qe(3 + c) + H(3)*qe(6 + c) + H(4)*qe(9 + c) + vvel(c) = H(1)*ve(c) + H(2)*ve(3 + c) + H(3)*ve(6 + c) + H(4)*ve(9 + c) + rp(c) = dH(1)*qe(c) + dH(2)*qe(3 + c) + dH(3)*qe(6 + c) + dH(4)*qe(9 + c) + END DO + IF (rpos(3) > waterline_z) CYCLE ! dry Gauss point: no lift + kg = (CD_ONE - gp(g))*k_node(1) + gp(g)*k_node(2) + IF (want_jac) THEN + CALL CD_VIV_Lift_Per_Length(fluid - vvel, rp, kg, fpl, ok, jrel, jtan) + ELSE + CALL CD_VIV_Lift_Per_Length(fluid - vvel, rp, kg, fpl, ok) + END IF + IF (.NOT. ok) THEN + ErrStat = CD_HCDYN_NOCONVERGE + ErrMsg = 'CD_HermiteCable_VIV_Lift_Element: degenerate centreline (|dr/dxi| ~ 0)'; RETURN + END IF + speed = SQRT(rp(1)**2 + rp(2)**2 + rp(3)**2) + tangent = rp/speed + scale = gw(g)*speed + DO s = 1, 4 + DO c = 1, 3 + a = 3*(s - 1) + c + flift(a) = flift(a) + scale*H(s)*fpl(c) + END DO + END DO + IF (.NOT. want_jac) CYCLE + DO s = 1, 4 + DO c = 1, 3 + a = 3*(s - 1) + c + DO sp = 1, 4 + DO cp = 1, 3 + b = 3*(sp - 1) + cp + djv(a, b) = djv(a, b) - scale*H(s)*H(sp)*jrel(c, cp) + djq(a, b) = djq(a, b) + gw(g)*H(s)*dH(sp)*(speed*jtan(c, cp) + fpl(c)*tangent(cp)) + END DO + END DO + END DO + END DO + END DO + IF (.NOT. CD_All_Finite(flift)) THEN + ErrStat = CD_HCDYN_NOCONVERGE; ErrMsg = 'CD_HermiteCable_VIV_Lift_Element: non-finite lift load' + END IF + END SUBROUTINE CD_HermiteCable_VIV_Lift_Element + SUBROUTINE CD_HermiteCable_AddedMass_Element(qe, l0, waterline_z, rho, diam, can, cat, Ma, ErrStat, ErrMsg) !! Consistent Gauss-integrated Morison ADDED MASS on one cubic-Hermite bending-cable element: !! Ma = integral N^T m_a(t) N ds, m_a(t) = rho A (Can (I - t t^T) + Cat t t^T), diff --git a/src/CableDyn_VIV.f90 b/src/CableDyn_VIV.f90 index fd6554b0..27d742cc 100644 --- a/src/CableDyn_VIV.f90 +++ b/src/CableDyn_VIV.f90 @@ -40,7 +40,9 @@ MODULE CableDyn_VIV PRIVATE PUBLIC :: CD_VIV_Node_Lift + PUBLIC :: CD_VIV_Lift_Per_Length PUBLIC :: CD_VIV_Crossflow_Motion + PUBLIC :: CD_VIV_Crossflow_Along PUBLIC :: CD_VIV_Phase_Rate PUBLIC :: CD_VIV_Mean_Square PUBLIC :: CD_VIV_Wrap_Phase @@ -172,6 +174,93 @@ PURE SUBROUTINE CD_VIV_Crossflow_Motion(r_prev, r_next, rd, rdd, u, yd, ydd, un, ydd = rdd(1)*e(1) + rdd(2)*e(2) + rdd(3)*e(3) END SUBROUTINE CD_VIV_Crossflow_Motion + PURE SUBROUTINE CD_VIV_Lift_Per_Length(urel, rp, k, f, ok, jrel, jtan) + !! Lift per unit length of a cable centreline point (the finite-EI cable's Gauss points), + !! f = k U (t x v_r), with k = 1/2 rho D Cl cos(phi), the unit tangent t = rp/|rp| of the raw + !! centreline derivative rp = dr/dxi, the relative flow v_r = urel and its normal speed U. + !! Optionally (both or neither) its Jacobians jrel = df/dv_r and jtan = df/drp, for chaining + !! through the shape functions as the drag primitive is. ok = .FALSE. (and f = 0) for a + !! degenerate centreline; f and its derivatives vanish with the normal flow. + REAL(wp), INTENT(IN) :: urel(3), rp(3), k + REAL(wp), INTENT(OUT) :: f(3) + LOGICAL, INTENT(OUT) :: ok + REAL(wp), INTENT(OUT), OPTIONAL :: jrel(3, 3), jtan(3, 3) + REAL(wp) :: speed, t(3), alpha, vn(3), un, w(3), dfdt(3, 3), proj(3, 3) + INTEGER :: i, j + + f = CD_ZERO + IF (PRESENT(jrel)) THEN + jrel = CD_ZERO + jtan = CD_ZERO + END IF + speed = SQRT(rp(1)*rp(1) + rp(2)*rp(2) + rp(3)*rp(3)) + ok = speed > TINY_CHORD + IF (.NOT. ok) RETURN + t = rp/speed + alpha = t(1)*urel(1) + t(2)*urel(2) + t(3)*urel(3) + vn = urel - alpha*t + un = SQRT(vn(1)*vn(1) + vn(2)*vn(2) + vn(3)*vn(3)) + w = cross3(t, urel) ! = t x v_n + f = (k*un)*w + IF (.NOT. PRESENT(jrel)) RETURN + IF (.NOT. (un > CD_ZERO)) RETURN + ! df/dv_r = k [w (x) v_n/U + U [t]x] + DO j = 1, 3 + DO i = 1, 3 + jrel(i, j) = k*w(i)*vn(j)/un + END DO + END DO + jrel(1, 2) = jrel(1, 2) - k*un*t(3) + jrel(1, 3) = jrel(1, 3) + k*un*t(2) + jrel(2, 1) = jrel(2, 1) + k*un*t(3) + jrel(2, 3) = jrel(2, 3) - k*un*t(1) + jrel(3, 1) = jrel(3, 1) - k*un*t(2) + jrel(3, 2) = jrel(3, 2) + k*un*t(1) + ! df/dt = k [-(alpha/U) w (x) v_r - U [v_r]x], chained through dt/drp = (I - t t^T)/|rp| + DO j = 1, 3 + DO i = 1, 3 + dfdt(i, j) = -k*(alpha/un)*w(i)*urel(j) + END DO + END DO + dfdt(1, 2) = dfdt(1, 2) + k*un*urel(3) + dfdt(1, 3) = dfdt(1, 3) - k*un*urel(2) + dfdt(2, 1) = dfdt(2, 1) - k*un*urel(3) + dfdt(2, 3) = dfdt(2, 3) + k*un*urel(1) + dfdt(3, 1) = dfdt(3, 1) + k*un*urel(2) + dfdt(3, 2) = dfdt(3, 2) - k*un*urel(1) + DO j = 1, 3 + DO i = 1, 3 + proj(i, j) = -t(i)*t(j)/speed + END DO + proj(j, j) = proj(j, j) + CD_ONE/speed + END DO + jtan = MATMUL(dfdt, proj) + END SUBROUTINE CD_VIV_Lift_Per_Length + + PURE SUBROUTINE CD_VIV_Crossflow_Along(tdir, rd, rdd, u, yd, ydd, un, ok) + !! CD_VIV_Crossflow_Motion with the line tangent given directly (tdir, any length: the + !! slope DOFs of a finite-EI node) instead of the chord of two neighbours. + REAL(wp), INTENT(IN) :: tdir(3), rd(3), rdd(3), u(3) + REAL(wp), INTENT(OUT) :: yd, ydd, un + LOGICAL, INTENT(OUT) :: ok + REAL(wp) :: speed, t(3), vr(3), vn(3), e(3) + + yd = CD_ZERO + ydd = CD_ZERO + un = CD_ZERO + speed = SQRT(tdir(1)*tdir(1) + tdir(2)*tdir(2) + tdir(3)*tdir(3)) + ok = speed > TINY_CHORD + IF (.NOT. ok) RETURN + t = tdir/speed + vr = u - rd + vn = vr - (t(1)*vr(1) + t(2)*vr(2) + t(3)*vr(3))*t + un = SQRT(vn(1)*vn(1) + vn(2)*vn(2) + vn(3)*vn(3)) + IF (.NOT. (un > CD_ZERO)) RETURN + e = cross3(t, vn)/un + yd = rd(1)*e(1) + rd(2)*e(2) + rd(3)*e(3) + ydd = rdd(1)*e(1) + rdd(2)*e(2) + rdd(3)*e(3) + END SUBROUTINE CD_VIV_Crossflow_Along + ELEMENTAL REAL(wp) FUNCTION CD_VIV_Mean_Square(ms_old, sample, weight) RESULT(ms) !! One step of the running mean square, ms_old + weight (sample^2 - ms_old); weight = !! 1/n_m is MoorDyn's ((n_m - 1) old^2 + new^2)/n_m. diff --git a/tests/test_hermite_viv.f90 b/tests/test_hermite_viv.f90 new file mode 100644 index 00000000..a1c75880 --- /dev/null +++ b/tests/test_hermite_viv.f90 @@ -0,0 +1,210 @@ +! File: tests/test_hermite_viv.f90 +! SPDX-License-Identifier: Apache-2.0 +! Copyright (c) 2026 Jae Hoon Seo, SMI Lab, Inha University +PROGRAM test_hermite_viv + !! Cross-flow VIV on the cubic-Hermite cable (CD_HermiteCable_Dyn_Set_VIV): the setter's + !! refusals, the state the step carries, and the lock-in itself. + !! + !! A 100 m taut, nearly neutrally buoyant line (20 elements, D 0.1 m, EA 5e7 N, EI 1 N m^2, + !! about 50 kN), pinned at both ends in a 0.15 m/s cross current with Cl 0.8 and MoorDyn's band + !! (dF 0.08, cF 0.18): the shedding frequency cF U/D = 0.27 Hz sits on the first mode, so the + !! line locks in (the deck benchmark of tests/test_viv_lockin.py, coarser here). + !! + !! Gates: + !! * the setter refuses a model without drag, mismatched sizes, a band with dF >= cF, a negative + !! averaging time, and an internal wave family afterwards; all-zero Cl installs nothing; + !! installing the lift in the cross current changes the committed acceleration and removing + !! it brings the no-lift acceleration back; a drag reconfigured afterwards carries the lift + !! scale and the shedding diameter with it; + !! * at 60 s the mid-span cross-flow amplitude is above 0.3 D with the lift and below 0.01 D + !! without it; + !! * a snapshot taken mid-run and restored replays the following steps bit for bit (state and + !! phase), and the recovering step equals the plain step when no step fails. + USE CableDyn_Precision, ONLY: wp + USE CableDyn_HermiteCableDynamic, ONLY: CD_HermiteCableDynType, CD_HermiteCable_Dyn_Init, & + CD_HermiteCable_Dyn_Set_Drag, CD_HermiteCable_Dyn_Set_AddedMass, & + CD_HermiteCable_Dyn_Set_VIV, CD_HermiteCable_Dyn_Set_Waves, & + CD_HermiteCable_Dyn_Step, CD_HermiteCable_Dyn_Step_Recovering, & + 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, GACC = 9.80665_wp + REAL(wp), PARAMETER :: D = 0.1_wp, MLIN = 8.10_wp, EA = 5.0e7_wp, EI = 1.0_wp, TENS = 5.0e4_wp + REAL(wp), PARAMETER :: SPAN = 100.0_wp, U = 0.15_wp, DT = 0.02_wp + INTEGER, PARAMETER :: NE = 20 + + TYPE(CD_HermiteCableDynType) :: model + REAL(wp), ALLOCATABLE :: cl(:), cf(:), df(:), q_ref(:, :), phi_ref(:, :), a_none(:) + REAL(wp) :: amp_lift, amp_none + INTEGER :: es, nfail, k, mid + CHARACTER(1024) :: em + + nfail = 0 + mid = 6*(NE/2) + 3 ! r_z of the mid-span node + ALLOCATE (cl(NE), cf(NE), df(NE)) + cl = 0.8_wp; cf = 0.18_wp; df = 0.08_wp + + ! ---- refusals ---- + CALL build(model, .FALSE.) + CALL CD_HermiteCable_Dyn_Set_VIV(model, cl, cf, df, 0.25_wp, es, em) + CALL require(es /= CD_HCDYN_OK, 'VIV without drag is refused') + CALL CD_HermiteCable_Dyn_End(model) + CALL build(model, .TRUE.) + CALL CD_HermiteCable_Dyn_Set_VIV(model, cl(1:NE - 1), cf(1:NE - 1), df(1:NE - 1), 0.25_wp, es, em) + CALL require(es /= CD_HCDYN_OK, 'mismatched VIV arrays are refused') + CALL CD_HermiteCable_Dyn_Set_VIV(model, cl, cf, cf, 0.25_wp, es, em) + CALL require(es /= CD_HCDYN_OK, 'a band with dF >= cF is refused') + CALL CD_HermiteCable_Dyn_Set_VIV(model, cl, cf, df, -1.0_wp, es, em) + CALL require(es /= CD_HCDYN_OK, 'a negative averaging time is refused') + CALL CD_HermiteCable_Dyn_Set_VIV(model, 0.0_wp*cl, cf, df, 0.25_wp, es, em) + CALL require(es == CD_HCDYN_OK .AND. .NOT. model%has_viv, 'all-zero Cl installs no VIV') + a_none = model%a + CALL CD_HermiteCable_Dyn_Set_VIV(model, cl, cf, df, 0.25_wp, es, em) + CALL require(es == CD_HCDYN_OK .AND. model%has_viv, 'VIV installs: '//TRIM(em)) + ! at rest in the cross current the lift (about 0.9 N/m) moves the committed acceleration + CALL require(MAXVAL(ABS(model%a - a_none)) > 1.0e-3_wp, 'installing the lift refreshes the acceleration') + CALL CD_HermiteCable_Dyn_Set_VIV(model, 0.0_wp*cl, cf, df, 0.25_wp, es, em) + CALL require(es == CD_HCDYN_OK .AND. .NOT. model%has_viv .AND. & + MAXVAL(ABS(model%a - a_none)) <= 1.0e-12_wp*MAXVAL(ABS(a_none)), & + 'removing the lift brings the no-lift acceleration back') + CALL CD_HermiteCable_Dyn_Set_VIV(model, cl, cf, df, 0.25_wp, es, em) + CALL require(es == CD_HCDYN_OK .AND. model%has_viv, 'VIV installs again: '//TRIM(em)) + CALL CD_HermiteCable_Dyn_Set_Waves(model, 1.0_wp, 8.0_wp, 0.0_wp, 100.0_wp, GACC, es, em) + CALL require(es /= CD_HCDYN_OK, 'an internal wave family is refused on a VIV cable') + CALL require(ABS(model%viv_phi(NE + 1)) < TINY(1.0_wp) .AND. & + ABS(model%viv_phi(1) - 2.0_wp*PI) < 1.0e-12_wp, 'the phases start at 2 pi i/N from End A') + ! a drag reconfigured after VIV carries the lift scale and shedding diameter with it + BLOCK + REAL(wp) :: k0(NE), dn0(NE + 1), hd(NE), hn(NE), ht(NE) + k0 = model%viv_k + dn0 = model%viv_dn + hd = 2.0_wp*D; hn = 1.2_wp; ht = 0.0_wp + CALL CD_HermiteCable_Dyn_Set_Drag(model, RHOW, hd, hn, ht, 0.0_wp, [0.0_wp, U, 0.0_wp], es, em) + CALL require(es == CD_HCDYN_OK .AND. ALL(ABS(model%viv_k - 2.0_wp*k0) <= 1.0e-12_wp*k0) .AND. & + ALL(ABS(model%viv_dn - 2.0_wp*dn0) <= 1.0e-12_wp*dn0), & + 'a drag reconfiguration updates the VIV lift scale and shedding diameter') + hd = D + CALL CD_HermiteCable_Dyn_Set_Drag(model, RHOW, hd, hn, ht, 0.0_wp, [0.0_wp, U, 0.0_wp], es, em) + CALL require(es == CD_HCDYN_OK .AND. ALL(model%viv_k == k0) .AND. ALL(model%viv_dn == dn0), & + 'the original drag restores them exactly') + END BLOCK + + ! ---- lock-in, and the same line without lift ---- + amp_lift = run_amplitude(model) + CALL CD_HermiteCable_Dyn_End(model) + CALL build(model, .TRUE.) + amp_none = run_amplitude(model) + CALL CD_HermiteCable_Dyn_End(model) + WRITE (*, '(A,F7.4,A,F8.5)') ' mid-span cross-flow amplitude / D: with lift ', amp_lift/D, ', without ', & + amp_none/D + CALL require(amp_lift > 0.3_wp*D, 'the line locks in with the lift') + CALL require(amp_none < 0.01_wp*D, 'the line stays still without it') + + ! ---- snapshot replay and the recovering step ---- + CALL build(model, .TRUE.) + CALL CD_HermiteCable_Dyn_Set_VIV(model, cl, cf, df, 0.25_wp, es, em) + CALL advance(model, 500, .FALSE.) + CALL CD_HermiteCable_Dyn_Snapshot(model, es, em) + CALL require(es == CD_HCDYN_OK, 'snapshot: '//TRIM(em)) + ALLOCATE (q_ref(SIZE(model%q), 100), phi_ref(NE + 1, 100)) + DO k = 1, 100 + CALL advance(model, 1, .FALSE.) + q_ref(:, k) = model%q + phi_ref(:, k) = model%viv_phi + END DO + CALL CD_HermiteCable_Dyn_Restore(model, es, em) + CALL require(es == CD_HCDYN_OK, 'restore: '//TRIM(em)) + DO k = 1, 100 + CALL advance(model, 1, .FALSE.) + IF (ANY(model%q /= q_ref(:, k)) .OR. ANY(model%viv_phi /= phi_ref(:, k))) EXIT + END DO + CALL require(k > 100, 'the restored snapshot replays the state and phase bit for bit') + ! the recovering step from the same snapshot follows the plain step exactly + CALL CD_HermiteCable_Dyn_Restore(model, es, em) + DO k = 1, 100 + CALL advance(model, 1, .TRUE.) + IF (ANY(model%q /= q_ref(:, k)) .OR. ANY(model%viv_phi /= phi_ref(:, k))) EXIT + END DO + CALL require(k > 100, 'the recovering step equals the plain step') + CALL CD_HermiteCable_Dyn_End(model) + + IF (nfail > 0) THEN + WRITE (*, '(A,I0,A)') 'FAIL: ', nfail, ' assertion(s) failed' + ERROR STOP 1 + END IF + WRITE (*, '(A)') 'PASS: cross-flow VIV on the cubic-Hermite cable' + +CONTAINS + + SUBROUTINE build(m, with_drag) + !! The pinned taut line along x, pretensioned through its unstretched length, with the cross + !! current along y (drag) and the normal added mass. + TYPE(CD_HermiteCableDynType), INTENT(INOUT) :: m + LOGICAL, INTENT(IN) :: with_drag + REAL(wp) :: seed(6*(NE + 1)), l0(NE), eav(NE), eiv(NE), wv(NE), rhoa(NE), hd(NE), hn(NE), ht(NE) + INTEGER :: fixed(6), i + seed = 0.0_wp + DO i = 1, NE + 1 + seed(6*(i - 1) + 1) = SPAN*REAL(i - 1, wp)/REAL(NE, wp) + seed(6*(i - 1) + 3) = -50.0_wp + seed(6*(i - 1) + 4) = 1.0_wp + END DO + l0 = SPAN/REAL(NE, wp)/(1.0_wp + TENS/EA) + eav = EA; eiv = EI; rhoa = MLIN + wv = (MLIN - RHOW*0.25_wp*PI*D**2)*GACC + fixed = [1, 2, 3, 6*NE + 1, 6*NE + 2, 6*NE + 3] + CALL CD_HermiteCable_Dyn_Init(m, l0, eav, eiv, rhoa, wv, seed, fixed, -200.0_wp, 0.0_wp, 0.5_wp, es, em) + CALL require(es == CD_HCDYN_OK, 'init: '//TRIM(em)) + IF (.NOT. with_drag) RETURN + hd = D; hn = 1.2_wp; ht = 0.0_wp + CALL CD_HermiteCable_Dyn_Set_Drag(m, RHOW, hd, hn, ht, 0.0_wp, [0.0_wp, U, 0.0_wp], es, em) + CALL require(es == CD_HCDYN_OK, 'drag: '//TRIM(em)) + hn = 1.0_wp + CALL CD_HermiteCable_Dyn_Set_AddedMass(m, RHOW, hd, hn, ht, 0.0_wp, es, em) + CALL require(es == CD_HCDYN_OK, 'added mass: '//TRIM(em)) + END SUBROUTINE build + + SUBROUTINE advance(m, n, recovering) + TYPE(CD_HermiteCableDynType), INTENT(INOUT) :: m + INTEGER, INTENT(IN) :: n + LOGICAL, INTENT(IN) :: recovering + INTEGER :: s + DO s = 1, n + IF (recovering) THEN + CALL CD_HermiteCable_Dyn_Step_Recovering(m, DT, 50, 1.0e-8_wp, es, em) + ELSE + CALL CD_HermiteCable_Dyn_Step(m, DT, 50, 1.0e-8_wp, es, em) + END IF + IF (es /= CD_HCDYN_OK) THEN + CALL require(.FALSE., 'step: '//TRIM(em)); RETURN + END IF + END DO + END SUBROUTINE advance + + REAL(wp) FUNCTION run_amplitude(m) RESULT(amp) + !! Half the peak-to-peak mid-span cross-flow (z) excursion over 40-60 s. + TYPE(CD_HermiteCableDynType), INTENT(INOUT) :: m + REAL(wp) :: zmin, zmax + INTEGER :: s + zmin = HUGE(1.0_wp); zmax = -HUGE(1.0_wp) + DO s = 1, NINT(60.0_wp/DT) + CALL advance(m, 1, .FALSE.) + IF (es /= CD_HCDYN_OK) EXIT + IF (REAL(s, wp)*DT < 40.0_wp) CYCLE + zmin = MIN(zmin, m%q(mid)); zmax = MAX(zmax, m%q(mid)) + END DO + amp = 0.5_wp*(zmax - zmin) + END FUNCTION run_amplitude + + SUBROUTINE require(cond, label) + LOGICAL, INTENT(IN) :: cond + CHARACTER(*), INTENT(IN) :: label + IF (.NOT. cond) THEN + WRITE (*, '(A,A)') 'MISMATCH: ', label + nfail = nfail + 1 + END IF + END SUBROUTINE require + +END PROGRAM test_hermite_viv diff --git a/tests/test_viv_kernels.f90 b/tests/test_viv_kernels.f90 index afe04541..e6ddad46 100644 --- a/tests/test_viv_kernels.f90 +++ b/tests/test_viv_kernels.f90 @@ -14,12 +14,12 @@ PROGRAM test_viv_kernels !! 6) the phase wraps to [0, 2 pi), and a node whose neighbours coincide fails closed. USE CableDyn_Precision, ONLY: wp USE CableDyn_VIV, ONLY: CD_VIV_Node_Lift, CD_VIV_Crossflow_Motion, CD_VIV_Phase_Rate, CD_VIV_Mean_Square, & - CD_VIV_Wrap_Phase, CD_VIV_TWO_PI, CD_VIV_NM + CD_VIV_Wrap_Phase, CD_VIV_TWO_PI, CD_VIV_NM, CD_VIV_Lift_Per_Length IMPLICIT NONE REAL(wp), PARAMETER :: RHO = 1025.0_wp, DIAM = 0.1_wp, CL = 0.8_wp, L1 = 2.0_wp, L2 = 1.5_wp REAL(wp) :: rp(3), rn(3), rd(3), u(3), coef, phi, f(3), q(3), vr(3), vn(3), un, w(3), ref(3) REAL(wp) :: jv(3, 3), jp(3, 3), jn(3, 3), fd(3, 3), fp(3), fm(3), h, e(3), yd, ydd, un2, rate - REAL(wp) :: ms, ms_md + REAL(wp) :: ms, ms_md, rpv(3), kk, fl(3), jr(3, 3), jt(3, 3) LOGICAL :: ok INTEGER :: nfail, j, k @@ -95,6 +95,30 @@ PROGRAM test_viv_kernels ms_md = ms END DO + ! (7) per-length lift at a centreline point (the finite-EI Gauss points): the node formula with + ! the exact tangent, scaled to unit length, independent of |dr/dxi|; Jacobians vs differences + rpv = 2.5_wp*(rn - rp) + kk = 0.5_wp*RHO*DIAM*CL*COS(phi) + CALL CD_VIV_Lift_Per_Length(u - rd, rpv, kk, fl, ok, jr, jt) + CALL CD_VIV_Node_Lift(rp, rn, rd, u, 1.0_wp, phi, f, ok) + CALL require(ok .AND. NORM2(fl - 0.5_wp*RHO*DIAM*CL*f) <= 1.0e-12_wp*NORM2(fl), & + 'per-length lift = 1/2 rho D Cl cos(phi) U (t x v_n)') + DO j = 1, 3 + CALL CD_VIV_Lift_Per_Length(u - rd + h*unit(j), rpv, kk, fp, ok) + CALL CD_VIV_Lift_Per_Length(u - rd - h*unit(j), rpv, kk, fm, ok) + fd(:, j) = (fp - fm)/(2.0_wp*h) + END DO + CALL require(MAXVAL(ABS(jr - fd)) <= 1.0e-6_wp*MAXVAL(ABS(fd)), 'per-length lift: flow Jacobian matches differences') + DO j = 1, 3 + CALL CD_VIV_Lift_Per_Length(u - rd, rpv + h*unit(j), kk, fp, ok) + CALL CD_VIV_Lift_Per_Length(u - rd, rpv - h*unit(j), kk, fm, ok) + fd(:, j) = (fp - fm)/(2.0_wp*h) + END DO + CALL require(MAXVAL(ABS(jt - fd)) <= 1.0e-6_wp*MAXVAL(ABS(fd)), & + 'per-length lift: tangent Jacobian matches differences') + CALL CD_VIV_Lift_Per_Length(u - rd, 3.0_wp*rpv, kk, fp, ok) + CALL require(NORM2(fp - fl) <= 1.0e-12_wp*NORM2(fl), 'per-length lift does not depend on |dr/dxi|') + ! (6) wrap and degenerate frame CALL require(CD_VIV_Wrap_Phase(-1.0e-300_wp) >= 0.0_wp .AND. CD_VIV_Wrap_Phase(-1.0e-300_wp) < CD_VIV_TWO_PI, & 'a tiny negative phase wraps into [0, 2 pi)') diff --git a/tests/test_viv_lockin.py b/tests/test_viv_lockin.py index 82500fae..1e664907 100644 --- a/tests/test_viv_lockin.py +++ b/tests/test_viv_lockin.py @@ -13,7 +13,17 @@ one spectral bin (1/60 Hz) of it, with the quarter-span amplitude of the first mode; * at dtM 0.002 s, a step that resolves the mesh zig-zag mode, the line stays locked in with the same amplitude (within 2 %): with the nodes' own kinematics in the synchronisation model the - zig-zag mode was pumped there and the line lost lock-in after about 70 s. + zig-zag mode was pumped there and the line lost lock-in after about 70 s; +* the same line as a finite-EI cable (EI 1 N m^2, a string to within 1e-6 of its geometric + stiffness: the cubic-Hermite route with the Gauss-integrated lift) locks in with the EI = 0 + line's mid-span and quarter-span amplitudes (within 1 %) and frequency, at dtM 0.01 s and at + 0.002 s (no smoothing needed on the Hermite route); +* a bending-stiff, neutrally buoyant cable (8.1 kg/m, EA 5e9 N, EI 5e7 N m^2, about 51 kN: + beta = pi^2 EI/(T L^2) ~ 1) against the EI = 0 string tensioned to T (1 + beta), which has + the same first-mode frequency and shape: at U 0.21 m/s both lock into mode 1 with the same + mid-span A/D (within 3 %) and frequency; at U 0.30 m/s the string jumps to mode 2 (mid-span + A/D below 0.15) while the cable, whose bending raises f2/f1 to about 3.15, stays in mode 1 + (mid-span A/D above 0.6). usage: test_viv_lockin.py --exe --output """ @@ -22,9 +32,11 @@ import argparse import math +import os import shutil import subprocess import sys +from concurrent.futures import ThreadPoolExecutor from pathlib import Path import numpy as np @@ -60,20 +72,21 @@ def check(ok: bool, message: str) -> None: 1 CurrentMod - type of current input z-depth x-current y-current (m) (m/s) (m/s) -0.0 0.0 0.15 --100.0 0.0 0.15 +0.0 0.0 {u} +-100.0 0.0 {u} --------------------- need this line ------------------ """ -def deck(dtm: float) -> str: - length = 100.0 / (1.0 + 5.0e4 / 5.0e7) +def deck(dtm: float, ei: float = 0.0, ea: float = 5.0e7, mass: float = 10.0, tension: float = 5.0e4, + waterkin: str = "current.dat") -> str: + length = 100.0 / (1.0 + tension / ea) return f"""--------------------- CableDyn Input File --------------------------------- VIV lock-in gate: taut line in a uniform cross current ----------------------- LINE TYPES ------------------------------------------ TypeName Diam Mass/m EA BA/-zeta EI Cd Ca CdAx CaAx Cl dF cF (name) (m) (kg/m) (N) (N-s/-) (-) (-) (-) (-) (-) (-) (-) (-) -riser 0.10 10.0 5.0e7 -0.8 0.0 1.2 1.0 0.0 0.0 0.8 0.08 0.18 +riser 0.10 {mass} {ea} -0.8 {ei} 1.2 1.0 0.0 0.0 0.8 0.08 0.18 ----------------------- POINTS ---------------------------------------------- ID Attachment X Y Z M V CdA CA (#) (-) (m) (m) (m) (kg) (m^3) (m^2) (-) @@ -88,7 +101,7 @@ def deck(dtm: float) -> str: 100.0 WtrDpth 1025.0 rhoW 9.80665 g -current.dat WaterKin +{waterkin} WaterKin 0.25 VIVrmsWindow 120.0 TMax ---------------------- OUTPUTS ----------------------------------------------- @@ -126,17 +139,39 @@ def main() -> int: if out.exists(): shutil.rmtree(out) out.mkdir(parents=True) - (out / "current.dat").write_text(CURRENT, encoding="utf-8", newline="\n") + for u in (0.15, 0.21, 0.30): + (out / f"current_{u}.dat").write_text(CURRENT.format(u=u), encoding="utf-8", newline="\n") + # the stiff cable and its equal-frequency string (neutrally buoyant: no sag stiffening) + beta = math.pi**2 * 5.0e7 / (5.0e4 * 100.0**2) + stiff = {"ei": 5.0e7, "ea": 5.0e9, "mass": 8.1} + string = {"ea": 5.0e7, "mass": 8.1, "tension": 5.0e4 * (1.0 + beta)} + runs = [ + (0.01, "viv_dt0.01", deck(0.01, waterkin="current_0.15.dat")), + (0.002, "viv_dt0.002", deck(0.002, waterkin="current_0.15.dat")), + ("fei", "viv_fei", deck(0.01, ei=1.0, waterkin="current_0.15.dat")), + ("fei_fine", "viv_fei_dt0.002", deck(0.002, ei=1.0, waterkin="current_0.15.dat")), + ] + for u in (0.21, 0.30): + runs.append((("stiff", u), f"viv_stiff_u{u}", deck(0.01, waterkin=f"current_{u}.dat", **stiff))) + runs.append((("string", u), f"viv_string_u{u}", deck(0.01, waterkin=f"current_{u}.dat", **string))) + for _, name, text in runs: + (out / f"{name}.dat").write_text(text, encoding="utf-8", newline="\n") + env = dict(os.environ, OMP_NUM_THREADS="1") + + def run(name: str) -> subprocess.CompletedProcess[str]: + cmd = [args.exe, f"{name}.dat", name] + return subprocess.run(cmd, cwd=out, capture_output=True, text=True, env=env) + + # the decks are independent: run them side by side (a checked Debug build is ~10x slower) + with ThreadPoolExecutor(max_workers=max(1, min(4, os.cpu_count() or 1))) as pool: + procs = list(pool.map(run, [name for _, name, _ in runs])) results = {} - for dtm in (0.01, 0.002): - name = f"viv_dt{dtm}" - (out / f"{name}.dat").write_text(deck(dtm), encoding="utf-8", newline="\n") - proc = subprocess.run([args.exe, f"{name}.dat", name], cwd=out, capture_output=True, text=True) + for (key, name, _), proc in zip(runs, procs): if proc.returncode != 0: print(proc.stdout[-2000:], proc.stderr[-2000:]) - check(False, f"dtM {dtm}: the run completes (exit {proc.returncode})") + check(False, f"{name}: the run completes (exit {proc.returncode})") continue - results[dtm] = response(out / f"{name}.out") + results[key] = response(out / f"{name}.out") if 0.01 in results: ad, f, qtr = results[0.01] check(abs(ad - MD_AD) <= 0.03 * MD_AD, @@ -150,6 +185,27 @@ def main() -> int: a1, a2 = results[0.01][0], results[0.002][0] check(abs(a2 - a1) <= 0.02 * a1, f"dtM 0.002 s stays locked in: mid-span A/D {a2:.3f} against {a1:.3f} at 0.01 s (within 2 %)") + if 0.01 in results and "fei" in results: + (a0, f0, q0), (a1, f1, q1) = results[0.01], results["fei"] + check(abs(a1 - a0) <= 0.01 * a0 and abs(q1 - q0) <= 0.01 * q0, + f"finite-EI cable: mid/quarter A/D {a1:.3f}/{q1:.3f}, EI = 0 line {a0:.3f}/{q0:.3f} (within 1 %)") + check(abs(f1 - f0) <= 1.0 / 60.0, + f"finite-EI cable: response frequency {f1:.3f} Hz, EI = 0 line {f0:.3f} Hz (within 1/60 Hz)") + if 0.01 in results and "fei_fine" in results: + (a0, f0, q0), (a1, f1, q1) = results[0.01], results["fei_fine"] + check(abs(a1 - a0) <= 0.01 * a0 and abs(q1 - q0) <= 0.01 * q0 and abs(f1 - f0) <= 1.0 / 60.0, + f"finite-EI cable at dtM 0.002 s: mid/quarter A/D {a1:.3f}/{q1:.3f} at {f1:.3f} Hz, EI = 0 " + f"line at 0.01 s {a0:.3f}/{q0:.3f} at {f0:.3f} Hz (within 1 % and one bin)") + if ("stiff", 0.21) in results and ("string", 0.21) in results: + (a1, f1, _), (a0, f0, _) = results[("stiff", 0.21)], results[("string", 0.21)] + check(abs(a1 - a0) <= 0.03 * a0 and abs(f1 - f0) <= 1.0 / 60.0, + f"U 0.21 m/s: stiff cable A/D {a1:.3f} at {f1:.3f} Hz, equal-frequency string {a0:.3f} " + f"at {f0:.3f} Hz (mode 1, within 3 % and one bin)") + if ("stiff", 0.30) in results and ("string", 0.30) in results: + a1, a0 = results[("stiff", 0.30)][0], results[("string", 0.30)][0] + check(a1 > 0.6 and a0 < 0.15, + f"U 0.30 m/s: stiff cable stays in mode 1 (mid-span A/D {a1:.3f}), the string jumps to " + f"mode 2 (mid-span A/D {a0:.3f})") print(f"{len(FAILURES)} failure(s)") return 1 if FAILURES else 0