diff --git a/CMakeLists.txt b/CMakeLists.txt index 96dcf84c..5819138f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1290,6 +1290,13 @@ add_executable(test_end_tangent_channels tests/test_end_tangent_channels.f90) target_link_libraries(test_end_tangent_channels PRIVATE cabledyn_core) add_test(NAME end_tangent_channels COMMAND test_end_tangent_channels WORKING_DIRECTORY ${CMAKE_BINARY_DIR}) set_tests_properties(end_tangent_channels PROPERTIES LABELS "fortran;integration;static;outputs" TIMEOUT 600) +# The end reactions of a finite-EI cable at rest in a uniform current, pinned or clamped, +# suspended or touching down, balance its weight and its Morison drag integrated independently. +add_executable(test_static_current_balance tests/test_static_current_balance.f90) +target_link_libraries(test_static_current_balance PRIVATE cabledyn_core) +add_test(NAME static_current_balance COMMAND test_static_current_balance + WORKING_DIRECTORY ${CMAKE_BINARY_DIR}) +set_tests_properties(static_current_balance PROPERTIES LABELS "fortran;integration;static;hydro" TIMEOUT 600) add_executable(test_viv_kernels tests/test_viv_kernels.f90) target_link_libraries(test_viv_kernels PRIVATE cabledyn_core) @@ -2831,6 +2838,15 @@ if(Python3_Interpreter_FOUND) LABELS "python;driver;integration;static;outputs" TIMEOUT 600 ENVIRONMENT "${_cabledyn_python_test_environment}") + # A negative BA damps the first axial mode of a line at zeta pi/(2N) per segment (the + # default), and at zeta on every mesh under axialDampingRatio mode1, uniform and composite. + add_test(NAME driver_axial_damping_ratio + COMMAND ${Python3_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/tests/check_axial_damping_ratio.py + $) + set_tests_properties(driver_axial_damping_ratio PROPERTIES + LABELS "python;driver;integration;dynamic;validation" + TIMEOUT 600 + ENVIRONMENT "${_cabledyn_python_test_environment}") endif() # The scan of the round-off CI job: it must flag a fallback note, a failed run and a forced # BLAS kernel that did not take effect, or a clean scan would prove nothing. diff --git a/doc/driver_format.md b/doc/driver_format.md index 84d808ed..20ba1a60 100644 --- a/doc/driver_format.md +++ b/doc/driver_format.md @@ -237,7 +237,7 @@ Inside OUTPUTS, a row whose first token is `END` also closes the channel list. | `Diam` | hydrodynamic / volume-equivalent diameter [m] | used for submerged weight, drag, and added mass; at least 1e-6 and at most 1e3 where used | | `MassDenInAir` | dry mass per unstretched metre [kg/m] | submerged weight = (m − ρ_w·πd²/4)·g; its magnitude at most 1e6 where used | | `EA` | axial stiffness [N] | linear (T = EA·ε); at least 1e-3 and at most 1e15 where used; see the viscoelastic and Syrope forms below | -| `BA/-zeta` | axial damping: ≥ 0 is BA [N·s], < 0 is −ζ (damping ratio) | active in EI = 0 and finite-EI dynamics; ignored in a static-only run | +| `BA/-zeta` | axial damping: ≥ 0 is BA [N·s], < 0 is −ζ (damping ratio): by default (MoorDyn's convention) of each segment, BA = ζ L0 √(EA m) per element, which damps the line's first axial mode at about ζ π/(2N) on N elements and so depends on the mesh (a run notes the ratio); under `mode1 axialDampingRatio` of the line's first axial mode, on any mesh (see the OPTIONS table) | active in EI = 0 and finite-EI dynamics; ignored in a static-only run | | `EI` | bending stiffness [N·m²] | finite and ≥ 0; see [EI routing](#ei-routing) | | `Cd_n`, `Cd_t` | normal / tangential drag coefficients | used by EI = 0 dynamic current and Airy-wave runs | | `Ca_n`, `Ca_t` | normal / tangential added-mass coefficients | used by EI = 0 dynamic Froude–Krylov and added-mass runs | @@ -1272,6 +1272,7 @@ syntax form. The most frequently edited keywords are: | `cable_load_feedback` | coupled finite-EI cable reaction switch. `True` returns cable force and moment to the host. `False` marches the cable with the same moving boundary and host fluid field and keeps its output channels, but returns zero force and moment; use it for a one-way comparison, not as a physical model | `True` | | `adaptive_mesh` | `True`/`False`; allow finite-EI mesh refinement when the static resolution check is fragile | `False` | | `cable_statics` | `continuation` or `sequenced`: which finite-EI static route runs first (the other is its fallback); both results are audited | `continuation` | +| `axialDampingRatio` / `axial_damping_ratio` | `segment` or `mode1`: what a negative `BA` is the damping ratio ζ of. `segment` (MoorDyn's convention): of each segment, BA = ζ L0 √(EA m) per element, so the line's first axial mode is damped at about ζ π/(2N) on N elements and less on a finer mesh; a dynamic run notes that ratio. `mode1`: of the line's first axial mode (both ends held, dry mass, from its sections, so the same on any mesh): BA = 2 ζ EA / ω1 on every element, a damping proportional to the stiffness, so the axial mode n is damped at ζ ωn/ω1. A line with a negative `BA` and a viscoelastic or Syrope section is refused under `mode1` | `segment` | | `OutputRecovery` / `output_recovery` | `equilibrium` or `element`: definition of the finite-EI node tension, curvature, bend moment and segment tension. `equilibrium` recovers them from nodal equilibrium (the effective tension F·t, the moment the neighbouring elements carry, curvature = moment / EI); `element` reports the length-weighted element-mean axial force EA(\|r'\| − 1), the larger one-sided exact curvature, and the element-midpoint axial resultant as segment tension. End forces, positions and TDP channels are the same under both | `equilibrium` | | `alpha_force_blend` | `True`/`False`; generalised-α blend of the finite-EI and `EI = 0` dynamics: forces (`True`) or the configuration `q_αf` (`False`), which biases the mean tension of a rotating finite-EI line at large `dtM` and lets `EI = 0` segments that go slack report spurious tension spikes | `True` | | `tensile_safety` | `False`, `warn`, or `True`; audits the element-mean axial force (three-point Gauss mean of the signed axial resultant, averaged over an element and its two neighbours). `True` rejects. `warn` commits the state, counts accepted-step events, and reports the worst force, threshold, element and time (the printed `xi` is always 0.5, the element centre) | `False` | diff --git a/doc/options.rst b/doc/options.rst index ca74bbde..e1c6cd1a 100644 --- a/doc/options.rst +++ b/doc/options.rst @@ -502,6 +502,22 @@ Finite-EI cable controls same under both - both (finite-EI lines) - ``element OutputRecovery`` + * - ``axialDampingRatio`` / ``axial_damping_ratio`` + - mode + - ``segment`` + - what a negative ``LINE TYPES`` ``BA`` is the damping ratio :math:`\zeta` of. + ``segment`` (MoorDyn's convention): of each segment, + :math:`BA = \zeta L_0 \sqrt{EA\,m}` per element, which damps the line's first axial mode + at about :math:`\zeta\pi/(2N)` on :math:`N` elements, so the axial damping depends on + the mesh; a dynamic run notes the ratio for each such line. ``mode1``: of the line's + first axial mode, both ends held, from its sections' lengths, ``EA`` and dry mass, so + the same on any mesh: :math:`BA = 2\zeta EA/\omega_1` on every element, a damping + proportional to the stiffness, under which the axial mode :math:`n` is damped at + :math:`\zeta\,\omega_n/\omega_1` (see :doc:`theory`). A positive ``BA`` is used as given + under both. Under ``mode1`` a line with a negative ``BA`` and a viscoelastic + (``ElasticMod`` 2 or 3) or Syrope section is refused by name + - both (``EI = 0`` and finite-EI lines) + - ``mode1 axialDampingRatio`` * - ``axial_quadrature_order`` / ``axialquadratureorder`` / ``axial_quadrature`` - integer, – - ``4`` diff --git a/doc/theory.rst b/doc/theory.rst index 6db8e69f..5085fae6 100644 --- a/doc/theory.rst +++ b/doc/theory.rst @@ -811,9 +811,31 @@ so the element-scale modes (:math:`n \approx N`) are damped at up to :math:`(\pi ``BA``), while the line's global axial modes are damped much less, and less again on a finer mesh: ``BA = -1`` on 100 elements gives the first axial mode 1.6 %, and 0.8 % on 200 elements. Results that depend on the axial damping (tension peaks of snatch loads, the decay of axial -oscillations) therefore change with the mesh. For mesh-independent damping give ``BA`` in N·s: -a material damping ratio :math:`\zeta_1` of the first axial mode of a line of length :math:`L` is -:math:`BA = 2\,\zeta_1\,EA/\omega_1` with :math:`\omega_1 = (\pi/L)\sqrt{EA/\rho_A}`. +oscillations) therefore change with the mesh. The initialisation of a dynamic run notes, for every +line with a negative ``BA``, the damping ratio this gives its first axial mode on its final mesh: +the Rayleigh quotient :math:`\zeta_1 = \mathbf u^\mathsf T\mathbf C\mathbf u / +(2\,\omega_1\,\mathbf u^\mathsf T\mathbf M\mathbf u)` of the first mode :math:`\mathbf u` of the +line's axial chain with both ends held (element stiffness :math:`EA/L_0`, damping +:math:`BA/L_0`, the dry mass lumped at the nodes), which is :math:`\zeta\sin(\pi/(2N))` on a +uniform line and holds for a composite one. + +**First-mode damping ratio** (``mode1 axialDampingRatio``, :doc:`options`). A negative ``BA`` is +then the damping ratio of the line's first axial mode, the same on any mesh: + +.. math:: + + BA = \frac{2\,\zeta\,EA}{\omega_1} + +on every element, with :math:`\omega_1` the first axial natural frequency of the line with both +ends held, from its sections' unstretched lengths, ``EA`` and dry mass per length (the first mode +of the axial chain on a fixed internal mesh of 2048 elements, so independent of the line's mesh; +:math:`\omega_1 = (\pi/L)\sqrt{EA/\rho_A}` on a uniform line, to 1e-7). The damping is then +proportional to the stiffness, :math:`\mathbf C = (2\zeta/\omega_1)\,\mathbf K`, so the first +axial mode of a composite line is damped at :math:`\zeta` too and the mode :math:`n` at +:math:`\zeta\,\omega_n/\omega_1`. Added mass and the tension are left out of :math:`\omega_1`. A +viscoelastic or Syrope section has no single ``EA`` that sets the first mode, so a line with one +and a negative ``BA`` is refused under this option; ``BA`` in N·s is used as given under both +conventions. Viscoelastic rope (MoorDyn ``ElasticMod`` 2 and 3) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -988,7 +1010,17 @@ With the relative velocity :math:`\mathbf{u}_r = \mathbf{u}_f - \mathbf{v}` spli + \tfrac{1}{2}\rho\,\pi d\,C_{d,t}\,\lvert\mathbf{u}_{r,t}\rvert\,\mathbf{u}_{r,t}. Its derivatives with respect to position (through :math:`\mathbf{t}`) and velocity enter the -implicit tangent exactly. +implicit tangent exactly. The length is the element's unstretched length :math:`L_0` on the +``EI = 0`` path (with the chord tangent and the wet-weighted relative velocity) and +the deformed length :math:`\lvert\mathbf r_{,\xi}\rvert\,\mathrm{d}\xi` of the cubic centreline +on the Hermite path (three Gauss points per element). At rest in a current the end reactions +(``FairTen``/``AnchTen``, ``Point

