diff --git a/CHANGELOG.md b/CHANGELOG.md index d449f5b8..4c95d454 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -19,6 +19,14 @@ All notable changes to CableDyn are recorded in this file. The format follows `EI = 0` + finite-EI route) the finite-EI cable steps with their residual, tangent and solve counts and times. Every output file is the same with and without it. See the manual's command-line page (Run-time profile). +- Torsion of finite-EI lines in coupled OpenFAST (`CompMooring = 5`) and FAST.Farm runs. The + End A frame of a line restrained in torsion turns with the platform orientation, the torque + moment is returned to the platform, `PtfmInit` twists the line in the static initialisation, + the `Torq`/`Twist` channels are written, and the unwrapped twist is restored on a checkpoint + restart. The C API and the standalone deck that mixes `EI = 0` and finite-EI lines without a + body, which move the line ends by translation only, still refuse torsion columns by name, and + so does OpenFAST linearisation of a line restrained in torsion. See the manual's OpenFAST page + (Line torsion). ### Changed diff --git a/CMakeLists.txt b/CMakeLists.txt index 0f05fc1b..b3d6db2d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1785,6 +1785,11 @@ target_link_libraries(test_torsion_deck PRIVATE cabledyn_core) add_test(NAME torsion_deck COMMAND test_torsion_deck) set_tests_properties(torsion_deck PROPERTIES LABELS "fortran;driver;integration;static;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}) +set_tests_properties(coupled_torsion PROPERTIES LABELS "fortran;unit;static;dynamic;openfast") + add_executable(test_torsion_orcaflex tests/test_torsion_orcaflex.f90) target_link_libraries(test_torsion_orcaflex PRIVATE cabledyn_core) add_test(NAME torsion_orcaflex diff --git a/VALIDATION.md b/VALIDATION.md index 8087502e..c93346d7 100644 --- a/VALIDATION.md +++ b/VALIDATION.md @@ -98,6 +98,7 @@ article's methods, are compared in | **T-8** | Cross-check with the Cosserat rod path | Cosserat path | shape 4.2e-4 L, torque 5.2e-5 | <1% | Pass | | **T-9** | Bordered Newton step on post-buckled states | predicted linear rate without the rank-one term | 3 iterations; rate 0.055 / 0.217 vs 0.055 / 0.218 | ≤4; within 25% | Pass | | **T-10** | Torsion dynamics, restart and body torque | quasi-static torque, energy, uninterrupted run, pendulum | torque 2.2e-16; energy band 4.9e-4; restart bit-identical; pendulum 6.4e-5 | 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 | **Pass** meets the stated acceptance value. **Pass measured** records a measured comparison without an acceptance value. **Informative** is reported but not used for @@ -875,13 +876,32 @@ in parentheses). form of the march's trapezoidal body integrator at every step (≤9.7e-8°), so the body–twist coupling is stable at any step. The `motionFile` roll column and a rolling vessel give `Twist = −roll` and the quasi-static torque at every step. +- **T-11 coupled route** (`coupled_torsion`, `torsion_deck`; OpenFAST runs). On the aggregate + surface the OpenFAST and FAST.Farm shells drive, the straight neutral line of T-2 with its End A + on the platform fairlead twists by `−roll` when the platform rolls about the line axis: a + non-stepping update gives `Twist1 = −20°` and `GJ(−roll)/L` at both ends, with the fairlead + moment equal to that torque about the line axis and resisting the roll; a 60 °/s roll gives the + quasi-static torque at every step (twist error 1.8e-15°, torque 1.7e-13 N·m), and the aggregate + column equals the single coupled cable driven with the same calls bit for bit. 1.5 turns of roll + in 18° steps carry no `2π` slip, a snapshot–step–restore–step is bit-identical, and a + non-stepping turn of 100° stops by name without changing the state. `PtfmInit` yaw over a + vertical line and a FAST.Farm `Turbine2` yaw give the static twist `+yaw` (15° and 10°, 1e-5). + The shell's checkpoint recipe, which restores the committed twist before it moves the fairlead + to the restart pose, continues bit-identically after 150° of roll, where the previous order is + refused by the 90° bound. In OpenFAST (IEA-15 MW VolturnUS-S with three chains and a lazy-wave + power cable restrained in torsion, 60 s of irregular SeaState waves, no wind) the run + completes with `Torq4N1 = GJ·Twist4/L`, the twist follows the platform yaw (±0.14° against + ±0.12°), and + `openfast -restart` from 30 s reproduces all 1200 later rows of the OpenFAST and CableDyn + outputs bit for bit. No full FAST.Farm run is part of this record. - **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`, modal analysis, the configuration blend, misuse of the roll column, channels on - an unrestrained line, the coupled entries and a mixed `EI = 0` + finite-EI deck without a body - stop with named errors. + `ATTACHMENTS`, modal analysis, 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. Limits. The torsion model is quasi-static (no torsional inertia), takes no seabed friction against twist and no torque–tension coupling, and does not resolve self-contact. Dynamic loop diff --git a/doc/capabilities.rst b/doc/capabilities.rst index 4032d823..398383c7 100644 --- a/doc/capabilities.rst +++ b/doc/capabilities.rst @@ -80,17 +80,19 @@ Line and constitutive capability - single-section taut dynamic line with OWC and two history states; composite, hydro, finite-EI, current, and wave combinations fail closed by name * - Torsion of finite-EI lines - - Standalone only, with limits + - Supported with limits - condensed isotropic torsion (uniform torque, quasi-static: no torsional inertia) of a finite-EI line restrained in torsion at both ends (``END CONNECTIONS`` torsion columns, explicit ``GJ``), in statics with a stability check and buckling descent, and in dynamics with turning Rigid6 bodies, ``vesselMotion``/``vesselRAO`` and the ``motionFile`` roll - column; ``Torq``/``Twist`` channels and range graphs. Stopped by name: coupled OpenFAST - and FAST.Farm, the mixed ``EI = 0`` + finite-EI aggregate, rod ends, bodies other than - Rigid6, lines with ``ATTACHMENTS``, modal analysis, ``False alpha_force_blend``, and C API - object queries (which take ``EI = 0`` decks only). Not modelled: seabed friction against - twist, torque–tension coupling, anisotropic sections, self-contact of a loop (see - :ref:`theory-torsion`) + column standalone, and with the platform orientation in coupled OpenFAST and FAST.Farm + runs (torque returned to the platform, ``PtfmInit``, checkpoints; see + :doc:`openfast`); ``Torq``/``Twist`` channels and standalone range graphs. Stopped by + name: the standalone mixed ``EI = 0`` + finite-EI aggregate and the C API (which move the + line ends by translation only), OpenFAST linearisation of a line restrained in torsion, + rod ends, bodies other than Rigid6, lines with ``ATTACHMENTS``, modal analysis, and + ``False alpha_force_blend``. Not modelled: seabed friction against twist, torque–tension + coupling, anisotropic sections, self-contact of a loop (see :ref:`theory-torsion`) * - Hockling loops, nonlinear cross-section laws - Not provided - the buckling onset and the post-buckled shape are computed, but a loop that closes on diff --git a/doc/driver_format.md b/doc/driver_format.md index 97dfd75a..cb048610 100644 --- a/doc/driver_format.md +++ b/doc/driver_format.md @@ -815,15 +815,17 @@ Behaviour: 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. 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 line with `ATTACHMENTS`, modal analysis (`nModes`), a -dynamic run with `False alpha_force_blend`, any restrained end (one end included) in a coupled -OpenFAST or FAST.Farm run or in a deck mixing `EI = 0` and finite-EI lines without a body -(`torsion is not yet supported in a deck that mixes ...`; with a body such a deck runs on the -multibody route, which supports torsion), and a `Torq`/`Twist` channel on a line that is not -restrained at both ends. Seabed -friction does not resist twist (the laid part of a line twists freely), and there is no -torque–tension coupling. +`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 line with `ATTACHMENTS`, +modal analysis (`nModes`), 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, 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), OpenFAST linearisation of a line +restrained in torsion, and a `Torq`/`Twist` channel on a line that is not restrained at both +ends. Seabed friction does not resist twist (the laid part of a line twists freely), and there +is no torque–tension coupling. ### EQUIVALENT BUOYANCY (optional) diff --git a/doc/openfast.rst b/doc/openfast.rst index 346aad04..3791536a 100644 --- a/doc/openfast.rst +++ b/doc/openfast.rst @@ -219,6 +219,25 @@ direction reversal of exactly 180° in one host update is rejected, because the is not unique. Formal linearisation (``Linearize = True``) with a platform-relative end connection fails during initialisation. Row grammar: :doc:`driver_format`. +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 +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 +step the line may turn by more than 90° about its end direction, because the step is cut into +substeps; an output probe moves the frame without a step, is limited to 90° from the +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 of a line restrained in torsion fails during initialisation: the torque's +rotational stiffness has no column in the translation-only quasi-static reduction. The C API +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. + Lifecycle features ------------------ diff --git a/doc/troubleshooting.rst b/doc/troubleshooting.rst index 40d5a8f1..46468820 100644 --- a/doc/troubleshooting.rst +++ b/doc/troubleshooting.rst @@ -342,11 +342,18 @@ Torsion - outside the torsion scope (:doc:`capabilities`). Move End A to a ``Fixed``, ``Coupled``/``Vessel`` point or a Rigid6 body, or represent the modules as a smeared buoyancy section. - * - ``torsion is not yet supported in coupled OpenFAST runs`` / ``torsion is not yet supported - in a deck that mixes EI = 0 and finite-EI lines without a BODY, nor in coupled OpenFAST or - FAST.Farm runs`` - - run the torsional line standalone (a mixed deck with a body runs on the multibody route, - which supports torsion), or set ``TorsStiffness Free`` in every ``END CONNECTIONS`` row. + * - ``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, move the line ends by translation only. Run the line in a coupled OpenFAST or + FAST.Farm run, add a body (such a deck runs on the multibody route, which supports + torsion), or set ``TorsStiffness Free`` in every ``END CONNECTIONS`` row. + * - ``formal OpenFAST linearization of a line restrained in torsion is not supported`` + - linearise the model with ``TorsStiffness Free``; the torque's rotational stiffness is not + part of the quasi-static reduction. + * - ``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 + coupling step well below 90°. * - ``a body holding a line restrained in torsion turns by more than 90 deg in one step even after 6 step halvings`` - the body turns faster than one step can follow the twist; reduce ``dtM``. diff --git a/python/cabledyn/deck_file.py b/python/cabledyn/deck_file.py index 0a621b57..66341c0f 100644 --- a/python/cabledyn/deck_file.py +++ b/python/cabledyn/deck_file.py @@ -3805,9 +3805,11 @@ def _check_torsion_lines( 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 and takes no modal analysis. The coupled routes - and a standalone mixed EI = 0 + finite-EI deck without bodies (``aggregate_route``, - run on the aggregate) refuse any torsion column, one restrained end included. + the force-blended generalised-alpha (a coupled run is always dynamic) and takes no + modal analysis. 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. """ # _check_attachments has already accepted every LineID as an integer attachment_lines = {str(_native_int(row.tokens[0])) for row in self._rows("ATTACHMENTS")} @@ -3861,19 +3863,24 @@ def _check_torsion_lines( "a Rigid6 body" ) torsion_lines.add(line_id) - # native CD_Init_Deck_Aggregate (deck_has_torsion_columns): the coupled routes and a - # standalone mixed EI = 0 + finite-EI deck without bodies refuse any restrained end - if has_torsion_column and (self.caller_driven or aggregate_route): + # 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}: torsion is not yet supported in a deck that mixes EI = 0 and " - "finite-EI lines without a BODY, nor in coupled OpenFAST or FAST.Farm runs (with a " - "BODY such a deck runs on the multibody route, which supports torsion); set " - "TorsStiffness Free in every END CONNECTIONS row" + f"{self._label}: a line restrained in torsion needs a host that turns its fairlead " + "frame: coupled OpenFAST and FAST.Farm runs do, while the C API 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") - dynamic = has_tmax and tmax_row is not None and _native_float(tmax_row.values[0]) > 0.0 + # 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", diff --git a/python/tests/test_deck_native_parity.py b/python/tests/test_deck_native_parity.py index 9a84c1c2..e10149e8 100644 --- a/python/tests/test_deck_native_parity.py +++ b/python/tests/test_deck_native_parity.py @@ -886,16 +886,25 @@ def test_torsion_line_rules_follow_the_native_checks(): 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"))) - # the dynamic run needs the force blend; modal analysis and the coupled routes refuse torsion + # the dynamic run needs the force blend; modal analysis refuses torsion dynamic = _edit(_TORSION, ("0.0 TMax\n", "10.0 TMax\n")) DeckFile.from_text(dynamic) _rejects( _options(dynamic, "False alpha_force_blend"), "needs the force-blended generalised-alpha" ) _rejects(_options(_TORSION, "3 nModes"), "modal analysis .* with torsion is not yet supported") - _rejects(_TORSION, "nor in coupled OpenFAST or FAST.Farm runs", caller_driven=True) - # the coupled routes refuse one restrained end too (any torsion column), after the line rules - _rejects(one_end, "nor in coupled OpenFAST or FAST.Farm runs", caller_driven=True) + # the coupled OpenFAST and FAST.Farm routes turn the fairlead frame with the platform and + # accept torsion, one restrained end included; a coupled run is always dynamic, so it + # needs the force blend whatever the deck's TMax + DeckFile.from_text(_TORSION, caller_driven=True) + DeckFile.from_text( + _edit(one_end, ("Torq1N1\nTwist1N41\nTwist1\n", "FairTen1\n")), caller_driven=True + ) + _rejects( + _options(_TORSION, "False alpha_force_blend"), + "needs the force-blended generalised-alpha", + caller_driven=True, + ) _rejects(ei0, "require a finite-EI line; line 1 has EI = 0", caller_driven=True) diff --git a/src/CableDyn_DeckDriver.f90 b/src/CableDyn_DeckDriver.f90 index 3fe730e6..6872c545 100644 --- a/src/CableDyn_DeckDriver.f90 +++ b/src/CableDyn_DeckDriver.f90 @@ -231,6 +231,14 @@ MODULE CableDyn_DeckDriver INTEGER, PARAMETER :: NAMELEN = CD_DECK_NAMELEN ! appended to a failed standalone march's message: the .out file keeps the committed rows 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, while the C API '// & + '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' + CHARACTER(*), PARAMETER :: TORSION_NEEDS_FORCE_BLEND = 'torsion in a dynamic run needs the force-blended '// & + 'generalised-alpha (OPTION alpha_force_blend True)' REAL(wp), PARAMETER :: QUARTER_PI = 0.785398163397448309616_wp ! pi/4 (displaced-area factor) REAL(wp), PARAMETER :: CD_RAD2DEG = 57.29577951308232087680_wp ! 180/pi (declination/azimuth output) INTEGER, PARAMETER :: WAVE_NONE = 0, WAVE_AIRY = 1, WAVE_JONSWAP = 2, WAVE_COMPONENTS = 3 @@ -4883,16 +4891,20 @@ PURE FUNCTION short_message(msg, max_len) RESULT(out) END IF END FUNCTION short_message - SUBROUTINE CD_Init_Deck_HermiteCable(deck_path, dt, cable, coupled_node, ErrStat, ErrMsg) + SUBROUTINE CD_Init_Deck_HermiteCable(deck_path, dt, cable, coupled_node, ErrStat, ErrMsg, host_orientation) !! Parse a single-cable deck (exactly one finite-EI LINE) and build it as a COUPLED !! cubic-Hermite lazy-wave cable driven at the fairlead. Fails closed on an EI=0 deck (use !! CD_Init_Deck_System) or a deck with more than one line (use the aggregate facade). + !! host_orientation: the caller passes the fairlead orientation with every update + !! (CD_HFMF_UpdateStates u_orientation), which a line restrained in torsion needs to turn + !! its End A frame; without it a torsion deck fails closed. CHARACTER(*), INTENT(IN) :: deck_path REAL(wp), INTENT(IN) :: dt TYPE(CD_HFMF_ModuleType), INTENT(INOUT) :: cable INTEGER, INTENT(OUT) :: coupled_node INTEGER, INTENT(OUT) :: ErrStat CHARACTER(*), INTENT(OUT) :: ErrMsg + LOGICAL, INTENT(IN), OPTIONAL :: host_orientation TYPE(DeckLineType), ALLOCATABLE :: types(:) TYPE(DeckBody), ALLOCATABLE :: bodies(:) @@ -4904,6 +4916,7 @@ SUBROUTINE CD_Init_Deck_HermiteCable(deck_path, dt, cable, coupled_node, ErrStat TYPE(DeckOptions) :: opts CHARACTER(NAMELEN), ALLOCATABLE :: channels(:) TYPE(CD_BathymetryType) :: bathymetry + LOGICAL :: host_turns ErrStat = CD_DECKDRV_OK ErrMsg = '' @@ -4911,9 +4924,15 @@ SUBROUTINE CD_Init_Deck_HermiteCable(deck_path, dt, cable, coupled_node, ErrStat CALL parse_deck(deck_path, types, bodies, rod_types, rods, points, lines, sections, opts, channels, & ErrStat, ErrMsg, caller_driven=.TRUE.) IF (ErrStat /= CD_DECKDRV_OK) RETURN - IF (deck_has_torsion_columns(lines)) THEN - CALL fail(ErrStat, ErrMsg, 'torsion is not yet supported in coupled OpenFAST runs; set TorsStiffness '// & - 'Free in every END CONNECTIONS row'); RETURN + 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 (SIZE(lines) == 1) THEN + IF (line_torsion_active(lines(1)) .AND. .NOT. opts%alpha_force_blend) THEN + CALL fail(ErrStat, ErrMsg, TORSION_NEEDS_FORCE_BLEND); RETURN + END IF END IF IF (.NOT. deck_has_finite_ei(types, sections)) THEN CALL fail(ErrStat, ErrMsg, 'CD_Init_Deck_HermiteCable: deck has no finite-EI (EI>0) line; '// & @@ -4966,7 +4985,7 @@ 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) + range_files, host_orientation) !! 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 @@ -5032,8 +5051,14 @@ SUBROUTINE CD_Init_Deck_Aggregate(deck_path, dt, agg, ErrStat, ErrMsg, env_gravi ! range_files: the caller writes the range graphs of the LINES flag r (the standalone ! 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. + LOGICAL, INTENT(IN), OPTIONAL :: host_orientation INTEGER :: nturb + LOGICAL :: host_turns TYPE(DeckLineType), ALLOCATABLE :: types(:) TYPE(DeckBody), ALLOCATABLE :: bodies(:) TYPE(DeckRodType), ALLOCATABLE :: rod_types(:) @@ -5066,11 +5091,13 @@ SUBROUTINE CD_Init_Deck_Aggregate(deck_path, dt, agg, ErrStat, ErrMsg, env_gravi 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.) IF (ErrStat == CD_DECKDRV_OK) THEN - IF (deck_has_torsion_columns(lines)) THEN - CALL fail(ErrStat, ErrMsg, 'torsion is not yet supported in a deck that mixes EI = 0 and finite-EI '// & - 'lines without a BODY, nor in coupled OpenFAST or FAST.Farm runs (with a BODY such a deck '// & - 'runs on the multibody route, which supports torsion); set TorsStiffness Free in every END '// & - 'CONNECTIONS row'); RETURN + 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 + CALL fail(ErrStat, ErrMsg, TORSION_NEEDS_FORCE_BLEND); RETURN END IF END IF IF (ErrStat /= CD_DECKDRV_OK) RETURN @@ -6139,8 +6166,7 @@ SUBROUTINE run_deck_driver(deck_path, out_root, converged, ErrStat, ErrMsg) END DO IF (ANY([(line_torsion_active(lines(li)), li=1, SIZE(lines))])) THEN IF (opts%has_tmax .AND. opts%tmax > CD_ZERO .AND. .NOT. opts%alpha_force_blend) THEN - CALL fail(ErrStat, ErrMsg, 'torsion in a dynamic run needs the force-blended generalised-alpha (OPTION '// & - 'alpha_force_blend True)'); RETURN + CALL fail(ErrStat, ErrMsg, TORSION_NEEDS_FORCE_BLEND); RETURN END IF IF (opts%n_modes > 0) THEN CALL fail(ErrStat, ErrMsg, 'modal analysis (OPTION nModes) of a line with torsion is not yet supported'); RETURN diff --git a/src/CableDyn_OpenFAST_Aggregate.f90 b/src/CableDyn_OpenFAST_Aggregate.f90 index 33c24088..bf713e6b 100644 --- a/src/CableDyn_OpenFAST_Aggregate.f90 +++ b/src/CableDyn_OpenFAST_Aggregate.f90 @@ -221,7 +221,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) + range_files, host_orientation) !! 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 @@ -257,6 +257,9 @@ SUBROUTINE CD_AGG_Init_From_Deck(self, deck_path, dt, ErrStat, ErrMsg, env_gravi LOGICAL, INTENT(IN), OPTIONAL :: forbid_deck_ambient ! range_files: the caller writes the range graphs of the LINES flag r (CD_AGG_Range_*) LOGICAL, INTENT(IN), OPTIONAL :: range_files + ! host_orientation: the caller passes the moving-point orientations with every update, + ! which a finite-EI line restrained in torsion requires (see CD_Init_Deck_Aggregate) + LOGICAL, INTENT(IN), OPTIONAL :: host_orientation ! 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. @@ -295,7 +298,7 @@ SUBROUTINE CD_AGG_Init_From_Deck(self, deck_path, dt, ErrStat, ErrMsg, env_gravi coupled_positions=coupled_positions, n_turbines=n_turbines, & 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) + range_files=range_files, host_orientation=host_orientation) IF (PRESENT(external_fluid)) THEN candidate%built_extfluid = external_fluid END IF diff --git a/src/CableDyn_OpenFAST_HermiteFMF.f90 b/src/CableDyn_OpenFAST_HermiteFMF.f90 index 4e38dd70..fe28b36f 100644 --- a/src/CableDyn_OpenFAST_HermiteFMF.f90 +++ b/src/CableDyn_OpenFAST_HermiteFMF.f90 @@ -83,6 +83,7 @@ MODULE CableDyn_OpenFAST_HermiteFMF PUBLIC :: CD_HFMF_MirrorSize PUBLIC :: CD_HFMF_FrictionMirrorSize PUBLIC :: CD_HFMF_ForceMirrorSize + PUBLIC :: CD_HFMF_TorsionMirrorSize PUBLIC :: CD_HFMF_PackMirror PUBLIC :: CD_HFMF_UnpackMirror PUBLIC :: CD_HFMF_End @@ -1482,17 +1483,18 @@ INTEGER FUNCTION CD_HFMF_MirrorSize(self) RESULT(n) n = 0 IF (.NOT. self%initialized) RETURN IF (ALLOCATED(self%line%freemask)) n = 3*COUNT(self%line%freemask) - n = n + CD_HFMF_FrictionMirrorSize(self) + CD_HFMF_ForceMirrorSize(self) + torsion_mirror_size(self) + n = n + CD_HFMF_FrictionMirrorSize(self) + CD_HFMF_ForceMirrorSize(self) + & + CD_HFMF_TorsionMirrorSize(self) END FUNCTION CD_HFMF_MirrorSize - INTEGER FUNCTION torsion_mirror_size(self) RESULT(n) + INTEGER FUNCTION CD_HFMF_TorsionMirrorSize(self) RESULT(n) !! Mirror slots of the condensed torsion, last: the accepted (unwrapped) Theta, Phi and the !! four end-frame vectors (14 values); zero without torsion. TYPE(CD_HFMF_ModuleType), INTENT(IN) :: self n = 0 IF (.NOT. self%initialized) RETURN IF (self%line%torsion%active) n = 14 - END FUNCTION torsion_mirror_size + END FUNCTION CD_HFMF_TorsionMirrorSize INTEGER FUNCTION CD_HFMF_ForceMirrorSize(self) RESULT(n) !! Mirror slots of the force-blended generalised-alpha integrator state beyond [v; q; a] of diff --git a/src/openfast/CableDyn_OF.f90 b/src/openfast/CableDyn_OF.f90 index 3acb5aba..432f98f9 100644 --- a/src/openfast/CableDyn_OF.f90 +++ b/src/openfast/CableDyn_OF.f90 @@ -90,7 +90,7 @@ MODULE CableDyn CD_AGG_WriteStaticProfile USE CableDyn_OpenFAST_HermiteFMF, ONLY: CD_HFMF_MirrorSize, CD_HFMF_PackMirror, CD_HFMF_UnpackMirror, & CD_HFMF_FrictionMirrorSize, CD_HFMF_ForceMirrorSize, & - CD_HFMF_OK + CD_HFMF_TorsionMirrorSize, CD_HFMF_OK USE CableDyn_HermiteCableDynamic, ONLY: CD_HermiteCable_Dyn_Reset_Profile, & CD_HermiteCable_Dyn_Disable_Profile, & CD_HermiteCable_Dyn_Get_Profile, & @@ -698,20 +698,23 @@ SUBROUTINE CD_Init(InitInp, u, p, x, xd, z, other, y, m, DTcoupling, InitOut, Er n_turbines=nT, & turbine_ref_pos=REAL(InitInp%TurbineRefPos, wp), & farm_ptfm_init=REAL(InitInp%PtfmInit(1:6, 1:nT), wp), & - forbid_deck_ambient=.TRUE., run_tmax=REAL(InitInp%Tmax, wp) ) + forbid_deck_ambient=.TRUE., run_tmax=REAL(InitInp%Tmax, wp), & + host_orientation=.TRUE. ) ELSE CALL CD_AGG_Init_From_Deck( Inst(id)%agg, TRIM(InitInp%FileName), dt_moor, es, em, & env_gravity=REAL(InitInp%g, wp), env_rho_water=REAL(InitInp%rhoW, wp), & env_wtrdpth=REAL(InitInp%WtrDepth, wp), external_fluid=use_extf, & n_turbines=nT, & turbine_ref_pos=REAL(InitInp%TurbineRefPos, wp), & - forbid_deck_ambient=.TRUE., run_tmax=REAL(InitInp%Tmax, wp) ) + forbid_deck_ambient=.TRUE., run_tmax=REAL(InitInp%Tmax, wp), & + host_orientation=.TRUE. ) END IF ELSE CALL CD_AGG_Init_From_Deck( Inst(id)%agg, TRIM(InitInp%FileName), dt_moor, es, em, & env_gravity=REAL(InitInp%g, wp), env_rho_water=REAL(InitInp%rhoW, wp), & env_wtrdpth=REAL(InitInp%WtrDepth, wp), ptfm_init=REAL(ptfm6, wp), & - external_fluid=use_extf, run_tmax=REAL(InitInp%Tmax, wp) ) + external_fluid=use_extf, run_tmax=REAL(InitInp%Tmax, wp), & + host_orientation=.TRUE. ) END IF IF (es /= CD_AGG_OK) THEN ! The slot stays inactive (it is activated only after full success, below), so this and @@ -733,6 +736,17 @@ SUBROUTINE CD_Init(InitInp, u, p, x, xd, z, other, y, m, DTcoupling, InitOut, Er END IF IF (InitInp%Linearize .AND. Inst(id)%agg%ncable > 0) THEN DO ic = 1, Inst(id)%agg%ncable + ! a line restrained in torsion returns a torque moment that turns with the platform + ! even at a bending-pinned end: its rotational stiffness a a^T / C has no column in + ! the translation-only reduction either + IF (Inst(id)%agg%cables(ic)%line%torsion%active) THEN + CALL SetErrStat( ErrID_Fatal, 'CableDyn mooring module: formal OpenFAST linearization '// & + 'of a line restrained in torsion is not supported; the torque''s '// & + 'orientation and moment Jacobian columns are not part of the current '// & + 'quasi-static reduction (set TorsStiffness Free to linearize).', & + ErrStat, ErrMsg, RoutineName ) + RETURN + END IF IF (.NOT. Inst(id)%agg%cables(ic)%has_parent_endconn) CYCLE CALL SetErrStat( ErrID_Fatal, 'CableDyn mooring module: formal OpenFAST linearization '// & 'with a platform-relative cable end connection is not supported; '// & @@ -1308,7 +1322,8 @@ SUBROUTINE rebuild_from_checkpoint( t, u1, p, x, other, m, ErrStat, ErrMsg ) CALL CD_AGG_Init_From_Deck( Inst(id)%agg, TRIM(rst_deck), REAL(p%dtM0, wp), es, em, & env_gravity=REAL(p%g, wp), env_rho_water=REAL(p%rhoW, wp), & env_wtrdpth=REAL(p%WtrDpth, wp), external_fluid=use_extf, & - ptfm_init=REAL(p%PtfmInit, wp), run_tmax=REAL(p%Tmax, wp) ) + ptfm_init=REAL(p%PtfmInit, wp), run_tmax=REAL(p%Tmax, wp), & + host_orientation=.TRUE. ) CALL delete_file( rst_deck ) IF (es /= CD_AGG_OK) THEN CALL SetErrStat( ErrID_Fatal, 'CableDyn mooring module: checkpoint rebuild: '//TRIM(em), & @@ -1383,6 +1398,12 @@ SUBROUTINE rebuild_from_checkpoint( t, u1, p, x, other, m, ErrStat, ErrMsg ) ErrStat2, ErrMsg2 ) CALL SetErrStat( ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName ) IF (ErrStat >= AbortErrLev) RETURN + ! a cable restrained in torsion first takes its committed state: moving its fairlead + ! frame from the static pose to the restart pose is bounded (pi/2) against the twist + ! it had at the checkpoint, not at t = 0 + CALL reload_cable_mirrors( Inst(id), m, x%states, REAL(t, wp), .TRUE., koff, ErrStat2, ErrMsg2 ) + CALL SetErrStat( ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName ) + IF (ErrStat >= AbortErrLev) RETURN CALL CD_AGG_UpdateStates_Moving( Inst(id)%agg, Inst(id)%ws_pos, Inst(id)%ws_vel, Inst(id)%ws_acc, es, em, & orientation=Inst(id)%ws_orient, angular_velocity=Inst(id)%ws_omega, & angular_acceleration=Inst(id)%ws_alpha ) @@ -2760,9 +2781,11 @@ SUBROUTINE CD_InitVars(Vars, u, p, x, y, m, inst_, Linearize, ErrStat, ErrMsg) DO ic = 1, inst_%agg%ncable csz = CD_HFMF_MirrorSize( inst_%agg%cables(ic) ) IF (csz <= 0) CYCLE ! uninitialised cable contributes no states - ! free DOFs; mirror = [v_free; q_free; a_free] then the friction anchors (if any) + ! free DOFs; mirror = [v_free; q_free; a_free] then the friction anchors, the + ! force-blend state and the torsion state (if any) nf = (csz - CD_HFMF_FrictionMirrorSize( inst_%agg%cables(ic) ) - & - CD_HFMF_ForceMirrorSize( inst_%agg%cables(ic) ))/3 + CD_HFMF_ForceMirrorSize( inst_%agg%cables(ic) ) - & + CD_HFMF_TorsionMirrorSize( inst_%agg%cables(ic) ))/3 LinStr = 'Cable '//TRIM(Num2LStr(ic)) ! Build the per-DOF linearization names in an explicit pre-allocated loop, NOT an ! inline implied-do array constructor: an impure function (Num2LStr) evaluated inside @@ -2794,8 +2817,9 @@ SUBROUTINE CD_InitVars(Vars, u, p, x, y, m, inst_, Linearize, ErrStat, ErrMsg) iAry=koff + 2*nf + 1, Num=nf, Perturb=0.1_R8Ki, & LinNames=CblLinAcc ) DEALLOCATE (CblLinVel, CblLinPos, CblLinAcc) - ! stick-slip friction anchors (x, y per node) and the force-blend committed force - ! (flag + force) after the acceleration block: coverage-only, like the acceleration block + ! stick-slip friction anchors (x, y per node), the force-blend committed force + ! (flag + force) and the torsion state (Theta, Phi, end frames) after the acceleration + ! block: coverage-only, like the acceleration block IF (csz > 3*nf) THEN ALLOCATE (CblLinVel(csz - 3*nf), STAT=ErrStat2) IF (ErrStat2 /= 0) THEN @@ -3137,27 +3161,8 @@ SUBROUTINE reload_interiors_ary(inst_, m, states, t_clock, ErrStat, ErrMsg) END BLOCK END IF END DO - koff = 0 - IF (inst_%nlines > 0) koff = m%LineStateIsN(inst_%nlines) - DO ic = 1, inst_%agg%ncable - csz = CD_HFMF_MirrorSize( inst_%agg%cables(ic) ) - IF (csz <= 0) CYCLE - IF (koff + csz > SIZE(states)) THEN - CALL SetErrStat( ErrID_Fatal, 'CableDyn mooring module: cable '//TRIM(Num2LStr(ic))// & - ' mirror extends past the state vector.', ErrStat, ErrMsg, RoutineName ) - RETURN - END IF - IF (ALLOCATED(inst_%ws_cbuf)) THEN - IF (SIZE(inst_%ws_cbuf) /= csz) DEALLOCATE (inst_%ws_cbuf) - END IF - IF (.NOT. ALLOCATED(inst_%ws_cbuf)) ALLOCATE (inst_%ws_cbuf(csz)) - inst_%ws_cbuf = REAL(states(koff + 1:koff + csz), wp) - CALL CD_HFMF_UnpackMirror( inst_%agg%cables(ic), inst_%ws_cbuf, t_clock, es, em ) - IF (es /= CD_HFMF_OK) THEN - CALL SetErrStat( ErrID_Fatal, TRIM(em), ErrStat, ErrMsg, RoutineName ); RETURN - END IF - koff = koff + csz - END DO + CALL reload_cable_mirrors( inst_, m, states, t_clock, .FALSE., koff, ErrStat, ErrMsg ) + IF (ErrStat >= AbortErrLev) RETURN ! coupled Rigid6 6-DOF body state: restore after the cable block, before the dynamic points ! (the body drives its attachment points, so the restored pose re-derives them next advance) IF (CD_AGG_HasRigid6( inst_%agg )) THEN @@ -3299,6 +3304,54 @@ SUBROUTINE reload_interiors_ary(inst_, m, states, t_clock, ErrStat, ErrMsg) END IF END SUBROUTINE reload_interiors_ary + SUBROUTINE reload_cable_mirrors(inst_, m, states, t_clock, torsion_only, koff, ErrStat, ErrMsg) + !! Unpack each cable's [v; q; a] free-DOF mirror (with its torsion tail) from the + !! checkpoint x%states layout. koff returns the offset past the cable block. With + !! torsion_only, only the cables restrained in torsion are unpacked: the checkpoint + !! rebuild restores their committed twist before it moves the fairlead to the restart + !! pose, whose preflight bounds the twist change against that committed value. + TYPE(CD_OF_Instance), INTENT(INOUT) :: inst_ + TYPE(CD_MiscVarType), INTENT(IN) :: m + REAL(R8Ki), INTENT(IN) :: states(:) + REAL(wp), INTENT(IN) :: t_clock + LOGICAL, INTENT(IN) :: torsion_only + INTEGER(IntKi), INTENT(OUT) :: koff + INTEGER(IntKi), INTENT(OUT) :: ErrStat + CHARACTER(*), INTENT(OUT) :: ErrMsg + + character(*), parameter :: RoutineName = 'CableDyn:reload_cable_mirrors' + INTEGER(IntKi) :: es, ic, csz + CHARACTER(512) :: em + + ErrStat = ErrID_None + ErrMsg = '' + koff = 0 + IF (inst_%nlines > 0) koff = m%LineStateIsN(inst_%nlines) + DO ic = 1, inst_%agg%ncable + csz = CD_HFMF_MirrorSize( inst_%agg%cables(ic) ) + IF (csz <= 0) CYCLE + IF (koff + csz > SIZE(states)) THEN + CALL SetErrStat( ErrID_Fatal, 'CableDyn mooring module: cable '//TRIM(Num2LStr(ic))// & + ' mirror extends past the state vector.', ErrStat, ErrMsg, RoutineName ) + RETURN + END IF + IF (torsion_only .AND. .NOT. inst_%agg%cables(ic)%line%torsion%active) THEN + koff = koff + csz + CYCLE + END IF + IF (ALLOCATED(inst_%ws_cbuf)) THEN + IF (SIZE(inst_%ws_cbuf) /= csz) DEALLOCATE (inst_%ws_cbuf) + END IF + IF (.NOT. ALLOCATED(inst_%ws_cbuf)) ALLOCATE (inst_%ws_cbuf(csz)) + inst_%ws_cbuf = REAL(states(koff + 1:koff + csz), wp) + CALL CD_HFMF_UnpackMirror( inst_%agg%cables(ic), inst_%ws_cbuf, t_clock, es, em ) + IF (es /= CD_HFMF_OK) THEN + CALL SetErrStat( ErrID_Fatal, TRIM(em), ErrStat, ErrMsg, RoutineName ); RETURN + END IF + koff = koff + csz + END DO + END SUBROUTINE reload_cable_mirrors + SUBROUTINE pack_state_mirror(inst_, m, x, ErrStat, ErrMsg) TYPE(CD_OF_Instance), INTENT(INOUT) :: inst_ TYPE(CD_MiscVarType), INTENT(IN) :: m diff --git a/tests/test_coupled_torsion.f90 b/tests/test_coupled_torsion.f90 new file mode 100644 index 00000000..fcfe2fe0 --- /dev/null +++ b/tests/test_coupled_torsion.f90 @@ -0,0 +1,509 @@ +! File: tests/test_coupled_torsion.f90 +! SPDX-License-Identifier: Apache-2.0 +! Copyright (c) 2026 Jae Hoon Seo, SMI Lab, Inha University +PROGRAM test_coupled_torsion + !! Condensed torsion of a finite-EI line on the coupled OpenFAST route: the aggregate surface + !! the OpenFAST and FAST.Farm shells drive, built with host_orientation. The line is the + !! straight 100 m neutral line of test_torsion_deck (GJ 5e4 N m^2, both ends clamped and + !! restrained in torsion, no pretwist), its End A on the platform fairlead (0, 0, -50) and + !! End B on a fixed anchor. Rolling the platform by phi about the line axis (+x) twists the + !! line by -phi: Twist1 = -phi and Torq = GJ (-phi) / L, with no torsional inertia. + !! 1. feedthrough: a non-stepping update with a rolled orientation gives that twist and + !! torque, and the fairlead moment is the restoring torque about the line axis; + !! 2. march: the platform rolls at 60 deg/s; every step gives Twist1 = -phi(t) and the + !! quasi-static torque (the coupled twin of the standalone vessel-roll gate), and the + !! single-cable entry driven with the same calls gives the same values bit for bit; + !! 3. unwrapping: 1.5 turns of roll in 18 deg steps, with no 2 pi slip; + !! 4. rewind: snapshot, step, restore and the same step again are bit-identical; + !! 5. a non-stepping turn of more than pi/2 fails by name and leaves the state unchanged; + !! 6. ptfm_init: an initial platform yaw over a vertical line hanging under the fairlead + !! (End A on the yaw axis) gives the static twist +yaw (a turn of -yaw about the line + !! direction A to B, -z); + !! 7. restart: the shell's checkpoint recipe (rebuild, torsion mirror first, coupled + !! kinematics, full mirror) after 150 deg of roll continues bit-identically; without the + !! torsion mirror first the coupled update is refused (the pi/2 bound); + !! 8. FAST.Farm: the vertical torsion line under Turbine2 with a farm_ptfm_init yaw gives + !! the static twist and follows that turbine's yaw. + USE CableDyn_Precision, ONLY: wp + USE CableDyn_DeckDriver, ONLY: CD_Init_Deck_HermiteCable, CD_DECKDRV_OK + 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_Snapshot, CD_AGG_Restore, & + CD_AGG_EvalChannel, CD_AGG_End, CD_AGG_OK + USE CableDyn_OpenFAST_HermiteFMF, ONLY: CD_HFMF_ModuleType, CD_HFMF_UpdateStates, CD_HFMF_CalcOutput, & + CD_HFMF_MirrorSize, CD_HFMF_PackMirror, CD_HFMF_UnpackMirror, & + CD_HFMF_End, CD_HFMF_OK + USE, INTRINSIC :: IEEE_ARITHMETIC, ONLY: IEEE_IS_FINITE + IMPLICIT NONE + + REAL(wp), PARAMETER :: PI = 3.14159265358979323846_wp, RHOW = 1025.0_wp + REAL(wp), PARAMETER :: GJ = 5.0e4_wp, L = 100.0_wp, DT = 0.05_wp, DEG = PI/180.0_wp + INTEGER :: n_fail = 0 + CHARACTER(160) :: neutral_type + + ! neutral 0.2 m section: mass = rhoW pi d^2 / 4; EA 1e7, EI 1e6, GAs 1e8, GJ 5e4 + 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.0 0.0 0.0 0.0 0.0' + + CALL check_feedthrough() + CALL check_march() + CALL check_unwrap() + CALL check_rewind() + CALL check_large_turn_refused() + CALL check_ptfm_init() + CALL check_restart() + CALL check_farm() + IF (n_fail > 0) THEN + WRITE (*, '(A,I0,A)') 'FAIL: ', n_fail, ' coupled torsion check(s) failed' + ERROR STOP 1 + END IF + WRITE (*, '(A)') 'PASS: coupled torsion (feedthrough, march, unwrapping, rewind, refusal, PtfmInit, '// & + 'restart, FAST.Farm)' + +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, point_a, vertical, anchor_x) + !! The straight neutral torsion line, End A on point_a, outputs Torq1N1, Torq1N41, Twist1: + !! along +x from (0, 0, -50) to (100, 0, -50), or with vertical from (0, 0, -20) down to + !! (anchor_x, 0, -120) (anchor_x: the farm-global x of the turbine the line hangs under). + CHARACTER(*), INTENT(IN) :: path, point_a + LOGICAL, INTENT(IN), OPTIONAL :: vertical + REAL(wp), INTENT(IN), OPTIONAL :: anchor_x + INTEGER :: u + LOGICAL :: vert + REAL(wp) :: ax + CHARACTER(48) :: anchor + vert = .FALSE. + IF (PRESENT(vertical)) vert = vertical + ax = 0.0_wp + IF (PRESENT(anchor_x)) ax = anchor_x + anchor = '2 Fixed 100.0 0.0 -50.0 0 0 0 0' + IF (vert) WRITE (anchor, '(A,F8.1,A)') '2 Fixed ', ax, ' 0.0 -120.0 0 0 0 0' + OPEN (NEWUNIT=u, FILE=path, STATUS='REPLACE', ACTION='WRITE') + WRITE (u, '(A)') 'coupled 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) + 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) (-)' + IF (vert) THEN + WRITE (u, '(A)') '1 '//point_a//' 0.0 0.0 -20.0 0 0 0 0' + ELSE + WRITE (u, '(A)') '1 '//point_a//' 0.0 0.0 -50.0 0 0 0 0' + END IF + WRITE (u, '(A)') TRIM(anchor) + 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 100.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 (vert) THEN + WRITE (u, '(A)') '1 A Rigid 0 0 -1 Rigid 1 0 0 0' + WRITE (u, '(A)') '1 B Rigid 0 0 -1 Rigid 1 0 0 0' + ELSE + 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 0' + END IF + 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)') 'Torq1N1' + WRITE (u, '(A)') 'Torq1N41' + WRITE (u, '(A)') 'Twist1' + WRITE (u, '(A)') '--- END ---' + CLOSE (u) + END SUBROUTINE write_deck + + 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 + + FUNCTION yaw_dcm(psi) RESULT(r) + !! OpenFAST mesh orientation (global to local) of a yaw psi about +z. + REAL(wp), INTENT(IN) :: psi + REAL(wp) :: r(3, 3) + r = 0.0_wp + r(3, 3) = 1.0_wp + r(1, 1) = COS(psi) + r(1, 2) = SIN(psi) + r(2, 1) = -SIN(psi) + r(2, 2) = COS(psi) + END FUNCTION yaw_dcm + + SUBROUTINE channels(agg, torq_a, torq_b, twist) + TYPE(CD_AGG_ModuleType), INTENT(IN) :: 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 channels + + SUBROUTINE init_agg(agg, path, ok) + TYPE(CD_AGG_ModuleType), INTENT(INOUT) :: agg + CHARACTER(*), INTENT(IN) :: path + LOGICAL, INTENT(OUT) :: ok + INTEGER :: es + CHARACTER(512) :: em + CALL CD_AGG_Init_From_Deck(agg, path, DT, es, em, host_orientation=.TRUE.) + ok = es == CD_AGG_OK + CALL require(ok, 'coupled torsion deck builds on the aggregate: '//TRIM(em)) + IF (ok) THEN + ok = agg%ncable == 1 .AND. CD_AGG_NMovingPoints(agg, es, em) == 1 + CALL require(ok, 'the deck is one coupled cable with one moving point') + END IF + END SUBROUTINE init_agg + + ! ------------------------------------------------------------------------------------------ + SUBROUTINE check_feedthrough() + 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) + REAL(wp) :: ta, tb, tw, phi, m_ref + INTEGER :: es + LOGICAL :: ok + CHARACTER(512) :: em + CALL write_deck('ctors_feed.dat', 'Coupled') + CALL init_agg(agg, 'ctors_feed.dat', ok) + IF (.NOT. ok) RETURN + CALL channels(agg, ta, tb, tw) + CALL require(ABS(ta) <= 1.0e-6_wp .AND. ABS(tw) <= 1.0e-9_wp, '1: no pretwist, no torque at rest') + CALL CD_AGG_GetMovingPointMesh(agg, pos, vel, acc, load, es, em, orientation=orient, moment=moment) + phi = 20.0_wp*DEG + orient(:, :, 1) = roll_dcm(phi) + CALL CD_AGG_UpdateStates_Moving(agg, pos, vel, acc, es, em, orientation=orient) + CALL require(es == CD_AGG_OK, '1: a rolled orientation is accepted: '//TRIM(em)) + CALL CD_AGG_CalcOutput(agg, es, em) + CALL channels(agg, ta, tb, tw) + m_ref = GJ*(-phi)/L + WRITE (*, '(A,3ES15.7,A,ES15.7)') '1 feedthrough: Torq A/B, Twist ', ta, tb, tw, '; ref torque ', m_ref + CALL require(ABS(tw + 20.0_wp) <= 1.0e-6_wp, '1: Twist1 = -roll') + CALL require(ABS(ta - m_ref) <= 1.0e-6_wp*ABS(m_ref) .AND. ABS(tb - m_ref) <= 1.0e-6_wp*ABS(m_ref), & + '1: Torq = GJ (-roll) / L at both ends') + CALL CD_AGG_GetMovingPointMesh(agg, pos, vel, acc, load, es, em, moment=moment) + WRITE (*, '(A,3ES15.7)') '1 feedthrough: fairlead moment ', moment(:, 1) + CALL require(ABS(ABS(moment(1, 1)) - ABS(m_ref)) <= 1.0e-6_wp*ABS(m_ref), & + '1: the fairlead moment about the line axis is the torque') + CALL require(moment(1, 1)*phi < 0.0_wp, '1: the moment on the platform resists its roll') + CALL require(MAX(ABS(moment(2, 1)), ABS(moment(3, 1))) <= 1.0e-6_wp*ABS(m_ref), & + '1: a straight line returns no bending moment') + CALL CD_AGG_End(agg, es, em) + END SUBROUTINE check_feedthrough + + ! ------------------------------------------------------------------------------------------ + SUBROUTINE check_march() + !! 60 deg/s roll for 10 steps; the single-cable entry driven with the same calls must match. + REAL(wp), PARAMETER :: RATE = 60.0_wp*DEG + TYPE(CD_AGG_ModuleType) :: agg + TYPE(CD_HFMF_ModuleType) :: cab + REAL(wp) :: pos(3, 1), vel(3, 1), acc(3, 1), load(3, 1), moment(3, 1), orient(3, 3, 1) + REAL(wp) :: omega(3, 1), alpha(3, 1), ta, tb, tw, phi, terr, werr, derr + REAL(wp) :: f_cab(3), m_cab(3) + INTEGER :: es, ni, k, node + LOGICAL :: ok, cv, st + CHARACTER(512) :: em + CALL write_deck('ctors_march.dat', 'Coupled') + CALL init_agg(agg, 'ctors_march.dat', ok) + IF (.NOT. ok) RETURN + CALL CD_Init_Deck_HermiteCable('ctors_march.dat', DT, cab, node, es, em, host_orientation=.TRUE.) + CALL require(es == CD_DECKDRV_OK, '2: the single-cable entry builds: '//TRIM(em)) + IF (es /= CD_DECKDRV_OK) RETURN + 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 + terr = 0.0_wp + werr = 0.0_wp + derr = 0.0_wp + DO k = 1, 10 + phi = RATE*DT*k + orient(:, :, 1) = roll_dcm(phi) + 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, '2: rolling step converges: '//TRIM(em)) + IF (es /= CD_AGG_OK) EXIT + CALL CD_AGG_CalcOutput(agg, es, em) + CALL channels(agg, ta, tb, tw) + werr = MAX(werr, ABS(tw + phi/DEG)) + terr = MAX(terr, ABS(ta - GJ*(-phi)/L), ABS(tb - ta)) + CALL CD_HFMF_UpdateStates(cab, pos(:, 1), vel(:, 1), acc(:, 1), es, em, u_orientation=orient(:, :, 1), & + u_angular_velocity=omega(:, 1), u_angular_acceleration=alpha(:, 1)) + CALL require(es == CD_HFMF_OK, '2: the single cable steps: '//TRIM(em)) + CALL CD_AGG_GetMovingPointMesh(agg, pos, vel, acc, load, es, em, moment=moment) + CALL CD_HFMF_CalcOutput(cab, f_cab, es, em, y_moment=m_cab) + derr = MAX(derr, nan_max_abs(agg%cables(1)%line%q - cab%line%q), nan_max_abs(load(:, 1) - f_cab), & + nan_max_abs(moment(:, 1) - m_cab), & + ABS(agg%cables(1)%line%torsion%theta - cab%line%torsion%theta)) + END DO + WRITE (*, '(A,ES10.3,A,ES10.3,A,ES10.3)') '2 march: Twist1 error ', werr, ' deg, torque error ', terr, & + ' N m; aggregate vs single cable ', derr + CALL require(werr <= 1.0e-6_wp, '2: Twist1 = -roll(t) at every step') + CALL require(terr <= 1.0e-6_wp*GJ, '2: Torq = GJ Twist / L at both ends at every step (quasi-static)') + CALL require(derr <= 0.0_wp, '2: the aggregate column equals the single coupled cable bit for bit') + CALL CD_HFMF_End(cab) + CALL CD_AGG_End(agg, es, em) + END SUBROUTINE check_march + + ! ------------------------------------------------------------------------------------------ + SUBROUTINE check_unwrap() + !! 1.5 turns of roll in 18 deg steps (30 steps). + TYPE(CD_AGG_ModuleType) :: agg + 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) :: ta, tb, tw, phi, werr + INTEGER :: es, ni, k + LOGICAL :: ok, cv, st + CHARACTER(512) :: em + CALL write_deck('ctors_unwrap.dat', 'Coupled') + CALL init_agg(agg, 'ctors_unwrap.dat', ok) + IF (.NOT. ok) RETURN + CALL CD_AGG_GetMovingPointMesh(agg, pos, vel, acc, load, es, em, orientation=orient) + omega = 0.0_wp + alpha = 0.0_wp + omega(1, 1) = 18.0_wp*DEG/DT + werr = 0.0_wp + DO k = 1, 30 + phi = 18.0_wp*DEG*k + orient(:, :, 1) = roll_dcm(phi) + 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, '3: 18 deg roll step converges: '//TRIM(em)) + IF (es /= CD_AGG_OK) EXIT + CALL CD_AGG_CalcOutput(agg, es, em) + CALL channels(agg, ta, tb, tw) + werr = MAX(werr, ABS(tw + 18.0_wp*k), ABS(ta - GJ*(-phi)/L)/GJ) + END DO + WRITE (*, '(A,F9.3,A,ES10.3)') '3 unwrap: final Twist1 ', tw, ' deg (ref -540), max error ', werr + CALL require(werr <= 1.0e-6_wp, '3: 1.5 turns of roll unwrap without a 2 pi slip') + CALL CD_AGG_End(agg, es, em) + END SUBROUTINE check_unwrap + + ! ------------------------------------------------------------------------------------------ + SUBROUTINE check_rewind() + TYPE(CD_AGG_ModuleType) :: agg + 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) :: moment(3, 1), m1(3), m2(3), th1, th2, tw1, tw2, ta, tb + REAL(wp), ALLOCATABLE :: qa(:), qb(:) + INTEGER :: es, ni + LOGICAL :: ok, cv, st + CHARACTER(512) :: em + CALL write_deck('ctors_rewind.dat', 'Coupled') + CALL init_agg(agg, 'ctors_rewind.dat', ok) + IF (.NOT. ok) RETURN + CALL CD_AGG_GetMovingPointMesh(agg, pos, vel, acc, load, es, em, orientation=orient) + omega = 0.0_wp + alpha = 0.0_wp + omega(1, 1) = 30.0_wp*DEG/DT + orient(:, :, 1) = roll_dcm(30.0_wp*DEG) + CALL CD_AGG_Snapshot(agg, es, em) + CALL require(es == CD_AGG_OK, '4: snapshot: '//TRIM(em)) + 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, '4: first step: '//TRIM(em)) + CALL CD_AGG_CalcOutput(agg, es, em) + CALL CD_AGG_GetMovingPointMesh(agg, pos, vel, acc, load, es, em, moment=moment) + qa = agg%cables(1)%line%q + m1 = moment(:, 1) + th1 = agg%cables(1)%line%torsion%theta + CALL channels(agg, ta, tb, tw1) + CALL CD_AGG_Restore(agg, es, em) + CALL require(es == CD_AGG_OK, '4: restore: '//TRIM(em)) + CALL require(ABS(agg%cables(1)%line%torsion%theta) <= 1.0e-12_wp, '4: restore rewinds the twist') + 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, '4: repeated step: '//TRIM(em)) + CALL CD_AGG_CalcOutput(agg, es, em) + CALL CD_AGG_GetMovingPointMesh(agg, pos, vel, acc, load, es, em, moment=moment) + qb = agg%cables(1)%line%q + m2 = moment(:, 1) + th2 = agg%cables(1)%line%torsion%theta + CALL channels(agg, ta, tb, tw2) + CALL require(nan_max_abs(qa - qb) <= 0.0_wp .AND. nan_max_abs(m1 - m2) <= 0.0_wp .AND. & + ABS(th1 - th2) <= 0.0_wp .AND. ABS(tw1 - tw2) <= 0.0_wp, & + '4: snapshot, step, restore, step is bit-identical (state, twist, torque moment)') + CALL CD_AGG_End(agg, es, em) + END SUBROUTINE check_rewind + + ! ------------------------------------------------------------------------------------------ + SUBROUTINE check_large_turn_refused() + TYPE(CD_AGG_ModuleType) :: agg + REAL(wp) :: pos(3, 1), vel(3, 1), acc(3, 1), load(3, 1), orient(3, 3, 1) + REAL(wp) :: th0, ta, tb, tw + REAL(wp), ALLOCATABLE :: q0(:) + INTEGER :: es + LOGICAL :: ok + CHARACTER(512) :: em + CALL write_deck('ctors_large.dat', 'Coupled') + CALL init_agg(agg, 'ctors_large.dat', ok) + IF (.NOT. ok) RETURN + CALL CD_AGG_GetMovingPointMesh(agg, pos, vel, acc, load, es, em, orientation=orient) + q0 = agg%cables(1)%line%q + th0 = agg%cables(1)%line%torsion%theta + orient(:, :, 1) = roll_dcm(100.0_wp*DEG) + CALL CD_AGG_UpdateStates_Moving(agg, pos, vel, acc, es, em, orientation=orient) + WRITE (*, '(A,A)') '5 large turn: ', TRIM(em) + CALL require(es /= CD_AGG_OK .AND. INDEX(em, 'pi/2') > 0, '5: a 100 deg non-stepping turn is refused by name') + CALL require(nan_max_abs(agg%cables(1)%line%q - q0) <= 0.0_wp .AND. & + ABS(agg%cables(1)%line%torsion%theta - th0) <= 0.0_wp, '5: the refused update changes no state') + CALL channels(agg, ta, tb, tw) + CALL require(ABS(tw) <= 1.0e-9_wp, '5: the twist is still zero after the refusal') + CALL CD_AGG_End(agg, es, em) + END SUBROUTINE check_large_turn_refused + + ! ------------------------------------------------------------------------------------------ + SUBROUTINE check_ptfm_init() + !! ptfm_init yaws the platform about the vertical axis through the origin, which carries the + !! vertical line's fairlead (0, 0, -20) onto itself: only its frame turns. + TYPE(CD_AGG_ModuleType) :: agg + REAL(wp) :: ta, tb, tw, psi + INTEGER :: es + CHARACTER(512) :: em + psi = 15.0_wp*DEG + CALL write_deck('ctors_ptfm.dat', 'Coupled', vertical=.TRUE.) + CALL CD_AGG_Init_From_Deck(agg, 'ctors_ptfm.dat', DT, es, em, ptfm_init=[0.0_wp, 0.0_wp, 0.0_wp, 0.0_wp, & + 0.0_wp, psi], host_orientation=.TRUE.) + CALL require(es == CD_AGG_OK, '6: the torsion deck builds at a yawed initial platform pose: '//TRIM(em)) + IF (es /= CD_AGG_OK) RETURN + CALL channels(agg, ta, tb, tw) + WRITE (*, '(A,F10.5,A,ES15.7,A,ES15.7)') '6 PtfmInit yaw 15 deg: Twist1 ', tw, ', Torq ', ta, '; ref ', & + GJ*psi/L + CALL require(ABS(tw - 15.0_wp) <= 1.0e-5_wp, '6: the static twist is +PtfmInit yaw') + CALL require(ABS(ta - GJ*psi/L) <= 1.0e-5_wp*GJ*psi/L, '6: the static torque is GJ yaw / L') + CALL CD_AGG_End(agg, es, em) + END SUBROUTINE check_ptfm_init + + ! ------------------------------------------------------------------------------------------ + SUBROUTINE check_restart() + !! Reference A rolls 150 deg in 15 deg steps, then 4 more steps. B is rebuilt from A's + !! mirror at 150 deg with the shell's recipe and steps the same 4 steps. + TYPE(CD_AGG_ModuleType) :: a, b + 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) :: ta, tb, twa, twb, tqa, tqb, phi, t + REAL(wp), ALLOCATABLE :: mirror(:) + INTEGER :: es, ni, k, nm + LOGICAL :: ok, cv, st, same + CHARACTER(512) :: em + CALL write_deck('ctors_restart.dat', 'Coupled') + CALL init_agg(a, 'ctors_restart.dat', ok) + IF (.NOT. ok) RETURN + CALL CD_AGG_GetMovingPointMesh(a, pos, vel, acc, load, es, em, orientation=orient) + omega = 0.0_wp + alpha = 0.0_wp + omega(1, 1) = 15.0_wp*DEG/DT + DO k = 1, 10 + orient(:, :, 1) = roll_dcm(15.0_wp*DEG*k) + 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, '7: reference roll step: '//TRIM(em)) + IF (es /= CD_AGG_OK) RETURN + END DO + t = DT*10 + nm = CD_HFMF_MirrorSize(a%cables(1)) + ALLOCATE (mirror(nm)) + CALL CD_HFMF_PackMirror(a%cables(1), mirror, es, em) + CALL require(es == CD_HFMF_OK, '7: pack the checkpoint mirror: '//TRIM(em)) + ! the previous order (coupled kinematics before the mirror) is refused by the pi/2 bound + CALL init_agg(b, 'ctors_restart.dat', ok) + IF (.NOT. ok) RETURN + CALL CD_AGG_UpdateStates_Moving(b, pos, vel, acc, es, em, orientation=orient, angular_velocity=omega, & + angular_acceleration=alpha) + CALL require(es /= CD_AGG_OK .AND. INDEX(em, 'pi/2') > 0, & + '7: kinematics at 150 deg before the torsion mirror are refused (the old rebuild order)') + CALL CD_AGG_End(b, es, em) + ! the shell's recipe: torsion mirror, coupled kinematics, full mirror + CALL init_agg(b, 'ctors_restart.dat', ok) + IF (.NOT. ok) RETURN + CALL CD_HFMF_UnpackMirror(b%cables(1), mirror, t, es, em) + CALL require(es == CD_HFMF_OK, '7: torsion mirror first: '//TRIM(em)) + CALL CD_AGG_UpdateStates_Moving(b, pos, vel, acc, es, em, orientation=orient, angular_velocity=omega, & + angular_acceleration=alpha) + CALL require(es == CD_AGG_OK, '7: coupled kinematics at the restart pose: '//TRIM(em)) + CALL CD_HFMF_UnpackMirror(b%cables(1), mirror, t, es, em) + CALL require(es == CD_HFMF_OK, '7: full mirror: '//TRIM(em)) + same = .TRUE. + DO k = 11, 14 + phi = 15.0_wp*DEG*k + orient(:, :, 1) = roll_dcm(phi) + 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, '7: reference continues: '//TRIM(em)) + CALL CD_AGG_Step_Moving(b, 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, '7: restarted run continues: '//TRIM(em)) + CALL channels(a, tqa, ta, twa) + CALL channels(b, tqb, tb, twb) + same = same .AND. nan_max_abs(a%cables(1)%line%q - b%cables(1)%line%q) <= 0.0_wp .AND. & + ABS(tqa - tqb) <= 0.0_wp .AND. ABS(twa - twb) <= 0.0_wp + END DO + WRITE (*, '(A,F10.4,A,F10.4)') '7 restart: Twist1 reference ', twa, ', restarted ', twb + CALL require(same, '7: the restarted run continues bit-identically through the twist') + CALL require(ABS(twa + 210.0_wp) <= 1.0e-6_wp, '7: the continued twist is -210 deg') + CALL CD_AGG_End(a, es, em) + CALL CD_AGG_End(b, es, em) + END SUBROUTINE check_restart + + ! ------------------------------------------------------------------------------------------ + SUBROUTINE check_farm() + !! Two turbines 500 m apart; the vertical torsion line hangs under Turbine2. + TYPE(CD_AGG_ModuleType) :: agg + REAL(wp) :: ref_pos(3, 2), farm_init(6, 2), ta, tb, tw, psi + REAL(wp), ALLOCATABLE :: pos(:, :), vel(:, :), acc(:, :), load(:, :), orient(:, :, :) + INTEGER :: es, ncp + CHARACTER(512) :: em + psi = 10.0_wp*DEG + CALL write_deck('ctors_farm.dat', 'Turbine2', vertical=.TRUE., anchor_x=500.0_wp) + ref_pos = 0.0_wp + ref_pos(1, 2) = 500.0_wp + farm_init = 0.0_wp + farm_init(6, 2) = psi + CALL CD_AGG_Init_From_Deck(agg, 'ctors_farm.dat', DT, es, em, n_turbines=2, turbine_ref_pos=ref_pos, & + farm_ptfm_init=farm_init, forbid_deck_ambient=.TRUE., host_orientation=.TRUE.) + CALL require(es == CD_AGG_OK, '8: the farm deck with a torsion line on Turbine2 builds: '//TRIM(em)) + IF (es /= CD_AGG_OK) RETURN + CALL channels(agg, ta, tb, tw) + WRITE (*, '(A,F10.5,A,ES15.7)') '8 farm: Turbine2 yaw 10 deg: Twist1 ', tw, ', Torq ', ta + CALL require(ABS(tw - 10.0_wp) <= 1.0e-5_wp, '8: the static twist is the yaw of Turbine2') + CALL require(ABS(ta - GJ*psi/L) <= 1.0e-5_wp*GJ*psi/L, '8: the static torque is GJ yaw / L') + ncp = CD_AGG_NMovingPoints(agg, es, em) + ALLOCATE (pos(3, ncp), vel(3, ncp), acc(3, ncp), load(3, ncp), orient(3, 3, ncp)) + CALL CD_AGG_GetMovingPointMesh(agg, pos, vel, acc, load, es, em, orientation=orient) + orient(:, :, ncp) = yaw_dcm(psi + 20.0_wp*DEG) + CALL CD_AGG_UpdateStates_Moving(agg, pos, vel, acc, es, em, orientation=orient) + CALL require(es == CD_AGG_OK, '8: Turbine2 turns its fairlead: '//TRIM(em)) + CALL channels(agg, ta, tb, tw) + CALL require(ABS(tw - 30.0_wp) <= 1.0e-5_wp, '8: the twist follows Turbine2 to 30 deg') + CALL CD_AGG_End(agg, es, em) + END SUBROUTINE check_farm + +END PROGRAM test_coupled_torsion diff --git a/tests/test_torsion_deck.f90 b/tests/test_torsion_deck.f90 index 37080d7c..428fa7ac 100644 --- a/tests/test_torsion_deck.f90 +++ b/tests/test_torsion_deck.f90 @@ -949,13 +949,39 @@ 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 CALL CD_Init_Deck_Aggregate('tdeck_e12.dat', 0.1_wp, agg, es, em) - CALL require(es /= CD_DECKDRV_OK .AND. INDEX(em, 'nor in coupled OpenFAST or FAST.Farm runs') > 0, & - 'the coupled aggregate refuses torsion by name (got: '//TRIM(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)//')') CALL CD_End_Deck_Aggregate(agg) CALL CD_Init_Deck_HermiteCable('tdeck_e12.dat', 0.1_wp, cab, node, es, em) - CALL require(es /= CD_DECKDRV_OK .AND. INDEX(em, 'not yet supported in coupled OpenFAST runs') > 0, & - 'the coupled single-cable entry refuses torsion by name (got: '//TRIM(em)//')') + CALL require(es /= CD_DECKDRV_OK .AND. INDEX(em, 'needs a host that turns its fairlead frame') > 0, & + 'a single-cable caller without orientations refuses torsion by name (got: '//TRIM(em)//')') + CALL CD_HFMF_End(cab) + CALL CD_Init_Deck_Aggregate('tdeck_e12.dat', 0.1_wp, agg, es, em, host_orientation=.TRUE.) + CALL require(es == CD_DECKDRV_OK, 'an orientation-passing host builds the coupled torsion line (got: '// & + TRIM(em)//')') + CALL CD_End_Deck_Aggregate(agg) + CALL CD_Init_Deck_HermiteCable('tdeck_e12.dat', 0.1_wp, cab, node, es, em, host_orientation=.TRUE.) + CALL require(es == CD_DECKDRV_OK, 'an orientation-passing host builds the single coupled torsion cable '// & + '(got: '//TRIM(em)//')') + CALL require(cab%line%torsion%active, 'the single coupled cable carries its torsion') + CALL CD_HFMF_End(cab) + ! a coupled run is always dynamic: the configuration blend is refused with torsion + CALL write_deck('tdeck_e15.dat', [neutral_type], no_rows, & + [CHARACTER(48) :: '1 Coupled 0.0 0.0 -50.0 0 0 0 0', '2 Fixed 100.0 0.0 -50.0 0 0 0 0'], & + [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(32) :: '0.1 dtM', 'False alpha_force_blend'], [CHARACTER(16) :: 'FairTen1']) + CALL CD_Init_Deck_Aggregate('tdeck_e15.dat', 0.1_wp, agg, es, em, host_orientation=.TRUE.) + CALL require(es /= CD_DECKDRV_OK .AND. INDEX(em, 'force-blended generalised-alpha') > 0, & + 'the coupled aggregate refuses torsion with the configuration blend (got: '//TRIM(em)//')') + CALL CD_End_Deck_Aggregate(agg) + CALL CD_Init_Deck_HermiteCable('tdeck_e15.dat', 0.1_wp, cab, node, es, em, host_orientation=.TRUE.) + CALL require(es /= CD_DECKDRV_OK .AND. INDEX(em, 'force-blended generalised-alpha') > 0, & + 'the coupled single cable refuses torsion with the configuration blend (got: '//TRIM(em)//')') CALL CD_HFMF_End(cab) CALL check_scope_refusals() ! the channel units of the torsion channels, as the range files label them