From cb988f9da8d30689c9b979b6c1bc8628b9891c8f Mon Sep 17 00:00:00 2001 From: Jae Hoon Seo Date: Wed, 11 Nov 2026 18:32:00 +0900 Subject: [PATCH] feat: load power channels VIVPow, DragPow and DampPow A VIV study needs the energy ledger of the response: what the VIV loads put into a line against what the drag and the structural damping take out, along the line and over the run. The OUTPUTS channels VIVPow, DragPow and DampPow [W] report the power these loads deliver to line L at the committed state, and N [W/m] the same per unit unstretched length about node J. The power of a load on an element is its nodal (finite-EI: generalised) load times the element's velocities, the exact rate of work of the load the solver applies; a node load delivers f . v at its node. A node takes half of each of its elements' power, so the node values sum to the line total, and an element's damping power, hence a node's, is never positive. - VIV: the cross-flow lift and the in-line force of a VIV section row. - Drag: the Morison drag, and on a finite-EI line its ATTACHMENTS' drag. - Damping: the axial dashpot BA, and the bending dashpot Bb on a finite-EI line. The torsional Bt and the viscoelastic and Syrope laws' internal damping are not included (documented). They run on EI = 0 lines and finite-EI cables, on the single-line, point-system, multibody, coupled (OpenFAST, FAST.Farm) and C API routes; a static run reports 0. The residual-only Morison drag call of the finite-EI element, written out three times, is one helper now (element_drag_load), with the same arguments as before. Checks: - tests/test_hermite_load_power: the work of the three loads closes a weightless cable's energy balance within 0.04 % of the largest work in a bending-dashpot decay, an axial-dashpot decay, a still-water drag decay and a VIV run in a current; - tests/test_load_power_deck: on the locked-in in-line VIV line the means balance within 0.04 % of the VIV power as a finite-EI cable, an EI = 0 line and two EI = 0 lines joined at a free point; the per-length channels of all nodes sum to the line total; malformed channels are refused by name; - tests/test_viv_coupled: on the coupled route both lines balance within 0.01 %; - the Python deck reader and builder mirror the channels (native parity of 13 spellings); - full ctest 414/414 on the default and Prescott kernels, Debug -fcheck=all on the new and touched tests, pytest, the example fallback scan clean. Signed-off-by: Jae Hoon Seo --- CHANGELOG.md | 6 + CMakeLists.txt | 10 + doc/capabilities.rst | 5 + doc/driver_format.md | 4 + doc/outputs.rst | 54 +++++ examples/viv_taut_cable_inline.dat | 7 +- python/cabledyn/builder.py | 1 + python/cabledyn/deck_file.py | 42 +++- python/tests/test_builder.py | 13 +- python/tests/test_deck_file.py | 2 + python/tests/test_deck_native_parity.py | 23 ++ src/CableDyn_DeckDriver.f90 | 144 +++++++++++- src/CableDyn_HermiteCableDynamic.f90 | 207 ++++++++++------ src/CableDyn_Model.f90 | 81 +++++++ src/CableDyn_System.f90 | 30 ++- tests/test_hermite_load_power.f90 | 180 ++++++++++++++ tests/test_load_power_deck.f90 | 300 ++++++++++++++++++++++++ tests/test_viv_coupled.f90 | 44 +++- 18 files changed, 1063 insertions(+), 90 deletions(-) create mode 100644 tests/test_hermite_load_power.f90 create mode 100644 tests/test_load_power_deck.f90 diff --git a/CHANGELOG.md b/CHANGELOG.md index 75944cee..412b2964 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -25,6 +25,12 @@ All notable changes to CableDyn are recorded in this file. The format follows finite-EI cables alike (within 1 % of each other). Exact Jacobians; the phase is in the step-recovery, snapshot and checkpoint state; the Python deck reader and builder take the section. +- Load power channels `VIVPow`, `DragPow` and `DampPow` [W], and `N` per + unit length about a node [W/m]: the power the VIV loads, the drag and the structural damping + (`BA`, `Bb`) deliver to a line at the committed state, on `EI = 0` lines and finite-EI cables, + standalone and coupled. Their work closes a cable's energy balance to 0.04 % in free decays + and VIV runs, and on the locked-in line of `examples/viv_taut_cable_inline.dat` their means + balance within 0.5 % of the VIV power. ## [0.4.2] - 2026-11-09 diff --git a/CMakeLists.txt b/CMakeLists.txt index cfd12517..a513c945 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1326,6 +1326,16 @@ target_link_libraries(test_hermite_viv_inline PRIVATE cabledyn_core) add_test(NAME hermite_viv_inline COMMAND test_hermite_viv_inline) set_tests_properties(hermite_viv_inline PROPERTIES LABELS "fortran;dynamic;viv") +add_executable(test_hermite_load_power tests/test_hermite_load_power.f90) +target_link_libraries(test_hermite_load_power PRIVATE cabledyn_core) +add_test(NAME hermite_load_power COMMAND test_hermite_load_power) +set_tests_properties(hermite_load_power PROPERTIES LABELS "fortran;dynamic;viv") + +add_executable(test_load_power_deck tests/test_load_power_deck.f90) +target_link_libraries(test_load_power_deck PRIVATE cabledyn_core) +add_test(NAME load_power_deck COMMAND test_load_power_deck WORKING_DIRECTORY ${CMAKE_BINARY_DIR}) +set_tests_properties(load_power_deck PROPERTIES LABELS "fortran;integration;dynamic;viv;driver") + add_executable(test_viv_inline_deck tests/test_viv_inline_deck.f90) target_link_libraries(test_viv_inline_deck PRIVATE cabledyn_core) add_test(NAME viv_inline_deck COMMAND test_viv_inline_deck WORKING_DIRECTORY ${CMAKE_BINARY_DIR}) diff --git a/doc/capabilities.rst b/doc/capabilities.rst index 165be866..34720cb4 100644 --- a/doc/capabilities.rst +++ b/doc/capabilities.rst @@ -201,6 +201,11 @@ Loads and environment - Standalone only - a 6-DOF vessel record, or the RAO response to the deck waves, moves every ``Coupled``/``Vessel`` point of a line deck; see :doc:`options` + * - Load power channels (``VIVPow``, ``DragPow``, ``DampPow``) + - Standalone and coupled + - the power of the VIV loads, the drag and the structural damping on a line, in total and per + unit length about a node, at every output time: the energy ledger of a VIV response; see + :doc:`outputs` * - Range graphs (``r`` line output flag, ``RangeStart``) - Standalone and OpenFAST - minimum, maximum, and mean along each line over the run, from the committed steps; a run diff --git a/doc/driver_format.md b/doc/driver_format.md index 9c7d6382..70cc394b 100644 --- a/doc/driver_format.md +++ b/doc/driver_format.md @@ -1651,6 +1651,10 @@ bending moment. None of these channels is mandatory. | `TorqN` | line L torque at node J (uniform along the line in statics); positive for a right-handed twist of End B relative to End A about the End A → End B tangent. Only on a line solved in torsion (restrained at both ends, or at one end with the other free) | N·m | | `TwistN` | line L material twist accumulated from End A to node J, `M × Σ L/GJ` (less `(K/GJ)(l − L)` under coupling) over the elements in between; 0 at End A, without the end-spring windup. Only on a line solved in torsion | deg | | `Twist` | line L total twist `Phi − Theta = M C`, end-spring windup included; on a line free at one end the twist of its elements, the free end's turn. Only on a line solved in torsion | deg | +| `VIVPow` | line L power of the VIV loads (cross-flow lift, and the in-line force of a `VIV` section row) at the committed state, positive into the line ([Outputs](outputs.rst)); 0 in static runs | W | +| `DragPow` | line L power of the Morison drag (and, on a finite-EI line, its ATTACHMENTS' drag) | W | +| `DampPow` | line L power of the structural damping (`BA`, and `EI|Bb` on a finite-EI line); never positive | W | +| `VIVPowN`, `DragPowN`, `DampPowN` | the same per unit unstretched length about node J (node J's share: half of each of its elements' power and its own node loads', over half their unstretched length) | W/m | - ``/`

