From 60804bb0f97195ea97e47621615220779914f437 Mon Sep 17 00:00:00 2001 From: Jae Hoon Seo Date: Thu, 15 Oct 2026 16:27:22 +0900 Subject: [PATCH 1/5] feat(outputs): equilibrium tension recovery, continuous TDP, anchor uplift channels Finite-EI node tension, curvature and bend moment are recovered from nodal equilibrium. They had used the element-mean axial force EA(|r'| - 1), which oscillates between elements wherever the line bends over an element and exceeds the tension by EI kappa^2 on any mesh: on the 87-element lazy wave of the IEA-15 mixed example the interior node tension dropped to -173 N against a true 1.2 kN. Each element's end forces, with its own distributed loads, contact and inertia, now give the effective tension (the axial component of the section force, the force that balances the loads), the bend moment and the curvature as that moment over EI. The largest interior tension error against the converged equilibrium falls from 1552 N to 60 N on the example mesh and from 516 N to 0.3 N on a 1 m mesh. Line-end values, positions and the material-strain checks are unchanged. OutputRecovery element restores the previous definitions; the exact geometric curvature stays available as CD_HermiteCable_Dyn_Curvature_Exact and CD_HFMF_Curvature_Exact. The touchdown point is located inside the element by the parabola through the last grounded node and the next two, so it moves continuously instead of in steps of one element: under a surge the largest step between output rows falls from 4.64 m to 0.08 m with 5 m elements. Adds the anchor uplift channels AnchFz and AnchFH (vertical and horizontal components of the AnchTen end force) and TDPGrd (the grounded length) for the drag-anchor check, on every route. Range graphs and .t.out files written every step cost about 4 % more run time, plain channels under 2 %. The T-6 record of VALIDATION.md, which reads the static-profile curvature, moves from 0.056 % to 0.049 %. Signed-off-by: Jae Hoon Seo --- CHANGELOG.md | 62 +++ CMakeLists.txt | 17 + VALIDATION.md | 4 +- doc/conventions.rst | 15 +- doc/driver_format.md | 16 +- doc/openfast.rst | 3 +- doc/options.rst | 15 + doc/outputs.rst | 130 +++-- doc/python.rst | 3 +- doc/python_postprocessing.rst | 8 +- doc/theory.rst | 118 ++++- doc/tutorial_bodies.rst | 11 +- doc/tutorial_dynamics.rst | 8 +- doc/tutorial_lazywave.rst | 2 +- doc/tutorial_motion.rst | 14 +- doc/tutorial_python.rst | 4 +- examples/cabledyn_options_reference.dat | 3 +- python/cabledyn/builder.py | 4 +- python/cabledyn/deck_file.py | 24 +- python/cabledyn/results.py | 2 +- python/cabledyn/touchdown.py | 41 +- python/tests/test_builder.py | 7 +- python/tests/test_deck_file.py | 24 +- python/tests/test_deck_native_parity.py | 16 +- python/tests/test_objects.py | 20 +- python/tests/test_results.py | 4 + python/tests/test_touchdown.py | 14 +- src/CableDyn_DeckDriver.f90 | 348 ++++++++++--- src/CableDyn_HermiteCableDynamic.f90 | 463 +++++++++++++++++- src/CableDyn_HermiteCableStatic.f90 | 5 +- src/CableDyn_OpenFAST_HermiteFMF.f90 | 26 +- src/CableDyn_RangeOutput.f90 | 91 +++- tests/test_anchor_uplift.py | 486 +++++++++++++++++++ tests/test_cable_statics_matrix.py | 23 +- tests/test_deck_driver.f90 | 10 + tests/test_flagship_compression_note.f90 | 49 +- tests/test_l3_lazywave_3d_dynamic.f90 | 4 +- tests/test_l3_lazywave_dynamic.f90 | 6 +- tests/test_l3_lazywave_irregular.f90 | 4 +- tests/test_l3_lazywave_touchdown_dynamic.f90 | 4 +- tests/test_l4_lazywave_coupled.f90 | 4 +- tests/test_lazywave_dynamics.f90 | 7 +- tests/test_openfast_aggregate.f90 | 118 ++++- tests/test_range_tdp.py | 28 ++ 44 files changed, 2034 insertions(+), 231 deletions(-) create mode 100644 tests/test_anchor_uplift.py diff --git a/CHANGELOG.md b/CHANGELOG.md index d476efcb..e17f4de8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -106,9 +106,71 @@ All notable changes to CableDyn are recorded in this file. The format follows snap peaks are not resolved in time. The standalone driver also prints a note for a dynamic deck with `rhoInf` above 0.95, on the missing numerical dissipation. See the manual's troubleshooting page. +- Anchor uplift channels for the drag-anchor check of a catenary mooring (no vertical load at + the anchor in the intact condition). `AnchFz` and `AnchFH` are the vertical component + (positive upward, the line lifting its anchor) and the horizontal magnitude of the `AnchTen` + end force; for an anchor that holds one line they equal `Point

Fz` and `Point

FH`. + `TDPGrd` is the grounded length, the deformed chord length from the grounded end to the + touchdown point, and is 0 while no node beyond the grounded end node rests on the seabed. The + channels are available on the static, `EI = 0`, finite-EI, mixed and multibody routes, in the C + API and in coupled OpenFAST and FAST.Farm runs; the two-moving-end finite-EI route rejects + `AnchFz`/`AnchFH` by name. The Python deck reader and builder accept the new names. See the + manual's outputs page (Anchor uplift), which also states the end-node weight share that a laid + `Fixed` anchor carries (`AnchFz` slightly negative, not uplift). +- `OutputRecovery` option (`equilibrium`, the default, or `element`): the definition of the + finite-EI node tension, curvature, bend moment and segment tension (see Changed). `element` + restores the definitions of 0.1.1. The Python deck reader accepts and checks it. +- `CD_HermiteCable_Dyn_Curvature_Exact` and `CD_HFMF_Curvature_Exact`: the exact geometric + nodal curvature of the cubic-Hermite centreline, the larger one-sided trace at a node, which + `CD_HermiteCable_Dyn_Curvature` and `CD_HFMF_Curvature` returned up to 0.1.1. ### Changed +- Finite-EI node tension, curvature and bend moment are recovered from nodal equilibrium. The + `TenN`, `CurvN` and `BendMomN` channels, the `Tension`, `Curvature` and + `BendMoment` columns of the static profile and the range graph, and the `.t.out` segment + tensions of a finite-EI line had used the element-mean axial force `EA(|r'| - 1)` and the + exact one-sided curvature of the element interpolation. With a stiff `EA` that axial force + oscillates between elements wherever the line bends over an element (the nodal seabed + reaction near touchdown, a section junction), and it exceeds the tension by `EI kappa^2` on + any mesh. The outputs now come from the element end forces, each element with its own + distributed loads and inertia: the effective tension is the axial component of the section + force, the bend moment the moment the neighbouring elements carry, and the curvature that + moment over `EI`. The derivation is in the manual's theory page (Node tension, curvature and + bend moment). On the lazy-wave cable of `examples/iea15mw_umaine_mixed_cabledyn.dat` (87 + elements) the static interior node tension now stays between 1217 N and the 11.9 kN fairlead + tension instead of dropping to -173 N. Against the equilibrium of the converged line, the + largest error falls from 1552 N to 60 N at the example's mesh, from 2059 N to 12 N, 1921 N to + 1 N and 516 N to 0.3 N at twice, four times and ten times the mesh density, and from 164 N to + 1 N at 0.25 m elements. The largest curvature error falls from 64 % to 30 %, 44 % to 7 %, 19 + % to 4 % and 2.1 % to 0.8 % of the peak. Under an 8 m surge and 2 m heave of the hang-off, + the error of the maximum-tension envelope against a 1 m mesh falls from 2164 N to 857 N, 1488 + N to 283 N and 3049 N to 31 N, and the minimum tension of the run from -719 N to +610 N at + the example's mesh. A `.t.out` segment tension is now the mean of the axial components of the + element's two end forces instead of the axial resultant at its midpoint. The library + curvature (`CD_HermiteCable_Dyn_Curvature`, `CD_HFMF_Curvature`) follows the same definition + as the channels. Line-end values (`FairTen`, `AnchTen`, the end-node tension), positions and + the material-strain checks (`tensile_safety`, the static compression notes) are unchanged. On + a line restrained in torsion the condensed torque is left out of the recovery; it moves the + tension by at most 0.45 N of 9.4 kN on `examples/torsion_lazy_wave_hangoff_twist.dat`. Range + graphs and `.t.out` files written every step cost 4 % more run time, plain channels under 2 + %. `OutputRecovery element` restores the previous definitions. The T-6 record of + `VALIDATION.md` (twisted lazy wave against OrcaFlex), which reads the static-profile + curvature, moves from 0.056 % to 0.049 %; the other records use end tensions or the exact + geometric curvature (`CD_HermiteCable_Dyn_Curvature_Exact`) and are unchanged. +- The touchdown point (`TDP` channels and `cabledyn.touchdown_history`) is located inside + the element by the parabola through the last grounded node and the next two nodes instead of + the linear clearance between the last grounded node and the next. On a stiff seabed the + linear interpolation held the TDP on the last grounded node until the next one grounded, so + the TDP moved in steps of one element and, under a small motion, jumped by an element and + back. The parabola reaches a node exactly when the node grounds or lifts off, so the TDP moves + continuously. On a 450 m finite-EI cable under a 10 m fairlead surge, the largest step between + output rows falls from 4.64 m to 0.08 m with 5 m elements and from 1.98 m to 0.08 m with + 2.5 m elements, and the largest error against a 1 m mesh from 2.96 m to 1.92 m and from + 1.39 m to 1.18 m; under a 0.5 m surge the quasi-static TDP excursion with 1 m elements is + 0.63 m against 0.64 m converged, where the linear interpolation gave 0.23 m. On the + `EI = 0` chain of `examples/chain_range_tdp.dat` the largest step falls from 2.59 m to 1.33 m. + The TDP now lies on the contact-onset height, and `TDPGrd` uses the same location. - Faster wave kinematics of directional and multi-train seas (`wavetrain` rows, spectral `waves` rows, `WaveSpreading`). Each component's phase cosine is now computed once for the surface elevation and the kinematics, and its depth profile with one exponential instead of diff --git a/CMakeLists.txt b/CMakeLists.txt index a6dbf325..168852c0 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1470,6 +1470,23 @@ if(Python3_Interpreter_FOUND) message(STATUS "range_graph_tdp: skipped (numpy not importable in ${Python3_EXECUTABLE})") endif() + # Anchor uplift channels (AnchFz/AnchFH, TDPGrd): the analytic laid and suspended elastic + # catenaries, the Point

F identity on every standalone route, and a surge that lifts the + # anchor of a catenary (needs numpy). + if(_range_tdp_numpy_rc EQUAL 0) + add_test(NAME anchor_uplift_channels + COMMAND ${Python3_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/tests/test_anchor_uplift.py + --exe $ + --examples ${CMAKE_CURRENT_SOURCE_DIR}/examples + --output ${CMAKE_BINARY_DIR}/anchor_uplift_channels) + set_tests_properties(anchor_uplift_channels PROPERTIES + LABELS "python;integration;static;dynamic;validation" + TIMEOUT 600 + ENVIRONMENT "${_cabledyn_python_test_environment}") + else() + message(STATUS "anchor_uplift_channels: skipped (numpy not importable in ${Python3_EXECUTABLE})") + endif() + # The arbiter imports numpy + scipy at load time; only register the test when they are # importable, so an image with python3 but without those packages does not fail the # validation suite with ModuleNotFoundError before any CableDyn gate runs. diff --git a/VALIDATION.md b/VALIDATION.md index cd0fe35a..9c47f3ad 100644 --- a/VALIDATION.md +++ b/VALIDATION.md @@ -93,7 +93,7 @@ article's methods, are compared in | **T-3** | Greenhill onset, clamped, `TL²/EI` −20 to 1600 | van der Heijden et al. (2003) eq. 33 | ≤3.9e-5 (32 elements); ≤6.5e-6 (128) | <1e-4; <1e-3 | Pass | | **T-4** | Onset, bending-pinned torsional (semi-tangential) end | `tan x = −x/3` | 6.4e-7 / 4.5e-7 | <1e-4 | Pass | | **T-5** | Onsets against OrcaFlex 11.6d (clamped and pinned) | OrcaFlex, extrapolated to zero segment length | ≤3.0e-5 | <2e-4 | Pass | -| **T-6** | Lazy-wave cable twisted 0–5 turns at the hang-off | OrcaFlex 11.6d | torque ≤0.019%, peak curvature ≤0.056%, offset ≤27 mm, tension ≤0.091% | 1% / 1% / 0.1 m / 0.5% | Pass | +| **T-6** | Lazy-wave cable twisted 0–5 turns at the hang-off | OrcaFlex 11.6d | torque ≤0.019%, peak curvature ≤0.049%, offset ≤27 mm, tension ≤0.091% | 1% / 1% / 0.1 m / 0.5% | Pass | | **T-7** | Kirchhoff helix, four turns | helical equilibrium | end force 1.5e-4, end moment 6.5e-5 | <5e-3 | Pass | | **T-8** | Cross-check with the Cosserat rod path | Cosserat path | shape 4.2e-4 L, torque 5.2e-5 | <1% | Pass | | **T-9** | Bordered Newton step on post-buckled states | predicted linear rate without the rank-one term | 3 iterations; rate 0.055 / 0.217 vs 0.055 / 0.218 | ≤4; within 25% | Pass | @@ -864,7 +864,7 @@ in parentheses). orientation and twisted 1 to 5 turns at the hang-off. Against OrcaFlex at 0.375 m segments, the hang-off torque agrees to ≤0.019%, the geometric twist `Θ` to ≤1.8e-4 turn per imposed turn (`Θ` = 0.188 turn at 5 turns, so the torque is 3.8% below `GJ Φ/L`), the peak interior - curvature to ≤0.056% (0.1197 against 0.1196 1/m at 5 turns), the out-of-plane offset to ≤27 mm + curvature to ≤0.049% (0.1197 against 0.1196 1/m at 5 turns), the out-of-plane offset to ≤27 mm of 6.8 m and the hang-off tension to ≤0.091%. The torque is uniform along the line. At zero twist the restrained deck reproduces the same cable without torsion columns (positions identical, tensions to 1.1e-8), the zero-twist parity case. diff --git a/doc/conventions.rst b/doc/conventions.rst index 7de88530..5b5b8b80 100644 --- a/doc/conventions.rst +++ b/doc/conventions.rst @@ -137,12 +137,15 @@ Tension definitions - CableDyn models lines as solid members with no internal contents, and applies buoyancy as a distributed load (the Archimedes resultant of the pressure field), not as a pressure term in the tension. Under this convention the **reported tension is the effective tension**, - :math:`T_e = EA\,\varepsilon` plus any axial damping or constitutive-state contribution. This - is the quantity in the interior node tension channels, and the quantity compared with - OrcaFlex effective tension in :doc:`validation`. Node tensions are segment tensions: the mean - of the two neighbouring element tensions (on a finite-EI line, the element-mean axial forces - weighted by element length), like OrcaFlex mid-segment tension. The continuous element field - is reported separately in ``.elements.out``. ``FairTen``, ``AnchTen``, and the end-node + :math:`T_e = EA\,\varepsilon` plus any axial damping or constitutive-state contribution on an + ``EI = 0`` line, and the axial component :math:`\mathbf{F}\cdot\mathbf{t}` of the section + force recovered from nodal equilibrium on a finite-EI line, which differs from + :math:`EA\,\varepsilon` by :math:`EI\kappa^2` (:ref:`theory-output-recovery`). This is the + quantity in the interior node tension channels, and the quantity compared with OrcaFlex + effective tension in :doc:`validation`. On an ``EI = 0`` line node tensions are segment + tensions, the mean of the two neighbouring element tensions, like OrcaFlex mid-segment tension. + The continuous element field :math:`EA\,\varepsilon` of a finite-EI line is reported + separately in ``.elements.out``. ``FairTen``, ``AnchTen``, and the end-node tension channels report the line-end force instead: the actual force on the attachment, the end element force (axial damping included) plus the end node's share of weight, seabed contact, and drag at the actual velocity, without the end node's inertia (:doc:`outputs`). diff --git a/doc/driver_format.md b/doc/driver_format.md index 944eb78f..b7466bdd 100644 --- a/doc/driver_format.md +++ b/doc/driver_format.md @@ -1006,6 +1006,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` | +| `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` | | `tensile_strain_tolerance` | non-negative strain band for the dynamic tensile audit | `2e-6` | @@ -1227,6 +1228,8 @@ bending moment. None of these channels is mandatory. |---------|---------|------| | `FairTen` | line L fairlead (End A) line-end tension: the magnitude of the force the line actually exerts on its End-A point (end element force with axial damping, including the bending shear of a finite-EI line, plus the end node's share of the submerged weight, seabed contact and drag at the actual velocity; without the end node's inertia), the static end reaction at rest. Route differences (seabed friction, the two-moving-end route) are in [Outputs](outputs.rst) | N | | `AnchTen` | line L anchor (End B) line-end tension, as `FairTen` | N | +| `AnchFz` | line L vertical component of the `AnchTen` end force, positive upward (the line lifts its End-B point). Not available on the two-moving-end finite-EI route, which rejects it by name | N | +| `AnchFH` | line L horizontal magnitude of the `AnchTen` end force (same availability as `AnchFz`) | N | | `FairIncl` | line L fairlead (End A) signed inclination below horizontal (0 = horizontal; positive = downward) | deg | | `AnchIncl` | line L anchor (End B) signed inclination below horizontal (0 = horizontal; positive = downward) | deg | | `FairDecl` | line L fairlead (End A) declination from +GZ (0 = up, 90 = horizontal, 180 = down) | deg | @@ -1236,18 +1239,19 @@ bending moment. None of these channels is mandatory. | `Con

p{x,y,z}` | alias of `Point

p{x,y,z}` (MoorDyn v1 spelling) | m | | `Body…`, `Rod…` | Rigid6 body and rod channels in the MoorDyn-F names: position, attitude, velocity and acceleration (`P`, `R`, `V`, `RV`, `A`, `RA`), net force and moment (`F`, `M`), rod end tensions (`TenA`, `TenB`), submerged fraction (`Sub`) and rod node positions (`RodNP`). Available on every route that carries bodies or rods, OpenFAST included; the full list and units are in [Outputs](outputs.rst) | see Outputs | | `Point

F{x,y,z}`, `Point

FH` | resultant of the line-end and cable end forces on point P (each the `FairTen`/`AnchTen` end force): the anchor load of a Fixed point shared by several lines, the line load a free point balances; `FH` is its horizontal magnitude. Available on every route (static, `EI = 0`, finite-EI, multibody and OpenFAST) except the two-moving-end finite-EI route, which rejects it by name | N | -| `TenN` | line L tension at node J (interior nodes average the adjacent elements; end nodes report the line-end force of `FairTen`/`AnchTen`) | N | -| `CurvN` | line L geometric curvature at node J. `EI = 0` lines: circle through the node and its two neighbours (end nodes take the adjacent interior value). Cubic-Hermite lines: exact curvature of the continuous centreline, the larger one-sided element value at an interior node | 1/m | -| `BendMomN` | line L bend moment = EI × curvature **relative to the stress-free reference shape** (≈ 0 at the reference; equals EI × geometric curvature because the finite-EI reference is straight; 0 on EI = 0 lines) | N·m | +| `TenN` | line L effective tension at node J. EI = 0 lines: the mean of the two adjacent segment tensions. Finite-EI lines: the axial component of the section force recovered from nodal equilibrium (`OutputRecovery element`: the length-weighted mean of the adjacent element-mean axial forces). End nodes report the line-end force of `FairTen`/`AnchTen` | N | +| `CurvN` | line L curvature at node J. `EI = 0` lines: geometric curvature of the circle through the node and its two neighbours (end nodes take the adjacent interior value). Cubic-Hermite lines: `BendMomN` / EI, the larger of the two sides at a section junction (`OutputRecovery element`: exact curvature of the continuous centreline, the larger one-sided element value at an interior node) | 1/m | +| `BendMomN` | line L bend moment = EI × curvature **relative to the stress-free reference shape** (≈ 0 at the reference; the finite-EI reference is straight). Finite-EI lines: recovered from nodal equilibrium, the moment the neighbouring elements carry (`OutputRecovery element`: EI × the larger one-sided exact curvature); 0 on EI = 0 lines | N·m | | `LNp{x,y,z}` | line L node J position component | m | | `LNv{x,y,z}` | line L node J velocity component (0 in static-only runs) | m/s | | `LNa{x,y,z}` | line L node J acceleration component (0 in static-only runs) | m/s² | | `LNDec` | line L declination of the axial tangent at node J (from +GZ; 0 = up, 90 = horizontal, 180 = down) | deg | | `LNAzi` | line L azimuth of the axial tangent at node J (from +GX toward +GY, in [0, 360)) | deg | -| `TDPs` | line L touchdown point (TDP): arc length from End A, interpolated between the last grounded node and the next where the centreline crosses the contact-onset height (1e-6 m above the seabed) | m | +| `TDPs` | line L touchdown point (TDP): arc length from End A, between the last grounded node and the next, where the parabola through the last grounded node and the next two nodes crosses the contact-onset height (1e-6 m above the seabed); continuous as nodes ground and lift off ([Outputs](outputs.rst)) | m | | `TDPx`, `TDPy`, `TDPz` | line L TDP position | m | | `TDPLay` | line L layback: horizontal distance from the TDP to the suspended end | m | | `TDPExc` | line L TDP excursion: horizontal TDP displacement from its initial position, along the initial direction toward the suspended end | m | +| `TDPGrd` | line L grounded length: deformed chord length along the nodes from the grounded end to the TDP; 0 once the grounded end has lifted off | m | | `TorqN` | line L torque at node J (uniform along the line); positive for a right-handed twist of End B relative to End A about the End A → End B tangent. Only on a line restrained in torsion at both ends | N·m | | `TwistN` | line L material twist accumulated from End A to node J, `M × Σ L/GJ` over the elements in between; 0 at End A, without the end-spring windup. Only on a line restrained in torsion at both ends | deg | | `Twist` | line L total twist `Phi − Theta = M C`, end-spring windup included. Only on a line restrained in torsion at both ends | deg | @@ -1265,6 +1269,10 @@ bending moment. None of these channels is mandatory. - `TDP` channels need a seabed (`WtrDpth` or `bathymetryFile`) and a line that rests on the seabed at exactly one end in its initial state; otherwise the run stops with exit code 1 naming the line. They are available on every route, OpenFAST included. +- The anchor uplift check of a drag-embedment anchor (no vertical load at the anchor in the + intact condition) reads `AnchFz` (its maximum over the run at most 0) or `TDPGrd` + (greater than 0 throughout); see [Outputs](outputs.rst) for the end-node weight share that a + grounded `Fixed` anchor carries. - In an OpenFAST `CompMooring = 5` run, channel headers in the OpenFAST output and in `.CD.out` use OpenFAST's 20-character width (`ChanLen`). A longer channel name stops coupled initialisation with an error naming the channel; keep coupled channel names diff --git a/doc/openfast.rst b/doc/openfast.rst index 2d7b6870..c8cfbe3b 100644 --- a/doc/openfast.rst +++ b/doc/openfast.rst @@ -140,7 +140,8 @@ closed by ``END`` — not in the ``.fst`` ``OutList``: END The channel vocabulary (tensions, end angles, node tension, curvature, bend moment, position, -velocity, acceleration, declination, azimuth) and units are in :doc:`outputs`. +velocity, acceleration, declination, azimuth, the touchdown point, and the anchor uplift +channels ``AnchFz``, ``AnchFH`` and ``TDPGrd``) and units are in :doc:`outputs`. .. list-table:: :header-rows: 1 diff --git a/doc/options.rst b/doc/options.rst index 6129c06d..27253d99 100644 --- a/doc/options.rst +++ b/doc/options.rst @@ -410,6 +410,21 @@ Finite-EI cable controls tolerance (see :doc:`theory`) - both (finite-EI lines) - ``sequenced cable_statics`` + * - ``OutputRecovery`` / ``output_recovery`` + - mode + - ``equilibrium`` + - definition of the finite-EI node outputs (``Ten``, ``Curv``, ``BendMom`` channels, the + static-profile and range-graph columns, ``.t.out`` segment tensions). + ``equilibrium`` recovers them from nodal equilibrium: the effective tension + :math:`\mathbf F\cdot\mathbf t`, the moment the neighbouring elements carry, and + curvature = moment / ``EI`` (see :ref:`theory-output-recovery`). ``element`` reports the + length-weighted element-mean axial force :math:`EA(\lvert\mathbf r'\rvert - 1)`, the + larger one-sided exact curvature, and the axial resultant at the element midpoint as the + segment tension, the definitions up to CableDyn 0.1.1. End forces, positions, ``TDP`` + channels and the material-strain checks (``tensile_safety``, compression notes) are the + same under both + - both (finite-EI lines) + - ``element OutputRecovery`` * - ``axial_quadrature_order`` / ``axialquadratureorder`` / ``axial_quadrature`` - integer, – - ``4`` diff --git a/doc/outputs.rst b/doc/outputs.rst index f4e411a5..dad67b54 100644 --- a/doc/outputs.rst +++ b/doc/outputs.rst @@ -236,15 +236,19 @@ Plot ``Curvature`` or ``Tension`` against ``ArcLength`` for a fatigue or strengt .. note:: - Node tensions are segment tensions; ``.elements.out`` holds pointwise field values. On a - finite-EI line the ``Tension`` column and ``TenN`` report, at an interior node, the - length-weighted average of the element-mean axial forces of the two neighbouring elements - (the tension that enters equilibrium, as the segment tension of an ``EI = 0`` line). The - ``MinimumAxialResultant`` and ``MaximumAxialResultant`` columns of ``.elements.out`` are - extrema of the pointwise field :math:`EA\,(|\mathbf r'| - 1)`. With a stiff ``EA`` that - field oscillates about the element mean wherever an element cannot follow the line -- at a - nodal seabed-contact kink near touchdown and at a section junction -- and can dip below - zero there while the line is tensile. Curvature and bend moment are pointwise in both files. + On a finite-EI line the ``Tension``, ``Curvature`` and ``BendMoment`` columns and the + ``Ten``/``Curv``/``BendMom`` channels are recovered from nodal equilibrium + (:ref:`theory-output-recovery`): the effective tension :math:`\mathbf F\cdot\mathbf t` + is the axial component of the section force that balances the loads, and the bend moment + is the moment the elements on either side of the node carry. ``.elements.out`` holds the + pointwise element fields instead: the ``MinimumAxialResultant`` and + ``MaximumAxialResultant`` columns are extrema of the material axial force + :math:`EA\,(|\mathbf r'| - 1)`, which exceeds the effective tension by + :math:`EI\kappa^2` and, with a stiff ``EA``, oscillates about the element mean wherever an + element cannot follow the line -- at a nodal seabed-contact kink near touchdown and at a + section junction -- and can dip below zero there while the line is tensile. ``OPTIONS`` + ``OutputRecovery element`` reports the element definitions in the node columns and channels + (:doc:`options`). ``.elements.out`` — Hermite element extrema ----------------------------------------------------- @@ -322,7 +326,9 @@ channels instead) and accept ``r``. - node positions, End A → End B * - ``t`` - ``.Line.t.out`` - - segment (element) tensions, End A → End B + - segment (element) tensions, End A → End B; on a finite-EI line the mean of the axial + components of the element's own two equilibrium end forces (``OutputRecovery element``: + the axial resultant at the element midpoint) * - ``r`` - ``.Line.range.out`` - range graph: minimum, maximum and mean over the run of the node tension, curvature, bend @@ -493,8 +499,18 @@ Line-end channels - line-end tension at End B (anchor) of line ``L``, defined as for ``FairTen``. On a grounded run it is close to the horizontal tension. A ``Fixed`` anchor at the seabed depth sits slightly above the grounded chain, which sinks into the penalty seabed, so the - anchor also carries part of its end node's weight (for example 192.4 kN against a - horizontal tension of 191.5 kN in :doc:`tutorial_catenary`) + anchor also carries its end node's weight (for example 192.4 kN against a horizontal + tension of 191.5 kN in :doc:`tutorial_catenary`; see `Anchor uplift`_) + - N + * - ``AnchFz`` + - vertical component of the ``AnchTen`` end force, the force line ``L`` exerts on its + End-B point: positive upward (the line lifts the anchor), negative downward. On every + route that reports ``AnchTen`` except the two-moving-end finite-EI route, which rejects it + by name; for an anchor that holds one line it equals ``Point

Fz`` + - N + * - ``AnchFH`` + - horizontal magnitude of the same end force, :math:`\sqrt{F_x^2 + F_y^2}`, with the same + availability; for an anchor that holds one line it equals ``Point

FH`` - N * - ``FairIncl`` / ``AnchIncl`` - signed inclination of the End-A / End-B tangent below horizontal @@ -510,6 +526,40 @@ Line-end channels A grounded anchor segment reads ``AnchIncl ≈ 0``; the small non-zero value reports the actual orientation of the last element, which CableDyn does not force to horizontal. +Anchor uplift +~~~~~~~~~~~~~ + +A drag-embedment anchor is designed for a horizontal pull and loses holding capacity under a +vertical one, so design practice for catenary moorings (DNV-OS-E301, API RP 2SK) requires no +vertical uplift at the anchor in the intact condition: some chain stays laid on the seabed. Two +channels give the check for line ``L`` directly: + +* the maximum of ``AnchFz`` over the run is at most 0; +* the minimum of ``TDPGrd`` (`Touchdown channels`_) over the run is greater than 0. + +The two agree: while chain is laid at the anchor the line pulls it horizontally, and once the +grounded length reaches 0 the line lifts its anchor and ``AnchFz`` turns positive. + +On a laid ``EI = 0`` line ``AnchFz`` is a small negative value, not 0. The anchor node of a +``Fixed`` point at the seabed depth is held at the seabed elevation, while the penalty seabed +lets the grounded line sink by :math:`\delta = w/(k_\text{Bot}\,d)` (:math:`w` the submerged +weight per unit length, :math:`d` the line diameter, see :doc:`conventions`). The anchor +therefore carries the end node's lumped submerged weight, :math:`w\,\Delta L/2` for an anchor +segment of unstretched length :math:`\Delta L`, and the downward pull of the anchor segment +toward the sunk line, about :math:`H\delta/\Delta L` for a horizontal tension :math:`H`: + +.. math:: + + \mathtt{AnchFz} \approx -\left(\frac{w\,\Delta L}{2} + \frac{H\,\delta}{\Delta L}\right). + +In :doc:`tutorial_catenary` (:math:`w` = 3.18 kN/m, :math:`\Delta L` = 10 m, +:math:`\delta` = 0.13 m) this estimate is −18.4 kN, and the run reports ``AnchFz1`` = −18.2 kN +beside ``AnchFH1`` = 191.5 kN (the horizontal tension) and ``AnchTen1`` = 192.4 kN. The share +belongs to the lumped anchor node: it scales with the anchor segment length, vanishes as the mesh +is refined, and is not uplift. A finite-EI (cubic-Hermite) end resting on the seabed leaves its +end node's weight to the floor and reads ``AnchFz`` = 0 there. Check the sign of ``AnchFz``, not +the difference between ``AnchTen`` and ``AnchFH``. + Line-node channels ~~~~~~~~~~~~~~~~~~ @@ -521,9 +571,13 @@ Line-node channels - Meaning - Unit * - ``TenN`` - - effective tension at node ``J``: an interior node takes the mean of its two neighbouring - element (segment) tensions -- on a finite-EI line their element-mean axial forces, - weighted by element length; an end node reports the line-end force of ``FairTen`` / + - effective tension at node ``J``. ``EI = 0`` lines: an interior node takes the mean of + its two neighbouring element (segment) tensions. Finite-EI lines: the axial component + :math:`\mathbf F\cdot\mathbf t` of the section force recovered from nodal equilibrium, + the mean of the end forces of the two neighbouring elements, each with its own + distributed loads and inertia (:ref:`theory-output-recovery`); ``OutputRecovery + element``: the length-weighted mean of the element-mean axial forces + :math:`EA(|\mathbf r'| - 1)`. An end node reports the line-end force of ``FairTen`` / ``AnchTen``. On the two-moving-end finite-EI route every value is the chord-stretch tension of ``FairTen`` there: the adjacent element at an end node and the unweighted mean of the two neighbouring elements at an interior node @@ -531,13 +585,20 @@ Line-node channels * - ``CurvN`` - curvature at node ``J``. ``EI = 0`` lines: discrete curvature of the circle through the node and its two neighbours (end nodes take the adjacent interior value). - Cubic-Hermite lines: exact curvature of the continuous centreline, taking the larger of - the two one-sided element values at an interior node + Cubic-Hermite lines: ``BendMomN`` / ``EI``, the larger of the two sides at a + section junction (``OutputRecovery element``: exact curvature of the continuous + centreline, the larger of the two one-sided element values at an interior node). The + library routines ``CD_HermiteCable_Dyn_Curvature`` and ``CD_HFMF_Curvature`` return the + same value; ``CD_HermiteCable_Dyn_Curvature_Exact`` and ``CD_HFMF_Curvature_Exact`` the + exact geometric traces - 1/m * - ``BendMomN`` - - bend moment ``EI × κ`` measured relative to the stress-free reference shape. The - cubic-Hermite reference is straight, so there it equals ``EI × CurvN`` - (larger one-sided value at an interior node); 0 on ``EI = 0`` lines + - bend moment ``EI × κ`` measured relative to the stress-free reference shape (the + cubic-Hermite reference is straight). Finite-EI lines: the component normal to the tangent + of the moment recovered from nodal equilibrium, the mean of the two neighbouring elements + (one-sided at a line end, where it is the end connection moment); + ``OutputRecovery element``: ``EI`` times the larger one-sided exact curvature. 0 on + ``EI = 0`` lines - N·m * - ``LNpx`` / ``py`` / ``pz`` - node position component @@ -578,9 +639,16 @@ Touchdown channels For a line that rests on the seabed at one end, the touchdown point (TDP) at every output time. A node is grounded when its centreline is at most 1e-6 m (the height at which the seabed contact law engages) above the seabed; the grounded end is the end grounded in the initial state. Walking -from that end, the TDP lies between the last grounded node and the next one, where the centreline -crosses that height (linear interpolation of the clearance). The definitions are those of -:func:`cabledyn.touchdown_history` with ``tolerance = 1e-6``. +from that end, the TDP lies between the last grounded node and the next one, where the parabola +through the last grounded node and the next two nodes (clearance against chord arc) crosses that +height, the crossing nearest the suspended node; the TDP sits on that height. With fewer than two +suspended nodes, or no crossing inside the element, the clearance is interpolated linearly. The +crossing reaches a node exactly when the node reaches the onset height, so the TDP moves +continuously as nodes ground and lift off, and between nodes it follows the lift-off of the line +instead of resting on the last grounded node until the next one grounds: on a 450 m cable with +5 m elements in a 10 m surge the largest step between output rows falls from 4.6 m (a whole +element) to 0.08 m, and the error against a 1 m mesh from 3.0 m to 1.9 m. The definitions are +those of :func:`cabledyn.touchdown_history` with ``tolerance = 1e-6``. .. list-table:: :header-rows: 1 @@ -603,12 +671,20 @@ crosses that height (linear interpolation of the clearance). The definitions are projected on the initial horizontal direction from the TDP to the suspended end (positive toward the suspended end) - m + * - ``TDPGrd`` + - grounded length: deformed chord length along the nodes from the grounded end to the TDP + (``TDPs`` measured from the grounded end instead of End A). 0 while no node beyond + the grounded end node is grounded: an anchor held at the seabed elevation counts as + grounded, but with its neighbour off the seabed no line lies there, so a taut or fully + suspended line reads 0. The whole line length when every node is grounded + - m The channels are available on every route, OpenFAST included, when the deck has a seabed (``WtrDpth`` or ``bathymetryFile``). A line whose initial state is grounded at both ends or at neither stops the run with exit code 1 naming the line. When the grounded end later lifts off, -the channels report that end node; when the whole line rests on the seabed, the suspended end -node. +the channels report that end node (and ``TDPGrd`` reads 0); when the whole line rests on the +seabed, the suspended end node. ``TDPGrd`` is the grounded length of the `Anchor uplift`_ +check. Point channels ~~~~~~~~~~~~~~ @@ -708,8 +784,8 @@ with exit code 1. A name is rejected when: * it matches none of the forms above, or carries trailing text (``Point2px_raw``, ``Point2pzz``, ``FairTen1x``); * it references an unknown line or point id, or a node number larger than the line's node - count, or is a ``TDP`` name with a suffix other than ``s``, ``x``, ``y``, ``z``, ``Lay`` or - ``Exc``; + count, or is a ``TDP`` name with a suffix other than ``s``, ``x``, ``y``, ``z``, ``Lay``, + ``Exc`` or ``Grd``; * it is a ``TorqN``, ``TwistN`` or ``Twist`` channel of a line that is not restrained in torsion at both ends (``... carries no torque``); * on a mixed ``EI = 0`` + finite-EI deck (and in OpenFAST), it is a ``Point

`` channel of a diff --git a/doc/python.rst b/doc/python.rst index c6def699..276ce877 100644 --- a/doc/python.rst +++ b/doc/python.rst @@ -832,7 +832,8 @@ state at the time of the call through the same evaluator as the deck ``OUTPUTS`` length and the end tensions; ``Point`` its position, velocity and the resultant line force; ``Body`` its pose, velocity, acceleration and net wrench about the reference point; ``Rod`` its node positions, End A pose, velocity and wrench. :meth:`~cabledyn.CableDyn.channel` evaluates -any ``OUTPUTS`` token (``L2N5px``, ``Curv1N3``, ``Point4Fz``, ``Body1Pz``, ``Rod2TenA``, ...). +any ``OUTPUTS`` token (``L2N5px``, ``Curv1N3``, ``Point4Fz``, ``AnchFz1``, ``Body1Pz``, +``Rod2TenA``, ...). Views are cheap and hold no state; re-initialising or closing the model makes them stale, and a stale view raises :class:`cabledyn.CableDynError`. diff --git a/doc/python_postprocessing.rst b/doc/python_postprocessing.rst index c9bd0a82..3a419292 100644 --- a/doc/python_postprocessing.rst +++ b/doc/python_postprocessing.rst @@ -396,13 +396,17 @@ Touchdown time histories every output time, from a CableDyn ``.Line.p.out`` file, a MoorDyn-F line file, or the ``LNpx``/``py``/``pz`` channels of a main output. A node is grounded as in :meth:`~cabledyn.LineGeometry.touchdown`. Between the last grounded node and the next, the TDP is -placed where the chord crosses ``seabed_z + tolerance``. The :class:`~cabledyn.TouchdownHistory` +placed where the parabola through the last grounded node and the next two nodes crosses +``seabed_z + tolerance`` (the crossing nearest the suspended node; the chord crossing when there +is none), so it moves continuously as nodes ground and lift off. The :class:`~cabledyn.TouchdownHistory` holds the TDP arc length from End A, its coordinates, the layback, and two excursions from a reference TDP (a static profile, or the first sample): the horizontal excursion, positive towards the suspended end, and the arc-length excursion. Samples without a touchdown are ``nan``. The driver computes the same quantities during the run as the ``TDPs``/``x``/``y``/``z``/ ``Lay``/``Exc`` channels (see :doc:`outputs`), with ``tolerance`` equal to the contact-onset -height of 1e-6 m. +height of 1e-6 m. Its ``TDPGrd`` channel adds the grounded length from the grounded end to the +TDP (with End B grounded, the deformed line length less the TDP arc length; 0 when no node beyond +the end node is grounded), for the anchor uplift check. .. code-block:: python diff --git a/doc/theory.rst b/doc/theory.rst index c71717d6..5cd6b9a7 100644 --- a/doc/theory.rst +++ b/doc/theory.rst @@ -107,8 +107,9 @@ strain energy \quad \mathbf{a} = \mathbf{r}',\ \mathbf{b} = \mathbf{r}'' . Using :math:`\kappa^2` directly, rather than :math:`\kappa`, keeps the energy smooth through -the straight state. The stress-free reference is straight, and the reported bending moment is -:math:`M = EI\,\kappa`. +the straight state. The stress-free reference is straight, and the bending moment is +:math:`M = EI\,\kappa`; the node outputs recover it from nodal equilibrium +(:ref:`theory-output-recovery`). At each Gauss point, :math:`\mathbf{a}` and :math:`\mathbf{b}` are fixed linear maps of the 12 element DOFs. The gradient and Hessian of the energy density with respect to @@ -139,6 +140,108 @@ The element follows the geometrically exact Kirchhoff-rod formulation of interpolation of :ref:`Meier, Popp & Wall (2015) `, reduced to a torsion-free cable. Torsion enters only through the condensed line term below. +.. _theory-output-recovery: + +Node tension, curvature and bend moment +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +**Section force.** For the energy density :math:`W(\mathbf{a}, \mathbf{b})` of the element, the +force across a section (exerted by the part of the line beyond :math:`s` on the part before it) +and the conjugate of the material tangent are + +.. math:: + + \mathbf{F} = \frac{\partial W}{\partial \mathbf{a}} - \left(\frac{\partial W}{\partial \mathbf{b}}\right)', + \qquad + \mathbf{m} = \frac{\partial W}{\partial \mathbf{b}} + = EI\,\frac{(\mathbf{a}\times\mathbf{b})\times\mathbf{a}}{\lvert\mathbf{a}\rvert^{6}} . + +On a stiff-``EA`` cable :math:`\lvert\mathbf{a}\rvert = 1 + \varepsilon` with +:math:`\varepsilon \ll 1`, :math:`\mathbf{a}\cdot\mathbf{b} = O(\varepsilon)` and +:math:`\mathbf{b} = \kappa\,\mathbf{n}`, so that +:math:`\partial W/\partial\mathbf{a} = (EA\,\varepsilon - 2EI\kappa^2)\,\mathbf{t}` plus normal +terms, :math:`\mathbf{m} = EI\,\kappa\,\mathbf{n}`, and +:math:`(\partial W/\partial\mathbf{b})'\cdot\mathbf{t} = EI\,\mathbf{b}'\cdot\mathbf{t} = -EI\kappa^2`. +The axial internal force of the rod, the effective tension that balances the loads, and the +bend moment are therefore + +.. math:: + + N = \mathbf{F}\cdot\mathbf{t} = EA\,\varepsilon - EI\,\kappa^2, + \qquad + M = \lvert \mathbf{m} - (\mathbf{m}\cdot\mathbf{t})\,\mathbf{t} \rvert = EI\,\kappa . + +The bending energy measures the curvature per deformed length, and its dependence on the +stretch puts :math:`-EI\kappa^2` into the axial force: :math:`EA(\lvert\mathbf{r}'\rvert - 1)` +is a formulation quantity, not the tension, and exceeds :math:`N` by :math:`EI\kappa^2` on any +mesh (161 N on a 1.2 kN tension at the sag bend of the lazy-wave cable of +``iea15mw_umaine_mixed_cabledyn.dat``, :math:`\kappa = 0.09` 1/m). Global equilibrium fixes +:math:`N` whatever the formulation: on a suspended run the horizontal component of +:math:`\mathbf{F}` is constant and the vertical one changes by the submerged weight, so :math:`N` +is what any code converges to, the OrcaFlex effective tension and the MoorDyn segment tension +on a fine mesh among them. + +**Pointwise oscillation.** With a stiff ``EA`` the cubic interpolation cannot keep +:math:`\lvert\mathbf{r}'\rvert` constant where the line must bend over an element (a nodal +seabed reaction, a section junction): the pointwise axial resultant oscillates about the element +mean by several times the tension, and the element means alternate between neighbours. On that +cable as meshed in the example (87 elements, 10 m on the grounded run, tension 1.2 kN) the +pointwise resultant spans -41.5 to +91.8 kN and the length-weighted element means at the nodes +reach -173 N; at 1 m elements the pointwise field still spans -5.9 to +11.9 kN. + +**Recovery from nodal equilibrium.** The node outputs are recovered from the element end +forces, the classical recovery of the finite-element nodal forces. For element :math:`e` the +end residual + +.. math:: + + \mathbf{g}_e = \mathbf{f}_{\text{int},e} + \mathbf{f}_{\text{damp},e} - \mathbf{f}_{\text{ext},e} + + \mathbf{M}_e\,\mathbf{a}_e + +holds only the element's own distributed loads: consistent submerged weight, the buoyancy lost +above the free surface, drag, Froude-Krylov force, structural and added-mass inertia, and the +seabed reaction of its end nodes, each nodal reaction spread uniformly over the node's tributary +length (the distributed floor reaction it stands for; without it a line resting on the floor +would report the fixed-end moment :math:`w L_0^2/12` of its own weight). :math:`\mathbf{g}_e` +is the generalised force the two end nodes exert on the element: its position rows at the +End-B side of the internal arc are the section force :math:`\mathbf{F}_j^-` just before node +:math:`j`, minus its rows at the other end the section force :math:`\mathbf{F}_j^+` just after +it, and its tangent rows are :math:`\mathbf{m}` there. An interior node reports + +.. math:: + + N_j = \mathbf{t}_j\cdot\tfrac{1}{2}\left(\mathbf{F}_j^- + \mathbf{F}_j^+\right), + \qquad + M_j = \lvert \mathbf{m}_j - (\mathbf{m}_j\cdot\mathbf{t}_j)\,\mathbf{t}_j \rvert, + \qquad + \kappa_j = M_j / EI , + +with :math:`\mathbf{t}_j` the unit nodal tangent, :math:`\mathbf{m}_j` the mean of the two +one-sided values, and at a section junction the larger of :math:`M_j/EI` on the two sides. The +difference of the two one-sided forces is the point load left at the node (seabed friction, an +attachment), so the nodal section forces satisfy the discrete equilibrium exactly and carry +none of the pointwise oscillation. A line end reports the ``FairTen``/``AnchTen`` end force and +its one-sided moment; the segment tension of an element is the mean of the axial components of +its own two end forces. The recovery costs one element evaluation per element and output row. + +On the 87-element lazy wave the interior node tension departs from the equilibrium of the +converged line by at most 60 N (1552 N for the element means), 12 N at twice the mesh density +and 0.3 N at 1 m elements (516 N); the largest curvature error falls from 64 % to 30 % of the +peak at 87 elements and from 2.1 % to 0.8 % at 1 m. The peak curvature at a +touchdown meshed coarser than the bending length is limited by the solution itself, not by the +recovery. + +The condensed torque of a line restrained in torsion is not part of :math:`\mathbf{g}_e`: it adds +a shear normal to the tangent and does no work on bending rotations. Including its element terms +on ``torsion_lazy_wave_hangoff_twist.dat`` (two turns, torque 3.5 kN m) moves the tension by +at most 0.45 N of 9.4 kN and moves the bend moment away from :math:`EI\kappa`. + +``OPTIONS`` ``OutputRecovery element`` restores the element definitions: the length-weighted +mean of the element-mean axial forces :math:`EA(\lvert\mathbf{r}'\rvert - 1)` at an interior +node, the larger one-sided exact curvature, and the midpoint axial resultant as the segment +tension. The material-strain checks (``tensile_safety``, the static compression notes) judge +:math:`EA\varepsilon` under either setting. + .. _theory-torsion: Condensed torsion @@ -1102,8 +1205,8 @@ mesh-sequenced route described below first and this route as its fallback): when the polish on the split mesh does not converge, or at an element budget. The report is judged on element-mean forces: the mean over each element and its two neighbours (length-weighted) beyond the - admissible band, or a node tension (the segment tension, :doc:`outputs`) in compression by - more than a tenth of the peak tension. + admissible band, or a nodal material axial force (the length-weighted mean of the two + adjacent element means) in compression by more than a tenth of the peak tension. The nodal seabed-contact reaction kinks the line at the touchdown node, and the element there can carry a small negative mean between tensile neighbours at any mesh; that dip does not enter equilibrium and is not reported. A failing route falls back to the @@ -1921,9 +2024,10 @@ Commands that would make the element length non-positive are rejected. Tension and coupled loads ------------------------- -An interior node tension is the segment tension: the average of the two adjacent element -tensions (``EI = 0``), or the length-weighted average of the element-mean axial forces of the -two adjacent elements (Hermite), including axial damping and constitutive-state contributions. +An interior node tension is the segment tension, the average of the two adjacent element +tensions, on an ``EI = 0`` line, and the effective tension recovered from nodal equilibrium +(:ref:`theory-output-recovery`) on a Hermite line, including axial damping and +constitutive-state contributions. ``FairTen``, ``AnchTen`` and the end-node tension channels report the line-end force instead (:doc:`conventions`, :doc:`outputs`). By the convention in :doc:`conventions` the reported tension is the effective tension. The diff --git a/doc/tutorial_bodies.rst b/doc/tutorial_bodies.rst index 683a6168..0c5be0e1 100644 --- a/doc/tutorial_bodies.rst +++ b/doc/tutorial_bodies.rst @@ -184,12 +184,13 @@ and clamps it there at 60° below horizontal: The direction is given in the body frame and turns with the buoy. The clamp moment, ``BendMom4N1``, acts on the body in the static solve and in the dynamics, and is part of -``Body1M*``. At rest the clamp carries 9.53 kN·m (a pinned cable would leave at 82°) and +``Body1M*``. At rest the clamp carries 9.63 kN·m (a pinned cable would leave at 82°) and ``Body1My`` is zero; the moment tilts the buoy to a static pitch of 0.15° instead of 0.30° -pinned. In 1 m, 14 s swell the clamp moment ranges from 8.6 to 10.8 kN·m and the buoy pitches -between −1.35° and +1.07°. With ``Pinned`` the end moment stays below 0.5 N·m. The first 10 m of -cable use 0.25 m elements to resolve the bending near the clamp; halving them changes the moment -by 0.8 %. A finite ``Stiffness`` in N·m/rad models a compliant hang-off. +pinned. In 1 m, 14 s swell the clamp moment ranges from 8.7 to 11.0 kN·m and the buoy pitches +between −1.35° and +1.07°. With ``Pinned`` the end moment stays below 0.1 N·m. The first 10 m of +cable use 0.25 m elements to resolve the bending near the clamp; ``BendMom4N1`` is the moment the +end element carries in equilibrium, so halving them changes it by under 0.01 % (0.5 % for twice +the elements' length). A finite ``Stiffness`` in N·m/rad models a compliant hang-off. A spar with pinned rods ----------------------- diff --git a/doc/tutorial_dynamics.rst b/doc/tutorial_dynamics.rst index 039c5ed0..18bd8164 100644 --- a/doc/tutorial_dynamics.rst +++ b/doc/tutorial_dynamics.rst @@ -255,19 +255,19 @@ current loads the run across its axis, so the lateral coefficient decides: - Sway at s = 160 m (m) * - 0.3 / 1.0 (deck) - 59.0 - - 109.8 + - 109.6 - 0.01 * - 1.0 isotropic - 59.0 - - 109.8 + - 109.6 - 0.01 * - 0.3 isotropic - 64.3 - - 117.5 + - 117.1 - 11.8 * - none - 73.9 - - 128.0 + - 127.9 - 19.6 A single coefficient equal to the axial value lets the laid run slide up to 16 m sideways and diff --git a/doc/tutorial_lazywave.rst b/doc/tutorial_lazywave.rst index 7141884b..40790dbb 100644 --- a/doc/tutorial_lazywave.rst +++ b/doc/tutorial_lazywave.rst @@ -84,7 +84,7 @@ Run it # CableDyn driver output (finite-EI dynamic; production cubic-Hermite route) Time(s) FairTen1 AnchTen1 FairIncl1 AnchIncl1 Curv1N383 BendMom1N383 - 0.0... 9.3201701E+003 1.3269019E+003 8.1600621E+001 -3.6937724E-001 9.6834389E-002 1.9270043E+003 + 0.0... 9.3201701E+003 1.3269019E+003 8.1600621E+001 -3.6920305E-001 9.6829202E-002 1.9269011E+003 Read the shape -------------- diff --git a/doc/tutorial_motion.rst b/doc/tutorial_motion.rst index 73c5a489..37e0bc3a 100644 --- a/doc/tutorial_motion.rst +++ b/doc/tutorial_motion.rst @@ -111,13 +111,13 @@ full-amplitude heave cycle): - 1 578 - 1 326 * - ``Curv1N25`` (1/m) - - 0.0911 - - 0.1034 - - 0.0969 + - 0.0915 + - 0.1041 + - 0.0973 * - ``BendMom1N25`` (N·m) - - 1 813 - - 2 058 - - 1 929 + - 1 820 + - 2 073 + - 1 937 A 3 m heave swings the hang-off tension by ±40 % about its static value and changes the sag-bend curvature by about ±6 %. Plot ``FairTen1`` against ``Time(s)``: the first 12 s show the smooth @@ -156,7 +156,7 @@ connection moment: .\CableDyn_driver.exe .\examples\lazy_wave_vessel_motion.dat .\results\vessel80 At rest the hang-off tension is 9320 N and the end moment is below 1 N·m. Over the last 24 s the -fairlead tension ranges from 7485 to 10969 N and the end moment peaks at 2953 N·m (a curvature of +fairlead tension ranges from 7485 to 10969 N and the end moment peaks at 2955 N·m (a curvature of 0.148 1/m, a bend radius of about 6.7 m). With the hang-off pinned, the end tangent swings between 71.5° and 89.2°; the clamp holds it to the vessel pitch, so the cable bends near the vessel instead. The peak moment changes by less than 0.1 % at ``dtM = 0.025`` s or with twice diff --git a/doc/tutorial_python.rst b/doc/tutorial_python.rst index b6090cb4..0abe6f5d 100644 --- a/doc/tutorial_python.rst +++ b/doc/tutorial_python.rst @@ -202,8 +202,8 @@ node. The fairlead tension ranges from 524 to 2815 kN (mean 1332 kN, static 1006 ``python C:\CableDyn\examples\plot_range_envelope.py results\range --save range.png`` plots the band and the mean against arc length. The ``TDP1s``, ``TDP1Lay`` and ``TDP1Exc`` channels track the touchdown -point: at rest it lies 159.9 m of arc from the fairlead with a 149.7 m layback, and during the -surge it moves between 109.9 and 286.6 m of arc, an excursion of −126.3 to +49.9 m. +point: at rest it lies 159.7 m of arc from the fairlead with a 149.5 m layback, and during the +surge it moves between 109.7 and 285.4 m of arc, an excursion of −125.2 to +49.9 m. Python API for GUIs and scripting --------------------------------- diff --git a/examples/cabledyn_options_reference.dat b/examples/cabledyn_options_reference.dat index 79ae9cbf..2d264baf 100644 --- a/examples/cabledyn_options_reference.dat +++ b/examples/cabledyn_options_reference.dat @@ -40,6 +40,7 @@ False modified_newton - Tangent-reuse mode {False=full Newton; True=guarded True cable_load_feedback - Return finite-EI cable reactions to OpenFAST {False; True} [default: True] False adaptive_mesh - Automatic finite-EI refinement {False; True} [default: False] continuation cable_statics - Finite-EI static route order {continuation; sequenced} [default: continuation] +equilibrium OutputRecovery - Finite-EI node tension/curvature/moment {equilibrium; element} [default: equilibrium] True alpha_force_blend - Generalised-alpha force blend, finite-EI and EI=0 lines {True; False=configuration blend} [default: True] False tensile_safety - Element-mean axial-force audit {False; warn; True=reject} [default: False] 2.0e-6 tensile_strain_tolerance - Dynamic audit strain band [default: 2.0e-6] @@ -100,7 +101,7 @@ none waves - Wave model and parameters (m, s, deg) {none; airy; -- staticsFriction = statics_friction = staticsSeabedFrictionPolicy = seabedFrictionPolicy -- 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 +-- cable_statics = cableStatics; alpha_force_blend = alphaForceBlend; OutputRecovery = output_recovery -- 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/builder.py b/python/cabledyn/builder.py index d2223602..3e81cf8a 100644 --- a/python/cabledyn/builder.py +++ b/python/cabledyn/builder.py @@ -103,12 +103,12 @@ ( "line", re.compile( - r"(fairten|anchten|fairangle|anchangle|fairdecl|anchdecl|fairincl|anchincl)" + r"(fairten|anchten|anchfz|anchfh|fairangle|anchangle|fairdecl|anchdecl|fairincl|anchincl)" r"([0-9]+)()", re.IGNORECASE, ), ), - ("line", re.compile(r"(tdp)([0-9]+)(s|x|y|z|lay|exc)", re.IGNORECASE)), + ("line", re.compile(r"(tdp)([0-9]+)(s|x|y|z|lay|exc|grd)", re.IGNORECASE)), ("line", re.compile(r"(ten|curv|bendmom|torq)([0-9]+)(n[0-9]+)", re.IGNORECASE)), ("line", re.compile(r"(twist)([0-9]+)(n[0-9]+|)", re.IGNORECASE)), ("line", re.compile(r"(l)([0-9]+)(n[0-9]+(?:[pva][xyz]|dec|azi))", re.IGNORECASE)), diff --git a/python/cabledyn/deck_file.py b/python/cabledyn/deck_file.py index be7f0813..a834aa96 100644 --- a/python/cabledyn/deck_file.py +++ b/python/cabledyn/deck_file.py @@ -248,6 +248,8 @@ "lay_azimuth": "lay_azimuth", "aslaidtension": "as_laid_tension", "as_laid_tension": "as_laid_tension", + "outputrecovery": "output_recovery", + "output_recovery": "output_recovery", } # 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. @@ -718,6 +720,9 @@ def _channel_identity_key(channel: str) -> str: if lowered.startswith(("fairten", "anchten")): line_id = _native_id_suffix(lowered[7:]) return f"{lowered[:7]}:{line_id}" if line_id > 0 else lowered + if lowered.startswith(("anchfz", "anchfh")): + line_id = _native_id_suffix(lowered[6:]) + return f"{lowered[:6]}:{line_id}" if line_id > 0 else lowered if lowered.startswith( ("fairangle", "anchangle", "fairdecl", "anchdecl", "fairincl", "anchincl") ): @@ -740,9 +745,9 @@ def _channel_identity_key(channel: str) -> str: else 0 ) return f"point:{point_id}:{component}" if point_id > 0 and component > 0 else lowered - touchdown = re.fullmatch(r"tdp([0-9]{1,9})(s|x|y|z|lay|exc)", lowered) + touchdown = re.fullmatch(r"tdp([0-9]{1,9})(s|x|y|z|lay|exc|grd)", lowered) if touchdown is not None and int(touchdown.group(1)) > 0: - component = ("s", "x", "y", "z", "lay", "exc").index(touchdown.group(2)) + 1 + 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", "l", "torq", "twist")): line_id, node_id, kind, component = _parse_line_node_channel(lowered) @@ -1221,6 +1226,12 @@ 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 == "output_recovery": + return ( + None + if value.lower() in {"equilibrium", "element"} + else "must be equilibrium or element" + ) if key in {"axial_quadrature_order", "bending_quadrature_order"}: try: numeric = _native_float(value) @@ -3682,8 +3693,8 @@ def is_body_kind(kind: str, pinned: bool) -> bool: for channel in channels: lowered = channel.lower() endpoint_channel = re.fullmatch( - r"(?:fairten|anchten|fairangle|anchangle|fairdecl|anchdecl|fairincl|anchincl)" - r"([0-9]+)", + r"(?:fairten|anchten|anchfz|anchfh|fairangle|anchangle|fairdecl|anchdecl" + r"|fairincl|anchincl)([0-9]+)", lowered, ) # Con

p{x,y,z} is the native alias of Point

p{x,y,z} (MoorDyn v1 spelling). @@ -3743,8 +3754,9 @@ def is_body_kind(kind: str, pinned: bool) -> bool: f"{self._label}: OUTPUT {channel!r} references an unknown point" ) continue - # TDP{s,x,y,z,Lay,Exc}: the touchdown point of line L (native CD_Parse_TDP_Channel) - touchdown_channel = re.fullmatch(r"tdp([0-9]{1,9})(?:s|x|y|z|lay|exc)", lowered) + # TDP{s,x,y,z,Lay,Exc,Grd}: the touchdown point of line L (native + # CD_Parse_TDP_Channel) + touchdown_channel = re.fullmatch(r"tdp([0-9]{1,9})(?:s|x|y|z|lay|exc|grd)", lowered) if touchdown_channel: if _channel_id(touchdown_channel.group(1)) not in line_ids: raise DeckFormatError( diff --git a/python/cabledyn/results.py b/python/cabledyn/results.py index 934874b7..6366013a 100644 --- a/python/cabledyn/results.py +++ b/python/cabledyn/results.py @@ -53,7 +53,7 @@ def _native_channel_unit(channel: str) -> str | None: Ids may carry leading zeros (``Ten01N01``), as the native channel parser accepts. """ patterns = ( - (r"(?:FairTen|AnchTen)0*[1-9][0-9]*", "N"), + (r"(?:FairTen|AnchTen|AnchFz|AnchFH)0*[1-9][0-9]*", "N"), (r"(?:FairIncl|AnchIncl|FairDecl|AnchDecl|FairAngle|AnchAngle)0*[1-9][0-9]*", "deg"), (r"Ten0*[1-9][0-9]*N0*[1-9][0-9]*", "N"), (r"Curv0*[1-9][0-9]*N0*[1-9][0-9]*", "1/m"), diff --git a/python/cabledyn/touchdown.py b/python/cabledyn/touchdown.py index 54173a24..738685d9 100644 --- a/python/cabledyn/touchdown.py +++ b/python/cabledyn/touchdown.py @@ -14,9 +14,16 @@ A node is grounded when ``z <= seabed_z + tolerance``, and the grounded run must start at one end of the line (as for :meth:`cabledyn.LineGeometry.touchdown`). Between the last grounded node and the next one the touchdown point (TDP) is -placed where the chord crosses ``seabed_z + tolerance``, so it moves smoothly -rather than jumping from node to node. Arc length is the cumulative deformed -chord length from End A through the available nodes. +placed where the parabola through the last grounded node and the next two +nodes (height against chord arc) crosses ``seabed_z + tolerance``, the crossing +nearest the suspended node; with fewer than two suspended nodes, or no crossing +inside the element, where the chord crosses that height. The crossing reaches a +node exactly when the node reaches that height, so the TDP moves continuously as +nodes ground and lift off, and the parabola follows a tangential lift-off between +nodes instead of holding the TDP at the last grounded node (the behaviour of the +chord crossing on a stiff seabed). It is the location of the driver's ``TDP`` +channels. Arc length is the cumulative deformed chord length from End A through +the available nodes. The excursion is the horizontal TDP displacement from a reference position, projected on the horizontal direction from the grounded end to the suspended @@ -290,13 +297,41 @@ def _locate( rise = high[:, 2] - low[:, 2] with np.errstate(divide="ignore", invalid="ignore"): fraction = np.clip(np.where(rise > 0.0, (level - low[:, 2]) / rise, 0.0), 0.0, 1.0) + n = xyz.shape[1] + quadratic = touching & (last + 2 < n) + for row in np.nonzero(quadratic)[0]: + fraction[row] = _quadratic_fraction(xyz[row], int(last[row]), level, fraction[row]) point = low + fraction[:, None] * (high - low) + point[touching, 2] = level tdp_arc = arc[rows, last] + fraction * chords[rows, np.minimum(last, chords.shape[1] - 1)] if end == "B": tdp_arc = arc[:, -1] - tdp_arc return touching, tdp_arc, point, xyz[:, -1, :2] +def _quadratic_fraction(xyz: npt.NDArray[Any], last: int, level: float, linear: float) -> float: + """Crossing of ``level`` by the quadratic height through the last grounded node and the + first two suspended nodes, nearest the suspended node, as a fraction of the first chord + (the linear fraction when the quadratic has no crossing in the element).""" + g0, g1, g2 = (xyz[last + k, 2] - level for k in range(3)) + l1 = float(np.linalg.norm(xyz[last + 1] - xyz[last])) + l2 = float(np.linalg.norm(xyz[last + 2] - xyz[last + 1])) + if not (l1 > 0.0 and l2 > 0.0): + return linear + d1 = (g1 - g0) / l1 + qa = ((g2 - g1) / l2 - d1) / (l1 + l2) + qb = d1 - qa * l1 + if abs(qa) * l1 <= 1e-12 * max(abs(qb), np.finfo(float).tiny): + return float(np.clip(-g0 / qb / l1, 0.0, 1.0)) if qb != 0.0 else linear + disc = qb * qb - 4.0 * qa * g0 + if disc < 0.0: + return linear + x1 = (-qb - math.sqrt(disc)) / (2.0 * qa) if qb >= 0.0 else (-qb + math.sqrt(disc)) / (2.0 * qa) + x2 = g0 / (qa * x1) if x1 != 0.0 else 0.0 + inside = [x for x in (x1, x2) if -1e-9 * l1 <= x <= l1 * (1.0 + 1e-9)] + return float(np.clip(max(inside) / l1, 0.0, 1.0)) if inside else linear + + def touchdown_history( source: TimeHistory, *, diff --git a/python/tests/test_builder.py b/python/tests/test_builder.py index 8ee00ec9..e5e5f161 100644 --- a/python/tests/test_builder.py +++ b/python/tests/test_builder.py @@ -246,7 +246,9 @@ 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", "Point2FH", "Con1py") + model.outputs.add( + "Ten1N3", "L1N2px", "TDP1s", "TDP1Grd", "AnchFz1", "AnchFH1", "Point2FH", "Con1py" + ) model.rename(model.lines[1], 7) model.rename(model.points[1], 11) model.rename(model.line_types["chain"], "R3chain") @@ -257,6 +259,9 @@ def test_rename_propagates_to_rows_and_output_channels() -> None: "Ten7N3", "L7N2px", "TDP7s", + "TDP7Grd", + "AnchFz7", + "AnchFH7", "Point2FH", "Con11py", ] diff --git a/python/tests/test_deck_file.py b/python/tests/test_deck_file.py index 74a5d40c..20baab9b 100644 --- a/python/tests/test_deck_file.py +++ b/python/tests/test_deck_file.py @@ -665,6 +665,7 @@ def test_unknown_scalar_option_keyword_fails_closed(tmp_path): ("1.5", "wave_seed", "must be an integer"), ("maybe", "alpha_force_blend", "native boolean"), ("relaxed", "cable_statics", "continuation or sequenced"), + ("nodal", "OutputRecovery", "equilibrium or element"), ], ) def test_invalid_scalar_option_values_fail_closed(tmp_path, value, keyword, message): @@ -738,6 +739,8 @@ def test_zero_e_exponent_waterkin_mode_is_accepted(tmp_path): "True alphaForceBlend", "continuation cable_statics", "sequenced cableStatics", + "equilibrium OutputRecovery", + "element output_recovery", ], ) def test_native_scalar_option_vocabulary_is_accepted(tmp_path, row): @@ -1986,6 +1989,10 @@ def test_static_line_endpoint_topology_matches_native_normalization(tmp_path): "TDP1z", "TDP1Lay", "TDP1Exc", + "TDP1Grd", + "AnchFz1", + "AnchFH1", + "anchfz01", ], ) def test_output_channel_vocabulary_matches_native_parser(tmp_path, channel): @@ -2008,6 +2015,11 @@ def test_output_channel_vocabulary_matches_native_parser(tmp_path, channel): ("TDP2s", "unknown line"), ("TDP1q", "unsupported OUTPUT"), ("TDP1sx", "unsupported OUTPUT"), + ("TDP1Grdx", "unsupported OUTPUT"), + ("AnchFz2", "unknown line"), + ("AnchFH0", "unknown line"), + ("AnchFz1x", "unsupported OUTPUT"), + ("AnchFy1", "unsupported OUTPUT"), ], ) def test_invalid_output_channels_fail_before_case_generation(tmp_path, channel, message): @@ -3628,6 +3640,9 @@ def unqueryable(first, second): ("L1N3va", "L1N3va"), ("TDP1s", "tdp01S"), ("TDP1Lay", "TDP1LAY"), + ("TDP1Grd", "tdp01GRD"), + ("AnchFz1", "anchfz01"), + ("AnchFH1", "ANCHFH1"), ], ) def test_duplicate_output_channels_fail_like_native(first, second): @@ -3653,8 +3668,8 @@ def test_duplicate_output_channel_on_one_row_and_across_sections_fails(): def test_distinct_output_channels_are_not_collapsed(): channels = ( - "FairTen1 AnchTen1 FairIncl1 AnchIncl1 FairDecl1 AnchDecl1 Point1px Point1py " - "Point2px Ten1N1 Ten1N2 Curv1N1 BendMom1N1 L1N1px L1N1vx L1N1ax L1N1Dec L1N1Azi" + "FairTen1 AnchTen1 AnchFz1 AnchFH1 FairIncl1 AnchIncl1 FairDecl1 AnchDecl1 Point1px " + "Point1py Point2px Ten1N1 Ten1N2 Curv1N1 BendMom1N1 L1N1px L1N1vx L1N1ax L1N1Dec L1N1Azi" ) deck = DeckFile.from_text(_edit(_STATIC, ("FairTen1\n", channels + "\n"))) assert deck.outputs == tuple(channels.split()) @@ -3696,6 +3711,11 @@ def test_distinct_output_channels_are_not_collapsed(): ("TDP2s", "tdp:2:1"), ("TDP0s", "tdp0s"), ("TDP1", "tdp1"), + ("TDP3Grd", "tdp:3:7"), + ("AnchFz01", "anchfz:1"), + ("AnchFH2", "anchfh:2"), + ("AnchFz", "anchfz"), + ("AnchFz0", "anchfz0"), ("Lxyz", "lxyz"), ("Other1", "other1"), ], diff --git a/python/tests/test_deck_native_parity.py b/python/tests/test_deck_native_parity.py index e10149e8..70afcd07 100644 --- a/python/tests/test_deck_native_parity.py +++ b/python/tests/test_deck_native_parity.py @@ -206,13 +206,25 @@ def test_attachment_arc_length_lies_on_the_line(arc, accepted): @pytest.mark.parametrize( - "channel", ["FairTen01", "AnchIncl001", "TDP01s", "L01N1px", "Ten01N01", "Point01px", "Con01pz"] + "channel", + [ + "FairTen01", + "AnchIncl001", + "AnchFz01", + "AnchFH001", + "TDP01s", + "TDP01Grd", + "L01N1px", + "Ten01N01", + "Point01px", + "Con01pz", + ], ) def test_line_and_point_channel_ids_may_have_leading_zeros(channel): DeckFile.from_text(_edit(_HELD, ("FairTen1\n", f"{channel}\n"))) -@pytest.mark.parametrize("channel", ["TDP1q", "Point1pq", "Ten9N0"]) +@pytest.mark.parametrize("channel", ["TDP1q", "Point1pq", "Ten9N0", "AnchFz1z", "TDP1Grd1"]) def test_malformed_line_and_point_channels_fail_closed(channel): _rejects(_edit(_HELD, ("FairTen1\n", f"FairTen1\n{channel}\n")), "unsupported OUTPUT") diff --git a/python/tests/test_objects.py b/python/tests/test_objects.py index 1eadb457..e360af3d 100644 --- a/python/tests/test_objects.py +++ b/python/tests/test_objects.py @@ -315,6 +315,12 @@ def test_views_equal_the_channel_evaluator_bit_for_bit(tmp_path): force = fixed.force() assert force[0] == model.channel("Point1Fx") assert np.linalg.norm(force) == pytest.approx(line.anchor_tension(), rel=1.0e-12) + # the anchor holds one line: AnchFz/AnchFH are components of the same end force + assert model.channel("AnchFz1") == model.channel("Point1Fz") == force[2] + assert model.channel("AnchFH1") == model.channel("Point1FH") + assert model.channel("AnchFH1") == pytest.approx(np.hypot(force[0], force[1]), rel=1.0e-14) + # a grounded anchor carries part of its end node's weight: a small downward force + assert -0.05 * line.anchor_tension() < model.channel("AnchFz1") < 0.0 assert model.bodies == () and model.rods == () @@ -399,7 +405,19 @@ def test_rod_views(tmp_path): def test_channel_errors_and_stale_views(tmp_path): deck = _held_chain(tmp_path) model = CableDyn(deck) - for bad in ("", "x" * 65, "L1N99px", "Line1", "FairTen9", "L1N5q", "Body1Pz", "TDP1s"): + for bad in ( + "", + "x" * 65, + "L1N99px", + "Line1", + "FairTen9", + "AnchFz9", + "AnchFz1x", + "L1N5q", + "Body1Pz", + "TDP1s", + "TDP1Grd", + ): with pytest.raises((CableDynError, ValueError)): model.channel(bad) with pytest.raises(TypeError): diff --git a/python/tests/test_results.py b/python/tests/test_results.py index 02ec705a..f213c8ca 100644 --- a/python/tests/test_results.py +++ b/python/tests/test_results.py @@ -298,6 +298,9 @@ def test_time_must_be_strictly_increasing(tmp_path): ("channel", "unit"), [ ("FairTen1", "N"), + ("AnchFz1", "N"), + ("AnchFH2", "N"), + ("anchfh02", "N"), ("AnchIncl2", "deg"), ("Ten3N4", "N"), ("Curv3N4", "1/m"), @@ -324,6 +327,7 @@ def test_time_must_be_strictly_increasing(tmp_path): # an all-zero id is no channel ("Twist0", None), ("Torq0N1", None), + ("AnchFz0", None), ("Unknown", None), ], ) diff --git a/python/tests/test_touchdown.py b/python/tests/test_touchdown.py index 14f17198..8a8ffdb5 100644 --- a/python/tests/test_touchdown.py +++ b/python/tests/test_touchdown.py @@ -32,14 +32,22 @@ def _frames(kinks=None) -> np.ndarray: def _expected(xyz: np.ndarray) -> tuple[float, np.ndarray]: - """Straightforward scalar TDP: last grounded node from End A, chord crossing.""" + """Straightforward scalar TDP: last grounded node from End A, then the crossing of the + level by the parabola through that node and the next two, in chord arc (on a straight + rise this is the chord crossing), nearest the suspended node.""" level = SEABED + TOLERANCE last = int(np.argmax(xyz[:, 2] > level)) - 1 low, high = xyz[last], xyz[last + 1] - fraction = (level - low[2]) / (high[2] - low[2]) chords = np.linalg.norm(np.diff(xyz, axis=0), axis=1) + arcs = np.array([0.0, chords[last], chords[last] + chords[last + 1]]) + coefficients = np.polyfit(arcs, xyz[last : last + 3, 2] - level, 2) + roots = [r.real for r in np.roots(coefficients) if abs(r.imag) < 1e-12] + inside = [r for r in roots if -1e-9 <= r <= chords[last] * (1.0 + 1e-9)] + fraction = max(inside) / chords[last] arc = float(np.sum(chords[:last]) + fraction * chords[last]) - return arc, low + fraction * (high - low) + point = low + fraction * (high - low) + point[2] = level + return arc, point def _write_line(path, frames, times=TIMES): diff --git a/src/CableDyn_DeckDriver.f90 b/src/CableDyn_DeckDriver.f90 index a4d79fbe..9f039010 100644 --- a/src/CableDyn_DeckDriver.f90 +++ b/src/CableDyn_DeckDriver.f90 @@ -97,6 +97,8 @@ MODULE CableDyn_DeckDriver CD_HCDYN_TENSILE_ERROR, & 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, & + CD_HermiteCable_Dyn_Set_Output_Recovery, & CD_HermiteCable_Dyn_Set_ForceBlend, CD_HC_FORCE_BLEND_DEFAULT, & CD_HermiteCable_Dyn_Set_Friction_Anchors, & CD_HermiteCable_Dyn_Set_Friction_Axial, & @@ -605,6 +607,10 @@ MODULE CableDyn_DeckDriver ! catenary-seeded EI continuation first and the mesh-sequenced route as its fallback; ! 'sequenced' runs the mesh-sequenced route first. LOGICAL :: cable_statics_sequenced = .FALSE. + ! Finite-EI node output definitions (OutputRecovery): 'equilibrium' (default) recovers the + ! 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. 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 @@ -2959,6 +2965,8 @@ RECURSIVE SUBROUTINE build_one_hermite_cable(ln, sections, types, points, opts, IF (es /= CD_HCDYN_OK) THEN CALL fail(ErrStat, ErrMsg, 'finite-EI cable alpha_force_blend wiring failed: '//TRIM(em)); RETURN END IF + ! OPTIONS OutputRecovery selects the definition of the node tension, curvature and bend moment. + CALL CD_HermiteCable_Dyn_Set_Output_Recovery(cable%line, opts%output_element_recovery) CONTAINS SUBROUTINE torsion_stage(est, emt) @@ -5731,8 +5739,9 @@ SUBROUTINE audit_hermite_static(l0, q, ea, ei, w, diam, endconn_mode, physical, ! the pointwise resultant, and a single element mean between tensile neighbours, dip ! next to a nodal seabed-contact reaction (a kink no element can follow, at every ! mesh) while the line in equilibrium stays tensile. Compression is reported when the - ! 3-element smoothed mean exceeds the admissible band, or when the node Tension - ! channel (the segment tension) falls below a tenth of the peak tension. + ! 3-element smoothed mean exceeds the admissible band, or when the nodal material + ! axial force (the length-weighted mean of the two adjacent element means) falls below a + ! tenth of the peak tension. hl_max = CD_ZERO DO e = 1, ne IF (ABS(w(e)) > CD_ZERO .AND. ei(e) > CD_ZERO) & @@ -12975,6 +12984,15 @@ SUBROUTINE apply_option(line, opts, ErrStat, ErrMsg) CASE DEFAULT CALL fail(ErrStat, ErrMsg, 'OPTION cable_statics "'//TRIM(val)//'" must be continuation or sequenced') END SELECT + CASE ('outputrecovery', 'output_recovery') + SELECT CASE (TRIM(to_lower(val))) + CASE ('equilibrium') + opts%output_element_recovery = .FALSE. + CASE ('element') + opts%output_element_recovery = .TRUE. + CASE DEFAULT + CALL fail(ErrStat, ErrMsg, 'OPTION OutputRecovery "'//TRIM(val)//'" must be equilibrium or element') + END SELECT CASE ('cable_load_feedback', 'cableloadfeedback') CALL rd_bool(val, opts%cable_load_feedback, ErrStat, ErrMsg) CASE ('tensile_safety', 'tensilesafety') @@ -13432,7 +13450,7 @@ END SUBROUTINE append_channel FUNCTION channel_identity_key(ch) RESULT(key) !! Canonical identity of an OUTPUTS channel, for duplicate detection: names compare - !! case-insensitively, numeric ids by value (FairTen01 = FairTen1), and alias + !! case-insensitively, numeric ids by value (FairTen01 = FairTen1, AnchFz01 = AnchFz1), and alias !! spellings of one quantity collapse (Con

p{x,y,z} = Point

p{x,y,z}; !! FairAngle = FairDecl, AnchAngle = AnchDecl). Names outside the parsed !! families keep their lowercased spelling. @@ -13446,6 +13464,9 @@ FUNCTION channel_identity_key(ch) RESULT(key) IF (starts_with(lo, 'fairten') .OR. starts_with(lo, 'anchten')) THEN a = int_suffix(ch, 8) IF (a > 0) key = lo(1:7)//':'//TRIM(int_to_str(a)) + ELSE IF (is_anchor_force_channel(lo)) THEN + a = anchor_force_line_id(ch) + IF (a > 0) key = lo(1:6)//':'//TRIM(int_to_str(a)) ELSE IF (is_endpoint_angle_channel(lo)) THEN a = endpoint_angle_line_id(ch) IF (a <= 0) RETURN @@ -24947,7 +24968,8 @@ SUBROUTINE write_hermite_dynamic_out(out_root, channels, lines, points, opts, ca IF (ErrStat == CD_DECKDRV_OK) & CALL write_hermite_static_profile(out_root, lines, cables, ErrStat, ErrMsg) IF (ErrStat == CD_DECKDRV_OK) & - CALL write_dynamic_hermite_line_outputs(CD_ZERO, lines, cables, pos_units, ten_units, ErrStat, ErrMsg) + CALL write_dynamic_hermite_line_outputs(CD_ZERO, lines, cables, pos_units, ten_units, ErrStat, ErrMsg, & + ranges=ranges) IF (ErrStat /= CD_DECKDRV_OK) THEN CLOSE (unit); CALL close_dynamic_line_outputs(pos_units, ten_units); RETURN END IF @@ -24999,7 +25021,8 @@ SUBROUTINE write_hermite_dynamic_out(out_root, channels, lines, points, opts, ca motion=motion, motion_time_index=MERGE(step + 1, 0, opts%has_motion_file), & has_motion=opts%has_motion_file, ranges=ranges) IF (ErrStat == CD_DECKDRV_OK) & - CALL write_dynamic_hermite_line_outputs(t, lines, cables, pos_units, ten_units, ErrStat, ErrMsg) + CALL write_dynamic_hermite_line_outputs(t, lines, cables, pos_units, ten_units, ErrStat, ErrMsg, & + ranges=ranges) IF (ErrStat /= CD_DECKDRV_OK) EXIT CALL CD_Profile_Enter(CD_PROF_PROGRESS) CALL update_driver_progress(progress, step, t) @@ -25407,6 +25430,8 @@ SUBROUTINE write_hermite_model_row(unit, time, channels, lines, points, cables, ELSE IF (starts_with(lo, 'fairten') .OR. starts_with(lo, 'anchten')) THEN line_id = int_suffix(channels(i), 8) + ELSE IF (is_anchor_force_channel(lo)) THEN + line_id = anchor_force_line_id(channels(i)) ELSE IF (is_endpoint_angle_channel(lo)) THEN line_id = endpoint_angle_line_id(channels(i)) ELSE @@ -25471,13 +25496,17 @@ SUBROUTINE open_dynamic_hermite_line_outputs(out_root, lines, cables, pos_units, END DO END SUBROUTINE open_dynamic_hermite_line_outputs - SUBROUTINE write_dynamic_hermite_line_outputs(time, lines, cables, pos_units, ten_units, ErrStat, ErrMsg) + SUBROUTINE write_dynamic_hermite_line_outputs(time, lines, cables, pos_units, ten_units, ErrStat, ErrMsg, ranges) + !! One row of the per-line position and segment-tension files. ranges, when given, is the + !! range set sampled for this row by write_hermite_model_row: a line with a range graph + !! then reuses the segment tensions of that sample's recovery pass (range_sample_cable). REAL(wp), INTENT(IN) :: time TYPE(DeckLine), INTENT(IN) :: lines(:) TYPE(CD_HFMF_ModuleType), INTENT(IN) :: cables(:) INTEGER, INTENT(IN) :: pos_units(:), ten_units(:) INTEGER, INTENT(OUT) :: ErrStat CHARACTER(*), INTENT(OUT) :: ErrMsg + TYPE(CD_RangeSet), INTENT(IN), OPTIONAL :: ranges INTEGER :: i, node, inode, seg, k ErrStat = CD_DECKDRV_OK; ErrMsg = '' DO i = 1, SIZE(lines) @@ -25502,8 +25531,19 @@ SUBROUTINE write_dynamic_hermite_line_outputs(time, lines, cables, pos_units, te IF (ten_units(i) /= 0) THEN BLOCK REAL(wp) :: tension(cables(i)%line%ne) + LOGICAL :: shared + shared = .FALSE. + IF (PRESENT(ranges)) THEN + IF (CD_Range_Needs_Sample(ranges, i)) shared = ranges%lines(i)%want_range .AND. & + .NOT. cables(i)%line%output_element_recovery + END IF + IF (shared) THEN + tension = ranges%lines(i)%ten_e(cables(i)%line%ne:1:-1) + ELSE + CALL cable_segment_tensions(cables(i), tension, ErrStat, ErrMsg) + IF (ErrStat /= CD_DECKDRV_OK) RETURN + END IF DO seg = 1, cables(i)%line%ne - tension(seg) = cable_element_tension(cables(i), cables(i)%line%ne - seg + 1) IF (.NOT. IEEE_IS_FINITE(tension(seg))) THEN WRITE (ten_units(i), ROW_VALUES_FMT, ADVANCE='NO') time, (char_tab(), tension(k), k=1, seg - 1) CALL fail_solve(ErrStat, ErrMsg, 'non-finite Hermite line tension output'); RETURN @@ -27070,7 +27110,7 @@ SUBROUTINE build_plan() work%ch_kind(j) = CH_TDP work%ch_line(j) = il work%ch_comp(j) = comp - ELSE IF (is_point_force_channel(lo) .OR. is_object_channel(lo)) THEN + ELSE IF (is_point_force_channel(lo) .OR. is_object_channel(lo) .OR. is_anchor_force_channel(lo)) THEN CYCLE ! evaluated channel-at-a-time (CH_LEGACY) ELSE IF (is_point_channel(lo)) THEN CALL parse_point_channel(channels(j), pidx, comp) @@ -27311,6 +27351,15 @@ SUBROUTINE system_channel_value(ch, lines, points, system, work, val, ErrStat, E ErrMsg = 'CableDyn_DeckDriver: system dynamic end-tension recovery failed: '//TRIM(em) RETURN END IF + ELSE IF (is_anchor_force_channel(lo)) THEN + ! a component of the AnchTen end force (End B = internal first node) + li = find_line(lines, anchor_force_line_id(ch)) + CALL line_model_anchor_force(system%lines(li), lo, val, es, em) + IF (es /= CD_DECKDRV_OK) THEN + ErrStat = CD_DECKDRV_SOLVEFAIL + ErrMsg = 'CableDyn_DeckDriver: system dynamic end-force recovery failed: '//TRIM(em) + RETURN + END IF ELSE IF (is_endpoint_angle_channel(lo)) THEN li = find_line(lines, endpoint_angle_line_id(ch)) ndof = CD_System_Line_NDOF(system, li, es, em) @@ -27433,6 +27482,12 @@ SUBROUTINE finite_model_channel_value(ch, lines, points, models, work, val, ErrS 'two-moving-end finite-EI route (use FairTen/AnchTen)') RETURN END IF + ! this route reports the axial chord-stretch tension of the end elements, not an end-force vector + IF (is_anchor_force_channel(lo)) THEN + CALL fail(ErrStat, ErrMsg, 'OUTPUT "'//TRIM(ch)//'": AnchFz/AnchFH channels are not available on the '// & + 'two-moving-end finite-EI route (use AnchTen and AnchIncl)') + RETURN + END IF IF (starts_with(lo, 'fairten') .OR. starts_with(lo, 'anchten')) THEN li = find_line(lines, int_suffix(ch, 8)) CALL ensure_model_output_workspace(work, 0, models(li)%n_elem) @@ -27618,6 +27673,15 @@ SUBROUTINE model_channel_value(ch, lines, points, models, work, val, ErrStat, Er ErrMsg = 'CableDyn_DeckDriver: dynamic end-tension recovery failed: '//TRIM(em) RETURN END IF + ELSE IF (is_anchor_force_channel(lo)) THEN + ! a component of the AnchTen end force (End B = internal first node) + li = find_line(lines, anchor_force_line_id(ch)) + CALL line_model_anchor_force(models(li), lo, val, es, em) + IF (es /= CD_DECKDRV_OK) THEN + ErrStat = CD_DECKDRV_SOLVEFAIL + ErrMsg = 'CableDyn_DeckDriver: dynamic end-force recovery failed: '//TRIM(em) + RETURN + END IF ELSE IF (is_endpoint_angle_channel(lo)) THEN li = find_line(lines, endpoint_angle_line_id(ch)) ndof = CD_Model_NDOF(models(li), es, em) @@ -29250,6 +29314,17 @@ REAL(wp) FUNCTION channel_value(ch, lines, points, ne, q_all, q_off, ten_all, te ELSE v = ten_all(ten_off(li) + 1) ! deck End B anchor = internal first element END IF + ELSE IF (is_anchor_force_channel(lo)) THEN + ! a component of the AnchTen end force; without end_force, of the anchor element's pull + ! on the anchor node (its tension along the element, toward the internal second node) + li = find_line(lines, anchor_force_line_id(ch)) + IF (PRESENT(end_force)) THEN + fsum = end_force(:, 1, li) + ELSE + fsum = q_all(q_off(li) + 4:q_off(li) + 6) - q_all(q_off(li) + 1:q_off(li) + 3) + IF (NORM2(fsum) > CD_ZERO) fsum = ten_all(ten_off(li) + 1)*fsum/NORM2(fsum) + END IF + v = anchor_force_component(lo, fsum) ELSE IF (is_endpoint_angle_channel(lo)) THEN li = find_line(lines, endpoint_angle_line_id(ch)) IF (is_fair_endpoint_angle(lo)) THEN @@ -29339,6 +29414,10 @@ SUBROUTINE check_channel(ch, lines, points, sections, ErrStat, ErrMsg, bodies, r IF (find_line(lines, int_suffix(ch, 8)) == 0) THEN CALL fail(ErrStat, ErrMsg, 'OUTPUT "'//TRIM(ch)//'": unknown line id'); RETURN END IF + ELSE IF (is_anchor_force_channel(lo)) THEN + IF (find_line(lines, anchor_force_line_id(ch)) == 0) THEN + CALL fail(ErrStat, ErrMsg, 'OUTPUT "'//TRIM(ch)//'": unknown line id'); RETURN + END IF ELSE IF (is_endpoint_angle_channel(lo)) THEN IF (find_line(lines, endpoint_angle_line_id(ch)) == 0) THEN CALL fail(ErrStat, ErrMsg, 'OUTPUT "'//TRIM(ch)//'": unknown line id'); RETURN @@ -29352,7 +29431,7 @@ SUBROUTINE check_channel(ch, lines, points, sections, ErrStat, ErrMsg, bodies, r CALL CD_Parse_TDP_Channel(ch, line_id, comp) IF (comp < 1) THEN CALL fail(ErrStat, ErrMsg, 'OUTPUT "'//TRIM(ch)//'": bad touchdown channel (use TDPs, TDPx, '// & - 'TDPy, TDPz, TDPLay or TDPExc)'); RETURN + 'TDPy, TDPz, TDPLay, TDPExc or TDPGrd)'); RETURN END IF IF (find_line(lines, line_id) == 0) THEN CALL fail(ErrStat, ErrMsg, 'OUTPUT "'//TRIM(ch)//'": unknown line id'); RETURN @@ -29399,12 +29478,12 @@ SUBROUTINE check_channel(ch, lines, points, sections, ErrStat, ErrMsg, bodies, r END IF ELSE CALL fail(ErrStat, ErrMsg, 'OUTPUT channel "'//TRIM(ch)// & - '" not supported (use FairTen, AnchTen, FairIncl, AnchIncl, '// & + '" not supported (use FairTen, AnchTen, AnchFz, AnchFH, FairIncl, AnchIncl, '// & 'FairDecl, AnchDecl (FairAngle/AnchAngle aliases), '// & 'Point

p{x,y,z} (alias Con

p{x,y,z}), Point

F{x,y,z,H}, '// & 'TenN, CurvN, BendMomN, TorqN, TwistN, Twist, '// & 'LNp{x,y,z}, LNv{x,y,z}, LNa{x,y,z}, LNDec, LNAzi, '// & - 'TDP{s,x,y,z,Lay,Exc}, or the Body/Rod channels)'); RETURN + 'TDP{s,x,y,z,Lay,Exc,Grd}, or the Body/Rod channels)'); RETURN END IF END SUBROUTINE check_channel @@ -29436,6 +29515,55 @@ LOGICAL FUNCTION is_point_channel(lo) RESULT(is_point) IF (starts_with(lo, 'con') .AND. LEN(lo) >= 4) is_point = VERIFY(lo(4:4), '0123456789') == 0 END FUNCTION is_point_channel + LOGICAL FUNCTION is_anchor_force_channel(lo) RESULT(yes) + !! AnchFz / AnchFH (lower case): the vertical component and the horizontal magnitude + !! of the AnchTen end force, the force line L exerts on its End-B point. + CHARACTER(*), INTENT(IN) :: lo + yes = starts_with(lo, 'anchfz') .OR. starts_with(lo, 'anchfh') + END FUNCTION is_anchor_force_channel + + INTEGER FUNCTION anchor_force_line_id(ch) RESULT(line_id) + !! Deck line id of an AnchFz / AnchFH name; 0 when the suffix is not a positive id. + CHARACTER(*), INTENT(IN) :: ch + line_id = int_suffix(ch, 7) + END FUNCTION anchor_force_line_id + + REAL(wp) FUNCTION anchor_force_component(lo, force) RESULT(v) + !! AnchFz (force(3), positive upward: the line lifts its anchor) or AnchFH (horizontal + !! magnitude) of the global end-B force vector `force` the line exerts on its anchor. + CHARACTER(*), INTENT(IN) :: lo + REAL(wp), INTENT(IN) :: force(3) + IF (starts_with(lo, 'anchfz')) THEN + v = force(3) + ELSE + v = SQRT(force(1)**2 + force(2)**2) + END IF + END FUNCTION anchor_force_component + + SUBROUTINE line_model_anchor_force(model, lo, val, ErrStat, ErrMsg) + !! AnchFz / AnchFH of an EI=0 line model: a component of the force the line exerts on the + !! point holding its internal first node (deck End B), the vector whose norm is AnchTen. + TYPE(CD_ModelType), INTENT(IN) :: model + CHARACTER(*), INTENT(IN) :: lo + REAL(wp), INTENT(OUT) :: val + INTEGER, INTENT(OUT) :: ErrStat + CHARACTER(*), INTENT(OUT) :: ErrMsg + REAL(wp) :: f_first(3), f_last(3) + INTEGER :: es + CHARACTER(160) :: em + + val = CD_ZERO + ErrStat = CD_DECKDRV_OK + ErrMsg = '' + CALL CD_Get_Model_EndForces(model, f_first, f_last, es, em) + IF (es /= CD_MODEL_OK) THEN + ErrStat = CD_DECKDRV_SOLVEFAIL + ErrMsg = em + RETURN + END IF + val = anchor_force_component(lo, f_first) + END SUBROUTINE line_model_anchor_force + LOGICAL FUNCTION is_point_force_channel(lo) RESULT(yes) !! Point

F{x,y,z} / Point

FH: the resultant of the line-end forces on point P. CHARACTER(*), INTENT(IN) :: lo @@ -30444,10 +30572,12 @@ SUBROUTINE range_sample_fmodel(fmodel, rl, ErrStat, ErrMsg) END SUBROUTINE range_sample_fmodel SUBROUTINE range_sample_cable(cable, rl, ErrStat, ErrMsg) - !! Sample a cubic-Hermite cable with the evaluators of eval_cable_channel: end-force - !! tension at the ends and the length-weighted element-mean axial force inside, the - !! larger one-sided exact curvature and EI * curvature traces, and the declination of - !! the cable-local state; positions are rotated into the deck's global frame. + !! Sample a cubic-Hermite cable with the definitions of eval_cable_channel: the node + !! tension, curvature and bend moment recovered from nodal equilibrium in one pass + !! (OutputRecovery element: end-force tension at the ends, the length-weighted element-mean + !! axial force inside, the larger one-sided exact curvature and EI * curvature traces), and + !! the declination of the cable-local state; positions are rotated into the deck's global + !! frame. TYPE(CD_HFMF_ModuleType), INTENT(IN) :: cable TYPE(CD_RangeLine), INTENT(INOUT) :: rl INTEGER, INTENT(OUT) :: ErrStat @@ -30479,38 +30609,20 @@ SUBROUTINE range_sample_cable(cable, rl, ErrStat, ErrMsg) END DO END DO IF (.NOT. rl%want_range) RETURN ! a touchdown-only line needs the positions alone - ! element traces: mean axial force, curvature at xi = 0 (vs) and xi = 1 (as) - DO e = 1, ne - rl%ten_e(e) = cable_element_mean_tension(cable, e) - CALL cable_element_curvature(cable, e, CD_ZERO, rl%vs(e), es, em) - IF (es == CD_HCABLE_OK) CALL cable_element_curvature(cable, e, CD_ONE, rl%as(e), es, em) - IF (es /= CD_HCABLE_OK) THEN - CALL fail_solve(ErrStat, ErrMsg, 'range-graph curvature sample failed: '//TRIM(em)); RETURN - END IF - END DO - DO j = 1, nn - inode = nn + 1 - j - IF (inode == 1 .OR. inode == nn) THEN - CALL cable_end_tension(cable, inode, rl%val(CD_RQ_TENSION, j), ErrStat, ErrMsg) - IF (ErrStat /= CD_DECKDRV_OK) RETURN - ELSE - rl%val(CD_RQ_TENSION, j) = (cable%line%l0(inode - 1)*rl%ten_e(inode - 1) + & - cable%line%l0(inode)*rl%ten_e(inode))/ & - (cable%line%l0(inode - 1) + cable%line%l0(inode)) - END IF - curv = CD_ZERO - bend = CD_ZERO - IF (inode > 1) THEN - curv = MAX(curv, rl%as(inode - 1)) - bend = MAX(bend, cable%line%EI(inode - 1)*rl%as(inode - 1)) - END IF - IF (inode <= ne) THEN - curv = MAX(curv, rl%vs(inode)) - bend = MAX(bend, cable%line%EI(inode)*rl%vs(inode)) + IF (.NOT. cable%line%output_element_recovery) THEN + ! equilibrium node values, one pass over the elements straight into the public-order rows + ! (internal node i is public node nn + 1 - i); the segment tensions (internal order) stay + ! in rl%ten_e for the .t.out row + CALL CD_HermiteCable_Dyn_Node_Recovery(cable%line, es, em, tension=rl%val(CD_RQ_TENSION, nn:1:-1), & + curvature=rl%val(CD_RQ_CURVATURE, nn:1:-1), & + bend_moment=rl%val(CD_RQ_BEND, nn:1:-1), segment_tension=rl%ten_e) + IF (es /= CD_HCDYN_OK) THEN + CALL fail_solve(ErrStat, ErrMsg, 'range-graph node-value recovery failed: '//TRIM(em)); RETURN END IF - rl%val(CD_RQ_CURVATURE, j) = curv - rl%val(CD_RQ_BEND, j) = bend - END DO + ELSE + CALL range_sample_cable_element(ErrStat, ErrMsg) + IF (ErrStat /= CD_DECKDRV_OK) RETURN + END IF IF (rl%has_torsion .AND. cable%line%torsion%active) THEN ! condensed torsion: the committed torque (uniform) and the cable's own twist from End A ! (public node 1, the last internal node), as the TorqN and TwistN channels @@ -30522,6 +30634,49 @@ SUBROUTINE range_sample_cable(cable, rl, ErrStat, ErrMsg) cable%line%l0(inode)/cable%line%torsion%gj(inode)*45.0_wp/QUARTER_PI END DO END IF + + CONTAINS + + SUBROUTINE range_sample_cable_element(ErrStat, ErrMsg) + !! OutputRecovery element: end-force tension at the ends and the length-weighted + !! element-mean axial force inside, the larger one-sided exact curvature and EI * curvature. + INTEGER, INTENT(OUT) :: ErrStat + CHARACTER(*), INTENT(OUT) :: ErrMsg + ErrStat = CD_DECKDRV_OK + ErrMsg = '' + ! element traces: mean axial force, curvature at xi = 0 (vs) and xi = 1 (as) + DO e = 1, ne + rl%ten_e(e) = cable_element_mean_tension(cable, e) + CALL cable_element_curvature(cable, e, CD_ZERO, rl%vs(e), es, em) + IF (es == CD_HCABLE_OK) CALL cable_element_curvature(cable, e, CD_ONE, rl%as(e), es, em) + IF (es /= CD_HCABLE_OK) THEN + CALL fail_solve(ErrStat, ErrMsg, 'range-graph curvature sample failed: '//TRIM(em)); RETURN + END IF + END DO + DO j = 1, nn + inode = nn + 1 - j + IF (inode == 1 .OR. inode == nn) THEN + CALL cable_end_tension(cable, inode, rl%val(CD_RQ_TENSION, j), ErrStat, ErrMsg) + IF (ErrStat /= CD_DECKDRV_OK) RETURN + ELSE + rl%val(CD_RQ_TENSION, j) = (cable%line%l0(inode - 1)*rl%ten_e(inode - 1) + & + cable%line%l0(inode)*rl%ten_e(inode))/ & + (cable%line%l0(inode - 1) + cable%line%l0(inode)) + END IF + curv = CD_ZERO + bend = CD_ZERO + IF (inode > 1) THEN + curv = MAX(curv, rl%as(inode - 1)) + bend = MAX(bend, cable%line%EI(inode - 1)*rl%as(inode - 1)) + END IF + IF (inode <= ne) THEN + curv = MAX(curv, rl%vs(inode)) + bend = MAX(bend, cable%line%EI(inode)*rl%vs(inode)) + END IF + rl%val(CD_RQ_CURVATURE, j) = curv + rl%val(CD_RQ_BEND, j) = bend + END DO + END SUBROUTINE range_sample_cable_element END SUBROUTINE range_sample_cable SUBROUTINE aggregate_line_positions(system, cables, line_is_cable, line_obj_index, line_id, r, ErrStat, ErrMsg) @@ -30870,6 +31025,8 @@ SUBROUTINE CD_Eval_Aggregate_Channel(ch, has_sys, system, cables, line_is_cable, ! Resolve the channel's deck line id; every other line-node token uses its own parser. IF (starts_with(lo, 'fairten') .OR. starts_with(lo, 'anchten')) THEN line_id = int_suffix(ch, 8) + ELSE IF (is_anchor_force_channel(lo)) THEN + line_id = anchor_force_line_id(ch) ELSE IF (is_endpoint_angle_channel(lo)) THEN line_id = endpoint_angle_line_id(ch) ELSE @@ -30915,7 +31072,7 @@ SUBROUTINE CD_Eval_Aggregate_Segment_Tensions(line_id, has_sys, system, cables, INTEGER, INTENT(OUT) :: ErrStat CHARACTER(*), INTENT(OUT) :: ErrMsg - INTEGER :: obj, ne, seg, es + INTEGER :: obj, ne, es CHARACTER(200) :: em ErrStat = CD_DECKDRV_OK @@ -30939,9 +31096,7 @@ SUBROUTINE CD_Eval_Aggregate_Segment_Tensions(line_id, has_sys, system, cables, IF (SIZE(tension) /= ne) THEN CALL fail(ErrStat, ErrMsg, 'segment tensions: output size does not match the element count'); RETURN END IF - DO seg = 1, ne - tension(seg) = cable_element_tension(cables(obj), ne - seg + 1) - END DO + CALL cable_segment_tensions(cables(obj), tension, ErrStat, ErrMsg) RETURN END IF IF (.NOT. has_sys) THEN @@ -31035,6 +31190,8 @@ LOGICAL FUNCTION CD_Channel_Token_Parses(ch) RESULT(ok) ok = LEN_TRIM(lo) > 7 IF (ok) ok = VERIFY(lo(8:LEN_TRIM(lo)), '0123456789') == 0 IF (ok) ok = int_suffix(ch, 8) > 0 + ELSE IF (is_anchor_force_channel(lo)) THEN + ok = anchor_force_line_id(ch) > 0 ELSE IF (is_endpoint_angle_channel(lo)) THEN ok = endpoint_angle_line_id(ch) > 0 ELSE @@ -31109,6 +31266,14 @@ SUBROUTINE eval_system_line_channel(system, li, ch, val, ErrStat, ErrMsg) END IF RETURN END IF + IF (is_anchor_force_channel(lo)) THEN + ! a component of the AnchTen end force (End B = internal first node) + CALL line_model_anchor_force(system%lines(li), lo, val, es, em) + IF (es /= CD_DECKDRV_OK) THEN + CALL sys_solvefail(ch, em, ErrStat, ErrMsg); RETURN + END IF + RETURN + END IF ndof = CD_System_Line_NDOF(system, li, es, em) IF (es /= CD_SYSTEM_OK) THEN CALL sys_solvefail(ch, em, ErrStat, ErrMsg); RETURN @@ -31196,6 +31361,7 @@ SUBROUTINE eval_cable_channel(cable, ch, val, ErrStat, ErrMsg) CHARACTER(NAMELEN) :: lo INTEGER :: line_id, node, kind, comp, nnode, nelem, inode, es + REAL(wp) :: sec_ten, sec_curv, sec_bend CHARACTER(200) :: em ErrStat = CD_DECKDRV_OK @@ -31213,6 +31379,19 @@ SUBROUTINE eval_cable_channel(cable, ch, val, ErrStat, ErrMsg) ELSE IF (starts_with(lo, 'anchten')) THEN CALL cable_end_tension(cable, 1, val, ErrStat, ErrMsg) RETURN + ELSE IF (is_anchor_force_channel(lo)) THEN + ! a component of the AnchTen end force; Fz and the horizontal magnitude do not depend on + ! the cable's frame heading about +z + BLOCK + REAL(wp) :: force(3) + CALL CD_HermiteCable_Dyn_End_Force(cable%line, 1, force, es, em) + IF (es /= CD_HCDYN_OK) THEN + CALL fail_solve(ErrStat, ErrMsg, 'OUTPUT "'//TRIM(ch)//'": finite-EI end-force recovery failed: '// & + TRIM(em)); RETURN + END IF + val = anchor_force_component(lo, force) + END BLOCK + RETURN ELSE IF (is_endpoint_angle_channel(lo)) THEN IF (is_fair_endpoint_angle(lo)) THEN val = line_geom_value(7, 1, nnode, cable%line%q(1:6*nnode), 6) @@ -31233,15 +31412,16 @@ SUBROUTINE eval_cable_channel(cable, ch, val, ErrStat, ErrMsg) IF (inode == 1 .OR. inode == nnode) THEN ! a line end: the same support-reaction tension as FairTen/AnchTen CALL cable_end_tension(cable, inode, val, ErrStat, ErrMsg) - ELSE - ! Segment tension, as the EI=0 nodal channel: the length-weighted average of - ! the two adjacent element-mean axial forces. The pointwise resultant at the - ! node is not reported: with a stiff EA it oscillates about the element mean - ! wherever an element cannot follow the line (a nodal seabed-contact kink, a - ! section junction), by up to several times the line tension at any mesh. + ELSE IF (cable%line%output_element_recovery) THEN + ! OutputRecovery element: the length-weighted average of the two adjacent + ! element-mean axial forces EA (|r'| - 1) val = (cable%line%l0(inode - 1)*cable_element_mean_tension(cable, inode - 1) + & cable%line%l0(inode)*cable_element_mean_tension(cable, inode))/ & (cable%line%l0(inode - 1) + cable%line%l0(inode)) + ELSE + ! effective tension from nodal equilibrium (CD_HermiteCable_Dyn_Node_Recovery) + CALL cable_node_values(cable, inode, val, sec_curv, sec_bend, ErrStat, ErrMsg) + IF (ErrStat /= CD_DECKDRV_OK) RETURN END IF END BLOCK CASE (1) ! position (cable-local state rotated to the deck's global frame) @@ -31250,12 +31430,20 @@ SUBROUTINE eval_cable_channel(cable, ch, val, ErrStat, ErrMsg) val = cable_global_component(cable, cable%line%v(6*(inode - 1) + 1:6*(inode - 1) + 3), comp) CASE (4) ! acceleration val = cable_global_component(cable, cable%line%a(6*(inode - 1) + 1:6*(inode - 1) + 3), comp) - CASE (5) ! exact Hermite curvature, retaining the larger interface trace + CASE (5) ! curvature: recovered bend moment / EI, or the larger exact one-sided trace + IF (.NOT. cable%line%output_element_recovery) THEN + CALL cable_node_values(cable, inode, sec_ten, val, sec_bend, ErrStat, ErrMsg) + RETURN + END IF CALL cable_nodal_curvature(cable, inode, val, es, em) IF (es /= CD_HCABLE_OK) THEN CALL fail_solve(ErrStat, ErrMsg, 'OUTPUT "'//TRIM(ch)//'": '//TRIM(em)); RETURN END IF - CASE (6) ! exact |EI*kappa|, retaining the larger interface trace + CASE (6) ! bend moment: recovered from nodal equilibrium, or EI times the larger exact trace + IF (.NOT. cable%line%output_element_recovery) THEN + CALL cable_node_values(cable, inode, sec_ten, sec_curv, val, ErrStat, ErrMsg) + RETURN + END IF CALL cable_nodal_bend_moment(cable, inode, val, es, em) IF (es /= CD_HCABLE_OK) THEN CALL fail_solve(ErrStat, ErrMsg, 'OUTPUT "'//TRIM(ch)//'": '//TRIM(em)); RETURN @@ -31411,6 +31599,44 @@ SUBROUTINE cable_end_tension(cable, inode, tension, ErrStat, ErrMsg) tension = NORM2(force) END SUBROUTINE cable_end_tension + SUBROUTINE cable_node_values(cable, inode, tension, curvature, bend_moment, ErrStat, ErrMsg) + !! Equilibrium node values of a finite-EI cable at internal node inode + !! (CD_HermiteCable_Dyn_Node_Values): effective tension, curvature and bend moment. + TYPE(CD_HFMF_ModuleType), INTENT(IN) :: cable + INTEGER, INTENT(IN) :: inode + REAL(wp), INTENT(OUT) :: tension, curvature, bend_moment + INTEGER, INTENT(OUT) :: ErrStat + CHARACTER(*), INTENT(OUT) :: ErrMsg + INTEGER :: es + CHARACTER(200) :: em + ErrStat = CD_DECKDRV_OK; ErrMsg = '' + CALL CD_HermiteCable_Dyn_Node_Values(cable%line, inode, tension, curvature, bend_moment, es, em) + IF (es /= CD_HCDYN_OK) CALL fail_solve(ErrStat, ErrMsg, 'finite-EI node-value recovery failed: '//TRIM(em)) + END SUBROUTINE cable_node_values + + SUBROUTINE cable_segment_tensions(cable, tension, ErrStat, ErrMsg) + !! Segment tensions of a finite-EI cable in public order (segment 1 at End A): the mean of + !! the axial components of each element's own equilibrium end forces, in one pass + !! (CD_HermiteCable_Dyn_Node_Recovery); OutputRecovery element: the axial resultant at the + !! element midpoint. + TYPE(CD_HFMF_ModuleType), INTENT(IN) :: cable + REAL(wp), INTENT(OUT) :: tension(:) + INTEGER, INTENT(OUT) :: ErrStat + CHARACTER(*), INTENT(OUT) :: ErrMsg + INTEGER :: ne, e, es + CHARACTER(200) :: em + ErrStat = CD_DECKDRV_OK; ErrMsg = '' + ne = cable%line%ne + IF (cable%line%output_element_recovery) THEN + DO e = 1, ne + tension(e) = cable_element_tension(cable, ne - e + 1) + END DO + RETURN + END IF + CALL CD_HermiteCable_Dyn_Node_Recovery(cable%line, es, em, segment_tension=tension(ne:1:-1)) + IF (es /= CD_HCDYN_OK) CALL fail_solve(ErrStat, ErrMsg, 'finite-EI segment-tension recovery failed: '//TRIM(em)) + END SUBROUTINE cable_segment_tensions + SUBROUTINE cable_nodal_curvature(cable, inode, curvature, ErrStat, ErrMsg) !! Exact one-sided Hermite curvature traces at an internal line node. Curvature !! need not be continuous across a material interface because the interpolation @@ -31487,8 +31713,8 @@ END SUBROUTINE cable_element_curvature FUNCTION CD_Channel_Unit(ch) RESULT(unit) !! OrcaFlex-vocabulary output unit for a channel token, by kind: tension (FairTen/AnchTen/Ten) - !! -> (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); + !! 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); !! velocity (...v) -> (m/s); !! acceleration (...a) -> (m/s2). CHARACTER(*), INTENT(IN) :: ch @@ -31510,7 +31736,7 @@ FUNCTION CD_Channel_Unit(ch) RESULT(unit) CASE (22:24); unit = '(N.m)' CASE DEFAULT; unit = '(-)' END SELECT - ELSE IF (starts_with(lo, 'fairten') .OR. starts_with(lo, 'anchten')) THEN + ELSE IF (starts_with(lo, 'fairten') .OR. starts_with(lo, 'anchten') .OR. is_anchor_force_channel(lo)) THEN unit = '(N)' ELSE IF (is_endpoint_angle_channel(lo)) THEN unit = '(deg)' diff --git a/src/CableDyn_HermiteCableDynamic.f90 b/src/CableDyn_HermiteCableDynamic.f90 index c039dd69..661767ec 100644 --- a/src/CableDyn_HermiteCableDynamic.f90 +++ b/src/CableDyn_HermiteCableDynamic.f90 @@ -121,6 +121,10 @@ MODULE CableDyn_HermiteCableDynamic PUBLIC :: CD_HermiteCable_Dyn_Energy PUBLIC :: CD_HermiteCable_Dyn_Curvature PUBLIC :: CD_HermiteCable_Dyn_Reaction + PUBLIC :: CD_HermiteCable_Dyn_Curvature_Exact + PUBLIC :: CD_HermiteCable_Dyn_Set_Output_Recovery + PUBLIC :: CD_HermiteCable_Dyn_Node_Recovery + PUBLIC :: CD_HermiteCable_Dyn_Node_Values PUBLIC :: CD_HermiteCable_Dyn_End_Force PUBLIC :: CD_HermiteCable_Dyn_Set_ForceBlend PUBLIC :: CD_HermiteCable_Dyn_Max_Step_Rotation @@ -412,6 +416,9 @@ MODULE CableDyn_HermiteCableDynamic REAL(wp) :: tensile_worst_force = CD_ZERO, tensile_worst_threshold = CD_ZERO REAL(wp) :: tensile_worst_xi = CD_ZERO, tensile_worst_time = CD_ZERO INTEGER :: recovery_event_count = 0, recovery_max_substeps_used = 0 + ! Node output definitions (CD_HermiteCable_Dyn_Set_Output_Recovery): equilibrium recovery + ! by default, the element-mean axial force and exact curvature traces when set. + LOGICAL :: output_element_recovery = .FALSE. LOGICAL :: initialized = .FALSE. END TYPE CD_HermiteCableDynType @@ -4417,7 +4424,32 @@ SUBROUTINE CD_HermiteCable_Dyn_Energy(model, kinetic, strain, ErrStat, ErrMsg, c END SUBROUTINE CD_HermiteCable_Dyn_Energy SUBROUTINE CD_HermiteCable_Dyn_Curvature(model, curv_out, ErrStat, ErrMsg) - !! Per-node centreline curvature at the current state (element-midpoint / endpoint maxima). + !! Per-node curvature at the current state, the definition of the CurvN channels: the + !! bend moment recovered from nodal equilibrium over EI (CD_HermiteCable_Dyn_Node_Recovery), + !! or, under CD_HermiteCable_Dyn_Set_Output_Recovery(.TRUE.), the exact one-sided traces of + !! CD_HermiteCable_Dyn_Curvature_Exact. + TYPE(CD_HermiteCableDynType), INTENT(IN) :: model + REAL(wp), INTENT(OUT) :: curv_out(:) + INTEGER, INTENT(OUT) :: ErrStat + CHARACTER(*), INTENT(OUT) :: ErrMsg + ErrStat = CD_HCDYN_OK; ErrMsg = '' + IF (model%output_element_recovery) THEN + CALL CD_HermiteCable_Dyn_Curvature_Exact(model, curv_out, ErrStat, ErrMsg) + RETURN + END IF + IF (.NOT. model%initialized) THEN + ErrStat = CD_HCDYN_BADINPUT; ErrMsg = 'CD_HermiteCable_Dyn_Curvature: model not initialised'; RETURN + END IF + IF (SIZE(curv_out) /= model%nn) THEN + ErrStat = CD_HCDYN_BADINPUT; ErrMsg = 'CD_HermiteCable_Dyn_Curvature: curv_out must be nn'; RETURN + END IF + CALL CD_HermiteCable_Dyn_Node_Recovery(model, ErrStat, ErrMsg, curvature=curv_out) + END SUBROUTINE CD_HermiteCable_Dyn_Curvature + + SUBROUTINE CD_HermiteCable_Dyn_Curvature_Exact(model, curv_out, ErrStat, ErrMsg) + !! Per-node geometric curvature of the cubic-Hermite centreline at the current state: the + !! exact curvature of the element interpolation at the node, the larger of the two + !! one-sided traces at an interior node (the curvature is discontinuous there). TYPE(CD_HermiteCableDynType), INTENT(IN) :: model REAL(wp), INTENT(OUT) :: curv_out(:) INTEGER, INTENT(OUT) :: ErrStat @@ -4427,10 +4459,10 @@ SUBROUTINE CD_HermiteCable_Dyn_Curvature(model, curv_out, ErrStat, ErrMsg) CHARACTER(200) :: em2 ErrStat = CD_HCDYN_OK; ErrMsg = '' IF (.NOT. model%initialized) THEN - ErrStat = CD_HCDYN_BADINPUT; ErrMsg = 'CD_HermiteCable_Dyn_Curvature: model not initialised'; RETURN + ErrStat = CD_HCDYN_BADINPUT; ErrMsg = 'CD_HermiteCable_Dyn_Curvature_Exact: model not initialised'; RETURN END IF IF (SIZE(curv_out) /= model%nn) THEN - ErrStat = CD_HCDYN_BADINPUT; ErrMsg = 'CD_HermiteCable_Dyn_Curvature: curv_out must be nn'; RETURN + ErrStat = CD_HCDYN_BADINPUT; ErrMsg = 'CD_HermiteCable_Dyn_Curvature_Exact: curv_out must be nn'; RETURN END IF DO a = 1, model%nn curv_out(a) = CD_ZERO @@ -4441,7 +4473,7 @@ SUBROUTINE CD_HermiteCable_Dyn_Curvature(model, curv_out, ErrStat, ErrMsg) CALL gather_elem(model, a, qe) CALL CD_HermiteCable_Curvature(qe, model%l0(a), CD_ZERO, kR, es, em2) IF (es /= CD_HCABLE_OK) THEN - ErrStat = CD_HCDYN_NOCONVERGE; ErrMsg = 'CD_HermiteCable_Dyn_Curvature: '//TRIM(em2); RETURN + ErrStat = CD_HCDYN_NOCONVERGE; ErrMsg = 'CD_HermiteCable_Dyn_Curvature_Exact: '//TRIM(em2); RETURN END IF curv_out(a) = kR END IF @@ -4449,12 +4481,12 @@ SUBROUTINE CD_HermiteCable_Dyn_Curvature(model, curv_out, ErrStat, ErrMsg) CALL gather_elem(model, a - 1, qe) CALL CD_HermiteCable_Curvature(qe, model%l0(a - 1), CD_ONE, kL, es, em2) IF (es /= CD_HCABLE_OK) THEN - ErrStat = CD_HCDYN_NOCONVERGE; ErrMsg = 'CD_HermiteCable_Dyn_Curvature: '//TRIM(em2); RETURN + ErrStat = CD_HCDYN_NOCONVERGE; ErrMsg = 'CD_HermiteCable_Dyn_Curvature_Exact: '//TRIM(em2); RETURN END IF curv_out(a) = MAX(curv_out(a), kL) END IF END DO - END SUBROUTINE CD_HermiteCable_Dyn_Curvature + END SUBROUTINE CD_HermiteCable_Dyn_Curvature_Exact SUBROUTINE CD_HermiteCable_Dyn_Reaction(model, node, freac, ErrStat, ErrMsg) !! Constraint reaction at a fixed/prescribed node: the force the LINE exerts ON its @@ -4682,6 +4714,425 @@ SUBROUTINE CD_HermiteCable_Dyn_End_Force(model, node, force, ErrStat, ErrMsg) force(3) = MAX(force(3), CD_ZERO) END SUBROUTINE CD_HermiteCable_Dyn_End_Force + SUBROUTINE CD_HermiteCable_Dyn_Set_Output_Recovery(model, element_recovery) + !! Definition of the node tension, curvature and bend moment (OPTIONS OutputRecovery). + !! .FALSE. (equilibrium, the default): recovered from nodal equilibrium + !! (CD_HermiteCable_Dyn_Node_Recovery). .TRUE. (element): the element-mean axial force + !! EA (|r'| - 1) and the exact one-sided curvature traces of the element interpolation. + TYPE(CD_HermiteCableDynType), INTENT(INOUT) :: model + LOGICAL, INTENT(IN) :: element_recovery + model%output_element_recovery = element_recovery + END SUBROUTINE CD_HermiteCable_Dyn_Set_Output_Recovery + + SUBROUTINE CD_HermiteCable_Dyn_Node_Values(model, node, tension, curvature, bend_moment, ErrStat, ErrMsg) + !! Equilibrium node values at one node (internal order), from the two adjacent elements; + !! the same values as CD_HermiteCable_Dyn_Node_Recovery returns for that node. + TYPE(CD_HermiteCableDynType), INTENT(IN) :: model + INTEGER, INTENT(IN) :: node + REAL(wp), INTENT(OUT) :: tension, curvature, bend_moment + INTEGER, INTENT(OUT) :: ErrStat + CHARACTER(*), INTENT(OUT) :: ErrMsg + REAL(wp) :: g(12), fm(3), mm(3), fp(3), mp(3) + + ErrStat = CD_HCDYN_OK; ErrMsg = '' + tension = CD_ZERO; curvature = CD_ZERO; bend_moment = CD_ZERO + IF (.NOT. model%initialized) THEN + ErrStat = CD_HCDYN_BADINPUT; ErrMsg = 'CD_HermiteCable_Dyn_Node_Values: model not initialised'; RETURN + END IF + IF (node < 1 .OR. node > model%nn) THEN + ErrStat = CD_HCDYN_BADINPUT; ErrMsg = 'CD_HermiteCable_Dyn_Node_Values: node out of range'; RETURN + END IF + fm = CD_ZERO; mm = CD_ZERO; fp = CD_ZERO; mp = CD_ZERO + IF (node > 1) THEN + CALL element_end_residual(model, node - 1, g, ErrStat, ErrMsg) + IF (ErrStat /= CD_HCDYN_OK) RETURN + fm = g(7:9); mm = g(10:12) + END IF + IF (node < model%nn) THEN + CALL element_end_residual(model, node, g, ErrStat, ErrMsg) + IF (ErrStat /= CD_HCDYN_OK) RETURN + fp = -g(1:3); mp = -g(4:6) + END IF + CALL node_values(model, node, fm, mm, fp, mp, tension, curvature, bend_moment, ErrStat, ErrMsg) + END SUBROUTINE CD_HermiteCable_Dyn_Node_Values + + SUBROUTINE CD_HermiteCable_Dyn_Node_Recovery(model, ErrStat, ErrMsg, tension, curvature, bend_moment, & + segment_tension) + !! Effective tension, curvature and bend moment at every node (internal order) recovered + !! from nodal equilibrium, in one pass over the elements. + !! + !! For element e the end residual g_e = f_int + f_damp - f_ext + M_e a_e holds the element's + !! own distributed loads (consistent submerged weight, dry-part buoyancy, drag, + !! Froude-Krylov force, the seabed contact of its end nodes spread over their tributary + !! lengths, and the structural and added-mass inertia): it is the generalized force the two + !! end nodes exert on the element. Its position rows on the End-B side (internal node e+1) + !! are the section force just before that node, minus its rows on the End-A side the + !! section force just after node e; its tangent rows are the conjugate of the material + !! tangent, EI r'' at the node. An interior node reports the mean of its two one-sided + !! values, whose difference is the point load left at the node, so the nodal section + !! forces satisfy the discrete equilibrium exactly and do not carry the pointwise + !! oscillation of the stiff-EA axial strain. + !! + !! tension(j) = t_j . F_j (t_j the unit nodal tangent; a line end reports the end force + !! magnitude of CD_HermiteCable_Dyn_End_Force), bend_moment(j) = |m_j - (m_j . t_j) t_j|, + !! curvature(j) = bend_moment(j)/EI, the larger of the two sides at a section junction (the + !! exact geometric trace on an element without bending stiffness). segment_tension(e) is the + !! mean of the axial components of element e's own two end forces. Every output is + !! optional (node arrays nn, segment_tension ne); the routine allocates nothing. + !! + !! The condensed torque of a line restrained in torsion is not part of g_e: it adds a shear + !! normal to the tangent and does no work on bending rotations, so tension and bend moment + !! are its axial and normal parts without it. Read-only. + TYPE(CD_HermiteCableDynType), INTENT(IN) :: model + INTEGER, INTENT(OUT) :: ErrStat + CHARACTER(*), INTENT(OUT) :: ErrMsg + REAL(wp), INTENT(OUT), OPTIONAL :: tension(:), curvature(:), bend_moment(:), segment_tension(:) + REAL(wp) :: g(12), fm(3), mm(3), fp(3), mp(3), ta(3), tb(3) + INTEGER :: e, nn + LOGICAL :: want_nodes + + ErrStat = CD_HCDYN_OK; ErrMsg = '' + IF (.NOT. model%initialized) THEN + ErrStat = CD_HCDYN_BADINPUT; ErrMsg = 'CD_HermiteCable_Dyn_Node_Recovery: model not initialised'; RETURN + END IF + nn = model%nn + IF (.NOT. (size_ok(tension, nn) .AND. size_ok(curvature, nn) .AND. size_ok(bend_moment, nn) .AND. & + size_ok(segment_tension, model%ne))) THEN + ErrStat = CD_HCDYN_BADINPUT + ErrMsg = 'CD_HermiteCable_Dyn_Node_Recovery: node arrays must be nn, segment_tension ne'; RETURN + END IF + want_nodes = PRESENT(tension) .OR. PRESENT(curvature) .OR. PRESENT(bend_moment) + fm = CD_ZERO; mm = CD_ZERO + DO e = 1, model%ne + CALL element_end_residual(model, e, g, ErrStat, ErrMsg) + IF (ErrStat /= CD_HCDYN_OK) RETURN + fp = -g(1:3); mp = -g(4:6) + IF (want_nodes) THEN + CALL store_node(e) + IF (ErrStat /= CD_HCDYN_OK) RETURN + END IF + IF (PRESENT(segment_tension)) THEN + ta = unit_tangent(model, e) + tb = unit_tangent(model, e + 1) + segment_tension(e) = 0.5_wp*(DOT_PRODUCT(ta, fp) + DOT_PRODUCT(tb, g(7:9))) + END IF + fm = g(7:9); mm = g(10:12) + END DO + fp = CD_ZERO; mp = CD_ZERO + IF (want_nodes) CALL store_node(nn) + + CONTAINS + + SUBROUTINE store_node(node) + INTEGER, INTENT(IN) :: node + REAL(wp) :: t_n, k_n, b_n + CALL node_values(model, node, fm, mm, fp, mp, t_n, k_n, b_n, ErrStat, ErrMsg) + IF (PRESENT(tension)) tension(node) = t_n + IF (PRESENT(curvature)) curvature(node) = k_n + IF (PRESENT(bend_moment)) bend_moment(node) = b_n + END SUBROUTINE store_node + + PURE LOGICAL FUNCTION size_ok(x, n) RESULT(ok) + REAL(wp), INTENT(IN), OPTIONAL :: x(:) + INTEGER, INTENT(IN) :: n + ok = .TRUE. + IF (PRESENT(x)) ok = SIZE(x) == n + END FUNCTION size_ok + END SUBROUTINE CD_HermiteCable_Dyn_Node_Recovery + + SUBROUTINE node_values(model, node, fm, mm, fp, mp, tension, curvature, bend_moment, ErrStat, ErrMsg) + !! Node values from the one-sided section force and moment before (fm, mm) and after + !! (fp, mp) the node; a line end uses its only side (see CD_HermiteCable_Dyn_Node_Recovery). + TYPE(CD_HermiteCableDynType), INTENT(IN) :: model + INTEGER, INTENT(IN) :: node + REAL(wp), INTENT(IN) :: fm(3), mm(3), fp(3), mp(3) + REAL(wp), INTENT(OUT) :: tension, curvature, bend_moment + INTEGER, INTENT(OUT) :: ErrStat + CHARACTER(*), INTENT(OUT) :: ErrMsg + REAL(wp) :: t(3), f(3), m(3), fend(3), qe(12), trace + INTEGER :: e, side + CHARACTER(200) :: em2 + + ErrStat = CD_HCDYN_OK; ErrMsg = '' + t = unit_tangent(model, node) + IF (node == 1) THEN + f = fp; m = mp + ELSE IF (node == model%nn) THEN + f = fm; m = mm + ELSE + f = 0.5_wp*(fm + fp); m = 0.5_wp*(mm + mp) + END IF + IF (node == 1 .OR. node == model%nn) THEN + CALL CD_HermiteCable_Dyn_End_Force(model, node, fend, ErrStat, ErrMsg) + IF (ErrStat /= CD_HCDYN_OK) RETURN + tension = NORM2(fend) + ELSE + tension = DOT_PRODUCT(t, f) + END IF + bend_moment = NORM2(m - DOT_PRODUCT(m, t)*t) + curvature = CD_ZERO + DO side = 0, 1 + e = node - 1 + side + IF (e < 1 .OR. e > model%ne) CYCLE + IF (model%EI(e) > CD_ZERO) THEN + curvature = MAX(curvature, bend_moment/model%EI(e)) + ELSE + CALL gather_elem(model, e, qe) + CALL CD_HermiteCable_Curvature(qe, model%l0(e), REAL(1 - side, wp), trace, ErrStat, em2) + IF (ErrStat /= CD_HCABLE_OK) THEN + ErrStat = CD_HCDYN_NOCONVERGE; ErrMsg = 'CD_HermiteCable_Dyn_Node_Recovery: '//TRIM(em2); RETURN + END IF + curvature = MAX(curvature, trace) + END IF + END DO + END SUBROUTINE node_values + + PURE FUNCTION unit_tangent(model, node) RESULT(t) + !! Unit material tangent of a node (internal arc direction); zero when degenerate. + TYPE(CD_HermiteCableDynType), INTENT(IN) :: model + INTEGER, INTENT(IN) :: node + REAL(wp) :: t(3), tn + t = model%q(6*(node - 1) + 4:6*(node - 1) + 6) + tn = NORM2(t) + IF (tn > CD_ZERO) THEN + t = t/tn + ELSE + t = CD_ZERO + END IF + END FUNCTION unit_tangent + + SUBROUTINE node_contact_normal(model, node, fc, ErrStat, ErrMsg) + !! Frictionless seabed normal force (with its damping) on a node at the committed state, as + !! assemble_contact applies it. + TYPE(CD_HermiteCableDynType), INTENT(IN) :: model + INTEGER, INTENT(IN) :: node + REAL(wp), INTENT(OUT) :: fc(3) + INTEGER, INTENT(OUT) :: ErrStat + CHARACTER(*), INTENT(OUT) :: ErrMsg + REAL(wp) :: z_floor, gx, gy, xg, yg, gxg, gyg, sfac, nvec(3), gap, normal, normal_gap, vn, gate, gate_gap + INTEGER :: iz, es + CHARACTER(200) :: em2 + ErrStat = CD_HCDYN_OK; ErrMsg = '' + fc = CD_ZERO + iz = 6*(node - 1) + 3 + IF (model%has_contact) THEN + z_floor = model%seabed_z + gx = CD_ZERO; gy = CD_ZERO + IF (model%has_contact_bathymetry) THEN + xg = model%contact_frame_c*model%q(iz - 2) - model%contact_frame_s*model%q(iz - 1) + yg = model%contact_frame_s*model%q(iz - 2) + model%contact_frame_c*model%q(iz - 1) + CALL CD_Bathymetry_Floor_Gradient(model%contact_bathymetry, xg, yg, z_floor, gxg, gyg, es, em2) + IF (es /= CD_BATHY_OK) THEN + ErrStat = CD_HCDYN_NOCONVERGE; ErrMsg = 'node_contact_normal: '//TRIM(em2); RETURN + END IF + gx = model%contact_frame_c*gxg + model%contact_frame_s*gyg + gy = -model%contact_frame_s*gxg + model%contact_frame_c*gyg + END IF + sfac = SQRT(CD_ONE + gx*gx + gy*gy) + nvec = [-gx, -gy, CD_ONE]/sfac + gap = (z_floor - model%q(iz))/sfac + CALL CD_Seabed_Normal_Law(gap, model%contact_kn(node), normal, normal_gap) + vn = DOT_PRODUCT(model%v(iz - 2:iz), nvec) + IF (ALLOCATED(model%contact_cn) .AND. vn < CD_ZERO) THEN + CALL CD_Seabed_Contact_Gate(gap, gate, gate_gap) + normal = normal - model%contact_cn(node)*gate*vn + END IF + IF (normal > CD_ZERO) fc = normal*nvec + ELSE IF (model%kn > CD_ZERO) THEN + gap = model%seabed_z - model%q(iz) + IF (gap > CD_ZERO) fc(3) = model%kn*gap*model%trib(node) + END IF + END SUBROUTINE node_contact_normal + + SUBROUTINE added_mass_force(qe, ae, l0, waterline_z, rho, diam, can, cat, f, ErrStat, ErrMsg) + !! Added-mass inertia force Ma(qe) ae of one element without forming Ma: the quadrature, + !! wet/dry culling and deformed length measure of CD_HermiteCable_AddedMass_Element. + REAL(wp), INTENT(IN) :: qe(12), ae(12), l0, waterline_z, rho, diam, can, cat + REAL(wp), INTENT(OUT) :: f(12) + INTEGER, INTENT(OUT) :: ErrStat + CHARACTER(*), INTENT(OUT) :: ErrMsg + INTEGER, PARAMETER :: NGP = 4 + REAL(wp), PARAMETER :: PI_L = 3.14159265358979323846_wp + REAL(wp) :: gp(NGP), gw(NGP), H(4), dH(4), rpos(3), rp(3), acc(3), speed, tangent(3), fa(3), area + INTEGER :: g, sh, c + + ErrStat = CD_HCDYN_OK; ErrMsg = '' + f = CD_ZERO + area = 0.25_wp*PI_L*diam*diam + gp = [0.5_wp*(CD_ONE - 0.8611363115940526_wp), 0.5_wp*(CD_ONE - 0.3399810435848563_wp), & + 0.5_wp*(CD_ONE + 0.3399810435848563_wp), 0.5_wp*(CD_ONE + 0.8611363115940526_wp)] + gw = 0.5_wp*[0.3478548451374538_wp, 0.6521451548625461_wp, & + 0.6521451548625461_wp, 0.3478548451374538_wp] + DO g = 1, NGP + CALL CD_HermiteCable_Shapes(gp(g), l0, H, dH) + DO c = 1, 3 + rpos(c) = H(1)*qe(c) + H(2)*qe(3 + c) + H(3)*qe(6 + c) + H(4)*qe(9 + c) + rp(c) = dH(1)*qe(c) + dH(2)*qe(3 + c) + dH(3)*qe(6 + c) + dH(4)*qe(9 + c) + acc(c) = H(1)*ae(c) + H(2)*ae(3 + c) + H(3)*ae(6 + c) + H(4)*ae(9 + c) + END DO + IF (rpos(3) > waterline_z) CYCLE ! dry Gauss point: no added mass + speed = SQRT(rp(1)**2 + rp(2)**2 + rp(3)**2) + IF (speed <= 1.0e-12_wp) THEN + ErrStat = CD_HCDYN_NOCONVERGE + ErrMsg = 'added-mass force: degenerate centreline (|dr/dxi| ~ 0)'; RETURN + END IF + tangent = rp/speed + fa = gw(g)*speed*rho*area*(can*acc + (cat - can)*DOT_PRODUCT(tangent, acc)*tangent) + DO sh = 1, 4 + f(3*(sh - 1) + 1:3*sh) = f(3*(sh - 1) + 1:3*sh) + H(sh)*fa + END DO + END DO + END SUBROUTINE added_mass_force + + SUBROUTINE element_end_residual(model, e, g, ErrStat, ErrMsg) + !! g = f_int + f_damp - f_ext + M_e a_e of element e alone at the committed state, with the + !! element's own distributed loads (see CD_HermiteCable_Dyn_Node_Recovery). + TYPE(CD_HermiteCableDynType), INTENT(IN) :: model + INTEGER, INTENT(IN) :: e + REAL(wp), INTENT(OUT) :: g(12) + INTEGER, INTENT(OUT) :: ErrStat + CHARACTER(*), INTENT(OUT) :: ErrMsg + REAL(wp), PARAMETER :: PI_L = 3.14159265358979323846_wp + INTEGER, PARAMETER :: ZS(4) = [3, 6, 9, 12] + REAL(wp) :: qe(12), ve(12), ae(12), fe(12), fx(12), energy, fdry(4), kdry(4, 4) + REAL(wp) :: dry_wl, dry_b, dry_r, hf_mid(3), l0, fca(3), fcb(3), c, a4(4), m4(4, 4) + INTEGER :: es, k + LOGICAL :: dry + CHARACTER(200) :: em2 + + ErrStat = CD_HCDYN_OK; ErrMsg = ''; em2 = '' + g = CD_ZERO + l0 = model%l0(e) + 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)) + CALL CD_HermiteCable_Element(qe, l0, model%EA(e), model%EI(e), energy, fe, ErrStat=es, ErrMsg=em2, & + axial_quadrature_order=model%axial_quadrature_order, & + bending_quadrature_order=model%bending_quadrature_order) + IF (es /= CD_HCABLE_OK) GOTO 900 + g = fe + IF (model%has_axial_damping) THEN + CALL CD_HermiteCable_Axial_Damping_Element(qe, ve, l0, model%BA(e), fx, ErrStat=es, ErrMsg=em2, & + quadrature_order=model%axial_quadrature_order) + IF (es /= CD_HCDYN_OK) GOTO 900 + g = g + fx + END IF + ! consistent submerged weight (as assemble_residual) + g(3) = g(3) + model%w(e)*0.5_wp*l0 + g(6) = g(6) + model%w(e)*l0*l0/12.0_wp + g(9) = g(9) + model%w(e)*0.5_wp*l0 + g(12) = g(12) - model%w(e)*l0*l0/12.0_wp + IF (model%has_drag .OR. model%has_am) THEN + IF (model%has_drag) THEN + dry_wl = model%waterline_z + dry_b = model%rho_w*model%gravity*0.25_wp*PI_L*model%diam(e)**2 + dry_r = 0.5_wp*model%diam(e) + ELSE + dry_wl = model%am_wl + dry_b = model%am_rho*model%gravity*0.25_wp*PI_L*model%am_diam(e)**2 + dry_r = 0.5_wp*model%am_diam(e) + END IF + IF (model%has_held_field) dry_wl = 0.5_wp*(model%hf_wl(e) + model%hf_wl(e + 1)) + CALL CD_HermiteCable_Dry_Buoyancy(qe(ZS), l0, dry_b, dry_wl, fdry, kdry, dry, radius=dry_r) + 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 + IF (es /= CD_HCDYN_OK) GOTO 900 + g = g - fx + END IF + IF (model%has_am .AND. (model%has_wave .OR. model%has_held_field)) THEN + IF (model%has_held_field) THEN + hf_mid = 0.5_wp*(model%hf_ud(:, e) + model%hf_ud(:, e + 1)) + CALL CD_HermiteCable_FK_Element(qe, l0, 0.5_wp*(model%hf_wl(e) + model%hf_wl(e + 1)), & + model%am_rho, model%am_diam(e), model%am_can(e), model%am_cat(e), & + wv_depth=CD_ZERO, wv_dir=CD_ZERO, wv_t=CD_ZERO, & + ffk=fx, ErrStat=es, ErrMsg=em2, hf_a=hf_mid) + ELSE IF (model%wv_ncomp > 0) THEN + CALL CD_HermiteCable_FK_Element(qe, l0, model%am_wl, model%am_rho, model%am_diam(e), & + model%am_can(e), model%am_cat(e), & + wv_depth=model%wv_depth, wv_dir=model%wv_dir, wv_t=model%t, & + ffk=fx, ErrStat=es, ErrMsg=em2, & + 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 + CALL CD_HermiteCable_FK_Element(qe, l0, model%am_wl, model%am_rho, model%am_diam(e), & + model%am_can(e), model%am_cat(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=model%t, & + ffk=fx, ErrStat=es, ErrMsg=em2) + END IF + IF (es /= CD_HCDYN_OK) GOTO 900 + g = g - fx + END IF + ! Seabed contact acts at the nodes; spread over each node's tributary length it is the + ! distributed floor reaction it stands for. Its consistent share is taken out of the element, + ! so a line resting on the floor carries no fixed-end moment of its own weight. + IF (model%has_contact .OR. model%kn > CD_ZERO) THEN + CALL node_contact_normal(model, e, fca, es, em2) + IF (es /= CD_HCDYN_OK) GOTO 900 + CALL node_contact_normal(model, e + 1, fcb, es, em2) + IF (es /= CD_HCDYN_OK) GOTO 900 + IF (model%trib(e) > CD_ZERO) fca = fca*l0/model%trib(e) + IF (model%trib(e + 1) > CD_ZERO) fcb = fcb*l0/model%trib(e + 1) + ! integrals of the four shapes over xi in [0, 1/2] (fca) and [1/2, 1] (fcb) + g(1:3) = g(1:3) - (0.40625_wp*fca + 0.09375_wp*fcb) + g(4:6) = g(4:6) - l0*(0.0572916666666666667_wp*fca + 0.0260416666666666667_wp*fcb) + g(7:9) = g(7:9) - (0.09375_wp*fca + 0.40625_wp*fcb) + g(10:12) = g(10:12) + l0*(0.0260416666666666667_wp*fca + 0.0572916666666666667_wp*fcb) + END IF + ae(1:6) = model%a(6*(e - 1) + 1:6*e); ae(7:12) = model%a(6*e + 1:6*(e + 1)) + IF (ANY(ABS(ae) > CD_ZERO)) THEN + ! consistent structural mass, closed form of CD_HermiteCable_Mass: per component the + ! 4 x 4 cubic-Hermite block on [r1, m1, r2, m2] + c = model%rho_a(e)*l0/420.0_wp + m4 = RESHAPE([156.0_wp, 22.0_wp*l0, 54.0_wp, -13.0_wp*l0, & + 22.0_wp*l0, 4.0_wp*l0*l0, 13.0_wp*l0, -3.0_wp*l0*l0, & + 54.0_wp, 13.0_wp*l0, 156.0_wp, -22.0_wp*l0, & + -13.0_wp*l0, -3.0_wp*l0*l0, -22.0_wp*l0, 4.0_wp*l0*l0], [4, 4]) + DO k = 1, 3 + a4 = [ae(k), ae(3 + k), ae(6 + k), ae(9 + k)] + a4 = c*MATMUL(m4, a4) + g(k) = g(k) + a4(1); g(3 + k) = g(3 + k) + a4(2) + g(6 + k) = g(6 + k) + a4(3); g(9 + k) = g(9 + k) + a4(4) + END DO + IF (model%has_am) THEN + dry_wl = model%am_wl + IF (model%has_held_field) dry_wl = 0.5_wp*(model%hf_wl(e) + model%hf_wl(e + 1)) + CALL added_mass_force(qe, ae, l0, dry_wl, model%am_rho, model%am_diam(e), model%am_can(e), & + model%am_cat(e), fx, es, em2) + IF (es /= CD_HCDYN_OK) GOTO 900 + g = g + fx + END IF + END IF + RETURN +900 ErrStat = CD_HCDYN_NOCONVERGE + ErrMsg = 'CD_HermiteCable_Dyn_Node_Recovery: element '//TRIM(em2) + END SUBROUTINE element_end_residual + PURE REAL(wp) FUNCTION CD_HermiteCable_Dyn_Max_Step_Rotation(model) RESULT(angle) !! Largest angle [rad] through which a nodal tangent turned over one committed step !! since initialisation: the time-step resolution of the tangent rotation. diff --git a/src/CableDyn_HermiteCableStatic.f90 b/src/CableDyn_HermiteCableStatic.f90 index 446ba6df..626c2efe 100644 --- a/src/CableDyn_HermiteCableStatic.f90 +++ b/src/CableDyn_HermiteCableStatic.f90 @@ -237,7 +237,7 @@ MODULE CableDyn_HermiteCableStatic REAL(wp) :: smoothed_axial_min = CD_ZERO !! minimum 3-element length-weighted mean axial force [N] LOGICAL :: smoothed_compressed = .FALSE. !! smoothed compression beyond compression_limit INTEGER :: smoothed_min_elem = 0 !! centre element of smoothed_axial_min - REAL(wp) :: nodal_axial_min = CD_ZERO !! minimum interior-node segment tension [N] + REAL(wp) :: nodal_axial_min = CD_ZERO !! minimum interior-node material axial force [N] INTEGER :: nodal_min_node = 0 !! interior node carrying nodal_axial_min REAL(wp) :: h_kappa_peak = CD_ZERO INTEGER :: h_kappa_elem = 0 @@ -5454,7 +5454,8 @@ SUBROUTINE CD_HermiteCable_Branch_Audit(l0, q, EA, audit, ErrStat, ErrMsg, end_z !! tensile neighbours (a mesh-local kink, e.g. next to a nodal seabed-contact reaction) !! is excluded by it; a run of three or more compressed elements never is. !! audit%nodal_axial_min is the minimum over interior nodes of the length-weighted - !! average of the two adjacent element means: the node Tension output channel. + !! average of the two adjacent element means: the nodal material axial force (the node + !! Tension output channel under OPTIONS OutputRecovery element). REAL(wp), INTENT(IN) :: l0(:), q(:), EA(:) TYPE(CD_HermiteBranchAuditType), INTENT(OUT) :: audit INTEGER, INTENT(OUT) :: ErrStat diff --git a/src/CableDyn_OpenFAST_HermiteFMF.f90 b/src/CableDyn_OpenFAST_HermiteFMF.f90 index fe28b36f..a9dbec8e 100644 --- a/src/CableDyn_OpenFAST_HermiteFMF.f90 +++ b/src/CableDyn_OpenFAST_HermiteFMF.f90 @@ -37,7 +37,7 @@ MODULE CableDyn_OpenFAST_HermiteFMF CD_HermiteCable_Dyn_Step, CD_HermiteCable_Dyn_Step_Recovering, & CD_HermiteCable_Dyn_Reaction, & CD_HermiteCable_Dyn_EndConnection_Moment, & - CD_HermiteCable_Dyn_Curvature, & + CD_HermiteCable_Dyn_Curvature, CD_HermiteCable_Dyn_Curvature_Exact, & CD_HermiteCable_Dyn_Snapshot, CD_HermiteCable_Dyn_Restore, & CD_HermiteCable_Dyn_End, CD_HCDYN_OK, & CD_HermiteCable_Dyn_Set_Torsion, CD_HermiteCable_Dyn_Set_Torsion_Drive, & @@ -78,7 +78,7 @@ MODULE CableDyn_OpenFAST_HermiteFMF PUBLIC :: CD_HFMF_SetCoupledKinematics PUBLIC :: CD_HFMF_GetCoupledKinematics PUBLIC :: CD_HFMF_CalcOutput - PUBLIC :: CD_HFMF_Curvature + PUBLIC :: CD_HFMF_Curvature, CD_HFMF_Curvature_Exact PUBLIC :: CD_HFMF_MinSpanZ PUBLIC :: CD_HFMF_MirrorSize PUBLIC :: CD_HFMF_FrictionMirrorSize @@ -1379,7 +1379,8 @@ PURE FUNCTION frame_to_global(self, v) RESULT(vg) END FUNCTION frame_to_global SUBROUTINE CD_HFMF_Curvature(self, curv_out, ErrStat, ErrMsg) - !! Nodal centreline curvature at the current state (the fatigue report channel). + !! Nodal curvature at the current state, the definition of the CurvN channels + !! (CD_HermiteCable_Dyn_Curvature: recovered from nodal equilibrium by default). TYPE(CD_HFMF_ModuleType), INTENT(INOUT) :: self REAL(wp), INTENT(OUT) :: curv_out(:) INTEGER, INTENT(OUT) :: ErrStat @@ -1396,6 +1397,25 @@ SUBROUTINE CD_HFMF_Curvature(self, curv_out, ErrStat, ErrMsg) END IF END SUBROUTINE CD_HFMF_Curvature + SUBROUTINE CD_HFMF_Curvature_Exact(self, curv_out, ErrStat, ErrMsg) + !! Nodal geometric curvature of the cubic-Hermite centreline at the current state, the larger + !! one-sided trace at an interior node (CD_HermiteCable_Dyn_Curvature_Exact). + TYPE(CD_HFMF_ModuleType), INTENT(INOUT) :: self + REAL(wp), INTENT(OUT) :: curv_out(:) + INTEGER, INTENT(OUT) :: ErrStat + CHARACTER(*), INTENT(OUT) :: ErrMsg + INTEGER :: es + CHARACTER(300) :: em + ErrStat = CD_HFMF_OK; ErrMsg = '' + IF (.NOT. self%initialized) THEN + ErrStat = CD_HFMF_BADINPUT; ErrMsg = 'CD_HFMF_Curvature_Exact: module not initialised'; RETURN + END IF + CALL CD_HermiteCable_Dyn_Curvature_Exact(self%line, curv_out, es, em) + IF (es /= CD_HCDYN_OK) THEN + ErrStat = CD_HFMF_BADINPUT; ErrMsg = 'CD_HFMF_Curvature_Exact: '//TRIM(em) + END IF + END SUBROUTINE CD_HFMF_Curvature_Exact + REAL(wp) FUNCTION CD_HFMF_MinSpanZ(self) RESULT(zmin) !! Minimum global z along the cubic-Hermite CENTRELINE (its static-seeded shape), computed !! EXACTLY per element from the cubic's stationary points -- NOT by fixed sampling. On each diff --git a/src/CableDyn_RangeOutput.f90 b/src/CableDyn_RangeOutput.f90 index 24e30059..041d0f5a 100644 --- a/src/CableDyn_RangeOutput.f90 +++ b/src/CableDyn_RangeOutput.f90 @@ -15,10 +15,16 @@ MODULE CableDyn_RangeOutput !! centreline is at most CD_SEABED_CONTACT_BLEND above the seabed (the height at which !! the normal contact law activates). The grounded end is the end grounded in the !! initial state; walking from it, the TDP lies between the last grounded node and the - !! next one, where the centreline crosses that height. Arc length is the deformed chord + !! next one, where the parabola through the last grounded node and the next two (clearance + !! against chord arc) crosses that height, the crossing nearest the suspended node; it + !! reaches a node exactly when the node does, so the TDP moves continuously as nodes ground + !! and lift off (linear clearance when there is no such crossing). The TDP sits on that + !! height. Arc length is the deformed chord !! length from End A, layback the horizontal distance from the TDP to the suspended end, - !! and the excursion the horizontal TDP displacement from its initial position projected - !! on the initial horizontal direction from the TDP to the suspended end. + !! the excursion the horizontal TDP displacement from its initial position projected + !! on the initial horizontal direction from the TDP to the suspended end, and the grounded + !! length the deformed chord length from the grounded end to the TDP (0 while no node + !! beyond the grounded end node is grounded). USE CableDyn_Precision, ONLY: wp, CD_ZERO, CD_ONE USE CableDyn_Bathymetry, ONLY: CD_BathymetryType, CD_Bathymetry_Floor, CD_Bathymetry_Is_Initialized, & CD_BATHY_OK @@ -38,9 +44,9 @@ MODULE CableDyn_RangeOutput INTEGER, PARAMETER, PUBLIC :: CD_RQ_TENSION = 1, CD_RQ_CURVATURE = 2, CD_RQ_BEND = 3, & CD_RQ_DECLINATION = 4, CD_RQ_CLEARANCE = 5, CD_RQ_TORQUE = 6, CD_RQ_TWIST = 7, & CD_RQ_N = 7 - ! Components of the TDP channels (TDPs, x, y, z, Lay, Exc). + ! Components of the TDP channels (TDPs, x, y, z, Lay, Exc, Grd). INTEGER, PARAMETER, PUBLIC :: CD_TDP_S = 1, CD_TDP_X = 2, CD_TDP_Y = 3, CD_TDP_Z = 4, CD_TDP_LAY = 5, & - CD_TDP_EXC = 6, CD_TDP_N = 6 + CD_TDP_EXC = 6, CD_TDP_GRD = 7, CD_TDP_N = 7 TYPE :: CD_RangeLine INTEGER :: line_id = 0 @@ -286,17 +292,21 @@ SUBROUTINE CD_Range_Commit_Sample(set, il, time, ErrStat, ErrMsg) END DO END SUBROUTINE CD_Range_Commit_Sample - PURE SUBROUTINE tdp_locate(r, clearance, grounded_end, touching, arc, point, suspended_xy) + PURE SUBROUTINE tdp_locate(r, clearance, grounded_end, touching, arc, point, suspended_xy, grounded) !! Touchdown point of one configuration for a given grounded end (1 = A, 2 = B), the !! algorithm of cabledyn.touchdown_history. `touching` is false when the grounded end !! has lifted off (the TDP is then reported at that end) or every node is grounded (the - !! TDP is then reported at the suspended end). + !! TDP is then reported at the suspended end). `grounded` is the deformed chord length + !! from the grounded end to the TDP, the whole line when every node is grounded, and 0 + !! when no node beyond the grounded end node is grounded: an end held at the seabed + !! elevation counts as grounded, but no line lies on the seabed there (the end is about + !! to lift, or has lifted). REAL(wp), INTENT(IN) :: r(:, :), clearance(:) INTEGER, INTENT(IN) :: grounded_end LOGICAL, INTENT(OUT) :: touching - REAL(wp), INTENT(OUT) :: arc, point(3), suspended_xy(2) + REAL(wp), INTENT(OUT) :: arc, point(3), suspended_xy(2), grounded INTEGER :: nn, k, j, jn, last - REAL(wp) :: g_low, g_high, fraction, chord, s_scan, s_total + REAL(wp) :: g_low, g_high, fraction, chord, s_scan, s_total, z_floor LOGICAL :: grounded_first, all_grounded nn = SIZE(r, 2) @@ -319,6 +329,7 @@ PURE SUBROUTINE tdp_locate(r, clearance, grounded_end, touching, arc, point, sus g_low = clearance(node_of(last)) - CD_SEABED_CONTACT_BLEND g_high = clearance(node_of(last + 1)) - CD_SEABED_CONTACT_BLEND IF (g_high > g_low) fraction = MIN(CD_ONE, MAX(CD_ZERO, -g_low/(g_high - g_low))) + CALL quadratic_fraction(fraction) END IF s_scan = CD_ZERO s_total = CD_ZERO @@ -333,7 +344,15 @@ PURE SUBROUTINE tdp_locate(r, clearance, grounded_end, touching, arc, point, sus jn = node_of(last + 1) point = r(:, j) + fraction*(r(:, jn) - r(:, j)) s_scan = s_scan + fraction*NORM2(r(:, jn) - r(:, j)) + ! the TDP sits at the contact-onset height: floor (z - clearance) interpolated along the + ! chord, plus the onset height + IF (touching) THEN + z_floor = (CD_ONE - fraction)*(r(3, j) - clearance(j)) + fraction*(r(3, jn) - clearance(jn)) + point(3) = z_floor + CD_SEABED_CONTACT_BLEND + END IF END IF + grounded = s_scan + IF (last <= 1) grounded = CD_ZERO arc = s_scan IF (grounded_end == 2) arc = s_total - s_scan suspended_xy = r(1:2, node_of(nn)) @@ -345,6 +364,46 @@ PURE INTEGER FUNCTION node_of(k_scan) RESULT(node) node = k_scan IF (grounded_end == 2) node = nn + 1 - k_scan END FUNCTION node_of + + PURE SUBROUTINE quadratic_fraction(f) + !! Quadratic clearance g(x) through the last grounded node (x = 0) and the first two + !! suspended nodes (x = l1, l1 + l2), g measured from the contact-onset height; the + !! touchdown is its crossing nearest the suspended node inside the element [0, l1]. The + !! crossing reaches a node exactly when that node reaches the onset height, so the + !! location is continuous as nodes ground and lift off. Keeps f (linear) when the line + !! has fewer than two suspended nodes or the quadratic has no crossing in the element. + REAL(wp), INTENT(INOUT) :: f + REAL(wp) :: g0, g1, g2, l1, l2, d1, qa, qb, disc, x1, x2, xc + IF (last + 2 > nn) RETURN + g0 = clearance(node_of(last)) - CD_SEABED_CONTACT_BLEND + g1 = clearance(node_of(last + 1)) - CD_SEABED_CONTACT_BLEND + g2 = clearance(node_of(last + 2)) - CD_SEABED_CONTACT_BLEND + l1 = NORM2(r(:, node_of(last + 1)) - r(:, node_of(last))) + l2 = NORM2(r(:, node_of(last + 2)) - r(:, node_of(last + 1))) + IF (.NOT. (l1 > CD_ZERO) .OR. .NOT. (l2 > CD_ZERO)) RETURN + d1 = (g1 - g0)/l1 + qa = ((g2 - g1)/l2 - d1)/(l1 + l2) + qb = d1 - qa*l1 + ! qa x^2 + qb x + g0 = 0 + IF (ABS(qa)*l1 <= 1.0e-12_wp*MAX(ABS(qb), TINY(CD_ONE))) THEN + IF (ABS(qb) > CD_ZERO) f = MIN(CD_ONE, MAX(CD_ZERO, (-g0/qb)/l1)) + RETURN + END IF + disc = qb*qb - 4.0_wp*qa*g0 + IF (disc < CD_ZERO) RETURN + ! numerically stable pair of roots + IF (qb >= CD_ZERO) THEN + x1 = (-qb - SQRT(disc))/(2.0_wp*qa) + ELSE + x1 = (-qb + SQRT(disc))/(2.0_wp*qa) + END IF + x2 = CD_ZERO + IF (ABS(x1) > CD_ZERO) x2 = g0/(qa*x1) + xc = -HUGE(CD_ONE) + IF (x1 >= -1.0e-9_wp*l1 .AND. x1 <= l1*(CD_ONE + 1.0e-9_wp)) xc = MAX(xc, x1) + IF (x2 >= -1.0e-9_wp*l1 .AND. x2 <= l1*(CD_ONE + 1.0e-9_wp)) xc = MAX(xc, x2) + IF (xc > -HUGE(CD_ONE)) f = MIN(CD_ONE, MAX(CD_ZERO, xc/l1)) + END SUBROUTINE quadratic_fraction END SUBROUTINE tdp_locate SUBROUTINE CD_Range_TDP_Reference(line, r, clearance, ErrStat, ErrMsg) @@ -354,7 +413,7 @@ SUBROUTINE CD_Range_TDP_Reference(line, r, clearance, ErrStat, ErrMsg) INTEGER, INTENT(OUT) :: ErrStat CHARACTER(*), INTENT(OUT) :: ErrMsg LOGICAL :: ga, gb, touching - REAL(wp) :: arc, point(3), suspended_xy(2), span + REAL(wp) :: arc, point(3), suspended_xy(2), span, grounded INTEGER :: nn ErrStat = CD_RANGE_OK @@ -378,7 +437,7 @@ SUBROUTINE CD_Range_TDP_Reference(line, r, clearance, ErrStat, ErrMsg) RETURN END IF line%tdp_end = MERGE(1, 2, ga) - CALL tdp_locate(r, clearance, line%tdp_end, touching, arc, point, suspended_xy) + CALL tdp_locate(r, clearance, line%tdp_end, touching, arc, point, suspended_xy, grounded) span = NORM2(suspended_xy - point(1:2)) IF (.NOT. touching .OR. .NOT. (span > CD_ZERO)) THEN ErrStat = CD_RANGE_BADINPUT @@ -402,20 +461,21 @@ END SUBROUTINE CD_Range_TDP_Reference PURE SUBROUTINE CD_Range_TDP_Evaluate(line, r, clearance, tdp) !! Touchdown channels of one configuration against the line's fixed reference: - !! tdp = [arc from End A, x, y, z, layback, excursion]. + !! tdp = [arc from End A, x, y, z, layback, excursion, grounded length]. TYPE(CD_RangeLine), INTENT(IN) :: line REAL(wp), INTENT(IN) :: r(:, :), clearance(:) REAL(wp), INTENT(OUT) :: tdp(CD_TDP_N) LOGICAL :: touching - REAL(wp) :: arc, point(3), suspended_xy(2) + REAL(wp) :: arc, point(3), suspended_xy(2), grounded tdp = CD_ZERO IF (.NOT. line%tdp_ready) RETURN - CALL tdp_locate(r, clearance, line%tdp_end, touching, arc, point, suspended_xy) + CALL tdp_locate(r, clearance, line%tdp_end, touching, arc, point, suspended_xy, grounded) tdp(CD_TDP_S) = arc tdp(CD_TDP_X:CD_TDP_Z) = point tdp(CD_TDP_LAY) = NORM2(suspended_xy - point(1:2)) tdp(CD_TDP_EXC) = DOT_PRODUCT(point(1:2) - line%ref_xy, line%ref_dir) + tdp(CD_TDP_GRD) = grounded END SUBROUTINE CD_Range_TDP_Evaluate SUBROUTINE CD_Range_Write_Files(set, out_root, ErrStat, ErrMsg) @@ -512,7 +572,7 @@ PURE LOGICAL FUNCTION CD_Is_TDP_Channel(lo) RESULT(yes) END FUNCTION CD_Is_TDP_Channel PURE SUBROUTINE CD_Parse_TDP_Channel(ch, line_id, comp) - !! TDPs / x / y / z / Lay / Exc (case-insensitive, leading zeros allowed) -> deck line + !! TDPs / x / y / z / Lay / Exc / Grd (case-insensitive, leading zeros allowed) -> deck line !! id and component CD_TDP_*; comp = 0 (and line_id = 0) when malformed. CHARACTER(*), INTENT(IN) :: ch INTEGER, INTENT(OUT) :: line_id, comp @@ -543,6 +603,7 @@ PURE SUBROUTINE CD_Parse_TDP_Channel(ch, line_id, comp) CASE ('z'); comp = CD_TDP_Z CASE ('lay'); comp = CD_TDP_LAY CASE ('exc'); comp = CD_TDP_EXC + CASE ('grd'); comp = CD_TDP_GRD END SELECT IF (comp == 0 .OR. line_id < 1) THEN comp = 0 diff --git a/tests/test_anchor_uplift.py b/tests/test_anchor_uplift.py new file mode 100644 index 00000000..6c314f1d --- /dev/null +++ b/tests/test_anchor_uplift.py @@ -0,0 +1,486 @@ +#!/usr/bin/env python3 +# SPDX-License-Identifier: Apache-2.0 +# Copyright (c) 2026 Jae Hoon Seo, SMI Lab, Inha University +"""Anchor uplift channels of the driver: AnchFz, AnchFH and TDPGrd. + +Gates, each on the driver's own output files: + +* laid catenary: on a grounded R3 chain ``AnchFH`` is the horizontal tension of the analytic + elastic catenary and equals the fairlead's horizontal force, ``TDPGrd`` is the analytic + grounded length and ``TDPs + TDPGrd`` the deformed line length, and ``AnchFz`` is the + small negative end-node share the documentation states (the anchor node's lumped weight plus + the pull of the anchor segment toward the chain sunk into the penalty seabed); +* suspended line: on a taut chain with no laid length ``AnchFz``/``AnchFH`` are the anchor + forces of the analytic suspended elastic catenary, consistent with ``AnchTen`` and + ``AnchIncl``, and ``TDPGrd`` is 0; +* consistency: for an anchor holding one line ``AnchFz`` = ``Point

Fz`` and + ``AnchFH`` = ``Point

FH`` exactly, and ``AnchTen`` is the norm of the two, on the static, + ``EI = 0`` dynamic, point-system, cubic-Hermite, mixed aggregate and multibody routes; +* dynamics: a fairlead surge lifts the anchor of a catenary; at every output time the channels + are finite and consistent, ``TDPGrd > 0`` implies ``AnchFz < 0`` and ``AnchFz > 0`` implies + ``TDPGrd = 0``, and the held end state is the suspended elastic catenary; +* fail-closed contracts: unknown lines and the two-moving-end finite-EI route reject the names. + +usage: test_anchor_uplift.py --exe --examples --output

+""" + +from __future__ import annotations + +import argparse +import math +import os +import re +import shutil +import subprocess +import sys +from pathlib import Path + +import numpy as np + +sys.path.insert(0, str(Path(__file__).resolve().parents[1] / "python")) +from cabledyn import read_output # noqa: E402 + +FAILURES: list[str] = [] +G = 9.80665 +RHO = 1025.0 + + +def check(ok: bool, message: str) -> None: + print(("PASS: " if ok else "FAIL: ") + message) + if not ok: + FAILURES.append(message) + + +# ----------------------------------------------------------------------------- decks + + +def table_rows(text: str, name: str) -> tuple[int, int]: + """Line index range of the data rows of a deck table (after its two header rows).""" + lines = text.splitlines() + start = next(i for i, line in enumerate(lines) if re.match(r"^-+\s*" + name + r"\b", line, re.I)) + end = next(i for i in range(start + 1, len(lines)) if lines[i].startswith("---")) + return start + 3, end + + +def set_option(text: str, key: str, value: str) -> str: + lines = text.splitlines() + a, b = table_rows(text, "OPTIONS") + a -= 2 + for i in range(a, b): + tok = lines[i].split() + if len(tok) >= 2 and tok[1].lower() == key.lower(): + lines[i] = f"{value} {key}" + return "\n".join(lines) + "\n" + lines.insert(a, f"{value} {key}") + return "\n".join(lines) + "\n" + + +def set_line_flag(text: str, line_id: int, flags: str) -> str: + lines = text.splitlines() + a, b = table_rows(text, "LINES") + for i in range(a, b): + tok = lines[i].split() + if tok and tok[0] == str(line_id): + tok[3] = flags + lines[i] = " ".join(tok) + return "\n".join(lines) + "\n" + + +def set_outputs(text: str, names: list[str]) -> str: + lines = text.splitlines() + start = next(i for i, line in enumerate(lines) if re.match(r"^-+\s*OUTPUTS\b", line, re.I)) + end = next(i for i in range(start + 1, len(lines)) if lines[i].startswith("---")) + return "\n".join(lines[: start + 1] + [f'"{n}"' for n in names] + lines[end:]) + "\n" + + +def anchor_channels(line_id: int, point_id: int) -> list[str]: + return [f"AnchTen{line_id}", f"AnchFz{line_id}", f"AnchFH{line_id}", f"Point{point_id}Fz", + f"Point{point_id}FH"] + + +def run(exe: str, deck: Path, root: Path, env: dict) -> None: + proc = subprocess.run([exe, str(deck), str(root)], capture_output=True, text=True, env=env, cwd=deck.parent) + if proc.returncode != 0: + raise SystemExit(f"{deck.name}: driver exit {proc.returncode}\n{proc.stdout[-2000:]}\n{proc.stderr[-2000:]}") + + +def out_strings(path: Path) -> tuple[list[str], list[list[str]]]: + """Header and the verbatim value fields of every data row of a driver .out file.""" + lines = path.read_text(encoding="utf-8").splitlines() + header = lines[1].split("\t") + return header, [row.split("\t") for row in lines[2:] if row.strip()] + + +def check_anchor_point(label: str, root: Path, line_id: int, point_id: int) -> None: + """AnchFz/AnchFH equal the Point

resultant of a one-line anchor (the printed text, every + row), and AnchTen is their norm to the 8 printed digits.""" + header, rows = out_strings(root.with_suffix(".out")) + col = {name.lower(): k for k, name in enumerate(header)} + fz, fh = col[f"anchfz{line_id}"], col[f"anchfh{line_id}"] + pz, ph = col[f"point{point_id}fz"], col[f"point{point_id}fh"] + same = all(r[fz] == r[pz] and r[fh] == r[ph] for r in rows) + check(same, f"{label}: AnchFz{line_id}/AnchFH{line_id} = Point{point_id}Fz/FH at all {len(rows)} rows") + hist = read_output(root.with_suffix(".out")) + ten = hist.column(f"AnchTen{line_id}") + norm = np.hypot(hist.column(f"AnchFz{line_id}"), hist.column(f"AnchFH{line_id}")) + worst = float(np.max(np.abs(norm - ten) / np.maximum(ten, 1e-30))) + check(worst < 2e-7, f"{label}: AnchTen{line_id} = |(AnchFH, AnchFz)| (max relative difference {worst:.1e})") + + +def line_lengths(path: Path) -> np.ndarray: + """Deformed chord length of a line at every row of a dynamic .Line.p.out file.""" + lines = path.read_text(encoding="utf-8").splitlines() + data = np.array([[float(v) for v in row.split()] for row in lines[2:] if row.strip()]) + xyz = data[:, 1:].reshape(data.shape[0], -1, 3) + return np.linalg.norm(np.diff(xyz, axis=1), axis=2).sum(axis=1) + + +def static_line_length(path: Path) -> float: + """Deformed chord length of a line from a static .Line.p.out table (Node X Y Z).""" + lines = path.read_text(encoding="utf-8").splitlines() + data = np.array([[float(v) for v in row.split()] for row in lines[2:] if row.strip()]) + return float(np.linalg.norm(np.diff(data[:, 1:4], axis=0), axis=1).sum()) + + +# ----------------------------------------------------------------------------- analytic catenaries + + +def newton2(residual, x0: np.ndarray, scale: np.ndarray) -> np.ndarray: + """Newton iteration on two unknowns (the first a positive tension), with step halving.""" + x = np.array(x0, dtype=float) + f = np.array(residual(x)) + for _ in range(200): + jac = np.empty((2, 2)) + for k in range(2): + dx = np.zeros(2) + dx[k] = 1e-7 * scale[k] + jac[:, k] = (np.array(residual(x + dx)) - f) / dx[k] + step = np.linalg.solve(jac, -f) + for _ in range(60): + trial = x + step + if trial[0] > 0.0: + f_trial = np.array(residual(trial)) + if np.all(np.isfinite(f_trial)) and np.linalg.norm(f_trial) < max(np.linalg.norm(f), 1e-300): + break + step = 0.5 * step + x, f = trial, f_trial + if np.all(np.abs(step) < 1e-12 * scale): + return x + raise RuntimeError("catenary Newton iteration did not converge") + + +def laid_catenary(length: float, span: float, depth: float, w: float, ea: float) -> tuple[float, float, float]: + """Elastic catenary with a grounded run on a frictionless seabed: (horizontal tension H, + deformed grounded length, deformed suspended length).""" + + def residual(x: np.ndarray) -> tuple[float, float]: + h, ls = x + a = h / w + xs = a * math.asinh(ls / a) + h * ls / ea + (length - ls) * (1.0 + h / ea) + zs = a * (math.sqrt(1.0 + (ls / a) ** 2) - 1.0) + w * ls * ls / (2.0 * ea) + return xs - span, zs - depth + + h, ls = newton2(residual, np.array([1.0e5, 1.5 * depth]), np.array([1.0e5, depth])) + a = h / w + u = ls / a + suspended = ls + (h / (2.0 * w * ea)) * h * (u * math.sqrt(1.0 + u * u) + math.asinh(u)) + return h, (length - ls) * (1.0 + h / ea), suspended + + +def suspended_catenary(length: float, span: float, rise: float, w: float, ea: float) -> tuple[float, float]: + """Elastic catenary lifted at its lower (anchor) end: (H, V) of the force the line exerts + on the anchor, V positive upward.""" + + def residual(x: np.ndarray) -> tuple[float, float]: + h, v = x + top = (v + w * length) / h + xs = (h / w) * (math.asinh(top) - math.asinh(v / h)) + h * length / ea + zs = (h / w) * (math.sqrt(1.0 + top * top) - math.sqrt(1.0 + (v / h) ** 2)) + ( + v * length + 0.5 * w * length * length) / ea + return xs - span, zs - rise + + h, v = newton2(residual, np.array([w * length, 0.5 * w * length]), np.array([w * length, w * length])) + return h, v + + +# ----------------------------------------------------------------------------- the chain decks + + +R3 = dict(diam=0.2466, mass=373.5, ea=1.607e9) +R4 = dict(diam=0.2791, mass=480.93, ea=2.058e9) + + +def submerged_weight(line: dict) -> float: + return (line["mass"] - RHO * math.pi / 4.0 * line["diam"] ** 2) * G + + +CHAIN = """--------------------- CableDyn Input File ------------------------------------ +Anchor uplift gate: one chain leg from a Coupled fairlead (End A) to a Fixed anchor (End B) +--------------------- 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) (-) (-) (-) (-) +chain {diam} {mass} {ea} -1.0 0.0 1.37 0.64 1.0 0.0 +--------------------- POINTS ------------------------------------------- +ID Type X Y Z Mass Vol CdA Ca +(-) (-) (m) (m) (m) (kg) (m^3) (m^2) (-) +1 Fixed {xa} 0.0 {za} 0 0 0 0 +2 Coupled 0.0 0.0 {zf} 0 0 0 0 +--------------------- LINES -------------------------------------------- +ID NodeA NodeB Outputs +(-) (-) (-) (-) +1 2 1 p +--------------------- SECTIONS ----------------------------------------- +LineID LineType Length NumSegs +(-) (-) (m) (-) +1 chain {length} {nseg} +--------------------- OPTIONS ------------------------------------------ +9.80665 g +1025.0 rhoW +{depth} WtrDpth +{kbot} kBot +--------------------- OUTPUTS ------------------------------------------ +"FairTen1" +--------------------- need this line ----------------------------------- +""" + +CHANNELS = ["FairTen1", "Point2FH", "AnchIncl1", "TDP1s", "TDP1Grd", *anchor_channels(1, 1)] + + +def chain_deck(line: dict, length: float, nseg: int, span: float, depth: float, fair_z: float, kbot: str) -> str: + deck = CHAIN.format(diam=line["diam"], mass=line["mass"], ea=line["ea"], xa=span, za=-depth, zf=fair_z, + length=length, nseg=nseg, depth=depth, kbot=kbot) + return set_outputs(deck, CHANNELS) + + +def surge_motion(path: Path, dt: float, tmax: float, offset: float, ramp: float) -> None: + """Fairlead (point 2) surge from x = 0 to x = offset with a quintic ramp, then held.""" + rows = ["# time id x y z vx vy vz ax ay az"] + for i in range(int(round(tmax / dt)) + 1): + t = i * dt + tau = min(t / ramp, 1.0) + s = 10 * tau**3 - 15 * tau**4 + 6 * tau**5 + ds = (30 * tau**2 - 60 * tau**3 + 30 * tau**4) / ramp if t < ramp else 0.0 + dds = (60 * tau - 180 * tau**2 + 120 * tau**3) / ramp**2 if t < ramp else 0.0 + rows.append("%.6f 2 %.12e 0 0 %.12e 0 0 %.12e 0 0" % (t, offset * s, offset * ds, offset * dds)) + path.write_text("\n".join(rows) + "\n", encoding="utf-8", newline="\n") + + +def main() -> int: + ap = argparse.ArgumentParser() + ap.add_argument("--exe", required=True) + ap.add_argument("--examples", required=True) + ap.add_argument("--output", required=True) + args = ap.parse_args() + out = Path(args.output) + if out.exists(): + shutil.rmtree(out) + out.mkdir(parents=True) + examples = Path(args.examples) + env = dict(os.environ) + + # --- (a) laid catenary: R3 chain, 550 m on a 500 m span at 100 m depth (the tutorial leg). The + # analytic catenary rests on a rigid seabed, so its gates use a stiff one (kBot 1e9 Pa/m: the + # chain sinks 13 microns); the tutorial's soft seabed (1e5 Pa/m) gates the end-node share. + w3 = submerged_weight(R3) + h_ref, grd_ref, _ = laid_catenary(550.0, 500.0, 100.0, w3, R3["ea"]) + for nseg, kbot in ((55, "1.0e9"), (110, "1.0e9"), (55, "1.0e5"), (110, "1.0e5")): + label = f"laid catenary, {550.0 / nseg:g} m segments, kBot {kbot}" + name = f"laid{nseg}_{kbot.replace('.', '').replace('+', '')}" + (out / f"{name}.dat").write_text(chain_deck(R3, 550.0, nseg, 500.0, 100.0, 0.0, kbot), encoding="utf-8", + newline="\n") + run(args.exe, out / f"{name}.dat", out / name, env) + hist = read_output(out / f"{name}.out") + fz, fh = float(hist.column("AnchFz1")[0]), float(hist.column("AnchFH1")[0]) + grd, s = float(hist.column("TDP1Grd")[0]), float(hist.column("TDP1s")[0]) + ds = 550.0 / nseg + if kbot == "1.0e9": + # discretisation: -2.2e-3 on 10 m segments, +5e-5 on 5 m segments + check(abs(fh - h_ref) < (3e-3 if nseg == 55 else 5e-4) * h_ref, + f"{label}: AnchFH1 {fh / 1e3:.2f} kN vs analytic horizontal tension {h_ref / 1e3:.2f} kN " + f"({(fh - h_ref) / h_ref:+.1e})") + check(abs(grd - grd_ref) < 0.5 * ds, + f"{label}: TDP1Grd {grd:.2f} m vs analytic grounded length {grd_ref:.2f} m " + f"(error {grd - grd_ref:+.2f} m, bound half a segment {0.5 * ds:g} m)") + fair_h = float(hist.column("Point2FH")[0]) + check(abs(fh - fair_h) < 1e-6 * fh, f"{label}: AnchFH1 equals the fairlead horizontal force Point2FH " + f"({(fh - fair_h) / fh:+.1e}, frictionless seabed)") + total = static_line_length(Path(f"{out / name}.Line1.p.out")) + check(abs(s + grd - total) < 1e-4, + f"{label}: TDP1s + TDP1Grd = deformed line length {total:.4f} m (difference {s + grd - total:+.1e} m)") + # the documented end-node share: -(w dL/2 + H delta/dL), delta = w/(kBot d) the sink depth + delta = w3 / (float(kbot) * R3["diam"]) + share = w3 * ds / 2.0 + fh * delta / ds + check(-1.05 * share < fz < -0.9 * w3 * ds / 2.0, + f"{label}: AnchFz1 {fz / 1e3:.2f} kN is the laid anchor's end-node share, estimate " + f"-{share / 1e3:.2f} kN (node weight -{w3 * ds / 2e3:.2f} kN): downward, not uplift") + check_anchor_point(label, out / name, 1, 1) + + # --- (b) suspended line: R4 chain 262 m on a 262.5 m chord at 200 m depth, no laid length + w4 = submerged_weight(R4) + (out / "taut.dat").write_text(chain_deck(R4, 262.0, 45, 200.0, 200.0, -30.0, "2.0e6"), encoding="utf-8", + newline="\n") + run(args.exe, out / "taut.dat", out / "taut", env) + hist = read_output(out / "taut.out") + fz, fh, ten = (float(hist.column(c)[0]) for c in ("AnchFz1", "AnchFH1", "AnchTen1")) + incl = math.radians(float(hist.column("AnchIncl1")[0])) + h_t, v_t = suspended_catenary(262.0, 200.0, 170.0, w4, R4["ea"]) + check(abs(fh - h_t) < 1e-3 * ten and abs(fz - v_t) < 1e-3 * ten, + f"suspended line: AnchFH1/AnchFz1 {fh / 1e6:.4f}/{fz / 1e6:.4f} MN vs analytic elastic catenary " + f"{h_t / 1e6:.4f}/{v_t / 1e6:.4f} MN (differences {(fh - h_t) / ten:+.1e}, {(fz - v_t) / ten:+.1e} of AnchTen)") + node_w = w4 * (262.0 / 45) / 2.0 + check(abs(fz + node_w - fh * math.tan(incl)) < 2e-4 * ten, + f"suspended line: AnchFz1 + end-node weight = AnchFH1 tan(AnchIncl1) (difference " + f"{(fz + node_w - fh * math.tan(incl)) / ten:+.1e} of AnchTen): the end force is the anchor " + "segment's pull plus the anchor node's weight") + check(fz > 0.5 * ten and float(hist.column("TDP1Grd")[0]) == 0.0, + f"suspended line: AnchFz1 = {fz / 1e6:.3f} MN uplift and TDP1Grd = 0 (only the anchor node touches)") + check_anchor_point("suspended line", out / "taut", 1, 1) + + # --- (d) dynamics: a 42 m fairlead surge away from the anchor lifts the laid chain off it + dt, tmax, offset, ramp = 0.05, 100.0, -42.0, 60.0 + surge_motion(out / "surge.txt", dt, tmax, offset, ramp) + deck = chain_deck(R3, 550.0, 55, 500.0, 100.0, 0.0, "1.0e5") + deck = set_option(deck, "dtM", str(dt)) + deck = set_option(deck, "TMax", str(tmax)) + deck = set_option(deck, "motionFile", "surge.txt") + (out / "lift.dat").write_text(deck, encoding="utf-8", newline="\n") + run(args.exe, out / "lift.dat", out / "lift", env) + hist = read_output(out / "lift.out") + fz, grd, s = hist.column("AnchFz1"), hist.column("TDP1Grd"), hist.column("TDP1s") + finite = all(bool(np.all(np.isfinite(hist.column(c)))) for c in CHANNELS) + check(finite and hist.time.size == 2001, f"surge: every channel is finite at all {hist.time.size} rows") + check_anchor_point("surge", out / "lift", 1, 1) + total = line_lengths(Path(f"{out / 'lift'}.Line1.p.out")) + laid = grd > 0.0 + worst = float(np.max(np.abs((s + grd - total)[laid]))) + check(worst < 2e-4, f"surge: TDP1s + TDP1Grd = deformed line length while chain is laid (max difference " + f"{worst:.1e} m over {int(np.count_nonzero(laid))} rows)") + check(bool(np.all(fz[laid] < 0.0)) and bool(np.all(grd[fz > 0.0] == 0.0)), + "surge: TDP1Grd > 0 implies AnchFz1 < 0, and AnchFz1 > 0 implies TDP1Grd = 0, at every row") + lift, bare = int(np.argmax(fz > 0.0)), int(np.argmax(grd == 0.0)) + check(fz[0] < 0.0 and grd[0] > 390.0 and fz[-1] > 0.0 and grd[-1] == 0.0 and bool(np.all(fz[lift:] > 0.0)) + and bool(np.all(grd[bare:] == 0.0)) and 0.0 <= hist.time[lift] - hist.time[bare] < 1.0, + f"surge: AnchFz1 {fz[0] / 1e3:.1f} -> {fz[-1] / 1e3:.1f} kN and TDP1Grd {grd[0]:.1f} -> {grd[-1]:.1f} m; " + f"the grounded length reaches 0 at t = {hist.time[bare]:.2f} s and the anchor lifts (AnchFz1 > 0) at " + f"t = {hist.time[lift]:.2f} s, both for the rest of the run") + h_end, v_end = suspended_catenary(550.0, 500.0 - offset, 100.0, w3, R3["ea"]) + fz_end, fh_end = float(np.mean(fz[hist.time >= 80.0])), float(np.mean(hist.column("AnchFH1")[hist.time >= 80.0])) + check(abs(fh_end - h_end) < 5e-3 * h_end and abs(fz_end - v_end) < 3e-3 * h_end, + f"surge: held state AnchFH1/AnchFz1 {fh_end / 1e6:.4f} MN/{fz_end / 1e3:.1f} kN vs suspended elastic catenary " + f"{h_end / 1e6:.4f} MN/{v_end / 1e3:.1f} kN") + + # --- (e) finite-EI lazy wave (cubic-Hermite route) under prescribed heave, End B on the seabed + src = (examples / "lozon_gomex80_power_cable_motion.dat").read_text(encoding="utf-8") + shutil.copytree(examples / "data", out / "data") + motion = out / "data" / "lozon" / "gomex80_heave_3m_12s_dt005.txt" + rows = [r for r in motion.read_text(encoding="utf-8").splitlines() if r.startswith("#") or float(r.split()[0]) <= 3.0001] + (out / "heave3.txt").write_text("\n".join(rows) + "\n", encoding="utf-8", newline="\n") + deck = set_line_flag(src, 1, "p") + deck = set_option(deck, "TMax", "3.0") + deck, n_motion = re.subn(r"^\S+\s+motionFile.*$", "heave3.txt motionFile", deck, flags=re.M) + if n_motion != 1: + raise RuntimeError("expected one motionFile row in the lazy-wave deck, found %d" % n_motion) + deck = set_outputs(deck, ["FairTen1", "TDP1s", "TDP1Grd", *anchor_channels(1, 2)]) + (out / "lazywave.dat").write_text(deck, encoding="utf-8", newline="\n") + run(args.exe, out / "lazywave.dat", out / "lazywave", env) + hist = read_output(out / "lazywave.out") + check_anchor_point("cubic-Hermite lazy wave", out / "lazywave", 1, 2) + total = line_lengths(Path(f"{out / 'lazywave'}.Line1.p.out")) + grd = hist.column("TDP1Grd") + worst = float(np.max(np.abs(hist.column("TDP1s") + grd - total))) + check(bool(np.all(grd > 30.0)) and worst < 2e-4, + f"cubic-Hermite lazy wave: TDP1Grd {grd.min():.2f}..{grd.max():.2f} m and TDP1s + TDP1Grd = line length " + f"(max difference {worst:.1e} m)") + fz = hist.column("AnchFz1") + check(bool(np.all(np.abs(fz) <= 1e-9 * hist.column("AnchTen1"))), + f"cubic-Hermite lazy wave: the grounded end leaves its node weight to the floor (|AnchFz1| <= " + f"{np.max(np.abs(fz)):.1e} N)") + + # --- (c) the other routes: point system (Free clump weight), mixed aggregate, multibody march + src = (examples / "clump_weight_free_point.dat").read_text(encoding="utf-8") + deck = set_outputs(set_option(src, "TMax", "0.5"), ["FairTen1", *anchor_channels(1, 2)]) + (out / "freepoint.dat").write_text(deck, encoding="utf-8", newline="\n") + run(args.exe, out / "freepoint.dat", out / "freepoint", env) + check_anchor_point("Free point (point system)", out / "freepoint", 1, 2) + hist = read_output(out / "freepoint.out") + check(bool(np.all(hist.column("AnchFz1") > 0.0)), + "Free point (point system): the hanging line pulls its clump weight upward (AnchFz1 > 0)") + + src = (examples / "iea15mw_umaine_mixed_cabledyn.dat").read_text(encoding="utf-8") + deck = set_option(src, "TMax", "0.5") + names = ["TDP1s", "TDP1Grd", "TDP4s", "TDP4Grd", *anchor_channels(1, 2), *anchor_channels(4, 8)] + deck = set_outputs(deck, names) + (out / "mixed.dat").write_text(deck, encoding="utf-8", newline="\n") + run(args.exe, out / "mixed.dat", out / "mixed", env) + check_anchor_point("mixed aggregate, EI = 0 chain", out / "mixed", 1, 2) + check_anchor_point("mixed aggregate, finite-EI cable", out / "mixed", 4, 8) + hist = read_output(out / "mixed.out") + check(bool(np.all(hist.column("TDP1Grd") > 0.0)) and bool(np.all(hist.column("AnchFz1") < 0.0)) and + bool(np.all(hist.column("TDP4Grd") > 0.0)), + f"mixed aggregate: laid chain (TDP1Grd {hist.column('TDP1Grd')[0]:.1f} m, AnchFz1 " + f"{hist.column('AnchFz1')[0] / 1e3:.2f} kN) and laid cable (TDP4Grd {hist.column('TDP4Grd')[0]:.1f} m)") + + src = (examples / "rigid6_buoy.dat").read_text(encoding="utf-8") + deck = set_outputs(set_option(src, "TMax", "0.2"), [*anchor_channels(1, 4), *anchor_channels(2, 5)]) + (out / "rigid6.dat").write_text(deck, encoding="utf-8", newline="\n") + run(args.exe, out / "rigid6.dat", out / "rigid6", env) + check_anchor_point("multibody march, line 1", out / "rigid6", 1, 4) + check_anchor_point("multibody march, line 2", out / "rigid6", 2, 5) + + # --- fail-closed contracts + bad = set_outputs(chain_deck(R3, 550.0, 55, 500.0, 100.0, 0.0, "1.0e5"), ["AnchFz2"]) + (out / "bad_line.dat").write_text(bad, encoding="utf-8", newline="\n") + proc = subprocess.run([args.exe, str(out / "bad_line.dat"), str(out / "bad_line")], capture_output=True, + text=True, env=env) + check(proc.returncode == 1 and "unknown line id" in proc.stderr, "AnchFz of an unknown line is rejected") + bad = set_outputs(chain_deck(R3, 550.0, 55, 500.0, 100.0, 0.0, "1.0e5").replace( + "0.0 0.0 0.0 ", "0.0 0.0 -100.0"), ["TDP1Grd"]) + (out / "bad_tdp.dat").write_text(bad, encoding="utf-8", newline="\n") + proc = subprocess.run([args.exe, str(out / "bad_tdp.dat"), str(out / "bad_tdp")], capture_output=True, + text=True, env=env) + check(proc.returncode != 0 and "exactly one end" in proc.stderr, + "TDP1Grd of a line grounded at both ends is rejected, as the other TDP channels") + # a finite-EI line shared by two turbines: both ends move (the two-moving-end route) + two_end = """two-moving-end finite-EI line +--- LINE TYPES --- +Name Diam Mass EA BA EI Cdn Cdt Can Cat +(-) (m) (kg/m) (N) (-) (Nm2) (-) (-) (-) (-) +pcable 0.20 250 8.0e8 0.0 2.0e5 1.0 0.0 1.0 0.0 +--- TURBINES --- +J X0 Y0 Z0 PtfmSurge PtfmSway PtfmHeave PtfmRoll PtfmPitch PtfmYaw +1 0.0 0.0 0 0 0 0 0 0 0 +2 60.0 0.0 0 0 0 0 0 0 0 +--- POINTS --- +ID Type X Y Z Mass Vol CdA Ca +(-) (-) (m) (m) (m) (kg) (m3) (m2) (-) +1 Turbine1 0 0 -20 0 0 0 0 +2 Turbine2 0 0 -20 0 0 0 0 +--- LINES --- +ID NodeA NodeB Outputs +(-) (-) (-) (-) +1 1 2 - +--- SECTIONS --- +LineID LineType Length NumSegs +(-) (-) (m) (-) +1 pcable 75 5 +--- OPTIONS --- +9.80665 g +1025.0 rhoW +0.005 dtM +0.01 TMax +--- OUTPUTS --- +AnchTen1 AnchFz1 +--- need this line --- +""" + (out / "two_end.dat").write_text(two_end, encoding="utf-8", newline="\n") + proc = subprocess.run([args.exe, str(out / "two_end.dat"), str(out / "two_end")], capture_output=True, + text=True, env=env) + check(proc.returncode != 0 and "AnchFz/AnchFH channels are not available on the two-moving-end" in + proc.stdout + proc.stderr, "the two-moving-end finite-EI route rejects AnchFz by name") + + print(f"{len(FAILURES)} failure(s)") + return 1 if FAILURES else 0 + + +if __name__ == "__main__": + sys.exit(main()) diff --git a/tests/test_cable_statics_matrix.py b/tests/test_cable_statics_matrix.py index b1be2c32..ad2b0f5f 100644 --- a/tests/test_cable_statics_matrix.py +++ b/tests/test_cable_statics_matrix.py @@ -122,16 +122,29 @@ def run_measured(cmd: list, cwd: str, env: dict, wall_limit: float): def read_static(path: Path) -> dict: - """Node rows of the static profile per line: [s, x, y, z, T].""" + """Node rows of the static profile per line: [s, x, y, z, T, curvature, bend moment].""" out: dict = {} for ln in path.read_text(encoding="utf-8").splitlines()[3:]: f = ln.split() - if len(f) < 7: + if len(f) < 9: continue - out.setdefault(int(f[0]), []).append([float(v) for v in f[2:7]]) + out.setdefault(int(f[0]), []).append([float(v) for v in f[2:9]]) return out +def material_axial_force(row: list) -> float: + """Material axial force EA (|r'| - 1) at a profile node. + + Why: the Tension column is the effective tension N = F . t recovered from nodal + equilibrium. The cubic-Hermite bending energy EI/2 |r''|^2 makes the material axial force + EA (|r'| - 1) = N + EI kappa^2 = Tension + BendMoment * Curvature, and the compression + notes judge material strain (element-mean EA (|r'| - 1)), so the matrix holds the notes to + the same quantity. At a tight bend N alone can be compressive while the material is in + tension (SW_1003: an end clamped into the seabed, kappa = 1.12 1/m). + """ + return row[4] + row[6] * row[5] + + def read_end_forces(path: Path, every_row: bool = False): """FairTen/AnchTen channels of the first output row (t = 0), or of every row.""" rows = path.read_text(encoding="utf-8").splitlines() @@ -249,8 +262,8 @@ def check_case(case: dict, res: dict) -> list: continue if self_intersects([r[1:4] for r in rows]): errs.append("line %s crosses itself" % lid) - tmin = min(r[4] for r in rows) - tmax = max(r[4] for r in rows) + tmin = min(material_axial_force(r) for r in rows) + tmax = max(material_axial_force(r) for r in rows) # only the compression notes waive nodal compression ("line N carries element-mean axial # compression ..." and the "line N: mesh too coarse for its bends" variant) noted = ("Note: line %s carries element-mean axial compression" % lid) in log or ( diff --git a/tests/test_deck_driver.f90 b/tests/test_deck_driver.f90 index cafe53cf..75ff7106 100644 --- a/tests/test_deck_driver.f90 +++ b/tests/test_deck_driver.f90 @@ -1842,6 +1842,16 @@ SUBROUTINE check_parser_hardening() CALL require(tok_ok(1) .AND. tok_ok(2), 'channel gate admits well-formed TDP tokens') CALL require(.NOT. tok_ok(3) .AND. .NOT. tok_ok(4), 'channel gate rejects a malformed TDP suffix') END BLOCK + ! ... and the anchor uplift channels: AnchFz, AnchFH, TDPGrd + BLOCK + LOGICAL :: tok_ok(7) + tok_ok = [CD_Channel_Token_Parses('AnchFz1'), CD_Channel_Token_Parses('ANCHFH012'), & + CD_Channel_Token_Parses('TDP3Grd'), CD_Channel_Token_Parses('AnchFz'), & + CD_Channel_Token_Parses('AnchFz0'), CD_Channel_Token_Parses('AnchFz1x'), & + CD_Channel_Token_Parses('TDP1Grdx')] + CALL require(ALL(tok_ok(1:3)), 'channel gate admits AnchFz, AnchFH and TDPGrd tokens') + CALL require(.NOT. ANY(tok_ok(4:7)), 'channel gate rejects malformed anchor uplift tokens') + END BLOCK ! the synthesised sea is bounded in total components, not only per factor BLOCK CHARACTER(1) :: nl diff --git a/tests/test_flagship_compression_note.f90 b/tests/test_flagship_compression_note.f90 index ba4329c3..47ab8401 100644 --- a/tests/test_flagship_compression_note.f90 +++ b/tests/test_flagship_compression_note.f90 @@ -10,9 +10,11 @@ PROGRAM test_flagship_compression_note !! positive, and that is the quantity the static note is gated on. !! !! The node Tension channel Ten4N (static profile, standalone and coupled outputs) is - !! the segment tension: at interior nodes the length-weighted average of the two adjacent - !! element-mean axial forces, recomputed here independently; at the ends the end force. - !! It stays within the end tensions instead of the pointwise spikes at the touchdown. + !! the effective tension recovered from nodal equilibrium; at the ends the end force. On the + !! suspended part it is checked here against the statics of the free body between the node + !! and the fairlead: the fairlead force less the submerged weight of the elements in between, + !! projected on the nodal tangent. It stays within the end tensions instead of the pointwise + !! spikes at the touchdown. !! !! 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. @@ -21,6 +23,7 @@ PROGRAM test_flagship_compression_note USE CableDyn_HermiteCableStatic, ONLY: CD_HermiteCable_Branch_Audit, CD_HermiteBranchAuditType, CD_HCSTAT_OK USE CableDyn_HermiteCable, ONLY: CD_HermiteCable_Axial_Resultant USE CableDyn_DeckDriver, ONLY: CD_Eval_Aggregate_Channel + USE CableDyn_HermiteCableDynamic, ONLY: CD_HermiteCable_Dyn_End_Force, CD_HCDYN_OK IMPLICIT NONE TYPE(CD_AGG_ModuleType) :: agg @@ -29,7 +32,8 @@ PROGRAM test_flagship_compression_note CHARACTER(512) :: em INTEGER :: es, i, nfail, nn, j, inode, k REAL(wp), ALLOCATABLE :: ten(:), emean(:) - REAL(wp) :: qe(12), ng, expect, dev_max, t_end + REAL(wp) :: qe(12), ng, expect, dev_max, t_end, fair(3), sec(3), tan_j(3) + INTEGER :: first_free, n_checked CHARACTER(32) :: ch REAL(wp), PARAMETER :: G3X(3) = [0.5_wp - 0.5_wp*SQRT(0.6_wp), 0.5_wp, 0.5_wp + 0.5_wp*SQRT(0.6_wp)] REAL(wp), PARAMETER :: G3W(3) = [5.0_wp/18.0_wp, 8.0_wp/18.0_wp, 5.0_wp/18.0_wp] @@ -81,21 +85,46 @@ PROGRAM test_flagship_compression_note emean(j) = emean(j) + G3W(k)*ng END DO END DO - dev_max = 0.0_wp + WRITE (*, '(A,2ES12.4)') ' element-mean axial force min, max [N]: ', MINVAL(emean), MAXVAL(emean) DO j = 1, nn WRITE (ch, '(A,I0)') 'Ten4N', j CALL CD_Eval_Aggregate_Channel(TRIM(ch), agg%has_sys, agg%sys%fast%system, agg%cables, & agg%line_is_cable, agg%line_obj_index, ten(j), es, em) IF (es /= 0) CALL check(.FALSE., 'node Tension channel '//TRIM(ch)//': '//TRIM(em)) - inode = nn - j + 1 - IF (inode > 1 .AND. inode < nn) THEN - expect = (ln%l0(inode - 1)*emean(inode - 1) + ln%l0(inode)*emean(inode))/(ln%l0(inode - 1) + ln%l0(inode)) - dev_max = MAX(dev_max, ABS(ten(j) - expect)) + END DO + ! Suspended run next to the fairlead (internal nodes first_free .. nn): no node from + ! first_free - 1 on touches the seabed (1 cm clearance), so the only loads between an + ! interior node and the fairlead, and in the element before it, are the consistent + ! submerged weights of the elements (the reaction of a grounded node is spread over its + ! tributary length, into the element after it). + first_free = 2 + DO k = nn, 1, -1 + IF (ln%q(6*(k - 1) + 3) <= ln%seabed_z + 0.01_wp) THEN + first_free = k + 2 + EXIT END IF END DO + CALL CD_HermiteCable_Dyn_End_Force(ln, nn, fair, es, em) + CALL check(es == CD_HCDYN_OK, 'fairlead end force evaluated: '//TRIM(em)) + sec = -fair ! force of the fairlead on the line + dev_max = 0.0_wp + n_checked = 0 + DO inode = nn - 1, first_free, -1 + sec(3) = sec(3) - ln%w(inode)*ln%l0(inode) + tan_j = ln%q(6*(inode - 1) + 4:6*(inode - 1) + 6) + expect = DOT_PRODUCT(sec, tan_j)/NORM2(tan_j) + dev_max = MAX(dev_max, ABS(ten(nn - inode + 1) - expect)) + n_checked = n_checked + 1 + END DO t_end = MAX(ten(1), ten(nn)) WRITE (*, '(A,3ES12.4)') ' node Tension min, max, max end tension [N]: ', MINVAL(ten), MAXVAL(ten), t_end - CALL check(dev_max <= 1.0e-6_wp*t_end, 'interior node Tension is the length-weighted element-mean average') + WRITE (*, '(A,I0,A,ES12.4)') ' suspended nodes checked against the free-body statics: ', n_checked, & + '; largest difference [N]: ', dev_max + CALL check(n_checked > 40, 'the suspended run spans the sag and hog bends') + ! The initialised state keeps a consistent acceleration of order 1e-4 m/s^2, whose inertia + ! the recovery includes and the free-body statics leave out (0.03 N here): 1e-5 of the + ! end tension bounds it; the element-mean axial force dips to -1.98 kN at the touchdown. + CALL check(dev_max <= 1.0e-5_wp*t_end, 'interior node Tension is the free-body effective tension') CALL check(MINVAL(ten) > -0.1_wp*MAXVAL(ten), 'node Tension carries no compression beyond a tenth of the peak') CALL check(MAXVAL(ten) <= 1.001_wp*t_end, 'node Tension peaks at the line end, not at the touchdown') END ASSOCIATE diff --git a/tests/test_l3_lazywave_3d_dynamic.f90 b/tests/test_l3_lazywave_3d_dynamic.f90 index 194fa006..007f144e 100644 --- a/tests/test_l3_lazywave_3d_dynamic.f90 +++ b/tests/test_l3_lazywave_3d_dynamic.f90 @@ -37,7 +37,7 @@ PROGRAM test_l3_lazywave_3d_dynamic USE CableDyn_HermiteCableStatic, ONLY: CD_HermiteCable_Static_Solve, CD_HCSTAT_OK USE CableDyn_HermiteCableDynamic, ONLY: CD_HermiteCableDynType, CD_HermiteCable_Dyn_Init, & CD_HermiteCable_Dyn_Set_Drag, CD_HermiteCable_Dyn_Set_AddedMass, & - CD_HermiteCable_Dyn_Step, CD_HermiteCable_Dyn_Curvature, & + CD_HermiteCable_Dyn_Step, CD_HermiteCable_Dyn_Curvature_Exact, & CD_HermiteCable_Dyn_End, CD_HCDYN_OK IMPLICIT NONE @@ -213,7 +213,7 @@ PROGRAM test_l3_lazywave_3d_dynamic END IF steps_done = steps_done + 1 IF (t >= T_SCORE) THEN - CALL CD_HermiteCable_Dyn_Curvature(model, cdyn, es, em) + CALL CD_HermiteCable_Dyn_Curvature_Exact(model, cdyn, es, em) DO i = 1, nn arc_i = REAL(i - 1, wp)*l0e IF (arc_i >= 0.03_wp*Lsus .AND. arc_i <= 0.97_wp*Lsus) THEN diff --git a/tests/test_l3_lazywave_dynamic.f90 b/tests/test_l3_lazywave_dynamic.f90 index b18d7ad1..703c4fd6 100644 --- a/tests/test_l3_lazywave_dynamic.f90 +++ b/tests/test_l3_lazywave_dynamic.f90 @@ -56,7 +56,7 @@ PROGRAM test_l3_lazywave_dynamic CD_HermiteCable_Dyn_Set_Drag, CD_HermiteCable_Dyn_Set_AddedMass, & CD_HermiteCable_Dyn_Step, CD_HermiteCable_Dyn_Step_Recovering, & CD_HermiteCable_Dyn_Recovery_Count, CD_HermiteCable_Dyn_Recovery_Reset, & - CD_HermiteCable_Dyn_Curvature, & + CD_HermiteCable_Dyn_Curvature_Exact, & CD_HermiteCable_Dyn_End, CD_HCDYN_OK IMPLICIT NONE @@ -360,7 +360,7 @@ SUBROUTINE run_site(is) IF (t >= T_SCORE) THEN cycle_index = MIN(3, MAX(1, INT((t - T_SCORE + 1.0e-9_wp)/PER) + 1)) step_peak = 0.0_wp - CALL CD_HermiteCable_Dyn_Curvature(model, cdyn, es, em) + CALL CD_HermiteCable_Dyn_Curvature_Exact(model, cdyn, es, em) DO e = 1, ne qr(1:6) = model%q(6*(e - 1) + 1:6*e) qr(7:12) = model%q(6*e + 1:6*(e + 1)) @@ -786,7 +786,7 @@ SUBROUTINE refined_dynamic_response(l0, q0, eav, eiv, w, rhoa, diam, cdn, cdt, c minimum_axial = MIN(minimum_axial, axial_now) IF (k > peak) THEN; peak = k; peak_arc = arc; END IF cycle_peak(cycle_index) = MAX(cycle_peak(cycle_index), k) - CALL CD_HermiteCable_Dyn_Curvature(dyn, nodal_curvature, es, em) + CALL CD_HermiteCable_Dyn_Curvature_Exact(dyn, nodal_curvature, es, em) IF (es /= CD_HCDYN_OK) THEN; CALL CD_HermiteCable_Dyn_End(dyn); RETURN; END IF curvature_profile = MAX(curvature_profile, nodal_curvature) mnorm = NORM2(dyn%q(4:6)); tension = EA*(mnorm - 1.0_wp)/1000.0_wp diff --git a/tests/test_l3_lazywave_irregular.f90 b/tests/test_l3_lazywave_irregular.f90 index 3f603c2b..33240044 100644 --- a/tests/test_l3_lazywave_irregular.f90 +++ b/tests/test_l3_lazywave_irregular.f90 @@ -37,7 +37,7 @@ PROGRAM test_l3_lazywave_irregular USE CableDyn_HermiteCableDynamic, ONLY: CD_HermiteCableDynType, CD_HermiteCable_Dyn_Init, & CD_HermiteCable_Dyn_Set_Drag, CD_HermiteCable_Dyn_Set_AddedMass, & CD_HermiteCable_Dyn_Set_Irregular_Waves, & - CD_HermiteCable_Dyn_Step, CD_HermiteCable_Dyn_Curvature, & + CD_HermiteCable_Dyn_Step, CD_HermiteCable_Dyn_Curvature_Exact, & CD_HermiteCable_Dyn_End, CD_HCDYN_OK IMPLICIT NONE @@ -239,7 +239,7 @@ PROGRAM test_l3_lazywave_irregular END IF steps_done = steps_done + 1 IF (t >= T_SCORE) THEN - CALL CD_HermiteCable_Dyn_Curvature(model, cdyn, es, em) + CALL CD_HermiteCable_Dyn_Curvature_Exact(model, cdyn, es, em) DO i = 1, nn arc_i = REAL(i - 1, wp)*l0e IF (arc_i >= 0.03_wp*Lsus .AND. arc_i <= 0.97_wp*Lsus) kdyn = MAX(kdyn, cdyn(i)) diff --git a/tests/test_l3_lazywave_touchdown_dynamic.f90 b/tests/test_l3_lazywave_touchdown_dynamic.f90 index b2639f94..25a7dd24 100644 --- a/tests/test_l3_lazywave_touchdown_dynamic.f90 +++ b/tests/test_l3_lazywave_touchdown_dynamic.f90 @@ -33,7 +33,7 @@ PROGRAM test_l3_lazywave_touchdown_dynamic USE CableDyn_HermiteCableStatic, ONLY: CD_HermiteCable_Static_Solve_Sequenced, CD_HCSTAT_OK USE CableDyn_HermiteCableDynamic, ONLY: CD_HermiteCableDynType, CD_HermiteCable_Dyn_Init, & CD_HermiteCable_Dyn_Set_Drag, CD_HermiteCable_Dyn_Set_AddedMass, & - CD_HermiteCable_Dyn_Step, CD_HermiteCable_Dyn_Curvature, & + CD_HermiteCable_Dyn_Step, CD_HermiteCable_Dyn_Curvature_Exact, & CD_HermiteCable_Dyn_End, CD_HCDYN_OK IMPLICIT NONE @@ -183,7 +183,7 @@ PROGRAM test_l3_lazywave_touchdown_dynamic END IF steps_done = steps_done + 1 IF (t >= T_SCORE) THEN - CALL CD_HermiteCable_Dyn_Curvature(model, cdyn, es, em) + CALL CD_HermiteCable_Dyn_Curvature_Exact(model, cdyn, es, em) DO i = 1, nn arc_i = REAL(i - 1, wp)*l0e IF (arc_i >= 0.03_wp*LTOT .AND. arc_i <= 0.97_wp*LTOT) kdyn = MAX(kdyn, cdyn(i)) diff --git a/tests/test_l4_lazywave_coupled.f90 b/tests/test_l4_lazywave_coupled.f90 index 635c75c2..85db726d 100644 --- a/tests/test_l4_lazywave_coupled.f90 +++ b/tests/test_l4_lazywave_coupled.f90 @@ -31,7 +31,7 @@ PROGRAM test_l4_lazywave_coupled USE CableDyn_HermiteCableStatic, ONLY: CD_HermiteCable_Static_Solve, CD_HCSTAT_OK USE CableDyn_HermiteCableDynamic, ONLY: CD_HermiteCableDynType, CD_HermiteCable_Dyn_Init, & CD_HermiteCable_Dyn_Set_Drag, CD_HermiteCable_Dyn_Set_AddedMass, & - CD_HermiteCable_Dyn_Step, CD_HermiteCable_Dyn_Curvature, & + CD_HermiteCable_Dyn_Step, CD_HermiteCable_Dyn_Curvature_Exact, & CD_HermiteCable_Dyn_End, CD_HCDYN_OK IMPLICIT NONE @@ -301,7 +301,7 @@ SUBROUTINE run_site(is) CALL require(.FALSE., TRIM(names(is))//' dynamic step stalled: '//TRIM(em)); EXIT END IF IF (t >= T_SCORE) THEN - CALL CD_HermiteCable_Dyn_Curvature(model, cdyn, es, em) + CALL CD_HermiteCable_Dyn_Curvature_Exact(model, cdyn, es, em) DO i = 1, nn arc_i = REAL(i - 1, wp)*l0e IF (arc_i >= 0.03_wp*Lsus .AND. arc_i <= 0.97_wp*Lsus) kdyn_max = MAX(kdyn_max, cdyn(i)) diff --git a/tests/test_lazywave_dynamics.f90 b/tests/test_lazywave_dynamics.f90 index b41ac1a3..d746ec2f 100644 --- a/tests/test_lazywave_dynamics.f90 +++ b/tests/test_lazywave_dynamics.f90 @@ -30,7 +30,7 @@ PROGRAM test_lazywave_dynamics USE CableDyn_HermiteCableDynamic, ONLY: CD_HermiteCableDynType, CD_HermiteCable_Dyn_Init, & CD_HermiteCable_Dyn_Set_Drag, CD_HermiteCable_Dyn_Set_AddedMass, & CD_HermiteCable_Dyn_Set_Waves, & - CD_HermiteCable_Dyn_Step, CD_HermiteCable_Dyn_Curvature, & + CD_HermiteCable_Dyn_Step, CD_HermiteCable_Dyn_Curvature_Exact, & CD_HermiteCable_Dyn_End, CD_HCDYN_OK IMPLICIT NONE @@ -172,7 +172,8 @@ PROGRAM test_lazywave_dynamics IF (es /= CD_HCDYN_OK) THEN CALL require(.FALSE., 'heave-driven step stalled: '//TRIM(em)); EXIT END IF - CALL CD_HermiteCable_Dyn_Curvature(model, cdyn, es, em) + ! the geometric curvature, the quantity of the static reference kstat + CALL CD_HermiteCable_Dyn_Curvature_Exact(model, cdyn, es, em) k_now = MAXVAL(cdyn) kdyn_max = MAX(kdyn_max, k_now); kdyn_min = MIN(kdyn_min, k_now) maxpos = MAX(maxpos, nan_max_abs(model%q - q_static)) ! max excursion from the static shape @@ -226,7 +227,7 @@ PROGRAM test_lazywave_dynamics IF (es /= CD_HCDYN_OK) THEN CALL require(.FALSE., 'full-hydro step stalled: '//TRIM(em)); EXIT END IF - CALL CD_HermiteCable_Dyn_Curvature(model, cdyn, es, em) + CALL CD_HermiteCable_Dyn_Curvature_Exact(model, cdyn, es, em) k_now = MAXVAL(cdyn) kdyn_max = MAX(kdyn_max, k_now); kdyn_min = MIN(kdyn_min, k_now) maxpos = MAX(maxpos, nan_max_abs(model%q - q_static)) diff --git a/tests/test_openfast_aggregate.f90 b/tests/test_openfast_aggregate.f90 index fe58f15a..56f52f54 100644 --- a/tests/test_openfast_aggregate.f90 +++ b/tests/test_openfast_aggregate.f90 @@ -42,12 +42,13 @@ PROGRAM test_openfast_aggregate CD_FMF_GetMovingPointMesh, CD_FMF_Step_Moving, CD_FMF_CalcOutput, & CD_FMF_End, CD_FMF_OK USE CableDyn_OpenFAST_HermiteFMF, ONLY: CD_HFMF_Restore, CD_HFMF_MinSpanZ, CD_HFMF_Curvature, CD_HFMF_CalcOutput, & - CD_HFMF_OK, & + CD_HFMF_OK, CD_HFMF_Curvature_Exact, & CD_HFMF_MirrorSize, CD_HFMF_PackMirror, CD_HFMF_UnpackMirror ! Public driver-side evaluators, used to cross-check the shell channel path against the ! standalone driver's channel definitions on the aggregate's own static configuration. USE CableDyn_DeckDriver, ONLY: tangent_declination_deg - USE CableDyn_HermiteCableDynamic, ONLY: CD_HermiteCable_Dyn_Reset_Profile, CD_HermiteCable_Dyn_Get_Profile + USE CableDyn_HermiteCableDynamic, ONLY: CD_HermiteCable_Dyn_Reset_Profile, CD_HermiteCable_Dyn_Get_Profile, & + CD_HermiteCable_Dyn_Set_Output_Recovery USE CableDyn_Model, ONLY: CD_Get_Model_EndForces, CD_MODEL_OK USE CableDyn_System, ONLY: CD_System_NSystemCoupledDOF, CD_Get_System_CoupledMotion, & CD_Update_System_CoupledMotion, & @@ -114,6 +115,7 @@ PROGRAM test_openfast_aggregate CALL case_pure_mooring_equals_fmf() CALL case_mixed_deck_composition() CALL case_touchdown_cable_end_tension() + CALL case_anchor_uplift_channels() CALL case_output_channels() CALL case_pure_cable_deck() CALL case_cable_load_feedback() @@ -805,16 +807,30 @@ SUBROUTINE case_output_channels() END BLOCK CALL require(vFairTen2 > 1.0e3_wp, 'chan:FairTen2-physical') - ! (b) cable Curv1N5 is the exact one-sided Hermite curvature at deck node 5, - ! conservatively retaining the larger adjacent-element trace. The channel and - ! public HFMF recovery must share that definition. + ! (b) cable Curv1N5 and the public HFMF nodal curvature share one definition at deck node 5: + ! the bend moment recovered from nodal equilibrium over EI by default, and under + ! OutputRecovery element the exact one-sided Hermite curvature, the larger adjacent-element + ! trace (CD_HFMF_Curvature_Exact). The channel follows the cable's setting. nnode = agg%cables(1)%line%nn ALLOCATE (exact_curvature(nnode)) CALL CD_HFMF_Curvature(agg%cables(1), exact_curvature, es, em) - CALL require(es == CD_HFMF_OK, 'chan:exact-Hermite-curvature: '//TRIM(em)) + CALL require(es == CD_HFMF_OK, 'chan:recovered-curvature: '//TRIM(em)) kexp = exact_curvature(nnode - 5 + 1) CALL require(ABS(vCurv1N5 - kexp) <= 1.0e-9_wp + 1.0e-6_wp*ABS(kexp), 'chan:Curv1N5-matches-driver') CALL require(vCurv1N5 > 0.0_wp, 'chan:Curv1N5-nonzero') + CALL CD_HFMF_Curvature_Exact(agg%cables(1), exact_curvature, es, em) + CALL require(es == CD_HFMF_OK, 'chan:exact-Hermite-curvature: '//TRIM(em)) + CALL CD_HermiteCable_Dyn_Set_Output_Recovery(agg%cables(1)%line, .TRUE.) + BLOCK + REAL(wp) :: k_element(nnode), v_element + CALL CD_HFMF_Curvature(agg%cables(1), k_element, es, em) + CALL require(es == CD_HFMF_OK .AND. MAXVAL(ABS(k_element - exact_curvature)) <= 0.0_wp, & + 'chan:element-recovery-curvature-is-the-exact-trace') + CALL CD_AGG_EvalChannel(agg, 3, v_element, es, em) + CALL require(es == CD_AGG_OK .AND. ABS(v_element - exact_curvature(nnode - 5 + 1)) <= & + 1.0e-9_wp + 1.0e-6_wp*ABS(exact_curvature(nnode - 5 + 1)), 'chan:Curv1N5-element-matches-driver') + END BLOCK + CALL CD_HermiteCable_Dyn_Set_Output_Recovery(agg%cables(1)%line, .FALSE.) ! (c) cable FairAngle1 == declination of the End-A one-sided tangent (deck nodes 1,2). base = 6*(nnode - 1); r1 = agg%cables(1)%line%q(base + 1:base + 3) @@ -4259,13 +4275,80 @@ SUBROUTINE case_touchdown_cable_end_tension() !! grounded run's tension H (~1.2 kN). The node-sampled stretch EA*(|dr/ds| - 1) at the held !! anchor read 78 kN; the element end force equals H. TYPE(CD_AGG_ModuleType) :: agg - INTEGER :: u, ios, es, k + INTEGER :: es, k REAL(wp) :: v(3) CHARACTER(512) :: em REAL(wp), PARAMETER :: DT = 0.025_wp - OPEN (NEWUNIT=u, FILE='agg_touchdown_cable.dat', STATUS='REPLACE', ACTION='WRITE', IOSTAT=ios) - CALL require(ios == 0, 'touchdown: create deck') + CALL write_touchdown_cable_deck('agg_touchdown_cable.dat', 'FairTen2 AnchTen2 Ten2N70') + CALL CD_AGG_Init_From_Deck(agg, 'agg_touchdown_cable.dat', DT, es, em) + CALL require(es == CD_AGG_OK, 'touchdown: init: '//TRIM(em)) + IF (es /= CD_AGG_OK) RETURN + CALL CD_AGG_CalcOutput(agg, es, em) + CALL require(es == CD_AGG_OK, 'touchdown: calc: '//TRIM(em)) + DO k = 1, 3 + CALL CD_AGG_EvalChannel(agg, k, v(k), es, em) + CALL require(es == CD_AGG_OK, 'touchdown: eval: '//TRIM(em)) + END DO + CALL require(v(3) > 1.0e3_wp .AND. v(3) < 1.5e3_wp, 'touchdown: grounded-run tension is the horizontal tension H') + CALL require(ABS(v(2) - v(3)) < 0.05_wp*v(3), 'touchdown: cable AnchTen equals the grounded-run tension H') + CALL require(v(1) > 1.1e4_wp .AND. v(1) < 1.25e4_wp, 'touchdown: cable FairTen carries the suspended weight') + CALL CD_AGG_End(agg, es, em) + END SUBROUTINE case_touchdown_cable_end_tension + + SUBROUTINE case_anchor_uplift_channels() + !! The anchor uplift channels through the shell accessor CD_AGG_EvalChannel, on the + !! touchdown deck: an EI=0 chain (line 1, anchor point 2) and a finite-EI power cable + !! (line 2, anchor point 4), both laid at the anchor. AnchFz/AnchFH are the components of the + !! AnchTen end force and equal the Point

F resultant of the one-line anchor; the chain's + !! anchor node carries its share of the chain weight (AnchFz < 0), the cable's grounded end + !! leaves it to the floor (AnchFz = 0); TDPs + TDPGrd is the deformed line length. + TYPE(CD_AGG_ModuleType) :: agg + INTEGER :: es, k + REAL(wp) :: v(14) + CHARACTER(512) :: em + REAL(wp), PARAMETER :: DT = 0.025_wp + + CALL write_touchdown_cable_deck('agg_anchor_uplift.dat', & + 'AnchTen1 AnchFz1 AnchFH1 Point2Fz Point2FH TDP1s TDP1Grd'//NEW_LINE('a')// & + 'AnchTen2 AnchFz2 AnchFH2 Point4Fz Point4FH TDP2s TDP2Grd') + CALL CD_AGG_Init_From_Deck(agg, 'agg_anchor_uplift.dat', DT, es, em) + CALL require(es == CD_AGG_OK, 'uplift: init: '//TRIM(em)) + IF (es /= CD_AGG_OK) RETURN + CALL require(CD_AGG_NumChannels(agg) == 14, 'uplift: fourteen channels') + CALL CD_AGG_CalcOutput(agg, es, em) + CALL require(es == CD_AGG_OK, 'uplift: calc: '//TRIM(em)) + v = 0.0_wp + DO k = 1, MIN(14, CD_AGG_NumChannels(agg)) + CALL CD_AGG_EvalChannel(agg, k, v(k), es, em) + CALL require(es == CD_AGG_OK .AND. IEEE_IS_FINITE(v(k)), 'uplift: eval: '//TRIM(em)) + END DO + WRITE (*, '(A,3ES13.5,A,2ES13.5)') 'uplift: chain AnchTen/Fz/FH = ', v(1:3), ', TDP s/Grd = ', v(6:7) + WRITE (*, '(A,3ES13.5,A,2ES13.5)') 'uplift: cable AnchTen/Fz/FH = ', v(8:10), ', TDP s/Grd = ', v(13:14) + ! EI=0 chain (system line) + CALL require(v(2) == v(4) .AND. v(3) == v(5), 'uplift: chain AnchFz1/AnchFH1 equal Point2Fz/Point2FH') + CALL require(ABS(HYPOT(v(2), v(3)) - v(1)) <= 1.0e-12_wp*v(1), 'uplift: chain AnchTen1 is |(AnchFH1, AnchFz1)|') + CALL require(v(2) < 0.0_wp .AND. -v(2) < 0.1_wp*v(1), 'uplift: laid chain anchor carries a small downward share') + CALL require(v(7) > 100.0_wp .AND. ABS(v(6) + v(7) - 850.0_wp) < 0.005_wp*850.0_wp, & + 'uplift: chain grounded length, TDP1s + TDP1Grd = deformed length') + ! finite-EI cable + CALL require(v(9) == v(11) .AND. v(10) == v(12), 'uplift: cable AnchFz2/AnchFH2 equal Point4Fz/Point4FH') + CALL require(ABS(HYPOT(v(9), v(10)) - v(8)) <= 1.0e-12_wp*v(8), 'uplift: cable AnchTen2 is |(AnchFH2, AnchFz2)|') + CALL require(ABS(v(9)) <= 1.0e-9_wp*v(8), 'uplift: grounded cable end leaves its node weight to the floor') + CALL require(v(14) > 100.0_wp .AND. ABS(v(13) + v(14) - 600.0_wp) < 0.01_wp*600.0_wp, & + 'uplift: cable grounded length, TDP2s + TDP2Grd = deformed length') + CALL CD_AGG_End(agg, es, em) + END SUBROUTINE case_anchor_uplift_channels + + SUBROUTINE write_touchdown_cable_deck(path, outputs_row) + !! IEA-15MW mooring chain (line 1, Fixed anchor point 2) + touchdown power cable (line 2, + !! Fixed anchor point 4) on a 200 m seabed, with the given OUTPUTS row(s). + CHARACTER(*), INTENT(IN) :: path, outputs_row + INTEGER :: u, ios + + OPEN (NEWUNIT=u, FILE=path, STATUS='REPLACE', ACTION='WRITE', IOSTAT=ios) + CALL require(ios == 0, 'touchdown: create deck '//path) + IF (ios /= 0) RETURN WRITE (u, '(A)') 'IEA-15MW mooring chain + touchdown power cable' WRITE (u, '(A)') '--- LINE TYPES ---' WRITE (u, '(A)') 'Name Diam Mass EA BA EI Cdn Cdt Can Cat' @@ -4300,24 +4383,11 @@ SUBROUTINE case_touchdown_cable_end_tension() WRITE (u, '(A)') '3.0e5 cBot' WRITE (u, '(A)') '0.35 frictionMu' WRITE (u, '(A)') '--- OUTPUTS ---' - WRITE (u, '(A)') 'FairTen2 AnchTen2 Ten2N70' + WRITE (u, '(A)') outputs_row WRITE (u, '(A)') 'END' WRITE (u, '(A)') '--- need this line ---' CLOSE (u) - CALL CD_AGG_Init_From_Deck(agg, 'agg_touchdown_cable.dat', DT, es, em) - CALL require(es == CD_AGG_OK, 'touchdown: init: '//TRIM(em)) - IF (es /= CD_AGG_OK) RETURN - CALL CD_AGG_CalcOutput(agg, es, em) - CALL require(es == CD_AGG_OK, 'touchdown: calc: '//TRIM(em)) - DO k = 1, 3 - CALL CD_AGG_EvalChannel(agg, k, v(k), es, em) - CALL require(es == CD_AGG_OK, 'touchdown: eval: '//TRIM(em)) - END DO - CALL require(v(3) > 1.0e3_wp .AND. v(3) < 1.5e3_wp, 'touchdown: grounded-run tension is the horizontal tension H') - CALL require(ABS(v(2) - v(3)) < 0.05_wp*v(3), 'touchdown: cable AnchTen equals the grounded-run tension H') - CALL require(v(1) > 1.1e4_wp .AND. v(1) < 1.25e4_wp, 'touchdown: cable FairTen carries the suspended weight') - CALL CD_AGG_End(agg, es, em) - END SUBROUTINE case_touchdown_cable_end_tension + END SUBROUTINE write_touchdown_cable_deck SUBROUTINE write_mixed_deck(path, finite_end_connection, rigid_end_connection) !! MIXED deck: one EI=0 catenary chain (mooring) + one finite-EI lazy-wave power cable. diff --git a/tests/test_range_tdp.py b/tests/test_range_tdp.py index 60abcd22..02fa3bec 100644 --- a/tests/test_range_tdp.py +++ b/tests/test_range_tdp.py @@ -165,6 +165,33 @@ def check_tdp_vs_python(label: str, root: Path, line_id: int, seabed_z: float, t check(worst < tol, f"{label}: TDP channels agree with touchdown_history (max difference {worst:.1e} m)") +def check_output_recovery(exe: str, deck: str, out: Path, env: dict, nodes: list[int]) -> None: + """OPTIONS OutputRecovery on the lazy-wave run: the element definitions change only the + interior node tension, curvature and bend moment; the end forces (also the end-node + Tension), positions and TDP are unchanged; an unknown value stops the run.""" + element = set_option(deck, "OutputRecovery", "element") + (out / "lazywave_element.dat").write_text(element, encoding="utf-8", newline="\n") + run(exe, out / "lazywave_element.dat", out / "lazywave_element", env) + eq = read_output(out / "lazywave.out") + el = read_output(out / "lazywave_element.out") + same = ["FairTen1", *tdp_channels(1), f"Ten1N{nodes[0]}", f"Ten1N{nodes[-1]}"] + same += [f"L1N{j}p{c}" for j in nodes for c in "xyz"] + check(all(np.array_equal(eq.column(n), el.column(n)) for n in same), + "OutputRecovery element: end forces, end-node Tension, positions and TDP channels are unchanged") + changed = all( + not np.array_equal(eq.column(f"{p}1N{j}"), el.column(f"{p}1N{j}")) + for j in nodes[1:-1] + for p in ("Ten", "Curv", "BendMom") + ) + check(changed, "OutputRecovery element: every interior Ten, Curv and BendMom channel takes the element definition") + bad = set_option(deck, "OutputRecovery", "nodal") + (out / "lazywave_bad.dat").write_text(bad, encoding="utf-8", newline="\n") + proc = subprocess.run([exe, str(out / "lazywave_bad.dat"), str(out / "lazywave_bad")], capture_output=True, + text=True, env=env, cwd=out) + check(proc.returncode == 1 and "must be equilibrium or element" in proc.stdout + proc.stderr, + "OutputRecovery: an unknown value stops the run by name") + + def catenary_tdp(length: float, span: float, depth: float, w: float, ea: float) -> tuple[float, float, float]: """Elastic catenary resting on a frictionless seabed: (TDP deformed arc from the fairlead, TDP horizontal distance from the fairlead, horizontal tension).""" @@ -349,6 +376,7 @@ def main() -> int: run(args.exe, out / "lazywave.dat", out / "lazywave", env) check_envelopes("cubic-Hermite", out / "lazywave", 1, nodes, 1.0, -80.0) check_tdp_vs_python("cubic-Hermite", out / "lazywave", 1, -80.0, 5e-3) + check_output_recovery(args.exe, deck, out, env, nodes) # --- Free point (point-system route) src = (examples / "clump_weight_free_point.dat").read_text(encoding="utf-8") From 0033661c27efd677ab6641228314c8a14151a692 Mon Sep 17 00:00:00 2001 From: Jae Hoon Seo Date: Thu, 15 Oct 2026 22:28:20 +0900 Subject: [PATCH 2/5] fix(outputs): laid-anchor moment, continuous grounded length, recovery cache - The recovered end moment of a held end laid on the seabed missed the floor reaction of the end node's half element, so a laid anchor reported a spurious bend moment (903 N m at the cable anchor of the IEA-15 mixed example, 205 N m at the next node). The end element now carries that reaction: 0.018 and 0.10 N m. Test in tests/test_anchor_uplift.py. - TDPGrd was reset to 0 while only the end node was grounded and then jumped by a full chord; it is now the deformed chord length from the grounded end to the touchdown point throughout, and TDPs + TDPGrd is the line length. - The node recovery is cached per element on the state (t, q, v, a and the load configuration) and reused across the Ten, Curv and BendMom channels of an output row (150 channels: 0.61 s -> 0.55 s on a 64 element cable); outputs are bit-identical. Channel evaluation takes the model INTENT(INOUT) (CD_AGG_EvalChannel and related). - A section with EI below max(|w| l0^2)/12 times 1 m reports the exact geometric curvature: the recovered moment carries an error independent of EI that Curv = BendMom/EI amplifies (6.9 1/m against 0.12 1/m at EI = 100 N m^2). - Regression tests pin the quadratic touchdown locator (Fortran and Python). Docs state that end values are the end reactions while interior values include inertia, that the recovery balance in dynamics is the one at t_{n+1}, and that AnchFz is exactly 0 at a grounded finite-EI anchor. Signed-off-by: Jae Hoon Seo --- CHANGELOG.md | 20 +++- CMakeLists.txt | 5 + app/cabledyn.f90 | 6 +- doc/driver_format.md | 4 +- doc/outputs.rst | 28 ++++-- doc/python_postprocessing.rst | 5 +- doc/theory.rst | 36 ++++++- python/tests/test_touchdown.py | 39 +++++++- src/CableDyn_DeckDriver.f90 | 12 +-- src/CableDyn_HermiteCableDynamic.f90 | 88 +++++++++++++++-- src/CableDyn_OpenFAST_Aggregate.f90 | 8 +- src/CableDyn_RangeOutput.f90 | 8 +- tests/test_anchor_uplift.py | 43 ++++++--- tests/test_coupled_torsion.f90 | 2 +- tests/test_range_tdp.py | 25 +++++ tests/test_range_tdp_locator.f90 | 138 +++++++++++++++++++++++++++ 16 files changed, 404 insertions(+), 63 deletions(-) create mode 100644 tests/test_range_tdp_locator.f90 diff --git a/CHANGELOG.md b/CHANGELOG.md index e17f4de8..fd7b6d8e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -111,12 +111,15 @@ All notable changes to CableDyn are recorded in this file. The format follows (positive upward, the line lifting its anchor) and the horizontal magnitude of the `AnchTen` end force; for an anchor that holds one line they equal `Point

Fz` and `Point

FH`. `TDPGrd` is the grounded length, the deformed chord length from the grounded end to the - touchdown point, and is 0 while no node beyond the grounded end node rests on the seabed. The + touchdown point; it varies continuously with the touchdown point and is 0 only when nothing + touches (an anchor node on the seabed beside a node a few millimetres clear of it reads + micrometres to millimetres, so test it against a small tolerance such as 0.01 m). The channels are available on the static, `EI = 0`, finite-EI, mixed and multibody routes, in the C API and in coupled OpenFAST and FAST.Farm runs; the two-moving-end finite-EI route rejects `AnchFz`/`AnchFH` by name. The Python deck reader and builder accept the new names. See the manual's outputs page (Anchor uplift), which also states the end-node weight share that a laid - `Fixed` anchor carries (`AnchFz` slightly negative, not uplift). + `Fixed` anchor carries (slightly negative `AnchFz` on an `EI = 0` line, not uplift; exactly 0 + on a finite-EI line, whose grounded end leaves its node weight to the floor). - `OutputRecovery` option (`equilibrium`, the default, or `element`): the definition of the finite-EI node tension, curvature, bend moment and segment tension (see Changed). `element` restores the definitions of 0.1.1. The Python deck reader accepts and checks it. @@ -149,8 +152,17 @@ All notable changes to CableDyn are recorded in this file. The format follows the example's mesh. A `.t.out` segment tension is now the mean of the axial components of the element's two end forces instead of the axial resultant at its midpoint. The library curvature (`CD_HermiteCable_Dyn_Curvature`, `CD_HFMF_Curvature`) follows the same definition - as the channels. Line-end values (`FairTen`, `AnchTen`, the end-node tension), positions and - the material-strain checks (`tensile_safety`, the static compression notes) are unchanged. On + as the channels. A section softer than `max(|w| L0^2)/12` times 1 m (about 1.3 kN m^2 for the + 10 m elements of that cable) takes its curvature from the exact geometric trace, as an + `EI = 0` section does: the recovered moment carries an error of that order whatever `EI` is, + which `Curv = BendMom/EI` would amplify (6.9 1/m against 0.12 1/m at `EI` = 100 N m^2). + Line-end values (`FairTen`, `AnchTen`, the end-node tension; the end reaction, without the + inertia, added mass and seabed friction that the recovered section forces of the interior + nodes include), positions and the material-strain checks (`tensile_safety`, the static + compression notes) are unchanged. At a `Fixed` anchor resting on the seabed the end element + carries the floor-support share of its weight, as in the residual, so the end node reports + the bend moment of the line (0.02 N m, not 903 N m, at the anchor of the cable of + `examples/iea15mw_umaine_mixed_cabledyn.dat`, and 0.1 N m, not 205 N m, at the next node). On a line restrained in torsion the condensed torque is left out of the recovery; it moves the tension by at most 0.45 N of 9.4 kN on `examples/torsion_lazy_wave_hangoff_twist.dat`. Range graphs and `.t.out` files written every step cost 4 % more run time, plain channels under 2 diff --git a/CMakeLists.txt b/CMakeLists.txt index 168852c0..7c2e0b0f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -688,6 +688,11 @@ target_link_libraries(test_bathymetry PRIVATE cabledyn_core) add_test(NAME bathymetry COMMAND test_bathymetry) set_tests_properties(bathymetry PROPERTIES LABELS "fortran;unit;seabed") +add_executable(test_range_tdp_locator tests/test_range_tdp_locator.f90) +target_link_libraries(test_range_tdp_locator PRIVATE cabledyn_core) +add_test(NAME range_tdp_locator COMMAND test_range_tdp_locator) +set_tests_properties(range_tdp_locator PROPERTIES LABELS "fortran;unit;seabed") + add_executable(test_hydro tests/test_hydro.f90) target_link_libraries(test_hydro PRIVATE cabledyn_core) add_test(NAME hydro COMMAND test_hydro) diff --git a/app/cabledyn.f90 b/app/cabledyn.f90 index 1f20b569..53a40257 100644 --- a/app/cabledyn.f90 +++ b/app/cabledyn.f90 @@ -692,7 +692,7 @@ FUNCTION ascii_lower(s) RESULT(r) END FUNCTION ascii_lower SUBROUTINE print_mixed_initialization(aggregate, stat, msg) - TYPE(CD_AGG_ModuleType), INTENT(IN) :: aggregate + TYPE(CD_AGG_ModuleType), INTENT(INOUT) :: aggregate INTEGER, INTENT(OUT) :: stat CHARACTER(*), INTENT(OUT) :: msg INTEGER :: n_lines, n_points, n_sections, n_ei0, n_finite, i, line_id, es @@ -743,7 +743,7 @@ END SUBROUTINE print_notes SUBROUTINE write_mixed_header(unit, aggregate, stat, msg) INTEGER, INTENT(IN) :: unit - TYPE(CD_AGG_ModuleType), INTENT(IN) :: aggregate + TYPE(CD_AGG_ModuleType), INTENT(INOUT) :: aggregate INTEGER, INTENT(OUT) :: stat CHARACTER(*), INTENT(OUT) :: msg INTEGER :: i, ios @@ -772,7 +772,7 @@ END SUBROUTINE write_mixed_header SUBROUTINE write_mixed_row(unit, time, aggregate, stat, msg) INTEGER, INTENT(IN) :: unit REAL(wp), INTENT(IN) :: time - TYPE(CD_AGG_ModuleType), INTENT(IN) :: aggregate + TYPE(CD_AGG_ModuleType), INTENT(INOUT) :: aggregate INTEGER, INTENT(OUT) :: stat CHARACTER(*), INTENT(OUT) :: msg INTEGER :: i, ios diff --git a/doc/driver_format.md b/doc/driver_format.md index b7466bdd..8a00cbab 100644 --- a/doc/driver_format.md +++ b/doc/driver_format.md @@ -1251,7 +1251,7 @@ bending moment. None of these channels is mandatory. | `TDPx`, `TDPy`, `TDPz` | line L TDP position | m | | `TDPLay` | line L layback: horizontal distance from the TDP to the suspended end | m | | `TDPExc` | line L TDP excursion: horizontal TDP displacement from its initial position, along the initial direction toward the suspended end | m | -| `TDPGrd` | line L grounded length: deformed chord length along the nodes from the grounded end to the TDP; 0 once the grounded end has lifted off | m | +| `TDPGrd` | line L grounded length: deformed chord length along the nodes from the grounded end to the TDP; continuous with the TDP, 0 only when nothing touches (the grounded end has lifted off) | m | | `TorqN` | line L torque at node J (uniform along the line); positive for a right-handed twist of End B relative to End A about the End A → End B tangent. Only on a line restrained in torsion at both ends | N·m | | `TwistN` | line L material twist accumulated from End A to node J, `M × Σ L/GJ` over the elements in between; 0 at End A, without the end-spring windup. Only on a line restrained in torsion at both ends | deg | | `Twist` | line L total twist `Phi − Theta = M C`, end-spring windup included. Only on a line restrained in torsion at both ends | deg | @@ -1271,7 +1271,7 @@ bending moment. None of these channels is mandatory. naming the line. They are available on every route, OpenFAST included. - The anchor uplift check of a drag-embedment anchor (no vertical load at the anchor in the intact condition) reads `AnchFz` (its maximum over the run at most 0) or `TDPGrd` - (greater than 0 throughout); see [Outputs](outputs.rst) for the end-node weight share that a + (greater than a small tolerance such as 0.01 m throughout); see [Outputs](outputs.rst) for the end-node weight share that a grounded `Fixed` anchor carries. - In an OpenFAST `CompMooring = 5` run, channel headers in the OpenFAST output and in `.CD.out` use OpenFAST's 20-character width (`ChanLen`). A longer channel name diff --git a/doc/outputs.rst b/doc/outputs.rst index dad67b54..727a5775 100644 --- a/doc/outputs.rst +++ b/doc/outputs.rst @@ -535,10 +535,13 @@ vertical uplift at the anchor in the intact condition: some chain stays laid on channels give the check for line ``L`` directly: * the maximum of ``AnchFz`` over the run is at most 0; -* the minimum of ``TDPGrd`` (`Touchdown channels`_) over the run is greater than 0. +* the minimum of ``TDPGrd`` (`Touchdown channels`_) over the run is greater than a small + tolerance (0.01 m is a centimetre, far below an element). The two agree: while chain is laid at the anchor the line pulls it horizontally, and once the -grounded length reaches 0 the line lifts its anchor and ``AnchFz`` turns positive. +grounded length falls to the tolerance the line lifts its anchor and ``AnchFz`` turns positive. +``TDPGrd`` is continuous with the touchdown point, so an anchor node held on the seabed beside a +node a few millimetres clear of it reads micrometres to millimetres, not exactly 0. On a laid ``EI = 0`` line ``AnchFz`` is a small negative value, not 0. The anchor node of a ``Fixed`` point at the seabed depth is held at the seabed elevation, while the penalty seabed @@ -578,15 +581,19 @@ Line-node channels distributed loads and inertia (:ref:`theory-output-recovery`); ``OutputRecovery element``: the length-weighted mean of the element-mean axial forces :math:`EA(|\mathbf r'| - 1)`. An end node reports the line-end force of ``FairTen`` / - ``AnchTen``. On the two-moving-end finite-EI route every value is the chord-stretch - tension of ``FairTen`` there: the adjacent element at an end node and the unweighted - mean of the two neighbouring elements at an interior node + ``AnchTen``, the end reaction on the support or platform, which excludes inertia, added + mass and seabed friction (the interior values are the recovered section force, whose + element end forces include inertia and added mass). On the two-moving-end finite-EI route + every value is the chord-stretch tension of ``FairTen`` there: the adjacent element at an + end node and the unweighted mean of the two neighbouring elements at an interior node - N * - ``CurvN`` - curvature at node ``J``. ``EI = 0`` lines: discrete curvature of the circle through the node and its two neighbours (end nodes take the adjacent interior value). Cubic-Hermite lines: ``BendMomN`` / ``EI``, the larger of the two sides at a - section junction (``OutputRecovery element``: exact curvature of the continuous + section junction, and the exact geometric curvature where ``EI`` is below + ``max(|w| L0^2)/12`` times 1 m (:ref:`theory-output-recovery`) (``OutputRecovery + element``: exact curvature of the continuous centreline, the larger of the two one-sided element values at an interior node). The library routines ``CD_HermiteCable_Dyn_Curvature`` and ``CD_HFMF_Curvature`` return the same value; ``CD_HermiteCable_Dyn_Curvature_Exact`` and ``CD_HFMF_Curvature_Exact`` the @@ -673,10 +680,11 @@ those of :func:`cabledyn.touchdown_history` with ``tolerance = 1e-6``. - m * - ``TDPGrd`` - grounded length: deformed chord length along the nodes from the grounded end to the TDP - (``TDPs`` measured from the grounded end instead of End A). 0 while no node beyond - the grounded end node is grounded: an anchor held at the seabed elevation counts as - grounded, but with its neighbour off the seabed no line lies there, so a taut or fully - suspended line reads 0. The whole line length when every node is grounded + (``TDPs`` measured from the grounded end instead of End A). It varies continuously with + the TDP: it grows from 0 as the TDP leaves the grounded end node, so a line whose + neighbour of the anchor is just above the seabed reads a fraction of the first element, and + it is 0 only when nothing touches (the grounded end node itself is off the seabed, or the + TDP sits at that node). The whole line length when every node is grounded - m The channels are available on every route, OpenFAST included, when the deck has a seabed diff --git a/doc/python_postprocessing.rst b/doc/python_postprocessing.rst index 3a419292..5f041ba0 100644 --- a/doc/python_postprocessing.rst +++ b/doc/python_postprocessing.rst @@ -405,8 +405,9 @@ the suspended end, and the arc-length excursion. Samples without a touchdown are The driver computes the same quantities during the run as the ``TDPs``/``x``/``y``/``z``/ ``Lay``/``Exc`` channels (see :doc:`outputs`), with ``tolerance`` equal to the contact-onset height of 1e-6 m. Its ``TDPGrd`` channel adds the grounded length from the grounded end to the -TDP (with End B grounded, the deformed line length less the TDP arc length; 0 when no node beyond -the end node is grounded), for the anchor uplift check. +TDP (with End B grounded, the deformed line length less the TDP arc length). It varies continuously +with the TDP and is 0 only when the grounded end node itself is off the seabed or the TDP sits at +that node, for the anchor uplift check. .. code-block:: python diff --git a/doc/theory.rst b/doc/theory.rst index 5cd6b9a7..91f0db76 100644 --- a/doc/theory.rst +++ b/doc/theory.rst @@ -202,7 +202,10 @@ holds only the element's own distributed loads: consistent submerged weight, the above the free surface, drag, Froude-Krylov force, structural and added-mass inertia, and the seabed reaction of its end nodes, each nodal reaction spread uniformly over the node's tributary length (the distributed floor reaction it stands for; without it a line resting on the floor -would report the fixed-end moment :math:`w L_0^2/12` of its own weight). :math:`\mathbf{g}_e` +would report the fixed-end moment :math:`w L_0^2/12` of its own weight; at a held line end whose +end element lies on the floor, the reaction of the end half is the floor-support share of the +weight, the share that the static and dynamic residuals carry on the end tangent rows). +:math:`\mathbf{g}_e` is the generalised force the two end nodes exert on the element: its position rows at the End-B side of the internal arc are the section force :math:`\mathbf{F}_j^-` just before node :math:`j`, minus its rows at the other end the section force :math:`\mathbf{F}_j^+` just after @@ -218,11 +221,34 @@ it, and its tangent rows are :math:`\mathbf{m}` there. An interior node reports with :math:`\mathbf{t}_j` the unit nodal tangent, :math:`\mathbf{m}_j` the mean of the two one-sided values, and at a section junction the larger of :math:`M_j/EI` on the two sides. The +recovered moment carries an error that does not depend on :math:`EI`, of the order of the largest +consistent-load moment :math:`w L_0^2/12` of an element (a section junction leaves a jump of that +order between the two one-sided moments), so over a soft section dividing by :math:`EI` amplifies +it. A section whose :math:`EI` is below :math:`\max_e(\lvert w_e\rvert L_{0,e}^2)/12` times 1 m, +the stiffness whose elastic moment at a 1 m bend radius equals that error, takes its curvature +from the exact geometric trace instead, as an element with :math:`EI = 0` does (on the lazy-wave +cable of ``iea15mw_umaine_mixed_cabledyn.dat`` with :math:`EI` lowered to 100 N m\ :sup:`2` the +recovered curvature reaches 6.9 1/m against a geometric peak of 0.12 1/m; the bend moment of such a +section remains the recovered one, with that error). The difference of the two one-sided forces is the point load left at the node (seabed friction, an -attachment), so the nodal section forces satisfy the discrete equilibrium exactly and carry -none of the pointwise oscillation. A line end reports the ``FairTen``/``AnchTen`` end force and -its one-sided moment; the segment tension of an element is the mean of the axial components of -its own two end forces. The recovery costs one element evaluation per element and output row. +attachment). At the converged static state the nodal section forces satisfy the discrete +equilibrium exactly. In a dynamic run the recovery is the balance at the output time +:math:`t_{n+1}`, with the position, velocity and acceleration the step committed there: the +inertia term :math:`\mathbf{M}_e\mathbf{a}_e` uses the step's acceleration +:math:`\mathbf{a}_{n+1}` at :math:`\mathbf{q}_{n+1}`. The integrator balances the generalised-alpha +combination of the :math:`t_n` and :math:`t_{n+1}` states, so the recovered forces differ from +the integrator's balance by :math:`O(\Delta t)`; the recovered forces carry none of the pointwise +oscillation. A line end reports the ``FairTen``/``AnchTen`` end force and its one-sided moment; +the segment tension of an element is the mean of the axial components of its own two end forces. +The recovery costs one element evaluation per element and output row. + +The end node tension and the interior node tension are therefore different quantities. The end +value is the end reaction, the force on the support or the platform: it holds the end element's +internal force and the end node's share of the weight, buoyancy, drag and contact, but not +inertia, added mass or seabed friction, which stay in the coupled load. The interior value is the +recovered section force, built from end forces that include those terms. At rest and in a +quasi-static march the two agree; under acceleration the interior values carry the inertia and +added-mass terms of the two neighbouring elements, and the end values do not. On the 87-element lazy wave the interior node tension departs from the equilibrium of the converged line by at most 60 N (1552 N for the element means), 12 N at twice the mesh density diff --git a/python/tests/test_touchdown.py b/python/tests/test_touchdown.py index 8a8ffdb5..c710fa71 100644 --- a/python/tests/test_touchdown.py +++ b/python/tests/test_touchdown.py @@ -34,7 +34,7 @@ def _frames(kinks=None) -> np.ndarray: def _expected(xyz: np.ndarray) -> tuple[float, np.ndarray]: """Straightforward scalar TDP: last grounded node from End A, then the crossing of the level by the parabola through that node and the next two, in chord arc (on a straight - rise this is the chord crossing), nearest the suspended node.""" + rise this is the chord crossing).""" level = SEABED + TOLERANCE last = int(np.argmax(xyz[:, 2] > level)) - 1 low, high = xyz[last], xyz[last + 1] @@ -122,6 +122,43 @@ def test_touchdown_history_grounded_at_end_b(tmp_path): np.testing.assert_allclose(backward.layback, forward.layback) +def test_touchdown_on_a_convex_stencil_lies_just_before_the_barely_lifted_node(tmp_path): + # Clearance above the onset height -0.005, 0.01, 1.0, 2.0 m on 1 m spacing: node 2 is barely off + # the seabed and the line rises sharply beyond it, so the line leaves the seabed just before + # node 2. The chord crossing (a third of the way) would put the TDP a node behind. The + # parabola through the first three nodes crosses zero once inside the element, at 0.97 chord. + level = SEABED + TOLERANCE + z = level + np.array([-0.005, 0.01, 1.0, 2.0]) + frame = np.column_stack([np.arange(4.0), np.zeros(4), z])[None, :, :] + history = touchdown_history( + _write_line(tmp_path / "convex.p.out", frame, times=[0.0]), + seabed_z=SEABED, + tolerance=TOLERANCE, + ) + arc, point = _expected(frame[0]) + assert history.arc_length[0] == pytest.approx(arc) + np.testing.assert_allclose(history.coordinates[0], point) + assert 0.95 < history.coordinates[0, 0] < 1.0 + # the same stencil with node 1 exactly at the onset height: the second crossing, still inside + z = level + np.array([0.0, 0.01, 1.0, 2.0]) + frame = np.column_stack([np.arange(4.0), np.zeros(4), z])[None, :, :] + history = touchdown_history( + _write_line(tmp_path / "onset.p.out", frame, times=[0.0]), + seabed_z=SEABED, + tolerance=TOLERANCE, + ) + assert 0.95 < history.coordinates[0, 0] < 1.0 + # a node reaching the onset height maps to that node + z = level + np.array([-0.5, 1e-12, 1.0, 2.0]) + frame = np.column_stack([np.arange(4.0), np.zeros(4), z])[None, :, :] + history = touchdown_history( + _write_line(tmp_path / "node.p.out", frame, times=[0.0]), + seabed_z=SEABED, + tolerance=TOLERANCE, + ) + assert history.coordinates[0, 0] == pytest.approx(1.0, abs=1e-6) + + def test_touchdown_history_from_main_output_node_channels(tmp_path): frames = _frames() times = np.linspace(0.0, 10.0, 201) diff --git a/src/CableDyn_DeckDriver.f90 b/src/CableDyn_DeckDriver.f90 index 9f039010..49d47397 100644 --- a/src/CableDyn_DeckDriver.f90 +++ b/src/CableDyn_DeckDriver.f90 @@ -19740,7 +19740,7 @@ END FUNCTION mb_cable_group SUBROUTINE mb_point_force(mb, ch, val, ErrStat, ErrMsg) !! Point

F{x,y,z,H} on the multibody march: the resultant of the forces the attached EI=0 !! lines and finite-EI cables exert on point P. - TYPE(MultibodyMarch), INTENT(IN) :: mb + TYPE(MultibodyMarch), INTENT(INOUT) :: mb CHARACTER(*), INTENT(IN) :: ch REAL(wp), INTENT(OUT) :: val INTEGER, INTENT(OUT) :: ErrStat @@ -25118,7 +25118,7 @@ SUBROUTINE write_hermite_static_profile(out_root, lines, cables, ErrStat, ErrMsg !! every node is available for touchdown, curvature, and tension inspection. CHARACTER(*), INTENT(IN) :: out_root TYPE(DeckLine), INTENT(IN) :: lines(:) - TYPE(CD_HFMF_ModuleType), INTENT(IN) :: cables(:) + TYPE(CD_HFMF_ModuleType), INTENT(INOUT) :: cables(:) INTEGER, INTENT(OUT) :: ErrStat CHARACTER(*), INTENT(OUT) :: ErrMsg @@ -25360,7 +25360,7 @@ SUBROUTINE write_hermite_model_row(unit, time, channels, lines, points, cables, CHARACTER(NAMELEN), INTENT(IN) :: channels(:) TYPE(DeckLine), INTENT(IN) :: lines(:) TYPE(DeckPoint), INTENT(IN) :: points(:) - TYPE(CD_HFMF_ModuleType), INTENT(IN) :: cables(:) + TYPE(CD_HFMF_ModuleType), INTENT(INOUT) :: cables(:) TYPE(MotionTable), INTENT(IN) :: motion LOGICAL, INTENT(IN) :: has_motion INTEGER, INTENT(OUT) :: ErrStat @@ -30881,7 +30881,7 @@ SUBROUTINE CD_Eval_Aggregate_Channel(ch, has_sys, system, cables, line_is_cable, TYPE(CD_SystemType), INTENT(IN) :: system ! ALLOCATABLE so a pure-mooring deck that declares channels (ncable = 0, cables unallocated) ! can pass its cables store: only a channel resolving to a cable dereferences it. - TYPE(CD_HFMF_ModuleType), ALLOCATABLE, INTENT(IN) :: cables(:) + TYPE(CD_HFMF_ModuleType), ALLOCATABLE, INTENT(INOUT) :: cables(:) LOGICAL, INTENT(IN) :: line_is_cable(:) INTEGER, INTENT(IN) :: line_obj_index(:) REAL(wp), INTENT(OUT) :: val @@ -31353,7 +31353,7 @@ SUBROUTINE eval_cable_channel(cable, ch, val, ErrStat, ErrMsg) !! -> fairlead (node nn, the coupled endpoint), so deck End A = internal node nn. Bend moment is !! EI(node) * |kvec_current - kvec_reference|; the built cable's reference is straight !! (kvec_reference = 0), so it reduces to EI * geometric curvature magnitude. - TYPE(CD_HFMF_ModuleType), INTENT(IN) :: cable + TYPE(CD_HFMF_ModuleType), INTENT(INOUT) :: cable CHARACTER(*), INTENT(IN) :: ch REAL(wp), INTENT(OUT) :: val INTEGER, INTENT(OUT) :: ErrStat @@ -31602,7 +31602,7 @@ END SUBROUTINE cable_end_tension SUBROUTINE cable_node_values(cable, inode, tension, curvature, bend_moment, ErrStat, ErrMsg) !! Equilibrium node values of a finite-EI cable at internal node inode !! (CD_HermiteCable_Dyn_Node_Values): effective tension, curvature and bend moment. - TYPE(CD_HFMF_ModuleType), INTENT(IN) :: cable + TYPE(CD_HFMF_ModuleType), INTENT(INOUT) :: cable INTEGER, INTENT(IN) :: inode REAL(wp), INTENT(OUT) :: tension, curvature, bend_moment INTEGER, INTENT(OUT) :: ErrStat diff --git a/src/CableDyn_HermiteCableDynamic.f90 b/src/CableDyn_HermiteCableDynamic.f90 index 661767ec..c83e355a 100644 --- a/src/CableDyn_HermiteCableDynamic.f90 +++ b/src/CableDyn_HermiteCableDynamic.f90 @@ -419,6 +419,20 @@ MODULE CableDyn_HermiteCableDynamic ! Node output definitions (CD_HermiteCable_Dyn_Set_Output_Recovery): equilibrium recovery ! by default, the element-mean axial force and exact curvature traces when set. LOGICAL :: output_element_recovery = .FALSE. + ! Smallest bending stiffness [N m^2] whose recovered bend moment resolves a curvature: the largest + ! consistent-load moment w L0^2/12 of an element over a 1 m bend radius. The moment recovered + ! from nodal equilibrium carries an error of that order, independent of EI, so over a softer + ! section it cannot give the curvature (node_values then takes the exact geometric trace). + REAL(wp) :: ei_resolve = CD_ZERO + ! Cache of the element end residuals behind the node outputs (CD_HermiteCable_Dyn_Node_Values), + ! valid for the state t, q, v, a and the configuration epoch it was filled at: the channels of + ! one output row share one evaluation per element. Allocated once at initialisation; rc_epoch + ! counts the loads configured after it (drag, waves, added mass, held fluid, contact). + INTEGER :: rc_epoch = 0, rc_key_epoch = -1 + LOGICAL :: rc_key_ok = .FALSE. + REAL(wp) :: rc_t = CD_ZERO + REAL(wp), ALLOCATABLE :: rc_q(:), rc_v(:), rc_a(:), rc_g(:, :) + LOGICAL, ALLOCATABLE :: rc_have(:) LOGICAL :: initialized = .FALSE. END TYPE CD_HermiteCableDynType @@ -543,6 +557,7 @@ SUBROUTINE CD_HermiteCable_Dyn_Init(model, l0, EA, EI, rho_a, w, seed, fixed_dof model%seabed_z = seabed_z; model%kn = kn ALLOCATE (model%l0(ne), model%EA(ne), model%EI(ne), model%rho_a(ne), model%w(ne)) model%l0 = l0; model%EA = EA; model%EI = EI; model%rho_a = rho_a; model%w = w + model%ei_resolve = MAXVAL(ABS(w)*l0*l0)/12.0_wp ! gen-alpha constants rho = rho_inf @@ -607,6 +622,9 @@ SUBROUTINE CD_HermiteCable_Dyn_Init(model, l0, EA, EI, rho_a, w, seed, fixed_dof ! state: at-rest seed, v = 0, consistent a0 ALLOCATE (model%q(ndof), model%v(ndof), model%a(ndof)) + ALLOCATE (model%rc_q(ndof), model%rc_v(ndof), model%rc_a(ndof), model%rc_g(12, ne), model%rc_have(ne)) + model%rc_have = .FALSE. + model%rc_key_ok = .FALSE. model%q = seed model%v = CD_ZERO model%a = CD_ZERO @@ -653,6 +671,7 @@ SUBROUTINE CD_HermiteCable_Dyn_Set_Contact(model, kn_node, cn_node, mu, ErrStat, CHARACTER(200) :: em ErrStat = CD_HCDYN_OK; ErrMsg = '' + model%rc_epoch = model%rc_epoch + 1 ! A load-configuration change invalidates the cached committed force F_n. model%fc_valid = .FALSE. model%tr_valid = .FALSE. @@ -1706,6 +1725,7 @@ SUBROUTINE CD_HermiteCable_Dyn_Set_Drag(model, rho_w, diam, cdn, cdt, waterline_ LOGICAL :: had_drag ErrStat = CD_HCDYN_OK; ErrMsg = '' + model%rc_epoch = model%rc_epoch + 1 ! A load-configuration change invalidates the cached committed force F_n. model%fc_valid = .FALSE. model%tr_valid = .FALSE. @@ -1804,6 +1824,7 @@ SUBROUTINE CD_HermiteCable_Dyn_Set_Axial_Damping(model, BA, ErrStat, ErrMsg) CHARACTER(300) :: em ErrStat = CD_HCDYN_OK + model%rc_epoch = model%rc_epoch + 1 ! A load-configuration change invalidates the cached committed force F_n. model%fc_valid = .FALSE. model%tr_valid = .FALSE. @@ -1874,6 +1895,7 @@ SUBROUTINE CD_HermiteCable_Dyn_Set_AddedMass(model, rho_w, diam, can, cat, water LOGICAL :: had_am ErrStat = CD_HCDYN_OK; ErrMsg = '' + model%rc_epoch = model%rc_epoch + 1 ! A load-configuration change invalidates the cached committed force F_n. model%fc_valid = .FALSE. model%tr_valid = .FALSE. @@ -1969,6 +1991,7 @@ SUBROUTINE CD_HermiteCable_Dyn_Set_Waves(model, height, period, direction_deg, d CHARACTER(200) :: em2 ErrStat = CD_HCDYN_OK; ErrMsg = '' + model%rc_epoch = model%rc_epoch + 1 ! A load-configuration change invalidates the cached committed force F_n. model%fc_valid = .FALSE. model%tr_valid = .FALSE. @@ -2088,6 +2111,7 @@ SUBROUTINE CD_HermiteCable_Dyn_Set_Irregular_Waves(model, amplitude, period, pha CHARACTER(200) :: em2 ErrStat = CD_HCDYN_OK; ErrMsg = '' + model%rc_epoch = model%rc_epoch + 1 ! A load-configuration change invalidates the cached committed force F_n. model%fc_valid = .FALSE. model%tr_valid = .FALSE. @@ -2224,6 +2248,7 @@ SUBROUTINE CD_HermiteCable_Dyn_Set_Held_Fluid(model, fluid_velocity, fluid_accel LOGICAL :: had_field CHARACTER(240) :: em ErrStat = CD_HCDYN_OK; ErrMsg = '' + model%rc_epoch = model%rc_epoch + 1 ! A load-configuration change invalidates the cached committed force F_n. The carried step ! factor stays usable (a per-step field update only perturbs the drag and inertia tangent; ! the first field's consistent-acceleration solve drops it). @@ -4726,8 +4751,12 @@ END SUBROUTINE CD_HermiteCable_Dyn_Set_Output_Recovery SUBROUTINE CD_HermiteCable_Dyn_Node_Values(model, node, tension, curvature, bend_moment, ErrStat, ErrMsg) !! Equilibrium node values at one node (internal order), from the two adjacent elements; - !! the same values as CD_HermiteCable_Dyn_Node_Recovery returns for that node. - TYPE(CD_HermiteCableDynType), INTENT(IN) :: model + !! the same values as CD_HermiteCable_Dyn_Node_Recovery returns for that node. The element end + !! residuals are kept in the model for the state they were evaluated at (see the rc_ fields), + !! so the tension, curvature and bend moment of a node, and of neighbouring nodes, share one + !! evaluation per element; a changed state or load configuration refreshes them. No + !! allocation. + TYPE(CD_HermiteCableDynType), INTENT(INOUT) :: model INTEGER, INTENT(IN) :: node REAL(wp), INTENT(OUT) :: tension, curvature, bend_moment INTEGER, INTENT(OUT) :: ErrStat @@ -4742,18 +4771,45 @@ SUBROUTINE CD_HermiteCable_Dyn_Node_Values(model, node, tension, curvature, bend IF (node < 1 .OR. node > model%nn) THEN ErrStat = CD_HCDYN_BADINPUT; ErrMsg = 'CD_HermiteCable_Dyn_Node_Values: node out of range'; RETURN END IF + ! the cached residuals belong to the state they were computed at (exact comparison; a NaN + ! state never matches and is recomputed) + IF (.NOT. (model%rc_key_ok .AND. model%rc_key_epoch == model%rc_epoch .AND. model%rc_t == model%t .AND. & + ALL(model%rc_q == model%q) .AND. ALL(model%rc_v == model%v) .AND. & + ALL(model%rc_a == model%a))) THEN + model%rc_q = model%q; model%rc_v = model%v; model%rc_a = model%a + model%rc_t = model%t; model%rc_key_epoch = model%rc_epoch + model%rc_key_ok = .TRUE. + model%rc_have = .FALSE. + END IF fm = CD_ZERO; mm = CD_ZERO; fp = CD_ZERO; mp = CD_ZERO IF (node > 1) THEN - CALL element_end_residual(model, node - 1, g, ErrStat, ErrMsg) + CALL cached_end_residual(node - 1, g) IF (ErrStat /= CD_HCDYN_OK) RETURN fm = g(7:9); mm = g(10:12) END IF IF (node < model%nn) THEN - CALL element_end_residual(model, node, g, ErrStat, ErrMsg) + CALL cached_end_residual(node, g) IF (ErrStat /= CD_HCDYN_OK) RETURN fp = -g(1:3); mp = -g(4:6) END IF CALL node_values(model, node, fm, mm, fp, mp, tension, curvature, bend_moment, ErrStat, ErrMsg) + + CONTAINS + + SUBROUTINE cached_end_residual(e, ge) + INTEGER, INTENT(IN) :: e + REAL(wp), INTENT(OUT) :: ge(12) + REAL(wp) :: gl(12) + IF (.NOT. model%rc_have(e)) THEN + CALL element_end_residual(model, e, gl, ErrStat, ErrMsg) + IF (ErrStat /= CD_HCDYN_OK) THEN + ge = CD_ZERO; RETURN + END IF + model%rc_g(:, e) = gl + model%rc_have(e) = .TRUE. + END IF + ge = model%rc_g(:, e) + END SUBROUTINE cached_end_residual END SUBROUTINE CD_HermiteCable_Dyn_Node_Values SUBROUTINE CD_HermiteCable_Dyn_Node_Recovery(model, ErrStat, ErrMsg, tension, curvature, bend_moment, & @@ -4776,7 +4832,9 @@ SUBROUTINE CD_HermiteCable_Dyn_Node_Recovery(model, ErrStat, ErrMsg, tension, cu !! tension(j) = t_j . F_j (t_j the unit nodal tangent; a line end reports the end force !! magnitude of CD_HermiteCable_Dyn_End_Force), bend_moment(j) = |m_j - (m_j . t_j) t_j|, !! curvature(j) = bend_moment(j)/EI, the larger of the two sides at a section junction (the - !! exact geometric trace on an element without bending stiffness). segment_tension(e) is the + !! exact geometric trace on an element without bending stiffness, or with EI below ei_resolve, + !! where the recovered moment error w L0^2/12 exceeds the elastic moment of a 1 m bend radius). + !! segment_tension(e) is the !! mean of the axial components of element e's own two end forces. Every output is !! optional (node arrays nn, segment_tension ne); the routine allocates nothing. !! @@ -4874,7 +4932,7 @@ SUBROUTINE node_values(model, node, fm, mm, fp, mp, tension, curvature, bend_mom DO side = 0, 1 e = node - 1 + side IF (e < 1 .OR. e > model%ne) CYCLE - IF (model%EI(e) > CD_ZERO) THEN + IF (model%EI(e) > CD_ZERO .AND. model%EI(e) >= model%ei_resolve) THEN curvature = MAX(curvature, bend_moment/model%EI(e)) ELSE CALL gather_elem(model, e, qe) @@ -4996,7 +5054,8 @@ SUBROUTINE element_end_residual(model, e, g, ErrStat, ErrMsg) INTEGER, PARAMETER :: ZS(4) = [3, 6, 9, 12] REAL(wp) :: qe(12), ve(12), ae(12), fe(12), fx(12), energy, fdry(4), kdry(4, 4) REAL(wp) :: dry_wl, dry_b, dry_r, hf_mid(3), l0, fca(3), fcb(3), c, a4(4), m4(4, 4) - INTEGER :: es, k + REAL(wp) :: support(3), dsupport(3), nin(3) + INTEGER :: es, k, inode LOGICAL :: dry CHARACTER(200) :: em2 @@ -5098,6 +5157,19 @@ SUBROUTINE element_end_residual(model, e, g, ErrStat, ErrMsg) IF (es /= CD_HCDYN_OK) GOTO 900 IF (model%trib(e) > CD_ZERO) fca = fca*l0/model%trib(e) IF (model%trib(e + 1) > CD_ZERO) fcb = fcb*l0/model%trib(e + 1) + ! A held end whose end element lies on the floor (assemble_residual): the seabed carries the + ! element's weight with its consistent end moment, which the held end node's own contact + ! (a point reaction at an anchor sitting on the floor) cannot. The floor reaction of the + ! end half of that element is the support share of its weight, uniform with the reaction + ! of the neighbouring node, so that a laid end element carries no fixed-end moment. + IF (e == 1) THEN + IF (held_end_floor_support(model, model%q, 1, support, dsupport, inode, nin)) & + fca = (model%w(1)*l0)*support + END IF + IF (e == model%ne) THEN + IF (held_end_floor_support(model, model%q, 2, support, dsupport, inode, nin)) & + fcb = (model%w(e)*l0)*support + END IF ! integrals of the four shapes over xi in [0, 1/2] (fca) and [1/2, 1] (fcb) g(1:3) = g(1:3) - (0.40625_wp*fca + 0.09375_wp*fcb) g(4:6) = g(4:6) - l0*(0.0572916666666666667_wp*fca + 0.0260416666666666667_wp*fcb) @@ -5634,6 +5706,8 @@ SUBROUTINE CD_HermiteCable_Dyn_End(model) model%ws_elem_Kwave, model%ws_elem_Kheld, & model%ws_elem_es, model%ws_elem_em) END IF + IF (ALLOCATED(model%rc_q)) DEALLOCATE (model%rc_q, model%rc_v, model%rc_a, model%rc_g, model%rc_have) + model%rc_key_ok = .FALSE. IF (ALLOCATED(model%freemask)) DEALLOCATE (model%freemask) IF (ALLOCATED(model%solve_mask)) DEALLOCATE (model%solve_mask) IF (ALLOCATED(model%fmap)) DEALLOCATE (model%fmap) diff --git a/src/CableDyn_OpenFAST_Aggregate.f90 b/src/CableDyn_OpenFAST_Aggregate.f90 index bf713e6b..0eced1d3 100644 --- a/src/CableDyn_OpenFAST_Aggregate.f90 +++ b/src/CableDyn_OpenFAST_Aggregate.f90 @@ -1888,7 +1888,7 @@ SUBROUTINE CD_AGG_GetInitLine(self, i, line_id, tension, force, inclination, dec note) !! Return one line's unconditional converged-static fairlead result in deck order, and !! (optional note) the static-initialisation notes of a finite-EI line ('' if none). - TYPE(CD_AGG_ModuleType), INTENT(IN) :: self + TYPE(CD_AGG_ModuleType), INTENT(INOUT) :: self INTEGER, INTENT(IN) :: i INTEGER, INTENT(OUT) :: line_id REAL(wp), INTENT(OUT) :: tension, force(3), inclination, declination, azimuth @@ -1925,7 +1925,7 @@ END SUBROUTINE CD_AGG_GetInitLine SUBROUTINE CD_AGG_ChannelHeader(self, i, hdr, unt, ErrStat, ErrMsg) !! Header token and OrcaFlex unit label for channel i (1 .. CD_AGG_NumChannels), for the !! OpenFAST InitOut%WriteOutputHdr / WriteOutputUnt registration. - TYPE(CD_AGG_ModuleType), INTENT(IN) :: self + TYPE(CD_AGG_ModuleType), INTENT(INOUT) :: self INTEGER, INTENT(IN) :: i CHARACTER(*), INTENT(OUT) :: hdr, unt INTEGER, INTENT(OUT) :: ErrStat @@ -1965,7 +1965,7 @@ SUBROUTINE CD_AGG_EvalChannel(self, i, value, ErrStat, ErrMsg) !! module reports the SAME value the standalone driver computes for that channel on the same !! configuration. Resolve to the EI=0 system's line/point state or a finite-EI cable's state !! through the retained deck-line-id map. - TYPE(CD_AGG_ModuleType), INTENT(IN) :: self + TYPE(CD_AGG_ModuleType), INTENT(INOUT) :: self INTEGER, INTENT(IN) :: i REAL(wp), INTENT(OUT) :: value INTEGER, INTENT(OUT) :: ErrStat @@ -2043,7 +2043,7 @@ SUBROUTINE CD_AGG_WriteStaticProfile(self, path, ErrStat, ErrMsg) !! effective tension, curvature, bend moment, declination, signed inclination below the !! horizontal, and azimuth. The channel evaluator remains the single source of truth for !! every reported physical quantity, so standalone and coupled results share conventions. - TYPE(CD_AGG_ModuleType), INTENT(IN) :: self + TYPE(CD_AGG_ModuleType), INTENT(INOUT) :: self CHARACTER(*), INTENT(IN) :: path INTEGER, INTENT(OUT) :: ErrStat CHARACTER(*), INTENT(OUT) :: ErrMsg diff --git a/src/CableDyn_RangeOutput.f90 b/src/CableDyn_RangeOutput.f90 index 041d0f5a..53059acd 100644 --- a/src/CableDyn_RangeOutput.f90 +++ b/src/CableDyn_RangeOutput.f90 @@ -297,10 +297,9 @@ PURE SUBROUTINE tdp_locate(r, clearance, grounded_end, touching, arc, point, sus !! algorithm of cabledyn.touchdown_history. `touching` is false when the grounded end !! has lifted off (the TDP is then reported at that end) or every node is grounded (the !! TDP is then reported at the suspended end). `grounded` is the deformed chord length - !! from the grounded end to the TDP, the whole line when every node is grounded, and 0 - !! when no node beyond the grounded end node is grounded: an end held at the seabed - !! elevation counts as grounded, but no line lies on the seabed there (the end is about - !! to lift, or has lifted). + !! from the grounded end to the TDP, so it varies continuously with the TDP: the whole + !! line when every node is grounded, and 0 only when the grounded end node itself is off + !! the seabed or the TDP sits at that node. REAL(wp), INTENT(IN) :: r(:, :), clearance(:) INTEGER, INTENT(IN) :: grounded_end LOGICAL, INTENT(OUT) :: touching @@ -352,7 +351,6 @@ PURE SUBROUTINE tdp_locate(r, clearance, grounded_end, touching, arc, point, sus END IF END IF grounded = s_scan - IF (last <= 1) grounded = CD_ZERO arc = s_scan IF (grounded_end == 2) arc = s_total - s_scan suspended_xy = r(1:2, node_of(nn)) diff --git a/tests/test_anchor_uplift.py b/tests/test_anchor_uplift.py index 6c314f1d..41f26e98 100644 --- a/tests/test_anchor_uplift.py +++ b/tests/test_anchor_uplift.py @@ -43,6 +43,10 @@ FAILURES: list[str] = [] G = 9.80665 RHO = 1025.0 +# TDPGrd is continuous with the touchdown point: an anchor node held on the seabed with the next node +# a few millimetres clear of it reads the contact-onset height times the chord over that clearance +# (micrometres to millimetres), not exactly 0. Laid means more than a centimetre. +GRD_TOL = 1.0e-2 def check(ok: bool, message: str) -> None: @@ -332,8 +336,10 @@ def main() -> int: f"suspended line: AnchFz1 + end-node weight = AnchFH1 tan(AnchIncl1) (difference " f"{(fz + node_w - fh * math.tan(incl)) / ten:+.1e} of AnchTen): the end force is the anchor " "segment's pull plus the anchor node's weight") - check(fz > 0.5 * ten and float(hist.column("TDP1Grd")[0]) == 0.0, - f"suspended line: AnchFz1 = {fz / 1e6:.3f} MN uplift and TDP1Grd = 0 (only the anchor node touches)") + grd_taut = float(hist.column("TDP1Grd")[0]) + check(fz > 0.5 * ten and grd_taut < GRD_TOL, + f"suspended line: AnchFz1 = {fz / 1e6:.3f} MN uplift and TDP1Grd = {grd_taut:.1e} m (only the anchor " + "node touches: the TDP sits within the contact-onset height of it)") check_anchor_point("suspended line", out / "taut", 1, 1) # --- (d) dynamics: a 42 m fairlead surge away from the anchor lifts the laid chain off it @@ -351,16 +357,17 @@ def main() -> int: check(finite and hist.time.size == 2001, f"surge: every channel is finite at all {hist.time.size} rows") check_anchor_point("surge", out / "lift", 1, 1) total = line_lengths(Path(f"{out / 'lift'}.Line1.p.out")) - laid = grd > 0.0 - worst = float(np.max(np.abs((s + grd - total)[laid]))) - check(worst < 2e-4, f"surge: TDP1s + TDP1Grd = deformed line length while chain is laid (max difference " - f"{worst:.1e} m over {int(np.count_nonzero(laid))} rows)") - check(bool(np.all(fz[laid] < 0.0)) and bool(np.all(grd[fz > 0.0] == 0.0)), - "surge: TDP1Grd > 0 implies AnchFz1 < 0, and AnchFz1 > 0 implies TDP1Grd = 0, at every row") - lift, bare = int(np.argmax(fz > 0.0)), int(np.argmax(grd == 0.0)) - check(fz[0] < 0.0 and grd[0] > 390.0 and fz[-1] > 0.0 and grd[-1] == 0.0 and bool(np.all(fz[lift:] > 0.0)) - and bool(np.all(grd[bare:] == 0.0)) and 0.0 <= hist.time[lift] - hist.time[bare] < 1.0, - f"surge: AnchFz1 {fz[0] / 1e3:.1f} -> {fz[-1] / 1e3:.1f} kN and TDP1Grd {grd[0]:.1f} -> {grd[-1]:.1f} m; " + laid = grd > GRD_TOL + worst = float(np.max(np.abs(s + grd - total))) + check(worst < 2e-4, f"surge: TDP1s + TDP1Grd = deformed line length at every row, laid or lifted (max " + f"difference {worst:.1e} m over {hist.time.size} rows, {int(np.count_nonzero(laid))} of them laid)") + check(bool(np.all(fz[laid] < 0.0)) and bool(np.all(grd[fz > 0.0] < GRD_TOL)), + f"surge: TDP1Grd > {GRD_TOL:g} m implies AnchFz1 < 0, and AnchFz1 > 0 implies TDP1Grd <= {GRD_TOL:g} m, " + "at every row") + lift, bare = int(np.argmax(fz > 0.0)), int(np.argmax(grd < GRD_TOL)) + check(fz[0] < 0.0 and grd[0] > 390.0 and fz[-1] > 0.0 and grd[-1] < GRD_TOL and bool(np.all(fz[lift:] > 0.0)) + and bool(np.all(grd[bare:] < GRD_TOL)) and 0.0 <= hist.time[lift] - hist.time[bare] < 1.0, + f"surge: AnchFz1 {fz[0] / 1e3:.1f} -> {fz[-1] / 1e3:.1f} kN and TDP1Grd {grd[0]:.1f} -> {grd[-1]:.1e} m; " f"the grounded length reaches 0 at t = {hist.time[bare]:.2f} s and the anchor lifts (AnchFz1 > 0) at " f"t = {hist.time[lift]:.2f} s, both for the rest of the run") h_end, v_end = suspended_catenary(550.0, 500.0 - offset, 100.0, w3, R3["ea"]) @@ -408,7 +415,8 @@ def main() -> int: src = (examples / "iea15mw_umaine_mixed_cabledyn.dat").read_text(encoding="utf-8") deck = set_option(src, "TMax", "0.5") - names = ["TDP1s", "TDP1Grd", "TDP4s", "TDP4Grd", *anchor_channels(1, 2), *anchor_channels(4, 8)] + names = ["TDP1s", "TDP1Grd", "TDP4s", "TDP4Grd", *anchor_channels(1, 2), *anchor_channels(4, 8), + "BendMom4N88", "BendMom4N87", "Curv4N88"] deck = set_outputs(deck, names) (out / "mixed.dat").write_text(deck, encoding="utf-8", newline="\n") run(args.exe, out / "mixed.dat", out / "mixed", env) @@ -419,6 +427,15 @@ def main() -> int: bool(np.all(hist.column("TDP4Grd") > 0.0)), f"mixed aggregate: laid chain (TDP1Grd {hist.column('TDP1Grd')[0]:.1f} m, AnchFz1 " f"{hist.column('AnchFz1')[0] / 1e3:.2f} kN) and laid cable (TDP4Grd {hist.column('TDP4Grd')[0]:.1f} m)") + # the cable's 'bare' type laid on the seabed (10 m elements): the recovered bend moment at the Fixed + # anchor node and its neighbour carries no fixed-end moment of the element's weight w l0^2 / 12 + w_bare = (36.70 - RHO * math.pi / 4.0 * 0.16**2) * G + m_end = w_bare * 10.0**2 / 12.0 + bm_anchor, bm_next = hist.column("BendMom4N88"), hist.column("BendMom4N87") + check(bool(np.all(np.abs(bm_anchor) < 0.02 * m_end)) and bool(np.all(np.abs(bm_next) < 0.02 * m_end)) and + bool(np.all(hist.column("Curv4N88") < 0.02 * m_end / 1.99e4)), + f"mixed aggregate, laid anchor: end-node BendMom4 {np.max(np.abs(bm_anchor)):.2e} N.m and next node " + f"{np.max(np.abs(bm_next)):.2e} N.m, well below the element weight moment w l0^2/12 = {m_end:.0f} N.m") src = (examples / "rigid6_buoy.dat").read_text(encoding="utf-8") deck = set_outputs(set_option(src, "TMax", "0.2"), [*anchor_channels(1, 4), *anchor_channels(2, 5)]) diff --git a/tests/test_coupled_torsion.f90 b/tests/test_coupled_torsion.f90 index fe2aaea2..285d0f2c 100644 --- a/tests/test_coupled_torsion.f90 +++ b/tests/test_coupled_torsion.f90 @@ -163,7 +163,7 @@ FUNCTION yaw_dcm(psi) RESULT(r) END FUNCTION yaw_dcm SUBROUTINE channels(agg, torq_a, torq_b, twist) - TYPE(CD_AGG_ModuleType), INTENT(IN) :: agg + TYPE(CD_AGG_ModuleType), INTENT(INOUT) :: agg REAL(wp), INTENT(OUT) :: torq_a, torq_b, twist INTEGER :: es CHARACTER(256) :: em diff --git a/tests/test_range_tdp.py b/tests/test_range_tdp.py index 02fa3bec..e8c99716 100644 --- a/tests/test_range_tdp.py +++ b/tests/test_range_tdp.py @@ -192,6 +192,30 @@ def check_output_recovery(exe: str, deck: str, out: Path, env: dict, nodes: list "OutputRecovery: an unknown value stops the run by name") +def check_soft_section_curvature(exe: str, deck: str, out: Path, env: dict, nodes: list[int]) -> None: + """A section softer than max(|w| L0^2)/12 times 1 m (1.3 kN m^2 on this cable) cannot resolve a + curvature from the recovered moment, whose error does not scale with EI: Curv takes the exact + geometric trace (the OutputRecovery element value) instead of an amplified moment error. With + EI = 100 N m^2 the recovered curvature would exceed 6 1/m against a peak trace of 0.12 1/m.""" + soft, count = re.subn(r"1\.99e4", "1.0e2", deck) + if count != 2: + raise RuntimeError("expected two EI entries in the lazy-wave line types, found %d" % count) + names = [f"Curv1N{j}" for j in nodes] + soft = set_outputs(soft, names) + (out / "lazywave_soft.dat").write_text(soft, encoding="utf-8", newline="\n") + run(exe, out / "lazywave_soft.dat", out / "lazywave_soft", env) + element = set_option(soft, "OutputRecovery", "element") + (out / "lazywave_soft_element.dat").write_text(element, encoding="utf-8", newline="\n") + run(exe, out / "lazywave_soft_element.dat", out / "lazywave_soft_element", env) + eq = read_output(out / "lazywave_soft.out") + el = read_output(out / "lazywave_soft_element.out") + worst = max(float(np.max(np.abs(eq.column(n) - el.column(n)))) for n in names) + peak = max(float(np.max(el.column(n))) for n in names) + check(worst == 0.0 and 0.0 < peak < 1.0, + f"soft section (EI = 100 N m^2): Curv takes the exact geometric trace (peak {peak:.3f} 1/m, " + f"difference to OutputRecovery element {worst:.1e})") + + def catenary_tdp(length: float, span: float, depth: float, w: float, ea: float) -> tuple[float, float, float]: """Elastic catenary resting on a frictionless seabed: (TDP deformed arc from the fairlead, TDP horizontal distance from the fairlead, horizontal tension).""" @@ -377,6 +401,7 @@ def main() -> int: check_envelopes("cubic-Hermite", out / "lazywave", 1, nodes, 1.0, -80.0) check_tdp_vs_python("cubic-Hermite", out / "lazywave", 1, -80.0, 5e-3) check_output_recovery(args.exe, deck, out, env, nodes) + check_soft_section_curvature(args.exe, deck, out, env, nodes) # --- Free point (point-system route) src = (examples / "clump_weight_free_point.dat").read_text(encoding="utf-8") diff --git a/tests/test_range_tdp_locator.f90 b/tests/test_range_tdp_locator.f90 new file mode 100644 index 00000000..f1d2b678 --- /dev/null +++ b/tests/test_range_tdp_locator.f90 @@ -0,0 +1,138 @@ +! File: tests/test_range_tdp_locator.f90 +! SPDX-License-Identifier: Apache-2.0 +! Copyright (c) 2026 Jae Hoon Seo, SMI Lab, Inha University +PROGRAM test_range_tdp_locator + !! Unit tests of the touchdown locator of CableDyn_RangeOutput on prescribed node + !! configurations: the quadratic crossing inside the element on convex and concave stencils, a + !! node reaching the onset height maps to that node, and the grounded length TDPGrd is + !! continuous with the touchdown point. + USE CableDyn_Precision, ONLY: wp + USE CableDyn_RangeOutput, ONLY: CD_RangeLine, CD_Range_TDP_Evaluate, CD_TDP_S, CD_TDP_X, CD_TDP_GRD, CD_TDP_N + USE CableDyn_SeabedContact, ONLY: CD_SEABED_CONTACT_BLEND + IMPLICIT NONE + + INTEGER :: nfail + nfail = 0 + + CALL case_convex_stencil() + CALL case_concave_stencil() + CALL case_node_at_onset() + CALL case_grounded_length_continuity() + CALL case_end_b() + + IF (nfail > 0) THEN + WRITE (*, '(A,I0,A)') 'FAIL: ', nfail, ' assertion(s) failed' + ERROR STOP 1 + END IF + WRITE (*, '(A)') 'PASS: CableDyn_RangeOutput touchdown locator' + +CONTAINS + + SUBROUTINE expect(got, want, tol, label) + REAL(wp), INTENT(IN) :: got, want, tol + CHARACTER(*), INTENT(IN) :: label + IF (.NOT. (ABS(got - want) <= tol)) THEN + WRITE (*, '(A,A,A,ES23.15,A,ES23.15)') 'MISMATCH [', label, ']: got ', got, ' want ', want + nfail = nfail + 1 + END IF + END SUBROUTINE expect + + SUBROUTINE locate(clearance, grounded_end, tdp) + !! Nodes on the x axis at unit spacing, heights = clearance (floor at z = 0). + REAL(wp), INTENT(IN) :: clearance(:) + INTEGER, INTENT(IN) :: grounded_end + REAL(wp), INTENT(OUT) :: tdp(CD_TDP_N) + TYPE(CD_RangeLine) :: line + REAL(wp) :: r(3, SIZE(clearance)) + INTEGER :: j + r = 0.0_wp + DO j = 1, SIZE(clearance) + r(1, j) = REAL(j - 1, wp) + r(3, j) = clearance(j) + END DO + line%tdp_ready = .TRUE. + line%tdp_end = grounded_end + line%ref_xy = 0.0_wp + line%ref_dir = [1.0_wp, 0.0_wp] + CALL CD_Range_TDP_Evaluate(line, r, clearance, tdp) + END SUBROUTINE locate + + SUBROUTINE case_convex_stencil() + !! Clearances from the onset height -0.005, 0.01, 1.0 on unit spacing: node 2 is barely off the + !! floor and the line rises sharply beyond it, so the line leaves the floor just before node 2. + !! The parabola crosses once inside the element, at 0.97 chord; the chord crossing (a third of + !! the way) would put the TDP a node behind. + REAL(wp) :: tdp(CD_TDP_N), c(4) + c = CD_SEABED_CONTACT_BLEND + [-0.005_wp, 0.01_wp, 1.0_wp, 2.0_wp] + CALL locate(c, 1, tdp) + IF (.NOT. (tdp(CD_TDP_X) > 0.95_wp .AND. tdp(CD_TDP_X) < 1.0_wp)) THEN + WRITE (*, '(A,ES23.15)') 'MISMATCH [convex: TDP just before the barely lifted node]: x = ', tdp(CD_TDP_X) + nfail = nfail + 1 + END IF + CALL expect(tdp(CD_TDP_GRD), tdp(CD_TDP_S), 1.0e-12_wp, 'convex: grounded length equals the arc from End A') + ! the same with the first node exactly at the onset height: the crossing stays inside the element + c(1) = CD_SEABED_CONTACT_BLEND + CALL locate(c, 1, tdp) + IF (.NOT. (tdp(CD_TDP_X) > 0.95_wp .AND. tdp(CD_TDP_X) < 1.0_wp)) THEN + WRITE (*, '(A,ES23.15)') 'MISMATCH [convex, node at onset: TDP inside the element]: x = ', tdp(CD_TDP_X) + nfail = nfail + 1 + END IF + END SUBROUTINE case_convex_stencil + + SUBROUTINE case_concave_stencil() + !! A stencil with the line rising more gently: g = -0.5, 0.5, 1.0, 1.5. + REAL(wp) :: tdp(CD_TDP_N), c(4) + c = CD_SEABED_CONTACT_BLEND + [-0.5_wp, 0.5_wp, 1.0_wp, 1.5_wp] + CALL locate(c, 1, tdp) + ! the parabola crosses before the linear crossing (x = 0.5) + IF (.NOT. (tdp(CD_TDP_X) > 0.4_wp .AND. tdp(CD_TDP_X) < 0.49_wp)) THEN + WRITE (*, '(A,ES23.15)') 'MISMATCH [concave: quadratic crossing before the linear one]: x = ', tdp(CD_TDP_X) + nfail = nfail + 1 + END IF + END SUBROUTINE case_concave_stencil + + SUBROUTINE case_node_at_onset() + !! A suspended node that reaches the onset height maps to that node. + REAL(wp) :: tdp(CD_TDP_N), c(4) + c = CD_SEABED_CONTACT_BLEND + [-0.5_wp, 1.0e-12_wp, 1.0_wp, 2.0_wp] + CALL locate(c, 1, tdp) + CALL expect(tdp(CD_TDP_X), 1.0_wp, 1.0e-6_wp, 'node reaching onset: TDP at that node') + END SUBROUTINE case_node_at_onset + + SUBROUTINE case_grounded_length_continuity() + !! Node 2 grounds while node 1 rests: Grd and the arc from End A are continuous (no jump + !! from 0 to a chord) and equal each other. + REAL(wp) :: tdp(CD_TDP_N), c(5), h, prev + INTEGER :: k + prev = 0.0_wp + DO k = 0, 12 + h = 0.5_wp*0.5_wp**k + c = CD_SEABED_CONTACT_BLEND + [-1.0e-3_wp, h, 1.0_wp, 2.0_wp, 3.0_wp] + CALL locate(c, 1, tdp) + CALL expect(tdp(CD_TDP_GRD), tdp(CD_TDP_S), 1.0e-12_wp, 'continuity: Grd equals the arc from End A') + IF (k > 0 .AND. ABS(tdp(CD_TDP_GRD) - prev) > 0.5_wp) THEN + WRITE (*, '(A,I0)') 'MISMATCH [continuity: jump of Grd while node 2 approaches the seabed] k = ', k + nfail = nfail + 1 + END IF + prev = tdp(CD_TDP_GRD) + END DO + ! node 2 on the seabed: Grd runs on to the next element, from a value below one chord + c = CD_SEABED_CONTACT_BLEND + [-1.0e-3_wp, 0.0_wp, 1.0_wp, 2.0_wp, 3.0_wp] + CALL locate(c, 1, tdp) + CALL expect(tdp(CD_TDP_GRD), 1.0_wp, 1.0e-5_wp, 'continuity: node 2 at the onset height') + ! the grounded end itself lifted off: nothing touches + c = CD_SEABED_CONTACT_BLEND + [1.0e-3_wp, 0.5_wp, 1.0_wp, 2.0_wp, 3.0_wp] + CALL locate(c, 1, tdp) + CALL expect(tdp(CD_TDP_GRD), 0.0_wp, 0.0_wp, 'lifted end: Grd = 0') + END SUBROUTINE case_grounded_length_continuity + + SUBROUTINE case_end_b() + !! The mirrored configuration gives the same grounded length. + REAL(wp) :: tdp_a(CD_TDP_N), tdp_b(CD_TDP_N), c(4) + c = CD_SEABED_CONTACT_BLEND + [-0.005_wp, 0.01_wp, 1.0_wp, 2.0_wp] + CALL locate(c, 1, tdp_a) + CALL locate(c(4:1:-1), 2, tdp_b) + CALL expect(tdp_b(CD_TDP_GRD), tdp_a(CD_TDP_GRD), 1.0e-12_wp, 'End B: grounded length of the mirrored line') + END SUBROUTINE case_end_b + +END PROGRAM test_range_tdp_locator From 2a2182eaeee5b2fdf61f5a199a42f2c3c9d712c0 Mon Sep 17 00:00:00 2001 From: Jae Hoon Seo Date: Fri, 16 Oct 2026 18:20:11 +0900 Subject: [PATCH 3/5] fix(outputs): restore the OpenFAST glue build, crease force in the recovery, O(n) node queries The OpenFAST CompMooring = 5 module no longer compiled: CD_AGG_ChannelHeader had become INTENT(INOUT) while CD_InitVars passes it part of an INTENT(IN) instance. CD_AGG_ChannelHeader and CD_AGG_GetInitLine write nothing and are INTENT(IN) again, as are the standalone driver's mixed-route header and initialisation printers; only the channel evaluator and the static profile, which reach the recovery cache, stay INTENT(INOUT), and every glue call of those passes the module-level instance or a local aggregate. The seabed force spread over the elements by the node recovery now matches the residual in a rounded bathymetry crease: it takes the crease curvature and adds the elastic increment of the penalty potential, as assemble_contact and the end force do, so interior tension, curvature and bend moment over a crease use the force the solve applied. A node query compared the whole line state with the cached one, so a loop over the nodes of a line (static profile, C API line values, a row of node channels) cost O(n^2). The cache is now keyed per element by its own 12 position, velocity and acceleration DOFs (the only state its end residual depends on) besides the time and the load configuration, so a query compares two elements and needs no list of the places that change the state. Tests: the pinned hang-off check of test_pinned_touchdown_stability and the kink checks of test_deck_hermite_cable read the geometric curvature (CD_HFMF_Curvature_Exact): the recovered curvature is zero at a pinned end by construction and is not a shape measure. test_anchor_uplift reads the anchor node and element length of the mixed example from its deck (the example is meshed with 248 elements since the rebase) and allows the bend of the laid run sinking into the penalty seabed beside the anchor. Documentation: the anchor uplift section no longer claims that AnchFz and TDPGrd agree. AnchFz is the anchor reaction; on an EI = 0 line it holds the anchor node's lumped weight, so its sign change lags the lift-off of the anchor segment, and TDPGrd (or AnchIncl) is the no-uplift check. The curvatures of the one-hour coupled full-turbine record, which cannot be re-run from the repository, are marked as the geometric definition; the Hs = 11 power-cable record and the OpenFAST tutorial give the recovered static values (Curv4N38 0.0902 1/m, BendMom4N38 1795 N m); the CHANGELOG qualifies the numbers measured on the example's former 87-element mesh and no longer says every other record is unchanged. Stale comments on the finite-EI segment tension and the TDP channel list are corrected. Signed-off-by: Jae Hoon Seo --- CHANGELOG.md | 45 +++++++----- VALIDATION.md | 2 +- app/cabledyn.f90 | 4 +- doc/driver_format.md | 7 +- doc/modeling.rst | 11 +-- doc/outputs.rst | 29 +++++--- doc/theory.rst | 12 ++-- doc/tutorial_openfast.rst | 4 +- src/CableDyn_DeckDriver.f90 | 9 ++- src/CableDyn_HermiteCableDynamic.f90 | 84 +++++++++++++++-------- src/CableDyn_OpenFAST_Aggregate.f90 | 4 +- tests/test_anchor_uplift.py | 37 +++++++--- tests/test_deck_hermite_cable.f90 | 9 ++- tests/test_pinned_touchdown_stability.f90 | 7 +- validation/OPENFAST_DLC_VERIFICATION.md | 10 ++- 15 files changed, 179 insertions(+), 95 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index fd7b6d8e..15818222 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -119,7 +119,9 @@ All notable changes to CableDyn are recorded in this file. The format follows `AnchFz`/`AnchFH` by name. The Python deck reader and builder accept the new names. See the manual's outputs page (Anchor uplift), which also states the end-node weight share that a laid `Fixed` anchor carries (slightly negative `AnchFz` on an `EI = 0` line, not uplift; exactly 0 - on a finite-EI line, whose grounded end leaves its node weight to the floor). + on a finite-EI line, whose grounded end leaves its node weight to the floor). Because of that + share, `AnchFz` on an `EI = 0` line turns positive only after the anchor segment has started + to lift, so `TDPGrd` is the primary no-uplift check and `AnchFz` the vertical anchor load. - `OutputRecovery` option (`equilibrium`, the default, or `element`): the definition of the finite-EI node tension, curvature, bend moment and segment tension (see Changed). `element` restores the definitions of 0.1.1. The Python deck reader accepts and checks it. @@ -140,16 +142,16 @@ All notable changes to CableDyn are recorded in this file. The format follows distributed loads and inertia: the effective tension is the axial component of the section force, the bend moment the moment the neighbouring elements carry, and the curvature that moment over `EI`. The derivation is in the manual's theory page (Node tension, curvature and - bend moment). On the lazy-wave cable of `examples/iea15mw_umaine_mixed_cabledyn.dat` (87 - elements) the static interior node tension now stays between 1217 N and the 11.9 kN fairlead - tension instead of dropping to -173 N. Against the equilibrium of the converged line, the - largest error falls from 1552 N to 60 N at the example's mesh, from 2059 N to 12 N, 1921 N to - 1 N and 516 N to 0.3 N at twice, four times and ten times the mesh density, and from 164 N to + bend moment). On the lazy-wave cable of `examples/iea15mw_umaine_mixed_cabledyn.dat` on its + former 87-element mesh the static interior node tension now stays between 1217 N and the + 11.9 kN fairlead tension instead of dropping to -173 N. Against the equilibrium of the + converged line, the largest error falls from 1552 N to 60 N at that mesh, from 2059 N to + 12 N, 1921 N to 1 N and 516 N to 0.3 N at twice, four times and ten times the mesh density, and from 164 N to 1 N at 0.25 m elements. The largest curvature error falls from 64 % to 30 %, 44 % to 7 %, 19 % to 4 % and 2.1 % to 0.8 % of the peak. Under an 8 m surge and 2 m heave of the hang-off, the error of the maximum-tension envelope against a 1 m mesh falls from 2164 N to 857 N, 1488 N to 283 N and 3049 N to 31 N, and the minimum tension of the run from -719 N to +610 N at - the example's mesh. A `.t.out` segment tension is now the mean of the axial components of the + that mesh. A `.t.out` segment tension is now the mean of the axial components of the element's two end forces instead of the axial resultant at its midpoint. The library curvature (`CD_HermiteCable_Dyn_Curvature`, `CD_HFMF_Curvature`) follows the same definition as the channels. A section softer than `max(|w| L0^2)/12` times 1 m (about 1.3 kN m^2 for the @@ -161,15 +163,22 @@ All notable changes to CableDyn are recorded in this file. The format follows nodes include), positions and the material-strain checks (`tensile_safety`, the static compression notes) are unchanged. At a `Fixed` anchor resting on the seabed the end element carries the floor-support share of its weight, as in the residual, so the end node reports - the bend moment of the line (0.02 N m, not 903 N m, at the anchor of the cable of - `examples/iea15mw_umaine_mixed_cabledyn.dat`, and 0.1 N m, not 205 N m, at the next node). On + the bend moment of the line (0.02 N m, not 903 N m, at the anchor of the 87-element cable of + `examples/iea15mw_umaine_mixed_cabledyn.dat`, and 0.1 N m, not 205 N m, at the next node; on + the example's 248-element mesh 0.1 N m and 1.5 N m, the bend of the laid run sinking into the + penalty seabed beside the anchor held at the seabed depth). On a line restrained in torsion the condensed torque is left out of the recovery; it moves the tension by at most 0.45 N of 9.4 kN on `examples/torsion_lazy_wave_hangoff_twist.dat`. Range graphs and `.t.out` files written every step cost 4 % more run time, plain channels under 2 %. `OutputRecovery element` restores the previous definitions. The T-6 record of `VALIDATION.md` (twisted lazy wave against OrcaFlex), which reads the static-profile - curvature, moves from 0.056 % to 0.049 %; the other records use end tensions or the exact - geometric curvature (`CD_HermiteCable_Dyn_Curvature_Exact`) and are unchanged. + curvature, moves from 0.056 % to 0.049 %. The curvatures of the one-hour coupled full-turbine + run in its coupled finite-EI touchdown row (0.156 1/m at the sag bend, 0.109 1/m at the + touchdown) were recorded with the previous definition and are marked as such, as is the + static sag-bend curvature of the Hs = 11 power-cable case of + `validation/OPENFAST_DLC_VERIFICATION.md`, which now also gives the recovered values. The other + records use end tensions or the exact geometric curvature + (`CD_HermiteCable_Dyn_Curvature_Exact`) and are unchanged. - The touchdown point (`TDP` channels and `cabledyn.touchdown_history`) is located inside the element by the parabola through the last grounded node and the next two nodes instead of the linear clearance between the last grounded node and the next. On a stiff seabed the @@ -219,12 +228,14 @@ All notable changes to CableDyn are recorded in this file. The format follows the static state, solved in the vertical plane of the cable, was unstable out of that plane. The static fairlead tension of the cable changes from 11 898 N to 11 922 N (11 921 N on a 1 m mesh), its anchor tension from 1218 N to 1230 N, and the touchdown curvature from - 0.058 1/m to 0.079 1/m (0.080 1/m on the 1 m mesh). The curvature output moves with the - mesh: `Curv4N20`/`BendMom4N20` (76 m from the hang-off) become `Curv4N38`/`BendMom4N38` - (74 m, the peak of the sag bend). In the one-hour full-turbine run of the validation record - the hang-off tension statistics are unchanged (11.5 ± 1.1 kN), the touchdown curvature peaks - at 0.109 1/m instead of 0.075 1/m, and the anchor tension stays at its static 1.23 kN, where - the coarse mesh showed stick-slip peaks up to 4.1 kN. The validation record and the tutorials + 0.058 1/m to 0.079 1/m (0.080 1/m on the 1 m mesh; the geometric curvature, which + `OutputRecovery element` reports, while the curvature recovered from nodal equilibrium reads + 0.100 1/m on the 87-element mesh and 0.081 1/m on the 248-element one). The curvature output + moves with the mesh: `Curv4N20`/`BendMom4N20` (76 m from the hang-off) become + `Curv4N38`/`BendMom4N38` (74 m, the peak of the sag bend). In the one-hour full-turbine run of + the validation record the hang-off tension statistics are unchanged (11.5 ± 1.1 kN), the + touchdown curvature (geometric) peaks at 0.109 1/m instead of 0.075 1/m, and the anchor + tension stays at its static 1.23 kN, where the coarse mesh showed stick-slip peaks up to 4.1 kN. The validation record and the tutorials are updated. - Faster tension-only (`EI = 0`) line steps. In every Newton evaluation the element kernels of the line loads (axial damping, Morison drag, Froude-Krylov, buoyancy recovery, added mass) no diff --git a/VALIDATION.md b/VALIDATION.md index 9c47f3ad..df910349 100644 --- a/VALIDATION.md +++ b/VALIDATION.md @@ -740,7 +740,7 @@ stop with a named error. | Active tension (`CtrlChan`) | Pass verified | CONTROL parsing, last-segment length/rate modulation, and exact unit tests; coupled A/B in which a ServoDyn cable-control DLL drives the same pay-out/haul-in `DeltaL` schedule into `=5` (CableDyn) and `=3` (stock MoorDyn) in one binary: hold tensions agree to <0.03% and the tension responses to <0.6% (controlled fairleads) / <0.7% (anchors) ([`validation/scripts/activetension/`](https://github.com/SMI-Lab-Inha/CableDyn/tree/main/validation/scripts/activetension), [`validation/scripts/openfast_activetension_ab.py`](https://github.com/SMI-Lab-Inha/CableDyn/blob/main/validation/scripts/openfast_activetension_ab.py)) | | Coupled `Rigid6` bodies + `Point3` buoys | Pass verified | 6-DOF `Rigid6` motion with hydrostatic (`C33`/`C44`/`C55`) restoring, checkpoint state (bit-identical `openfast -restart` of a 13.9 MN-swinging tethered body), and SeaState drag / Froude–Krylov / added mass. `Point3` buoys take buoyancy and drag/added-mass/FK; a submerged volume-only buoy takes FK. Tests: `case_coupled_rigid6`/`_mirror`/`_fluid`, `case_coupled_point3_buoy`/`_fluid` | | Coupled rigid rods | Pass verified | host-driven `RodA/B` endpoints, correction rewind, bit-identical 24-scalar-per-rod checkpoint state, and two Gauss fluid nodes per rod with SeaState drag/Froude–Krylov/added mass; `case_coupled_rod`, `_mirror`, and `_fluid` pass, and the OpenFAST module compiles with rod decks enabled | -| Coupled finite-EI touchdown/contact | Pass verified | flat `WtrDpth` and equivalent constant structured bathymetry initialise and step with matching loads; friction and checkpoint restore are tested. The IEA-15 mixed example (its power cable on 248 elements, each at most half the bending length) has 149 grounded nodes and completes a 20 s aggregate trajectory at `dtM=0.025 s` with 2 m surge, 1 m heave, and 0.5 m/s host current, without fallback or stall recovery, at most 12 Newton iterations. A full-turbine run of the same model (one hour after a 200 s transient; TurbSim normal turbulence, 10.6 m/s, 17 % TI; JONSWAP Hs 8 m, Tp 12 s, aligned with the wind and the cable; AeroDyn with the rotor held at 7.55 rpm, no controller, rigid blades and tower; SeaState grid covering the lines) completes without recoveries or non-finite values. The cable's hang-off tension is 11.5 ± 1.1 kN (static 11.9 kN, maximum 17.9 kN). The 149 nodes grounded at the static state stay grounded, joined by one more once the platform has drifted (the touchdown moves 2.5 m toward the platform). The peak curvature is 0.156 1/m at the sag bend, 72 m from the hang-off, and 0.109 1/m at the touchdown. On the former 87-element mesh (10 m elements along the laid section) the peak was 0.160 1/m and the touchdown curvature 0.075 1/m, under-resolved by about 30 %. The chain-only twin of the run matches stock MoorDyn over 1200 s to 0.3 % in platform motion and fairlead tension statistics. The anchor tension of the laid cable stays at its static 1.23 kN (maximum 1.24 kN): the seabed friction of the 370 m laid section holds the tension changes at the touchdown. On the former mesh it read 1.39 kN (median) with wave-frequency stick-slip peaks up to 4.1 kN lasting under 1 s, which the resolved mesh does not show, and before the anchor-end correction of this release it locked at about 2.75 kN for the whole run. The run takes 27.1 min of wall time (18.8 min on the former mesh) | +| Coupled finite-EI touchdown/contact | Pass verified | flat `WtrDpth` and equivalent constant structured bathymetry initialise and step with matching loads; friction and checkpoint restore are tested. The IEA-15 mixed example (its power cable on 248 elements, each at most half the bending length) has 149 grounded nodes and completes a 20 s aggregate trajectory at `dtM=0.025 s` with 2 m surge, 1 m heave, and 0.5 m/s host current, without fallback or stall recovery, at most 12 Newton iterations. A full-turbine run of the same model (one hour after a 200 s transient; TurbSim normal turbulence, 10.6 m/s, 17 % TI; JONSWAP Hs 8 m, Tp 12 s, aligned with the wind and the cable; AeroDyn with the rotor held at 7.55 rpm, no controller, rigid blades and tower; SeaState grid covering the lines) completes without recoveries or non-finite values. The cable's hang-off tension is 11.5 ± 1.1 kN (static 11.9 kN, maximum 17.9 kN). The 149 nodes grounded at the static state stay grounded, joined by one more once the platform has drifted (the touchdown moves 2.5 m toward the platform). The peak curvature is 0.156 1/m at the sag bend, 72 m from the hang-off, and 0.109 1/m at the touchdown. On the former 87-element mesh (10 m elements along the laid section) the peak was 0.160 1/m and the touchdown curvature 0.075 1/m, under-resolved by about 30 %. These curvatures were recorded before the `Curv` channels took the curvature recovered from nodal equilibrium: they are the geometric curvature of the centreline (the larger one-sided trace at a node), which `OutputRecovery element` reproduces. The chain-only twin of the run matches stock MoorDyn over 1200 s to 0.3 % in platform motion and fairlead tension statistics. The anchor tension of the laid cable stays at its static 1.23 kN (maximum 1.24 kN): the seabed friction of the 370 m laid section holds the tension changes at the touchdown. On the former mesh it read 1.39 kN (median) with wave-frequency stick-slip peaks up to 4.1 kN lasting under 1 s, which the resolved mesh does not show, and before the anchor-end correction of this release it locked at about 2.75 kN for the whole run. The run takes 27.1 min of wall time (18.8 min on the former mesh) | | `WaterKin` from file | Pass verified | See [WaterKin and SeaState modes](#waterkin-and-seastate-modes) | | Syrope polyester (`SYROPE:` syntax; [Falkenberg et al., 2017](https://cabledyn.readthedocs.io/en/latest/references.html#ref-falkenberg2017)) | Pass verified | MoorDyn-F/C `BA_s|BA_d` rate and force equations; analytic position/velocity tangents with finite-difference checks; projected, bracketed backward-Euler slow-state update with a strong-unloading boundary test; OWC running maximum; `SYROPE IC` `Tmax0/Tmean0` history with range/order checks; both states carried through every lifecycle stage and the coupled checkpoint. `BA_s` is kept separate from line axial damping (`BA`) and tested against double counting. Composite, hydrodynamic, finite-EI, current, and wave combinations stop with a named error | | VIV (`compVIV`) | Not supported | outside CableDyn's scope | diff --git a/app/cabledyn.f90 b/app/cabledyn.f90 index 53a40257..8cf7357d 100644 --- a/app/cabledyn.f90 +++ b/app/cabledyn.f90 @@ -692,7 +692,7 @@ FUNCTION ascii_lower(s) RESULT(r) END FUNCTION ascii_lower SUBROUTINE print_mixed_initialization(aggregate, stat, msg) - TYPE(CD_AGG_ModuleType), INTENT(INOUT) :: aggregate + TYPE(CD_AGG_ModuleType), INTENT(IN) :: aggregate INTEGER, INTENT(OUT) :: stat CHARACTER(*), INTENT(OUT) :: msg INTEGER :: n_lines, n_points, n_sections, n_ei0, n_finite, i, line_id, es @@ -743,7 +743,7 @@ END SUBROUTINE print_notes SUBROUTINE write_mixed_header(unit, aggregate, stat, msg) INTEGER, INTENT(IN) :: unit - TYPE(CD_AGG_ModuleType), INTENT(INOUT) :: aggregate + TYPE(CD_AGG_ModuleType), INTENT(IN) :: aggregate INTEGER, INTENT(OUT) :: stat CHARACTER(*), INTENT(OUT) :: msg INTEGER :: i, ios diff --git a/doc/driver_format.md b/doc/driver_format.md index 8a00cbab..105bf385 100644 --- a/doc/driver_format.md +++ b/doc/driver_format.md @@ -1270,9 +1270,10 @@ bending moment. None of these channels is mandatory. seabed at exactly one end in its initial state; otherwise the run stops with exit code 1 naming the line. They are available on every route, OpenFAST included. - The anchor uplift check of a drag-embedment anchor (no vertical load at the anchor in the - intact condition) reads `AnchFz` (its maximum over the run at most 0) or `TDPGrd` - (greater than a small tolerance such as 0.01 m throughout); see [Outputs](outputs.rst) for the end-node weight share that a - grounded `Fixed` anchor carries. + intact condition) reads `TDPGrd` (greater than a small tolerance such as 0.01 m + throughout); `AnchFz` is the vertical anchor load. On an `EI = 0` line it includes the + anchor node's lumped weight, so its sign change lags the anchor segment's lift-off; see + [Outputs](outputs.rst) (Anchor uplift). - In an OpenFAST `CompMooring = 5` run, channel headers in the OpenFAST output and in `.CD.out` use OpenFAST's 20-character width (`ChanLen`). A longer channel name stops coupled initialisation with an error naming the channel; keep coupled channel names diff --git a/doc/modeling.rst b/doc/modeling.rst index b68537c8..2ce56278 100644 --- a/doc/modeling.rst +++ b/doc/modeling.rst @@ -92,10 +92,13 @@ section change, keep the element length at most half the bending length power cable with :math:`EI = 2\times10^4` N m² and :math:`w = 158` N/m that is 2.5 m. A longer element cannot follow the bend: it stays stiff in bending, and its stiff axial term absorbs the mismatch, so the pointwise axial force oscillates about the element mean, by tens of kN on a -lazy wave of 1–2 kN tension at 10 m elements. The ``.t.out`` segment tensions, evaluated at the -element midpoints, show these spikes and negative values near touchdown and at section changes; -they shrink as the mesh is refined, and the element-mean force (what enters equilibrium, see -``tensile_safety`` in :doc:`theory`) is far smoother. The compressed Gauss points also lower the +lazy wave of 1–2 kN tension at 10 m elements. The tension outputs (node ``Ten`` channels, +``.t.out`` segment tensions) are recovered from the element end forces and do not carry it (see +Node tension, curvature and bend moment in :doc:`theory`); under ``OutputRecovery element`` the +``.t.out`` segment tensions, evaluated at the element midpoints, show these spikes and negative +values near touchdown and at section changes. They shrink as the mesh is refined, and the +element-mean force (what the material-strain checks judge, see ``tensile_safety`` in +:doc:`theory`) is far smoother. The compressed Gauss points also lower the out-of-plane stiffness: a line solved in 3D (restrained in torsion, or with an end connection direction or a current out of its vertical plane) can read as an unstable equilibrium on such a mesh. The static solve then refines that state to the rule above, whichever route reached it and diff --git a/doc/outputs.rst b/doc/outputs.rst index 727a5775..f55546b5 100644 --- a/doc/outputs.rst +++ b/doc/outputs.rst @@ -531,17 +531,24 @@ Anchor uplift A drag-embedment anchor is designed for a horizontal pull and loses holding capacity under a vertical one, so design practice for catenary moorings (DNV-OS-E301, API RP 2SK) requires no -vertical uplift at the anchor in the intact condition: some chain stays laid on the seabed. Two -channels give the check for line ``L`` directly: +vertical uplift at the anchor in the intact condition: some chain stays laid on the seabed. The +primary check for line ``L`` is the grounded length: -* the maximum of ``AnchFz`` over the run is at most 0; * the minimum of ``TDPGrd`` (`Touchdown channels`_) over the run is greater than a small - tolerance (0.01 m is a centimetre, far below an element). - -The two agree: while chain is laid at the anchor the line pulls it horizontally, and once the -grounded length falls to the tolerance the line lifts its anchor and ``AnchFz`` turns positive. -``TDPGrd`` is continuous with the touchdown point, so an anchor node held on the seabed beside a -node a few millimetres clear of it reads micrometres to millimetres, not exactly 0. + tolerance (0.01 m is a centimetre, far below an element). ``TDPGrd`` is continuous with + the touchdown point, so an anchor node held on the seabed beside a node a few millimetres + clear of it reads micrometres to millimetres, not exactly 0. ``AnchIncl`` departing from 0 + (the anchor segment rising from the seabed) shows the same onset. + +``AnchFz`` is the anchor reaction itself (equal to ``Point

Fz`` of a one-line anchor), the +quantity to compare with the anchor's vertical capacity. It is not an exact uplift indicator on +an ``EI = 0`` line: the reaction includes the anchor node's lumped weight (below), so it stays +negative for a while after the anchor segment starts to lift and turns positive only once the +line's pull exceeds that weight. When a surge pulls the chain off its anchor the sign change +lags the grounded length reaching 0 (by under a second in the regression suite's surge case), +so ``max AnchFz <= 0`` alone can pass a run in which the anchor segment already lifts by an +angle of order :math:`w\,\Delta L/(2H)`. Use ``TDPGrd`` (or ``AnchIncl``) for the +no-uplift criterion and ``AnchFz`` for the vertical load. On a laid ``EI = 0`` line ``AnchFz`` is a small negative value, not 0. The anchor node of a ``Fixed`` point at the seabed depth is held at the seabed elevation, while the penalty seabed @@ -560,8 +567,8 @@ In :doc:`tutorial_catenary` (:math:`w` = 3.18 kN/m, :math:`\Delta L` = 10 m, beside ``AnchFH1`` = 191.5 kN (the horizontal tension) and ``AnchTen1`` = 192.4 kN. The share belongs to the lumped anchor node: it scales with the anchor segment length, vanishes as the mesh is refined, and is not uplift. A finite-EI (cubic-Hermite) end resting on the seabed leaves its -end node's weight to the floor and reads ``AnchFz`` = 0 there. Check the sign of ``AnchFz``, not -the difference between ``AnchTen`` and ``AnchFH``. +end node's weight to the floor and reads ``AnchFz`` = 0 there. Read the vertical anchor load from +``AnchFz``, not from the difference between ``AnchTen`` and ``AnchFH``. Line-node channels ~~~~~~~~~~~~~~~~~~ diff --git a/doc/theory.rst b/doc/theory.rst index 91f0db76..20a6de90 100644 --- a/doc/theory.rst +++ b/doc/theory.rst @@ -185,7 +185,7 @@ on a fine mesh among them. :math:`\lvert\mathbf{r}'\rvert` constant where the line must bend over an element (a nodal seabed reaction, a section junction): the pointwise axial resultant oscillates about the element mean by several times the tension, and the element means alternate between neighbours. On that -cable as meshed in the example (87 elements, 10 m on the grounded run, tension 1.2 kN) the +cable on the example's former 87-element mesh (10 m on the grounded run, tension 1.2 kN) the pointwise resultant spans -41.5 to +91.8 kN and the length-weighted element means at the nodes reach -173 N; at 1 m elements the pointwise field still spans -5.9 to +11.9 kN. @@ -226,12 +226,16 @@ consistent-load moment :math:`w L_0^2/12` of an element (a section junction leav order between the two one-sided moments), so over a soft section dividing by :math:`EI` amplifies it. A section whose :math:`EI` is below :math:`\max_e(\lvert w_e\rvert L_{0,e}^2)/12` times 1 m, the stiffness whose elastic moment at a 1 m bend radius equals that error, takes its curvature -from the exact geometric trace instead, as an element with :math:`EI = 0` does (on the lazy-wave -cable of ``iea15mw_umaine_mixed_cabledyn.dat`` with :math:`EI` lowered to 100 N m\ :sup:`2` the +from the exact geometric trace instead, as an element with :math:`EI = 0` does (on the 87-element +lazy-wave cable with :math:`EI` lowered to 100 N m\ :sup:`2` the recovered curvature reaches 6.9 1/m against a geometric peak of 0.12 1/m; the bend moment of such a section remains the recovered one, with that error). The difference of the two one-sided forces is the point load left at the node (seabed friction, an -attachment). At the converged static state the nodal section forces satisfy the discrete +attachment) plus, where the nodal seabed reaction varies from node to node (the touchdown, a +rounded crease of the bathymetry), the difference between its spread and its nodal form, about +0.094 times its second difference along the line. The seabed reaction spread here is the one the +residual applies, with the crease increment of the penalty potential inside a rounded crease. At +the converged static state the nodal section forces satisfy the discrete equilibrium exactly. In a dynamic run the recovery is the balance at the output time :math:`t_{n+1}`, with the position, velocity and acceleration the step committed there: the inertia term :math:`\mathbf{M}_e\mathbf{a}_e` uses the step's acceleration diff --git a/doc/tutorial_openfast.rst b/doc/tutorial_openfast.rst index a04334e7..425ad77d 100644 --- a/doc/tutorial_openfast.rst +++ b/doc/tutorial_openfast.rst @@ -319,8 +319,8 @@ seabed. Copy it into the case folder and point a copy of the ``.fst`` at it: 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 ... - Curv4N38 = 9.06020E-02 (1/m) - BendMom4N38 = 1803 (N.m) + Curv4N38 = 9.01821E-02 (1/m) + BendMom4N38 = 1794.6 (N.m) CableDyn found the cable's touchdown and lazy-wave shape by itself: in ``Mixed_CableDyn.CD.static.out``, 149 of line 4's 249 nodes lie on the seabed. Node 38, 74 m diff --git a/src/CableDyn_DeckDriver.f90 b/src/CableDyn_DeckDriver.f90 index 49d47397..fd34c926 100644 --- a/src/CableDyn_DeckDriver.f90 +++ b/src/CableDyn_DeckDriver.f90 @@ -30985,7 +30985,8 @@ SUBROUTINE CD_Eval_Aggregate_Channel(ch, has_sys, system, cables, line_is_cable, RETURN END IF - ! TDP{s,x,y,z,Lay,Exc}: the touchdown point of the current configuration. + ! TDP{s,x,y,z,Lay,Exc,Grd}: the touchdown point of the current configuration and the + ! grounded length behind it. IF (CD_Is_TDP_Channel(lo)) THEN IF (.NOT. PRESENT(ranges)) THEN CALL fail(ErrStat, ErrMsg, 'OUTPUT "'//TRIM(ch)//'": touchdown channels are not available here'); RETURN @@ -31060,8 +31061,10 @@ SUBROUTINE CD_Eval_Aggregate_Segment_Tensions(line_id, has_sys, system, cables, tension, ErrStat, ErrMsg) !! Segment (element) tensions of deck line line_id in public order End A -> End B, the !! values the standalone driver writes to .Line.t.out: the EI=0 element tensions of - !! CD_Get_Model_Tension, or the Hermite element-midpoint axial tension of a finite-EI cable. - !! tension must hold exactly the line's element count. + !! CD_Get_Model_Tension, or the segment tensions of a finite-EI cable (cable_segment_tensions: + !! the mean axial component of the element's two equilibrium end forces, or under OPTIONS + !! OutputRecovery element the axial resultant at the element midpoint). tension must hold + !! exactly the line's element count. INTEGER, INTENT(IN) :: line_id LOGICAL, INTENT(IN) :: has_sys TYPE(CD_SystemType), INTENT(IN) :: system diff --git a/src/CableDyn_HermiteCableDynamic.f90 b/src/CableDyn_HermiteCableDynamic.f90 index c83e355a..485488fd 100644 --- a/src/CableDyn_HermiteCableDynamic.f90 +++ b/src/CableDyn_HermiteCableDynamic.f90 @@ -424,14 +424,17 @@ MODULE CableDyn_HermiteCableDynamic ! from nodal equilibrium carries an error of that order, independent of EI, so over a softer ! section it cannot give the curvature (node_values then takes the exact geometric trace). REAL(wp) :: ei_resolve = CD_ZERO - ! Cache of the element end residuals behind the node outputs (CD_HermiteCable_Dyn_Node_Values), - ! valid for the state t, q, v, a and the configuration epoch it was filled at: the channels of - ! one output row share one evaluation per element. Allocated once at initialisation; rc_epoch - ! counts the loads configured after it (drag, waves, added mass, held fluid, contact). + ! Cache of the element end residuals behind the node outputs (CD_HermiteCable_Dyn_Node_Values). + ! Element e's entry rc_g(:, e) is valid for the time and configuration epoch the cache was + ! keyed at (rc_t, rc_key_epoch) and for the element's own 12 q, v and a DOFs it was evaluated + ! at (rc_q/rc_v/rc_a(:, e)), the only state its residual depends on, so a node query costs two + ! element comparisons and the channels of one output row share one evaluation per element. + ! Allocated once at initialisation; rc_epoch counts the loads configured after it (drag, + ! waves, added mass, held fluid, contact). INTEGER :: rc_epoch = 0, rc_key_epoch = -1 LOGICAL :: rc_key_ok = .FALSE. REAL(wp) :: rc_t = CD_ZERO - REAL(wp), ALLOCATABLE :: rc_q(:), rc_v(:), rc_a(:), rc_g(:, :) + REAL(wp), ALLOCATABLE :: rc_q(:, :), rc_v(:, :), rc_a(:, :), rc_g(:, :) LOGICAL, ALLOCATABLE :: rc_have(:) LOGICAL :: initialized = .FALSE. END TYPE CD_HermiteCableDynType @@ -622,7 +625,7 @@ SUBROUTINE CD_HermiteCable_Dyn_Init(model, l0, EA, EI, rho_a, w, seed, fixed_dof ! state: at-rest seed, v = 0, consistent a0 ALLOCATE (model%q(ndof), model%v(ndof), model%a(ndof)) - ALLOCATE (model%rc_q(ndof), model%rc_v(ndof), model%rc_a(ndof), model%rc_g(12, ne), model%rc_have(ne)) + ALLOCATE (model%rc_q(12, ne), model%rc_v(12, ne), model%rc_a(12, ne), model%rc_g(12, ne), model%rc_have(ne)) model%rc_have = .FALSE. model%rc_key_ok = .FALSE. model%q = seed @@ -4752,10 +4755,11 @@ END SUBROUTINE CD_HermiteCable_Dyn_Set_Output_Recovery SUBROUTINE CD_HermiteCable_Dyn_Node_Values(model, node, tension, curvature, bend_moment, ErrStat, ErrMsg) !! Equilibrium node values at one node (internal order), from the two adjacent elements; !! the same values as CD_HermiteCable_Dyn_Node_Recovery returns for that node. The element end - !! residuals are kept in the model for the state they were evaluated at (see the rc_ fields), - !! so the tension, curvature and bend moment of a node, and of neighbouring nodes, share one - !! evaluation per element; a changed state or load configuration refreshes them. No - !! allocation. + !! residuals are kept in the model for the element state they were evaluated at (see the rc_ + !! fields), so the tension, curvature and bend moment of a node, and of neighbouring nodes, + !! share one evaluation per element; a changed time, load configuration or element state + !! refreshes them. A query compares the two adjacent elements' states only, so a loop over + !! every node of a line costs O(nn). No allocation. TYPE(CD_HermiteCableDynType), INTENT(INOUT) :: model INTEGER, INTENT(IN) :: node REAL(wp), INTENT(OUT) :: tension, curvature, bend_moment @@ -4771,12 +4775,9 @@ SUBROUTINE CD_HermiteCable_Dyn_Node_Values(model, node, tension, curvature, bend IF (node < 1 .OR. node > model%nn) THEN ErrStat = CD_HCDYN_BADINPUT; ErrMsg = 'CD_HermiteCable_Dyn_Node_Values: node out of range'; RETURN END IF - ! the cached residuals belong to the state they were computed at (exact comparison; a NaN - ! state never matches and is recomputed) - IF (.NOT. (model%rc_key_ok .AND. model%rc_key_epoch == model%rc_epoch .AND. model%rc_t == model%t .AND. & - ALL(model%rc_q == model%q) .AND. ALL(model%rc_v == model%v) .AND. & - ALL(model%rc_a == model%a))) THEN - model%rc_q = model%q; model%rc_v = model%v; model%rc_a = model%a + ! the cached residuals belong to the time and load configuration they were computed at, and + ! each to its element's state (exact comparisons; a NaN never matches and is recomputed) + IF (.NOT. (model%rc_key_ok .AND. model%rc_key_epoch == model%rc_epoch .AND. model%rc_t == model%t)) THEN model%rc_t = model%t; model%rc_key_epoch = model%rc_epoch model%rc_key_ok = .TRUE. model%rc_have = .FALSE. @@ -4800,15 +4801,26 @@ SUBROUTINE cached_end_residual(e, ge) INTEGER, INTENT(IN) :: e REAL(wp), INTENT(OUT) :: ge(12) REAL(wp) :: gl(12) - IF (.NOT. model%rc_have(e)) THEN - CALL element_end_residual(model, e, gl, ErrStat, ErrMsg) - IF (ErrStat /= CD_HCDYN_OK) THEN - ge = CD_ZERO; RETURN + INTEGER :: i0 + ! the element's residual depends on its own two nodes' q, v and a only (element_end_residual) + i0 = 6*(e - 1) + IF (model%rc_have(e)) THEN + IF (ALL(model%rc_q(:, e) == model%q(i0 + 1:i0 + 12)) .AND. ALL(model%rc_v(:, e) == model%v(i0 + 1:i0 + 12)) & + .AND. ALL(model%rc_a(:, e) == model%a(i0 + 1:i0 + 12))) THEN + ge = model%rc_g(:, e); RETURN END IF - model%rc_g(:, e) = gl - model%rc_have(e) = .TRUE. END IF - ge = model%rc_g(:, e) + model%rc_have(e) = .FALSE. + CALL element_end_residual(model, e, gl, ErrStat, ErrMsg) + IF (ErrStat /= CD_HCDYN_OK) THEN + ge = CD_ZERO; RETURN + END IF + model%rc_q(:, e) = model%q(i0 + 1:i0 + 12) + model%rc_v(:, e) = model%v(i0 + 1:i0 + 12) + model%rc_a(:, e) = model%a(i0 + 1:i0 + 12) + model%rc_g(:, e) = gl + model%rc_have(e) = .TRUE. + ge = gl END SUBROUTINE cached_end_residual END SUBROUTINE CD_HermiteCable_Dyn_Node_Values @@ -4960,15 +4972,18 @@ PURE FUNCTION unit_tangent(model, node) RESULT(t) END FUNCTION unit_tangent SUBROUTINE node_contact_normal(model, node, fc, ErrStat, ErrMsg) - !! Frictionless seabed normal force (with its damping) on a node at the committed state, as - !! assemble_contact applies it. + !! Frictionless seabed contact force on a node at the committed state, exactly as + !! assemble_contact applies it: the normal force with its damping and, in a rounded crease + !! of the bathymetry, the elastic increment of the penalty potential (crease_contact_increment). TYPE(CD_HermiteCableDynType), INTENT(IN) :: model INTEGER, INTENT(IN) :: node REAL(wp), INTENT(OUT) :: fc(3) INTEGER, INTENT(OUT) :: ErrStat CHARACTER(*), INTENT(OUT) :: ErrMsg REAL(wp) :: z_floor, gx, gy, xg, yg, gxg, gyg, sfac, nvec(3), gap, normal, normal_gap, vn, gate, gate_gap + REAL(wp) :: curv_g(3), fcrease(3), kcrease(3, 3) INTEGER :: iz, es + LOGICAL :: creased CHARACTER(200) :: em2 ErrStat = CD_HCDYN_OK; ErrMsg = '' fc = CD_ZERO @@ -4976,26 +4991,35 @@ SUBROUTINE node_contact_normal(model, node, fc, ErrStat, ErrMsg) IF (model%has_contact) THEN z_floor = model%seabed_z gx = CD_ZERO; gy = CD_ZERO + creased = .FALSE. IF (model%has_contact_bathymetry) THEN xg = model%contact_frame_c*model%q(iz - 2) - model%contact_frame_s*model%q(iz - 1) yg = model%contact_frame_s*model%q(iz - 2) + model%contact_frame_c*model%q(iz - 1) - CALL CD_Bathymetry_Floor_Gradient(model%contact_bathymetry, xg, yg, z_floor, gxg, gyg, es, em2) + CALL CD_Bathymetry_Floor_Gradient(model%contact_bathymetry, xg, yg, z_floor, gxg, gyg, es, em2, & + crease_curvature=curv_g) IF (es /= CD_BATHY_OK) THEN ErrStat = CD_HCDYN_NOCONVERGE; ErrMsg = 'node_contact_normal: '//TRIM(em2); RETURN END IF gx = model%contact_frame_c*gxg + model%contact_frame_s*gyg gy = -model%contact_frame_s*gxg + model%contact_frame_c*gyg + creased = ANY(ABS(curv_g) > CD_ZERO) END IF sfac = SQRT(CD_ONE + gx*gx + gy*gy) nvec = [-gx, -gy, CD_ONE]/sfac gap = (z_floor - model%q(iz))/sfac CALL CD_Seabed_Normal_Law(gap, model%contact_kn(node), normal, normal_gap) + CALL CD_Seabed_Contact_Gate(gap, gate, gate_gap) + IF (normal <= CD_ZERO .AND. gate <= CD_ZERO) RETURN vn = DOT_PRODUCT(model%v(iz - 2:iz), nvec) - IF (ALLOCATED(model%contact_cn) .AND. vn < CD_ZERO) THEN - CALL CD_Seabed_Contact_Gate(gap, gate, gate_gap) - normal = normal - model%contact_cn(node)*gate*vn + IF (ALLOCATED(model%contact_cn) .AND. vn < CD_ZERO) normal = normal - model%contact_cn(node)*gate*vn + fc = normal*nvec + IF (creased) THEN + CALL crease_contact_increment(z_floor - model%q(iz), gx, gy, model%contact_kn(node), & + CD_Bathymetry_Rotate_Curvature(curv_g, [model%contact_frame_c, & + model%contact_frame_s]), & + fcrease, kcrease) + fc = fc + fcrease END IF - IF (normal > CD_ZERO) fc = normal*nvec ELSE IF (model%kn > CD_ZERO) THEN gap = model%seabed_z - model%q(iz) IF (gap > CD_ZERO) fc(3) = model%kn*gap*model%trib(node) diff --git a/src/CableDyn_OpenFAST_Aggregate.f90 b/src/CableDyn_OpenFAST_Aggregate.f90 index 0eced1d3..3eb67ebc 100644 --- a/src/CableDyn_OpenFAST_Aggregate.f90 +++ b/src/CableDyn_OpenFAST_Aggregate.f90 @@ -1888,7 +1888,7 @@ SUBROUTINE CD_AGG_GetInitLine(self, i, line_id, tension, force, inclination, dec note) !! Return one line's unconditional converged-static fairlead result in deck order, and !! (optional note) the static-initialisation notes of a finite-EI line ('' if none). - TYPE(CD_AGG_ModuleType), INTENT(INOUT) :: self + TYPE(CD_AGG_ModuleType), INTENT(IN) :: self INTEGER, INTENT(IN) :: i INTEGER, INTENT(OUT) :: line_id REAL(wp), INTENT(OUT) :: tension, force(3), inclination, declination, azimuth @@ -1925,7 +1925,7 @@ END SUBROUTINE CD_AGG_GetInitLine SUBROUTINE CD_AGG_ChannelHeader(self, i, hdr, unt, ErrStat, ErrMsg) !! Header token and OrcaFlex unit label for channel i (1 .. CD_AGG_NumChannels), for the !! OpenFAST InitOut%WriteOutputHdr / WriteOutputUnt registration. - TYPE(CD_AGG_ModuleType), INTENT(INOUT) :: self + TYPE(CD_AGG_ModuleType), INTENT(IN) :: self INTEGER, INTENT(IN) :: i CHARACTER(*), INTENT(OUT) :: hdr, unt INTEGER, INTENT(OUT) :: ErrStat diff --git a/tests/test_anchor_uplift.py b/tests/test_anchor_uplift.py index 41f26e98..23a5c5fc 100644 --- a/tests/test_anchor_uplift.py +++ b/tests/test_anchor_uplift.py @@ -97,6 +97,14 @@ def set_outputs(text: str, names: list[str]) -> str: return "\n".join(lines[: start + 1] + [f'"{n}"' for n in names] + lines[end:]) + "\n" +def line_sections(text: str, line_id: int) -> list[tuple[str, float, int]]: + """(type, length, segments) of each SECTIONS row of one line, End A first.""" + lines = text.splitlines() + a, b = table_rows(text, "SECTIONS") + rows = [lines[i].split() for i in range(a, b)] + return [(tok[1], float(tok[2]), int(tok[3])) for tok in rows if tok and tok[0] == str(line_id)] + + def anchor_channels(line_id: int, point_id: int) -> list[str]: return [f"AnchTen{line_id}", f"AnchFz{line_id}", f"AnchFH{line_id}", f"Point{point_id}Fz", f"Point{point_id}FH"] @@ -415,8 +423,14 @@ def main() -> int: src = (examples / "iea15mw_umaine_mixed_cabledyn.dat").read_text(encoding="utf-8") deck = set_option(src, "TMax", "0.5") + # the cable's anchor (End B) node and its laid end section, from the example's own mesh + sections = line_sections(src, 4) + n_anchor = sum(nseg for _, _, nseg in sections) + 1 + end_type, end_length, end_nseg = sections[-1] + check(end_type == "bare", f"mixed example: the cable's anchor section is the bare type ({end_type})") + l0_end = end_length / end_nseg names = ["TDP1s", "TDP1Grd", "TDP4s", "TDP4Grd", *anchor_channels(1, 2), *anchor_channels(4, 8), - "BendMom4N88", "BendMom4N87", "Curv4N88"] + f"BendMom4N{n_anchor}", f"BendMom4N{n_anchor - 1}", f"Curv4N{n_anchor}"] deck = set_outputs(deck, names) (out / "mixed.dat").write_text(deck, encoding="utf-8", newline="\n") run(args.exe, out / "mixed.dat", out / "mixed", env) @@ -427,15 +441,22 @@ def main() -> int: bool(np.all(hist.column("TDP4Grd") > 0.0)), f"mixed aggregate: laid chain (TDP1Grd {hist.column('TDP1Grd')[0]:.1f} m, AnchFz1 " f"{hist.column('AnchFz1')[0] / 1e3:.2f} kN) and laid cable (TDP4Grd {hist.column('TDP4Grd')[0]:.1f} m)") - # the cable's 'bare' type laid on the seabed (10 m elements): the recovered bend moment at the Fixed - # anchor node and its neighbour carries no fixed-end moment of the element's weight w l0^2 / 12 + # the cable's 'bare' type laid on the seabed: the recovered bend moment at the Fixed anchor node and + # its neighbour carries no fixed-end moment of the element's weight w l0^2 / 12. The line does bend + # there: the anchor node is held at the seabed depth and the laid run sinks delta = w/(kBot d) into + # the penalty seabed, a bend of about 2 delta / l0^2 over the anchor element (EI 2 delta / l0^2 = + # 2.1 N.m on 2.5 m elements), which the bound allows on top of 2 % of the weight moment w_bare = (36.70 - RHO * math.pi / 4.0 * 0.16**2) * G - m_end = w_bare * 10.0**2 / 12.0 - bm_anchor, bm_next = hist.column("BendMom4N88"), hist.column("BendMom4N87") - check(bool(np.all(np.abs(bm_anchor) < 0.02 * m_end)) and bool(np.all(np.abs(bm_next) < 0.02 * m_end)) and - bool(np.all(hist.column("Curv4N88") < 0.02 * m_end / 1.99e4)), + ei_bare, kbot = 1.99e4, 3.0e6 + m_end = w_bare * l0_end**2 / 12.0 + m_sink = ei_bare * 2.0 * w_bare / (kbot * 0.16) / l0_end**2 + bound = 0.02 * m_end + m_sink + bm_anchor, bm_next = hist.column(f"BendMom4N{n_anchor}"), hist.column(f"BendMom4N{n_anchor - 1}") + check(bool(np.all(np.abs(bm_anchor) < bound)) and bool(np.all(np.abs(bm_next) < bound)) and + bool(np.all(hist.column(f"Curv4N{n_anchor}") < bound / ei_bare)) and bound < 0.1 * m_end, f"mixed aggregate, laid anchor: end-node BendMom4 {np.max(np.abs(bm_anchor)):.2e} N.m and next node " - f"{np.max(np.abs(bm_next)):.2e} N.m, well below the element weight moment w l0^2/12 = {m_end:.0f} N.m") + f"{np.max(np.abs(bm_next)):.2e} N.m, below {bound:.1f} N.m and far below the element weight moment " + f"w l0^2/12 = {m_end:.0f} N.m") src = (examples / "rigid6_buoy.dat").read_text(encoding="utf-8") deck = set_outputs(set_option(src, "TMax", "0.2"), [*anchor_channels(1, 4), *anchor_channels(2, 5)]) diff --git a/tests/test_deck_hermite_cable.f90 b/tests/test_deck_hermite_cable.f90 index 6ab57782..652e30f0 100644 --- a/tests/test_deck_hermite_cable.f90 +++ b/tests/test_deck_hermite_cable.f90 @@ -12,7 +12,8 @@ PROGRAM test_deck_hermite_cable USE CableDyn_Precision, ONLY: wp USE CableDyn_DeckDriver, ONLY: CD_Init_Deck_HermiteCable, CD_DECKDRV_OK, CD_DECKDRV_BADINPUT USE CableDyn_OpenFAST_HermiteFMF, ONLY: CD_HFMF_ModuleType, CD_HFMF_UpdateStates, CD_HFMF_CalcOutput, & - CD_HFMF_Curvature, CD_HFMF_GetCoupledKinematics, & + CD_HFMF_Curvature, CD_HFMF_Curvature_Exact, & + CD_HFMF_GetCoupledKinematics, & CD_HFMF_MinSpanZ, CD_HFMF_Snapshot, CD_HFMF_Restore, & CD_HFMF_End, CD_HFMF_OK USE CableDyn_EndConnection, ONLY: CD_ENDCONN_RIGID @@ -112,7 +113,9 @@ SUBROUTINE case_build_and_drive() ! Curvature must stay SMOOTH: a lazy-wave sag/arch bend is O(0.1 /m); a value near 1 /m would ! be a sub-element kink (the slack-catenary buckling mode this lazy-wave gate avoids). Bound ! well below that so the gate actually fails on a kinked response, not just a non-finite one. - CALL CD_HFMF_Curvature(cable, curv, es, em) + ! A kink is a defect of the centreline shape, so the gate reads its geometric trace + ! (CD_HFMF_Curvature_Exact), not the Curv channel's equilibrium moment over EI. + CALL CD_HFMF_Curvature_Exact(cable, curv, es, em) CALL require(es == CD_HFMF_OK .AND. .NOT. ANY(IEEE_IS_NAN(curv)) .AND. nan_max_abs(curv) < 1.0_wp, & 'curvature finite, bounded, and smooth (no kink)') WRITE (*, '(A,F9.1,A,F9.2,A,ES10.3)') 'deck-Hermite cable: steady |Fair| = ', ymag*1.0e-3_wp, & @@ -189,7 +192,7 @@ SUBROUTINE case_adaptive_mesh_refines() END DO IF (stepped_ok) THEN ALLOCATE (curv(nn_adapt)) - CALL CD_HFMF_Curvature(adapt, curv, es, em) + CALL CD_HFMF_Curvature_Exact(adapt, curv, es, em) ! geometric trace: a kink is a shape defect CALL require(es == CD_HFMF_OK .AND. .NOT. ANY(IEEE_IS_NAN(curv)) .AND. nan_max_abs(curv) < 1.0_wp, & 'adaptive-mesh: refined cable curvature finite, bounded, smooth') WRITE (*, '(A,I0,A,I0,A)') 'adaptive-mesh: coupled cable refined ', nn_plain, ' -> ', nn_adapt, ' nodes' diff --git a/tests/test_pinned_touchdown_stability.f90 b/tests/test_pinned_touchdown_stability.f90 index df9e714f..b0037cc4 100644 --- a/tests/test_pinned_touchdown_stability.f90 +++ b/tests/test_pinned_touchdown_stability.f90 @@ -13,7 +13,7 @@ PROGRAM test_pinned_touchdown_stability USE CableDyn_OpenFAST_Aggregate, ONLY: CD_AGG_ModuleType, CD_AGG_Init_From_Deck, & CD_AGG_GetMovingPointMesh, CD_AGG_Step_Moving, & CD_AGG_End, CD_AGG_OK - USE CableDyn_OpenFAST_HermiteFMF, ONLY: CD_HFMF_Curvature, CD_HFMF_OK + USE CableDyn_OpenFAST_HermiteFMF, ONLY: CD_HFMF_Curvature_Exact, CD_HFMF_OK IMPLICIT NONE REAL(wp), PARAMETER :: DT = 0.05_wp, T_END = 30.0_wp, RAMP_TIME = 10.0_wp @@ -63,7 +63,10 @@ PROGRAM test_pinned_touchdown_stability CALL require(.FALSE., 'held dynamic step at t='//TRIM(real_text(REAL(s, wp)*DT))//' s: '//TRIM(em)) EXIT END IF - CALL CD_HFMF_Curvature(agg%cables(1), curvature, hs, em) + ! The geometric trace of the centreline at the pinned hang-off: a collapsing endpoint tangent + ! shows here. The recovered curvature (CD_HFMF_Curvature) is the equilibrium moment over EI, + ! which a pinned end does not carry, so it cannot detect the collapse. + CALL CD_HFMF_Curvature_Exact(agg%cables(1), curvature, hs, em) IF (hs /= CD_HFMF_OK) THEN CALL require(.FALSE., 'curvature evaluation: '//TRIM(em)) EXIT diff --git a/validation/OPENFAST_DLC_VERIFICATION.md b/validation/OPENFAST_DLC_VERIFICATION.md index 8dab5f4e..903c7ba2 100644 --- a/validation/OPENFAST_DLC_VERIFICATION.md +++ b/validation/OPENFAST_DLC_VERIFICATION.md @@ -177,9 +177,13 @@ with 248 elements to resolve its bending length, and the one-hour full-turbine r coupled finite-EI touchdown row in [`VALIDATION.md`](../VALIDATION.md) uses that mesh. The run completed (exit 0, all 2400 steps, 0 NaN/Inf), and its output contains the finite-EI curvature and bending-moment channels of the sag bend, which confirms that the cable ran on the finite-EI -element. At the static initial state the standalone driver gives 0.0915 1/m and 1821 N·m on -that mesh (`Curv4N20`, `BendMom4N20`), and 0.0906 1/m and 1803 N·m on the current one -(`Curv4N38`, `BendMom4N38`). This case has no MoorDyn-F twin and establishes completion only; cable accuracy is established against OrcaFlex in cases L3-4, L3-5, L3-6 and +element. With the geometric curvature of the centreline, which these channels reported when the +case was run and which `OutputRecovery element` reproduces, the standalone driver gives at the +static initial state 0.0915 1/m and 1821 N·m on that mesh (`Curv4N20`, `BendMom4N20`) and +0.0906 1/m and 1803 N·m on the current one (`Curv4N38`, `BendMom4N38`). The curvature and bend moment +recovered from nodal equilibrium, the channels' definition now, are 0.0838 1/m and 1667 N·m at +node 20 of the former mesh (0.0914 1/m at node 19, the recovered peak) and 0.0902 1/m and +1795 N·m at node 38 of the current one. This case has no MoorDyn-F twin and establishes completion only; cable accuracy is established against OrcaFlex in cases L3-4, L3-5, L3-6 and L4-1c of [`VALIDATION.md`](../VALIDATION.md). ### Coupled rod between two fairleads, still water From 939600106dbcc514c61b753750abf4574f024235 Mon Sep 17 00:00:00 2001 From: Jae Hoon Seo Date: Fri, 16 Oct 2026 18:32:07 +0900 Subject: [PATCH 4/5] fix(outputs): profile tension wording, deck-read uplift bound - The static-profile Tension column is described by its channel definition only; "the segment tension" was wrong for a finite-EI line, whose profile tension is the recovered nodal F.t. - test_anchor_uplift reads the bare type's diameter, mass per length and EI and the kBot option from the mixed example instead of hard-coding them, so the laid-anchor moment bound follows the deck. - The recovery-cache comment lists axial damping among the loads that advance the epoch, as Set_Axial_Damping does. Signed-off-by: Jae Hoon Seo --- doc/outputs.rst | 2 +- src/CableDyn_HermiteCableDynamic.f90 | 2 +- tests/test_anchor_uplift.py | 11 ++++++++--- 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/doc/outputs.rst b/doc/outputs.rst index f55546b5..9f06152e 100644 --- a/doc/outputs.rst +++ b/doc/outputs.rst @@ -214,7 +214,7 @@ on every route: - node position in the global frame (Z up, ``Z = 0`` at the still-water line) * - ``Tension`` - ``(N)`` - - nodal effective tension, the segment tension (same definition as ``TenN``) + - nodal effective tension (same definition as ``TenN``) * - ``Curvature`` - ``(1/m)`` - nodal curvature (same definition as ``CurvN``) diff --git a/src/CableDyn_HermiteCableDynamic.f90 b/src/CableDyn_HermiteCableDynamic.f90 index 485488fd..43d8195d 100644 --- a/src/CableDyn_HermiteCableDynamic.f90 +++ b/src/CableDyn_HermiteCableDynamic.f90 @@ -430,7 +430,7 @@ MODULE CableDyn_HermiteCableDynamic ! at (rc_q/rc_v/rc_a(:, e)), the only state its residual depends on, so a node query costs two ! element comparisons and the channels of one output row share one evaluation per element. ! Allocated once at initialisation; rc_epoch counts the loads configured after it (drag, - ! waves, added mass, held fluid, contact). + ! axial damping, waves, added mass, held fluid, contact). INTEGER :: rc_epoch = 0, rc_key_epoch = -1 LOGICAL :: rc_key_ok = .FALSE. REAL(wp) :: rc_t = CD_ZERO diff --git a/tests/test_anchor_uplift.py b/tests/test_anchor_uplift.py index 23a5c5fc..b6be0c29 100644 --- a/tests/test_anchor_uplift.py +++ b/tests/test_anchor_uplift.py @@ -446,10 +446,15 @@ def main() -> int: # there: the anchor node is held at the seabed depth and the laid run sinks delta = w/(kBot d) into # the penalty seabed, a bend of about 2 delta / l0^2 over the anchor element (EI 2 delta / l0^2 = # 2.1 N.m on 2.5 m elements), which the bound allows on top of 2 % of the weight moment - w_bare = (36.70 - RHO * math.pi / 4.0 * 0.16**2) * G - ei_bare, kbot = 1.99e4, 3.0e6 + bare_row = re.search(r"^bare\s+(\S+)\s+(\S+)\s+\S+\s+\S+\s+(\S+)", src, re.MULTILINE) + kbot_row = re.search(r"^(\S+)\s+kBot\b", src, re.MULTILINE) + check(bare_row is not None and kbot_row is not None, "mixed example: bare LINE TYPES row and kBot option") + assert bare_row is not None and kbot_row is not None + d_bare, mass_bare, ei_bare = (float(v) for v in bare_row.groups()) + kbot = float(kbot_row.group(1)) + w_bare = (mass_bare - RHO * math.pi / 4.0 * d_bare**2) * G m_end = w_bare * l0_end**2 / 12.0 - m_sink = ei_bare * 2.0 * w_bare / (kbot * 0.16) / l0_end**2 + m_sink = ei_bare * 2.0 * w_bare / (kbot * d_bare) / l0_end**2 bound = 0.02 * m_end + m_sink bm_anchor, bm_next = hist.column(f"BendMom4N{n_anchor}"), hist.column(f"BendMom4N{n_anchor - 1}") check(bool(np.all(np.abs(bm_anchor) < bound)) and bool(np.all(np.abs(bm_next) < bound)) and From f9f2fd7a57fdc79b136b5c310b70248c3c6bbba8 Mon Sep 17 00:00:00 2001 From: Jae Hoon Seo Date: Sat, 17 Oct 2026 06:56:47 +0900 Subject: [PATCH 5/5] fix(python): refuse a coupled finite-EI cable without a Fixed End B The native aggregate builds every finite-EI line of a coupled deck (OpenFAST, FAST.Farm, the C API, the standalone mixed deck) held at a Fixed End B and refuses any other. The Python validator accepted such a line, for example a finite-EI cable shared by two turbines, together with its AnchFz and AnchFH channels, so a deck it reported valid failed at initialisation. It now refuses the line with the native message. An EI = 0 line shared by two turbines keeps its end-force channels. Signed-off-by: Jae Hoon Seo --- python/cabledyn/deck_file.py | 20 ++++++++++++++++++++ python/tests/test_deck_file.py | 26 ++++++++++++++++++++++++++ 2 files changed, 46 insertions(+) diff --git a/python/cabledyn/deck_file.py b/python/cabledyn/deck_file.py index a834aa96..f7163bf1 100644 --- a/python/cabledyn/deck_file.py +++ b/python/cabledyn/deck_file.py @@ -2894,6 +2894,26 @@ def end_key(token: str) -> str: ) mixed_route = any(finite_lines) and not all(finite_lines) and not has_objects mixed_static = mixed_route and not has_tmax + finite_line_ids = [ + line_id + for line_id, section_types in section_types_by_line.items() + if any(line_type_meta[line_type][3] > 0.0 for line_type in section_types) + ] + # Native build_one_hermite_cable, which builds every finite-EI line of the coupled + # aggregate (OpenFAST, FAST.Farm, the C API and the standalone mixed deck): the cable + # is held at a Fixed End B (the anchor) and driven at End A. A finite-EI line shared by + # two turbines is refused here, before its end-force channels (AnchFz, AnchFH) could be + # accepted for an end the aggregate cannot hold. (A standalone line's moving End B is + # refused by the static LINE checks above.) + if self.caller_driven or mixed_route: + for line_id in finite_line_ids: + end_b = normalized_line_endpoints[line_id][1] + end_b_type = point_types.get(end_b, end_b) + if end_b_type != "fixed": + raise DeckFormatError( + f"{self._label}: line {line_id}: finite-EI coupled cable requires End B " + f'(the anchor) to be a Fixed point; got "{end_b_type}"' + ) for line_type in used_type_names: _, _, ea_static, ei = line_type_meta[line_type] if ea_static <= 0.0: diff --git a/python/tests/test_deck_file.py b/python/tests/test_deck_file.py index 20baab9b..2760d72a 100644 --- a/python/tests/test_deck_file.py +++ b/python/tests/test_deck_file.py @@ -2032,6 +2032,32 @@ def test_invalid_output_channels_fail_before_case_generation(tmp_path, channel, DeckFile.read(path) +@pytest.mark.parametrize("channel", ["FairTen1", "AnchFz1", "AnchFH1"]) +def test_finite_ei_cable_shared_by_two_turbines_is_refused(tmp_path, channel): + # native build_one_hermite_cable: the coupled aggregate holds a finite-EI cable at a Fixed + # anchor, so a cable between two turbines (End B moving) is refused, end-force channels + # included + path = _chain_variant( + tmp_path, + ("1.607e9 -1.0 0.0 ", "1.607e9 -1.0 2.0e5 "), + ("1 Fixed 500.0", "1 Turbine2 500.0"), + ("2 Coupled 0.0", "2 Turbine1 0.0"), + ('"FairTen1"', f'"{channel}"'), + ) + with pytest.raises(DeckFormatError, match=r"requires End B \(the anchor\) to be a Fixed point"): + DeckFile.read(path, caller_driven=True) + + +def test_ei0_line_shared_by_two_turbines_keeps_its_end_force_channels(tmp_path): + path = _chain_variant( + tmp_path, + ("1 Fixed 500.0", "1 Turbine2 500.0"), + ("2 Coupled 0.0", "2 Turbine1 0.0"), + ('"FairTen1"', '"AnchFz1"'), + ) + assert "AnchFz1" in DeckFile.read(path, caller_driven=True).outputs + + def test_case_generation_records_changes_hashes_and_working_directory(tmp_path): source = ROOT / "examples/chain_catenary_r3_100m.dat" cases = generate_deck_cases(