Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1284,6 +1284,12 @@ add_executable(test_static_dry_weight tests/test_static_dry_weight.f90)
target_link_libraries(test_static_dry_weight PRIVATE cabledyn_core)
add_test(NAME static_dry_weight COMMAND test_static_dry_weight WORKING_DIRECTORY ${CMAKE_BINARY_DIR})
set_tests_properties(static_dry_weight PROPERTIES LABELS "fortran;integration;static;openfast")
# The tangent channels of a finite-EI line read its tangent DOF: at a clamped end the clamp's
# angles, at a pinned end and every other node the solution's tangent.
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)

add_executable(test_viv_kernels tests/test_viv_kernels.f90)
target_link_libraries(test_viv_kernels PRIVATE cabledyn_core)
Expand Down Expand Up @@ -2816,6 +2822,15 @@ if(Python3_Interpreter_FOUND)
LABELS "python;driver;integration;static;validation"
SKIP_RETURN_CODE 77
ENVIRONMENT "${_cabledyn_python_test_environment}")
# The end tangent outputs of a clamped finite-EI line (channels, static profile, range graph,
# initialisation reports on the finite-EI and mixed routes) are the clamp's angles.
add_test(NAME driver_end_tangent_channels
COMMAND ${Python3_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/tests/check_end_tangent_channels.py
$<TARGET_FILE:cabledyn>)
set_tests_properties(driver_end_tangent_channels PROPERTIES
LABELS "python;driver;integration;static;outputs"
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.
Expand Down
24 changes: 21 additions & 3 deletions doc/outputs.rst
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,8 @@ finite-EI line of the run:
stiffener); written as 0 by the ``EI = 0`` static route
* - ``Declination``
- ``(deg)``
- axial-tangent angle from +Z (0 = up, 90 = horizontal, 180 = down)
- axial-tangent angle from +Z (0 = up, 90 = horizontal, 180 = down); the
:ref:`node tangent <outputs-node-tangent>`
* - ``Inclination``
- ``(deg)``
- signed inclination below horizontal, ``Declination − 90``
Expand Down Expand Up @@ -608,7 +609,8 @@ Line-end channels
availability; for an anchor that holds one line it equals ``Point<P>FH``
- N
* - ``FairIncl<L>`` / ``AnchIncl<L>``
- signed inclination of the End-A / End-B tangent below horizontal
- signed inclination of the End-A / End-B tangent (:ref:`node tangent <outputs-node-tangent>`)
below horizontal
(``Decl − 90``: 0 = horizontal, +90 = pointing down, −90 = pointing up)
- deg
* - ``FairDecl<L>`` / ``AnchDecl<L>``
Expand Down Expand Up @@ -751,7 +753,8 @@ Line-node channels
- node acceleration component (0 on a static run)
- m/s²
* - ``L<L>N<J>Dec``
- declination of the node's axial tangent from +Z (0 = up, 90 = horizontal, 180 = down)
- declination of the node's axial tangent from +Z (0 = up, 90 = horizontal, 180 = down);
the :ref:`node tangent <outputs-node-tangent>`
- deg
* - ``L<L>N<J>Azi``
- azimuth of the node's axial tangent from +X toward +Y, in the line's range
Expand Down Expand Up @@ -944,6 +947,21 @@ The axial tangent of every orientation channel points from End A toward End B (O
``Ez`` axis). Curvature, declination and azimuth are evaluated from the solved geometry on
every route (static, ``EI = 0`` dynamic, finite-EI dynamic, rod and Rigid6 decks).

.. _outputs-node-tangent:

The tangent of a node is the line's own direction there. On a finite-EI line it is the node's
tangent degree of freedom :math:`\mathbf r_{,s}` of the cubic-Hermite centreline, normalised: at
an end clamped by an ``END CONNECTIONS`` ``Rigid`` row it is the direction the connection holds,
at an end on a rotational spring the direction the spring lets the line take, and at every other
node the tangent of the solution, continuous through the node. On an ``EI = 0`` line, whose segments are straight, it is the direction from
the previous to the next node (from the end node to its neighbour at an end). The
``L<L>N<J>Dec``/``Azi`` channels, ``FairDecl``/``AnchDecl``, ``FairIncl``/``AnchIncl`` and
their aliases, the ``Declination``, ``Inclination`` and ``Azimuth`` columns of ``.static.out``,
the ``Declination`` envelope of the range graph and the ``line tangent`` of the initialisation
reports all take it, on every route (the standalone driver, the mixed and multibody routes, the
C API and Python, and OpenFAST). :func:`cabledyn.line_geometry` is a post-processing estimate from
the node positions alone.

Validation of channel names
~~~~~~~~~~~~~~~~~~~~~~~~~~~

Expand Down
2 changes: 1 addition & 1 deletion doc/tutorial_openfast.rst
Original file line number Diff line number Diff line change
Expand Up @@ -339,7 +339,7 @@ seabed. Copy it into the case folder and point a copy of the ``.fst`` at it:
...
Line 4 fairlead effective tension: 11922 N
force [Fx, Fy, Fz]: [1230, 0, -11858] N, inclination=84.078 deg
line tangent: inclination=83.943 deg, declination=173.94 deg, azimuth=0 deg
line tangent: inclination=83.973 deg, declination=173.97 deg, azimuth=0 deg
...
Curv4N38 = 9.01822E-02 (1/m)
BendMom4N38 = 1794.6 (N.m)
Expand Down
69 changes: 69 additions & 0 deletions python/tests/test_end_tangent.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
# SPDX-License-Identifier: Apache-2.0
"""The tangent of a finite-EI line in process: at an end clamped by END CONNECTIONS Rigid the
declination and azimuth the C API returns are the clamp's, and the line values match the
channels (aggregate route)."""

from __future__ import annotations

import math
from pathlib import Path

import pytest

try:
import cabledyn._lib # noqa: F401 (loads the shared library)
except (ImportError, OSError) as exc: # a missing library raises OSError
pytest.skip(f"CableDyn shared library not available: {exc}", allow_module_level=True)

from cabledyn.model import CableDyn

_BAR = "-" * 21


def _deck(path: Path, declination: float, azimuth: float) -> Path:
d, a = math.radians(declination), math.radians(azimuth)
ez = (math.sin(d) * math.cos(a), math.sin(d) * math.sin(a), math.cos(d))
path.write_text(
f"""{_BAR} CableDyn Input File {_BAR}
a cable clamped at End A
{_BAR} LINE TYPES {_BAR}
Name Diam Mass EA BA EI Cdn Cdt Can Cat
cable 0.2 60.0 1.0e8 -1.0 1.0e4 1.2 0.008 1.0 0.0
{_BAR} POINTS {_BAR}
ID Type X Y Z Mass Vol CdA Ca
1 Coupled 0.0 0.0 -10.0 0 0 0 0
2 Fixed 80.0 0.0 -80.0 0 0 0 0
{_BAR} LINES {_BAR}
ID NodeA NodeB Outputs
1 1 2 -
{_BAR} SECTIONS {_BAR}
LineID LineType Length NumSegs
1 cable 125.0 100
{_BAR} END CONNECTIONS {_BAR}
LineID End Stiffness EzX EzY EzZ
1 A Rigid {ez[0]:.17g} {ez[1]:.17g} {ez[2]:.17g}
{_BAR} OPTIONS {_BAR}
9.80665 g
1025.0 rhoW
0.05 dtM
1.0 TMax
{_BAR} OUTPUTS {_BAR}
FairDecl1
{_BAR} need this line {_BAR}
""",
encoding="utf-8",
)
return path


@pytest.mark.parametrize(("declination", "azimuth"), [(165.0, 0.0), (135.0, 20.0)])
def test_the_clamped_end_reads_the_clamp(tmp_path, declination, azimuth):
with CableDyn(_deck(tmp_path / "clamp.dat", declination, azimuth)) as model:
line = model.line(1)
dec, azi = line.declination(), line.azimuth()
assert dec[0] == pytest.approx(declination, abs=1.0e-9)
assert azi[0] == pytest.approx(azimuth, abs=1.0e-9)
assert model.channel("FairDecl1") == pytest.approx(declination, abs=1.0e-9)
# the ends of the line's mesh (refined at the clamp) are its deck end nodes
assert dec[0] == model.channel("L1N1Dec") and azi[0] == model.channel("L1N1Azi")
assert dec[-1] == model.channel("AnchDecl1")
68 changes: 58 additions & 10 deletions src/CableDyn_DeckDriver.f90
Original file line number Diff line number Diff line change
Expand Up @@ -36621,12 +36621,28 @@ END FUNCTION wrap_azimuth_deg

PURE REAL(wp) FUNCTION line_geom_value(kind, deck_node, nnode, q_flat, stride, signed) RESULT(v)
!! Shared evaluator for the GEOMETRIC output channels so every writer computes them
!! identically. `q_flat` holds the line node positions in INTERNAL order
!! (anchor->fairlead) with `stride` reals per node (3 for EI=0, 6 for finite-EI).
!! identically. `q_flat` holds the line node states in INTERNAL order
!! (anchor->fairlead) with `stride` reals per node (3 for EI=0: the position; 6 for
!! finite-EI: the position and the tangent DOF m = dr/ds).
!! kind: 5 curvature, 7 declination, 8 azimuth. Bend moment is NOT geometric -- it is
!! the MATERIAL moment EI*(kappa - kappa_0), computed per path (zero on EI=0 lines;
!! eval_cable_channel and range_sample_cable on finite-EI lines), so it is not handled here and
!! kind = 6 returns 0. signed: the line's azimuth range (DeckLine%azi_signed).
!! kind = 6 returns 0. signed: the line's azimuth range (DeckLine%azi_signed). The
!! declination and azimuth of a finite-EI node are those of its tangent DOF
!! (cable_node_tangent), of an EI = 0 node those of the difference of node positions
!! (deck_node_tangent).
INTEGER, INTENT(IN) :: kind, deck_node, nnode, stride
REAL(wp), INTENT(IN) :: q_flat(:)
LOGICAL, INTENT(IN), OPTIONAL :: signed
IF (stride >= 6 .AND. (kind == 7 .OR. kind == 8)) THEN
v = cable_tangent_angle(kind, cable_node_tangent(q_flat, stride, nnode, deck_node), signed)
ELSE
v = position_geom_value(kind, deck_node, nnode, q_flat, stride, signed)
END IF
END FUNCTION line_geom_value

PURE REAL(wp) FUNCTION position_geom_value(kind, deck_node, nnode, q_flat, stride, signed) RESULT(v)
!! line_geom_value from the node positions alone (line_geom_from_r), q_flat as there.
INTEGER, INTENT(IN) :: kind, deck_node, nnode, stride
REAL(wp), INTENT(IN) :: q_flat(:)
LOGICAL, INTENT(IN), OPTIONAL :: signed
Expand All @@ -36638,21 +36654,56 @@ PURE REAL(wp) FUNCTION line_geom_value(kind, deck_node, nnode, q_flat, stride, s
r(:, j) = q_flat(base + 1:base + 3)
END DO
v = line_geom_from_r(kind, r, nnode, deck_node, signed)
END FUNCTION line_geom_value
END FUNCTION position_geom_value

PURE SUBROUTINE line_geom_values(kind, nnode, stride, q, signed, values)
!! line_geom_value at every deck node of a line. q(:, n) is internal node n's state, its first
!! three entries the position; the deck-ordered positions are read in place, not copied.
!! three entries the position (and on a finite-EI line, stride 6, the next three its tangent
!! DOF); the deck-ordered positions are read in place, not copied.
INTEGER, INTENT(IN) :: kind, nnode, stride
REAL(wp), INTENT(IN) :: q(stride, nnode)
LOGICAL, INTENT(IN) :: signed
REAL(wp), INTENT(OUT) :: values(nnode)
INTEGER :: j
IF (stride >= 6 .AND. (kind == 7 .OR. kind == 8)) THEN
DO j = 1, nnode
! deck node j is internal node nnode + 1 - j, whose tangent runs End B -> End A
values(j) = cable_tangent_angle(kind, -q(4:6, nnode + 1 - j), signed)
END DO
RETURN
END IF
DO j = 1, nnode
values(j) = line_geom_from_r(kind, q(1:3, nnode:1:-1), nnode, j, signed)
END DO
END SUBROUTINE line_geom_values

PURE FUNCTION cable_node_tangent(q_flat, stride, nnode, deck_node) RESULT(t)
!! The axial tangent of a finite-EI line at a deck node, oriented End A -> End B: its tangent
!! DOF m = dr/ds (q_flat in internal order, anchor -> fairlead, stride reals per node, the
!! position then m), reversed, as the internal arc length runs from End B. It is the line's
!! own direction at the node: the direction an END CONNECTIONS row holds at a restrained
!! end, continuous through the node, where a difference of node positions is the direction
!! of a chord.
REAL(wp), INTENT(IN) :: q_flat(:)
INTEGER, INTENT(IN) :: stride, nnode, deck_node
REAL(wp) :: t(3)
INTEGER :: base
base = stride*(nnode - MIN(MAX(deck_node, 1), nnode))
t = -q_flat(base + 4:base + 6)
END FUNCTION cable_node_tangent

PURE REAL(wp) FUNCTION cable_tangent_angle(kind, t, signed) RESULT(v)
!! kind 7: the declination [deg] of the tangent t; 8: its azimuth, in the line's range.
INTEGER, INTENT(IN) :: kind
REAL(wp), INTENT(IN) :: t(3)
LOGICAL, INTENT(IN), OPTIONAL :: signed
IF (kind == 7) THEN
v = tangent_declination_deg(t)
ELSE
v = tangent_azimuth_deg(t, signed)
END IF
END FUNCTION cable_tangent_angle

PURE REAL(wp) FUNCTION line_geom_from_r(kind, r, nnode, deck_node, signed) RESULT(v)
!! Geometric channel value (kind: 5 curvature, 7 declination, 8 azimuth) from the
!! deck-ordered node positions r(3, nnode). Factored out of line_geom_value so a caller
Expand Down Expand Up @@ -37222,13 +37273,10 @@ SUBROUTINE range_sample_cable(cable, rl, ErrStat, ErrMsg)
IF (cable%line%nn /= nn .OR. cable%line%ne /= ne .OR. SIZE(cable%line%q) < 6*nn) THEN
CALL fail_solve(ErrStat, ErrMsg, 'range-graph sample: cable state not available'); RETURN
END IF
DO j = 1, nn
inode = nn + 1 - j
rl%r(:, j) = cable%line%q(6*(inode - 1) + 1:6*(inode - 1) + 3)
END DO
IF (rl%want_range) THEN
! the declination of each node's tangent DOF (cable_node_tangent), as L<L>N<J>Dec
DO j = 1, nn
rl%val(CD_RQ_DECLINATION, j) = line_geom_from_r(7, rl%r, nn, j)
rl%val(CD_RQ_DECLINATION, j) = cable_tangent_angle(7, cable_node_tangent(cable%line%q, 6, nn, j))
END DO
END IF
DO j = 1, nn
Expand Down
Loading
Loading