` are deck LINE/POINT **ids**, not array positions. A channel that matches no supported form, names an unknown id, or carries trailing text (for example `Point2px_raw`) is a diff --git a/doc/outputs.rst b/doc/outputs.rst index a9c7ffaa..1e8fb1aa 100644 --- a/doc/outputs.rst +++ b/doc/outputs.rst @@ -864,6 +864,60 @@ lowest value differs from the converged one by 0.6 m. Elements no longer than ab :math:`\sqrt{EI/T}` at touchdown keep the node tension there within about 1.5 % of the converged value through the motion, and a tenth within 0.5 %. +Load power channels +~~~~~~~~~~~~~~~~~~~ + +The power three loads deliver to a line at every output time, for an energy ledger of its +motion: the work the VIV loads put in against what the drag and the structural damping take out, +along the line and over the run. Each is the load times the velocity it acts through at the +committed state, positive when the load puts energy into the line: + +.. list-table:: + :header-rows: 1 + :widths: 24 56 20 + + * - Channel + - Meaning + - Unit + * - ``VIVPow`` + - power of the VIV loads on line ``L``: the cross-flow lift (:ref:`theory-viv`) and, on a + type with a ``VIV`` section row, the in-line force (:ref:`theory-viv-inline`); zero on a + line without VIV + - W + * - ``DragPow`` + - power of the Morison drag on the line (current, waves and a host's fluid field) and, on a + finite-EI line, of its ATTACHMENTS' drag; zero without drag + - W + * - ``DampPow`` + - power of the structural damping: the axial dashpot ``BA`` and, on a finite-EI line, the + bending dashpot (``EI|Bb``); never positive + - W + * - ``VIVPowN``, ``DragPowN``, ``DampPowN`` + - the same per unit unstretched length about node ``J`` + - W/m + +The power of a load on an element is :math:`\mathbf{f}_e\cdot\dot{\mathbf{q}}_e`, its nodal +(finite-EI: generalised) load on the element's degrees of freedom times their velocities, which +is the exact rate of work of the load the solver applies; a node load (the lift of an +``EI = 0`` line, an attachment's drag) delivers :math:`\mathbf{f}\cdot\mathbf{v}` at its node. +A node takes half the power of each of its elements and the power of its own node loads, so the +line total ```` is the sum over its nodes, and ``N`` is node ``J``'s share +over half the unstretched length of its elements (W per metre of unstretched line; on a refined +line, at the deck node's node of the final mesh). An element's damping power is never positive, +so neither is a node's. + +The three are the non-conservative loads of a VIV study, not all of them: the work of the end +supports and points, the seabed contact, damping and friction, the added mass and Froude-Krylov +loads, a body's or point's own drag, the torsional damping ``Bt`` and the internal damping of the +viscoelastic and Syrope laws is not in them. Where those do no net work, the energy the line holds +only oscillates in a steady response, so the means balance: +:math:`\overline{P}_\text{VIV} + \overline{P}_\text{drag} + \overline{P}_\text{damp} \approx 0`. +On the locked-in taut line of ``viv_taut_cable_inline.dat`` (pinned ends, steady current) the VIV +loads put in 8.52 W over 60-90 s, the drag takes out 8.56 W and the axial damping 0.002 W: the +three balance within 0.5 % of the VIV power, the line's loss of energy over the window as its +response settles, and as an ``EI = 0`` line the same. Integrating a channel over the output times gives the work of its +load, :math:`W = \int P\,dt`; a static run reports 0. + Point channels ~~~~~~~~~~~~~~ diff --git a/examples/viv_taut_cable_inline.dat b/examples/viv_taut_cable_inline.dat index f8c64b16..0f388d4d 100644 --- a/examples/viv_taut_cable_inline.dat +++ b/examples/viv_taut_cable_inline.dat @@ -9,7 +9,9 @@ CableDyn driver deck -- cross-flow and in-line VIV of a taut cable in a uniform -- about twice the cross-flow one. Over 60-90 s the quarter span (L1N13py) moves in line at A/D -- 0.19, at twice the 0.29 Hz cross-flow frequency of the mid span (L1N26pz, A/D 0.82); with the -- cross-flow lift alone (drop the VIV section) they are 0.03 and 0.66. The Outputs flag V writes --- the VIV force, lift and in-line, at every node to .Line1.V.out. +-- the VIV force, lift and in-line, at every node to .Line1.V.out. VIVPow1, DragPow1 and +-- DampPow1 are the power the VIV loads, the drag and the axial damping deliver to the line: over +-- 60-90 s the VIV loads put in 8.52 W and the drag and damping take out 8.56 W. --------------------- LINE TYPES --------------------------------------- TypeName Diam MassDenInAir EA BA/-zeta EI Cd_n Cd_t Ca_n Ca_t Cl dF cF (-) (m) (kg/m) (N) (N-s/-) (N-m^2) (-) (-) (-) (-) (-) (-) (-) @@ -57,4 +59,7 @@ none frictionMu - Seabed friction coefficient {none; value>=0} [defau "FairTen1" "L1N26pz" "L1N13py" +"VIVPow1" +"DragPow1" +"DampPow1" --------------------- need this line ----------------------------------- diff --git a/python/cabledyn/builder.py b/python/cabledyn/builder.py index 1fd9b948..fe34ed6b 100644 --- a/python/cabledyn/builder.py +++ b/python/cabledyn/builder.py @@ -117,6 +117,7 @@ re.compile(r"(ten|curvx|curvy|curv|bendmom|stfmom|torq)([0-9]+)(n[0-9]+)", re.IGNORECASE), ), ("line", re.compile(r"(twist)([0-9]+)(n[0-9]+|)", re.IGNORECASE)), + ("line", re.compile(r"(vivpow|dragpow|damppow)([0-9]+)(n[0-9]+|)", re.IGNORECASE)), ("line", re.compile(r"(l)([0-9]+)(n[0-9]+(?:[pva][xyz]|dec|azi))", re.IGNORECASE)), ("point", re.compile(r"(point|con)([0-9]+)(p[xyz])", re.IGNORECASE)), ("point", re.compile(r"(point)([0-9]+)(f[xyzh])", re.IGNORECASE)), diff --git a/python/cabledyn/deck_file.py b/python/cabledyn/deck_file.py index c55ac019..fa595d92 100644 --- a/python/cabledyn/deck_file.py +++ b/python/cabledyn/deck_file.py @@ -740,6 +740,20 @@ def _parse_line_node_channel(lowered: str) -> tuple[int, int, int, int]: # Twist: the line's total twist (node 1) line_id = _native_positive_int(lowered, 6, last) return (line_id, 1, 11, 0) if line_id > 0 else (line_id, 0, 0, 0) + for keyword, code in (("vivpow", 15), ("dragpow", 17), ("damppow", 19)): + if not lowered.startswith(keyword): + continue + # the load power channels: the line total (node 1), N per length + prefix = len(keyword) + if last > prefix and "n" not in lowered[prefix:]: + line_id = _native_positive_int(lowered, prefix + 1, last) + return (line_id, 1, code, 0) if line_id > 0 else (line_id, 0, 0, 0) + separator = lowered.find("n", prefix) + if last <= prefix or separator < 0: + return 0, 0, 0, 0 + line_id = _native_positive_int(lowered, prefix + 1, separator) + node_id = _native_positive_int(lowered, separator + 2, last) + return line_id, node_id, code + 1 if line_id > 0 and node_id > 0 else 0, 0 for keyword, code in ( ("torq", 9), ("twist", 10), @@ -822,7 +836,9 @@ def _channel_identity_key(channel: str) -> str: if touchdown is not None and int(touchdown.group(1)) > 0: component = ("s", "x", "y", "z", "lay", "exc", "grd").index(touchdown.group(2)) + 1 return f"tdp:{int(touchdown.group(1))}:{component}" - if lowered.startswith(("ten", "curv", "bendmom", "stfmom", "l", "torq", "twist")): + if lowered.startswith( + ("ten", "curv", "bendmom", "stfmom", "l", "torq", "twist", "vivpow", "dragpow", "damppow") + ): line_id, node_id, kind, component = _parse_line_node_channel(lowered) if line_id > 0 and node_id > 0 and kind > 0: return f"node:{line_id}:{node_id}:{kind}:{component}" @@ -5407,6 +5423,30 @@ def is_body_kind(kind: str, pinned: bool) -> bool: "restrained (END CONNECTIONS TorsStiffness), so it carries no torque" ) continue + if lowered.startswith(("vivpow", "dragpow", "damppow")): + # native: VIVPow/DragPow/DampPow and N, the load power channels + line_number, node_id, kind, _ = _parse_line_node_channel(lowered) + line_id = str(line_number) + if ( + node_id == 0 + and line_id in line_ids + and re.search(r"[0-9]n0(?![0-9])", lowered) is not None + ): + raise DeckFormatError( + f"{self._label}: OUTPUT {channel!r}: node numbers start at 1 = End A " + "(MoorDyn numbers from N0)" + ) + if line_id not in line_ids or kind == 0 or node_id < 1: + raise DeckFormatError( + f"{self._label}: OUTPUT {channel!r}: bad load power channel (use " + "VIVPow, DragPow, DampPow, or N per unit length, " + "with a known line id)" + ) + if node_id > line_nelems[line_id] + 1: + raise DeckFormatError( + f"{self._label}: OUTPUT {channel!r} node exceeds the line node count" + ) + continue if lowered.startswith(("ten", "curv", "bendmom", "stfmom", "l")): # native parse_line_node_channel: Ten/Curv/BendMom/StfMomN, LN... line_number, node_id, kind, _ = _parse_line_node_channel(lowered) diff --git a/python/tests/test_builder.py b/python/tests/test_builder.py index 2e0abd73..dea9ad8c 100644 --- a/python/tests/test_builder.py +++ b/python/tests/test_builder.py @@ -267,7 +267,16 @@ def test_edit_fields_in_place_and_revalidate() -> None: def test_rename_propagates_to_rows_and_output_channels() -> None: model = _chain_model() model.outputs.add( - "Ten1N3", "L1N2px", "TDP1s", "TDP1Grd", "AnchFz1", "AnchFH1", "Point2FH", "Con1py" + "Ten1N3", + "L1N2px", + "TDP1s", + "TDP1Grd", + "AnchFz1", + "AnchFH1", + "Point2FH", + "Con1py", + "VIVPow1", + "DampPow1N3", ) model.rename(model.lines[1], 7) model.rename(model.points[1], 11) @@ -284,6 +293,8 @@ def test_rename_propagates_to_rows_and_output_channels() -> None: "AnchFH7", "Point2FH", "Con11py", + "VIVPow7", + "DampPow7N3", ] deck = model.to_deck_file() assert deck.lines[0].tokens == ("7", "11", "2", "-") diff --git a/python/tests/test_deck_file.py b/python/tests/test_deck_file.py index 09682893..6b69c46c 100644 --- a/python/tests/test_deck_file.py +++ b/python/tests/test_deck_file.py @@ -3862,6 +3862,8 @@ def unqueryable(first, second): ("TDP1Grd", "tdp01GRD"), ("AnchFz1", "anchfz01"), ("AnchFH1", "ANCHFH1"), + ("VIVPow1", "vivpow01"), + ("DragPow1N3", "dragpow01n03"), ], ) def test_duplicate_output_channels_fail_like_native(first, second): diff --git a/python/tests/test_deck_native_parity.py b/python/tests/test_deck_native_parity.py index 735d489b..e5fad9d5 100644 --- a/python/tests/test_deck_native_parity.py +++ b/python/tests/test_deck_native_parity.py @@ -1025,6 +1025,29 @@ def test_inline_viv_acts_on_an_ei0_line(row): DeckFile.from_text(_section(_example("viv_taut_line_crossflow.dat"), "VIV", row)) +@pytest.mark.parametrize( + ("channel", "message"), + [ + ("VIVPow1", None), + ("DragPow1", None), + ("DampPow1", None), + ("vivpow01n26", None), + ("DampPow1N51", None), + ("VIVPow0", "bad load power channel"), + ("DragPow7", "bad load power channel"), + ("DampPowx", "bad load power channel"), + ("VIVPow1N0", "node numbers start at 1 = End A"), + ("DragPow1N52", "node exceeds the line node count"), + ], +) +def test_load_power_channels_are_native(channel, message): + text = _example("viv_taut_line_crossflow.dat", ('"FairTen1"', f'"FairTen1"\n"{channel}"')) + if message is None: + DeckFile.from_text(text) + else: + _rejects(text, re.escape(message)) + + def test_stiffener_needs_a_finite_ei_line(): text = _section(_HELD, "STIFFENERS", "1 A 1.0 0.5 0.5 0.3 5.0e7 1150") _rejects(text, "STIFFENERS name line 1, which is not a finite-EI line") diff --git a/src/CableDyn_DeckDriver.f90 b/src/CableDyn_DeckDriver.f90 index ec1aa327..ed0c0ff2 100644 --- a/src/CableDyn_DeckDriver.f90 +++ b/src/CableDyn_DeckDriver.f90 @@ -59,11 +59,12 @@ MODULE CableDyn_DeckDriver CD_Get_Model_EndForces, & CD_Update_Model_CoupledMotion, CD_Update_Model_Hydro_Fields, & CD_Recompute_Model_Acceleration, CD_Step_Model, CD_Step_Model_Recovering, CD_MODEL_OK, & - CD_Audit_Model_Step, CD_Set_Model_VIV, CD_Get_Model_VIV_Lift + CD_Audit_Model_Step, CD_Set_Model_VIV, CD_Get_Model_VIV_Lift, CD_Get_Model_Load_Power USE CableDyn_System, ONLY: CD_SystemType, CD_SystemPointType, CD_LineEndpointBinding, & CD_Init_System_From_Points, CD_End_System, CD_System_Line_NDOF, & CD_System_Line_NElem, CD_Get_System_Point_State, CD_Get_System_Line_State, & CD_Get_System_Line_Tension, CD_Get_System_Line_VIV_Lift, & + CD_Get_System_Line_Load_Power, & CD_Update_System_Point_Fluid_Fields, & CD_Get_System_CoupledMotion, CD_Update_System_Point_States, & CD_Calc_System_CoupledLoads, CD_Step_System, CD_Step_System_DynamicPoints, & @@ -95,7 +96,7 @@ MODULE CableDyn_DeckDriver CD_HCSTAT_NOCONVERGE, CD_HC_COMPRESSION_OSCILLATION, & CD_HC_COMPRESSION_STRICT USE CableDyn_HermiteCableDynamic, ONLY: CD_HCDYN_OK, CD_HCDYN_TENSILE_OFF, CD_HCDYN_TENSILE_WARN, & - CD_HCDYN_TENSILE_ERROR, & + CD_HCDYN_TENSILE_ERROR, CD_HermiteCable_Dyn_Load_Power, & CD_HermiteCable_Axial_Damping_Resultant, & CD_HermiteCable_Axial_Damping_Element, CD_HermiteCable_Dyn_End_Force, & CD_HermiteCable_Dyn_Node_Values, CD_HermiteCable_Dyn_Node_Recovery, & @@ -18574,7 +18575,7 @@ FUNCTION channel_identity_key(ch) RESULT(key) IF (a > 0 .AND. b > 0) key = 'point:'//TRIM(int_to_str(a))//':'//TRIM(int_to_str(b)) ELSE IF (starts_with(lo, 'ten') .OR. starts_with(lo, 'curv') .OR. starts_with(lo, 'bendmom') .OR. & starts_with(lo, 'stfmom') .OR. starts_with(lo, 'l') .OR. starts_with(lo, 'torq') .OR. & - starts_with(lo, 'twist')) THEN + starts_with(lo, 'twist') .OR. is_load_power_channel(lo)) THEN CALL parse_line_node_channel(ch, a, b, c, d) IF (a > 0 .AND. b > 0 .AND. c > 0) key = 'node:'//TRIM(int_to_str(a))//':'//TRIM(int_to_str(b))// & ':'//TRIM(int_to_str(c))//':'//TRIM(int_to_str(d)) @@ -35033,6 +35034,7 @@ SUBROUTINE build_plan() END IF ELSE CALL parse_line_node_channel(channels(j), il, node, kind, comp) + IF (is_load_power_kind(kind)) CYCLE ! from the line model, channel-at-a-time (CH_LEGACY) il = find_line(lines, il) IF (il < 1) CYCLE CALL line_sizes(il, sized, tension_sized) @@ -35286,6 +35288,19 @@ SUBROUTINE system_channel_value(ch, lines, points, system, work, val, ErrStat, E RETURN END IF inode = deck_to_internal_node(node, nnode - 1) + IF (is_load_power_kind(kind)) THEN + BLOCK + REAL(wp) :: pv(nnode), pd(nnode), pm(nnode) + CALL CD_Get_System_Line_Load_Power(system, li, pv, pd, pm, es, em) + IF (es /= CD_SYSTEM_OK) THEN + ErrStat = CD_DECKDRV_SOLVEFAIL + ErrMsg = 'CableDyn_DeckDriver: system line load power recovery failed: '//TRIM(em) + RETURN + END IF + val = load_power_value(kind, inode, pv, pd, pm, system%lines(li)%l0) + END BLOCK + RETURN + END IF IF (kind == 3) THEN CALL ensure_model_output_workspace(work, 0, nnode - 1) CALL CD_Get_System_Line_Tension(system, li, work%tension(1:nnode - 1), es, em) @@ -35428,6 +35443,19 @@ SUBROUTINE model_channel_value(ch, lines, points, models, work, val, ErrStat, Er RETURN END IF inode = deck_to_internal_node(node, nnode - 1) + IF (is_load_power_kind(kind)) THEN + BLOCK + REAL(wp) :: pv(nnode), pd(nnode), pm(nnode) + CALL CD_Get_Model_Load_Power(models(li), pv, pd, pm, es, em) + IF (es /= CD_MODEL_OK) THEN + ErrStat = CD_DECKDRV_SOLVEFAIL + ErrMsg = 'CableDyn_DeckDriver: dynamic line load power recovery failed: '//TRIM(em) + RETURN + END IF + val = load_power_value(kind, inode, pv, pd, pm, models(li)%l0) + END BLOCK + RETURN + END IF IF (kind == 3) THEN CALL ensure_model_output_workspace(work, 0, nnode - 1) CALL CD_Get_Model_Tension(models(li), work%tension(1:nnode - 1), es, em) @@ -36870,6 +36898,21 @@ SUBROUTINE check_channel(ch, lines, points, sections, ErrStat, ErrMsg, bodies, r CALL fail(ErrStat, ErrMsg, 'OUTPUT "'//TRIM(ch)//'": line '//TRIM(int_to_str(line_id))//' is not '// & 'torsionally restrained (END CONNECTIONS TorsStiffness), so it carries no torque'); RETURN END IF + ELSE IF (is_load_power_channel(lo)) THEN + CALL parse_line_node_channel(ch, line_id, node, kind, comp) + li = find_line(lines, line_id) + IF (li /= 0 .AND. node == 0 .AND. names_node_zero(lo)) THEN + CALL fail(ErrStat, ErrMsg, 'OUTPUT "'//TRIM(ch)//'": node numbers start at 1 = End A (MoorDyn '// & + 'numbers from N0)'); RETURN + END IF + IF (li == 0 .OR. kind == 0 .OR. node < 1) THEN + CALL fail(ErrStat, ErrMsg, 'OUTPUT "'//TRIM(ch)//'": bad load power channel (use VIVPow, '// & + 'DragPow, DampPow, or N per unit length, with a known line id)'); RETURN + END IF + nelem = line_nelem_from_sections(lines(li)%id, sections) + IF (node > nelem + 1) THEN + CALL fail(ErrStat, ErrMsg, 'OUTPUT "'//TRIM(ch)//'": node index exceeds line node count'); RETURN + END IF ELSE IF (starts_with(lo, 'ten') .OR. starts_with(lo, 'curv') .OR. & starts_with(lo, 'bendmom') .OR. starts_with(lo, 'stfmom') .OR. starts_with(lo, 'l')) THEN CALL parse_line_node_channel(ch, line_id, node, kind, comp) @@ -36903,6 +36946,7 @@ SUBROUTINE check_channel(ch, lines, points, sections, ErrStat, ErrMsg, bodies, r 'Point

p{x,y,z} (alias Con

p{x,y,z}), Point

F{x,y,z,H}, '// & 'TenN, CurvN, CurvXN, CurvYN, BendMomN, StfMomN, '// & 'TorqN, TwistN, Twist, '// & + 'VIVPow, DragPow, DampPow (and N), '// & 'LNp{x,y,z}, LNv{x,y,z}, LNa{x,y,z}, LNDec, LNAzi, '// & 'TDP{s,x,y,z,Lay,Exc,Grd}, or the Body/Rod channels)'); RETURN END IF @@ -36911,11 +36955,12 @@ END SUBROUTINE check_channel LOGICAL FUNCTION CD_Is_Line_Node_Channel(ch) RESULT(yes) !! True for an OUTPUTS channel that names a node of a line (TenN, Curv, BendMom, StfMom, !! Torq, TwistN, LN...), whose node numbering differs from MoorDyn's - !! (CD_LINE_NODE_NUMBERING_NOTE); the line total Twist names no node. + !! (CD_LINE_NODE_NUMBERING_NOTE); the line totals Twist, VIVPow, DragPow and + !! DampPow name no node. CHARACTER(*), INTENT(IN) :: ch INTEGER :: line_id, node_id, kind, comp CALL parse_line_node_channel(ch, line_id, node_id, kind, comp) - yes = kind /= 0 .AND. kind /= 11 + yes = kind /= 0 .AND. kind /= 11 .AND. kind /= 15 .AND. kind /= 17 .AND. kind /= 19 END FUNCTION CD_Is_Line_Node_Channel PURE LOGICAL FUNCTION names_node_zero(lo) RESULT(yes) @@ -37158,11 +37203,17 @@ SUBROUTINE parse_line_node_channel(ch, line_id, node_id, kind, comp) !! TorqN -> kind=9, comp=0 line torque [N.m] !! TwistN -> kind=10, comp=0 twist from End A [deg] !! Twist -> kind=11, comp=0 total twist (node 1) [deg] + !! VIVPow -> kind=15, comp=0 power of the VIV loads on the line (node 1) [W] + !! VIVPowN -> kind=16, comp=0 the same per unit length about node J [W/m] + !! DragPow -> kind=17, comp=0 power of the hydrodynamic drag (node 1) [W] + !! DragPowN -> kind=18, comp=0 the same per unit length about node J [W/m] + !! DampPow -> kind=19, comp=0 power of the structural damping (node 1) [W] + !! DampPowN -> kind=20, comp=0 the same per unit length about node J [W/m] CHARACTER(*), INTENT(IN) :: ch INTEGER, INTENT(OUT) :: line_id, node_id, kind, comp CHARACTER(NAMELEN) :: lo - INTEGER :: npos, field_pos, last, sfx + INTEGER :: npos, field_pos, last, sfx, plen, pkind lo = to_lower(ch) line_id = 0 @@ -37210,6 +37261,24 @@ SUBROUTINE parse_line_node_channel(ch, line_id, node_id, kind, comp) CALL parse_keyword_line_node(lo, 6, last, line_id, node_id) IF (line_id > 0 .AND. node_id > 0) kind = 12 RETURN + ELSE IF (is_load_power_channel(lo)) THEN + ! the load power channels: the line total (node 1, as Twist), or the power per + ! unit length about a node N (the next kind) + plen = MERGE(6, 7, starts_with(lo, 'vivpow')) + pkind = MERGE(15, MERGE(17, 19, starts_with(lo, 'dragpow')), starts_with(lo, 'vivpow')) + IF (last > plen) THEN + IF (INDEX(lo(plen + 1:last), 'n') == 0) THEN + line_id = parse_positive_int(lo, plen + 1, last) + IF (line_id > 0) THEN + node_id = 1 + kind = pkind + END IF + RETURN + END IF + END IF + CALL parse_keyword_line_node(lo, plen, last, line_id, node_id) + IF (line_id > 0 .AND. node_id > 0) kind = pkind + 1 + RETURN END IF ! LN... channels: p/v/a{x,y,z} (component) or Dec/Azi (scalar). IF (.NOT. starts_with(lo, 'l')) RETURN @@ -37272,6 +37341,45 @@ SUBROUTINE parse_keyword_line_node(lo, prefix_len, last, line_id, node_id) node_id = parse_positive_int(lo, npos + 1, last) END SUBROUTINE parse_keyword_line_node + LOGICAL FUNCTION is_load_power_channel(lo) RESULT(yes) + !! The load power channels VIVPow, DragPow and DampPow (lower case), of a line or a node. + CHARACTER(*), INTENT(IN) :: lo + yes = starts_with(lo, 'vivpow') .OR. starts_with(lo, 'dragpow') .OR. starts_with(lo, 'damppow') + END FUNCTION is_load_power_channel + + PURE LOGICAL FUNCTION is_load_power_kind(kind) RESULT(yes) + !! The parse_line_node_channel kinds of the load power channels (15-20). + INTEGER, INTENT(IN) :: kind + yes = kind >= 15 .AND. kind <= 20 + END FUNCTION is_load_power_kind + + PURE REAL(wp) FUNCTION load_power_value(kind, inode, p_viv, p_drag, p_damp, l0) RESULT(val) + !! A load power channel from the node powers of its line (internal order, element e joining + !! nodes e and e+1 of unstretched length l0(e)): the line total [W] for the odd kinds (15, 17, + !! 19), and for the even ones the power per unit unstretched length about internal node inode + !! [W/m], the node's power over half the unstretched length of its elements. + INTEGER, INTENT(IN) :: kind, inode + REAL(wp), INTENT(IN) :: p_viv(:), p_drag(:), p_damp(:), l0(:) + REAL(wp) :: trib + val = CD_ZERO + SELECT CASE (kind) + CASE (15) + val = SUM(p_viv) + CASE (17) + val = SUM(p_drag) + CASE (19) + val = SUM(p_damp) + CASE (16, 18, 20) + trib = CD_ZERO + IF (inode > 1) trib = trib + 0.5_wp*l0(inode - 1) + IF (inode <= SIZE(l0)) trib = trib + 0.5_wp*l0(inode) + IF (.NOT. (trib > CD_ZERO)) RETURN + IF (kind == 16) val = p_viv(inode)/trib + IF (kind == 18) val = p_drag(inode)/trib + IF (kind == 20) val = p_damp(inode)/trib + END SELECT + END FUNCTION load_power_value + INTEGER FUNCTION parse_positive_int(s, first, last) RESULT(n) CHARACTER(*), INTENT(IN) :: s INTEGER, INTENT(IN) :: first, last @@ -39061,6 +39169,17 @@ SUBROUTINE eval_system_line_channel(system, li, ch, val, ErrStat, ErrMsg) CALL fail(ErrStat, ErrMsg, 'OUTPUT "'//TRIM(ch)//'": node index out of range'); RETURN END IF inode = deck_to_internal_node(node, nnode - 1) + IF (is_load_power_kind(kind)) THEN + BLOCK + REAL(wp) :: pv(nnode), pd(nnode), pm(nnode) + CALL CD_Get_System_Line_Load_Power(system, li, pv, pd, pm, es, em) + IF (es /= CD_SYSTEM_OK) THEN + CALL sys_solvefail(ch, em, ErrStat, ErrMsg); RETURN + END IF + val = load_power_value(kind, inode, pv, pd, pm, system%lines(li)%l0) + END BLOCK + RETURN + END IF IF (kind == 3) THEN BLOCK REAL(wp) :: tension(nnode - 1) @@ -39205,6 +39324,16 @@ SUBROUTINE eval_cable_channel(cable, ch, val, ErrStat, ErrMsg, mesh_node) END IF inode = deck_to_internal_node(node, nelem) SELECT CASE (kind) + CASE (15:20) ! load power: the line total, or per unit length about the node + BLOCK + REAL(wp) :: pv(nnode), pd(nnode), pm(nnode) + CALL CD_HermiteCable_Dyn_Load_Power(cable%line, pv, pd, pm, es, em) + IF (es /= CD_HCDYN_OK) THEN + CALL fail_solve(ErrStat, ErrMsg, 'OUTPUT "'//TRIM(ch)//'": finite-EI load power recovery failed: '// & + TRIM(em)); RETURN + END IF + val = load_power_value(kind, inode, pv, pd, pm, cable%line%l0) + END BLOCK CASE (3, 5, 6) ! nodal tension, curvature, bend moment CALL cable_recovered_value(cable, kind, inode, ch, val, ErrStat, ErrMsg) CASE (1) ! position (cable-local state rotated to the deck's global frame) @@ -39677,6 +39806,7 @@ FUNCTION CD_Channel_Unit(ch) RESULT(unit) !! OrcaFlex-vocabulary output unit for a channel token, by kind: tension (FairTen/AnchTen/Ten) !! and anchor force (AnchFz/AnchFH) -> (N); curvature (Curv) -> (1/m); bend moment (BendMom) !! -> (N.m); endpoint orientation/Dec/Azi -> (deg); torque (Torq) -> (N.m); twist (Twist) -> (deg); position (Point/...p) -> (m); + !! load power (VIVPow/DragPow/DampPow) -> (W), per unit length about a node -> (W/m); !! velocity (...v) -> (m/s); !! acceleration (...a) -> (m/s2). CHARACTER(*), INTENT(IN) :: ch @@ -39715,6 +39845,8 @@ FUNCTION CD_Channel_Unit(ch) RESULT(unit) CASE (7, 8); unit = '(deg)' CASE (9); unit = '(N.m)' CASE (10, 11); unit = '(deg)' + CASE (15, 17, 19); unit = '(W)' + CASE (16, 18, 20); unit = '(W/m)' CASE (1); unit = '(m)' CASE (2); unit = '(m/s)' CASE (4); unit = '(m/s2)' diff --git a/src/CableDyn_HermiteCableDynamic.f90 b/src/CableDyn_HermiteCableDynamic.f90 index e1bef7bc..5fd11852 100644 --- a/src/CableDyn_HermiteCableDynamic.f90 +++ b/src/CableDyn_HermiteCableDynamic.f90 @@ -128,6 +128,7 @@ MODULE CableDyn_HermiteCableDynamic PUBLIC :: CD_HermiteCable_Dyn_Set_Irregular_Waves PUBLIC :: CD_HermiteCable_Drag_Element PUBLIC :: CD_HermiteCable_VIV_Lift_Element + PUBLIC :: CD_HermiteCable_Dyn_Load_Power PUBLIC :: CD_HermiteCable_Axial_Damping_Element PUBLIC :: CD_HermiteCable_Axial_Damping_Resultant PUBLIC :: CD_HermiteCable_AddedMass_Element @@ -1547,6 +1548,45 @@ SUBROUTINE viv_element_lift(model, q_cfg, v_cfg, e, flift, ErrStat, ErrMsg, djq, END IF END SUBROUTINE viv_element_lift + SUBROUTINE element_drag_load(model, e, qe, ve, l0, t_eval, fdrag, ErrStat, ErrMsg) + !! The Morison drag load of element e (generalised, 12) at element state (qe, ve) and + !! unstretched length l0, in the flow the drag configuration gives at time t_eval: the current + !! plus the regular or irregular wave kinematics, or plus the held field's element average. + TYPE(CD_HermiteCableDynType), INTENT(IN) :: model + INTEGER, INTENT(IN) :: e + REAL(wp), INTENT(IN) :: qe(12), ve(12), l0, t_eval + REAL(wp), INTENT(OUT) :: fdrag(12) + INTEGER, INTENT(OUT) :: ErrStat + CHARACTER(*), INTENT(OUT) :: ErrMsg + INTEGER :: es + IF (model%has_wave .AND. model%wv_ncomp > 0) THEN + CALL CD_HermiteCable_Drag_Element(qe, ve, l0, model%current, model%waterline_z, & + model%rho_w, model%diam(e), model%cdn(e), model%cdt(e), & + fdrag, ErrStat=es, ErrMsg=ErrMsg, & + wv_depth=model%wv_depth, wv_dir=model%wv_dir, wv_t=t_eval, & + wvc_amp=model%wv_ampc, wvc_om=model%wv_omc, & + wvc_k=model%wv_kc, wvc_ph=model%wv_phc, & + wvc_e2kd=model%wv_e2kd) + ELSE IF (model%has_wave) THEN + CALL CD_HermiteCable_Drag_Element(qe, ve, l0, model%current, model%waterline_z, & + model%rho_w, model%diam(e), model%cdn(e), model%cdt(e), & + fdrag, ErrStat=es, ErrMsg=ErrMsg, & + wv_h=model%wv_h, wv_om=model%wv_om, wv_k=model%wv_k, & + wv_depth=model%wv_depth, wv_dir=model%wv_dir, wv_t=t_eval) + ELSE IF (model%has_held_field) THEN + CALL CD_HermiteCable_Drag_Element(qe, ve, l0, & + model%current + 0.5_wp*(model%hf_u(:, e) + model%hf_u(:, e + 1)), & + 0.5_wp*(model%hf_wl(e) + model%hf_wl(e + 1)), & + model%rho_w, model%diam(e), model%cdn(e), model%cdt(e), & + fdrag, ErrStat=es, ErrMsg=ErrMsg) + ELSE + CALL CD_HermiteCable_Drag_Element(qe, ve, l0, model%current, model%waterline_z, & + model%rho_w, model%diam(e), model%cdn(e), model%cdt(e), & + fdrag, ErrStat=es, ErrMsg=ErrMsg) + END IF + ErrStat = es + END SUBROUTINE element_drag_load + SUBROUTINE CD_HermiteCable_Dyn_VIV_Node_Lift(model, lift, ErrStat, ErrMsg) !! The VIV lift on every node at the committed state [N] (3, nn), in the model frame: the !! translational components of the elements' consistent lift loads, summed at the nodes @@ -1575,6 +1615,86 @@ SUBROUTINE CD_HermiteCable_Dyn_VIV_Node_Lift(model, lift, ErrStat, ErrMsg) END DO END SUBROUTINE CD_HermiteCable_Dyn_VIV_Node_Lift + SUBROUTINE CD_HermiteCable_Dyn_Load_Power(model, p_viv, p_drag, p_damp, ErrStat, ErrMsg) + !! The power [W] three loads deliver to the cable at the committed state, per node (nn): the + !! VIV loads (cross-flow lift, and the in-line force where it is on), the hydrodynamic drag + !! (the cable's Morison drag and the attachments' drag) and the structural damping (the axial + !! and bending dashpots, BA and Bb). An element's generalised load f (12) delivers f . v_e, + !! half to each of its two nodes, so the node values sum to the exact power of the load; an + !! attachment's drag delivers f . v at its node. The damping power of every element, and so of + !! every node, is never positive. The torsional damping Bt is not included. + TYPE(CD_HermiteCableDynType), INTENT(IN) :: model + REAL(wp), INTENT(OUT) :: p_viv(:), p_drag(:), p_damp(:) + INTEGER, INTENT(OUT) :: ErrStat + CHARACTER(*), INTENT(OUT) :: ErrMsg + REAL(wp) :: qe(12), ve(12), fe(12), rk(3), jrel(3, 3), jtan(3, 3), fd(3) + INTEGER :: e, k, base + LOGICAL :: has_jac + p_viv = CD_ZERO + p_drag = CD_ZERO + p_damp = CD_ZERO + ErrStat = CD_HCDYN_OK; ErrMsg = '' + IF (.NOT. model%initialized) THEN + ErrStat = CD_HCDYN_BADINPUT; ErrMsg = 'CD_HermiteCable_Dyn_Load_Power: model not initialised'; RETURN + END IF + IF (SIZE(p_viv) /= model%nn .OR. SIZE(p_drag) /= model%nn .OR. SIZE(p_damp) /= model%nn) THEN + ErrStat = CD_HCDYN_BADINPUT; ErrMsg = 'CD_HermiteCable_Dyn_Load_Power: the powers must have one entry per node' + RETURN + END IF + DO e = 1, model%ne + qe(1:6) = model%q(6*(e - 1) + 1:6*e); qe(7:12) = model%q(6*e + 1:6*(e + 1)) + ve(1:6) = model%v(6*(e - 1) + 1:6*e); ve(7:12) = model%v(6*e + 1:6*(e + 1)) + IF (model%has_axial_damping .OR. model%has_bend_damping) THEN + ! an internal force: the load on the nodes is -fe + CALL structural_damping_element(model, e, qe, ve, fe, ErrStat, ErrMsg) + IF (ErrStat /= CD_HCDYN_OK) THEN + ErrMsg = 'CD_HermiteCable_Dyn_Load_Power: '//TRIM(ErrMsg); RETURN + END IF + CALL add_shares(p_damp, -fe) + END IF + IF (model%has_drag) THEN + CALL element_drag_load(model, e, qe, ve, model%l0(e), model%t, fe, ErrStat, ErrMsg) + IF (ErrStat /= CD_HCDYN_OK) THEN + ErrMsg = 'CD_HermiteCable_Dyn_Load_Power: '//TRIM(ErrMsg); RETURN + END IF + CALL add_shares(p_drag, fe) + END IF + IF (model%has_viv) THEN + CALL viv_element_lift(model, model%q, model%v, e, fe, ErrStat, ErrMsg) + IF (ErrStat /= CD_HCDYN_OK) THEN + ErrMsg = 'CD_HermiteCable_Dyn_Load_Power: '//TRIM(ErrMsg); RETURN + END IF + CALL add_shares(p_viv, fe) + END IF + END DO + IF (ALLOCATED(model%att_node)) THEN + DO k = 1, SIZE(model%att_node) + CALL attachment_residual(model, k, model%q, model%v, .FALSE., rk, has_jac, jrel, jtan, ErrStat, ErrMsg, & + f_drag=fd) + IF (ErrStat /= CD_HCDYN_OK) THEN + ErrMsg = 'CD_HermiteCable_Dyn_Load_Power: '//TRIM(ErrMsg); RETURN + END IF + base = 6*(model%att_node(k) - 1) + p_drag(model%att_node(k)) = p_drag(model%att_node(k)) + DOT_PRODUCT(fd, model%v(base + 1:base + 3)) + END DO + END IF + IF (.NOT. (CD_All_Finite(p_viv) .AND. CD_All_Finite(p_drag) .AND. CD_All_Finite(p_damp))) THEN + ErrStat = CD_HCDYN_NOCONVERGE; ErrMsg = 'CD_HermiteCable_Dyn_Load_Power: non-finite load power' + END IF + + CONTAINS + + SUBROUTINE add_shares(p, f) + !! Element e's load f (on the nodes) times its generalised velocity, half to each node. + REAL(wp), INTENT(INOUT) :: p(:) + REAL(wp), INTENT(IN) :: f(12) + REAL(wp) :: pe + pe = 0.5_wp*DOT_PRODUCT(f, ve) + p(e) = p(e) + pe + p(e + 1) = p(e + 1) + pe + END SUBROUTINE add_shares + END SUBROUTINE CD_HermiteCable_Dyn_Load_Power + 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 @@ -1793,10 +1913,12 @@ SUBROUTINE assemble_attachments(model, q_cfg, v_cfg, want_residual, want_tangent END DO END SUBROUTINE assemble_attachments - SUBROUTINE attachment_residual(model, k, q_cfg, v_cfg, want_jac, rk, has_jac, jrel, jtan, ErrStat, ErrMsg) + SUBROUTINE attachment_residual(model, k, q_cfg, v_cfg, want_jac, rk, has_jac, jrel, jtan, ErrStat, ErrMsg, & + f_drag) !! Contribution rk of attachment k to R = f_int - f_ext at the translations of its node: !! weight, buoyancy, Froude-Krylov force and drag (inertia excluded). With want_jac, the - !! drag Jacobians d f/d w and d f/d tangent are returned when has_jac is set. + !! drag Jacobians d f/d w and d f/d tangent are returned when has_jac is set. f_drag + !! (optional) returns the drag force on the node alone (zero above the free surface). TYPE(CD_HermiteCableDynType), INTENT(IN) :: model INTEGER, INTENT(IN) :: k REAL(wp), INTENT(IN) :: q_cfg(:), v_cfg(:) @@ -1805,10 +1927,12 @@ SUBROUTINE attachment_residual(model, k, q_cfg, v_cfg, want_jac, rk, has_jac, jr LOGICAL, INTENT(OUT) :: has_jac INTEGER, INTENT(OUT) :: ErrStat CHARACTER(*), INTENT(OUT) :: ErrMsg + REAL(wp), INTENT(OUT), OPTIONAL :: f_drag(3) INTEGER :: j, base REAL(wp) :: u(3), ud(3), wrel(3), wl, f(3) ErrStat = CD_HCDYN_OK; ErrMsg = '' rk = CD_ZERO; jrel = CD_ZERO; jtan = CD_ZERO; has_jac = .FALSE. + IF (PRESENT(f_drag)) f_drag = CD_ZERO j = model%att_node(k) base = 6*(j - 1) u = CD_ZERO; ud = CD_ZERO; wl = CD_ZERO @@ -1840,6 +1964,7 @@ SUBROUTINE attachment_residual(model, k, q_cfg, v_cfg, want_jac, rk, has_jac, jr END IF IF (ErrStat /= CD_HCDYN_OK) RETURN rk = rk - f + IF (PRESENT(f_drag)) f_drag = f END SUBROUTINE attachment_residual SUBROUTINE CD_HermiteCable_Dyn_Recompute_Acceleration(model, ErrStat, ErrMsg, pres_dofs, pres_a) @@ -6899,31 +7024,7 @@ SUBROUTINE CD_HermiteCable_Dyn_End_Force(model, node, force, ErrStat, ErrMsg) IF (gap > CD_ZERO) r3(3) = r3(3) - model%kn*gap*model%trib(node) END IF IF (model%has_drag) THEN - IF (model%has_wave .AND. model%wv_ncomp > 0) THEN - CALL CD_HermiteCable_Drag_Element(qe, ve, model%l0(e), model%current, model%waterline_z, & - model%rho_w, model%diam(e), model%cdn(e), model%cdt(e), & - fdrag, ErrStat=es, ErrMsg=em2, & - wv_depth=model%wv_depth, wv_dir=model%wv_dir, wv_t=model%t, & - wvc_amp=model%wv_ampc, wvc_om=model%wv_omc, & - wvc_k=model%wv_kc, wvc_ph=model%wv_phc, & - wvc_e2kd=model%wv_e2kd) - ELSE IF (model%has_wave) THEN - CALL CD_HermiteCable_Drag_Element(qe, ve, model%l0(e), model%current, model%waterline_z, & - model%rho_w, model%diam(e), model%cdn(e), model%cdt(e), & - fdrag, ErrStat=es, ErrMsg=em2, & - wv_h=model%wv_h, wv_om=model%wv_om, wv_k=model%wv_k, & - wv_depth=model%wv_depth, wv_dir=model%wv_dir, wv_t=model%t) - ELSE IF (model%has_held_field) THEN - CALL CD_HermiteCable_Drag_Element(qe, ve, model%l0(e), & - model%current + 0.5_wp*(model%hf_u(:, e) + model%hf_u(:, e + 1)), & - 0.5_wp*(model%hf_wl(e) + model%hf_wl(e + 1)), & - model%rho_w, model%diam(e), model%cdn(e), model%cdt(e), & - fdrag, ErrStat=es, ErrMsg=em2) - ELSE - CALL CD_HermiteCable_Drag_Element(qe, ve, model%l0(e), model%current, model%waterline_z, & - model%rho_w, model%diam(e), model%cdn(e), model%cdt(e), & - fdrag, ErrStat=es, ErrMsg=em2) - END IF + CALL element_drag_load(model, e, qe, ve, model%l0(e), model%t, fdrag, es, em2) IF (es /= CD_HCDYN_OK) THEN ErrStat = es; ErrMsg = 'CD_HermiteCable_Dyn_End_Force: '//TRIM(em2); RETURN END IF @@ -7802,31 +7903,7 @@ SUBROUTINE element_end_residual(model, e, g, ErrStat, ErrMsg) IF (dry) g(ZS) = g(ZS) + fdry END IF IF (model%has_drag) THEN - IF (model%has_wave .AND. model%wv_ncomp > 0) THEN - CALL CD_HermiteCable_Drag_Element(qe, ve, l0, model%current, model%waterline_z, & - model%rho_w, model%diam(e), model%cdn(e), model%cdt(e), & - fx, ErrStat=es, ErrMsg=em2, & - wv_depth=model%wv_depth, wv_dir=model%wv_dir, wv_t=model%t, & - wvc_amp=model%wv_ampc, wvc_om=model%wv_omc, & - wvc_k=model%wv_kc, wvc_ph=model%wv_phc, & - wvc_e2kd=model%wv_e2kd) - ELSE IF (model%has_wave) THEN - CALL CD_HermiteCable_Drag_Element(qe, ve, l0, model%current, model%waterline_z, & - model%rho_w, model%diam(e), model%cdn(e), model%cdt(e), & - fx, ErrStat=es, ErrMsg=em2, & - wv_h=model%wv_h, wv_om=model%wv_om, wv_k=model%wv_k, & - wv_depth=model%wv_depth, wv_dir=model%wv_dir, wv_t=model%t) - ELSE IF (model%has_held_field) THEN - CALL CD_HermiteCable_Drag_Element(qe, ve, l0, & - model%current + 0.5_wp*(model%hf_u(:, e) + model%hf_u(:, e + 1)), & - 0.5_wp*(model%hf_wl(e) + model%hf_wl(e + 1)), & - model%rho_w, model%diam(e), model%cdn(e), model%cdt(e), & - fx, ErrStat=es, ErrMsg=em2) - ELSE - CALL CD_HermiteCable_Drag_Element(qe, ve, l0, model%current, model%waterline_z, & - model%rho_w, model%diam(e), model%cdn(e), model%cdt(e), & - fx, ErrStat=es, ErrMsg=em2) - END IF + CALL element_drag_load(model, e, qe, ve, l0, model%t, fx, es, em2) IF (es /= CD_HCDYN_OK) GOTO 900 g = g - fx END IF @@ -9244,31 +9321,7 @@ SUBROUTINE assemble_residual(model, q_cfg, v_cfg, t_eval, want_residual, want_ta fdrag, djq, djv, es, em_e) END IF ELSE - IF (model%has_wave .AND. model%wv_ncomp > 0) THEN - CALL CD_HermiteCable_Drag_Element(qe, ve, model%l0(e), model%current, model%waterline_z, & - model%rho_w, model%diam(e), model%cdn(e), model%cdt(e), & - fdrag, ErrStat=es, ErrMsg=em_e, & - wv_depth=model%wv_depth, wv_dir=model%wv_dir, wv_t=t_eval, & - wvc_amp=model%wv_ampc, wvc_om=model%wv_omc, & - wvc_k=model%wv_kc, wvc_ph=model%wv_phc, & - wvc_e2kd=model%wv_e2kd) - ELSE IF (model%has_wave) THEN - CALL CD_HermiteCable_Drag_Element(qe, ve, model%l0(e), model%current, model%waterline_z, & - model%rho_w, model%diam(e), model%cdn(e), model%cdt(e), & - fdrag, ErrStat=es, ErrMsg=em_e, & - wv_h=model%wv_h, wv_om=model%wv_om, wv_k=model%wv_k, & - wv_depth=model%wv_depth, wv_dir=model%wv_dir, wv_t=t_eval) - ELSE IF (model%has_held_field) THEN - CALL CD_HermiteCable_Drag_Element(qe, ve, model%l0(e), & - model%current + 0.5_wp*(model%hf_u(:, e) + model%hf_u(:, e + 1)), & - 0.5_wp*(model%hf_wl(e) + model%hf_wl(e + 1)), & - model%rho_w, model%diam(e), model%cdn(e), model%cdt(e), & - fdrag, ErrStat=es, ErrMsg=em_e) - ELSE - CALL CD_HermiteCable_Drag_Element(qe, ve, model%l0(e), model%current, model%waterline_z, & - model%rho_w, model%diam(e), model%cdn(e), model%cdt(e), & - fdrag, ErrStat=es, ErrMsg=em_e) - END IF + CALL element_drag_load(model, e, qe, ve, model%l0(e), t_eval, fdrag, es, em_e) END IF IF (es /= CD_HCDYN_OK) THEN ErrStat = es; ErrMsg = TRIM(em_e); RETURN diff --git a/src/CableDyn_Model.f90 b/src/CableDyn_Model.f90 index 06960125..90fde800 100644 --- a/src/CableDyn_Model.f90 +++ b/src/CableDyn_Model.f90 @@ -99,6 +99,7 @@ MODULE CableDyn_Model PUBLIC :: CD_Latch_Model_VIV_Window PUBLIC :: CD_Get_Model_VIV_State, CD_Set_Model_VIV_State, CD_Model_Has_VIV, CD_Get_Model_VIV_Lift PUBLIC :: CD_Model_Has_VIV_Inline + PUBLIC :: CD_Get_Model_Load_Power PUBLIC :: CD_Get_Model_Tension PUBLIC :: CD_Get_Model_Internal_Rates PUBLIC :: CD_Get_Model_EndForces @@ -4288,6 +4289,86 @@ SUBROUTINE CD_Get_Model_VIV_Lift(model, lift, ErrStat, ErrMsg) END DO END SUBROUTINE CD_Get_Model_VIV_Lift + SUBROUTINE CD_Get_Model_Load_Power(model, p_viv, p_drag, p_damp, ErrStat, ErrMsg) + !! The power [W] three loads deliver to the line at the committed state, per node (n_nodes): + !! the VIV loads (cross-flow lift, and the in-line force where it is on) at the committed + !! phases, the Morison drag and the axial structural damping (BA). An element's force on its + !! two nodes delivers f_a . v_a + f_b . v_b, half to each node, and a node load f . v to its + !! node, so the node values sum to the exact power of the load. The damping power of every + !! element, and so of every node, is never positive; the viscoelastic and Syrope laws' own + !! damping is not included. + TYPE(CD_ModelType), INTENT(IN) :: model + REAL(wp), INTENT(OUT) :: p_viv(:), p_drag(:), p_damp(:) + INTEGER, INTENT(OUT) :: ErrStat + CHARACTER(*), INTENT(OUT) :: ErrMsg + INTEGER :: e, nd, nn, idx(6), lk + REAL(wp) :: q2(6), v2(6), f2(6), fluid2(3, 2), wl2(2), fl(3) + LOGICAL :: ok + p_viv = CD_ZERO + p_drag = CD_ZERO + p_damp = CD_ZERO + ErrStat = CD_MODEL_OK + ErrMsg = '' + IF (.NOT. model%initialized) THEN + CALL fail(ErrStat, ErrMsg, 'load power: the model is not initialised') + RETURN + END IF + nn = model%n_dof/3 + IF (SIZE(p_viv) /= nn .OR. SIZE(p_drag) /= nn .OR. SIZE(p_damp) /= nn) THEN + CALL fail(ErrStat, ErrMsg, 'load power: the powers must have one entry per node') + RETURN + END IF + lk = MIN(LEN(ErrMsg), KERNEL_MSG_LEN) + DO e = 1, model%n_elem + CALL extract_element_state(model, e, model%q, model%v, idx, q2, v2) + IF (model%has_damping) THEN + CALL CD_Axial_Damping_Element_Force(q2(1:3), q2(4:6), v2(1:3), v2(4:6), model%l0(e), & + model%ba_dyn(e), f2, ErrStat, ErrMsg(1:lk), & + l0_dot=model%l0_dot(e), inputs_validated=.TRUE.) + IF (ErrStat /= 0) RETURN + CALL add_shares(p_damp) + END IF + IF (model%has_morison_drag) THEN + CALL extract_nodal_vector(model%fluid_velocity, model, e, fluid2) + CALL extract_nodal_scalar(model%drag_waterline_z, model, e, wl2) + CALL CD_Morison_Drag_Element_Force(q2(1:3), q2(4:6), v2(1:3), v2(4:6), model%l0(e), & + fluid2(:, 1), fluid2(:, 2), wl2(1), wl2(2), model%drag_rho, & + model%drag_diameter_elem(e), model%drag_cdn_elem(e), & + model%drag_cdt_elem(e), f2, ErrStat, ErrMsg(1:lk), inputs_validated=.TRUE.) + IF (ErrStat /= 0) RETURN + CALL add_shares(p_drag) + END IF + END DO + IF (model%has_viv) THEN + DO nd = 2, nn - 1 + IF (.NOT. model%viv_node(nd)) CYCLE + CALL viv_node_load(model, model%q, model%v, nd, .FALSE., fl, ok) + IF (.NOT. ok) THEN + CALL fail(ErrStat, ErrMsg, 'load power: the neighbours of a VIV node coincide (no line tangent)') + RETURN + END IF + p_viv(nd) = DOT_PRODUCT(fl, model%v(3*nd - 2:3*nd)) + END DO + END IF + IF (.NOT. (CD_All_Finite(p_viv) .AND. CD_All_Finite(p_drag) .AND. CD_All_Finite(p_damp))) THEN + CALL fail(ErrStat, ErrMsg, 'load power: non-finite load power') + END IF + + CONTAINS + + SUBROUTINE add_shares(p) + !! The element force f2 on its two nodes times their velocities, half to each node. + REAL(wp), INTENT(INOUT) :: p(:) + INTEGER :: a, b + REAL(wp) :: pe + a = (idx(1) + 2)/3 + b = (idx(4) + 2)/3 + pe = 0.5_wp*DOT_PRODUCT(f2, v2) + p(a) = p(a) + pe + p(b) = p(b) + pe + END SUBROUTINE add_shares + END SUBROUTINE CD_Get_Model_Load_Power + PURE LOGICAL FUNCTION CD_Model_Has_VIV_Inline(model) RESULT(has) !! True if the model carries the in-line VIV phase state (as well as the cross-flow one). TYPE(CD_ModelType), INTENT(IN) :: model diff --git a/src/CableDyn_System.f90 b/src/CableDyn_System.f90 index 0f1fd327..bb58dd14 100644 --- a/src/CableDyn_System.f90 +++ b/src/CableDyn_System.f90 @@ -18,7 +18,7 @@ MODULE CableDyn_System CD_Model_Has_Viscoelastic, CD_Get_Model_VE_Dl1, CD_Set_Model_VE_Dl1, & CD_Model_Has_Syrope, CD_Get_Model_Syrope_State, CD_Set_Model_Syrope_State, & CD_Model_Has_VIV, CD_Get_Model_VIV_State, CD_Set_Model_VIV_State, CD_Get_Model_VIV_Lift, & - CD_Model_Has_VIV_Inline, & + CD_Model_Has_VIV_Inline, CD_Get_Model_Load_Power, & CD_Model_Has_Friction, CD_Get_Model_Friction_Anchors, CD_Set_Model_Friction_Anchors, & CD_Latch_Model_VIV_Window, & CD_Get_Model_EndNodeMassDiag, CD_Get_Model_EndNodeAddedMass, & @@ -80,7 +80,7 @@ MODULE CableDyn_System PUBLIC :: CD_Set_System_Line_Friction_Anchors PUBLIC :: CD_Get_System_Line_Syrope_State PUBLIC :: CD_System_Line_VIV_MirrorSize, CD_Get_System_Line_VIV_State, CD_Set_System_Line_VIV_State, & - CD_Get_System_Line_VIV_Lift + CD_Get_System_Line_VIV_Lift, CD_Get_System_Line_Load_Power PUBLIC :: CD_Set_System_Line_Syrope_State PUBLIC :: CD_Get_System_PointBlocks PUBLIC :: CD_Get_System_Point_State @@ -1043,6 +1043,32 @@ SUBROUTINE CD_Set_System_Line_VIV_State(system, line_index, buf, ErrStat, ErrMsg ErrMsg = '' END SUBROUTINE CD_Set_System_Line_VIV_State + SUBROUTINE CD_Get_System_Line_Load_Power(system, line_index, p_viv, p_drag, p_damp, ErrStat, ErrMsg) + !! The VIV, drag and structural damping power [W] on every node of one contained line at the + !! committed state (n_nodes each; CD_Get_Model_Load_Power). + TYPE(CD_SystemType), INTENT(IN) :: system + INTEGER, INTENT(IN) :: line_index + REAL(wp), INTENT(OUT) :: p_viv(:), p_drag(:), p_damp(:) + INTEGER, INTENT(OUT) :: ErrStat + CHARACTER(*), INTENT(OUT) :: ErrMsg + INTEGER :: es + CHARACTER(160) :: em + + p_viv = CD_ZERO + p_drag = CD_ZERO + p_damp = CD_ZERO + CALL validate_line_index(system, line_index, ErrStat, ErrMsg) + IF (ErrStat /= CD_SYSTEM_OK) RETURN + CALL CD_Get_Model_Load_Power(system%lines(line_index), p_viv, p_drag, p_damp, es, em) + IF (es /= CD_MODEL_OK) THEN + ErrStat = CD_SYSTEM_SOLVEFAIL + ErrMsg = 'CableDyn_System: line load power query failed: '//TRIM(em) + RETURN + END IF + ErrStat = CD_SYSTEM_OK + ErrMsg = '' + END SUBROUTINE CD_Get_System_Line_Load_Power + SUBROUTINE CD_Get_System_Line_VIV_Lift(system, line_index, lift, ErrStat, ErrMsg) !! VIV lift force on every node of one contained line at the committed state (3, n_nodes). TYPE(CD_SystemType), INTENT(IN) :: system diff --git a/tests/test_hermite_load_power.f90 b/tests/test_hermite_load_power.f90 new file mode 100644 index 00000000..1f0305a8 --- /dev/null +++ b/tests/test_hermite_load_power.f90 @@ -0,0 +1,180 @@ +! File: tests/test_hermite_load_power.f90 +! SPDX-License-Identifier: Apache-2.0 +! Copyright (c) 2026 Jae Hoon Seo, SMI Lab, Inha University +PROGRAM test_hermite_load_power + !! The load powers of a finite-EI cable (CD_HermiteCable_Dyn_Load_Power) close its energy + !! balance: on a weightless, pinned-pinned, tensioned cable with no added mass the kinetic plus + !! elastic energy changes by the work of the VIV loads, the drag and the structural damping, + !! E(t) - E(0) = int (P_viv + P_drag + P_damp) dt, + !! integrated by the trapezoidal rule over generalised-alpha steps with rho_inf = 1 (no numerical + !! damping) of 1/200 of the period of the motion the case resolves, so the two sides agree to + !! the steps' second-order error. + !! L1 the free decay of the first bending mode with the bending dashpot Bb; + !! L2 the free decay of the first axial mode with the axial dashpot BA (its own time step); + !! L3 the bending decay in still water with Morison drag and no dashpots; + !! L4 a cable starting straight in a 0.5 m/s current with the cross-flow and in-line VIV loads, + !! the drag and the bending dashpot; + !! each within 0.5 % of the largest work; the damping power is never positive at any node, and + !! the VIV and drag powers are zero without those loads. L5 power arrays of the wrong size are + !! refused. + USE CableDyn_Precision, ONLY: wp + USE CableDyn_HermiteCableDynamic, ONLY: CD_HermiteCableDynType, CD_HermiteCable_Dyn_Init, & + CD_HermiteCable_Dyn_Step, CD_HermiteCable_Dyn_Set_Bending_Damping, & + CD_HermiteCable_Dyn_Set_Axial_Damping, CD_HermiteCable_Dyn_Set_Drag, & + CD_HermiteCable_Dyn_Set_VIV, CD_HermiteCable_Dyn_Energy, & + CD_HermiteCable_Dyn_Load_Power, CD_HCDYN_OK + IMPLICIT NONE + REAL(wp), PARAMETER :: PI = 3.14159265358979323846_wp + REAL(wp), PARAMETER :: LL = 20.0_wp, EA = 1.0e8_wp, EI = 1.0e5_wp, RHOA = 10.0_wp, TENS = 1.0e4_wp + REAL(wp), PARAMETER :: DIAM = 0.1_wp, RHOW = 1025.0_wp + INTEGER, PARAMETER :: NE = 40, NN = NE + 1, NDOF = 6*NN + INTEGER, PARAMETER :: BENDING = 1, AXIAL = 2, DRAG = 3, VIV = 4 + INTEGER :: nfail = 0 + + CALL balance_case('L1 bending dashpot decay', BENDING) + CALL balance_case('L2 axial dashpot decay', AXIAL) + CALL balance_case('L3 still-water drag decay', DRAG) + CALL balance_case('L4 VIV in a current', VIV) + CALL check_refusals() + IF (nfail > 0) THEN + WRITE (*, '(A,I0,A)') 'FAIL: ', nfail, ' assertion(s) failed' + ERROR STOP 1 + END IF + WRITE (*, '(A)') 'PASS: Hermite load power energy balance' + +CONTAINS + + SUBROUTINE require(cond, label) + LOGICAL, INTENT(IN) :: cond + CHARACTER(*), INTENT(IN) :: label + IF (cond) RETURN + nfail = nfail + 1 + WRITE (*, '(A)') 'FAIL: '//TRIM(label) + END SUBROUTINE require + + SUBROUTINE setup(model, a0, u0, ok) + !! The tensioned cable along x, pinned at both ends, at rest in its first bending mode of + !! amplitude a0 (z) and its first axial mode of amplitude u0 (x), rho_inf = 1. + TYPE(CD_HermiteCableDynType), INTENT(OUT) :: model + REAL(wp), INTENT(IN) :: a0, u0 + LOGICAL, INTENT(OUT) :: ok + REAL(wp) :: l0(NE), ea_(NE), ei_(NE), rho(NE), w(NE), q(NDOF), eps, lt, x, s, c + INTEGER :: k, es + CHARACTER(512) :: em + eps = TENS/EA; lt = (1.0_wp + eps)*LL + l0 = LL/REAL(NE, wp); ea_ = EA; ei_ = EI; rho = RHOA; w = 0.0_wp + DO k = 1, NN + x = lt*REAL(k - 1, wp)/REAL(NE, wp) + s = SIN(PI*x/lt) + c = COS(PI*x/lt) + q(6*k - 5:6*k) = [x + u0*s, 0.0_wp, a0*s, (1.0_wp + eps) + (1.0_wp + eps)*u0*PI/lt*c, 0.0_wp, & + (1.0_wp + eps)*a0*PI/lt*c] + END DO + CALL CD_HermiteCable_Dyn_Init(model, l0, ea_, ei_, rho, w, q, [1, 2, 3, 6*NE + 1, 6*NE + 2, 6*NE + 3], & + -1.0e4_wp, 0.0_wp, 1.0_wp, es, em) + ok = es == CD_HCDYN_OK + CALL require(ok, 'init: '//TRIM(em)) + END SUBROUTINE setup + + SUBROUTINE balance_case(label, what) + CHARACTER(*), INTENT(IN) :: label + INTEGER, INTENT(IN) :: what + TYPE(CD_HermiteCableDynType) :: model + REAL(wp) :: kk, period, dt, ek, es0, e0, e1, p_prev(3), p_now(3), work(3), res, scale, pm_max + REAL(wp) :: cl(NE), cf(NE), df(NE), clx(NE), alx(NE) + INTEGER :: n, k, es, it + CHARACTER(512) :: em + LOGICAL :: zero_viv, zero_drag, ok + kk = PI/LL + IF (what == AXIAL) THEN + period = 2.0_wp*LL/SQRT(EA/RHOA) + CALL setup(model, 0.0_wp, 1.0e-4_wp, ok) + ELSE + period = 2.0_wp*PI/SQRT((EI*kk**4 + TENS*kk**2)/RHOA) + CALL setup(model, MERGE(0.0_wp, 0.05_wp, what == VIV), 0.0_wp, ok) + END IF + IF (.NOT. ok) RETURN + dt = period/200.0_wp + IF (what == AXIAL) THEN + CALL CD_HermiteCable_Dyn_Set_Axial_Damping(model, [(2.0e4_wp, k=1, NE)], es, em) + CALL require(es == CD_HCDYN_OK, label//': axial damping: '//TRIM(em)) + END IF + IF (what == BENDING .OR. what == VIV) THEN + CALL CD_HermiteCable_Dyn_Set_Bending_Damping(model, [(2.0e2_wp, k=1, NE)], es, em) + CALL require(es == CD_HCDYN_OK, label//': bending damping: '//TRIM(em)) + END IF + IF (what == DRAG .OR. what == VIV) THEN + CALL CD_HermiteCable_Dyn_Set_Drag(model, RHOW, [(DIAM, k=1, NE)], [(1.2_wp, k=1, NE)], [(0.0_wp, k=1, NE)], & + 1.0e3_wp, [0.0_wp, MERGE(0.5_wp, 0.0_wp, what == VIV), 0.0_wp], es, em) + CALL require(es == CD_HCDYN_OK, label//': drag: '//TRIM(em)) + END IF + IF (what == VIV) THEN + cl = 0.8_wp; cf = 0.18_wp; df = 0.08_wp; clx = 0.85_wp; alx = 0.15_wp + CALL CD_HermiteCable_Dyn_Set_VIV(model, cl, cf, df, 0.25_wp, es, em, clx=clx, il_alpha=alx) + CALL require(es == CD_HCDYN_OK, label//': VIV: '//TRIM(em)) + END IF + IF (es /= CD_HCDYN_OK) RETURN + CALL CD_HermiteCable_Dyn_Energy(model, ek, es0, es, em) + e0 = ek + es0 + work = 0.0_wp + pm_max = -HUGE(1.0_wp) + zero_viv = .TRUE. + zero_drag = .TRUE. + CALL powers(model, label, p_prev, pm_max, zero_viv, zero_drag) + DO n = 1, 2400 + CALL CD_HermiteCable_Dyn_Step(model, dt, 50, 1.0e-10_wp, es, em, it, res) + IF (es /= CD_HCDYN_OK) THEN + CALL require(.FALSE., label//': step failed: '//TRIM(em)); RETURN + END IF + CALL powers(model, label, p_now, pm_max, zero_viv, zero_drag) + work = work + 0.5_wp*dt*(p_prev + p_now) + p_prev = p_now + END DO + CALL CD_HermiteCable_Dyn_Energy(model, ek, es0, es, em) + e1 = ek + es0 + scale = MAXVAL(ABS(work)) + WRITE (*, '(2A,ES12.4,A,3ES12.4,A,ES10.2)') label, ': dE ', e1 - e0, ', work VIV/drag/damp ', work, & + ', mismatch/largest ', ABS(e1 - e0 - SUM(work))/MAX(scale, TINY(1.0_wp)) + CALL require(scale > 0.0_wp, label//': the loads did work') + IF (.NOT. (scale > 0.0_wp)) RETURN + CALL require(ABS(e1 - e0 - SUM(work)) <= 5.0e-3_wp*scale, label//': the load work closes the energy balance') + CALL require(pm_max <= 0.0_wp, label//': the damping power is never positive at a node') + CALL require(zero_viv .EQV. what /= VIV, label//': VIV power only with VIV') + CALL require(zero_drag .EQV. (what /= DRAG .AND. what /= VIV), label//': drag power only with drag') + IF (what == BENDING .OR. what == AXIAL) CALL require(work(3) < 0.0_wp, label//': the dashpot dissipates') + IF (what == DRAG) CALL require(work(2) < 0.0_wp, label//': still-water drag dissipates') + IF (what == VIV) CALL require(work(1) > 0.0_wp, label//': the VIV loads put energy in') + END SUBROUTINE balance_case + + SUBROUTINE powers(model, label, p, pm_max, zero_viv, zero_drag) + !! The line totals of the three load powers, with the running checks: the largest node + !! damping power, and whether the VIV and drag powers stayed zero at every node. + TYPE(CD_HermiteCableDynType), INTENT(IN) :: model + CHARACTER(*), INTENT(IN) :: label + REAL(wp), INTENT(OUT) :: p(3) + REAL(wp), INTENT(INOUT) :: pm_max + LOGICAL, INTENT(INOUT) :: zero_viv, zero_drag + REAL(wp) :: pv(NN), pd(NN), pm(NN) + INTEGER :: esp + CHARACTER(512) :: emp + CALL CD_HermiteCable_Dyn_Load_Power(model, pv, pd, pm, esp, emp) + CALL require(esp == CD_HCDYN_OK, label//': load power: '//TRIM(emp)) + p = [SUM(pv), SUM(pd), SUM(pm)] + pm_max = MAX(pm_max, MAXVAL(pm)) + zero_viv = zero_viv .AND. ALL(pv == 0.0_wp) + zero_drag = zero_drag .AND. ALL(pd == 0.0_wp) + END SUBROUTINE powers + + SUBROUTINE check_refusals() + TYPE(CD_HermiteCableDynType) :: model + REAL(wp) :: pv(NN), pd(NN), pm(NN - 1) + INTEGER :: es + LOGICAL :: ok + CHARACTER(512) :: em + CALL setup(model, 0.0_wp, 0.0_wp, ok) + IF (.NOT. ok) RETURN + CALL CD_HermiteCable_Dyn_Load_Power(model, pv, pd, pm, es, em) + CALL require(es /= CD_HCDYN_OK .AND. INDEX(em, 'one entry per node') > 0, 'L5: a wrong-size power array is refused') + END SUBROUTINE check_refusals + +END PROGRAM test_hermite_load_power diff --git a/tests/test_load_power_deck.f90 b/tests/test_load_power_deck.f90 new file mode 100644 index 00000000..b98930da --- /dev/null +++ b/tests/test_load_power_deck.f90 @@ -0,0 +1,300 @@ +! File: tests/test_load_power_deck.f90 +! SPDX-License-Identifier: Apache-2.0 +! Copyright (c) 2026 Jae Hoon Seo, SMI Lab, Inha University +PROGRAM test_load_power_deck + !! The load power channels VIVPow, DragPow and DampPow ( the line total in W, N per unit + !! length about node J in W/m) on the in-line VIV deck of tests/test_viv_inline_deck.f90: a taut + !! line, 100 m pinned at 50 m depth in a uniform 0.15 m/s current along y, Cl 0.8, ClX 0.85. + !! Locked in, the energy the line holds only oscillates, so over 50-100 s + !! mean(VIVPow + DragPow + DampPow) = 0 + !! to the window's change of energy. + !! P1 the finite-EI cable: the VIV loads put power in, the drag takes it out, the damping power + !! is never positive, and the three balance within 1 % of the VIV power; + !! P2 the per-length channels of all 51 nodes, times their half-element lengths, sum to the + !! line total; + !! P3 the same line as an EI = 0 line (the single-line march) balances within 1 % and puts in + !! the cable's VIV power within 2 %; + !! P4 the EI = 0 line split at a free point into two lines (the multi-line system) balances + !! within 1 % over both lines; + !! P5 malformed channels, an unknown line, node 0 and a node past the end are refused. + USE CableDyn_Precision, ONLY: wp + USE CableDyn_DeckDriver, ONLY: CD_Run_Deck_Driver, CD_DECKDRV_OK + IMPLICIT NONE + INTEGER, PARAMETER :: NSEG = 50 + REAL(wp), PARAMETER :: LEN0 = 99.9001_wp + INTEGER :: nfail = 0 + + CALL write_current('lpd_current.dat') + CALL check_cable() + CALL check_ei0() + CALL check_system() + CALL check_refusals() + IF (nfail > 0) THEN + WRITE (*, '(A,I0,A)') 'FAIL: ', nfail, ' assertion(s) failed' + ERROR STOP 1 + END IF + WRITE (*, '(A)') 'PASS: load power channel gates' + +CONTAINS + + SUBROUTINE require(cond, label) + LOGICAL, INTENT(IN) :: cond + CHARACTER(*), INTENT(IN) :: label + IF (cond) RETURN + nfail = nfail + 1 + WRITE (*, '(A)') 'FAIL: '//TRIM(label) + END SUBROUTINE require + + SUBROUTINE write_current(path) + CHARACTER(*), INTENT(IN) :: path + INTEGER :: u + OPEN (NEWUNIT=u, FILE=path, STATUS='REPLACE', ACTION='WRITE') + WRITE (u, '(A)') 'MoorDyn v2 water kinematics file' + WRITE (u, '(A)') 'uniform current along y for the load power deck gate' + WRITE (u, '(A)') '--------------------------- WAVES -------------------------------------' + WRITE (u, '(A)') '0 WaveKinMod - type of wave input' + WRITE (u, '(A)') '"" WaveKinFile - file containing wave elevation time series' + WRITE (u, '(A)') '0.000000E+00 dtWave - time step to use in setting up wave kinematics grid (s)' + WRITE (u, '(A)') '0 WaveDir - wave heading (deg)' + WRITE (u, '(A)') '2 - X wave input type' + WRITE (u, '(A)') '-10, 110, 2 - X wave grid point data' + WRITE (u, '(A)') '2 - Y wave input type' + WRITE (u, '(A)') '-10, 10, 2 - Y wave grid point data' + WRITE (u, '(A)') '2 - Z wave input type' + WRITE (u, '(A)') '-100, 0, 2 - Z wave grid point data' + WRITE (u, '(A)') '--------------------------- CURRENT -------------------------------------' + WRITE (u, '(A)') '1 CurrentMod - type of current input' + WRITE (u, '(A)') 'z-depth x-current y-current' + WRITE (u, '(A)') '(m) (m/s) (m/s)' + WRITE (u, '(A)') '0.0 0.0 0.15' + WRITE (u, '(A)') '-100.0 0.0 0.15' + WRITE (u, '(A)') '--------------------- need this line ------------------' + CLOSE (u) + END SUBROUTINE write_current + + SUBROUTINE write_deck(path, ei, channels, split, tmax) + !! channels: the OUTPUTS rows, ';'-separated; split: the EI = 0 line as two lines joined at + !! a free point at mid-span. + CHARACTER(*), INTENT(IN) :: path, ei, channels + LOGICAL, INTENT(IN) :: split + REAL(wp), INTENT(IN) :: tmax + INTEGER :: u, i0, i1 + OPEN (NEWUNIT=u, FILE=path, STATUS='REPLACE', ACTION='WRITE') + WRITE (u, '(A)') '--------------------- CableDyn Input File ---------------------------------' + WRITE (u, '(A)') 'load power deck gate: taut line with in-line VIV in a uniform current' + WRITE (u, '(A)') '----------------------- LINE TYPES ------------------------------------------' + WRITE (u, '(A)') 'TypeName Diam Mass/m EA BA/-zeta EI Cd Ca CdAx CaAx Cl dF cF' + WRITE (u, '(A)') '(name) (m) (kg/m) (N) (N-s/-) (-) (-) (-) (-) (-) (-) (-) (-)' + WRITE (u, '(A)') 'riser 0.10 10.0 5.0e7 -0.8 '//ei//' 1.2 1.0 0.0 0.0 0.8 0.08 0.18' + WRITE (u, '(A)') '----------------------- POINTS ----------------------------------------------' + WRITE (u, '(A)') 'ID Attachment X Y Z M V CdA CA' + WRITE (u, '(A)') '(#) (-) (m) (m) (m) (kg) (m^3) (m^2) (-)' + WRITE (u, '(A)') '1 Coupled 0.0 0.0 -50.0 0 0 0 0' + WRITE (u, '(A)') '2 Fixed 100.0 0.0 -50.0 0 0 0 0' + IF (split) WRITE (u, '(A)') '3 Free 50.0 0.0 -50.0 0 0 0 0' + WRITE (u, '(A)') '----------------------- LINES -----------------------------------------------' + WRITE (u, '(A)') 'ID LineType AttachA AttachB UnstrLen NumSegs Outputs' + WRITE (u, '(A)') '(#) (name) (#) (#) (m) (-) (-)' + IF (split) THEN + WRITE (u, '(A)') '1 riser 1 3 49.95005 25 -' + WRITE (u, '(A)') '2 riser 3 2 49.95005 25 -' + ELSE + WRITE (u, '(A)') '1 riser 1 2 99.900100 50 -' + END IF + WRITE (u, '(A)') '----------------------- VIV -------------------------------------------------' + WRITE (u, '(A)') 'TypeName ClX alpha' + WRITE (u, '(A)') '(name) (-) (-)' + WRITE (u, '(A)') 'riser 0.85 0.15' + WRITE (u, '(A)') '---------------------- OPTIONS ----------------------------------------------' + WRITE (u, '(A)') '0.01 dtM' + WRITE (u, '(A)') '100.0 WtrDpth' + WRITE (u, '(A)') '1025.0 rhoW' + WRITE (u, '(A)') '9.80665 g' + WRITE (u, '(A)') 'lpd_current.dat WaterKin' + WRITE (u, '(A)') '0.25 VIVrmsWindow' + WRITE (u, '(A,F8.3,A)') ' ', tmax, ' TMax' + WRITE (u, '(A)') '---------------------- OUTPUTS -----------------------------------------------' + i0 = 1 + DO + i1 = INDEX(channels(i0:), ';') + IF (i1 == 0) THEN + WRITE (u, '(A)') TRIM(channels(i0:)) + EXIT + END IF + WRITE (u, '(A)') channels(i0:i0 + i1 - 2) + i0 = i0 + i1 + END DO + WRITE (u, '(A)') 'END' + WRITE (u, '(A)') '------------------------- need this line --------------------------------------' + CLOSE (u) + END SUBROUTINE write_deck + + SUBROUTINE run(deck, root, ok, msg) + CHARACTER(*), INTENT(IN) :: deck, root + LOGICAL, INTENT(OUT) :: ok + CHARACTER(*), INTENT(OUT) :: msg + LOGICAL :: conv + INTEGER :: es + CALL CD_Run_Deck_Driver(deck, root, conv, es, msg) + ok = es == CD_DECKDRV_OK .AND. conv + END SUBROUTINE run + + SUBROUTINE read_out(path, ncol, tab, n) + !! The rows of a deck's main output file (time and ncol channels) from 50 s on. + CHARACTER(*), INTENT(IN) :: path + INTEGER, INTENT(IN) :: ncol + REAL(wp), ALLOCATABLE, INTENT(OUT) :: tab(:, :) + INTEGER, INTENT(OUT) :: n + CHARACTER(8192) :: rec + REAL(wp) :: row(ncol + 1) + INTEGER :: u, ios + ALLOCATE (tab(ncol + 1, 20000)) + n = 0 + OPEN (NEWUNIT=u, FILE=path, STATUS='OLD', ACTION='READ', IOSTAT=ios) + IF (ios /= 0) RETURN + READ (u, '(A)') rec + READ (u, '(A)') rec + DO + READ (u, '(A)', IOSTAT=ios) rec + IF (ios /= 0) EXIT + IF (LEN_TRIM(rec) == 0) CYCLE + READ (rec, *) row + IF (row(1) < 50.0_wp - 1.0e-9_wp) CYCLE + IF (n == SIZE(tab, 2)) EXIT + n = n + 1 + tab(:, n) = row + END DO + CLOSE (u) + END SUBROUTINE read_out + + SUBROUTINE balance(label, tab, n, lines, p_viv) + !! The mean of the three powers over the window (columns 2-4 of a line, lines in a row) and + !! the balance check; p_viv returns the mean VIV power. + CHARACTER(*), INTENT(IN) :: label + REAL(wp), INTENT(IN) :: tab(:, :) + INTEGER, INTENT(IN) :: n, lines + REAL(wp), INTENT(OUT) :: p_viv + REAL(wp) :: m(3) + INTEGER :: k, j + m = 0.0_wp + DO j = 1, lines + DO k = 1, 3 + m(k) = m(k) + SUM(tab(1 + 3*(j - 1) + k, 1:n))/REAL(n, wp) + END DO + END DO + p_viv = m(1) + WRITE (*, '(2A,3F10.4,A,ES10.2)') label, ': mean VIVPow, DragPow, DampPow [W] ', m, & + ', balance/VIV ', SUM(m)/m(1) + CALL require(m(1) > 0.0_wp .AND. m(2) < 0.0_wp, label//': the VIV loads put power in, the drag takes it out') + CALL require(ABS(SUM(m)) <= 0.01_wp*m(1), label//': the powers balance within 1 % of the VIV power') + DO j = 1, lines + CALL require(ALL(tab(1 + 3*j, 1:n) <= 0.0_wp), label//': the damping power is never positive') + END DO + END SUBROUTINE balance + + SUBROUTINE check_cable() + REAL(wp), ALLOCATABLE :: tab(:, :) + REAL(wp) :: pv, trib, s, sabs + INTEGER :: n, j, k + LOGICAL :: ok + CHARACTER(1024) :: msg + CHARACTER(4096) :: chans + CALL write_deck('lpd_cab.dat', '1.0', 'VIVPow1;DragPow1;DampPow1;DampPow1N26', .FALSE., 100.0_wp) + CALL run('lpd_cab.dat', 'lpd_cab', ok, msg) + CALL require(ok, 'P1: the finite-EI deck runs: '//TRIM(msg)) + IF (.NOT. ok) RETURN + CALL read_out('lpd_cab.out', 4, tab, n) + CALL require(n > 1000, 'P1: the run wrote its rows') + IF (n <= 1000) RETURN + CALL balance('P1 finite-EI cable', tab, n, 1, pv) + CALL require(ALL(tab(5, 1:n) <= 0.0_wp), 'P1: the damping power per length is never positive') + ! P2: every node's power per length, times its half elements, sums to the line total + chans = 'VIVPow1' + DO j = 1, NSEG + 1 + chans = TRIM(chans)//';VIVPow1N'//TRIM(int_text(j)) + END DO + CALL write_deck('lpd_nodes.dat', '1.0', TRIM(chans), .FALSE., 52.0_wp) + CALL run('lpd_nodes.dat', 'lpd_nodes', ok, msg) + CALL require(ok, 'P2: the all-node deck runs: '//TRIM(msg)) + IF (.NOT. ok) RETURN + CALL read_out('lpd_nodes.out', NSEG + 2, tab, n) + CALL require(n > 100, 'P2: the run wrote its rows') + IF (n <= 100) RETURN + DO k = 1, n + s = 0.0_wp + sabs = 0.0_wp + DO j = 1, NSEG + 1 + trib = LEN0/REAL(NSEG, wp) + IF (j == 1 .OR. j == NSEG + 1) trib = 0.5_wp*trib + s = s + tab(2 + j, k)*trib + sabs = sabs + ABS(tab(2 + j, k))*trib + END DO + IF (ABS(s - tab(2, k)) > 1.0e-5_wp*MAX(sabs, 1.0e-12_wp)) THEN + CALL require(.FALSE., 'P2: the per-length powers sum to the line total') + EXIT + END IF + END DO + END SUBROUTINE check_cable + + SUBROUTINE check_ei0() + REAL(wp), ALLOCATABLE :: tab(:, :) + REAL(wp) :: pv0, pvf + INTEGER :: n + LOGICAL :: ok + CHARACTER(1024) :: msg + CALL write_deck('lpd_ei0.dat', '0.0', 'VIVPow1;DragPow1;DampPow1', .FALSE., 100.0_wp) + CALL run('lpd_ei0.dat', 'lpd_ei0', ok, msg) + CALL require(ok, 'P3: the EI = 0 deck runs: '//TRIM(msg)) + IF (.NOT. ok) RETURN + CALL read_out('lpd_ei0.out', 3, tab, n) + CALL require(n > 1000, 'P3: the run wrote its rows') + IF (n <= 1000) RETURN + CALL balance('P3 EI = 0 line', tab, n, 1, pv0) + CALL read_out('lpd_cab.out', 4, tab, n) + IF (n <= 1000) RETURN + pvf = SUM(tab(2, 1:n))/REAL(n, wp) + CALL require(ABS(pv0/pvf - 1.0_wp) <= 0.02_wp, 'P3: the EI = 0 line takes the cable''s VIV power within 2 %') + END SUBROUTINE check_ei0 + + SUBROUTINE check_system() + REAL(wp), ALLOCATABLE :: tab(:, :) + REAL(wp) :: pv + INTEGER :: n + LOGICAL :: ok + CHARACTER(1024) :: msg + CALL write_deck('lpd_sys.dat', '0.0', 'VIVPow1;DragPow1;DampPow1;VIVPow2;DragPow2;DampPow2', .TRUE., 100.0_wp) + CALL run('lpd_sys.dat', 'lpd_sys', ok, msg) + CALL require(ok, 'P4: the two-line deck runs: '//TRIM(msg)) + IF (.NOT. ok) RETURN + CALL read_out('lpd_sys.out', 6, tab, n) + CALL require(n > 1000, 'P4: the run wrote its rows') + IF (n <= 1000) RETURN + CALL balance('P4 two EI = 0 lines and a free point', tab, n, 2, pv) + END SUBROUTINE check_system + + SUBROUTINE check_refusals() + CALL refused('VIVPow0', 'bad load power channel', 'line 0') + CALL refused('DragPow7', 'bad load power channel', 'an unknown line') + CALL refused('DampPowx', 'bad load power channel', 'a channel without a line id') + CALL refused('VIVPow1N0', 'node numbers start at 1', 'node 0') + CALL refused('DragPow1N52', 'exceeds line node count', 'a node past End B') + END SUBROUTINE check_refusals + + SUBROUTINE refused(channel, needle, what) + CHARACTER(*), INTENT(IN) :: channel, needle, what + LOGICAL :: ok + CHARACTER(1024) :: msg + CALL write_deck('lpd_bad.dat', '1.0', channel, .FALSE., 1.0_wp) + CALL run('lpd_bad.dat', 'lpd_bad', ok, msg) + CALL require(.NOT. ok .AND. INDEX(msg, needle) > 0, 'P5: '//what//' is refused: '//TRIM(msg)) + END SUBROUTINE refused + + FUNCTION int_text(i) RESULT(s) + INTEGER, INTENT(IN) :: i + CHARACTER(:), ALLOCATABLE :: s + CHARACTER(16) :: b + WRITE (b, '(I0)') i + s = TRIM(b) + END FUNCTION int_text + +END PROGRAM test_load_power_deck diff --git a/tests/test_viv_coupled.f90 b/tests/test_viv_coupled.f90 index 53045117..1514c5fe 100644 --- a/tests/test_viv_coupled.f90 +++ b/tests/test_viv_coupled.f90 @@ -12,6 +12,9 @@ PROGRAM test_viv_coupled !! * lock-in: over 60-120 s the mid-span cross-flow amplitude of both lines is MoorDyn-F's !! A/D 0.662 within 0.03 and the response frequency its 0.293 Hz within 0.01 Hz; with Cl = 0 !! the lines stay still (A/D below 0.01); + !! * load power (the VIVPow, DragPow and DampPow channels of each line): over the lock-in window + !! the VIV loads put power in, the drag takes it out, the damping power is never positive, and + !! their means balance within 1 % of the VIV power; !! * checkpoint restart (the shell's rebuild recipe: a fresh instance takes the coupled !! kinematics, each EI = 0 line's interior [v; q; a] and VIV block and each cable's mirror, !! then the host field): the restarted run continues bit for bit, and a rebuild that skips the @@ -34,7 +37,7 @@ PROGRAM test_viv_coupled CD_AGG_SetFluidFields, CD_AGG_Snapshot, CD_AGG_Restore USE CableDyn_OpenFAST_HermiteFMF, ONLY: CD_HFMF_MirrorSize, CD_HFMF_VIVMirrorSize, CD_HFMF_PackMirror, & CD_HFMF_UnpackMirror, CD_HFMF_OK - USE CableDyn_DeckDriver, ONLY: CD_Deck_VIV_Phase_Seed + USE CableDyn_DeckDriver, ONLY: CD_Deck_VIV_Phase_Seed, CD_Eval_Aggregate_Channel, CD_DECKDRV_OK USE CableDyn_System, ONLY: CD_System_NLines, CD_System_Line_NDOF, CD_Get_System_Line_State, & CD_Update_System_Line_Interior_State, CD_System_Line_VIV_MirrorSize, & CD_Get_System_Line_VIV_State, CD_Set_System_Line_VIV_State, CD_SYSTEM_OK @@ -73,20 +76,44 @@ SUBROUTINE case_lockin() !! 120 s in the host current; the response statistics over 60-120 s. INTEGER, PARAMETER :: NSTEP = 12000, NSKIP = 6000 TYPE(CD_AGG_ModuleType) :: agg - REAL(wp) :: zs(NSTEP - NSKIP, 2), ad(2), f(2) + REAL(wp) :: zs(NSTEP - NSKIP, 2), ad(2), f(2), pw(3, 2), pmax(2) INTEGER :: pass, s, k + CHARACTER(8) :: pname(3) = ['VIVPow ', 'DragPow ', 'DampPow '] CHARACTER(16) :: what(2) = ['EI = 0 riser ', 'finite-EI cable '] DO pass = 1, 2 IF (.NOT. start(agg, MERGE('viv_coupled.dat ', 'viv_coupled_nolift.dat', pass == 1))) RETURN DO s = 1, NSKIP IF (.NOT. advance(agg)) RETURN END DO + pw = 0.0_wp + pmax = -HUGE(1.0_wp) DO s = 1, NSTEP - NSKIP IF (.NOT. advance(agg)) RETURN zs(s, 1) = agg%sys%fast%system%lines(1)%q(3*MID) zs(s, 2) = agg%cables(1)%line%q(6*(MID - 1) + 3) + IF (pass == 2) CYCLE + DO k = 1, 2 + BLOCK + REAL(wp) :: val + INTEGER :: j + DO j = 1, 3 + IF (.NOT. channel(agg, TRIM(pname(j))//MERGE('1', '2', k == 1), val)) RETURN + pw(j, k) = pw(j, k) + val/REAL(NSTEP - NSKIP, wp) + IF (j == 3) pmax(k) = MAX(pmax(k), val) + END DO + END BLOCK + END DO END DO CALL finish(agg) + IF (pass == 1) THEN + DO k = 1, 2 + WRITE (*, '(2A,3F9.4,A,ES10.2)') ' ', what(k), pw(:, k), ' W mean VIV/drag/damping power, balance/VIV ', & + SUM(pw(:, k))/pw(1, k) + CALL check(pw(1, k) > 0.0_wp .AND. pw(2, k) < 0.0_wp, TRIM(what(k))//': VIV power in, drag power out') + CALL check(pmax(k) <= 0.0_wp, TRIM(what(k))//': the damping power is never positive') + CALL check(ABS(SUM(pw(:, k))) <= 0.01_wp*pw(1, k), TRIM(what(k))//': the load powers balance within 1 %') + END DO + END IF DO k = 1, 2 CALL response(zs(:, k), ad(k), f(k)) IF (pass == 1) THEN @@ -101,6 +128,19 @@ SUBROUTINE case_lockin() END DO END SUBROUTINE case_lockin + LOGICAL FUNCTION channel(agg, name, val) RESULT(ok) + !! One deck channel of the aggregate at its committed state (the shells' evaluator). + TYPE(CD_AGG_ModuleType), INTENT(INOUT) :: agg + CHARACTER(*), INTENT(IN) :: name + REAL(wp), INTENT(OUT) :: val + INTEGER :: es + CHARACTER(512) :: em + CALL CD_Eval_Aggregate_Channel(name, agg%has_sys, agg%sys%fast%system, agg%cables, agg%line_is_cable, & + agg%line_obj_index, val, es, em, cable_points=agg%cable_points) + ok = es == CD_DECKDRV_OK + CALL check(ok, name//': '//TRIM(em)) + END FUNCTION channel + SUBROUTINE case_restart() !! Checkpoint after 10 s, while the lock-in builds up; 50 steps on. INTEGER, PARAMETER :: NPRE = 1000, NPOST = 50