F``) balance the weight and this drag to the static +tolerance, about :math:`10^{-8}` of the end force, pinned or clamped ends alike. A check of the +balance must integrate the drag the same way: on straight chords between the nodes of a +finite-EI line it misses by a share that falls with the square of the element length +(:math:`3\times10^{-5}` of the end force on 1.25 m elements of a cable in a 1 m/s current, +:math:`4.5\times10^{-4}` on 5 m elements), and per unstretched length by about the axial strain +times the drag. Added mass and fluid inertia ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -1079,6 +1111,8 @@ phases, the running mean squares and the averaging time are part of the checkpoi restart continues the uninterrupted run bit for bit. The OpenFAST correction iterations rewind them with the rest of the state. +.. _theory-dry-buoyancy: + Buoyancy and wetting ~~~~~~~~~~~~~~~~~~~~ @@ -1406,7 +1440,15 @@ laid node sinks into the penalty seabed along its normal by its static penetrati slope moves it horizontally by :math:`w_i\,(z_{,x}, z_{,y})/k_i`, with :math:`w_i` its nodal load: its share of the line's submerged weight, plus the net weight of a discrete attachment lumped at it (the finite-EI solve first smears an attachment over the two elements at its -node, then rebuilds the reference for the discrete loads before it polishes to them). Where +node, then rebuilds the reference for the discrete loads before it polishes to them). It is the +normal load the solver applies to the node resting at its laid position: a finite-EI section +that lies within its radius of the still-water level there (a seabed shallower than the cable +radius) carries the buoyancy of its dry part, as in the static solve and the dynamics +(:ref:`buoyancy recovery `), at the height the node sinks to under that +load, :math:`z_f - w_i s^2/k_i`, and an attachment above the level its dry weight. The seabed +lies below the still-water level everywhere (a positive ``WtrDpth`` and positive bathymetry +depths), so a grounded node with its attachment stays submerged; an ``EI = 0`` line, whose +submergence follows its node heights, is wholly submerged where it is grounded. Where the slope varies, the laid tension turns at every node and adds :math:`-T_\text{laid}\,(\mathbf{t}_{i}^{+} - \mathbf{t}_{i}^{-})\cdot\mathbf{n}_i` to the normal load (it presses the line into a crest and lifts it from a hollow), with diff --git a/examples/cabledyn_options_reference.dat b/examples/cabledyn_options_reference.dat index b9fc3128..a9f693e1 100644 --- a/examples/cabledyn_options_reference.dat +++ b/examples/cabledyn_options_reference.dat @@ -82,6 +82,7 @@ none waves - Wave model and parameters (m, s, deg) {none; airy; -- 0.5 frictionMuAxial - Seabed friction along the line axis {>=0} [default: frictionMu] -- 0.5 frictionMuLateral - Seabed friction across the line axis {>=0} [default: frictionMu] -- asLaid staticsFriction - Statics seabed friction policy {none; asLaid} [default: none] +-- mode1 axialDampingRatio - A negative BA is the damping ratio of {segment=each segment; mode1=the first axial mode} [default: segment] -- 0.0 layAzimuth - Lay azimuth of every line from +x toward +y (deg) [default: anchor -> fairlead] -- 225.0 layAzimuth2 - Lay azimuth of line 2 alone (deg) [default: layAzimuth] -- 0.0 asLaidTension - As-laid effective tension of every line (N) [default: 0] @@ -108,6 +109,7 @@ none waves - Wave model and parameters (m, s, deg) {none; airy; -- layAzimuth = lay_azimuth; asLaidTension = as_laid_tension -- dtM = dt; rhoInf = rho_inf; modified_newton = modifiedNewton; adaptive_mesh = adaptiveMesh -- cable_statics = cableStatics; alpha_force_blend = alphaForceBlend; OutputRecovery = output_recovery +-- axialDampingRatio = axial_damping_ratio -- maxStrain = max_strain; WaveSeed = wave_seed; rampTime = ramp_time = tRamp -- RangeStart = range_start -- cable_load_feedback = cableLoadFeedback; tensile_safety = tensileSafety diff --git a/python/cabledyn/deck_file.py b/python/cabledyn/deck_file.py index 5ba451b2..255916f9 100644 --- a/python/cabledyn/deck_file.py +++ b/python/cabledyn/deck_file.py @@ -266,6 +266,8 @@ "as_laid_tension": "as_laid_tension", "outputrecovery": "output_recovery", "output_recovery": "output_recovery", + "axialdampingratio": "axial_damping_ratio", + "axial_damping_ratio": "axial_damping_ratio", } # Per-line static friction rows (native apply_option): ``layAzimuth`` and ``asLaidTension`` # with the LINE id appended; the id is a plain decimal suffix, and leading zeros name the same line. @@ -1338,6 +1340,13 @@ def _scalar_option_value_error(keyword: str, value: str) -> str | None: if value.lower() in {"continuation", "sequenced"} else "must be continuation or sequenced" ) + if key == "axial_damping_ratio": + # native: the value is dequoted and compared case-insensitively + return ( + None + if _strip_quotes(value).lower() in {"segment", "mode1"} + else "must be segment or mode1" + ) if key == "output_recovery": return ( None diff --git a/python/tests/test_deck_file.py b/python/tests/test_deck_file.py index 25fea080..b5c2d1ba 100644 --- a/python/tests/test_deck_file.py +++ b/python/tests/test_deck_file.py @@ -673,6 +673,8 @@ def test_unknown_scalar_option_keyword_fails_closed(tmp_path): ("maybe", "alpha_force_blend", "native boolean"), ("relaxed", "cable_statics", "continuation or sequenced"), ("nodal", "OutputRecovery", "equilibrium or element"), + ("mode2", "axialDampingRatio", "segment or mode1"), + ("element", "axial_damping_ratio", "segment or mode1"), ("on", "ei0_substeps", "auto or off"), ("0", "ei0_substep_angle", r"\(0, 90\] deg"), ("91", "ei0SubstepAngle", r"\(0, 90\] deg"), @@ -758,6 +760,9 @@ def test_zero_e_exponent_waterkin_mode_is_accepted(tmp_path): "sequenced cableStatics", "equilibrium OutputRecovery", "element output_recovery", + "segment axialDampingRatio", + "mode1 axial_damping_ratio", + "MODE1 AXIALDAMPINGRATIO", "auto ei0_substeps", "off ei0Substeps", "0.5 ei0_substep_angle", diff --git a/python/tests/test_init_notes.py b/python/tests/test_init_notes.py index 645e347a..426e630c 100644 --- a/python/tests/test_init_notes.py +++ b/python/tests/test_init_notes.py @@ -4,6 +4,7 @@ from __future__ import annotations +import math import os import re import subprocess @@ -119,6 +120,21 @@ def test_the_notes_of_a_deck_on_both_routes(tmp_path): assert "LINE 1: dtM = 0.1000 s resolves its axial period" in notes +@pytest.mark.parametrize("ei", [0.0, 1.0e6], ids=["point", "aggregate"]) +def test_the_axial_damping_note_reaches_an_in_process_host(tmp_path, ei): + # BA = -1 is a damping ratio per segment: the note gives the first-mode ratio of the mesh + with CableDyn(_deck(tmp_path, ei=ei)) as model: + notes = [note for note in model.init_notes if "damping ratio per segment" in note] + assert len(notes) == 1 + match = re.search(r"at ([0-9.]+) % of critical on its ([0-9]+) elements", notes[0]) + assert match is not None, notes[0] + # zeta pi/(2N) on the uniform chain, N its final mesh + expected = 100.0 * math.pi / (2 * int(match.group(2))) + assert float(match.group(1)) == pytest.approx(expected, rel=1e-3) + with CableDyn(_deck(tmp_path, "mode1 axialDampingRatio", ei=ei, name="mode1.dat")) as model: + assert not [note for note in model.init_notes if "damping ratio per segment" in note] + + def test_a_note_of_the_parse_is_kept_once(tmp_path): # the deck is read twice, to find its route and to build it (tmp_path / "current_profile_dynamic.txt").write_text(CONSTANT_GRID, encoding="utf-8") diff --git a/src/CableDyn_Damping.f90 b/src/CableDyn_Damping.f90 index 03e4bdfb..04708243 100644 --- a/src/CableDyn_Damping.f90 +++ b/src/CableDyn_Damping.f90 @@ -21,7 +21,13 @@ MODULE CableDyn_Damping !! -- a non-negative value IS the coefficient (N.s); a NEGATIVE !! value is the desired damping ratio -zeta, giving BA = zeta * L_seg * sqrt(EA * w) !! (w = mass per unstretched metre), so each segment's axial mode carries that - !! fraction of critical damping. + !! fraction of critical damping. That ratio belongs to the segment, so the line's own axial + !! modes are damped less on a finer mesh (zeta_1 = zeta pi/(2N) on a uniform line of N + !! elements, CD_Axial_Mode1_Damping). The mesh-independent alternative + !! (CD_Resolve_Mode1_BA) makes -zeta the damping ratio of the line's first axial mode: + !! BA = 2 zeta EA / omega_1, a damping proportional to the stiffness, with omega_1 the + !! line's first axial frequency (CD_Axial_Mode1_Omega), so the first mode of a composite + !! line is damped at zeta too. !! !! Load convention (matches CD_Cable_Dynamic_Load_Proc / CableDyn_Hydro): the !! returned `force` is the external load to SUBTRACT from the residual, and @@ -33,6 +39,9 @@ MODULE CableDyn_Damping PRIVATE PUBLIC :: CD_Resolve_Legacy_BA + PUBLIC :: CD_Resolve_Mode1_BA + PUBLIC :: CD_Axial_Mode1_Omega + PUBLIC :: CD_Axial_Mode1_Damping PUBLIC :: CD_Cable_Axial_Damping_Force PUBLIC :: CD_Cable_Axial_Damping_Load PUBLIC :: CD_Axial_Damping_Element_Force @@ -78,6 +87,195 @@ SUBROUTINE CD_Resolve_Legacy_BA(ba_input, segment_length, ea, mass_per_length, b ba = (-ba_input)*segment_length*SQRT(ea*mass_per_length) END SUBROUTINE CD_Resolve_Legacy_BA + SUBROUTINE CD_Resolve_Mode1_BA(ba_input, ea, omega1, ba, ErrStat, ErrMsg) + !! Resolve a BA/-zeta line-type value with -zeta the damping ratio of the line's first axial + !! mode: BA = 2 zeta EA / omega_1 [N.s] on every element, the same for any mesh. The damping + !! is then proportional to the stiffness, so the axial mode n of a uniform line has the + !! ratio zeta omega_n / omega_1. ba_input >= 0 is the coefficient directly. + REAL(wp), INTENT(IN) :: ba_input !! BA value (negative => -zeta ratio of the first axial mode) + REAL(wp), INTENT(IN) :: ea !! axial stiffness EA of the element [N] (> 0 if -zeta) + REAL(wp), INTENT(IN) :: omega1 !! first axial frequency of the line [rad/s] (> 0 if -zeta) + REAL(wp), INTENT(OUT) :: ba !! resolved damping coefficient [N.s] + INTEGER, INTENT(OUT) :: ErrStat + CHARACTER(*), INTENT(OUT) :: ErrMsg + + ba = CD_ZERO + ErrStat = CD_DAMP_OK + ErrMsg = '' + IF (.NOT. CD_Is_Finite(ba_input)) THEN + CALL fail(ErrStat, ErrMsg, 'BA must be finite'); RETURN + END IF + IF (ba_input >= CD_ZERO) THEN + ba = ba_input + RETURN + END IF + IF (.NOT. (CD_Is_Finite(ea) .AND. ea > CD_ZERO) .OR. .NOT. (CD_Is_Finite(omega1) .AND. omega1 > CD_ZERO)) THEN + CALL fail(ErrStat, ErrMsg, 'resolving a -zeta first-mode damping ratio needs a positive EA and '// & + 'first axial frequency') + RETURN + END IF + ba = 2.0_wp*(-ba_input)*ea/omega1 + END SUBROUTINE CD_Resolve_Mode1_BA + + SUBROUTINE CD_Axial_Mode1_Omega(length, ea, mass_per_length, omega1, ErrStat, ErrMsg) + !! First axial natural frequency [rad/s] of a line of sections (unstretched length, EA and + !! dry mass per length each) fixed at both ends: the first mode of the axial chain of a + !! fixed mesh of the sections (CD_Axial_Mode1_Damping on MODE1_ELEMENTS elements shared by + !! the sections in proportion to their axial-wave transit times, at least + !! MODE1_SECTION_ELEMENTS each), so it does not depend on the line's own mesh. It is + !! (pi/L) sqrt(EA/m) on a uniform line, low by (pi/(2 MODE1_ELEMENTS))^2/6 = 1e-7. Added + !! mass is left out. + REAL(wp), INTENT(IN) :: length(:) !! section unstretched lengths [m] (> 0) + REAL(wp), INTENT(IN) :: ea(:) !! section EA [N] (> 0) + REAL(wp), INTENT(IN) :: mass_per_length(:) !! section dry mass per length [kg/m] (> 0) + REAL(wp), INTENT(OUT) :: omega1 + INTEGER, INTENT(OUT) :: ErrStat + CHARACTER(*), INTENT(OUT) :: ErrMsg + INTEGER, PARAMETER :: MODE1_ELEMENTS = 2048, MODE1_SECTION_ELEMENTS = 16 + REAL(wp), ALLOCATABLE :: l0(:), ea_e(:), m_e(:), ba_e(:) + REAL(wp) :: transit, zeta1 + INTEGER :: i, j, e, ns + INTEGER, ALLOCATABLE :: n_sec(:) + + omega1 = CD_ZERO + ErrStat = CD_DAMP_OK + ErrMsg = '' + ns = SIZE(length) + IF (ns < 1 .OR. SIZE(ea) /= ns .OR. SIZE(mass_per_length) /= ns) THEN + CALL fail(ErrStat, ErrMsg, 'the first axial frequency needs one length, EA and mass per section'); RETURN + END IF + DO i = 1, ns + IF (.NOT. (CD_Is_Finite(length(i)) .AND. length(i) > CD_ZERO .AND. CD_Is_Finite(ea(i)) .AND. & + ea(i) > CD_ZERO .AND. CD_Is_Finite(mass_per_length(i)) .AND. mass_per_length(i) > CD_ZERO)) THEN + CALL fail(ErrStat, ErrMsg, 'the first axial frequency needs a positive length, EA and mass per length'); RETURN + END IF + END DO + transit = SUM(length*SQRT(mass_per_length/ea)) + IF (.NOT. (CD_Is_Finite(transit) .AND. transit > CD_ZERO)) THEN + CALL fail(ErrStat, ErrMsg, 'the first axial frequency is not finite'); RETURN + END IF + ALLOCATE (n_sec(ns)) + DO i = 1, ns + n_sec(i) = MAX(MODE1_SECTION_ELEMENTS, NINT(REAL(MODE1_ELEMENTS, wp)*length(i)*SQRT(mass_per_length(i)/ea(i))/ & + transit)) + END DO + ALLOCATE (l0(SUM(n_sec)), ea_e(SUM(n_sec)), m_e(SUM(n_sec)), ba_e(SUM(n_sec))) + e = 0 + DO i = 1, ns + DO j = 1, n_sec(i) + e = e + 1 + l0(e) = length(i)/REAL(n_sec(i), wp) + ea_e(e) = ea(i) + m_e(e) = mass_per_length(i) + END DO + END DO + ba_e = CD_ZERO + CALL CD_Axial_Mode1_Damping(l0, ea_e, m_e, ba_e, zeta1, omega1, ErrStat, ErrMsg) + IF (ErrStat /= CD_DAMP_OK) RETURN + IF (.NOT. (CD_Is_Finite(omega1) .AND. omega1 > CD_ZERO)) THEN + omega1 = CD_ZERO + CALL fail(ErrStat, ErrMsg, 'the first axial frequency is not finite'); RETURN + END IF + END SUBROUTINE CD_Axial_Mode1_Omega + + SUBROUTINE CD_Axial_Mode1_Damping(l0, ea, mass_per_length, ba, zeta1, omega1, ErrStat, ErrMsg) + !! Damping ratio zeta_1 and frequency omega_1 [rad/s] of the first axial mode of a line of + !! elements (unstretched length, EA, dry mass per length and resolved BA each) fixed at both + !! ends: the axial chain of the mesh, element stiffness EA/L0 and damping BA/L0, the mass + !! lumped at the nodes. The undamped first mode u (inverse iteration) gives + !! omega_1^2 = u'Ku / u'Mu and zeta_1 = u'Cu / (2 omega_1 u'Mu). On a uniform line with + !! BA = zeta L0 sqrt(EA m), zeta_1 = zeta sin(pi/(2N)) ~ zeta pi/(2N). A one-element line, + !! which has no free node, takes the continuous bar: omega_1 = (pi/L0) sqrt(EA/m). + REAL(wp), INTENT(IN) :: l0(:), ea(:), mass_per_length(:), ba(:) + REAL(wp), INTENT(OUT) :: zeta1, omega1 + INTEGER, INTENT(OUT) :: ErrStat + CHARACTER(*), INTENT(OUT) :: ErrMsg + REAL(wp), PARAMETER :: PI = 3.14159265358979323846_wp + INTEGER, PARAMETER :: MAX_ITER = 2000 + REAL(wp), PARAMETER :: RAYLEIGH_TOL = 1.0e-14_wp + REAL(wp), ALLOCATABLE :: k(:), c(:), m(:), u(:), rhs(:), cp(:), dp(:) + REAL(wp) :: ukk, umm, ucc, rq, rq_old, denom + INTEGER :: n, i, it + + zeta1 = CD_ZERO + omega1 = CD_ZERO + ErrStat = CD_DAMP_OK + ErrMsg = '' + n = SIZE(l0) + IF (n < 1 .OR. SIZE(ea) /= n .OR. SIZE(mass_per_length) /= n .OR. SIZE(ba) /= n) THEN + CALL fail(ErrStat, ErrMsg, 'the first axial mode needs one length, EA, mass and BA per element'); RETURN + END IF + DO i = 1, n + IF (.NOT. (CD_Is_Finite(l0(i)) .AND. l0(i) > CD_ZERO .AND. CD_Is_Finite(ea(i)) .AND. ea(i) > CD_ZERO .AND. & + CD_Is_Finite(mass_per_length(i)) .AND. mass_per_length(i) > CD_ZERO .AND. & + CD_Is_Finite(ba(i)) .AND. ba(i) >= CD_ZERO)) THEN + CALL fail(ErrStat, ErrMsg, 'the first axial mode needs a positive length, EA and mass and a '// & + 'non-negative BA on every element'); RETURN + END IF + END DO + IF (n == 1) THEN + omega1 = (PI/l0(1))*SQRT(ea(1)/mass_per_length(1)) + zeta1 = ba(1)*omega1/(2.0_wp*ea(1)) + RETURN + END IF + ! element stiffness and damping, node masses of the n - 1 free nodes (node i joins + ! elements i and i + 1) + ALLOCATE (k(n), c(n), m(n - 1), u(n - 1), rhs(n - 1), cp(n - 1), dp(n - 1)) + k = ea/l0 + c = ba/l0 + DO i = 1, n - 1 + m(i) = 0.5_wp*(mass_per_length(i)*l0(i) + mass_per_length(i + 1)*l0(i + 1)) + END DO + u = CD_ONE + rq_old = -CD_ONE + DO it = 1, MAX_ITER + ! solve K y = M u (K tridiagonal, symmetric positive definite: Thomas without pivoting) + rhs = m*u + cp(1) = -k(2)/(k(1) + k(2)) + dp(1) = rhs(1)/(k(1) + k(2)) + DO i = 2, n - 1 + denom = (k(i) + k(i + 1)) + k(i)*cp(i - 1) + IF (i < n - 1) cp(i) = -k(i + 1)/denom + dp(i) = (rhs(i) + k(i)*dp(i - 1))/denom + END DO + u(n - 1) = dp(n - 1) + DO i = n - 2, 1, -1 + u(i) = dp(i) - cp(i)*u(i + 1) + END DO + u = u/MAXVAL(ABS(u)) + CALL forms(u, ukk, umm, ucc) + rq = ukk/umm + IF (ABS(rq - rq_old) <= RAYLEIGH_TOL*rq) EXIT + rq_old = rq + END DO + omega1 = SQRT(rq) + zeta1 = ucc/(2.0_wp*omega1*umm) + IF (.NOT. (CD_Is_Finite(omega1) .AND. CD_Is_Finite(zeta1))) THEN + zeta1 = CD_ZERO + omega1 = CD_ZERO + CALL fail(ErrStat, ErrMsg, 'the first axial mode is not finite'); RETURN + END IF + + CONTAINS + + SUBROUTINE forms(x, xkx, xmx, xcx) + !! The quadratic forms of K, M and C at the free-node displacements x (both ends held). + REAL(wp), INTENT(IN) :: x(:) + REAL(wp), INTENT(OUT) :: xkx, xmx, xcx + REAL(wp) :: dx + INTEGER :: e + ! the end elements stretch by the displacement of their free node alone + xkx = k(1)*x(1)**2 + k(n)*x(n - 1)**2 + xcx = c(1)*x(1)**2 + c(n)*x(n - 1)**2 + DO e = 2, n - 1 + dx = x(e) - x(e - 1) + xkx = xkx + k(e)*dx*dx + xcx = xcx + c(e)*dx*dx + END DO + xmx = SUM(m*x*x) + END SUBROUTINE forms + END SUBROUTINE CD_Axial_Mode1_Damping + SUBROUTINE CD_Cable_Element_Damping_Tension(q, v, elem_conn, l0, ba, td, ErrStat, ErrMsg, l0_dot) !! Signed per-element axial damping tension Td = (BA/L0)(t . (v_b - v_a)). !! Positive when the element is stretching, negative when shortening; zero at rest. diff --git a/src/CableDyn_DeckDriver.f90 b/src/CableDyn_DeckDriver.f90 index 0e6abd55..84ed52e7 100644 --- a/src/CableDyn_DeckDriver.f90 +++ b/src/CableDyn_DeckDriver.f90 @@ -47,7 +47,8 @@ MODULE CableDyn_DeckDriver CD_Nodal_Seabed_Stiffness, CD_LINE_OK USE CableDyn_Catenary, ONLY: CD_Catenary_Seed, CD_CAT_OK, CD_CAT_NOSEED USE CableDyn_Linalg, ONLY: CD_Solve_Dense_As_Banded, CD_LINALG_OK - USE CableDyn_Damping, ONLY: CD_Resolve_Legacy_BA, CD_DAMP_OK + USE CableDyn_Damping, ONLY: CD_Resolve_Legacy_BA, CD_Resolve_Mode1_BA, CD_Axial_Mode1_Omega, & + CD_Axial_Mode1_Damping, CD_DAMP_OK USE CableDyn_Syrope, ONLY: CD_SYROPE_WC_LINEAR, CD_SYROPE_WC_QUADRATIC, CD_SYROPE_WC_EXP, & CD_SyropeType, CD_Syrope_Init, CD_Syrope_End, & CD_Syrope_Static_Tension, CD_Syrope_Slow_For_Tension, CD_SYROPE_OK, & @@ -785,6 +786,10 @@ MODULE CableDyn_DeckDriver ! effective tension, curvature and bend moment from nodal equilibrium; 'element' reports the ! element-mean axial force EA (|r'| - 1) and the exact one-sided curvature traces. LOGICAL :: output_element_recovery = .FALSE. + ! A negative LINE TYPES BA (axialDampingRatio): 'segment' (default, MoorDyn's convention) + ! is the damping ratio of each segment, BA = zeta L0 sqrt(EA m) per element; 'mode1' is the + ! damping ratio of the line's first axial mode, BA = 2 zeta EA / omega_1 (CD_Resolve_Mode1_BA). + LOGICAL :: axial_damping_mode1 = .FALSE. INTEGER :: tensile_mode = CD_HCDYN_TENSILE_OFF REAL(wp) :: tensile_strain_tolerance = 2.0e-6_wp ! HOST-DRIVEN AMBIENT FLUID (not a deck keyword): set by CD_Init_Deck_Aggregate when @@ -1179,6 +1184,10 @@ MODULE CableDyn_DeckDriver ! seabed_drift: a current moves the line along a seabed without friction (seabed_drift_note); ! friction_refused: the line's route rejects frictionMu (FOLD_FRICTION_NONE). LOGICAL :: seabed_drift = .FALSE., friction_refused = .FALSE. + ! axial_zeta1: the damping ratio of the first axial mode of the built line, with both ends + ! held, on its axial_elements elements (summary_axial_damping); -1 when not worked out. + REAL(wp) :: axial_zeta1 = -1.0_wp + INTEGER :: axial_elements = 0 END TYPE CD_LineInitSummary TYPE :: CD_DeckAggregateType @@ -1619,6 +1628,9 @@ SUBROUTINE capture_system_notes(lines, points, sections, types, opts, system, dt CALL axial_period_note(summaries(i)%line_id, dt, sections, types, note) CALL capture_note(note) END IF + ! the caller marches the system, with the deck's step or its own + CALL axial_damping_note(summaries(i), sections, types, opts, note) + CALL capture_note(note) END DO IF (ANY(summaries%seabed_drift)) THEN CALL seabed_drift_note(PACK(summaries%line_id, summaries%seabed_drift), & @@ -1844,6 +1856,7 @@ RECURSIVE SUBROUTINE build_one_hermite_cable(ln, sections, types, points, opts, 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) :: mode1_omega 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 REAL(wp) :: dxh, dyh, hspan, frame_cs(2), horizontal_tension, grounded_length @@ -3221,11 +3234,24 @@ RECURSIVE SUBROUTINE build_one_hermite_cable(ln, sections, types, points, opts, CALL MOVE_ALLOC(w_am, w) CALL MOVE_ALLOC(fixed_am, fixed_dofs) ALLOCATE (ba(SIZE(l0))) + ! OPTION axialDampingRatio mode1: a negative BA is the damping ratio of the line's first + ! axial mode, set by the deck sections whatever the mesh + mode1_omega = CD_ZERO + IF (opts%axial_damping_mode1 .AND. ANY(ba_raw < CD_ZERO)) THEN + CALL line_mode1_omega(ln%id, sections, types, mode1_omega, es, em) + IF (es /= CD_DECKDRV_OK) THEN + CALL fail(ErrStat, ErrMsg, TRIM(em)); RETURN + END IF + END IF DO i = 1, SIZE(l0) ! Resolve negative damping-ratio inputs only after adaptive remeshing because ! BA = zeta*l0*sqrt(EA*mass_per_length) is defined for the final element length. ! A direct positive BA remains a mesh-independent constitutive coefficient. - CALL CD_Resolve_Legacy_BA(ba_raw(i), l0(i), ea(i), rho_a(i), ba(i), es, em) + IF (opts%axial_damping_mode1) THEN + CALL CD_Resolve_Mode1_BA(ba_raw(i), ea(i), mode1_omega, ba(i), es, em) + ELSE + CALL CD_Resolve_Legacy_BA(ba_raw(i), l0(i), ea(i), rho_a(i), ba(i), es, em) + END IF IF (es /= CD_DAMP_OK) THEN CALL fail(ErrStat, ErrMsg, 'finite-EI BA resolution failed: '//TRIM(em)); RETURN END IF @@ -3257,16 +3283,20 @@ RECURSIVE SUBROUTINE build_one_hermite_cable(ln, sections, types, points, opts, ! friction deflection along a slope, beyond the slope load its spring carries at rest. IF (as_laid .AND. PRESENT(bathymetry)) THEN BLOCK - REAL(wp), ALLOCATABLE :: node_load(:) - ALLOCATE (node_load(SIZE(l0) + 1)) + REAL(wp), ALLOCATABLE :: node_load(:), node_dry(:) + ALLOCATE (node_load(SIZE(l0) + 1), node_dry(SIZE(l0) + 1)) node_load = CD_ZERO + node_dry = CD_ZERO DO i = 1, SIZE(l0) node_load(i:i + 1) = node_load(i:i + 1) + 0.5_wp*w_bare(i)*l0(i) END DO + ! the net weight of each attachment, and the buoyancy it has not above the surface + ! (attachment_static_weight) DO i = 1, SIZE(att_node) node_load(att_node(i)) = node_load(att_node(i)) + (ln%att(2, i) - opts%rhoW*ln%att(3, i))*opts%g + node_dry(att_node(i)) = node_dry(att_node(i)) + opts%rhoW*ln%att(3, i)*opts%g END DO - CALL as_laid_reference(es, em, node_load) + CALL as_laid_reference(es, em, node_load, node_dry) END BLOCK IF (es /= CD_DECKDRV_OK) THEN CALL fail_solve(ErrStat, ErrMsg, 'finite-EI as-laid reference for the seabed friction with discrete '// & @@ -5138,7 +5168,7 @@ LOGICAL FUNCTION as_laid_cross_slope() RESULT(cross) END DO END FUNCTION as_laid_cross_slope - SUBROUTINE as_laid_reference(esr, emr, node_load) + SUBROUTINE as_laid_reference(esr, emr, node_load, node_dry_load) !! Friction reference of the static solve (CD_HermiteCable_As_Laid_Offsets): the line laid !! on the seabed from its lower end (the anchor, node 1, unless the fairlead is lower, as in !! the EI = 0 line model) along the lay azimuth at the as-laid tension, as (x, y) offsets @@ -5152,9 +5182,13 @@ SUBROUTINE as_laid_reference(esr, emr, node_load) !! dynamic hand-off does on the final mesh. node_load [N, downward positive, one entry per !! node]: the discrete loads of an attachment polish on the final mesh l0, which hold on !! that mesh alone; the reference is then this profile (default: the lumped weights w). + !! node_dry_load (with node_load): the attachments' buoyancy at each node, which a node + !! laid above the still-water level does not have. On a bathymetry a node sinks under the + !! normal load the solver applies at its laid position, the dry part of a section laid + !! within its radius of the surface included (the friction's laid_* dry-part data). INTEGER, INTENT(OUT) :: esr CHARACTER(*), INTENT(OUT) :: emr - REAL(wp), INTENT(IN), OPTIONAL :: node_load(:) + REAL(wp), INTENT(IN), OPTIONAL :: node_load(:), node_dry_load(:) REAL(wp), ALLOCATABLE :: wn(:), kn_r(:), offsets(:, :) REAL(wp) :: laid_t, az INTEGER :: k, ne_r, es_r @@ -5180,6 +5214,15 @@ SUBROUTINE as_laid_reference(esr, emr, node_load) cur_obj%friction%laid_azimuth = az cur_obj%friction%laid_tension = laid_t cur_obj%friction%laid_frame_cs = frame_cs + ! the dry part of the line at the still-water level z = 0, the diameter by reference arc + cur_obj%friction%laid_water_weight = opts%rhoW*opts%g + cur_obj%friction%laid_waterline_z = CD_ZERO + ALLOCATE (cur_obj%friction%laid_arc_end(ne_r), cur_obj%friction%laid_diam(ne_r)) + cur_obj%friction%laid_arc_end(1) = l0(1) + DO k = 2, ne_r + cur_obj%friction%laid_arc_end(k) = cur_obj%friction%laid_arc_end(k - 1) + l0(k) + END DO + cur_obj%friction%laid_diam = diam(1:ne_r) ! the nodal loads and seabed stiffnesses the nodes of mesh l0 sink under ALLOCATE (wn(ne_r + 1), kn_r(ne_r + 1), offsets(2, ne_r + 1)) wn = CD_ZERO @@ -5194,7 +5237,10 @@ SUBROUTINE as_laid_reference(esr, emr, node_load) wn(k:k + 1) = wn(k:k + 1) + 0.5_wp*w(k)*l0(k) END DO END IF - IF (PRESENT(bathymetry)) THEN + IF (PRESENT(bathymetry) .AND. PRESENT(node_dry_load)) THEN + CALL CD_HermiteCable_As_Laid_Offsets(cur_obj%friction, l0, ea, wn, kn_r, offsets, es_r, emr, bathymetry, & + node_dry_load=node_dry_load) + ELSE IF (PRESENT(bathymetry)) THEN CALL CD_HermiteCable_As_Laid_Offsets(cur_obj%friction, l0, ea, wn, kn_r, offsets, es_r, emr, bathymetry) ELSE CALL CD_HermiteCable_As_Laid_Offsets(cur_obj%friction, l0, ea, wn, kn_r, offsets, es_r, emr) @@ -8571,6 +8617,8 @@ SUBROUTINE CD_Init_Deck_Aggregate(deck_path, dt, agg, ErrStat, ErrMsg, env_gravi IF (static_only) CYCLE CALL axial_period_note(agg%init_lines(il)%line_id, dt, sections, types, strain_note) IF (LEN_TRIM(strain_note) > 0) CALL append_note_line(agg%init_lines(il)%note, strain_note) + CALL axial_damping_note(agg%init_lines(il), sections, types, opts, strain_note) + IF (LEN_TRIM(strain_note) > 0) CALL append_note_line(agg%init_lines(il)%note, strain_note) END DO IF (own_current) CALL warn_coarse_sections(lines, sections) END BLOCK @@ -10008,9 +10056,9 @@ RECURSIVE SUBROUTINE init_one_model(ln, sections, types, points, opts, model, Er REAL(wp), ALLOCATABLE :: ve_ead(:), ve_bas(:), ve_bad(:), ve_ambl(:), ve_vbet(:) REAL(wp), ALLOCATABLE :: viv_cl(:), viv_cf(:), viv_df(:) LOGICAL, ALLOCATABLE :: syr_el(:) - REAL(wp) :: anchor(3), fairlead(3) + REAL(wp) :: anchor(3), fairlead(3), mode1_omega REAL(wp), PARAMETER :: factors(4) = [0.25_wp, 0.5_wp, 0.75_wp, CD_ONE] - INTEGER :: j, i, e, es + INTEGER :: j, i, e, er, es LOGICAL :: want_wave_cfg CHARACTER(1024) :: em ! static seabed friction of this line: lay azimuth override [rad] (unallocated: the @@ -10054,12 +10102,31 @@ RECURSIVE SUBROUTINE init_one_model(ln, sections, types, points, opts, model, Er ve_bad = CD_ZERO ve_ambl = CD_ZERO ve_vbet = CD_ZERO + ! OPTION axialDampingRatio mode1: a negative BA is the damping ratio of the line's first + ! axial mode, set by the deck sections whatever the mesh + mode1_omega = CD_ZERO + IF (opts%axial_damping_mode1) THEN + IF (ANY([(types(line_section_type(sections, ln%id, i))%ba < CD_ZERO, i=1, SIZE(secs))])) THEN + CALL line_mode1_omega(ln%id, sections, types, mode1_omega, es, em) + IF (es /= CD_DECKDRV_OK) THEN + CALL fail(ErrStat, ErrMsg, TRIM(em)); RETURN + END IF + END IF + END IF e = 0 DO i = 1, SIZE(secs) DO j = 1, secs(i)%n_segments e = e + 1 - CALL CD_Resolve_Legacy_BA(types(line_section_type(sections, ln%id, i))%ba, l0(e), ea(e), mpl(e), & - ba(e), es, em) + ! e counts the elements from End A, as the per-element arrays filled here (reversed + ! below); the mesh l0, ea, mpl runs from the anchor, End B: element e is er there + er = SIZE(l0) + 1 - e + IF (opts%axial_damping_mode1) THEN + CALL CD_Resolve_Mode1_BA(types(line_section_type(sections, ln%id, i))%ba, ea(er), mode1_omega, ba(e), & + es, em) + ELSE + CALL CD_Resolve_Legacy_BA(types(line_section_type(sections, ln%id, i))%ba, l0(er), ea(er), mpl(er), & + ba(e), es, em) + END IF IF (es /= CD_DAMP_OK) THEN CALL fail(ErrStat, ErrMsg, 'BA resolution for model init: '//TRIM(em)); RETURN END IF @@ -12371,6 +12438,117 @@ SUBROUTINE axial_period_note(line_id, dt, sections, types, note) 'can be wrong. A dtM of at most '//TRIM(ADJUSTL(b4))//' s resolves them' END SUBROUTINE axial_period_note + SUBROUTINE line_mode1_omega(line_id, sections, types, omega1, ErrStat, ErrMsg) + !! The first axial frequency [rad/s] that OPTION axialDampingRatio mode1 sets a negative BA + !! of the line by: the first axial mode of the line fixed at both ends, from its deck + !! sections (CD_Axial_Mode1_Omega: unstretched lengths, EA, dry mass per length, on a fixed + !! internal mesh), so it does not depend on the line's mesh. A section whose axial stiffness is not one EA + !! (viscoelastic ElasticMod 2 or 3, Syrope) fails by name: its first axial mode is not set + !! by one BA. + INTEGER, INTENT(IN) :: line_id + TYPE(DeckSection), INTENT(IN) :: sections(:) + TYPE(DeckLineType), INTENT(IN) :: types(:) + REAL(wp), INTENT(OUT) :: omega1 + INTEGER, INTENT(OUT) :: ErrStat + CHARACTER(*), INTENT(OUT) :: ErrMsg + REAL(wp), ALLOCATABLE :: len_s(:), ea_s(:), m_s(:) + INTEGER :: j, k, es + CHARACTER(1024) :: em + + ErrStat = CD_DECKDRV_OK + ErrMsg = '' + omega1 = CD_ZERO + ALLOCATE (len_s(0), ea_s(0), m_s(0)) + DO j = 1, SIZE(sections) + IF (sections(j)%line_id /= line_id) CYCLE + k = find_type(types, sections(j)%ltype_name) + IF (k < 1) THEN + CALL fail(ErrStat, ErrMsg, 'internal: LINE '//TRIM(int_to_str(line_id))//' has a section of an unknown type') + RETURN + END IF + IF (types(k)%is_syrope .OR. types(k)%elastic_mod > 1) THEN + CALL fail(ErrStat, ErrMsg, 'OPTION axialDampingRatio mode1: LINE '//TRIM(int_to_str(line_id))// & + ' has a negative BA and the section type '//TRIM(types(k)%name)//', whose axial stiffness is '// & + 'viscoelastic or a Syrope working curve: the damping ratio of its first axial mode is not set by '// & + 'one BA. Give BA in N s or use axialDampingRatio segment') + RETURN + END IF + len_s = [len_s, sections(j)%length] + ea_s = [ea_s, types(k)%ea] + m_s = [m_s, types(k)%mass] + END DO + CALL CD_Axial_Mode1_Omega(len_s, ea_s, m_s, omega1, es, em) + IF (es /= CD_DAMP_OK) THEN + CALL fail(ErrStat, ErrMsg, 'OPTION axialDampingRatio mode1: LINE '//TRIM(int_to_str(line_id))//': '//TRIM(em)) + RETURN + END IF + END SUBROUTINE line_mode1_omega + + SUBROUTINE axial_damping_note(summary, sections, types, opts, note) + !! A line whose negative BA is the damping ratio of each segment (MoorDyn's convention, the + !! default of OPTION axialDampingRatio): the damping ratio this gives the line's first axial + !! mode, from the line's final mesh and resolved BA (summary%axial_zeta1, + !! CD_Axial_Mode1_Damping: the line fixed at both ends), with the number of elements, since + !! it falls as the mesh is refined (zeta pi/(2N) on a uniform line). A line with a + !! viscoelastic or Syrope section is noted without the ratio. Only a note: nothing is changed. + TYPE(CD_LineInitSummary), INTENT(IN) :: summary + TYPE(DeckSection), INTENT(IN) :: sections(:) + TYPE(DeckLineType), INTENT(IN) :: types(:) + TYPE(DeckOptions), INTENT(IN) :: opts + CHARACTER(*), INTENT(OUT) :: note + INTEGER :: j, k + LOGICAL :: negative, simple + CHARACTER(32) :: b1 + + note = '' + IF (opts%axial_damping_mode1) RETURN + negative = .FALSE. + simple = .TRUE. + DO j = 1, SIZE(sections) + IF (sections(j)%line_id /= summary%line_id) CYCLE + k = find_type(types, sections(j)%ltype_name) + IF (k < 1) RETURN + IF (types(k)%ba < CD_ZERO) negative = .TRUE. + IF (types(k)%is_syrope .OR. types(k)%elastic_mod > 1) simple = .FALSE. + END DO + IF (.NOT. negative) RETURN + note = 'LINE '//TRIM(int_to_str(summary%line_id))//': its negative BA is a damping ratio per segment, BA = '// & + 'zeta L0 sqrt(EA m) on each element' + IF (simple .AND. summary%axial_zeta1 >= CD_ZERO .AND. summary%axial_elements > 0) THEN + IF (100.0_wp*summary%axial_zeta1 >= 0.01_wp) THEN + WRITE (b1, '(F12.3)') 100.0_wp*summary%axial_zeta1 + ELSE + WRITE (b1, '(ES10.3)') 100.0_wp*summary%axial_zeta1 + END IF + note = TRIM(note)//', which damps the first axial mode of the line (both ends held) at '// & + TRIM(ADJUSTL(b1))//' % of critical on its '//TRIM(int_to_str(summary%axial_elements))// & + ' elements (zeta pi/(2N) on a uniform line of N elements): the axial damping depends on the mesh' + ELSE + note = TRIM(note)//': the axial damping of the line depends on the mesh' + END IF + note = TRIM(note)//'. With OPTION mode1 axialDampingRatio a negative BA is the damping ratio of the '// & + 'first axial mode, the same on any mesh' + END SUBROUTINE axial_damping_note + + SUBROUTINE summary_axial_damping(summary, l0, ea, mass_per_length, ba) + !! The damping ratio of the first axial mode of a built line (CD_Axial_Mode1_Damping), for its + !! initialisation note (axial_damping_note); left unset (-1) when it cannot be worked out. + TYPE(CD_LineInitSummary), INTENT(INOUT) :: summary + REAL(wp), INTENT(IN) :: l0(:), ea(:), mass_per_length(:), ba(:) + REAL(wp) :: zeta1, omega1 + INTEGER :: es + CHARACTER(256) :: em + + summary%axial_zeta1 = -CD_ONE + summary%axial_elements = 0 + IF (SIZE(l0) < 1 .OR. SIZE(ea) /= SIZE(l0) .OR. SIZE(mass_per_length) /= SIZE(l0) .OR. & + SIZE(ba) /= SIZE(l0)) RETURN + CALL CD_Axial_Mode1_Damping(l0, ea, mass_per_length, ba, zeta1, omega1, es, em) + IF (es /= CD_DAMP_OK) RETURN + summary%axial_zeta1 = zeta1 + summary%axial_elements = SIZE(l0) + END SUBROUTINE summary_axial_damping + SUBROUTINE warn_line_below_anchor(lines, points, sections, q_all, q_off) !! Standard-output WARNING for a deck with no seabed (no WtrDpth or bathymetryFile) on !! which a line hangs below its lowest Fixed end by more than max(1 m, 1 % of its @@ -17263,6 +17441,17 @@ SUBROUTINE apply_option(line, opts, ErrStat, ErrMsg) CASE DEFAULT CALL fail(ErrStat, ErrMsg, 'OPTION OutputRecovery "'//TRIM(val)//'" must be equilibrium or element') END SELECT + CASE ('axialdampingratio', 'axial_damping_ratio') + ! what a negative LINE TYPES BA is the damping ratio of: each segment (MoorDyn) or the + ! line's first axial mode + SELECT CASE (to_lower(TRIM(strip_quotes(val)))) + CASE ('segment') + opts%axial_damping_mode1 = .FALSE. + CASE ('mode1') + opts%axial_damping_mode1 = .TRUE. + CASE DEFAULT + CALL fail(ErrStat, ErrMsg, 'OPTION axialDampingRatio "'//TRIM(val)//'" must be segment or mode1') + END SELECT CASE ('cable_load_feedback', 'cableloadfeedback') CALL rd_bool(val, opts%cable_load_feedback, ErrStat, ErrMsg) CASE ('predict_loads', 'predictloads') @@ -36810,6 +36999,7 @@ SUBROUTINE collect_aggregate_init_summaries(lines, agg, ErrStat, ErrMsg) RETURN END IF CALL set_init_summary(lines(i)%id, tension, declination, azimuth, agg%init_lines(i), fair_force=fair_force) + CALL cable_axial_damping(agg%init_lines(i), agg%cables(agg%line_obj_index(lines(i)%id))) IF (ALLOCATED(agg%cable_note)) agg%init_lines(i)%note = agg%cable_note(agg%line_obj_index(lines(i)%id)) ELSE IF (agg%has_sys) THEN ! The force the EI=0 line exerts on its fairlead (internal last node), as the @@ -36822,6 +37012,7 @@ SUBROUTINE collect_aggregate_init_summaries(lines, agg, ErrStat, ErrMsg) RETURN END IF CALL set_init_summary(lines(i)%id, tension, declination, azimuth, agg%init_lines(i), fair_force=fair_force) + CALL model_axial_damping(agg%init_lines(i), agg%sys%lines(agg%line_obj_index(lines(i)%id))) ELSE CALL set_init_summary(lines(i)%id, tension, declination, azimuth, agg%init_lines(i)) END IF @@ -36889,6 +37080,7 @@ SUBROUTINE collect_model_init_summaries(lines, points, models, summaries, ErrSta RETURN END IF CALL set_init_summary(lines(i)%id, tension, declination, azimuth, summaries(i), fair_force=fair_force) + CALL model_axial_damping(summaries(i), models(i)) END DO IF (PRESENT(opts)) CALL add_model_fold_notes(lines, points, opts, models, summaries, FOLD_FRICTION_FULL) END SUBROUTINE collect_model_init_summaries @@ -36929,6 +37121,7 @@ SUBROUTINE collect_system_init_summaries(lines, points, system, summaries, ErrSt RETURN END IF CALL set_init_summary(lines(i)%id, tension, declination, azimuth, summaries(i), fair_force=fair_force) + CALL model_axial_damping(summaries(i), system%lines(i)) END DO IF (PRESENT(opts)) THEN IF (PRESENT(friction_support)) THEN @@ -36964,9 +37157,29 @@ SUBROUTINE collect_hermite_init_summaries(lines, cables, summaries, opts, fricti CALL set_init_summary(lines(i)%id, tension, declination, azimuth, summaries(i), fair_force=fair_force) summaries(i)%seabed_drift = cable_seabed_drift(opts, cables(i)) summaries(i)%friction_refused = friction_support == FOLD_FRICTION_NONE + CALL cable_axial_damping(summaries(i), cables(i)) END DO END SUBROUTINE collect_hermite_init_summaries + SUBROUTINE model_axial_damping(summary, model) + !! summary_axial_damping of an EI = 0 line: its plain axial damping (zero on viscoelastic and + !! Syrope elements, whose own laws carry theirs). + TYPE(CD_LineInitSummary), INTENT(INOUT) :: summary + TYPE(CD_ModelType), INTENT(IN) :: model + IF (.NOT. (ALLOCATED(model%ba_dyn) .AND. ALLOCATED(model%l0) .AND. ALLOCATED(model%ea) .AND. & + ALLOCATED(model%rho_a))) RETURN + CALL summary_axial_damping(summary, model%l0, model%ea, model%rho_a, model%ba_dyn) + END SUBROUTINE model_axial_damping + + SUBROUTINE cable_axial_damping(summary, cable) + !! summary_axial_damping of a finite-EI cable, on its final mesh. + TYPE(CD_LineInitSummary), INTENT(INOUT) :: summary + TYPE(CD_HFMF_ModuleType), INTENT(IN) :: cable + IF (.NOT. (ALLOCATED(cable%line%BA) .AND. ALLOCATED(cable%line%l0) .AND. ALLOCATED(cable%line%EA) .AND. & + ALLOCATED(cable%line%rho_a))) RETURN + CALL summary_axial_damping(summary, cable%line%l0, cable%line%EA, cable%line%rho_a, cable%line%BA) + END SUBROUTINE cable_axial_damping + SUBROUTINE print_deck_init_report(deck_path, lines, points, sections, n_finite, summaries, types, opts) !! The initialization report goes to stderr (see doc/cli.rst). CHARACTER(*), INTENT(IN) :: deck_path @@ -37025,6 +37238,8 @@ SUBROUTINE print_deck_init_report(deck_path, lines, points, sections, n_finite, IF (opts%has_dtm .AND. opts%tmax > CD_ZERO) THEN CALL axial_period_note(summaries(i)%line_id, opts%dtM, sections, types, strain_note) IF (LEN_TRIM(strain_note) > 0) WRITE (error_unit, '(A)') ' Note: '//TRIM(strain_note)//'.' + CALL axial_damping_note(summaries(i), sections, types, opts, strain_note) + IF (LEN_TRIM(strain_note) > 0) WRITE (error_unit, '(A)') ' Note: '//TRIM(strain_note)//'.' END IF END IF END DO diff --git a/src/CableDyn_HermiteCableStatic.f90 b/src/CableDyn_HermiteCableStatic.f90 index 4aa6374b..975c5f0c 100644 --- a/src/CableDyn_HermiteCableStatic.f90 +++ b/src/CableDyn_HermiteCableStatic.f90 @@ -206,6 +206,13 @@ MODULE CableDyn_HermiteCableStatic REAL(wp) :: laid_origin(2) = 0.0_wp, laid_node1(2) = 0.0_wp REAL(wp) :: laid_azimuth = 0.0_wp, laid_tension = 0.0_wp REAL(wp) :: laid_frame_cs(2) = [1.0_wp, 0.0_wp] + ! The dry part of a laid line (laid_water_weight > 0, on a bathymetry): the nodes of a line + ! laid within its section radius of the still-water level laid_waterline_z sink under the + ! buoyancy the solver gives back there (CD_HermiteCable_As_Laid_Offsets). laid_water_weight + ! is rho g [N/m^3]; the section diameter is laid_diam on the reference-arc intervals ending + ! at laid_arc_end (cumulative rest length from node 1), so any mesh of the line looks it up. + REAL(wp) :: laid_water_weight = 0.0_wp, laid_waterline_z = 0.0_wp + REAL(wp), ALLOCATABLE :: laid_arc_end(:), laid_diam(:) END TYPE CD_HermiteStaticFrictionType TYPE, PUBLIC :: CD_HermiteStaticCurrentType @@ -2786,7 +2793,8 @@ END SUBROUTINE fail END SUBROUTINE CD_HermiteCable_Static_Solve - SUBROUTINE CD_HermiteCable_As_Laid_Offsets(fr, l0, EA, node_load, node_kn, offsets, ErrStat, ErrMsg, bathymetry) + SUBROUTINE CD_HermiteCable_As_Laid_Offsets(fr, l0, EA, node_load, node_kn, offsets, ErrStat, ErrMsg, bathymetry, & + node_dry_load) !! As-laid friction reference of the nodes of mesh l0 (the lay of fr, laid_* above; !! CD_Static_As_Laid_Reference): node i at the stretched arc length of the elements !! l0 (1 + laid_tension/EA) along the seabed from the lower end, and on a bathymetry @@ -2795,13 +2803,20 @@ SUBROUTINE CD_HermiteCable_As_Laid_Offsets(fr, l0, EA, node_load, node_kn, offse !! turning force of the laid tension). offsets(1:2, i) is the reference of node i less !! the global position laid_node1 of node 1, in the solve frame laid_frame_cs; with !! laid_in_plane on a bathymetry only the sink offset across the chord leaves its plane. + !! node_load holds the submerged weights. On a bathymetry with fr%laid_water_weight > 0 a + !! node sinks under the normal load the solver applies at its laid position instead + !! (laid_dry_loads): with the buoyancy the line gives back on its part above the still-water + !! level fr%laid_waterline_z (CD_HermiteCable_Dry_Buoyancy of the laid centreline: a section + !! within its radius of the surface is partly dry), and node_dry_load(i) [N, downward, the + !! buoyancy of the attachments on node i] where node i is laid above that level. TYPE(CD_HermiteStaticFrictionType), INTENT(IN) :: fr REAL(wp), INTENT(IN) :: l0(:), EA(:), node_load(:), node_kn(:) REAL(wp), INTENT(OUT) :: offsets(:, :) INTEGER, INTENT(OUT) :: ErrStat CHARACTER(*), INTENT(OUT) :: ErrMsg TYPE(CD_BathymetryType), INTENT(IN), OPTIONAL :: bathymetry - REAL(wp), ALLOCATABLE :: ref_g(:, :), ref_0(:, :), wn(:), sn(:), kn_o(:), l0_r(:), ea_r(:) + REAL(wp), INTENT(IN), OPTIONAL :: node_dry_load(:) + REAL(wp), ALLOCATABLE :: ref_g(:, :), ref_0(:, :), wn(:), sn(:), kn_o(:), l0_r(:), ea_r(:), load(:) REAL(wp) :: dg(2), dg0(2), cs(2) INTEGER :: k, ne, es CHARACTER(1024) :: em @@ -2816,13 +2831,26 @@ SUBROUTINE CD_HermiteCable_As_Laid_Offsets(fr, l0, EA, node_load, node_kn, offse ErrStat = CD_HCSTAT_BADINPUT; ErrMsg = 'as-laid friction reference: nodal loads and stiffnesses must be finite' RETURN END IF + IF (PRESENT(node_dry_load)) THEN + IF (SIZE(node_dry_load) /= ne + 1 .OR. .NOT. CD_All_Finite(node_dry_load)) THEN + ErrStat = CD_HCSTAT_BADINPUT + ErrMsg = 'as-laid friction reference: node_dry_load must be finite, one entry per node'; RETURN + END IF + END IF offsets = CD_ZERO ALLOCATE (ref_g(2, ne + 1)) IF (PRESENT(bathymetry)) THEN + load = node_load + IF (fr%laid_water_weight > CD_ZERO) THEN + CALL laid_dry_loads(load, es, em) + IF (es /= CD_HCSTAT_OK) THEN + ErrStat = CD_HCSTAT_BADINPUT; ErrMsg = 'as-laid friction reference: '//TRIM(em); RETURN + END IF + END IF ! the static penalty penetration factor w_i/k_i of every node ALLOCATE (wn(ne + 1)) WHERE (node_kn > CD_ZERO) - wn = MAX(node_load, CD_ZERO)/node_kn + wn = MAX(load, CD_ZERO)/node_kn ELSEWHERE wn = CD_ZERO END WHERE @@ -2870,6 +2898,156 @@ SUBROUTINE CD_HermiteCable_As_Laid_Offsets(fr, l0, EA, node_load, node_kn, offse offsets(2, k) = (-cs(2)*dg(1) + cs(1)*dg(2)) - (-cs(2)*dg0(1) + cs(1)*dg0(2)) END IF END DO + + CONTAINS + + SUBROUTINE laid_dry_loads(nl, esd, emd) + !! The nodal loads nl (the submerged weights on entry) as the static solve and the dynamics + !! apply them to a node resting at its laid position: the line laid without its sink, the + !! seabed under every node, the tangent along the laid path stretched by the laid tension. + !! There a node of load W stands at the height z = z_floor - W (1 + |grad z_floor|^2)/k of + !! the penalty seabed's static penetration, and the line gives back the buoyancy + !! laid_water_weight pi d^2/4 of its part above laid_waterline_z + !! (CD_HermiteCable_Dry_Buoyancy with the section radius d/2, d the laid_diam of the + !! element's midpoint arc), a node above that level also node_dry_load: W = nl + the dry + !! load at z(W), solved by Newton's method with the dry load's exact height derivative (its + !! residual decreases monotonically in W), each step halved until it reduces the residual's + !! 2-norm: a full step can jump between a node held off the floor (wholly dry) and one sunk + !! below the surface (wholly wet) and cycle there. The turning force of the laid tension is left + !! out of the height. nl is unchanged where the line lies below the surface by more than + !! its radius. + REAL(wp), INTENT(INOUT) :: nl(:) + INTEGER, INTENT(OUT) :: esd + CHARACTER(*), INTENT(OUT) :: emd + INTEGER, PARAMETER :: MAX_NEWTON = 200 + REAL(wp), PARAMETER :: LOAD_RTOL = 1.0e-12_wp + ! the Armijo slope of the step acceptance and the shortest step tried + REAL(wp), PARAMETER :: ARMIJO = 1.0e-4_wp, MIN_STEP = 2.0_wp**(-30) + REAL(wp), ALLOCATABLE :: ref_u(:, :), zf(:), dzds(:), sfac2(:), de(:), base(:), wl(:), z(:), fd(:), & + gres(:), dg(:), lo(:), up(:), y(:), wl_acc(:) + REAL(wp) :: dir(2), gx, gy, ga, qz(4), fdry(4), kdry(4, 4), s_mid, stretch, scale_w, piv, gnorm, & + gnorm_acc, lam + INTEGER :: j, e, ix, esq, it + LOGICAL :: dry, any_dry + esd = CD_HCSTAT_OK + emd = '' + IF (.NOT. (ALLOCATED(fr%laid_arc_end) .AND. ALLOCATED(fr%laid_diam))) RETURN + IF (SIZE(fr%laid_arc_end) < 1 .OR. SIZE(fr%laid_diam) /= SIZE(fr%laid_arc_end)) THEN + esd = CD_HCSTAT_BADINPUT; emd = 'the dry-part diameter profile is inconsistent'; RETURN + END IF + IF (ANY(node_kn <= CD_ZERO)) RETURN + ! the laid path without the sink, from the lower end, in node order + ALLOCATE (ref_u(2, ne + 1), zf(ne + 1), dzds(ne + 1), sfac2(ne + 1), de(ne)) + IF (fr%laid_from_top) THEN + CALL CD_Static_As_Laid_Reference(fr%laid_origin, fr%laid_azimuth, l0(ne:1:-1), EA(ne:1:-1), & + fr%laid_tension, ref_u, esq, emd, bathymetry=bathymetry) + ref_u = ref_u(:, ne + 1:1:-1) + ELSE + CALL CD_Static_As_Laid_Reference(fr%laid_origin, fr%laid_azimuth, l0, EA, fr%laid_tension, ref_u, esq, & + emd, bathymetry=bathymetry) + END IF + IF (esq /= CD_STATIC_OK) THEN + esd = CD_HCSTAT_BADINPUT; RETURN + END IF + dir = [COS(fr%laid_azimuth), SIN(fr%laid_azimuth)] + DO j = 1, ne + 1 + CALL CD_Bathymetry_Floor_Gradient(bathymetry, ref_u(1, j), ref_u(2, j), zf(j), gx, gy, esq, emd) + IF (esq /= CD_BATHY_OK) THEN + esd = CD_HCSTAT_BADINPUT; RETURN + END IF + ! the rise of the laid path per unit length along it, in node order (laid from the last + ! node, the node order runs against the lay) + ga = gx*dir(1) + gy*dir(2) + dzds(j) = MERGE(-CD_ONE, CD_ONE, fr%laid_from_top)*ga/SQRT(CD_ONE + ga*ga) + sfac2(j) = CD_ONE + gx*gx + gy*gy + END DO + s_mid = CD_ZERO + ix = 1 + DO e = 1, ne + s_mid = s_mid + 0.5_wp*l0(e) + DO WHILE (ix < SIZE(fr%laid_arc_end)) + IF (fr%laid_arc_end(ix) >= s_mid) EXIT + ix = ix + 1 + END DO + s_mid = s_mid + 0.5_wp*l0(e) + de(e) = fr%laid_diam(ix) + END DO + base = nl + wl = nl + scale_w = MAX(CD_ONE, MAXVAL(ABS(base))) + ALLOCATE (z(ne + 1), fd(ne + 1), gres(ne + 1), dg(ne + 1), lo(ne + 1), up(ne + 1), y(ne + 1), & + wl_acc(ne + 1)) + wl_acc = wl + gnorm_acc = HUGE(CD_ONE) + lam = CD_ONE + DO it = 1, MAX_NEWTON + ! the dry load at the heights of the loads wl, and its derivative with respect to them + z = zf - MAX(wl, CD_ZERO)*sfac2/node_kn + fd = CD_ZERO + dg = CD_ONE + lo = CD_ZERO + up = CD_ZERO + any_dry = .FALSE. + DO e = 1, ne + IF (.NOT. (de(e) > CD_ZERO)) CYCLE + stretch = CD_ONE + fr%laid_tension/EA(e) + qz = [z(e), stretch*dzds(e), z(e + 1), stretch*dzds(e + 1)] + CALL CD_HermiteCable_Dry_Buoyancy(qz, l0(e), fr%laid_water_weight*0.25_wp*PI_W*de(e)**2, & + fr%laid_waterline_z, fdry, kdry, dry, radius=0.5_wp*de(e)) + IF (.NOT. dry) CYCLE + any_dry = .TRUE. + fd(e) = fd(e) + fdry(1) + fd(e + 1) = fd(e + 1) + fdry(3) + ! d(fd)/d(wl) = -kdry dz/dwl, dz/dwl = -sfac2/kn where the load presses the node in + IF (wl(e) > CD_ZERO) THEN + dg(e) = dg(e) + kdry(1, 1)*sfac2(e)/node_kn(e) + lo(e + 1) = lo(e + 1) + kdry(3, 1)*sfac2(e)/node_kn(e) + END IF + IF (wl(e + 1) > CD_ZERO) THEN + dg(e + 1) = dg(e + 1) + kdry(3, 3)*sfac2(e + 1)/node_kn(e + 1) + up(e) = up(e) + kdry(1, 3)*sfac2(e + 1)/node_kn(e + 1) + END IF + END DO + IF (PRESENT(node_dry_load)) THEN + WHERE (z > fr%laid_waterline_z) fd = fd + node_dry_load + any_dry = any_dry .OR. ANY(z > fr%laid_waterline_z .AND. ABS(node_dry_load) > CD_ZERO) + END IF + IF (it == 1 .AND. .NOT. any_dry) RETURN + gres = wl - base - fd + IF (MAXVAL(ABS(gres)) <= LOAD_RTOL*scale_w) EXIT + ! a step that does not reduce the residual is halved from the last accepted loads (the + ! Newton step is a descent direction of its 2-norm); the shortest is taken as it is + gnorm = SQRT(SUM(gres*gres)) + IF (.NOT. (gnorm <= (CD_ONE - ARMIJO*lam)*gnorm_acc) .AND. lam > MIN_STEP) THEN + lam = 0.5_wp*lam + wl = wl_acc + lam*y + CYCLE + END IF + wl_acc = wl + gnorm_acc = gnorm + lam = CD_ONE + ! (I + K D) dw = -gres, tridiagonal (diagonal dg, sub lo, super up): Thomas elimination; + ! the diagonal is at least 1 and grows with the dry stiffness + y = -gres + DO j = 2, ne + 1 + piv = lo(j)/dg(j - 1) + dg(j) = dg(j) - piv*up(j - 1) + y(j) = y(j) - piv*y(j - 1) + END DO + y(ne + 1) = y(ne + 1)/dg(ne + 1) + DO j = ne, 1, -1 + y(j) = (y(j) - up(j)*y(j + 1))/dg(j) + END DO + wl = wl + y + IF (.NOT. CD_All_Finite(wl)) THEN + esd = CD_HCSTAT_BADINPUT; emd = 'the dry-part load is not finite'; RETURN + END IF + END DO + IF (MAXVAL(ABS(gres)) > LOAD_RTOL*scale_w) THEN + esd = CD_HCSTAT_BADINPUT; emd = 'the dry-part load of the laid line did not converge'; RETURN + END IF + nl = wl + END SUBROUTINE laid_dry_loads END SUBROUTINE CD_HermiteCable_As_Laid_Offsets SUBROUTINE CD_HermiteCable_Friction_Reference(fr, l0, origin, ref, ErrStat, ErrMsg, EA, w, node_kn, bathymetry) diff --git a/tests/check_axial_damping_ratio.py b/tests/check_axial_damping_ratio.py new file mode 100644 index 00000000..d8da219c --- /dev/null +++ b/tests/check_axial_damping_ratio.py @@ -0,0 +1,227 @@ +# SPDX-License-Identifier: Apache-2.0 +"""Axial damping of a negative BA under OPTION axialDampingRatio (driver_axial_damping_ratio in +CMakeLists.txt). + +A vertical taut line (99.5 m between points 100 m apart, no axial drag or added mass) is excited in +its first axial mode by a smooth half-cosine lift of its top end, held afterwards, and the free +decay of the anchor tension is fitted with one damped sinusoid. On the uniform line (EA = 5e7 N, +50 kg/m) the lift lasts 3/4 of the mode-1 period, which leaves the second mode at rest; the third, +damped three times as much, has died out before the fitted window. The composite line puts a +stiffer, heavier lower half (EA = 2e8 N, 100 kg/m) under the same upper half. + +* Default ``segment`` form, BA = -1 (BA = zeta L0 sqrt(EA m) of each element): the first axial + mode of the uniform line is damped at zeta pi/(2N), halving as the mesh doubles (N = 50, 100, + 200), and the initialisation note gives that ratio for the line's mesh. On the composite line + the ratio is the Rayleigh quotient of the axial chain with every element damped by its own EA + and mass, worked out here independently. +* ``mode1 axialDampingRatio``, BA = -0.02: the first axial mode is damped at 2 % on every mesh, + uniform and composite, on the EI = 0 route and on the finite-EI route, and no note is made. + The finite-EI route also checks the segment form and its note on 100 elements. A viscoelastic + section, whose first axial mode one BA does not set, is refused by name under mode1. + +Every fitted ratio must lie within 3 % of its target. + +Usage: check_axial_damping_ratio.py +""" + +import math +import pathlib +import re +import subprocess +import sys +import tempfile + +import numpy as np + +UPPER = ("rope", 5.0e7, 50.0) +LOWER = ("wire", 2.0e8, 100.0) +LENGTH = 99.5 +SPAN = 100.0 +TOP_Z = -10.0 +LIFT = 0.05 +OMEGA1 = math.pi / LENGTH * math.sqrt(UPPER[1] / UPPER[2]) +PERIOD = 2.0 * math.pi / OMEGA1 +DT = 0.002 +RAMP = 0.75 * PERIOD +WINDOW = (1.5, 7.5) +TOLERANCE = 0.03 +MESHES = (50, 100, 200) +ZETA_MODE1 = 0.02 + + +def deck(n_elem: int, ba: float, ei: float, mode1: bool, composite: bool = False) -> str: + option = "mode1 axialDampingRatio\n" if mode1 else "" + types = "".join(f"{name} 0.1 {mass} {ea} {ba} {ei} 1.2 0.0 1.0 0.0\n" for name, ea, mass in (UPPER, LOWER)) + if composite: + sections = f"1 rope {LENGTH / 2} {n_elem // 2}\n1 wire {LENGTH / 2} {n_elem // 2}\n" + else: + sections = f"1 rope {LENGTH} {n_elem}\n" + return f"""--------------------- CableDyn Input File ------------------------------------ +Free axial decay of a vertical taut line +--------------------- LINE TYPES --------------------------------------------- +TypeName Diam MassDenInAir EA BA/-zeta EI Cd_n Cd_t Ca_n Ca_t +(-) (m) (kg/m) (N) (N-s/-) (N-m^2) (-) (-) (-) (-) +{types}--------------------- POINTS ------------------------------------------------- +ID Type X Y Z Mass Vol CdA Ca +(-) (-) (m) (m) (m) (kg) (m^3) (m^2) (-) +1 Coupled 0.0 0.0 {TOP_Z} 0 0 0 0 +2 Fixed 0.0 0.0 {TOP_Z - SPAN} 0 0 0 0 +--------------------- LINES -------------------------------------------------- +ID NodeA NodeB Outputs +(-) (-) (-) (-) +1 1 2 - +--------------------- SECTIONS ----------------------------------------------- +LineID LineType Length NumSegs +(-) (-) (m) (-) +{sections}--------------------- OPTIONS ------------------------------------------------ +{option}9.80665 g +1025.0 rhoW +1.0 rhoInf +{DT} dtM +{WINDOW[1]} TMax +motion.txt motionFile +--------------------- OUTPUTS ------------------------------------------------ +"AnchTen1" +END +""" + + +def motion() -> str: + rows = ["# time point x y z vx vy vz ax ay az"] + for k in range(int(round(WINDOW[1] / DT)) + 2): + t = k * DT + if t < RAMP: + arg = math.pi * t / RAMP + z = 0.5 * LIFT * (1.0 - math.cos(arg)) + vz = 0.5 * LIFT * math.pi / RAMP * math.sin(arg) + az = 0.5 * LIFT * (math.pi / RAMP) ** 2 * math.cos(arg) + else: + z, vz, az = LIFT, 0.0, 0.0 + rows.append(f"{t:.6f} 1 0 0 {TOP_Z + z:.12g} 0 0 {vz:.12g} 0 0 {az:.12g}") + return "\n".join(rows) + "\n" + + +def run(exe: str, tmp: pathlib.Path, name: str, text: str) -> tuple[np.ndarray, np.ndarray, str]: + folder = tmp / name + folder.mkdir() + (folder / "motion.txt").write_text(motion()) + (folder / "deck.dat").write_text(text) + proc = subprocess.run([exe, "deck.dat", "run"], cwd=folder, capture_output=True, text=True) + if proc.returncode != 0: + raise SystemExit(f"FAIL: the driver did not run {name}:\n{(proc.stdout + proc.stderr)[-3000:]}") + lines = (folder / "run.out").read_text().splitlines() + names = [name.split("(")[0] for name in lines[1].split()] + data = np.array([[float(v) for v in row.split()] for row in lines[2:] if row.strip()]) + return data[:, names.index("Time")], data[:, names.index("AnchTen1")], proc.stdout + proc.stderr + + +def fit_decay(t: np.ndarray, y: np.ndarray) -> float: + """The damping ratio of y = c + exp(-s t) (a cos(w t) + b sin(w t)), by Gauss-Newton from a + zero-crossing frequency and a log-decrement start.""" + keep = (t >= WINDOW[0]) & (t <= WINDOW[1]) + t, y = t[keep] - WINDOW[0], y[keep] + yc = y - y.mean() + crossings = t[np.nonzero(np.diff(np.signbit(yc)))[0]] + w = math.pi * (len(crossings) - 1) / (crossings[-1] - crossings[0]) + half = len(t) // 2 + s = math.log(np.abs(yc[:half]).max() / np.abs(yc[half:]).max()) / (t[half] - t[0]) + p = np.array([y.mean(), yc[0], 0.0, s, w]) + for _ in range(100): + c, a, b, s, w = p + e = np.exp(-s * t) + cs, sn = np.cos(w * t), np.sin(w * t) + model = c + e * (a * cs + b * sn) + jac = np.column_stack( + [np.ones_like(t), e * cs, e * sn, -t * e * (a * cs + b * sn), t * e * (-a * sn + b * cs)] + ) + step = np.linalg.lstsq(jac, y - model, rcond=None)[0] + p = p + step + if abs(step[3]) <= 1.0e-12 * abs(p[3]) and abs(step[4]) <= 1.0e-12 * abs(p[4]): + break + s, w = p[3], p[4] + return s / math.hypot(s, w) + + +def chain_ratio(n_elem: int, zeta: float) -> float: + """The first-mode damping ratio of the composite line's axial chain (both ends held, element + stiffness EA/L0, damping zeta sqrt(EA m) = BA/L0 of each element itself, lumped masses).""" + half = n_elem // 2 + h = LENGTH / n_elem + ea = np.array([UPPER[1]] * half + [LOWER[1]] * half) + mass = np.array([UPPER[2]] * half + [LOWER[2]] * half) + k, c = ea / h, zeta * np.sqrt(ea * mass) + stiff, damp = np.zeros((n_elem - 1, n_elem - 1)), np.zeros((n_elem - 1, n_elem - 1)) + for e in range(n_elem): + for p, q, sign in ((e - 1, e - 1, 1), (e, e, 1), (e - 1, e, -1), (e, e - 1, -1)): + if 0 <= p < n_elem - 1 and 0 <= q < n_elem - 1: + stiff[p, q] += sign * k[e] + damp[p, q] += sign * c[e] + lumped = 0.5 * (mass[:-1] + mass[1:]) * h + scale = 1.0 / np.sqrt(lumped) + w2, vec = np.linalg.eigh(scale[:, None] * stiff * scale[None, :]) + u = scale * vec[:, 0] + return float(u @ damp @ u / (2.0 * math.sqrt(w2[0]) * (u @ (lumped * u)))) + + +def note_ratio(log: str) -> float | None: + match = re.search(r"first axial mode of the line \(both ends held\) at ([0-9.Ee+-]+) % of critical", log) + return None if match is None else float(match.group(1)) / 100.0 + + +def check(label: str, zeta: float, target: float) -> bool: + err = zeta / target - 1.0 + print(f"{label}: zeta_1 = {zeta:.5f}, target {target:.5f} ({err:+.2%})") + if abs(err) > TOLERANCE: + print(f"FAIL: {label} is not damped at its target ratio") + return False + return True + + +def main() -> int: + exe = sys.argv[1] + ok = True + with tempfile.TemporaryDirectory() as folder: + tmp = pathlib.Path(folder) + print(f"first axial mode of the uniform line: {OMEGA1:.4f} rad/s, period {PERIOD:.4f} s") + for n_elem, ei in [(n, 0.0) for n in MESHES] + [(100, 1.0)]: + target = math.pi / (2.0 * n_elem) + route = "finite-EI " if ei > 0.0 else "" + t, y, log = run(exe, tmp, f"segment_{n_elem}_{ei}", deck(n_elem, -1.0, ei, False)) + ok = check(f"segment {route}N={n_elem}", fit_decay(t, y), target) and ok + noted = note_ratio(log) + print(f" note: {noted}") + if noted is None or abs(noted / target - 1.0) > TOLERANCE: + print("FAIL: the note does not give the first-mode ratio of the segment form") + ok = False + if f"on its {n_elem} elements" not in log or "the axial damping depends on the mesh" not in log: + print("FAIL: the note does not name the mesh") + ok = False + t, y, log = run(exe, tmp, "segment_composite", deck(50, -1.0, 0.0, False, composite=True)) + ok = check("segment composite N=50", fit_decay(t, y), chain_ratio(50, 1.0)) and ok + cases = [(n, 0.0, False) for n in MESHES] + [(50, 0.0, True), (200, 0.0, True), (100, 1.0, False), (100, 1.0, True)] + for n_elem, ei, composite in cases: + label = f"mode1 {'finite-EI' if ei > 0.0 else 'EI=0'}{' composite' if composite else ''} N={n_elem}" + t, y, log = run(exe, tmp, label.replace(" ", "_").replace("=", ""), + deck(n_elem, -ZETA_MODE1, ei, True, composite=composite)) + ok = check(label, fit_decay(t, y), ZETA_MODE1) and ok + if "damping ratio per segment" in log: + print("FAIL: a mode1 line is noted as damped per segment") + ok = False + # a viscoelastic section has no one EA to set its first mode by: refused by name + text = deck(50, -ZETA_MODE1, 0.0, True).replace(f" {UPPER[1]} {-ZETA_MODE1} ", f" {UPPER[1]}|1.0e8 {-ZETA_MODE1}|0 ") + folder_ve = tmp / "mode1_viscoelastic" + folder_ve.mkdir() + (folder_ve / "motion.txt").write_text(motion()) + (folder_ve / "deck.dat").write_text(text) + proc = subprocess.run([exe, "deck.dat", "run"], cwd=folder_ve, capture_output=True, text=True) + refused = "OPTION axialDampingRatio mode1: LINE 1 has a negative BA and the section type rope" + print(f"mode1 viscoelastic: exit {proc.returncode}, refused by name: {refused in proc.stdout + proc.stderr}") + if proc.returncode == 0 or refused not in proc.stdout + proc.stderr: + print("FAIL: mode1 on a viscoelastic section is not refused by name") + ok = False + print("PASS" if ok else "FAIL") + return 0 if ok else 1 + + +if __name__ == "__main__": + sys.exit(main()) diff --git a/tests/test_flagship_compression_note.f90 b/tests/test_flagship_compression_note.f90 index 3b53933a..309cd909 100644 --- a/tests/test_flagship_compression_note.f90 +++ b/tests/test_flagship_compression_note.f90 @@ -16,6 +16,8 @@ PROGRAM test_flagship_compression_note !! projected on the nodal tangent. It stays within the end tensions instead of the pointwise !! spikes at the touchdown. !! + !! The chains' negative BA, a damping ratio per segment, carries the axial-damping note only. + !! !! A deck whose finite-EI elements are shorter than sqrt(EI/EA) (the conditioning limit !! of the static Newton system) carries the fine-mesh note; the flagship does not. !! @@ -57,7 +59,8 @@ PROGRAM test_flagship_compression_note DO i = 1, SIZE(agg%init_lines) IF (LEN_TRIM(agg%init_lines(i)%note) > 0) WRITE (*, '(A,I0,2A)') ' line ', agg%init_lines(i)%line_id, & ' note: ', TRIM(agg%init_lines(i)%note) - CALL check(LEN_TRIM(agg%init_lines(i)%note) == 0, 'no static-initialisation note on any line') + ! the chains' negative BA is a damping ratio per segment: only that note of the run + CALL check(only_damping_note(agg%init_lines(i)%note), 'no static-initialisation note on any line') END DO END IF @@ -234,6 +237,21 @@ SUBROUTINE case_weightless_bow_note() CALL CD_AGG_End(light, es_l, em_l) END SUBROUTINE case_weightless_bow_note + LOGICAL FUNCTION only_damping_note(note) RESULT(ok) + !! Every line of note is the axial-damping note of a negative BA (axial_damping_note). + CHARACTER(*), INTENT(IN) :: note + INTEGER :: a, b, n + ok = .TRUE. + n = LEN_TRIM(note) + a = 1 + DO WHILE (a <= n) + b = INDEX(note(a:n), NEW_LINE('a')) + IF (b == 0) b = n - a + 2 + IF (INDEX(note(a:a + b - 2), 'its negative BA is a damping ratio per segment') == 0) ok = .FALSE. + a = a + b + END DO + END FUNCTION only_damping_note + SUBROUTINE check(ok, label) LOGICAL, INTENT(IN) :: ok CHARACTER(*), INTENT(IN) :: label diff --git a/tests/test_static_current_balance.f90 b/tests/test_static_current_balance.f90 new file mode 100644 index 00000000..b5e7b449 --- /dev/null +++ b/tests/test_static_current_balance.f90 @@ -0,0 +1,230 @@ +! File: tests/test_static_current_balance.f90 +! SPDX-License-Identifier: Apache-2.0 +! Copyright (c) 2026 Jae Hoon Seo, SMI Lab, Inha University +PROGRAM test_static_current_balance + !! Global force balance of the static equilibrium of a finite-EI cable in a uniform current: + !! the end reactions (the force the line exerts on each end point, CD_HermiteCable_Dyn_End_Force, + !! the FairTen/AnchTen and Point

F quantities) balance the submerged weight and the Morison + !! drag of the converged shape, -F_A - F_B + W + D = 0. D is integrated here independently: + !! the documented law f = rho d Cdn |u_n| u_n / 2 + rho pi d Cdt |u_t| u_t / 2 per unit + !! deformed length on the converged cubic-Hermite centreline (its nodal positions and + !! tangents), by the solver's 3-point Gauss rule and by a 10-point one. The cables are pinned + !! (bending-free) or clamped at End A, in currents of 0.5, 1 and 2 m/s at headings 0, 45, 90 + !! and 180 deg across the vertical plane of the ends, suspended (every component checked) and + !! with a touchdown on a flat seabed (the horizontal components: the floor carries the vertical + !! load), on 100 and 25 elements. With the 3-point rule the balance closes to 1e-7 of the end + !! force on every case (the reactions are those of the equilibrium); with the 10-point rule to + !! 2e-7 on 100 elements and 5e-6 on 25 (the drag quadrature). A current that leaves the line + !! no tension-only equilibrium is refused by name, as the deck is. + USE CableDyn_Precision, ONLY: wp + USE CableDyn_OpenFAST_Aggregate, ONLY: CD_AGG_ModuleType, CD_AGG_Init_From_Deck, CD_AGG_End, CD_AGG_OK + USE CableDyn_HermiteCableDynamic, ONLY: CD_HermiteCable_Dyn_End_Force, CD_HCDYN_OK + IMPLICIT NONE + + REAL(wp), PARAMETER :: PI = 3.14159265358979323846_wp + REAL(wp), PARAMETER :: TOL_SOLVER_RULE = 1.0e-7_wp + INTEGER, PARAMETER :: MESHES(2) = [100, 25] + REAL(wp), PARAMETER :: TOL_EXACT(2) = [2.0e-7_wp, 5.0e-6_wp] + REAL(wp), PARAMETER :: SPEEDS(3) = [0.5_wp, 1.0_wp, 2.0_wp] + REAL(wp), PARAMETER :: HEADINGS(4) = [0.0_wp, 45.0_wp, 90.0_wp, 180.0_wp] + INTEGER :: nfail, n_run, iu, ih, iclamp, itd, n_elem, im + REAL(wp) :: worst3, worst10, tol10 + + nfail = 0 + n_run = 0 + DO im = 1, SIZE(MESHES) + n_elem = MESHES(im) + tol10 = TOL_EXACT(im) + worst3 = 0.0_wp + worst10 = 0.0_wp + DO itd = 0, 1 + DO iclamp = 0, 1 + DO iu = 1, SIZE(SPEEDS) + DO ih = 1, SIZE(HEADINGS) + CALL run_case(iclamp == 1, itd == 1, SPEEDS(iu), HEADINGS(ih)) + END DO + END DO + END DO + END DO + WRITE (*, '(A,I0,A,ES10.3,A,ES10.3,A)') 'on ', n_elem, ' elements, largest relative imbalance ', worst3, & + ' (3-point drag), ', worst10, ' (10-point drag)' + END DO + WRITE (*, '(A,I0)') 'cases solved: ', n_run + IF (nfail > 0) THEN + WRITE (*, '(A,I0,A)') 'FAIL: ', nfail, ' check(s) failed' + ERROR STOP 1 + END IF + WRITE (*, '(A)') 'PASS' + +CONTAINS + + SUBROUTINE run_case(clamp, touchdown, speed, heading) + LOGICAL, INTENT(IN) :: clamp, touchdown + REAL(wp), INTENT(IN) :: speed, heading + TYPE(CD_AGG_ModuleType) :: agg + CHARACTER(512) :: em + CHARACTER(64) :: path + CHARACTER(160) :: label + REAL(wp) :: fa(3), fb(3), weight(3), drag3(3), drag10(3), imb3(3), imb10(3), scale, rel3, rel10 + REAL(wp), ALLOCATABLE :: u_elem(:, :) + INTEGER :: es, e + + path = 'static_current_balance.dat' + CALL write_deck(path, clamp, touchdown, speed, heading) + WRITE (label, '(A,I0,A,L1,A,L1,A,F4.1,A,F6.1)') 'N=', n_elem, ' clamped=', clamp, ' touchdown=', touchdown, & + ' U=', speed, ' heading=', heading + CALL CD_AGG_Init_From_Deck(agg, TRIM(path), 0.05_wp, es, em, deck_current=.TRUE.) + IF (es /= CD_AGG_OK) THEN + IF (INDEX(em, 'no tension-only static equilibrium') > 0 .OR. INDEX(em, 'no physical equilibrium') > 0) THEN + WRITE (*, '(2A)') ' skip ', TRIM(label)//': no tension-only equilibrium in this current' + CALL CD_AGG_End(agg, es, em) + RETURN + END IF + CALL check(.FALSE., TRIM(label)//': init: '//TRIM(em)) + CALL CD_AGG_End(agg, es, em) + RETURN + END IF + ASSOCIATE (ln => agg%cables(1)%line) + CALL CD_HermiteCable_Dyn_End_Force(ln, 1, fa, es, em) + CALL check(es == CD_HCDYN_OK, TRIM(label)//': end force 1: '//TRIM(em)) + CALL CD_HermiteCable_Dyn_End_Force(ln, ln%nn, fb, es, em) + CALL check(es == CD_HCDYN_OK, TRIM(label)//': end force 2: '//TRIM(em)) + weight = [0.0_wp, 0.0_wp, -SUM(ln%w*ln%l0)] + ! the element fluid velocity: the model's uniform current and, with a held field, the mean + ! of the held field at the element's nodes (the deck current of the aggregate) + ALLOCATE (u_elem(3, ln%ne)) + DO e = 1, ln%ne + u_elem(:, e) = ln%current + IF (ln%has_held_field) u_elem(:, e) = u_elem(:, e) + 0.5_wp*(ln%hf_u(:, e) + ln%hf_u(:, e + 1)) + END DO + ! the deck's uniform current, in the cable's frame (turned about z) + CALL check(MAXVAL(ABS(NORM2(u_elem(1:2, :), DIM=1) - speed)) <= 1.0e-12_wp*speed .AND. & + MAXVAL(ABS(u_elem(3, :))) <= 1.0e-12_wp*speed, TRIM(label)//': the cable sees the deck current') + CALL line_drag(ln%q, ln%l0, ln%diam, ln%cdn, ln%cdt, ln%rho_w, u_elem, 3, drag3) + CALL line_drag(ln%q, ln%l0, ln%diam, ln%cdn, ln%cdt, ln%rho_w, u_elem, 10, drag10) + END ASSOCIATE + imb3 = -fa - fb + weight + drag3 + imb10 = -fa - fb + weight + drag10 + IF (touchdown) THEN + imb3(3) = 0.0_wp + imb10(3) = 0.0_wp + END IF + scale = MAX(NORM2(fa), NORM2(fb)) + rel3 = NORM2(imb3)/scale + rel10 = NORM2(imb10)/scale + worst3 = MAX(worst3, rel3) + worst10 = MAX(worst10, rel10) + n_run = n_run + 1 + WRITE (*, '(2A,ES10.3,A,ES10.3,A,ES10.3,A)') ' ', TRIM(label)//': end force ', scale, & + ' N, relative imbalance ', rel3, ' (3-point drag), ', rel10, ' (10-point)' + CALL check(rel3 <= TOL_SOLVER_RULE, TRIM(label)//': the end reactions balance the weight and the drag') + CALL check(rel10 <= tol10, TRIM(label)//': the drag quadrature is converged') + CALL CD_AGG_End(agg, es, em) + END SUBROUTINE run_case + + SUBROUTINE line_drag(q, l0, diam, cdn, cdt, rho, u, order, drag) + !! The documented Morison drag of the still line in the current u (per element), integrated + !! on the cubic-Hermite centreline of q ([r, m] per node) per deformed length by the + !! order-point Gauss rule (3 or 10). + REAL(wp), INTENT(IN) :: q(:), l0(:), diam(:), cdn(:), cdt(:), rho, u(:, :) + INTEGER, INTENT(IN) :: order + REAL(wp), INTENT(OUT) :: drag(3) + REAL(wp), PARAMETER :: X10(5) = [0.1488743389816312_wp, 0.4333953941292472_wp, 0.6794095682990244_wp, & + 0.8650633666889845_wp, 0.9739065285171717_wp] + REAL(wp), PARAMETER :: W10(5) = [0.2955242247147529_wp, 0.2692667193099963_wp, 0.2190863625159820_wp, & + 0.1494513491505806_wp, 0.0666713443086881_wp] + REAL(wp), PARAMETER :: X3 = 0.7745966692414834_wp + REAL(wp) :: xg(10), wg(10), xi, rp(3), sp, t(3), ut(3), un(3), dh(4) + INTEGER :: e, g, s, b, ng + IF (order == 3) THEN + ng = 3 + xg(1:3) = [0.5_wp*(1.0_wp - X3), 0.5_wp, 0.5_wp*(1.0_wp + X3)] + wg(1:3) = [5.0_wp, 8.0_wp, 5.0_wp]/18.0_wp + ELSE + ng = 10 + xg = [0.5_wp*(1.0_wp - X10(5:1:-1)), 0.5_wp*(1.0_wp + X10)] + wg = [0.5_wp*W10(5:1:-1), 0.5_wp*W10] + END IF + drag = 0.0_wp + DO e = 1, SIZE(l0) + b = 6*(e - 1) + DO g = 1, ng + xi = xg(g) + dh = [6.0_wp*xi*xi - 6.0_wp*xi, l0(e)*(3.0_wp*xi*xi - 4.0_wp*xi + 1.0_wp), -6.0_wp*xi*xi + 6.0_wp*xi, & + l0(e)*(3.0_wp*xi*xi - 2.0_wp*xi)] + rp = 0.0_wp + DO s = 1, 2 + rp = rp + dh(2*s - 1)*q(b + 6*(s - 1) + 1:b + 6*(s - 1) + 3) + dh(2*s)*q(b + 6*(s - 1) + 4:b + 6*(s - 1) + 6) + END DO + sp = NORM2(rp) + t = rp/sp + ut = DOT_PRODUCT(u(:, e), t)*t + un = u(:, e) - ut + drag = drag + wg(g)*sp*(0.5_wp*rho*diam(e)*cdn(e)*NORM2(un)*un + 0.5_wp*rho*PI*diam(e)*cdt(e)*NORM2(ut)*ut) + END DO + END DO + END SUBROUTINE line_drag + + SUBROUTINE write_deck(path, clamp, touchdown, speed, heading) + CHARACTER(*), INTENT(IN) :: path + LOGICAL, INTENT(IN) :: clamp, touchdown + REAL(wp), INTENT(IN) :: speed, heading + INTEGER :: u + REAL(wp) :: ux, uy + ux = speed*COS(heading*PI/180.0_wp) + uy = speed*SIN(heading*PI/180.0_wp) + OPEN (NEWUNIT=u, FILE=path, STATUS='REPLACE', ACTION='WRITE') + WRITE (u, '(A)') '--------------------- CableDyn Input File ------------------------------------' + WRITE (u, '(A)') 'static force balance of a cable in a current' + WRITE (u, '(A)') '--------------------- LINE TYPES ---------------------------------------------' + WRITE (u, '(A)') 'TypeName Diam MassDenInAir EA BA/-zeta EI Cd_n Cd_t Ca_n Ca_t' + WRITE (u, '(A)') '(-) (m) (kg/m) (N) (N-s/-) (N-m^2) (-) (-) (-) (-)' + WRITE (u, '(A)') 'cable 0.2 60.0 1.0e8 -1.0 1.0e4 1.2 0.008 1.0 0.0' + WRITE (u, '(A)') '--------------------- POINTS -------------------------------------------------' + WRITE (u, '(A)') 'ID Type X Y Z Mass Vol CdA Ca' + WRITE (u, '(A)') '(-) (-) (m) (m) (m) (kg) (m^3) (m^2) (-)' + WRITE (u, '(A)') '1 Coupled 0.0 0.0 -10.0 0 0 0 0' + IF (touchdown) THEN + WRITE (u, '(A)') '2 Fixed 150.0 0.0 -100.0 0 0 0 0' + ELSE + WRITE (u, '(A)') '2 Fixed 80.0 0.0 -80.0 0 0 0 0' + END IF + WRITE (u, '(A)') '--------------------- LINES --------------------------------------------------' + WRITE (u, '(A)') 'ID NodeA NodeB Outputs' + WRITE (u, '(A)') '(-) (-) (-) (-)' + WRITE (u, '(A)') '1 1 2 -' + WRITE (u, '(A)') '--------------------- SECTIONS -----------------------------------------------' + WRITE (u, '(A)') 'LineID LineType Length NumSegs' + WRITE (u, '(A)') '(-) (-) (m) (-)' + IF (touchdown) THEN + WRITE (u, '(A,I0)') '1 cable 190.0 ', n_elem + ELSE + WRITE (u, '(A,I0)') '1 cable 125.0 ', n_elem + END IF + IF (clamp) THEN + WRITE (u, '(A)') '--------------------- END CONNECTIONS ----------------------------------------' + WRITE (u, '(A)') 'LineID End Stiffness EzX EzY EzZ' + WRITE (u, '(A)') '(-) (-) (N-m/rad) (-) (-) (-)' + WRITE (u, '(A)') '1 A Rigid 0.0 0.0 -1.0' + END IF + WRITE (u, '(A)') '--------------------- OPTIONS ------------------------------------------------' + WRITE (u, '(A)') '9.80665 g' + WRITE (u, '(A)') '1025.0 rhoW' + IF (touchdown) WRITE (u, '(A)') '100.0 WtrDpth' + WRITE (u, '(A)') '0.05 dtM' + WRITE (u, '(A)') '0.0 TMax' + WRITE (u, '(A,2(1X,ES23.16),A)') 'uniform', ux, uy, ' 0.0 current' + WRITE (u, '(A)') '--------------------- OUTPUTS ------------------------------------------------' + WRITE (u, '(A)') 'END' + CLOSE (u) + END SUBROUTINE write_deck + + SUBROUTINE check(ok, label) + LOGICAL, INTENT(IN) :: ok + CHARACTER(*), INTENT(IN) :: label + IF (ok) RETURN + nfail = nfail + 1 + WRITE (*, '(2A)') ' FAIL ', TRIM(label) + END SUBROUTINE check + +END PROGRAM test_static_current_balance diff --git a/tests/test_static_friction_as_laid.py b/tests/test_static_friction_as_laid.py index 2235fa52..fe743bbe 100644 --- a/tests/test_static_friction_as_laid.py +++ b/tests/test_static_friction_as_laid.py @@ -36,6 +36,13 @@ * ``att_cross`` (a finite-EI line with discrete buoyancy modules on a cross slope): the reference sinks each node under its discrete load, so the module nodes rest on the laid path (no lateral kink, as in the smeared twin) and a march from the static state stays at rest; +* ``shallow_cross`` (a 0.5 m finite-EI cable on a seabed 0.1 m deep, sloping across it): the + reference sinks each node under the load the solver applies there, the dry part of the section + that pierces the surface included, so the run rests on its laid path and a march from the + static state stays at rest; +* ``buoyant_shallow`` (a net-buoyant 0.5 m cable on a flat seabed 0.01 m deep, kBot = 1000): the + reference's dry load, whose full Newton step cycles between a wholly dry and a wholly wet node, + converges with halved steps, and a march from the static state stays at rest; * ``pl_*``: per-line rows win over the global ones (``layAzimuth`` over ``layAzimuth``, ``asLaidTension`` over ``asLaidTension``, in either order), and a row for line 2 leaves line 1 alone; ``aniso_*``: the axial coefficient rules the friction along a laid run; @@ -509,6 +516,73 @@ def kink(y: list) -> float: "att_cross: the module nodes rest on the laid path as closely as in the smeared twin (%.2e <= %.2e m)" % (kd, ks)) + # --- finite-EI cable laid on a shelf shallower than its radius, sloping across it --- + # A light 0.5 m cable rests on a seabed 0.1 m deep (5 degrees across the line): its section + # pierces the surface, and the static solve and the dynamics give back the buoyancy of the dry + # part, about 2.3 times its submerged weight. The friction reference sinks every node under + # that same normal load (the dry part at the node's sunk height), so the laid run rests on its + # laid path, y = 0. A reference sunk under the submerged weight alone would hold the run down + # the slope by the difference of the two sinks times tan(slope), about 0.8 mm, with a spurious + # friction force. Checked: the run's nodes stay within a tenth of that of the laid path + # (about 4e-6 m), and a march from the static state stays at rest. + cdir = root / "shallow_cross" + cdir.mkdir(parents=True, exist_ok=True) + rows = [] + for x in range(-300, 1000, 100): + for y in (-1.0, 1.0): + rows.append("%.1f %.1f %.12g" % (x, y, 0.1 + math.tan(math.radians(5.0)) * y)) + (cdir / "bathy.txt").write_text("\n".join(rows) + "\n", encoding="utf-8", newline="\n") + d_s, m_s = 0.5, 220.0 + w_s = (m_s - RHO * math.pi / 4.0 * d_s * d_s) * G + sc = dict(ei=1.0e4, length=100.0, nseg=50, fair=(100.0, 0.0, -0.095), anch=(0.0, 0.0, -0.1), seabed=sb, + types=f"chain {d_s} {m_s} 1.0e8 -1 1.0e4 1.2 0.008 1 0\n") + rc, log = run(a.exe, cdir, "shallow", deck("shallow cross", **sc)) + check(rc == 0, "shallow_cross converges (rc %d)%s" % (rc, "" if rc == 0 else ": " + log.strip()[-300:])) + if rc == 0: + p = first_row(cdir / "shallow.Line1.p.out") + # the run away from its two held ends, which rest at their deck positions above the + # sunk run and bend it within a few elements of them + y_run = [p[3 * i + 1] for i in range(5, len(p) // 3 - 5)] + # the sink of a node under its submerged weight and under its load with the dry part + kn_l = 1.0e5 * d_s + dry_load = w_s + for _ in range(100): + u = max(-1.0, min(1.0, (-0.1 - dry_load / kn_l) / (0.5 * d_s))) + phi = 1.0 - (math.acos(u) - u * math.sqrt(1.0 - u * u)) / math.pi + dry_load = w_s + phi * RHO * G * math.pi / 4.0 * d_s * d_s + spurious = (dry_load - w_s) / kn_l * math.tan(math.radians(5.0)) + dev = max(abs(y) for y in y_run) + check(dev < 0.1 * spurious, + "shallow_cross: the run rests on its laid path (%.2e m off it, a reference without the dry part " + "would hold it %.2e m off)" % (dev, spurious)) + rc, _ = run(a.exe, cdir, "shallow_rest", deck("shallow cross rest", **sc, tmax=1.0)) + check(rc == 0, "shallow_cross at-rest march runs (rc %d)" % rc) + if rc == 0: + drift = at_rest(cdir, "shallow", "shallow_rest") + check(drift <= REST_TOL, "shallow_cross stays at rest from the static state (drift %.2e)" % drift) + + # --- net-buoyant cable on a flat seabed shallower than its radius, soft seabed --- + # A 0.5 m cable of 180 kg/m floats (its displaced water is 201 kg/m), held on a seabed 0.01 m + # deep with kBot = 1000. A node held off the floor is wholly dry and one sunk under the dry + # load wholly wet, so the full Newton step of the reference's dry load jumps between about + # -208 and 728 N/m; the root (70.3 N/m, a sink of 0.14 m) lies between. Checked: the + # halved steps reach it, the static solve converges, and a march from it stays at rest. + cdir = root / "buoyant_shallow" + cdir.mkdir(parents=True, exist_ok=True) + rows = ["%.1f %.1f 0.01" % (x, y) for x in range(-300, 1000, 100) for y in (-300.0, 300.0)] + (cdir / "bathy.txt").write_text("\n".join(rows) + "\n", encoding="utf-8", newline="\n") + bs = dict(ei=1.0e4, length=100.0, nseg=50, fair=(100.0, 0.0, -0.005), anch=(0.0, 0.0, -0.01), seabed=sb, + types="chain 0.5 180.0 1.0e8 -1 1.0e4 1.2 0.008 1 0\n") + rc, log = run(a.exe, cdir, "buoyant", deck("buoyant shallow", **bs).replace("100000.0 kBot", "1000.0 kBot")) + check(rc == 0, "buoyant_shallow converges (rc %d)%s" % (rc, "" if rc == 0 else ": " + log.strip()[-300:])) + if rc == 0: + rc, _ = run(a.exe, cdir, "buoyant_rest", + deck("buoyant shallow rest", **bs, tmax=1.0).replace("100000.0 kBot", "1000.0 kBot")) + check(rc == 0, "buoyant_shallow at-rest march runs (rc %d)" % rc) + if rc == 0: + drift = at_rest(cdir, "buoyant", "buoyant_rest") + check(drift <= REST_TOL, "buoyant_shallow stays at rest from the static state (drift %.2e)" % drift) + # --- per-line rows, non-default azimuth and tension, anisotropic friction (EI = 0) --- cdir = root / "perline" keys = ("FairTen1", "AnchTen1", "Point1Fx", "Point2Fx", "Point1Fz")