diff --git a/CHANGELOG.md b/CHANGELOG.md index 9001b2f6..7200f2d4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -64,6 +64,21 @@ All notable changes to CableDyn are recorded in this file. The format follows fairlead to 4.9e-4. In a `Linearize = True` run every input Jacobian, those of the time march included, steps the coupled-point rotation by 1e-4 rad instead of 0.1 rad, which changes the rotation columns of a deck with a hang-off spring by up to 0.17 %. +- Prescribed motion and torsion on the standalone mixed deck (`EI = 0` and finite-EI lines between + `Fixed`/`Coupled`/`Vessel` points, run on the coupled aggregate): the driver marches a + `motionFile` or `vesselMotion` as on the cubic-Hermite route, row 1 installed before `t = 0` + (also with `TMax = 0`). A vessel turns the end connection and torsion frames of the cables on + its points, and the roll column imposes the twist of a line restrained in torsion, which these + decks no longer refuse. + Under vessel roll, pitch and heave, or a surge with the roll column, a clamped line gives the + single-line route's torque, twist and node positions to the printed eight digits and its end + tensions and bend moment within 8.2e-6 of their range (the coupled cables' Newton tolerance; with + the single-line route's, every channel to the printed digits). These figures are for motions + that start from rest; a start with a jump in velocity differs by several percent of the range + (3 to 11 % in the cases tried) under the coupled Newton tolerance. A straight line rolled + slowly gives `Torq = GJ Phi / L` to 5e-6 N m. A static mixed run (`TMax = 0`) with torsion + takes `False alpha_force_blend`, as the single-line route and the Python reader do. + `vesselRAO` stays refused with the deck waves. - OpenFAST linearisation with the line dynamics, as MoorDyn-F's: the continuous states are the interior-node positions of every `EI = 0` line (MoorDyn's names and order) and the free degrees of freedom of every finite-EI cable (node positions and tangents), then their @@ -112,6 +127,49 @@ All notable changes to CableDyn are recorded in this file. The format follows modes match the clamped Greenhill cable to 3e-7; eliminating the angles reproduces the condensed static tangent to 1e-16. `.modes.out` adds `PolarShare` and `dTwist` when a line carries twist. +- Torsion of a finite-EI line restrained at one end only, the other free to twist (`TorsStiffness` + `Free` there, or no row): solved where a line restrained at both ends is and its LINE TYPES + rows give `GJ`, instead of being ignored. The free end carries no torque and turns with the + twist of the line: statically `Twist = −Σ (K/GJ)(l − L)` under `GJ|K` (End B relative to + End A; to 1e-8 on a stretched straight cable, the moving end free or the anchored one), and in + the dynamics with torsional waves that reflect at it. A straight line held rigidly at the other end rings at the + clamped–free frequencies `(2n − 1) π/(2L) √(GJ/Irn)` (3e-4 and 3e-3 for n = 1, 2), and a roll + of the restrained end gives the continuum's free-end turn `A/cos kL` and reaction + `GJ A k tan kL` to 0.5 % below and above the first mode, in the standalone driver and on the + coupled aggregate. The `Torq`/`Twist` channels and range columns work on such a line, and + its `CurvX`/`CurvY` axes follow its twist. Results change on such decks: the dynamics carry + the twist (on a swaying lazy-wave cable with `GJ|K` the tensions move by up to 1.5e-4, 7e-8 + in a planar heave), and a line restrained at End A on a Rigid6 body joins the static body + balance of the clamped ends: bending-Pinned there, its body's static moment now balances + (Body1My −103.9 N m to 1e-6 on a buoy, FairTen1 126885 to 126857 N, 2.2e-4, Body1Ry + 0.3004 to 0.2984 deg; the march then differs by up to 2.6 % at dtM 0.05 s, 0.5 % at + 0.0125 s); clamped there, by about 1e-7. OpenFAST checkpoints of such decks written before + this change do not reload: the cable's state mirror now carries the nodal twist, and the + rebuild stops at a mirror-extent check (`... mirror extends past the state vector`). A line + restrained at one end that misses a rule (no `GJ`, two moving ends, the configuration blend, + a restrained End A on a free, pinned or Coupled rod end or a non-Rigid6 body) is solved + without torsion as before, with a note naming the rule; a solved one's restrained `Pretwist` + is held within 1000 turns. +- Torsion at a rod end: a line restrained in torsion may hang from an end of a `Fixed` rod (an + I-tube or J-tube), whose frame holds the End A torsion frame, with `Nx` in the rod's deck + axes. Two turns on an inclined J-tube give `GJ Phi / L` to 1.2e-9, the same torque as from a + held Coupled point, and `RodM` the torque along the line axis; the line written anchor + first (MoorDyn's order) runs bit for bit as written rod first. On a rod fixed to a rolling Rigid6 + body the torque follows `GJ (Phi - theta)/L` to 4e-11, and `RodM` of a rod fixed to a body + now includes the connection moment of a cable clamped at its end (it read 0). Free, pinned + and Coupled rods refuse the torsion by name, and so does `staggered bodyScheme` on a body or + rod (it drove the cable end by translation, so the torsion frame did not turn); a line between + two rods is refused as ending on a rod end, not as having two moving ends. +- The torsion routes combined: a line restrained in torsion at one end only takes `ATTACHMENTS`, + `CONTROL`, `nModes` and a `Fixed` rod end, which left it unsolved in torsion. With modules of + net weights 14.6, −9.1 and 5.8 kN on a vertical cable its free end turns by `−(K/GJ)(H − L)` + to 8.5e-9 and its mid-line node with the module tensions to 3.9e-4 (a first-order mesh + error); a paid-out fairlead turns it by `−(K/GJ)(H − L(t))` to 4e-11 with no torque; its modes + and the eigenvalues of the OpenFAST `A` are the clamped–free chain's to 8e-10 and 2e-14 and + the quarter-wave `(2n − 1)π/(2L) √(GJ/Irn)` within the lumped-inertia error, with no roll + stiffness. The modal twist Hessian no longer takes a free end for an elastic one of infinite + stiffness. `ATTACHMENTS` on a line restrained at both ends run on the mixed `EI = 0` + + finite-EI route and on a `Fixed` rod end as on the single-line route (to the printed digits). - Torque–tension coupling of finite-EI cables: the 14-column LINE TYPES row's `GJ` column takes `GJ|K`, with `K` the coupling of an armoured cable or wire rope (`T = EA ε + K τ`, `M = GJ τ + K ε`). The cable carries the axial stiffness `EA − K²/GJ` of a section free to twist. @@ -184,6 +242,11 @@ All notable changes to CableDyn are recorded in this file. The format follows ### Changed +- With a `motionFile` or `vesselMotion`, the single-line finite-EI route writes `.static.out` + before it installs the first motion row, so the file holds the static solve; before, it showed + the fairlead already moved to row 1. A deck whose row 1 is off the deck fairlead changes + `.static.out` only (a 2 cm offset changed the fairlead x by 0.02 m and its tension from 3.5 MN + back to the static 29 kN); the example decks are unchanged. - `TMax = 0` checks the static start of any dynamic deck as it stands: a `motionFile` or `vesselMotion` record may run past `TMax` (its later rows are checked on the `dtM` grid and not used, so a long record also serves a shorter run), and `RangeStart` is accepted at diff --git a/CMakeLists.txt b/CMakeLists.txt index da62485d..e10ad393 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1443,6 +1443,14 @@ if(CMAKE_Fortran_COMPILER_ID STREQUAL "GNU" AND CMAKE_C_COMPILER_ID STREQUAL "GN # And the MoorDyn-C current grid (Currents 2 and 5) every standalone step samples at the nodes. add_test(NAME step_allocations_current_grid COMMAND test_step_allocations current_grid) set_tests_properties(step_allocations_current_grid PROPERTIES LABELS "fortran;dynamic;memory") + # The standalone driver's march of a mixed deck with its prescribed motion (roll column, vessel). + add_test(NAME step_allocations_motion_roll COMMAND test_step_allocations motion_roll) + set_tests_properties(step_allocations_motion_roll PROPERTIES LABELS "fortran;dynamic;memory") + add_test(NAME step_allocations_motion_vessel COMMAND test_step_allocations motion_vessel) + set_tests_properties(step_allocations_motion_vessel PROPERTIES LABELS "fortran;dynamic;memory") + # And with the nodal twist of a line free in torsion at one end. + add_test(NAME step_allocations_torsion_one_end COMMAND test_step_allocations free) + set_tests_properties(step_allocations_torsion_one_end PROPERTIES LABELS "fortran;dynamic;memory") endif() add_executable(test_snap_load tests/test_snap_load.f90) @@ -2157,6 +2165,10 @@ add_test(NAME torsion_attachments COMMAND test_torsion_attachments ${CMAKE_CURRENT_SOURCE_DIR}/tests/data/lazy_wave_torsion_attachments.dat WORKING_DIRECTORY ${CMAKE_BINARY_DIR}) set_tests_properties(torsion_attachments PROPERTIES LABELS "fortran;driver;integration;static;dynamic") +add_executable(test_rod_end_torsion tests/test_rod_end_torsion.f90) +target_link_libraries(test_rod_end_torsion PRIVATE cabledyn_core) +add_test(NAME rod_end_torsion COMMAND test_rod_end_torsion) +set_tests_properties(rod_end_torsion PROPERTIES LABELS "fortran;driver;integration;static;dynamic") # Where the MoorDyn-parity features meet: a CoupledPinned body in a Currents 2/5 deck (refused on # the coupled aggregate for the current files, standalone for the body), CONTROL on viscoelastic @@ -2199,6 +2211,14 @@ target_link_libraries(test_torsion_coupling PRIVATE cabledyn_core) add_test(NAME torsion_coupling COMMAND test_torsion_coupling) set_tests_properties(torsion_coupling PROPERTIES LABELS "fortran;unit;driver;integration;static") +# Torsion and prescribed motion on the standalone mixed EI = 0 + finite-EI route (the driver +# executable marches the aggregate): route equivalence with the cubic-Hermite route under vessel +# and roll-column motion, quasi-static torque, roll-column refusal. +add_executable(test_mixed_route_torsion tests/test_mixed_route_torsion.f90) +target_link_libraries(test_mixed_route_torsion PRIVATE cabledyn_core) +add_test(NAME mixed_route_torsion COMMAND test_mixed_route_torsion $) +set_tests_properties(mixed_route_torsion PROPERTIES LABELS "fortran;driver;integration;dynamic") + add_executable(test_coupled_torsion tests/test_coupled_torsion.f90) target_link_libraries(test_coupled_torsion PRIVATE cabledyn_core) add_test(NAME coupled_torsion COMMAND test_coupled_torsion WORKING_DIRECTORY ${CMAKE_BINARY_DIR}) @@ -2211,6 +2231,13 @@ add_executable(test_lin_torsion tests/test_lin_torsion.f90) target_link_libraries(test_lin_torsion PRIVATE cabledyn_core) add_test(NAME lin_torsion COMMAND test_lin_torsion WORKING_DIRECTORY ${CMAKE_BINARY_DIR}) set_tests_properties(lin_torsion PROPERTIES LABELS "fortran;unit;dynamic;openfast") +# A line restrained in torsion at one end only: the clamped-free torsional modes and waves of the +# nodal twist, the free end's coupling twist, the deck channels, the standalone driver and the +# coupled aggregate. +add_executable(test_torsion_one_end tests/test_torsion_one_end.f90) +target_link_libraries(test_torsion_one_end PRIVATE cabledyn_core) +add_test(NAME torsion_one_end COMMAND test_torsion_one_end WORKING_DIRECTORY ${CMAKE_BINARY_DIR}) +set_tests_properties(torsion_one_end PROPERTIES LABELS "fortran;unit;driver;integration;static;dynamic;openfast") add_executable(test_torsion_orcaflex tests/test_torsion_orcaflex.f90) target_link_libraries(test_torsion_orcaflex PRIVATE cabledyn_core) @@ -2880,7 +2907,8 @@ if(CMAKE_Fortran_COMPILER_ID STREQUAL "GNU") test_hermite_cable_control test_control_torsion test_endconn_spring - test_torsion_coupling) + test_torsion_coupling + test_torsion_one_end) target_compile_options(${_cabledyn_exact_real_test} PRIVATE -Wno-compare-reals) endforeach() target_compile_options(test_openfast_aggregate PRIVATE @@ -2888,6 +2916,7 @@ if(CMAKE_Fortran_COMPILER_ID STREQUAL "GNU") -Wno-uninitialized -Wno-maybe-uninitialized) target_compile_options(test_torsion_deck PRIVATE -Wno-uninitialized -Wno-maybe-uninitialized) + target_compile_options(test_torsion_one_end PRIVATE -Wno-uninitialized -Wno-maybe-uninitialized) target_compile_options(test_hermite_cable_control PRIVATE -Wno-uninitialized -Wno-maybe-uninitialized) target_compile_options(test_syrope_control PRIVATE -Wno-uninitialized -Wno-maybe-uninitialized) target_compile_options(test_viscoelastic_control PRIVATE -Wno-uninitialized -Wno-maybe-uninitialized) @@ -2933,6 +2962,7 @@ if(CABLEDYN_ENABLE_COVERAGE) test_hermite_torsion_kernel test_hermite_twist_kernel test_nodal_twist_dynamic + test_torsion_one_end test_hermite_torsion_static test_hermite_torsion_dynamic test_hermite_cable_static diff --git a/VALIDATION.md b/VALIDATION.md index 1ce8ef0c..c6c0594e 100644 --- a/VALIDATION.md +++ b/VALIDATION.md @@ -106,6 +106,8 @@ article's methods, are compared in | **T-13** | Nodal twist (torsional inertia and damping) | condensed torsion in the limit of no inertia; continuum torsional wave; `ζ = ω Bt/(2 GJ)`; energy; restart | ≤6e-7 against the condensed torsion; wave torque 0.07 %; decrement 6 %; energy band 4.9e-4; restart bit-identical | see [Torsion](#torsion) | Pass | | **T-12** | Torque–tension coupling | `T = EA ε + K τ`, `M = GJ τ + K ε` closed forms; kernel FD; march | ≤1e-7 against every closed form; kernel gradient 1.7e-10, Hessian 9.8e-11 | see [Torsion](#torsion) | Pass | | **T-11** | Torsion on the coupled OpenFAST / FAST.Farm route | `GJ (−roll)/L`; single coupled cable; uninterrupted run | twist ≤1.8e-15°, torque ≤1.7e-13 N·m; aggregate = single cable bit for bit; restart bit-identical (aggregate and `openfast -restart`) | see [Torsion](#torsion) | Pass | +| **T-17** | One restrained end with ATTACHMENTS, CONTROL, modes, linearisation and rod ends; ATTACHMENTS on the mixed and rod routes | `-(K/GJ)(H - L)`; module tensions; clamped–free chain and quarter-wave; continuum roll response; zero roll stiffness; a second route | twist ≤8.5e-9, mid-line 3.9e-4 (first-order mesh error); modes chain ≤8e-10, quarter-wave within `1 − sin x/x`; roll stiffness 0; routes to the printed digits | 1e-6; 1e-3; 2e-8 | Pass | +| **T-16** | Torsion and prescribed motion on the standalone mixed deck | the single-line cubic-Hermite route; `GJ Φ/L` | torque, twist, node positions to the printed digits; end loads ≤8.2e-6 of range (all channels to the printed digits with the same Newton controls); torque ≤4.7e-6 N·m | printed digits; 5e-5; 1e-6 GJ | Pass | **Pass** meets the stated acceptance value. **Pass measured** records a measured comparison without an acceptance value. **Informative** is reported but not used for @@ -1101,14 +1103,72 @@ in parentheses). straight line's torsional modes and its bending and axial modes against `TorsStiffness Free` hold to the table's nine digits, turned 30° about +z it keeps its frequencies and writes its positions in the deck's axes, and the lazy wave twisted two turns writes its modes. +- **T-16 standalone mixed deck** (`mixed_route_torsion`, `step_allocations_motion_*`). A deck + that mixes `EI = 0` and finite-EI lines between `Fixed`/`Coupled`/`Vessel` points runs on the + coupled aggregate, which the driver marches through the deck's `motionFile` or + `vesselMotion`. A sagging 100 m finite-EI line clamped and restrained in torsion at both ends + (Pretwist 20° at End B), driven from rest by a vessel rolling 20°, pitching 4° and heaving + 1 m, or by a 1 m surge with a 20° roll column, gives the same channels alone (the single-line + cubic-Hermite route) and beside a moving chain (the mixed route): torque, twist and the + mid-line node to the printed digits (at most 0.57 of a unit in the eighth digit), the fairlead + and anchor tensions, fairlead inclination and End A bend moment within 8.2e-6 of their range, + the out-of-plane node offset within 2.2e-8 m. The difference is the Newton tolerance: the + coupled cables step with the coupled controls (relative tolerance 5e-3, a fresh factor every + step), the single line with the deck's (1e-8, a carried factor); given the single-line + controls, the mixed route reproduces every channel of the single-line route to 0.36 of a + printed unit. The vessel turns the clamp and the torsion frame on both routes: a `motionFile` + of the same point translations, which holds them, changes the End A bend moment by 11 % of + its range and the twist by 19°. A straight neutral line beside a chain, its End A held or + rolled by up to 30° by a vessel or by the roll column, gives `Twist1 = Pretwist − roll` to + 5e-7° and `Torq = GJ Φ/L` at both ends to 4.7e-6 N·m. A non-zero roll column at the chain's + point stops by name, and the march makes no heap allocation after warm-up. The agreement + figures are for motions from rest; a start with a jump in velocity differs by several percent + of the range under the coupled Newton tolerance. With `TMax = 0` and row 1 2 cm off the deck + fairlead both routes write the same `t = 0` row at the installed row and a `.static.out` of + the static solve; a static mixed run with torsion takes `False alpha_force_blend`, and a + dynamic one stops by name. +- **T-17 the routes combined** (`torsion_one_end`, `control_torsion`, `modal_torsion_deck`, + `lin_torsion`, `rod_end_torsion`, `mixed_route_torsion`). A line restrained in torsion at one + end only, its other end free to twist (GJ|K 5e4 N·m²|4e5 N·m unless named otherwise): + - `ATTACHMENTS`: hung vertically, 99 m between points 100 m apart, with two clumps and a buoy + of net weights 14.6, −9.1 and 5.8 kN, free at End A and at End B in turn: `Twist1` is + `−(K/GJ)(H − L0)` to 8.5e-9 whatever the weights, the end tensions carry them to 2.9e-9, no + torque, and the mid-line twist follows the module tensions to 3.9e-4 (the shared nodal + tangent spreads each tension step over two elements: 1.9e-4 at 80 elements, 9.6e-5 at + 160); with neutral modules a roll of the restrained end at `kL = π/8` gives the continuum's + free-end twist and end torques to 9e-4; + - `CONTROL` on the coupled aggregate: the free end, the controlled fairlead or the anchor, + turns with the commanded length, `Twist1 = −(K/GJ)(H − L(t))`, to 3.7e-11 through a 0.2 m + pay-out, with no torque (8.2e-11 of `K ε`) and the mean held tension `(EA − K²/GJ) ε` to 1.2e-4; + - `nModes` (straight clamped line of T-15): the torsional modes are the clamped–free chain's + `2 √(GJ/Irn)/l0 sin((2n − 1)π/(4N))` to 8e-10 and the quarter-wave `(2n − 1)π/(2L) √(GJ/Irn)` + within the chain's `1 − sin x/x` (6.4e-5 on the first), the first mode shape + `sin(π s/(2L))` to 5e-10, the other modes those of `TorsStiffness Free`; + - OpenFAST linearisation (the shell's recipe): the free end's angle is a state, the twist + modes of `A` are the clamped–free chain's to 2e-14 and the quarter-wave's within the + lumped-inertia error (4.1e-5 on the first), and the reduced roll stiffness is 0 (End B free: + `C A⁻¹ B` cancels the feedthrough `GJ/l_e`; End A free: no column); + - on a `Fixed` rod end (the J-tube of the rod-end gate), free at End B or at the rod end: + `Twist1 = −(K/GJ) dl` to 8.5e-9 and the held Coupled point's to the printed digits. + + Before these routes were combined, `ATTACHMENTS`, `CONTROL`, `nModes` and a restrained End A + on a rod end left such a line unsolved in torsion (a note; its twist channels stopped by + name), while the linearisation already took it; lifting the rules alone would not do: the + torsion stage after the attachment polish read the pre-polish mesh (a crash), and the modal + twist Hessian took the free end for an elastic one of infinite stiffness (a non-finite + matrix). `ATTACHMENTS` on a line restrained at both ends + run on the mixed route (three buoyancy modules on the gate-2 line of T-16: the single-line + route's torque and twist to 1.15 printed units, end loads to 2.1e-5 of their range) and on a + `Fixed` rod end (two clumps and a buoy: the held Coupled point's torque and twist to the + printed digits). - **Backward compatibility and refusals** (`torsion_deck`, full suite). Without torsion columns, - with `Free` columns (whatever their normal), or with one restrained end, every output is - byte-identical to the 6-column deck, and `Rigid`, `Infinity`, `Inf` and a quoted `"Rigid"` - give the same run. Malformed rows, a missing `GJ`, an `EI = 0` line, a rod end, a `Point3` body, - `ATTACHMENTS`, the configuration blend (also on the coupled entries), misuse of - the roll column, channels on an unrestrained line, a coupled caller that passes no orientation - (the C API) and a standalone mixed `EI = 0` + finite-EI deck without a body stop with named - errors. + with `Free` columns (whatever their normal), or with one restrained end on a line whose + `LINE TYPES` rows give no `GJ`, every output is byte-identical to the 6-column deck, and + `Rigid`, `Infinity`, `Inf` and a quoted `"Rigid"` give the same run. Malformed rows, a missing + `GJ`, an `EI = 0` line, the end of a free, pinned or `Coupled` rod, a `Point3` body, + the configuration blend (also on the coupled entries), misuse of the roll column, channels on + an unrestrained line and a coupled caller that passes no orientation (the C API's + `CableDyn_InitDeck`/`InitDeckAt`) stop with named errors. Limits. The torsion model takes no seabed friction against twist and does not resolve self-contact; its statics are condensed (uniform torque). The nodal twist's inertia and damping diff --git a/app/cabledyn.f90 b/app/cabledyn.f90 index abb2ad00..9676692b 100644 --- a/app/cabledyn.f90 +++ b/app/cabledyn.f90 @@ -31,7 +31,9 @@ PROGRAM cabledyn CD_AGG_NumChannels, CD_AGG_ChannelHeader, & CD_AGG_EvalChannel, CD_AGG_WriteStaticProfile, & CD_AGG_GetInitMetadata, CD_AGG_GetInitLine, & - CD_AGG_Range_Sample, CD_AGG_Range_Write, CD_AGG_OK, CD_AGG_BADINPUT + CD_AGG_Range_Sample, CD_AGG_Range_Write, CD_AGG_OK, CD_AGG_BADINPUT, & + CD_AGG_UpdateStates_Moving, CD_AGG_MotionKinematics, & + CD_AGG_Refresh_Accelerations USE CableDyn_Banner, ONLY: CD_Print_Banner USE CableDyn_Linalg, ONLY: CD_Blas_Runtime_Check, CD_LINALG_OK USE CableDyn_FatalReport, ONLY: CD_Fatal_Report_Install, CD_Fatal_Report_Time @@ -452,9 +454,13 @@ END FUNCTION normalized_path SUBROUTINE run_mixed_held_deck(deck, root, dt, has_dt, run_time, has_run_time, has_motion, line_outputs, & run_converged, run_stat, run_msg) !! Standalone owner for a mixed {EI=0 + finite-EI} deck. It deliberately reuses - !! the production OpenFAST aggregate and holds the initialized coupled endpoints. - !! Prescribed reference-body motion and deck-owned ambient fields require separate - !! transformations/updaters and therefore remain explicit fail-closed boundaries. + !! the production OpenFAST aggregate and holds the initialized coupled endpoints, or, + !! with a motionFile or vesselMotion OPTION, marches them through the deck's prescribed + !! motion as the standalone cubic-Hermite route does: the point rows' translations, the + !! vessel's rotation (the orientation and angular rates the fairlead end connection and + !! torsion frames turn with) and the motionFile roll column (the imposed twist of a line + !! restrained in torsion). Deck-owned ambient fields require separate updaters and + !! therefore remain an explicit fail-closed boundary. CHARACTER(*), INTENT(IN) :: deck, root REAL(wp), INTENT(IN) :: dt, run_time LOGICAL, INTENT(IN) :: has_dt, has_run_time, has_motion, line_outputs @@ -464,10 +470,12 @@ SUBROUTINE run_mixed_held_deck(deck, root, dt, has_dt, run_time, has_run_time, h TYPE(CD_AGG_ModuleType), ALLOCATABLE :: aggregate ! about 37 KB: on the heap, not the stack REAL(wp), ALLOCATABLE :: position(:, :), velocity(:, :), acceleration(:, :), load(:, :) + ! the prescribed motion's frame rotation and roll over the moving surface + REAL(wp), ALLOCATABLE :: orientation(:, :, :), angular_velocity(:, :), angular_acceleration(:, :), roll(:) REAL(wp) :: time, first_miss_time, last_miss_time, step_dt INTEGER :: es, n_moving, nstep, step, n_iter, miss_count, consecutive_miss, max_consecutive_miss INTEGER :: unit, ios - LOGICAL :: step_converged, stalled, file_open + LOGICAL :: step_converged, stalled, file_open, turns, rolls CHARACTER(4096) :: em CHARACTER(4096) :: static_path, dynamic_path TYPE(StandaloneProgress) :: progress @@ -477,11 +485,8 @@ SUBROUTINE run_mixed_held_deck(deck, root, dt, has_dt, run_time, has_run_time, h run_msg = '' file_open = .FALSE. unit = 0 - IF (has_motion) THEN - run_msg = 'CableDyn_driver: mixed-deck motionFile is not supported; platform-reference motion '// & - 'must be rigidly transformed to every coupled hang-off before marching' - RETURN - END IF + turns = .FALSE. + rolls = .FALSE. IF (line_outputs) THEN run_msg = 'CableDyn_driver: mixed-deck LINE Outputs p/t/V are not supported; '// & 'use main OUTPUTS channels or remove the per-line flags' @@ -523,9 +528,12 @@ SUBROUTINE run_mixed_held_deck(deck, root, dt, has_dt, run_time, has_run_time, h EXIT mixed_run END IF ! The aggregate is caller-driven and cannot refresh standalone wave/current - ! OPTIONS. Reject such decks by name instead of silently holding zero fluid. + ! OPTIONS. Reject such decks by name instead of silently holding zero fluid. The driver + ! holds the line end frames or turns them with the deck's vesselMotion table + ! (host_orientation), and marches the deck's prescribed motion (prescribed_motion). CALL CD_AGG_Init_From_Deck(aggregate, deck, step_dt, es, em, forbid_deck_ambient=.TRUE., & - run_tmax=MAX(CD_ZERO, run_time), range_files=.TRUE.) + run_tmax=MAX(CD_ZERO, run_time), range_files=.TRUE., host_orientation=.TRUE., & + prescribed_motion=has_motion, static_run=nstep == 0) IF (es /= CD_AGG_OK) THEN CALL set_aggregate_error(es, em, run_stat, run_msg) EXIT mixed_run @@ -539,7 +547,8 @@ SUBROUTINE run_mixed_held_deck(deck, root, dt, has_dt, run_time, has_run_time, h EXIT mixed_run END IF ALLOCATE (position(3, n_moving), velocity(3, n_moving), acceleration(3, n_moving), & - load(3, n_moving), STAT=ios) + load(3, n_moving), orientation(3, 3, n_moving), angular_velocity(3, n_moving), & + angular_acceleration(3, n_moving), roll(n_moving), STAT=ios) IF (ios /= 0) THEN run_stat = CD_DECKDRV_SOLVEFAIL run_msg = 'CableDyn_driver: cannot allocate the mixed aggregate boundary workspace' @@ -550,18 +559,43 @@ SUBROUTINE run_mixed_held_deck(deck, root, dt, has_dt, run_time, has_run_time, h CALL set_aggregate_error(es, em, run_stat, run_msg) EXIT mixed_run END IF - ! A standalone deck with no motionFile means held coupling boundaries. Initial - ! solver accelerations are not prescribed boundary accelerations and must not be - ! fed back into the first step. - velocity = CD_ZERO - acceleration = CD_ZERO - + ! The static configuration, before a prescribed motion moves the ends. static_path = TRIM(root)//'.static.out' CALL CD_AGG_WriteStaticProfile(aggregate, TRIM(static_path), es, em) IF (es /= CD_AGG_OK) THEN CALL set_aggregate_error(es, em, run_stat, run_msg) EXIT mixed_run END IF + IF (has_motion) THEN + ! Install row 1 of the prescribed motion without advancing (it may differ from the deck + ! pose), then recompute the cables' free-node accelerations from their complete + ! residual at that state, as the standalone cubic-Hermite route does before its march + ! (also for TMax = 0, whose single row is then the t = 0 state of the motion). On the + ! EI = 0 lines the transfer re-derives the interior accelerations at that state + ! (CD_FMF_UpdateStates_Moving), which the EI = 0-only route's row-1 transfer does not. + CALL CD_AGG_MotionKinematics(aggregate, 1, position, velocity, acceleration, orientation, & + angular_velocity, angular_acceleration, roll, turns, rolls, es, em) + IF (es == CD_AGG_OK) THEN + IF (turns) THEN + CALL CD_AGG_UpdateStates_Moving(aggregate, position, velocity, acceleration, es, em, & + orientation=orientation, angular_velocity=angular_velocity, & + angular_acceleration=angular_acceleration) + ELSE + CALL CD_AGG_UpdateStates_Moving(aggregate, position, velocity, acceleration, es, em) + END IF + END IF + IF (es == CD_AGG_OK) CALL CD_AGG_Refresh_Accelerations(aggregate, es, em) + IF (es /= CD_AGG_OK) THEN + CALL set_aggregate_error(es, em, run_stat, run_msg) + EXIT mixed_run + END IF + ELSE + ! A standalone deck with no prescribed motion means held coupling boundaries. Initial + ! solver accelerations are not prescribed boundary accelerations and must not be + ! fed back into the first step. + velocity = CD_ZERO + acceleration = CD_ZERO + END IF dynamic_path = TRIM(root)//'.out' OPEN (NEWUNIT=unit, FILE=TRIM(dynamic_path), STATUS='REPLACE', ACTION='WRITE', IOSTAT=ios) IF (ios /= 0) THEN @@ -604,8 +638,26 @@ SUBROUTINE run_mixed_held_deck(deck, root, dt, has_dt, run_time, has_run_time, h IF (nstep > 0) CALL start_standalone_progress(progress, nstep, step_dt) DO step = 1, nstep time = REAL(step, wp)*step_dt - CALL CD_AGG_Step_Moving(aggregate, step_dt, position, velocity, acceleration, step_converged, stalled, & - n_iter, es, em, t_committed=time) + IF (has_motion) THEN + ! the prescribed boundary at t + dt: grid row step + 1 + CALL CD_AGG_MotionKinematics(aggregate, step + 1, position, velocity, acceleration, orientation, & + angular_velocity, angular_acceleration, roll, turns, rolls, es, em) + IF (es /= CD_AGG_OK) THEN + CALL set_aggregate_error(es, em, run_stat, run_msg) + EXIT mixed_run + END IF + END IF + IF (turns) THEN + CALL CD_AGG_Step_Moving(aggregate, step_dt, position, velocity, acceleration, step_converged, stalled, & + n_iter, es, em, t_committed=time, orientation=orientation, & + angular_velocity=angular_velocity, angular_acceleration=angular_acceleration) + ELSE IF (rolls) THEN + CALL CD_AGG_Step_Moving(aggregate, step_dt, position, velocity, acceleration, step_converged, stalled, & + n_iter, es, em, t_committed=time, roll=roll) + ELSE + CALL CD_AGG_Step_Moving(aggregate, step_dt, position, velocity, acceleration, step_converged, stalled, & + n_iter, es, em, t_committed=time) + END IF CALL CD_Profile_Enter(CD_PROF_CHECK) IF (es /= CD_AGG_OK) THEN CALL set_aggregate_error(es, em, run_stat, run_msg) diff --git a/doc/capabilities.rst b/doc/capabilities.rst index a1ba6767..a4634a59 100644 --- a/doc/capabilities.rst +++ b/doc/capabilities.rst @@ -67,10 +67,11 @@ Line and constitutive capability * - Mixed ``EI = 0`` + finite-EI deck - Supported with route limits - a mixed deck of lines between held or coupled points only (no bodies, rods, or - ``Free``/``Connect`` points) runs in OpenFAST and standalone as a static or held-end - dynamic run, and rejects a standalone ``motionFile`` or deck waves; a mixed deck with - bodies, rods, or ``Free``/``Connect`` points runs standalone on the multibody march, with - moving objects and deck waves/current, but not with a ``motionFile`` + ``Free``/``Connect`` points) runs in OpenFAST and standalone as a static run or a dynamic + run with held ends or a ``motionFile``/``vesselMotion`` prescription, and rejects deck + waves standalone (so ``vesselRAO`` too); a mixed deck with bodies, rods, or + ``Free``/``Connect`` points runs standalone on the multibody march, with moving objects + and deck waves/current, but not with a ``motionFile`` * - Viscoelastic rope (MoorDyn ``ElasticMod`` 2/3) - Supported - per-element series-Kelvin state (standard linear solid only when ``BA_D = 0``), @@ -86,20 +87,25 @@ Line and constitutive capability change, as in MoorDyn); finite-EI combinations fail closed by name * - Torsion of finite-EI lines - Supported with limits - - isotropic torsion of a finite-EI line restrained in torsion at both ends + - isotropic torsion of a finite-EI line restrained in torsion at both ends, or at one end + with the other free to twist (the free end carries no torque and turns with the twist of + the line: the stretch's under ``GJ|K``, and torsional waves in dynamics; on every route + and with every feature below that takes a line restrained at both ends) (``END CONNECTIONS`` torsion columns, explicit ``GJ``), with torque–tension coupling (``GJ|K``): condensed (uniform torque) in statics with a stability check and buckling descent, and a twist angle at every node in dynamics, with the polar inertia ``Irn`` and torsional damping (``GJ|K|Bt``), - with turning Rigid6 bodies, ``vesselMotion``/``vesselRAO`` and the ``motionFile`` roll - column standalone, and with the platform orientation in coupled OpenFAST and FAST.Farm - runs (torque returned to the platform, ``PtfmInit``, checkpoints, linearisation with the - twist angles as states; see :doc:`openfast`) and through the C API with the host's - rotations (``CableDyn_InitDeckRotating``, :doc:`capi`), active line control - (``CONTROL``) of the fairlead segment on the coupled route; ``Torq``/``Twist`` channels and - standalone range graphs. Stopped by name: the standalone mixed ``EI = 0`` + finite-EI - aggregate and ``CableDyn_InitDeck``/``InitDeckAt`` (which move the line ends by - translation only), rod ends, bodies other than Rigid6 and ``False alpha_force_blend``. + with turning Rigid6 bodies (the ends of rods fixed to them included), ends of ``Fixed`` + rods, ``vesselMotion``/``vesselRAO`` and the ``motionFile`` roll column standalone + (``vesselMotion`` and the roll column also on a mixed ``EI = 0`` + finite-EI deck), and + with the platform orientation in coupled OpenFAST and FAST.Farm runs (torque returned to + the platform, ``PtfmInit``, checkpoints, linearisation with the twist angles as states; + see :doc:`openfast`) and through the C API with the host's rotations + (``CableDyn_InitDeckRotating``, :doc:`capi`), active line control (``CONTROL``) of the + fairlead segment on the coupled route; ``Torq``/``Twist`` channels and standalone range + graphs. Stopped by name: ``CableDyn_InitDeck``/``InitDeckAt`` (which move the line ends by + translation only), ends of free and pinned rods (axisymmetric, no roll angle) and of + ``Coupled``/``Vessel`` rods, bodies other than Rigid6 and ``False alpha_force_blend``. Modal analysis carries the twist angle of every node. Not modelled: seabed friction against twist, anisotropic sections, self-contact of a loop (see :ref:`theory-torsion`) * - Hockling loops, nonlinear cross-section laws diff --git a/doc/conventions.rst b/doc/conventions.rst index 811baa10..7b8556b8 100644 --- a/doc/conventions.rst +++ b/doc/conventions.rst @@ -172,7 +172,12 @@ Angles at line ends Torsion signs ------------- -These apply to a finite-EI line restrained in torsion at both ends (:doc:`driver_format`). +These apply to a finite-EI line solved in torsion: restrained at both ends, or at one end with +the other free to twist (:doc:`driver_format`). On a line free at one end the free end's +``Pretwist`` is not used (0), :math:`\Phi` is the restrained end's alone, and ``Twist`` +keeps its sign, the turn of End B relative to End A about the End A → End B tangent: a free +End B turns by ``+Twist`` against End A's frame carried along the line, a free End A by +``−Twist`` against End B's. - The end frame of each end is its direction ``Ez`` (End A → End B) and its reference normal ``Nx``, in the frame of ``Ez``. ``Pretwist`` rolls the end frame about ``Ez`` by a right-handed diff --git a/doc/driver_format.md b/doc/driver_format.md index 22872dd0..371c8667 100644 --- a/doc/driver_format.md +++ b/doc/driver_format.md @@ -334,13 +334,23 @@ rejected. `EI > 0` is routed as follows. [multibody march](#multibody-march). - When `motionFile` row 1 differs from the deck fairlead, CableDyn installs that boundary state and the initial fluid field, then recomputes the free-node acceleration from the full - structural, contact, and hydrodynamic residual before writing `t = 0`. + structural, contact, and hydrodynamic residual before writing `t = 0` (also with `TMax = 0`). + The `.static.out` profile is written before that, so it holds the static solve. **Standalone mixed deck** (separate `EI = 0` and `EI > 0` lines between `Fixed`/`Coupled`/`Vessel` points only): the deck is partitioned through the same atomic aggregate used by OpenFAST. -`Coupled`/`Vessel` endpoints are held at their deck positions. The run writes the common `.out` -and the all-line `.static.out` tables, plus the range graph of every line with the `r` flag. -Mixed decks reject, by name, `motionFile`, deck wave/current OPTIONS, WaterKin `WaveKinMod 1`, +`Coupled`/`Vessel` endpoints are held at their deck positions, or follow a `motionFile` or +`vesselMotion` as on the cubic-Hermite route: row 1 is installed and the cables' free-node +accelerations recomputed before `t = 0` (also with `TMax = 0`, whose `.out` row is then that +state; `.static.out` holds the static solve), a vessel turns the end connection and torsion +frames of the cables on its points, and the roll column imposes the twist of a line restrained +in torsion. The row-1 transfer also re-derives the interior accelerations of the `EI = 0` lines +at that state, which the `EI = 0`-only route does not, so when row 1 is off the deck pose their +first steps differ from that route's. A static run (`TMax = 0`) of a line restrained in torsion +takes `False alpha_force_blend`, as on the single-line route. +The run writes the common `.out` and the all-line `.static.out` tables, plus the range graph of +every line with the `r` flag. +Mixed decks reject, by name, deck wave/current OPTIONS (so `vesselRAO`), WaterKin `WaveKinMod 1`, MoorDyn-C `WaveKin 3`/`7` and `Currents 1`/`2`/`5`, and per-line `p`/`t` flags. (multibody-march)= @@ -385,8 +395,9 @@ connection moment. On this route: - a finite-EI cable needs a `Fixed` End B, and its End A may be a `Fixed` point, a Rigid6 `Body` point or a rod end, not a `Free`/`Connect` point or a `Point3` buoy; -- a clamped or elastic End A on a body or rod needs `bodyScheme monolithic` (the default); - `staggered` rejects it by name; +- a clamped or elastic End A on a body or rod, or one restrained in torsion (bending-pinned + included), needs `bodyScheme monolithic` (the default); `staggered`, which drives a cable end by + translation, rejects it by name; - every `Free`/`Connect` point carries at least one EI = 0 line; - `motionFile` and `Coupled`/`Vessel` rods are rejected by name. @@ -699,10 +710,11 @@ never both: a `SECTIONS` row for a 7-column line is an error naming the line. **Automatic anchor-first swap.** Stock MoorDyn decks list lines anchor first. When a line's `NodeA` is a `Fixed` point and its `NodeB` is a `Coupled`, `Vessel`, `Body`, `Free`, or -`Connect` point (`Turbine` points count as coupled), the parser swaps the two ends, reverses -that line's `SECTIONS` rows, and swaps its `END CONNECTIONS` ends, negating their reference -directions. Lines already listed fairlead first, and `Free`/`Connect`-to-`Coupled` lines, are left -as written. +`Connect` point (`Turbine` points count as coupled), or a finite-EI line's `NodeB` is a rod +end (`RA`/`RB`), the parser swaps the two ends, reverses that line's `SECTIONS` rows, and +swaps its `END CONNECTIONS` ends, negating their reference directions and pretwists (the +torsion normals swap with their ends). Lines already listed fairlead first, `EI = 0` lines to a +rod end, and `Free`/`Connect`-to-`Coupled` lines are left as written. **Endpoint rules.** @@ -802,8 +814,8 @@ Behaviour: - On a `Body` point the direction is given in the body frame, like the point offset, and turns with the body. On a rod end it must be parallel to the rod axis (either sense, in the frame of the rod's deck coordinates); another direction is rejected by name. The connection - moment is part of `BodyM*`/`RodM*`, and the body or rod carries it in the dynamics and in - the static solve. + moment is part of `BodyM*`/`RodM*` (of both on an end of a rod fixed to a body), and the + body or rod carries it in the dynamics and in the static solve. - A finite stiffness is an isotropic rotational spring on the tangent direction; the tangent magnitude stays free. - `Rigid` is an exact two-coordinate direction constraint, not a large penalty; the tangent @@ -839,10 +851,31 @@ used. Behaviour: -- Torsion is solved only on a line restrained at **both** ends. With one end restrained the - other end is free to twist, the line carries no torque, and the driver prints a note and - solves the line as without the columns (the rules below then do not apply). `Free` columns, - or no columns, reproduce the 6-column results exactly. +- Torsion is solved on a line restrained at both ends, and on a line restrained at **one** end + whose other end is free to twist (`TorsStiffness` `Free` there, or no row), under the rules + below. A free end carries no torque. In statics the line then has none, and its static state + is that of the line without the columns; under torque–tension coupling (`GJ|K`) the stretch + twists it by `Twist = −Σ (K/GJ)(l − L)` over the elements (`l` stretched, `L` + unstretched). `Twist` keeps its sign, the turn of End B relative to End A, right-handed + about the End A → End B tangent: a free End B turns by `+Twist` against End A's frame + carried along the line, a free End A by `−Twist` against End B's. In the dynamics the + polar inertia `Irn` carries torsional waves that reflect at the free end, and the restrained + end (and the body or vessel holding it) takes their torque. The free end's `Nx` and + `Pretwist` are not used. The section axes of `CurvX`/`CurvY` start, with End A restrained, + from End A's `Nx` (not rolled by its `Pretwist`, as on a line restrained at both ends) and, + with End B restrained, from End B's `Nx` rolled by End B's `Pretwist`; either way they are + carried along the line and turned by its twist. `ATTACHMENTS`, `CONTROL`, `nModes` (the + free end's angle is a mode coordinate, with the clamped–free modes) and OpenFAST + linearisation (the free end's angle is a state) take such a line as they take one + restrained at both ends. A line restrained at one end that misses a rule (its `LINE TYPES` + rows give no `GJ`, two moving ends, a dynamic or coupled run with `False alpha_force_blend`, + a restrained End A on a rod end other than a `Fixed` rod's or on a non-Rigid6 body) is + solved as without the columns, and the standalone driver prints a note with the reason. A + solved one's imposed twist, its restrained end's `Pretwist`, must lie within 1000 turns, as + `Pretwist(B) − Pretwist(A)` must on a line restrained at both ends. A line restrained at End A + on a Rigid6 body joins the static balance of the body's clamped and elastic ends, also at a + bending-`Pinned` End A (the body takes its torque). + `Free` columns, or no columns, reproduce the 6-column results exactly. - The imposed twist is `Phi = Pretwist(B) − Pretwist(A)`, measured against the line's own geometric twist `Theta`, the parallel-transport rotation of the End A normal carried along the centreline to End B (zero for a line that stays in a plane, with both normals perpendicular to @@ -853,9 +886,15 @@ Behaviour: set the End B pretwist to minus the static `Twist` of a run with zero pretwist (in degrees); the line then keeps its untwisted shape. - The torsion end frame turns with what carries the end: a Rigid6 body, the vessel of - `vesselMotion`/`vesselRAO`, or nothing at a `Fixed` or held point. The `motionFile` roll - column rolls the frame of the line's moving end + `vesselMotion`/`vesselRAO`, or nothing at a `Fixed` or held point or on a `Fixed` rod. The + `motionFile` roll column rolls the frame of the line's moving end ([Prescribed motion](#prescribed-motion-motionfile)). +- On a rod end (an I-tube or J-tube modelled as a rod), `Ez` lies along the rod axis and `Nx` + is given in the frame of the rod's deck coordinates, as `Ez` is. A `Fixed` rod holds the frame + still, and its `RodM*` carries the torque about the line axis. The ends of a rod fixed to a + Rigid6 body (`RODS` type `Body`) are points of the body: `Ez` and `Nx` are given in the body + frame, the frame rolls with the body, and the torque reaches the body (`BodyM*`) and appears + in the rod's `RodM*`. - A Rigid6 body holding such a line turns by less than 90° per step: a step whose turn would be larger is halved (the twist is read from the body's orientation, which repeats every turn), and a run that still needs more after six halvings stops by name; reduce `dtM`. @@ -869,24 +908,26 @@ Behaviour: dynamics; it is part of `BodyM*`. - Statics solve the imposed twist as the last load stage, in steps of at most 45°, test every stage for stability and, above a buckling onset, leave the unstable straight state for the - buckled one. Dynamics carry the torque in every step; torsion has no inertia (quasi-static - torsion), so the torque follows the imposed twist without a torsional wave. + buckled one. Dynamics carry the torsion in every step with a twist angle at every node and the + polar inertia `Irn` of the `LINE TYPES` row (see [theory](theory.rst)). Scope. A torsionally restrained line needs a finite-EI line with a `Fixed` End B, an explicit -`GJ` on every section, and, at End A, a `Fixed`, `Coupled`/`Vessel` point or a Rigid6 -`Body` point; in a coupled OpenFAST or FAST.Farm run the End A frame turns with the platform -(see the manual's OpenFAST page, Line torsion). Each of the following stops with a named error: -torsion on an `EI = 0` line, on a rod end or on a `Point3` body, -a dynamic or coupled run with `False alpha_force_blend`, any -restrained end (one end included) in a standalone deck mixing `EI = 0` and finite-EI lines -without a body or through the C API's `CableDyn_InitDeck`/`InitDeckAt`, which move the line -ends by translation only (`a line restrained in torsion needs a host that turns its fairlead -frame ...`; with a body such a deck runs on the multibody route, which supports torsion, and a C -API host passes its rotations after `CableDyn_InitDeckRotating`), and a `Torq`/`Twist` channel -on a line that is not restrained at both ends. OpenFAST linearisation includes the twist angles -as states; like any cable, the line must not have a `Rigid` bending connection there. Seabed -friction does not resist twist (the laid part of a line twists freely), and there -is no torque–tension coupling. +`GJ` on every section, and, at End A, a `Fixed`, `Coupled`/`Vessel` point, a Rigid6 `Body` +point (the ends of a `Body` rod included) or an end of a `Fixed` rod; in a coupled OpenFAST +or FAST.Farm run the End A frame turns with the platform (see the manual's OpenFAST page, Line +torsion). Each of the following stops with a named error: torsion on an `EI = 0` line, on an end +of a `Free`, `Pinned`, `BodyPinned` or `CoupledPinned` rod (an axisymmetric rod has no roll +angle about its own axis: no load acts about the axis and its static solve has none, so it +cannot hold the torque) or of a `Coupled`/`Vessel` rod (no route carries a finite-EI line on a +host-driven rod), a line whose End B is a rod end (a line between two rods: put a `Fixed` point +at the rod end), on a `Point3` body, a dynamic or coupled run with `False alpha_force_blend`, +any restrained end (one end included) through the C API's `CableDyn_InitDeck`/`InitDeckAt`, +which move the line ends by translation only (`a line restrained in torsion needs a host that +turns its fairlead frame ...`; a C API host passes its rotations after +`CableDyn_InitDeckRotating`), and a `Torq`/`Twist` channel on a line whose torsion is not +solved. OpenFAST linearisation includes the twist angles as states; like any cable, the line +must not have a `Rigid` bending connection there. Seabed friction does not resist twist (the +laid part of a line twists freely). ### EQUIVALENT BUOYANCY (optional) @@ -1347,14 +1388,16 @@ cases. With an active path: `Free` rods in the same deck are integrated dynamically. - Rigid6 decks prescribe the full 6-DOF body motion from `Body` rows (see [BODIES](#deck-bodies)). -- `Connect`/`Free` point-system decks, FAILURE decks, and mixed `EI = 0` + finite-EI decks reject - `motionFile`. +- A mixed `EI = 0` + finite-EI deck of lines between `Fixed`/`Coupled`/`Vessel` points moves the + points of both line kinds from their rows, and a finite-EI line on them as on the finite-EI + route (row 1 installed before `t = 0`, the roll column below). +- `Connect`/`Free` point-system decks and FAILURE decks reject `motionFile`. Every non-comment record of the motion file is one row `time point_id x y z vx vy vz ax ay az` of -plain numbers; tokens after the eleventh are ignored, except that a deck with a line restrained -in torsion at both ends reads a twelfth, `roll` [deg]: at the point, the roll of the frame of the -line's moving end (End A, or End B in a deck that lists the `Fixed` anchor as End A), right-handed -about the line tangent pointing into the line from that end. Either way it imposes +plain numbers; tokens after the eleventh are ignored, except that a deck with a line solved in +torsion reads a twelfth, `roll` [deg]: at the point, the roll of the frame of the line's moving +end, restrained in torsion (End A, or End B in a deck that lists the `Fixed` anchor as End A), +right-handed about the line tangent pointing into the line from that end. Either way it imposes `Phi(t) = Pretwist(B) − Pretwist(A) − roll(t)`: the roll has the sense of `Pretwist(A)` at End A (where the inward tangent is `Ez`) and the opposite sense to `Pretwist(B)` at End B (where it is `−Ez`). The roll is 0 at @@ -1476,9 +1519,9 @@ bending moment. None of these channels is mandatory. | `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; 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 | +| `TorqN` | line L torque at node J (uniform along the line in statics); positive for a right-handed twist of End B relative to End A about the End A → End B tangent. Only on a line solved in torsion (restrained at both ends, or at one end with the other free) | N·m | +| `TwistN` | line L material twist accumulated from End A to node J, `M × Σ L/GJ` (less `(K/GJ)(l − L)` under coupling) over the elements in between; 0 at End A, without the end-spring windup. Only on a line solved in torsion | deg | +| `Twist` | line L total twist `Phi − Theta = M C`, end-spring windup included; on a line free at one end the twist of its elements, the free end's turn. Only on a line solved in torsion | deg | - ``/`

` are deck LINE/POINT **ids**, not array positions. A channel that matches no supported form, names an unknown id, or carries trailing text (for example `Point2px_raw`) is a diff --git a/doc/file_formats.rst b/doc/file_formats.rst index 430b1c13..b236a570 100644 --- a/doc/file_formats.rst +++ b/doc/file_formats.rst @@ -174,10 +174,10 @@ Each data row has eleven whitespace-separated numbers: Every row must start with a number, so any header or column-label line must be a comment. Tokens after the eleventh are ignored, except on a deck with a torsional line (below). -**Roll column (torsion).** On a deck where some finite-EI line is restrained in torsion at both -ends (``END CONNECTIONS`` ``TorsStiffness``, see :doc:`driver_format`), a numeric twelfth token is -read as the roll of the frame of that line's moving end (End A, or End B in a deck that lists the -anchor as End A), in degrees, right-handed about the line tangent pointing into the line from that +**Roll column (torsion).** On a deck where some finite-EI line is solved in torsion, restrained +at both ends or at one (``END CONNECTIONS`` ``TorsStiffness``, see :doc:`driver_format`), a numeric +twelfth token is read as the roll of the frame of a line's moving end (End A, or End B in a deck +that lists the anchor as End A), in degrees, right-handed about the line tangent pointing into the line from that end. It imposes a twist history without turning the point: the line's imposed twist is .. math:: @@ -193,12 +193,11 @@ inward tangent is ``−Ez``, it has the opposite sense to ``Pretwist`` (B). Rule * the roll must be 0 at ``t = 0``, because the static initial condition uses the deck ``Pretwist``; give a constant twist there (``the roll column of point must be 0 at t = 0``); -* a non-zero roll is accepted only at the moving end of a line restrained in torsion at both - ends (``has a non-zero roll column, but no line restrained in torsion at both ends ... has its - moving (non-Fixed) end there``); -* the roll is real valued and not wrapped, so several turns are written as they accumulate. - Torsion carries no inertia (see :doc:`theory`), so the torque follows the roll at once and no - roll rate or acceleration column is needed. +* a non-zero roll is accepted only at the moving end of a line solved in torsion, restrained + there (``has a non-zero roll column, but no line restrained in torsion ... at its moving + (non-Fixed) end has that end there``): a free end has no torsion frame to roll; +* the roll is real valued and not wrapped, so several turns are written as they accumulate; the + time integration takes its rate and acceleration from the roll history (no column). :file:`examples/data/torsion/hangoff_roll_2turns_60s_dt01.txt`, used by :file:`examples/torsion_lazy_wave_hangoff_twist.dat`, holds the hang-off in place and rolls it diff --git a/doc/index.rst b/doc/index.rst index 37d9dfb6..fa0d24ad 100644 --- a/doc/index.rst +++ b/doc/index.rst @@ -85,7 +85,8 @@ What CableDyn does - static and dynamic - coupled dynamic * - Mixed deck: moorings and power cables together - - static and dynamic (held ends; moving bodies, rods, and points on the multibody march) + - static and dynamic (held ends or a ``motionFile``/``vesselMotion``; moving bodies, rods, + and points on the multibody march) - coupled dynamic * - Automatic Newton static equilibrium, no initial shape or relaxation - yes diff --git a/doc/openfast.rst b/doc/openfast.rst index 3ba7a555..9c9cc7e7 100644 --- a/doc/openfast.rst +++ b/doc/openfast.rst @@ -333,9 +333,12 @@ Line torsion ------------ A finite-EI line restrained in torsion at both ends (``END CONNECTIONS`` torsion columns, see -:ref:`theory-torsion`) runs coupled as it does standalone. Its End A frame is given in platform -axes and turns with the OpenFAST point-mesh orientation, whatever the bending connection, so a -platform roll, pitch or yaw about the line's end direction twists the line. The torque moment is +:ref:`theory-torsion`), or at one end with the other free to twist, runs coupled as it does +standalone. A restrained End A frame is given in platform axes and turns with the OpenFAST +point-mesh orientation, whatever the bending connection, so a platform roll, pitch or yaw about +the line's end direction twists the line (on a line free at End B it spins the line, whose +torsional inertia loads the platform); a free End A transmits no torque, and the platform's +turn does not reach the line. The torque moment is returned to OpenFAST with the connection moment, the ``TorqN`` and ``Twist`` channels are available, ``PtfmInit`` twists the line in the static initialisation, and the unwrapped twist is part of the checkpoint state. End B must be a ``Fixed`` point. Within one @@ -344,10 +347,12 @@ substeps; an output probe moves the frame without a step, is limited to 90° fro committed twist, and stops by name beyond it (a restart first restores the checkpoint's twist, so it is not limited this way). Formal linearisation takes the line's twist angles as states and the platform rotation as an input -(see `Linearisation`_). The C API's ``CableDyn_InitDeck``/``InitDeckAt`` and the standalone -deck that mixes ``EI = 0`` and finite-EI lines without a body move the line ends by translation -only and refuse torsion columns; a C API host that initialises with -``CableDyn_InitDeckRotating`` passes its rotations (:doc:`capi`). +(see `Linearisation`_). The C API's ``CableDyn_InitDeck``/``InitDeckAt`` move the line ends by +translation only and refuse torsion columns; a C API host that initialises with +``CableDyn_InitDeckRotating`` passes its rotations (:doc:`capi`). The standalone driver runs a +deck that mixes ``EI = 0`` and finite-EI lines on the same aggregate, holding the line end +frames or turning them with its ``vesselMotion``, and imposing the twist of its ``motionFile`` +roll column. Lifecycle features ------------------ diff --git a/doc/options.rst b/doc/options.rst index 63fe7acf..6c75f4b4 100644 --- a/doc/options.rst +++ b/doc/options.rst @@ -465,7 +465,8 @@ Finite-EI cable controls ``dtM`` 0.1 / 0.05 / 0.025 / 0.0125 s with ``False`` and 9424 / 9322 / 9314 / 9311 N with ``True``. A run prints a note when a nodal tangent turns by more than 0.25 deg (``True``) or 0.1 deg (``False``) in one step. A dynamic run with a torsional line - (``END CONNECTIONS`` ``TorsStiffness`` at both ends) needs ``True``. The lines the raw C + (``END CONNECTIONS`` ``TorsStiffness``) needs ``True``; a line restrained at one end only is + otherwise solved without torsion (noted). The lines the raw C API builds without a deck (``CableDyn_InitLine``, ``CableDyn_InitLines``) always use ``True``: their only integrator setting is ``rho_inf`` (:doc:`capi`). ``False`` also turns ``ei0_substeps`` off unless the deck sets it @@ -693,8 +694,9 @@ Ambient fluid and prescribed motion - path, or ``0``/``none`` - absent - an active path requires ``dtM`` and ``TMax``; ``0`` or case-insensitive ``none`` disables - it. On a deck with a line restrained in torsion at both ends, an optional twelfth column - rolls the frame of that line's moving end (degrees, 0 at ``t = 0``). See the file + it. On a deck with a line solved in torsion, an optional twelfth column rolls the frame of + that line's moving end when that end is restrained in torsion (degrees, 0 at + ``t = 0``). See the file grammar in :doc:`file_formats` - standalone ``Coupled``/``Vessel`` points, prescribed rods, and Rigid6 bodies; rejected on ``Connect``/``Free`` point-system, FAILURE, and mixed decks; forbidden in OpenFAST, diff --git a/doc/outputs.rst b/doc/outputs.rst index eda174c4..5a3ede04 100644 --- a/doc/outputs.rst +++ b/doc/outputs.rst @@ -431,11 +431,12 @@ End A -> End B)``. Present only when the deck defines a seabed * - ``TorqueMin`` ``TorqueMax`` ``TorqueMean`` - ``(N.m)`` - - torque, as ``TorqN``. Present only on a line restrained in torsion at both ends + - torque, as ``TorqN``. Present only on a line solved in torsion (restrained at both + ends, or at one end with the other free) * - ``TwistMin`` ``TwistMax`` ``TwistMean`` - ``(deg)`` - twist of the cable from End A to the node, as ``TwistN``. Present only on a line - restrained in torsion at both ends + solved in torsion The accumulation keeps three numbers per node and quantity and makes no heap allocation per step. Sampling a line evaluates its node channels once per output row; on the 1024-element cubic-Hermite @@ -747,8 +748,9 @@ Line-node channels (:ref:`outputs-azimuth-range`) - deg * - ``TorqN`` - - torque (twisting moment) at node ``J`` of a line restrained in torsion at both ends - (``END CONNECTIONS`` ``TorsStiffness``, see :doc:`driver_format`). In the statics it is + - torque (twisting moment) at node ``J`` of a line restrained in torsion at both ends, or at + one end with the other free to twist (``END CONNECTIONS`` ``TorsStiffness``, see + :doc:`driver_format`; zero in the statics of a line free at one end). In the statics it is uniform along the line, :math:`M = (\Phi - \Theta_{\text{eff}})/C` (:math:`\Theta_{\text{eff}} = \Theta` without torque–tension coupling); in the dynamics it is the nodal twist's torque at the node, the mean of its two elements' (an end node's @@ -767,7 +769,11 @@ Line-node channels - total twist of the line, :math:`\Phi - \Theta = M C`, including the windup of torsional end springs: the imposed twist :math:`\Phi` less the geometric twist :math:`\Theta` the line takes up by writhing out of its plane (in the dynamics the - element twists plus the end springs' windup) + element twists plus the end springs' windup). On a line free in torsion at one end, the + twist of its elements (no windup at the free end), still the turn of End B relative to + End A: a free End B turns by ``+Twist`` and a free End A by ``−Twist`` against + the restrained end's frame carried along the line; statically + :math:`-\sum (K/GJ)(l_e - L_e)` under torque–tension coupling - deg Touchdown channels @@ -895,8 +901,9 @@ output time. - deg/s, deg/s² * - ``RodFx`` / ``Fy`` / ``Fz``, ``Mx`` / ``My`` / ``Mz`` - net external force on the rod and its moment about End A: weight, buoyancy, Morison and - seabed loads and the line and cable end forces (not the pin reaction of a pinned rod, - whose ``M`` therefore vanishes at a static equilibrium) + seabed loads, the line and cable end forces and the connection moment (bending and + torque) of a cable clamped at its ends, on a rod fixed to a body too (not the pin + reaction of a pinned rod, whose ``M`` therefore vanishes at a static equilibrium) - N, N·m * - ``RodTenA`` / ``TenB`` - magnitude of the summed line and cable end force at End A / End B @@ -927,7 +934,8 @@ with exit code 1. A name is rejected when: 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``); + solved in torsion (``... carries no torque``, or ``... restrained at one end only and its + torsion is not solved: ``); * on a mixed ``EI = 0`` + finite-EI deck (and in OpenFAST), it is a ``Point

`` channel of a ``Coupled``/``Vessel`` point attached **only** to finite-EI lines — that point is not part of the ``EI = 0`` point system that serves point channels. Use the cable's diff --git a/doc/standalone_driver.rst b/doc/standalone_driver.rst index 67abac60..7b3416e5 100644 --- a/doc/standalone_driver.rst +++ b/doc/standalone_driver.rst @@ -99,20 +99,25 @@ The standalone driver accepts a deck containing separate ``EI = 0`` mooring line power cables between ``Fixed`` and ``Coupled``/``Vessel`` points. It uses the same aggregate that backs ``CompMooring = 5`` in OpenFAST (maintained by NLR, the National Laboratory of the Rockies, formerly NREL) and advances the objects atomically. Every ``Coupled``/``Vessel`` endpoint is held -at its initialised position. A mixed deck that also has bodies, rods or ``Connect``/``Free`` -points runs on the multibody march instead (:doc:`driver_format`), which accepts deck waves and -current. ``examples/iea15mw_umaine_mixed_cabledyn.dat`` is the maintained four-line +at its initialised position, or follows the deck's ``motionFile`` or ``vesselMotion`` (a vessel +turns the end connection and torsion frames of the power cables on its points, and the +``motionFile`` roll column twists a cable restrained in torsion, as on the single-cable route). +A mixed deck that also has bodies, rods or ``Connect``/``Free`` points runs on the multibody +march instead (:doc:`driver_format`), which accepts deck waves and current. ``examples/iea15mw_umaine_mixed_cabledyn.dat`` is the maintained four-line example; its ``TMax = 0`` setting writes the common static configuration. Give a positive ``TMax`` to march held-end dynamics. A static-only mixed deck with no dynamic-only option may instead omit both ``dtM`` and ``TMax``; the time-step option becomes mandatory when a positive-duration march is requested. -A mixed deck rejects ``motionFile`` and deck-owned wave/current OPTIONS by name. Platform -six-DOF motion is defined at the OpenFAST platform reference point, whereas a cable requires each -hang-off's translated and rotated position, velocity, and acceleration, and CableDyn does not -equate those two boundaries. Mixed-deck LINE ``Outputs`` flags ``p`` and ``t`` are rejected as -well; request the needed mixed-deck quantities through the main ``OUTPUTS`` section instead -(the ``r`` range graph is available). +A mixed deck rejects deck-owned wave/current OPTIONS by name, and with them ``vesselRAO``, +which needs deck waves. A ``vesselMotion`` record moves every ``Coupled``/``Vessel`` point +rigidly with the vessel (translation and rotation of each hang-off); a ``motionFile`` gives the +rows of each point. Row 1 is installed before ``t = 0``, also with ``TMax = 0``, after the +``.static.out`` of the static solve is written. On the ``EI = 0`` lines that transfer re-derives +the interior accelerations, which the ``EI = 0``-only route does not, so with row 1 off the deck +pose their first steps differ from that route's. Mixed-deck LINE ``Outputs`` flags ``p`` and +``t`` are rejected as well; request the needed mixed-deck quantities through the main +``OUTPUTS`` section instead (the ``r`` range graph is available). Initialisation report ~~~~~~~~~~~~~~~~~~~~~ diff --git a/doc/theory.rst b/doc/theory.rst index fd9f148b..384e1743 100644 --- a/doc/theory.rst +++ b/doc/theory.rst @@ -345,7 +345,9 @@ The section axis :math:`\mathbf{d}_1` (x) starts at End A normal to the End A :math:`\mathbf{t}`: - on a line restrained in torsion, along End A's torsion normal ``Nx``, which turns with the - hang-off; + hang-off; on a line restrained at End B only (End A free to twist), along End A's own + section: End B's ``Nx``, rolled by End B's ``Pretwist``, carried to End A and turned by the + twist of the line (:ref:`a free end `); - otherwise along the static start's upper normal, the projection of global +z normal to the End A tangent (global +x where the tangent is vertical). It is fixed in the hang-off's axes when End A is clamped or held by a finite rotational stiffness, so it turns with the vessel, @@ -496,7 +498,9 @@ length, integrated on the bending rule with its gradient and Hessian. Everything including the rank-one tangent, the step limit and the stability test, holds with :math:`\Theta_{\text{eff}}`. The coupling part has no :math:`2\pi` ambiguity, so the first evaluation unwraps the holonomy alone. A line free to twist at one end carries no torque and -the axial stiffness :math:`EA - K^2/GJ`. Restrained at both ends, a straight stretched line +the axial stiffness :math:`EA - K^2/GJ`, and its free end turns by the element twists, +:math:`-\sum_e (K_e/GJ_e)(l_e - L_{0,e})` (see the free end below). Restrained at both ends, a +straight stretched line cannot twist, so it carries :math:`T = EA\,\varepsilon` and :math:`M = K\varepsilon`. The node tension adds the element's :math:`(K/GJ)\,M`, and the twist channels sum the element twists :math:`M L_0/GJ - (K/GJ)(l - L_0)`. @@ -541,6 +545,28 @@ order, End B, and :math:`\Phi` at End A), so a turn of the frame enters the end reference twist through the same solid angles. A turn of an end frame by more than :math:`\pi/2` about the line within one step is refused, and the step is cut. +.. _theory-free-end: + +**A free end.** A line restrained in torsion at one end only has its other end free to twist: +an infinite end compliance, so the condensed compliance :math:`C` is infinite and the condensed +torque :math:`(\Phi - \Theta_{\text{eff}})/C` zero. The statics are then those of the line +without torsion (with the axial stiffness :math:`EA - K^2/GJ`), and every element twists by +:math:`\hat\tau_e = 0`, i.e. by :math:`-(K_e/GJ_e)(l_e - L_{0,e})` of material twist; their sum +is ``Twist``, the turn of End B relative to End A against the restrained end's frame +carried along the line (a free End A turns by its negative). In the dynamics the free end's node has no spring and no held angle: its angle +is free, its lumped inertia :math:`I_{rn} L_0/2` and its element's torque balance it, and its +end frame is a gauge that nothing reads (the free end's ``Nx`` and ``Pretwist`` are not used). +The torque vanishes at the free end, so torsional waves reflect there, and the line's modes are +the clamped–free ones, :math:`\omega_n = (2n - 1)\,\pi/(2L)\,\sqrt{GJ/I_{rn}}` for a uniform +line held rigidly at the other end; a roll :math:`A\sin\Omega t` of the restrained end turns +the free end by :math:`A/\cos kL` (:math:`k = \Omega\sqrt{I_{rn}/GJ}`) and loads the +restrained end with :math:`GJ A k \tan kL`. Exactly one end is restrained, so no rigid spin of +the angles is left free. The modal analysis and the OpenFAST linearisation take the free end's +angle as a coordinate (no spring term in the twist Hessian) and give these clamped–free modes, +and a free end has no roll stiffness. The test suite checks these frequencies, the driven +response at :math:`kL = \pi/4` and :math:`3\pi/4` and the free end's coupling turn against +the continuum. + In the limit of a negligible inertia the element torques are uniform and equal the condensed torque; the test suite holds the two models to 1e-6 on a rolling, swaying, bowed line with clamped, bending-pinned and elastic ends, and checks the torque of a driven torsional wave @@ -2686,7 +2712,11 @@ end force and moment load the object at the force level :math:`(1-\alpha_f)\,\mathbf{f}_{n+1} + \alpha_f\,\mathbf{f}_n`. Its condensed dynamic end stiffness with respect to the object's translation and rotation enters the Newton matrix by differences of the cable step. On a rod end the direction must lie along the rod axis, so the -moment has no component about the axis, which carries no degree of freedom. The static solve +bending moment has no component about the axis, which carries no degree of freedom on a free +or pinned rod (an axisymmetric rod has no roll angle; a line restrained in torsion is refused +there). A ``Fixed`` rod holds its end frame, and the torque of a line restrained in torsion +returns to it about the line axis; the ends of a rod fixed to a body are points of the body, +whose frame rolls with it. The static solve carries the cable first without bending; passes then add the difference between the cubic-Hermite cable's end force and that surrogate, and the Hermite connection moment, at the previous pass's pose, until these loads change by less than :math:`10^{-7}` of the force scale. At the diff --git a/doc/troubleshooting.rst b/doc/troubleshooting.rst index b69874b5..d6dce3bb 100644 --- a/doc/troubleshooting.rst +++ b/doc/troubleshooting.rst @@ -215,9 +215,8 @@ Clock, motion, and environment header lines with ``#``. * - motionFile ``... which is not Coupled/Vessel`` / ``duplicate row for point`` - the ``point_id`` is not a prescribed point, or a (point, time) pair appears twice. - * - ``Connect/Free dynamic-point deck does not support motionFile coupling`` / - ``mixed-deck motionFile is not supported`` - - these routes hold their coupled endpoints. Remove ``motionFile`` or separate the model. + * - ``Connect/Free dynamic-point deck does not support motionFile coupling`` + - this route holds its coupled endpoints. Remove ``motionFile`` or separate the model. * - ``bathymetry file must define one complete rectangular grid`` / ``grid is incomplete`` / ``duplicate x/y entries`` / ``needs at least a 2x2 grid`` / ``depths must be positive`` - the ``x y depth`` rows must cover every combination of the distinct ``x`` and ``y`` @@ -361,6 +360,7 @@ Model data finite-EI line with Fixed End B`` - bending end connections apply only to ``EI > 0`` lines whose End B is an anchor. * - ``a clamped or elastic END CONNECTION on a body or rod needs bodyScheme monolithic`` / + ``a torsional END CONNECTION on a body or rod needs bodyScheme monolithic`` / ``the END CONNECTION direction on a rod end must be parallel to the rod axis`` - remove ``staggered bodyScheme``; on a rod end give the direction along the rod axis (either sense). @@ -392,17 +392,23 @@ Torsion * - ``torsional END CONNECTIONS ... require a finite-EI line`` / ``require a finite-EI line with Fixed End B`` - torsion is solved on cubic-Hermite lines whose End B is an anchor. - * - ``a torsional END CONNECTION on a rod end is not supported`` / ``on a body needs a Rigid6 - body`` - - outside the torsion scope (:doc:`capabilities`). Move End A to a ``Fixed``, - ``Coupled``/``Vessel`` point or a Rigid6 body. + * - ``a torsional END CONNECTION on the end of ROD (...) is not supported: a free or + pinned rod is axisymmetric`` / ``on the end of Coupled/Vessel ROD is not supported`` / + ``on a body needs a Rigid6 body`` + - outside the torsion scope (:doc:`capabilities`). A free or pinned rod has no roll angle + about its own axis, so it cannot hold the torque. Move End A to a ``Fixed`` rod, a rod fixed + to a Rigid6 body (``RODS`` type ``Body``), a Rigid6 body or a ``Fixed`` point (a + ``Coupled``/``Vessel`` End A only in a deck without bodies and rods: a deck with them runs + on the multibody march, which takes no ``Coupled`` End A for a finite-EI line). + * - ``... require a finite-EI line with Fixed End B; line ends (End B) on a rod end`` + - the cable holds its End B at a ``Fixed`` point only, so a line between two rods (a J-tube + to a J-tube) is not supported. For a ``Fixed`` rod, end the line on a ``Fixed`` point at + the rod end's position; that rod's ``Rod`` loads then leave its force out. * - ``a line restrained in torsion needs a host that turns its fairlead frame`` - - the standalone deck that mixes ``EI = 0`` and finite-EI lines without a body, and the C - API's ``CableDyn_InitDeck``/``InitDeckAt``, move the line ends by translation only. Run the - line in a coupled OpenFAST or FAST.Farm run, initialise a C API handle with - ``CableDyn_InitDeckRotating`` and pass the host's rotations, add a body (such a deck runs - on the multibody route, which supports torsion), or set ``TorsStiffness Free`` in every - ``END CONNECTIONS`` row. + - the C API's ``CableDyn_InitDeck``/``InitDeckAt`` move the line ends by translation only. + Run the line in a coupled OpenFAST or FAST.Farm run or in the standalone driver, + initialise a C API handle with ``CableDyn_InitDeckRotating`` and pass the host's + rotations, or set ``TorsStiffness Free`` in every ``END CONNECTIONS`` row. * - ``torsion: the twist would move more than pi/2 from its committed value`` - the host turned a fairlead by more than 90° about the line's end direction without a step (an output probe or a non-stepping input update). Keep the platform turn per @@ -413,11 +419,15 @@ Torsion * - ``torsion in a dynamic run needs the force-blended generalised-alpha (OPTION alpha_force_blend True)`` - remove ``False alpha_force_blend`` from a deck with torsion. - * - ``OUTPUT "Torq...": line is not torsionally restrained at both ends ..., so it carries - no torque`` - - a ``Torq``/``Twist`` channel needs a line with a torsional restraint at both ends. - * - ``motionFile: point has a non-zero roll column, but no line restrained in torsion at - both ends ... has its moving (non-Fixed) end there`` / ``the roll column of point must + * - ``OUTPUT "Torq...": line is not torsionally restrained (END CONNECTIONS + TorsStiffness), so it carries no torque`` / ``... line is torsionally restrained at + one end only and its torsion is not solved: `` + - a ``Torq``/``Twist`` channel needs a line solved in torsion: restrained at both ends, or + at one end with the other free to twist; the second message gives the rule a line + restrained at one end missed (see the note below). + * - ``motionFile: point has a non-zero roll column, but no line restrained in torsion + (END CONNECTIONS TorsStiffness) at its moving (non-Fixed) end has that end there`` / + ``the roll column of point must be 0 at t = 0`` / ``gives the roll column (12th) on some rows only`` / ``the roll column (12th, degrees) must be a finite number`` - the roll column drives the frame of a torsional line's moving end, starts from 0 (put a @@ -620,9 +630,20 @@ Warnings and notes that do not stop a run * - Message - Cause and fix - * - ``Note: line is torsionally restrained at one end only; ... no torsion is solved`` - - with the other end free to twist the line carries no torque, so the torsion columns of the - restrained end have no effect. Restrain both ends to solve torsion. + * - ``Note: line is torsionally restrained at one end only and its torsion is not solved: + `` + - a line restrained at one end, its other end free to twist, is solved in torsion (its free + end turns with the twist of the line) where a line restrained at both ends would be; the + reason names the rule it misses: no ``GJ`` in its ``LINE TYPES`` rows (give the 14-column + row), two moving ends, ``False alpha_force_blend`` in a dynamic run, or a restrained End A + on the end of a free, pinned or ``Coupled``/``Vessel`` rod or on a body other than Rigid6. + The line is then solved as without the torsion columns. + * - ``Note: line : torsion restrained at End only: no static torque; Twist = + deg (End B relative to End A, right-handed about the End A -> End B tangent)`` + - a line restrained in torsion at one end: it carries no static torque, and under + torque–tension coupling (``GJ|K``) its stretch twists it by + :math:`-\sum (K/GJ)(l - L)`, so a free End B turns by :math:`+x` and a free End A by + :math:`-x` about the End A → End B tangent. * - ``Note: line : torsion solved, imposed twist ... deg, torque ... N m ( twist stage(s), buckling descent(s))`` - the static twist stage of a torsional line. A non-zero descent count means the straight or diff --git a/python/cabledyn/deck_file.py b/python/cabledyn/deck_file.py index 631d1f33..22856450 100644 --- a/python/cabledyn/deck_file.py +++ b/python/cabledyn/deck_file.py @@ -372,6 +372,12 @@ _RIGID_END_CONNECTIONS = frozenset({"rigid", "infinity", "inf"}) # TorsStiffness keywords of an end free to twist (a numeric 0 is free too) _FREE_TORSION_KEYWORDS = frozenset({"free", "zero"}) +# native ROD_END_B_NOTE: a finite-EI line with an END CONNECTION whose End B is a rod end +_ROD_END_B_NOTE = ( + " ends (End B) on a rod end: a line between two rods is not supported in this build (the " + "cable holds its End B at a Fixed point only); for a Fixed rod, end the line on a Fixed " + "point at the rod end's position (its force then stays out of that rod's Rod loads)" +) # native CD_HTORS_MAX_TWIST: the largest imposed static twist, 1000 turns _MAX_STATIC_TWIST_DEG = 360000.0 # Native TORS_NX_PARALLEL_TOL: smallest |Nx x Ez| of unit vectors (about 0.06 degrees off Ez). @@ -3019,6 +3025,16 @@ def end_key(token: str) -> str: normalized_line_endpoints: dict[str, tuple[str, str]] = {} # lines whose stock anchor-first row the native reader turns around (its ends swap) swapped_lines: set[str] = set() + # native finite_ei_by_name (normalize_stock_endpoint_order): the lines whose SECTIONS + # rows name a line type with EI > 0 + finite_ei_lines: set[str] = set() + for section in self._rows("SECTIONS"): + if len(section.tokens) < 2: + continue + meta = line_type_meta.get(section.tokens[1].lower()) + if meta is not None and meta[3] > 0.0: + with contextlib.suppress(ValueError): + finite_ei_lines.add(str(_native_int(section.tokens[0]))) range_lines = 0 lift_lines = 0 # lines with the VIV lift file (flag V) series_lines = 0 # lines with per-line time-series files (flags p, t, V) @@ -3096,11 +3112,19 @@ def end_key(token: str) -> str: # when NodeB is a fairlead (Coupled/Vessel/Body/Turbine), or a Free/Connect # point at or above the Fixed NodeA. A Fixed NodeA above a Free/Connect # NodeB is an elevated hang-off already in CableDyn (upper-end-first) order. + # A finite-EI line to a rod end swaps too (it runs only from the rod, End A, to a + # Fixed End B); an EI = 0 line to a rod end keeps its written order. + line_key = str(_native_int(row.tokens[0])) + line_is_finite_ei = line_key in finite_ei_lines or ( + len(row.tokens) == 7 + and line_type_meta.get(row.tokens[1].lower(), (0.0, 0.0, 0.0, 0.0))[3] > 0.0 + ) upper_b = ( type_b in {"coupled", "vessel"} or type_b.startswith("body") or _is_turbine_point_type(type_b) or (type_b in {"connect", "free"} and point_z[node_a] <= point_z[node_b]) + or (line_is_finite_ei and _rod_point(type_b) is not None) ) if type_a == "fixed" and upper_b: node_a, node_b = node_b, node_a @@ -3245,7 +3269,9 @@ def end_key(token: str) -> str: assigned_end_connections: set[tuple[str, str]] = set() # (line, end) held by a Rigid or rotational-spring row, in native End A/B order held_ends: set[tuple[str, str]] = set() - # line id -> {end: torsionally restrained} from the optional torsion columns + # line id -> {end: torsionally restrained} from the optional torsion columns, and the + # pretwists, in native End A/B order (after the anchor-first swap, which reverses Ez and + # so negates a pretwist) torsion_ends: dict[str, dict[str, bool]] = {} torsion_pretwist: dict[str, dict[str, float]] = {} for row in self.end_connections: @@ -3334,11 +3360,15 @@ def end_key(token: str) -> str: pretwist = 0.0 if len(row.tokens) == 11: pretwist = numeric(row.tokens[10], row, "END CONNECTIONS pretwist") - torsion_pretwist.setdefault(line_id, {})[end] = pretwist + native_end = end + if line_id in swapped_lines: + native_end = {"a": "b", "b": "a"}[end] + pretwist = -pretwist + torsion_pretwist.setdefault(line_id, {})[native_end] = pretwist if restrained: # a Free end has no torsion frame: its normal is not checked (native) self._check_torsion_normal(where, row, normal, direction, norm) - torsion_ends.setdefault(line_id, {})[end] = restrained + torsion_ends.setdefault(line_id, {})[native_end] = restrained if non_pinned: swapped = line_id in swapped_lines held_ends.add((line_id, {"a": "b", "b": "a"}[end] if swapped else end)) @@ -3349,6 +3379,11 @@ def end_key(token: str) -> str: if not has_finite_ei: raise DeckFormatError(f"{where} END CONNECTIONS requires a finite-EI line") end_b = normalized_line_endpoints[line_id][1] + if _rod_point(point_types[end_b]) is not None: + raise DeckFormatError( + f"{where} non-pinned END CONNECTIONS require a finite-EI line with Fixed " + f"End B; line {line_id}{_ROD_END_B_NOTE}" + ) if point_types[end_b] != "fixed": raise DeckFormatError( f"{where} non-pinned END CONNECTIONS require " @@ -3437,7 +3472,7 @@ def end_key(token: str) -> str: ) for row in bodies } - torsion_lines = self._check_torsion_lines( + torsion_lines, torsion_notes = self._check_torsion_lines( torsion_ends, torsion_pretwist, section_types_by_line, @@ -3448,7 +3483,6 @@ def end_key(token: str) -> str: body_types, option_by_key, has_tmax, - mixed_route, ) rod_types = self._rows("ROD TYPES") @@ -3622,18 +3656,15 @@ def end_key(token: str) -> str: # deck driver, whose dispatch gates follow. deck_driver_route = not self.caller_driven and not mixed_route if self.caller_driven or mixed_route: - # native CD_Init_Deck_Aggregate: the host (or, for a standalone mixed deck, the - # driver holding the initialized ends) drives the coupled boundary + # native CD_Init_Deck_Aggregate: the host drives the coupled boundary; a standalone + # mixed deck is driven by the driver, which holds the initialized ends or marches + # the deck's motionFile/vesselMotion (prescribed_motion; vesselRAO needs deck + # waves, which the still-water mixed route refuses below) if has_motion_file and self.caller_driven: raise DeckFormatError( f"{self._label}: the coupled boundary is driven by the host, not a deck " "motionFile; remove the motionFile OPTION" ) - if has_motion_file: - raise DeckFormatError( - f"{self._label}: a mixed EI=0/finite-EI deck does not support motionFile " - "(the driver holds its coupled ends)" - ) if not line_ids: raise DeckFormatError(f"{self._label}: the coupled route needs at least one line") if self.caller_driven: @@ -4201,11 +4232,16 @@ def is_body_kind(kind: str, pinned: bool) -> bool: raise DeckFormatError( f"{self._label}: OUTPUT {channel!r} node exceeds the line node count" ) + if line_id in torsion_notes: + raise DeckFormatError( + f"{self._label}: OUTPUT {channel!r}: line {line_id} is torsionally " + "restrained at one end only and its torsion is not solved: " + f"{torsion_notes[line_id]}" + ) if line_id not in torsion_lines: raise DeckFormatError( f"{self._label}: OUTPUT {channel!r}: line {line_id} is not torsionally " - "restrained at both ends (END CONNECTIONS TorsStiffness), so it carries " - "no torque" + "restrained (END CONNECTIONS TorsStiffness), so it carries no torque" ) continue if lowered.startswith(("ten", "curv", "bendmom", "stfmom", "l")): @@ -4285,35 +4321,98 @@ def _check_torsion_lines( body_types: dict[str, str], option_by_key: dict[str, OptionRecord], has_tmax: bool, - aggregate_route: bool, - ) -> set[str]: - """Native ``check_torsion_line`` and the driver's torsion scope; the torsional lines. + ) -> tuple[set[str], dict[str, str]]: + """Native ``check_torsion_line`` and the driver's torsion scope. + + Returns the lines solved in torsion and, for a line restrained at one end only whose + torsion is not solved, why (native ``resolve_one_end_torsion``). A line with a torsional END CONNECTIONS restraint (TorsStiffness Rigid or a - stiffness) must be finite-EI. With one restrained end it carries no torque and is - solved as without the columns. Restrained at both ends, torsion is solved: End B must - be Fixed, every section type needs an explicit GJ > 0, no ATTACHMENTS, End A neither a - rod end nor on a body other than Rigid6. A deck with torsion runs dynamics only with - the force-blended generalised-alpha (a coupled run is always dynamic); its modal - analysis (nModes) carries the twist. A standalone mixed EI = 0 + finite-EI deck - without bodies (``aggregate_route``, run on the aggregate, which moves the line ends by - translation only) refuses any torsion column, one restrained end included; the coupled - OpenFAST and FAST.Farm routes turn the fairlead frame with the platform and accept it. + stiffness) must be finite-EI. Restrained at both ends, torsion is solved: End B must + be Fixed, every section type needs an explicit GJ > 0, End A neither on a rod other than + a Fixed one (a free or pinned rod has no roll angle, a Coupled/Vessel rod carries no + finite-EI line; the ends of a rod fixed to a body are body points) nor on a body other + than Rigid6. Restrained at one end only (its other end free to twist), it is solved in + torsion under the same rules and with a force-blended march; otherwise it keeps the + meaning of the 6-column rows (no error). ATTACHMENTS, CONTROL and the modal analysis + (nModes, whose modes carry the twist) take a line solved in torsion. A deck with torsion + runs dynamics only with the force-blended generalised-alpha (a coupled run is always + dynamic). The coupled OpenFAST and FAST.Farm routes turn the fairlead frame with the + platform, and the standalone mixed EI = 0 + finite-EI deck without bodies (run on the + aggregate) holds it or turns it with its vesselMotion and rolls it with the motionFile + roll column, as the standalone cubic-Hermite route does. """ - # _check_attachments has already accepted every LineID as an integer + rod_kinds = self._rod_rows_by_id() + tmax_row = option_by_key.get("tmax") + # a coupled run is always dynamic (the host owns TMax) + dynamic = self.caller_driven or ( + has_tmax and tmax_row is not None and _native_float(tmax_row.values[0]) > 0.0 + ) + blend_row = option_by_key.get("alpha_force_blend") + force_blend = blend_row is None or blend_row.values[0].lower() in { + "true", + "t", + "yes", + "y", + "on", + "1", + } torsion_lines: set[str] = set() - has_torsion_column = False + torsion_notes: dict[str, str] = {} for line_id, ends in torsion_ends.items(): if not any(ends.values()): continue - has_torsion_column = True if not any(line_type_meta[name][3] > 0.0 for name in section_types_by_line[line_id]): raise DeckFormatError( f"{self._label}: torsional END CONNECTIONS (TorsStiffness Rigid or a " f"stiffness) require a finite-EI line; line {line_id} has EI = 0" ) - # one restrained end only carries no torque: noted and ignored if not (ends.get("a", False) and ends.get("b", False)): + # one restrained end: solved where the rules hold, noted otherwise + end_a, end_b = normalized_line_endpoints[line_id] + note = "" + if not all(line_type_gj[name] > 0.0 for name in section_types_by_line[line_id]): + note = ( + "its LINE TYPES rows give no GJ (the 14-column row; torsion has no " + "EI/1.3 default)" + ) + elif point_types[end_b] != "fixed": + note = "it has two moving ends (torsion needs a Fixed End B)" + elif dynamic and not force_blend: + note = ( + "torsion in a dynamic run needs the force-blended generalised-alpha " + "(alpha_force_blend True)" + ) + elif ends.get("a", False): + body_id = _body_point_id(point_types[end_a]) + rod_end = _rod_point(point_types[end_a]) + rod_kind = None if rod_end is None else rod_kinds.get(rod_end[0], (None, 0))[0] + if rod_end is not None and rod_kind is not None and rod_kind != "fixed": + if rod_kind in {"coupled", "vessel"}: + note = ( + "its restrained End A is on a Coupled/Vessel rod end (no route " + "carries a finite-EI line on a host-driven rod)" + ) + else: + note = ( + "its restrained End A is on the end of a free or pinned rod " + "(axisymmetric, with no roll angle to hold the torque)" + ) + elif body_id > 0 and body_types.get(str(body_id), "rigid6") != "rigid6": + note = "its restrained End A is on a body that is not Rigid6" + if note: + torsion_notes[line_id] = note + continue + # native check_torsion_line: the restrained end's pretwist is the imposed twist + restrained_end = "a" if ends.get("a", False) else "b" + twist = torsion_pretwist[line_id].get(restrained_end, 0.0) + if abs(twist) > _MAX_STATIC_TWIST_DEG: + raise DeckFormatError( + f"{self._label}: line {line_id}: the Pretwist of its restrained End " + f"{restrained_end.upper()} = {twist:.5e} deg exceeds 1000 turns " + "(360000 deg), the largest twist" + ) + torsion_lines.add(line_id) continue twist = torsion_pretwist[line_id]["b"] - torsion_pretwist[line_id]["a"] if abs(twist) > _MAX_STATIC_TWIST_DEG: @@ -4322,6 +4421,11 @@ def _check_torsion_lines( f"{twist:.5e} deg exceeds 1000 turns (360000 deg), the largest static twist" ) end_a, end_b = normalized_line_endpoints[line_id] + if _rod_point(point_types[end_b]) is not None: + raise DeckFormatError( + f"{self._label}: torsional END CONNECTIONS require a finite-EI line with Fixed " + f"End B; line {line_id}{_ROD_END_B_NOTE}" + ) if point_types[end_b] != "fixed": raise DeckFormatError( f"{self._label}: torsional END CONNECTIONS require a finite-EI line with Fixed " @@ -4334,10 +4438,24 @@ def _check_torsion_lines( f'its LINE TYPES row "{name}" must give an explicit GJ > 0 (the 14-column ' "row; torsion has no EI/1.3 default)" ) - if _rod_point(point_types[end_a]) is not None: + rod_end = _rod_point(point_types[end_a]) + rod_kind = None if rod_end is None else rod_kinds.get(rod_end[0], (None, 0))[0] + if rod_end is not None and rod_kind is not None and rod_kind != "fixed": + if re.fullmatch(r"body[0-9]+pin", rod_kind): + rod_kind += "ned" + if rod_kind in {"coupled", "vessel"}: + raise DeckFormatError( + f"{self._label}: line {line_id}: a torsional END CONNECTION on the end of " + f"Coupled/Vessel ROD {rod_end[0]} is not supported: no route of this build " + "carries a finite-EI line on a host-driven rod" + ) raise DeckFormatError( - f"{self._label}: line {line_id}: a torsional END CONNECTION on a rod end is " - "not supported (a rod has no spin angle in this build)" + f"{self._label}: line {line_id}: a torsional END CONNECTION on the end of ROD " + f"{rod_end[0]} ({rod_kind}) is not supported: a free or pinned rod is " + "axisymmetric, with no roll about its own axis (no load acts about the axis " + "and its static solve has no roll angle), so it cannot hold the line's torque; " + "restrain End A on a Fixed rod, on a rod fixed to a Rigid6 body (RODS type " + "Body), on a Rigid6 body point or on a Fixed point" ) body_id = _body_point_id(point_types[end_a]) if body_id > 0 and body_types.get(str(body_id), "rigid6") != "rigid6": @@ -4346,40 +4464,14 @@ def _check_torsion_lines( "a Rigid6 body" ) torsion_lines.add(line_id) - # native CD_Init_Deck_Aggregate (deck_has_torsion_columns): a standalone mixed EI = 0 + - # finite-EI deck without bodies moves its line ends by translation only and refuses any - # restrained end; the OpenFAST and FAST.Farm hosts turn the fairlead frame - if has_torsion_column and aggregate_route and not self.caller_driven: - raise DeckFormatError( - f"{self._label}: a line restrained in torsion needs a host that turns its fairlead " - "frame: coupled OpenFAST and FAST.Farm runs do, and a C API host initialised with " - "CableDyn_InitDeckRotating, while CableDyn_InitDeck/InitDeckAt and a standalone " - "deck that mixes EI = 0 and finite-EI lines without a BODY move the line ends by " - "translation only (with a BODY such a deck runs on the multibody route, which " - "supports torsion); set TorsStiffness Free in every END CONNECTIONS row" - ) if not torsion_lines: - return torsion_lines - tmax_row = option_by_key.get("tmax") - # a coupled run is always dynamic (the host owns TMax) - dynamic = self.caller_driven or ( - has_tmax and tmax_row is not None and _native_float(tmax_row.values[0]) > 0.0 - ) - blend_row = option_by_key.get("alpha_force_blend") - force_blend = blend_row is None or blend_row.values[0].lower() in { - "true", - "t", - "yes", - "y", - "on", - "1", - } + return torsion_lines, torsion_notes if dynamic and not force_blend: raise DeckFormatError( f"{self._label}: torsion in a dynamic run needs the force-blended " "generalised-alpha (OPTION alpha_force_blend True)" ) - return torsion_lines + return torsion_lines, torsion_notes def _line_type_fields(self, record: DeckRecord) -> tuple[str, ...]: fields = _FIELDS["line_type"] diff --git a/python/cabledyn/ranges.py b/python/cabledyn/ranges.py index f823c8eb..be641e19 100644 --- a/python/cabledyn/ranges.py +++ b/python/cabledyn/ranges.py @@ -455,8 +455,9 @@ def read_range_graphs(source: str | os.PathLike[str] | OutputTable) -> dict[str, LINES ``Outputs`` flag ``r``: the minimum, maximum, and mean over the output times of the range window of the node tension, curvature, bend moment, and declination, the seabed clearance when the deck has a - seabed, and the torque and twist from End A when the line is restrained - in torsion at both ends, at every node against its arc length. + seabed, and the torque and twist from End A when the line is solved in + torsion (restrained at both ends, or at one end with the other free), at + every node against its arc length. Parameters ---------- diff --git a/python/tests/test_deck_native_parity.py b/python/tests/test_deck_native_parity.py index f481cd63..eb00bbe5 100644 --- a/python/tests/test_deck_native_parity.py +++ b/python/tests/test_deck_native_parity.py @@ -846,7 +846,11 @@ def test_standalone_mixed_deck_runs_on_the_still_water_aggregate(): _rejects(_options(_MIXED, "uniform 0.5 0 0 current"), "runs in still water") _rejects(_options(_MIXED, "airy 2 8 0 waves"), "runs in still water") _rejects(_edit(_MIXED, ("2 2 3 -", "2 2 3 pt")), "writes no per-line files") - _rejects(_options(_MIXED, "m.txt motionFile"), "mixed EI=0/finite-EI deck does not support") + # the driver marches the deck's motionFile or vesselMotion; vesselRAO needs deck waves + DeckFile.from_text(_options(_MIXED, "m.txt motionFile")) + DeckFile.from_text(_options(_MIXED, "v.txt vesselMotion", "0|0|0 vesselRef")) + _rejects(_options(_MIXED, "r.txt vesselRAO"), "vesselRAO needs deck waves") + _rejects(_options(_MIXED, "r.txt vesselRAO", "airy 2 8 0 waves"), "runs in still water") def test_coupled_route_takes_no_motion_file_and_needs_a_line(): @@ -970,6 +974,9 @@ def test_end_connection_errors_name_the_line_end_and_value(row, message): _rejects(_edit(_TORSION, (_TORSION_ROW_A, row)), message) +_NO_TORSION_OUTPUTS_ONE_END = ("Torq1N1\nTwist1N41\nTwist1\n", "FairTen1\n") + + def test_torsion_line_rules_follow_the_native_checks(): # torsion has no EI/1.3 default: the 10-column LINE TYPES row has no GJ no_gj = _edit( @@ -992,10 +999,53 @@ def test_torsion_line_rules_follow_the_native_checks(): ("Torq1N1\nTwist1N41\nTwist1\n", "FairTen1\n"), ) _rejects(ei0, "require a finite-EI line; line 1 has EI = 0") - # one restrained end is accepted (it carries no torque), but takes no torsion channel + # one restrained end, the other free to twist, is solved in torsion with its channels ... one_end = _edit(_TORSION, (_TORSION_ROW_A, "1 A Rigid 1 0 0 Free 0 0 1 0\n")) - _rejects(one_end, "is not torsionally restrained at both ends") - DeckFile.from_text(_edit(one_end, ("Torq1N1\nTwist1N41\nTwist1\n", "FairTen1\n"))) + DeckFile.from_text(one_end) + # ... where both-end torsion would be; otherwise it is not, and its channels are refused + one_end_no_gj = _edit( + one_end, + ( + "Name Diam Mass EA BA EI GAs GJ Irt Irn Cdn Cdt Can Cat\n", + "Name Diam Mass EA BA EI Cdn Cdt Can Cat\n", + ), + ( + "cab 0.2 32.2 1.0e7 0.0 1.0e6 1.0e8 5.0e4 1.0 1.0 0.0 0.0 0.0 0.0", + "cab 0.2 32.2 1.0e7 0.0 1.0e6 0 0 0 0", + ), + ) + _rejects( + one_end_no_gj, "restrained at one end only and its torsion is not solved: its LINE TYPES" + ) + DeckFile.from_text(_edit(one_end_no_gj, ("Torq1N1\nTwist1N41\nTwist1\n", "FairTen1\n"))) + one_end_dyn = _edit(one_end, ("0.0 TMax\n", "10.0 TMax\n")) + DeckFile.from_text(one_end_dyn) + _rejects( + _options(one_end_dyn, "False alpha_force_blend"), + "torsion is not solved: torsion in a dynamic run needs the force-blended", + ) + # the modal analysis, ATTACHMENTS and CONTROL take a line solved at one end, its channels too + DeckFile.from_text(_options(one_end, "3 nModes")) + DeckFile.from_text( + _edit( + one_end, + ( + f"{_BAR} OPTIONS {_BAR}", + f"{_BAR} ATTACHMENTS {_BAR}\nLineID ArcLength Mass Volume CdA Ca\n" + f"1 50.0 10.0 0.0 0.0 0.0\n{_BAR} OPTIONS {_BAR}", + ), + ) + ) + DeckFile.from_text( + _edit( + one_end, + ( + f"{_BAR} OPTIONS {_BAR}", + f"{_BAR} CONTROL {_BAR}\nChannelID Line(s)\n(-) (-)\n1 1\n{_BAR} OPTIONS {_BAR}", + ), + ), + caller_driven=True, + ) # the dynamic run needs the force blend; modal analysis carries the twist dynamic = _edit(_TORSION, ("0.0 TMax\n", "10.0 TMax\n")) DeckFile.from_text(dynamic) @@ -1045,6 +1095,24 @@ def _torsion_two_moving(row_a: str) -> str: ) +def _one_end_rod(rod_kind: str) -> str: + """The pure-torsion line hung from End B of a rod of the given kind along its axis (+x), + restrained in torsion there only (End B of the line free to twist).""" + return _edit( + _TORSION_DYN, + ( + f"{_BAR} POINTS {_BAR}", + f"{_BAR} ROD TYPES {_BAR}\nName Diam Mass Cd Ca CdEnd CaEnd\n" + "spar 1.0 300.0 0.8 1.0 0.0 0.0\n" + f"{_BAR} RODS {_BAR}\nID RodType Type XA YA ZA XB YB ZB NumSegs Outputs\n" + f"1 spar {rod_kind} -10 0 -50 0 0 -50 2 -\n{_BAR} POINTS {_BAR}", + ), + ("1 1 2 -", "1 R1B 2 -"), + ("1 Coupled 0.0 0.0 -50.0 0 0 0 0\n", ""), + ("1 B Rigid 1 0 0 Rigid 0 0 1 720", "1 B Rigid 1 0 0 Free 0 0 1 0"), + ) + + def test_torsion_scope_rules_follow_the_native_checks(): # End A on a Rigid6 body is supported, on a Point3 body or a rod end it stops by name DeckFile.from_text( @@ -1066,7 +1134,66 @@ def test_torsion_scope_rules_follow_the_native_checks(): ("1 1 2 -", "1 R1A 2 -"), ("1 Coupled 0.0 0.0 -50.0 0 0 0 0\n", ""), ) - _rejects(rod_end, "a torsional END CONNECTION on a rod end is not supported") + # a Fixed rod holds the End A torsion frame still; a free or pinned rod has no roll angle, + # and a Coupled rod carries no finite-EI line on any route + DeckFile.from_text(rod_end) + axisymmetric = "is not supported: a free or pinned rod is axisymmetric, with no roll about" + _rejects( + _edit(rod_end, ("1 spar Fixed", "1 spar Pinned")), + rf"line 1: a torsional END CONNECTION on the end of ROD 1 \(pinned\) {axisymmetric}", + ) + _rejects( + _edit(rod_end, ("1 spar Fixed", "1 spar Free")), + rf"on the end of ROD 1 \(free\) {axisymmetric}", + ) + _rejects( + _edit( + rod_end, + ( + f"{_BAR} ROD TYPES {_BAR}", + f"{_BAR} BODIES {_BAR}\n" + "ID Type X Y Z Roll Pitch Yaw Mass Vol C33 C44 C55 CdA Ca Ixx Iyy Izz\n" + "1 Rigid6 0 0 -30 0 0 0 1.0e5 97.56 0 0 0 0 0 1.0e3 1.0e3 1.0e3\n" + f"{_BAR} ROD TYPES {_BAR}", + ), + ("1 spar Fixed 0 0 -50 0 0 -40", "1 spar Body1Pin 0 0 -20 0 0 -10"), + ), + rf"on the end of ROD 1 \(body1pinned\) {axisymmetric}", + ) + # written anchor first (MoorDyn's order) the finite-EI line is turned around, onto the Fixed + # rod as onto a pinned one; a line between two rods ends on a rod end + anchor_first = _edit(rod_end, ("1 R1A 2 -", "1 2 R1A -")) + DeckFile.from_text(anchor_first) + _rejects( + _edit(anchor_first, ("1 spar Fixed", "1 spar Pinned")), + rf"on the end of ROD 1 \(pinned\) {axisymmetric}", + ) + _rejects( + _edit( + rod_end, + ( + "1 spar Fixed 0 0 -50 0 0 -40 2 -\n", + "1 spar Fixed 0 0 -50 0 0 -40 2 -\n2 spar Fixed 100 0 -50 100 0 -60 2 -\n", + ), + ("1 R1A 2 -", "1 R1A R2A -"), + ), + # the bending row is checked first here, the torsion first natively: one remedy + r"END CONNECTIONS require a finite-EI line with Fixed End B; line 1 ends \(End B\) on a " + "rod end: a line between two rods is not supported in this build", + ) + _rejects( + _options(_edit(rod_end, ("1 spar Fixed", "1 spar Coupled")), "rod.motion motionFile"), + "a torsional END CONNECTION on the end of Coupled/Vessel ROD 1 is not supported: no route " + "of this build carries a finite-EI line on a host-driven rod", + ) + # restrained at the rod end only (End B free to twist): solved on a Fixed rod, noted on a + # pinned one, whose twist channels are then refused with the reason + DeckFile.from_text(_one_end_rod("Fixed")) + _rejects( + _one_end_rod("Pinned"), + "its torsion is not solved: its restrained End A is on the end of a free or pinned rod", + ) + DeckFile.from_text(_edit(_one_end_rod("Pinned"), _NO_TORSION_OUTPUTS)) attachments = _edit( _TORSION, ( @@ -1096,12 +1223,14 @@ def test_torsion_scope_rules_follow_the_native_checks(): (_TORSION_ROW_A, "1 A Rigid 1 0 0 Free 0 0 1 0\n"), ("1 B Rigid 1 0 0 Rigid 0 0 1 720", "1 B Rigid 1 0 0 Free 0 0 1 720"), ) - _rejects(both_free, "is not torsionally restrained at both ends") + _rejects(both_free, "is not torsionally restrained \\(END CONNECTIONS") DeckFile.from_text(_edit(both_free, _NO_TORSION_OUTPUTS)) -def test_torsion_on_a_standalone_mixed_deck_is_refused(): - # a mixed EI = 0 + finite-EI deck without bodies runs on the aggregate, which has no torsion +def test_torsion_on_a_standalone_mixed_deck_is_accepted(): + # a mixed EI = 0 + finite-EI deck without bodies runs on the aggregate, whose driver holds the + # line end frames or turns them with the deck's vesselMotion and rolls them with the + # motionFile roll column (test_mixed_route_torsion) gj_cable = _edit( _MIXED, ( @@ -1128,8 +1257,21 @@ def test_torsion_on_a_standalone_mixed_deck_is_refused(): "LineID End Stiffness EzX EzY EzZ TorsStiffness NxX NxY NxZ Pretwist", *rows, ) - _rejects(text, "mixes EI = 0 and finite-EI lines without a BODY") - _rejects(_options(text, "10.0 TMax"), "mixes EI = 0 and finite-EI lines without a BODY") + DeckFile.from_text(text) + DeckFile.from_text(_edit(text, ("10.0 TMax\n", "0.0 TMax\n"))) + DeckFile.from_text(_options(text, "m.txt motionFile")) + DeckFile.from_text(_options(text, "v.txt vesselMotion", "0|0|0 vesselRef")) + # a static run (TMax = 0) marches no step and takes the configuration blend, as native + # CD_Init_Deck_Aggregate with static_run (test_mixed_route_torsion gate 6) + DeckFile.from_text( + _options(_edit(text, ("10.0 TMax\n", "0.0 TMax\n")), "False alpha_force_blend") + ) + if "Free" not in rows[1]: + # restrained at both ends, the dynamic run needs the force blend, as on every route + _rejects( + _options(text, "False alpha_force_blend"), + "needs the force-blended generalised-alpha", + ) @pytest.mark.parametrize( @@ -1250,7 +1392,7 @@ def test_static_twist_of_1000_turns_is_accepted(): def test_torsion_rows_get_the_native_verdict(row_a, tmp_path): text = _edit(_TORSION, (_TORSION_ROW_A, f"{row_a}\n")) if row_a.split()[6].lower() in {"free", "zero"}: - # one restrained end carries no torque: judge the row, not the torsion channels + # a Free End A: judge the row (its normal and pretwist), not the torsion channels text = _edit(text, _NO_TORSION_OUTPUTS) try: DeckFile.from_text(text) @@ -1317,6 +1459,122 @@ def test_torsion_channels_get_the_native_verdict(channel, tmp_path): assert python_accepts == (_native_exit(text, tmp_path) != 1) +def _stock_body(body_row: str, row_a: str, row_b: str) -> str: + """A line written anchor first (NodeA the Fixed anchor, NodeB on body 1), which the reader + turns around: its deck End B becomes End A.""" + return f"""{_BAR} CableDyn Input File {_BAR} +in-memory fixture: an anchor-first line restrained in torsion at one end +{_BAR} LINE TYPES {_BAR} +Name Diam Mass EA BA EI GAs GJ Irt Irn Cdn Cdt Can Cat +cab 0.2 32.2 1.0e7 0.0 1.0e6 1.0e8 5.0e4 1.0 1.0 0.0 0.0 0.0 0.0 +{_BAR} BODIES {_BAR} +ID Type X Y Z Roll Pitch Yaw Mass Vol C33 C44 C55 CdA Ca Ixx Iyy Izz +{body_row} +{_BAR} POINTS {_BAR} +ID Type X Y Z Mass Vol CdA Ca +1 Body1 0.0 0.0 0.0 0 0 0 0 +2 Fixed 100.0 0.0 -50.0 0 0 0 0 +{_BAR} LINES {_BAR} +ID NodeA NodeB Outputs +1 2 1 - +{_BAR} SECTIONS {_BAR} +LineID LineType Length NumSegs +1 cab 100.0 40 +{_BAR} END CONNECTIONS {_BAR} +LineID End Stiffness EzX EzY EzZ TorsStiffness NxX NxY NxZ Pretwist +{row_a} +{row_b} +{_BAR} OPTIONS {_BAR} +9.80665 g +1025.0 rhoW +50.0 WtrDpth +0.1 dtM +1.0 TMax +{_BAR} OUTPUTS {_BAR} +FairTen1 +Twist1 +{_BAR} need this line {_BAR} +""" + + +# restrained at the deck's End B, the body, which the anchor-first swap makes End A +_STOCK_POINT3_AT_BODY = _stock_body( + "1 Point3 0 0 -50 0 0 0 1.0e5 97.56 0 0 0 0 0", + "1 A Rigid -1 0 0 Free 0 0 1 0", + "1 B Rigid -1 0 0 Rigid 0 0 1 0", +) +_STOCK_RIGID6_AT_BODY = _stock_body( + "1 Rigid6 0 0 -50 0 0 0 1.0e5 97.56 0 0 0 0 0 1.0e3 1.0e3 1.0e3", + "1 A Rigid -1 0 0 Free 0 0 1 0", + "1 B Rigid -1 0 0 Rigid 0 0 1 0", +) + + +def test_one_end_torsion_follows_the_anchor_first_swap(): + # a Point3 body does not carry torsion: the line restrained there is not solved, and its + # twist channel is refused; on a Rigid6 body it is solved + _rejects(_STOCK_POINT3_AT_BODY, "its restrained End A is on a body that is not Rigid6") + DeckFile.from_text(_STOCK_RIGID6_AT_BODY) + + +def test_one_end_pretwist_stays_within_1000_turns(): + one_end = _edit( + _TORSION, + (_TORSION_ROW_A, "1 A Rigid 1 0 0 Free 0 0 1 0\n"), + ("1 B Rigid 1 0 0 Rigid 0 0 1 720", "1 B Rigid 1 0 0 Rigid 0 0 1 1e8"), + ) + _rejects(one_end, "the Pretwist of its restrained End B = 1.00000e\\+08 deg exceeds 1000 turns") + # the free end's pretwist rolls nothing and is not checked + DeckFile.from_text(_edit(_TORSION, (_TORSION_ROW_A, "1 A Rigid 1 0 0 Free 0 0 1 1e8\n"))) + + +@pytest.mark.skipif( + not _PARITY_DRIVER or not Path(_PARITY_DRIVER).is_file(), + reason="set CABLEDYN_TEST_DRIVER to a built native driver to run the native torsion parity", +) +@pytest.mark.parametrize( + "text", + [ + _STOCK_POINT3_AT_BODY, + _STOCK_RIGID6_AT_BODY, + _edit( + _TORSION, + (_TORSION_ROW_A, "1 A Rigid 1 0 0 Free 0 0 1 0\n"), + ("1 B Rigid 1 0 0 Rigid 0 0 1 720", "1 B Rigid 1 0 0 Rigid 0 0 1 1e8"), + ), + _options(_edit(_TORSION, (_TORSION_ROW_A, "1 A Rigid 1 0 0 Free 0 0 1 0\n")), "3 nModes"), + _edit( + _TORSION, + (_TORSION_ROW_A, "1 A Rigid 1 0 0 Free 0 0 1 0\n"), + ( + f"{_BAR} OPTIONS {_BAR}", + f"{_BAR} ATTACHMENTS {_BAR}\nLineID ArcLength Mass Volume CdA Ca\n" + f"1 50.0 10.0 0.0 0.0 0.0\n{_BAR} OPTIONS {_BAR}", + ), + ), + _one_end_rod("Fixed"), + _one_end_rod("Pinned"), + ], + ids=[ + "stock-point3-body", + "stock-rigid6-body", + "one-end-huge-pretwist", + "one-end-nmodes", + "one-end-attachments", + "one-end-fixed-rod", + "one-end-pinned-rod", + ], +) +def test_one_end_torsion_gets_the_native_verdict(text, tmp_path): + try: + DeckFile.from_text(text) + python_accepts = True + except DeckFormatError: + python_accepts = False + # exit code 1 is an input refusal; 0 a run and 2 a solve failure after validation + assert python_accepts == (_native_exit(text, tmp_path) != 1) + + @pytest.mark.parametrize( ("channel", "message"), [ diff --git a/src/CableDyn_DeckDriver.f90 b/src/CableDyn_DeckDriver.f90 index 57a4214e..2fc338ce 100644 --- a/src/CableDyn_DeckDriver.f90 +++ b/src/CableDyn_DeckDriver.f90 @@ -113,7 +113,8 @@ MODULE CableDyn_DeckDriver CD_HermiteCable_Dyn_Element_Twist, CD_HermiteCable_Dyn_Coupling_Tension, & CD_HermiteCable_Dyn_Node_Torque, CD_HermiteCable_Dyn_End_Twist USE CableDyn_HermiteTorsion, ONLY: CD_HermiteTorsionType, CD_HermiteTorsion_Compliance, CD_HTORS_MAX_STEP, & - CD_HTORS_MAX_TWIST, CD_HermiteTorsion_Zeta_Damping + CD_HTORS_MAX_TWIST, CD_HermiteTorsion_Zeta_Damping, CD_HermiteTorsion_Line, & + CD_HermiteTorsion_Unwrap, CD_HermiteTorsion_Element_Stretch, CD_HTORS_OK USE CableDyn_EndConnection, ONLY: CD_ENDCONN_PINNED, CD_ENDCONN_FINITE, CD_ENDCONN_RIGID USE CableDyn_Vessel, ONLY: CD_VesselRAOType, CD_Vessel_Euler_DCM, CD_Vessel_Euler_Angular, & CD_Vessel_Point_Kinematics, CD_Vessel_RAO_Set, CD_Vessel_RAO_Eval, & @@ -215,6 +216,11 @@ MODULE CableDyn_DeckDriver PUBLIC :: CD_Rigid6_ScatterHostPoints, CD_Rigid6_HostWrench, CD_Rigid6_Stage, CD_Rigid6_Unstage PUBLIC :: CD_Rigid6_StartAccelerations, CD_Rod_StartAccelerations PUBLIC :: CD_RodRuntimeType + ! Prescribed motion of a standalone mixed deck: the aggregate owns the schedule the standalone + ! driver marches it with (opaque; MotionTable/DeckPoint stay private). + PUBLIC :: CD_MotionRuntimeType + PUBLIC :: CD_Motion_Active, CD_Motion_NColumns, CD_Motion_Has_Rotation, CD_Motion_Has_Roll + PUBLIC :: CD_Motion_Kinematics, CD_Motion_Deck_Positions, CD_Motion_End PUBLIC :: CD_Init_Deck_Aggregate_Rod, CD_Step_Aggregate_Rod PUBLIC :: CD_Rod_NRods, CD_Rod_Snapshot, CD_Rod_Restore, CD_Rod_End PUBLIC :: CD_Rod_MirrorSize, CD_Rod_Get_States, CD_Rod_Set_States, CD_Rod_Apply_States @@ -285,11 +291,10 @@ MODULE CableDyn_DeckDriver CHARACTER(*), PARAMETER :: INSPECTION_NOTE = ' Output contains only committed states and is for inspection only.' ! a line restrained in torsion on an entry whose caller does not turn the fairlead frame CHARACTER(*), PARAMETER :: TORSION_NEEDS_ORIENTATION = 'a line restrained in torsion needs a host that '// & - 'turns its fairlead frame: coupled OpenFAST and FAST.Farm runs do, and a C API host '// & - 'initialised with CableDyn_InitDeckRotating, while CableDyn_InitDeck/InitDeckAt '// & - 'and a standalone deck that mixes EI = 0 and finite-EI lines without a BODY move '// & - 'the line ends by translation only (with a BODY such a deck runs on the multibody '// & - 'route, which supports torsion); set TorsStiffness Free in every END CONNECTIONS row' + 'turns its fairlead frame: coupled OpenFAST and FAST.Farm runs do, as does the '// & + 'standalone driver and a C API host initialised with CableDyn_InitDeckRotating, '// & + 'while CableDyn_InitDeck/InitDeckAt move the line ends by translation only; set '// & + 'TorsStiffness Free in every END CONNECTIONS row' CHARACTER(*), PARAMETER :: TORSION_NEEDS_FORCE_BLEND = 'torsion in a dynamic run needs the force-blended '// & 'generalised-alpha (OPTION alpha_force_blend True)' CHARACTER(*), PARAMETER :: CONTROL_NEEDS_FORCE_BLEND = 'active line control of a finite-EI line needs the '// & @@ -492,6 +497,12 @@ MODULE CableDyn_DeckDriver ! Smallest |Nx x Ez| / |Nx| accepted for a reference normal (about 0.06 degrees off Ez). REAL(wp), PARAMETER :: TORS_NX_PARALLEL_TOL = 1.0e-3_wp REAL(wp), PARAMETER :: DEG2RAD_TORS = 3.14159265358979323846264338327950288_wp/180.0_wp + ! A finite-EI line with a bending or torsional END CONNECTION whose End B is a rod end (also a + ! line between two rods, a J-tube to a J-tube): the cable holds End B at a Fixed point only. + CHARACTER(*), PARAMETER :: ROD_END_B_NOTE = ' ends (End B) on a rod end: a line between two rods is not '// & + 'supported in this build (the cable holds its End B at a Fixed point only); for a '// & + 'Fixed rod, end the line on a Fixed point at the rod end''s position (its force then '// & + 'stays out of that rod''s Rod loads)' TYPE :: DeckLine INTEGER :: id = 0, nodeA = 0, nodeB = 0 @@ -513,11 +524,16 @@ MODULE CableDyn_DeckDriver ! Torsional end restraint of the optional END CONNECTIONS columns (End A, End B): mode ! TORS_FREE (default), TORS_RIGID or TORS_FINITE with stiffness tors_k [N m/rad]; tors_nx the ! unit zero-twist reference normal in the frame of Ez (perpendicular to Ez); tors_pretwist - ! the roll of the end frame about Ez [rad]. Torsion is active only with both ends restrained. + ! the roll of the end frame about Ez [rad]. Torsion is solved with both ends restrained, or + ! with one (line_torsion_active): tors_free_end is then the deck end free in torsion (1 = End + ! A, 2 = End B; resolve_one_end_torsion, which zeroes its Pretwist), 0 otherwise; tors_note + ! says why a line restrained at one end only is not solved in torsion. INTEGER :: tors_mode(2) = TORS_FREE REAL(wp) :: tors_k(2) = CD_ZERO REAL(wp) :: tors_nx(3, 2) = CD_ZERO REAL(wp) :: tors_pretwist(2) = CD_ZERO + INTEGER :: tors_free_end = 0 + CHARACTER(200) :: tors_note = '' INTEGER :: deck_line = 0 ! deck file line of the row, for error messages ! True when the anchor-first swap (normalize_stock_endpoint_order) exchanged the two ends: ! the deck's written NodeB (MoorDyn's AttachB) is then End A, otherwise End B. Active line @@ -1042,6 +1058,25 @@ MODULE CableDyn_DeckDriver TYPE(RodState), ALLOCATABLE :: stage_rods(:) END TYPE + !> Opaque prescribed-motion schedule of a standalone mixed deck, which the standalone driver + !> marches on the coupled aggregate: the deck's motionFile or vesselMotion table (read by + !> CD_Init_Deck_Aggregate with prescribed_motion) and, per aggregate moving column, the + !> Coupled/Vessel point that drives it. CD_Motion_Kinematics returns one grid row of the + !> moving surface: the point translations, the vessel rotation of a vesselMotion table (the + !> orientation the end connection and torsion frames turn with) and the motionFile roll column. + TYPE :: CD_MotionRuntimeType + PRIVATE + LOGICAL :: active = .FALSE. + TYPE(MotionTable) :: motion + ! per aggregate moving column: the motion-table point that drives it, and its deck position + INTEGER, ALLOCATABLE :: col_point(:) + REAL(wp), ALLOCATABLE :: col_pos(:, :) + ! per aggregate moving column: the column takes the roll column of its point (the moving + ! End A of a finite-EI line restrained in torsion at both ends, as on the standalone + ! cubic-Hermite route) + LOGICAL, ALLOCATABLE :: col_roll(:) + END TYPE + TYPE :: FiniteDeckModel TYPE(CD_FiniteEIModelType) :: model INTEGER :: n_elem = 0 @@ -1180,6 +1215,9 @@ MODULE CableDyn_DeckDriver ! Range graphs (LINES flag r, standalone only) and the touchdown references of the ! TDP channels, keyed by deck line id and fixed at the converged initial state. TYPE(CD_RangeSet) :: ranges + ! The deck's own prescribed motion (prescribed_motion: the standalone driver), in the + ! aggregate moving-set order; inactive otherwise. + TYPE(CD_MotionRuntimeType) :: motion END TYPE CONTAINS @@ -1853,7 +1891,8 @@ RECURSIVE SUBROUTINE build_one_hermite_cable(ln, sections, types, points, opts, REAL(wp), ALLOCATABLE :: ei_cable(:) REAL(wp) :: att_offset ! Condensed torsion (both END CONNECTIONS rows torsionally restrained): solved as the last - ! static load stage on the final mesh, then installed in the cable. + ! static load stage on the final mesh, then installed in the cable; a line restrained at one + ! end only (ln%tors_free_end) has no static torque and installs its free end. LOGICAL :: tors_line TYPE(CD_HermiteTorsionType) :: tors ! the residual tolerance the accepted torsion stage met (torsion_note) @@ -2001,9 +2040,10 @@ RECURSIVE SUBROUTINE build_one_hermite_cable(ln, sections, types, points, opts, ABS(endconn_d0_local(2, i)) > 64.0_wp*EPSILON(CD_ONE)) require_3d_static = .TRUE. END DO ! A twisted line leaves the plane of its chord (the torque bends it out of plane), so a - ! torsional line is solved in 3D from the start. + ! torsional line is solved in 3D from the start; a line free in torsion at one end carries no + ! static torque, so its statics are those of the line without torsion. tors_line = line_torsion_active(ln) - IF (tors_line) require_3d_static = .TRUE. + IF (tors_line .AND. ln%tors_free_end == 0) require_3d_static = .TRUE. ! A current with a component across the vertical plane of the chord pushes the line out ! of that plane, which the dynamics (endpoints held, every other DOF free) follow: the ! static equilibrium is then solved in 3D as well. @@ -3231,7 +3271,13 @@ RECURSIVE SUBROUTINE build_one_hermite_cable(ln, sections, types, points, opts, CALL fail(ErrStat, ErrMsg, 'finite-EI cable end-connection wiring failed: '//TRIM(em)); RETURN END IF END IF - IF (tors_line) THEN + IF (tors_line .AND. ln%tors_free_end == 1) THEN + ! a free End A: its torsion frame is a gauge, which no parent turns + CALL CD_HFMF_Set_Torsion(cable, tors, es, em) + IF (es /= CD_HFMF_OK) THEN + CALL fail(ErrStat, ErrMsg, 'finite-EI cable torsion wiring failed: '//TRIM(em)); RETURN + END IF + ELSE IF (tors_line) THEN ! The End A torsion frame (director -Ez, reference normal Nx, in the frame of Ez) is held ! by End A's parent and turns with it in the dynamics, whatever the bending connection. BLOCK @@ -3388,11 +3434,15 @@ SUBROUTINE torsion_stage(est, emt, f_nodal) !! f_nodal: the stage of a line with ATTACHMENTS, after the attachment polish (the final !! mesh then is l0, with the bare weights w_bare and the deck mesh l0_deck_att), with the !! attachments' lumped loads. + !! A line restrained at one end only (ln%tors_free_end) carries no static torque: the + !! untwisted state is its static state, Theta is evaluated there, and the free end's frame + !! is a gauge (end_free): the end's connection direction, or its static tangent at a + !! bending-pinned end, with the restrained end's normal made normal to it. INTEGER, INTENT(OUT) :: est CHARACTER(*), INTENT(OUT) :: emt REAL(wp), INTENT(IN), OPTIONAL :: f_nodal(:) REAL(wp) :: nvec(3), dvec(3), tol_t - INTEGER :: k, attempt + INTEGER :: k, attempt, kf LOGICAL :: nodal_loads TYPE(CD_HermiteTorsionType) :: tors0 ! the deck mesh, the final mesh and its per-element arrays of this stage @@ -3439,7 +3489,11 @@ SUBROUTINE torsion_stage(est, emt, f_nodal) END IF END DO END IF + ! the free end, internal end 3 - tors_free_end (0: none) + kf = 0 + IF (ln%tors_free_end > 0) kf = 3 - ln%tors_free_end DO k = 1, 2 + IF (k == kf) CYCLE dvec = endconn_d0_local(:, k)/NORM2(endconn_d0_local(:, k)) IF (k == 1) THEN nvec = ln%tors_nx(:, 2) @@ -3460,6 +3514,10 @@ SUBROUTINE torsion_stage(est, emt, f_nodal) IF (ln%tors_mode(2) == TORS_FINITE) tors%end_compliance(1) = CD_ONE/ln%tors_k(2) IF (ln%tors_mode(1) == TORS_FINITE) tors%end_compliance(2) = CD_ONE/ln%tors_k(1) tors%phi = ln%tors_pretwist(2) - ln%tors_pretwist(1) + IF (kf > 0) THEN + CALL one_end_state(kf, lf, est, emt) + RETURN + END IF ! Rotating a buckled shape about a common clamp axis is an exact symmetry only without ! weight or current, with both ends clamped on one axis. nodal_loads = .FALSE. @@ -3508,8 +3566,10 @@ END SUBROUTINE torsion_stage SUBROUTINE torsion_note() !! The notes of the accepted torsion stage: a residual floor above the tolerance, and the - !! imposed twist and torque. + !! imposed twist and torque. A line restrained at one end only solves no twist stage; its + !! note is one_end_state's. CHARACTER(320) :: tnote + IF (ln%tors_free_end > 0) RETURN IF (tors_tol_used > static_tol_target) THEN WRITE (tnote, '(A,I0,A,ES9.2,A,ES9.2)') 'line ', ln%id, ': torsion static residual floor above the '// & 'tolerance ', static_tol_target, '; twisted equilibrium accepted at ', tors_tol_used @@ -3595,6 +3655,65 @@ SUBROUTINE twisted_attachment_checks(est, emt) END IF END SUBROUTINE twisted_attachment_checks + SUBROUTINE one_end_state(kf, lf, est, emt) + !! torsion_stage of a line restrained at one end only (internal end 3 - kf restrained, the + !! other set up here): the free end's gauge frame, Theta at the untwisted static state + !! (has_theta, no torque), and the note of the free end's static turn, the summed element + !! twists -sum (K/GJ)(l_e - l0_e) of torque-tension coupling (Twist). lf: the stage's + !! final mesh (l0_am, or l0 after the attachment polish of a line with ATTACHMENTS). + INTEGER, INTENT(IN) :: kf + REAL(wp), INTENT(IN) :: lf(:) + INTEGER, INTENT(OUT) :: est + CHARACTER(*), INTENT(OUT) :: emt + REAL(wp), ALLOCATABLE :: gth(:) + REAL(wp) :: raw, twist, ax(3), nvec(3), dvec(3) + INTEGER :: node, e, ks + CHARACTER(320) :: tnote + est = CD_DECKDRV_OK + emt = '' + IF (NORM2(endconn_d0_local(:, kf)) > CD_ZERO .AND. endconn_mode(kf) /= CD_ENDCONN_PINNED) THEN + dvec = endconn_d0_local(:, kf)/NORM2(endconn_d0_local(:, kf)) + ELSE + node = MERGE(1, SIZE(lf) + 1, kf == 1) + dvec = q_static(6*node - 2:6*node)/NORM2(q_static(6*node - 2:6*node)) + END IF + nvec = tors%ends(:, 2*(3 - kf)) + nvec = nvec - DOT_PRODUCT(nvec, dvec)*dvec + IF (NORM2(nvec) < TORS_NX_PARALLEL_TOL) THEN + ! the restrained normal along this end's director: any normal of it is the gauge + ax = CD_ZERO + ax(MINLOC(ABS(dvec), DIM=1)) = CD_ONE + nvec = ax - DOT_PRODUCT(ax, dvec)*dvec + END IF + tors%ends(:, 2*kf - 1) = dvec + tors%ends(:, 2*kf) = nvec/NORM2(nvec) + tors%end_free(kf) = .TRUE. + ALLOCATE (gth(SIZE(q_static))) + CALL CD_HermiteTorsion_Line(q_static, lf, tors%ends, raw, gth, ks, emt, couple=tors%couple, & + quadrature_order=tors%quadrature_order) + IF (ks /= CD_HTORS_OK) THEN + est = CD_DECKDRV_SOLVEFAIL + emt = 'torsion at the static state: '//TRIM(emt) + RETURN + END IF + tors%theta = CD_HermiteTorsion_Unwrap(raw, CD_ZERO) + tors%has_theta = .TRUE. + tors%torque = CD_ZERO + twist = CD_ZERO + IF (ALLOCATED(tors%couple)) THEN + DO e = 1, SIZE(lf) + twist = twist - tors%couple(e)*(CD_HermiteTorsion_Element_Stretch(q_static(6*e - 5:6*e + 6), lf(e), & + tors%quadrature_order) - lf(e)) + END DO + END IF + ! Twist is the turn of End B relative to End A, right-handed about the End A -> End B + ! tangent: a free End B turns by +Twist, a free End A by -Twist + WRITE (tnote, '(A,I0,A,A,A,ES12.5,A)') 'line ', ln%id, ': torsion restrained at End ', & + MERGE('B', 'A', ln%tors_free_end == 1), ' only: no static torque; Twist = ', twist*45.0_wp/QUARTER_PI, & + ' deg (End B relative to End A, right-handed about the End A -> End B tangent)' + CALL report_note(tnote) + END SUBROUTINE one_end_state + SUBROUTINE bow_route(done, why) !! A line too long for its span whose anchor walk failed or reached an equilibrium the !! audit rejects (an arch facing the anchor that has looped through itself): trace the @@ -7124,7 +7243,8 @@ END SUBROUTINE CD_Init_Deck_HermiteCable SUBROUTINE CD_Init_Deck_Aggregate(deck_path, dt, agg, ErrStat, ErrMsg, env_gravity, env_rho_water, env_wtrdpth, & ptfm_init, external_fluid, coupled_positions, & n_turbines, turbine_ref_pos, farm_ptfm_init, forbid_deck_ambient, run_tmax, & - range_files, host_orientation, static_current) + range_files, host_orientation, static_current, prescribed_motion, & + static_run) !! Parse a MIXED deck ONCE and partition its lines into {EI=0 mooring} and !! {finite-EI cable}, returning the raw parts the OpenFAST aggregate facade wraps: !! the EI=0 mooring SYSTEM built from the mooring subset (over ALL deck points, the @@ -7138,8 +7258,8 @@ SUBROUTINE CD_Init_Deck_Aggregate(deck_path, dt, agg, ErrStat, ErrMsg, env_gravi !! Scope: EI=0 lines with Fixed/Coupled/Vessel/Connect/Free points, Point3 buoys, Rigid6 !! bodies and RODs (free, fixed, pinned, host-coupled or host-pinned), CONTROL, FAILURE and !! FAST.Farm turbines, plus finite-EI cables. Fails closed with a clear message on: a - !! motionFile (the host drives the coupled boundary); deck waves (the host supplies wave - !! kinematics); a deck current on + !! motionFile (the host drives the coupled boundary; prescribed_motion excepted); deck + !! waves (the host supplies wave kinematics); a deck current on !! a deck with a finite-EI cable, a Rigid6 body or a rod, under a host fluid field, or in !! FAST.Farm mode; a deck with a finite-EI cable that also carries Free/Connect dynamic !! points. A deck current on any other deck is a steady field applied through the lines. @@ -7192,9 +7312,10 @@ SUBROUTINE CD_Init_Deck_Aggregate(deck_path, dt, agg, ErrStat, ErrMsg, env_gravi ! mixed route); a coupled host does not, so the flag fails closed there. LOGICAL, INTENT(IN), OPTIONAL :: range_files ! host_orientation: the caller passes each moving point's orientation with every update - ! (the OpenFAST and FAST.Farm shells), which turns the fairlead frame of a finite-EI line - ! restrained in torsion. Without it (the C API, the standalone mixed route) a deck with - ! torsion columns fails closed rather than holding that frame fixed. + ! (the OpenFAST and FAST.Farm shells, and the standalone mixed route, which holds the frame + ! or turns it with its vesselMotion table), which turns the fairlead frame of a finite-EI + ! line restrained in torsion. Without it (the C API) a deck with torsion columns fails + ! closed rather than holding that frame fixed. LOGICAL, INTENT(IN), OPTIONAL :: host_orientation ! static_current (4, n): the host's steady current as a depth profile, rows z (ascending), ! ux, uy, uz -- the OpenFAST shell's SeaState CurrMod 1 current at SeaState's grid levels. @@ -7204,9 +7325,17 @@ SUBROUTINE CD_Init_Deck_Aggregate(deck_path, dt, agg, ErrStat, ErrMsg, env_gravi ! dynamics take the host field alone: the profile goes into a copy of the options that ! only the static builders see. REAL(wp), INTENT(IN), OPTIONAL :: static_current(:, :) + ! prescribed_motion: the caller marches the deck's own motionFile or vesselMotion table + ! (the standalone driver on a mixed deck of lines between Fixed/Coupled/Vessel points): + ! the table is read into agg%motion in the moving-set order instead of being refused. + LOGICAL, INTENT(IN), OPTIONAL :: prescribed_motion + ! static_run: the caller marches no step (the standalone driver's TMax = 0 run), so a line + ! restrained in torsion needs no force-blended step, as on the single-line standalone route; + ! a coupled host always marches. + LOGICAL, INTENT(IN), OPTIONAL :: static_run INTEGER :: nturb - LOGICAL :: host_turns + LOGICAL :: host_turns, own_motion, dynamic_points, static_only TYPE(DeckLineType), ALLOCATABLE :: types(:) TYPE(DeckBody), ALLOCATABLE :: bodies(:) TYPE(DeckRodType), ALLOCATABLE :: rod_types(:) @@ -7239,14 +7368,18 @@ SUBROUTINE CD_Init_Deck_Aggregate(deck_path, dt, agg, ErrStat, ErrMsg, env_gravi CALL parse_deck(deck_path, types, bodies, rod_types, rods, points, lines, sections, opts, channels, & ErrStat, ErrMsg, caller_driven=.TRUE., env_gravity=env_gravity, & env_rho_water=env_rho_water, env_wtrdpth=env_wtrdpth, allow_turbine=.TRUE., & - failures=fails, controls=ctrls, run_tmax=run_tmax, host_coupled_objects=.TRUE.) + failures=fails, controls=ctrls, run_tmax=run_tmax, host_coupled_objects=.TRUE., & + static_run=static_run) IF (ErrStat == CD_DECKDRV_OK) THEN host_turns = .FALSE. IF (PRESENT(host_orientation)) host_turns = host_orientation IF (deck_has_torsion_columns(lines) .AND. .NOT. host_turns) THEN CALL fail(ErrStat, ErrMsg, TORSION_NEEDS_ORIENTATION); RETURN END IF - IF (ANY([(line_torsion_active(lines(i)), i=1, SIZE(lines))]) .AND. .NOT. opts%alpha_force_blend) THEN + static_only = .FALSE. + IF (PRESENT(static_run)) static_only = static_run + IF (ANY([(line_torsion_active(lines(i)), i=1, SIZE(lines))]) .AND. .NOT. opts%alpha_force_blend .AND. & + .NOT. static_only) THEN CALL fail(ErrStat, ErrMsg, TORSION_NEEDS_FORCE_BLEND); RETURN END IF END IF @@ -7498,10 +7631,22 @@ SUBROUTINE CD_Init_Deck_Aggregate(deck_path, dt, agg, ErrStat, ErrMsg, env_gravi n_host_rod = COUNT(rods%rod_type == 'coupled' .OR. rods%rod_type == 'vessel' .OR. & rods%rod_type == 'coupledpinned') n_host_body = COUNT(bodies%host_coupled .OR. bodies%host_pinned) - IF (opts%has_motion_file) THEN + own_motion = .FALSE. + IF (PRESENT(prescribed_motion)) own_motion = prescribed_motion .AND. opts%has_motion_file + IF (opts%has_motion_file .AND. .NOT. own_motion) THEN CALL fail(ErrStat, ErrMsg, 'CD_Init_Deck_Aggregate: the coupled boundary is driven by the host, '// & 'not a deck motionFile; remove the motionFile OPTION'); RETURN END IF + IF (own_motion) THEN + ! the deck's table moves the Coupled/Vessel line points; the caller marches it from the + ! deck pose (no host placement) over lines between Fixed/Coupled/Vessel points only + dynamic_points = deck_has_dynamic_points(points) + IF (dynamic_points .OR. SIZE(bodies) > 0 .OR. n_rod > 0 .OR. nturb > 0 .OR. & + PRESENT(ptfm_init) .OR. PRESENT(coupled_positions) .OR. PRESENT(farm_ptfm_init)) THEN + CALL fail(ErrStat, ErrMsg, 'CD_Init_Deck_Aggregate: a deck-prescribed motion drives lines between '// & + 'Fixed/Coupled/Vessel points only, from the deck pose'); RETURN + END IF + END IF IF (SIZE(lines) == 0) THEN CALL fail(ErrStat, ErrMsg, 'CD_Init_Deck_Aggregate: deck defines no lines'); RETURN END IF @@ -7923,6 +8068,13 @@ SUBROUTINE CD_Init_Deck_Aggregate(deck_path, dt, agg, ErrStat, ErrMsg, env_gravi IF (ErrStat /= CD_DECKDRV_OK) THEN CALL CD_End_Deck_Aggregate(agg); RETURN END IF + ! The deck's own prescribed motion over the same moving-set order. + IF (own_motion) THEN + CALL build_aggregate_motion(points, lines, is_fin, opts, agg%motion, ErrStat, ErrMsg) + IF (ErrStat /= CD_DECKDRV_OK) THEN + CALL CD_End_Deck_Aggregate(agg); RETURN + END IF + END IF ! Range graphs and touchdown channels: fix the TDP references at the converged state. BLOCK @@ -8483,10 +8635,204 @@ SUBROUTINE CD_End_Deck_Aggregate(agg) agg%has_rod = .FALSE. agg%has_point3 = .FALSE. CALL CD_Range_End(agg%ranges) + CALL CD_Motion_End(agg%motion) agg%gravity = CD_ZERO agg%rho_water = CD_ZERO END SUBROUTINE CD_End_Deck_Aggregate + SUBROUTINE build_aggregate_motion(points, lines, is_fin, opts, rt, ErrStat, ErrMsg) + !! The deck's motionFile or vesselMotion table, keyed to the aggregate moving-set order (the + !! enumeration of apply_coupled_positions: the system's BOUND Coupled/Vessel points in deck + !! POINT order, then one coupled fairlead per finite-EI cable in deck LINE order). The roll + !! column of a motionFile drives the moving End A of a line solved in torsion whose End A is + !! restrained, as on the standalone cubic-Hermite route (check_motion_roll_lines). + TYPE(DeckPoint), INTENT(IN) :: points(:) + TYPE(DeckLine), INTENT(IN) :: lines(:) + LOGICAL, INTENT(IN) :: is_fin(:) + TYPE(DeckOptions), INTENT(IN) :: opts + TYPE(CD_MotionRuntimeType), INTENT(INOUT) :: rt + INTEGER, INTENT(OUT) :: ErrStat + CHARACTER(*), INTENT(OUT) :: ErrMsg + INTEGER :: i, l, n, pass, ip + LOGICAL :: bound_ei0 + + ErrStat = CD_DECKDRV_OK + ErrMsg = '' + CALL CD_Motion_End(rt) + CALL read_motion_file(opts%motion_file, points, opts, rt%motion, ErrStat, ErrMsg, & + with_roll=ANY([(line_torsion_active(lines(i)), i=1, SIZE(lines))])) + IF (ErrStat /= CD_DECKDRV_OK) RETURN + CALL check_motion_roll_lines(rt%motion, lines, ErrStat, ErrMsg) + IF (ErrStat /= CD_DECKDRV_OK) RETURN + ! pass 1 counts the moving columns, pass 2 fills them + DO pass = 1, 2 + n = 0 + DO i = 1, SIZE(points) + SELECT CASE (TRIM(points(i)%ptype)) + CASE ('coupled', 'vessel') + bound_ei0 = .FALSE. + DO l = 1, SIZE(lines) + IF (is_fin(l)) CYCLE + IF (lines(l)%nodeA == points(i)%id .OR. lines(l)%nodeB == points(i)%id) THEN + bound_ei0 = .TRUE.; EXIT + END IF + END DO + IF (bound_ei0) THEN + n = n + 1 + IF (pass == 2) CALL set_column(n, i, .FALSE.) + END IF + END SELECT + END DO + DO l = 1, SIZE(lines) + IF (.NOT. is_fin(l)) CYCLE + DO i = 1, SIZE(points) + IF (points(i)%id /= lines(l)%nodeA .AND. points(i)%id /= lines(l)%nodeB) CYCLE + SELECT CASE (TRIM(points(i)%ptype)) + CASE ('coupled', 'vessel') + n = n + 1 + IF (pass == 2) CALL set_column(n, i, rt%motion%has_roll .AND. line_torsion_at_a(lines(l)) .AND. & + points(i)%id == lines(l)%nodeA) + END SELECT + END DO + END DO + IF (pass == 1) ALLOCATE (rt%col_point(n), rt%col_pos(3, n), rt%col_roll(n)) + END DO + IF (ErrStat /= CD_DECKDRV_OK) RETURN + rt%active = .TRUE. + + CONTAINS + + SUBROUTINE set_column(col, ipt, takes_roll) + INTEGER, INTENT(IN) :: col, ipt + LOGICAL, INTENT(IN) :: takes_roll + ip = find_motion_point(rt%motion, points(ipt)%id) + IF (ip < 1) THEN + CALL fail(ErrStat, ErrMsg, 'the prescribed motion has no rows for point '//TRIM(int_to_str(points(ipt)%id))) + ip = 1 + END IF + rt%col_point(col) = ip + rt%col_pos(:, col) = points(ipt)%pos + rt%col_roll(col) = takes_roll + END SUBROUTINE set_column + END SUBROUTINE build_aggregate_motion + + LOGICAL FUNCTION CD_Motion_Active(rt) RESULT(active) + !! The schedule holds the deck's prescribed motion. + TYPE(CD_MotionRuntimeType), INTENT(IN) :: rt + active = rt%active + END FUNCTION CD_Motion_Active + + INTEGER FUNCTION CD_Motion_NColumns(rt) RESULT(n) + !! Moving columns the schedule drives (0 when inactive). + TYPE(CD_MotionRuntimeType), INTENT(IN) :: rt + n = 0 + IF (rt%active) n = SIZE(rt%col_point) + END FUNCTION CD_Motion_NColumns + + LOGICAL FUNCTION CD_Motion_Has_Rotation(rt) RESULT(has) + !! A vesselMotion table: the moving points turn with the vessel. + TYPE(CD_MotionRuntimeType), INTENT(IN) :: rt + has = .FALSE. + IF (rt%active) has = rt%motion%has_rot + END FUNCTION CD_Motion_Has_Rotation + + LOGICAL FUNCTION CD_Motion_Has_Roll(rt) RESULT(has) + !! A motionFile roll column drives some column (a line restrained in torsion). + TYPE(CD_MotionRuntimeType), INTENT(IN) :: rt + has = .FALSE. + IF (rt%active) has = ANY(rt%col_roll) + END FUNCTION CD_Motion_Has_Roll + + SUBROUTINE CD_Motion_Deck_Positions(rt, position, ErrStat, ErrMsg) + !! Deck position of the point that drives each moving column (3, n): the caller checks the + !! column map against its own moving surface at the static state. + TYPE(CD_MotionRuntimeType), INTENT(IN) :: rt + REAL(wp), INTENT(OUT) :: position(:, :) + INTEGER, INTENT(OUT) :: ErrStat + CHARACTER(*), INTENT(OUT) :: ErrMsg + position = CD_ZERO + ErrStat = CD_DECKDRV_BADINPUT + IF (.NOT. rt%active) THEN + ErrMsg = 'CD_Motion_Deck_Positions: no prescribed motion'; RETURN + END IF + IF (SIZE(position, 1) /= 3 .OR. SIZE(position, 2) /= SIZE(rt%col_point)) THEN + ErrMsg = 'CD_Motion_Deck_Positions: position must be shaped (3, n_columns)'; RETURN + END IF + position = rt%col_pos + ErrStat = CD_DECKDRV_OK + ErrMsg = '' + END SUBROUTINE CD_Motion_Deck_Positions + + SUBROUTINE CD_Motion_Kinematics(rt, time_index, position, velocity, acceleration, orientation, angular_velocity, & + angular_acceleration, roll, ErrStat, ErrMsg) + !! Grid row time_index (1 = t 0) of the moving surface, columns in the aggregate moving-set + !! order: position, velocity and acceleration of each driving point (3, n); the + !! global-to-parent DCM (3, 3, n) and the global-axis angular velocity and acceleration + !! (3, n) -- the vessel's under a vesselMotion table, the identity and zero otherwise, so a + !! motionFile turns no frame -- and the motionFile roll [rad] of each column that takes one + !! (zero elsewhere). Allocation free. + TYPE(CD_MotionRuntimeType), INTENT(IN) :: rt + INTEGER, INTENT(IN) :: time_index + REAL(wp), INTENT(OUT) :: position(:, :), velocity(:, :), acceleration(:, :) + REAL(wp), INTENT(OUT) :: orientation(:, :, :), angular_velocity(:, :), angular_acceleration(:, :), roll(:) + INTEGER, INTENT(OUT) :: ErrStat + CHARACTER(*), INTENT(OUT) :: ErrMsg + INTEGER :: col, ip, n + + ErrStat = CD_DECKDRV_BADINPUT + ErrMsg = '' + IF (.NOT. rt%active) THEN + ErrMsg = 'CD_Motion_Kinematics: no prescribed motion'; RETURN + END IF + n = SIZE(rt%col_point) + IF (SIZE(position, 1) /= 3 .OR. SIZE(position, 2) /= n .OR. SIZE(velocity, 1) /= 3 .OR. & + SIZE(velocity, 2) /= n .OR. SIZE(acceleration, 1) /= 3 .OR. SIZE(acceleration, 2) /= n .OR. & + SIZE(orientation, 1) /= 3 .OR. SIZE(orientation, 2) /= 3 .OR. SIZE(orientation, 3) /= n .OR. & + SIZE(angular_velocity, 1) /= 3 .OR. SIZE(angular_velocity, 2) /= n .OR. & + SIZE(angular_acceleration, 1) /= 3 .OR. SIZE(angular_acceleration, 2) /= n .OR. SIZE(roll) /= n) THEN + ErrMsg = 'CD_Motion_Kinematics: arrays must be shaped (3, n), (3, 3, n) and (n) over the moving columns' + RETURN + END IF + IF (time_index < 1 .OR. time_index > rt%motion%n_time) THEN + ErrMsg = 'CD_Motion_Kinematics: time index '//TRIM(int_to_str(time_index))//' outside the motion grid of '// & + TRIM(int_to_str(rt%motion%n_time))//' rows' + RETURN + END IF + DO col = 1, n + ip = rt%col_point(col) + position(:, col) = rt%motion%q(:, ip, time_index) + velocity(:, col) = rt%motion%v(:, ip, time_index) + acceleration(:, col) = rt%motion%a(:, ip, time_index) + IF (rt%motion%has_rot) THEN + ! the vessel-to-global rotation R: the parent DCM is its transpose (global to vessel) + orientation(:, :, col) = TRANSPOSE(rt%motion%rot(:, :, time_index)) + angular_velocity(:, col) = rt%motion%omega(:, time_index) + angular_acceleration(:, col) = rt%motion%alpha(:, time_index) + ELSE + orientation(:, :, col) = CD_ZERO + orientation(1, 1, col) = CD_ONE + orientation(2, 2, col) = CD_ONE + orientation(3, 3, col) = CD_ONE + angular_velocity(:, col) = CD_ZERO + angular_acceleration(:, col) = CD_ZERO + END IF + roll(col) = CD_ZERO + IF (rt%col_roll(col)) roll(col) = rt%motion%roll(ip, time_index) + END DO + ErrStat = CD_DECKDRV_OK + END SUBROUTINE CD_Motion_Kinematics + + SUBROUTINE CD_Motion_End(rt) + !! Release the schedule. Idempotent. + TYPE(CD_MotionRuntimeType), INTENT(INOUT) :: rt + TYPE(MotionTable) :: empty + rt%motion = empty + IF (ALLOCATED(rt%col_point)) DEALLOCATE (rt%col_point) + IF (ALLOCATED(rt%col_pos)) DEALLOCATE (rt%col_pos) + IF (ALLOCATED(rt%col_roll)) DEALLOCATE (rt%col_roll) + rt%active = .FALSE. + END SUBROUTINE CD_Motion_End + SUBROUTINE CD_Run_Deck_Driver(deck_path, out_root, converged, ErrStat, ErrMsg) !! Parse a MoorDyn-style deck, run static IC and optional held-end dynamic march, !! write `.out`. @@ -8539,14 +8885,16 @@ SUBROUTINE run_deck_driver(deck_path, out_root, converged, ErrStat, ErrMsg) IF (ANY([(CD_Is_Line_Node_Channel(channels(j)), j=1, SIZE(channels))]) .OR. & ANY([(line_outputs_requested(lines(j)%outputs), j=1, SIZE(lines))])) & WRITE (output_unit, '(A)') ' Note: '//CD_LINE_NODE_NUMBERING_NOTE//'.' - ! Torsion (both ends of a line torsionally restrained) runs on the standalone cubic-Hermite - ! route and the multibody march, in statics and dynamics (quasi-static torsion: no torsional - ! inertia). One restrained end carries no torque (the other end is free to twist), so it is - ! noted and ignored. + ! Torsion (a line torsionally restrained at both ends, or at one with the other free to + ! twist) runs on the standalone cubic-Hermite route, the multibody march and the mixed + ! EI = 0 + finite-EI aggregate, in statics and in dynamics with the nodal twist's polar + ! inertia and the torque-tension coupling. A line restrained at one end only whose torsion + ! is not solved (resolve_one_end_torsion) is noted with the reason. DO li = 1, SIZE(lines) - IF (COUNT(lines(li)%tors_mode /= TORS_FREE) == 1) WRITE (output_unit, '(A)') ' Note: line '// & - TRIM(int_to_str(lines(li)%id))//' is torsionally restrained at one end only; with the other end free '// & - 'to twist it carries no torque, so no torsion is solved.' + IF (COUNT(lines(li)%tors_mode /= TORS_FREE) == 1 .AND. lines(li)%tors_free_end == 0 .AND. & + LEN_TRIM(lines(li)%tors_note) > 0) WRITE (output_unit, '(A)') ' Note: line '// & + TRIM(int_to_str(lines(li)%id))//' is torsionally restrained at one end only and its torsion is not '// & + 'solved: '//TRIM(lines(li)%tors_note)//'.' END DO ! rhoInf near 1 leaves the march without numerical dissipation of the modes dtM does not ! resolve (axial waves, slack-taut transitions). In an irregular sea a finite-EI lazy wave @@ -12062,7 +12410,8 @@ END SUBROUTINE solve_one_line SUBROUTINE parse_deck(path, types, bodies, rod_types, rods, points, lines, sections, opts, channels, & ErrStat, ErrMsg, caller_driven, env_gravity, env_rho_water, env_wtrdpth, & - allow_turbine, failures, controls, run_tmax, allow_static_finite_ei, host_coupled_objects) + allow_turbine, failures, controls, run_tmax, allow_static_finite_ei, host_coupled_objects, & + static_run) !! Sectioned MoorDyn-style parser. Sections: LINE TYPES / BODIES / ROD TYPES / RODS / !! POINTS / LINES / SECTIONS / OPTIONS / OUTPUTS (TABLE sections skip the column-name !! + units rows). Unsupported variants fail closed during validation. @@ -12098,6 +12447,10 @@ SUBROUTINE parse_deck(path, types, bodies, rod_types, rods, points, lines, secti ! host_coupled_objects: ONLY the CompMooring=5 aggregate drives Coupled/Vessel rods/bodies from its ! host mesh; every other entry point keeps the motionFile requirement. LOGICAL, INTENT(IN), OPTIONAL :: host_coupled_objects + ! static_run: a caller-driven deck whose caller marches no step (the standalone driver's + ! TMax = 0 run on the aggregate): a line restrained in torsion at one end is then resolved + ! as in a static run, needing no force-blended step (resolve_one_end_torsion) + LOGICAL, INTENT(IN), OPTIONAL :: static_run ! FAILURE rows. A deck DECLARING failures parsed by an entry point that does not ! consume them fails closed (never silently ignore a declared failure). TYPE(DeckFailure), ALLOCATABLE, INTENT(OUT), OPTIONAL :: failures(:) @@ -12119,7 +12472,7 @@ SUBROUTINE parse_deck(path, types, bodies, rod_types, rods, points, lines, secti INTEGER, ALLOCATABLE :: stf_lines(:) INTEGER :: n_stf CHARACTER(2*NAMELEN), ALLOCATABLE :: channel_keys(:) - LOGICAL :: ext_march, types_stock_cols, rodtypes_legacy_cols, turb_ok, static_finite_ok + LOGICAL :: ext_march, types_stock_cols, rodtypes_legacy_cols, turb_ok, static_finite_ok, tors_marched INTEGER :: unit, ios, section, nt, nb, nrt, nr, np, nlin, nsec, neq, nch, nfl, nct, nec, lineno CHARACTER(DECK_RECLEN) :: line ! list_safe_row output: every token may gain a pair of quotes @@ -12461,7 +12814,10 @@ SUBROUTINE parse_deck(path, types, bodies, rod_types, rods, points, lines, secti RETURN END IF END DO - CALL normalize_stock_endpoint_order(points, lines, sections) + CALL normalize_stock_endpoint_order(points, lines, sections, types) + tors_marched = ext_march + IF (PRESENT(static_run)) tors_marched = ext_march .AND. .NOT. static_run + CALL resolve_one_end_torsion(types, bodies, rods, points, lines, sections, opts, tors_marched) CALL finalize_and_validate(types, bodies, rod_types, rods, points, lines, sections, opts, channels, ext_march, & static_finite_ok, ErrStat, ErrMsg, channel_lines) IF (ErrStat == 0) CALL set_azimuth_ranges(points, lines) @@ -16816,7 +17172,7 @@ SUBROUTINE set_azimuth_ranges(points, lines) END DO END SUBROUTINE set_azimuth_ranges - SUBROUTINE normalize_stock_endpoint_order(points, lines, sections) + SUBROUTINE normalize_stock_endpoint_order(points, lines, sections, types) !! Stock MoorDyn decks write lines anchor (End A) -> fairlead (End B); the CableDyn !! deck convention is the reverse (End A = fairlead side, End B = anchor). When a !! line arrives in stock order -- NodeA a Fixed anchor, NodeB a Coupled/Vessel/ @@ -16827,12 +17183,17 @@ SUBROUTINE normalize_stock_endpoint_order(points, lines, sections) !! point ids are untouched. The normalization runs on dynamic-point decks too: their !! anchored Fixed<->Coupled legs carry the same stock-order convention (a clump-split !! farm deck's anchor legs would otherwise reach the builders reversed). + !! A finite-EI line (types given) from a Fixed NodeA to a rod end NodeB swaps too: such a + !! line runs only from the rod (End A, on the multibody march) to a Fixed End B, so the + !! stock row would otherwise stop. An EI = 0 line to a rod end keeps its written order. TYPE(DeckPoint), INTENT(IN) :: points(:) TYPE(DeckLine), INTENT(INOUT) :: lines(:) TYPE(DeckSection), INTENT(INOUT) :: sections(:) + TYPE(DeckLineType), INTENT(IN), OPTIONAL :: types(:) INTEGER :: i, ia, ib, tmp, mode_tmp REAL(wp) :: k_tmp, ez_tmp(3) CHARACTER(NAMELEN) :: ta, tb + LOGICAL :: rod_b DO i = 1, SIZE(lines) ia = find_point(points, lines(i)%nodeA) ib = find_point(points, lines(i)%nodeB) @@ -16849,8 +17210,12 @@ SUBROUTINE normalize_stock_endpoint_order(points, lines, sections) ! that line is already in CableDyn order (End A = upper end) and is left as written, ! so the internal anchor->fairlead model keeps its fairlead above its anchor. (Both ! positions are global there; Coupled/Vessel/Body points may be body-relative.) + rod_b = .FALSE. + IF (PRESENT(types) .AND. TRIM(ta) == 'fixed') THEN + IF (is_rod_point_type(tb)) rod_b = finite_ei_by_name(lines(i)%id) + END IF IF (TRIM(ta) == 'fixed' .AND. (TRIM(tb) == 'coupled' .OR. TRIM(tb) == 'vessel' .OR. & - starts_with(TRIM(tb), 'body') .OR. & + starts_with(TRIM(tb), 'body') .OR. rod_b .OR. & ((TRIM(tb) == 'free' .OR. TRIM(tb) == 'connect') .AND. & points(ia)%pos(3) <= points(ib)%pos(3)))) THEN tmp = lines(i)%nodeA @@ -16888,6 +17253,19 @@ SUBROUTINE normalize_stock_endpoint_order(points, lines, sections) CALL reverse_line_sections(sections, lines(i)%id) END IF END DO + CONTAINS + LOGICAL FUNCTION finite_ei_by_name(line_id) RESULT(fin) + !! line_is_finite_ei before the SECTIONS line types are resolved (by name). + INTEGER, INTENT(IN) :: line_id + INTEGER :: j, it + fin = .FALSE. + DO j = 1, SIZE(sections) + IF (sections(j)%line_id /= line_id) CYCLE + it = find_type(types, sections(j)%ltype_name) + IF (it < 1) CYCLE + IF (types(it)%ei > CD_ZERO) fin = .TRUE. + END DO + END FUNCTION finite_ei_by_name END SUBROUTINE normalize_stock_endpoint_order SUBROUTINE reverse_line_sections(sections, line_id) @@ -17959,6 +18337,13 @@ SUBROUTINE finalize_checks(types, bodies, rod_types, rods, points, lines, sectio ! as pinned, while retaining finite/rigid connections at either end of every ! supported Fixed-End-B cable. j = find_point(points, lines(i)%nodeB) + IF (j > 0) THEN + IF (is_rod_point_type(points(j)%ptype)) THEN + CALL fail(ErrStat, ErrMsg, 'non-pinned END CONNECTIONS require a finite-EI line with Fixed End B; '// & + 'line '//TRIM(int_to_str(lines(i)%id))//ROD_END_B_NOTE) + RETURN + END IF + END IF IF (j < 1 .OR. TRIM(points(j)%ptype) /= 'fixed') THEN CALL fail(ErrStat, ErrMsg, 'non-pinned END CONNECTIONS require a finite-EI line with Fixed End B; '// & 'the two-moving-end compatibility solver does not apply bending connections') @@ -17995,12 +18380,22 @@ SUBROUTINE finalize_checks(types, bodies, rod_types, rods, points, lines, sectio SUBROUTINE check_torsion_line(ln, es_t, em_t) !! A line with a torsional END CONNECTIONS restraint: a finite-EI (cubic-Hermite) line. With !! both ends restrained (torsion active) End B must be Fixed, every section's LINE TYPES row - !! must give an explicit GJ, End A may not be a rod end, and a body End A must be a Rigid6 - !! body. + !! must give an explicit GJ, a body End A must be a Rigid6 body, and a rod End A must be on a + !! Fixed rod. + !! + !! The End A torsion frame (director, reference normal) is held by End A's parent and turns + !! with its whole orientation, its roll about the line included. A Fixed rod holds it still, + !! as a Fixed point does; the ends of a rod fixed to a Rigid6 body (RODS type Body) are + !! points of the body (resolve_rod_end_tokens) and turn with it. A Free or Pinned rod (also + !! BodyPinned, CoupledPinned) is an axisymmetric body: no load acts about its axis, its + !! static solve has no roll angle and its roll in the dynamics is never loaded, so the line's + !! torque would have nothing to react it. A Coupled/Vessel rod carries no finite-EI line on + !! any route of this build (the multibody march takes no motionFile, the coupled aggregate no + !! rod beside a finite-EI cable), so its host-driven frame is not wired to the torsion. TYPE(DeckLine), INTENT(IN) :: ln INTEGER, INTENT(OUT) :: es_t CHARACTER(*), INTENT(OUT) :: em_t - INTEGER :: js, jp, jb + INTEGER :: js, jp, jb, rid, rend CHARACTER(32) :: lid es_t = 0 em_t = '' @@ -18010,8 +18405,25 @@ SUBROUTINE check_torsion_line(ln, es_t, em_t) 'finite-EI line; line '//TRIM(lid)//' has EI = 0') RETURN END IF - ! one restrained end only carries no torque (noted and ignored): the rules below apply to a - ! line restrained at both ends + ! one restrained end only: solved in torsion where resolve_one_end_torsion found the rules + ! below met, otherwise noted (no torsion); the rules apply to a line restrained at both ends. + ! A solved one's imposed twist is its restrained end's Pretwist (the free end's is 0), within + ! the same 1000 turns. + IF (ln%tors_free_end > 0) THEN + js = 3 - ln%tors_free_end + IF (ABS(ln%tors_pretwist(js)) > CD_HTORS_MAX_TWIST) THEN + BLOCK + CHARACTER(32) :: tw + INTEGER :: tw_ios + tw = '' + WRITE (tw, '(ES12.5)', IOSTAT=tw_ios) ln%tors_pretwist(js)/DEG2RAD_TORS + CALL fail(es_t, em_t, 'line '//TRIM(lid)//': the Pretwist of its restrained End '// & + MERGE('A', 'B', js == 1)//' = '//TRIM(ADJUSTL(tw))//' deg exceeds 1000 turns '// & + '(360000 deg), the largest twist') + END BLOCK + END IF + RETURN + END IF IF (.NOT. ALL(ln%tors_mode /= TORS_FREE)) RETURN IF (ABS(ln%tors_pretwist(2) - ln%tors_pretwist(1)) > CD_HTORS_MAX_TWIST) THEN BLOCK @@ -18026,6 +18438,11 @@ SUBROUTINE check_torsion_line(ln, es_t, em_t) END IF jp = find_point(points, ln%nodeB) IF (jp < 1) RETURN + IF (is_rod_point_type(points(jp)%ptype)) THEN + CALL fail(es_t, em_t, 'torsional END CONNECTIONS require a finite-EI line with Fixed End B; line '// & + TRIM(lid)//ROD_END_B_NOTE) + RETURN + END IF IF (TRIM(points(jp)%ptype) /= 'fixed') THEN CALL fail(es_t, em_t, 'torsional END CONNECTIONS require a finite-EI line with Fixed End B; line '// & TRIM(lid)//' has two moving ends') @@ -18044,9 +18461,26 @@ SUBROUTINE check_torsion_line(ln, es_t, em_t) jp = find_point(points, ln%nodeA) IF (jp < 1) RETURN IF (is_rod_point_type(points(jp)%ptype)) THEN - CALL fail(es_t, em_t, 'line '//TRIM(lid)//': a torsional END CONNECTION on a rod end is not supported '// & - '(a rod has no spin angle in this build)') - RETURN + CALL parse_rod_point_type(points(jp)%ptype, rid, rend) + jb = find_rod(rods, rid) + IF (jb > 0) THEN + SELECT CASE (TRIM(rods(jb)%rod_type)) + CASE ('fixed') + CASE ('coupled', 'vessel') + CALL fail(es_t, em_t, 'line '//TRIM(lid)//': a torsional END CONNECTION on the end of Coupled/Vessel '// & + 'ROD '//TRIM(int_to_str(rid))//' is not supported: no route of this build carries a '// & + 'finite-EI line on a host-driven rod') + RETURN + CASE DEFAULT + CALL fail(es_t, em_t, 'line '//TRIM(lid)//': a torsional END CONNECTION on the end of ROD '// & + TRIM(int_to_str(rid))//' ('//TRIM(rods(jb)%rod_type)//') is not supported: a free or '// & + 'pinned rod is axisymmetric, with no roll about its own axis (no load acts about the axis '// & + 'and its static solve has no roll angle), so it cannot hold the line''s torque; restrain '// & + 'End A on a Fixed rod, on a rod fixed to a Rigid6 body (RODS type Body), on a Rigid6 '// & + 'body point or on a Fixed point') + RETURN + END SELECT + END IF END IF IF (starts_with(TRIM(points(jp)%ptype), 'body')) THEN jb = find_body(bodies, points(jp)%body_id) @@ -20230,7 +20664,8 @@ SUBROUTINE object_channel_value(ch, val, found, rigid, rods, points, opts, time, !! MoorDyn's roll and pitch of the axis from the vertical [deg]. Loads are evaluated at the !! committed state: Body F/M is the net external load about the reference point, Rod F/M !! about End A (weight, buoyancy, hydrodynamic and seabed loads, external loads, the line - !! end forces and, for a body, its fixed rods and the pin forces of its pinned rods); Rod + !! end forces, the connection moments of clamped cables and, for a body, its fixed rods and + !! the pin forces of its pinned rods); Rod !! TenA/TenB is the magnitude of the summed line force at End A/B, Sub the submerged !! fraction of its length. CHARACTER(*), INTENT(IN) :: ch @@ -20500,7 +20935,8 @@ END SUBROUTINE body_net_wrench SUBROUTINE rod_net_wrench(rs, body_of, points, opts, time, f6, ten, sub, ErrStat, ErrMsg, system, mb, bathymetry, & added6) !! Net external force and moment on a rod about its End A (global axes) at its committed - !! state (weight, buoyancy, Morison and seabed loads, the line forces at its ends), the + !! state (weight, buoyancy, Morison and seabed loads, the line forces at its ends and the + !! connection moments, bending and torque, of the cables clamped there), the !! summed line force magnitudes at End A and End B, and its submerged length fraction. !! body_of > 0: the rod is fixed to that body, and its end lines are the body attachment !! points made from its ends (DeckPoint rod_ref/rod_end). added6: its 6x6 added mass @@ -20558,12 +20994,21 @@ SUBROUTINE rod_net_wrench(rs, body_of, points, opts, time, f6, ten, sub, ErrStat ten(2) = NORM2(fe(:, 2)) f = f + fe(:, 1) + fe(:, 2) m = m + cross3(pb - pa, fe(:, 2)) - ! the connection moments of the cables clamped (or elastically connected) to the rod's ends - IF (PRESENT(mb) .AND. body_of == 0) THEN + ! the connection moments of the cables clamped (or elastically connected) to the rod's ends: + ! on a rod of the march its rod-end attachments, on a rod fixed to a body the body points made + ! from its ends (whose cables the body carries) + IF (PRESENT(mb)) THEN IF (ALLOCATED(mb%cab_mend)) THEN DO ip = 1, SIZE(mb%cables) - IF (mb%cab_kind(ip) /= 2) CYCLE - IF (mb%rods(mb%cab_obj(ip))%rod_id == rs%rod_id) m = m + mb%cab_mend(:, ip) + IF (body_of == 0) THEN + IF (mb%cab_kind(ip) /= 2) CYCLE + IF (mb%rods(mb%cab_obj(ip))%rod_id == rs%rod_id) m = m + mb%cab_mend(:, ip) + ELSE + IF (mb%cab_kind(ip) /= 1 .OR. mb%cab_obj(ip) /= body_of .OR. .NOT. ALLOCATED(mb%cable_points)) CYCLE + e = find_point(points, mb%cable_points(1, ip)) + IF (e < 1) CYCLE + IF (points(e)%rod_ref == rs%rod_id .AND. points(e)%rod_end > 0) m = m + mb%cab_mend(:, ip) + END IF END DO END IF END IF @@ -21169,12 +21614,21 @@ SUBROUTINE write_multibody_dynamic_out(deck_path, out_root, channels, types, bod 'standalone driver runs with its Coupled points held still (that route takes no motionFile '// & 'either)'); RETURN END IF - IF (lines(i)%endconn_mode(1) /= CD_ENDCONN_PINNED .AND. TRIM(points(pa)%ptype) /= 'fixed') THEN - ! a clamped or elastic End A on a body or rod: implicit (monolithic step) only + IF ((lines(i)%endconn_mode(1) /= CD_ENDCONN_PINNED .OR. line_torsion_at_a(lines(i))) .AND. & + TRIM(points(pa)%ptype) /= 'fixed') THEN + ! a clamped, elastic or torsionally restrained End A on a body or rod: implicit (monolithic + ! step) only; the staggered step drives the cable end by translation, so its End A frame + ! would not turn with the object nor return the torque IF (opts%body_scheme_staggered) THEN - CALL fail(ErrStat, ErrMsg, 'finite-EI LINE '//TRIM(int_to_str(lines(i)%id))//': a clamped or '// & - 'elastic END CONNECTION on a body or rod needs bodyScheme monolithic (the staggered '// & - 'scheme couples cable ends as point forces)') + IF (lines(i)%endconn_mode(1) /= CD_ENDCONN_PINNED) THEN + CALL fail(ErrStat, ErrMsg, 'finite-EI LINE '//TRIM(int_to_str(lines(i)%id))//': a clamped or '// & + 'elastic END CONNECTION on a body or rod needs bodyScheme monolithic (the staggered '// & + 'scheme couples cable ends as point forces)') + ELSE + CALL fail(ErrStat, ErrMsg, 'finite-EI LINE '//TRIM(int_to_str(lines(i)%id))//': a torsional END '// & + 'CONNECTION on a body or rod needs bodyScheme monolithic (the staggered scheme drives cable '// & + 'ends by translation and couples them as point forces)') + END IF RETURN END IF BLOCK @@ -21271,19 +21725,20 @@ SUBROUTINE write_multibody_dynamic_out(deck_path, out_root, channels, types, bod pc = points pa = find_point(points, cab_lines(c)%nodeA) IF (TRIM(pc(pa)%ptype) /= 'fixed') pc(pa)%ptype = 'coupled' - mb%cab_clamp(c) = (cab_lines(c)%endconn_mode(1) /= CD_ENDCONN_PINNED .OR. line_torsion_active(cab_lines(c))) & + mb%cab_clamp(c) = (cab_lines(c)%endconn_mode(1) /= CD_ENDCONN_PINNED .OR. line_torsion_at_a(cab_lines(c))) & .AND. TRIM(points(pa)%ptype) /= 'fixed' IF (mb%cab_clamp(c)) THEN ! End A clamped or elastic on its object: the connection direction is stored in the object ! frame and turns with the object's orientation (the OpenFAST parent-frame contract) BLOCK TYPE(DeckLine) :: lnc - REAL(wp) :: rclamp(3, 3), dclamp(3) + REAL(wp) :: rclamp(3, 3), dclamp(3), nclamp(3) lnc = cab_lines(c) CALL clamp_object_frame(lnc, points, bodies, rods, rclamp, dclamp, ErrStat, ErrMsg, & - check_axis=.NOT. opts%body_ic_static) + check_axis=.NOT. opts%body_ic_static, nx0=nclamp) IF (ErrStat /= CD_DECKDRV_OK) GOTO 900 lnc%endconn_ez_ref(:, 1) = dclamp + lnc%tors_nx(:, 1) = nclamp CALL build_one_hermite_cable(lnc, sections, types, pc, opts, opts%dtM, mb%cables(c), node, & ErrStat, ErrMsg, standalone_controls=.TRUE., bathymetry=bathymetry, & fairlead_orientation=TRANSPOSE(rclamp), install_viv=.TRUE., & @@ -23426,7 +23881,9 @@ SUBROUTINE mb_torsion_turn_limit(mb, x, dt, beta_na, limited) limited = .FALSE. IF (.NOT. ALLOCATED(mb%cables)) RETURN DO c = 1, SIZE(mb%cables) + ! (a free End A: the body's turn does not twist the line) IF (mb%cab_kind(c) /= 1 .OR. .NOT. mb%cables(c)%line%torsion%active) CYCLE + IF (mb%cables(c)%line%torsion%end_free(2)) CYCLE ib = mb%cab_obj(c) o = mb%jb_off(ib) IF (o < 0) CYCLE @@ -27057,7 +27514,7 @@ SUBROUTINE solve_body_equilibrium(types, bodies, rod_types, rods, points, lines, ALLOCATE (cl(0)) IF (.NOT. only_points .AND. .NOT. PRESENT(jac_check_err) .AND. opts%body_ic_static) THEN DO j = 1, SIZE(lines) - IF (lines(j)%endconn_mode(1) == CD_ENDCONN_PINNED .AND. .NOT. line_torsion_active(lines(j))) CYCLE + IF (lines(j)%endconn_mode(1) == CD_ENDCONN_PINNED .AND. .NOT. line_torsion_at_a(lines(j))) CYCLE IF (.NOT. line_is_finite_ei(lines(j), types, sections)) CYCLE pa = find_point(points, lines(j)%nodeA) IF (pa < 1) CYCLE @@ -27090,7 +27547,7 @@ SUBROUTINE solve_body_equilibrium(types, bodies, rod_types, rods, points, lines, pass_tol_eff = PASS_TOL DO e = 1, ncl ext_pt(e) = find_point(points, lines(cl(e))%nodeA) - IF (line_torsion_active(lines(cl(e)))) pass_tol_eff = PASS_TOL_TORSION + IF (line_torsion_at_a(lines(cl(e)))) pass_tol_eff = PASS_TOL_TORSION END DO ext_fm = CD_ZERO ext_km = CD_ZERO @@ -27157,17 +27614,19 @@ SUBROUTINE hermite_end_loads(jl, fm, km, rot) TYPE(CD_HFMF_ModuleType) :: cab TYPE(DeckLine) :: lnc TYPE(DeckPoint), ALLOCATABLE :: pc(:) - REAL(wp) :: rclamp(3, 3), dclamp(3), dtb + REAL(wp) :: rclamp(3, 3), dclamp(3), nclamp(3), dtb INTEGER :: node, es CHARACTER(1024) :: note CHARACTER(1024) :: em fm = CD_ZERO km = CD_ZERO lnc = lines(jl) - CALL clamp_object_frame(lnc, points, bodies, rods, rclamp, dclamp, ErrStat, ErrMsg, check_axis=.FALSE.) + CALL clamp_object_frame(lnc, points, bodies, rods, rclamp, dclamp, ErrStat, ErrMsg, check_axis=.FALSE., & + nx0=nclamp) rot = rclamp IF (ErrStat /= CD_DECKDRV_OK) RETURN lnc%endconn_ez_ref(:, 1) = dclamp + lnc%tors_nx(:, 1) = nclamp pc = points pc(find_point(points, lnc%nodeA))%ptype = 'coupled' dtb = CD_ONE @@ -29768,6 +30227,9 @@ SUBROUTINE write_hermite_dynamic_out(out_root, channels, lines, points, opts, ca IF (ErrStat /= CD_DECKDRV_OK) RETURN CALL check_motion_roll(ErrStat, ErrMsg) IF (ErrStat /= CD_DECKDRV_OK) RETURN + ! The static configuration, before row 1 moves the fairlead. + CALL write_hermite_static_profile(out_root, lines, cables, ErrStat, ErrMsg) + IF (ErrStat /= CD_DECKDRV_OK) RETURN ! Install row 1 without advancing the cable clock. The first pass makes the ! t=0 fluid sample use the prescribed geometry. The held-field setter refreshes ! the consistent free acceleration and deliberately zeros fixed DOFs, so repeat @@ -29810,7 +30272,7 @@ SUBROUTINE write_hermite_dynamic_out(out_root, channels, lines, points, opts, ca CALL write_hermite_model_row(unit, CD_ZERO, channels, lines, points, cables, ErrStat, ErrMsg, & motion=motion, motion_time_index=MERGE(1, 0, opts%has_motion_file), & has_motion=opts%has_motion_file, ranges=ranges) - IF (ErrStat == CD_DECKDRV_OK) & + IF (ErrStat == CD_DECKDRV_OK .AND. .NOT. opts%has_motion_file) & 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, & @@ -29845,7 +30307,7 @@ SUBROUTINE write_hermite_dynamic_out(out_root, channels, lines, points, opts, ca u_orientation=TRANSPOSE(motion%rot(:, :, step + 1)), & u_angular_velocity=motion%omega(:, step + 1), & u_angular_acceleration=motion%alpha(:, step + 1)) - ELSE IF (motion%has_roll .AND. line_torsion_active(lines(i)) .AND. & + ELSE IF (motion%has_roll .AND. line_torsion_at_a(lines(i)) .AND. & find_motion_point(motion, lines(i)%nodeA) > 0) THEN ! imposed roll of End A about its director: Phi = Pretwist(B) - (Pretwist(A) + roll) CALL CD_HFMF_UpdateStates(cables(i), up, uv, ua, es, em, & @@ -29926,37 +30388,45 @@ SUBROUTINE write_hermite_dynamic_out(out_root, channels, lines, points, opts, ca CONTAINS SUBROUTINE check_motion_roll(est, emt) - !! The motionFile roll column drives a torsional line through its moving end only (internal - !! End A after the anchor-first swap: the user's End A, or End B of an anchor-first deck), - !! right-handed about the tangent pointing into the line, so Phi = Pretwist(B) - - !! Pretwist(A) - roll in either order; it starts from the static state (roll 0 at t = 0). INTEGER, INTENT(OUT) :: est CHARACTER(*), INTENT(OUT) :: emt - INTEGER :: ip, li - LOGICAL :: used - est = CD_DECKDRV_OK - emt = '' - IF (.NOT. motion%has_roll) RETURN - DO ip = 1, motion%n_point - IF (.NOT. ANY(ABS(motion%roll(ip, :)) > CD_ZERO)) CYCLE - used = .FALSE. - DO li = 1, SIZE(lines) - IF (lines(li)%nodeA == motion%point_ids(ip) .AND. line_torsion_active(lines(li))) used = .TRUE. - END DO - IF (.NOT. used) THEN - CALL fail(est, emt, 'motionFile: point '//TRIM(int_to_str(motion%point_ids(ip)))//' has a non-zero roll '// & - 'column, but no line restrained in torsion at both ends (END CONNECTIONS TorsStiffness) '// & - 'has its moving (non-Fixed) end there'); RETURN - END IF - IF (ABS(motion%roll(ip, 1)) > CD_ZERO) THEN - CALL fail(est, emt, 'motionFile: the roll column of point '//TRIM(int_to_str(motion%point_ids(ip)))// & - ' must be 0 at t = 0 (the static solve uses the END CONNECTIONS Pretwist, which takes a '// & - 'constant twist)'); RETURN - END IF - END DO + CALL check_motion_roll_lines(motion, lines, est, emt) END SUBROUTINE check_motion_roll END SUBROUTINE write_hermite_dynamic_out + SUBROUTINE check_motion_roll_lines(motion, lines, est, emt) + !! The motionFile roll column drives a torsional line through its moving end only (internal + !! End A after the anchor-first swap: the user's End A, or End B of an anchor-first deck), + !! right-handed about the tangent pointing into the line, so Phi = Pretwist(B) - + !! Pretwist(A) - roll in either order; it starts from the static state (roll 0 at t = 0). + TYPE(MotionTable), INTENT(IN) :: motion + TYPE(DeckLine), INTENT(IN) :: lines(:) + INTEGER, INTENT(OUT) :: est + CHARACTER(*), INTENT(OUT) :: emt + INTEGER :: ip, li + LOGICAL :: used + est = CD_DECKDRV_OK + emt = '' + IF (.NOT. motion%has_roll) RETURN + DO ip = 1, motion%n_point + IF (.NOT. ANY(ABS(motion%roll(ip, :)) > CD_ZERO)) CYCLE + used = .FALSE. + DO li = 1, SIZE(lines) + IF (lines(li)%nodeA == motion%point_ids(ip) .AND. line_torsion_at_a(lines(li))) used = .TRUE. + END DO + IF (.NOT. used) THEN + CALL fail(est, emt, 'motionFile: point '//TRIM(int_to_str(motion%point_ids(ip)))//' has a non-zero roll '// & + 'column, but no line restrained in torsion (END CONNECTIONS TorsStiffness) at its moving '// & + '(non-Fixed) end has that end there'); RETURN + END IF + IF (ABS(motion%roll(ip, 1)) > CD_ZERO) THEN + CALL fail(est, emt, 'motionFile: the roll column of point '//TRIM(int_to_str(motion%point_ids(ip)))// & + ' must be 0 at t = 0 (the static solve uses the END CONNECTIONS Pretwist, which takes a '// & + 'constant twist)'); RETURN + END IF + END DO + END SUBROUTINE check_motion_roll_lines + SUBROUTINE write_hermite_static_profile(out_root, lines, cables, ErrStat, ErrMsg) !! Persist the converged finite-EI initialization as the same engineering range !! table emitted by the coupled OpenFAST facade. This is independent of OUTPUTS: @@ -34479,10 +34949,13 @@ SUBROUTINE check_channel(ch, lines, points, sections, ErrStat, ErrMsg, bodies, r IF (node > nelem + 1) THEN CALL fail(ErrStat, ErrMsg, 'OUTPUT "'//TRIM(ch)//'": node index exceeds line node count'); RETURN END IF - IF (.NOT. line_torsion_active(lines(li))) THEN + IF (.NOT. line_torsion_active(lines(li)) .AND. LEN_TRIM(lines(li)%tors_note) > 0) THEN + CALL fail(ErrStat, ErrMsg, 'OUTPUT "'//TRIM(ch)//'": line '//TRIM(int_to_str(line_id))//' is '// & + 'torsionally restrained at one end only and its torsion is not solved: '// & + TRIM(lines(li)%tors_note)); RETURN + ELSE IF (.NOT. line_torsion_active(lines(li))) THEN CALL fail(ErrStat, ErrMsg, 'OUTPUT "'//TRIM(ch)//'": line '//TRIM(int_to_str(line_id))//' is not '// & - 'torsionally restrained at both ends (END CONNECTIONS TorsStiffness), so it carries no '// & - 'torque'); RETURN + 'torsionally restrained (END CONNECTIONS TorsStiffness), so it carries no torque'); RETURN END IF ELSE IF (starts_with(lo, 'ten') .OR. starts_with(lo, 'curv') .OR. & starts_with(lo, 'bendmom') .OR. starts_with(lo, 'stfmom') .OR. starts_with(lo, 'l')) THEN @@ -37677,11 +38150,110 @@ PURE FUNCTION ptfm_zyx_dcm(theta) RESULT(m) END FUNCTION ptfm_zyx_dcm PURE LOGICAL FUNCTION line_torsion_active(ln) RESULT(active) - !! Condensed torsion is solved on a line only when both ends declare a torsional restraint. + !! Torsion is solved on a line whose two ends declare a torsional restraint, or one of them + !! with the other free to twist (tors_free_end, resolve_one_end_torsion). TYPE(DeckLine), INTENT(IN) :: ln - active = ALL(ln%tors_mode /= TORS_FREE) + active = ALL(ln%tors_mode /= TORS_FREE) .OR. ln%tors_free_end > 0 END FUNCTION line_torsion_active + PURE LOGICAL FUNCTION line_torsion_at_a(ln) RESULT(at_a) + !! The line is solved in torsion and its End A is restrained in torsion: End A's object takes + !! the torque, and a roll or a turn of that object twists the line. + TYPE(DeckLine), INTENT(IN) :: ln + at_a = line_torsion_active(ln) .AND. ln%tors_mode(1) /= TORS_FREE + END FUNCTION line_torsion_at_a + + SUBROUTINE resolve_one_end_torsion(types, bodies, rods, points, lines, sections, opts, caller_driven) + !! A finite-EI line restrained in torsion at one end only (the other end TorsStiffness Free, + !! or no END CONNECTIONS row there) is solved in torsion where a line restrained at both ends + !! is: every section gives GJ (the 14-column LINE TYPES row, whose Irn > 0 gives the nodal + !! twist its inertia), End B is Fixed, a march (TMax > 0, or a caller-driven deck) is + !! force-blended, and a restrained End A is on no body but a Rigid6 one and on no rod end but + !! a Fixed rod's (check_torsion_line). ATTACHMENTS, CONTROL and the modal analysis take it as + !! they take a line restrained at both ends. Its free end carries no torque and turns with + !! the twist of the line: the stretch's under torque-tension coupling, and the torsional + !! waves of the dynamics. tors_free_end is then the free deck end and its Pretwist 0 (it + !! rolls nothing: Phi is the restrained end's Pretwist alone). Otherwise the line keeps the + !! meaning of the 6-column rows and tors_note says why. Runs after the anchor-first swap; + !! sections are matched to their LINE TYPES by name (validation resolves them later). + TYPE(DeckLineType), INTENT(IN) :: types(:) + TYPE(DeckBody), INTENT(IN) :: bodies(:) + TYPE(DeckRod), INTENT(IN) :: rods(:) + TYPE(DeckPoint), INTENT(IN) :: points(:) + TYPE(DeckLine), INTENT(INOUT) :: lines(:) + TYPE(DeckSection), INTENT(IN) :: sections(:) + TYPE(DeckOptions), INTENT(IN) :: opts + LOGICAL, INTENT(IN) :: caller_driven + INTEGER :: i, j, k, ifree, ja, jb, rid, rend + LOGICAL :: finite, has_gj + CHARACTER(200) :: why + DO i = 1, SIZE(lines) + lines(i)%tors_free_end = 0 + lines(i)%tors_note = '' + IF (COUNT(lines(i)%tors_mode /= TORS_FREE) /= 1) CYCLE + ifree = MERGE(1, 2, lines(i)%tors_mode(1) == TORS_FREE) + finite = .FALSE. + has_gj = .TRUE. + DO j = 1, SIZE(sections) + IF (sections(j)%line_id /= lines(i)%id) CYCLE + k = find_type(types, sections(j)%ltype_name) + IF (k < 1) THEN + has_gj = .FALSE. + CYCLE + END IF + IF (types(k)%ei > CD_ZERO) finite = .TRUE. + IF (.NOT. (types(k)%gj > CD_ZERO)) has_gj = .FALSE. + END DO + ! (an EI = 0 line with a torsional restraint is refused by name in finalize_checks) + IF (.NOT. finite) CYCLE + why = '' + j = find_point(points, lines(i)%nodeB) + IF (.NOT. has_gj) THEN + why = 'its LINE TYPES rows give no GJ (the 14-column row; torsion has no EI/1.3 default)' + ELSE IF (j < 1) THEN + why = 'its End B point is undefined' + ELSE IF (TRIM(points(j)%ptype) /= 'fixed') THEN + why = 'it has two moving ends (torsion needs a Fixed End B)' + ELSE IF (.NOT. opts%alpha_force_blend .AND. (caller_driven .OR. (opts%has_tmax .AND. opts%tmax > CD_ZERO))) THEN + why = 'torsion in a dynamic run needs the force-blended generalised-alpha (alpha_force_blend True)' + ELSE IF (ifree == 2) THEN + ! the restrained End A turns with its object + ja = find_point(points, lines(i)%nodeA) + IF (ja > 0) THEN + IF (is_rod_point_type(points(ja)%ptype)) THEN + ! a Fixed rod holds the End A torsion frame; a free or pinned rod is axisymmetric (no + ! roll angle to react the torque), and no route carries a finite-EI line on a + ! Coupled/Vessel rod + CALL parse_rod_point_type(points(ja)%ptype, rid, rend) + jb = find_rod(rods, rid) + IF (jb > 0) THEN + SELECT CASE (TRIM(rods(jb)%rod_type)) + CASE ('fixed') + CASE ('coupled', 'vessel') + why = 'its restrained End A is on a Coupled/Vessel rod end (no route carries a finite-EI line '// & + 'on a host-driven rod)' + CASE DEFAULT + why = 'its restrained End A is on the end of a free or pinned rod (axisymmetric, with no roll '// & + 'angle to hold the torque)' + END SELECT + END IF + ELSE IF (starts_with(TRIM(points(ja)%ptype), 'body')) THEN + jb = find_body(bodies, int_suffix(TRIM(points(ja)%ptype), 5)) + IF (jb > 0) THEN + IF (TRIM(bodies(jb)%btype) /= 'rigid6') why = 'its restrained End A is on a body that is not Rigid6' + END IF + END IF + END IF + END IF + IF (LEN_TRIM(why) > 0) THEN + lines(i)%tors_note = why + ELSE + lines(i)%tors_free_end = ifree + lines(i)%tors_pretwist(ifree) = CD_ZERO + END IF + END DO + END SUBROUTINE resolve_one_end_torsion + PURE LOGICAL FUNCTION deck_has_torsion_columns(lines) RESULT(has) !! Some END CONNECTIONS row declares a torsional restraint (TorsStiffness not Free). TYPE(DeckLine), INTENT(IN) :: lines(:) @@ -38042,15 +38614,19 @@ PURE FUNCTION rod_orientation_from_axis(axis) RESULT(rot) rot(:, 3) = zaxis END FUNCTION rod_orientation_from_axis - SUBROUTINE clamp_object_frame(ln, points, bodies, rods, rot, d0, ErrStat, ErrMsg, check_axis) + SUBROUTINE clamp_object_frame(ln, points, bodies, rods, rot, d0, ErrStat, ErrMsg, check_axis, nx0) !! The object frame of a finite-EI line's End A END CONNECTION on a Rigid6 body point or a rod !! end, at the object's current pose (its static-equilibrium pose once solved): rot, the !! object-to-global rotation, and d0, the connection direction (End A to End B) in the object !! frame. On a body point the deck direction is given in the body frame. On a rod end it must !! be parallel to the rod axis (either sense, in the frame of the rod's deck coordinates): a - !! rod has no spin angle in its static solve, and a direction along the axis makes the - !! connection moment normal to the axis. check_axis = .FALSE. (after the static solve has - !! turned the rod; the deck direction was checked before it) keeps only the sense. + !! free or pinned rod has no spin angle in its static solve, and a direction along the axis + !! makes the connection moment normal to the axis. check_axis = .FALSE. (after the static + !! solve has turned the rod; the deck direction was checked before it) keeps only the sense. + !! nx0: End A's torsion reference normal in the object frame. On a body point the deck gives + !! it in the body frame; on an end of a Fixed rod in the frame of the rod's deck coordinates, + !! so it is carried into the rod frame rot: nx0 = rot^T Nx. On any other rod (torsion refused + !! there, check_torsion_line) nx0 is the deck's Nx unchanged, not a normal in that rod's frame. TYPE(DeckLine), INTENT(IN) :: ln TYPE(DeckPoint), INTENT(IN) :: points(:) TYPE(DeckBody), INTENT(IN) :: bodies(:) @@ -38059,6 +38635,7 @@ SUBROUTINE clamp_object_frame(ln, points, bodies, rods, rot, d0, ErrStat, ErrMsg INTEGER, INTENT(OUT) :: ErrStat CHARACTER(*), INTENT(OUT) :: ErrMsg LOGICAL, INTENT(IN), OPTIONAL :: check_axis + REAL(wp), INTENT(OUT), OPTIONAL :: nx0(3) INTEGER :: pa, ib, ir, rid, iend REAL(wp) :: axis(3), ez(3), an LOGICAL :: check @@ -38072,6 +38649,7 @@ SUBROUTINE clamp_object_frame(ln, points, bodies, rods, rot, d0, ErrStat, ErrMsg rot(3, 3) = CD_ONE ez = ln%endconn_ez_ref(:, 1) d0 = ez + IF (PRESENT(nx0)) nx0 = ln%tors_nx(:, 1) check = .TRUE. IF (PRESENT(check_axis)) check = check_axis who = 'finite-EI LINE '//TRIM(int_to_str(ln%id))//' End A' @@ -38113,6 +38691,10 @@ SUBROUTINE clamp_object_frame(ln, points, bodies, rods, rot, d0, ErrStat, ErrMsg IF (ib > 0) axis = MATMUL(deck_body_pose_rotation(bodies(ib)), axis) END IF rot = rod_orientation_from_axis(axis) + ! a Fixed rod keeps the frame init_rod_states gives it (rod_orientation_from_axis of its deck + ! axis), in which the march holds the End A frame (mb_attachment_motion); a free or pinned + ! rod's march frame differs from rot by a roll, and torsion is refused there + IF (PRESENT(nx0) .AND. TRIM(rods(ir)%rod_type) == 'fixed') nx0 = MATMUL(TRANSPOSE(rot), ln%tors_nx(:, 1)) ELSE CALL fail(ErrStat, ErrMsg, TRIM(who)//': a clamped or elastic END CONNECTION needs a Fixed point, a '// & 'Rigid6 body point or a rod end'); RETURN diff --git a/src/CableDyn_HermiteCableDynamic.f90 b/src/CableDyn_HermiteCableDynamic.f90 index a7ac4008..21116950 100644 --- a/src/CableDyn_HermiteCableDynamic.f90 +++ b/src/CableDyn_HermiteCableDynamic.f90 @@ -5828,7 +5828,7 @@ SUBROUTINE CD_HermiteCable_Dyn_Energy(model, kinetic, strain, ErrStat, ErrMsg, c strain = strain + 0.5_wp*model%torsion%gj(e)/model%l0(e)*tau*tau END DO DO iend = 1, 2 - IF (model%tw_rigid(iend)) CYCLE + IF (.NOT. tw_spring(model, iend)) CYCLE CALL twist_link(model, iend, model%q, model%torsion%ends, .FALSE., psi, gl, hl, ErrStat, em2) IF (ErrStat /= CD_HCDYN_OK) THEN ErrMsg = 'CD_HermiteCable_Dyn_Energy: '//TRIM(em2) @@ -6005,11 +6005,13 @@ SUBROUTINE CD_HermiteCable_Dyn_Section_Curvature(model, ref_a, kx, ky, ErrStat, t = -unit_tangent(model, model%nn) d1 = r - DOT_PRODUCT(r, t)*t rn = NORM2(d1) - IF (.NOT. rn > 1.0e-6_wp*MAX(NORM2(r), TINY(CD_ONE))) THEN + ! (a free End A's torsion frame is a gauge: its section is the material director below) + IF (.NOT. rn > 1.0e-6_wp*MAX(NORM2(r), TINY(CD_ONE)) .AND. .NOT. (model%tw_active .AND. & + model%torsion%end_free(2))) THEN ErrStat = CD_HCDYN_BADINPUT ErrMsg = 'CD_HermiteCable_Dyn_Section_Curvature: the section reference lies along the End A tangent'; RETURN END IF - d1 = d1/rn + IF (rn > CD_ZERO) d1 = d1/rn IF (model%tw_active) THEN ! Nodal twist: the material director Rot(t_k, phi - Phi) u of every node (t_k the solve ! tangent, End 1 -> End 2), on the frame convention above: End A (node nn) takes the @@ -6763,7 +6765,7 @@ SUBROUTINE CD_HermiteCable_Dyn_End_Twist(model, twist, ErrStat, ErrMsg) RETURN END IF DO iend = 1, 2 - IF (model%tw_rigid(iend)) CYCLE + IF (.NOT. tw_spring(model, iend)) CYCLE CALL twist_link(model, iend, model%q, model%torsion%ends, .FALSE., psi, gl, hl, ErrStat, ErrMsg) IF (ErrStat /= CD_HCDYN_OK) THEN ErrMsg = 'CD_HermiteCable_Dyn_End_Twist: '//TRIM(ErrMsg) @@ -6802,7 +6804,7 @@ SUBROUTINE CD_HermiteCable_Dyn_Twist_Check(model, q_check, ends, ErrStat, ErrMsg END IF END DO DO iend = 1, 2 - IF (model%tw_rigid(iend)) CYCLE + IF (.NOT. tw_spring(model, iend)) CYCLE CALL twist_link(model, iend, q_check, ends, .FALSE., psi, gl, hl, ErrStat, ErrMsg) IF (ErrStat /= CD_HCDYN_OK) THEN ErrMsg = 'CD_HermiteCable_Dyn_Twist_Check: '//TRIM(ErrMsg); RETURN @@ -6820,7 +6822,8 @@ SUBROUTINE CD_HermiteCable_Dyn_Twist_Hessian(model, eg, eh, ek, emt, lg, lh, lk, !! without damping), so d2E/dq2 = emt eh + ek eg eg^T, d2E/dphi_{e+1} dq = ek eg = -d2E/dphi_e dq !! and d2E/dphi2 = ek [[1, -1], [-1, 1]]. Per end k (columns): lg = d psi/dm and lh = d2 psi/dm2 !! in the end node's tangent handle m, lk the spring stiffness (0 at a rigid end, whose - !! angle is held) and lmt = lk tw, so d2E/dm2 = lk lg lg^T -+ lmt lh (- at end 1, + at end 2), + !! angle is held, and at a free end, which has no spring) and lmt = lk tw, so + !! d2E/dm2 = lk lg lg^T -+ lmt lh (- at end 1, + at end 2), !! d2E/dphi dm = -lk lg and d2E/dphi2 = lk. Fails closed without the nodal twist. TYPE(CD_HermiteCableDynType), INTENT(IN) :: model REAL(wp), INTENT(OUT) :: eg(:, :), eh(:, :, :), ek(:), emt(:), lg(3, 2), lh(3, 3, 2), lk(2), lmt(2) @@ -6856,7 +6859,8 @@ SUBROUTINE CD_HermiteCable_Dyn_Twist_Hessian(model, eg, eh, ek, emt, lg, lh, lk, emt(e) = ek(e)*(model%tw_phi(e + 1) - model%tw_phi(e) + rho) END DO DO iend = 1, 2 - IF (model%tw_rigid(iend)) CYCLE + ! (a free end, end_free, has no spring: its angle is free and its energy term absent) + IF (.NOT. tw_spring(model, iend)) CYCLE CALL twist_link(model, iend, model%q, model%torsion%ends, .TRUE., psi, lg(:, iend), lh(:, :, iend), & ErrStat, ErrMsg) IF (ErrStat /= CD_HCDYN_OK) THEN @@ -7417,7 +7421,7 @@ SUBROUTINE CD_HermiteCable_Dyn_EndConnection_Moment(model, node, moment, ErrStat ! director in a transport triangle adds d x dOmega/dd. The slaved tangent of a rigid ! bending end adds its share through the constraint reaction below. The held end section ! turns with the frame and its held angle, chi_dot = -+drho/dw . omega + phi_dot (End 1, - ! End 2): its polar inertia I adds -I chi_ddot dchi/dw. + ! End 2): its polar inertia I adds -I chi_ddot dchi/dw. A free end transmits no torque. BLOCK REAL(wp) :: rho, beta, g(12), h(12, 12), ew(3, 2), psi, gl(3), hl(3, 3), lw(3), tw, sg, chi_dd IF (model%tw_rigid(iend)) THEN @@ -7432,7 +7436,7 @@ SUBROUTINE CD_HermiteCable_Dyn_EndConnection_Moment(model, node, moment, ErrStat sg = MERGE(-CD_ONE, CD_ONE, iend == 1) chi_dd = sg*DOT_PRODUCT(ew(:, iend), model%tw_oal(:, iend)) + model%tw_al(node) moment = moment - model%tw_mass(node)*chi_dd*sg*ew(:, iend) - ELSE + ELSE IF (tw_spring(model, iend)) THEN CALL twist_link(model, iend, model%q, model%torsion%ends, .FALSE., psi, gl, hl, es, em, end_w=lw) IF (es /= CD_HCDYN_OK) THEN ErrStat = es @@ -7745,7 +7749,9 @@ SUBROUTINE CD_HermiteCable_Dyn_Torsion_State(model, theta, torque, ErrStat, ErrM RETURN END IF theta = CD_HermiteTorsion_Unwrap(raw, model%torsion%theta) - IF (ABS(theta - model%torsion%theta) > CD_HTORS_MAX_STEP) THEN + ! (a line free at one end carries no condensed torque on any branch: the nodal twist, not + ! Theta, holds its state, and its accepted Theta is only the view Phi less the summed twist) + IF (ABS(theta - model%torsion%theta) > CD_HTORS_MAX_STEP .AND. .NOT. ANY(model%torsion%end_free)) THEN ErrStat = CD_HCDYN_NOCONVERGE ErrMsg = 'torsion: the twist moved more than pi/2 from its accepted value' theta = CD_ZERO @@ -9182,7 +9188,7 @@ SUBROUTINE assemble_twist(model, q_cfg, v_cfg, want_residual, want_tangent, R, K model%tw_lk = CD_ZERO END IF DO iend = 1, 2 - IF (model%tw_rigid(iend)) CYCLE + IF (.NOT. tw_spring(model, iend)) CYCLE CALL twist_link(model, iend, q_cfg, ends, want_tangent, psi, gl, hl, es, em) IF (es /= CD_HCDYN_OK) THEN ErrStat = es @@ -9348,7 +9354,10 @@ SUBROUTINE tw_init(model, mt, ErrStat, ErrMsg) !! holonomy), angles accumulated from the element twists mt l0/GJ - rho_e and the end !! compliances, rates zero. A rigid end 2 holds phi = Phi: the last element's reference !! twist takes the multiple of 2 pi the accumulated angle needs, as an elastic end 2's psi - !! does; a remainder above STATE_TOL (a static state off equilibrium) fails closed. + !! does; a remainder above STATE_TOL (a static state off equilibrium) fails closed. A free + !! end (mt = 0) has no reference of its own: a free end 1 starts the directors from its + !! gauge frame and the angles shift as one to meet the restrained end 2 (its held Phi or a + !! slack spring); a free end 2 ends the accumulation. TYPE(CD_HermiteCableDynType), INTENT(INOUT) :: model REAL(wp), INTENT(IN) :: mt INTEGER, INTENT(OUT) :: ErrStat @@ -9415,15 +9424,15 @@ SUBROUTINE tw_init(model, mt, ErrStat, ErrMsg) model%tw_som = CD_ZERO model%tw_om = CD_ZERO model%tw_oal = CD_ZERO - IF (.NOT. model%tw_rigid(1)) model%tw_psi(1) = CD_HermiteTwist_Angle(model%tw_u(:, 1), & - CD_HermiteTwist_Carry(ends(:, 1), & - model%tw_tn(:, 1), & - ends(:, 2)), & - model%tw_tn(:, 1)) + IF (tw_spring(model, 1)) model%tw_psi(1) = CD_HermiteTwist_Angle(model%tw_u(:, 1), & + CD_HermiteTwist_Carry(ends(:, 1), & + model%tw_tn(:, 1), & + ends(:, 2)), & + model%tw_tn(:, 1)) ! angles from the uniform torque tol = STATE_TOL*MAX(CD_ONE, ABS(phi_end)) model%tw_phi = CD_ZERO - IF (.NOT. model%tw_rigid(1)) model%tw_phi(1) = mt*model%torsion%end_compliance(1) + model%tw_psi(1) + IF (tw_spring(model, 1)) model%tw_phi(1) = mt*model%torsion%end_compliance(1) + model%tw_psi(1) model%tors_use_step = .FALSE. DO e = 1, ne CALL twist_reference(model, e, model%q, ends, .FALSE., rho, beta, g, h, es, em2) @@ -9433,7 +9442,12 @@ SUBROUTINE tw_init(model, mt, ErrStat, ErrMsg) RETURN END IF model%tw_phi(e + 1) = model%tw_phi(e) + mt*model%l0(e)/model%torsion%gj(e) - rho - IF (e == ne .AND. model%tw_rigid(2)) THEN + IF (e == ne .AND. model%tw_rigid(2) .AND. model%torsion%end_free(1)) THEN + ! a free end 1: the angles shift as one to the held Phi of end 2 + diff = model%tw_phi(nn) - phi_end + model%tw_phi = model%tw_phi - diff + model%tw_phi(nn) = phi_end + ELSE IF (e == ne .AND. model%tw_rigid(2)) THEN diff = model%tw_phi(nn) - phi_end kk = ANINT(diff/(2.0_wp*CD_HTORS_PI)) IF (ABS(diff - 2.0_wp*CD_HTORS_PI*kk) > tol) THEN @@ -9446,11 +9460,13 @@ SUBROUTINE tw_init(model, mt, ErrStat, ErrMsg) model%tw_phi(nn) = phi_end END IF END DO - IF (.NOT. model%tw_rigid(2)) THEN + IF (tw_spring(model, 2)) THEN ! the End-2 spring: its psi at the committed state is the director angle itself, on the - ! branch that puts the static end twist mt/k_2 on it + ! branch that puts the static end twist mt/k_2 on it (a free end 1: the angles shift as + ! one to leave the spring slack, mt = 0) psi = CD_HermiteTwist_Angle(model%tw_u(:, nn), CD_HermiteTwist_Carry(ends(:, 3), model%tw_tn(:, nn), & ends(:, 4)), model%tw_tn(:, nn)) + IF (model%torsion%end_free(1)) model%tw_phi = model%tw_phi + (psi + phi_end - model%tw_phi(nn)) diff = mt*model%torsion%end_compliance(2) - (psi + phi_end - model%tw_phi(nn)) kk = ANINT(diff/(2.0_wp*CD_HTORS_PI)) IF (ABS(diff - 2.0_wp*CD_HTORS_PI*kk) > tol) THEN @@ -9476,11 +9492,12 @@ END SUBROUTINE tw_init SUBROUTINE tw_set_derived(model, tors) !! The rigid ends, held angles and lumped polar inertia (half of each adjacent element's - !! Irn l0) the torsion description tors gives. + !! Irn l0) the torsion description tors gives. A free end (tors%end_free) is neither rigid + !! nor elastic: its angle is free and nothing twists it against its end frame. TYPE(CD_HermiteCableDynType), INTENT(INOUT) :: model TYPE(CD_HermiteTorsionType), INTENT(IN) :: tors INTEGER :: e - model%tw_rigid = .NOT. (tors%end_compliance > CD_ZERO) + model%tw_rigid = .NOT. (tors%end_compliance > CD_ZERO) .AND. .NOT. tors%end_free model%tw_free = .TRUE. IF (model%tw_rigid(1)) model%tw_free(1) = .FALSE. IF (model%tw_rigid(2)) model%tw_free(model%nn) = .FALSE. @@ -9491,6 +9508,14 @@ SUBROUTINE tw_set_derived(model, tors) END DO END SUBROUTINE tw_set_derived + PURE LOGICAL FUNCTION tw_spring(model, iend) RESULT(spring) + !! End iend of the nodal twist is elastic: a torsional spring between its end node and its + !! end frame (neither rigid, holding the angle, nor free, without restraint). + TYPE(CD_HermiteCableDynType), INTENT(IN) :: model + INTEGER, INTENT(IN) :: iend + spring = .NOT. (model%tw_rigid(iend) .OR. model%torsion%end_free(iend)) + END FUNCTION tw_spring + SUBROUTINE tw_settle_committed(model) !! After an evaluation of the committed state (solve_consistent_acceleration): the angles' !! accelerations staged in tw_ak, the element torques, and the condensed view Theta_eff = @@ -9540,7 +9565,7 @@ SUBROUTINE tw_advance_reference(model, q_new, ends_new, ErrStat, ErrMsg) END DO model%tw_spsi = model%tw_psi DO iend = 1, 2 - IF (model%tw_rigid(iend)) CYCLE + IF (.NOT. tw_spring(model, iend)) CYCLE CALL twist_link(model, iend, q_new, ends_new, .FALSE., psi, gl, hl, ErrStat, ErrMsg) IF (ErrStat /= CD_HCDYN_OK) RETURN model%tw_spsi(iend) = psi diff --git a/src/CableDyn_HermiteCableStatic.f90 b/src/CableDyn_HermiteCableStatic.f90 index 29f2b3bb..f4eac2af 100644 --- a/src/CableDyn_HermiteCableStatic.f90 +++ b/src/CableDyn_HermiteCableStatic.f90 @@ -743,6 +743,11 @@ SUBROUTINE CD_HermiteCable_Static_Solve(l0, EA, EI, w, seed, fixed_dofs, seabed_ IF (es /= CD_HTORS_OK) THEN CALL fail(TRIM(ErrMsg)); RETURN END IF + ! a free end (infinite end compliance): the static torque is zero, nothing to solve + IF (ANY(torsion%end_free)) THEN + CALL fail('torsion: a line free in torsion at one end carries no static torque; solve it without '// & + 'torsion'); RETURN + END IF tors_c = CD_HermiteTorsion_Compliance(torsion, l0) IF (.NOT. (tors_c > CD_ZERO) .OR. .NOT. CD_Is_Finite(tors_c)) THEN CALL fail('torsion: the line compliance must be finite and positive'); RETURN diff --git a/src/CableDyn_HermiteTorsion.f90 b/src/CableDyn_HermiteTorsion.f90 index d93094f6..6f97c2f3 100644 --- a/src/CableDyn_HermiteTorsion.f90 +++ b/src/CableDyn_HermiteTorsion.f90 @@ -109,6 +109,12 @@ MODULE CableDyn_HermiteTorsion REAL(wp) :: ends(3, 4) = CD_ZERO !! Torsional end compliances 1/k_t [rad/(N m)] at ends 1 and 2 (0 for a rigid end). REAL(wp) :: end_compliance(2) = CD_ZERO + !! A free end (no torsional restraint, at most one of the two): an infinite end compliance. + !! The line then carries no condensed torque, C = +Inf, and its twist is carried by the nodal + !! twist alone (irn required): torque-tension coupling and the torsional inertia twist it, and + !! the free end turns by the element twists, sum (M_e l0/GJ - (K/GJ)(l_e - l0)). Its end + !! frame is a gauge only (no spring, no held angle) and end_compliance there stays 0. + LOGICAL :: end_free(2) = .FALSE. !! Torsional stiffness GJ of every element [N m^2/rad] (the line compliance is the sum of !! l0/GJ over the elements plus the end compliances). REAL(wp), ALLOCATABLE :: gj(:) @@ -167,15 +173,20 @@ MODULE CableDyn_HermiteTorsion ! ------------------------------------------------------------------------------------------ PURE REAL(wp) FUNCTION CD_HermiteTorsion_Compliance(tors, l0) RESULT(c) - !! Line torsional compliance C = sum_e l0_e/GJ_e + 1/k_t1 + 1/k_t2 [rad/(N m)]. Meant for a - !! description that passed CD_HermiteTorsion_Validate: without one GJ per element it - !! returns NaN (so no caller can take the end compliances alone for the line's). - USE, INTRINSIC :: IEEE_ARITHMETIC, ONLY: IEEE_VALUE, IEEE_QUIET_NAN + !! Line torsional compliance C = sum_e l0_e/GJ_e + 1/k_t1 + 1/k_t2 [rad/(N m)]; +Inf with a + !! free end (end_free), so the condensed torque (Phi - Theta)/C and stiffness 1/C are zero. + !! Meant for a description that passed CD_HermiteTorsion_Validate: without one GJ per + !! element it returns NaN (so no caller can take the end compliances alone for the line's). + USE, INTRINSIC :: IEEE_ARITHMETIC, ONLY: IEEE_VALUE, IEEE_QUIET_NAN, IEEE_POSITIVE_INF TYPE(CD_HermiteTorsionType), INTENT(IN) :: tors REAL(wp), INTENT(IN) :: l0(:) c = IEEE_VALUE(c, IEEE_QUIET_NAN) IF (.NOT. ALLOCATED(tors%gj)) RETURN IF (SIZE(tors%gj) /= SIZE(l0)) RETURN + IF (ANY(tors%end_free)) THEN + c = IEEE_VALUE(c, IEEE_POSITIVE_INF) + RETURN + END IF c = tors%end_compliance(1) + tors%end_compliance(2) + SUM(l0/tors%gj) END FUNCTION CD_HermiteTorsion_Compliance @@ -282,6 +293,19 @@ PURE SUBROUTINE CD_HermiteTorsion_Validate(tors, l0, ErrStat, ErrMsg) ErrMsg = 'torsion: end compliances must be non-negative' RETURN END IF + IF (ALL(tors%end_free)) THEN + ErrMsg = 'torsion: both ends are free, so the line carries no torque (describe it without torsion)' + RETURN + END IF + IF (ANY(tors%end_free .AND. tors%end_compliance > CD_ZERO)) THEN + ErrMsg = 'torsion: a free end has no end compliance' + RETURN + END IF + IF (ANY(tors%end_free) .AND. .NOT. ALLOCATED(tors%irn)) THEN + ErrMsg = 'torsion: a line free at one end carries no condensed torque; its twist needs the nodal twist '// & + '(the polar rotary inertia irn)' + RETURN + END IF IF (tors%quadrature_order < 1 .OR. tors%quadrature_order > NG_MAX) THEN ErrMsg = 'torsion: quadrature order must lie in [1,6]' RETURN diff --git a/src/CableDyn_OpenFAST_Aggregate.f90 b/src/CableDyn_OpenFAST_Aggregate.f90 index 53446968..2652e6b8 100644 --- a/src/CableDyn_OpenFAST_Aggregate.f90 +++ b/src/CableDyn_OpenFAST_Aggregate.f90 @@ -57,7 +57,7 @@ MODULE CableDyn_OpenFAST_Aggregate CD_HFMF_End, CD_HFMF_OK, CD_HFMF_BADINPUT, & CD_HFMF_Snapshot, CD_HFMF_Restore, & CD_HFMF_Set_Held_Fluid, CD_HFMF_NNodes, CD_HFMF_GetNodePositions, & - CD_HFMF_Set_SegmentLength + CD_HFMF_Set_SegmentLength, CD_HFMF_Refresh_Acceleration USE CableDyn_HermiteCableDynamic, ONLY: CD_HermiteCable_Dyn_Profile_Enabled, CD_HermiteCableControlSaveType, & CD_HermiteCable_Dyn_Save_Control, CD_HermiteCable_Dyn_Restore_Control, & CD_HCDYN_OK @@ -82,7 +82,10 @@ MODULE CableDyn_OpenFAST_Aggregate CD_Rod_NHost, CD_Rod_SetHostKinematics, CD_Rod_GetHostKinematics, & CD_Rod_ScatterHostPoints, CD_Rod_HostWrench, CD_Rod_Stage, CD_Rod_Unstage, & CD_Rigid6_StartAccelerations, CD_Rod_StartAccelerations, & - CD_Deck_Range_Sample_Aggregate, CD_Deck_Range_Write + CD_Deck_Range_Sample_Aggregate, CD_Deck_Range_Write, & + CD_MotionRuntimeType, CD_Motion_Active, CD_Motion_NColumns, & + CD_Motion_Has_Rotation, CD_Motion_Has_Roll, CD_Motion_Kinematics, & + CD_Motion_Deck_Positions, CD_Motion_End USE CableDyn_RangeOutput, ONLY: CD_RangeSet, CD_Range_End USE CableDyn_System, ONLY: CD_Get_System_Substep_Counts, CD_System_NLines, CD_System_Line_NDOF, & CD_Get_System_Line_State, & @@ -121,6 +124,8 @@ MODULE CableDyn_OpenFAST_Aggregate PUBLIC :: CD_AGG_Get_Failure_Flags, CD_AGG_Set_Failure_Flags PUBLIC :: CD_AGG_NCtrlChans, CD_AGG_Apply_LineControl PUBLIC :: CD_AGG_IsInitialized + ! The deck's own prescribed motion on the standalone mixed route (not a coupled-host surface) + PUBLIC :: CD_AGG_HasMotion, CD_AGG_MotionKinematics, CD_AGG_Refresh_Accelerations ! OpenFAST CompMooring=5 output-channel surface (consumed by CableDyn_OF): the deck OUTPUTS ! channel count/header/unit for registration, and the per-channel evaluator for CalcOutput. PUBLIC :: CD_AGG_NumChannels @@ -160,6 +165,13 @@ MODULE CableDyn_OpenFAST_Aggregate REAL(wp), ALLOCATABLE :: mv_pos(:, :), mv_vel(:, :), mv_acc(:, :), mv_load(:, :), mv_moment(:, :) REAL(wp), ALLOCATABLE :: mv_omega(:, :), mv_alpha(:, :) REAL(wp), ALLOCATABLE :: mv_orient(:, :, :) + ! The roll of each moving column of a step (CD_AGG_Step_Moving roll), and the static + ! imposed twist Phi_0 = Pretwist(B) - Pretwist(A) of each cable restrained in torsion: the + ! step's imposed twist is Phi_0 - roll. + REAL(wp), ALLOCATABLE :: mv_roll(:) + REAL(wp), ALLOCATABLE :: cable_phi0(:) + ! The deck's own prescribed motion (standalone mixed route; inactive for a coupled host). + TYPE(CD_MotionRuntimeType) :: motion ! Per-cable status staging lets independent finite-EI cables advance concurrently while ! preserving deterministic, cable-order error reporting after the parallel region. INTEGER, ALLOCATABLE :: cable_stat(:) @@ -259,7 +271,7 @@ MODULE CableDyn_OpenFAST_Aggregate SUBROUTINE CD_AGG_Init_From_Deck(self, deck_path, dt, ErrStat, ErrMsg, env_gravity, env_rho_water, env_wtrdpth, & ptfm_init, external_fluid, coupled_positions, & n_turbines, turbine_ref_pos, farm_ptfm_init, forbid_deck_ambient, run_tmax, & - range_files, host_orientation, static_current) + range_files, host_orientation, static_current, prescribed_motion, static_run) !! Build the aggregate from ONE mixed deck: partition its lines into {EI=0 mooring} !! and {finite-EI cable}, wrap the mooring subset into a CD_FMF, and own one CD_HFMF !! per cable. Same signature philosophy as CD_FMF_Init_From_Deck (host environment @@ -301,6 +313,12 @@ SUBROUTINE CD_AGG_Init_From_Deck(self, deck_path, dt, ErrStat, ErrMsg, env_gravi ! static_current (4, n): the host's steady current (z, ux, uy, uz by ascending z) for the ! static solves only (see CD_Init_Deck_Aggregate) REAL(wp), INTENT(IN), OPTIONAL :: static_current(:, :) + ! prescribed_motion: the caller marches the deck's own motionFile or vesselMotion table + ! (CD_AGG_MotionKinematics; the standalone driver, see CD_Init_Deck_Aggregate) + LOGICAL, INTENT(IN), OPTIONAL :: prescribed_motion + ! static_run: the caller marches no step (the standalone TMax = 0 run; see + ! CD_Init_Deck_Aggregate) + LOGICAL, INTENT(IN), OPTIONAL :: static_run ! Both bundles (about 70 KB together) are built on the heap: initialisation runs on the ! thread of the calling host, whose stack size CableDyn does not choose. @@ -340,7 +358,8 @@ SUBROUTINE CD_AGG_Init_From_Deck(self, deck_path, dt, ErrStat, ErrMsg, env_gravi turbine_ref_pos=turbine_ref_pos, farm_ptfm_init=farm_ptfm_init, & forbid_deck_ambient=forbid_deck_ambient, run_tmax=run_tmax, & range_files=range_files, host_orientation=host_orientation, & - static_current=static_current) + static_current=static_current, prescribed_motion=prescribed_motion, & + static_run=static_run) IF (PRESENT(external_fluid)) THEN candidate%built_extfluid = external_fluid END IF @@ -458,6 +477,7 @@ SUBROUTINE CD_AGG_Init_From_Deck(self, deck_path, dt, ErrStat, ErrMsg, env_gravi IF (ALLOCATED(parts%line_is_cable)) CALL MOVE_ALLOC(parts%line_is_cable, candidate%line_is_cable) IF (ALLOCATED(parts%line_obj_index)) CALL MOVE_ALLOC(parts%line_obj_index, candidate%line_obj_index) candidate%ranges = parts%ranges + candidate%motion = parts%motion IF (ALLOCATED(parts%cable_points)) THEN CALL MOVE_ALLOC(parts%cable_points, candidate%cable_points) ELSE @@ -501,13 +521,19 @@ SUBROUTINE CD_AGG_Init_From_Deck(self, deck_path, dt, ErrStat, ErrMsg, env_gravi ALLOCATE (candidate%mv_pos(3, ncp_total), candidate%mv_vel(3, ncp_total), candidate%mv_acc(3, ncp_total), & candidate%mv_load(3, ncp_total), candidate%mv_moment(3, ncp_total), & candidate%mv_omega(3, ncp_total), candidate%mv_alpha(3, ncp_total), & - candidate%mv_orient(3, 3, ncp_total), STAT=istat) + candidate%mv_orient(3, 3, ncp_total), candidate%mv_roll(ncp_total), & + candidate%cable_phi0(candidate%ncable), STAT=istat) IF (istat /= 0) THEN ErrStat = CD_AGG_ALLOCFAIL ErrMsg = 'CableDyn_OpenFAST_Aggregate: moving-surface scratch allocation failed' CALL CD_AGG_End(candidate, es, em) RETURN END IF + candidate%mv_roll = CD_ZERO + candidate%cable_phi0 = CD_ZERO + DO ich = 1, candidate%ncable + IF (candidate%cables(ich)%line%torsion%active) candidate%cable_phi0(ich) = candidate%cables(ich)%line%torsion%phi + END DO IF (candidate%ncable > 0) THEN ALLOCATE (candidate%cable_stat(candidate%ncable), candidate%cable_msg(candidate%ncable), STAT=istat) IF (istat /= 0) THEN @@ -537,6 +563,13 @@ SUBROUTINE CD_AGG_Init_From_Deck(self, deck_path, dt, ErrStat, ErrMsg, env_gravi END IF candidate%dt = dt ! freeze the coupling step for the fixed-dt Step_Moving guard candidate%initialized = .TRUE. + IF (CD_Motion_Active(candidate%motion)) THEN + CALL check_motion_columns(candidate, ErrStat, ErrMsg) + IF (ErrStat /= CD_AGG_OK) THEN + CALL CD_AGG_End(candidate, es, em) + RETURN + END IF + END IF CALL CD_AGG_End(self, es, em) self = candidate CALL CD_AGG_End(candidate, es, em) @@ -921,7 +954,7 @@ SUBROUTINE CD_AGG_UpdateStates_Moving(self, position, velocity, acceleration, Er END SUBROUTINE CD_AGG_UpdateStates_Moving SUBROUTINE CD_AGG_Step_Moving(self, dt, position, velocity, acceleration, converged, stalled, n_iter, ErrStat, & - ErrMsg, t_committed, orientation, angular_velocity, angular_acceleration) + ErrMsg, t_committed, orientation, angular_velocity, angular_acceleration, roll) !! Advance every owned object one coupling step of dt with the moving points prescribed. !! The EI=0 system columns route to CD_FMF_Step_Moving; each cable's fairlead column !! routes to CD_HFMF_UpdateStates (the implicit prescribed-motion step). Aggregate @@ -951,9 +984,16 @@ SUBROUTINE CD_AGG_Step_Moving(self, dt, position, velocity, acceleration, conver REAL(wp), INTENT(IN), OPTIONAL :: t_committed REAL(wp), INTENT(IN), OPTIONAL :: orientation(:, :, :) REAL(wp), INTENT(IN), OPTIONAL :: angular_velocity(:, :), angular_acceleration(:, :) + ! roll (ncp_total) [rad]: the roll of the line end frames at each moving point about their + ! directors at t + dt, from the static state, right-handed about the tangent into the line + ! (the standalone motionFile roll column). A cable restrained in torsion takes the imposed + ! twist Phi = Phi_0 - roll of its column, Phi_0 = Pretwist(B) - Pretwist(A), as on the + ! standalone cubic-Hermite route; the other columns carry no twist and ignore it. Without + ! it the imposed twist is held. + REAL(wp), INTENT(IN), OPTIONAL :: roll(:) INTEGER :: c, col, es, nsys, nsub - LOGICAL :: csys, ssys, staged + LOGICAL :: csys, ssys, staged, use_roll REAL(wp) :: t_start CHARACTER(1024) :: em @@ -1021,12 +1061,27 @@ SUBROUTINE CD_AGG_Step_Moving(self, dt, position, velocity, acceleration, conver RETURN END IF END IF + use_roll = PRESENT(roll) + IF (use_roll) THEN + IF (SIZE(roll) /= ncp_all(self)) THEN + ErrStat = CD_AGG_BADINPUT + ErrMsg = 'CableDyn_OpenFAST_Aggregate: roll must be shaped (ncp_total)' + RETURN + END IF + IF (.NOT. CD_All_Finite(roll)) THEN + ErrStat = CD_AGG_BADINPUT + ErrMsg = 'CableDyn_OpenFAST_Aggregate: roll must be finite' + RETURN + END IF + END IF self%mv_omega = CD_ZERO self%mv_alpha = CD_ZERO IF (PRESENT(angular_velocity)) THEN self%mv_omega = angular_velocity self%mv_alpha = angular_acceleration END IF + self%mv_roll = CD_ZERO + IF (use_roll) self%mv_roll = roll ! stage: snapshot every sub-object before any of them steps (multi-object only; a ! single sub-object is already atomic -- the hot mooring-only path skips this). ! A Rigid6 deck is single-subobject (ncable == 0) yet still needs staging: its branch @@ -1178,30 +1233,29 @@ SUBROUTINE CD_AGG_Step_Moving(self, dt, position, velocity, acceleration, conver n_iter = MAX(n_iter, nsys) END IF IF (PRESENT(orientation)) THEN - !$OMP PARALLEL DEFAULT(NONE) SHARED(self, position, velocity, acceleration, orientation) & + !$OMP PARALLEL DEFAULT(NONE) SHARED(self, position, velocity, acceleration, orientation, use_roll) & !$OMP PRIVATE(c, col, es, em) & !$OMP IF(self%ncable > 1 .AND. .NOT. CD_HermiteCable_Dyn_Profile_Enabled()) CALL CD_Fatal_Thread_Init() ! this thread can report its own stack overflow !$OMP DO SCHEDULE(STATIC) DO c = 1, self%ncable col = self%ncp_sys + c - CALL CD_HFMF_UpdateStates(self%cables(c), position(:, col), velocity(:, col), acceleration(:, col), & - es, em, orientation(:, :, col), self%mv_omega(:, col), self%mv_alpha(:, col)) + CALL step_cable(self, c, position(:, col), velocity(:, col), acceleration(:, col), use_roll, es, em, & + orientation(:, :, col)) self%cable_stat(c) = es self%cable_msg(c) = em END DO !$OMP END DO !$OMP END PARALLEL ELSE - !$OMP PARALLEL DEFAULT(NONE) SHARED(self, position, velocity, acceleration) PRIVATE(c, col, es, em) & + !$OMP PARALLEL DEFAULT(NONE) SHARED(self, position, velocity, acceleration, use_roll) & + !$OMP PRIVATE(c, col, es, em) & !$OMP IF(self%ncable > 1 .AND. .NOT. CD_HermiteCable_Dyn_Profile_Enabled()) CALL CD_Fatal_Thread_Init() ! this thread can report its own stack overflow !$OMP DO SCHEDULE(STATIC) DO c = 1, self%ncable col = self%ncp_sys + c - CALL CD_HFMF_UpdateStates(self%cables(c), position(:, col), velocity(:, col), acceleration(:, col), es, em, & - u_angular_velocity=self%mv_omega(:, col), & - u_angular_acceleration=self%mv_alpha(:, col)) + CALL step_cable(self, c, position(:, col), velocity(:, col), acceleration(:, col), use_roll, es, em) self%cable_stat(c) = es self%cable_msg(c) = em END DO @@ -1270,6 +1324,146 @@ SUBROUTINE rewind_step() END SUBROUTINE rewind_step END SUBROUTINE CD_AGG_Step_Moving + SUBROUTINE step_cable(self, c, u_pos, u_vel, u_acc, use_roll, ErrStat, ErrMsg, u_orientation) + !! One cable's implicit step to its column's t + dt kinematics (CD_HFMF_UpdateStates): the + !! parent orientation when given, the column's angular rates, and with use_roll the imposed + !! twist Phi_0 - roll of a cable restrained in torsion. Touches cable c alone, so the cables + !! step concurrently. + TYPE(CD_AGG_ModuleType), INTENT(INOUT) :: self + INTEGER, INTENT(IN) :: c + REAL(wp), INTENT(IN) :: u_pos(3), u_vel(3), u_acc(3) + LOGICAL, INTENT(IN) :: use_roll + INTEGER, INTENT(OUT) :: ErrStat + CHARACTER(*), INTENT(OUT) :: ErrMsg + REAL(wp), INTENT(IN), OPTIONAL :: u_orientation(3, 3) + INTEGER :: col + REAL(wp) :: twist + col = self%ncp_sys + c + IF (use_roll .AND. self%cables(c)%line%torsion%active) THEN + twist = self%cable_phi0(c) - self%mv_roll(col) + IF (PRESENT(u_orientation)) THEN + CALL CD_HFMF_UpdateStates(self%cables(c), u_pos, u_vel, u_acc, ErrStat, ErrMsg, u_orientation, & + self%mv_omega(:, col), self%mv_alpha(:, col), u_twist=twist) + ELSE + CALL CD_HFMF_UpdateStates(self%cables(c), u_pos, u_vel, u_acc, ErrStat, ErrMsg, & + u_angular_velocity=self%mv_omega(:, col), & + u_angular_acceleration=self%mv_alpha(:, col), u_twist=twist) + END IF + ELSE IF (PRESENT(u_orientation)) THEN + CALL CD_HFMF_UpdateStates(self%cables(c), u_pos, u_vel, u_acc, ErrStat, ErrMsg, u_orientation, & + self%mv_omega(:, col), self%mv_alpha(:, col)) + ELSE + CALL CD_HFMF_UpdateStates(self%cables(c), u_pos, u_vel, u_acc, ErrStat, ErrMsg, & + u_angular_velocity=self%mv_omega(:, col), & + u_angular_acceleration=self%mv_alpha(:, col)) + END IF + END SUBROUTINE step_cable + + LOGICAL FUNCTION CD_AGG_HasMotion(self) RESULT(has) + !! The aggregate carries the deck's own prescribed motion (Init prescribed_motion). + TYPE(CD_AGG_ModuleType), INTENT(IN) :: self + has = self%initialized .AND. CD_Motion_Active(self%motion) + END FUNCTION CD_AGG_HasMotion + + SUBROUTINE CD_AGG_MotionKinematics(self, time_index, position, velocity, acceleration, orientation, & + angular_velocity, angular_acceleration, roll, has_rotation, has_roll, & + ErrStat, ErrMsg) + !! Grid row time_index (1 = t 0) of the deck's prescribed motion over the moving surface, + !! shaped as CD_AGG_Step_Moving takes it: translations (3, ncp_total), the global-to-parent + !! DCM (3, 3, ncp_total) with the global-axis angular velocity and acceleration (3, + !! ncp_total), and the roll (ncp_total). has_rotation: a vesselMotion table, whose + !! orientation and rates the step takes (the fairlead end connection and torsion frames + !! turn with the vessel, as on the standalone cubic-Hermite route); has_roll: a motionFile + !! roll column the step takes as roll. Without them (motionFile point rows) the frames are + !! held and the step takes the translations alone. + TYPE(CD_AGG_ModuleType), INTENT(IN) :: self + INTEGER, INTENT(IN) :: time_index + REAL(wp), INTENT(OUT) :: position(:, :), velocity(:, :), acceleration(:, :) + REAL(wp), INTENT(OUT) :: orientation(:, :, :), angular_velocity(:, :), angular_acceleration(:, :), roll(:) + LOGICAL, INTENT(OUT) :: has_rotation, has_roll + INTEGER, INTENT(OUT) :: ErrStat + CHARACTER(*), INTENT(OUT) :: ErrMsg + INTEGER :: es + CHARACTER(1024) :: em + has_rotation = .FALSE. + has_roll = .FALSE. + IF (.NOT. require_initialized(self, ErrStat, ErrMsg)) RETURN + IF (.NOT. CD_Motion_Active(self%motion)) THEN + ErrStat = CD_AGG_BADINPUT + ErrMsg = 'CableDyn_OpenFAST_Aggregate: the aggregate carries no prescribed motion' + RETURN + END IF + CALL CD_Motion_Kinematics(self%motion, time_index, position, velocity, acceleration, orientation, & + angular_velocity, angular_acceleration, roll, es, em) + IF (es /= CD_DECKDRV_OK) THEN + CALL map_deck_status(es, em, ErrStat, ErrMsg) + RETURN + END IF + has_rotation = CD_Motion_Has_Rotation(self%motion) + has_roll = CD_Motion_Has_Roll(self%motion) + ErrStat = CD_AGG_OK + ErrMsg = '' + END SUBROUTINE CD_AGG_MotionKinematics + + SUBROUTINE CD_AGG_Refresh_Accelerations(self, ErrStat, ErrMsg) + !! Recompute every cable's free-node acceleration from its complete residual at the + !! committed state, keeping the coupled node's prescribed acceleration + !! (CD_HFMF_Refresh_Acceleration): after CD_AGG_UpdateStates_Moving installs the first row + !! of a prescribed motion, so the first step does not start from the static acceleration + !! (the standalone cubic-Hermite route's row-1 station). The EI = 0 system is unchanged. + TYPE(CD_AGG_ModuleType), INTENT(INOUT) :: self + INTEGER, INTENT(OUT) :: ErrStat + CHARACTER(*), INTENT(OUT) :: ErrMsg + INTEGER :: c, es + CHARACTER(1024) :: em + IF (.NOT. require_initialized(self, ErrStat, ErrMsg)) RETURN + DO c = 1, self%ncable + CALL CD_HFMF_Refresh_Acceleration(self%cables(c), es, em) + IF (es /= CD_HFMF_OK) THEN + CALL map_hfmf_status(es, em, ErrStat, ErrMsg) + RETURN + END IF + END DO + ErrStat = CD_AGG_OK + ErrMsg = '' + END SUBROUTINE CD_AGG_Refresh_Accelerations + + SUBROUTINE check_motion_columns(self, ErrStat, ErrMsg) + !! The prescribed-motion columns match the moving surface: one column per moving point, and + !! each column's driving point at that moving point's static position (a column map that + !! drifted from the aggregate's moving-set order would drive the wrong point). + TYPE(CD_AGG_ModuleType), INTENT(INOUT) :: self + INTEGER, INTENT(OUT) :: ErrStat + CHARACTER(*), INTENT(OUT) :: ErrMsg + INTEGER :: es, col + REAL(wp), ALLOCATABLE :: deck_pos(:, :) + CHARACTER(1024) :: em + IF (CD_Motion_NColumns(self%motion) /= ncp_all(self) .OR. self%nhost_rod + self%nhost_body > 0) THEN + ErrStat = CD_AGG_BADINPUT + ErrMsg = 'CableDyn_OpenFAST_Aggregate: the prescribed motion does not cover the moving surface' + RETURN + END IF + CALL CD_AGG_GetMovingPointMesh(self, self%mv_pos, self%mv_vel, self%mv_acc, self%mv_load, ErrStat, ErrMsg, & + cable_loads=.FALSE.) + IF (ErrStat /= CD_AGG_OK) RETURN + ALLOCATE (deck_pos(3, ncp_all(self))) + CALL CD_Motion_Deck_Positions(self%motion, deck_pos, es, em) + IF (es /= CD_DECKDRV_OK) THEN + CALL map_deck_status(es, em, ErrStat, ErrMsg) + RETURN + END IF + DO col = 1, ncp_all(self) + IF (ANY(ABS(deck_pos(:, col) - self%mv_pos(:, col)) > 1.0e-9_wp*(CD_ONE + MAXVAL(ABS(deck_pos(:, col)))))) THEN + ErrStat = CD_AGG_BADINPUT + WRITE (ErrMsg, '(A,I0,A)') 'CableDyn_OpenFAST_Aggregate: the prescribed motion of moving point ', col, & + ' is not keyed to that point' + RETURN + END IF + END DO + ErrStat = CD_AGG_OK + ErrMsg = '' + END SUBROUTINE check_motion_columns + SUBROUTINE CD_AGG_Snapshot(self, ErrStat, ErrMsg) !! Capture the committed state of EVERY sub-object (system + all cables), any !! composition -- the caller-facing twin of the internal staged snapshot (which the @@ -2020,6 +2214,9 @@ SUBROUTINE CD_AGG_End(self, ErrStat, ErrMsg) IF (ALLOCATED(self%mv_orient)) DEALLOCATE (self%mv_orient) IF (ALLOCATED(self%mv_omega)) DEALLOCATE (self%mv_omega) IF (ALLOCATED(self%mv_alpha)) DEALLOCATE (self%mv_alpha) + IF (ALLOCATED(self%mv_roll)) DEALLOCATE (self%mv_roll) + IF (ALLOCATED(self%cable_phi0)) DEALLOCATE (self%cable_phi0) + CALL CD_Motion_End(self%motion) IF (ALLOCATED(self%cable_stat)) DEALLOCATE (self%cable_stat) IF (ALLOCATED(self%cable_msg)) DEALLOCATE (self%cable_msg) IF (ALLOCATED(self%channels)) DEALLOCATE (self%channels) diff --git a/tests/test_control_torsion.f90 b/tests/test_control_torsion.f90 index e63a3ec6..850884ba 100644 --- a/tests/test_control_torsion.f90 +++ b/tests/test_control_torsion.f90 @@ -43,6 +43,15 @@ PROGRAM test_control_torsion !! (the CompMooring = 5 route; the standalone driver takes no CONTROL) initialises, its !! Torq1N1 follows GJ Twist1/L(t) through a haul-in ramp, and the shell's checkpoint recipe !! continues bit-identically. + !! O deck, a line restrained in torsion at one end only: a straight neutral cable (EA 1e7 N, + !! GJ|K 5e4 N m2|4e5 N m, Irn 1e-9 kg m) of L0 = 99 m held H = 100 m apart, free in torsion + !! at End A (the controlled fairlead) and, in turn, at End B, paid out by 0.2 m on a half + !! cosine over 2 s and held. With no torque the section is free to twist, so each element + !! twists by -(K/GJ)(l_e - l0_e) and the free end turns with the commanded length: + !! Twist1 = -(K/GJ)(H - L0 - dL(t)) at every step, with no torque at either end; over the + !! hold the tension, about which the undamped axial waves of the ramp ring, has the mean + !! (EA - K^2/GJ)(H - L0 - dL)/(L0 + dL) of a section free to twist (within 5e-4: the 2 s mean + !! of the 2.4e-3 ringing). USE CableDyn_Precision, ONLY: wp USE CableDyn_EndConnection, ONLY: CD_ENDCONN_RIGID USE CableDyn_HermiteTorsion, ONLY: CD_HermiteTorsionType, CD_HermiteTorsion_Line, CD_HermiteTorsion_Unwrap, & @@ -92,6 +101,8 @@ PROGRAM test_control_torsion CALL check_lag() CALL check_restart() CALL check_deck() + CALL check_deck_one_end(1) + CALL check_deck_one_end(2) IF (nfail > 0) THEN WRITE (*, '(A,I0,A)') 'FAIL: ', nfail, ' assertion(s) failed' @@ -1045,4 +1056,122 @@ SUBROUTINE check_deck() CALL CD_AGG_End(b, es, em) END SUBROUTINE check_deck + ! ------------------------------------------------------------------------------------------ + SUBROUTINE check_deck_one_end(kfree) + !! O: the controlled line free in torsion at deck End kfree (1 = A, the fairlead, 2 = B). + REAL(wp), PARAMETER :: DT = 0.05_wp, GJD = 5.0e4_wp, KD = 4.0e5_wp, EAD = 1.0e7_wp, H0 = 100.0_wp, & + L0D = 99.0_wp, DLMAX = 0.2_wp, TR = 2.0_wp, DEG = PI/180.0_wp + INTEGER, PARAMETER :: NSTEP = 80 + INTEGER, INTENT(IN) :: kfree + TYPE(CD_AGG_ModuleType) :: a + REAL(wp) :: pos(3, 1), vel(3, 1), acc(3, 1), load(3, 1), orient(3, 3, 1), omega(3, 1), alpha(3, 1) + REAL(wp) :: dl, dldot, tw, tqa, tqb, ten, tw_ref, ten_ref, e_tw, e_tq, e_ten, t, ten_sum + INTEGER :: es, ni, k, u, n_hold + LOGICAL :: cv, st + CHARACTER(512) :: em + CHARACTER(160) :: ltype + CHARACTER(2) :: tag + tag = MERGE('A ', 'B ', kfree == 1) + WRITE (ltype, '(A,ES24.16,A)') 'cab 0.2 ', 1025.0_wp*0.25_wp*PI*0.04_wp, & + ' 1.0e7 0.0 1.0e6 1.0e8 5.0e4|4.0e5 1.0 1.0e-9 0.0 0.0 0.0 0.0' + OPEN (NEWUNIT=u, FILE='ctl_torsion_one_end.dat', STATUS='REPLACE', ACTION='WRITE') + WRITE (u, '(A)') 'controlled line restrained in torsion at one end' + WRITE (u, '(A)') '--- LINE TYPES ---' + WRITE (u, '(A)') 'Name Diam Mass EA BA EI GAs GJ Irt Irn Cdn Cdt Can Cat' + WRITE (u, '(A)') '(-) (m) (kg/m) (N) (-) (Nm2) (N) (Nm2) (kgm) (kgm) (-) (-) (-) (-)' + WRITE (u, '(A)') TRIM(ltype) + WRITE (u, '(A)') '--- POINTS ---' + WRITE (u, '(A)') 'ID Type X Y Z Mass Vol CdA Ca' + WRITE (u, '(A)') '(-) (-) (m) (m) (m) (kg) (m3) (m2) (-)' + WRITE (u, '(A)') '1 Coupled 0.0 0.0 -50.0 0 0 0 0' + WRITE (u, '(A)') '2 Fixed 100.0 0.0 -50.0 0 0 0 0' + WRITE (u, '(A)') '--- LINES ---' + WRITE (u, '(A)') 'ID NodeA NodeB Outputs' + WRITE (u, '(A)') '(-) (-) (-) (-)' + WRITE (u, '(A)') '1 1 2 -' + WRITE (u, '(A)') '--- SECTIONS ---' + WRITE (u, '(A)') 'LineID LineType Length NumSegs' + WRITE (u, '(A)') '(-) (-) (m) (-)' + WRITE (u, '(A)') '1 cab 99.0 40' + WRITE (u, '(A)') '--- END CONNECTIONS ---' + WRITE (u, '(A)') 'LineID End Stiffness EzX EzY EzZ TorsStiffness NxX NxY NxZ Pretwist' + WRITE (u, '(A)') '(-) (-) (N-m/rad) (-) (-) (-) (N-m/rad) (-) (-) (-) (deg)' + IF (kfree == 1) THEN + WRITE (u, '(A)') '1 A Rigid 1 0 0 Free 0 0 1' + WRITE (u, '(A)') '1 B Rigid 1 0 0 Rigid 0 0 1 30' + ELSE + WRITE (u, '(A)') '1 A Rigid 1 0 0 Rigid 0 0 1 -30' + WRITE (u, '(A)') '1 B Rigid 1 0 0 Free 0 0 1' + END IF + WRITE (u, '(A)') '--- CONTROL ---' + WRITE (u, '(A)') 'ChannelID Line(s)' + WRITE (u, '(A)') '(-) (-)' + WRITE (u, '(A)') '1 1' + WRITE (u, '(A)') '--- OPTIONS ---' + WRITE (u, '(A)') '9.80665 g' + WRITE (u, '(A)') '1025.0 rhoW' + WRITE (u, '(A)') '0.05 dtM' + WRITE (u, '(A)') '--- OUTPUTS ---' + WRITE (u, '(A)') 'Twist1' + WRITE (u, '(A)') 'Torq1N1' + WRITE (u, '(A)') 'Torq1N41' + WRITE (u, '(A)') 'FairTen1' + WRITE (u, '(A)') '--- END ---' + CLOSE (u) + CALL CD_AGG_Init_From_Deck(a, 'ctl_torsion_one_end.dat', DT, es, em, host_orientation=.TRUE.) + CALL require(es == CD_AGG_OK, 'O (End '//TRIM(tag)//' free): a CONTROL deck on a line restrained at one end '// & + 'initialises with its twist channels: '//TRIM(em)) + IF (es /= CD_AGG_OK) RETURN + CALL require(a%ctrl_is_cable(1) .AND. a%cables(1)%line%tw_active .AND. & + a%cables(1)%line%torsion%end_free(3 - kfree), & + 'O: the row controls the nodal-twist cable, free at the deck end') + CALL CD_AGG_GetMovingPointMesh(a, pos, vel, acc, load, es, em, orientation=orient) + omega = 0.0_wp + alpha = 0.0_wp + e_tw = 0.0_wp + e_tq = 0.0_wp + e_ten = 0.0_wp + ten_sum = 0.0_wp + n_hold = 0 + DO k = 1, NSTEP + t = DT*REAL(k, wp) + IF (t < TR) THEN + dl = DLMAX*0.5_wp*(1.0_wp - COS(PI*t/TR)) + dldot = DLMAX*0.5_wp*PI/TR*SIN(PI*t/TR) + ELSE + dl = DLMAX + dldot = 0.0_wp + END IF + CALL CD_AGG_Apply_LineControl(a, [dl], [dldot], es, em) + CALL require(es == CD_AGG_OK, 'O: command: '//TRIM(em)) + CALL CD_AGG_Step_Moving(a, DT, pos, vel, acc, cv, st, ni, es, em, orientation=orient, & + angular_velocity=omega, angular_acceleration=alpha) + CALL require(es == CD_AGG_OK .AND. cv, 'O: step: '//TRIM(em)) + IF (es /= CD_AGG_OK) RETURN + CALL CD_AGG_CalcOutput(a, es, em) + CALL CD_AGG_EvalChannel(a, 1, tw, es, em) + CALL CD_AGG_EvalChannel(a, 2, tqa, es, em) + CALL CD_AGG_EvalChannel(a, 3, tqb, es, em) + CALL CD_AGG_EvalChannel(a, 4, ten, es, em) + tw_ref = -(KD/GJD)*(H0 - L0D - dl)/DEG + e_tw = MAX(e_tw, ABS(tw - tw_ref)/ABS(tw_ref)) + ! against the torque K eps the coupling would give a section held from twisting + e_tq = MAX(e_tq, ABS(tqa), ABS(tqb)) + IF (t > TR) THEN + ten_sum = ten_sum + ten + n_hold = n_hold + 1 + END IF + END DO + ten_ref = (EAD - KD**2/GJD)*(H0 - L0D - DLMAX)/(L0D + DLMAX) + e_ten = ABS(ten_sum/REAL(n_hold, wp) - ten_ref)/ten_ref + e_tq = e_tq/(KD*(H0 - L0D - DLMAX)/(L0D + DLMAX)) + WRITE (*, '(A,A,A,F12.5,A,F12.5,A,3ES10.3)') 'O deck, End ', TRIM(tag), ' free, paid out 0.2 m: Twist1 ', tw, & + ' deg (-(K/GJ)(H - L) ', tw_ref, '); max rel. errors twist, |torque| / K eps, mean held tension ', e_tw, & + e_tq, e_ten + CALL require(e_tw <= 1.0e-6_wp, 'O: the free end turns with the commanded length, -(K/GJ)(H - L(t))') + CALL require(e_tq <= 1.0e-6_wp, 'O: no torque at either end') + CALL require(e_ten <= 5.0e-4_wp, 'O: the mean held tension is (EA - K^2/GJ) eps') + CALL CD_AGG_End(a, es, em) + END SUBROUTINE check_deck_one_end + END PROGRAM test_control_torsion diff --git a/tests/test_lin_torsion.f90 b/tests/test_lin_torsion.f90 index efd33dd4..c0bcdd5f 100644 --- a/tests/test_lin_torsion.f90 +++ b/tests/test_lin_torsion.f90 @@ -28,6 +28,14 @@ PROGRAM test_lin_torsion !! velocity of the platform about the line axis is Bt/L, the steady-roll torque of the !! march (test_nodal_twist_dynamic D), and it vanishes without the frame rates; the moment !! per unit angular acceleration is the held end section's polar inertia Irn l_e/2. + !! O one restrained end: the line of F free in torsion at End B (the anchor), then at End A + !! (the fairlead); the free end's angle is a state too (N of them), and the twist modes of + !! A are the clamped-free ones, the continuum's quarter-wave (2n - 1) pi/(2L) sqrt(GJ/Irn) + !! within the lumped-inertia error and the lumped chain's 2 sqrt(GJ/Irn)/h + !! sin((2n - 1) pi/(4N)) to 1e-6; a free end carries no torque, so the reduced roll + !! stiffness vanishes (to 1e-6 of GJ/L): with End B free the platform turns the line as a + !! whole (the feedthrough D, GJ/l_e, is cancelled by C A^-1 B), with End A free the platform + !! roll does not reach the line at all. USE CableDyn_Precision, ONLY: wp USE CableDyn_OpenFAST_Aggregate, ONLY: CD_AGG_ModuleType, CD_AGG_Init_From_Deck, CD_AGG_NMovingPoints, & CD_AGG_GetMovingPointMesh, CD_AGG_UpdateStates_Moving, & @@ -59,13 +67,15 @@ PROGRAM test_lin_torsion CALL check_condensed() CALL check_elastic_end() CALL check_frame_rates() + CALL check_free_end(2) + CALL check_free_end(1) IF (nfail > 0) THEN WRITE (*, '(A,I0,A)') 'FAIL: ', nfail, ' assertion(s) failed' ERROR STOP 1 END IF WRITE (*, '(A)') 'PASS: linearisation of a line restrained in torsion (modes, roll stiffness, condensed, '// & - 'elastic end, frame rates)' + 'elastic end, frame rates, one restrained end)' CONTAINS @@ -77,13 +87,13 @@ SUBROUTINE require(cond, label) WRITE (*, '(A)') 'FAIL: '//TRIM(label) END SUBROUTINE require - SUBROUTINE write_deck(path, irn_v, bt_v, tors_b) + SUBROUTINE write_deck(path, irn_v, bt_v, tors_b, tors_a) !! The straight vertical line, neutrally buoyant (mass rhoW pi d^2/4) and without drag or !! added mass, so the 0.5 % strain is uniform; Irn irn_v, torsional damping bt_v, and the - !! torsional restraint of End B tors_b (default Rigid). + !! torsional restraints of End B tors_b and End A tors_a (default Rigid). CHARACTER(*), INTENT(IN) :: path REAL(wp), INTENT(IN) :: irn_v, bt_v - CHARACTER(*), INTENT(IN), OPTIONAL :: tors_b + CHARACTER(*), INTENT(IN), OPTIONAL :: tors_b, tors_a INTEGER :: u CHARACTER(240) :: ltype CHARACTER(40) :: gj_col @@ -113,7 +123,11 @@ SUBROUTINE write_deck(path, irn_v, bt_v, tors_b) WRITE (u, '(A)') '--- END CONNECTIONS ---' WRITE (u, '(A)') 'LineID End Stiffness EzX EzY EzZ TorsStiffness NxX NxY NxZ Pretwist' WRITE (u, '(A)') '(-) (-) (N-m/rad) (-) (-) (-) (N-m/rad) (-) (-) (-) (deg)' - WRITE (u, '(A)') '1 A Pinned 0 0 -1 Rigid 1 0 0 0' + IF (PRESENT(tors_a)) THEN + WRITE (u, '(A)') '1 A Pinned 0 0 -1 '//tors_a//' 1 0 0 0' + ELSE + WRITE (u, '(A)') '1 A Pinned 0 0 -1 Rigid 1 0 0 0' + END IF IF (PRESENT(tors_b)) THEN WRITE (u, '(A)') '1 B Pinned 0 0 -1 '//tors_b//' 1 0 0 0' ELSE @@ -583,4 +597,57 @@ SUBROUTINE check_frame_rates() CALL require(.NOT. MAXVAL(ABS(b)) > 0.0_wp, 'R: the angular acceleration does not drive the line states') CALL CD_AGG_End(agg, es, em) END SUBROUTINE check_frame_rates + ! ------------------------------------------------------------------------------------------ + SUBROUTINE check_free_end(kfree) + !! O: the line of F free in torsion at deck End kfree (1 = A, 2 = B). + INTEGER, INTENT(IN) :: kfree + REAL(wp), ALLOCATABLE :: amat(:, :), cmom(:, :), b(:), omega(:) + REAL(wp) :: dmom(3), coupling, w_cont, w_disc, e_cont, e_disc, k_red, h, x + INTEGER :: n, es + LOGICAL :: ok + CHARACTER(512) :: em + CHARACTER(5) :: tag + tag = MERGE('End A', 'End B', kfree == 1) + IF (kfree == 1) THEN + CALL write_deck('lin_torsion_free.dat', IRN, 0.0_wp, tors_a='Free') + ELSE + CALL write_deck('lin_torsion_free.dat', IRN, 0.0_wp, tors_b='Free') + END IF + CALL setup('lin_torsion_free.dat', ok) + IF (.NOT. ok) RETURN + CALL require(agg%cables(1)%line%torsion%end_free(3 - kfree), 'O ('//tag//' free): the line is solved free there') + ! the held end's angle is not a state, the free end's is + CALL require(ntw == NE, 'O ('//tag//' free): the free end''s angle is a state') + IF (ntw /= NE) THEN + CALL CD_AGG_End(agg, es, em) + RETURN + END IF + ALLOCATE (amat(2*nx2, 2*nx2), cmom(3, 2*nx2), b(2*nx2), omega(ntw)) + CALL state_matrix(amat, cmom) + CALL twist_eigen(amat, omega, coupling) + h = L/REAL(NE, wp) + WRITE (*, '(A,A,A,I0,A,I0,A,ES10.3)') 'O: ', tag, ' free: ', 2*nx2, ' states (', 2*ntw, & + ' twist); twist-line coupling / block ', coupling + CALL require(coupling <= 1.0e-8_wp, 'O: the twist block is decoupled from the line states') + DO n = 1, 3 + x = REAL(2*n - 1, wp)*PI/(4.0_wp*REAL(NE, wp)) + w_cont = REAL(2*n - 1, wp)*PI/(2.0_wp*L)*SQRT(GJ/IRN) + w_disc = 2.0_wp/h*SQRT(GJ/IRN)*SIN(x) + e_cont = omega(n)/w_cont - 1.0_wp + e_disc = omega(n)/w_disc - 1.0_wp + WRITE (*, '(A,A,A,I0,A,F12.8,A,F12.8,A,ES10.3,A,F12.8,A,ES10.3,A)') 'O: ', tag, ' free: mode ', n, ' omega ', & + omega(n), ' rad/s; quarter-wave ', w_cont, ' (', e_cont, '); clamped-free chain ', w_disc, ' (', e_disc, ')' + CALL require(ABS(e_disc) <= 1.0e-6_wp, 'O: the twist mode matches the clamped-free chain') + ! the lumped-inertia chain lies x^2/6 below the continuum + CALL require(ABS(e_cont) <= 1.2_wp*x**2/6.0_wp + 1.0e-6_wp, & + 'O: the twist mode matches the quarter-wave (2n - 1) pi/(2L) sqrt(GJ/Irn)') + END DO + CALL input_columns(3, 1, b, dmom) + k_red = reduced(amat, cmom, b, dmom, 3) + WRITE (*, '(A,A,A,ES12.4,A,ES16.9,A,ES16.9)') 'O: ', tag, ' free: -(D - C A^-1 B) ', k_red, & + ' N m/rad (GJ/L ', GJ/L, '); feedthrough D alone ', -dmom(3) + CALL require(ABS(k_red) <= 1.0e-6_wp*GJ/L, 'O: a line free at one end has no roll stiffness') + CALL CD_AGG_End(agg, es, em) + END SUBROUTINE check_free_end + END PROGRAM test_lin_torsion diff --git a/tests/test_mixed_route_torsion.f90 b/tests/test_mixed_route_torsion.f90 new file mode 100644 index 00000000..57bf791d --- /dev/null +++ b/tests/test_mixed_route_torsion.f90 @@ -0,0 +1,810 @@ +! File: tests/test_mixed_route_torsion.f90 +! SPDX-License-Identifier: Apache-2.0 +! Copyright (c) 2026 Jae Hoon Seo, SMI Lab, Inha University +!> Torsion and prescribed motion on the standalone mixed route: a deck that mixes EI = 0 and +!> finite-EI lines without bodies, rods or Free/Connect points runs on the coupled aggregate, +!> marched by the standalone driver (the executable given as the first argument) through the +!> deck's motionFile or vesselMotion table. +!> 1. Vessel roll, pitch and heave from rest (vesselMotion) drive a sagging finite-EI line +!> clamped (Rigid) at both ends and restrained in torsion (Pretwist 20 deg at End B), run +!> alone on the standalone cubic-Hermite route and beside a moving EI = 0 chain on the mixed +!> route. Torq, Twist and the mid-line node agree to the printed precision of the .out +!> (8 digits), the fairlead and anchor tension, fairlead inclination and End A bend moment +!> (the Rigid clamp turns with the vessel on both routes) to 5e-5 of their range: the +!> coupled cables step with the coupled Newton controls (relative tolerance 5e-3, a fresh +!> factor every step), the standalone line with the deck's (1e-8, a carried factor). With +!> the aggregate cables given the standalone controls the mixed route reproduces every +!> channel of the standalone route to the printed precision. The same chain moved by a +!> motionFile of the same point translations holds the frames: the End A bend moment and +!> the twist then differ from the turning-vessel run (the rotation is not dropped). +!> 2. A motionFile surge with a roll column (End A rolls 20 deg about its director, from +!> rest) gives the same agreement between the two routes. +!> 3. Quasi-static torsion of a straight neutral line on the mixed route, End A held, or rolled +!> slowly about the line axis by a vessel or by the roll column: Twist1 = Pretwist - roll +!> and Torq = GJ Twist / L at both ends at every step (1e-6 GJ). +!> 4. A non-zero roll column at the chain's point (no line restrained in torsion there) is +!> refused by name on the mixed route. +!> 5. TMax = 0 with a motionFile whose first row is 2 cm off the deck fairlead: both routes write +!> the t = 0 row at that installed row (the fairlead element takes the 2 cm against the +!> static interior: FairTen 3.5 MN against 29 kN) and agree to the printed precision, and +!> both write the .static.out of the static solve (fairlead x = 0) before it. +!> 6. Without the force blend a line restrained in torsion runs a static mixed deck (TMax = 0, +!> no step) and its torque, as the single-line route, and a dynamic one stops by name; so +!> does a line restrained at one end only (static: Torq/Twist channels, no torque at the +!> free end), which the caller-driven parse must still resolve as a static run. +!> 7. ATTACHMENTS: the gate 2 line carrying three buoyancy modules (ATTACHMENTS, with drag and +!> added mass), its torsion stage after the attachment polish on both routes, gives the gate 2 +!> agreement between the single-line route and the mixed route beside the chain. +PROGRAM test_mixed_route_torsion + USE CableDyn_Precision, ONLY: wp + USE CableDyn_OpenFAST_Aggregate, ONLY: CD_AGG_ModuleType, CD_AGG_Init_From_Deck, CD_AGG_NMovingPoints, & + CD_AGG_GetMovingPointMesh, CD_AGG_UpdateStates_Moving, & + CD_AGG_Step_Moving, CD_AGG_CalcOutput, CD_AGG_EvalChannel, & + CD_AGG_NumChannels, CD_AGG_End, CD_AGG_MotionKinematics, & + CD_AGG_Refresh_Accelerations, CD_AGG_HasMotion, CD_AGG_OK + USE, INTRINSIC :: IEEE_ARITHMETIC, ONLY: IEEE_IS_FINITE + IMPLICIT NONE + + REAL(wp), PARAMETER :: PI = 3.14159265358979323846_wp, D2R = PI/180.0_wp, RHOW = 1025.0_wp + REAL(wp), PARAMETER :: DT = 0.05_wp, TMAX = 10.0_wp, PERIOD = 10.0_wp + INTEGER, PARAMETER :: NSTEP = 200, MAXCOL = 32, MAXROW = 400 + ! gate 3: End A held, rolled by a vessel, rolled by the motionFile roll column + INTEGER, PARAMETER :: QS_HELD = 0, QS_VESSEL = 1, QS_ROLL = 2 + CHARACTER(*), PARAMETER :: CAB_T = 'cab 0.2 60.0 4.0e8 0.0 1.0e4 1.0e8 1.0e4 1.0 1.0e-12 1.2 0.1 1.0 0.0' + CHARACTER(*), PARAMETER :: CHAIN_T = 'chain 0.1 50.0 1.0e9 -1.0 0.0 0 0 0 0 1.37 0.64 1.0 0.0' + ! channels compared to the printed precision, the loads to LOAD_TOL of their range, the + ! out-of-plane node offset (about 1e-4 m) to POS_TOL + CHARACTER(16), PARAMETER :: EXACT(5) = [CHARACTER(16) :: 'Torq1N1', 'Torq1N41', 'Twist1', 'L1N21px', 'L1N21pz'] + CHARACTER(16), PARAMETER :: LOADS(4) = [CHARACTER(16) :: 'FairTen1', 'AnchTen1', 'FairIncl1', 'BendMom1N1'] + ! the gate 1 and 2 channels of line 1 (the same in both decks) and the chain's + CHARACTER(16), PARAMETER :: OUTS(10) = [LOADS, EXACT(1:3), [CHARACTER(16) :: 'L1N21px', 'L1N21py', 'L1N21pz']] + CHARACTER(16), PARAMETER :: CHAIN_OUTS(2) = [CHARACTER(16) :: 'FairTen2', 'Point3pz'] + REAL(wp), PARAMETER :: LOAD_TOL = 5.0e-5_wp, POS_TOL = 1.0e-6_wp + ! printed precision of ES15.7E3: half a unit in the 8th significant digit of each value, with a + ! unit of the 8th digit of the channel's range for a value that crosses zero + REAL(wp), PARAMETER :: PRINT_TOL = 6.0e-8_wp, PRINT_FLOOR = 1.0e-7_wp + CHARACTER(1024) :: driver + CHARACTER(160) :: neutral_t + INTEGER :: n_fail = 0 + + IF (COMMAND_ARGUMENT_COUNT() < 1) ERROR STOP 'usage: test_mixed_route_torsion ' + CALL GET_COMMAND_ARGUMENT(1, driver) + ! neutral 0.2 m section of test_torsion_deck: EA 1e7, EI 1e6, GAs 1e8, GJ 5e4, Irn 1e-12 + WRITE (neutral_t, '(A,ES24.16,A)') 'cab 0.2 ', RHOW*0.25_wp*PI*0.04_wp, & + ' 1.0e7 0.0 1.0e6 1.0e8 5.0e4 1.0 1.0e-12 0.0 0.0 0.0 0.0' + + CALL check_vessel_routes() + CALL check_roll_routes() + CALL check_quasi_static(QS_HELD) + CALL check_quasi_static(QS_VESSEL) + CALL check_quasi_static(QS_ROLL) + CALL check_refusal() + CALL check_static_row1() + CALL check_static_blend() + CALL check_attachment_routes() + IF (n_fail > 0) THEN + WRITE (*, '(A,I0,A)') 'FAIL: ', n_fail, ' mixed-route torsion gate(s) failed' + ERROR STOP 1 + END IF + WRITE (*, '(A)') 'PASS: torsion and prescribed motion on the standalone mixed route' + +CONTAINS + + SUBROUTINE require(cond, msg) + LOGICAL, INTENT(IN) :: cond + CHARACTER(*), INTENT(IN) :: msg + IF (.NOT. cond) THEN + n_fail = n_fail + 1 + WRITE (*, '(A,A)') 'FAILED: ', msg + END IF + END SUBROUTINE require + + SUBROUTINE write_deck(path, types, points, lines, sections, endconns, options, outs, atts) + CHARACTER(*), INTENT(IN) :: path, types(:), points(:), lines(:), sections(:), endconns(:), options(:), outs(:) + ! ATTACHMENTS rows (none when absent) + CHARACTER(*), INTENT(IN), OPTIONAL :: atts(:) + INTEGER :: u, i + OPEN (NEWUNIT=u, FILE=path, STATUS='REPLACE', ACTION='WRITE') + WRITE (u, '(A)') 'mixed-route torsion gate' + WRITE (u, '(A)') '--- LINE TYPES ---' + WRITE (u, '(A)') 'Name Diam Mass EA BA EI GAs GJ Irt Irn Cdn Cdt Can Cat' + WRITE (u, '(A)') '(-) (m) (kg/m) (N) (-) (Nm2) (N) (Nm2) (kgm) (kgm) (-) (-) (-) (-)' + DO i = 1, SIZE(types) + WRITE (u, '(A)') TRIM(types(i)) + END DO + WRITE (u, '(A)') '--- POINTS ---' + WRITE (u, '(A)') 'ID Type X Y Z Mass Vol CdA Ca' + WRITE (u, '(A)') '(-) (-) (m) (m) (m) (kg) (m3) (m2) (-)' + DO i = 1, SIZE(points) + WRITE (u, '(A)') TRIM(points(i)) + END DO + WRITE (u, '(A)') '--- LINES ---' + WRITE (u, '(A)') 'ID NodeA NodeB Outputs' + WRITE (u, '(A)') '(-) (-) (-) (-)' + DO i = 1, SIZE(lines) + WRITE (u, '(A)') TRIM(lines(i)) + END DO + WRITE (u, '(A)') '--- SECTIONS ---' + WRITE (u, '(A)') 'LineID LineType Length NumSegs' + WRITE (u, '(A)') '(-) (-) (m) (-)' + DO i = 1, SIZE(sections) + WRITE (u, '(A)') TRIM(sections(i)) + END DO + IF (PRESENT(atts)) THEN + WRITE (u, '(A)') '--- ATTACHMENTS ---' + WRITE (u, '(A)') 'LineID ArcLength Mass Volume CdA Ca' + WRITE (u, '(A)') '(-) (m) (kg) (m3) (m2) (-)' + DO i = 1, SIZE(atts) + WRITE (u, '(A)') TRIM(atts(i)) + END DO + END IF + WRITE (u, '(A)') '--- END CONNECTIONS ---' + WRITE (u, '(A)') 'LineID End Stiffness EzX EzY EzZ TorsStiffness NxX NxY NxZ Pretwist' + WRITE (u, '(A)') '(-) (-) (N-m/rad) (-) (-) (-) (N-m/rad) (-) (-) (-) (deg)' + DO i = 1, SIZE(endconns) + WRITE (u, '(A)') TRIM(endconns(i)) + END DO + WRITE (u, '(A)') '--- OPTIONS ---' + WRITE (u, '(A)') '9.80665 g' + WRITE (u, '(A)') '1025.0 rhoW' + DO i = 1, SIZE(options) + WRITE (u, '(A)') TRIM(options(i)) + END DO + WRITE (u, '(A)') '--- OUTPUTS ---' + DO i = 1, SIZE(outs) + WRITE (u, '(A)') TRIM(outs(i)) + END DO + WRITE (u, '(A)') '--- END ---' + CLOSE (u) + END SUBROUTINE write_deck + + SUBROUTINE sag_deck(path, point_type, chain, options, tmax_row, atts) + !! Gates 1 and 2: a 100 m finite-EI line from End A (0, 0, -50) on a point_type point to a + !! Fixed End B (95, 0, -60), 40 elements, both ends Rigid in bending and in torsion + !! (Pretwist 20 deg at End B); with chain, an EI = 0 chain from (0, 20, -50) on a second + !! point_type point to a Fixed (0, 110, -100); atts: ATTACHMENTS rows of line 1. + CHARACTER(*), INTENT(IN) :: path, point_type, options(:) + LOGICAL, INTENT(IN) :: chain + ! the TMax row (default 10 s) + CHARACTER(*), INTENT(IN), OPTIONAL :: tmax_row + CHARACTER(*), INTENT(IN), OPTIONAL :: atts(:) + CHARACTER(48) :: points(4), tm + CHARACTER(96) :: ec(2) + ec(1) = '1 A Rigid 1 0 -0.1 Rigid 0 0 1 0' + ec(2) = '1 B Rigid 1 0 0.1 Rigid 0 0 1 20' + tm = '10.0 TMax' + IF (PRESENT(tmax_row)) tm = tmax_row + points(1) = '1 '//point_type//' 0.0 0.0 -50.0 0 0 0 0' + points(2) = '2 Fixed 95.0 0.0 -60.0 0 0 0 0' + points(3) = '3 '//point_type//' 0.0 20.0 -50.0 0 0 0 0' + points(4) = '4 Fixed 0.0 110.0 -100.0 0 0 0 0' + IF (PRESENT(atts)) THEN + IF (chain) THEN + CALL write_deck(path, [CHARACTER(96) :: CAB_T, CHAIN_T], points, [CHARACTER(16) :: '1 1 2 -', '2 3 4 -'], & + [CHARACTER(24) :: '1 cab 100.0 40', '2 chain 110.0 20'], EC, & + [CHARACTER(48) :: '200.0 WtrDpth', '0.05 dtM', tm, options], [OUTS, CHAIN_OUTS], atts) + ELSE + CALL write_deck(path, [CHARACTER(96) :: CAB_T], points(1:2), [CHARACTER(16) :: '1 1 2 -'], & + [CHARACTER(24) :: '1 cab 100.0 40'], EC, & + [CHARACTER(48) :: '200.0 WtrDpth', '0.05 dtM', tm, options], OUTS, atts) + END IF + ELSE IF (chain) THEN + CALL write_deck(path, [CHARACTER(96) :: CAB_T, CHAIN_T], points, [CHARACTER(16) :: '1 1 2 -', '2 3 4 -'], & + [CHARACTER(24) :: '1 cab 100.0 40', '2 chain 110.0 20'], EC, & + [CHARACTER(48) :: '200.0 WtrDpth', '0.05 dtM', tm, options], [OUTS, CHAIN_OUTS]) + ELSE + CALL write_deck(path, [CHARACTER(96) :: CAB_T], points(1:2), [CHARACTER(16) :: '1 1 2 -'], & + [CHARACTER(24) :: '1 cab 100.0 40'], EC, & + [CHARACTER(48) :: '200.0 WtrDpth', '0.05 dtM', tm, options], OUTS) + END IF + END SUBROUTINE sag_deck + + PURE SUBROUTINE smooth(amplitude, t, f, df, d2f) + !! f = F (1 - cos w t) / 2 and its rates, w = 2 pi / PERIOD: a motion from rest. + REAL(wp), INTENT(IN) :: amplitude, t + REAL(wp), INTENT(OUT) :: f, df, d2f + REAL(wp) :: w + w = 2.0_wp*PI/PERIOD + f = 0.5_wp*amplitude*(1.0_wp - COS(w*t)) + df = 0.5_wp*amplitude*w*SIN(w*t) + d2f = 0.5_wp*amplitude*w*w*COS(w*t) + END SUBROUTINE smooth + + SUBROUTINE vessel_state(t, r, v, a, rot, omega, alpha) + !! The gate 1 vessel about its reference (0, 0, -50): heave 1 m, roll 20 deg and pitch 4 deg + !! from rest, R = Ry(pitch) Rx(roll); the global angular velocity of these Euler rates is + !! omega = Ry(pitch) (roll', 0, 0) + (0, pitch', 0), alpha its derivative. + REAL(wp), INTENT(IN) :: t + REAL(wp), INTENT(OUT) :: r(3), v(3), a(3), rot(3, 3), omega(3), alpha(3) + REAL(wp) :: z, vz, az, ro, dro, d2ro, p, dp, d2p, cr, sr, cp, sp + CALL smooth(1.0_wp, t, z, vz, az) + CALL smooth(20.0_wp*D2R, t, ro, dro, d2ro) + CALL smooth(4.0_wp*D2R, t, p, dp, d2p) + r = [0.0_wp, 0.0_wp, -50.0_wp + z] + v = [0.0_wp, 0.0_wp, vz] + a = [0.0_wp, 0.0_wp, az] + cr = COS(ro); sr = SIN(ro); cp = COS(p); sp = SIN(p) + ! rot = Ry(p) Rx(ro), columns + rot(:, 1) = [cp, 0.0_wp, -sp] + rot(:, 2) = [sp*sr, cr, cp*sr] + rot(:, 3) = [sp*cr, -sr, cp*cr] + omega = [dro*cp, dp, -dro*sp] + alpha = [d2ro*cp - dro*dp*sp, d2p, -d2ro*sp - dro*dp*cp] + END SUBROUTINE vessel_state + + FUNCTION cross(x, y) RESULT(c) + REAL(wp), INTENT(IN) :: x(3), y(3) + REAL(wp) :: c(3) + c = [x(2)*y(3) - x(3)*y(2), x(3)*y(1) - x(1)*y(3), x(1)*y(2) - x(2)*y(1)] + END FUNCTION cross + + SUBROUTINE write_vessel_record(path) + !! The gate 1 vessel as a vesselMotion record (time x y z roll pitch yaw vx vy vz wx wy wz ax ay + !! az alx aly alz). + CHARACTER(*), INTENT(IN) :: path + REAL(wp) :: t, r(3), v(3), a(3), rot(3, 3), omega(3), alpha(3), ro, dro, d2ro, p, dp, d2p + INTEGER :: u, k + OPEN (NEWUNIT=u, FILE=path, STATUS='REPLACE', ACTION='WRITE') + DO k = 0, NSTEP + t = DT*k + CALL vessel_state(t, r, v, a, rot, omega, alpha) + CALL smooth(20.0_wp, t, ro, dro, d2ro) + CALL smooth(4.0_wp, t, p, dp, d2p) + WRITE (u, '(F8.3,18ES25.16E3)') t, r, ro, p, 0.0_wp, v, omega, a, alpha + END DO + CLOSE (u) + END SUBROUTINE write_vessel_record + + SUBROUTINE write_vessel_points(path) + !! The translations the gate 1 vessel gives points 1 and 3 (x = r + R p, v = v_r + w x R p, + !! a = a_r + al x R p + w x (w x R p)) as motionFile rows without a roll column. + CHARACTER(*), INTENT(IN) :: path + REAL(wp) :: t, r(3), v(3), a(3), rot(3, 3), omega(3), alpha(3), rp(3) + REAL(wp), PARAMETER :: P_LOCAL(3, 2) = RESHAPE([0.0_wp, 0.0_wp, 0.0_wp, 0.0_wp, 20.0_wp, 0.0_wp], [3, 2]) + INTEGER :: u, k, j + OPEN (NEWUNIT=u, FILE=path, STATUS='REPLACE', ACTION='WRITE') + DO k = 0, NSTEP + t = DT*k + CALL vessel_state(t, r, v, a, rot, omega, alpha) + DO j = 1, 2 + rp = MATMUL(rot, P_LOCAL(:, j)) + WRITE (u, '(F8.3,I3,9ES25.16E3)') t, 2*j - 1, r + rp, v + cross(omega, rp), & + a + cross(alpha, rp) + cross(omega, cross(omega, rp)) + END DO + END DO + CLOSE (u) + END SUBROUTINE write_vessel_points + + SUBROUTINE write_roll_rows(path, with_chain_point) + !! Gate 2 motionFile: point 1 surges 1 m and rolls 20 deg (roll column), from rest; point 3 + !! (with_chain_point) surges with it and gives no roll column. + CHARACTER(*), INTENT(IN) :: path + LOGICAL, INTENT(IN) :: with_chain_point + REAL(wp) :: t, x, vx, ax, ro, dro, d2ro + INTEGER :: u, k + OPEN (NEWUNIT=u, FILE=path, STATUS='REPLACE', ACTION='WRITE') + DO k = 0, NSTEP + t = DT*k + CALL smooth(1.0_wp, t, x, vx, ax) + CALL smooth(20.0_wp, t, ro, dro, d2ro) + WRITE (u, '(F8.3,A,ES25.16E3,A,ES25.16E3,A,ES25.16E3,A,ES25.16E3)') t, ' 1 ', x, ' 0 -50 ', vx, ' 0 0 ', ax, & + ' 0 0 ', ro + IF (with_chain_point) WRITE (u, '(F8.3,A,ES25.16E3,A,ES25.16E3,A,ES25.16E3,A)') t, ' 3 ', x, ' 20 -50 ', vx, & + ' 0 0 ', ax, ' 0 0' + END DO + CLOSE (u) + END SUBROUTINE write_roll_rows + + SUBROUTINE run_driver(deck, root, ok) + !! Run the driver executable on a deck, its stdout and stderr to .log. + CHARACTER(*), INTENT(IN) :: deck, root + LOGICAL, INTENT(OUT) :: ok + INTEGER :: ex, cs + CALL EXECUTE_COMMAND_LINE('"'//TRIM(driver)//'" '//deck//' '//root//' > '//root//'.log 2>&1', & + WAIT=.TRUE., EXITSTAT=ex, CMDSTAT=cs) + ok = cs == 0 .AND. ex == 0 + END SUBROUTINE run_driver + + LOGICAL FUNCTION log_has(root, text) RESULT(found) + CHARACTER(*), INTENT(IN) :: root, text + CHARACTER(4096) :: line + INTEGER :: u, ios + found = .FALSE. + OPEN (NEWUNIT=u, FILE=root//'.log', STATUS='OLD', ACTION='READ', IOSTAT=ios) + IF (ios /= 0) RETURN + DO + READ (u, '(A)', IOSTAT=ios) line + IF (ios /= 0) EXIT + IF (INDEX(line, text) > 0) found = .TRUE. + END DO + CLOSE (u) + END FUNCTION log_has + + SUBROUTINE read_out(path, names, vals, nrow) + !! The channel names and rows of a driver .out file (Time first). + CHARACTER(*), INTENT(IN) :: path + CHARACTER(32), INTENT(OUT) :: names(MAXCOL) + REAL(wp), INTENT(OUT) :: vals(MAXROW, MAXCOL) + INTEGER, INTENT(OUT) :: nrow + CHARACTER(4096) :: buf + INTEGER :: u, ios, ncol, k + names = '' + vals = 0.0_wp + nrow = 0 + OPEN (NEWUNIT=u, FILE=path, STATUS='OLD', ACTION='READ', IOSTAT=ios) + IF (ios /= 0) RETURN + READ (u, '(A)', IOSTAT=ios) buf + READ (u, '(A)', IOSTAT=ios) buf + READ (buf, *, IOSTAT=ios) names + ncol = 0 + DO k = 1, MAXCOL + IF (LEN_TRIM(names(k)) > 0) ncol = k + END DO + DO + IF (nrow == MAXROW) EXIT + READ (u, *, IOSTAT=ios) vals(nrow + 1, 1:ncol) + IF (ios /= 0) EXIT + nrow = nrow + 1 + END DO + CLOSE (u) + END SUBROUTINE read_out + + INTEGER FUNCTION col_of(names, name) RESULT(c) + CHARACTER(32), INTENT(IN) :: names(:) + CHARACTER(*), INTENT(IN) :: name + INTEGER :: k + c = 0 + DO k = 1, SIZE(names) + IF (TRIM(names(k)) == TRIM(name)) c = k + END DO + END FUNCTION col_of + + REAL(wp) FUNCTION range_error(a, b, n) RESULT(e) + !! max |b - a| over the rows, relative to the range max |a|. + REAL(wp), INTENT(IN) :: a(:), b(:) + INTEGER, INTENT(IN) :: n + e = MAXVAL(ABS(b(1:n) - a(1:n)))/MAX(MAXVAL(ABS(a(1:n))), TINY(1.0_wp)) + IF (.NOT. IEEE_IS_FINITE(e)) e = HUGE(1.0_wp) + END FUNCTION range_error + + REAL(wp) FUNCTION print_error(a, b, n) RESULT(e) + !! max over the rows of |b - a| in units of the printed precision of a (PRINT_TOL |a|, at least + !! PRINT_FLOOR of the channel's range): <= 1 when b equals a to the digits printed. + REAL(wp), INTENT(IN) :: a(:), b(:) + INTEGER, INTENT(IN) :: n + REAL(wp) :: scale + INTEGER :: k + scale = MAXVAL(ABS(a(1:n))) + e = 0.0_wp + DO k = 1, n + e = MAX(e, ABS(b(k) - a(k))/MAX(PRINT_TOL*ABS(a(k)), PRINT_FLOOR*scale, TINY(1.0_wp))) + END DO + IF (.NOT. IEEE_IS_FINITE(e)) e = HUGE(1.0_wp) + END FUNCTION print_error + + SUBROUTINE compare_routes(label, root_a, root_b) + !! Gate 1/2 comparison of the standalone cubic-Hermite route (root_a.out) and the mixed route + !! (root_b.out) over the channels of line 1. + CHARACTER(*), INTENT(IN) :: label, root_a, root_b + CHARACTER(32) :: na(MAXCOL), nb(MAXCOL) + REAL(wp), ALLOCATABLE :: va(:, :), vb(:, :) + INTEGER :: ra, rb, k, ca, cb + REAL(wp) :: e, e_exact, e_loads + ALLOCATE (va(MAXROW, MAXCOL), vb(MAXROW, MAXCOL)) + CALL read_out(root_a//'.out', na, va, ra) + CALL read_out(root_b//'.out', nb, vb, rb) + CALL require(ra == NSTEP + 1 .AND. rb == NSTEP + 1, label//': both routes write every row') + IF (ra /= NSTEP + 1 .OR. rb /= NSTEP + 1) RETURN + e_exact = 0.0_wp + DO k = 1, SIZE(EXACT) + ca = col_of(na, EXACT(k)) + cb = col_of(nb, EXACT(k)) + CALL require(ca > 0 .AND. cb > 0, label//': channel '//TRIM(EXACT(k))//' in both outputs') + IF (ca == 0 .OR. cb == 0) CYCLE + e = print_error(va(:, ca), vb(:, cb), ra) + WRITE (*, '(A,A,A,ES10.3,A)') ' ', label, ': '//TRIM(EXACT(k))//' difference ', e, ' printed units' + e_exact = MAX(e_exact, e) + END DO + e_loads = 0.0_wp + DO k = 1, SIZE(LOADS) + ca = col_of(na, LOADS(k)) + cb = col_of(nb, LOADS(k)) + CALL require(ca > 0 .AND. cb > 0, label//': channel '//TRIM(LOADS(k))//' in both outputs') + IF (ca == 0 .OR. cb == 0) CYCLE + e = range_error(va(:, ca), vb(:, cb), ra) + WRITE (*, '(A,A,A,ES10.3,A)') ' ', label, ': '//TRIM(LOADS(k))//' difference ', e, ' of its range' + e_loads = MAX(e_loads, e) + END DO + ca = col_of(na, 'L1N21py') + cb = col_of(nb, 'L1N21py') + e = HUGE(1.0_wp) + IF (ca > 0 .AND. cb > 0) e = MAXVAL(ABS(vb(1:ra, cb) - va(1:ra, ca))) + WRITE (*, '(A,A,A,ES10.3,A)') ' ', label, ': L1N21py difference ', e, ' m' + CALL require(e_exact <= 2.0_wp, label//': torque, twist and node positions agree to the printed precision') + CALL require(e_loads <= LOAD_TOL, label//': end loads and bend moment agree within the Newton tolerances') + CALL require(e <= POS_TOL, label//': the out-of-plane node offset agrees within the Newton tolerances') + END SUBROUTINE compare_routes + + SUBROUTINE march_library(deck, root_a, label) + !! The mixed route's march (CableDyn_driver run_mixed_held_deck) through the aggregate library + !! with every cable given the standalone route's Newton controls (the deck's dynamic tolerance + !! 1e-8, 30 iterations, the carried factor): each channel of line 1 is compared at every + !! step with the standalone route's output root_a.out to its printed precision. + CHARACTER(*), INTENT(IN) :: deck, root_a, label + TYPE(CD_AGG_ModuleType), ALLOCATABLE :: agg + REAL(wp), ALLOCATABLE :: pos(:, :), vel(:, :), acc(:, :), load(:, :), orient(:, :, :), omega(:, :), alpha(:, :) + REAL(wp), ALLOCATABLE :: roll(:), va(:, :), got(:, :) + CHARACTER(32) :: na(MAXCOL) + CHARACTER(2048) :: em + INTEGER :: es, n, c, step, ra, k, ca, nch, n_iter + LOGICAL :: turns, rolls, conv, stalled + REAL(wp) :: worst, v + ALLOCATE (agg, va(MAXROW, MAXCOL)) + CALL CD_AGG_Init_From_Deck(agg, deck, DT, es, em, forbid_deck_ambient=.TRUE., run_tmax=TMAX, & + host_orientation=.TRUE., prescribed_motion=.TRUE.) + CALL require(es == CD_AGG_OK .AND. CD_AGG_HasMotion(agg), label//': the aggregate takes the deck motion: '// & + TRIM(em)) + IF (es /= CD_AGG_OK) RETURN + DO c = 1, agg%ncable + agg%cables(c)%tol = 1.0e-8_wp + agg%cables(c)%max_iter = 30 + agg%cables(c)%line%tangent_reuse = .TRUE. + END DO + n = CD_AGG_NMovingPoints(agg, es, em) + nch = CD_AGG_NumChannels(agg) + ALLOCATE (pos(3, n), vel(3, n), acc(3, n), load(3, n), orient(3, 3, n), omega(3, n), alpha(3, n), roll(n), & + got(NSTEP + 1, nch)) + CALL CD_AGG_GetMovingPointMesh(agg, pos, vel, acc, load, es, em) + CALL CD_AGG_MotionKinematics(agg, 1, pos, vel, acc, orient, omega, alpha, roll, turns, rolls, es, em) + IF (turns) THEN + CALL CD_AGG_UpdateStates_Moving(agg, pos, vel, acc, es, em, orientation=orient, angular_velocity=omega, & + angular_acceleration=alpha) + ELSE + CALL CD_AGG_UpdateStates_Moving(agg, pos, vel, acc, es, em) + END IF + IF (es == CD_AGG_OK) CALL CD_AGG_Refresh_Accelerations(agg, es, em) + CALL require(es == CD_AGG_OK, label//': the first motion row installs: '//TRIM(em)) + DO step = 0, NSTEP + IF (step > 0) THEN + CALL CD_AGG_MotionKinematics(agg, step + 1, pos, vel, acc, orient, omega, alpha, roll, turns, rolls, es, em) + IF (turns) THEN + CALL CD_AGG_Step_Moving(agg, DT, pos, vel, acc, conv, stalled, n_iter, es, em, t_committed=DT*step, & + orientation=orient, angular_velocity=omega, angular_acceleration=alpha) + ELSE IF (rolls) THEN + CALL CD_AGG_Step_Moving(agg, DT, pos, vel, acc, conv, stalled, n_iter, es, em, t_committed=DT*step, & + roll=roll) + ELSE + CALL CD_AGG_Step_Moving(agg, DT, pos, vel, acc, conv, stalled, n_iter, es, em, t_committed=DT*step) + END IF + IF (es /= CD_AGG_OK .OR. .NOT. conv) THEN + CALL require(.FALSE., label//': library march step: '//TRIM(em)) + EXIT + END IF + END IF + CALL CD_AGG_CalcOutput(agg, es, em) + DO k = 1, nch + CALL CD_AGG_EvalChannel(agg, k, v, es, em) + got(step + 1, k) = v + END DO + END DO + CALL read_out(root_a//'.out', na, va, ra) + worst = 0.0_wp + IF (ra == NSTEP + 1) THEN + DO k = 1, SIZE(OUTS) + ca = col_of(na, OUTS(k)) + IF (ca > 0) worst = MAX(worst, print_error(va(:, ca), got(:, k), ra)) + END DO + ELSE + worst = HUGE(1.0_wp) + END IF + WRITE (*, '(A,A,A,ES10.3,A)') ' ', label, ': mixed route with the standalone Newton controls, largest '// & + 'difference ', worst, ' printed units' + CALL require(worst <= 2.0_wp, label//': with the same Newton controls the mixed route reproduces the '// & + 'standalone route') + CALL CD_AGG_End(agg, es, em) + END SUBROUTINE march_library + + SUBROUTINE check_vessel_routes() + !! Gate 1. + CHARACTER(32) :: nb(MAXCOL), nc(MAXCOL) + REAL(wp), ALLOCATABLE :: vb(:, :), vc(:, :) + INTEGER :: rb, rc + LOGICAL :: ok + REAL(wp) :: dm, dt_twist + CHARACTER(48), PARAMETER :: VM(2) = [CHARACTER(48) :: 'tmrt_vessel.txt vesselMotion', '0|0|-50 vesselRef'] + CALL write_vessel_record('tmrt_vessel.txt') + CALL sag_deck('tmrt_vessel_a.dat', 'Vessel', .FALSE., VM) + CALL sag_deck('tmrt_vessel_b.dat', 'Vessel', .TRUE., VM) + CALL run_driver('tmrt_vessel_a.dat', 'tmrt_vessel_a', ok) + CALL require(ok, '1: the vessel deck runs on the standalone cubic-Hermite route') + CALL run_driver('tmrt_vessel_b.dat', 'tmrt_vessel_b', ok) + CALL require(ok, '1: the mixed vessel deck with a line restrained in torsion runs') + CALL require(log_has('tmrt_vessel_b', 'mixed standalone aggregate'), '1: the mixed deck runs on the aggregate') + CALL compare_routes('1 vessel', 'tmrt_vessel_a', 'tmrt_vessel_b') + CALL march_library('tmrt_vessel_b.dat', 'tmrt_vessel_a', '1 vessel') + ! the same point translations as a motionFile: the frames are held + CALL write_vessel_points('tmrt_vessel_points.txt') + CALL sag_deck('tmrt_vessel_c.dat', 'Coupled', .TRUE., [CHARACTER(48) :: 'tmrt_vessel_points.txt motionFile']) + CALL run_driver('tmrt_vessel_c.dat', 'tmrt_vessel_c', ok) + CALL require(ok, '1: the mixed deck of the vessel point translations runs') + ALLOCATE (vb(MAXROW, MAXCOL), vc(MAXROW, MAXCOL)) + CALL read_out('tmrt_vessel_b.out', nb, vb, rb) + CALL read_out('tmrt_vessel_c.out', nc, vc, rc) + IF (rb == NSTEP + 1 .AND. rc == NSTEP + 1) THEN + dm = range_error(vb(:, col_of(nb, 'BendMom1N1')), vc(:, col_of(nc, 'BendMom1N1')), rb) + dt_twist = MAXVAL(ABS(vb(1:rb, col_of(nb, 'Twist1')) - vc(1:rc, col_of(nc, 'Twist1')))) + WRITE (*, '(A,ES10.3,A,F8.3,A)') ' 1 vessel: held frames change the End A bend moment by ', dm, & + ' of its range and the twist by ', dt_twist, ' deg' + CALL require(dm > 0.01_wp .AND. dt_twist > 10.0_wp, '1: the vessel rotation turns the end frames (a '// & + 'motionFile of the same translations holds them)') + ! the chain moves with the vessel + CALL require(MAXVAL(vb(1:rb, col_of(nb, 'Point3pz'))) - MINVAL(vb(1:rb, col_of(nb, 'Point3pz'))) > 5.0_wp, & + '1: the chain point rolls with the vessel') + ELSE + CALL require(.FALSE., '1: the turning and the held-frame outputs are complete') + END IF + END SUBROUTINE check_vessel_routes + + SUBROUTINE check_roll_routes() + !! Gate 2. + LOGICAL :: ok + CALL write_roll_rows('tmrt_roll_1.txt', .FALSE.) + CALL write_roll_rows('tmrt_roll_2.txt', .TRUE.) + CALL sag_deck('tmrt_roll_a.dat', 'Coupled', .FALSE., [CHARACTER(48) :: 'tmrt_roll_1.txt motionFile']) + CALL sag_deck('tmrt_roll_b.dat', 'Coupled', .TRUE., [CHARACTER(48) :: 'tmrt_roll_2.txt motionFile']) + CALL run_driver('tmrt_roll_a.dat', 'tmrt_roll_a', ok) + CALL require(ok, '2: the roll-column deck runs on the standalone cubic-Hermite route') + CALL run_driver('tmrt_roll_b.dat', 'tmrt_roll_b', ok) + CALL require(ok, '2: the mixed roll-column deck runs') + CALL compare_routes('2 roll column', 'tmrt_roll_a', 'tmrt_roll_b') + CALL march_library('tmrt_roll_b.dat', 'tmrt_roll_a', '2 roll column') + END SUBROUTINE check_roll_routes + + SUBROUTINE check_attachment_routes() + !! Gate 7: the gate 2 decks with three buoyancy modules on line 1. + LOGICAL :: ok + CHARACTER(48), PARAMETER :: ATTS(3) = [CHARACTER(48) :: '1 40.0 100.0 0.5 0.5 1.0', '1 50.0 100.0 0.5 0.5 1.0', & + '1 60.0 100.0 0.5 0.5 1.0'] + CALL write_roll_rows('tmrt_att_1.txt', .FALSE.) + CALL write_roll_rows('tmrt_att_2.txt', .TRUE.) + CALL sag_deck('tmrt_att_a.dat', 'Coupled', .FALSE., [CHARACTER(48) :: 'tmrt_att_1.txt motionFile'], atts=ATTS) + CALL sag_deck('tmrt_att_b.dat', 'Coupled', .TRUE., [CHARACTER(48) :: 'tmrt_att_2.txt motionFile'], atts=ATTS) + CALL run_driver('tmrt_att_a.dat', 'tmrt_att_a', ok) + CALL require(ok, '7: the roll-column deck with ATTACHMENTS runs on the standalone cubic-Hermite route') + CALL run_driver('tmrt_att_b.dat', 'tmrt_att_b', ok) + CALL require(ok, '7: the mixed roll-column deck with ATTACHMENTS runs') + CALL require(log_has('tmrt_att_b', 'mixed standalone aggregate'), '7: the mixed deck runs on the aggregate') + CALL compare_routes('7 attachments', 'tmrt_att_a', 'tmrt_att_b') + END SUBROUTINE check_attachment_routes + + SUBROUTINE check_quasi_static(mode) + !! Gate 3: the straight 100 m neutral line of test_torsion_deck from (0, 0, -50) to a Fixed + !! (100, 0, -50), clamped and restrained at both ends (Pretwist 90 deg at End B), beside a + !! chain from (0, 10, -50) to a Fixed (0, 100, -100); End A held (roll 0) or rolled about the + !! line axis by up to 30 deg from rest over 10 s (dtM 0.1): Twist1 = 90 - roll, + !! Torq = GJ Twist / L at both ends. + INTEGER, INTENT(IN) :: mode + REAL(wp), PARAMETER :: GJ = 5.0e4_wp, L = 100.0_wp + CHARACTER(48) :: points(4) + CHARACTER(48), ALLOCATABLE :: options(:) + CHARACTER(32) :: names(MAXCOL) + REAL(wp), ALLOCATABLE :: vals(:, :) + REAL(wp) :: t, ro, dro, d2ro, werr, terr, twist + INTEGER :: u, k, nrow + LOGICAL :: ok + CHARACTER(16) :: label + REAL(wp) :: amplitude + OPEN (NEWUNIT=u, FILE='tmrt_qs_motion.txt', STATUS='REPLACE', ACTION='WRITE') + DO k = 0, 100 + t = 0.1_wp*k + CALL smooth(30.0_wp, t, ro, dro, d2ro) + IF (mode == QS_VESSEL) THEN + WRITE (u, '(F8.3,A,ES25.16E3,A,ES25.16E3,A,ES25.16E3,A)') t, ' 0 0 -50 ', ro, ' 0 0 0 0 0 ', dro*D2R, & + ' 0 0 0 0 0 ', d2ro*D2R, ' 0 0' + ELSE IF (mode == QS_ROLL) THEN + WRITE (u, '(F8.3,A,ES25.16E3)') t, ' 1 0 0 -50 0 0 0 0 0 0 ', ro + WRITE (u, '(F8.3,A)') t, ' 3 0 10 -50 0 0 0 0 0 0' + END IF + END DO + CLOSE (u) + points(1) = '1 Coupled 0.0 0.0 -50.0 0 0 0 0' + points(2) = '2 Fixed 100.0 0.0 -50.0 0 0 0 0' + points(3) = '3 Coupled 0.0 10.0 -50.0 0 0 0 0' + points(4) = '4 Fixed 0.0 100.0 -100.0 0 0 0 0' + amplitude = 30.0_wp + SELECT CASE (mode) + CASE (QS_VESSEL) + label = '3 vessel roll' + points(1) = '1 Vessel 0.0 0.0 -50.0 0 0 0 0' + points(3) = '3 Vessel 0.0 10.0 -50.0 0 0 0 0' + options = [CHARACTER(48) :: '0.1 dtM', '10.0 TMax', 'tmrt_qs_motion.txt vesselMotion', '0|0|-50 vesselRef'] + CASE (QS_ROLL) + label = '3 roll column' + options = [CHARACTER(48) :: '0.1 dtM', '10.0 TMax', 'tmrt_qs_motion.txt motionFile'] + CASE DEFAULT + label = '3 held' + amplitude = 0.0_wp + options = [CHARACTER(48) :: '0.1 dtM', '10.0 TMax'] + END SELECT + CALL write_deck('tmrt_qs.dat', [CHARACTER(160) :: neutral_t, CHAIN_T], points, & + [CHARACTER(16) :: '1 1 2 -', '2 3 4 -'], [CHARACTER(24) :: '1 cab 100.0 40', '2 chain 110.0 20'], & + [CHARACTER(96) :: '1 A Rigid 1 0 0 Rigid 0 0 1 0', '1 B Rigid 1 0 0 Rigid 0 0 1 90'], & + options, [CHARACTER(16) :: 'Torq1N1', 'Torq1N41', 'Twist1', 'FairTen2']) + CALL run_driver('tmrt_qs.dat', 'tmrt_qs', ok) + CALL require(ok, TRIM(label)//': the mixed deck runs') + ALLOCATE (vals(MAXROW, MAXCOL)) + CALL read_out('tmrt_qs.out', names, vals, nrow) + CALL require(nrow == 101, TRIM(label)//': every row written') + werr = 0.0_wp + terr = 0.0_wp + DO k = 1, nrow + CALL smooth(amplitude, vals(k, 1), ro, dro, d2ro) + twist = 90.0_wp - ro + werr = MAX(werr, ABS(vals(k, col_of(names, 'Twist1')) - twist)) + terr = MAX(terr, ABS(vals(k, col_of(names, 'Torq1N1')) - GJ*twist*D2R/L), & + ABS(vals(k, col_of(names, 'Torq1N41')) - GJ*twist*D2R/L)) + END DO + IF (nrow == 0) THEN + werr = HUGE(1.0_wp) + terr = HUGE(1.0_wp) + END IF + WRITE (*, '(A,A,ES10.3,A,ES10.3,A)') ' ', TRIM(label)//': Twist1 error ', werr, ' deg, torque error ', terr, & + ' N m' + CALL require(werr <= 1.0e-6_wp, TRIM(label)//': Twist1 = Pretwist - roll at every step') + CALL require(terr <= 1.0e-6_wp*GJ, TRIM(label)//': Torq = GJ Twist / L at both ends at every step') + END SUBROUTINE check_quasi_static + + SUBROUTINE check_refusal() + !! Gate 4. + LOGICAL :: ok + INTEGER :: u, k + OPEN (NEWUNIT=u, FILE='tmrt_bad_roll.txt', STATUS='REPLACE', ACTION='WRITE') + DO k = 0, NSTEP + WRITE (u, '(F8.3,A,F6.2)') DT*k, ' 1 0 0 -50 0 0 0 0 0 0 ', 0.0_wp + WRITE (u, '(F8.3,A,F6.2)') DT*k, ' 3 0 20 -50 0 0 0 0 0 0 ', MERGE(0.0_wp, 5.0_wp, k == 0) + END DO + CLOSE (u) + CALL sag_deck('tmrt_bad.dat', 'Coupled', .TRUE., [CHARACTER(48) :: 'tmrt_bad_roll.txt motionFile']) + CALL run_driver('tmrt_bad.dat', 'tmrt_bad', ok) + CALL require(.NOT. ok, '4: a roll column at the chain point stops the run') + CALL require(log_has('tmrt_bad', 'has a non-zero roll column'), '4: the roll column at the chain point is named') + END SUBROUTINE check_refusal + + REAL(wp) FUNCTION static_fairlead(root, column) RESULT(x) + !! Column `column` of line 1's End A (the first node row) in .static.out (4: X, 7: + !! tension). + CHARACTER(*), INTENT(IN) :: root + INTEGER, INTENT(IN) :: column + CHARACTER(4096) :: buf + REAL(wp) :: row(12) + INTEGER :: u, ios, k + x = HUGE(1.0_wp) + OPEN (NEWUNIT=u, FILE=root//'.static.out', STATUS='OLD', ACTION='READ', IOSTAT=ios) + IF (ios /= 0) RETURN + DO k = 1, 3 + READ (u, '(A)', IOSTAT=ios) buf + END DO + READ (u, *, IOSTAT=ios) row + IF (ios == 0) x = row(column) + CLOSE (u) + END FUNCTION static_fairlead + + SUBROUTINE check_static_row1() + !! Gate 5. + CHARACTER(32) :: na(MAXCOL), nb(MAXCOL) + REAL(wp), ALLOCATABLE :: va(:, :), vb(:, :) + INTEGER :: u, ra, rb, k, ca, cb + LOGICAL :: ok + REAL(wp) :: e, xa, xb, ta, tb + DO k = 1, 2 + OPEN (NEWUNIT=u, FILE=MERGE('tmrt_t0_1.txt', 'tmrt_t0_2.txt', k == 1), STATUS='REPLACE', ACTION='WRITE') + WRITE (u, '(A)') '0 1 0.02 0 -50 0 0 0 0 0 0' + IF (k == 2) WRITE (u, '(A)') '0 3 0.02 20 -50 0 0 0 0 0 0' + CLOSE (u) + END DO + CALL sag_deck('tmrt_t0_a.dat', 'Coupled', .FALSE., [CHARACTER(48) :: 'tmrt_t0_1.txt motionFile'], '0.0 TMax') + CALL sag_deck('tmrt_t0_b.dat', 'Coupled', .TRUE., [CHARACTER(48) :: 'tmrt_t0_2.txt motionFile'], '0.0 TMax') + CALL run_driver('tmrt_t0_a.dat', 'tmrt_t0_a', ok) + CALL require(ok, '5: the TMax = 0 motion deck runs on the single-line route') + CALL run_driver('tmrt_t0_b.dat', 'tmrt_t0_b', ok) + CALL require(ok, '5: the TMax = 0 mixed motion deck runs') + ALLOCATE (va(MAXROW, MAXCOL), vb(MAXROW, MAXCOL)) + CALL read_out('tmrt_t0_a.out', na, va, ra) + CALL read_out('tmrt_t0_b.out', nb, vb, rb) + CALL require(ra == 1 .AND. rb == 1, '5: one t = 0 row on each route') + IF (ra /= 1 .OR. rb /= 1) RETURN + e = 0.0_wp + DO k = 1, SIZE(OUTS) + ca = col_of(na, OUTS(k)) + cb = col_of(nb, OUTS(k)) + IF (ca == 0 .OR. cb == 0) THEN + e = HUGE(1.0_wp) + ELSE IF (TRIM(OUTS(k)) == 'L1N21py') THEN + e = MAX(e, ABS(vb(1, cb) - va(1, ca))/POS_TOL) + ELSE IF (ANY(LOADS == OUTS(k))) THEN + e = MAX(e, ABS(vb(1, cb) - va(1, ca))/(LOAD_TOL*ABS(va(1, ca)))) + ELSE + e = MAX(e, print_error(va(:, ca), vb(:, cb), 1)/2.0_wp) + END IF + END DO + xa = static_fairlead('tmrt_t0_a', 4) + xb = static_fairlead('tmrt_t0_b', 4) + ta = static_fairlead('tmrt_t0_a', 7) + tb = static_fairlead('tmrt_t0_b', 7) + WRITE (*, '(A,ES10.3,A,2ES12.4,A)') ' 5 TMax = 0, row 1 off by 2 cm: t = 0 rows agree to ', e, & + ' of their tolerances; static fairlead x ', xa, xb, ' m' + CALL require(e <= 1.0_wp, '5: both routes write the t = 0 row at the installed row 1') + CALL require(va(1, col_of(na, 'FairTen1')) > 10.0_wp*ta .AND. vb(1, col_of(nb, 'FairTen1')) > 10.0_wp*tb, & + '5: the t = 0 row carries the installed row 1, not the static state') + CALL require(ABS(xa) <= 1.0e-9_wp .AND. ABS(xb) <= 1.0e-9_wp, & + '5: both routes write the static configuration before row 1 moves the fairlead') + END SUBROUTINE check_static_row1 + + SUBROUTINE check_static_blend() + !! Gate 6. + REAL(wp), PARAMETER :: GJ = 5.0e4_wp, L = 100.0_wp + CHARACTER(32) :: names(MAXCOL) + REAL(wp), ALLOCATABLE :: vals(:, :) + CHARACTER(48) :: points(4) + INTEGER :: nrow + LOGICAL :: ok + REAL(wp) :: terr + points(1) = '1 Coupled 0.0 0.0 -50.0 0 0 0 0' + points(2) = '2 Fixed 100.0 0.0 -50.0 0 0 0 0' + points(3) = '3 Coupled 0.0 10.0 -50.0 0 0 0 0' + points(4) = '4 Fixed 0.0 100.0 -100.0 0 0 0 0' + CALL write_deck('tmrt_blend_s.dat', [CHARACTER(160) :: neutral_t, CHAIN_T], points, & + [CHARACTER(16) :: '1 1 2 -', '2 3 4 -'], [CHARACTER(24) :: '1 cab 100.0 40', '2 chain 110.0 20'], & + [CHARACTER(96) :: '1 A Rigid 1 0 0 Rigid 0 0 1 0', '1 B Rigid 1 0 0 Rigid 0 0 1 90'], & + [CHARACTER(48) :: '0.1 dtM', '0.0 TMax', 'False alpha_force_blend'], & + [CHARACTER(16) :: 'Torq1N1', 'Twist1']) + CALL run_driver('tmrt_blend_s.dat', 'tmrt_blend_s', ok) + CALL require(ok, '6: a static mixed deck with torsion runs without the force blend') + ALLOCATE (vals(MAXROW, MAXCOL)) + CALL read_out('tmrt_blend_s.out', names, vals, nrow) + terr = HUGE(1.0_wp) + IF (nrow == 1) terr = ABS(vals(1, col_of(names, 'Torq1N1')) - GJ*90.0_wp*D2R/L) + WRITE (*, '(A,ES10.3,A)') ' 6 static mixed deck without the force blend: torque error ', terr, ' N m' + CALL require(terr <= 1.0e-6_wp*GJ, '6: the static torque is GJ Phi / L') + CALL write_deck('tmrt_blend_d.dat', [CHARACTER(160) :: neutral_t, CHAIN_T], points, & + [CHARACTER(16) :: '1 1 2 -', '2 3 4 -'], [CHARACTER(24) :: '1 cab 100.0 40', '2 chain 110.0 20'], & + [CHARACTER(96) :: '1 A Rigid 1 0 0 Rigid 0 0 1 0', '1 B Rigid 1 0 0 Rigid 0 0 1 90'], & + [CHARACTER(48) :: '0.1 dtM', '1.0 TMax', 'False alpha_force_blend'], & + [CHARACTER(16) :: 'Torq1N1', 'Twist1']) + CALL run_driver('tmrt_blend_d.dat', 'tmrt_blend_d', ok) + CALL require(.NOT. ok, '6: a dynamic mixed deck with torsion and the configuration blend stops') + CALL require(log_has('tmrt_blend_d', 'torsion in a dynamic run needs the force-blended'), & + '6: the configuration blend of a dynamic torsion run is named') + ! one restrained end: the aggregate parses the deck caller-driven, so the static run must + ! reach the one-end resolution, or the line is left unsolved in torsion and its channels + ! refused; the free End B carries no torque + CALL write_deck('tmrt_blend_s1.dat', [CHARACTER(160) :: neutral_t, CHAIN_T], points, & + [CHARACTER(16) :: '1 1 2 -', '2 3 4 -'], [CHARACTER(24) :: '1 cab 100.0 40', '2 chain 110.0 20'], & + [CHARACTER(96) :: '1 A Rigid 1 0 0 Rigid 0 0 1 0', '1 B Rigid 1 0 0 Free 0 0 1'], & + [CHARACTER(48) :: '0.1 dtM', '0.0 TMax', 'False alpha_force_blend'], & + [CHARACTER(16) :: 'Torq1N1', 'Twist1']) + BLOCK + INTEGER :: u, ios + ! no output of an earlier run may stand in for this one + OPEN (NEWUNIT=u, FILE='tmrt_blend_s1.out', STATUS='OLD', IOSTAT=ios) + IF (ios == 0) CLOSE (u, STATUS='DELETE') + END BLOCK + CALL run_driver('tmrt_blend_s1.dat', 'tmrt_blend_s1', ok) + CALL require(ok, '6: a static mixed deck with one restrained end runs without the force blend') + terr = HUGE(1.0_wp) + nrow = 0 + IF (ok) CALL read_out('tmrt_blend_s1.out', names, vals, nrow) + IF (nrow == 1) terr = ABS(vals(1, col_of(names, 'Torq1N1'))) + WRITE (*, '(A,ES10.3,A)') ' 6 static mixed deck, one restrained end: torque ', terr, ' N m' + CALL require(terr <= 1.0e-6_wp*GJ*90.0_wp*D2R/L, '6: the free end of a static one-end line carries no torque') + CALL write_deck('tmrt_blend_d1.dat', [CHARACTER(160) :: neutral_t, CHAIN_T], points, & + [CHARACTER(16) :: '1 1 2 -', '2 3 4 -'], [CHARACTER(24) :: '1 cab 100.0 40', '2 chain 110.0 20'], & + [CHARACTER(96) :: '1 A Rigid 1 0 0 Rigid 0 0 1 0', '1 B Rigid 1 0 0 Free 0 0 1'], & + [CHARACTER(48) :: '0.1 dtM', '1.0 TMax', 'False alpha_force_blend'], & + [CHARACTER(16) :: 'Torq1N1', 'Twist1']) + CALL run_driver('tmrt_blend_d1.dat', 'tmrt_blend_d1', ok) + CALL require(.NOT. ok, '6: a dynamic one-end torsion run with the configuration blend stops') + CALL require(log_has('tmrt_blend_d1', 'torsion in a dynamic run needs the force-blended'), & + '6: the configuration blend of a dynamic one-end torsion run is named') + END SUBROUTINE check_static_blend +END PROGRAM test_mixed_route_torsion diff --git a/tests/test_modal_torsion_deck.py b/tests/test_modal_torsion_deck.py index 092ac0fd..b316ab9b 100644 --- a/tests/test_modal_torsion_deck.py +++ b/tests/test_modal_torsion_deck.py @@ -14,7 +14,15 @@ deck's axes. 2. tests/data/torsion_lazy_wave_modes.dat, the lazy wave twisted two turns, runs its modes: 12 ascending, finite frequencies with PolarShare in [0, 1] and a dTwist column. -Both fail closed on a driver that refuses nModes with torsion. +3. The straight line of 1 restrained in torsion at one end only, the other free to twist (End B + free, then End A): its torsional modes are the clamped-free chain's + 2 sqrt(GJ/Irn)/l0 sin((2n - 1) pi/(4 NE)) (the free end's half polar mass is the mid-node of + a clamped-clamped chain twice as long) and the continuum's quarter-wave (2n - 1) pi/(2 L0) + sqrt(GJ/Irn) within the chain's own 1 - sin(x)/x, x = (2n - 1) pi/(4 NE); the first one's + dTwist is sin(pi s/(2 L0)) from the restrained end, largest at the free end; the bending and + axial modes are those of the TorsStiffness Free deck. +1 and 2 fail closed on a driver that refuses nModes with torsion, 3 on one that does not solve +the torsion of a line restrained at one end with nModes (no twist columns). """ from __future__ import annotations @@ -31,7 +39,7 @@ REL_EXACT = 2.0e-8 -def straight_deck(torsion: str, heading_deg: float = 0.0) -> str: +def straight_deck(torsion: str, heading_deg: float = 0.0, torsion_b: str | None = None) -> str: mass = RHO_W * math.pi * DIAM**2 / 4.0 # neutrally buoyant: the line stays straight span = L0 * (1.0 + TENSION / EA) c, s = math.cos(math.radians(heading_deg)), math.sin(math.radians(heading_deg)) @@ -54,7 +62,7 @@ def straight_deck(torsion: str, heading_deg: float = 0.0) -> str: {bar} END CONNECTIONS {bar} LineID End Stiffness EzX EzY EzZ TorsStiffness NxX NxY NxZ Pretwist 1 A Rigid {c!r} {s!r} 0 {torsion} 0 0 1 0 -1 B Rigid {c!r} {s!r} 0 {torsion} 0 0 1 0 +1 B Rigid {c!r} {s!r} 0 {torsion if torsion_b is None else torsion_b} 0 0 1 0 {bar} OPTIONS {bar} 9.80665 g {RHO_W!r} rhoW @@ -172,6 +180,63 @@ def check_straight(exe: str, out: Path) -> list[str]: return failures +def check_one_end(exe: str, out: Path) -> list[str]: + failures: list[str] = [] + _, freq0, _, _ = read_modes(run_deck(exe, out, "straight_free", straight_deck("Free"))) + omega0 = [row[4] for row in freq0] + l0 = L0 / NE + for label, row_a, row_b in (("End B free", "Rigid", "Free"), ("End A free", "Free", "Rigid")): + name = "one_end_" + label.split()[1].lower() + fh, freq, sh, shapes = read_modes(run_deck(exe, out, name, straight_deck(row_a, torsion_b=row_b))) + if fh[-1] != "PolarShare" or sh[-1] != "dTwist": + failures.append(f"{label}: no PolarShare/dTwist columns ({fh}, {sh})") + continue + n = 0 + other = [] + for j, row in enumerate(freq, start=1): + om, share = row[4], row[5] + if share <= 0.5: + other.append(om) + continue + n += 1 + x = (2 * n - 1) * math.pi / (4.0 * NE) + chain = 2.0 * math.sqrt(GJ / IRN) / l0 * math.sin(x) + cont = (2 * n - 1) * math.pi / (2.0 * L0) * math.sqrt(GJ / IRN) + err_d, err_c = abs(om / chain - 1.0), abs(om / cont - 1.0) + bound = 1.0 - math.sin(x) / x + print( + f" {label}: torsional mode {n} (mode {j}): omega {om:.6f} rad/s, quarter-wave " + f"{cont:.6f}, error {err_c:.2e} (bound {1.01 * bound:.2e}), clamped-free chain error " + f"{err_d:.2e}, polar share 1 - {1 - share:.1e}" + ) + if err_d > REL_EXACT or err_c > 1.01 * bound + REL_EXACT or 1.0 - share > REL_EXACT: + failures.append(f"{label}: torsional mode {n}: omega {om}, chain {chain}, continuum {cont}") + if n == 1: + rows = [r for r in shapes if int(r[1]) == j] + twist = [r[9] for r in rows] + # the node index from End A; the restrained end is End A when End B is free + ks = range(NE + 1) if row_a == "Rigid" else range(NE, -1, -1) + ref = [math.sin(0.5 * math.pi * k / NE) for k in ks] + sign = 1.0 if twist[NE // 2] * ref[NE // 2] > 0.0 else -1.0 + err_s = max(abs(sign * t - r) for t, r in zip(twist, ref)) + print(f" {label}: torsional mode 1 shape against sin(pi s/(2 L0)) {err_s:.2e}") + if err_s > 1.0e-6: + failures.append(f"{label}: torsional mode 1 shape {err_s}") + err_o = max(abs(om / om0 - 1.0) for om, om0 in zip(other, omega0)) + print(f" {label}: {n} torsional modes; {len(other)} others against TorsStiffness Free {err_o:.2e}") + if n < 3: + failures.append(f"{label}: expected at least 3 torsional modes among the {N_MODES} lowest, found {n}") + if err_o > REL_EXACT: + failures.append(f"{label}: bending/axial modes differ from the Free deck by {err_o}") + return failures + + +def run_deck(exe: str, out: Path, name: str, text: str) -> Path: + deck = out / f"{name}.dat" + deck.write_text(text, encoding="utf-8") + return run(exe, deck, out / name) + + def check_lazy_wave(exe: str, source: Path, out: Path) -> list[str]: failures: list[str] = [] path = run(exe, source / "tests" / "data" / "torsion_lazy_wave_modes.dat", out / "torsion_lazy_wave_modes") @@ -204,6 +269,7 @@ def main() -> int: try: failures += check_straight(args.exe, args.output) failures += check_lazy_wave(args.exe, args.source, args.output) + failures += check_one_end(args.exe, args.output) except AssertionError as exc: failures.append(str(exc)) for failure in failures: diff --git a/tests/test_rod_end_torsion.f90 b/tests/test_rod_end_torsion.f90 new file mode 100644 index 00000000..3923feb2 --- /dev/null +++ b/tests/test_rod_end_torsion.f90 @@ -0,0 +1,586 @@ +! File: tests/test_rod_end_torsion.f90 +! SPDX-License-Identifier: Apache-2.0 +! Copyright (c) 2026 Jae Hoon Seo, SMI Lab, Inha University +!> A torsional END CONNECTION on a rod end (an I-tube or J-tube modelled as a rod): the End A +!> torsion frame is held by the rod and turns with its whole orientation, and the line's torque +!> returns to the rod about the line axis. Gates (multibody march, the route of every deck with +!> rods and finite-EI lines): +!> 1. a straight neutral line, stretched by 1e-4 and restrained in torsion, hung along the axis +!> of an inclined Fixed rod (the J-tube; its frame is not the global one), with the reference +!> normals given in global axes: two turns of pretwist give Torq = GJ Phi / L at every node, +!> the same torque as the line hung from a Coupled point held still (a second route, the +!> standalone finite-EI march) to the printed digits, and equal normals with equal pretwists +!> give no torque (the End A normal is carried into the rod frame; taken in the rod frame instead it +!> would twist the line by the roll of that frame); RodM about the rod's End A is the +!> torque along the line axis, M_t a (the moment returned to the rod); a 1 s march keeps the +!> torque; a bending-pinned, torsionally rigid End A carries the same torque; the deck written +!> anchor first (MoorDyn's order, NodeA the anchor) is turned around and runs bit for bit; +!> 2. a rod fixed to a rolling Rigid6 body (RODS type Body, the body attitude rolled, +!> pitched and yawed), the line hung along the rod axis and pretwisted by 30 deg, the body +!> released from rest: the body and its rod roll about the line axis as a torsional pendulum +!> (Omega = sqrt(GJ / (L I)), I the body's roll inertia plus the rod's polar inertia), at every +!> step the torque is GJ (Phi - theta) / L with theta the body's roll (quasi-static torsion), +!> the moment returned to the body is the torque along the turned line axis, and the rod's +!> RodM channel carries it (it left out the connection moment of a cable at the end of a +!> body-fixed rod); +!> 3. named refusals: a Pinned, a Free and a BodyPinned rod are axisymmetric with no roll +!> angle and cannot hold the torque; a Coupled rod carries no finite-EI line on any route; the +!> staggered body scheme, which drives a cable end by translation, refuses a torsional End A +!> on a body-fixed rod even when its bending is pinned (it ran with the frame frozen); a line +!> written anchor first onto a Pinned rod meets the Pinned rod's refusal (it read "two moving +!> ends"), and a line between two Fixed rods is refused as one with End B on a rod end. +!> 4. with the other routes: the gate 1 line on the Fixed J-tube, with torque-tension coupling +!> (GJ|K 5e4 N m2|4e5 N m) and restrained in torsion at the rod end only (End B free to twist), +!> carries no torque and its free end turns with the 1e-4 stretch, Twist1 = -(K/GJ) dl, the +!> same as from the held Coupled point; free at the rod end and restrained at the anchor +!> instead, the same twist. The gate 1 line twisted two turns and carrying two clumps and a +!> buoy (ATTACHMENTS, which bend it off the rod axis) gives the torque and twist of the same +!> line from the held Coupled point to the printed digits. +!> The multibody march has no restart (checkpoint) path, so there is no restart gate. +PROGRAM test_rod_end_torsion + USE CableDyn_Precision, ONLY: wp + USE CableDyn_Conventions, ONLY: CD_Body_Rotation + USE CableDyn_DeckDriver, ONLY: CD_Run_Deck_Driver, CD_DECKDRV_OK, CD_Multibody_Probe_Arm, CD_Multibody_Probe_Get + USE, INTRINSIC :: IEEE_ARITHMETIC, ONLY: IEEE_IS_FINITE + IMPLICIT NONE + + REAL(wp), PARAMETER :: PI = 3.14159265358979323846_wp, RHOW = 1025.0_wp, GJ = 5.0e4_wp + INTEGER :: n_fail = 0 + CHARACTER(160) :: neutral_type, rod_type + + ! neutral 0.2 m section: EA 1e7, EI 1e6, GAs 1e8, GJ 5e4, Irn 1e-12 (massless torsion) + WRITE (neutral_type, '(A,ES24.16,A)') 'cab 0.2 ', RHOW*0.25_wp*PI*0.04_wp, & + ' 1.0e7 0.0 1.0e6 1.0e8 5.0e4 1.0 1.0e-12 0.0 0.0 0.0 0.0' + ! neutral 0.2 m rod without hydrodynamic coefficients + WRITE (rod_type, '(A,ES24.16,A)') 'arm 0.2 ', RHOW*0.25_wp*PI*0.04_wp, ' 0.0 0.0 0.0 0.0' + + CALL check_fixed_rod() + CALL check_body_rod_roll() + CALL check_refusals() + CALL check_one_end_rod() + CALL check_attachments_rod() + IF (n_fail > 0) THEN + WRITE (*, '(A,I0,A)') 'FAIL: ', n_fail, ' rod-end torsion gate(s) failed' + ERROR STOP 1 + END IF + WRITE (*, '(A)') 'PASS: rod-end torsion (Fixed rod, rod on a rolling body, refusals)' + +CONTAINS + + INCLUDE 'nan_max_abs.inc' + + SUBROUTINE require(cond, msg) + LOGICAL, INTENT(IN) :: cond + CHARACTER(*), INTENT(IN) :: msg + IF (.NOT. cond) THEN + n_fail = n_fail + 1 + WRITE (*, '(A,A)') 'FAILED: ', msg + END IF + END SUBROUTINE require + + SUBROUTINE write_deck(path, bodies, rods, points, line, length_segs, endconns, options, outs, atts) + !! A one-line deck: the neutral line type, optional BODIES and RODS rows (the arm rod type), + !! POINTS, one LINES row, its SECTIONS row, optional ATTACHMENTS rows atts, END CONNECTIONS, + !! OPTIONS (g, rhoW, WtrDpth 200 and the given rows) and OUTPUTS. + CHARACTER(*), INTENT(IN) :: path, bodies(:), rods(:), points(:), line, length_segs, endconns(:), options(:), & + outs(:) + CHARACTER(*), INTENT(IN), OPTIONAL :: atts(:) + INTEGER :: u, i + OPEN (NEWUNIT=u, FILE=path, STATUS='REPLACE', ACTION='WRITE') + WRITE (u, '(A)') 'rod-end torsion gate' + WRITE (u, '(A)') '--- LINE TYPES ---' + WRITE (u, '(A)') 'Name Diam Mass EA BA EI GAs GJ Irt Irn Cdn Cdt Can Cat' + WRITE (u, '(A)') '(-) (m) (kg/m) (N) (-) (Nm2) (N) (Nm2) (kgm) (kgm) (-) (-) (-) (-)' + WRITE (u, '(A)') TRIM(neutral_type) + IF (SIZE(bodies) > 0) THEN + WRITE (u, '(A)') '--- BODIES ---' + WRITE (u, '(A)') 'ID Type X Y Z Roll Pitch Yaw Mass Vol C33 C44 C55 CdA Ca Ixx Iyy Izz' + WRITE (u, '(A)') '(-) (-) (m) (m) (m) (deg) (deg) (deg) (kg) (m3) (N/m) (Nm) (Nm) (m2) (-) (kgm2) (kgm2) (kgm2)' + DO i = 1, SIZE(bodies) + WRITE (u, '(A)') TRIM(bodies(i)) + END DO + END IF + IF (SIZE(rods) > 0) THEN + WRITE (u, '(A)') '--- ROD TYPES ---' + WRITE (u, '(A)') 'Name Diam Mass Cd Ca CdEnd CaEnd' + WRITE (u, '(A)') '(-) (m) (kg/m) (-) (-) (-) (-)' + WRITE (u, '(A)') TRIM(rod_type) + WRITE (u, '(A)') '--- RODS ---' + WRITE (u, '(A)') 'ID RodType Attachment XA YA ZA XB YB ZB NumSegs Outputs' + WRITE (u, '(A)') '(-) (-) (-) (m) (m) (m) (m) (m) (m) (-) (-)' + DO i = 1, SIZE(rods) + WRITE (u, '(A)') TRIM(rods(i)) + END DO + END IF + WRITE (u, '(A)') '--- POINTS ---' + WRITE (u, '(A)') 'ID Type X Y Z Mass Vol CdA Ca' + WRITE (u, '(A)') '(-) (-) (m) (m) (m) (kg) (m3) (m2) (-)' + DO i = 1, SIZE(points) + WRITE (u, '(A)') TRIM(points(i)) + END DO + WRITE (u, '(A)') '--- LINES ---' + WRITE (u, '(A)') 'ID NodeA NodeB Outputs' + WRITE (u, '(A)') '(-) (-) (-) (-)' + WRITE (u, '(A)') TRIM(line) + WRITE (u, '(A)') '--- SECTIONS ---' + WRITE (u, '(A)') 'LineID LineType Length NumSegs' + WRITE (u, '(A)') '(-) (-) (m) (-)' + WRITE (u, '(A)') '1 cab '//TRIM(length_segs) + IF (PRESENT(atts)) THEN + WRITE (u, '(A)') '--- ATTACHMENTS ---' + WRITE (u, '(A)') 'LineID ArcLength Mass Volume CdA Ca' + WRITE (u, '(A)') '(-) (m) (kg) (m3) (m2) (-)' + DO i = 1, SIZE(atts) + WRITE (u, '(A)') TRIM(atts(i)) + END DO + END IF + WRITE (u, '(A)') '--- END CONNECTIONS ---' + WRITE (u, '(A)') 'LineID End Stiffness EzX EzY EzZ TorsStiffness NxX NxY NxZ Pretwist' + WRITE (u, '(A)') '(-) (-) (N-m/rad) (-) (-) (-) (N-m/rad) (-) (-) (-) (deg)' + DO i = 1, SIZE(endconns) + WRITE (u, '(A)') TRIM(endconns(i)) + END DO + WRITE (u, '(A)') '--- OPTIONS ---' + WRITE (u, '(A)') '9.80665 g' + WRITE (u, '(A)') '1025.0 rhoW' + WRITE (u, '(A)') '200.0 WtrDpth' + DO i = 1, SIZE(options) + WRITE (u, '(A)') TRIM(options(i)) + END DO + WRITE (u, '(A)') '--- OUTPUTS ---' + DO i = 1, SIZE(outs) + WRITE (u, '(A)') TRIM(outs(i)) + END DO + WRITE (u, '(A)') '--- END ---' + CLOSE (u) + END SUBROUTINE write_deck + + SUBROUTINE run_deck(path, root, ok, em_out) + CHARACTER(*), INTENT(IN) :: path, root + LOGICAL, INTENT(OUT) :: ok + CHARACTER(*), INTENT(OUT) :: em_out + LOGICAL :: conv + INTEGER :: es + CALL CD_Run_Deck_Driver(path, root, conv, es, em_out) + ok = es == CD_DECKDRV_OK .AND. conv + END SUBROUTINE run_deck + + SUBROUTINE read_row(path, row, vals, ok) + !! Data row `row` (0 = first) of a driver .out file. + CHARACTER(*), INTENT(IN) :: path + INTEGER, INTENT(IN) :: row + REAL(wp), INTENT(OUT) :: vals(:) + LOGICAL, INTENT(OUT) :: ok + INTEGER :: u, ios, i + CHARACTER(2048) :: buf + ok = .FALSE. + vals = 0.0_wp + OPEN (NEWUNIT=u, FILE=path, STATUS='OLD', ACTION='READ', IOSTAT=ios) + IF (ios /= 0) RETURN + READ (u, '(A)', IOSTAT=ios) buf + READ (u, '(A)', IOSTAT=ios) buf + DO i = 0, row + READ (u, *, IOSTAT=ios) vals + IF (ios /= 0) THEN + CLOSE (u) + RETURN + END IF + END DO + CLOSE (u) + ok = ALL(IEEE_IS_FINITE(vals)) + END SUBROUTINE read_row + + LOGICAL FUNCTION same_file(a, b) RESULT(same) + !! Byte-identical text files. + CHARACTER(*), INTENT(IN) :: a, b + INTEGER :: ua, ub, ia, ib + CHARACTER(4096) :: la, lb + same = .FALSE. + OPEN (NEWUNIT=ua, FILE=a, STATUS='OLD', ACTION='READ', IOSTAT=ia) + IF (ia /= 0) RETURN + OPEN (NEWUNIT=ub, FILE=b, STATUS='OLD', ACTION='READ', IOSTAT=ib) + IF (ib /= 0) THEN + CLOSE (ua) + RETURN + END IF + DO + READ (ua, '(A)', IOSTAT=ia) la + READ (ub, '(A)', IOSTAT=ib) lb + IF (ia /= 0 .OR. ib /= 0) EXIT + IF (la /= lb) THEN + CLOSE (ua) + CLOSE (ub) + RETURN + END IF + END DO + same = ia /= 0 .AND. ib /= 0 + CLOSE (ua) + CLOSE (ub) + END FUNCTION same_file + + FUNCTION vec(v) RESULT(s) + !! Three numbers at full precision for a deck row. + REAL(wp), INTENT(IN) :: v(3) + CHARACTER(80) :: s + WRITE (s, '(3ES25.16E3)') v + END FUNCTION vec + + ! ------------------------------------------------------------------------------------------ + SUBROUTINE check_fixed_rod() + !! Gate 1. The rod runs 10 m from (0, 0, -30) along a = (0.48, 0.36, -0.8); the 100 m line + !! hangs from its End B along a to an anchor 100.01 m away, both ends Rigid in bending and + !! torsion with Ez = a and Nx = (0.6, -0.8, 0) (normal to a, global axes). + CHARACTER(16), PARAMETER :: OUTS(6) = [CHARACTER(16) :: 'Torq1N1', 'Torq1N41', 'Twist1', 'Rod1Mx', 'Rod1My', & + 'Rod1Mz'] + REAL(wp), PARAMETER :: AX(3) = [0.48_wp, 0.36_wp, -0.8_wp], NX(3) = [0.6_wp, -0.8_wp, 0.0_wp] + REAL(wp), PARAMETER :: LN = 100.0_wp + REAL(wp) :: pa(3), pb(3), anchor(3), m_ref, v(7), vp(7), e_ref, e_route, e_zero, e_mom, e_dyn, e_pin + CHARACTER(256) :: rrow, prow, arow, ca, cb + LOGICAL :: ok + CHARACTER(512) :: em + INTEGER :: k + pa = [0.0_wp, 0.0_wp, -30.0_wp] + pb = pa + 10.0_wp*AX + anchor = pb + (LN*1.0001_wp)*AX + rrow = '1 arm Fixed '//TRIM(vec(pa))//' '//TRIM(vec(pb))//' 4 -' + WRITE (arow, '(A,A,A)') '2 Fixed ', TRIM(vec(anchor)), ' 0 0 0 0' + m_ref = GJ*4.0_wp*PI/LN + ! (a) two turns between the ends, from a nonzero End A pretwist + ca = '1 A Rigid '//TRIM(vec(AX))//' Rigid '//TRIM(vec(NX))//' 30' + cb = '1 B Rigid '//TRIM(vec(AX))//' Rigid '//TRIM(vec(NX))//' 750' + CALL write_deck('trod_fixed.dat', [CHARACTER(8) ::], [rrow], [arow], '1 R1B 2 -', '100.0 40', [ca, cb], & + [CHARACTER(16) :: '0.1 dtM', '0.0 TMax'], OUTS) + CALL run_deck('trod_fixed.dat', 'trod_fixed', ok, em) + CALL require(ok, '1: a torsional End A on a Fixed rod runs: '//TRIM(em)) + IF (.NOT. ok) RETURN + CALL read_row('trod_fixed.out', 0, v, ok) + CALL require(ok, '1: Fixed rod output readable') + e_ref = nan_max_abs(v(2:3) - m_ref)/m_ref + ! Rod1M about the rod's End A: the line pulls along the rod axis through End B, the neutral + ! rod's weight and buoyancy cancel, so the moment is the connection moment M_t a + e_mom = NORM2(v(5:7) - m_ref*AX)/m_ref + ! (b) the same line hung from a Coupled point at the rod's End B, which the standalone finite-EI + ! march (a second route; it takes no Fixed End A) holds still + WRITE (prow, '(A,A,A)') '1 Coupled ', TRIM(vec(pb)), ' 0 0 0 0' + CALL write_deck('trod_point.dat', [CHARACTER(8) ::], [CHARACTER(8) ::], [prow, arow], '1 1 2 -', '100.0 40', & + [ca, cb], [CHARACTER(16) :: '0.1 dtM', '0.0 TMax'], OUTS(1:3)) + CALL run_deck('trod_point.dat', 'trod_point', ok, em) + CALL require(ok, '1: the same line from a held Coupled point runs: '//TRIM(em)) + e_route = 1.0_wp + IF (ok) CALL read_row('trod_point.out', 0, vp(1:4), ok) + IF (ok) e_route = nan_max_abs(v(2:4) - vp(2:4))/m_ref + ! (c) equal normals and pretwists: no twist, whatever the roll of the rod frame + ca = '1 A Rigid '//TRIM(vec(AX))//' Rigid '//TRIM(vec(NX))//' 45' + cb = '1 B Rigid '//TRIM(vec(AX))//' Rigid '//TRIM(vec(NX))//' 45' + CALL write_deck('trod_zero.dat', [CHARACTER(8) ::], [rrow], [arow], '1 R1B 2 -', '100.0 40', [ca, cb], & + [CHARACTER(16) :: '0.1 dtM', '0.0 TMax'], OUTS) + CALL run_deck('trod_zero.dat', 'trod_zero', ok, em) + CALL require(ok, '1: the untwisted rod-end line runs: '//TRIM(em)) + CALL read_row('trod_zero.out', 0, vp, ok) + e_zero = nan_max_abs([vp(2:3), NORM2(vp(5:7))])/m_ref + ! (d) a 1 s march holds the torque + ca = '1 A Rigid '//TRIM(vec(AX))//' Rigid '//TRIM(vec(NX))//' 30' + cb = '1 B Rigid '//TRIM(vec(AX))//' Rigid '//TRIM(vec(NX))//' 750' + CALL write_deck('trod_dyn.dat', [CHARACTER(8) ::], [rrow], [arow], '1 R1B 2 -', '100.0 40', [ca, cb], & + [CHARACTER(16) :: '0.1 dtM', '1.0 TMax'], OUTS) + CALL run_deck('trod_dyn.dat', 'trod_dyn', ok, em) + CALL require(ok, '1: the Fixed rod march runs: '//TRIM(em)) + e_dyn = 0.0_wp + DO k = 0, 10 + CALL read_row('trod_dyn.out', k, vp, ok) + IF (.NOT. ok) EXIT + e_dyn = nan_max_abs([e_dyn, nan_max_abs(vp(2:3) - m_ref)/m_ref, NORM2(vp(5:7) - m_ref*AX)/m_ref]) + END DO + CALL require(ok, '1: every march row readable') + ! (e) bending-pinned, torsionally rigid End A (the semi-tangential end): a straight line + ! carries the same torque + ca = '1 A Pinned '//TRIM(vec(AX))//' Rigid '//TRIM(vec(NX))//' 30' + CALL write_deck('trod_pin.dat', [CHARACTER(8) ::], [rrow], [arow], '1 R1B 2 -', '100.0 40', [ca, cb], & + [CHARACTER(16) :: '0.1 dtM', '0.0 TMax'], OUTS) + CALL run_deck('trod_pin.dat', 'trod_pin', ok, em) + CALL require(ok, '1: the bending-pinned rod-end line runs: '//TRIM(em)) + CALL read_row('trod_pin.out', 0, vp, ok) + e_pin = nan_max_abs(vp(2:3) - m_ref)/m_ref + ! (f) the deck of (a) written anchor first (MoorDyn's order: NodeA the anchor, NodeB the rod + ! end, each row's Ez from the anchor and its pretwist about it): the reader turns the line + ! around, and the run is (a)'s bit for bit + ca = '1 A Rigid '//TRIM(vec(-AX))//' Rigid '//TRIM(vec(NX))//' -750' + cb = '1 B Rigid '//TRIM(vec(-AX))//' Rigid '//TRIM(vec(NX))//' -30' + CALL write_deck('trod_af.dat', [CHARACTER(8) ::], [rrow], [arow], '1 2 R1B -', '100.0 40', [ca, cb], & + [CHARACTER(16) :: '0.1 dtM', '0.0 TMax'], OUTS) + CALL run_deck('trod_af.dat', 'trod_af', ok, em) + CALL require(ok, '1: the anchor-first line onto the Fixed rod runs: '//TRIM(em)) + CALL require(same_file('trod_fixed.out', 'trod_af.out'), '1: the anchor-first deck runs bit for bit as '// & + 'the rod-first one') + WRITE (*, '(A,2ES15.7,A,ES15.7,A,ES10.3,A,ES10.3,A,ES10.3,A,ES10.3,A,ES10.3,A,ES10.3,A,L1)') & + 'Fixed rod: Torq N1/N41 ', v(2:3), ' ref GJ Phi/L ', m_ref, ' (rel ', e_ref, '); vs a held Coupled point ', & + e_route, '; untwisted ', e_zero, '; Rod1M - M a ', e_mom, '; 1 s march ', e_dyn, '; pinned bending ', e_pin, & + '; anchor-first identical ', same_file('trod_fixed.out', 'trod_af.out') + CALL require(e_ref <= 1.0e-7_wp, '1: Torq = GJ Phi / L on a Fixed rod end') + CALL require(e_route <= 1.0e-7_wp, '1: the same torque and twist as from a held Coupled point') + CALL require(e_zero <= 1.0e-7_wp, '1: equal normals and pretwists give no torque (normal in the rod frame)') + CALL require(e_mom <= 1.0e-7_wp, '1: RodM is the torque along the line axis') + CALL require(e_dyn <= 1.0e-7_wp, '1: the march holds the torque and the rod moment') + CALL require(e_pin <= 1.0e-7_wp, '1: a bending-pinned torsional End A carries the same torque') + END SUBROUTINE check_fixed_rod + + ! ------------------------------------------------------------------------------------------ + SUBROUTINE check_body_rod_roll() + !! Gate 2. A Rigid6 body (attitude ROT, translation massive, roll inertia IB) carries a rod + !! fixed to it from its reference point along dbody (10 m); the 20 m line hangs from the rod's + !! End B along the rod axis dg = R dbody to an anchor, stretched by 1e-4, and is twisted by + !! PHI at End B. Released from rest, the body rolls about dg: theta = PHI (1 - cos Omega t). + REAL(wp), PARAMETER :: ROT(3) = [10.0_wp, -20.0_wp, 35.0_wp], MB = 1.0e9_wp, IB = 1.0e3_wp, LN = 20.0_wp + REAL(wp), PARAMETER :: PHI_DEG = 30.0_wp, DT = 0.01_wp + INTEGER, PARAMETER :: NSTEP = 400 + REAL(wp), ALLOCATABLE :: rec(:, :) + REAL(wp) :: r0(3, 3), rk(3, 3), q(3, 3), dbody(3), nbody(3), dg(3), dk(3), pb(3), anchor(3), w(3), s, ang + REAL(wp) :: kt, phi, ieff, omega, m0, theta, mt, v(5), e_torque, e_axis, e_rod, e_chan, e_wave, mrod + CHARACTER(256) :: brow, rrow, arow, ca, cb + LOGICAL :: ok + CHARACTER(512) :: em + INTEGER :: k + r0 = CD_Body_Rotation(ROT(1), ROT(2), ROT(3)) + dbody = [0.0_wp, 0.6_wp, -0.8_wp] + nbody = [1.0_wp, 0.0_wp, 0.0_wp] + dg = MATMUL(r0, dbody) + pb = [0.0_wp, 0.0_wp, -60.0_wp] + 10.0_wp*dg + anchor = pb + (LN*1.0001_wp)*dg + WRITE (brow, '(A,3F8.2,A,ES24.16,A,ES24.16,A,3ES12.4)') '1 Rigid6 0 0 -60 ', ROT, ' ', MB, ' ', MB/RHOW, & + ' 0 0 0 0 0 ', IB, IB, IB + rrow = '1 arm Body1 0 0 0 '//TRIM(vec(10.0_wp*dbody))//' 4 -' + WRITE (arow, '(A,A,A)') '2 Fixed ', TRIM(vec(anchor)), ' 0 0 0 0' + ca = '1 A Rigid '//TRIM(vec(dbody))//' Rigid '//TRIM(vec(nbody))//' 0' + WRITE (cb, '(A,A,A,A,F8.2)') '1 B Rigid ', TRIM(vec(dg)), ' Rigid ', TRIM(vec(MATMUL(r0, nbody))), PHI_DEG + CALL write_deck('trod_body.dat', [brow], [rrow], [arow], '1 R1B 2 -', '20.0 20', [ca, cb], & + [CHARACTER(24) :: 'moordyn bodyWetting', 'deck bodyIC', '0.01 dtM', '4.0 TMax'], & + [CHARACTER(12) :: 'Torq1N1', 'Rod1Mx', 'Rod1My', 'Rod1Mz']) + CALL CD_Multibody_Probe_Arm([0.0_wp, 0.0_wp, 0.0_wp], [0.0_wp, 0.0_wp, 0.0_wp]) + CALL run_deck('trod_body.dat', 'trod_body', ok, em) + CALL CD_Multibody_Probe_Get(rec) + ok = ok .AND. ALLOCATED(rec) + CALL require(ok, '2: the rod on a rolling body runs and is probed: '//TRIM(em)) + IF (.NOT. ok) RETURN + ok = UBOUND(rec, 2) >= NSTEP + CALL require(ok, '2: every step is recorded') + IF (.NOT. ok) RETURN + kt = GJ/LN + phi = PHI_DEG*PI/180.0_wp + m0 = kt*phi + ! the roll inertia about dg: the body's and the rod's polar inertia m r^2 / 2 (the rod axis is + ! the roll axis) + mrod = RHOW*0.25_wp*PI*0.04_wp*10.0_wp + ieff = IB + 0.5_wp*mrod*0.1_wp**2 + omega = SQRT(kt/ieff) + e_torque = 0.0_wp + e_axis = 0.0_wp + e_rod = 0.0_wp + e_chan = 0.0_wp + e_wave = 0.0_wp + DO k = 0, NSTEP + CALL read_row('trod_body.out', k, v, ok) + IF (.NOT. ok) EXIT + rk = RESHAPE(rec(8:16, k), [3, 3]) + ! the body's roll since the start, about dg (axis-angle of R_k R_0^T) + q = MATMUL(rk, TRANSPOSE(r0)) + ang = ACOS(MAX(-1.0_wp, MIN(1.0_wp, 0.5_wp*(q(1, 1) + q(2, 2) + q(3, 3) - 1.0_wp)))) + w = [q(3, 2) - q(2, 3), q(1, 3) - q(3, 1), q(2, 1) - q(1, 2)] + s = NORM2(w) + theta = 0.0_wp + IF (s > 1.0e-12_wp) theta = SIGN(ang, DOT_PRODUCT(w, dg)) + dk = MATMUL(q, dg) + ! the moment the line returns to the body (committed connection moment) + mt = DOT_PRODUCT(rec(24:26, k), dk) + e_torque = nan_max_abs([e_torque, ABS(mt - kt*(phi - theta))/m0]) + e_axis = nan_max_abs([e_axis, NORM2(rec(24:26, k) - mt*dk)/m0]) + e_rod = nan_max_abs([e_rod, NORM2(v(3:5) - rec(24:26, k))/m0]) + e_chan = nan_max_abs([e_chan, ABS(v(2) - mt)/m0]) + e_wave = nan_max_abs([e_wave, ABS(theta - phi*(1.0_wp - COS(omega*REAL(k, wp)*DT)))/phi]) + END DO + CALL require(ok, '2: all output rows readable') + WRITE (*, '(A,ES10.3,A,ES10.3,A,ES10.3,A,ES10.3,A,ES10.3,A,F8.4,A)') 'rod on a rolling body: torque vs '// & + 'GJ (Phi - theta)/L ', e_torque, ', moment off the line axis ', e_axis, ', Rod1M vs the returned moment ', & + e_rod, ', Torq channel ', e_chan, ' (of GJ Phi/L); roll vs Phi (1 - cos Omega t) ', e_wave, ' of Phi (Omega = ', & + omega, ' rad/s)' + CALL require(e_torque <= 1.0e-6_wp, '2: the torque follows GJ (Phi - theta) / L quasi-statically') + CALL require(e_axis <= 1.0e-6_wp, '2: the moment returned to the body is the torque along the line axis') + CALL require(e_rod <= 1.0e-6_wp, '2: RodM of the body-fixed rod carries the connection moment') + CALL require(e_chan <= 1.0e-6_wp, '2: TorqN1 is the returned torque') + CALL require(e_wave <= 1.0e-2_wp, '2: the body and rod swing as a torsional pendulum at sqrt(GJ/(L I))') + END SUBROUTINE check_body_rod_roll + + ! ------------------------------------------------------------------------------------------ + SUBROUTINE check_refusals() + !! Gate 3. A rod without a roll angle refuses the torsion by name; so does a Coupled rod. + CHARACTER(256) :: brow + CALL refused('Pinned', '1 arm Pinned 0 0 -30 0 0 -40 4 -', [CHARACTER(8) ::], & + 'on the end of ROD 1 (pinned) is not supported: a free or pinned rod is axisymmetric') + CALL refused('Free', '1 arm Free 0 0 -30 0 0 -40 4 -', [CHARACTER(8) ::], & + 'on the end of ROD 1 (free) is not supported: a free or pinned rod is axisymmetric') + brow = '1 Rigid6 0 0 -20 0 0 0 1.0e9 975609.75609756098 0 0 0 0 0 1.0e3 1.0e3 1.0e3' + CALL refused('BodyPinned', '1 arm Body1Pinned 0 0 -10 0 0 -20 4 -', [brow], & + 'on the end of ROD 1 (body1pinned) is not supported: a free or pinned rod is axisymmetric') + CALL refused('Coupled', '1 arm Coupled 0 0 -30 0 0 -40 4 -', [CHARACTER(8) ::], & + 'on the end of Coupled/Vessel ROD 1 is not supported: no route of this build carries a finite-EI '// & + 'line on a host-driven rod', 'trod_none.motion motionFile') + ! the staggered body scheme drives a cable end by translation only: a torsional End A on a + ! rod fixed to a body (here bending-pinned, which that scheme otherwise takes) is refused + CALL refused('Body (staggered)', '1 arm Body1 0 0 -10 0 0 -20 4 -', [brow], & + 'a torsional END CONNECTION on a body or rod needs bodyScheme monolithic', 'staggered bodyScheme', & + 'Pinned') + ! written anchor first onto a Pinned rod, the line is turned around and meets the rod's own + ! refusal (not "two moving ends") + CALL refused_rows('anchor-first Pinned', ['1 arm Pinned 0 0 -30 0 0 -40 4 -'], '1 2 R1B -', 1.0_wp, & + 'on the end of ROD 1 (pinned) is not supported: a free or pinned rod is axisymmetric') + ! a line between two Fixed rods (a J-tube to a J-tube): End B is a rod end + CALL refused_rows('two Fixed', [CHARACTER(48) :: '1 arm Fixed 0 0 -30 0 0 -40 4 -', & + '2 arm Fixed 0 0 -140.01 0 0 -150.01 4 -'], '1 R1B R2A -', -1.0_wp, & + 'torsional END CONNECTIONS require a finite-EI line with Fixed End B; line 1 ends (End B) '// & + 'on a rod end: a line between two rods is not supported in this build') + END SUBROUTINE check_refusals + + SUBROUTINE refused_rows(label, rod_rows, line_row, ez_z, needle) + !! A vertical line between z = -40 and -140.01 twisted by 90 deg (Ez = (0, 0, ez_z) at both + !! ends) on the given rods and LINES row (the Fixed point 2 at the bottom): the deck stops + !! with the message needle. + CHARACTER(*), INTENT(IN) :: label, rod_rows(:), line_row, needle + REAL(wp), INTENT(IN) :: ez_z + CHARACTER(256) :: ca, cb + LOGICAL :: ok + CHARACTER(512) :: em + ca = '1 A Rigid '//TRIM(vec([0.0_wp, 0.0_wp, ez_z]))//' Rigid 1 0 0 0' + cb = '1 B Rigid '//TRIM(vec([0.0_wp, 0.0_wp, ez_z]))//' Rigid 1 0 0 90' + CALL write_deck('trod_ref.dat', [CHARACTER(8) ::], rod_rows, ['2 Fixed 0.0 0.0 -140.01 0 0 0 0'], line_row, & + '100.0 40', [ca, cb], [CHARACTER(32) :: '0.1 dtM', '1.0 TMax'], [CHARACTER(8) :: 'Torq1N1']) + CALL run_deck('trod_ref.dat', 'trod_ref', ok, em) + WRITE (*, '(A,A,A,A)') 'refusal on a ', label, ' rod line: ', TRIM(em) + CALL require(.NOT. ok .AND. INDEX(em, needle) > 0, '3: a torsional line on a '//label//' rod is refused '// & + 'by name (got: '//TRIM(em)//')') + END SUBROUTINE refused_rows + + SUBROUTINE refused(label, rod_row, bodies, needle, extra, bend_a) + !! A vertical rod (End B at z = -40, or the body rods' at -40 in global axes) holding a + !! vertical line twisted by 90 deg: the deck stops with the message needle. extra: one more + !! OPTIONS row; bend_a: End A's bending connection (default Rigid). + CHARACTER(*), INTENT(IN) :: label, rod_row, bodies(:), needle + CHARACTER(*), INTENT(IN), OPTIONAL :: extra, bend_a + REAL(wp), PARAMETER :: AX(3) = [0.0_wp, 0.0_wp, -1.0_wp], NX(3) = [1.0_wp, 0.0_wp, 0.0_wp] + CHARACTER(64), PARAMETER :: ROW_A = '2 Fixed 0.0 0.0 -140.01 0 0 0 0' + CHARACTER(256) :: ca, cb + LOGICAL :: ok + CHARACTER(512) :: em + ca = '1 A Rigid '//TRIM(vec(AX))//' Rigid '//TRIM(vec(NX))//' 0' + IF (PRESENT(bend_a)) ca = '1 A '//bend_a//' '//TRIM(vec(AX))//' Rigid '//TRIM(vec(NX))//' 0' + cb = '1 B Rigid '//TRIM(vec(AX))//' Rigid '//TRIM(vec(NX))//' 90' + IF (PRESENT(extra)) THEN + CALL write_deck('trod_ref.dat', bodies, [rod_row], [ROW_A], '1 R1B 2 -', '100.0 40', [ca, cb], & + [CHARACTER(32) :: '0.1 dtM', '1.0 TMax', 'deck bodyIC', extra], [CHARACTER(8) :: 'Torq1N1']) + ELSE + CALL write_deck('trod_ref.dat', bodies, [rod_row], [ROW_A], '1 R1B 2 -', '100.0 40', [ca, cb], & + [CHARACTER(32) :: '0.1 dtM', '1.0 TMax', 'deck bodyIC'], [CHARACTER(8) :: 'Torq1N1']) + END IF + CALL run_deck('trod_ref.dat', 'trod_ref', ok, em) + WRITE (*, '(A,A,A,A)') 'refusal on a ', label, ' rod: ', TRIM(em) + CALL require(.NOT. ok .AND. INDEX(em, needle) > 0, '3: a torsional End A on a '//label//' rod is refused '// & + 'by name (got: '//TRIM(em)//')') + END SUBROUTINE refused + + ! ------------------------------------------------------------------------------------------ + SUBROUTINE check_one_end_rod() + !! Gate 4, one restrained end: the gate 1 J-tube line with GJ|K, free in torsion at one end. + CHARACTER(16), PARAMETER :: OUTS(3) = [CHARACTER(16) :: 'Torq1N1', 'Torq1N41', 'Twist1'] + REAL(wp), PARAMETER :: AX(3) = [0.48_wp, 0.36_wp, -0.8_wp], NX(3) = [0.6_wp, -0.8_wp, 0.0_wp] + REAL(wp), PARAMETER :: LN = 100.0_wp, KC = 4.0e5_wp + CHARACTER(160) :: bare_type + REAL(wp) :: pa(3), pb(3), anchor(3), tw_ref, v(4), vp(4), e_tw(2), e_m(2), e_route(2) + CHARACTER(256) :: rrow, prow, arow, ca(2), cb(2) + CHARACTER(24), PARAMETER :: LABEL(2) = [CHARACTER(24) :: 'End B free', 'End A (rod end) free'] + LOGICAL :: ok + CHARACTER(512) :: em + INTEGER :: iv + bare_type = neutral_type + WRITE (neutral_type, '(A,ES24.16,A)') 'cab 0.2 ', RHOW*0.25_wp*PI*0.04_wp, & + ' 1.0e7 0.0 1.0e6 1.0e8 5.0e4|4.0e5 1.0 1.0e-12 0.0 0.0 0.0 0.0' + pa = [0.0_wp, 0.0_wp, -30.0_wp] + pb = pa + 10.0_wp*AX + anchor = pb + (LN*1.0001_wp)*AX + rrow = '1 arm Fixed '//TRIM(vec(pa))//' '//TRIM(vec(pb))//' 4 -' + WRITE (arow, '(A,A,A)') '2 Fixed ', TRIM(vec(anchor)), ' 0 0 0 0' + WRITE (prow, '(A,A,A)') '1 Coupled ', TRIM(vec(pb)), ' 0 0 0 0' + ! the free end turns by the stretch's -(K/GJ) dl relative to the restrained one + tw_ref = -(KC/GJ)*(LN*1.0e-4_wp)*180.0_wp/PI + ca(1) = '1 A Rigid '//TRIM(vec(AX))//' Rigid '//TRIM(vec(NX))//' 30' + cb(1) = '1 B Rigid '//TRIM(vec(AX))//' Free '//TRIM(vec(NX))//' 0' + ca(2) = '1 A Rigid '//TRIM(vec(AX))//' Free '//TRIM(vec(NX))//' 0' + cb(2) = '1 B Rigid '//TRIM(vec(AX))//' Rigid '//TRIM(vec(NX))//' 30' + DO iv = 1, 2 + CALL write_deck('trod_oe.dat', [CHARACTER(8) ::], [rrow], [arow], '1 R1B 2 -', '100.0 40', [ca(iv), cb(iv)], & + [CHARACTER(16) :: '0.1 dtM', '0.0 TMax'], OUTS) + CALL run_deck('trod_oe.dat', 'trod_oe', ok, em) + CALL require(ok, '4: a line restrained at one end ('//TRIM(LABEL(iv))//') on a Fixed rod runs with its twist '// & + 'channels: '//TRIM(em)) + e_tw(iv) = 1.0_wp + e_m(iv) = 1.0_wp + e_route(iv) = 1.0_wp + IF (.NOT. ok) CYCLE + CALL read_row('trod_oe.out', 0, v, ok) + CALL require(ok, '4: one-end rod output readable') + e_tw(iv) = ABS(v(4) - tw_ref)/ABS(tw_ref) + ! against the torque K eps the coupling would give a section held from twisting + e_m(iv) = nan_max_abs(v(2:3))/(KC*1.0e-4_wp) + CALL write_deck('trod_oep.dat', [CHARACTER(8) ::], [CHARACTER(8) ::], [prow, arow], '1 1 2 -', '100.0 40', & + [ca(iv), cb(iv)], [CHARACTER(16) :: '0.1 dtM', '0.0 TMax'], OUTS) + CALL run_deck('trod_oep.dat', 'trod_oep', ok, em) + CALL require(ok, '4: the same line from a held Coupled point runs: '//TRIM(em)) + IF (ok) CALL read_row('trod_oep.out', 0, vp, ok) + IF (ok) e_route(iv) = ABS(v(4) - vp(4))/ABS(tw_ref) + WRITE (*, '(A,A,A,F12.7,A,F12.7,A,3ES10.3)') 'one end on a Fixed rod, ', TRIM(LABEL(iv)), ': Twist1 ', v(4), & + ' deg (-(K/GJ) dl ', tw_ref, '); errors twist, |torque| / K eps, vs a held Coupled point ', e_tw(iv), & + e_m(iv), e_route(iv) + END DO + neutral_type = bare_type + CALL require(MAXVAL(e_tw) <= 1.0e-6_wp, '4: the free end turns by -(K/GJ) dl on a Fixed rod end') + CALL require(MAXVAL(e_m) <= 1.0e-6_wp, '4: a line free at one end carries no torque on a Fixed rod end') + CALL require(MAXVAL(e_route) <= 1.0e-6_wp, '4: the same twist as from a held Coupled point') + END SUBROUTINE check_one_end_rod + + SUBROUTINE check_attachments_rod() + !! Gate 4, ATTACHMENTS: the gate 1 line twisted two turns with two clumps and a buoy. + CHARACTER(16), PARAMETER :: OUTS(3) = [CHARACTER(16) :: 'Torq1N1', 'Torq1N41', 'Twist1'] + REAL(wp), PARAMETER :: AX(3) = [0.48_wp, 0.36_wp, -0.8_wp], NX(3) = [0.6_wp, -0.8_wp, 0.0_wp] + REAL(wp), PARAMETER :: LN = 100.0_wp + CHARACTER(48), PARAMETER :: ATTS(3) = [CHARACTER(48) :: '1 25.0 500.0 0.1 0.0 0.0', '1 50.0 50.0 0.4 0.0 0.0', & + '1 75.0 300.0 0.05 0.0 0.0'] + REAL(wp) :: pa(3), pb(3), anchor(3), m_ref, v(4), vp(4), e_route + CHARACTER(256) :: rrow, prow, arow, ca, cb + LOGICAL :: ok + CHARACTER(512) :: em + pa = [0.0_wp, 0.0_wp, -30.0_wp] + pb = pa + 10.0_wp*AX + anchor = pb + (LN*1.0001_wp)*AX + rrow = '1 arm Fixed '//TRIM(vec(pa))//' '//TRIM(vec(pb))//' 4 -' + WRITE (arow, '(A,A,A)') '2 Fixed ', TRIM(vec(anchor)), ' 0 0 0 0' + WRITE (prow, '(A,A,A)') '1 Coupled ', TRIM(vec(pb)), ' 0 0 0 0' + m_ref = GJ*4.0_wp*PI/LN + ca = '1 A Rigid '//TRIM(vec(AX))//' Rigid '//TRIM(vec(NX))//' 30' + cb = '1 B Rigid '//TRIM(vec(AX))//' Rigid '//TRIM(vec(NX))//' 750' + CALL write_deck('trod_att.dat', [CHARACTER(8) ::], [rrow], [arow], '1 R1B 2 -', '100.0 40', [ca, cb], & + [CHARACTER(16) :: '0.1 dtM', '0.0 TMax'], OUTS, atts=ATTS) + CALL run_deck('trod_att.dat', 'trod_att', ok, em) + CALL require(ok, '4: a rod-end line with ATTACHMENTS runs: '//TRIM(em)) + IF (.NOT. ok) RETURN + CALL read_row('trod_att.out', 0, v, ok) + CALL write_deck('trod_attp.dat', [CHARACTER(8) ::], [CHARACTER(8) ::], [prow, arow], '1 1 2 -', '100.0 40', & + [ca, cb], [CHARACTER(16) :: '0.1 dtM', '0.0 TMax'], OUTS, atts=ATTS) + CALL run_deck('trod_attp.dat', 'trod_attp', ok, em) + CALL require(ok, '4: the same line with ATTACHMENTS from a held Coupled point runs: '//TRIM(em)) + IF (.NOT. ok) RETURN + CALL read_row('trod_attp.out', 0, vp, ok) + e_route = nan_max_abs(v(2:4) - vp(2:4))/m_ref + WRITE (*, '(A,3ES15.7,A,3ES15.7,A,ES10.3)') 'ATTACHMENTS on a Fixed rod line: Torq N1/N41, Twist1 ', v(2:4), & + '; from a held Coupled point ', vp(2:4), '; difference / (GJ Phi/L) ', e_route + CALL require(e_route <= 1.0e-7_wp, '4: the rod-end line with ATTACHMENTS has the held point''s torque and twist') + CALL require(ABS(v(2)/m_ref - 1.0_wp) > 1.0e-6_wp, '4: the attachments bend the line (its torque is not GJ Phi/L)') + END SUBROUTINE check_attachments_rod + +END PROGRAM test_rod_end_torsion diff --git a/tests/test_step_allocations.f90 b/tests/test_step_allocations.f90 index df0ccab8..c20dade2 100644 --- a/tests/test_step_allocations.f90 +++ b/tests/test_step_allocations.f90 @@ -23,15 +23,21 @@ PROGRAM test_step_allocations !! committed-state outputs (CD_HFMF_SetCoupledKinematics, CD_HFMF_CalcOutput with the connection !! moment, both end forces, the energy and the torque query) are gated as well. With "nodal" !! the same cable carries the nodal twist (polar inertia and torsional damping), with its - !! 7-DOF-per-node band and the node-torque and element-twist queries. + !! 7-DOF-per-node band and the node-torque and element-twist queries; with "free" the nodal + !! twist of the same cable free in torsion at its held end (restrained at the coupled end only). !! !! With "current_grid" the gate runs the evaluation of a MoorDyn-C current grid (Currents 2 and !! 5) that every standalone step makes at every node: CD_Current_Grid_Velocity, and the gradient !! of the EI = 0 static tangent (CD_Current_Grid_Gradient), at points inside and outside a !! sheared grid and at times before, inside and past its last sample. !! + !! With "motion_roll" or "motion_vessel" the gate runs the standalone driver's march of a mixed + !! EI = 0 + finite-EI deck with the deck's prescribed motion (CD_AGG_MotionKinematics, then + !! CD_AGG_Step_Moving with the roll column or with the vessel orientation and rates): a straight + !! line restrained in torsion whose End A rolls about its axis, beside an EI = 0 chain. + !! !! Usage: test_step_allocations [ranges] - !! test_step_allocations torsion | nodal | current_grid + !! test_step_allocations torsion | nodal | free | current_grid | motion_roll | motion_vessel USE, INTRINSIC :: ISO_C_BINDING, ONLY: C_INT, C_LONG_LONG USE CableDyn_Precision, ONLY: wp USE CableDyn_EndConnection, ONLY: CD_ENDCONN_RIGID @@ -48,7 +54,8 @@ PROGRAM test_step_allocations CD_AGG_NFluidNodes, CD_AGG_NumChannels, CD_AGG_GetMovingPointMesh, & CD_AGG_Snapshot, CD_AGG_SetFluidFields, CD_AGG_Step_Moving, & CD_AGG_CalcOutput, CD_AGG_EvalChannel, CD_AGG_End, & - CD_AGG_Range_Sample + CD_AGG_Range_Sample, CD_AGG_UpdateStates_Moving, CD_AGG_MotionKinematics, & + CD_AGG_Refresh_Accelerations IMPLICIT NONE INTERFACE FUNCTION cd_test_allocation_count() BIND(C, NAME='cd_test_allocation_count') RESULT(n) @@ -74,13 +81,17 @@ END SUBROUTINE cd_test_allocation_counting IF (COMMAND_ARGUMENT_COUNT() == 1) THEN CALL GET_COMMAND_ARGUMENT(1, arg) - IF (TRIM(arg) == 'current_grid') THEN + SELECT CASE (TRIM(arg)) + CASE ('torsion', 'nodal', 'free') + CALL torsion_gate(TRIM(arg) /= 'torsion', TRIM(arg) == 'free') + CASE ('current_grid') CALL current_grid_gate() - STOP - END IF - IF (TRIM(arg) /= 'torsion' .AND. TRIM(arg) /= 'nodal') & - ERROR STOP 'a single argument must be "torsion", "nodal" or "current_grid"' - CALL torsion_gate(TRIM(arg) == 'nodal') + CASE ('motion_roll', 'motion_vessel') + CALL motion_gate(TRIM(arg) == 'motion_vessel') + CASE DEFAULT + ERROR STOP 'a single argument must be "torsion", "nodal", "free", "current_grid", "motion_roll" or '// & + '"motion_vessel"' + END SELECT STOP END IF IF (COMMAND_ARGUMENT_COUNT() /= 3 .AND. COMMAND_ARGUMENT_COUNT() /= 4) THEN @@ -184,10 +195,10 @@ SUBROUTINE march(first_step, count, counted) END DO END SUBROUTINE march - SUBROUTINE torsion_gate(nodal) + SUBROUTINE torsion_gate(nodal, free_end) !! Zero heap allocation in CD_HFMF_UpdateStates of a cable with condensed torsion, or with the - !! nodal twist. - LOGICAL, INTENT(IN) :: nodal + !! nodal twist (free_end: free in torsion at the held end 1). + LOGICAL, INTENT(IN) :: nodal, free_end INTEGER, PARAMETER :: NE = 20, NN = NE + 1, NDOF = 6*NN, N_WARM = 40, N_COUNT = 200 REAL(wp), PARAMETER :: LL = 10.0_wp, DTT = 0.01_wp TYPE(CD_HFMF_ModuleType) :: cab @@ -228,6 +239,7 @@ SUBROUTINE torsion_gate(nodal) tors%irn = 0.05_wp tors%bt = 0.5_wp END IF + IF (free_end) tors%end_free(1) = .TRUE. tors%has_theta = .TRUE. frame(:, 1) = [1.0_wp, 0.0_wp, 0.0_wp] frame(:, 2) = [0.0_wp, 0.0_wp, 1.0_wp] @@ -335,6 +347,127 @@ SUBROUTINE current_grid_gate() PRINT '(A)', 'PASS: no heap allocation in the current grid evaluation' END SUBROUTINE current_grid_gate + SUBROUTINE motion_gate(vessel) + !! Zero heap allocation in the standalone driver's per-step march of a mixed deck with its + !! prescribed motion: the 100 m straight neutral line of test_mixed_route_torsion, clamped and + !! restrained in torsion at both ends, End A rolled about the line axis (by a vessel, or by the + !! motionFile roll column), beside a chain on a second moving point. + LOGICAL, INTENT(IN) :: vessel + INTEGER, PARAMETER :: N_WARM = 40, N_COUNT = 160, NT = N_WARM + N_COUNT + REAL(wp), PARAMETER :: DTM = 0.05_wp, PI = 3.14159265358979323846_wp + TYPE(CD_AGG_ModuleType), ALLOCATABLE :: mag + REAL(wp), ALLOCATABLE :: p(:, :), v(:, :), a(:, :), ld(:, :), o(:, :, :), w(:, :), al(:, :), roll(:) + REAL(wp) :: t, ro, dro, d2ro, om + INTEGER :: u, k, n, n_it + INTEGER(C_LONG_LONG) :: c0, n_alloc + LOGICAL :: turns, rolls, converged, stalled + ! one file root per mode: the two gates may run at once in one directory + CHARACTER(32) :: root + root = MERGE('step_alloc_motion_vessel', 'step_alloc_motion_roll ', vessel) + om = 2.0_wp*PI/10.0_wp + OPEN (NEWUNIT=u, FILE=TRIM(root)//'.txt', STATUS='REPLACE', ACTION='WRITE') + DO k = 0, NT + t = DTM*k + ro = 15.0_wp*(1.0_wp - COS(om*t)) + dro = 15.0_wp*om*SIN(om*t) + d2ro = 15.0_wp*om*om*COS(om*t) + IF (vessel) THEN + WRITE (u, '(F8.3,A,ES25.16E3,A,ES25.16E3,A,ES25.16E3,A)') t, ' 0 0 -50 ', ro, ' 0 0 0 0 0 ', dro*PI/180.0_wp, & + ' 0 0 0 0 0 ', d2ro*PI/180.0_wp, ' 0 0' + ELSE + WRITE (u, '(F8.3,A,ES25.16E3)') t, ' 1 0 0 -50 0 0 0 0 0 0 ', ro + WRITE (u, '(F8.3,A)') t, ' 3 0 10 -50 0 0 0 0 0 0' + END IF + END DO + CLOSE (u) + OPEN (NEWUNIT=u, FILE=TRIM(root)//'.dat', STATUS='REPLACE', ACTION='WRITE') + WRITE (u, '(A)') 'step allocation gate: mixed deck with prescribed motion' + WRITE (u, '(A)') '--- LINE TYPES ---' + WRITE (u, '(A)') 'Name Diam Mass EA BA EI GAs GJ Irt Irn Cdn Cdt Can Cat' + WRITE (u, '(A)') '(-) (m) (kg/m) (N) (-) (Nm2) (N) (Nm2) (kgm) (kgm) (-) (-) (-) (-)' + WRITE (u, '(A,ES24.16,A)') 'cab 0.2 ', 1025.0_wp*0.01_wp*PI, ' 1.0e7 0.0 1.0e6 1.0e8 5.0e4 1.0 1.0e-12 0 0 0 0' + WRITE (u, '(A)') 'chain 0.1 50.0 1.0e9 -1.0 0.0 0 0 0 0 1.37 0.64 1.0 0.0' + WRITE (u, '(A)') '--- POINTS ---' + WRITE (u, '(A)') 'ID Type X Y Z Mass Vol CdA Ca' + WRITE (u, '(A)') '(-) (-) (m) (m) (m) (kg) (m3) (m2) (-)' + WRITE (u, '(A)') '1 '//MERGE('Vessel ', 'Coupled', vessel)//' 0.0 0.0 -50.0 0 0 0 0' + WRITE (u, '(A)') '2 Fixed 100.0 0.0 -50.0 0 0 0 0' + WRITE (u, '(A)') '3 '//MERGE('Vessel ', 'Coupled', vessel)//' 0.0 10.0 -50.0 0 0 0 0' + WRITE (u, '(A)') '4 Fixed 0.0 100.0 -100.0 0 0 0 0' + WRITE (u, '(A)') '--- LINES ---' + WRITE (u, '(A)') 'ID NodeA NodeB Outputs' + WRITE (u, '(A)') '(-) (-) (-) (-)' + WRITE (u, '(A)') '1 1 2 -' + WRITE (u, '(A)') '2 3 4 -' + WRITE (u, '(A)') '--- SECTIONS ---' + WRITE (u, '(A)') 'LineID LineType Length NumSegs' + WRITE (u, '(A)') '(-) (-) (m) (-)' + WRITE (u, '(A)') '1 cab 100.0 40' + WRITE (u, '(A)') '2 chain 110.0 20' + WRITE (u, '(A)') '--- END CONNECTIONS ---' + WRITE (u, '(A)') 'LineID End Stiffness EzX EzY EzZ TorsStiffness NxX NxY NxZ Pretwist' + WRITE (u, '(A)') '(-) (-) (N-m/rad) (-) (-) (-) (N-m/rad) (-) (-) (-) (deg)' + WRITE (u, '(A)') '1 A Rigid 1 0 0 Rigid 0 0 1 0' + WRITE (u, '(A)') '1 B Rigid 1 0 0 Rigid 0 0 1 90' + WRITE (u, '(A)') '--- OPTIONS ---' + WRITE (u, '(A)') '9.80665 g' + WRITE (u, '(A)') '1025.0 rhoW' + WRITE (u, '(A)') '0.05 dtM' + WRITE (u, '(A)') '10.0 TMax' + IF (vessel) THEN + WRITE (u, '(A)') TRIM(root)//'.txt vesselMotion' + WRITE (u, '(A)') '0|0|-50 vesselRef' + ELSE + WRITE (u, '(A)') TRIM(root)//'.txt motionFile' + END IF + WRITE (u, '(A)') '--- OUTPUTS ---' + WRITE (u, '(A)') 'Torq1N1' + WRITE (u, '(A)') '--- END ---' + CLOSE (u) + ALLOCATE (mag) + CALL CD_AGG_Init_From_Deck(mag, TRIM(root)//'.dat', DTM, es, em, forbid_deck_ambient=.TRUE., & + run_tmax=10.0_wp, host_orientation=.TRUE., prescribed_motion=.TRUE.) + CALL check('motion deck initialization') + n = CD_AGG_NMovingPoints(mag, es, em) + CALL check('motion moving-point count') + ALLOCATE (p(3, n), v(3, n), a(3, n), ld(3, n), o(3, 3, n), w(3, n), al(3, n), roll(n)) + CALL CD_AGG_GetMovingPointMesh(mag, p, v, a, ld, es, em) + CALL check('motion initial mesh') + CALL CD_AGG_MotionKinematics(mag, 1, p, v, a, o, w, al, roll, turns, rolls, es, em) + CALL check('motion row 1') + IF (turns .EQV. rolls) ERROR STOP 'the motion gate drives neither or both frame inputs' + CALL CD_AGG_UpdateStates_Moving(mag, p, v, a, es, em) + CALL check('motion row 1 transfer') + CALL CD_AGG_Refresh_Accelerations(mag, es, em) + CALL check('motion row 1 accelerations') + n_alloc = 0 + DO k = 1, NT + c0 = cd_test_allocation_count() + IF (k > N_WARM) CALL cd_test_allocation_counting(1_C_INT) + CALL CD_AGG_MotionKinematics(mag, k + 1, p, v, a, o, w, al, roll, turns, rolls, es, em) + IF (es == 0) THEN + IF (turns) THEN + CALL CD_AGG_Step_Moving(mag, DTM, p, v, a, converged, stalled, n_it, es, em, t_committed=DTM*k, & + orientation=o, angular_velocity=w, angular_acceleration=al) + ELSE + CALL CD_AGG_Step_Moving(mag, DTM, p, v, a, converged, stalled, n_it, es, em, t_committed=DTM*k, roll=roll) + END IF + END IF + CALL cd_test_allocation_counting(0_C_INT) + CALL check('motion step') + IF (.NOT. converged .OR. stalled) ERROR STOP 'motion step did not converge' + n_alloc = n_alloc + (cd_test_allocation_count() - c0) + END DO + CALL CD_AGG_End(mag, es, em) + PRINT '(A,I0,A,I0,A)', 'mixed deck with '//MERGE('vessel motion', 'roll column ', vessel)//': ', N_COUNT, & + ' counted steps, ', n_alloc, ' heap allocations in the steps' + IF (n_alloc /= 0) THEN + PRINT '(A)', 'FAIL: the prescribed-motion march of a mixed deck allocated after warm-up' + ERROR STOP 1 + END IF + PRINT '(A)', 'PASS: no heap allocation in the prescribed-motion march of a mixed deck after warm-up' + END SUBROUTINE motion_gate + SUBROUTINE check(stage) CHARACTER(*), INTENT(IN) :: stage diff --git a/tests/test_torsion_deck.f90 b/tests/test_torsion_deck.f90 index c20f5ceb..d06cfff3 100644 --- a/tests/test_torsion_deck.f90 +++ b/tests/test_torsion_deck.f90 @@ -7,8 +7,9 @@ !> pretwist: Torq = GJ Phi / L at every node, Twist = 720 deg, TwistN linear from !> End A; torsional end springs add their compliance; !> 2. backward compatibility: the same deck with Free torsion columns (any normal), or with one -!> end restrained only, writes the same .out bytes as the 6-column rows; Rigid, Infinity, -!> Inf and a quoted "Rigid" are one restraint; +!> end restrained only on a 10-column LINE TYPES row (no GJ, so its torsion is not solved), +!> writes the same .out bytes as the 6-column rows; Rigid, Infinity, Inf and a quoted +!> "Rigid" are one restraint; !> 3. a pretwist sweep to three turns on a sagging clamped line: the torque grows in equal !> steps (no 2 pi slip) and Twist follows the pretwist; !> 4. body torque return: a massive Rigid6 body (attitude rolled, pitched and yawed) holding a @@ -845,8 +846,8 @@ SUBROUTINE expect_error(label, path, root, needle) END SUBROUTINE expect_error SUBROUTINE check_one_end_two_moving() - !! One restrained end is ignored before the torsion rules: on a line with two moving ends - !! (Coupled to Free, dynamic) the one-end row gets exactly the verdict of the six-column rows, + !! One restrained end on a line with two moving ends (Coupled to Free, dynamic) is not solved + !! in torsion (it is noted): the one-end row gets exactly the verdict of the six-column rows, !! not the torsion rule "two moving ends". LOGICAL :: ok0, ok1 CHARACTER(512) :: em0, em1 @@ -926,7 +927,8 @@ SUBROUTINE check_errors() CALL straight_deck('tdeck_e8.dat', 'Pinned 1 0 0 Rigid 0 0 1 0', 'Pinned 1 0 0 Free 0 0 1 0', & [CHARACTER(16) :: 'FairTen1'], tei0) CALL expect_error('torsion on an EI = 0 line is named', 'tdeck_e8.dat', 'tdeck_e8', 'require a finite-EI line') - CALL straight_deck('tdeck_e9.dat', 'Rigid 1 0 0 Rigid 0 0 1 0', 'Rigid 1 0 0 Free 0 0 1 720', OUTS) + ! (a line restrained at one end only is solved in torsion: test_torsion_one_end) + CALL straight_deck('tdeck_e9.dat', 'Rigid 1 0 0 Free 0 0 1 0', 'Rigid 1 0 0 Free 0 0 1 720', OUTS) CALL expect_error('a torque channel on a line without torsion is named', 'tdeck_e9.dat', 'tdeck_e9', & 'carries no torque') CALL write_deck('tdeck_e10.dat', [neutral_type], no_rows, & @@ -968,9 +970,9 @@ SUBROUTINE check_errors() [CHARACTER(16) :: '1 1 2 -'], [CHARACTER(24) :: '1 cab 100.0 40'], & [CHARACTER(96) :: '1 A Rigid 1 0 0 Rigid 0 0 1 0', '1 B Rigid 1 0 0 Rigid 0 0 1 90'], & [CHARACTER(24) :: '0.1 dtM'], [CHARACTER(16) :: 'FairTen1']) - ! a caller that does not pass the fairlead orientation (the C API, the standalone mixed - ! route) is refused by name; one that does (the OpenFAST and FAST.Farm shells) builds the - ! line with its torsion + ! a caller that does not pass the fairlead orientation (the C API) is refused by name; one + ! that does (the OpenFAST and FAST.Farm shells, the standalone mixed route) builds the line + ! with its torsion CALL CD_Init_Deck_Aggregate('tdeck_e12.dat', 0.1_wp, agg, es, em) CALL require(es /= CD_DECKDRV_OK .AND. INDEX(em, 'needs a host that turns its fairlead frame') > 0, & 'an aggregate caller without orientations refuses torsion by name (got: '//TRIM(em)//')') @@ -1021,8 +1023,9 @@ SUBROUTINE write_lines(path, rows) END SUBROUTINE write_lines SUBROUTINE check_scope_refusals() - !! 6 (continued). Torsion outside its scope stops by name: End A on a rod end and End A on a - !! Point3 body; a torsional line carrying ATTACHMENTS solves (test_torsion_attachments). + !! 6 (continued). Torsion outside its scope stops by name: End A on a pinned rod (a Fixed rod + !! end is supported, test_rod_end_torsion) and End A on a Point3 body; a torsional line + !! carrying ATTACHMENTS solves (test_torsion_attachments). CHARACTER(120) :: tail(9), ty(4) ty(1) = '--- LINE TYPES ---' ty(2) = 'Name Diam Mass EA BA EI GAs GJ Irt Irn Cdn Cdt Can Cat' @@ -1042,14 +1045,15 @@ SUBROUTINE check_scope_refusals() 'Name Diam Mass Cd Ca CdEnd CaEnd', '(-) (m) (kg/m) (-) (-) (-) (-)', & 'arm 0.6 400.0 1.0 1.0 0.0 0.0', '--- RODS ---', & 'ID RodType Attachment XA YA ZA XB YB ZB NumSegs Outputs', & - '(-) (-) (-) (m) (m) (m) (m) (m) (m) (-) (-)', '1 arm Fixed 0 0 -40 0 0 -50 4 -', & + '(-) (-) (-) (m) (m) (m) (m) (m) (m) (-) (-)', '1 arm Pinned 0 0 -40 0 0 -50 4 -', & '--- POINTS ---', 'ID Type X Y Z Mass Vol CdA Ca', '(-) (-) (m) (m) (m) (kg) (m3) (m2) (-)', & '2 Fixed 100.0 0.0 -50.0 0 0 0 0', '--- LINES ---', 'ID NodeA NodeB Outputs', '(-) (-) (-) (-)', & '1 R1B 2 -', tail(1:4), '--- END CONNECTIONS ---', & 'LineID End Stiffness EzX EzY EzZ TorsStiffness NxX NxY NxZ Pretwist', & '(-) (-) (N-m/rad) (-) (-) (-) (N-m/rad) (-) (-) (-) (deg)', '1 A Rigid 0 0 -1 Rigid 1 0 0 0', & '1 B Rigid 1 0 0 Rigid 0 0 1 0', tail(5:9)]) - CALL expect_error('a torsional end on a rod is named', 'tdeck_s1.dat', 'tdeck_s1', 'on a rod end is not supported') + CALL expect_error('a torsional end on a pinned rod is named', 'tdeck_s1.dat', 'tdeck_s1', & + 'on the end of ROD 1 (pinned) is not supported') ! End A on a Point3 body CALL write_lines('tdeck_s2.dat', [CHARACTER(120) :: 'torsion scope', ty, '--- BODIES ---', & 'ID Type X Y Z Roll Pitch Yaw Mass Vol C33 C44 C55 CdA Ca', & diff --git a/tests/test_torsion_one_end.f90 b/tests/test_torsion_one_end.f90 new file mode 100644 index 00000000..6f902cbc --- /dev/null +++ b/tests/test_torsion_one_end.f90 @@ -0,0 +1,1001 @@ +! File: tests/test_torsion_one_end.f90 +! SPDX-License-Identifier: Apache-2.0 +! Copyright (c) 2026 Jae Hoon Seo, SMI Lab, Inha University +PROGRAM test_torsion_one_end + !! Gates of a finite-EI line restrained in torsion at one end only, its other end free to twist + !! (END CONNECTIONS TorsStiffness Free there, or no row): the free end carries no torque and + !! turns with the twist of the line. + !! M modes and waves of the cubic-Hermite dynamics: a straight taut 10 m line (GJ 80 N m2, + !! Irn 0.5 kg m, 20 elements, clamped in bending, both end positions held), rigid in + !! torsion at one end and free at the other, the free end at internal end 2 (deck End A) + !! and at internal end 1 (deck End B) in turn: + !! M1 released from a twist (the restrained end's frame turned by 0.2 rad over a quarter + !! period, then held), the free end rings at the quarter-wave frequencies of the + !! clamped-free continuum, omega_n = (2n - 1) pi/(2L) sqrt(GJ/Irn), n = 1, 2 (the peaks + !! of its Hann-windowed spectrum, 0.4 % and 1 %); + !! M2 driven in roll A sin(Omega t) at the restrained end, Omega = omega_1/2 and + !! 3 omega_1/2 (kL = pi/4, 3 pi/4): the free end rolls with the continuum's A/cos kL + !! (in antiphase above the first mode) and the restrained end's support reacts with + !! GJ A k tan kL (1 %, the Fourier components at Omega); the free end's support takes + !! no torque; + !! M3 a snapshot of the driven run, restored, continues bit-identically. + !! C torque-tension coupling on the deck (standalone driver): a straight neutral cable (EA + !! 1e7 N, GJ|K 5e4 N m2|4e5 N m) of 99 m held 100 m apart, restrained in torsion at one end: + !! C1 statics, End A free, End B free, and End A without an END CONNECTIONS row (End B an + !! elastic restraint): the stretch twists the line by -(K/GJ) sum (l_e - l0_e) = -8 rad + !! (Twist1, half of it at mid-line, Twist1N41 = Twist1), no torque anywhere, and the + !! tension (EA - K^2/GJ) eps of a section free to twist; + !! C2 a march moving End A 0.1 m away over 20 s (polar inertia negligible, Irn 1e-9): the + !! free end, the moving End A or the anchored End B, turns with the stretch at every + !! step, Twist1 = -(K/GJ)(l(t) - l0), and the tension follows (EA - K^2/GJ) eps(t); + !! D torsional inertia on the deck: the 100 m line (GJ 5e4 N m2, Irn 1 kg m) restrained at + !! End A, free at End B, End A rolled A sin(Omega t) by the motionFile roll column at + !! Omega = omega_1/4 (kL = pi/8): the Fourier components at Omega of Twist1, Torq1N1 and + !! Torq1N41 are the continuum's, A (1/cos kL - 1) and GJ times its mean twist rate over the + !! end elements (the free end's element carries 1.3 % of the driven end's torque); + !! A the coupled aggregate (End A host-driven, host_orientation): the C1 line free at End A + !! keeps its static twist and no torque while the platform rolls about the line axis (the + !! roll does not reach a free end), with no axial moment on the platform; the D line + !! restrained at End A rolled by the platform gives D's continuum response; + !! N a line restrained at one end whose LINE TYPES row gives no GJ (10 columns) keeps the + !! meaning of the 6-column rows: its twist channels are refused with the reason; a solved + !! line's restrained Pretwist beyond 1000 turns is refused by name. + !! T ATTACHMENTS on a line free at one end (the torsion stage after the attachment polish, + !! on the polished mesh): + !! T1 statics: the C1 cable hung vertically (99 m between points 100 m apart) carrying three + !! clumps and buoys of net weights w_k at nodes n_k, free at End A and at End B in turn. + !! The line stays straight and its section is free to twist, so each element carries + !! the tension T_e = T_A - sum_(n_k <= e) w_k and the strain T_e/(EA - K^2/GJ), with + !! sum_e l0 eps_e = H - L0: T_A = [(EA - K^2/GJ)(H - L0)/l0 + sum_k w_k (NE + 1 - n_k)]/NE. + !! The free end turns by Twist1 = -(K/GJ)(H - L0) whatever the weights, with no torque + !! and the tensions T_A, T_A - sum w_k; the mid-line node by -(K/GJ) sum_(e<=20) l0 eps_e + !! (0.8 % beyond the uniform strain's half) within 1e-3: the shared nodal tangent of + !! the cubic-Hermite elements spreads each tension step over its two elements, a + !! first-order mesh error (3.9e-4, 1.9e-4, 9.6e-5 at 40, 80, 160 elements); + !! T2 dynamics: the D roll of the restrained End A, the line taut (99.9 m over the span), + !! with three neutral modules (their mass is translational only, so the torsional + !! response is D's continuum over the 99.9 m). + USE CableDyn_Precision, ONLY: wp + USE CableDyn_EndConnection, ONLY: CD_ENDCONN_RIGID + USE CableDyn_HermiteTorsion, ONLY: CD_HermiteTorsionType, CD_HermiteTorsion_Line, CD_HermiteTorsion_Unwrap, & + CD_HTORS_OK + USE CableDyn_DeckDriver, ONLY: CD_Run_Deck_Driver, CD_DECKDRV_OK + USE CableDyn_OpenFAST_Aggregate, ONLY: CD_AGG_ModuleType, CD_AGG_Init_From_Deck, CD_AGG_GetMovingPointMesh, & + CD_AGG_Step_Moving, CD_AGG_CalcOutput, CD_AGG_EvalChannel, CD_AGG_End, & + CD_AGG_OK + USE CableDyn_HermiteCableDynamic, ONLY: CD_HermiteCableDynType, CD_HermiteCable_Dyn_Init, & + CD_HermiteCable_Dyn_Step, CD_HermiteCable_Dyn_End, & + CD_HermiteCable_Dyn_Set_EndConnection, CD_HermiteCable_Dyn_Set_Torsion, & + CD_HermiteCable_Dyn_Set_Torsion_Drive, & + CD_HermiteCable_Dyn_EndConnection_Moment, CD_HermiteCable_Dyn_Snapshot, & + CD_HermiteCable_Dyn_Restore, CD_HCDYN_OK + IMPLICIT NONE + + REAL(wp), PARAMETER :: PI = 3.14159265358979323846_wp, RHOW = 1025.0_wp, DEG = PI/180.0_wp + ! the deck cable of gates C, D, A: EA 1e7 N, GJ 5e4 N m2 and, under coupling, K 4e5 N m + REAL(wp), PARAMETER :: EA_D = 1.0e7_wp, GJ_D = 5.0e4_wp, K_D = 4.0e5_wp, SPAN = 100.0_wp, L0_D = 99.0_wp + REAL(wp), PARAMETER :: LL = 10.0_wp, EA = 1.0e5_wp, EI = 100.0_wp, GJ = 80.0_wp, RHOA = 1.0_wp, IRN = 0.5_wp + INTEGER, PARAMETER :: NE = 20, NN = NE + 1, NDOF = 6*NN + INTEGER :: nfail = 0, kfree, mom_sign(2) = 0 + + DO kfree = 2, 1, -1 + CALL check_modes(kfree) + CALL check_driven(kfree, 0.5_wp) + CALL check_driven(kfree, 1.5_wp) + END DO + CALL check_restore() + CALL check_deck_statics() + CALL check_deck_stretch() + CALL check_deck_inertia() + CALL check_aggregate() + CALL check_not_solved() + CALL check_attachments_statics() + CALL check_attachments_inertia() + + IF (nfail > 0) THEN + WRITE (*, '(A,I0,A)') 'FAIL: ', nfail, ' assertion(s) failed' + ERROR STOP 1 + END IF + WRITE (*, '(A)') 'PASS: one-end torsion gates' + +CONTAINS + + INCLUDE 'nan_max_abs.inc' + + SUBROUTINE require(cond, label) + LOGICAL, INTENT(IN) :: cond + CHARACTER(*), INTENT(IN) :: label + IF (cond) RETURN + nfail = nfail + 1 + WRITE (*, '(A)') 'FAIL: '//TRIM(label) + END SUBROUTINE require + + CHARACTER(5) FUNCTION end_name(kf) RESULT(s) + !! The deck end of internal end kf (internal end 1 is End B, end 2 End A). + INTEGER, INTENT(IN) :: kf + s = MERGE('End B', 'End A', kf == 1) + END FUNCTION end_name + + ! ------------------------------------------------------------------------------------------ + SUBROUTINE build_line(m, kf, ok) + !! The straight line along +x (node 1 at the origin), clamped in bending at both ends (end + !! positions held), rigid in torsion at internal end 3 - kf and free at internal end kf; both + !! end frames (+x, +z); rho_inf 1 (no numerical dissipation). + TYPE(CD_HermiteCableDynType), INTENT(INOUT) :: m + INTEGER, INTENT(IN) :: kf + LOGICAL, INTENT(OUT) :: ok + TYPE(CD_HermiteTorsionType) :: tors + REAL(wp) :: q(NDOF), l0(NE), g(NDOF), raw + INTEGER :: k, es + CHARACTER(300) :: em + l0 = LL/REAL(NE, wp) + q = 0.0_wp + DO k = 1, NN + q(6*k - 5) = LL*REAL(k - 1, wp)/REAL(NE, wp) + q(6*k - 2) = 1.0_wp + END DO + CALL CD_HermiteCable_Dyn_Init(m, l0, [(EA, k=1, NE)], [(EI, k=1, NE)], [(RHOA, k=1, NE)], [(0.0_wp, k=1, NE)], q, & + [1, 2, 3, NDOF - 5, NDOF - 4, NDOF - 3], 0.0_wp, 0.0_wp, 1.0_wp, es, em) + ok = es == CD_HCDYN_OK + CALL require(ok, 'init: '//TRIM(em)) + IF (.NOT. ok) RETURN + CALL CD_HermiteCable_Dyn_Set_EndConnection(m, [0.0_wp, 0.0_wp], & + RESHAPE([1.0_wp, 0.0_wp, 0.0_wp, 1.0_wp, 0.0_wp, 0.0_wp], [3, 2]), & + es, em, connection_mode=[CD_ENDCONN_RIGID, CD_ENDCONN_RIGID]) + ok = es == CD_HCDYN_OK + CALL require(ok, 'end connections: '//TRIM(em)) + IF (.NOT. ok) RETURN + tors%active = .TRUE. + tors%ends = frames(0.0_wp) + tors%end_free(kf) = .TRUE. + ALLOCATE (tors%gj(NE), tors%irn(NE)) + tors%gj = GJ + tors%irn = IRN + CALL CD_HermiteTorsion_Line(q, l0, tors%ends, raw, g, es, em) + CALL require(es == CD_HTORS_OK, 'seed twist evaluates: '//TRIM(em)) + tors%theta = CD_HermiteTorsion_Unwrap(raw, 0.0_wp) + tors%has_theta = .TRUE. + CALL CD_HermiteCable_Dyn_Set_Torsion(m, tors, es, em) + ok = es == CD_HCDYN_OK .AND. m%tw_active + CALL require(ok, 'one-end torsion installs the nodal twist ('//end_name(kf)//' free): '//TRIM(em)) + IF (.NOT. ok) RETURN + CALL require(m%torsion%torque == 0.0_wp, 'one-end torsion: no condensed torque') + END SUBROUTINE build_line + + FUNCTION frames(ang) RESULT(ends) + !! Both end frames (+x, +z), the restrained end's turned by ang about +x by the caller. + REAL(wp), INTENT(IN) :: ang + REAL(wp) :: ends(3, 4) + ends(:, 1) = [1.0_wp, 0.0_wp, 0.0_wp] + ends(:, 2) = [0.0_wp, -SIN(ang), COS(ang)] + ends(:, 3) = [1.0_wp, 0.0_wp, 0.0_wp] + ends(:, 4) = [0.0_wp, -SIN(ang), COS(ang)] + END FUNCTION frames + + SUBROUTINE drive_step(m, kf, ang, dt, ok) + !! One step with the restrained end's frame turned to ang about +x (the free end's held). + TYPE(CD_HermiteCableDynType), INTENT(INOUT) :: m + INTEGER, INTENT(IN) :: kf + REAL(wp), INTENT(IN) :: ang, dt + LOGICAL, INTENT(OUT) :: ok + REAL(wp) :: ends(3, 4), turned(3, 4) + INTEGER :: es, kr + CHARACTER(300) :: em + kr = 3 - kf + ends = frames(0.0_wp) + turned = frames(ang) + ends(:, 2*kr - 1:2*kr) = turned(:, 2*kr - 1:2*kr) + CALL CD_HermiteCable_Dyn_Set_Torsion_Drive(m, ends, 0.0_wp, es, em) + IF (es == CD_HCDYN_OK) CALL CD_HermiteCable_Dyn_Step(m, dt, 40, 1.0e-11_wp, es, em) + ok = es == CD_HCDYN_OK + IF (.NOT. ok) WRITE (*, '(A)') ' step: '//TRIM(em) + END SUBROUTINE drive_step + + REAL(wp) FUNCTION free_roll(m, kf) RESULT(r) + !! The roll of the free end's section about +x: its twist angle against its director, which + !! the straight, unmoving line keeps fixed (no transport). + TYPE(CD_HermiteCableDynType), INTENT(IN) :: m + INTEGER, INTENT(IN) :: kf + r = m%tw_phi(MERGE(1, NN, kf == 1)) + END FUNCTION free_roll + + REAL(wp) FUNCTION axial_moment(m, node) RESULT(mx) + !! The axial (x) component of the line's moment on the support of end node node. + TYPE(CD_HermiteCableDynType), INTENT(INOUT) :: m + INTEGER, INTENT(IN) :: node + REAL(wp) :: mom(3) + INTEGER :: es + CHARACTER(300) :: em + CALL CD_HermiteCable_Dyn_EndConnection_Moment(m, node, mom, es, em) + CALL require(es == CD_HCDYN_OK, 'end moment: '//TRIM(em)) + mx = mom(1) + END FUNCTION axial_moment + + REAL(wp) FUNCTION ramp(t, tr) RESULT(s) + !! C2 quintic from 0 at t = 0 to 1 at t = tr. + REAL(wp), INTENT(IN) :: t, tr + REAL(wp) :: x + x = MIN(MAX(t/tr, 0.0_wp), 1.0_wp) + s = x**3*(10.0_wp - 15.0_wp*x + 6.0_wp*x**2) + END FUNCTION ramp + + ! ------------------------------------------------------------------------------------------ + SUBROUTINE check_modes(kf) + !! M1: released from a twist, the free end rings at the clamped-free frequencies. + INTEGER, INTENT(IN) :: kf + REAL(wp), PARAMETER :: AMP = 0.2_wp + INTEGER, PARAMETER :: NPP = 200, NPER = 40 + TYPE(CD_HermiteCableDynType) :: m + REAL(wp) :: c, om1, dt, tr, t, ang, err(2), peak(2) + REAL(wp), ALLOCATABLE :: sig(:), ts(:) + INTEGER :: k, n, nrec, nstep + LOGICAL :: ok + c = SQRT(GJ/IRN) + om1 = 0.5_wp*PI*c/LL + dt = 2.0_wp*PI/om1/REAL(NPP, wp) + tr = 0.25_wp*2.0_wp*PI/om1 + CALL build_line(m, kf, ok) + IF (.NOT. ok) RETURN + nstep = NPER*NPP + NINT(tr/dt) + ALLOCATE (sig(nstep), ts(nstep)) + nrec = 0 + DO k = 1, nstep + t = dt*REAL(k, wp) + ang = AMP*ramp(t, tr) + CALL drive_step(m, kf, ang, dt, ok) + CALL require(ok, 'M1 ('//end_name(kf)//' free): step') + IF (.NOT. ok) EXIT + IF (t > tr) THEN + nrec = nrec + 1 + sig(nrec) = free_roll(m, kf) - AMP + ts(nrec) = t + END IF + END DO + IF (ok) THEN + DO n = 1, 2 + peak(n) = spectrum_peak(sig(1:nrec), ts(1:nrec), REAL(2*n - 1, wp)*om1) + err(n) = peak(n)/(REAL(2*n - 1, wp)*om1) - 1.0_wp + END DO + WRITE (*, '(A,A,A,2F10.5,A,2F10.5,A,2ES10.2)') 'M1 ', end_name(kf), ' free: ring-down peaks ', peak, & + ' rad/s, quarter-wave ', om1, 3.0_wp*om1, ' rad/s, errors ', err + CALL require(ABS(err(1)) <= 4.0e-3_wp, 'M1 ('//end_name(kf)//' free): the first mode is the quarter wave') + CALL require(ABS(err(2)) <= 1.0e-2_wp, 'M1 ('//end_name(kf)//' free): the second mode is three quarter waves') + END IF + CALL CD_HermiteCable_Dyn_End(m) + END SUBROUTINE check_modes + + REAL(wp) FUNCTION spectrum_peak(x, t, om0) RESULT(om_pk) + !! The frequency of the largest Hann-windowed Fourier amplitude of x(t) within 15 % of om0. + REAL(wp), INTENT(IN) :: x(:), t(:), om0 + INTEGER, PARAMETER :: NGRID = 3001 + INTEGER :: i, j, n + REAL(wp) :: om, w, re, im, amp, best, t0, span + n = SIZE(x) + t0 = t(1) + span = t(n) - t0 + best = -1.0_wp + om_pk = om0 + DO j = 1, NGRID + om = om0*(0.85_wp + 0.3_wp*REAL(j - 1, wp)/REAL(NGRID - 1, wp)) + re = 0.0_wp + im = 0.0_wp + DO i = 1, n + w = 0.5_wp - 0.5_wp*COS(2.0_wp*PI*(t(i) - t0)/span) + re = re + w*x(i)*COS(om*(t(i) - t0)) + im = im + w*x(i)*SIN(om*(t(i) - t0)) + END DO + amp = re*re + im*im + IF (amp > best) THEN + best = amp + om_pk = om + END IF + END DO + END FUNCTION spectrum_peak + + ! ------------------------------------------------------------------------------------------ + SUBROUTINE check_driven(kf, ratio) + !! M2: the restrained end rolled A sin(Omega t) (amplitude ramped in over eight periods), + !! Omega = ratio omega_1. Over six periods after one more, the Fourier components at Omega + !! (orthogonal there to the free modes the ramp leaves ringing, omega_1 and 3 omega_1) of the + !! free end's roll and of the restrained support's axial reaction are the continuum's: + !! A/cos kL (in phase below the first mode, in antiphase above it) and GJ A k tan kL, the + !! latter with a sign the same at both frequencies. + INTEGER, INTENT(IN) :: kf + REAL(wp), INTENT(IN) :: ratio + REAL(wp), PARAMETER :: AMP = 0.2_wp + INTEGER, PARAMETER :: NPER_RAMP = 8, NPER_MEAS = 6, NPP = 200 + TYPE(CD_HermiteCableDynType) :: m + REAL(wp) :: c, om, dt, t, ramp_t, kw, fmax, roll_ref, mom_ref, e_roll, e_mom, s, co + REAL(wp) :: rs, rc, ms, mc, a_roll, a_mom, mf + INTEGER :: k, node_r, node_f, k0 + LOGICAL :: ok + CHARACTER(8) :: lab + c = SQRT(GJ/IRN) + om = ratio*0.5_wp*PI*c/LL + dt = 2.0_wp*PI/om/REAL(NPP, wp) + WRITE (lab, '(F4.2)') ratio + CALL build_line(m, kf, ok) + IF (.NOT. ok) RETURN + node_r = MERGE(NN, 1, kf == 1) + node_f = MERGE(1, NN, kf == 1) + ramp_t = REAL(NPER_RAMP, wp)*2.0_wp*PI/om + k0 = (NPER_RAMP + 1)*NPP + rs = 0.0_wp + rc = 0.0_wp + ms = 0.0_wp + mc = 0.0_wp + fmax = 0.0_wp + DO k = 1, k0 + NPER_MEAS*NPP + t = dt*REAL(k, wp) + CALL drive_step(m, kf, AMP*ramp(t, ramp_t)*SIN(om*t), dt, ok) + CALL require(ok, 'M2 ('//end_name(kf)//' free, Omega/omega_1 = '//TRIM(lab)//'): step') + IF (.NOT. ok) EXIT + IF (k > k0) THEN + s = SIN(om*t) + co = COS(om*t) + rs = rs + free_roll(m, kf)*s + rc = rc + free_roll(m, kf)*co + ms = ms + axial_moment(m, node_r)*s + mc = mc + axial_moment(m, node_r)*co + mf = axial_moment(m, node_f) + fmax = MAX(fmax, ABS(mf)) + END IF + END DO + IF (ok) THEN + rs = 2.0_wp*rs/REAL(NPER_MEAS*NPP, wp) + rc = 2.0_wp*rc/REAL(NPER_MEAS*NPP, wp) + ms = 2.0_wp*ms/REAL(NPER_MEAS*NPP, wp) + mc = 2.0_wp*mc/REAL(NPER_MEAS*NPP, wp) + kw = om/c + roll_ref = AMP/COS(kw*LL) + mom_ref = GJ*AMP*kw*TAN(kw*LL) + a_roll = rs + a_mom = ms + e_roll = a_roll/roll_ref - 1.0_wp + e_mom = ABS(a_mom/mom_ref) - 1.0_wp + WRITE (*, '(A,A,A,F4.2,A,2ES13.5,A,2ES13.5,A,2ES10.2,A,2ES9.2,A,ES9.2)') 'M2 ', end_name(kf), & + ' free, Omega/omega_1 = ', ratio, ': free-end roll and driven torque at Omega ', a_roll, a_mom, & + ' continuum ', roll_ref, mom_ref, ' errors ', e_roll, e_mom, '; quadrature ', rc/roll_ref, mc/mom_ref, & + '; free-end axial moment ', fmax + CALL require(ABS(e_roll) <= 1.0e-2_wp .AND. ABS(rc) <= 1.0e-2_wp*ABS(roll_ref), & + 'M2 ('//end_name(kf)//' free, '//TRIM(lab)//'): the free end rolls by A/cos kL') + CALL require(ABS(e_mom) <= 1.0e-2_wp .AND. ABS(mc) <= 1.0e-2_wp*ABS(mom_ref), & + 'M2 ('//end_name(kf)//' free, '//TRIM(lab)//'): the restrained end reacts with GJ A k tan kL') + IF (mom_sign(kf) == 0) THEN + mom_sign(kf) = NINT(SIGN(1.0_wp, a_mom/mom_ref)) + ELSE + CALL require(mom_sign(kf) == NINT(SIGN(1.0_wp, a_mom/mom_ref)), 'M2 ('//end_name(kf)//' free, '// & + TRIM(lab)//'): the reaction turns sign with tan kL across the first mode') + END IF + CALL require(fmax <= 1.0e-9_wp*ABS(mom_ref), 'M2 ('//end_name(kf)//' free, '//TRIM(lab)// & + '): the free end transmits no torque') + END IF + CALL CD_HermiteCable_Dyn_End(m) + END SUBROUTINE check_driven + + ! ------------------------------------------------------------------------------------------ + SUBROUTINE check_restore() + !! M3: the driven run of the End A free line: 300 steps, snapshot, 100 more; restored, the + !! same 100 steps are bit-identical. + TYPE(CD_HermiteCableDynType) :: m + REAL(wp) :: dt, om, qref(NDOF), pref(NN) + INTEGER :: k, es + LOGICAL :: ok + CHARACTER(300) :: em + om = 0.5_wp*0.5_wp*PI*SQRT(GJ/IRN)/LL + dt = 2.0_wp*PI/om/200.0_wp + CALL build_line(m, 2, ok) + IF (.NOT. ok) RETURN + DO k = 1, 300 + CALL drive_step(m, 2, 0.2_wp*ramp(dt*k, 50.0_wp*dt)*SIN(om*dt*k), dt, ok) + IF (.NOT. ok) EXIT + END DO + CALL CD_HermiteCable_Dyn_Snapshot(m, es, em) + CALL require(ok .AND. es == CD_HCDYN_OK, 'M3: snapshot: '//TRIM(em)) + DO k = 301, 400 + CALL drive_step(m, 2, 0.2_wp*SIN(om*dt*k), dt, ok) + IF (.NOT. ok) EXIT + END DO + qref = m%q + pref = m%tw_phi + CALL CD_HermiteCable_Dyn_Restore(m, es, em) + CALL require(es == CD_HCDYN_OK, 'M3: restore: '//TRIM(em)) + DO k = 301, 400 + CALL drive_step(m, 2, 0.2_wp*SIN(om*dt*k), dt, ok) + IF (.NOT. ok) EXIT + END DO + CALL require(ok .AND. ALL(bits(m%q) == bits(qref)) .AND. ALL(bits(m%tw_phi) == bits(pref)), & + 'M3: the restored one-end run continues bit-identically') + WRITE (*, '(A,ES13.5,A)') 'M3 restore: free-end roll ', pref(NN), ' rad, restored run identical' + CALL CD_HermiteCable_Dyn_End(m) + END SUBROUTINE check_restore + + ! ------------------------------------------------------------------------------------------ + ! deck gates + ! ------------------------------------------------------------------------------------------ + CHARACTER(160) FUNCTION type_row(gj_col, irn) RESULT(row) + !! The neutral 0.2 m LINE TYPES row (mass rhoW pi d^2/4, EA 1e7, EI 1e6, GAs 1e8) with the GJ + !! column gj_col and the polar inertia irn. + CHARACTER(*), INTENT(IN) :: gj_col + REAL(wp), INTENT(IN) :: irn + WRITE (row, '(A,ES24.16,A,ES12.5,A)') 'cab 0.2 ', RHOW*0.25_wp*PI*0.04_wp, ' 1.0e7 0.0 1.0e6 1.0e8 '// & + TRIM(gj_col)//' 1.0 ', irn, ' 0.0 0.0 0.0 0.0' + END FUNCTION type_row + + SUBROUTINE write_deck(path, trow, conns, length, options, outs, ten_cols, atts, end_b) + !! The straight cable along +x from a Coupled End A (0, 0, -50) to a Fixed End B (100, 0, -50) + !! (or end_b), 40 elements over length, LINE TYPES row trow (14 columns, or 10 with ten_cols), + !! END CONNECTIONS rows conns (none when empty), ATTACHMENTS rows atts, then options and outs. + CHARACTER(*), INTENT(IN) :: path, trow, conns(:), options(:), outs(:) + REAL(wp), INTENT(IN) :: length + LOGICAL, INTENT(IN), OPTIONAL :: ten_cols + CHARACTER(*), INTENT(IN), OPTIONAL :: atts(:) + REAL(wp), INTENT(IN), OPTIONAL :: end_b(3) + INTEGER :: u, i + LOGICAL :: ten + ten = .FALSE. + IF (PRESENT(ten_cols)) ten = ten_cols + OPEN (NEWUNIT=u, FILE=path, STATUS='REPLACE', ACTION='WRITE') + WRITE (u, '(A)') 'one-end torsion gate' + WRITE (u, '(A)') '--- LINE TYPES ---' + IF (ten) THEN + WRITE (u, '(A)') 'Name Diam Mass EA BA EI Cdn Cdt Can Cat' + WRITE (u, '(A)') '(-) (m) (kg/m) (N) (-) (Nm2) (-) (-) (-) (-)' + ELSE + WRITE (u, '(A)') 'Name Diam Mass EA BA EI GAs GJ Irt Irn Cdn Cdt Can Cat' + WRITE (u, '(A)') '(-) (m) (kg/m) (N) (-) (Nm2) (N) (Nm2) (kgm) (kgm) (-) (-) (-) (-)' + END IF + WRITE (u, '(A)') TRIM(trow) + WRITE (u, '(A)') '--- POINTS ---' + WRITE (u, '(A)') 'ID Type X Y Z Mass Vol CdA Ca' + WRITE (u, '(A)') '(-) (-) (m) (m) (m) (kg) (m3) (m2) (-)' + WRITE (u, '(A)') '1 Coupled 0.0 0.0 -50.0 0 0 0 0' + IF (PRESENT(end_b)) THEN + WRITE (u, '(A,3ES24.16,A)') '2 Fixed ', end_b, ' 0 0 0 0' + ELSE + WRITE (u, '(A)') '2 Fixed 100.0 0.0 -50.0 0 0 0 0' + END IF + WRITE (u, '(A)') '--- LINES ---' + WRITE (u, '(A)') 'ID NodeA NodeB Outputs' + WRITE (u, '(A)') '(-) (-) (-) (-)' + WRITE (u, '(A)') '1 1 2 -' + WRITE (u, '(A)') '--- SECTIONS ---' + WRITE (u, '(A)') 'LineID LineType Length NumSegs' + WRITE (u, '(A)') '(-) (-) (m) (-)' + WRITE (u, '(A,F10.4,A)') '1 cab ', length, ' 40' + IF (PRESENT(atts)) THEN + WRITE (u, '(A)') '--- ATTACHMENTS ---' + WRITE (u, '(A)') 'LineID ArcLength Mass Volume CdA Ca' + WRITE (u, '(A)') '(-) (m) (kg) (m3) (m2) (-)' + DO i = 1, SIZE(atts) + WRITE (u, '(A)') TRIM(atts(i)) + END DO + END IF + IF (SIZE(conns) > 0) THEN + WRITE (u, '(A)') '--- END CONNECTIONS ---' + WRITE (u, '(A)') 'LineID End Stiffness EzX EzY EzZ TorsStiffness NxX NxY NxZ Pretwist' + WRITE (u, '(A)') '(-) (-) (N-m/rad) (-) (-) (-) (N-m/rad) (-) (-) (-) (deg)' + DO i = 1, SIZE(conns) + WRITE (u, '(A)') TRIM(conns(i)) + END DO + END IF + WRITE (u, '(A)') '--- OPTIONS ---' + WRITE (u, '(A)') '9.80665 g' + WRITE (u, '(A)') '1025.0 rhoW' + DO i = 1, SIZE(options) + WRITE (u, '(A)') TRIM(options(i)) + END DO + WRITE (u, '(A)') '--- OUTPUTS ---' + DO i = 1, SIZE(outs) + WRITE (u, '(A)') TRIM(outs(i)) + END DO + WRITE (u, '(A)') '--- END ---' + CLOSE (u) + END SUBROUTINE write_deck + + SUBROUTINE run_deck(path, root, ok, em) + CHARACTER(*), INTENT(IN) :: path, root + LOGICAL, INTENT(OUT) :: ok + CHARACTER(*), INTENT(OUT) :: em + LOGICAL :: conv + INTEGER :: es + CALL CD_Run_Deck_Driver(path, root, conv, es, em) + ok = es == CD_DECKDRV_OK .AND. conv + END SUBROUTINE run_deck + + SUBROUTINE read_out(path, ncol, rows, nrow) + !! Every data row of a driver .out file (time first, then ncol - 1 channels). + CHARACTER(*), INTENT(IN) :: path + INTEGER, INTENT(IN) :: ncol + REAL(wp), ALLOCATABLE, INTENT(OUT) :: rows(:, :) + INTEGER, INTENT(OUT) :: nrow + REAL(wp), ALLOCATABLE :: tmp(:, :) + REAL(wp) :: v(ncol) + INTEGER :: u, ios + CHARACTER(4096) :: buf + nrow = 0 + ALLOCATE (rows(ncol, 64)) + OPEN (NEWUNIT=u, FILE=path, STATUS='OLD', ACTION='READ', IOSTAT=ios) + IF (ios /= 0) RETURN + READ (u, '(A)', IOSTAT=ios) buf + READ (u, '(A)', IOSTAT=ios) buf + DO + READ (u, *, IOSTAT=ios) v + IF (ios /= 0) EXIT + nrow = nrow + 1 + IF (nrow > SIZE(rows, 2)) THEN + ALLOCATE (tmp(ncol, 2*SIZE(rows, 2))) + tmp(:, 1:nrow - 1) = rows(:, 1:nrow - 1) + CALL MOVE_ALLOC(tmp, rows) + END IF + rows(:, nrow) = v + END DO + CLOSE (u) + END SUBROUTINE read_out + + ! ------------------------------------------------------------------------------------------ + SUBROUTINE check_deck_statics() + !! C1: the static coupling twist of a line free at one end. + CHARACTER(16), PARAMETER :: OUTS(8) = [CHARACTER(16) :: 'FairTen1', 'Torq1N1', 'Torq1N21', 'Torq1N41', & + 'Twist1N21', 'Twist1N41', 'Twist1', 'Ten1N21'] + CHARACTER(48) :: conns(2, 3) + CHARACTER(24), PARAMETER :: LABEL(3) = [CHARACTER(24) :: 'End A free', 'End B free', 'End A without a row'] + REAL(wp), ALLOCATABLE :: rows(:, :) + REAL(wp) :: eps, t_ref, tw_ref, e_t, e_tw, e_m + INTEGER :: iv, nrow, nconn + LOGICAL :: ok + CHARACTER(512) :: em + conns(:, 1) = [CHARACTER(48) :: '1 A Rigid 1 0 0 Free 0 0 1', '1 B Rigid 1 0 0 Rigid 0 0 1 30'] + conns(:, 2) = [CHARACTER(48) :: '1 A Rigid 1 0 0 Rigid 0 0 1 -30', '1 B Rigid 1 0 0 Free 0 0 1'] + conns(:, 3) = [CHARACTER(48) :: '1 B Rigid 1 0 0 1.0e5 0 0 1 10', ''] + eps = SPAN/L0_D - 1.0_wp + t_ref = (EA_D - K_D**2/GJ_D)*eps + tw_ref = -(K_D/GJ_D)*(SPAN - L0_D)/DEG + DO iv = 1, 3 + nconn = MERGE(1, 2, iv == 3) + CALL write_deck('t1e_static.dat', type_row('5.0e4|4.0e5', 1.0e-9_wp), conns(1:nconn, iv), L0_D, & + [CHARACTER(16) :: '0.1 dtM', '0.0 TMax'], OUTS) + CALL run_deck('t1e_static.dat', 't1e_static', ok, em) + CALL require(ok, 'C1 ('//TRIM(LABEL(iv))//'): the static deck runs with its twist channels: '//TRIM(em)) + IF (.NOT. ok) CYCLE + CALL read_out('t1e_static.out', 9, rows, nrow) + CALL require(nrow == 1, 'C1: one static row') + IF (nrow < 1) CYCLE + e_t = MAX(ABS(rows(2, 1) - t_ref), ABS(rows(9, 1) - t_ref))/t_ref + e_tw = MAX(ABS(rows(8, 1) - tw_ref), ABS(rows(7, 1) - tw_ref), ABS(rows(6, 1) - 0.5_wp*tw_ref))/ABS(tw_ref) + e_m = nan_max_abs(rows(3:5, 1)) + WRITE (*, '(A,A,A,F12.5,A,F12.5,A,ES14.7,A,ES14.7,A,3ES10.2)') 'C1 ', TRIM(LABEL(iv)), ': Twist1 ', & + rows(8, 1), ' deg (expected ', tw_ref, '), FairTen1 ', rows(2, 1), ' N (expected ', t_ref, & + '); errors twist, tension, |torque| ', e_tw, e_t, e_m + CALL require(e_tw <= 1.0e-6_wp, 'C1 ('//TRIM(LABEL(iv))//'): the stretch twists the free line by -(K/GJ) dl') + CALL require(e_t <= 1.0e-6_wp, 'C1 ('//TRIM(LABEL(iv))//'): the tension is (EA - K^2/GJ) eps') + CALL require(e_m <= 1.0e-6_wp, 'C1 ('//TRIM(LABEL(iv))//'): no static torque') + END DO + END SUBROUTINE check_deck_statics + + ! ------------------------------------------------------------------------------------------ + SUBROUTINE stretch_motion(path) + !! End A held at its place, moved by -DX s(t) along x (s a C2 quintic over 20 s), then held. + CHARACTER(*), INTENT(IN) :: path + INTEGER, PARAMETER :: NSTEP = 500 + REAL(wp), PARAMETER :: TR = 20.0_wp, DTM = 0.05_wp, DX = 0.1_wp + REAL(wp) :: t, tau, s, sd, sdd + INTEGER :: u, k + OPEN (NEWUNIT=u, FILE=path, STATUS='REPLACE', ACTION='WRITE') + WRITE (u, '(A)') '# time id x y z vx vy vz ax ay az' + DO k = 0, NSTEP + t = DTM*REAL(k, wp) + tau = MIN(t/TR, 1.0_wp) + s = 10.0_wp*tau**3 - 15.0_wp*tau**4 + 6.0_wp*tau**5 + sd = (30.0_wp*tau**2 - 60.0_wp*tau**3 + 30.0_wp*tau**4)/TR + sdd = (60.0_wp*tau - 180.0_wp*tau**2 + 120.0_wp*tau**3)/TR**2 + IF (t > TR) THEN + sd = 0.0_wp + sdd = 0.0_wp + END IF + WRITE (u, '(ES16.8,A,ES16.8,A,ES16.8,A,ES16.8,A)') t, ' 1 ', -DX*s, ' 0.0 -50.0 ', -DX*sd, ' 0 0 ', -DX*sdd, & + ' 0 0' + END DO + CLOSE (u) + END SUBROUTINE stretch_motion + + SUBROUTINE check_deck_stretch() + !! C2: the free end turns with the stretch at every step of the march. + REAL(wp), PARAMETER :: TR = 20.0_wp, DX = 0.1_wp + CHARACTER(48) :: conns(2, 2) + CHARACTER(24), PARAMETER :: LABEL(2) = [CHARACTER(24) :: 'End A free', 'End B free'] + REAL(wp), ALLOCATABLE :: rows(:, :) + REAL(wp) :: tau, s, dl, e_tw, e_t + INTEGER :: iv, k, nrow + LOGICAL :: ok + CHARACTER(512) :: em + conns(:, 1) = [CHARACTER(48) :: '1 A Rigid 1 0 0 Free 0 0 1', '1 B Rigid 1 0 0 Rigid 0 0 1 0'] + conns(:, 2) = [CHARACTER(48) :: '1 A Rigid 1 0 0 Rigid 0 0 1 0', '1 B Rigid 1 0 0 Free 0 0 1'] + CALL stretch_motion('t1e_stretch.txt') + DO iv = 1, 2 + CALL write_deck('t1e_stretch.dat', type_row('5.0e4|4.0e5', 1.0e-9_wp), conns(:, iv), L0_D, & + [CHARACTER(32) :: '0.05 dtM', '25.0 TMax', 't1e_stretch.txt motionFile'], & + [CHARACTER(16) :: 'FairTen1', 'Twist1']) + CALL run_deck('t1e_stretch.dat', 't1e_stretch', ok, em) + CALL require(ok, 'C2 ('//TRIM(LABEL(iv))//'): the stretching march runs: '//TRIM(em)) + IF (.NOT. ok) CYCLE + CALL read_out('t1e_stretch.out', 3, rows, nrow) + CALL require(nrow == 501, 'C2: one row per step') + e_tw = 0.0_wp + e_t = 0.0_wp + DO k = 1, nrow + tau = MIN(rows(1, k)/TR, 1.0_wp) + s = 10.0_wp*tau**3 - 15.0_wp*tau**4 + 6.0_wp*tau**5 + dl = SPAN + DX*s - L0_D + e_tw = MAX(e_tw, ABS(rows(3, k) + (K_D/GJ_D)*dl/DEG)/((K_D/GJ_D)*dl/DEG)) + e_t = MAX(e_t, ABS(rows(2, k) - (EA_D - K_D**2/GJ_D)*dl/L0_D)/((EA_D - K_D**2/GJ_D)*dl/L0_D)) + END DO + WRITE (*, '(A,A,A,F12.5,A,F12.5,A,2ES10.2)') 'C2 ', TRIM(LABEL(iv)), ': Twist1 from ', rows(3, 1), & + ' to ', rows(3, nrow), ' deg; largest errors twist, tension ', e_tw, e_t + CALL require(e_tw <= 1.0e-6_wp, 'C2 ('//TRIM(LABEL(iv))//'): the free end turns with the stretch at every step') + ! (the axial inertia of the ramp, about 3e-5 of the tension, included) + CALL require(e_t <= 1.0e-4_wp, 'C2 ('//TRIM(LABEL(iv))//'): the tension is (EA - K^2/GJ) eps(t)') + END DO + END SUBROUTINE check_deck_stretch + + ! ------------------------------------------------------------------------------------------ + SUBROUTINE inertia_expect(amp, kw, len, ne_d, tw_amp, mt_a, mt_b) + !! The continuum's response at Omega to a roll amp sin(Omega t) of the restrained End A of a + !! line free at End B, theta(s) = amp cos(k (L - s))/cos(kL) (s from End A): the twist of End + !! B relative to End A, and GJ times the mean twist rate over the End A and End B elements + !! (an end node's torque is its element's). + REAL(wp), INTENT(IN) :: amp, kw, len + INTEGER, INTENT(IN) :: ne_d + REAL(wp), INTENT(OUT) :: tw_amp, mt_a, mt_b + REAL(wp) :: h + h = len/REAL(ne_d, wp) + tw_amp = amp*(1.0_wp/COS(kw*len) - 1.0_wp) + mt_a = GJ_D*amp*(COS(kw*(len - h)) - COS(kw*len))/(h*COS(kw*len)) + mt_b = GJ_D*amp*(1.0_wp - COS(kw*h))/(h*COS(kw*len)) + END SUBROUTINE inertia_expect + + SUBROUTINE check_deck_inertia() + !! D: the motionFile roll of the restrained End A spins the line, whose free End B follows. + REAL(wp), PARAMETER :: IRN_D = 1.0_wp, AMP = 0.1_wp + INTEGER, PARAMETER :: NPP = 120, NPER_RAMP = 8, NPER_MEAS = 4 + REAL(wp), ALLOCATABLE :: rows(:, :) + REAL(wp) :: c, om, dt, t, kw, tw_ref, ma_ref, mb_ref, proj(3), e(3) + INTEGER :: u, k, nrow, k0, nstep + LOGICAL :: ok + CHARACTER(512) :: em + CHARACTER(64) :: opt(3) + c = SQRT(GJ_D/IRN_D) + om = 0.25_wp*0.5_wp*PI*c/SPAN + dt = 2.0_wp*PI/om/REAL(NPP, wp) + nstep = (NPER_RAMP + 1 + NPER_MEAS)*NPP + OPEN (NEWUNIT=u, FILE='t1e_roll.txt', STATUS='REPLACE', ACTION='WRITE') + WRITE (u, '(A)') '# time id x y z vx vy vz ax ay az roll' + DO k = 0, nstep + t = dt*REAL(k, wp) + WRITE (u, '(ES24.16,A,ES24.16)') t, ' 1 0.0 0.0 -50.0 0 0 0 0 0 0 ', & + AMP*ramp(t, REAL(NPER_RAMP, wp)*2.0_wp*PI/om)*SIN(om*t)/DEG + END DO + CLOSE (u) + WRITE (opt(1), '(ES24.16,A)') dt, ' dtM' + WRITE (opt(2), '(ES24.16,A)') dt*REAL(nstep, wp), ' TMax' + opt(3) = 't1e_roll.txt motionFile' + CALL write_deck('t1e_roll.dat', type_row('5.0e4', IRN_D), & + [CHARACTER(48) :: '1 A Rigid 1 0 0 Rigid 0 0 1 0', '1 B Rigid 1 0 0 Free 0 0 1'], SPAN, opt, & + [CHARACTER(16) :: 'Twist1', 'Torq1N1', 'Torq1N41']) + CALL run_deck('t1e_roll.dat', 't1e_roll', ok, em) + CALL require(ok, 'D: the rolling march runs: '//TRIM(em)) + IF (.NOT. ok) RETURN + CALL read_out('t1e_roll.out', 4, rows, nrow) + CALL require(nrow == nstep + 1, 'D: one row per step') + IF (nrow /= nstep + 1) RETURN + k0 = (NPER_RAMP + 1)*NPP + 1 + proj = 0.0_wp + DO k = k0 + 1, nrow + proj = proj + rows(2:4, k)*SIN(om*rows(1, k)) + END DO + proj = 2.0_wp*proj/REAL(NPER_MEAS*NPP, wp) + kw = om/c + CALL inertia_expect(AMP, kw, SPAN, 40, tw_ref, ma_ref, mb_ref) + ! Twist1 in degrees + e(1) = proj(1)*DEG/tw_ref - 1.0_wp + e(2) = proj(2)/ma_ref - 1.0_wp + e(3) = proj(3)/mb_ref - 1.0_wp + WRITE (*, '(A,3ES13.5,A,3ES13.5,A,3ES10.2)') 'D roll of the restrained End A (kL = pi/8): Twist1, Torq1N1, '// & + 'Torq1N41 at Omega ', proj(1)*DEG, proj(2:3), ' continuum ', tw_ref, ma_ref, mb_ref, ' errors ', e + CALL require(ABS(e(1)) <= 1.0e-2_wp, 'D: the free End B follows the roll with the continuum''s twist') + CALL require(ABS(e(2)) <= 1.0e-2_wp, 'D: the restrained End A carries the continuum''s inertial torque') + CALL require(ABS(e(3)) <= 3.0e-2_wp, 'D: the free End B''s element carries the continuum''s small torque') + END SUBROUTINE check_deck_inertia + + ! ------------------------------------------------------------------------------------------ + FUNCTION roll_dcm(phi) RESULT(r) + !! OpenFAST mesh orientation (global to local) of a roll phi about +x. + REAL(wp), INTENT(IN) :: phi + REAL(wp) :: r(3, 3) + r = 0.0_wp + r(1, 1) = 1.0_wp + r(2, 2) = COS(phi) + r(2, 3) = SIN(phi) + r(3, 2) = -SIN(phi) + r(3, 3) = COS(phi) + END FUNCTION roll_dcm + + SUBROUTINE check_aggregate() + !! A: the coupled aggregate, End A on the platform (host orientation). + REAL(wp), PARAMETER :: IRN_D = 1.0_wp, AMP = 0.1_wp, DT_A = 0.05_wp, RATE = 60.0_wp*PI/180.0_wp + INTEGER, PARAMETER :: NPP = 120, NPER_RAMP = 8, NPER_MEAS = 4 + TYPE(CD_AGG_ModuleType) :: agg + REAL(wp) :: pos(3, 1), vel(3, 1), acc(3, 1), load(3, 1), moment(3, 1), orient(3, 3, 1), omega(3, 1) + REAL(wp) :: alpha(3, 1), tw0, tw, ta, tb, werr, merr, c, om, dt, t, ang, kw, tw_ref, ma_ref, mb_ref, proj(3), e(3) + REAL(wp) :: s, sd, sdd, tr + INTEGER :: es, ni, k, k0, nstep + LOGICAL :: cv, st, ok + CHARACTER(512) :: em + ! A1: the C1 line free at End A, the platform rolling at 60 deg/s + CALL write_deck('t1e_agg1.dat', type_row('5.0e4|4.0e5', 1.0e-9_wp), & + [CHARACTER(48) :: '1 A Rigid 1 0 0 Free 0 0 1', '1 B Rigid 1 0 0 Rigid 0 0 1 0'], L0_D, & + [CHARACTER(16) :: '0.05 dtM'], [CHARACTER(16) :: 'Torq1N1', 'Torq1N41', 'Twist1']) + CALL CD_AGG_Init_From_Deck(agg, 't1e_agg1.dat', DT_A, es, em, host_orientation=.TRUE.) + ok = es == CD_AGG_OK + CALL require(ok, 'A1: the line free at End A builds on the aggregate: '//TRIM(em)) + IF (ok) THEN + CALL agg_channels(agg, ta, tb, tw0) + CALL CD_AGG_GetMovingPointMesh(agg, pos, vel, acc, load, es, em, orientation=orient) + omega = 0.0_wp + alpha = 0.0_wp + omega(1, 1) = RATE + werr = 0.0_wp + merr = 0.0_wp + DO k = 1, 10 + orient(:, :, 1) = roll_dcm(RATE*DT_A*k) + CALL CD_AGG_Step_Moving(agg, DT_A, pos, vel, acc, cv, st, ni, es, em, orientation=orient, & + angular_velocity=omega, angular_acceleration=alpha) + CALL require(es == CD_AGG_OK .AND. cv, 'A1: the rolling step converges: '//TRIM(em)) + IF (es /= CD_AGG_OK) EXIT + CALL CD_AGG_CalcOutput(agg, es, em) + CALL agg_channels(agg, ta, tb, tw) + CALL CD_AGG_GetMovingPointMesh(agg, pos, vel, acc, load, es, em, moment=moment) + werr = MAX(werr, ABS(tw - tw0)) + merr = MAX(merr, ABS(ta), ABS(tb), ABS(moment(1, 1))) + IF (k == 10) WRITE (*, '(A,3ES12.4)') ' A1 last step: Torq1N1, Torq1N41, axial moment ', ta, tb, moment(1, 1) + END DO + WRITE (*, '(A,F12.5,A,ES10.2,A,ES10.2,A)') 'A1 aggregate, End A free, platform roll 30 deg: Twist1 ', tw0, & + ' deg, change ', werr, ' deg; torques and axial fairlead moment ', merr, ' N m' + CALL require(ABS(tw0 + (K_D/GJ_D)*(SPAN - L0_D)/DEG) <= 1.0e-6_wp*ABS(tw0), & + 'A1: the static coupling twist on the aggregate') + CALL require(werr <= 1.0e-6_wp, 'A1: the platform roll does not twist a line free at End A') + ! (against the torque GJ phi/L the roll would put into a line restrained at both ends) + CALL require(merr <= 1.0e-6_wp*GJ_D*RATE*DT_A*10.0_wp/SPAN, 'A1: no torque, and no axial moment on the platform') + CALL CD_AGG_End(agg, es, em) + END IF + ! A2: the D line restrained at End A, rolled by the platform + c = SQRT(GJ_D/IRN_D) + om = 0.25_wp*0.5_wp*PI*c/SPAN + dt = 2.0_wp*PI/om/REAL(NPP, wp) + tr = REAL(NPER_RAMP, wp)*2.0_wp*PI/om + CALL write_deck('t1e_agg2.dat', type_row('5.0e4', IRN_D), & + [CHARACTER(48) :: '1 A Rigid 1 0 0 Rigid 0 0 1 0', '1 B Rigid 1 0 0 Free 0 0 1'], SPAN, & + [CHARACTER(16) :: '0.05 dtM'], [CHARACTER(16) :: 'Torq1N1', 'Torq1N41', 'Twist1']) + CALL CD_AGG_Init_From_Deck(agg, 't1e_agg2.dat', dt, es, em, host_orientation=.TRUE.) + ok = es == CD_AGG_OK + CALL require(ok, 'A2: the line free at End B builds on the aggregate: '//TRIM(em)) + IF (.NOT. ok) RETURN + CALL CD_AGG_GetMovingPointMesh(agg, pos, vel, acc, load, es, em, orientation=orient) + nstep = (NPER_RAMP + 1 + NPER_MEAS)*NPP + k0 = (NPER_RAMP + 1)*NPP + proj = 0.0_wp + DO k = 1, nstep + t = dt*REAL(k, wp) + ! the roll AMP s(t) sin(Omega t) with its rate and acceleration (s the quintic ramp) + CALL ramp_derivs(t, tr, s, sd, sdd) + ang = AMP*s*SIN(om*t) + orient(:, :, 1) = roll_dcm(ang) + omega = 0.0_wp + alpha = 0.0_wp + omega(1, 1) = AMP*(sd*SIN(om*t) + s*om*COS(om*t)) + alpha(1, 1) = AMP*(sdd*SIN(om*t) + 2.0_wp*sd*om*COS(om*t) - s*om*om*SIN(om*t)) + CALL CD_AGG_Step_Moving(agg, dt, pos, vel, acc, cv, st, ni, es, em, orientation=orient, & + angular_velocity=omega, angular_acceleration=alpha) + CALL require(es == CD_AGG_OK .AND. cv, 'A2: the rolling step converges: '//TRIM(em)) + IF (es /= CD_AGG_OK) EXIT + IF (k > k0) THEN + CALL CD_AGG_CalcOutput(agg, es, em) + CALL agg_channels(agg, ta, tb, tw) + proj = proj + [tw, ta, tb]*SIN(om*t) + END IF + END DO + IF (es == CD_AGG_OK) THEN + proj = 2.0_wp*proj/REAL(NPER_MEAS*NPP, wp) + kw = om/c + CALL inertia_expect(AMP, kw, SPAN, 40, tw_ref, ma_ref, mb_ref) + e(1) = proj(1)*DEG/tw_ref - 1.0_wp + e(2) = proj(2)/ma_ref - 1.0_wp + e(3) = proj(3)/mb_ref - 1.0_wp + WRITE (*, '(A,3ES13.5,A,3ES10.2)') 'A2 aggregate, platform roll of the restrained End A: Twist1, Torq1N1, '// & + 'Torq1N41 at Omega ', proj(1)*DEG, proj(2:3), ' errors against the continuum ', e + CALL require(ABS(e(1)) <= 1.0e-2_wp, 'A2: the free End B follows the platform roll') + CALL require(ABS(e(2)) <= 1.0e-2_wp, 'A2: the fairlead End A carries the continuum''s inertial torque') + CALL require(ABS(e(3)) <= 3.0e-2_wp, 'A2: the free End B''s element carries the continuum''s small torque') + END IF + CALL CD_AGG_End(agg, es, em) + END SUBROUTINE check_aggregate + + SUBROUTINE ramp_derivs(t, tr, s, sd, sdd) + !! The quintic ramp of ramp() and its first two time derivatives. + REAL(wp), INTENT(IN) :: t, tr + REAL(wp), INTENT(OUT) :: s, sd, sdd + REAL(wp) :: x + x = MIN(MAX(t/tr, 0.0_wp), 1.0_wp) + s = x**3*(10.0_wp - 15.0_wp*x + 6.0_wp*x**2) + sd = 0.0_wp + sdd = 0.0_wp + IF (t < tr) THEN + sd = 30.0_wp*x**2*(1.0_wp - x)**2/tr + sdd = 60.0_wp*x*(1.0_wp - x)*(1.0_wp - 2.0_wp*x)/tr**2 + END IF + END SUBROUTINE ramp_derivs + + SUBROUTINE agg_channels(agg, torq_a, torq_b, twist) + TYPE(CD_AGG_ModuleType), INTENT(INOUT) :: agg + REAL(wp), INTENT(OUT) :: torq_a, torq_b, twist + INTEGER :: es + CHARACTER(256) :: em + CALL CD_AGG_EvalChannel(agg, 1, torq_a, es, em) + CALL require(es == CD_AGG_OK, 'Torq1N1 evaluates: '//TRIM(em)) + CALL CD_AGG_EvalChannel(agg, 2, torq_b, es, em) + CALL require(es == CD_AGG_OK, 'Torq1N41 evaluates: '//TRIM(em)) + CALL CD_AGG_EvalChannel(agg, 3, twist, es, em) + CALL require(es == CD_AGG_OK, 'Twist1 evaluates: '//TRIM(em)) + END SUBROUTINE agg_channels + + ! ------------------------------------------------------------------------------------------ + SUBROUTINE check_not_solved() + !! N: a 10-column LINE TYPES row (no GJ) with one restrained end: the twist channel is refused + !! with the reason, and without it the deck runs as before. + LOGICAL :: ok + CHARACTER(512) :: em + CALL write_deck('t1e_n.dat', 'cab 0.2 60.0 1.0e9 0.0 1.0e5 0.0 0.0 0.0 0.0', & + [CHARACTER(48) :: '1 A Rigid 1 0 0 Rigid 0 0 1 0', '1 B Rigid 1 0 0 Free 0 0 1'], L0_D, & + [CHARACTER(16) :: '0.1 dtM', '0.0 TMax'], [CHARACTER(16) :: 'FairTen1', 'Twist1'], & + ten_cols=.TRUE.) + CALL run_deck('t1e_n.dat', 't1e_n', ok, em) + CALL require(.NOT. ok .AND. INDEX(em, 'restrained at one end only and its torsion is not solved') > 0 .AND. & + INDEX(em, 'give no GJ') > 0, 'N: the twist channel of a line not solved in torsion is refused '// & + 'with the reason (got: '//TRIM(em)//')') + CALL write_deck('t1e_n.dat', 'cab 0.2 60.0 1.0e9 0.0 1.0e5 0.0 0.0 0.0 0.0', & + [CHARACTER(48) :: '1 A Rigid 1 0 0 Rigid 0 0 1 0', '1 B Rigid 1 0 0 Free 0 0 1'], L0_D, & + [CHARACTER(16) :: '0.1 dtM', '0.0 TMax'], [CHARACTER(16) :: 'FairTen1'], ten_cols=.TRUE.) + CALL run_deck('t1e_n.dat', 't1e_n', ok, em) + CALL require(ok, 'N: without the twist channel the deck runs: '//TRIM(em)) + ! a solved line's imposed twist, its restrained end's Pretwist, is held within 1000 turns + CALL write_deck('t1e_n2.dat', type_row('5.0e4', 1.0_wp), & + [CHARACTER(48) :: '1 A Rigid 1 0 0 Free 0 0 1 0', '1 B Rigid 1 0 0 Rigid 0 0 1 4.0e5'], L0_D, & + [CHARACTER(16) :: '0.1 dtM', '0.0 TMax'], [CHARACTER(16) :: 'Twist1']) + CALL run_deck('t1e_n2.dat', 't1e_n2', ok, em) + CALL require(.NOT. ok .AND. INDEX(em, 'the Pretwist of its restrained End B = 4.00000E+05 deg exceeds 1000 '// & + 'turns') > 0, 'N: a restrained Pretwist beyond 1000 turns is named (got: '// & + TRIM(em)//')') + END SUBROUTINE check_not_solved + + ! ------------------------------------------------------------------------------------------ + SUBROUTINE check_attachments_statics() + !! T1: the static coupling twist of a vertical line free at one end carrying attachments. + INTEGER, PARAMETER :: NE_D = 40, NATT = 3, NODE(NATT) = [11, 21, 31] + REAL(wp), PARAMETER :: MASS(NATT) = [2000.0_wp, 100.0_wp, 800.0_wp], VOL(NATT) = [0.5_wp, 1.0_wp, 0.2_wp] + CHARACTER(16), PARAMETER :: OUTS(7) = [CHARACTER(16) :: 'FairTen1', 'AnchTen1', 'Torq1N1', 'Torq1N41', & + 'Twist1N21', 'Twist1', 'Twist1N41'] + CHARACTER(48) :: conns(2, 2), atts(NATT) + CHARACTER(24), PARAMETER :: LABEL(2) = [CHARACTER(24) :: 'End A free', 'End B free'] + REAL(wp), ALLOCATABLE :: rows(:, :) + REAL(wp) :: w(NATT), l0, ea_eff, t_a, t_e, tw_ref, tw_mid, tw_mid0, e_tw, e_mid, e_t, e_m + INTEGER :: iv, k, e, nrow + LOGICAL :: ok + CHARACTER(512) :: em + l0 = L0_D/REAL(NE_D, wp) + w = (MASS - RHOW*VOL)*9.80665_wp + DO k = 1, NATT + WRITE (atts(k), '(A,F12.6,F10.2,F8.3,A)') '1 ', REAL(NODE(k) - 1, wp)*l0, MASS(k), VOL(k), ' 0.0 0.0' + END DO + ! the element tensions from End A down, their strains and the twists + ea_eff = EA_D - K_D**2/GJ_D + t_a = ea_eff*(SPAN - L0_D)/l0 + DO k = 1, NATT + t_a = t_a + w(k)*REAL(NE_D + 1 - NODE(k), wp) + END DO + t_a = t_a/REAL(NE_D, wp) + tw_ref = -(K_D/GJ_D)*(SPAN - L0_D)/DEG + tw_mid = 0.0_wp + DO e = 1, 20 + t_e = t_a - SUM(w, MASK=NODE <= e) + tw_mid = tw_mid - (K_D/GJ_D)*l0*t_e/ea_eff + END DO + tw_mid = tw_mid/DEG + tw_mid0 = 0.5_wp*tw_ref + conns(:, 1) = [CHARACTER(48) :: '1 A Rigid 0 0 -1 Free 1 0 0', '1 B Rigid 0 0 -1 Rigid 1 0 0 30'] + conns(:, 2) = [CHARACTER(48) :: '1 A Rigid 0 0 -1 Rigid 1 0 0 -30', '1 B Rigid 0 0 -1 Free 1 0 0'] + DO iv = 1, 2 + CALL write_deck('t1e_att.dat', type_row('5.0e4|4.0e5', 1.0e-9_wp), conns(:, iv), L0_D, & + [CHARACTER(16) :: '200.0 WtrDpth', '0.1 dtM', '0.0 TMax'], OUTS, atts=atts, & + end_b=[0.0_wp, 0.0_wp, -50.0_wp - SPAN]) + CALL run_deck('t1e_att.dat', 't1e_att', ok, em) + CALL require(ok, 'T1 ('//TRIM(LABEL(iv))//'): the deck with attachments runs with its twist channels: '//TRIM(em)) + IF (.NOT. ok) CYCLE + CALL read_out('t1e_att.out', 8, rows, nrow) + CALL require(nrow == 1, 'T1: one static row') + IF (nrow < 1) CYCLE + e_tw = MAX(ABS(rows(7, 1) - tw_ref), ABS(rows(8, 1) - tw_ref))/ABS(tw_ref) + e_mid = ABS(rows(6, 1) - tw_mid)/ABS(tw_mid) + e_t = MAX(ABS(rows(2, 1) - t_a), ABS(rows(3, 1) - (t_a - SUM(w))))/t_a + e_m = nan_max_abs(rows(4:5, 1)) + WRITE (*, '(A,A,A,F12.5,A,F12.5,A,F12.5,A,F12.5,A,F12.5,A,4ES10.2)') 'T1 ', TRIM(LABEL(iv)), ': Twist1 ', & + rows(7, 1), ' deg (expected ', tw_ref, '), Twist1N21 ', rows(6, 1), ' (expected ', tw_mid, & + '; uniform strain ', tw_mid0, '); errors twist, mid twist, tensions, |torque| ', e_tw, e_mid, e_t, e_m + CALL require(e_tw <= 1.0e-6_wp, 'T1 ('//TRIM(LABEL(iv))//'): the free end turns by -(K/GJ) dl with the modules') + CALL require(e_mid <= 1.0e-3_wp, 'T1 ('//TRIM(LABEL(iv))//'): the mid-line twist follows the module tensions') + CALL require(e_t <= 1.0e-6_wp, 'T1 ('//TRIM(LABEL(iv))//'): the end tensions carry the module weights') + CALL require(e_m <= 1.0e-6_wp, 'T1 ('//TRIM(LABEL(iv))//'): no static torque') + END DO + END SUBROUTINE check_attachments_statics + + SUBROUTINE check_attachments_inertia() + !! T2: the D roll of the restrained End A with three neutral modules (mass rhoW V, no drag), the + !! line taut (an attachment polish of the slack-free D line does not converge, with or without + !! torsion). + REAL(wp), PARAMETER :: IRN_D = 1.0_wp, AMP = 0.1_wp, LEN_T = 99.9_wp + INTEGER, PARAMETER :: NPP = 120, NPER_RAMP = 8, NPER_MEAS = 4 + REAL(wp), ALLOCATABLE :: rows(:, :) + REAL(wp) :: c, om, dt, t, kw, tw_ref, ma_ref, mb_ref, proj(3), e(3) + INTEGER :: u, k, nrow, k0, nstep + LOGICAL :: ok + CHARACTER(512) :: em + CHARACTER(64) :: opt(3) + c = SQRT(GJ_D/IRN_D) + om = 0.25_wp*0.5_wp*PI*c/SPAN + dt = 2.0_wp*PI/om/REAL(NPP, wp) + nstep = (NPER_RAMP + 1 + NPER_MEAS)*NPP + OPEN (NEWUNIT=u, FILE='t1e_att_roll.txt', STATUS='REPLACE', ACTION='WRITE') + WRITE (u, '(A)') '# time id x y z vx vy vz ax ay az roll' + DO k = 0, nstep + t = dt*REAL(k, wp) + WRITE (u, '(ES24.16,A,ES24.16)') t, ' 1 0.0 0.0 -50.0 0 0 0 0 0 0 ', & + AMP*ramp(t, REAL(NPER_RAMP, wp)*2.0_wp*PI/om)*SIN(om*t)/DEG + END DO + CLOSE (u) + WRITE (opt(1), '(ES24.16,A)') dt, ' dtM' + WRITE (opt(2), '(ES24.16,A)') dt*REAL(nstep, wp), ' TMax' + opt(3) = 't1e_att_roll.txt motionFile' + CALL write_deck('t1e_att_roll.dat', type_row('5.0e4', IRN_D), & + [CHARACTER(48) :: '1 A Rigid 1 0 0 Rigid 0 0 1 0', '1 B Rigid 1 0 0 Free 0 0 1'], LEN_T, opt, & + [CHARACTER(16) :: 'Twist1', 'Torq1N1', 'Torq1N41'], & + atts=[CHARACTER(48) :: '1 25.0 512.5 0.5 0.0 0.0', '1 50.0 1025.0 1.0 0.0 0.0', & + '1 75.0 205.0 0.2 0.0 0.0']) + CALL run_deck('t1e_att_roll.dat', 't1e_att_roll', ok, em) + CALL require(ok, 'T2: the rolling march with neutral modules runs: '//TRIM(em)) + IF (.NOT. ok) RETURN + CALL read_out('t1e_att_roll.out', 4, rows, nrow) + CALL require(nrow == nstep + 1, 'T2: one row per step') + IF (nrow /= nstep + 1) RETURN + k0 = (NPER_RAMP + 1)*NPP + 1 + proj = 0.0_wp + DO k = k0 + 1, nrow + proj = proj + rows(2:4, k)*SIN(om*rows(1, k)) + END DO + proj = 2.0_wp*proj/REAL(NPER_MEAS*NPP, wp) + kw = om/c + CALL inertia_expect(AMP, kw, LEN_T, 40, tw_ref, ma_ref, mb_ref) + e(1) = proj(1)*DEG/tw_ref - 1.0_wp + e(2) = proj(2)/ma_ref - 1.0_wp + e(3) = proj(3)/mb_ref - 1.0_wp + WRITE (*, '(A,3ES13.5,A,3ES13.5,A,3ES10.2)') 'T2 roll with neutral modules (kL = pi/8): Twist1, Torq1N1, '// & + 'Torq1N41 at Omega ', proj(1)*DEG, proj(2:3), ' continuum ', tw_ref, ma_ref, mb_ref, ' errors ', e + CALL require(ABS(e(1)) <= 1.0e-2_wp, 'T2: the free End B follows the roll with the continuum''s twist') + CALL require(ABS(e(2)) <= 1.0e-2_wp, 'T2: the restrained End A carries the continuum''s inertial torque') + CALL require(ABS(e(3)) <= 3.0e-2_wp, 'T2: the free End B''s element carries the continuum''s small torque') + END SUBROUTINE check_attachments_inertia + + ELEMENTAL INTEGER(8) FUNCTION bits(x) + REAL(wp), INTENT(IN) :: x + bits = TRANSFER(x, 0_8) + END FUNCTION bits + +END PROGRAM test_torsion_one_end diff --git a/validation/scripts/openfast_lin_torsion.py b/validation/scripts/openfast_lin_torsion.py index 6efbe120..7b29f051 100644 --- a/validation/scripts/openfast_lin_torsion.py +++ b/validation/scripts/openfast_lin_torsion.py @@ -2,7 +2,7 @@ # SPDX-License-Identifier: Apache-2.0 """OpenFAST linearisation of finite-EI lines restrained in torsion (CompMooring = 5). -Two decks, each linearised once at t = 0 in the case of openfast_lin_ab.py (the IEA-15MW +Three decks, each linearised once at t = 0 in the case of openfast_lin_ab.py (the IEA-15MW UMaine model, platform DOFs only, still water, OutFmt ES24.15E3, module-level output), with the deck below as the only mooring: @@ -36,10 +36,19 @@ >= 1 % of it within twice that. The operating-point moment about d must equal the static Torq1N1. + 3. The straight line of 1 restrained in torsion at End A only, End B free to twist: the free + end's angle is a state; the torsional modes of A are the clamped-free ones, against the + continuum's quarter-wave (2n - 1) pi/(2L) sqrt(GJ/Irn) within x^2/6, x = (2n - 1) pi/(4N), + and the lumped chain's 2 sqrt(GJ/Irn)/h sin(x); the roll stiffness about the line axis + vanishes (the platform turns the line as a whole), against the feedthrough GJ/l_e. + Measured (the 0.4.0 module): the three torsional modes are the lumped chain's to 5e-14 and the continuum's within -1.6e-4, -6.6e-4, -1.5e-3; the straight line's roll stiffness is GJ/L to 1.5e-14 (feedthrough D alone 25 000 = GJ/l_e); the twisted lazy wave matches its static -solutions to 4.9e-4 (the moment about d per unit rotation 82.4268 / 82.4263 N m/rad, 5.9e-6). +solutions to 4.9e-4 (the moment about d per unit rotation 82.4268 / 82.4263 N m/rad, 5.9e-6); +the line free at End B has 100 twist states, its modes are the clamped-free chain's to 2.5e-13 +and lie 4.1e-5, 3.7e-4, 1.0e-3 below the quarter-wave, and its roll stiffness is 0 against the +feedthrough 25 000. An executable without twist states refuses both decks at initialisation ("formal OpenFAST linearization of a line restrained in torsion is not supported"); with the twist angles held the straight line's roll stiffness would be the end element's GJ/l_e, 50 times GJ/L. @@ -70,7 +79,7 @@ IRN_STRAIGHT = 2.0 -def straight_deck() -> str: +def straight_deck(tors_b: str = "Rigid") -> str: mass = RHOW * 0.25 * np.pi * 0.2**2 return "\n".join([ "--------------------- CableDyn Input File ------------------------------------", @@ -96,7 +105,7 @@ def straight_deck() -> str: "LineID End Stiffness EzX EzY EzZ TorsStiffness NxX NxY NxZ Pretwist", "(-) (-) (N-m/rad) (-) (-) (-) (N-m/rad) (-) (-) (-) (deg)", "1 A Pinned 0 0 -1 Rigid 1 0 0 0", - "1 B Pinned 0 0 -1 Rigid 1 0 0 0", + f"1 B Pinned 0 0 -1 {tors_b} 1 0 0 0", "--------------------- OPTIONS -----------------------------------------------", "0.025 dtM - CableDyn time step (s)", "--------------------- OUTPUTS -----------------------------------------------", @@ -286,6 +295,43 @@ def gate_straight(args: argparse.Namespace, case: Path) -> list[str]: return fails +def gate_straight_free(args: argparse.Namespace, case: Path) -> list[str]: + mod = lin_case(args, case, "tors_straight_free", straight_deck("Free")) + fails = [] + labels = [ab_label(s) for s in state_labels(case / "Main_lin_tors_straight_free.1.CD.lin", mod["n_x"])] + tw = np.array(["twist" in s for s in labels]) + print(f"straight line free at End B: {mod['n_x']} states, {int(tw.sum())} twist") + if int(tw.sum()) != 2 * N_STRAIGHT: + fails.append("the free end's angle is not a state") + ev, vec = np.linalg.eig(mod["A"]) + share = np.sum(np.abs(vec[tw, :])**2, axis=0) / np.sum(np.abs(vec)**2, axis=0) + pick = (ev.imag > 1e-9) & (share > 0.999) + w = np.sort(np.abs(ev[pick])) + h = L_STRAIGHT / N_STRAIGHT + c = np.sqrt(GJ / IRN_STRAIGHT) + worst_c = worst_d = 0.0 + if len(w) < 3: + ab.die(f"found {len(w)} torsional modes of the line free at End B, expected at least 3") + for n in (1, 2, 3): + x = (2 * n - 1) * np.pi / (4 * N_STRAIGHT) + wc = (2 * n - 1) * np.pi / (2 * L_STRAIGHT) * c + wd = 2.0 / h * c * np.sin(x) + ec, ed = w[n - 1] / wc - 1.0, w[n - 1] / wd - 1.0 + bound = 1.2 * x**2 / 6.0 + 1e-6 + print(f" torsional mode {n}: {w[n - 1] / (2 * np.pi):.8f} Hz; quarter-wave {wc / (2 * np.pi):.8f} " + f"({ec:+.3e}, bound {bound:.2e}); clamped-free chain {wd / (2 * np.pi):.8f} ({ed:+.3e})") + worst_c = max(worst_c, abs(ec) / bound) + worst_d = max(worst_d, abs(ed)) + if worst_c > 1.0 or worst_d > 1e-6: + fails.append("the torsional modes of A differ from the clamped-free ones") + K, Dft = reduced_6x6(mod) + print(f" roll stiffness about the line axis -(D - C A^-1 B) = {K[5, 5]:.3e} N m/rad (GJ/L = " + f"{GJ / L_STRAIGHT:.3e}); feedthrough -D = {Dft[5, 5]:.6e} (GJ/l_e = {GJ / h:.6e})") + if abs(K[5, 5]) > 1e-6 * GJ / L_STRAIGHT: + fails.append("the line free at End B has a roll stiffness") + return fails + + def state_labels(path: Path, n_x: int) -> list[str]: text = path.read_text().splitlines() out: list[str] = [] @@ -404,7 +450,7 @@ def main() -> None: if not args.driver.is_file(): ab.die(f"driver not found: {args.driver}") case = args.case_dir - fails = gate_straight(args, case) + gate_lazy_wave(args, case) + fails = gate_straight(args, case) + gate_straight_free(args, case) + gate_lazy_wave(args, case) if fails: ab.die("; ".join(fails)) print("PASS")