diff --git a/CHANGELOG.md b/CHANGELOG.md index 7200f2d4..03ce9a44 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,40 @@ All notable changes to CableDyn are recorded in this file. The format follows ### Added +- Finite-EI lines with two moving ends on the cubic-Hermite route: a line whose End B is a + `Coupled`/`Vessel` point (a cable shared by two floaters, a FAST.Farm shared line) is driven at + both ends standalone, in OpenFAST, FAST.Farm and the C API (End B on a moving column of its + own), with `END CONNECTIONS` and torsion at both ends (both end frames turn with their + parents) and every Hermite feature. A `Coupled` End B held at rest writes the `Fixed` End B's + files byte for byte; a symmetric cable whose ends move apart stays mirror-symmetric to 4e-11 m; + a rigidly translating line keeps its + end loads to 4e-5 N of 1.6e4 N; driving End B matches the reversed line driven at End A to + 1e-3 N, with a turning clamped End B to 2e-5 N and 4e-7 N m; equal rolls of both end frames + keep the torque to 3e-6 N m and opposite rolls change it by `GJ (2 phi)/L` to 5e-6 N m; a + FAST.Farm aggregate driven by prescribed turbine motions reports the standalone deck's end + tensions to 7e-3 N of 1.9e4 N; restarts are bit-identical. The compatibility (Cosserat) route + these decks ran on is retired: on four shared-line decks it failed to converge or reached a + compressive static state (-6.1e8 N), and the Hermite route runs all four. +- A finite-EI line between two objects on the standalone multibody march: End B on a Rigid6 + `Body` point or a rod end as well as End A, both ends driven by their objects and their end + forces, connection moments and torques returned to them, with `END CONNECTIONS` and torsion at + both ends (`bodyScheme monolithic`; the staggered scheme takes pinned ends). The monolithic step + re-steps such a cable at every outer iteration and couples the junction coordinates of its two + objects through its finite-difference end-to-end stiffness in one Newton matrix (on a stiff taut + cable between light bodies, dropping that coupling took 9.2 mean outer iterations and 300 step + halvings over 100 steps, against 3.9 and none); a pinned cable with one moving end is coupled at + the predictor whichever end that is, and an end on a fixed rod's end is the `Fixed` end there + (byte for byte). `bodyIC static` balances both objects on the cubic-Hermite cable, its passes + accelerated by Anderson mixing: a stiff (EI 1e6 N m^2) clamped cable between two unequal moored + bodies, out of their plane, converges in 8 passes, written in either direction, to the same + equilibrium. Two identical bodies stay mirror images to the output precision, a body joined to + an immobile body (1e15 kg) moves as on a `Fixed` End B to 8e-9, two free bodies keep the total + linear momentum to 3e-5 and the energy to 0.2 %, a cable twisted 90 deg returns equal and + opposite torques (`GJ Phi/L` at the start, their sum below 2e-10 N m), and a moored pair starts + and stays at rest. An End B on a `Free`/`Connect` point, a `Point3` buoy or a `Coupled`/`Vessel` + point stays refused there by name (this march drives no `Coupled` point), and so are, by name, + torsion at an End B on a rod end and a line restrained in torsion at a rod End A with a moving + End B, which no route of this build solves. - C API host rotations (ABI 1.3): `CableDyn_InitDeckRotating` initialises a handle whose host passes each coupled point's rotation (`CableDyn_UpdateRotations`: the global-to-body DCM and the angular velocity and acceleration) with every update and step, so a line restrained in @@ -78,7 +112,11 @@ All notable changes to CableDyn are recorded in this file. The format follows (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. + `vesselRAO` stays refused with the deck waves. A line between two moving points there takes the + roll columns of both ends, `Phi = Pretwist(B) − Pretwist(A) − roll(A) − roll(B)`: rolled + oppositely (a rigid roll about its axis) a line twisted 90 deg keeps its twist exactly, and rolled + equally it twists by twice the roll to 5e-7 deg, with `Torq = GJ Phi / L` at both ends to + 5e-6 N m. - 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 @@ -247,6 +285,21 @@ All notable changes to CableDyn are recorded in this file. The format follows 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. +- Standalone `TURBINES` decks read the `END CONNECTIONS` direction `Ez` and torsion normal `Nx` + of an end on a `Turbine` point in that turbine's axes, turned by its `PtfmInit` rotation at + the static start, as the FAST.Farm aggregate does (they were global). A deck whose turbines + start rotated and whose finite-EI lines carry end connections or torsion changes; on a clamped + line twisted 90 deg between turbines yawed +15 and -8 deg the standalone run now matches the + FAST.Farm aggregate to 8e-9 in every channel. Decks without a `PtfmInit` rotation, or without + end connections and torsion, are unchanged. +- Standalone `TURBINES` motion rows turn the `END CONNECTIONS` and torsion frames of a finite-EI + line end on a `Turbine` point with the row's rotation, angular velocity and acceleration (End A + and End B), as `vesselMotion` and the OpenFAST and FAST.Farm hosts do; they were held at their + start orientation while the end moved. A `TURBINES` deck whose rows rotate the turbines and whose + finite-EI lines carry end connections or torsion changes: a clamped line twisted 90 deg between + turbines that roll 10 deg in opposite senses over 1 s ends at 613.6 N m of torque (788.1 N m + before; the tensions change by under 5e-7) and matches the FAST.Farm aggregate to 3.4e-8 in every channel. + No example deck uses `TURBINES` rows; the examples 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 @@ -294,6 +347,13 @@ All notable changes to CableDyn are recorded in this file. The format follows ### Fixed +- A rod numbered as a body no longer joins the body's attachment points. A `RodA/B` end point + keeps its rod's id where a `Body` point keeps its body's, and the body's point list took + every point with its id: a rod end POINT row listed before the body's points became the body's + first point, and the list overran its allocation (also in 0.3.0). A free body on three legs with + a pinned arm rod numbered 1, its tether on an explicit `Rod1B` POINT listed first, now writes + the outputs of the same deck with the arm as rod 3 bit for bit; before, the arm turned 172 deg + in pitch, the body 1.06 deg, and a leg tension moved 3.0 kN in 1 s. - In OpenFAST, Free Rigid6 bodies and Free, Pinned and CoupledPinned rods started their first step from zero acceleration: the module restores its state mirror after the output call at `t = 0`, which marked the objects' accelerations as committed before the start accelerations @@ -328,6 +388,10 @@ All notable changes to CableDyn are recorded in this file. The format follows and buoyancy modules had no mass (with `nModes`, the first six frequencies of `lazy_wave_buoyancy_modules.dat` drop by 13 % to 29 %). The positions and translations of a line with a heading are written in the deck's axes, not the line's. +- A finite-EI line restrained in torsion whose bending-pinned End A is on a body or a rod is + refused on `bodyScheme staggered`, as a clamped End A is: that scheme passes cable ends as point + forces and held the torsion frame still while the body turned (a body could spin through +-180 + deg); `bodyScheme monolithic` turns the frame with the body. - A deck with a WaterKin elevation history (`WaveKinMod 1`) at `TMax = 0`, a check of the static start, reduces the record over its own length instead of failing for want of a positive `TMax`. diff --git a/CMakeLists.txt b/CMakeLists.txt index e10ad393..d414303a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1682,6 +1682,17 @@ if(Python3_Interpreter_FOUND) TIMEOUT 600 ENVIRONMENT "${_cabledyn_python_test_environment}") + # A rod numbered as a body is not one of the body's points: a Rod1B end POINT listed before + # the Body1 points gives the run of the same deck with the rod renumbered, bit for bit. + add_test(NAME body_rod_numbering + COMMAND ${Python3_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/tests/test_body_rod_numbering.py + --exe $ + --output ${CMAKE_BINARY_DIR}/body_rod_numbering) + set_tests_properties(body_rod_numbering PROPERTIES + LABELS "python;driver;integration;dynamic" + TIMEOUT 600 + ENVIRONMENT "${_cabledyn_python_test_environment}") + # Anchor uplift channels (AnchFz/AnchFH, TDPGrd): the analytic laid and suspended elastic # catenaries, the Point

F identity on every standalone route, and a surge that lifts the # anchor of a catenary (needs numpy). @@ -2182,6 +2193,16 @@ add_test(NAME parity_integration WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/parity_integration) set_tests_properties(parity_integration PROPERTIES LABELS "fortran;driver;integration;dynamic;openfast") +add_executable(test_two_moving_ends tests/test_two_moving_ends.f90) +target_link_libraries(test_two_moving_ends PRIVATE cabledyn_core) +add_test(NAME two_moving_ends COMMAND test_two_moving_ends) +set_tests_properties(two_moving_ends PROPERTIES LABELS "fortran;driver;integration;dynamic;openfast") + +add_executable(test_cable_between_bodies tests/test_cable_between_bodies.f90) +target_link_libraries(test_cable_between_bodies PRIVATE cabledyn_core) +add_test(NAME cable_between_bodies COMMAND test_cable_between_bodies) +set_tests_properties(cable_between_bodies PROPERTIES LABELS "fortran;driver;integration;dynamic;static") + add_executable(test_section_curvature tests/test_section_curvature.f90) target_link_libraries(test_section_curvature PRIVATE cabledyn_core) add_test(NAME section_curvature COMMAND test_section_curvature) @@ -2696,12 +2717,13 @@ cabledyn_msg_test(quiet_catenary ../../examples/chain_catenary_r3_100m.dat 0 "" cabledyn_msg_test(shared_line msg_shared_line.dat 1 "LINE 1 End B .NodeB, POINT 2, coupled. must be a Fixed .anchor. point;Workaround for this EI=0 line: split it into two lines that meet at a Connect point" "cannot be split") -# A finite-EI shared line cannot be split at a Connect point: that advice is not given. +# A finite-EI line between two Coupled points has both ends driven: neither the End B refusal nor +# the Connect-point split advice is given; as a static deck it asks for dtM and TMax. cabledyn_msg_test(shared_line_finite_ei msg_shared_line_finite_ei.dat 1 - "finite-EI LINE 1 End B .NodeB, POINT 2, coupled. must be a Fixed .anchor. point;A finite-EI line cannot be split at a Connect point either;anchor it on a Fixed point" - "Workaround") + "finite-EI section .EI>0. requires a dynamic deck with dtM and TMax" + "Workaround;must be a Fixed") cabledyn_msg_test(pliant_connect_end_b msg_pliant_connect_end_b.dat 1 - "finite-EI LINE 1 in a mixed-topology deck needs a Fixed End B;End B is POINT 2 .connect.;Anchor the cable on a Fixed point" + "finite-EI LINE 1 in a mixed-topology deck: End B is POINT 2 .connect.;is not supported on the multibody march;End the cable on a Fixed point" "") cabledyn_msg_test(mixed_current msg_mixed_current.dat 1 "the deck current OPTION is not supported for a standalone mixed EI=0/finite-EI deck;runs the mooring in STILL WATER;couple the deck to OpenFAST .CompMooring = 5. with SeaState" @@ -2908,7 +2930,8 @@ if(CMAKE_Fortran_COMPILER_ID STREQUAL "GNU") test_control_torsion test_endconn_spring test_torsion_coupling - test_torsion_one_end) + test_torsion_one_end + test_two_moving_ends) target_compile_options(${_cabledyn_exact_real_test} PRIVATE -Wno-compare-reals) endforeach() target_compile_options(test_openfast_aggregate PRIVATE diff --git a/doc/api_reference.md b/doc/api_reference.md index 2bfb0122..29c0e844 100644 --- a/doc/api_reference.md +++ b/doc/api_reference.md @@ -77,8 +77,8 @@ follow `CD_[Action]_[Object]`. ## Secondary Cosserat path -The rotation-DOF Cosserat rod path (CTest label `cosserat`) backs the finite-EI compatibility -route for lines with two moving ends. +The rotation-DOF Cosserat rod path (CTest label `cosserat`) is a separate, verified library path; +no deck route runs on it (a finite-EI line with two moving ends runs on the cubic-Hermite route). ```{list-table} :header-rows: 1 @@ -95,7 +95,7 @@ route for lines with two moving ends. * - `CableDyn_CosseratDynamic`, `CableDyn_CosseratEMC` - generalised-α dynamics and an energy-conserving integrator option * - `CableDyn_FiniteEIModel`, `CableDyn_FiniteEIStatic` - - the finite-EI compatibility-route model and grounded static equilibrium + - the Cosserat-path line model and its grounded static equilibrium ``` ## Hydrodynamics and contact diff --git a/doc/capabilities.rst b/doc/capabilities.rst index a4634a59..7493bdf7 100644 --- a/doc/capabilities.rst +++ b/doc/capabilities.rst @@ -62,8 +62,12 @@ Line and constitutive capability * - Finite-EI bending cable - Supported - production cubic-Hermite static/dynamic path for suspended and flat/structured - seabed-contact cables in standalone and OpenFAST-coupled use; the uncommon - two-moving-end standalone topology uses a separate compatibility solver + seabed-contact cables in standalone and OpenFAST-coupled use; a line between two moving + points (End B on a ``Coupled``/``Vessel`` point: a cable shared by two floaters, a + FAST.Farm shared line) has both ends driven, standalone, in OpenFAST, FAST.Farm and the C + API, with end connections and torsion at both ends; on the standalone multibody march + a line between two objects (both ends on Rigid6 bodies or rod ends) is driven by both + objects, coupled in its monolithic step and balanced in its static solve * - 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 @@ -116,14 +120,12 @@ Line and constitutive capability * - Discrete attachments (``ATTACHMENTS``: buoyancy modules, clumps) - Supported - lumped at nodes of a finite-EI cable, standalone and coupled, also on a line restrained in - torsion (they add no polar inertia to its twist); rejected on the two-moving-end - compatibility solver + torsion (they add no polar inertia to its twist) * - Bend stiffeners (``STIFFENERS``) - Supported with limits - tapered linear-elastic sleeve over a finite-EI line end, adding bending stiffness, mass, buoyancy and drag per element, standalone and coupled; nonlinear (moment–curvature) - materials and bend restrictors are not provided; rejected on the two-moving-end - compatibility solver + materials and bend restrictors are not provided * - Modal analysis (``nModes``) - Standalone only - natural frequencies and mode shapes of each line about its static equilibrium (all @@ -135,7 +137,7 @@ Line and constitutive capability - MoorDyn v2's synchronisation model on ``EI = 0`` lines and, as a distributed lift, on finite-EI cables of the Hermite and multibody marches (:ref:`theory-viv`), with the host's fluid field on the coupled routes and its state in the checkpoint; in-line VIV is - not provided; a finite-EI line with two moving ends refuses ``Cl > 0`` by name + not provided Loads and environment --------------------- diff --git a/doc/capi.rst b/doc/capi.rst index 75e5faae..3f582ec8 100644 --- a/doc/capi.rst +++ b/doc/capi.rst @@ -414,8 +414,9 @@ initialised. One ``x, y, z`` block for every host-driven point and nothing else: first the ``Coupled``/``Vessel`` points attached to an ``EI = 0`` line, in ``POINTS`` table order, then the fairlead (End A, which must be ``Coupled``/``Vessel``) of each finite-EI line, in - ``LINES`` table order. ``Fixed`` anchors, ``Free``/``Connect`` points, bodies and rods have - no block. + ``LINES`` table order, then the End B of each finite-EI line whose End B is also + ``Coupled``/``Vessel`` (a line between two moving points, driven at both ends), in ``LINES`` + table order. ``Fixed`` anchors, ``Free``/``Connect`` points, bodies and rods have no block. ``CableDyn_InitLine`` ``n_fixed`` entries. Entry ``k`` is the DOF ``fixed_dofs[k]``, in the order the caller @@ -1990,7 +1991,9 @@ allocatable data does. There is no serialisation of the state to a caller buffer The host drives the ``CD_C_POINT_COUPLED`` blocks. On the point route the blocks are the line-bound points of every type in ``POINTS`` order; on the aggregate route they are the -``Coupled``/``Vessel`` points only (`Coupled DOF layout`_). A handle initialised from raw arrays +``Coupled``/``Vessel`` points only (`Coupled DOF layout`_), and a finite-EI line between two +``Coupled`` points has one block per end, its End B block after the fairleads of all +finite-EI lines, so that point id appears once per line end it carries. A handle initialised from raw arrays has no deck points, and the call returns ``CD_C_BAD_INPUT``: its coupled vector is the caller's own ``fixed_dofs`` list. A wrong ``n_block`` returns ``CD_C_BAD_INPUT``. diff --git a/doc/driver_format.md b/doc/driver_format.md index 371c8667..7cd9dc7d 100644 --- a/doc/driver_format.md +++ b/doc/driver_format.md @@ -260,7 +260,7 @@ torsional stiffness, transverse and polar (axial) rotary inertia per length): `Name Diam Mass EA BA EI GAs GJ Irt Irn Cd_n Cd_t Ca_n Ca_t`. The four extra values must be finite and either all `0` or all `> 0`. All zero, or the 10-column row, selects the circular-section closure `GAs = EA/(2(1+0.3))`, `GJ = EI/(1+0.3)`, `Irt = m d²/16`, `Irn = m d²/8`. The closure -serves the secondary Cosserat path only: a finite-EI line restrained in torsion +serves the secondary Cosserat library path only: a finite-EI line restrained in torsion ([END CONNECTIONS](#end-connections-optional-finite-ei-lines)) takes `GJ` [N·m²/rad] from the 14-column row of each of its sections and stops by name without it. In the dynamics such a line carries a twist angle at every node, whose polar rotary inertia is `Irn` [kg·m²/m] @@ -270,7 +270,7 @@ used by the cubic-Hermite route, but the all-or-nothing rule still asks for posi The `GJ` column may be written `GJ|K`, with `K` [N·m] the torque–tension coupling of an armoured cable or wire rope (`T = EA ε + K τ`, `M = GJ τ + K ε`; see [Torque–tension coupling](theory.rst)). It needs a finite-EI, linear-elastic type with -`K² < EA·GJ`; the two-moving-end compatibility route refuses it. `GJ|0` is the plain `GJ`. +`K² < EA·GJ`. `GJ|0` is the plain `GJ`. `GJ|K|Bt` adds the torsional damping `Bt` [N·m²·s] of the nodal twist (the torque `Bt dτ/dt`, stiffness-proportional: a torsional mode of frequency `ω` has the damping ratio `ω Bt/(2 GJ)`); a negative `Bt` is `-ζ`, the fraction of an element's critical torsional damping @@ -321,13 +321,19 @@ rejected. `EI > 0` is routed as follows. **Standalone dynamic run** (`dtM`/`TMax` set): -- When every line's End B is a `Fixed` point, finite-EI lines run on the cubic-Hermite route. It +- Finite-EI lines whose End B is a `Fixed`, `Coupled` or `Vessel` point run on the cubic-Hermite + route. It covers suspended spans, motion-file, current, and wave cases, and flat or structured seabed contact. Contact uses a C1 normal penalty, compression-only normal damping, and stick-slip seabed friction, each scaled by nodal diameter × tributary length. Slack spans with both endpoints above the bed start from an isometric two-touchdown seed. -- A line whose End B is not `Fixed` (both ends moving) runs on the finite-EI compatibility route: - End A is driven and End B is held. +- A line whose End B is a `Coupled`/`Vessel` point (a line between two moving points, such as a + cable shared by two floaters or a `TURBINES` shared line) has both ends driven: End B moves with + the same motion table as End A (`motionFile` rows, the `vesselMotion`/`vesselRAO` vessel and its + rotation, `TURBINES` rows, the `motionFile` roll column) and is held where no motion is given. + Its static solve is that of a `Fixed` End B at its deck position, so a `Coupled` End B the motion + leaves at rest is the `Fixed` End B, byte for byte. `staticsFriction asLaid` is refused on such a + line (it has no anchored end to lay the line from). - A deck whose finite-EI lines are its only lines and whose endpoints are all `Fixed`/`Coupled`/`Vessel` runs on this route; with EI = 0 lines beside them it is a standalone mixed deck (below). With BODIES, RODS, or `Connect`/`Free` points it runs on the @@ -385,19 +391,31 @@ With `bodyScheme staggered` each step is a predictor-corrector: The staggered steps are sub-cycled so the explicit object positions resolve the stiffest object-mooring mode of the EI = 0 lines. A finite-EI cable end on a body point or a rod end is -pinned unless its -End A has an [END CONNECTIONS](#end-connections-optional-finite-ei-lines) row: a pinned end passes -its end force to the object at the attachment and no moment. A `Rigid` or spring End A is fixed -in the object: its direction turns with the object, the connection moment is returned to it, and -the monolithic step re-steps the cable at every outer iteration with its end stiffness in the -Newton matrix. The static solve (`bodyIC static`) balances the cable's bending end force and -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, 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; +pinned unless it has an [END CONNECTIONS](#end-connections-optional-finite-ei-lines) row: a pinned +end passes its end force to the object at the attachment and no moment. A `Rigid` or spring end +is fixed in the object: its direction turns with the object, the connection moment is returned to +it, and the monolithic step re-steps the cable at every outer iteration with its end stiffness in +the Newton matrix. A cable between two objects (End B on a body point or a rod end as well) is +driven at both ends and re-stepped at every outer iteration whatever its connections; its +end-to-end stiffness couples the two objects' coordinates in the one Newton matrix of the step, +and its end loads (and, at a connected or torsional end, the connection moment and torque) return +to each object. The static solve (`bodyIC static`) balances the cable's bending end force and +connection moment at every connected end, and at both ends of a cable between two objects +(passes accelerated by Anderson mixing when the deck has such a cable). On this route: + +- a finite-EI cable's ends may be `Fixed` points, Rigid6 `Body` points or rod ends, not + `Free`/`Connect` points or `Point3` buoys; a `Coupled`/`Vessel` end, which this march has no + motion to drive, is rejected by name; +- a clamped or elastic end, or a torsional one (bending-pinned included), on a body or rod needs + `bodyScheme monolithic` (the default); `staggered` rejects it by name, at either end. The + staggered scheme passes cable end forces explicitly and sizes its sub-steps from each end's + spring to its own object, so a stiff cable with both ends on one body (or between two light + objects) is resolved there only as far as `dtM` allows; the monolithic scheme couples it in its + Newton matrix; +- a cable re-stepped at every outer iteration of the monolithic step is one connected at an end + on a moving object or one between two moving objects (Rigid6 bodies, free or pinned rods); + a pinned cable with one moving end is coupled at the predictor, whichever end that is, and an + end on a fixed rod's end is the `Fixed` end there; - every `Free`/`Connect` point carries at least one EI = 0 line; - `motionFile` and `Coupled`/`Vessel` rods are rejected by name. @@ -565,8 +583,12 @@ degrees). Turbines not in the section are an error naming the point. With a `mot rows are per-turbine rigid-body records `time J x y z q0 q1 q2 q3 vx vy vz wx wy wz ax ay az alx aly alz` (reference position, unit quaternion, velocity, angular velocity, and their rates); each Turbine fairlead -follows `x + R(q) p`, with the rigid-body velocity and acceleration. In FAST.Farm the host -supplies the turbine positions and the section is not used. +follows `x + R(q) p`, with the rigid-body velocity and acceleration. A finite-EI line end on a +`Turbine` point takes its `END CONNECTIONS` direction `Ez` and torsion normal `Nx` in that +turbine's axes: turned by the `PtfmInit` rotation at the static start and by `R(q)`, with the +row's angular velocity and acceleration, in the run (End A and End B alike), as the FAST.Farm +host's orientations turn them. In FAST.Farm the host supplies the turbine positions and the +section is not used. ### ROD TYPES + RODS (rigid cylindrical rods) @@ -720,8 +742,9 @@ rod end, and `Free`/`Connect`-to-`Coupled` lines are left as written. - In a deck without dynamic points (`Connect`, `Free`, `Body`, or `RodA/B`), End A must be a `Coupled`, `Vessel`, or `Body` point and End B a `Fixed` point. A fairlead below its anchor - fails with `LINE End A fairlead (NodeA) must not be below End B anchor (NodeB)`. The exception - is a FAST.Farm shared line with both ends on `Turbine` points. + fails with `LINE End A fairlead (NodeA) must not be below End B anchor (NodeB)`. The exceptions + are a FAST.Farm shared line with both ends on `Turbine` points and a finite-EI line whose End + B is also a `Coupled`/`Vessel` point (a line between two moving points, driven at both ends). - In a deck with dynamic points, line ends may be `Fixed`, `Coupled`, `Vessel`, `Connect`, `Free`, `Body`, or `RodA/B`. @@ -783,8 +806,12 @@ rope: its static solve uses the OWC, and each element's running maximum is its s `END CONNECTIONS` sets the bending boundary at either end of a finite-EI line. Omitted ends are pinned. At most one row may name a given line end. A non-pinned connection requires a finite-EI -line whose End B is a `Fixed` point; a finite-EI line with two moving ends fails deck validation. -End A may be a `Fixed` or `Coupled` point, a Rigid6 `Body` point or a rod end. +line whose End B is a `Fixed` point or a `Coupled`/`Vessel` point, whose connection is held by +that point's parent and turns with it as End A's does (the `vesselMotion`/`vesselRAO` vessel +standalone, the host orientation of End B's point when coupled), or a Rigid6 `Body` point or a +rod end on the [multibody march](#multibody-march) (a line between two objects, whose connection +turns with End B's object); any other End B fails deck validation. End A may be a `Fixed` or +`Coupled` point, a Rigid6 `Body` point or a rod end. ```text --------------------- END CONNECTIONS ------------------------------- @@ -911,23 +938,26 @@ Behaviour: 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, 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). +Scope. A torsionally restrained line needs a finite-EI line with a `Fixed` End B or, restrained +at both ends, a `Coupled`/`Vessel` or Rigid6 `Body` End B (both end frames then turn with +their parents, and standalone the `motionFile` roll column rolls either end: `Φ = Pretwist(B) − +Pretwist(A) − roll(A) − roll(B)`, each roll about the tangent pointing into the line from that +end), an explicit `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 (with a +`Fixed` End B); 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), at End B on a rod end (a line between two rods: +restrain it through End A, or 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, nor a second moving end. Seabed +friction does not resist twist (the laid part of a line twists freely). ### EQUIVALENT BUOYANCY (optional) @@ -1011,10 +1041,9 @@ Behaviour: non-positive pitch or `first > last`. A stock-order line (anchor as `NodeA`) measures the arc from that anchor. Attachments run on the cubic-Hermite cable route, standalone (End A `Coupled`/ - `Vessel` or `Fixed`, End B `Fixed`) and coupled (OpenFAST `CompMooring = 5`, the C API and - Python), where the SeaState kinematics the host samples at every cable node reach the - attachments at theirs; a checkpoint restart is bit-identical. They are rejected on the - two-moving-end compatibility route. + `Vessel` or `Fixed`, End B `Fixed`, `Coupled` or `Vessel`) and coupled (OpenFAST + `CompMooring = 5`, the C API and Python), where the SeaState kinematics the host samples at + every cable node reach the attachments at theirs; a checkpoint restart is bit-identical. ### STIFFENERS (optional, finite-EI lines) @@ -1072,8 +1101,7 @@ Behaviour: `InnerD` and `Density` non-negative, `InnerD` below both outer diameters), or the stiffeners of End A and End B together are longer than the line. On a stock-order line (anchor as `NodeA`) the `End` column follows the written row, so the stiffener stays on the same physical - end. Stiffeners run wherever the cubic-Hermite cable does, standalone and coupled; they are - rejected on the two-moving-end compatibility route. + end. Stiffeners run wherever the cubic-Hermite cable does, standalone and coupled. ### FAILURE (optional, EI = 0 decks) @@ -1396,11 +1424,14 @@ cases. With an active path: 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 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 +end restrained in torsion (End A, or End B in a deck that lists the `Fixed` anchor as End A; both +ends of a line between two moving points), right-handed about the line tangent pointing into the +line from that end. It imposes `Phi(t) = Pretwist(B) − Pretwist(A) − roll(A)(t) − roll(B)(t)`, +the roll of a `Fixed` end, or of an end free in torsion, being 0: 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`), so equal rolls of the two ends of a line between two moving points +twist it by twice the roll, and a rigid roll of the line about its axis (opposite rolls) does not +twist it. The roll is 0 at `t = 0` and is given on every row of the point or on none. Header lines must be comments. `time` must lie on the `0, dtM, 2·dtM, …` grid (rows after `TMax` are read and not used) and `point_id` must be a prescribed point. Each @@ -1491,9 +1522,9 @@ bending moment. None of these channels is mandatory. | Channel | Meaning | Unit | |---------|---------|------| -| `FairTen` | line L fairlead (End A) line-end tension: the magnitude of the force the line actually exerts on its End-A point (end element force with axial damping, including the bending shear of a finite-EI line, plus the end node's share of the submerged weight, seabed contact and drag at the actual velocity; without the end node's inertia), the static end reaction at rest. Route differences (seabed friction, the two-moving-end route) are in [Outputs](outputs.rst) | N | +| `FairTen` | line L fairlead (End A) line-end tension: the magnitude of the force the line actually exerts on its End-A point (end element force with axial damping, including the bending shear of a finite-EI line, plus the end node's share of the submerged weight, seabed contact and drag at the actual velocity; without the end node's inertia), the static end reaction at rest. Route differences (seabed friction) are in [Outputs](outputs.rst) | N | | `AnchTen` | line L anchor (End B) line-end tension, as `FairTen` | N | -| `AnchFz` | line L vertical component of the `AnchTen` end force, positive upward (the line lifts its End-B point). Not available on the two-moving-end finite-EI route, which rejects it by name | N | +| `AnchFz` | line L vertical component of the `AnchTen` end force, positive upward (the line lifts its End-B point) | N | | `AnchFH` | line L horizontal magnitude of the `AnchTen` end force (same availability as `AnchFz`) | N | | `FairIncl` | line L fairlead (End A) signed inclination below horizontal (0 = horizontal; positive = downward) | deg | | `AnchIncl` | line L anchor (End B) signed inclination below horizontal (0 = horizontal; positive = downward) | deg | @@ -1504,7 +1535,7 @@ bending moment. None of these channels is mandatory. | `Point

p{x,y,z}` | point P position component | m | | `Con

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

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

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

FH` | resultant of the line-end and cable end forces on point P (each the `FairTen`/`AnchTen` end force): the anchor load of a Fixed point shared by several lines, the line load a free point balances; `FH` is its horizontal magnitude. Available on every route (static, `EI = 0`, finite-EI, multibody and OpenFAST) except the two-moving-end finite-EI route, which rejects it by name | N | +| `Point

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

FH` | resultant of the line-end and cable end forces on point P (each the `FairTen`/`AnchTen` end force): the anchor load of a Fixed point shared by several lines, the line load a free point balances; `FH` is its horizontal magnitude. Available on every route (static, `EI = 0`, finite-EI, multibody and OpenFAST) | N | | `TenN` | line L effective tension at node J. EI = 0 lines: the mean of the two adjacent segment tensions. Finite-EI lines: the axial component of the section force recovered from nodal equilibrium (`OutputRecovery element`: the length-weighted mean of the adjacent element-mean axial forces). End nodes report the line-end force of `FairTen`/`AnchTen` | N | | `CurvN` | line L curvature at node J. `EI = 0` lines: geometric curvature of the circle through the node and its two neighbours (end nodes take the adjacent interior value). Cubic-Hermite lines: `BendMomN` / EI, the larger of the two sides at a section junction (`OutputRecovery element`: exact curvature of the continuous centreline, the larger one-sided element value at an interior node) | 1/m | | `BendMomN` | line L bend moment = EI × curvature **relative to the stress-free reference shape** (≈ 0 at the reference; the finite-EI reference is straight). Finite-EI lines: recovered from nodal equilibrium, the moment the neighbouring elements carry (`OutputRecovery element`: EI × the larger one-sided exact curvature); 0 on EI = 0 lines. Under a bend stiffener: the cable's own share, the line type's EI × curvature | N·m | @@ -1560,8 +1591,8 @@ Azimuth` ([Outputs](outputs.rst) defines each one). These standalone routes writ the element-extrema file `.elements.out`; - a mixed `EI = 0` + finite-EI deck. -The independent `EI = 0` dynamic, point-system, rod, and Rigid6 routes, and the two-moving-end -finite-EI compatibility route, do not write it. The file is additive; `.out` is +The independent `EI = 0` dynamic, point-system, rod, and Rigid6 routes do not write it. The file +is additive; `.out` is unchanged. An OpenFAST `CompMooring = 5` run always writes `.CD.static.out` after coupled diff --git a/doc/file_formats.rst b/doc/file_formats.rst index b236a570..32cff5ab 100644 --- a/doc/file_formats.rst +++ b/doc/file_formats.rst @@ -176,15 +176,16 @@ Tokens after the eleventh are ignored, except on a deck with a torsional line (b **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 +twelfth token is read as the roll of the frame of a line's moving end restrained in torsion (End A, +or End B in a deck that lists the anchor as End A; both ends of a line between two moving points), +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:: - \Phi(t) = \text{Pretwist}_B - \text{Pretwist}_A - \text{roll}(t), + \Phi(t) = \text{Pretwist}_B - \text{Pretwist}_A - \text{roll}_A(t) - \text{roll}_B(t), -whichever end moves, so a positive roll lowers :math:`\Phi`. At End A it has the sense of +the roll of a ``Fixed`` end being 0, so a positive roll lowers :math:`\Phi`. At End A it has the sense of ``Pretwist`` (A) and of rolling the End A frame through a body or vessel; at End B, where the inward tangent is ``−Ez``, it has the opposite sense to ``Pretwist`` (B). Rules: diff --git a/doc/openfast.rst b/doc/openfast.rst index 9c9cc7e7..a2b56410 100644 --- a/doc/openfast.rst +++ b/doc/openfast.rst @@ -329,6 +329,19 @@ is not unique. Formal linearisation (``Linearize = True``) supports pinned and n connections; a ``Rigid`` row fails during initialisation, because only the axial stretch of its end tangent is a degree of freedom (see `Linearisation`_). Row grammar: :doc:`driver_format`. +Lines between two moving points +------------------------------- + +A finite-EI line may run between two host-driven points: both ends on ``Coupled``/``Vessel`` +points, or in FAST.Farm between two ``Turbine`` fairleads (a shared power cable between two +floating turbines). Each end is a mesh point of its own: End A takes the line's fairlead point, +End B a second point placed after the fairleads of all finite-EI lines (in FAST.Farm on End B's +turbine), and the load and moment of each end return to its own host. End B's connection +direction and torsion frame are given in its parent's axes and turn with its point-mesh +orientation as End A's do. The static initialisation is that of the same line with End B held +at its position; ``PtfmInit`` (or the farm's initial turbine displacements) places both ends. +Formal linearisation of such a line fails during initialisation. + Line torsion ------------ @@ -341,7 +354,9 @@ torsional inertia loads the platform); a free End A transmits no torque, and the 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 +unwrapped twist is part of the checkpoint state. End B is a ``Fixed`` point or a second +host-driven end whose frame turns with its own orientation (`Lines between two moving points`_). +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, diff --git a/doc/options.rst b/doc/options.rst index 6c75f4b4..2564dbd5 100644 --- a/doc/options.rst +++ b/doc/options.rst @@ -126,8 +126,8 @@ Environment and seabed - finite, ≥ 0. Anisotropic seabed friction of line nodes (the axial/normal pair of OrcaFlex, by Orcina): the coefficient along the line and across it. A row omitted takes ``frictionMu``; both must then be positive, or both zero. An equal pair is the isotropic - law bit-for-bit. Rods and bodies, which have no line axis, use the lateral coefficient; - the finite-EI two-moving-end route rejects an unequal pair. The route limits of + law bit-for-bit. Rods and bodies, which have no line axis, use the lateral coefficient. + The route limits of ``frictionMu`` apply. Aliases: ``frictionMu_axial``, ``mu_axial``, ``muaxial`` for the axial coefficient; ``frictionMu_lateral``, ``mu_lateral``, ``mulateral``, ``frictionMuNormal``, ``frictionMu_normal`` for the lateral one. See :doc:`theory` @@ -156,8 +156,9 @@ Environment and seabed known. Used only with ``frictionMu > 0`` and a seabed; rejected where the static equilibrium solves the lines without seabed friction: on decks with bodies, rods or ``Connect``/``Free`` points (``frictionMu`` itself is accepted on the default monolithic - body and rod march), and on the finite-EI two-moving-end route (a line whose End B is - not ``Fixed``, as a line shared between two turbines). See + body and rod march), and on a finite-EI line between two moving points (End B on a + ``Coupled``/``Vessel`` point, as a line shared between two turbines), which has no anchored + end to lay it from. See :ref:`friction in statics ` - both - ``asLaid staticsFriction`` @@ -612,8 +613,9 @@ Ambient fluid and prescribed motion tangent stiffness, structural plus added mass, ends held), written to ``.modes.out`` before any dynamic march. Decks of lines between Fixed and Coupled/Vessel points on a flat ``WtrDpth`` seabed: all ``EI = 0`` lines (static or - dynamic deck), or all finite-EI lines on the cubic-Hermite route (dynamic deck, every - End B Fixed). Other decks are rejected; a deck that mixes ``EI = 0`` and finite-EI + dynamic deck), or all finite-EI lines on the cubic-Hermite route (dynamic deck; a moving + End B is held at its static position, as End A is). Other decks are rejected; a deck that + mixes ``EI = 0`` and finite-EI lines stops with ``OPTION nModes is not supported for mixed EI=0/finite-EI decks; remove it or set it to 0``. A line restrained in torsion adds the twist angle of every node to its modes (``PolarShare`` and ``dTwist`` in :doc:`outputs`). The banded solver has diff --git a/doc/outputs.rst b/doc/outputs.rst index 5a3ede04..3229e994 100644 --- a/doc/outputs.rst +++ b/doc/outputs.rst @@ -61,18 +61,13 @@ The driver names every file from the ```` argument. Which files appear - -- - -- - -- - * - Dynamic, all lines finite-EI, every End B on a ``Fixed`` point (cubic-Hermite route) + * - Dynamic, all lines finite-EI, every End B on a ``Fixed``, ``Coupled`` or ``Vessel`` point + (cubic-Hermite route; a ``Coupled``/``Vessel`` End B is a second driven end) - time series - yes (the converged initial state) - yes - time series - -- - * - Dynamic, all lines finite-EI, some End B not ``Fixed`` - - time series - - no - - -- - - time series - - -- * - Mixed ``EI = 0`` and finite-EI lines (static or dynamic) - ``t = 0`` row, plus time series when ``TMax > 0`` - yes @@ -149,11 +144,8 @@ The title line identifies the route that produced the file: * - rods - ``# CableDyn driver output (rod dynamic; convergence quality is reported by status message)`` - * - finite-EI (cubic-Hermite) + * - finite-EI (cubic-Hermite, one or two moving ends) - ``# CableDyn driver output (finite-EI dynamic; production cubic-Hermite route)`` - * - finite-EI, two moving ends - - ``# CableDyn driver output (finite-EI dynamic; convergence quality in the status - message)`` * - mixed ``EI = 0`` + finite-EI - ``# CableDyn driver output (mixed aggregate dynamic; convergence quality is reported by status message)`` @@ -345,8 +337,7 @@ write. Any other letter is a parse error. Mixed ``EI = 0`` + finite-EI decks rej flag ``V``; a static run carries no lift and writes no file). On an ``EI = 0`` line the end nodes carry none, as in MoorDyn; on a finite-EI line each element's lift is lumped to its two nodes (the translational part of its consistent load), so the end nodes carry - the lift of their half-elements. Zero on a line without VIV (``Cl = 0``); a finite-EI - line with two moving ends carries no VIV and refuses the flag + the lift of their half-elements. Zero on a line without VIV (``Cl = 0``) * - ``r`` - ``.Line.range.out`` - range graph: minimum, maximum and mean over the run of the node tension, curvature, bend @@ -578,10 +569,7 @@ Line-end channels matches the magnitude of its end ``GX``/``GZ`` force. Seabed friction at a grounded end node is part of the ``EI = 0`` end force but not of the finite-EI (cubic-Hermite) end force, which leaves the end node's friction, like its inertia, in the coupled load; the - two agree whenever the end node is off the seabed or friction is off. On the - two-moving-end finite-EI route (End B not ``Fixed``) the value is instead the signed - chord-stretch axial tension ``EA (chord/L0 − 1)`` of the end element, without end shear, - axial damping or the end node's lumped loads + two agree whenever the end node is off the seabed or friction is off - N * - ``AnchTen`` - line-end tension at End B (anchor) of line ``L``, defined as for ``FairTen``. On a @@ -593,8 +581,8 @@ Line-end channels * - ``AnchFz`` - vertical component of the ``AnchTen`` end force, the force line ``L`` exerts on its End-B point: positive upward (the line lifts the anchor), negative downward. On every - route that reports ``AnchTen`` except the two-moving-end finite-EI route, which rejects it - by name; for an anchor that holds one line it equals ``Point

Fz`` + route that reports ``AnchTen``, a moving End B included; for an anchor that holds one line + it equals ``Point

Fz`` - N * - ``AnchFH`` - horizontal magnitude of the same end force, :math:`\sqrt{F_x^2 + F_y^2}`, with the same @@ -690,9 +678,7 @@ Line-node channels :math:`EA(|\mathbf r'| - 1)`. An end node reports the line-end force of ``FairTen`` / ``AnchTen``, the end reaction on the support or platform, which excludes inertia, added mass and seabed friction (the interior values are the recovered section force, whose - element end forces include inertia and added mass). On the two-moving-end finite-EI route - every value is the chord-stretch tension of ``FairTen`` there: the adjacent element at an - end node and the unweighted mean of the two neighbouring elements at an interior node + element end forces include inertia and added mass) - N * - ``CurvN`` - curvature at node ``J``. ``EI = 0`` lines: discrete curvature of the circle through @@ -712,8 +698,8 @@ Line-node channels length is ``CurvN`` (``CurvX² + CurvY² = Curv²``), and a section point at (x, y) has the bending strain ``−(CurvX x + CurvY y)``. The axes start at End A from the end connection, follow the hang-off when End A is clamped, and are carried along the line, - turned by the twist when the line is restrained in torsion. ``EI = 0`` lines and - finite-EI lines with two moving ends refuse the channels. ``CD_HFMF_Section_Curvature`` + turned by the twist when the line is restrained in torsion. ``EI = 0`` lines refuse the + channels. ``CD_HFMF_Section_Curvature`` returns them for every node - 1/m * - ``BendMomN`` @@ -852,8 +838,7 @@ Point channels - resultant of the forces of the lines and finite-EI cables attached to point ``P`` (each the ``FairTen``/``AnchTen`` end force): the load on a shared anchor, or the line load a free point balances; ``FH`` is the horizontal magnitude. Available on every route - (static, ``EI = 0``, finite-EI, multibody and OpenFAST) except the two-moving-end - finite-EI route, which rejects it by name + (static, ``EI = 0``, finite-EI, multibody and OpenFAST) - N Body and rod channels diff --git a/doc/solver_paths.rst b/doc/solver_paths.rst index 0996a2bc..d67279d8 100644 --- a/doc/solver_paths.rst +++ b/doc/solver_paths.rst @@ -146,9 +146,9 @@ Secondary path: Cosserat rod A finite-bending Cosserat rod with rotation DOFs (``CableDyn_Cosserat*``) is retained as a secondary, non-production path. It is not part of the validated product; its integration -regressions carry the ``cosserat`` CTest label (``ctest -L cosserat``). The standalone driver -uses it only for the uncommon -finite-``EI`` topology in which both line ends move. +regressions carry the ``cosserat`` CTest label (``ctest -L cosserat``). No deck route uses it: +a finite-``EI`` line whose two ends move runs on the cubic-Hermite route like every other +finite-``EI`` line. The element uses the geometrically exact rod strains of :ref:`Simo (1985) `: the material strain diff --git a/doc/standalone_driver.rst b/doc/standalone_driver.rst index 7b3416e5..d608a667 100644 --- a/doc/standalone_driver.rst +++ b/doc/standalone_driver.rst @@ -47,8 +47,8 @@ digits so time stamps stay exact on long records. The static configuration profi ``results\spread3.static.out`` is written by three routes: a static-only ``EI = 0`` deck (no ``dtM``/``TMax``), every production Hermite finite-EI deck (its initial configuration, together with the element-extrema file ``spread3.elements.out``), and a mixed ``EI = 0`` plus finite-EI -deck. The independent ``EI = 0`` dynamic, point-system, rod, ``Rigid6`` and multibody routes, and -the two-moving-end finite-EI compatibility route, write no ``.static.out``. A deck +deck. The independent ``EI = 0`` dynamic, point-system, rod, ``Rigid6`` and multibody routes write +no ``.static.out``. A deck requesting per-line position or tension output can add ``spread3.Line.p.out`` and ``spread3.Line.t.out``; a dynamic rod deck can add ``spread3.Rod.p.out``. See :doc:`outputs` for channel names, units, and file layouts. @@ -153,9 +153,7 @@ horizontal, and 180 degrees down. ``azimuth`` is measured from global ``+X`` tow together deliberately so the convention is auditable. For the production Hermite finite-EI route, the reported vector is the complete fairlead reaction, -including bending and distributed-load effects. The two-moving-end finite-EI compatibility route -(a finite-EI line whose End B is not ``Fixed``) reports only the axial endpoint contribution and -labels that row ``axial force component`` so it cannot be mistaken for a complete reaction. +including bending and distributed-load effects, also on a line whose End B moves. Input-record style ~~~~~~~~~~~~~~~~~~ diff --git a/doc/theory.rst b/doc/theory.rst index 384e1743..2bc324c6 100644 --- a/doc/theory.rst +++ b/doc/theory.rst @@ -971,8 +971,7 @@ needed: the Hermite tangent and the integrated lift leave no mesh-scale mode for pump, and the response is the same from ``dtM`` 5e-4 to 1e-2 s. A finite-EI line with :math:`EI \to 0` reproduces the ``EI = 0`` line's lock-in. The standalone Hermite march and the multibody march (a cable on a body or rod, or beside free points) carry it, including -deck waves and current through the held fluid field; a finite-EI line with two moving ends -refuses :math:`C_L > 0`. +deck waves and current through the held fluid field, on a line with one or two moving ends. VIV runs on every route that carries the line: the standalone driver, the coupled OpenFAST and FAST.Farm routes and the standalone runner of a mixed ``EI = 0`` / finite-EI deck. On the diff --git a/doc/troubleshooting.rst b/doc/troubleshooting.rst index d6dce3bb..36aee8f9 100644 --- a/doc/troubleshooting.rst +++ b/doc/troubleshooting.rst @@ -263,22 +263,33 @@ Model data anchor. Check the point coordinates. * - ``LINE End A (NodeA) must be Coupled/Vessel/Body ...`` / ``LINE End B (NodeB, POINT , ) must be a Fixed (anchor) point`` - - in a deck without dynamic points every line runs from a fairlead to an anchor. A line - between two Coupled points (a shared line) is supported only between two ``Turbine`` - fairleads of a FAST.Farm deck. An ``EI = 0`` line can be split into two lines that meet at - a ``Connect`` point in the middle; each line then ends on one Coupled point, and the deck - becomes dynamic and needs ``dtM`` and ``TMax``. A finite-EI line cannot be split that way - (beside ``Connect`` points a finite-EI cable needs a Fixed End B and cannot end on a - ``Connect`` point; the message then starts ``finite-EI LINE ``): anchor it on a Fixed - point, or model the shared span with ``EI = 0`` line types split at a ``Connect`` point. - * - ``finite-EI LINE in a mixed-topology deck needs a Fixed End B ... End B is POINT - ()`` - - a deck with ``Connect``/``Free`` points, bodies or rods that also has finite-EI cables drives - each cable at End A, so End B must be a ``Fixed`` point. A cable that ends on a ``Connect``/``Free``/``Coupled`` - point (a junction with other lines, a buoy, a pliant-wave hang-off) is not supported in a - deck with ``Connect``/``Free`` points, bodies or rods, which is marched as one multibody - system. Anchor the cable on a Fixed point, or run the cable and the lines it joins as - separate decks. + - in a deck without dynamic points every ``EI = 0`` line runs from a fairlead to an anchor. An + ``EI = 0`` line between two Coupled points (a shared line) is supported only between two + ``Turbine`` fairleads of a FAST.Farm deck; it can also be split into two lines that meet + at a ``Connect`` point in the middle (each line then ends on one Coupled point, and the deck + becomes dynamic and needs ``dtM`` and ``TMax``). A finite-EI line may join two + ``Coupled``/``Vessel`` points (both ends driven); its End B on any other moving point is + refused (``finite-EI LINE End B ... must be a Fixed (anchor), Coupled or Vessel + point``), and it cannot be split at a ``Connect`` point (beside ``Connect`` points a + finite-EI cable needs a Fixed End B): anchor it, or end it on a ``Coupled``/``Vessel`` point. + * - ``finite-EI LINE in a mixed-topology deck: End B is POINT (); a cable end on a + Free/Connect point or a Point3 buoy ... is not supported`` + - a deck with ``Connect``/``Free`` points, bodies or rods that also has finite-EI cables + drives each cable by the objects at its ends: End B must be a ``Fixed`` point, a Rigid6 + ``Body`` point or a rod end. A cable that ends on a ``Connect``/``Free`` point or a + ``Point3`` buoy (a junction with other lines, a buoy, a pliant-wave hang-off) is not + supported in a deck marched as one multibody system. End the cable on a Fixed point, a + body or a rod end, or run the cable and the lines it joins as separate decks. + * - ``static body/rod equilibrium with the bending end loads of finite-EI LINE (its End A|B, + on a body or rod) did not converge after 60 passes`` + - the static passes that balance a finite-EI line between two objects on its cubic-Hermite + end loads (Anderson-accelerated) did not settle; the line's bending couples the objects + more strongly than their own restoring holds them. Check the connection directions and + the mooring, or start from the deck pose (``deck bodyIC``). + * - ``finite-EI LINE : a Coupled/Vessel End B (POINT ) would need motionFile coupling to + drive it`` + - the multibody march takes no ``motionFile``, so it has nothing to drive a ``Coupled``/ + ``Vessel`` end with. End the cable on a Fixed point, a Rigid6 body point or a rod end. * - ``finite-EI LINE : a Coupled/Vessel End A (POINT ) would need motionFile coupling to drive it`` - a mixed-topology deck that has ``Connect``/``Free`` points or bodies is marched as one @@ -356,9 +367,10 @@ Model data * - ``FAST.Farm Turbine decks are consumed by the CompMooring=5 aggregate path only`` - ``Turbine`` points use turbine-local coordinates. Run the deck through FAST.Farm, or replace them with ``Coupled`` points in global coordinates for a standalone run. - * - ``END CONNECTIONS requires a finite-EI line`` / ``non-pinned END CONNECTIONS require a - finite-EI line with Fixed End B`` - - bending end connections apply only to ``EI > 0`` lines whose End B is an anchor. + * - ``END CONNECTIONS requires a finite-EI line`` / ``non-pinned END CONNECTIONS need End B on + a Fixed, Coupled or Vessel point`` + - bending end connections apply only to ``EI > 0`` lines whose End B is an anchor or a + ``Coupled``/``Vessel`` point (a second driven end), not a ``Connect``/``Free`` point. * - ``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`` @@ -389,9 +401,10 @@ Torsion explicit GJ > 0`` - torsion has no ``EI/1.3`` default: use the 14-column ``LINE TYPES`` row with ``GJ`` (and positive ``GAs``, ``Irt``, ``Irn``) for every section of the line. - * - ``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. + * - ``torsional END CONNECTIONS ... require a finite-EI line`` / ``need End B on a Fixed, + Coupled or Vessel point or a Rigid6 body point`` + - torsion is solved on cubic-Hermite lines whose End B is an anchor, a ``Coupled``/ + ``Vessel`` point or a Rigid6 body point (both end frames then turn with their parents). * - ``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`` @@ -400,10 +413,11 @@ Torsion 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 torsional END CONNECTION on a rod end is not supported at End B`` / ``on a rod end + needs a Fixed End B`` + - a rod end holds a torsion frame at End A only, with a ``Fixed`` End B. Restrain the line + through its End A at the rod end, or end it on a ``Fixed`` point at a ``Fixed`` 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 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, @@ -873,8 +887,11 @@ aborts with a CableDyn fatal error, check whether the deck uses one of these com support all of them * - a ``Rigid`` end-connection direction reversed by exactly 180 degrees in one host update - drive the platform through intermediate orientations - * - VIV on a finite-EI line with two moving ends (``needs its End B fixed``) - - fix End B of the line, or set ``Cl = 0`` for its line type + * - ``OPTION staticsFriction asLaid lays a line on the seabed from its anchored end; ... has a + moving End B`` + - a line between two moving points has no anchored end to lay it from: use + ``staticsFriction none`` (the march then starts from the frictionless static equilibrium, + and the friction acts from there) * - a host/file fluid combination named as inseparable - select host wave/current and file wave/current independently as documented, or place the whole field in SeaState diff --git a/python/cabledyn/deck_file.py b/python/cabledyn/deck_file.py index 22856450..8065c46a 100644 --- a/python/cabledyn/deck_file.py +++ b/python/cabledyn/deck_file.py @@ -372,12 +372,6 @@ _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). @@ -835,6 +829,23 @@ def _channel_id(digits: str) -> str: return str(_native_id_suffix(digits)) +def _end_b_holds_connection(point_type: str) -> bool: + """Native finalize_checks: an End B that holds a connection or a torsion frame -- a Fixed point, + or a Coupled/Vessel (Turbine) point that drives it as a second moving end.""" + return point_type in {"fixed", "coupled", "vessel"} or _is_turbine_point_type(point_type) + + +def _end_b_holds_frame(point_type: str) -> bool: + """Native end_b_holds_frame: an End B that can hold an END CONNECTION or a torsion frame -- as + _end_b_holds_connection, or a body point or a rod end (a line between two objects on the + multibody march, which checks the object).""" + return ( + _end_b_holds_connection(point_type) + or point_type.startswith("body") + or _rod_point(point_type) is not None + ) + + def _is_turbine_point_type(point_type: str) -> bool: """Mirror the native FAST.Farm ``Turbine``/``T`` vocabulary detection.""" return point_type.startswith("turbine") or ( @@ -3037,6 +3048,8 @@ def end_key(token: str) -> str: finite_ei_lines.add(str(_native_int(section.tokens[0]))) range_lines = 0 lift_lines = 0 # lines with the VIV lift file (flag V) + # LINES whose End B is a moving point (row, line id, End B point type), checked below + moving_b_lines: list[tuple[DeckRecord, str, str]] = [] series_lines = 0 # lines with per-line time-series files (flags p, t, V) for row in self.lines: if len(row.tokens) not in {3, 4, 7}: @@ -3141,7 +3154,9 @@ def end_key(token: str) -> str: ) farm_shared = _is_turbine_point_type(type_a) and _is_turbine_point_type(type_b) if type_b != "fixed" and not farm_shared: - raise DeckFormatError(f"{self._at(row)}: static LINE End B must be Fixed") + # native finalize_checks: a finite-EI line may end on two Coupled/Vessel + # points (both ends driven); decided once the SECTIONS give its line types + moving_b_lines.append((row, str(_native_int(row.tokens[0])), type_b)) if type_b == "fixed" and point_z[node_a] < point_z[node_b]: raise DeckFormatError(f"{self._at(row)}: fairlead must not be below its anchor") for row in self.sections: @@ -3208,6 +3223,37 @@ def end_key(token: str) -> str: any(line_type_meta[line_type][3] > 0.0 for line_type in section_types) for section_types in section_types_by_line.values() ] + # native finalize_checks: a line between two moving points is a FAST.Farm shared line + # (accepted above) or a finite-EI line between two Coupled/Vessel points + for row, line_id, type_b in moving_b_lines: + finite = any(line_type_meta[name][3] > 0.0 for name in section_types_by_line[line_id]) + if finite and type_b in {"coupled", "vessel"}: + continue + if finite: + raise DeckFormatError( + f"{self._at(row)}: static LINE End B of a finite-EI line must be Fixed, " + "Coupled or Vessel" + ) + raise DeckFormatError(f"{self._at(row)}: static LINE End B must be Fixed") + # native build_one_hermite_cable: the as-laid reference lays a line on the seabed from its + # anchored end, which a finite-EI line between two moving points does not have + statics_row = option_by_key.get("statics_friction") + if ( + statics_row is not None + and _strip_quotes(statics_row.values[0]).lower() != "none" + and friction_active + and (has_depth or has_bathymetry) + ): + for line_id, (_, end_b) in normalized_line_endpoints.items(): + end_b_type = point_types.get(end_b, end_b) + if end_b_type == "fixed" or not _end_b_holds_connection(end_b_type): + continue + if any(line_type_meta[name][3] > 0.0 for name in section_types_by_line[line_id]): + raise DeckFormatError( + f"{self._label}: OPTION staticsFriction asLaid lays a line on the seabed " + f"from its anchored end; finite-EI LINE {line_id} has a moving End B (both " + "ends on moving points): use staticsFriction none" + ) # native CD_Deck_Query_dtM has_objects, on the parsed (zero-length rods collapsed) deck has_objects = ( bool(self._rows("BODIES")) @@ -3223,18 +3269,18 @@ def end_key(token: str) -> str: ] # Native build_one_hermite_cable, which builds every finite-EI line of the coupled # aggregate (OpenFAST, FAST.Farm, the C API and the standalone mixed deck): the cable - # is held at a Fixed End B (the anchor) and driven at End A. A finite-EI line shared by - # two turbines is refused here, before its end-force channels (AnchFz, AnchFH) could be - # accepted for an end the aggregate cannot hold. (A standalone line's moving End B is - # refused by the static LINE checks above.) + # is driven at End A and either held at a Fixed End B (the anchor) or driven at a + # Coupled/Vessel End B (its own moving column: a line between two moving points, such + # as a line shared by two turbines). Any other End B is refused here. if self.caller_driven or mixed_route: for line_id in finite_line_ids: end_b = normalized_line_endpoints[line_id][1] end_b_type = point_types.get(end_b, end_b) - if end_b_type != "fixed": + if not _end_b_holds_connection(end_b_type): raise DeckFormatError( f"{self._label}: line {line_id}: finite-EI coupled cable requires End B " - f'(the anchor) to be a Fixed point; got "{end_b_type}"' + "to be a Fixed point or a Coupled/Vessel point (a second driven end); " + f'got "{end_b_type}"' ) for line_type in used_type_names: _, _, ea_static, ei = line_type_meta[line_type] @@ -3378,16 +3424,14 @@ def end_key(token: str) -> str: ) if not has_finite_ei: raise DeckFormatError(f"{where} END CONNECTIONS requires a finite-EI line") + # native finalize_checks: End B is held at a Fixed point or driven with its + # own parent at a Coupled/Vessel point (a line between two moving points) or on + # a body point or a rod end (a line between two objects) 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": + if not _end_b_holds_frame(point_types[end_b]): raise DeckFormatError( - f"{where} non-pinned END CONNECTIONS require " - "a finite-EI line with Fixed End B" + f"{where} non-pinned END CONNECTIONS need End B on a Fixed, Coupled or " + "Vessel point, a Rigid6 body point or a rod end" ) # Advanced native sections are preserved, but preservation must not mean @@ -3771,32 +3815,6 @@ def is_body_kind(kind: str, pinned: bool) -> bool: ) elif has_rigid6: needs_multibody = non_rigid6_points - if deck_driver_route and has_dtm and has_tmax and line_ids and all(finite_lines): - # native run_deck_driver: a finite-EI deck the multibody march does not take, with a - # line whose End B moves, runs on the compatibility route, which carries no VIV - moving_end_b = not needs_multibody and any( - point_types[node_b] != "fixed" for _, node_b in normalized_line_endpoints.values() - ) - if moving_end_b and any( - viv_type_names.intersection(types) for types in section_types_by_line.values() - ): - raise DeckFormatError( - f"{self._label}: VIV (LINE TYPES Cl > 0) of a finite-EI line needs its End B " - "fixed (the cubic-Hermite march); set Cl = 0 for a line with two moving ends" - ) - if moving_end_b and lift_lines: - raise DeckFormatError( - f"{self._label}: the LINES Outputs flag V (VIV lift) needs a line that carries " - "VIV, which a finite-EI line with two moving ends does not" - ) - if moving_end_b: - for channel in channels: - if _parse_line_node_channel(channel.lower())[2] in (13, 14): - raise DeckFormatError( - f"{self._label}: OUTPUT {channel!r}: the section curvature components " - "need a finite-EI line with a Fixed End B (the cubic-Hermite march); a " - "line with two moving ends reports CurvN" - ) if failures and deck_driver_route: # native CD_Run_Deck_Driver: FAILURE runs on the point-system object graph only if not has_dtm: @@ -3825,6 +3843,21 @@ def is_body_kind(kind: str, pinned: bool) -> bool: f"{self._label}: a mixed-topology deck (bodies, rods, dynamic points, EI=0 and " "finite-EI lines together) does not support motionFile coupling" ) + if deck_driver_route and needs_multibody and (has_dtm or has_tmax): + self._check_multibody_cable_ends( + finite_line_ids, + normalized_line_endpoints, + point_types, + body_types, + held_ends, + { + (line_id, end) + for line_id in torsion_lines + for end in ("a", "b") + if torsion_ends.get(line_id, {}).get(end, False) + }, + option_by_key.get("bodyscheme"), + ) # Native standalone dispatch: ROD and Rigid6 decks take prescribed motion; the # Connect/Free point-system route does not. if ( @@ -3853,13 +3886,8 @@ def is_body_kind(kind: str, pinned: bool) -> bool: "(not bathymetryFile)" ) # (native also requires all-finite-EI lines and dtM here; on this route the - # finite-EI clock rule and the object checks above already enforce both) - if any(finite_lines) and any( - point_types[end_b] != "fixed" for _, end_b in normalized_line_endpoints.values() - ): - raise DeckFormatError( - f"{self._label}: OPTION nModes on finite-EI lines needs every End B Fixed" - ) + # finite-EI clock rule and the object checks above already enforce both; the modes + # hold both line ends, a moving End B included) rod_ids = unique(rods, "rod", True) if rods else set() body_refs: dict[str, int] = dict.fromkeys(body_ids, 0) @@ -4309,6 +4337,59 @@ def _check_torsion_normal( f"direction Ez ({', '.join(row.tokens[3:6])})" ) + def _check_multibody_cable_ends( + self, + finite_line_ids: list[str], + normalized_line_endpoints: dict[str, tuple[str, str]], + point_types: dict[str, str], + body_types: dict[str, str], + held_ends: set[tuple[str, str]], + torsion_held: set[tuple[str, str]], + scheme_row: OptionRecord | None, + ) -> None: + """Native write_multibody_dynamic_out: the ends of a finite-EI cable on the multibody march. + + End B may be a Fixed point, a Rigid6 body point or a rod end; a Free/Connect point or a + Point3 buoy, and a Coupled/Vessel point (no motion drives it there), are refused. A + connected (Rigid or spring) or torsional end on a body or rod needs bodyScheme + monolithic; torsion_held lists the (line, end) pairs restrained in torsion of the lines + solved in torsion (an end free in torsion holds no frame). + """ + staggered = ( + scheme_row is not None and _strip_quotes(scheme_row.values[0]).lower() == "staggered" + ) + for line_id in finite_line_ids: + end_a, end_b = normalized_line_endpoints[line_id] + type_a = point_types.get(end_a, end_a) + type_b = point_types.get(end_b, end_b) + body_b = _body_point_id(type_b) + if type_b in {"free", "connect"} or ( + body_b > 0 and body_types.get(str(body_b), "rigid6") == "point3" + ): + raise DeckFormatError( + f"{self._label}: finite-EI LINE {line_id} in a mixed-topology deck: End B is " + f"POINT {end_b} ({type_b}); a cable end on a Free/Connect point or a Point3 " + "buoy is not supported on the multibody march. End the cable on a Fixed " + "point, a Rigid6 body point or a rod end" + ) + if type_b in {"coupled", "vessel"}: + raise DeckFormatError( + f"{self._label}: finite-EI LINE {line_id}: a Coupled/Vessel End B (POINT " + f"{end_b}) would need motionFile coupling to drive it, which a mixed-topology " + "deck marched as one multibody system does not support" + ) + if not staggered: + continue + for end, point_type in (("a", type_a), ("b", type_b)): + if point_type == "fixed": + continue + if (line_id, end) in held_ends or (line_id, end) in torsion_held: + raise DeckFormatError( + f"{self._label}: finite-EI LINE {line_id}: a clamped or elastic END " + "CONNECTION or a torsional one on a body or rod needs bodyScheme " + "monolithic (the staggered scheme couples cable ends as point forces)" + ) + def _check_torsion_lines( self, torsion_ends: dict[str, dict[str, bool]], @@ -4329,16 +4410,17 @@ def _check_torsion_lines( A line with a torsional END CONNECTIONS restraint (TorsStiffness Rigid or a 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 + be Fixed, Coupled/Vessel or a Rigid6 body point (not a rod end), 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; a Fixed rod's with a Fixed End B) nor either end + 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. """ @@ -4421,15 +4503,13 @@ 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: + # End B is held at a Fixed point or driven with its own frame at a Coupled/Vessel point + # (a line between two moving points) or on a body point (a line between two objects) + if not _end_b_holds_frame(point_types[end_b]): 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 " - f"End B; line {line_id} has two moving ends" + f"{self._label}: torsional END CONNECTIONS need End B on a Fixed, Coupled or " + f"Vessel point or a Rigid6 body point; line {line_id} ends on a " + f'"{point_types[end_b]}" point' ) for name in section_types_by_line[line_id]: if not line_type_gj[name] > 0.0: @@ -4438,6 +4518,14 @@ 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_b]) is not None: + raise DeckFormatError( + f"{self._label}: line {line_id}: a torsional END CONNECTION on a rod end is " + "not supported at End B: restrain the line at the rod end through its End A " + "(a Fixed rod, or a rod fixed to a Rigid6 body, RODS type Body), or end it " + "on a Fixed point at a Fixed rod end's position (its force then stays out of " + "that rod's Rod loads)" + ) 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": @@ -4457,12 +4545,20 @@ def _check_torsion_lines( "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": + if rod_end is not None and point_types[end_b] != "fixed": raise DeckFormatError( - f"{self._label}: line {line_id}: a torsional END CONNECTION on a body needs " - "a Rigid6 body" + f"{self._label}: line {line_id}: a torsional END CONNECTION on a rod end needs " + "a Fixed End B (a line restrained in torsion between a rod end and a moving " + "object is not supported in this build)" ) + # either end on a non-Rigid6 body (End B on a body point: a line between two objects) + for end_point in (end_a, end_b): + body_id = _body_point_id(point_types[end_point]) + if body_id > 0 and body_types.get(str(body_id), "rigid6") != "rigid6": + raise DeckFormatError( + f"{self._label}: line {line_id}: a torsional END CONNECTION on a body " + "needs a Rigid6 body" + ) torsion_lines.add(line_id) if not torsion_lines: return torsion_lines, torsion_notes diff --git a/python/cabledyn/model.py b/python/cabledyn/model.py index 7b2a776d..97a81963 100644 --- a/python/cabledyn/model.py +++ b/python/cabledyn/model.py @@ -655,8 +655,10 @@ def coupled_layout(self) -> tuple[tuple[int, PointKind], ...]: ``"fixed"``, ``"coupled"`` (Coupled or Vessel), ``"free"`` or ``"connect"``. On a point-system deck every line-bound point has a block, in deck POINTS order; on the coupled aggregate (finite-EI lines, bodies or - rods) only the Coupled points do. The host drives the ``"coupled"`` - blocks (:meth:`host_dofs`). + rods) only the Coupled points do: those of the ``EI = 0`` lines, then the + End A of every finite-EI line, then the End B of every finite-EI line + between two Coupled points (so such a point id appears once per line end). + The host drives the ``"coupled"`` blocks (:meth:`host_dofs`). """ with self._lock: self._require_host_coupling() diff --git a/python/tests/test_deck_file.py b/python/tests/test_deck_file.py index 0cf7ff28..62254259 100644 --- a/python/tests/test_deck_file.py +++ b/python/tests/test_deck_file.py @@ -157,7 +157,8 @@ def test_end_connection_duplicate_and_unsupported_topology_fail_preflight(tmp_pa ) moving = tmp_path / "moving-end-connection.dat" moving.write_text(moving_source, encoding="utf-8") - with pytest.raises(DeckFormatError, match="Fixed End B"): + # a Connect End B can neither hold the connection nor drive it (a Coupled/Vessel one can) + with pytest.raises(DeckFormatError, match="need End B on a Fixed, Coupled or Vessel point"): DeckFile.read(moving) @@ -2122,10 +2123,9 @@ def test_invalid_output_channels_fail_before_case_generation(tmp_path, channel, @pytest.mark.parametrize("channel", ["FairTen1", "AnchFz1", "AnchFH1"]) -def test_finite_ei_cable_shared_by_two_turbines_is_refused(tmp_path, channel): - # native build_one_hermite_cable: the coupled aggregate holds a finite-EI cable at a Fixed - # anchor, so a cable between two turbines (End B moving) is refused, end-force channels - # included +def test_finite_ei_cable_shared_by_two_turbines_runs_coupled(tmp_path, channel): + # native build_one_hermite_cable: the coupled aggregate drives a finite-EI cable between two + # turbines at both ends (End B on its own moving column), end-force channels included path = _chain_variant( tmp_path, ("1.607e9 -1.0 0.0 ", "1.607e9 -1.0 2.0e5 "), @@ -2133,8 +2133,7 @@ def test_finite_ei_cable_shared_by_two_turbines_is_refused(tmp_path, channel): ("2 Coupled 0.0", "2 Turbine1 0.0"), ('"FairTen1"', f'"{channel}"'), ) - with pytest.raises(DeckFormatError, match=r"requires End B \(the anchor\) to be a Fixed point"): - DeckFile.read(path, caller_driven=True) + assert channel in DeckFile.read(path, caller_driven=True).outputs def test_ei0_line_shared_by_two_turbines_keeps_its_end_force_channels(tmp_path): @@ -3979,7 +3978,7 @@ def test_stock_anchor_to_free_swap_needs_the_free_point_at_or_above_the_anchor() DeckFile.from_text(_free_leg_deck("-30.0", "-30.0")) # Fixed NodeA above the Free NodeB: an elevated hang-off already written upper end # first, so End B stays the Free point. - with pytest.raises(DeckFormatError, match="Fixed End B"): + with pytest.raises(DeckFormatError, match="need End B on a Fixed, Coupled or Vessel point"): DeckFile.from_text(_free_leg_deck("-10.0", "-30.0")) @@ -4188,7 +4187,8 @@ def test_section_curvature_channels_need_a_finite_ei_line(): ei0 = _edit(_TIMED, ("\nFairTen1\n", "\nFairTen1\nCurvX1N2\n")) with pytest.raises(DeckFormatError, match="section curvature components need a finite-EI line"): DeckFile.from_text(ei0) - # a farm-shared cable (two moving ends) runs on the compatibility route, which has no frame + # a farm-shared cable (two moving ends) runs on the cubic-Hermite route, which drives End B + # as a second moving end and carries the section frame from End A shared = _edit( _TURBINE_DECK, ("chain 0.1 20.0 1.0e9 -1.0 0.0 1.2", "chain 0.1 20.0 1.0e9 -1.0 1.0e4 1.2"), @@ -4197,13 +4197,13 @@ def test_section_curvature_channels_need_a_finite_ei_line(): ("100 WtrDpth\n", "100 WtrDpth\n0.1 dtM\n10.0 TMax\n"), ('"Point3FH"', '"CurvY1N5"'), ) - with pytest.raises(DeckFormatError, match="Fixed End B"): - DeckFile.from_text(shared) + assert "CurvY1N5" in DeckFile.from_text(shared).outputs -def test_viv_and_lift_flag_refused_on_a_finite_ei_line_with_two_moving_ends(): +def test_viv_and_lift_flag_on_a_finite_ei_line_with_two_moving_ends(): # native run_deck_driver: a farm-shared finite-EI line (Turbine1 to Turbine2) runs on the - # compatibility route, which carries no VIV: Cl > 0 and the lift file V are refused + # cubic-Hermite march with both ends driven, which carries VIV: Cl > 0 and the lift file V + # are accepted as on a line with a Fixed End B shared = _edit( _TURBINE_DECK, ("chain 0.1 20.0 1.0e9 -1.0 0.0 1.2", "chain 0.1 20.0 1.0e9 -1.0 1.0e4 1.2"), @@ -4212,14 +4212,40 @@ def test_viv_and_lift_flag_refused_on_a_finite_ei_line_with_two_moving_ends(): ("100 WtrDpth\n", "100 WtrDpth\n0.1 dtM\n10.0 TMax\n"), ) DeckFile.from_text(shared) - with pytest.raises(DeckFormatError, match="needs its End B fixed"): - DeckFile.from_text(_edit(shared, ("1.2 0.2 1.0 0.0\n", "1.2 0.2 1.0 0.0 0.8\n"))) - with pytest.raises(DeckFormatError, match=r"flag V \(VIV lift\) needs a line that carries VIV"): - DeckFile.from_text(_edit(shared, ("1 1 2 -\n", "1 1 2 V\n"))) + viv = _edit(shared, ("1.2 0.2 1.0 0.0\n", "1.2 0.2 1.0 0.0 0.8\n")) + DeckFile.from_text(viv) + DeckFile.from_text(_edit(viv, ("1 1 2 -\n", "1 1 2 V\n"))) # the same flag on a line with a Fixed End B is accepted DeckFile.from_text(_edit(_DYNAMIC, ("1 2 1 -\n", "1 2 1 V\n"))) +def test_finite_ei_line_between_two_coupled_points(): + # native finalize_checks: a finite-EI line may join two Coupled/Vessel points (both ends + # driven on the cubic-Hermite route); an EI = 0 line between them, or a finite-EI line to a + # Connect point, stays refused + deck = ( + "title\n" + "--------------------- LINE TYPES ---------------------------------------\n" + "chain 0.1 20.0 1.0e9 -1.0 1.0e4 1.2 0.2 1.0 0.0\n" + "--------------------- POINTS -------------------------------------------\n" + "1 Coupled 0 0 -10 0 0 0 0\n" + "2 Vessel 300 0 -10 0 0 0 0\n" + "--------------------- LINES --------------------------------------------\n" + "1 1 2 -\n" + "--------------------- SECTIONS -----------------------------------------\n" + "1 chain 620 30\n" + "--------------------- OPTIONS ------------------------------------------\n" + "100 WtrDpth\n0.1 dtM\n10.0 TMax\n" + "--------------------- OUTPUTS ------------------------------------------\n" + "FairTen1\n" + "--------------------- need this line -----------------------------------\n" + ) + DeckFile.from_text(deck) + ei0 = _edit(deck, ("chain 0.1 20.0 1.0e9 -1.0 1.0e4 1.2", "chain 0.1 20.0 1.0e9 -1.0 0.0 1.2")) + with pytest.raises(DeckFormatError, match="End B must be Fixed"): + DeckFile.from_text(ei0) + + @pytest.mark.parametrize( ("edit", "message"), [ @@ -4774,3 +4800,27 @@ def test_viv_rms_window_option_is_non_negative(): DeckFile.from_text(_edit(base, ("50.0 WtrDpth\n", "50.0 WtrDpth\n0.25 VIVrmsWindow\n"))) with pytest.raises(DeckFormatError, match="VIVrmsWindow"): DeckFile.from_text(_edit(base, ("50.0 WtrDpth\n", "50.0 WtrDpth\n-1.0 VIVrmsWindow\n"))) + + +def test_as_laid_statics_refused_on_a_finite_ei_line_between_two_moving_points(): + # native build_one_hermite_cable: no anchored end to lay the line from + deck = ( + "title\n" + "--------------------- LINE TYPES ---------------------------------------\n" + "chain 0.1 20.0 1.0e9 -1.0 1.0e4 1.2 0.2 1.0 0.0\n" + "--------------------- POINTS -------------------------------------------\n" + "1 Coupled 0 0 -10 0 0 0 0\n" + "2 Vessel 300 0 -10 0 0 0 0\n" + "--------------------- LINES --------------------------------------------\n" + "1 1 2 -\n" + "--------------------- SECTIONS -----------------------------------------\n" + "1 chain 620 30\n" + "--------------------- OPTIONS ------------------------------------------\n" + "100 WtrDpth\n0.1 dtM\n10.0 TMax\n0.5 frictionMu\nasLaid staticsFriction\n" + "--------------------- OUTPUTS ------------------------------------------\n" + "FairTen1\n" + "--------------------- need this line -----------------------------------\n" + ) + with pytest.raises(DeckFormatError, match="has a moving End B"): + DeckFile.from_text(deck) + DeckFile.from_text(deck.replace("asLaid staticsFriction", "none staticsFriction")) diff --git a/python/tests/test_deck_native_parity.py b/python/tests/test_deck_native_parity.py index eb00bbe5..2abb9c5e 100644 --- a/python/tests/test_deck_native_parity.py +++ b/python/tests/test_deck_native_parity.py @@ -532,7 +532,9 @@ def test_modal_analysis_follows_the_native_deck_rules(): _rejects(_modes(_section(_HELD, *_FAILURE)), "no BODIES, RODS, Connect/Free points or FAILURE") -def test_modal_analysis_needs_a_fixed_end_b_on_finite_ei_lines(): +def test_modal_analysis_holds_a_moving_end_b_of_a_finite_ei_line(): + # the modes hold both line ends: a finite-EI line shared by two turbines is accepted (its + # moving End B held at its static position, as End A is) text = ( "title\n" f"{_BAR} LINE TYPES {_BAR}\n" @@ -549,7 +551,7 @@ def test_modal_analysis_needs_a_fixed_end_b_on_finite_ei_lines(): "100 WtrDpth\n0.1 dtM\n1.0 TMax\n5 nModes\n" f"{_BAR} need this line {_BAR}\n" ) - _rejects(text, "nModes on finite-EI lines needs every End B Fixed") + assert DeckFile.from_text(text).option("nModes").values == ("5",) def test_mixed_aggregate_route_takes_no_modal_analysis(): @@ -1113,6 +1115,73 @@ def _one_end_rod(rod_kind: str) -> str: ) +def _torsion_between_bodies(body2_row: str, end_b: str = "2 Body2 0.0 0.0 0.0") -> str: + """The torsional line of _TORSION_DYN between two bodies: End A on body 1, End B on body 2.""" + return _edit( + _torsion_body( + "1 Rigid6 0 0 -50 0 0 0 1.0e5 97.56 0 0 0 0 0 1.0e3 1.0e3 1.0e3\n" + body2_row + ), + ("2 Fixed 100.0 0.0 -50.0 0 0 0 0", end_b + " 0 0 0 0"), + ) + + +def test_torsion_between_two_bodies_follows_the_native_checks(): + # a line restrained in torsion between two Rigid6 bodies: both end frames on their bodies + DeckFile.from_text( + _torsion_between_bodies("2 Rigid6 100 0 -50 0 0 0 1.0e5 97.56 0 0 0 0 0 1.0e3 1.0e3 1.0e3") + ) + # End B on a Point3 buoy or a rod end stops by name, as End A does + _rejects( + _torsion_between_bodies("2 Point3 100 0 -50 0 0 0 1.0e5 97.56 0 0 0 0 0"), + "a torsional END CONNECTION on a body needs a Rigid6 body", + ) + rod_end = _edit( + _torsion_body("1 Rigid6 0 0 -50 0 0 0 1.0e5 97.56 0 0 0 0 0 1.0e3 1.0e3 1.0e3"), + ( + 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 Free 100 0 -50 110 0 -50 2 -\n{_BAR} POINTS {_BAR}", + ), + ("2 Fixed 100.0 0.0 -50.0 0 0 0 0", "2 Rod1A 100.0 0.0 -50.0 0 0 0 0"), + ) + _rejects(rod_end, "a torsional END CONNECTION on a rod end is not supported") + + +_RIGID6_B = "2 Rigid6 100 0 -50 0 0 0 1.0e5 97.56 0 0 0 0 0 1.0e3 1.0e3 1.0e3" + + +def test_multibody_cable_ends_follow_the_native_march_checks(): + # End B on a Free/Connect point, a Point3 buoy or a Coupled point stops by name on the march + for end_b, message in [ + ("2 Free 100.0 0.0 -50.0", "a cable end on a Free/Connect point or a Point3 buoy"), + ("2 Coupled 100.0 0.0 -50.0", "a Coupled/Vessel End B"), + ]: + pinned = _edit( + _torsion_between_bodies(_RIGID6_B, end_b), + (_TORSION_ROW_A, "1 A Pinned 1 0 0\n"), + ("1 B Rigid 1 0 0 Rigid 0 0 1 720", "1 B Pinned 1 0 0"), + _NO_TORSION_OUTPUTS, + ) + _rejects(pinned, message) + _rejects( + _torsion_between_bodies("2 Point3 100 0 -50 0 0 0 1.0e5 97.56 0 0 0 0 0"), + "a torsional END CONNECTION on a body needs a Rigid6 body", + ) + # a connected or torsional end on a body needs the monolithic scheme, at either end: a + # torsion frame at a bending-pinned End A included + staggered = ("0.1 dtM\n", "0.1 dtM\nstaggered bodyScheme\n") + DeckFile.from_text(_torsion_between_bodies(_RIGID6_B)) + _rejects(_edit(_torsion_between_bodies(_RIGID6_B), staggered), "needs bodyScheme monolithic") + torsion_pinned_a = _edit( + _torsion_body("1 Rigid6 0 0 -50 0 0 0 1.0e5 97.56 0 0 0 0 0 1.0e3 1.0e3 1.0e3"), + (_TORSION_ROW_A, "1 A Pinned 1 0 0 Rigid 0 0 1 0\n"), + ) + DeckFile.from_text(torsion_pinned_a) + _rejects(_edit(torsion_pinned_a, staggered), "needs bodyScheme monolithic") + + 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( @@ -1177,9 +1246,9 @@ def test_torsion_scope_rules_follow_the_native_checks(): ), ("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", + # a line between two rods takes its bending connections (a line between two objects); + # its torsion at the End B rod end stops + "line 1: a torsional END CONNECTION on a rod end is not supported at End B", ) _rejects( _options(_edit(rod_end, ("1 spar Fixed", "1 spar Coupled")), "rod.motion motionFile"), @@ -1203,21 +1272,23 @@ def test_torsion_scope_rules_follow_the_native_checks(): ), ) DeckFile.from_text(attachments) # a torsional line with ATTACHMENTS is accepted - # restrained at both ends, End B must be Fixed + # restrained at both ends, End B must hold its frame: Fixed, Coupled/Vessel (driven) or a + # Rigid6 body point (a line between two objects) _rejects( _torsion_two_moving("1 A Pinned 1 0 0 Rigid 0 0 1 0\n"), - "torsional END CONNECTIONS require a finite-EI line with Fixed End B; line 1 has two " - "moving ends", + "torsional END CONNECTIONS need End B on a Fixed, Coupled or Vessel point or a Rigid6 body " + 'point; line 1 ends on a "free" point', ) - # one restrained end only, or none, is ignored: the same verdict as the six-column rows + # one restrained end only, or none, is ignored: the same verdict as the six-column rows (here + # the multibody march's, which ends no finite-EI cable on a Free point) one_end = _edit(_torsion_two_moving("1 A Pinned 1 0 0 Free 0 0 1 0\n"), _NO_TORSION_OUTPUTS) six = _edit( _torsion_two_moving("1 A Pinned 1 0 0\n"), ("1 B Pinned 1 0 0 Rigid 0 0 1 720", "1 B Pinned 1 0 0"), _NO_TORSION_OUTPUTS, ) - DeckFile.from_text(six) - DeckFile.from_text(one_end) + for deck in (six, one_end): + _rejects(deck, "a cable end on a Free/Connect point or a Point3 buoy") both_free = _edit( _TORSION, (_TORSION_ROW_A, "1 A Rigid 1 0 0 Free 0 0 1 0\n"), diff --git a/python/tests/test_host_rotation.py b/python/tests/test_host_rotation.py index 6e2aaffe..794d515f 100644 --- a/python/tests/test_host_rotation.py +++ b/python/tests/test_host_rotation.py @@ -5,7 +5,10 @@ 100 m along +x from the Coupled fairlead (0, 0, -50) to a Fixed anchor, both ends clamped and restrained in torsion, a negligible polar inertia (the quasi-static torsion). Rolling the fairlead by phi about the line axis twists the line by -phi, -and the line returns the torque GJ phi / L to the host about that axis. +and the line returns the torque GJ phi / L to the host about that axis. With End B on a +second Coupled point (a line between two moving points) the host turns both end frames: +rolling End A by +phi and End B by -phi about the line twists it by -2 phi, and each end +returns its share of the torque to its own block. """ from __future__ import annotations @@ -32,7 +35,7 @@ BOX = Path(__file__).resolve().parents[2] / "tests" / "data" / "foam_esflowc_box_points.dat" -def _deck(tmp_path: Path, tors: str = "Rigid") -> Path: +def _deck(tmp_path: Path, tors: str = "Rigid", end_b: str = "Fixed") -> Path: mass = 1025.0 * 0.25 * math.pi * 0.04 outputs = "Torq1N1\nTorq1N41\nTwist1\n" if tors != "Free" else "FairTen1\n" text = ( @@ -41,7 +44,7 @@ def _deck(tmp_path: Path, tors: str = "Rigid") -> Path: "(-) (m) (kg/m) (N) (-) (Nm2) (N) (Nm2) (kgm) (kgm) (-) (-) (-) (-)\n" f"cab 0.2 {mass:.16e} 1.0e7 0.0 1.0e6 1.0e8 5.0e4 1.0 1.0e-9 0.0 0.0 0.0 0.0\n" "--- POINTS ---\nID Type X Y Z Mass Vol CdA Ca\n(-) (-) (m) (m) (m) (kg) (m3) (m2) (-)\n" - "1 Coupled 0.0 0.0 -50.0 0 0 0 0\n2 Fixed 100.0 0.0 -50.0 0 0 0 0\n" + f"1 Coupled 0.0 0.0 -50.0 0 0 0 0\n2 {end_b} 100.0 0.0 -50.0 0 0 0 0\n" "--- LINES ---\nID NodeA NodeB Outputs\n(-) (-) (-) (-)\n1 1 2 -\n" "--- SECTIONS ---\nLineID LineType Length NumSegs\n(-) (-) (m) (-)\n1 cab 100.0 40\n" "--- END CONNECTIONS ---\n" @@ -51,7 +54,7 @@ def _deck(tmp_path: Path, tors: str = "Rigid") -> Path: "--- OPTIONS ---\n9.80665 g\n1025.0 rhoW\n0.05 dtM\n0.0 TMax\n" f"--- OUTPUTS ---\n{outputs}--- END ---\n" ) - path = tmp_path / f"rotation_{tors.lower()}.dat" + path = tmp_path / f"rotation_{tors.lower()}_{end_b.lower()}.dat" path.write_text(text, encoding="utf-8") return path @@ -127,3 +130,29 @@ def test_point_route_takes_rotations_and_returns_no_moment(): dcm = np.repeat(_roll(0.3), nb, axis=0) model.update_rotations(dcm, np.zeros((nb, 3)), np.zeros((nb, 3))) assert np.array_equal(model.coupled_moments(), np.zeros(3 * nb)) + + +def test_host_turns_both_end_frames_of_a_line_between_two_coupled_points(tmp_path): + # End B is a second host-driven block: its rotation turns End B's torsion frame + rate = math.radians(60.0) + with CableDyn() as model: + model.init_deck_rotating(_deck(tmp_path, end_b="Coupled")) + assert model.n_coupled_dof == 6 + q, v, a = model.get_coupled_motion() + for k in range(1, 11): + phi = rate * DT * k + dcm = np.concatenate([_roll(phi), _roll(-phi)]) + model.update_rotations(dcm, [[rate, 0.0, 0.0], [-rate, 0.0, 0.0]], np.zeros((2, 3))) + model.step(DT, q, v, a) + m = model.coupled_moments() + torque = GJ * 2.0 * phi / LENGTH + assert m[0] == pytest.approx(-torque, abs=1.0e-6 * GJ) + assert m[3] == pytest.approx(torque, abs=1.0e-6 * GJ) + assert np.all(np.abs(m[[1, 2, 4, 5]]) <= 1.0e-6 * GJ) + assert model.channel("Twist1") == pytest.approx(-math.degrees(2.0 * phi), abs=1.0e-6) + # equal rolls of both ends are a rigid roll of the line: the torque returns to zero + dcm = np.concatenate([_roll(0.3), _roll(0.3)]) + for _ in range(3): + model.update_rotations(dcm, np.zeros((2, 3)), np.zeros((2, 3))) + model.step(DT, q, v, a) + assert np.all(np.abs(model.coupled_moments()) <= 1.0e-6 * GJ) diff --git a/python/tests/test_two_moving_ends_capi.py b/python/tests/test_two_moving_ends_capi.py new file mode 100644 index 00000000..d197998a --- /dev/null +++ b/python/tests/test_two_moving_ends_capi.py @@ -0,0 +1,104 @@ +# SPDX-License-Identifier: Apache-2.0 +"""A finite-EI line between two Coupled points driven through the C API host recipe. + +The deck is a 100 m suspended power cable between Coupled points 1 (0, 0, -20) and 2 +(80, 0, -20), no seabed, no drag. CableDyn_GetCoupledLayout names one block per line end +(End A, then End B after the fairleads of every finite-EI line); the host drives both +blocks, steps and reads the loads (CalcOutput) and moments (GetCoupledMoments): + +* held at rest, the two end loads carry the line's submerged weight w L between them and, + the hang being symmetric, mirror each other (Fx_A = -Fx_B, Fz_A = Fz_B = -w L / 2); +* the End A load equals that of the same line built with a Fixed End B (the established + fairlead route), to the solver tolerance; +* moving the End B block alone (a slow surge away from End A) moves node 1 to the host's + position and changes both end loads: End B's block is driven, not held. +""" + +from __future__ import annotations + +import math +from pathlib import Path + +import numpy as np +import pytest + +try: + import cabledyn._lib # noqa: F401 (loads the shared library) +except (ImportError, OSError) as exc: # a missing library raises OSError + pytest.skip(f"CableDyn shared library not available: {exc}", allow_module_level=True) + +from cabledyn.model import CableDyn + +DT = 0.05 +MASS = 60.0 +DIAM = 0.20 +LENGTH = 100.0 +W_SUB = (MASS - 1025.0 * math.pi * DIAM**2 / 4.0) * 9.80665 + + +def _deck(tmp_path: Path, end_b: str) -> Path: + text = ( + "two moving ends host recipe\n--- LINE TYPES ---\n" + "Name Diam Mass EA BA EI Cdn Cdt Can Cat\n(-) (m) (kg/m) (N) (-) (Nm2) (-) (-) (-) (-)\n" + f"pcable {DIAM} {MASS} 8.0e8 0.0 2.0e4 0.0 0.0 1.0 0.0\n" + "--- POINTS ---\nID Type X Y Z Mass Vol CdA Ca\n(-) (-) (m) (m) (m) (kg) (m3) (m2) (-)\n" + f"1 Coupled 0.0 0.0 -20.0 0 0 0 0\n2 {end_b} 80.0 0.0 -20.0 0 0 0 0\n" + "--- LINES ---\nID NodeA NodeB Outputs\n(-) (-) (-) (-)\n1 1 2 -\n" + "--- SECTIONS ---\nLineID LineType Length NumSegs\n(-) (-) (m) (-)\n1 pcable 100.0 40\n" + "--- OPTIONS ---\n9.80665 g\n1025.0 rhoW\n0.05 dtM\n0.0 TMax\n" + "--- OUTPUTS ---\nFairTen1\n--- END ---\n" + ) + path = tmp_path / f"two_end_{end_b.lower()}.dat" + path.write_text(text, encoding="utf-8") + return path + + +def test_layout_names_both_ends_and_the_host_drives_them(tmp_path): + with CableDyn() as model: + model.init_deck(_deck(tmp_path, "Coupled")) + assert model.coupled_layout() == ((1, "coupled"), (2, "coupled")) + assert list(model.host_dofs()) == [0, 1, 2, 3, 4, 5] + q, v, a = model.get_coupled_motion() + assert np.allclose(q.reshape(2, 3), [[0.0, 0.0, -20.0], [80.0, 0.0, -20.0]]) + # held at rest: the two ends carry the weight and mirror each other + for _ in range(5): + model.step(DT, q, v, a) + f = model.calc_output().reshape(2, 3) + print(f"held: End A {f[0]}, End B {f[1]} N; w L / 2 = {W_SUB * LENGTH / 2:.6e} N") + assert f[0, 2] == pytest.approx(-W_SUB * LENGTH / 2.0, rel=1.0e-6) + assert f[1, 2] == pytest.approx(f[0, 2], rel=1.0e-8) + assert f[1, 0] == pytest.approx(-f[0, 0], rel=1.0e-8) + assert np.all(np.abs(model.coupled_moments()) <= 1.0e-6) + # End A equals the same line with a Fixed End B (the established route) at End A + with CableDyn() as fixed: + fixed.init_deck(_deck(tmp_path, "Fixed")) + assert fixed.coupled_layout() == ((1, "coupled"),) + qf, vf, af = fixed.get_coupled_motion() + for _ in range(5): + fixed.step(DT, qf, vf, af) + ff = fixed.calc_output() + print(f"End A load, two moving ends {f[0]}, Fixed End B {ff} N") + assert np.allclose(f[0], ff, rtol=0.0, atol=1.0e-6 * np.linalg.norm(ff)) + + +def test_the_end_b_block_is_driven(tmp_path): + with CableDyn() as model: + model.init_deck(_deck(tmp_path, "Coupled")) + q, v, a = model.get_coupled_motion() + model.step(DT, q, v, a) + f0 = model.calc_output().copy() + n_move = 40 + for k in range(1, n_move + 1): + qk = q.copy() + qk[3] += 2.0 * 0.5 * (1.0 - math.cos(math.pi * k / n_move)) + vk = np.zeros(6) + vk[3] = math.pi / (n_move * DT) * math.sin(math.pi * k / n_move) + ak = np.zeros(6) + ak[3] = (math.pi / (n_move * DT)) ** 2 * math.cos(math.pi * k / n_move) + model.step(DT, qk, vk, ak) + q1, _, _ = model.get_coupled_motion() + assert np.array_equal(q1, qk) + assert q1[3] == pytest.approx(82.0) + f1 = model.calc_output() + print(f"End B surged 2 m: end loads {f0} -> {f1} N") + assert np.max(np.abs(f1 - f0)) > 0.01 * np.max(np.abs(f0)) diff --git a/src/CableDyn_CAPI.f90 b/src/CableDyn_CAPI.f90 index 1cf5a9e8..13e7451b 100644 --- a/src/CableDyn_CAPI.f90 +++ b/src/CableDyn_CAPI.f90 @@ -2101,7 +2101,8 @@ SUBROUTINE coupled_layout(h, ids, types, err_stat) !! the line-bound points of every type in deck POINT order. Aggregate route: the moving !! points, i.e. the EI=0-bound Coupled/Vessel points in deck POINT order, then the fairlead !! (End A, which the coupled cable builder requires to be Coupled/Vessel) of each finite-EI - !! line in deck LINE order. + !! line in deck LINE order, then the moving End B of each finite-EI line between two moving + !! points, in deck LINE order (cable_col_b). TYPE(CD_C_Handle), POINTER, INTENT(INOUT) :: h INTEGER, ALLOCATABLE, INTENT(OUT) :: ids(:), types(:) INTEGER(C_INT), INTENT(OUT) :: err_stat @@ -2134,9 +2135,9 @@ SUBROUTINE coupled_layout(h, ids, types, err_stat) nm = CD_AGG_NMovingPoints(h%agg, es, em) nsys = 0 IF (h%agg%has_sys) nsys = h%agg%ncp_sys - IF (es /= CD_AGG_OK .OR. nm /= nsys + h%agg%ncable) THEN + IF (es /= CD_AGG_OK .OR. nm /= nsys + h%agg%ncable + h%agg%ncable_b) THEN CALL set_status(h, CD_C_SOLVE_FAIL, 'CableDyn_GetCoupledLayout: the moving points of the model are not '// & - 'its Coupled points and cable fairleads', err_stat) + 'its Coupled points and cable ends', err_stat) RETURN END IF ALLOCATE (ids(nm), types(nm)) @@ -2155,6 +2156,11 @@ SUBROUTINE coupled_layout(h, ids, types, err_stat) DO i = 1, h%agg%ncable ids(nsys + i) = h%agg%cable_points(1, i) types(nsys + i) = CD_POINT_COUPLED + ! a line between two moving points: its End B has a block of its own + IF (h%agg%cable_col_b(i) > 0) THEN + ids(h%agg%cable_col_b(i)) = h%agg%cable_points(2, i) + types(h%agg%cable_col_b(i)) = CD_POINT_COUPLED + END IF END DO END SUBROUTINE coupled_layout diff --git a/src/CableDyn_DeckDriver.f90 b/src/CableDyn_DeckDriver.f90 index 2fc338ce..24401cab 100644 --- a/src/CableDyn_DeckDriver.f90 +++ b/src/CableDyn_DeckDriver.f90 @@ -72,10 +72,6 @@ MODULE CableDyn_DeckDriver CD_Detach_System_LineEnds, & CD_SYSTEM_OK, CD_POINT_FIXED, CD_POINT_COUPLED, CD_POINT_FREE, CD_POINT_CONNECT, & CD_LINE_END_A, CD_LINE_END_B - USE CableDyn_FiniteEIModel, ONLY: CD_FiniteEIModelType, CD_Init_FiniteEI_Model, CD_Step_FiniteEI_Model, & - CD_Get_FiniteEI_Model_State, CD_End_FiniteEI_Model, & - CD_FiniteEI_Model_Is_Initialized, CD_Set_FiniteEI_Model_Load, & - CD_Set_FiniteEI_Model_PrescribedDofs USE CableDyn_HermiteArch, ONLY: CD_FiniteEI_Hermite_Arch_Seed_LengthMatched, CD_HARCH_OK USE CableDyn_HermiteCable, ONLY: CD_HermiteCable_Curvature, & CD_HermiteCable_Peak_Curvature, CD_HermiteCable_Axial_Resultant, & @@ -109,6 +105,7 @@ MODULE CableDyn_DeckDriver CD_HermiteCable_Dyn_VIV_Node_Lift, & CD_HermiteCable_Dyn_Set_Control_Seabed, & CD_HermiteCable_Dyn_Max_Step_Rotation, CD_HermiteCable_Dyn_Energy, & + CD_HermiteCable_Dyn_Momentum, & CD_HermiteCable_Attachment_Drag, CD_HermiteCable_Dyn_Torsion_State, & CD_HermiteCable_Dyn_Element_Twist, CD_HermiteCable_Dyn_Coupling_Tension, & CD_HermiteCable_Dyn_Node_Torque, CD_HermiteCable_Dyn_End_Twist @@ -132,6 +129,7 @@ MODULE CableDyn_DeckDriver CD_HFMF_GetNodePositions, CD_HFMF_UpdateStates, & CD_HFMF_CalcOutput, CD_HFMF_Snapshot, CD_HFMF_Restore, & CD_HFMF_SetCoupledKinematics, CD_HFMF_GetCoupledKinematics, & + CD_HFMF_Set_Moving_End_B, CD_HFMF_GetEndBKinematics, & CD_HFMF_End, CD_HFMF_OK USE CableDyn_VIV, ONLY: CD_VIV_DEFAULT_DF, CD_VIV_DEFAULT_CF, CD_VIV_NM USE CableDyn_Hydro, ONLY: CD_Airy_Wave_Kinematics_Precomputed, CD_Component_Wave_Kinematics, & @@ -260,7 +258,11 @@ MODULE CableDyn_DeckDriver ! the next multibody run start body 1 with the given velocity and angular velocity and record ! its full-precision state after every step; CD_Multibody_Probe_Get returns the record. PUBLIC :: CD_Multibody_Probe_Arm, CD_Multibody_Probe_Get - INTEGER, PARAMETER, PUBLIC :: CD_MB_PROBE_NCOL = 29 + ! Verification hook: the largest number of static passes of solve_body_equilibrium (its + ! default when n <= 0), to reach its non-convergence report in a test. + PUBLIC :: CD_Body_Static_Pass_Limit + INTEGER, SAVE :: body_static_pass_limit = 0 + INTEGER, PARAMETER, PUBLIC :: CD_MB_PROBE_NCOL = 56 LOGICAL, SAVE :: probe_armed = .FALSE. REAL(wp), SAVE :: probe_v0(3) = 0.0_wp, probe_w0(3) = 0.0_wp REAL(wp), ALLOCATABLE, SAVE :: probe_rec(:, :) @@ -497,12 +499,6 @@ 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 @@ -832,6 +828,11 @@ MODULE CableDyn_DeckDriver ! angular velocity and acceleration (3,t); an end connection on a vessel point turns with R. LOGICAL :: has_rot = .FALSE. REAL(wp), ALLOCATABLE :: rot(:, :, :), omega(:, :), alpha(:, :) + ! TURBINES rows (a standalone farm deck): each turbine's rotation turb_rot(3,3,J,t) (turbine to + ! global, from the row's quaternion) and its global-axis angular velocity and acceleration; a + ! finite-EI line end on a Turbine point turns its connection and torsion frames with it. + LOGICAL :: has_turb_rot = .FALSE. + REAL(wp), ALLOCATABLE :: turb_rot(:, :, :, :), turb_omega(:, :, :), turb_alpha(:, :, :) ! Roll column of motionFile point rows (read only on a deck with a torsional line): roll(p, t) ! [rad] of the line end frames at point p about their directors, added to the END ! CONNECTIONS Pretwist of those ends; has_roll when some row gives one. @@ -982,6 +983,17 @@ MODULE CableDyn_DeckDriver ! the committed cable states; no state of their own. LOGICAL, ALLOCATABLE :: cab_clamp(:) REAL(wp), ALLOCATABLE :: cab_moment(:, :), cab_fend(:, :), cab_mend(:, :), cab_f0(:, :), cab_m0(:, :) + ! A cable between two objects (End B on a body point or a rod end, its End A on an object or a + ! Fixed point): cab_kind_b/cab_obj_b/cab_off_b describe End B as cab_kind/cab_obj/cab_off do + ! End A (cab_kind_b 0: a Fixed End B, held), cab_clamp_b its connection or torsion frame on its + ! object, and the *_b loads those of End B on its object. cab_imp: the cable is re-stepped at + ! every outer iteration of the monolithic step with its end stiffness in the Newton matrix + ! (cab_clamp, or an End B on an object: the cable then couples the groups of its two objects). + INTEGER, ALLOCATABLE :: cab_kind_b(:), cab_obj_b(:) + REAL(wp), ALLOCATABLE :: cab_off_b(:, :) + LOGICAL, ALLOCATABLE :: cab_clamp_b(:), cab_imp(:) + REAL(wp), ALLOCATABLE :: cab_force_b(:, :), cab_moment_b(:, :), cab_fend_b(:, :), cab_mend_b(:, :) + REAL(wp), ALLOCATABLE :: cab_f0_b(:, :), cab_m0_b(:, :) LOGICAL, ALLOCATABLE :: line_is_cable(:) INTEGER, ALLOCATABLE :: line_obj_index(:) TYPE(RigidBodyState), ALLOCATABLE :: rigid(:), old_rigid(:) @@ -999,7 +1011,9 @@ MODULE CableDyn_DeckDriver INTEGER :: tan_age = HUGE(1), last_outer = 0, n_refresh = 0 ! clamped-cable Jacobian reuse: each clamped cable's finite-difference contribution to the ! junction Jacobian over its object's group (cab_jac(1:n, 1:n, c), rows and columns from the - ! group's first coordinate), the steps since it was built and the step size it was built for + ! group's first coordinate; for a cable between the objects of two groups, the first group's + ! coordinates then the second's), the steps since it was built and the step size it was built + ! for REAL(wp), ALLOCATABLE :: cab_jac(:, :, :) INTEGER :: cab_age = HUGE(1) REAL(wp) :: cab_dt = CD_ZERO @@ -1077,30 +1091,6 @@ MODULE CableDyn_DeckDriver LOGICAL, ALLOCATABLE :: col_roll(:) END TYPE - TYPE :: FiniteDeckModel - TYPE(CD_FiniteEIModelType) :: model - INTEGER :: n_elem = 0 - LOGICAL :: has_seabed = .FALSE. - LOGICAL :: has_bathymetry = .FALSE. - REAL(wp) :: seabed_z_floor = CD_ZERO - TYPE(CD_BathymetryType) :: bathymetry - REAL(wp), ALLOCATABLE :: l0(:) - REAL(wp), ALLOCATABLE :: ea(:) - REAL(wp), ALLOCATABLE :: ei(:) - REAL(wp), ALLOCATABLE :: base_f_ext(:) - REAL(wp), ALLOCATABLE :: diam(:) - REAL(wp), ALLOCATABLE :: cdn(:) - REAL(wp), ALLOCATABLE :: cdt(:) - REAL(wp), ALLOCATABLE :: can(:) - REAL(wp), ALLOCATABLE :: cat(:) - REAL(wp), ALLOCATABLE :: seabed_kn(:) - REAL(wp), ALLOCATABLE :: seabed_cn(:) - REAL(wp), ALLOCATABLE :: q_work(:), v_work(:), a_work(:) - REAL(wp), ALLOCATABLE :: f_ext_work(:), contact_work(:), env_work(:) - REAL(wp), ALLOCATABLE :: q_fixed_work(:), v_fixed_work(:), a_fixed_work(:) - INTEGER, ALLOCATABLE :: free_map_work(:) - END TYPE - TYPE :: CD_LineInitSummary !! Engineering quantities at the converged static initial condition. The !! fairlead force is the force exerted by the line on public End A and the @@ -1554,231 +1544,26 @@ SUBROUTINE init_deck_system_from_parsed(types, points, lines, sections, opts, sy END IF END SUBROUTINE init_deck_system_from_parsed - SUBROUTINE init_finite_deck_models(types, points, lines, sections, opts, models, ErrStat, ErrMsg, bathymetry) - !! Initialize persistent finite-EI dynamic line models from a parsed deck. - !! This deck bridge supports held/prescribed translational endpoints, structural - !! submerged weight, normal seabed contact, regularized seabed friction, and - !! translational current/wave forcing. - TYPE(DeckLineType), INTENT(IN) :: types(:) - TYPE(DeckPoint), INTENT(IN) :: points(:) - TYPE(DeckLine), INTENT(IN) :: lines(:) - TYPE(DeckSection), INTENT(IN) :: sections(:) - TYPE(DeckOptions), INTENT(IN) :: opts - TYPE(FiniteDeckModel), ALLOCATABLE, INTENT(OUT) :: models(:) - INTEGER, INTENT(OUT) :: ErrStat - CHARACTER(*), INTENT(OUT) :: ErrMsg - TYPE(CD_BathymetryType), INTENT(IN), OPTIONAL :: bathymetry - - INTEGER :: i, es - CHARACTER(1024) :: em - - ErrStat = CD_DECKDRV_OK - ErrMsg = '' - IF (.NOT. all_lines_have_finite_ei(types, lines, sections)) THEN - CALL fail(ErrStat, ErrMsg, 'mixed EI=0 and finite-EI dynamic decks are not supported by this entry point') - RETURN - END IF - ! This compatibility route (a finite-EI deck with a line whose End B is not Fixed) solves - ! its statics without seabed friction: fail closed on the as-laid policy instead of - ! starting from a frictionless equilibrium reported as the as-laid one. - IF (opts%has_friction .AND. opts%static_friction == CD_STATIC_FRICTION_AS_LAID) THEN - CALL fail(ErrStat, ErrMsg, 'OPTION staticsFriction asLaid is not applied by the finite-EI route of a deck '// & - 'whose line has a moving End B (End B not Fixed); hold End B at a Fixed point or use '// & - 'staticsFriction none') - RETURN - END IF - - ALLOCATE (models(SIZE(lines))) - DO i = 1, SIZE(lines) - IF (PRESENT(bathymetry)) THEN - CALL init_one_finite_model(lines(i), sections, types, points, opts, models(i), es, em, bathymetry=bathymetry) - ELSE - CALL init_one_finite_model(lines(i), sections, types, points, opts, models(i), es, em) - END IF - IF (es /= CD_DECKDRV_OK) THEN - CALL end_finite_models(models) - ErrStat = es - ErrMsg = em - RETURN - END IF - END DO - END SUBROUTINE init_finite_deck_models - - SUBROUTINE init_one_finite_model(ln, sections, types, points, opts, deck_model, ErrStat, ErrMsg, bathymetry) - !! Initialize one finite-EI Cosserat dynamic model from a deck LINE. Torque-tension coupling - !! (GJ|K) is a cubic-Hermite cable feature and fails closed here. - TYPE(DeckLine), INTENT(IN) :: ln - TYPE(DeckSection), INTENT(IN) :: sections(:) - TYPE(DeckLineType), INTENT(IN) :: types(:) - TYPE(DeckPoint), INTENT(IN) :: points(:) - TYPE(DeckOptions), INTENT(IN) :: opts - TYPE(FiniteDeckModel), INTENT(INOUT) :: deck_model - INTEGER, INTENT(OUT) :: ErrStat - CHARACTER(*), INTENT(OUT) :: ErrMsg - TYPE(CD_BathymetryType), INTENT(IN), OPTIONAL :: bathymetry - - TYPE(GenAlphaConfig) :: dynamic_cfg - INTEGER, ALLOCATABLE :: conn(:, :), fixed_dofs(:) - REAL(wp), ALLOCATABLE :: nodes_ref(:, :), q0(:), v0(:), f_ext(:), f3(:), contact_f(:) - REAL(wp), ALLOCATABLE :: ea(:), gas(:), ei(:), gj(:), rho_a(:), i_rt(:), i_rn(:), diam(:), mpl(:) - REAL(wp), ALLOCATABLE :: gas_in(:), gj_in(:), i_rt_in(:), i_rn_in(:) - REAL(wp), ALLOCATABLE :: load_per_length(:, :), w(:) - REAL(wp) :: anchor(3), fairlead(3) - INTEGER :: pa, pb, es, nnode, ndof - CHARACTER(1024) :: em - - ErrStat = CD_DECKDRV_OK - ErrMsg = '' - ! This compatibility model prescribes both endpoint translations and predates - ! the Hermite end-connection residual. Never accept a declared bending - ! connection here: doing so would silently replace it with a pinned end if a - ! future dispatcher change made this route reachable for that deck. - IF (ALLOCATED(ln%att)) THEN - CALL fail(ErrStat, ErrMsg, 'finite-EI two-moving-end compatibility solver does not support '// & - 'ATTACHMENTS; use a Fixed End B'); RETURN - END IF - IF (ALLOCATED(ln%stf)) THEN - CALL fail(ErrStat, ErrMsg, 'finite-EI two-moving-end compatibility solver does not support '// & - 'STIFFENERS; use a Fixed End B'); RETURN - END IF - IF (opts%friction_mu_axial > CD_ZERO) THEN - CALL fail(ErrStat, ErrMsg, 'the finite-EI two-moving-end compatibility solver has isotropic seabed '// & - 'friction only; remove frictionMuAxial/frictionMuLateral') - RETURN - END IF - IF (ANY(ln%endconn_mode /= CD_ENDCONN_PINNED)) THEN - CALL fail(ErrStat, ErrMsg, 'finite-EI two-moving-end compatibility solver does not support '// & - 'END CONNECTIONS; use a Fixed End B') - RETURN - END IF - BLOCK - INTEGER :: js - DO js = 1, SIZE(sections) - IF (sections(js)%line_id /= ln%id) CYCLE - IF (ABS(types(sections(js)%ltype)%ktt) > CD_ZERO) THEN - CALL fail(ErrStat, ErrMsg, 'finite-EI two-moving-end compatibility solver does not support '// & - 'torque-tension coupling (GJ|K); use a Fixed End B') - RETURN - END IF - END DO - END BLOCK - pa = find_point(points, ln%nodeB) - pb = find_point(points, ln%nodeA) - IF (pa < 1 .OR. pb < 1) THEN - CALL fail(ErrStat, ErrMsg, 'finite-EI LINE references an unknown endpoint POINT') - RETURN - END IF - anchor = points(pa)%pos - fairlead = points(pb)%pos - - CALL build_finite_section_mesh(ln, sections, types, conn, deck_model%l0, ea, mpl, diam, ei, & - gas_in, gj_in, i_rt_in, i_rn_in, ErrStat, ErrMsg) - IF (ErrStat /= CD_DECKDRV_OK) RETURN - deck_model%n_elem = SIZE(deck_model%l0) - ALLOCATE (deck_model%ea(deck_model%n_elem), deck_model%ei(deck_model%n_elem)) - deck_model%ea = ea - ! Per-element bend stiffness (internal anchor->fairlead order, matching ea/l0) for the - ! BendMom output channel: BendMom = EI(node) * geometric curvature. EI=0 lines report 0. - deck_model%ei = ei - ALLOCATE (deck_model%diam(deck_model%n_elem), deck_model%cdn(deck_model%n_elem), & - deck_model%cdt(deck_model%n_elem), deck_model%can(deck_model%n_elem), & - deck_model%cat(deck_model%n_elem)) - CALL finite_hydro_arrays(ln, sections, types, deck_model%diam, deck_model%cdn, deck_model%cdt, & - deck_model%can, deck_model%cat) - - nnode = deck_model%n_elem + 1 - ndof = 6*nnode - ALLOCATE (nodes_ref(3, nnode), q0(ndof), v0(ndof), f_ext(ndof), f3(3*nnode), contact_f(ndof), & - load_per_length(3, deck_model%n_elem), w(deck_model%n_elem), fixed_dofs(6)) - CALL CD_Submerged_Weight(mpl, diam, opts%rhoW, opts%g, w, es, em) - IF (es /= 0) THEN - CALL fail(ErrStat, ErrMsg, 'finite-EI submerged weight: '//TRIM(em)); RETURN - END IF - CALL finite_section_closure(ea, ei, mpl, diam, gas_in, gj_in, i_rt_in, i_rn_in, & - gas, gj, rho_a, i_rt, i_rn, ErrStat, ErrMsg) - IF (ErrStat /= CD_DECKDRV_OK) RETURN - - IF (ANY(w <= CD_ZERO)) THEN - CALL finite_lazy_wave_reference_and_state(anchor, fairlead, deck_model%l0, nodes_ref, q0, ErrStat, ErrMsg) - IF (ErrStat /= CD_DECKDRV_OK) RETURN - ELSE - CALL finite_reference_and_state(anchor, fairlead, deck_model%l0, nodes_ref, q0) - END IF - v0 = CD_ZERO - f_ext = CD_ZERO - load_per_length = CD_ZERO - load_per_length(3, :) = -w - CALL CD_Assemble_Distributed_Load(conn, deck_model%l0, load_per_length, f3, es, em) - IF (es /= 0) THEN - CALL fail(ErrStat, ErrMsg, 'finite-EI load assembly: '//TRIM(em)); RETURN - END IF - CALL pack_translational_load(f3, f_ext) - ALLOCATE (deck_model%base_f_ext(ndof)) - deck_model%base_f_ext = f_ext - ALLOCATE (deck_model%q_work(ndof), deck_model%v_work(ndof), deck_model%a_work(ndof)) - ALLOCATE (deck_model%f_ext_work(ndof), deck_model%contact_work(ndof), deck_model%env_work(ndof)) - ALLOCATE (deck_model%q_fixed_work(ndof), deck_model%v_fixed_work(ndof), deck_model%a_fixed_work(ndof)) - ALLOCATE (deck_model%free_map_work(ndof)) - deck_model%q_work = CD_ZERO - deck_model%v_work = CD_ZERO - deck_model%a_work = CD_ZERO - deck_model%f_ext_work = CD_ZERO - deck_model%contact_work = CD_ZERO - deck_model%env_work = CD_ZERO - deck_model%q_fixed_work = CD_ZERO - deck_model%v_fixed_work = CD_ZERO - deck_model%a_fixed_work = CD_ZERO - deck_model%free_map_work = 0 - IF (opts%has_wtrdpth .OR. PRESENT(bathymetry)) THEN - CALL CD_Nodal_Seabed_Stiffness(opts%kbot, diam, deck_model%l0, deck_model%seabed_kn, es, em) - IF (es /= CD_LINE_OK) THEN - CALL fail(ErrStat, ErrMsg, 'finite-EI seabed stiffness: '//TRIM(em)); RETURN - END IF - ALLOCATE (deck_model%seabed_cn(SIZE(deck_model%seabed_kn))) - deck_model%seabed_cn = deck_model%seabed_kn*(opts%cbot/opts%kbot) - deck_model%has_seabed = .TRUE. - IF (PRESENT(bathymetry)) THEN - deck_model%bathymetry = bathymetry - deck_model%has_bathymetry = .TRUE. - CALL finite_bathymetry_contact_force(q0, v0, deck_model%bathymetry, deck_model%seabed_kn, & - deck_model%seabed_cn, opts%friction_mu, contact_f, ErrStat, ErrMsg) - ELSE - deck_model%seabed_z_floor = -opts%wtrdpth - CALL finite_seabed_contact_force(q0, v0, deck_model%seabed_z_floor, deck_model%seabed_kn, & - deck_model%seabed_cn, opts%friction_mu, contact_f, ErrStat, ErrMsg) - END IF - IF (ErrStat /= CD_DECKDRV_OK) RETURN - f_ext = f_ext + contact_f - END IF - - fixed_dofs = [1, 2, 3, ndof - 5, ndof - 4, ndof - 3] - dynamic_cfg%rho_inf = opts%rho_inf - dynamic_cfg%rel_tol = opts%dynamic_rel_tol - dynamic_cfg%abs_tol = opts%dynamic_abs_tol - dynamic_cfg%max_iter = opts%dynamic_max_iter - dynamic_cfg%armijo_max_backtracks = opts%dynamic_backtracks - dynamic_cfg%modified_newton = opts%dynamic_modified_newton - CALL CD_Init_FiniteEI_Model(deck_model%model, nodes_ref, conn, ea, gas, ei, gj, rho_a, i_rt, i_rn, .TRUE., & - es, em, q0=q0, v0=v0, f_ext=f_ext, fixed_dofs=fixed_dofs, cfg=dynamic_cfg) - IF (es /= CD_MODEL_OK) THEN - ErrStat = CD_DECKDRV_SOLVEFAIL - ErrMsg = 'CableDyn_DeckDriver: finite-EI model init failed: '//TRIM(em) - END IF - END SUBROUTINE init_one_finite_model - RECURSIVE SUBROUTINE build_one_hermite_cable(ln, sections, types, points, opts, dt, cable, coupled_node, & ErrStat, ErrMsg, standalone_controls, bathymetry, & fairlead_orientation, init_note, coarse_pass, fold_support, & - install_viv, aux_weight, fixed_fairlead) + install_viv, aux_weight, fixed_fairlead, allow_moving_end_b, & + end_b_orientation) !! Build one COUPLED cubic-Hermite lazy-wave cable (CD_HFMF) from a finite-EI deck !! LINE -- the production Hermite bending path shared by the coupled route and !! standalone and coupled finite-EI dynamics, including flat/structured seabed contact. !! Reuses the finite-EI deck extraction (mesh, submerged weight, section closure, and !! the cubic-Hermite arch seed) then routes it through the production Hermite static !! solve and the coupled FMF shell. Node ordering runs anchor/touchdown (node 1, - !! held) -> fairlead (node nn, the platform-driven coupled node), matching - !! init_one_finite_model. Both call routes install flat/structured nodal contact when + !! held, or a second driven end) -> fairlead (node nn, the platform-driven coupled node). + !! Both call routes install flat/structured nodal contact when !! the host/deck declares a seabed; a cable that remains clear sees exactly zero reaction. + !! With allow_moving_end_b, an End B on a Coupled/Vessel point is a second host-driven end + !! (CD_HFMF_Set_Moving_End_B): a line between two moving points. Its static problem is the one + !! of a Fixed End B at that position (both end translations are held in every static solve), + !! so the statics, seeds, continuations and audits run unchanged; End B's connection direction + !! Ez and torsion normal Nx are in End B's parent axes, whose global-to-parent DCM at the static + !! state is end_b_orientation (identity by default), and turn with that parent in the dynamics. TYPE(DeckLine), INTENT(IN) :: ln TYPE(DeckSection), INTENT(IN) :: sections(:) TYPE(DeckLineType), INTENT(IN) :: types(:) @@ -1809,6 +1594,10 @@ RECURSIVE SUBROUTINE build_one_hermite_cable(ln, sections, types, points, opts, ! Admit a Fixed End A as a standalone build does (the recursive builds of a standalone ! line, which run without its standalone controls). LOGICAL, INTENT(IN), OPTIONAL :: fixed_fairlead + ! Admit a Coupled/Vessel End B as a second host-driven end, and the global-to-parent DCM of + ! End B's parent at the static state (see above). + LOGICAL, INTENT(IN), OPTIONAL :: allow_moving_end_b + REAL(wp), INTENT(IN), OPTIONAL :: end_b_orientation(3, 3) INTEGER, ALLOCATABLE :: conn(:, :), fixed_dofs(:), dynamic_fixed_dofs(:) REAL(wp), ALLOCATABLE :: l0(:), ea(:), mpl(:), diam(:), ei(:), gas_in(:), gj_in(:), i_rt_in(:), i_rn_in(:) @@ -1824,6 +1613,9 @@ RECURSIVE SUBROUTINE build_one_hermite_cable(ln, sections, types, points, opts, REAL(wp) :: endconn_k(2), endconn_d0_global(3, 2), endconn_d0_local(3, 2) INTEGER :: endconn_mode(2) REAL(wp) :: fairlead_dcm(3, 3), dcm_gram(3, 3), dcm_det + ! a moving End B (allow_moving_end_b) and its parent's global-to-parent DCM at the static state + LOGICAL :: moving_b + REAL(wp) :: end_b_dcm(3, 3) REAL(wp) :: bending_mesh_limit, proposed_coarse_max INTEGER :: pa, pb, nnode, ndof, es, iters, i, applied_scale, step_max_iter, sequence_levels, coarse_ne, next_ne INTEGER :: nfixed, kfixed @@ -1934,6 +1726,26 @@ RECURSIVE SUBROUTINE build_one_hermite_cable(ln, sections, types, points, opts, END IF fairlead_dcm = fairlead_orientation END IF + end_b_dcm = CD_ZERO + end_b_dcm(1, 1) = CD_ONE + end_b_dcm(2, 2) = CD_ONE + end_b_dcm(3, 3) = CD_ONE + IF (PRESENT(end_b_orientation)) THEN + IF (.NOT. ALL(IEEE_IS_FINITE(end_b_orientation))) THEN + CALL fail(ErrStat, ErrMsg, 'finite-EI End B orientation must be finite'); RETURN + END IF + dcm_gram = MATMUL(end_b_orientation, TRANSPOSE(end_b_orientation)) + dcm_det = end_b_orientation(1, 1)*(end_b_orientation(2, 2)*end_b_orientation(3, 3) - & + end_b_orientation(2, 3)*end_b_orientation(3, 2)) - & + end_b_orientation(1, 2)*(end_b_orientation(2, 1)*end_b_orientation(3, 3) - & + end_b_orientation(2, 3)*end_b_orientation(3, 1)) + & + end_b_orientation(1, 3)*(end_b_orientation(2, 1)*end_b_orientation(3, 2) - & + end_b_orientation(2, 2)*end_b_orientation(3, 1)) + IF (MAXVAL(ABS(dcm_gram - end_b_dcm)) > 1.0e-8_wp .OR. ABS(dcm_det - CD_ONE) > 1.0e-8_wp) THEN + CALL fail(ErrStat, ErrMsg, 'finite-EI End B orientation must be a proper orthogonal DCM'); RETURN + END IF + end_b_dcm = end_b_orientation + END IF contact_z = -2000.0_wp IF (PRESENT(standalone_controls)) THEN IF (standalone_controls) THEN @@ -1974,9 +1786,18 @@ RECURSIVE SUBROUTINE build_one_hermite_cable(ln, sections, types, points, opts, CALL fail(ErrStat, ErrMsg, 'finite-EI coupled cable requires End A (the fairlead) to be a '// & 'Coupled/Vessel point; got "'//TRIM(points(pb)%ptype)//'"'); RETURN END IF - IF (TRIM(points(pa)%ptype) /= 'fixed') THEN - CALL fail(ErrStat, ErrMsg, 'finite-EI coupled cable requires End B (the anchor) to be a '// & - 'Fixed point; got "'//TRIM(points(pa)%ptype)//'"'); RETURN + moving_b = .FALSE. + IF (PRESENT(allow_moving_end_b)) moving_b = allow_moving_end_b .AND. & + (TRIM(points(pa)%ptype) == 'coupled' .OR. TRIM(points(pa)%ptype) == 'vessel') + IF (TRIM(points(pa)%ptype) /= 'fixed' .AND. .NOT. moving_b) THEN + IF (PRESENT(allow_moving_end_b)) THEN + IF (allow_moving_end_b) THEN + CALL fail(ErrStat, ErrMsg, 'finite-EI coupled cable requires End B to be a Fixed point or a '// & + 'Coupled/Vessel point (a second driven end); got "'//TRIM(points(pa)%ptype)//'"'); RETURN + END IF + END IF + CALL fail(ErrStat, ErrMsg, 'finite-EI coupled cable requires End B to be a Fixed point; got "'// & + TRIM(points(pa)%ptype)//'"'); RETURN END IF anchor = points(pa)%pos fairlead = points(pb)%pos @@ -2026,6 +1847,8 @@ RECURSIVE SUBROUTINE build_one_hermite_cable(ln, sections, types, points, opts, endconn_mode = [ln%endconn_mode(2), ln%endconn_mode(1)] endconn_d0_global = CD_ZERO endconn_d0_global(:, 1) = -ln%endconn_ez_ref(:, 2) + ! a moving End B's Ez is in its parent's axes, as End A's is + IF (moving_b) endconn_d0_global(:, 1) = MATMUL(TRANSPOSE(end_b_dcm), -ln%endconn_ez_ref(:, 2)) endconn_d0_global(:, 2) = MATMUL(TRANSPOSE(fairlead_dcm), -ln%endconn_ez_ref(:, 1)) DO i = 1, 2 endconn_d0_local(:, i) = [frame_cs(1)*endconn_d0_global(1, i) + & @@ -2351,6 +2174,13 @@ RECURSIVE SUBROUTINE build_one_hermite_cable(ln, sections, types, points, opts, ! springs. Their forces then seed the stick-slip anchors of the march (standalone and ! coupled alike). as_laid = contact_enabled .AND. opts%has_friction .AND. opts%static_friction == CD_STATIC_FRICTION_AS_LAID + ! The as-laid reference is the line laid on the seabed from its lower, anchored end; a line + ! between two moving points has no such end. + IF (as_laid .AND. moving_b) THEN + CALL fail(ErrStat, ErrMsg, 'OPTION staticsFriction asLaid lays a line on the seabed from its anchored end; '// & + 'finite-EI LINE '//TRIM(int_to_str(ln%id))//' has a moving End B (both ends on moving points): '// & + 'use staticsFriction none'); RETURN + END IF static_friction = contact_enabled .AND. opts%has_friction .AND. (opts%has_current .OR. as_laid) IF (opts%has_current .OR. as_laid) THEN ALLOCATE (cur_obj) @@ -3248,6 +3078,12 @@ RECURSIVE SUBROUTINE build_one_hermite_cable(ln, sections, types, points, opts, IF (es /= CD_HFMF_OK) THEN CALL fail(ErrStat, ErrMsg, 'finite-EI cable coupled-shell init failed: '//TRIM(em)); RETURN END IF + IF (moving_b) THEN + CALL CD_HFMF_Set_Moving_End_B(cable, es, em) + IF (es /= CD_HFMF_OK) THEN + CALL fail(ErrStat, ErrMsg, 'finite-EI cable moving End B wiring failed: '//TRIM(em)); RETURN + END IF + END IF IF (ALLOCATED(deck_map)) CALL MOVE_ALLOC(deck_map, cable%deck_node) cable%azimuth_signed = ln%azi_signed ! a stiffened line: the outputs report the cable's own share of the bend moment @@ -3259,7 +3095,17 @@ RECURSIVE SUBROUTINE build_one_hermite_cable(ln, sections, types, points, opts, END IF END IF IF (ANY(endconn_mode /= CD_ENDCONN_PINNED)) THEN - IF (endconn_mode(2) /= CD_ENDCONN_PINNED) THEN + ! a connected moving End B is attached to its own parent (end_b_d0_parent), as End A to its + IF (moving_b .AND. endconn_mode(1) /= CD_ENDCONN_PINNED .AND. endconn_mode(2) /= CD_ENDCONN_PINNED) THEN + CALL CD_HFMF_Set_EndConnection(cable, endconn_k, endconn_d0_global, es, em, & + coupled_d0_parent=-ln%endconn_ez_ref(:, 1), & + parent_orientation=fairlead_dcm, connection_mode=endconn_mode, & + end_b_d0_parent=-ln%endconn_ez_ref(:, 2), end_b_parent_orientation=end_b_dcm) + ELSE IF (moving_b .AND. endconn_mode(1) /= CD_ENDCONN_PINNED) THEN + CALL CD_HFMF_Set_EndConnection(cable, endconn_k, endconn_d0_global, es, em, & + connection_mode=endconn_mode, & + end_b_d0_parent=-ln%endconn_ez_ref(:, 2), end_b_parent_orientation=end_b_dcm) + ELSE IF (endconn_mode(2) /= CD_ENDCONN_PINNED) THEN CALL CD_HFMF_Set_EndConnection(cable, endconn_k, endconn_d0_global, es, em, & coupled_d0_parent=-ln%endconn_ez_ref(:, 1), & parent_orientation=fairlead_dcm, connection_mode=endconn_mode) @@ -3279,13 +3125,22 @@ RECURSIVE SUBROUTINE build_one_hermite_cable(ln, sections, types, points, opts, 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. + ! by End A's parent and turns with it in the dynamics, whatever the bending connection; a + ! moving End B's frame (director -Ez, normal Nx of End B) is held by End B's parent likewise. BLOCK - REAL(wp) :: tframe(3, 2) + REAL(wp) :: tframe(3, 2), bframe(3, 2) tframe(:, 1) = -ln%endconn_ez_ref(:, 1)/NORM2(ln%endconn_ez_ref(:, 1)) tframe(:, 2) = ln%tors_nx(:, 1) - DOT_PRODUCT(ln%tors_nx(:, 1), tframe(:, 1))*tframe(:, 1) tframe(:, 2) = tframe(:, 2)/NORM2(tframe(:, 2)) - CALL CD_HFMF_Set_Torsion(cable, tors, es, em, coupled_frame_parent=tframe, parent_orientation=fairlead_dcm) + IF (moving_b) THEN + bframe(:, 1) = -ln%endconn_ez_ref(:, 2)/NORM2(ln%endconn_ez_ref(:, 2)) + bframe(:, 2) = ln%tors_nx(:, 2) - DOT_PRODUCT(ln%tors_nx(:, 2), bframe(:, 1))*bframe(:, 1) + bframe(:, 2) = bframe(:, 2)/NORM2(bframe(:, 2)) + CALL CD_HFMF_Set_Torsion(cable, tors, es, em, coupled_frame_parent=tframe, parent_orientation=fairlead_dcm, & + end_b_frame_parent=bframe, end_b_parent_orientation=end_b_dcm) + ELSE + CALL CD_HFMF_Set_Torsion(cable, tors, es, em, coupled_frame_parent=tframe, parent_orientation=fairlead_dcm) + END IF END BLOCK IF (es /= CD_HFMF_OK) THEN CALL fail(ErrStat, ErrMsg, 'finite-EI cable torsion wiring failed: '//TRIM(em)); RETURN @@ -3495,7 +3350,9 @@ SUBROUTINE torsion_stage(est, emt, f_nodal) DO k = 1, 2 IF (k == kf) CYCLE dvec = endconn_d0_local(:, k)/NORM2(endconn_d0_local(:, k)) - IF (k == 1) THEN + IF (k == 1 .AND. moving_b) THEN + nvec = MATMUL(TRANSPOSE(end_b_dcm), ln%tors_nx(:, 2)) + ELSE IF (k == 1) THEN nvec = ln%tors_nx(:, 2) ELSE nvec = MATMUL(TRANSPOSE(fairlead_dcm), ln%tors_nx(:, 1)) @@ -3993,11 +3850,13 @@ SUBROUTINE still_water_compression(text) IF (PRESENT(bathymetry)) THEN CALL build_one_hermite_cable(ln, sections, types, points, opts_sw, dt, sw_cable, sw_node, esw, emw, & standalone_controls=.FALSE., fixed_fairlead=fixed_fairlead_ok, & - bathymetry=bathymetry, fairlead_orientation=fairlead_dcm, init_note=sw_note) + bathymetry=bathymetry, fairlead_orientation=fairlead_dcm, init_note=sw_note, & + allow_moving_end_b=moving_b, end_b_orientation=end_b_dcm) ELSE CALL build_one_hermite_cable(ln, sections, types, points, opts_sw, dt, sw_cable, sw_node, esw, emw, & standalone_controls=.FALSE., fixed_fairlead=fixed_fairlead_ok, & - fairlead_orientation=fairlead_dcm, init_note=sw_note) + fairlead_orientation=fairlead_dcm, init_note=sw_note, & + allow_moving_end_b=moving_b, end_b_orientation=end_b_dcm) END IF IF (esw == CD_DECKDRV_OK) THEN CALL CD_HermiteCable_Mean_Axial_Extremes(sw_cable%line%l0, sw_cable%line%EA, sw_cable%line%q, t_min, & @@ -4073,11 +3932,13 @@ SUBROUTINE light_line_route(done, why) CALL build_one_hermite_cable(ln, sections, types, points, opts, dt, aux_cable, aux_node, es_r, em_r, & standalone_controls=.FALSE., fixed_fairlead=fixed_fairlead_ok, & bathymetry=bathymetry, & - fairlead_orientation=fairlead_dcm, init_note=aux_note, aux_weight=aux) + fairlead_orientation=fairlead_dcm, init_note=aux_note, aux_weight=aux, & + allow_moving_end_b=moving_b, end_b_orientation=end_b_dcm) ELSE CALL build_one_hermite_cable(ln, sections, types, points, opts, dt, aux_cable, aux_node, es_r, em_r, & standalone_controls=.FALSE., fixed_fairlead=fixed_fairlead_ok, & - fairlead_orientation=fairlead_dcm, init_note=aux_note, aux_weight=aux) + fairlead_orientation=fairlead_dcm, init_note=aux_note, aux_weight=aux, & + allow_moving_end_b=moving_b, end_b_orientation=end_b_dcm) END IF IF (es_r /= CD_DECKDRV_OK) THEN WRITE (why, '(A,ES10.3,A)') 'the line with an auxiliary weight of ', aux, ' N/m found no equilibrium: ' @@ -4665,11 +4526,13 @@ SUBROUTINE coarse_current_first(done, fail_msg) CALL build_one_hermite_cable(ln, sec_c, types, points, opts_c, dt, c_cable, c_node, esc, emc, & standalone_controls=.FALSE., fixed_fairlead=fixed_fairlead_ok, & bathymetry=bathymetry, & - fairlead_orientation=fairlead_dcm, init_note=c_note, coarse_pass=.TRUE.) + fairlead_orientation=fairlead_dcm, init_note=c_note, coarse_pass=.TRUE., & + allow_moving_end_b=moving_b, end_b_orientation=end_b_dcm) ELSE CALL build_one_hermite_cable(ln, sec_c, types, points, opts_c, dt, c_cable, c_node, esc, emc, & standalone_controls=.FALSE., fixed_fairlead=fixed_fairlead_ok, & - fairlead_orientation=fairlead_dcm, init_note=c_note, coarse_pass=.TRUE.) + fairlead_orientation=fairlead_dcm, init_note=c_note, coarse_pass=.TRUE., & + allow_moving_end_b=moving_b, end_b_orientation=end_b_dcm) END IF IF (esc /= CD_DECKDRV_OK) THEN CALL CD_HFMF_End(c_cable) @@ -4802,11 +4665,13 @@ SUBROUTINE still_water_reference(esr, emr) IF (PRESENT(bathymetry)) THEN CALL build_one_hermite_cable(ln, sections, types, points, opts_sw, dt, sw_cable, sw_node, esr, emr, & standalone_controls=.FALSE., fixed_fairlead=fixed_fairlead_ok, & - bathymetry=bathymetry, fairlead_orientation=fairlead_dcm, init_note=sw_note) + bathymetry=bathymetry, fairlead_orientation=fairlead_dcm, init_note=sw_note, & + allow_moving_end_b=moving_b, end_b_orientation=end_b_dcm) ELSE CALL build_one_hermite_cable(ln, sections, types, points, opts_sw, dt, sw_cable, sw_node, esr, emr, & standalone_controls=.FALSE., fixed_fairlead=fixed_fairlead_ok, & - fairlead_orientation=fairlead_dcm, init_note=sw_note) + fairlead_orientation=fairlead_dcm, init_note=sw_note, & + allow_moving_end_b=moving_b, end_b_orientation=end_b_dcm) END IF IF (esr /= CD_DECKDRV_OK) THEN CALL CD_HFMF_End(sw_cable) @@ -7145,20 +7010,23 @@ 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, host_orientation) + SUBROUTINE CD_Init_Deck_HermiteCable(deck_path, dt, cable, coupled_node, ErrStat, ErrMsg, host_orientation, & + moving_end_b) !! 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. + !! its End A frame; without it a torsion deck fails closed. moving_end_b: the caller also + !! drives End B (CD_HFMF_UpdateStates ub_*), so a Coupled/Vessel End B is built as a second + !! host-driven end (CD_HFMF_Set_Moving_End_B); without it such a 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 + LOGICAL, INTENT(IN), OPTIONAL :: host_orientation, moving_end_b TYPE(DeckLineType), ALLOCATABLE :: types(:) TYPE(DeckBody), ALLOCATABLE :: bodies(:) @@ -7233,10 +7101,11 @@ SUBROUTINE CD_Init_Deck_HermiteCable(deck_path, dt, cable, coupled_node, ErrStat points=points) IF (ErrStat /= CD_DECKDRV_OK) RETURN CALL build_one_hermite_cable(lines(1), sections, types, points, opts, dt, cable, coupled_node, & - ErrStat, ErrMsg, bathymetry=bathymetry) + ErrStat, ErrMsg, bathymetry=bathymetry, allow_moving_end_b=moving_end_b) CALL CD_End_Bathymetry(bathymetry) ELSE - CALL build_one_hermite_cable(lines(1), sections, types, points, opts, dt, cable, coupled_node, ErrStat, ErrMsg) + CALL build_one_hermite_cable(lines(1), sections, types, points, opts, dt, cable, coupled_node, ErrStat, ErrMsg, & + allow_moving_end_b=moving_end_b) END IF END SUBROUTINE CD_Init_Deck_HermiteCable @@ -7288,7 +7157,8 @@ SUBROUTINE CD_Init_Deck_Aggregate(deck_path, dt, agg, ErrStat, ErrMsg, env_gravi ! coupled_positions (3, n_moving): explicit placement of every host-prescribed ! (moving) point BEFORE the static solves, in the aggregate moving-set order -- ! the system's BOUND Coupled/Vessel points in deck POINT order, then one coupled - ! fairlead per finite-EI cable in deck LINE order. The generalization of ptfm_init + ! fairlead (End A) per finite-EI cable in deck LINE order, then the moving End B of + ! each finite-EI cable between two moving points, in deck LINE order. The generalization of ptfm_init ! (which is a rigid transform of the same points; the two are mutually exclusive). ! Consumed by the linearization probe: each perturbed init IS a static solve at ! the probed boundary. @@ -7353,7 +7223,7 @@ SUBROUTINE CD_Init_Deck_Aggregate(deck_path, dt, agg, ErrStat, ErrMsg, env_gravi LOGICAL, ALLOCATABLE :: is_fin(:) INTEGER :: i, c, n_fin, n_ei0, cn, es, j INTEGER :: n_rigid6, n_point3, n_rod, n_host_rod, n_host_body - REAL(wp) :: fairlead_dcm(3, 3), host_dcm(3, 3) + REAL(wp) :: fairlead_dcm(3, 3), host_dcm(3, 3), end_b_dcm(3, 3) ! Preserve the complete multi-hierarchy finite-EI initialization diagnostic. ! This path feeds both the aggregate and OpenFAST facade; clipping it hides the ! mesh level/resolution evidence users need to correct a rejected deck. @@ -7967,18 +7837,33 @@ SUBROUTINE CD_Init_Deck_Aggregate(deck_path, dt, agg, ErrStat, ErrMsg, env_gravi ELSE IF (PRESENT(ptfm_init)) THEN fairlead_dcm = ptfm_zyx_dcm(ptfm_init(4:6)) END IF + ! a moving End B (a line between two moving points) is host-driven like End A: its + ! parent's orientation at the static state is that of its own turbine, or the platform's + end_b_dcm = CD_ZERO + end_b_dcm(1, 1) = CD_ONE + end_b_dcm(2, 2) = CD_ONE + end_b_dcm(3, 3) = CD_ONE + IF (nturb > 0 .AND. PRESENT(farm_ptfm_init)) THEN + j = find_point(points, lines(i)%nodeB) + IF (j > 0 .AND. points(j)%turbine_id > 0) & + end_b_dcm = ptfm_zyx_dcm(farm_ptfm_init(4:6, points(j)%turbine_id)) + ELSE IF (PRESENT(ptfm_init)) THEN + end_b_dcm = ptfm_zyx_dcm(ptfm_init(4:6)) + END IF IF (opts%has_bathymetry_file) THEN CALL build_one_hermite_cable(lines(i), sections, types, points, opts_static, dt, agg%cables(c), cn, es, & em, bathymetry=bathymetry, fairlead_orientation=fairlead_dcm, & init_note=agg%cable_note(c), install_viv=.TRUE., & fold_support=MERGE(FOLD_FRICTION_NONE, FOLD_FRICTION_FULL, & - deck_has_dynamic_points(points))) + deck_has_dynamic_points(points)), & + allow_moving_end_b=.TRUE., end_b_orientation=end_b_dcm) ELSE CALL build_one_hermite_cable(lines(i), sections, types, points, opts_static, dt, agg%cables(c), cn, es, & em, fairlead_orientation=fairlead_dcm, init_note=agg%cable_note(c), & install_viv=.TRUE., & fold_support=MERGE(FOLD_FRICTION_NONE, FOLD_FRICTION_FULL, & - deck_has_dynamic_points(points))) + deck_has_dynamic_points(points)), & + allow_moving_end_b=.TRUE., end_b_orientation=end_b_dcm) END IF IF (es /= CD_DECKDRV_OK) THEN ErrStat = es @@ -8380,6 +8265,7 @@ SUBROUTINE fill_turbine_of_moving(points, lines, is_fin, agg, ErrStat, ErrMsg) END DO DO l = 1, SIZE(lines) IF (is_fin(l)) n = n + 1 + IF (is_fin(l) .AND. moving_end_b_point(points, lines(l))) n = n + 1 END DO ALLOCATE (agg%turbine_of_moving(n), STAT=istat) IF (istat /= 0) THEN @@ -8403,19 +8289,38 @@ SUBROUTINE fill_turbine_of_moving(points, lines, is_fin, agg, ErrStat, ErrMsg) END IF END SELECT END DO + ! one coupled fairlead (End A) per finite-EI cable, then the moving End B of each cable between + ! two moving points (the turbine that drives each) DO l = 1, SIZE(lines) IF (.NOT. is_fin(l)) CYCLE n = n + 1 - 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') - agg%turbine_of_moving(n) = points(i)%turbine_id - END SELECT - END DO + i = find_point(points, lines(l)%nodeA) + IF (i < 1) CYCLE + SELECT CASE (TRIM(points(i)%ptype)) + CASE ('coupled', 'vessel') + agg%turbine_of_moving(n) = points(i)%turbine_id + END SELECT + END DO + DO l = 1, SIZE(lines) + IF (.NOT. is_fin(l)) CYCLE + IF (.NOT. moving_end_b_point(points, lines(l))) CYCLE + n = n + 1 + agg%turbine_of_moving(n) = points(find_point(points, lines(l)%nodeB))%turbine_id END DO END SUBROUTINE fill_turbine_of_moving + LOGICAL FUNCTION moving_end_b_point(points, ln) RESULT(moving) + !! Line ln ends at End B on a Coupled/Vessel point: a finite-EI cable then has two moving ends + !! (build_one_hermite_cable allow_moving_end_b). + TYPE(DeckPoint), INTENT(IN) :: points(:) + TYPE(DeckLine), INTENT(IN) :: ln + INTEGER :: j + moving = .FALSE. + j = find_point(points, ln%nodeB) + IF (j < 1) RETURN + moving = TRIM(points(j)%ptype) == 'coupled' .OR. TRIM(points(j)%ptype) == 'vessel' + END FUNCTION moving_end_b_point + SUBROUTINE CD_Deck_Query_dtM(deck_path, dtM, has_dtm, ErrStat, ErrMsg, env_gravity, env_rho_water, env_wtrdpth, & tmax, has_tmax, n_ei0, n_finite_ei, has_motion_file, standalone_scan, has_line_outputs, & input_files, has_objects, n_bodies_rods) @@ -8643,9 +8548,10 @@ 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). + !! POINT order, then one coupled fairlead per finite-EI cable in deck LINE order, then the + !! moving End B of each cable between two moving points). The roll column of a motionFile + !! drives a moving end restrained in torsion of a line solved in torsion, 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(:) @@ -8662,7 +8568,7 @@ SUBROUTINE build_aggregate_motion(points, lines, is_fin, opts, rt, ErrStat, ErrM 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) + CALL check_motion_roll_lines(rt%motion, lines, points, ErrStat, ErrMsg) IF (ErrStat /= CD_DECKDRV_OK) RETURN ! pass 1 counts the moving columns, pass 2 fills them DO pass = 1, 2 @@ -8683,17 +8589,24 @@ SUBROUTINE build_aggregate_motion(points, lines, is_fin, opts, rt, ErrStat, ErrM END IF END SELECT END DO + ! one coupled fairlead (End A) per finite-EI cable, then the moving End B of each cable + ! between two moving points (apply_coupled_positions) 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 + i = find_point(points, lines(l)%nodeA) + IF (i < 1) 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))) + END SELECT + END DO + DO l = 1, SIZE(lines) + IF (.NOT. is_fin(l)) CYCLE + IF (.NOT. moving_end_b_point(points, lines(l))) CYCLE + n = n + 1 + IF (pass == 2) CALL set_column(n, find_point(points, lines(l)%nodeB), & + rt%motion%has_roll .AND. line_torsion_at_b(lines(l))) END DO IF (pass == 1) ALLOCATE (rt%col_point(n), rt%col_pos(3, n), rt%col_roll(n)) END DO @@ -8865,13 +8778,14 @@ SUBROUTINE run_deck_driver(deck_path, out_root, converged, ErrStat, ErrMsg) INTEGER, ALLOCATABLE :: q_off(:), ten_off(:), nn(:), ne(:) CHARACTER(1024) :: fail_msg TYPE(CD_ModelType), ALLOCATABLE :: models(:) - TYPE(FiniteDeckModel), ALLOCATABLE :: finite_models(:) TYPE(CD_HFMF_ModuleType), ALLOCATABLE :: hermite_models(:) + ! the global-to-parent DCM of each line end at the static start (turbine_end_dcm) + REAL(wp) :: dcm_end(3, 3, 2) TYPE(CD_SystemType) :: point_system TYPE(CD_BathymetryType) :: bathymetry TYPE(DeckFailure), ALLOCATABLE :: fails(:) TYPE(CD_LineInitSummary), ALLOCATABLE :: init_summaries(:) - INTEGER :: nl, li, es, j, n_finite, node_sc, kind_sc, comp_sc + INTEGER :: nl, li, es, j, n_finite LOGICAL :: line_conv, has_line_outputs, has_finite, has_dyn_points, has_rigid6, hermite_standalone_eligible CHARACTER(1024) :: em @@ -8980,7 +8894,7 @@ SUBROUTINE run_deck_driver(deck_path, out_root, converged, ErrStat, ErrMsg) IF (opts%n_modes > 0) THEN ! modal analysis about the static equilibrium: EI = 0 lines here, finite-EI lines on ! the cubic-Hermite route below - CALL check_modal_deck(bodies, rods, points, lines, opts, n_finite, has_dyn_points, SIZE(fails) > 0, & + CALL check_modal_deck(bodies, rods, lines, opts, n_finite, has_dyn_points, SIZE(fails) > 0, & ErrStat, ErrMsg) IF (ErrStat == CD_DECKDRV_OK .AND. n_finite == 0) & CALL write_deck_modes_ei0(out_root, types, points, lines, sections, opts, ErrStat, ErrMsg) @@ -9021,8 +8935,8 @@ SUBROUTINE run_deck_driver(deck_path, out_root, converged, ErrStat, ErrMsg) IF (has_finite) THEN ! The standalone finite-EI march owns one homogeneous family of bending ! lines. Mixed EI=0/EI>0 composition belongs to the aggregate route; keep - ! this guard ahead of BOTH the Hermite and compatibility dispatches so an - ! EI=0 line can never be coerced through the all-lines Hermite builder. + ! this guard ahead of the Hermite dispatch so an EI=0 line can never be + ! coerced through the all-lines Hermite builder. IF (.NOT. all_lines_have_finite_ei(types, lines, sections)) THEN IF (opts%has_bathymetry_file) CALL CD_End_Bathymetry(bathymetry) CALL fail(ErrStat, ErrMsg, 'mixed EI=0 and finite-EI dynamic decks are not supported by this entry point') @@ -9030,87 +8944,58 @@ SUBROUTINE run_deck_driver(deck_path, out_root, converged, ErrStat, ErrMsg) END IF ! (bodies, rods and Free/Connect points beside finite-EI lines never reach here: ! deck_needs_multibody routes them to the multibody march above) - hermite_standalone_eligible = .TRUE. + ! The production cubic-Hermite route owns every standalone finite-EI dynamic deck, + ! including flat/structured contact, damping, friction, motion and deck-owned fluid + ! fields: the HFMF lifecycle drives End A and holds a Fixed End B or drives a + ! Coupled/Vessel one (a line between two moving points, CD_HFMF_Set_Moving_End_B). DO li = 1, SIZE(lines) - ! The HFMF lifecycle drives End A and holds End B. Decks with two moving - ! ends use the compatibility route, which supports that topology. j = find_point(points, lines(li)%nodeB) - IF (j < 1 .OR. TRIM(points(j)%ptype) /= 'fixed') hermite_standalone_eligible = .FALSE. - END DO - ! The production cubic-Hermite route owns every eligible standalone finite-EI - ! dynamic deck, including flat/structured contact, damping, friction, motion, - ! and deck-owned fluid fields. The compatibility route remains only for the - ! two-moving-end topology that the HFMF boundary cannot represent. - IF (.NOT. hermite_standalone_eligible) THEN - DO li = 1, SIZE(lines) - IF (.NOT. line_has_viv(lines(li), types, sections)) CYCLE - IF (opts%has_bathymetry_file) CALL CD_End_Bathymetry(bathymetry) - CALL fail(ErrStat, ErrMsg, 'VIV (LINE TYPES Cl > 0) of a finite-EI line needs its End B fixed '// & - '(the cubic-Hermite march); set Cl = 0 for a line with two moving ends') - RETURN - END DO - ! the compatibility route carries no section frame for the curvature components - DO li = 1, SIZE(channels) - CALL parse_line_node_channel(channels(li), j, node_sc, kind_sc, comp_sc) - IF (kind_sc /= 13 .AND. kind_sc /= 14) CYCLE + IF (j < 1) THEN + hermite_standalone_eligible = .FALSE. + ELSE + hermite_standalone_eligible = TRIM(points(j)%ptype) == 'fixed' .OR. & + TRIM(points(j)%ptype) == 'coupled' .OR. TRIM(points(j)%ptype) == 'vessel' + END IF + IF (.NOT. hermite_standalone_eligible) THEN IF (opts%has_bathymetry_file) CALL CD_End_Bathymetry(bathymetry) - CALL fail(ErrStat, ErrMsg, 'OUTPUT "'//TRIM(channels(li))//'": the section curvature components '// & - 'need a finite-EI line with a Fixed End B (the cubic-Hermite march); a line with two '// & - 'moving ends reports CurvN') + CALL fail(ErrStat, ErrMsg, 'finite-EI LINE '//TRIM(int_to_str(lines(li)%id))//' End B must be a '// & + 'Fixed, Coupled or Vessel point on the standalone finite-EI route') RETURN - END DO - END IF - IF (hermite_standalone_eligible) THEN - ALLOCATE (hermite_models(SIZE(lines))) - DO li = 1, SIZE(lines) - IF (opts%has_bathymetry_file) THEN - CALL build_one_hermite_cable(lines(li), sections, types, points, opts, opts%dtM, & - hermite_models(li), j, ErrStat, ErrMsg, standalone_controls=.TRUE., & - bathymetry=bathymetry, install_viv=.TRUE.) - ELSE - CALL build_one_hermite_cable(lines(li), sections, types, points, opts, opts%dtM, & - hermite_models(li), j, ErrStat, ErrMsg, standalone_controls=.TRUE., & - install_viv=.TRUE.) - END IF - IF (ErrStat /= CD_DECKDRV_OK) EXIT - END DO - IF (ErrStat == CD_DECKDRV_OK) THEN - CALL collect_hermite_init_summaries(lines, hermite_models, init_summaries, ErrStat, ErrMsg) END IF - IF (ErrStat == CD_DECKDRV_OK .AND. opts%n_modes > 0) & - CALL write_deck_modes_hermite(out_root, lines, opts, hermite_models, ErrStat, ErrMsg) - IF (ErrStat == CD_DECKDRV_OK) THEN - CALL print_deck_init_report(deck_path, lines, points, sections, n_finite, init_summaries, & - types=types, opts=opts) - CALL write_hermite_dynamic_out(out_root, channels, lines, points, opts, hermite_models, & - converged, ErrStat, ErrMsg, bathymetry=bathymetry) + END DO + ALLOCATE (hermite_models(SIZE(lines))) + DO li = 1, SIZE(lines) + ! a TURBINES deck: an end on a Turbine point takes its Ez and Nx in that turbine's axes, + ! turned by the turbine's PtfmInit at the static start (as the FAST.Farm aggregate does) + dcm_end(:, :, 1) = turbine_end_dcm(points, opts, lines(li)%nodeA) + dcm_end(:, :, 2) = turbine_end_dcm(points, opts, lines(li)%nodeB) + IF (opts%has_bathymetry_file) THEN + CALL build_one_hermite_cable(lines(li), sections, types, points, opts, opts%dtM, & + hermite_models(li), j, ErrStat, ErrMsg, standalone_controls=.TRUE., & + bathymetry=bathymetry, install_viv=.TRUE., allow_moving_end_b=.TRUE., & + fairlead_orientation=dcm_end(:, :, 1), end_b_orientation=dcm_end(:, :, 2)) + ELSE + CALL build_one_hermite_cable(lines(li), sections, types, points, opts, opts%dtM, & + hermite_models(li), j, ErrStat, ErrMsg, standalone_controls=.TRUE., & + install_viv=.TRUE., allow_moving_end_b=.TRUE., & + fairlead_orientation=dcm_end(:, :, 1), end_b_orientation=dcm_end(:, :, 2)) END IF - CALL end_hermite_cables(hermite_models) - ELSE IF (opts%has_bathymetry_file) THEN - CALL init_finite_deck_models(types, points, lines, sections, opts, finite_models, ErrStat, ErrMsg, & - bathymetry=bathymetry) - ELSE - CALL init_finite_deck_models(types, points, lines, sections, opts, finite_models, ErrStat, ErrMsg) - END IF - IF (.NOT. ALLOCATED(finite_models)) THEN - IF (opts%has_bathymetry_file) CALL CD_End_Bathymetry(bathymetry) - RETURN - END IF - IF (ErrStat /= 0) THEN - IF (opts%has_bathymetry_file) CALL CD_End_Bathymetry(bathymetry) - RETURN + IF (ErrStat /= CD_DECKDRV_OK) EXIT + END DO + IF (ErrStat == CD_DECKDRV_OK) THEN + CALL collect_hermite_init_summaries(lines, hermite_models, init_summaries, ErrStat, ErrMsg) END IF - CALL collect_finite_init_summaries(lines, points, finite_models, init_summaries, ErrStat, ErrMsg) - IF (ErrStat /= CD_DECKDRV_OK) THEN - CALL end_finite_models(finite_models) - IF (opts%has_bathymetry_file) CALL CD_End_Bathymetry(bathymetry) - RETURN + IF (ErrStat == CD_DECKDRV_OK .AND. opts%n_modes > 0) & + CALL write_deck_modes_hermite(out_root, lines, opts, hermite_models, ErrStat, ErrMsg) + IF (ErrStat == CD_DECKDRV_OK) THEN + CALL print_deck_init_report(deck_path, lines, points, sections, n_finite, init_summaries, & + types=types, opts=opts) + CALL write_hermite_dynamic_out(out_root, channels, lines, points, opts, hermite_models, & + converged, ErrStat, ErrMsg, bathymetry=bathymetry) END IF - CALL print_deck_init_report(deck_path, lines, points, sections, n_finite, init_summaries, & - types=types, opts=opts) - CALL write_finite_dynamic_out(out_root, channels, lines, points, opts, finite_models, & - converged, ErrStat, ErrMsg, bathymetry=bathymetry) - CALL end_finite_models(finite_models) + CALL end_hermite_cables(hermite_models) + IF (opts%has_bathymetry_file) CALL CD_End_Bathymetry(bathymetry) + RETURN ELSE IF (SIZE(lines) == 0 .AND. (SIZE(rods) > 0 .OR. has_rigid6)) THEN ! bodies (with rods fixed to them) and free or pinned rods, no lines IF (opts%has_bathymetry_file) THEN @@ -10422,41 +10307,6 @@ SUBROUTINE end_models(models) END DO END SUBROUTINE end_models - SUBROUTINE end_finite_models(models) - !! Best-effort cleanup for finite-EI dynamic deck model arrays. - TYPE(FiniteDeckModel), INTENT(INOUT) :: models(:) - INTEGER :: i, es - CHARACTER(1024) :: em - DO i = 1, SIZE(models) - CALL CD_End_FiniteEI_Model(models(i)%model, es, em) - IF (ALLOCATED(models(i)%l0)) DEALLOCATE (models(i)%l0) - IF (ALLOCATED(models(i)%ea)) DEALLOCATE (models(i)%ea) - IF (ALLOCATED(models(i)%base_f_ext)) DEALLOCATE (models(i)%base_f_ext) - IF (ALLOCATED(models(i)%diam)) DEALLOCATE (models(i)%diam) - IF (ALLOCATED(models(i)%cdn)) DEALLOCATE (models(i)%cdn) - IF (ALLOCATED(models(i)%cdt)) DEALLOCATE (models(i)%cdt) - IF (ALLOCATED(models(i)%can)) DEALLOCATE (models(i)%can) - IF (ALLOCATED(models(i)%cat)) DEALLOCATE (models(i)%cat) - IF (ALLOCATED(models(i)%seabed_kn)) DEALLOCATE (models(i)%seabed_kn) - IF (ALLOCATED(models(i)%seabed_cn)) DEALLOCATE (models(i)%seabed_cn) - IF (ALLOCATED(models(i)%q_work)) DEALLOCATE (models(i)%q_work) - IF (ALLOCATED(models(i)%v_work)) DEALLOCATE (models(i)%v_work) - IF (ALLOCATED(models(i)%a_work)) DEALLOCATE (models(i)%a_work) - IF (ALLOCATED(models(i)%f_ext_work)) DEALLOCATE (models(i)%f_ext_work) - IF (ALLOCATED(models(i)%contact_work)) DEALLOCATE (models(i)%contact_work) - IF (ALLOCATED(models(i)%env_work)) DEALLOCATE (models(i)%env_work) - IF (ALLOCATED(models(i)%q_fixed_work)) DEALLOCATE (models(i)%q_fixed_work) - IF (ALLOCATED(models(i)%v_fixed_work)) DEALLOCATE (models(i)%v_fixed_work) - IF (ALLOCATED(models(i)%a_fixed_work)) DEALLOCATE (models(i)%a_fixed_work) - IF (ALLOCATED(models(i)%free_map_work)) DEALLOCATE (models(i)%free_map_work) - CALL CD_End_Bathymetry(models(i)%bathymetry) - models(i)%n_elem = 0 - models(i)%has_seabed = .FALSE. - models(i)%has_bathymetry = .FALSE. - models(i)%seabed_z_floor = CD_ZERO - END DO - END SUBROUTINE end_finite_models - SUBROUTINE end_hermite_cables(cables) !! Best-effort cleanup for the standalone production finite-EI route. TYPE(CD_HFMF_ModuleType), ALLOCATABLE, INTENT(INOUT) :: cables(:) @@ -11297,175 +11147,6 @@ SUBROUTINE scatter_finite_contact_band(ab, free_map, kl, ku, row_dof, col_dof, v ab(brow, jcol) = ab(brow, jcol) + value END SUBROUTINE scatter_finite_contact_band - SUBROUTINE finite_environment_force(model, opts, time, q, v, f_ext, ErrStat, ErrMsg) - !! Translational Morison/FK environmental load for finite-EI deck dynamics. - !! The force uses the same two-node wet-subsegment kernels as the EI=0 path, - !! scattered only into translational DOFs. Rotational hydrodynamic moments - !! are not supported on the finite-EI deck path. - TYPE(FiniteDeckModel), INTENT(IN) :: model - TYPE(DeckOptions), INTENT(IN) :: opts - REAL(wp), INTENT(IN) :: time, q(:), v(:) - REAL(wp), INTENT(OUT) :: f_ext(:) - INTEGER, INTENT(OUT) :: ErrStat - CHARACTER(*), INTENT(OUT) :: ErrMsg - INTEGER :: e, a, b, ia, ib, es - INTEGER :: idx(6) - REAL(wp) :: xa(3), xb(3), va(3), vb(3), eta_a, eta_b - REAL(wp) :: fluid_a(3), fluid_b(3), accel_a(3), accel_b(3), f2(6) - CHARACTER(200) :: em ! per-element kinematics and Morison messages (at most 160 characters) - - f_ext = CD_ZERO - ErrStat = CD_DECKDRV_OK - ErrMsg = '' - IF (.NOT. (opts%has_current .OR. opts%has_wave)) RETURN - IF (SIZE(q) /= SIZE(v) .OR. SIZE(f_ext) /= SIZE(q) .OR. MOD(SIZE(q), 6) /= 0) THEN - CALL fail(ErrStat, ErrMsg, 'finite-EI hydro state/load shapes must be 6*n_nodes') - RETURN - END IF - DO e = 1, model%n_elem - a = e - b = e + 1 - ia = 6*a - 5 - ib = 6*b - 5 - xa = q(ia:ia + 2) - xb = q(ib:ib + 2) - va = v(ia:ia + 2) - vb = v(ib:ib + 2) - idx = [ia, ia + 1, ia + 2, ib, ib + 1, ib + 2] - CALL finite_environment_node(opts, time, xa, eta_a, fluid_a, accel_a, es, em) - IF (es /= CD_HYDRO_OK) THEN - ErrStat = CD_DECKDRV_BADINPUT - ErrMsg = 'CableDyn_DeckDriver: finite-EI environment node A failed: '//TRIM(em) - RETURN - END IF - CALL finite_environment_node(opts, time, xb, eta_b, fluid_b, accel_b, es, em) - IF (es /= CD_HYDRO_OK) THEN - ErrStat = CD_DECKDRV_BADINPUT - ErrMsg = 'CableDyn_DeckDriver: finite-EI environment node B failed: '//TRIM(em) - RETURN - END IF - CALL CD_Morison_Drag_Element_Force(xa, xb, va, vb, model%l0(e), fluid_a, fluid_b, eta_a, eta_b, & - opts%rhoW, model%diam(e), model%cdn(e), model%cdt(e), f2, es, em) - IF (es /= CD_HYDRO_OK) THEN - ErrStat = CD_DECKDRV_SOLVEFAIL - ErrMsg = 'CableDyn_DeckDriver: finite-EI drag element failed: '//TRIM(em) - RETURN - END IF - f_ext(idx) = f_ext(idx) + f2 - IF (opts%has_wave) THEN - CALL CD_Froude_Krylov_Element_Force(xa, xb, va, vb, model%l0(e), accel_a, accel_b, eta_a, eta_b, & - opts%rhoW, model%diam(e), model%can(e), model%cat(e), f2, es, em) - IF (es /= CD_HYDRO_OK) THEN - ErrStat = CD_DECKDRV_SOLVEFAIL - ErrMsg = 'CableDyn_DeckDriver: finite-EI FK element failed: '//TRIM(em) - RETURN - END IF - f_ext(idx) = f_ext(idx) + f2 - END IF - END DO - END SUBROUTINE finite_environment_force - - SUBROUTINE finite_environment_load_banded(model, opts, time, q, v, free, kl, ku, free_map, & - force, jac_q_band, jac_v_band, ErrStat, ErrMsg) - !! Add finite-EI translational current/wave load plus reduced banded Jacobian. - TYPE(FiniteDeckModel), INTENT(IN) :: model - TYPE(DeckOptions), INTENT(IN) :: opts - REAL(wp), INTENT(IN) :: time, q(:), v(:) - INTEGER, INTENT(IN) :: free(:), kl, ku - INTEGER, INTENT(INOUT) :: free_map(:) - REAL(wp), INTENT(INOUT) :: force(:), jac_q_band(:, :), jac_v_band(:, :) - INTEGER, INTENT(OUT) :: ErrStat - CHARACTER(*), INTENT(OUT) :: ErrMsg - INTEGER :: e, a, b, ia, ib, irow, jcol, es - INTEGER :: idx(6) - REAL(wp) :: xa(3), xb(3), va(3), vb(3), eta_a, eta_b - REAL(wp) :: fluid_a(3), fluid_b(3), accel_a(3), accel_b(3), f2(6), jq2(6, 6), jv2(6, 6) - CHARACTER(200) :: em ! per-element kinematics and Morison messages (at most 160 characters) - - ErrStat = CD_DECKDRV_OK - ErrMsg = '' - IF (.NOT. (opts%has_current .OR. opts%has_wave)) RETURN - IF (SIZE(q) /= SIZE(v) .OR. SIZE(force) /= SIZE(q) .OR. MOD(SIZE(q), 6) /= 0) THEN - CALL fail(ErrStat, ErrMsg, 'finite-EI hydro tangent state/load shapes must be 6*n_nodes') - RETURN - END IF - IF (SIZE(free_map) < SIZE(q)) THEN - CALL fail(ErrStat, ErrMsg, 'finite-EI hydro tangent free map is undersized') - RETURN - END IF - free_map(1:SIZE(q)) = 0 - DO irow = 1, SIZE(free) - IF (free(irow) < 1 .OR. free(irow) > SIZE(q)) THEN - CALL fail(ErrStat, ErrMsg, 'finite-EI hydro tangent free DOF out of range') - RETURN - END IF - free_map(free(irow)) = irow - END DO - DO e = 1, model%n_elem - a = e - b = e + 1 - ia = 6*a - 5 - ib = 6*b - 5 - idx = [ia, ia + 1, ia + 2, ib, ib + 1, ib + 2] - xa = q(ia:ia + 2) - xb = q(ib:ib + 2) - va = v(ia:ia + 2) - vb = v(ib:ib + 2) - CALL finite_environment_node(opts, time, xa, eta_a, fluid_a, accel_a, es, em) - IF (es /= CD_HYDRO_OK) THEN - ErrStat = CD_DECKDRV_BADINPUT - ErrMsg = 'CableDyn_DeckDriver: finite-EI tangent node A failed: '//TRIM(em) - RETURN - END IF - CALL finite_environment_node(opts, time, xb, eta_b, fluid_b, accel_b, es, em) - IF (es /= CD_HYDRO_OK) THEN - ErrStat = CD_DECKDRV_BADINPUT - ErrMsg = 'CableDyn_DeckDriver: finite-EI tangent node B failed: '//TRIM(em) - RETURN - END IF - CALL CD_Morison_Drag_Element_Load(xa, xb, va, vb, model%l0(e), fluid_a, fluid_b, eta_a, eta_b, & - opts%rhoW, model%diam(e), model%cdn(e), model%cdt(e), & - f2, jq2, jv2, es, em) - IF (es /= CD_HYDRO_OK) THEN - ErrStat = CD_DECKDRV_SOLVEFAIL - ErrMsg = 'CableDyn_DeckDriver: finite-EI drag tangent failed: '//TRIM(em) - RETURN - END IF - force(idx) = force(idx) + f2 - DO jcol = 1, 6 - DO irow = 1, 6 - CALL scatter_finite_contact_band(jac_q_band, free_map, kl, ku, idx(irow), idx(jcol), & - jq2(irow, jcol), ErrStat, ErrMsg) - IF (ErrStat /= CD_DECKDRV_OK) RETURN - CALL scatter_finite_contact_band(jac_v_band, free_map, kl, ku, idx(irow), idx(jcol), & - jv2(irow, jcol), ErrStat, ErrMsg) - IF (ErrStat /= CD_DECKDRV_OK) RETURN - END DO - END DO - IF (opts%has_wave) THEN - CALL CD_Froude_Krylov_Element_Load(xa, xb, va, vb, model%l0(e), accel_a, accel_b, eta_a, eta_b, & - opts%rhoW, model%diam(e), model%can(e), model%cat(e), & - f2, jq2, jv2, es, em) - IF (es /= CD_HYDRO_OK) THEN - ErrStat = CD_DECKDRV_SOLVEFAIL - ErrMsg = 'CableDyn_DeckDriver: finite-EI FK tangent failed: '//TRIM(em) - RETURN - END IF - force(idx) = force(idx) + f2 - DO jcol = 1, 6 - DO irow = 1, 6 - CALL scatter_finite_contact_band(jac_q_band, free_map, kl, ku, idx(irow), idx(jcol), & - jq2(irow, jcol), ErrStat, ErrMsg) - IF (ErrStat /= CD_DECKDRV_OK) RETURN - CALL scatter_finite_contact_band(jac_v_band, free_map, kl, ku, idx(irow), idx(jcol), & - jv2(irow, jcol), ErrStat, ErrMsg) - IF (ErrStat /= CD_DECKDRV_OK) RETURN - END DO - END DO - END IF - END DO - END SUBROUTINE finite_environment_load_banded - SUBROUTINE finite_environment_node(opts, time, x, eta, fluid_velocity, fluid_acceleration, ErrStat, ErrMsg) TYPE(DeckOptions), INTENT(IN) :: opts REAL(wp), INTENT(IN) :: time, x(3) @@ -17417,6 +17098,8 @@ SUBROUTINE finalize_checks(types, bodies, rod_types, rods, points, lines, sectio INTEGER :: i, j, idx, nsec_for_line, body_id, body_idx, rod_id, rod_idx, na_ref, nb_ref INTEGER :: nstep LOGICAL :: grid_ok + ! a finite-EI line (some section with EI > 0), for the End B rule of a line between moving points + LOGICAL :: shared_finite REAL(wp) :: displaced_mass CHARACTER(NAMELEN) :: ta, tb ErrStat = 0; ErrMsg = '' @@ -18097,6 +17780,7 @@ SUBROUTINE finalize_checks(types, bodies, rod_types, rods, points, lines, sectio ! lines: positive unique ids, endpoints resolve, >=1 section, known output flags DO i = 1, SIZE(lines) at_line = lines(i)%deck_line + shared_finite = .FALSE. IF (lines(i)%id < 1) THEN CALL fail(ErrStat, ErrMsg, 'LINE id must be >= 1'); RETURN END IF @@ -18150,34 +17834,34 @@ SUBROUTINE finalize_checks(types, bodies, rod_types, rods, points, lines, sectio RETURN END IF IF (tb /= 'fixed') THEN - ! FAST.Farm SHARED line: both ends coupled is legal iff BOTH endpoints carry - ! the Turbine vocabulary (the fairlead-to-fairlead line between turbines); - ! any other non-anchor End B stays rejected. + ! A line between two moving points: legal for a FAST.Farm SHARED line, whose endpoints both + ! carry the Turbine vocabulary (the fairlead-to-fairlead line between turbines), and for + ! a finite-EI line between two Coupled/Vessel points (the cubic-Hermite cable drives both + ! ends); any other non-anchor End B stays rejected. + BLOCK + INTEGER :: js, ks + shared_finite = .FALSE. + DO js = 1, SIZE(sections) + IF (sections(js)%line_id /= lines(i)%id) CYCLE + ks = find_type(types, sections(js)%ltype_name) + IF (ks < 1) CYCLE + IF (types(ks)%ei > CD_ZERO) shared_finite = .TRUE. + END DO + END BLOCK IF (.NOT. ((tb == 'coupled' .OR. tb == 'vessel') .AND. & - points(find_point(points, lines(i)%nodeA))%turbine_id > 0 .AND. & - points(find_point(points, lines(i)%nodeB))%turbine_id > 0)) THEN + ((points(find_point(points, lines(i)%nodeA))%turbine_id > 0 .AND. & + points(find_point(points, lines(i)%nodeB))%turbine_id > 0) .OR. shared_finite))) THEN ! The Connect-point split is a workaround only for an EI=0 line: in a deck with ! Connect points a finite-EI cable needs a Fixed End B and cannot end on a Connect point. - BLOCK - INTEGER :: js, ks - LOGICAL :: shared_finite - shared_finite = .FALSE. - DO js = 1, SIZE(sections) - IF (sections(js)%line_id /= lines(i)%id) CYCLE - ks = find_type(types, sections(js)%ltype_name) - IF (ks < 1) CYCLE - IF (types(ks)%ei > CD_ZERO) shared_finite = .TRUE. - END DO - IF (shared_finite) THEN - CALL fail(ErrStat, ErrMsg, 'finite-EI LINE '//TRIM(int_to_str(lines(i)%id))//' End B (NodeB, '// & - 'POINT '//TRIM(int_to_str(lines(i)%nodeB))//', '//TRIM(tb)//') must be a Fixed '// & - '(anchor) point: a line between two moving points (a shared line) is not supported, '// & - 'except a FAST.Farm shared line between two Turbine fairleads. A finite-EI line '// & - 'cannot be split at a Connect point either (beside Connect points a finite-EI cable '// & - 'needs a Fixed End B and cannot end on a Connect point): anchor it on a Fixed point, '// & - 'or model the shared span with EI=0 line types split at a Connect point'); RETURN - END IF - END BLOCK + IF (shared_finite) THEN + CALL fail(ErrStat, ErrMsg, 'finite-EI LINE '//TRIM(int_to_str(lines(i)%id))//' End B (NodeB, '// & + 'POINT '//TRIM(int_to_str(lines(i)%nodeB))//', '//TRIM(tb)//') must be a Fixed '// & + '(anchor), Coupled or Vessel point (a finite-EI line between two Coupled/Vessel points '// & + 'has both ends driven). A finite-EI line cannot be split at a Connect point (beside '// & + 'Connect points a finite-EI cable needs a Fixed End B and cannot end on a Connect '// & + 'point): anchor it on a Fixed point, or model the shared span with EI=0 line types '// & + 'split at a Connect point'); RETURN + END IF CALL fail(ErrStat, ErrMsg, 'LINE '//TRIM(int_to_str(lines(i)%id))//' End B (NodeB, POINT '// & TRIM(int_to_str(lines(i)%nodeB))//', '//TRIM(tb)//') must be a Fixed (anchor) point: a line '// & 'between two moving points (a shared line) is not supported, except a FAST.Farm shared line '// & @@ -18330,23 +18014,20 @@ SUBROUTINE finalize_checks(types, bodies, rod_types, rods, points, lines, sectio CALL fail(ErrStat, ErrMsg, 'END CONNECTIONS requires a finite-EI line') RETURN END IF - ! The production Hermite boundary supports a moving End A and a held End B. - ! The two-moving-end route does not assemble bending - ! connection forces or moments. Reject that topology at the common parser - ! boundary so no entry point can silently reinterpret a declared connection - ! as pinned, while retaining finite/rigid connections at either end of every - ! supported Fixed-End-B cable. + ! The production Hermite boundary connects End A to its moving parent and End B to a + ! Fixed point or to its own moving parent (a Coupled/Vessel End B, a line between two + ! moving points; a body point or a rod end, a line between two objects on the multibody + ! march). Any other End B fails closed here, at the common parser boundary, so no entry + ! point can silently reinterpret a declared connection as pinned. 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') + IF (j < 1) THEN + CALL fail(ErrStat, ErrMsg, 'non-pinned END CONNECTIONS need End B on a Fixed, Coupled or Vessel point, '// & + 'a Rigid6 body point or a rod end') + RETURN + ELSE IF (.NOT. end_b_holds_frame(points(j)%ptype)) THEN + CALL fail(ErrStat, ErrMsg, 'non-pinned END CONNECTIONS need End B on a Fixed, Coupled or Vessel point, '// & + 'a Rigid6 body point or a rod end; line '//TRIM(int_to_str(lines(i)%id))//' ends on a "'// & + TRIM(points(j)%ptype)//'" point') RETURN END IF END DO @@ -18379,9 +18060,9 @@ 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, a body End A must be a Rigid6 body, and a rod End A must be on a - !! Fixed rod. + !! both ends restrained (torsion active) End B must be Fixed, Coupled/Vessel or a Rigid6 body + !! point (not a rod end), every section's LINE TYPES row must give an explicit GJ, a body end + !! must be on a Rigid6 body, and a rod End A must be on a Fixed rod, with a Fixed End B. !! !! 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, @@ -18391,11 +18072,13 @@ SUBROUTINE check_torsion_line(ln, es_t, em_t) !! 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. + !! rod beside a finite-EI cable), so its host-driven frame is not wired to the torsion. A + !! moving End B (a Coupled/Vessel point, or a body point: a line between two objects) turns + !! its own frame with its parent. TYPE(DeckLine), INTENT(IN) :: ln INTEGER, INTENT(OUT) :: es_t CHARACTER(*), INTENT(OUT) :: em_t - INTEGER :: js, jp, jb, rid, rend + INTEGER :: js, jp, jb, je, rid, rend CHARACTER(32) :: lid es_t = 0 em_t = '' @@ -18436,16 +18119,14 @@ SUBROUTINE check_torsion_line(ln, es_t, em_t) END BLOCK RETURN END IF + ! End B is held at a Fixed point or driven with its own frame at a Coupled/Vessel point (a + ! line between two moving points: both end frames turn with their parents) or on a body + ! point (a line between two objects) 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') + IF (.NOT. end_b_holds_frame(points(jp)%ptype)) THEN + CALL fail(es_t, em_t, 'torsional END CONNECTIONS need End B on a Fixed, Coupled or Vessel point or a '// & + 'Rigid6 body point; line '//TRIM(lid)//' ends on a "'//TRIM(points(jp)%ptype)//'" point') RETURN END IF DO js = 1, SIZE(sections) @@ -18458,6 +18139,14 @@ SUBROUTINE check_torsion_line(ln, es_t, em_t) RETURN END IF END DO + ! End B on a rod end: no route of this build solves a torsion frame at a rod's end at End B + 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 '// & + 'at End B: restrain the line at the rod end through its End A (a Fixed rod, or a rod fixed to '// & + 'a Rigid6 body, RODS type Body), or end it on a Fixed point at a Fixed rod end''s position '// & + '(its force then stays out of that rod''s Rod loads)') + RETURN + END IF jp = find_point(points, ln%nodeA) IF (jp < 1) RETURN IF (is_rod_point_type(points(jp)%ptype)) THEN @@ -18481,17 +18170,31 @@ SUBROUTINE check_torsion_line(ln, es_t, em_t) RETURN END SELECT END IF - END IF - IF (starts_with(TRIM(points(jp)%ptype), 'body')) THEN - jb = find_body(bodies, points(jp)%body_id) + jb = find_point(points, ln%nodeB) IF (jb > 0) THEN - IF (TRIM(bodies(jb)%btype) /= 'rigid6') THEN - CALL fail(es_t, em_t, 'line '//TRIM(lid)//': a torsional END CONNECTION on a body needs a Rigid6 '// & - 'body') + IF (TRIM(points(jb)%ptype) /= 'fixed') THEN + CALL fail(es_t, em_t, 'line '//TRIM(lid)//': a torsional END CONNECTION on a rod end needs a Fixed '// & + 'End B (a line restrained in torsion between a rod end and a moving object is not '// & + 'supported in this build)') RETURN END IF END IF END IF + ! either end on a non-Rigid6 body (End B on a body point: a line between two objects) + DO je = 1, 2 + jp = find_point(points, MERGE(ln%nodeA, ln%nodeB, je == 1)) + IF (jp < 1) RETURN + IF (starts_with(TRIM(points(jp)%ptype), 'body')) THEN + jb = find_body(bodies, points(jp)%body_id) + IF (jb > 0) THEN + IF (TRIM(bodies(jb)%btype) /= 'rigid6') THEN + CALL fail(es_t, em_t, 'line '//TRIM(lid)//': a torsional END CONNECTION on a body needs a Rigid6 '// & + 'body') + RETURN + END IF + END IF + END IF + END DO END SUBROUTINE check_torsion_line END SUBROUTINE finalize_checks @@ -19089,117 +18792,6 @@ SUBROUTINE write_dynamic_system_line_outputs(time, lines, system, pos_units, ten END DO END SUBROUTINE write_dynamic_system_line_outputs - SUBROUTINE open_dynamic_finite_line_outputs(out_root, lines, models, pos_units, ten_units, ErrStat, ErrMsg) - !! Open optional finite-EI per-line dynamic time-series files. - CHARACTER(*), INTENT(IN) :: out_root - TYPE(DeckLine), INTENT(IN) :: lines(:) - TYPE(FiniteDeckModel), INTENT(IN) :: models(:) - INTEGER, ALLOCATABLE, INTENT(OUT) :: pos_units(:), ten_units(:) - INTEGER, INTENT(OUT) :: ErrStat - CHARACTER(*), INTENT(OUT) :: ErrMsg - - INTEGER :: i, ios, nnode, ne, node, seg - CHARACTER(LEN(out_root) + 32) :: path - - ErrStat = CD_DECKDRV_OK - ErrMsg = '' - IF (SIZE(models) /= SIZE(lines)) THEN - CALL fail(ErrStat, ErrMsg, 'finite-EI line-output model count does not match line count') - RETURN - END IF - ALLOCATE (pos_units(SIZE(lines)), ten_units(SIZE(lines))) - pos_units = 0 - ten_units = 0 - DO i = 1, SIZE(lines) - IF (.NOT. line_outputs_requested(lines(i)%outputs)) CYCLE - ne = models(i)%n_elem - nnode = ne + 1 - IF (line_output_has_flag(lines(i)%outputs, 'p')) THEN - path = TRIM(out_root)//'.Line'//TRIM(int_to_str(lines(i)%id))//'.p.out' - OPEN (NEWUNIT=pos_units(i), FILE=path, STATUS='REPLACE', ACTION='WRITE', IOSTAT=ios) - IF (ios /= 0) THEN - CALL close_dynamic_line_outputs(pos_units, ten_units) - CALL fail(ErrStat, ErrMsg, 'cannot open finite-EI line position output file: '//TRIM(path)); RETURN - END IF - WRITE (pos_units(i), '(A)') '# CableDyn finite-EI dynamic line node positions; public node order EndA -> EndB' - WRITE (pos_units(i), '(A)', ADVANCE='NO') 'Time(s)' - DO node = 1, nnode - WRITE (pos_units(i), '(A,A,I0,A)', ADVANCE='NO') char_tab(), 'Node', node, 'X(m)' - WRITE (pos_units(i), '(A,A,I0,A)', ADVANCE='NO') char_tab(), 'Node', node, 'Y(m)' - WRITE (pos_units(i), '(A,A,I0,A)', ADVANCE='NO') char_tab(), 'Node', node, 'Z(m)' - END DO - WRITE (pos_units(i), '(A)') '' - END IF - IF (line_output_has_flag(lines(i)%outputs, 't')) THEN - path = TRIM(out_root)//'.Line'//TRIM(int_to_str(lines(i)%id))//'.t.out' - OPEN (NEWUNIT=ten_units(i), FILE=path, STATUS='REPLACE', ACTION='WRITE', IOSTAT=ios) - IF (ios /= 0) THEN - CALL close_dynamic_line_outputs(pos_units, ten_units) - CALL fail(ErrStat, ErrMsg, 'cannot open finite-EI line tension output file: '//TRIM(path)); RETURN - END IF - WRITE (ten_units(i), '(A)') '# CableDyn finite-EI dynamic line segment tensions; public segment order '// & - 'EndA -> EndB' - WRITE (ten_units(i), '(A)', ADVANCE='NO') 'Time(s)' - DO seg = 1, ne - WRITE (ten_units(i), '(A,A,I0,A)', ADVANCE='NO') char_tab(), 'Segment', seg, 'Tension(N)' - END DO - WRITE (ten_units(i), '(A)') '' - END IF - END DO - END SUBROUTINE open_dynamic_finite_line_outputs - - SUBROUTINE write_dynamic_finite_line_outputs(time, lines, models, pos_units, ten_units, work, ErrStat, ErrMsg) - !! Append one row to requested finite-EI dynamic per-line output files. - REAL(wp), INTENT(IN) :: time - TYPE(DeckLine), INTENT(IN) :: lines(:) - TYPE(FiniteDeckModel), INTENT(IN) :: models(:) - INTEGER, INTENT(IN) :: pos_units(:), ten_units(:) - TYPE(ModelOutputWorkspace), INTENT(INOUT) :: work - INTEGER, INTENT(OUT) :: ErrStat - CHARACTER(*), INTENT(OUT) :: ErrMsg - - INTEGER :: i, nnode, ndof, ne, es - CHARACTER(1024) :: em - - ErrStat = CD_DECKDRV_OK - ErrMsg = '' - DO i = 1, SIZE(lines) - IF (pos_units(i) == 0 .AND. ten_units(i) == 0) CYCLE - ne = models(i)%n_elem - nnode = ne + 1 - ndof = 6*nnode - IF (pos_units(i) /= 0) THEN - CALL ensure_model_output_workspace(work, ndof, 0) - CALL CD_Get_FiniteEI_Model_State(models(i)%model, work%q(1:ndof), work%v(1:ndof), & - work%a(1:ndof), es, em) - IF (es /= 0) THEN - ErrStat = CD_DECKDRV_SOLVEFAIL - ErrMsg = 'CableDyn_DeckDriver: finite-EI line-output state recovery failed: '//TRIM(em) - RETURN - END IF - CALL write_line_position_row(pos_units(i), time, work%q(1:ndof), 6, ne, ErrStat) - IF (ErrStat /= CD_DECKDRV_OK) THEN - ErrMsg = 'CableDyn_DeckDriver: non-finite finite-EI line position output' - RETURN - END IF - END IF - IF (ten_units(i) /= 0) THEN - CALL ensure_model_output_workspace(work, 0, ne) - CALL finite_model_tension(models(i), work%tension(1:ne), work, es, em) - IF (es /= CD_DECKDRV_OK) THEN - ErrStat = es - ErrMsg = em - RETURN - END IF - CALL write_line_tension_row(ten_units(i), time, work%tension(1:ne), ErrStat) - IF (ErrStat /= CD_DECKDRV_OK) THEN - ErrMsg = 'CableDyn_DeckDriver: non-finite finite-EI line tension output' - RETURN - END IF - END IF - END DO - END SUBROUTINE write_dynamic_finite_line_outputs - SUBROUTINE close_dynamic_line_outputs(pos_units, ten_units, lift_units) INTEGER, ALLOCATABLE, INTENT(INOUT) :: pos_units(:), ten_units(:) INTEGER, ALLOCATABLE, INTENT(INOUT), OPTIONAL :: lift_units(:) @@ -20857,6 +20449,17 @@ SUBROUTINE point_line_force(points, pidx, system, mb, f, ErrStat, ErrMsg) f = f + [cable_global_component(mb%cables(c), fl, 1), cable_global_component(mb%cables(c), fl, 2), & cable_global_component(mb%cables(c), fl, 3)] END DO + ! End B of a cable between two objects (internal node 1) + IF (.NOT. ALLOCATED(mb%cab_kind_b)) RETURN + DO c = 1, SIZE(mb%cables) + IF (mb%cab_kind_b(c) == 0 .OR. mb%cable_points(2, c) /= points(pidx)%id) CYCLE + CALL CD_HermiteCable_Dyn_End_Force(mb%cables(c)%line, 1, fl, es, em) + IF (es /= CD_HCDYN_OK) THEN + CALL fail_solve(ErrStat, ErrMsg, 'cable end-force recovery failed: '//TRIM(em)); RETURN + END IF + f = f + [cable_global_component(mb%cables(c), fl, 1), cable_global_component(mb%cables(c), fl, 2), & + cable_global_component(mb%cables(c), fl, 3)] + END DO END IF END SUBROUTINE point_line_force @@ -20912,6 +20515,7 @@ SUBROUTINE body_net_wrench(rigid, ib, points, opts, time, f6, ErrStat, ErrMsg, s IF (ALLOCATED(mb%cab_mend)) THEN DO ip = 1, SIZE(mb%cables) IF (mb%cab_kind(ip) == 1 .AND. mb%cab_obj(ip) == ib) m = m + mb%cab_mend(:, ip) + IF (mb%cab_kind_b(ip) == 1 .AND. mb%cab_obj_b(ip) == ib) m = m + mb%cab_mend_b(:, ip) END DO END IF DO ir = 1, SIZE(mb%rods) @@ -21001,13 +20605,26 @@ SUBROUTINE rod_net_wrench(rs, body_of, points, opts, time, f6, ten, sub, ErrStat IF (ALLOCATED(mb%cab_mend)) THEN DO ip = 1, SIZE(mb%cables) 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) + IF (mb%cab_kind(ip) == 2) THEN + IF (mb%rods(mb%cab_obj(ip))%rod_id == rs%rod_id) m = m + mb%cab_mend(:, ip) + END IF + IF (mb%cab_kind_b(ip) == 2) THEN + IF (mb%rods(mb%cab_obj_b(ip))%rod_id == rs%rod_id) m = m + mb%cab_mend_b(:, ip) + END IF + ELSE IF (ALLOCATED(mb%cable_points)) THEN + IF (mb%cab_kind(ip) == 1 .AND. mb%cab_obj(ip) == body_of) THEN + e = find_point(points, mb%cable_points(1, ip)) + IF (e > 0) THEN + IF (points(e)%rod_ref == rs%rod_id .AND. points(e)%rod_end > 0) m = m + mb%cab_mend(:, ip) + END IF + END IF + ! End B on a body point made from this rod's end (a line between two objects) + IF (mb%cab_kind_b(ip) == 1 .AND. mb%cab_obj_b(ip) == body_of) THEN + e = find_point(points, mb%cable_points(2, ip)) + IF (e > 0) THEN + IF (points(e)%rod_ref == rs%rod_id .AND. points(e)%rod_end > 0) m = m + mb%cab_mend_b(:, ip) + END IF + END IF END IF END DO END IF @@ -21588,16 +21205,25 @@ SUBROUTINE write_multibody_dynamic_out(deck_path, out_root, channels, types, bod pa = find_point(points, lines(i)%nodeA) pb = find_point(points, lines(i)%nodeB) IF (is_fin(i)) THEN - IF (TRIM(points(pb)%ptype) /= 'fixed') THEN + ! End B: a Fixed point (held), or a Rigid6 body point or a rod end (a cable between two + ! objects, driven at both ends); a Connect/Free point or a Point3 buoy is refused, and a + ! Coupled/Vessel End B, which this march has no motion to drive + IF (TRIM(points(pb)%ptype) == 'free' .OR. TRIM(points(pb)%ptype) == 'connect' .OR. & + point_on_point3_body(points(pb), bodies)) THEN CALL fail(ErrStat, ErrMsg, 'finite-EI LINE '//TRIM(int_to_str(lines(i)%id))//' in a mixed-topology '// & - 'deck needs a Fixed End B (the cable is driven at End A), but End B is POINT '// & - TRIM(int_to_str(points(pb)%id))//' ('//TRIM(points(pb)%ptype)//'). A finite-EI cable that '// & - 'ends on a Connect/Free/Coupled point (a junction with other lines, a buoy or a pliant-wave '// & - 'hang-off) '// & - 'is not supported in a deck with Connect/Free points, bodies or rods (the multibody '// & - 'march). Anchor the cable on a Fixed point, or run the cable and the lines it joins as '// & + 'deck: End B is POINT '//TRIM(int_to_str(points(pb)%id))//' ('//TRIM(points(pb)%ptype)// & + '); a cable end on a Free/Connect point or a Point3 buoy (a junction with other lines, a '// & + 'buoy or a pliant-wave hang-off) is not supported on the multibody march. End the cable on '// & + 'a Fixed point, a Rigid6 body point or a rod end, or run the cable and the lines it joins as '// & 'separate decks'); RETURN END IF + IF (TRIM(points(pb)%ptype) == 'coupled' .OR. TRIM(points(pb)%ptype) == 'vessel') THEN + CALL fail(ErrStat, ErrMsg, 'finite-EI LINE '//TRIM(int_to_str(lines(i)%id))//': a Coupled/Vessel End B '// & + '(POINT '//TRIM(int_to_str(points(pb)%id))//') would need motionFile coupling to drive it, '// & + 'which a mixed-topology deck with Connect/Free points or bodies (marched as one multibody '// & + 'system) does not support. End the cable on a Fixed point, a Rigid6 body point or a rod end') + RETURN + END IF IF (TRIM(points(pa)%ptype) == 'free' .OR. TRIM(points(pa)%ptype) == 'connect' .OR. & point_on_point3_body(points(pa), bodies)) THEN CALL fail(ErrStat, ErrMsg, 'finite-EI LINE '//TRIM(int_to_str(lines(i)%id))//': a cable end on a '// & @@ -21625,9 +21251,9 @@ SUBROUTINE write_multibody_dynamic_out(deck_path, out_root, channels, types, bod '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)') + CALL fail(ErrStat, ErrMsg, 'finite-EI LINE '//TRIM(int_to_str(lines(i)%id))//': a clamped or '// & + 'elastic END CONNECTION or a torsional one on a body or rod needs bodyScheme monolithic '// & + '(the staggered scheme couples cable ends as point forces)') END IF RETURN END IF @@ -21638,6 +21264,24 @@ SUBROUTINE write_multibody_dynamic_out(deck_path, out_root, channels, types, bod END BLOCK IF (ErrStat /= CD_DECKDRV_OK) RETURN END IF + IF (TRIM(points(pb)%ptype) /= 'fixed' .AND. (lines(i)%endconn_mode(2) /= CD_ENDCONN_PINNED .OR. & + line_torsion_at_b(lines(i)))) THEN + ! the same for a clamped or elastic End B, or a torsion frame, on a body or rod + 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 or a torsional one on a body or rod needs bodyScheme monolithic '// & + '(the staggered scheme couples cable ends as point forces)') + RETURN + END IF + IF (lines(i)%endconn_mode(2) /= CD_ENDCONN_PINNED) THEN + BLOCK + REAL(wp) :: rclamp(3, 3), dclamp(3) + CALL clamp_object_frame(lines(i), points, bodies, rods, rclamp, dclamp, ErrStat, ErrMsg, & + check_axis=.NOT. opts%body_ic_static, end_b=.TRUE.) + END BLOCK + IF (ErrStat /= CD_DECKDRV_OK) RETURN + END IF + END IF END IF END DO ! Free/Connect points integrate on the EI=0 line end loads: each needs one @@ -21691,6 +21335,21 @@ SUBROUTINE write_multibody_dynamic_out(deck_path, out_root, channels, types, bod mb%cab_clamp(SIZE(cab_lines)), mb%cab_moment(3, SIZE(cab_lines)), mb%cab_fend(3, SIZE(cab_lines)), & mb%cab_mend(3, SIZE(cab_lines)), mb%cab_f0(3, SIZE(cab_lines)), mb%cab_m0(3, SIZE(cab_lines)), & mb%cab_kax(SIZE(cab_lines)), mb%cab_len(SIZE(cab_lines))) + ALLOCATE (mb%cab_kind_b(SIZE(cab_lines)), mb%cab_obj_b(SIZE(cab_lines)), mb%cab_off_b(3, SIZE(cab_lines)), & + mb%cab_clamp_b(SIZE(cab_lines)), mb%cab_imp(SIZE(cab_lines)), mb%cab_force_b(3, SIZE(cab_lines)), & + mb%cab_moment_b(3, SIZE(cab_lines)), mb%cab_fend_b(3, SIZE(cab_lines)), & + mb%cab_mend_b(3, SIZE(cab_lines)), mb%cab_f0_b(3, SIZE(cab_lines)), mb%cab_m0_b(3, SIZE(cab_lines))) + mb%cab_kind_b = 0 + mb%cab_obj_b = 0 + mb%cab_off_b = CD_ZERO + mb%cab_clamp_b = .FALSE. + mb%cab_imp = .FALSE. + mb%cab_force_b = CD_ZERO + mb%cab_moment_b = CD_ZERO + mb%cab_fend_b = CD_ZERO + mb%cab_mend_b = CD_ZERO + mb%cab_f0_b = CD_ZERO + mb%cab_m0_b = CD_ZERO mb%cab_age = HUGE(1) mb%cab_kind = 0 mb%cab_obj = 0 @@ -21727,6 +21386,51 @@ SUBROUTINE write_multibody_dynamic_out(deck_path, out_root, channels, types, bod 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_at_a(cab_lines(c))) & .AND. TRIM(points(pa)%ptype) /= 'fixed' + pb = find_point(points, cab_lines(c)%nodeB) + IF (TRIM(points(pb)%ptype) /= 'fixed') THEN + ! a cable between two objects: End B is a second driven end on its body or rod, its + ! connection direction and torsion normal in that object's frame + pc(pb)%ptype = 'coupled' + mb%cab_clamp_b(c) = cab_lines(c)%endconn_mode(2) /= CD_ENDCONN_PINNED .OR. line_torsion_at_b(cab_lines(c)) + ! re-stepped inside the outer Newton when End A is connected, otherwise set with the + ! attachments below: when End B is connected on an object that moves, or both ends' objects + ! move; a cable with one moving end on an object is coupled at the predictor (pinned) or + ! implicitly (connected) whichever end that is + mb%cab_imp(c) = mb%cab_clamp(c) + BLOCK + TYPE(DeckLine) :: lnc + REAL(wp) :: rclamp(3, 3), dclamp(3), rclamp_b(3, 3), dclamp_b(3) + lnc = cab_lines(c) + rclamp = CD_ZERO + rclamp(1, 1) = CD_ONE + rclamp(2, 2) = CD_ONE + rclamp(3, 3) = CD_ONE + rclamp_b = rclamp + IF (mb%cab_clamp(c)) THEN + CALL clamp_object_frame(lnc, points, bodies, rods, rclamp, dclamp, ErrStat, ErrMsg, & + check_axis=.NOT. opts%body_ic_static) + IF (ErrStat /= CD_DECKDRV_OK) GOTO 900 + lnc%endconn_ez_ref(:, 1) = dclamp + END IF + IF (mb%cab_clamp_b(c)) THEN + CALL clamp_object_frame(lnc, points, bodies, rods, rclamp_b, dclamp_b, ErrStat, ErrMsg, & + check_axis=.NOT. opts%body_ic_static, end_b=.TRUE.) + IF (ErrStat /= CD_DECKDRV_OK) GOTO 900 + lnc%endconn_ez_ref(:, 2) = dclamp_b + END IF + 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., & + fold_support=MERGE(FOLD_FRICTION_NONE, FOLD_FRICTION_NO_AS_LAID, & + deck_has_non_rigid6_dynamic_points(points, bodies)), & + allow_moving_end_b=.TRUE., end_b_orientation=TRANSPOSE(rclamp_b)) + END BLOCK + IF (ErrStat /= CD_DECKDRV_OK) GOTO 900 + ! re-stepped inside the outer Newton of the monolithic step + IF (mb%cab_imp(c)) mb%cables(c)%tol = MIN(mb%cables(c)%tol, CLAMPED_CABLE_TOL) + CYCLE + END IF + mb%cab_imp(c) = mb%cab_clamp(c) 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) @@ -21828,12 +21532,43 @@ SUBROUTINE write_multibody_dynamic_out(deck_path, out_root, channels, types, bod 'unresolved rod end'); GOTO 900 END IF END IF + ! End B on a body point or a rod end (a cable between two objects) + pb = find_point(points, cab_lines(c)%nodeB) + IF (starts_with(TRIM(points(pb)%ptype), 'body')) THEN + DO ib = 1, SIZE(mb%rigid) + IF (mb%rigid(ib)%body_id == points(pb)%body_id) THEN + mb%cab_kind_b(c) = 1 + mb%cab_obj_b(c) = ib + mb%cab_off_b(:, c) = points(pb)%body_offset + END IF + END DO + ELSE IF (is_rod_point_type(points(pb)%ptype)) THEN + CALL parse_rod_point_type(points(pb)%ptype, bid, k) + DO ir = 1, SIZE(mb%rods) + IF (mb%rods(ir)%rod_id /= bid) CYCLE + mb%cab_kind_b(c) = 2 + mb%cab_obj_b(c) = ir + mb%cab_off_b(:, c) = [MERGE(-CD_ONE, CD_ONE, k == 1), CD_ZERO, CD_ZERO] + END DO + IF (mb%cab_kind_b(c) == 0) THEN + CALL fail(ErrStat, ErrMsg, 'finite-EI LINE '//TRIM(int_to_str(cab_lines(c)%id))//' attaches to an '// & + 'unresolved rod end'); GOTO 900 + END IF + END IF + ! a cable connected at End B on a moving object, or between two moving objects, couples + ! them implicitly + IF (mb%cab_kind_b(c) > 0 .AND. .NOT. mb%cab_imp(c)) THEN + mb%cab_imp(c) = attachment_moves(mb%cab_kind_b(c), mb%cab_obj_b(c)) .AND. & + (mb%cab_clamp_b(c) .OR. attachment_moves(mb%cab_kind(c), mb%cab_obj(c))) + IF (mb%cab_imp(c)) mb%cables(c)%tol = MIN(mb%cables(c)%tol, CLAMPED_CABLE_TOL) + END IF END DO ALLOCATE (mb%cable_points(2, SIZE(cab_lines))) DO c = 1, SIZE(cab_lines) mb%cable_points(:, c) = [cab_lines(c)%nodeA, cab_lines(c)%nodeB] ! the committed end loads of the initial state (outputs at t = 0, the first step's entry) - CALL mb_cable_committed_loads(mb, c, mb%cab_fend(:, c), mb%cab_mend(:, c), ErrStat, ErrMsg) + CALL mb_cable_committed_loads(mb, c, mb%cab_fend(:, c), mb%cab_mend(:, c), ErrStat, ErrMsg, & + fb=mb%cab_fend_b(:, c), mbm=mb%cab_mend_b(:, c)) IF (ErrStat /= CD_DECKDRV_OK) GOTO 900 END DO CALL range_setup_aggregate(mb_ranges, lines, channels, opts, mb%has_sys, mb%system, mb%cables, & @@ -21941,6 +21676,19 @@ SUBROUTINE write_multibody_dynamic_out(deck_path, out_root, channels, types, bod CONTAINS + LOGICAL FUNCTION attachment_moves(kind, obj) RESULT(moves) + !! A cable end attachment that the march moves: a Rigid6 body, or a free or pinned rod (a + !! fixed rod, a rod fixed in place, and a held point do not). + INTEGER, INTENT(IN) :: kind, obj + moves = .FALSE. + SELECT CASE (kind) + CASE (1) + moves = .TRUE. + CASE (2) + moves = mb%rods(obj)%is_free .OR. mb%rods(obj)%is_pinned + END SELECT + END FUNCTION attachment_moves + SUBROUTINE probe_record(col, time) !! Column col of the probe record: t, r(3), v(3), rot_mat(9, column-major), omega(3), a(3) of !! body 1; finite-EI cable 1 energy (kinetic plus elastic), End A connection moment(3) and end @@ -21966,6 +21714,25 @@ SUBROUTINE probe_record(col, time) END BLOCK probe_rec(24:26, col) = mb%cab_mend(:, 1) probe_rec(27:29, col) = mb%cab_fend(:, 1) + ! End B's connection moment and end force on its object, the cable's linear momentum + probe_rec(51:53, col) = mb%cab_mend_b(:, 1) + probe_rec(54:56, col) = mb%cab_fend_b(:, 1) + BLOCK + REAL(wp) :: pm(3) + INTEGER :: es_p + CHARACTER(1024) :: em_p + CALL CD_HermiteCable_Dyn_Momentum(mb%cables(1)%line, pm, es_p, em_p) + probe_rec(48:50, col) = [cable_global_component(mb%cables(1), pm, 1), & + cable_global_component(mb%cables(1), pm, 2), & + cable_global_component(mb%cables(1), pm, 3)] + END BLOCK + END IF + ! body 2: r(3), v(3), rot_mat(9), omega(3) + IF (SIZE(mb%rigid) > 1) THEN + probe_rec(30:32, col) = mb%rigid(2)%r + probe_rec(33:35, col) = mb%rigid(2)%v + probe_rec(36:44, col) = RESHAPE(mb%rigid(2)%rot_mat, [9]) + probe_rec(45:47, col) = mb%rigid(2)%omega END IF END SUBROUTINE probe_record @@ -22026,6 +21793,13 @@ SUBROUTINE mb_outputs(time) END SUBROUTINE mb_outputs END SUBROUTINE write_multibody_dynamic_out + SUBROUTINE CD_Body_Static_Pass_Limit(n) + !! Verification hook: limit the static passes of solve_body_equilibrium to n (n <= 0: the + !! default MAX_PASS). + INTEGER, INTENT(IN) :: n + body_static_pass_limit = n + END SUBROUTINE CD_Body_Static_Pass_Limit + SUBROUTINE CD_Multibody_Probe_Arm(v0, omega0) !! Arm the multibody-march probe (verification tests): the next multibody run starts body 1 !! with velocity v0 and angular velocity omega0 (global frame, m/s and rad/s) and records its @@ -22040,8 +21814,10 @@ END SUBROUTINE CD_Multibody_Probe_Arm SUBROUTINE CD_Multibody_Probe_Get(rec) !! The record of the last probed multibody run: rec(CD_MB_PROBE_NCOL, 0:nstep), columns t, !! r(3), v(3), rot_mat(9, column-major), omega(3), a(3) of body 1 (1-22), then finite-EI cable - !! 1's energy (23), committed End A connection moment (24-26) and end force (27-29) - !! (probe_record); unallocated when none. + !! 1's energy (23), committed End A connection moment (24-26) and end force (27-29), body 2's + !! r(3), v(3), rot_mat(9), omega(3) (30-47, zero without a second body), cable 1's linear + !! momentum (48-50) and its committed End B connection moment (51-53) and end force (54-56) + !! on End B's object (zero with a Fixed End B) (probe_record); unallocated when none. REAL(wp), ALLOCATABLE, INTENT(OUT) :: rec(:, :) IF (ALLOCATED(probe_rec)) rec = probe_rec END SUBROUTINE CD_Multibody_Probe_Get @@ -22072,19 +21848,23 @@ SUBROUTINE mb_snap_pinned(rod, rigid) rod%a = a_pin + cross3(rod%alpha, arm) + cross3(rod%omega, cross3(rod%omega, arm)) END SUBROUTINE mb_snap_pinned - SUBROUTINE mb_attachment_motion(mb, c, x, v, a, es, em, dcm, w, al) + SUBROUTINE mb_attachment_motion(mb, c, x, v, a, es, em, dcm, w, al, end_b) !! Position, velocity and acceleration of cable c's End A attachment (body point, rod end or - !! held point); optionally the attached object's orientation as a global-to-object DCM (the - !! OpenFAST mesh convention of CD_HFMF_UpdateStates) and its angular velocity and - !! acceleration in global axes (identity and zero at a held point). es/em carry the held - !! point's kinematics query status (CD_HFMF_OK otherwise). + !! held point), or with end_b its End B attachment; optionally the attached object's + !! orientation as a global-to-object DCM (the OpenFAST mesh convention of + !! CD_HFMF_UpdateStates) and its angular velocity and acceleration in global axes (identity + !! and zero at a held point). es/em carry the held point's kinematics query status (CD_HFMF_OK + !! otherwise). TYPE(MultibodyMarch), INTENT(IN) :: mb INTEGER, INTENT(IN) :: c REAL(wp), INTENT(OUT) :: x(3), v(3), a(3) INTEGER, INTENT(OUT) :: es CHARACTER(*), INTENT(OUT) :: em REAL(wp), INTENT(OUT), OPTIONAL :: dcm(3, 3), w(3), al(3) - REAL(wp) :: arm(3), rot(3, 3), wo(3), alo(3) + LOGICAL, INTENT(IN), OPTIONAL :: end_b + REAL(wp) :: arm(3), rot(3, 3), wo(3), alo(3), off(3) + INTEGER :: kind, obj + LOGICAL :: at_b es = CD_HFMF_OK em = '' rot = CD_ZERO @@ -22093,10 +21873,21 @@ SUBROUTINE mb_attachment_motion(mb, c, x, v, a, es, em, dcm, w, al) rot(3, 3) = CD_ONE wo = CD_ZERO alo = CD_ZERO - SELECT CASE (mb%cab_kind(c)) + at_b = .FALSE. + IF (PRESENT(end_b)) at_b = end_b + IF (at_b) THEN + kind = mb%cab_kind_b(c) + obj = mb%cab_obj_b(c) + off = mb%cab_off_b(:, c) + ELSE + kind = mb%cab_kind(c) + obj = mb%cab_obj(c) + off = mb%cab_off(:, c) + END IF + SELECT CASE (kind) CASE (1) - ASSOCIATE (b => mb%rigid(mb%cab_obj(c))) - arm = MATMUL(b%rot_mat, mb%cab_off(:, c)) + ASSOCIATE (b => mb%rigid(obj)) + arm = MATMUL(b%rot_mat, off) x = b%r + arm v = b%v + cross3(b%omega, arm) a = b%a + cross3(b%alpha, arm) + cross3(b%omega, cross3(b%omega, arm)) @@ -22105,8 +21896,8 @@ SUBROUTINE mb_attachment_motion(mb, c, x, v, a, es, em, dcm, w, al) alo = b%alpha END ASSOCIATE CASE (2) - ASSOCIATE (r => mb%rods(mb%cab_obj(c))) - arm = mb%cab_off(1, c)*r%half_length*r%rot_mat(:, 1) + ASSOCIATE (r => mb%rods(obj)) + arm = off(1)*r%half_length*r%rot_mat(:, 1) x = r%r + arm v = r%v + cross3(r%omega, arm) a = r%a + cross3(r%alpha, arm) + cross3(r%omega, cross3(r%omega, arm)) @@ -22115,7 +21906,11 @@ SUBROUTINE mb_attachment_motion(mb, c, x, v, a, es, em, dcm, w, al) alo = r%alpha END ASSOCIATE CASE DEFAULT - CALL CD_HFMF_GetCoupledKinematics(mb%cables(c), x, v, a, es, em) + IF (at_b) THEN + CALL CD_HFMF_GetEndBKinematics(mb%cables(c), x, v, a, es, em) + ELSE + CALL CD_HFMF_GetCoupledKinematics(mb%cables(c), x, v, a, es, em) + END IF v = CD_ZERO a = CD_ZERO END SELECT @@ -22127,18 +21922,44 @@ END SUBROUTINE mb_attachment_motion SUBROUTINE mb_cable_drive(mb, c, dt, ErrStat, ErrMsg) !! Step cable c over dt with its End A attachment's current (end-of-step) motion, the object !! orientation driving a clamped or elastic connection, and read its committed end force and - !! connection moment into cab_fend/cab_mend. + !! connection moment into cab_fend/cab_mend. A cable between two objects is driven at End B + !! by its End B attachment as well (cab_fend_b/cab_mend_b). TYPE(MultibodyMarch), INTENT(INOUT) :: mb INTEGER, INTENT(IN) :: c REAL(wp), INTENT(IN) :: dt INTEGER, INTENT(OUT) :: ErrStat CHARACTER(*), INTENT(OUT) :: ErrMsg REAL(wp) :: xa(3), va(3), aa(3), dcm(3, 3), wa(3), ala(3) + REAL(wp) :: xb(3), vb(3), ab(3), dcmb(3, 3), wb(3), alb(3) INTEGER :: es CHARACTER(1024) :: em ErrStat = CD_DECKDRV_OK ErrMsg = '' mb%cables(c)%dt = dt + IF (mb%cab_kind_b(c) > 0) THEN + CALL mb_attachment_motion(mb, c, xa, va, aa, es, em, dcm, wa, ala) + IF (es == CD_HFMF_OK) CALL mb_attachment_motion(mb, c, xb, vb, ab, es, em, dcmb, wb, alb, end_b=.TRUE.) + IF (es == CD_HFMF_OK) THEN + IF (mb%cab_clamp(c) .AND. mb%cab_clamp_b(c)) THEN + CALL CD_HFMF_UpdateStates(mb%cables(c), xa, va, aa, es, em, u_orientation=dcm, u_angular_velocity=wa, & + u_angular_acceleration=ala, ub_pos=xb, ub_vel=vb, ub_acc=ab, & + ub_orientation=dcmb, ub_angular_velocity=wb, ub_angular_acceleration=alb) + ELSE IF (mb%cab_clamp(c)) THEN + CALL CD_HFMF_UpdateStates(mb%cables(c), xa, va, aa, es, em, u_orientation=dcm, u_angular_velocity=wa, & + u_angular_acceleration=ala, ub_pos=xb, ub_vel=vb, ub_acc=ab) + ELSE IF (mb%cab_clamp_b(c)) THEN + CALL CD_HFMF_UpdateStates(mb%cables(c), xa, va, aa, es, em, ub_pos=xb, ub_vel=vb, ub_acc=ab, & + ub_orientation=dcmb, ub_angular_velocity=wb, ub_angular_acceleration=alb) + ELSE + CALL CD_HFMF_UpdateStates(mb%cables(c), xa, va, aa, es, em, ub_pos=xb, ub_vel=vb, ub_acc=ab) + END IF + END IF + IF (es == CD_HFMF_OK) CALL CD_HFMF_CalcOutput(mb%cables(c), mb%cab_fend(:, c), es, em, & + y_moment=mb%cab_mend(:, c), y_end_b=mb%cab_fend_b(:, c), & + y_moment_b=mb%cab_mend_b(:, c)) + IF (es /= CD_HFMF_OK) CALL fail_solve(ErrStat, ErrMsg, 'multibody finite-EI cable step failed: '//TRIM(em)) + RETURN + END IF IF (mb%cab_clamp(c)) THEN CALL mb_attachment_motion(mb, c, xa, va, aa, es, em, dcm, wa, ala) IF (es == CD_HFMF_OK) CALL CD_HFMF_UpdateStates(mb%cables(c), xa, va, aa, es, em, u_orientation=dcm, & @@ -22152,28 +21973,49 @@ SUBROUTINE mb_cable_drive(mb, c, dt, ErrStat, ErrMsg) IF (es /= CD_HFMF_OK) CALL fail_solve(ErrStat, ErrMsg, 'multibody finite-EI cable step failed: '//TRIM(em)) END SUBROUTINE mb_cable_drive - SUBROUTINE mb_cable_committed_loads(mb, c, f, m, ErrStat, ErrMsg) - !! Committed end force and connection moment of cable c on its End A attachment. + SUBROUTINE mb_cable_committed_loads(mb, c, f, m, ErrStat, ErrMsg, fb, mbm) + !! Committed end force and connection moment of cable c on its End A attachment; fb/mbm those + !! on its End B attachment (a cable between two objects; zero otherwise). TYPE(MultibodyMarch), INTENT(INOUT) :: mb INTEGER, INTENT(IN) :: c REAL(wp), INTENT(OUT) :: f(3), m(3) INTEGER, INTENT(OUT) :: ErrStat CHARACTER(*), INTENT(OUT) :: ErrMsg + REAL(wp), INTENT(OUT), OPTIONAL :: fb(3), mbm(3) INTEGER :: es CHARACTER(1024) :: em ErrStat = CD_DECKDRV_OK ErrMsg = '' - CALL CD_HFMF_CalcOutput(mb%cables(c), f, es, em, y_moment=m) + IF (PRESENT(fb)) fb = CD_ZERO + IF (PRESENT(mbm)) mbm = CD_ZERO + IF (PRESENT(fb) .AND. PRESENT(mbm) .AND. mb%cab_kind_b(c) > 0) THEN + CALL CD_HFMF_CalcOutput(mb%cables(c), f, es, em, y_moment=m, y_end_b=fb, y_moment_b=mbm) + ELSE + CALL CD_HFMF_CalcOutput(mb%cables(c), f, es, em, y_moment=m) + END IF IF (es /= CD_HFMF_OK) CALL fail_solve(ErrStat, ErrMsg, 'multibody cable end-load query failed: '//TRIM(em)) END SUBROUTINE mb_cable_committed_loads - SUBROUTINE mb_cable_arm(mb, c, arm) + SUBROUTINE mb_cable_arm(mb, c, arm, end_b) !! Arm from the attached object's reference point (body reference, rod centre) to cable c's - !! End A. + !! End A, or with end_b to its End B. TYPE(MultibodyMarch), INTENT(IN) :: mb INTEGER, INTENT(IN) :: c REAL(wp), INTENT(OUT) :: arm(3) + LOGICAL, INTENT(IN), OPTIONAL :: end_b + LOGICAL :: at_b + at_b = .FALSE. + IF (PRESENT(end_b)) at_b = end_b arm = CD_ZERO + IF (at_b) THEN + SELECT CASE (mb%cab_kind_b(c)) + CASE (1) + arm = MATMUL(mb%rigid(mb%cab_obj_b(c))%rot_mat, mb%cab_off_b(:, c)) + CASE (2) + arm = mb%cab_off_b(1, c)*mb%rods(mb%cab_obj_b(c))%half_length*mb%rods(mb%cab_obj_b(c))%rot_mat(:, 1) + END SELECT + RETURN + END IF SELECT CASE (mb%cab_kind(c)) CASE (1) arm = MATMUL(mb%rigid(mb%cab_obj(c))%rot_mat, mb%cab_off(:, c)) @@ -22200,12 +22042,23 @@ SUBROUTINE mb_cable_k6(mb, kind, obj, shift, k6) eye(k, k) = CD_ONE END DO DO c = 1, SIZE(mb%cables) - IF (mb%cab_kind(c) /= kind .OR. mb%cab_obj(c) /= obj) CYCLE - CALL mb_cable_arm(mb, c, arm) + IF (mb%cab_kind(c) == kind .AND. mb%cab_obj(c) == obj) THEN + CALL mb_cable_arm(mb, c, arm) + CALL add_end(mb%cab_force(:, c)) + END IF + ! End B of a cable between two objects + IF (mb%cab_kind_b(c) == kind .AND. mb%cab_obj_b(c) == obj) THEN + CALL mb_cable_arm(mb, c, arm, end_b=.TRUE.) + CALL add_end(mb%cab_force_b(:, c)) + END IF + END DO + CONTAINS + SUBROUTINE add_end(fend) + REAL(wp), INTENT(IN) :: fend(3) arm = arm + shift - ten = NORM2(mb%cab_force(:, c)) + ten = NORM2(fend) IF (ten > CD_ZERO .AND. mb%cab_len(c) > CD_ZERO) THEN - t = mb%cab_force(:, c)/ten + t = fend/ten katt = mb%cab_kax(c)*SPREAD(t, 2, 3)*SPREAD(t, 1, 3) + & ten/mb%cab_len(c)*(eye - SPREAD(t, 2, 3)*SPREAD(t, 1, 3)) ELSE @@ -22217,7 +22070,7 @@ SUBROUTINE mb_cable_k6(mb, kind, obj, shift, k6) k6(k) = k6(k) + katt(k, k) k6(3 + k) = k6(3 + k) + krot(k, k) END DO - END DO + END SUBROUTINE add_end END SUBROUTINE mb_cable_k6 SUBROUTINE mb_rod_bases(mb, points, rod, bases, arms) @@ -22511,6 +22364,19 @@ SUBROUTINE mb_accelerations(mb, points, opts, time, dt, ErrStat, ErrMsg, bathyme fxr(:, mb%cab_obj(c)) = fxr(:, mb%cab_obj(c)) + mb%cab_force(:, c) mxr(:, mb%cab_obj(c)) = mxr(:, mb%cab_obj(c)) + cross3(arm, mb%cab_force(:, c)) + mb%cab_moment(:, c) END SELECT + ! End B of a cable between two objects + IF (mb%cab_kind_b(c) == 0) CYCLE + CALL mb_cable_arm(mb, c, arm, end_b=.TRUE.) + SELECT CASE (mb%cab_kind_b(c)) + CASE (1) + fxb(:, mb%cab_obj_b(c)) = fxb(:, mb%cab_obj_b(c)) + mb%cab_force_b(:, c) + mxb(:, mb%cab_obj_b(c)) = mxb(:, mb%cab_obj_b(c)) + cross3(arm, mb%cab_force_b(:, c)) + & + mb%cab_moment_b(:, c) + CASE (2) + fxr(:, mb%cab_obj_b(c)) = fxr(:, mb%cab_obj_b(c)) + mb%cab_force_b(:, c) + mxr(:, mb%cab_obj_b(c)) = mxr(:, mb%cab_obj_b(c)) + cross3(arm, mb%cab_force_b(:, c)) + & + mb%cab_moment_b(:, c) + END SELECT END DO ! bodies with their pinned rods DO ib = 1, SIZE(mb%rigid) @@ -22643,7 +22509,12 @@ SUBROUTINE mb_line_loads(mb, ErrStat, ErrMsg) END IF END IF DO c = 1, SIZE(mb%cables) - CALL CD_HFMF_CalcOutput(mb%cables(c), mb%cab_force(:, c), es, em, y_moment=mb%cab_moment(:, c)) + IF (mb%cab_kind_b(c) > 0) THEN + CALL CD_HFMF_CalcOutput(mb%cables(c), mb%cab_force(:, c), es, em, y_moment=mb%cab_moment(:, c), & + y_end_b=mb%cab_force_b(:, c), y_moment_b=mb%cab_moment_b(:, c)) + ELSE + CALL CD_HFMF_CalcOutput(mb%cables(c), mb%cab_force(:, c), es, em, y_moment=mb%cab_moment(:, c)) + END IF IF (es /= CD_HFMF_OK) THEN CALL fail_solve(ErrStat, ErrMsg, 'multibody cable end-force query failed: '//TRIM(em)); RETURN END IF @@ -22868,6 +22739,13 @@ SUBROUTINE mb_step_once(mb, points, opts, time, dt, converged, stalled, n_iter, END IF END IF DO c = 1, SIZE(mb%cables) + IF (mb%cab_kind_b(c) > 0) THEN + ! a cable between two objects (pinned at both ends on this scheme): both ends driven by + ! their predicted attachments + CALL mb_cable_drive(mb, c, dt, ErrStat, ErrMsg) + IF (ErrStat /= CD_DECKDRV_OK) RETURN + CYCLE + END IF CALL mb_attachment_motion(mb, c, x, v, a, es, em) mb%cables(c)%dt = dt IF (es == CD_HFMF_OK) CALL CD_HFMF_UpdateStates(mb%cables(c), x, v, a, es, em) @@ -23050,11 +22928,12 @@ SUBROUTINE mb_junction_layout(mb, points) END IF END DO ! the clamped cables' kept Jacobian columns span a whole group: a body's six coordinates - ! and three for each rod pinned to it + ! and three for each rod pinned to it; a cable between two objects spans both groups IF (ALLOCATED(mb%cables)) THEN IF (ALLOCATED(mb%cab_jac)) DEALLOCATE (mb%cab_jac) k = 1 IF (mb%ng > 0) k = MAX(k, MAXVAL(mb%g_hi(1:mb%ng) - mb%g_lo(1:mb%ng) + 1)) + IF (ANY(mb%cab_kind_b > 0)) k = 2*k ALLOCATE (mb%cab_jac(k, k, SIZE(mb%cables))) mb%cab_jac = CD_ZERO mb%cab_age = HUGE(1) @@ -23381,15 +23260,26 @@ SUBROUTINE cable_load(kind, obj, f, m) m = CD_ZERO IF (.NOT. ALLOCATED(mb%cables)) RETURN DO cc = 1, SIZE(mb%cables) - IF (mb%cab_kind(cc) /= kind .OR. mb%cab_obj(cc) /= obj) CYCLE - IF (kind == 1) THEN - arm = MATMUL(mb%rig_af(obj)%rot_mat, mb%cab_off(:, cc)) - ELSE - arm = mb%cab_off(1, cc)*mb%rod_af(obj)%half_length*mb%rod_af(obj)%rot_mat(:, 1) + IF (mb%cab_kind(cc) == kind .AND. mb%cab_obj(cc) == obj) THEN + IF (kind == 1) THEN + arm = MATMUL(mb%rig_af(obj)%rot_mat, mb%cab_off(:, cc)) + ELSE + arm = mb%cab_off(1, cc)*mb%rod_af(obj)%half_length*mb%rod_af(obj)%rot_mat(:, 1) + END IF + f = f + mb%cab_force(:, cc) + ! a clamped or elastic End A also returns its connection moment to the object + m = m + cross3(arm, mb%cab_force(:, cc)) + mb%cab_moment(:, cc) + END IF + ! End B of a cable between two objects, with its connection moment + IF (mb%cab_kind_b(cc) == kind .AND. mb%cab_obj_b(cc) == obj) THEN + IF (kind == 1) THEN + arm = MATMUL(mb%rig_af(obj)%rot_mat, mb%cab_off_b(:, cc)) + ELSE + arm = mb%cab_off_b(1, cc)*mb%rod_af(obj)%half_length*mb%rod_af(obj)%rot_mat(:, 1) + END IF + f = f + mb%cab_force_b(:, cc) + m = m + cross3(arm, mb%cab_force_b(:, cc)) + mb%cab_moment_b(:, cc) END IF - f = f + mb%cab_force(:, cc) - ! a clamped or elastic End A also returns its connection moment to the object - m = m + cross3(arm, mb%cab_force(:, cc)) + mb%cab_moment(:, cc) END DO END SUBROUTINE cable_load END SUBROUTINE mb_imp_group_residual @@ -23466,6 +23356,7 @@ REAL(wp) FUNCTION cable_force(kind, obj) RESULT(fc) IF (.NOT. ALLOCATED(mb%cables)) RETURN DO cc = 1, SIZE(mb%cables) IF (mb%cab_kind(cc) == kind .AND. mb%cab_obj(cc) == obj) fc = MAX(fc, NORM2(mb%cab_force(:, cc))) + IF (mb%cab_kind_b(cc) == kind .AND. mb%cab_obj_b(cc) == obj) fc = MAX(fc, NORM2(mb%cab_force_b(:, cc))) END DO END FUNCTION cable_force @@ -23477,7 +23368,8 @@ REAL(wp) FUNCTION torsion_stiffness(obj) RESULT(ks) ks = CD_ZERO IF (.NOT. ALLOCATED(mb%cables)) RETURN DO cc = 1, SIZE(mb%cables) - IF (mb%cab_kind(cc) /= 1 .OR. mb%cab_obj(cc) /= obj) CYCLE + IF (.NOT. ((mb%cab_kind(cc) == 1 .AND. mb%cab_obj(cc) == obj) .OR. & + (mb%cab_kind_b(cc) == 1 .AND. mb%cab_obj_b(cc) == obj))) CYCLE IF (.NOT. mb%cables(cc)%line%torsion%active) CYCLE cmp = CD_HermiteTorsion_Compliance(mb%cables(cc)%line%torsion, mb%cables(cc)%line%l0) IF (cmp > CD_ZERO) ks = ks + CD_ONE/cmp @@ -23513,7 +23405,7 @@ RECURSIVE SUBROUTINE mb_step_implicit(mb, points, opts, time, dt, converged, sta ! times the object length scale); the line reactions carry the inner tolerance REAL(wp), PARAMETER :: JUNCTION_TOL = 1.0e-6_wp, PREDICTOR_TOL = 1.0e-9_wp CHARACTER(24) :: tstr - INTEGER :: dep, it, g, c, ib, ir, p, o, es, lit, nj, gworst, it2, gsz + INTEGER :: dep, it, g, c, ib, ir, p, o, es, lit, nj, gworst, it2, gsz, gb, gszb LOGICAL :: lconv, lstall, first, ok, conv2, stall2, refresh, lines_stepped, tors_turn, lim, cab_refresh INTEGER, PARAMETER :: TAN_MAX_AGE = 20 REAL(wp) :: rho, am, af, beta_na, gam_na, t_af, h, fac, dth, worst, tol_it, am_p, gam_p, beta_p @@ -23565,9 +23457,11 @@ RECURSIVE SUBROUTINE mb_step_implicit(mb, points, opts, time, dt, converged, sta IF (es /= CD_HFMF_OK) THEN CALL fail_solve(ErrStat, ErrMsg, 'multibody cable snapshot failed: '//TRIM(em)); RETURN END IF - ! the step-entry end loads of a clamped cable (its alpha-level blend) - IF (mb%cab_clamp(c)) THEN - CALL mb_cable_committed_loads(mb, c, mb%cab_f0(:, c), mb%cab_m0(:, c), ErrStat, ErrMsg) + ! the step-entry end loads of a clamped cable or one between two objects (its alpha-level + ! blend) + IF (mb%cab_imp(c)) THEN + CALL mb_cable_committed_loads(mb, c, mb%cab_f0(:, c), mb%cab_m0(:, c), ErrStat, ErrMsg, & + fb=mb%cab_f0_b(:, c), mbm=mb%cab_m0_b(:, c)) IF (ErrStat /= CD_DECKDRV_OK) RETURN END IF END DO @@ -23634,13 +23528,14 @@ RECURSIVE SUBROUTINE mb_step_implicit(mb, points, opts, time, dt, converged, sta IF (.NOT. lconv) EXIT mb%loads = mb%floads END IF - ! finite-EI cables with a pinned End A: stepped once, with the attachment motion of the - ! Newmark predictor; their end force is held through the outer iterations (explicit - ! coupling at the predictor). A cable clamped (or elastically connected) to its object is - ! re-stepped from the step entry at every outer iteration with the iterate's motion and - ! orientation, and loads the junction at the alpha level (implicit coupling) + ! finite-EI cables with a pinned End A and a Fixed End B: stepped once, with the attachment + ! motion of the Newmark predictor; their end force is held through the outer iterations + ! (explicit coupling at the predictor). A cable clamped (or elastically connected) to its + ! object, or one between two objects, is re-stepped from the step entry at every outer + ! iteration with the iterate's motion and orientation of its objects, and loads the + ! junction at both ends at the alpha level (implicit coupling) DO c = 1, SIZE(mb%cables) - IF (.NOT. (first .OR. mb%cab_clamp(c))) CYCLE + IF (.NOT. (first .OR. mb%cab_imp(c))) CYCLE IF (.NOT. first) THEN CALL CD_HFMF_Restore(mb%cables(c), es, em) IF (es /= CD_HFMF_OK) THEN @@ -23649,11 +23544,16 @@ RECURSIVE SUBROUTINE mb_step_implicit(mb, points, opts, time, dt, converged, sta END IF CALL mb_cable_drive(mb, c, dt, ErrStat, ErrMsg) IF (ErrStat /= CD_DECKDRV_OK) EXIT - IF (mb%cab_clamp(c)) THEN + IF (mb%cab_imp(c)) THEN mb%cab_force(:, c) = (CD_ONE - af)*mb%cab_fend(:, c) + af*mb%cab_f0(:, c) mb%cab_moment(:, c) = (CD_ONE - af)*mb%cab_mend(:, c) + af*mb%cab_m0(:, c) + IF (mb%cab_kind_b(c) > 0) THEN + mb%cab_force_b(:, c) = (CD_ONE - af)*mb%cab_fend_b(:, c) + af*mb%cab_f0_b(:, c) + mb%cab_moment_b(:, c) = (CD_ONE - af)*mb%cab_mend_b(:, c) + af*mb%cab_m0_b(:, c) + END IF ELSE mb%cab_force(:, c) = mb%cab_fend(:, c) + IF (mb%cab_kind_b(c) > 0) mb%cab_force_b(:, c) = mb%cab_fend_b(:, c) END IF END DO IF (ErrStat /= CD_DECKDRV_OK) EXIT @@ -23731,16 +23631,37 @@ RECURSIVE SUBROUTINE mb_step_implicit(mb, points, opts, time, dt, converged, sta cab_refresh = cab_refresh .OR. it >= 3 END IF DO c = 1, SIZE(mb%cables) - IF (.NOT. mb%cab_clamp(c)) CYCLE + IF (.NOT. mb%cab_imp(c)) CYCLE g = mb_cable_group(mb, c) + ! a cable between two objects: the junction coordinates of both groups (the same group + ! counted once), its end-to-end stiffness coupling them in the Newton matrix + gb = 0 + IF (mb%cab_kind_b(c) > 0) gb = mb_cable_group(mb, c, end_b=.TRUE.) + IF (gb == g) gb = 0 + IF (g == 0) THEN + g = gb + gb = 0 + END IF IF (g == 0) CYCLE IF (cab_refresh) THEN - CALL cable_columns(c, g) + CALL cable_columns(c, g, gb) IF (ErrStat /= CD_DECKDRV_OK) EXIT + ELSE IF (gb == 0) THEN + gsz = mb%g_hi(g) - mb%g_lo(g) + 1 + jac(mb%g_lo(g):mb%g_hi(g), mb%g_lo(g):mb%g_hi(g)) = & + jac(mb%g_lo(g):mb%g_hi(g), mb%g_lo(g):mb%g_hi(g)) + mb%cab_jac(1:gsz, 1:gsz, c) ELSE gsz = mb%g_hi(g) - mb%g_lo(g) + 1 + gszb = mb%g_hi(gb) - mb%g_lo(gb) + 1 jac(mb%g_lo(g):mb%g_hi(g), mb%g_lo(g):mb%g_hi(g)) = & jac(mb%g_lo(g):mb%g_hi(g), mb%g_lo(g):mb%g_hi(g)) + mb%cab_jac(1:gsz, 1:gsz, c) + jac(mb%g_lo(g):mb%g_hi(g), mb%g_lo(gb):mb%g_hi(gb)) = & + jac(mb%g_lo(g):mb%g_hi(g), mb%g_lo(gb):mb%g_hi(gb)) + mb%cab_jac(1:gsz, gsz + 1:gsz + gszb, c) + jac(mb%g_lo(gb):mb%g_hi(gb), mb%g_lo(g):mb%g_hi(g)) = & + jac(mb%g_lo(gb):mb%g_hi(gb), mb%g_lo(g):mb%g_hi(g)) + mb%cab_jac(gsz + 1:gsz + gszb, 1:gsz, c) + jac(mb%g_lo(gb):mb%g_hi(gb), mb%g_lo(gb):mb%g_hi(gb)) = & + jac(mb%g_lo(gb):mb%g_hi(gb), mb%g_lo(gb):mb%g_hi(gb)) + & + mb%cab_jac(gsz + 1:gsz + gszb, gsz + 1:gsz + gszb, c) END IF END DO IF (ErrStat /= CD_DECKDRV_OK) EXIT @@ -23824,19 +23745,26 @@ RECURSIVE SUBROUTINE mb_step_implicit(mb, points, opts, time, dt, converged, sta converged = conv2 stalled = stall2 CONTAINS - SUBROUTINE cable_columns(cc, gg) + SUBROUTINE cable_columns(cc, gg, gg2) !! Add clamped cable cc's end-load derivative to the Jacobian columns of its group gg: !! the cable re-stepped from the step entry with each column perturbed, the group residual !! re-evaluated at the unperturbed objects with the perturbed cable loads. The columns are - !! also kept in mb%cab_jac for reuse. - INTEGER, INTENT(IN) :: cc, gg + !! also kept in mb%cab_jac for reuse. gg2 > 0: the cable joins the objects of groups gg and + !! gg2, and the derivative spans the rows and columns of both (cable_columns_two). + INTEGER, INTENT(IN) :: cc, gg, gg2 REAL(wp), PARAMETER :: CABLE_FD = 1.0e-5_wp INTEGER :: col, lo, hi - REAL(wp) :: fsave(3), msave(3), hc + REAL(wp) :: fsave(3), msave(3), fbsave(3), mbsave(3), hc + IF (gg2 > 0) THEN + CALL cable_columns_two(cc, gg, gg2) + RETURN + END IF lo = mb%g_lo(gg) hi = mb%g_hi(gg) fsave = mb%cab_force(:, cc) msave = mb%cab_moment(:, cc) + fbsave = mb%cab_force_b(:, cc) + mbsave = mb%cab_moment_b(:, cc) hc = CABLE_FD/(beta_na*dt*dt) DO col = lo, hi xp = x @@ -23854,14 +23782,81 @@ SUBROUTINE cable_columns(cc, gg) CALL mb_imp_alpha(mb, af, am, am_p) mb%cab_force(:, cc) = (CD_ONE - af)*mb%cab_fend(:, cc) + af*mb%cab_f0(:, cc) mb%cab_moment(:, cc) = (CD_ONE - af)*mb%cab_mend(:, cc) + af*mb%cab_m0(:, cc) + ! a cable whose two objects share the group loads it at both ends + IF (mb%cab_kind_b(cc) > 0) THEN + mb%cab_force_b(:, cc) = (CD_ONE - af)*mb%cab_fend_b(:, cc) + af*mb%cab_f0_b(:, cc) + mb%cab_moment_b(:, cc) = (CD_ONE - af)*mb%cab_mend_b(:, cc) + af*mb%cab_m0_b(:, cc) + END IF CALL mb_imp_group_residual(mb, points, opts, gg, t_af, rp, ErrStat, ErrMsg, bathymetry) mb%cab_force(:, cc) = fsave mb%cab_moment(:, cc) = msave + IF (mb%cab_kind_b(cc) > 0) THEN + mb%cab_force_b(:, cc) = fbsave + mb%cab_moment_b(:, cc) = mbsave + END IF IF (ErrStat /= CD_DECKDRV_OK) RETURN mb%cab_jac(1:hi - lo + 1, col - lo + 1, cc) = (rp(lo:hi) - r(lo:hi))/hc jac(lo:hi, col) = jac(lo:hi, col) + mb%cab_jac(1:hi - lo + 1, col - lo + 1, cc) END DO END SUBROUTINE cable_columns + + SUBROUTINE cable_columns_two(cc, g1, g2) + !! cable_columns for a cable joining the objects of two groups g1 (End A's) and g2: each + !! column of either group perturbs the end-of-step pose of its object, the cable is + !! re-stepped with both ends' motion, and the residuals of both groups are re-evaluated with + !! the perturbed loads at both ends. Rows and columns are stored g1 first, then g2. + INTEGER, INTENT(IN) :: cc, g1, g2 + REAL(wp), PARAMETER :: CABLE_FD = 1.0e-5_wp + INTEGER :: col, n1, jg, gcol, k + INTEGER :: lo(2), hi(2), roff(2) + REAL(wp) :: fsave(3), msave(3), fbsave(3), mbsave(3), hc + lo = [mb%g_lo(g1), mb%g_lo(g2)] + hi = [mb%g_hi(g1), mb%g_hi(g2)] + n1 = hi(1) - lo(1) + 1 + roff = [0, n1] + fsave = mb%cab_force(:, cc) + msave = mb%cab_moment(:, cc) + fbsave = mb%cab_force_b(:, cc) + mbsave = mb%cab_moment_b(:, cc) + hc = CABLE_FD/(beta_na*dt*dt) + DO jg = 1, 2 + DO col = lo(jg), hi(jg) + gcol = roff(jg) + col - lo(jg) + 1 + xp = x + xp(col) = x(col) + hc + CALL mb_imp_states(mb, xp, dt, gam_na, beta_na, gam_p, beta_p, ErrStat, ErrMsg) + IF (ErrStat /= CD_DECKDRV_OK) RETURN + CALL CD_HFMF_Restore(mb%cables(cc), es, em) + IF (es /= CD_HFMF_OK) THEN + CALL fail_solve(ErrStat, ErrMsg, 'multibody cable restore failed: '//TRIM(em)); RETURN + END IF + CALL mb_cable_drive(mb, cc, dt, ErrStat, ErrMsg) + IF (ErrStat /= CD_DECKDRV_OK) RETURN + CALL mb_imp_states(mb, x, dt, gam_na, beta_na, gam_p, beta_p, ErrStat, ErrMsg) + IF (ErrStat /= CD_DECKDRV_OK) RETURN + CALL mb_imp_alpha(mb, af, am, am_p) + mb%cab_force(:, cc) = (CD_ONE - af)*mb%cab_fend(:, cc) + af*mb%cab_f0(:, cc) + mb%cab_moment(:, cc) = (CD_ONE - af)*mb%cab_mend(:, cc) + af*mb%cab_m0(:, cc) + mb%cab_force_b(:, cc) = (CD_ONE - af)*mb%cab_fend_b(:, cc) + af*mb%cab_f0_b(:, cc) + mb%cab_moment_b(:, cc) = (CD_ONE - af)*mb%cab_mend_b(:, cc) + af*mb%cab_m0_b(:, cc) + DO k = 1, 2 + CALL mb_imp_group_residual(mb, points, opts, MERGE(g1, g2, k == 1), t_af, rp, ErrStat, ErrMsg, & + bathymetry) + IF (ErrStat /= CD_DECKDRV_OK) EXIT + END DO + mb%cab_force(:, cc) = fsave + mb%cab_moment(:, cc) = msave + mb%cab_force_b(:, cc) = fbsave + mb%cab_moment_b(:, cc) = mbsave + IF (ErrStat /= CD_DECKDRV_OK) RETURN + DO k = 1, 2 + mb%cab_jac(roff(k) + 1:roff(k) + hi(k) - lo(k) + 1, gcol, cc) = (rp(lo(k):hi(k)) - r(lo(k):hi(k)))/hc + jac(lo(k):hi(k), col) = jac(lo(k):hi(k), col) + mb%cab_jac(roff(k) + 1:roff(k) + hi(k) - lo(k) + 1, & + gcol, cc) + END DO + END DO + END DO + END SUBROUTINE cable_columns_two END SUBROUTINE mb_step_implicit SUBROUTINE mb_torsion_turn_limit(mb, x, dt, beta_na, limited) @@ -23881,33 +23876,50 @@ 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) + IF (.NOT. mb%cables(c)%line%torsion%active) CYCLE + ! (a free end, end_free, solve-frame end 2 at End A and 1 at End B: its object's turn does + ! not twist the line) + IF (mb%cab_kind(c) == 1 .AND. .NOT. mb%cables(c)%line%torsion%end_free(2)) CALL limit_body(mb%cab_obj(c)) + ! End B's body (a cable between two objects) + IF (mb%cab_kind_b(c) == 1 .AND. .NOT. mb%cables(c)%line%torsion%end_free(1)) & + CALL limit_body(mb%cab_obj_b(c)) + END DO + CONTAINS + SUBROUTINE limit_body(ibody) + INTEGER, INTENT(IN) :: ibody + ib = ibody o = mb%jb_off(ib) - IF (o < 0) CYCLE + IF (o < 0) RETURN base = dt*mb%old_rigid(ib)%omega + dt*dt*(0.5_wp - beta_na)*mb%old_rigid(ib)%alpha dpsi = base + dt*dt*beta_na*x(o + 4:o + 6) - IF (NORM2(dpsi) <= TURN_FRAC*CD_HTORS_MAX_STEP) CYCLE + IF (NORM2(dpsi) <= TURN_FRAC*CD_HTORS_MAX_STEP) RETURN ! non-finite trials are left to the residual's finite check - IF (.NOT. ALL(IEEE_IS_FINITE(dpsi))) CYCLE + IF (.NOT. ALL(IEEE_IS_FINITE(dpsi))) RETURN s = TURN_FRAC*CD_HTORS_MAX_STEP/NORM2(dpsi) x(o + 4:o + 6) = (s*dpsi - base)/(dt*dt*beta_na) limited = .TRUE. - END DO + END SUBROUTINE limit_body END SUBROUTINE mb_torsion_turn_limit - INTEGER FUNCTION mb_cable_group(mb, c) RESULT(g) - !! The junction group that carries cable c's End A object (0: a held attachment or an object - !! without junction coordinates). A rod pinned to a body belongs to the body's group. + INTEGER FUNCTION mb_cable_group(mb, c, end_b) RESULT(g) + !! The junction group that carries cable c's End A object, or with end_b its End B object (0: + !! a held attachment or an object without junction coordinates). A rod pinned to a body + !! belongs to the body's group. TYPE(MultibodyMarch), INTENT(IN) :: mb INTEGER, INTENT(IN) :: c - INTEGER :: gg, kind, obj + LOGICAL, INTENT(IN), OPTIONAL :: end_b + INTEGER :: gg, kind, obj, akind g = 0 kind = 0 obj = mb%cab_obj(c) - SELECT CASE (mb%cab_kind(c)) + akind = mb%cab_kind(c) + IF (PRESENT(end_b)) THEN + IF (end_b) THEN + obj = mb%cab_obj_b(c) + akind = mb%cab_kind_b(c) + END IF + END IF + SELECT CASE (akind) CASE (1) kind = 1 CASE (2) @@ -25909,7 +25921,7 @@ END SUBROUTINE rigid6_rod_loads SUBROUTINE solve_body_equilibrium_core(types, bodies, rod_types, rods, points, lines, sections, opts, ErrStat, & ErrMsg, bathymetry, points_only, jac_check_err, ext_pt, ext_fm, & - end_force_a, quiet, skipped, ext_km, ext_rot) + end_force_a, quiet, skipped, ext_km, ext_rot, end_force_b) !! Static equilibrium of the free objects of a deck: free Rigid6 bodies (six DOFs: position !! and a rotation-vector increment on SO(3); a CoupledPinned body holds its position at its !! host node and balances its moment about it), free rods (position and the two rotations @@ -25985,6 +25997,8 @@ SUBROUTINE solve_body_equilibrium_core(types, bodies, rod_types, rods, points, l ! The end force every moving line exerts on its End A point at the solution (zero for a line ! that does not move), and quiet: no notes or completion line. REAL(wp), INTENT(OUT), OPTIONAL :: end_force_a(:, :) + ! ... and on its End B point (a line between two objects) + REAL(wp), INTENT(OUT), OPTIONAL :: end_force_b(:, :) LOGICAL, INTENT(IN), OPTIONAL :: quiet ! skipped: the objects were held at their deck poses (a moving line has no moving-end ! static solve), so nothing was balanced @@ -26025,6 +26039,7 @@ SUBROUTINE solve_body_equilibrium_core(types, bodies, rod_types, rods, points, l IF (PRESENT(points_only)) only_points = points_only IF (PRESENT(jac_check_err)) jac_check_err = -CD_ONE IF (PRESENT(end_force_a)) end_force_a = CD_ZERO + IF (PRESENT(end_force_b)) end_force_b = CD_ZERO silent = .FALSE. IF (PRESENT(quiet)) silent = quiet IF (PRESENT(skipped)) skipped = .FALSE. @@ -26397,6 +26412,11 @@ SUBROUTINE solve_body_equilibrium_core(types, bodies, rod_types, rods, points, l DO j = 1, SIZE(lines) IF (lmove(j)) end_force_a(:, j) = lc(j)%ef(:, 2) END DO + IF (PRESENT(end_force_b)) THEN + DO j = 1, SIZE(lines) + IF (lmove(j)) end_force_b(:, j) = lc(j)%ef(:, 1) + END DO + END IF END IF CALL apply_state(x, bodies, rods, points) IF (only_points .OR. silent) RETURN @@ -27479,7 +27499,15 @@ SUBROUTINE solve_body_equilibrium(types, bodies, rod_types, rods, points, lines, !! core the torque's moment stiffness (1/C) a a^T about the previous pass's pose (a = dTheta/dw !! of the cable at that pose, its shape held; C the line torsional compliance), so the passes !! converge whatever the ratio of the object's own restoring stiffness to GJ/L (the passes - !! alone would need it far above GJ/L), to 1e-10 of the force scale. + !! alone would need it far above GJ/L), to 1e-10 of the force scale. A finite-EI line between + !! two objects (End B on a body point or a rod end) takes the same corrections at both ends, + !! whatever its connections (the passes balance both objects on the cubic-Hermite cable); the + !! torque's stiffness at each end is about that end's object with the other's held, the + !! coupling between them carried by the passes. A deck with such a line accelerates the passes + !! (Anderson mixing of the last ANDERSON_DEPTH passes on the extra loads, ext_fm, a secant + !! method that a pass map oscillating about its fixed point does not defeat: a stiff cable + !! between two moored bodies turns them through an out-of-plane mode that the plain passes + !! overshoot); a deck without one keeps the plain passes. TYPE(DeckLineType), INTENT(IN) :: types(:) TYPE(DeckBody), INTENT(INOUT) :: bodies(:) TYPE(DeckRodType), INTENT(IN) :: rod_types(:) @@ -27493,15 +27521,19 @@ SUBROUTINE solve_body_equilibrium(types, bodies, rod_types, rods, points, lines, TYPE(CD_BathymetryType), INTENT(IN), OPTIONAL :: bathymetry LOGICAL, INTENT(IN), OPTIONAL :: points_only REAL(wp), INTENT(OUT), OPTIONAL :: jac_check_err - INTEGER, PARAMETER :: MAX_PASS = 60 + INTEGER, PARAMETER :: MAX_PASS = 60, ANDERSON_DEPTH = 6 REAL(wp), PARAMETER :: PASS_TOL = 1.0e-7_wp, PASS_TOL_TORSION = 1.0e-10_wp TYPE(DeckBody), ALLOCATABLE :: bodies0(:) TYPE(DeckRod), ALLOCATABLE :: rods0(:) TYPE(DeckPoint), ALLOCATABLE :: points0(:) - INTEGER, ALLOCATABLE :: cl(:), ext_pt(:) + INTEGER, ALLOCATABLE :: cl(:), ext_pt(:), clb(:), eb(:), eline(:) + ! Anderson mixing of the passes (lines between two objects): the last passes' inputs and + ! residuals (new_fm - ext_fm), packed + REAL(wp), ALLOCATABLE :: and_x(:, :), and_f(:, :) + INTEGER :: n_and, max_pass_eff REAL(wp), ALLOCATABLE :: ext_fm(:, :), new_fm(:, :), fs(:, :), ext_km(:, :, :), ext_rot(:, :, :) - REAL(wp), ALLOCATABLE :: new_km(:, :, :), new_rot(:, :, :) - INTEGER :: j, pa, e, pass, ncl, eworst + REAL(wp), ALLOCATABLE :: new_km(:, :, :), new_rot(:, :, :), fsb(:, :) + INTEGER :: j, pa, e, pass, ncl, eworst, pb, ne, nb LOGICAL :: only_points, held REAL(wp) :: scale, change, pass_tol_eff CHARACTER(24) :: b1 @@ -27510,12 +27542,21 @@ SUBROUTINE solve_body_equilibrium(types, bodies, rod_types, rods, points, lines, ErrMsg = '' only_points = .FALSE. IF (PRESENT(points_only)) only_points = points_only - ! the lines with a connected End A on a Rigid6 body point or a rod end - ALLOCATE (cl(0)) + ! the lines with a connected End A on a Rigid6 body point or a rod end, and the lines between + ! two objects (End B on a body point or a rod end; clb lists those, with their End B entries) + ALLOCATE (cl(0), clb(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_at_a(lines(j))) CYCLE IF (.NOT. line_is_finite_ei(lines(j), types, sections)) CYCLE + pb = find_point(points, lines(j)%nodeB) + IF (pb > 0) THEN + IF (starts_with(TRIM(points(pb)%ptype), 'body') .OR. is_rod_point_type(points(pb)%ptype)) THEN + cl = [cl, j] + clb = [clb, j] + CYCLE + END IF + END IF + IF (lines(j)%endconn_mode(1) == CD_ENDCONN_PINNED .AND. .NOT. line_torsion_at_a(lines(j))) CYCLE pa = find_point(points, lines(j)%nodeA) IF (pa < 1) CYCLE IF (starts_with(TRIM(points(pa)%ptype), 'body')) THEN @@ -27526,6 +27567,7 @@ SUBROUTINE solve_body_equilibrium(types, bodies, rod_types, rods, points, lines, END DO END IF ncl = SIZE(cl) + nb = SIZE(clb) IF (ncl == 0) THEN CALL solve_body_equilibrium_core(types, bodies, rod_types, rods, points, lines, sections, opts, ErrStat, & ErrMsg, bathymetry, points_only, jac_check_err) @@ -27535,29 +27577,48 @@ SUBROUTINE solve_body_equilibrium(types, bodies, rod_types, rods, points, lines, DO e = 1, ncl BLOCK REAL(wp) :: rclamp(3, 3), dclamp(3) - CALL clamp_object_frame(lines(cl(e)), points, bodies, rods, rclamp, dclamp, ErrStat, ErrMsg) + IF (connected_end(cl(e), .FALSE.)) & + CALL clamp_object_frame(lines(cl(e)), points, bodies, rods, rclamp, dclamp, ErrStat, ErrMsg) + IF (ErrStat == CD_DECKDRV_OK .AND. connected_end(cl(e), .TRUE.)) & + CALL clamp_object_frame(lines(cl(e)), points, bodies, rods, rclamp, dclamp, ErrStat, ErrMsg, end_b=.TRUE.) END BLOCK IF (ErrStat /= CD_DECKDRV_OK) RETURN END DO bodies0 = bodies rods0 = rods points0 = points - ALLOCATE (ext_pt(ncl), ext_fm(6, ncl), new_fm(6, ncl), fs(3, SIZE(lines))) - ALLOCATE (ext_km(3, 3, ncl), ext_rot(3, 3, ncl), new_km(3, 3, ncl), new_rot(3, 3, ncl)) + ! the extra loads: End A of every listed line (1:ncl), then End B of the lines between two + ! objects (ncl + 1:ncl + nb, eb(e) the End B entry of line cl(e), 0 for none) + ne = ncl + nb + ALLOCATE (ext_pt(ne), ext_fm(6, ne), new_fm(6, ne), fs(3, SIZE(lines)), fsb(3, SIZE(lines)), eb(ncl), & + eline(ne)) + ALLOCATE (ext_km(3, 3, ne), ext_rot(3, 3, ne), new_km(3, 3, ne), new_rot(3, 3, ne)) pass_tol_eff = PASS_TOL + eb = 0 DO e = 1, ncl ext_pt(e) = find_point(points, lines(cl(e))%nodeA) + eline(e) = cl(e) IF (line_torsion_at_a(lines(cl(e)))) pass_tol_eff = PASS_TOL_TORSION END DO + DO j = 1, nb + e = FINDLOC(cl, clb(j), DIM=1) + eb(e) = ncl + j + ext_pt(ncl + j) = find_point(points, lines(clb(j))%nodeB) + eline(ncl + j) = clb(j) + END DO + n_and = 0 + max_pass_eff = MAX_PASS + IF (body_static_pass_limit > 0) max_pass_eff = body_static_pass_limit + IF (nb > 0) ALLOCATE (and_x(6*ne, ANDERSON_DEPTH + 1), and_f(6*ne, ANDERSON_DEPTH + 1)) ext_fm = CD_ZERO ext_km = CD_ZERO ext_rot = CD_ZERO - DO e = 1, ncl + DO e = 1, ne ext_rot(1, 1, e) = CD_ONE ext_rot(2, 2, e) = CD_ONE ext_rot(3, 3, e) = CD_ONE END DO - DO pass = 1, MAX_PASS + DO pass = 1, max_pass_eff bodies = bodies0 rods = rods0 points = points0 @@ -27566,78 +27627,241 @@ SUBROUTINE solve_body_equilibrium(types, bodies, rod_types, rods, points, lines, IF (pass_tol_eff < PASS_TOL) THEN CALL solve_body_equilibrium_core(types, bodies, rod_types, rods, points, lines, sections, opts, ErrStat, & ErrMsg, bathymetry, ext_pt=ext_pt, ext_fm=ext_fm, end_force_a=fs, & - quiet=pass > 1, skipped=held, ext_km=ext_km, ext_rot=ext_rot) + quiet=pass > 1, skipped=held, ext_km=ext_km, ext_rot=ext_rot, & + end_force_b=fsb) ELSE CALL solve_body_equilibrium_core(types, bodies, rod_types, rods, points, lines, sections, opts, ErrStat, & ErrMsg, bathymetry, ext_pt=ext_pt, ext_fm=ext_fm, end_force_a=fs, & - quiet=pass > 1, skipped=held) + quiet=pass > 1, skipped=held, end_force_b=fsb) END IF IF (ErrStat /= CD_DECKDRV_OK) RETURN ! the objects stay at their deck poses (the core has already said why): nothing to balance IF (held) RETURN scale = CD_ONE DO e = 1, ncl - CALL hermite_end_loads(cl(e), new_fm(:, e), new_km(:, :, e), new_rot(:, :, e)) + IF (eb(e) > 0) THEN + CALL hermite_end_loads(cl(e), new_fm(:, e), new_km(:, :, e), new_rot(:, :, e), new_fm(:, eb(e)), & + new_km(:, :, eb(e)), new_rot(:, :, eb(e))) + ELSE + CALL hermite_end_loads(cl(e), new_fm(:, e), new_km(:, :, e), new_rot(:, :, e)) + END IF IF (ErrStat /= CD_DECKDRV_OK) RETURN new_fm(1:3, e) = new_fm(1:3, e) - fs(:, cl(e)) scale = MAX(scale, NORM2(fs(:, cl(e))), NORM2(new_fm(1:3, e) + fs(:, cl(e)))) + IF (eb(e) > 0) THEN + new_fm(1:3, eb(e)) = new_fm(1:3, eb(e)) - fsb(:, cl(e)) + scale = MAX(scale, NORM2(fsb(:, cl(e))), NORM2(new_fm(1:3, eb(e)) + fsb(:, cl(e)))) + END IF END DO change = MAXVAL(ABS(new_fm - ext_fm)) eworst = MAXLOC(MAXVAL(ABS(new_fm - ext_fm), DIM=1), DIM=1) - ext_fm = new_fm ext_km = new_km ext_rot = new_rot - IF (change <= pass_tol_eff*scale) EXIT + IF (change <= pass_tol_eff*scale) THEN + ext_fm = new_fm + EXIT + END IF + IF (nb > 0) THEN + CALL anderson_next(ext_fm, new_fm) + ELSE + ext_fm = new_fm + END IF END DO IF (change > pass_tol_eff*scale) THEN WRITE (b1, '(ES10.3)') change/scale - CALL fail_solve(ErrStat, ErrMsg, 'static body/rod equilibrium with the clamped or elastic END CONNECTION '// & - 'of finite-EI LINE '//TRIM(int_to_str(lines(cl(eworst))%id))//' did not converge after '// & - TRIM(int_to_str(MAX_PASS))//' passes (relative end-load change '//TRIM(ADJUSTL(b1))// & - '); OPTION bodyIC deck starts from the deck pose instead') + IF (nb == 0) THEN + CALL fail_solve(ErrStat, ErrMsg, 'static body/rod equilibrium with the clamped or elastic END '// & + 'CONNECTION of finite-EI LINE '//TRIM(int_to_str(lines(eline(eworst))%id))// & + ' did not converge after '//TRIM(int_to_str(max_pass_eff))//' passes (relative end-load '// & + 'change '//TRIM(ADJUSTL(b1))//'); OPTION bodyIC deck starts from the deck pose instead') + ELSE + ! the worst entry may be the End B of a line between two objects, connected or pinned + CALL fail_solve(ErrStat, ErrMsg, 'static body/rod equilibrium with the bending end loads of finite-EI '// & + 'LINE '//TRIM(int_to_str(lines(eline(eworst))%id))//' (its End '// & + MERGE('B', 'A', eworst > ncl)//', on a body or rod) did not converge after '// & + TRIM(int_to_str(max_pass_eff))//' passes (relative end-load change '//TRIM(ADJUSTL(b1))// & + '); OPTION bodyIC deck starts from the deck pose instead') + END IF RETURN END IF - WRITE (output_unit, '(A)') ' Initial conditions: the end moments and bending end forces of '// & - TRIM(int_to_str(ncl))//' clamped or elastic finite-EI line end(s) balanced in '// & - TRIM(int_to_str(pass))//' static pass(es).' + IF (nb == 0) THEN + WRITE (output_unit, '(A)') ' Initial conditions: the end moments and bending end forces of '// & + TRIM(int_to_str(ncl))//' clamped or elastic finite-EI line end(s) balanced in '// & + TRIM(int_to_str(pass))//' static pass(es).' + ELSE + WRITE (output_unit, '(A)') ' Initial conditions: the end moments and bending end forces of '// & + TRIM(int_to_str(ne))//' finite-EI line end(s) on bodies and rods ('//TRIM(int_to_str(nb))// & + ' line(s) between two objects) balanced in '//TRIM(int_to_str(pass))//' static pass(es).' + END IF CONTAINS - SUBROUTINE hermite_end_loads(jl, fm, km, rot) + SUBROUTINE anderson_next(x, g) + !! The next pass input from the pass map g(x) (the extra loads one pass returns for the + !! loads x it was given): Anderson mixing, x+ = g - dG gamma with gamma the least-squares + !! fit of the residual f = g - x by the differences of the last residuals, dF gamma ~ f + !! (at most ANDERSON_DEPTH of them, the oldest dropped first). The fit is solved by + !! modified Gram-Schmidt on dF; a column that adds no new direction is dropped. A residual + !! that grows tenfold over the last one restarts the mixing from the plain pass. + REAL(wp), INTENT(INOUT) :: x(:, :) + REAL(wp), INTENT(IN) :: g(:, :) + REAL(wp) :: xv(SIZE(x)), gv(SIZE(x)), fv(SIZE(x)), q(SIZE(x), ANDERSON_DEPTH), rr(ANDERSON_DEPTH, ANDERSON_DEPTH) + REAL(wp) :: dfi(SIZE(x)), dgk(SIZE(x), ANDERSON_DEPTH), c(ANDERSON_DEPTH), gam(ANDERSON_DEPTH), nrm + INTEGER :: m, i, k, kept + xv = RESHAPE(x, [SIZE(x)]) + gv = RESHAPE(g, [SIZE(g)]) + fv = gv - xv + IF (n_and > 0) THEN + IF (NORM2(fv) > 10.0_wp*NORM2(and_f(:, n_and))) n_and = 0 + END IF + ! history: inputs and residuals of the passes so far (newest last) + IF (n_and == ANDERSON_DEPTH + 1) THEN + and_x(:, 1:ANDERSON_DEPTH) = and_x(:, 2:ANDERSON_DEPTH + 1) + and_f(:, 1:ANDERSON_DEPTH) = and_f(:, 2:ANDERSON_DEPTH + 1) + n_and = ANDERSON_DEPTH + END IF + n_and = n_and + 1 + and_x(:, n_and) = xv + and_f(:, n_and) = fv + m = n_and - 1 + IF (m == 0) THEN + x = g + RETURN + END IF + ! dF columns orthonormalised (modified Gram-Schmidt), dG the matching map differences + kept = 0 + rr = CD_ZERO + DO i = 1, m + dfi = and_f(:, i + 1) - and_f(:, i) + nrm = NORM2(dfi) + IF (.NOT. nrm > CD_ZERO) CYCLE + DO k = 1, kept + rr(k, kept + 1) = DOT_PRODUCT(q(:, k), dfi) + dfi = dfi - rr(k, kept + 1)*q(:, k) + END DO + IF (NORM2(dfi) <= 1.0e-10_wp*nrm) CYCLE + kept = kept + 1 + rr(kept, kept) = NORM2(dfi) + q(:, kept) = dfi/rr(kept, kept) + ! the column's map difference: dG = dF + dX + dgk(:, kept) = (and_f(:, i + 1) + and_x(:, i + 1)) - (and_f(:, i) + and_x(:, i)) + END DO + IF (kept == 0) THEN + x = g + RETURN + END IF + ! R gamma = Q^T f, back substitution over the kept (upper triangular in kept order) columns + DO k = 1, kept + c(k) = DOT_PRODUCT(q(:, k), fv) + END DO + DO k = kept, 1, -1 + gam(k) = (c(k) - DOT_PRODUCT(rr(k, k + 1:kept), gam(k + 1:kept)))/rr(k, k) + END DO + DO k = 1, kept + gv = gv - gam(k)*dgk(:, k) + END DO + IF (.NOT. ALL(IEEE_IS_FINITE(gv))) THEN + n_and = 0 + x = g + RETURN + END IF + x = RESHAPE(gv, SHAPE(x)) + END SUBROUTINE anderson_next + + LOGICAL FUNCTION connected_end(jl, at_b) RESULT(yes) + !! Line jl's End A (End B with at_b) carries a connection or a torsion frame on a body point + !! or a rod end, whose object frame clamp_object_frame gives. + INTEGER, INTENT(IN) :: jl + LOGICAL, INTENT(IN) :: at_b + INTEGER :: ip + yes = .FALSE. + ip = find_point(points, MERGE(lines(jl)%nodeB, lines(jl)%nodeA, at_b)) + IF (ip < 1) RETURN + IF (.NOT. (starts_with(TRIM(points(ip)%ptype), 'body') .OR. is_rod_point_type(points(ip)%ptype))) RETURN + yes = lines(jl)%endconn_mode(MERGE(2, 1, at_b)) /= CD_ENDCONN_PINNED .OR. & + MERGE(line_torsion_at_b(lines(jl)), line_torsion_at_a(lines(jl)), at_b) + END FUNCTION connected_end + + SUBROUTINE hermite_end_loads(jl, fm, km, rot, fmb, kmb, rotb) !! The cubic-Hermite static end force and connection moment of line jl on its End A object, !! at the current (solved) object poses and point positions; for a line with condensed !! torsion, km = (1/C) a a^T, the torque's moment stiffness against a rotation of the object !! with the cable shape held (a = dTheta/dw: the End A frame turns, and a clamped end's !! tangent with it), in global axes, and rot the object's orientation (km = 0 otherwise). + !! fmb, kmb, rotb: the same on the End B object of a line between two objects. INTEGER, INTENT(IN) :: jl REAL(wp), INTENT(OUT) :: fm(6), km(3, 3), rot(3, 3) + REAL(wp), INTENT(OUT), OPTIONAL :: fmb(6), kmb(3, 3), rotb(3, 3) TYPE(CD_HFMF_ModuleType) :: cab TYPE(DeckLine) :: lnc TYPE(DeckPoint), ALLOCATABLE :: pc(:) - REAL(wp) :: rclamp(3, 3), dclamp(3), nclamp(3), dtb + REAL(wp) :: rclamp(3, 3), dclamp(3), nclamp(3), dtb, rclamp_b(3, 3) INTEGER :: node, es + LOGICAL :: two CHARACTER(1024) :: note CHARACTER(1024) :: em fm = CD_ZERO km = CD_ZERO + two = PRESENT(fmb) lnc = lines(jl) - 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 + IF (two) THEN + fmb = CD_ZERO + kmb = CD_ZERO + ! a line between two objects: each connected end in its object's frame, both ends driven + rclamp = CD_ZERO + rclamp(1, 1) = CD_ONE + rclamp(2, 2) = CD_ONE + rclamp(3, 3) = CD_ONE + rclamp_b = rclamp + IF (connected_end(jl, .FALSE.)) THEN + CALL clamp_object_frame(lnc, points, bodies, rods, rclamp, dclamp, ErrStat, ErrMsg, check_axis=.FALSE., & + nx0=nclamp) + IF (ErrStat /= CD_DECKDRV_OK) RETURN + lnc%endconn_ez_ref(:, 1) = dclamp + lnc%tors_nx(:, 1) = nclamp + END IF + IF (connected_end(jl, .TRUE.)) THEN + CALL clamp_object_frame(lnc, points, bodies, rods, rclamp_b, dclamp, ErrStat, ErrMsg, check_axis=.FALSE., & + end_b=.TRUE.) + IF (ErrStat /= CD_DECKDRV_OK) RETURN + lnc%endconn_ez_ref(:, 2) = dclamp + END IF + rot = rclamp + rotb = rclamp_b + ELSE + 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 + END IF pc = points - pc(find_point(points, lnc%nodeA))%ptype = 'coupled' + IF (TRIM(pc(find_point(points, lnc%nodeA))%ptype) /= 'fixed' .OR. .NOT. two) & + pc(find_point(points, lnc%nodeA))%ptype = 'coupled' dtb = CD_ONE IF (opts%dtM > CD_ZERO) dtb = opts%dtM - CALL build_one_hermite_cable(lnc, sections, types, pc, opts, dtb, cab, node, ErrStat, ErrMsg, & - standalone_controls=.TRUE., bathymetry=bathymetry, & - fairlead_orientation=TRANSPOSE(rclamp), init_note=note, & - fold_support=MERGE(FOLD_FRICTION_NONE, FOLD_FRICTION_NO_AS_LAID, & - deck_has_non_rigid6_dynamic_points(points, bodies))) + IF (two) THEN + pc(find_point(points, lnc%nodeB))%ptype = 'coupled' + CALL build_one_hermite_cable(lnc, sections, types, pc, opts, dtb, cab, node, ErrStat, ErrMsg, & + standalone_controls=.TRUE., bathymetry=bathymetry, & + fairlead_orientation=TRANSPOSE(rclamp), init_note=note, & + fold_support=MERGE(FOLD_FRICTION_NONE, FOLD_FRICTION_NO_AS_LAID, & + deck_has_non_rigid6_dynamic_points(points, bodies)), & + allow_moving_end_b=.TRUE., end_b_orientation=TRANSPOSE(rclamp_b)) + ELSE + CALL build_one_hermite_cable(lnc, sections, types, pc, opts, dtb, cab, node, ErrStat, ErrMsg, & + standalone_controls=.TRUE., bathymetry=bathymetry, & + fairlead_orientation=TRANSPOSE(rclamp), init_note=note, & + fold_support=MERGE(FOLD_FRICTION_NONE, FOLD_FRICTION_NO_AS_LAID, & + deck_has_non_rigid6_dynamic_points(points, bodies))) + END IF IF (ErrStat == CD_DECKDRV_OK) THEN - CALL CD_HFMF_CalcOutput(cab, fm(1:3), es, em, y_moment=fm(4:6)) + IF (two) THEN + CALL CD_HFMF_CalcOutput(cab, fm(1:3), es, em, y_moment=fm(4:6), y_end_b=fmb(1:3), y_moment_b=fmb(4:6)) + ELSE + CALL CD_HFMF_CalcOutput(cab, fm(1:3), es, em, y_moment=fm(4:6)) + END IF IF (es /= CD_HFMF_OK) CALL fail_solve(ErrStat, ErrMsg, 'finite-EI LINE '//TRIM(int_to_str(lnc%id))// & ' static end loads failed: '//TRIM(em)) END IF @@ -27658,6 +27882,13 @@ SUBROUTINE hermite_end_loads(jl, fm, km, rot) ag = [cab%frame_c*a(1) - cab%frame_s*a(2), cab%frame_s*a(1) + cab%frame_c*a(2), a(3)] cc = CD_HermiteTorsion_Compliance(cab%line%torsion, cab%line%l0) km = SPREAD(ag, 2, 3)*SPREAD(ag, 1, 3)/cc + IF (two) THEN + ! End B is the cable's first node (internal end 1) + a = eg(1:3) + IF (cab%line%endconn_mode(1) == CD_ENDCONN_RIGID) a = a + cross3(cab%line%q(4:6), gq(4:6)) + ag = [cab%frame_c*a(1) - cab%frame_s*a(2), cab%frame_s*a(1) + cab%frame_c*a(2), a(3)] + kmb = SPREAD(ag, 2, 3)*SPREAD(ag, 1, 3)/cc + END IF END IF END BLOCK END IF @@ -30209,6 +30440,10 @@ SUBROUTINE write_hermite_dynamic_out(out_root, channels, lines, points, opts, ca CHARACTER(LEN(out_root) + 8) :: path CHARACTER(1024) :: em REAL(wp) :: t, up(3), uv(3), ua(3), tensile_force, tensile_threshold, tensile_xi, tensile_time, turn + ! a moving End B's kinematics (CD_HFMF_Set_Moving_End_B), unused on a line with a Fixed End B + REAL(wp) :: ubp(3), ubv(3), uba(3) + ! the parent rotation of each end on a TURBINES deck (turbine_end_rotation) + REAL(wp) :: dcm_a(3, 3), w_a(3), al_a(3), dcm_b(3, 3), w_b(3), al_b(3) ! Per-step tangent turn [deg] above which the time-step note is printed (see below). REAL(wp), PARAMETER :: TURN_NOTE_FORCE_BLEND = 0.25_wp, TURN_NOTE_CONFIG_BLEND = 0.1_wp REAL(wp), PARAMETER :: RAD2DEG = 57.29577951308232_wp @@ -30223,7 +30458,10 @@ SUBROUTINE write_hermite_dynamic_out(out_root, channels, lines, points, opts, ca END IF IF (opts%has_motion_file) THEN CALL read_motion_file(opts%motion_file, points, opts, motion, ErrStat, ErrMsg, & - with_roll=ANY([(line_torsion_active(lines(i)), i=1, SIZE(lines))])) + with_roll=ANY([(line_torsion_active(lines(i)), i=1, SIZE(lines))]), & + with_turbine_frames=ANY([(line_torsion_active(lines(i)) .OR. & + ANY(lines(i)%endconn_mode /= CD_ENDCONN_PINNED), & + i=1, SIZE(lines))])) IF (ErrStat /= CD_DECKDRV_OK) RETURN CALL check_motion_roll(ErrStat, ErrMsg) IF (ErrStat /= CD_DECKDRV_OK) RETURN @@ -30288,33 +30526,53 @@ SUBROUTINE write_hermite_dynamic_out(out_root, channels, lines, points, opts, ca IF (ErrStat /= CD_DECKDRV_OK) EXIT CALL CD_Profile_Enter(CD_PROF_SOLVE) DO i = 1, SIZE(cables) + ubp = CD_ZERO; ubv = CD_ZERO; uba = CD_ZERO IF (opts%has_motion_file) THEN pidx = find_point(points, lines(i)%nodeA) CALL prescribed_point_state(points(pidx), motion, step + 1, up, uv, ua, ErrStat, ErrMsg) IF (ErrStat /= CD_DECKDRV_OK) EXIT + IF (cables(i)%moving_b) THEN + pidx = find_point(points, lines(i)%nodeB) + CALL prescribed_point_state(points(pidx), motion, step + 1, ubp, ubv, uba, ErrStat, ErrMsg) + IF (ErrStat /= CD_DECKDRV_OK) EXIT + END IF ELSE CALL CD_HFMF_GetCoupledKinematics(cables(i), up, uv, ua, es, em) + IF (es == CD_HFMF_OK .AND. cables(i)%moving_b) CALL CD_HFMF_GetEndBKinematics(cables(i), ubp, ubv, uba, es, em) IF (es /= CD_HFMF_OK) THEN ErrStat = CD_DECKDRV_SOLVEFAIL ErrMsg = 'CableDyn_DeckDriver: Hermite endpoint query failed: '//TRIM(em); EXIT END IF uv = CD_ZERO; ua = CD_ZERO + ubv = CD_ZERO; uba = CD_ZERO END IF IF (motion%has_rot) THEN ! vessel motion: the fairlead end connection turns with the vessel (the DCM is - ! global-to-vessel, the transpose of the vessel rotation) - CALL CD_HFMF_UpdateStates(cables(i), up, uv, ua, es, em, & - 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_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, & - u_twist=lines(i)%tors_pretwist(2) - lines(i)%tors_pretwist(1) - & - motion%roll(find_motion_point(motion, lines(i)%nodeA), step + 1)) + ! global-to-vessel, the transpose of the vessel rotation); a moving End B rides on the + ! same vessel + CALL hermite_step_ends(cables(i), up, uv, ua, ubp, ubv, uba, es, em, & + u_orientation=TRANSPOSE(motion%rot(:, :, step + 1)), & + u_angular_velocity=motion%omega(:, step + 1), & + u_angular_acceleration=motion%alpha(:, step + 1), & + ub_orientation=TRANSPOSE(motion%rot(:, :, step + 1)), & + ub_angular_velocity=motion%omega(:, step + 1), & + ub_angular_acceleration=motion%alpha(:, step + 1)) + ELSE IF (motion%has_turb_rot) THEN + ! TURBINES rows: each end's connection and torsion frames turn with its own turbine + CALL turbine_end_rotation(points, motion, lines(i)%nodeA, step + 1, dcm_a, w_a, al_a) + CALL turbine_end_rotation(points, motion, lines(i)%nodeB, step + 1, dcm_b, w_b, al_b) + CALL hermite_step_ends(cables(i), up, uv, ua, ubp, ubv, uba, es, em, & + u_orientation=dcm_a, u_angular_velocity=w_a, u_angular_acceleration=al_a, & + ub_orientation=dcm_b, ub_angular_velocity=w_b, ub_angular_acceleration=al_b) + ELSE IF (motion%has_roll .AND. ((line_torsion_at_a(lines(i)) .AND. & + find_motion_point(motion, lines(i)%nodeA) > 0) .OR. & + (line_torsion_at_b(lines(i)) .AND. cables(i)%moving_b))) THEN + ! imposed roll of each moving end restrained in torsion about its inward tangent: + ! Phi = Pretwist(B) - Pretwist(A) - roll(A) - roll(B) + CALL hermite_step_ends(cables(i), up, uv, ua, ubp, ubv, uba, es, em, & + u_twist=line_roll_twist(lines(i), motion, step + 1)) ELSE - CALL CD_HFMF_UpdateStates(cables(i), up, uv, ua, es, em) + CALL hermite_step_ends(cables(i), up, uv, ua, ubp, ubv, uba, es, em) END IF IF (es /= CD_HFMF_OK) THEN ErrStat = CD_DECKDRV_SOLVEFAIL @@ -30390,20 +30648,22 @@ SUBROUTINE write_hermite_dynamic_out(out_root, channels, lines, points, opts, ca SUBROUTINE check_motion_roll(est, emt) INTEGER, INTENT(OUT) :: est CHARACTER(*), INTENT(OUT) :: emt - CALL check_motion_roll_lines(motion, lines, est, emt) + CALL check_motion_roll_lines(motion, lines, points, 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). + SUBROUTINE check_motion_roll_lines(motion, lines, points, est, emt) + !! The motionFile roll column drives a torsional line through its moving ends restrained in + !! torsion only (internal End A after the anchor-first swap: the user's End A, or End B of an + !! anchor-first deck, and a Coupled/Vessel End B of a line between two moving points), + !! right-handed about the tangent pointing into the line from that end, so Phi = Pretwist(B) + !! - Pretwist(A) - roll(A) - roll(B); it starts from the static state (roll 0 at t = 0). TYPE(MotionTable), INTENT(IN) :: motion TYPE(DeckLine), INTENT(IN) :: lines(:) + TYPE(DeckPoint), INTENT(IN) :: points(:) INTEGER, INTENT(OUT) :: est CHARACTER(*), INTENT(OUT) :: emt - INTEGER :: ip, li + INTEGER :: ip, li, jp LOGICAL :: used est = CD_DECKDRV_OK emt = '' @@ -30413,6 +30673,12 @@ SUBROUTINE check_motion_roll_lines(motion, lines, est, emt) used = .FALSE. DO li = 1, SIZE(lines) IF (lines(li)%nodeA == motion%point_ids(ip) .AND. line_torsion_at_a(lines(li))) used = .TRUE. + IF (lines(li)%nodeB == motion%point_ids(ip) .AND. line_torsion_at_b(lines(li))) THEN + jp = find_point(points, lines(li)%nodeB) + IF (jp > 0) THEN + IF (TRIM(points(jp)%ptype) == 'coupled' .OR. TRIM(points(jp)%ptype) == 'vessel') used = .TRUE. + END IF + END IF 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 '// & @@ -30427,6 +30693,122 @@ SUBROUTINE check_motion_roll_lines(motion, lines, est, emt) END DO END SUBROUTINE check_motion_roll_lines + PURE SUBROUTINE turbine_end_rotation(points, motion, point_id, time_index, dcm, omega, alpha) + !! The parent orientation of a line end at a TURBINES motion row: for a Turbine point the + !! global-to-turbine DCM (the transpose of the row's rotation, the OpenFAST mesh convention) and + !! the turbine's angular velocity and acceleration; identity and zero for any other point (its + !! frames are held). + TYPE(DeckPoint), INTENT(IN) :: points(:) + TYPE(MotionTable), INTENT(IN) :: motion + INTEGER, INTENT(IN) :: point_id, time_index + REAL(wp), INTENT(OUT) :: dcm(3, 3), omega(3), alpha(3) + INTEGER :: j, k + dcm = CD_ZERO + dcm(1, 1) = CD_ONE + dcm(2, 2) = CD_ONE + dcm(3, 3) = CD_ONE + omega = CD_ZERO + alpha = CD_ZERO + j = 0 + DO k = 1, SIZE(points) + IF (points(k)%id == point_id) j = k + END DO + IF (j < 1) RETURN + k = points(j)%turbine_id + IF (k < 1 .OR. k > SIZE(motion%turb_rot, 3)) RETURN + dcm = TRANSPOSE(motion%turb_rot(:, :, k, time_index)) + omega = motion%turb_omega(:, k, time_index) + alpha = motion%turb_alpha(:, k, time_index) + END SUBROUTINE turbine_end_rotation + + PURE FUNCTION turbine_end_dcm(points, opts, point_id) RESULT(dcm) + !! The global-to-parent DCM, at the static start, of a line end on point point_id: on a + !! TURBINES deck a Turbine point's parent is turbine J, turned by its PtfmInit rotation + !! (ptfm_zyx_dcm, the FAST.Farm farm_ptfm_init convention); identity otherwise. + TYPE(DeckPoint), INTENT(IN) :: points(:) + TYPE(DeckOptions), INTENT(IN) :: opts + INTEGER, INTENT(IN) :: point_id + REAL(wp) :: dcm(3, 3) + INTEGER :: j, k + dcm = CD_ZERO + dcm(1, 1) = CD_ONE + dcm(2, 2) = CD_ONE + dcm(3, 3) = CD_ONE + IF (opts%n_turb < 1) RETURN + j = 0 + DO k = 1, SIZE(points) + IF (points(k)%id == point_id) j = k + END DO + IF (j < 1) RETURN + k = points(j)%turbine_id + IF (k < 1 .OR. k > SIZE(opts%turb_ptfm, 2)) RETURN + dcm = ptfm_zyx_dcm(opts%turb_ptfm(4:6, k)) + END FUNCTION turbine_end_dcm + + SUBROUTINE hermite_step_ends(cable, up, uv, ua, ubp, ubv, uba, es, em, u_orientation, u_angular_velocity, & + u_angular_acceleration, u_twist, ub_orientation, ub_angular_velocity, & + ub_angular_acceleration) + !! CD_HFMF_UpdateStates of a standalone cable: End A's kinematics, and End B's (ub*) for a cable + !! whose End B moves (CD_HFMF_Set_Moving_End_B); a Fixed End B's ub* are not passed. + TYPE(CD_HFMF_ModuleType), INTENT(INOUT) :: cable + REAL(wp), INTENT(IN) :: up(3), uv(3), ua(3), ubp(3), ubv(3), uba(3) + INTEGER, INTENT(OUT) :: es + CHARACTER(*), INTENT(OUT) :: em + REAL(wp), INTENT(IN), OPTIONAL :: u_orientation(3, 3), u_angular_velocity(3), u_angular_acceleration(3) + REAL(wp), INTENT(IN), OPTIONAL :: u_twist + REAL(wp), INTENT(IN), OPTIONAL :: ub_orientation(3, 3), ub_angular_velocity(3), ub_angular_acceleration(3) + IF (cable%moving_b) THEN + CALL CD_HFMF_UpdateStates(cable, up, uv, ua, es, em, u_orientation=u_orientation, & + u_angular_velocity=u_angular_velocity, u_angular_acceleration=u_angular_acceleration, & + u_twist=u_twist, ub_pos=ubp, ub_vel=ubv, ub_acc=uba, ub_orientation=ub_orientation, & + ub_angular_velocity=ub_angular_velocity, ub_angular_acceleration=ub_angular_acceleration) + ELSE + CALL CD_HFMF_UpdateStates(cable, up, uv, ua, es, em, u_orientation=u_orientation, & + u_angular_velocity=u_angular_velocity, u_angular_acceleration=u_angular_acceleration, & + u_twist=u_twist) + END IF + END SUBROUTINE hermite_step_ends + + SUBROUTINE hermite_set_ends(cable, up, uv, ua, ubp, ubv, uba, es, em, u_orientation, u_angular_velocity, & + u_angular_acceleration, ub_orientation, ub_angular_velocity, ub_angular_acceleration) + !! CD_HFMF_SetCoupledKinematics with End B's kinematics for a cable whose End B moves. + TYPE(CD_HFMF_ModuleType), INTENT(INOUT) :: cable + REAL(wp), INTENT(IN) :: up(3), uv(3), ua(3), ubp(3), ubv(3), uba(3) + INTEGER, INTENT(OUT) :: es + CHARACTER(*), INTENT(OUT) :: em + REAL(wp), INTENT(IN), OPTIONAL :: u_orientation(3, 3), u_angular_velocity(3), u_angular_acceleration(3) + REAL(wp), INTENT(IN), OPTIONAL :: ub_orientation(3, 3), ub_angular_velocity(3), ub_angular_acceleration(3) + IF (cable%moving_b) THEN + CALL CD_HFMF_SetCoupledKinematics(cable, up, uv, ua, es, em, u_orientation=u_orientation, & + u_angular_velocity=u_angular_velocity, & + u_angular_acceleration=u_angular_acceleration, ub_pos=ubp, ub_vel=ubv, & + ub_acc=uba, ub_orientation=ub_orientation, & + ub_angular_velocity=ub_angular_velocity, & + ub_angular_acceleration=ub_angular_acceleration) + ELSE + CALL CD_HFMF_SetCoupledKinematics(cable, up, uv, ua, es, em, u_orientation=u_orientation, & + u_angular_velocity=u_angular_velocity, & + u_angular_acceleration=u_angular_acceleration) + END IF + END SUBROUTINE hermite_set_ends + + REAL(wp) FUNCTION line_roll_twist(ln, motion, time_index) RESULT(phi) + !! The imposed twist of a torsional line at a motion row: Phi = Pretwist(B) - Pretwist(A) - + !! roll(A) - roll(B), each roll the motionFile roll column of the end's point (zero for a point + !! without one, a Fixed point included), right-handed about the tangent pointing into the line + !! from that end: a common roll of both ends about the line axis cancels. The roll of an + !! end free in torsion (a line restrained at one end only) twists nothing. + TYPE(DeckLine), INTENT(IN) :: ln + TYPE(MotionTable), INTENT(IN) :: motion + INTEGER, INTENT(IN) :: time_index + INTEGER :: ia, ib + phi = ln%tors_pretwist(2) - ln%tors_pretwist(1) + ia = find_motion_point(motion, ln%nodeA) + ib = find_motion_point(motion, ln%nodeB) + IF (ia > 0 .AND. ln%tors_mode(1) /= TORS_FREE) phi = phi - motion%roll(ia, time_index) + IF (ib > 0 .AND. ln%tors_mode(2) /= TORS_FREE) phi = phi - motion%roll(ib, time_index) + END FUNCTION line_roll_twist + 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: @@ -30607,7 +30989,8 @@ SUBROUTINE apply_motion_to_hermite_cables(cables, lines, points, motion, time_in INTEGER, INTENT(OUT) :: ErrStat CHARACTER(*), INTENT(OUT) :: ErrMsg INTEGER :: i, pidx, es - REAL(wp) :: q(3), v(3), a(3) + REAL(wp) :: q(3), v(3), a(3), qb(3), vb(3), ab(3) + REAL(wp) :: dcm_a(3, 3), w_a(3), al_a(3), dcm_b(3, 3), w_b(3), al_b(3) CHARACTER(1024) :: em ErrStat = CD_DECKDRV_OK; ErrMsg = '' @@ -30621,14 +31004,30 @@ SUBROUTINE apply_motion_to_hermite_cables(cables, lines, points, motion, time_in END IF CALL prescribed_point_state(points(pidx), motion, time_index, q, v, a, ErrStat, ErrMsg) IF (ErrStat /= CD_DECKDRV_OK) RETURN + qb = CD_ZERO; vb = CD_ZERO; ab = CD_ZERO + IF (cables(i)%moving_b) THEN + pidx = find_point(points, lines(i)%nodeB) + CALL prescribed_point_state(points(pidx), motion, time_index, qb, vb, ab, ErrStat, ErrMsg) + IF (ErrStat /= CD_DECKDRV_OK) RETURN + END IF IF (motion%has_rot) THEN - ! vessel motion: an end connection at the fairlead turns with the vessel - CALL CD_HFMF_SetCoupledKinematics(cables(i), q, v, a, es, em, & - u_orientation=TRANSPOSE(motion%rot(:, :, time_index)), & - u_angular_velocity=motion%omega(:, time_index), & - u_angular_acceleration=motion%alpha(:, time_index)) + ! vessel motion: an end connection at the fairlead (and at a moving End B) turns with the vessel + CALL hermite_set_ends(cables(i), q, v, a, qb, vb, ab, es, em, & + u_orientation=TRANSPOSE(motion%rot(:, :, time_index)), & + u_angular_velocity=motion%omega(:, time_index), & + u_angular_acceleration=motion%alpha(:, time_index), & + ub_orientation=TRANSPOSE(motion%rot(:, :, time_index)), & + ub_angular_velocity=motion%omega(:, time_index), & + ub_angular_acceleration=motion%alpha(:, time_index)) + ELSE IF (motion%has_turb_rot) THEN + ! TURBINES rows: each end's frames turn with its own turbine + CALL turbine_end_rotation(points, motion, lines(i)%nodeA, time_index, dcm_a, w_a, al_a) + CALL turbine_end_rotation(points, motion, lines(i)%nodeB, time_index, dcm_b, w_b, al_b) + CALL hermite_set_ends(cables(i), q, v, a, qb, vb, ab, es, em, u_orientation=dcm_a, & + u_angular_velocity=w_a, u_angular_acceleration=al_a, ub_orientation=dcm_b, & + ub_angular_velocity=w_b, ub_angular_acceleration=al_b) ELSE - CALL CD_HFMF_SetCoupledKinematics(cables(i), q, v, a, es, em) + CALL hermite_set_ends(cables(i), q, v, a, qb, vb, ab, es, em) END IF IF (es /= CD_HFMF_OK) THEN ErrStat = CD_DECKDRV_SOLVEFAIL @@ -30945,150 +31344,6 @@ SUBROUTINE write_dynamic_hermite_line_outputs(time, lines, cables, pos_units, te END DO END SUBROUTINE write_dynamic_hermite_line_outputs - SUBROUTINE write_finite_dynamic_out(out_root, channels, lines, points, opts, models, converged, ErrStat, ErrMsg, & - bathymetry) - CHARACTER(*), INTENT(IN) :: out_root - CHARACTER(NAMELEN), INTENT(IN) :: channels(:) - TYPE(DeckLine), INTENT(IN) :: lines(:) - TYPE(DeckPoint), INTENT(IN) :: points(:) - TYPE(DeckOptions), INTENT(IN) :: opts - TYPE(FiniteDeckModel), INTENT(INOUT) :: models(:) - LOGICAL, INTENT(OUT) :: converged - INTEGER, INTENT(OUT) :: ErrStat - CHARACTER(*), INTENT(OUT) :: ErrMsg - TYPE(CD_BathymetryType), INTENT(IN), OPTIONAL :: bathymetry - - INTEGER :: unit, ios, step, nstep, es, n_iter - INTEGER, ALLOCATABLE :: pos_units(:), ten_units(:) - INTEGER :: miss_count, consecutive_miss, max_consecutive_miss - CHARACTER(LEN(out_root) + 8) :: path - CHARACTER(1024) :: em - LOGICAL :: step_converged, stalled - REAL(wp) :: t, first_miss_time, last_miss_time - TYPE(MotionTable) :: motion - TYPE(ModelOutputWorkspace) :: output_work - TYPE(DriverProgress) :: progress - - converged = .TRUE. - ErrStat = CD_DECKDRV_OK - ErrMsg = '' - ! the two-moving-end finite-EI line carries no VIV (Cl > 0 is refused on it), so no lift - IF (ANY([(line_output_has_lift(lines(step)%outputs), step=1, SIZE(lines))])) THEN - CALL fail(ErrStat, ErrMsg, 'the LINES Outputs flag V (VIV lift) needs a line that carries VIV, which a '// & - 'finite-EI line with two moving ends does not'); RETURN - END IF - nstep = NINT(opts%tmax/opts%dtM) - CALL range_setup_planned(output_work%rset, lines, channels, opts, ErrStat, ErrMsg, fmodels=models, & - bathymetry=bathymetry) - IF (ErrStat /= CD_DECKDRV_OK) RETURN - miss_count = 0 - consecutive_miss = 0 - max_consecutive_miss = 0 - first_miss_time = CD_ZERO - last_miss_time = CD_ZERO - IF (opts%has_motion_file) THEN - CALL read_motion_file(opts%motion_file, points, opts, motion, ErrStat, ErrMsg) - IF (ErrStat /= CD_DECKDRV_OK) RETURN - CALL apply_motion_to_finite_models(models, lines, points, motion, 1, es, em) - IF (es /= CD_DECKDRV_OK) THEN - ErrStat = es - ErrMsg = em - RETURN - END IF - END IF - ! Seed a_0 with the t=0 seabed-contact + current/wave loads so the first step does not - ! march from a gravity-only initial acceleration (mirrors the EI=0 update_wave_models recompute). - CALL seed_finite_initial_acceleration(models, opts, ErrStat, ErrMsg) - IF (ErrStat /= CD_DECKDRV_OK) RETURN - path = TRIM(out_root)//'.out' - OPEN (NEWUNIT=unit, FILE=path, STATUS='REPLACE', ACTION='WRITE', IOSTAT=ios) - IF (ios /= 0) THEN - CALL fail(ErrStat, ErrMsg, 'cannot open output file: '//TRIM(path)); RETURN - END IF - WRITE (unit, '(A)') '# CableDyn driver output (finite-EI dynamic; convergence quality in the status message)' - CALL write_header(unit, channels) - CALL open_dynamic_finite_line_outputs(out_root, lines, models, pos_units, ten_units, ErrStat, ErrMsg) - IF (ErrStat /= CD_DECKDRV_OK) THEN - CLOSE (unit) - RETURN - END IF - IF (opts%has_motion_file) THEN - CALL write_finite_model_row(unit, CD_ZERO, channels, lines, points, models, output_work, ErrStat, ErrMsg, & - motion, 1) - ELSE - CALL write_finite_model_row(unit, CD_ZERO, channels, lines, points, models, output_work, ErrStat, ErrMsg) - END IF - IF (ErrStat /= CD_DECKDRV_OK) THEN - CLOSE (unit) - CALL close_dynamic_line_outputs(pos_units, ten_units) - RETURN - END IF - CALL write_dynamic_finite_line_outputs(CD_ZERO, lines, models, pos_units, ten_units, output_work, ErrStat, ErrMsg) - IF (ErrStat /= CD_DECKDRV_OK) THEN - CLOSE (unit) - CALL close_dynamic_line_outputs(pos_units, ten_units) - RETURN - END IF - CALL start_driver_progress(progress, nstep, opts%dtM) - DO step = 1, nstep - CALL CD_Profile_Enter(CD_PROF_SOLVE) - t = REAL(step, wp)*opts%dtM - IF (opts%has_motion_file) THEN - ! Moving-support march: the prescribed endpoint translations follow the motionFile - ! trajectory to t_{n+1}, their velocity/acceleration coupling into the dynamic residual - ! (the gen-alpha sets the fixed DOFs to the targets -- no separate re-apply needed). - CALL step_finite_held_models(models, opts, t, opts%dtM, step_converged, stalled, n_iter, es, em, & - motion=motion, lines=lines, points=points, time_index=step + 1) - ELSE - CALL step_finite_held_models(models, opts, t, opts%dtM, step_converged, stalled, n_iter, es, em) - END IF - CALL CD_Profile_Enter(CD_PROF_CHECK) - IF (es /= CD_DECKDRV_OK) THEN - CLOSE (unit) - CALL close_dynamic_line_outputs(pos_units, ten_units) - ErrStat = es - ErrMsg = em - RETURN - END IF - CALL update_dynamic_completion_quality(t, step_converged, stalled, miss_count, consecutive_miss, & - max_consecutive_miss, first_miss_time, last_miss_time) - IF (.NOT. step_converged .OR. stalled) THEN - CLOSE (unit) - CALL close_dynamic_line_outputs(pos_units, ten_units) - CALL CD_Classify_Dynamic_Completion('finite-EI dynamic run', nstep, miss_count, & - max_consecutive_miss, first_miss_time, last_miss_time, & - converged, ErrStat, ErrMsg) - RETURN - END IF - CALL CD_Profile_Step() - CALL CD_Profile_Enter(CD_PROF_OUTPUT) - IF (opts%has_motion_file) THEN - CALL write_finite_model_row(unit, t, channels, lines, points, models, output_work, ErrStat, ErrMsg, & - motion, step + 1) - ELSE - CALL write_finite_model_row(unit, t, channels, lines, points, models, output_work, ErrStat, ErrMsg) - END IF - IF (ErrStat /= CD_DECKDRV_OK) THEN - CLOSE (unit) - CALL close_dynamic_line_outputs(pos_units, ten_units) - RETURN - END IF - CALL write_dynamic_finite_line_outputs(t, lines, models, pos_units, ten_units, output_work, ErrStat, ErrMsg) - IF (ErrStat /= CD_DECKDRV_OK) THEN - CLOSE (unit) - CALL close_dynamic_line_outputs(pos_units, ten_units) - RETURN - END IF - CALL CD_Profile_Enter(CD_PROF_PROGRESS) - CALL update_driver_progress(progress, step, t) - END DO - CLOSE (unit) - CALL close_dynamic_line_outputs(pos_units, ten_units) - CALL CD_Classify_Dynamic_Completion('finite-EI dynamic run', nstep, miss_count, max_consecutive_miss, & - first_miss_time, last_miss_time, converged, ErrStat, ErrMsg) - IF (ErrStat == CD_DECKDRV_OK .AND. converged) CALL range_write(output_work%rset, out_root, ErrStat, ErrMsg) - END SUBROUTINE write_finite_dynamic_out - FUNCTION deck_current_velocity(opts, pos, time, ErrStat, ErrMsg) RESULT(velocity) !! Return the deck current velocity at position pos and time: uniform, a depth profile at !! pos(3), or the MoorDyn-C current grid (Currents 2 and 5) at pos and time. @@ -31247,21 +31502,20 @@ PURE SUBROUTINE deck_wave_ramp(ramp_time, time, ramp, ramp_rate) ramp_rate = 2.0_wp*QUARTER_PI*SIN(arg)/ramp_time END SUBROUTINE deck_wave_ramp - SUBROUTINE check_modal_deck(bodies, rods, points, lines, opts, n_finite, has_dyn_points, has_failures, & + SUBROUTINE check_modal_deck(bodies, rods, lines, opts, n_finite, has_dyn_points, has_failures, & ErrStat, ErrMsg) !! OPTION nModes runs on decks of lines between fixed and prescribed points: all !! EI = 0 lines (static or dynamic deck), or all finite-EI lines on the standalone - !! cubic-Hermite route (dynamic deck, every End B Fixed); flat seabed only. + !! cubic-Hermite route (dynamic deck); flat seabed only. The modes hold both line ends, so a + !! moving (Coupled/Vessel) End B is held at its static position as End A is. TYPE(DeckBody), INTENT(IN) :: bodies(:) TYPE(DeckRod), INTENT(IN) :: rods(:) - TYPE(DeckPoint), INTENT(IN) :: points(:) TYPE(DeckLine), INTENT(IN) :: lines(:) TYPE(DeckOptions), INTENT(IN) :: opts INTEGER, INTENT(IN) :: n_finite LOGICAL, INTENT(IN) :: has_dyn_points, has_failures INTEGER, INTENT(OUT) :: ErrStat CHARACTER(*), INTENT(OUT) :: ErrMsg - INTEGER :: li, j ErrStat = CD_DECKDRV_OK ErrMsg = '' IF (SIZE(bodies) > 0 .OR. SIZE(rods) > 0 .OR. has_dyn_points .OR. has_failures .OR. SIZE(lines) == 0) THEN @@ -31276,13 +31530,6 @@ SUBROUTINE check_modal_deck(bodies, rods, points, lines, opts, n_finite, has_dyn CALL fail(ErrStat, ErrMsg, 'OPTION nModes on finite-EI lines needs a dynamic deck (dtM, TMax) whose '// & 'lines are all finite-EI'); RETURN END IF - DO li = 1, SIZE(lines) - j = find_point(points, lines(li)%nodeB) - IF (j < 1) CYCLE - IF (TRIM(points(j)%ptype) /= 'fixed') THEN - CALL fail(ErrStat, ErrMsg, 'OPTION nModes on finite-EI lines needs every End B Fixed'); RETURN - END IF - END DO END IF END SUBROUTINE check_modal_deck @@ -32202,24 +32449,6 @@ SUBROUTINE write_model_row(unit, time, channels, lines, points, models, work, Er motion=motion, motion_time_index=motion_time_index) END SUBROUTINE write_model_row - SUBROUTINE write_finite_model_row(unit, time, channels, lines, points, models, work, ErrStat, ErrMsg, & - motion, motion_time_index) - INTEGER, INTENT(IN) :: unit - REAL(wp), INTENT(IN) :: time - CHARACTER(NAMELEN), INTENT(IN) :: channels(:) - TYPE(DeckLine), INTENT(IN) :: lines(:) - TYPE(DeckPoint), INTENT(IN) :: points(:) - TYPE(FiniteDeckModel), INTENT(IN) :: models(:) - TYPE(ModelOutputWorkspace), INTENT(INOUT) :: work - INTEGER, INTENT(OUT) :: ErrStat - CHARACTER(*), INTENT(OUT) :: ErrMsg - TYPE(MotionTable), INTENT(IN), OPTIONAL :: motion - INTEGER, INTENT(IN), OPTIONAL :: motion_time_index - - CALL write_planned_row(unit, time, channels, lines, points, work, 'finite-EI ', ErrStat, ErrMsg, & - fmodels=models, motion=motion, motion_time_index=motion_time_index) - END SUBROUTINE write_finite_model_row - SUBROUTINE write_system_model_row(unit, time, channels, lines, points, system, work, ErrStat, ErrMsg, rigid, & rods, opts, bathymetry) !! rigid/rods: the body and rod states that Body/Rod channels report. @@ -32243,14 +32472,14 @@ SUBROUTINE write_system_model_row(unit, time, channels, lines, points, system, w END SUBROUTINE write_system_model_row SUBROUTINE write_planned_row(unit, time, channels, lines, points, work, label, ErrStat, ErrMsg, models, & - fmodels, system, motion, motion_time_index, rigid, rods, opts, bathymetry) - !! Shared dynamic .out row writer for the EI=0 line (`models`), finite-EI (`fmodels`) - !! and point-system (`system`) paths; exactly one of the three is present. The + system, motion, motion_time_index, rigid, rods, opts, bathymetry) + !! Shared dynamic .out row writer for the EI=0 line (`models`) and point-system (`system`) + !! paths; exactly one of the two is present. The !! channel list is resolved into descriptors on the first row, each referenced !! line's state and tensions are fetched at most once per row, and the row is !! emitted by one formatted WRITE. Values and text are identical to evaluating - !! every channel through model_channel_value / finite_model_channel_value / - !! system_channel_value: any channel the plan cannot resolve, and any per-row + !! every channel through model_channel_value / system_channel_value: any channel the plan + !! cannot resolve, and any per-row !! query failure, is delegated to that routine so its value or error is unchanged. !! On an error the row prefix up to the failing channel is left non-advancing. INTEGER, INTENT(IN) :: unit @@ -32263,7 +32492,6 @@ SUBROUTINE write_planned_row(unit, time, channels, lines, points, work, label, E INTEGER, INTENT(OUT) :: ErrStat CHARACTER(*), INTENT(OUT) :: ErrMsg TYPE(CD_ModelType), INTENT(IN), OPTIONAL :: models(:) - TYPE(FiniteDeckModel), INTENT(IN), OPTIONAL :: fmodels(:) TYPE(CD_SystemType), INTENT(IN), OPTIONAL :: system TYPE(MotionTable), INTENT(IN), OPTIONAL :: motion INTEGER, INTENT(IN), OPTIONAL :: motion_time_index @@ -32285,7 +32513,6 @@ SUBROUTINE write_planned_row(unit, time, channels, lines, points, work, label, E n = SIZE(channels) has_motion = PRESENT(motion) .AND. PRESENT(motion_time_index) stride = 3 - IF (PRESENT(fmodels)) stride = 6 IF (.NOT. work%plan_ready) THEN CALL build_plan() ELSE IF (SIZE(work%ch_kind) /= n .OR. SIZE(work%line_ndof) /= SIZE(lines) .OR. & @@ -32387,8 +32614,6 @@ SUBROUTINE sample_ranges() IF (.NOT. CD_Range_Needs_Sample(work%rset, il)) CYCLE IF (PRESENT(models)) THEN CALL range_sample_model(models(il), work%rset%lines(il), ErrStat, ErrMsg) - ELSE IF (PRESENT(fmodels)) THEN - CALL range_sample_fmodel(fmodels(il), work%rset%lines(il), ErrStat, ErrMsg) ELSE CALL range_sample_model(system%lines(il), work%rset%lines(il), ErrStat, ErrMsg) END IF @@ -32424,9 +32649,6 @@ SUBROUTINE legacy_value(ich, v) IF (PRESENT(models)) THEN CALL model_channel_value(channels(ich), lines, points, models, work, v, ErrStat, ErrMsg, motion, & motion_time_index) - ELSE IF (PRESENT(fmodels)) THEN - CALL finite_model_channel_value(channels(ich), lines, points, fmodels, work, v, ErrStat, ErrMsg, & - motion, motion_time_index) ELSE CALL system_channel_value(channels(ich), lines, points, system, work, v, ErrStat, ErrMsg) END IF @@ -32446,10 +32668,6 @@ SUBROUTINE fetch_state(il, fetched) CALL CD_Get_Model_State(models(il), work%line_q(o + 1:o + m), work%line_v(o + 1:o + m), & work%line_a(o + 1:o + m), es, msg) fetched = es == CD_MODEL_OK - ELSE IF (PRESENT(fmodels)) THEN - CALL CD_Get_FiniteEI_Model_State(fmodels(il)%model, work%line_q(o + 1:o + m), work%line_v(o + 1:o + m), & - work%line_a(o + 1:o + m), es, msg) - fetched = es == 0 ELSE CALL CD_Get_System_Line_State(system, il, work%line_q(o + 1:o + m), work%line_v(o + 1:o + m), & work%line_a(o + 1:o + m), es, msg) @@ -32493,9 +32711,6 @@ SUBROUTINE fetch_tension(il, fetched) IF (PRESENT(models)) THEN CALL CD_Get_Model_Tension(models(il), work%line_ten(o + 1:o + m), es, msg) fetched = es == CD_MODEL_OK - ELSE IF (PRESENT(fmodels)) THEN - CALL finite_model_tension(fmodels(il), work%line_ten(o + 1:o + m), work, es, msg) - fetched = es == CD_DECKDRV_OK ELSE CALL CD_Get_System_Line_Tension(system, il, work%line_ten(o + 1:o + m), es, msg) fetched = es == CD_SYSTEM_OK @@ -32517,11 +32732,6 @@ SUBROUTINE line_sizes(il, sized, tension_sized) sized = es == CD_MODEL_OK ne_l = ndof_l/3 - 1 tension_sized = sized - ELSE IF (PRESENT(fmodels)) THEN - ne_l = fmodels(il)%n_elem - ndof_l = 6*(ne_l + 1) - sized = .TRUE. - tension_sized = .TRUE. ELSE ndof_l = CD_System_Line_NDOF(system, il, es, msg) sized = es == CD_SYSTEM_OK @@ -32623,19 +32833,6 @@ SUBROUTINE build_plan() END IF EXIT END DO - ELSE IF (PRESENT(fmodels)) THEN - ppos = point_index(points, pidx) - IF (ppos == 0) CYCLE - IF (has_motion .AND. (TRIM(points(ppos)%ptype) == 'coupled' .OR. & - TRIM(points(ppos)%ptype) == 'vessel')) THEN - midx = find_motion_point(motion, points(ppos)%id) - IF (midx == 0) CYCLE - work%ch_kind(j) = CH_POINT_MOTION - work%ch_aux(j) = midx - ELSE - work%ch_kind(j) = CH_POINT_FIXED - work%ch_aux(j) = ppos - END IF ELSE IF (point_index(points, pidx) == 0) CYCLE work%ch_kind(j) = CH_SYS_POINT @@ -32653,8 +32850,6 @@ SUBROUTINE build_plan() work%ch_kind(j) = CH_NODE_TEN work%ch_node(j) = deck_to_internal_node(node, work%line_ne(il)) ELSE - ! The finite-EI material bend moment keeps its reference-curvature evaluator. - IF (PRESENT(fmodels) .AND. kind == 6) CYCLE work%ch_kind(j) = CH_NODE_STATE work%ch_node(j) = node work%ch_aux(j) = kind @@ -32938,184 +33133,6 @@ SUBROUTINE system_channel_value(ch, lines, points, system, work, val, ErrStat, E END IF END SUBROUTINE system_channel_value - SUBROUTINE finite_model_channel_value(ch, lines, points, models, work, val, ErrStat, ErrMsg, motion, & - motion_time_index) - CHARACTER(*), INTENT(IN) :: ch - TYPE(DeckLine), INTENT(IN) :: lines(:) - TYPE(DeckPoint), INTENT(IN) :: points(:) - TYPE(FiniteDeckModel), INTENT(IN) :: models(:) - TYPE(ModelOutputWorkspace), INTENT(INOUT) :: work - REAL(wp), INTENT(OUT) :: val - INTEGER, INTENT(OUT) :: ErrStat - CHARACTER(*), INTENT(OUT) :: ErrMsg - TYPE(MotionTable), INTENT(IN), OPTIONAL :: motion - INTEGER, INTENT(IN), OPTIONAL :: motion_time_index - - INTEGER :: li, pidx, comp, kind, node, nnode, es, inode, ppos, midx - CHARACTER(NAMELEN) :: lo - CHARACTER(1024) :: em - - ErrStat = CD_DECKDRV_OK - ErrMsg = '' - val = CD_ZERO - lo = to_lower(ch) - IF (is_point_force_channel(lo)) THEN - CALL fail(ErrStat, ErrMsg, 'OUTPUT "'//TRIM(ch)//'": Point

F channels are not available on the '// & - 'two-moving-end finite-EI route (use FairTen/AnchTen)') - RETURN - END IF - ! this route reports the axial chord-stretch tension of the end elements, not an end-force vector - IF (is_anchor_force_channel(lo)) THEN - CALL fail(ErrStat, ErrMsg, 'OUTPUT "'//TRIM(ch)//'": AnchFz/AnchFH channels are not available on the '// & - 'two-moving-end finite-EI route (use AnchTen and AnchIncl)') - RETURN - END IF - IF (starts_with(lo, 'fairten') .OR. starts_with(lo, 'anchten')) THEN - li = find_line(lines, int_suffix(ch, 8)) - CALL ensure_model_output_workspace(work, 0, models(li)%n_elem) - CALL finite_model_tension(models(li), work%tension(1:models(li)%n_elem), work, es, em) - IF (es /= CD_DECKDRV_OK) THEN - ErrStat = es - ErrMsg = em - RETURN - END IF - IF (starts_with(lo, 'fairten')) THEN - val = work%tension(models(li)%n_elem) - ELSE - val = work%tension(1) - END IF - ELSE IF (is_endpoint_angle_channel(lo)) THEN - li = find_line(lines, endpoint_angle_line_id(ch)) - nnode = models(li)%n_elem + 1 - CALL ensure_model_output_workspace(work, 6*nnode, 0) - CALL CD_Get_FiniteEI_Model_State(models(li)%model, work%q(1:6*nnode), work%v(1:6*nnode), & - work%a(1:6*nnode), es, em) - IF (es /= 0) THEN - ErrStat = CD_DECKDRV_SOLVEFAIL - ErrMsg = 'CableDyn_DeckDriver: finite-EI state query failed for line-angle channel: '//TRIM(em) - RETURN - END IF - IF (is_fair_endpoint_angle(lo)) THEN - val = line_geom_value(7, 1, nnode, work%q(1:6*nnode), 6) ! End A declination [deg] - ELSE - val = line_geom_value(7, nnode, nnode, work%q(1:6*nnode), 6) ! End B declination [deg] - END IF - val = endpoint_angle_from_declination(lo, val) - ELSE IF (is_point_channel(lo)) THEN - CALL parse_point_channel(ch, pidx, comp) - ppos = point_index(points, pidx) - IF (ppos == 0) THEN - ErrStat = CD_DECKDRV_BADINPUT - ErrMsg = 'CableDyn_DeckDriver: finite-EI Point OUTPUT channel references an unknown point' - RETURN - END IF - IF (PRESENT(motion) .AND. PRESENT(motion_time_index) .AND. & - (TRIM(points(ppos)%ptype) == 'coupled' .OR. TRIM(points(ppos)%ptype) == 'vessel')) THEN - midx = find_motion_point(motion, points(ppos)%id) - IF (midx == 0) THEN - ErrStat = CD_DECKDRV_BADINPUT - ErrMsg = 'CableDyn_DeckDriver: finite-EI motion output missing point id '//TRIM(int_to_str(points(ppos)%id)) - RETURN - END IF - val = motion%q(comp, midx, motion_time_index) - ELSE - val = points(ppos)%pos(comp) - END IF - ELSE - CALL parse_line_node_channel(ch, li, node, kind, comp) - li = find_line(lines, li) - nnode = models(li)%n_elem + 1 - IF (node < 1 .OR. node > nnode) THEN - ErrStat = CD_DECKDRV_BADINPUT - ErrMsg = 'CableDyn_DeckDriver: finite-EI line-node OUTPUT channel node index is out of range' - RETURN - END IF - inode = deck_to_internal_node(node, models(li)%n_elem) - IF (kind == 3) THEN - CALL ensure_model_output_workspace(work, 0, models(li)%n_elem) - CALL finite_model_tension(models(li), work%tension(1:models(li)%n_elem), work, es, em) - IF (es /= CD_DECKDRV_OK) THEN - ErrStat = es - ErrMsg = em - RETURN - END IF - val = nodal_tension_value(work%tension(1:models(li)%n_elem), inode) - ELSE - CALL ensure_model_output_workspace(work, 6*nnode, 0) - CALL CD_Get_FiniteEI_Model_State(models(li)%model, work%q(1:6*nnode), work%v(1:6*nnode), & - work%a(1:6*nnode), es, em) - IF (es /= 0) THEN - ErrStat = CD_DECKDRV_SOLVEFAIL - ErrMsg = 'CableDyn_DeckDriver: finite-EI state query failed for line-node channel: '//TRIM(em) - RETURN - END IF - SELECT CASE (kind) - CASE (1) ! position - val = work%q(6*(inode - 1) + comp) - CASE (2) ! velocity - val = work%v(6*(inode - 1) + comp) - CASE (4) ! acceleration - val = work%a(6*(inode - 1) + comp) - CASE (6) ! bend moment [N.m] = EI(node) * |kvec_current - kvec_reference| - BLOCK - REAL(wp) :: r_cur(3, nnode), kc(3), kr(3) - INTEGER :: nn - ! OrcaFlex-convention bend moment: EI*|kappa - kappa_ref|, the curvature RELATIVE - ! to the stress-free reference shape, so a cable resting at its reference reports - ! ~0. On this route the reference (nodes_ref) is a straight rod, so kappa_ref = 0 - ! and the value is EI times the geometric curvature. - DO nn = 1, nnode - r_cur(:, nn) = work%q(6*nn - 5:6*nn - 3) - END DO - kc = node_curvature_vector(r_cur, nnode, inode) - kr = node_curvature_vector(models(li)%model%nodes_ref, nnode, inode) - val = nodal_ei_value(models(li)%ei, inode)*NORM2(kc - kr) - END BLOCK - CASE DEFAULT ! curvature (5) / declination (7) / azimuth (8) -- geometric - val = line_geom_value(kind, node, nnode, work%q(1:6*nnode), 6, lines(li)%azi_signed) - END SELECT - END IF - END IF - END SUBROUTINE finite_model_channel_value - - SUBROUTINE finite_model_tension(deck_model, tension, work, ErrStat, ErrMsg) - !! Recover an axial-tension scalar per element from the translational stretch. - !! This is an output diagnostic for deck channels; the dynamic residual still - !! uses the full Cosserat internal force/tangent. - TYPE(FiniteDeckModel), INTENT(IN) :: deck_model - REAL(wp), INTENT(OUT) :: tension(:) - TYPE(ModelOutputWorkspace), INTENT(INOUT) :: work - INTEGER, INTENT(OUT) :: ErrStat - CHARACTER(*), INTENT(OUT) :: ErrMsg - - INTEGER :: e, es, nnode - REAL(wp) :: xa(3), xb(3), length - CHARACTER(1024) :: em - - tension = CD_ZERO - ErrStat = CD_DECKDRV_OK - ErrMsg = '' - IF (SIZE(tension) /= deck_model%n_elem) THEN - CALL fail(ErrStat, ErrMsg, 'finite-EI tension output has wrong shape') - RETURN - END IF - nnode = deck_model%n_elem + 1 - CALL ensure_model_output_workspace(work, 6*nnode, 0) - CALL CD_Get_FiniteEI_Model_State(deck_model%model, work%q(1:6*nnode), work%v(1:6*nnode), & - work%a(1:6*nnode), es, em) - IF (es /= 0) THEN - ErrStat = CD_DECKDRV_SOLVEFAIL - ErrMsg = 'CableDyn_DeckDriver: finite-EI tension state query failed: '//TRIM(em) - RETURN - END IF - DO e = 1, deck_model%n_elem - xa = work%q(6*e - 5:6*e - 3) - xb = work%q(6*(e + 1) - 5:6*(e + 1) - 3) - length = SQRT(DOT_PRODUCT(xb - xa, xb - xa)) - tension(e) = deck_model%ea(e)*(length/deck_model%l0(e) - CD_ONE) - END DO - END SUBROUTINE finite_model_tension - SUBROUTINE model_channel_value(ch, lines, points, models, work, val, ErrStat, ErrMsg, motion, motion_time_index) CHARACTER(*), INTENT(IN) :: ch TYPE(DeckLine), INTENT(IN) :: lines(:) @@ -33339,291 +33356,6 @@ INTEGER FUNCTION model_nelem_from_line(line, model, ErrStat, ErrMsg) RESULT(ne) ErrMsg = '' END FUNCTION model_nelem_from_line - SUBROUTINE seed_finite_initial_acceleration(models, opts, ErrStat, ErrMsg) - !! Recompute each finite-EI line's stored initial acceleration so it is consistent with the - !! t=0 configuration-dependent loads the in-loop callback applies during the first step: - !! seabed contact AND the current/wave environment force. CD_Init_FiniteEI_Model builds a_0 - !! from gravity/buoyancy (base_f_ext) alone, so without this seed the first generalized-alpha - !! predictor starts from an a_0 inconsistent with the residual -- injecting a spurious startup - !! transient for grounded or hydrodynamically loaded finite-EI cables. Mirrors the EI=0 path's - !! update_wave_models recompute at t=0. The stored load is restored to base_f_ext afterwards - !! so the per-step reset invariant in step_finite_held_models is preserved (the contact/env - !! contribution is re-added through the callback each step and must not be double-counted). - TYPE(FiniteDeckModel), INTENT(INOUT) :: models(:) - TYPE(DeckOptions), INTENT(IN) :: opts - INTEGER, INTENT(OUT) :: ErrStat - CHARACTER(*), INTENT(OUT) :: ErrMsg - - INTEGER :: i, es - LOGICAL :: use_live_env - CHARACTER(1024) :: em - - ErrStat = CD_DECKDRV_OK - ErrMsg = '' - use_live_env = opts%has_current .OR. opts%has_wave - DO i = 1, SIZE(models) - IF (.NOT. (models(i)%has_seabed .OR. use_live_env)) CYCLE - CALL CD_Get_FiniteEI_Model_State(models(i)%model, models(i)%q_work, models(i)%v_work, & - models(i)%a_work, es, em) - IF (es /= 0) THEN - ErrStat = CD_DECKDRV_SOLVEFAIL - ErrMsg = 'CableDyn_DeckDriver: finite-EI state query before initial-load seed failed: '//TRIM(em) - RETURN - END IF - models(i)%contact_work = CD_ZERO - models(i)%env_work = CD_ZERO - IF (models(i)%has_seabed) THEN - IF (models(i)%has_bathymetry) THEN - CALL finite_bathymetry_contact_force(models(i)%q_work, models(i)%v_work, models(i)%bathymetry, & - models(i)%seabed_kn, models(i)%seabed_cn, opts%friction_mu, & - models(i)%contact_work, ErrStat, ErrMsg) - ELSE - CALL finite_seabed_contact_force(models(i)%q_work, models(i)%v_work, models(i)%seabed_z_floor, & - models(i)%seabed_kn, models(i)%seabed_cn, opts%friction_mu, & - models(i)%contact_work, ErrStat, ErrMsg) - END IF - IF (ErrStat /= CD_DECKDRV_OK) RETURN - END IF - IF (use_live_env) THEN - CALL finite_environment_force(models(i), opts, CD_ZERO, models(i)%q_work, models(i)%v_work, & - models(i)%env_work, ErrStat, ErrMsg) - IF (ErrStat /= CD_DECKDRV_OK) RETURN - END IF - models(i)%f_ext_work = models(i)%base_f_ext + models(i)%contact_work + models(i)%env_work - CALL CD_Set_FiniteEI_Model_Load(models(i)%model, models(i)%f_ext_work, es, em, & - recompute_acceleration=.TRUE.) - IF (es /= 0) THEN - ErrStat = CD_DECKDRV_SOLVEFAIL - ErrMsg = 'CableDyn_DeckDriver: finite-EI initial-acceleration seed failed: '//TRIM(em) - RETURN - END IF - models(i)%f_ext_work = models(i)%base_f_ext - CALL CD_Set_FiniteEI_Model_Load(models(i)%model, models(i)%f_ext_work, es, em, & - recompute_acceleration=.FALSE.) - IF (es /= 0) THEN - ErrStat = CD_DECKDRV_SOLVEFAIL - ErrMsg = 'CableDyn_DeckDriver: finite-EI load restore after seed failed: '//TRIM(em) - RETURN - END IF - END DO - END SUBROUTINE seed_finite_initial_acceleration - - SUBROUTINE step_finite_held_models(models, opts, time, dt, converged, stalled, n_iter, ErrStat, ErrMsg, & - motion, lines, points, time_index) - !! Advance every finite-EI line model one step. With no motion arguments the prescribed - !! endpoints are HELD at their stored positions. When motion/lines/points/time_index are - !! supplied (together), each line's prescribed endpoint translations follow the motionFile - !! trajectory to t_{n+1} as a MOVING support (their velocity/acceleration couple into the - !! dynamic residual), rather than being teleported-and-held. - TYPE(FiniteDeckModel), INTENT(INOUT) :: models(:) - TYPE(DeckOptions), INTENT(IN) :: opts - REAL(wp), INTENT(IN) :: time - REAL(wp), INTENT(IN) :: dt - LOGICAL, INTENT(OUT) :: converged, stalled - INTEGER, INTENT(OUT) :: n_iter, ErrStat - CHARACTER(*), INTENT(OUT) :: ErrMsg - TYPE(MotionTable), INTENT(IN), OPTIONAL :: motion - TYPE(DeckLine), INTENT(IN), OPTIONAL :: lines(:) - TYPE(DeckPoint), INTENT(IN), OPTIONAL :: points(:) - INTEGER, INTENT(IN), OPTIONAL :: time_index - - INTEGER :: i, es, line_iter, active_model - LOGICAL :: line_converged, line_stalled, use_motion, use_live_env, line_has_live_load - CHARACTER(1024) :: em - - converged = .TRUE. - stalled = .FALSE. - n_iter = 0 - ErrStat = CD_DECKDRV_OK - ErrMsg = '' - use_motion = PRESENT(motion) .AND. PRESENT(lines) .AND. PRESENT(points) .AND. PRESENT(time_index) - use_live_env = opts%has_current .OR. opts%has_wave - active_model = 0 - DO i = 1, SIZE(models) - line_has_live_load = models(i)%has_seabed .OR. use_live_env - IF (line_has_live_load) THEN - CALL CD_Get_FiniteEI_Model_State(models(i)%model, models(i)%q_work, models(i)%v_work, models(i)%a_work, es, em) - IF (es /= 0) THEN - ErrStat = CD_DECKDRV_SOLVEFAIL - ErrMsg = 'CableDyn_DeckDriver: finite-EI state query before load update failed: '//TRIM(em) - RETURN - END IF - models(i)%f_ext_work = models(i)%base_f_ext - CALL CD_Set_FiniteEI_Model_Load(models(i)%model, models(i)%f_ext_work, es, em, & - recompute_acceleration=.FALSE.) - IF (es /= 0) THEN - ErrStat = CD_DECKDRV_SOLVEFAIL - ErrMsg = 'CableDyn_DeckDriver: finite-EI load update failed: '//TRIM(em) - RETURN - END IF - END IF - active_model = i - IF (use_motion) THEN - CALL finite_motion_targets(models(i), lines(i), points, motion, time_index, models(i)%q_fixed_work, & - models(i)%v_fixed_work, models(i)%a_fixed_work, ErrStat, ErrMsg) - IF (ErrStat /= CD_DECKDRV_OK) RETURN - IF (line_has_live_load) THEN - ! a live load always carries its banded tangent - CALL CD_Step_FiniteEI_Model(models(i)%model, dt, line_converged, line_stalled, line_iter, es, em, & - q_fixed_target=models(i)%q_fixed_work, v_fixed_target=models(i)%v_fixed_work, & - a_fixed_target=models(i)%a_fixed_work, & - load_force_proc=finite_deck_dynamic_force, & - load_band_proc=finite_deck_dynamic_load_banded) - ELSE - CALL CD_Step_FiniteEI_Model(models(i)%model, dt, line_converged, line_stalled, line_iter, es, em, & - q_fixed_target=models(i)%q_fixed_work, v_fixed_target=models(i)%v_fixed_work, & - a_fixed_target=models(i)%a_fixed_work) - END IF - ELSE - IF (line_has_live_load) THEN - CALL CD_Step_FiniteEI_Model(models(i)%model, dt, line_converged, line_stalled, line_iter, es, em, & - load_force_proc=finite_deck_dynamic_force, & - load_band_proc=finite_deck_dynamic_load_banded) - ELSE - CALL CD_Step_FiniteEI_Model(models(i)%model, dt, line_converged, line_stalled, line_iter, es, em) - END IF - END IF - IF (es /= 0) THEN - ErrStat = CD_DECKDRV_SOLVEFAIL - ErrMsg = 'CableDyn_DeckDriver: finite-EI dynamic step failed: '//TRIM(em) - RETURN - END IF - converged = converged .AND. line_converged - stalled = stalled .OR. line_stalled - n_iter = MAX(n_iter, line_iter) - END DO - - CONTAINS - - SUBROUTINE finite_deck_dynamic_force(q_in, v_in, force, ErrStatCb, ErrMsgCb) - REAL(wp), INTENT(IN) :: q_in(:), v_in(:) - REAL(wp), INTENT(OUT) :: force(:) - INTEGER, INTENT(OUT) :: ErrStatCb - CHARACTER(*), INTENT(OUT) :: ErrMsgCb - - force = CD_ZERO - ErrStatCb = CD_DECKDRV_OK - ErrMsgCb = '' - IF (active_model < 1 .OR. active_model > SIZE(models)) THEN - ErrStatCb = CD_DECKDRV_SOLVEFAIL - ErrMsgCb = 'finite-EI dynamic force callback has no active model' - RETURN - END IF - IF (SIZE(q_in) /= SIZE(force) .OR. SIZE(v_in) /= SIZE(force) .OR. & - SIZE(force) /= SIZE(models(active_model)%base_f_ext)) THEN - ErrStatCb = CD_DECKDRV_SOLVEFAIL - ErrMsgCb = 'finite-EI dynamic force callback shape mismatch' - RETURN - END IF - models(active_model)%env_work = CD_ZERO - models(active_model)%contact_work = CD_ZERO - IF (models(active_model)%has_seabed) THEN - IF (models(active_model)%has_bathymetry) THEN - CALL finite_bathymetry_contact_force(q_in, v_in, models(active_model)%bathymetry, & - models(active_model)%seabed_kn, models(active_model)%seabed_cn, & - opts%friction_mu, models(active_model)%contact_work, ErrStatCb, ErrMsgCb) - ELSE - CALL finite_seabed_contact_force(q_in, v_in, models(active_model)%seabed_z_floor, & - models(active_model)%seabed_kn, models(active_model)%seabed_cn, & - opts%friction_mu, models(active_model)%contact_work, ErrStatCb, ErrMsgCb) - END IF - IF (ErrStatCb /= CD_DECKDRV_OK) RETURN - END IF - IF (opts%has_current .OR. opts%has_wave) THEN - CALL finite_environment_force(models(active_model), opts, time, q_in, v_in, models(active_model)%env_work, & - ErrStatCb, ErrMsgCb) - IF (ErrStatCb /= CD_DECKDRV_OK) RETURN - END IF - force = models(active_model)%contact_work + models(active_model)%env_work - END SUBROUTINE finite_deck_dynamic_force - - SUBROUTINE finite_deck_dynamic_load_banded(q_in, v_in, free, kl, ku, force, jac_q_band, jac_v_band, & - ErrStatCb, ErrMsgCb) - REAL(wp), INTENT(IN) :: q_in(:), v_in(:) - INTEGER, INTENT(IN) :: free(:), kl, ku - REAL(wp), INTENT(OUT) :: force(:), jac_q_band(:, :), jac_v_band(:, :) - INTEGER, INTENT(OUT) :: ErrStatCb - CHARACTER(*), INTENT(OUT) :: ErrMsgCb - - force = CD_ZERO - jac_q_band = CD_ZERO - jac_v_band = CD_ZERO - ErrStatCb = CD_DECKDRV_OK - ErrMsgCb = '' - IF (active_model < 1 .OR. active_model > SIZE(models)) THEN - ErrStatCb = CD_DECKDRV_SOLVEFAIL - ErrMsgCb = 'finite-EI dynamic banded load callback has no active model' - RETURN - END IF - IF (SIZE(q_in) /= SIZE(force) .OR. SIZE(v_in) /= SIZE(force) .OR. & - SIZE(force) /= SIZE(models(active_model)%base_f_ext)) THEN - ErrStatCb = CD_DECKDRV_SOLVEFAIL - ErrMsgCb = 'finite-EI dynamic banded load callback shape mismatch' - RETURN - END IF - models(active_model)%contact_work = CD_ZERO - models(active_model)%env_work = CD_ZERO - IF (models(active_model)%has_seabed) THEN - IF (models(active_model)%has_bathymetry) THEN - CALL finite_bathymetry_contact_load_banded(q_in, v_in, models(active_model)%bathymetry, & - models(active_model)%seabed_kn, models(active_model)%seabed_cn, & - opts%friction_mu, free, kl, ku, & - models(active_model)%free_map_work, & - models(active_model)%contact_work, jac_q_band, jac_v_band, & - ErrStatCb, ErrMsgCb) - ELSE - CALL finite_seabed_contact_load_banded(q_in, v_in, models(active_model)%seabed_z_floor, & - models(active_model)%seabed_kn, models(active_model)%seabed_cn, & - opts%friction_mu, free, kl, ku, & - models(active_model)%free_map_work, & - models(active_model)%contact_work, jac_q_band, jac_v_band, & - ErrStatCb, ErrMsgCb) - END IF - IF (ErrStatCb /= CD_DECKDRV_OK) RETURN - force = force + models(active_model)%contact_work - END IF - IF (opts%has_current .OR. opts%has_wave) THEN - CALL finite_environment_load_banded(models(active_model), opts, time, q_in, v_in, free, kl, ku, & - models(active_model)%free_map_work, models(active_model)%env_work, & - jac_q_band, jac_v_band, ErrStatCb, ErrMsgCb) - IF (ErrStatCb /= CD_DECKDRV_OK) RETURN - force = force + models(active_model)%env_work - END IF - END SUBROUTINE finite_deck_dynamic_load_banded - END SUBROUTINE step_finite_held_models - - SUBROUTINE finite_motion_targets(model, line, points, motion, time_index, q_ft, v_ft, a_ft, ErrStat, ErrMsg) - !! Build the t_{n+1} prescribed-support target vectors for a finite-EI line: the full - !! current model state with the two endpoint TRANSLATION triplets (DOFs 1..3 and - !! ndof-5..ndof-3) overwritten by the motionFile sample. Only those fixed entries are read - !! by the moving-support gen-alpha; the rest carry the (finite) current state. - TYPE(FiniteDeckModel), INTENT(IN) :: model - TYPE(DeckLine), INTENT(IN) :: line - TYPE(DeckPoint), INTENT(IN) :: points(:) - TYPE(MotionTable), INTENT(IN) :: motion - INTEGER, INTENT(IN) :: time_index - REAL(wp), INTENT(OUT) :: q_ft(:), v_ft(:), a_ft(:) - INTEGER, INTENT(OUT) :: ErrStat - CHARACTER(*), INTENT(OUT) :: ErrMsg - INTEGER :: ndof, pa, pb, es - CHARACTER(1024) :: em - ErrStat = CD_DECKDRV_OK - ErrMsg = '' - ndof = SIZE(q_ft) - CALL CD_Get_FiniteEI_Model_State(model%model, q_ft, v_ft, a_ft, es, em) - IF (es /= 0) THEN - ErrStat = CD_DECKDRV_SOLVEFAIL - ErrMsg = 'CableDyn_DeckDriver: finite-EI state query for motion targets failed: '//TRIM(em) - RETURN - END IF - pa = find_point(points, line%nodeB) - pb = find_point(points, line%nodeA) - CALL prescribed_point_state(points(pa), motion, time_index, q_ft(1:3), v_ft(1:3), a_ft(1:3), ErrStat, ErrMsg) - IF (ErrStat /= CD_DECKDRV_OK) RETURN - CALL prescribed_point_state(points(pb), motion, time_index, q_ft(ndof - 5:ndof - 3), & - v_ft(ndof - 5:ndof - 3), a_ft(ndof - 5:ndof - 3), ErrStat, ErrMsg) - END SUBROUTINE finite_motion_targets - SUBROUTINE step_held_models(models, dt, recovery_max_substeps, converged, stalled, n_iter, & max_substeps_used, ErrStat, ErrMsg, work) TYPE(CD_ModelType), INTENT(INOUT) :: models(:) @@ -33808,48 +33540,6 @@ SUBROUTINE apply_motion_to_models(models, lines, points, motion, time_index, Err END DO END SUBROUTINE apply_motion_to_models - SUBROUTINE apply_motion_to_finite_models(models, lines, points, motion, time_index, ErrStat, ErrMsg, & - recompute_acceleration) - TYPE(FiniteDeckModel), INTENT(INOUT) :: models(:) - TYPE(DeckLine), INTENT(IN) :: lines(:) - TYPE(DeckPoint), INTENT(IN) :: points(:) - TYPE(MotionTable), INTENT(IN) :: motion - INTEGER, INTENT(IN) :: time_index - INTEGER, INTENT(OUT) :: ErrStat - CHARACTER(*), INTENT(OUT) :: ErrMsg - LOGICAL, INTENT(IN), OPTIONAL :: recompute_acceleration - - INTEGER :: i, ndof, pa, pb, es - INTEGER :: dofs(6) - REAL(wp) :: q_vals(6), v_vals(6), a_vals(6) - LOGICAL :: do_recompute - CHARACTER(1024) :: em - - ErrStat = CD_DECKDRV_OK - ErrMsg = '' - do_recompute = .TRUE. - IF (PRESENT(recompute_acceleration)) do_recompute = recompute_acceleration - DO i = 1, SIZE(models) - ndof = 6*(models(i)%n_elem + 1) - pa = find_point(points, lines(i)%nodeB) - pb = find_point(points, lines(i)%nodeA) - CALL prescribed_point_state(points(pa), motion, time_index, q_vals(1:3), v_vals(1:3), a_vals(1:3), & - ErrStat, ErrMsg) - IF (ErrStat /= CD_DECKDRV_OK) RETURN - CALL prescribed_point_state(points(pb), motion, time_index, q_vals(4:6), v_vals(4:6), a_vals(4:6), & - ErrStat, ErrMsg) - IF (ErrStat /= CD_DECKDRV_OK) RETURN - dofs = [1, 2, 3, ndof - 5, ndof - 4, ndof - 3] - CALL CD_Set_FiniteEI_Model_PrescribedDofs(models(i)%model, dofs, q_vals, v_vals, a_vals, es, em, & - recompute_acceleration=do_recompute) - IF (es /= CD_DYN_OK) THEN - ErrStat = CD_DECKDRV_SOLVEFAIL - ErrMsg = 'CableDyn_DeckDriver: finite-EI prescribed motion update failed: '//TRIM(em) - RETURN - END IF - END DO - END SUBROUTINE apply_motion_to_finite_models - SUBROUTINE prescribed_full_state(model, line, points, motion, time_index, q, v, a, ErrStat, ErrMsg) TYPE(CD_ModelType), INTENT(IN) :: model TYPE(DeckLine), INTENT(IN) :: line @@ -33977,7 +33667,7 @@ SUBROUTINE prescribed_point_state(point, motion, time_index, q, v, a, ErrStat, E END SUBROUTINE prescribed_point_state SUBROUTINE read_motion_file(path, points, opts, motion, ErrStat, ErrMsg, include_rod_points, include_body_points, & - with_roll) + with_roll, with_turbine_frames) !! Prescribed point motion: rows "time point_id x y z vx vy vz ax ay az". with_roll (a deck !! with a torsional line) also reads an optional 12th column, the roll [deg] of the line end !! frames at that point about their directors (motion%roll, radians); a point gives it on @@ -33991,6 +33681,11 @@ SUBROUTINE read_motion_file(path, points, opts, motion, ErrStat, ErrMsg, include LOGICAL, INTENT(IN), OPTIONAL :: include_rod_points LOGICAL, INTENT(IN), OPTIONAL :: include_body_points LOGICAL, INTENT(IN), OPTIONAL :: with_roll + ! with_turbine_frames: keep each TURBINES row's rotation, angular velocity and acceleration + ! (motion%turb_rot/turb_omega/turb_alpha) for a deck whose line ends carry connection or + ! torsion frames + LOGICAL, INTENT(IN), OPTIONAL :: with_turbine_frames + LOGICAL :: keep_turb INTEGER :: unit, ios, ip, it, pid, nstep, lineno, row_status, ipt LOGICAL :: read_roll, roll_ok @@ -34136,6 +33831,21 @@ SUBROUTINE read_motion_file(path, points, opts, motion, ErrStat, ErrMsg, include END IF turb_seen = .FALSE. END IF + keep_turb = .FALSE. + IF (PRESENT(with_turbine_frames)) keep_turb = with_turbine_frames + IF (keep_turb .AND. .NOT. ALLOCATED(motion%turb_rot)) THEN + ALLOCATE (motion%turb_rot(3, 3, SIZE(opts%turb_ref, 2), motion%n_time), & + motion%turb_omega(3, SIZE(opts%turb_ref, 2), motion%n_time), & + motion%turb_alpha(3, SIZE(opts%turb_ref, 2), motion%n_time), STAT=ios) + IF (ios /= 0) THEN + CLOSE (unit) + CALL fail(ErrStat, ErrMsg, 'cannot allocate the TURBINES rotation table'); RETURN + END IF + motion%turb_rot = CD_ZERO + motion%turb_omega = CD_ZERO + motion%turb_alpha = CD_ZERO + motion%has_turb_rot = .TRUE. + END IF IF (turb_seen(jturb, it)) THEN CLOSE (unit) CALL fail(ErrStat, ErrMsg, 'duplicate row for turbine '//TRIM(int_to_str(jturb))//' at this time') @@ -34144,6 +33854,11 @@ SUBROUTINE read_motion_file(path, points, opts, motion, ErrStat, ErrMsg, include END IF turb_seen(jturb, it) = .TRUE. rq = quat_rotation(trow(6:9)) + IF (motion%has_turb_rot) THEN + motion%turb_rot(:, :, jturb, it) = rq + motion%turb_omega(:, jturb, it) = trow(13:15) + motion%turb_alpha(:, jturb, it) = trow(19:21) + END IF DO ip = 1, motion%n_point ipt = find_point(points, motion%point_ids(ip)) IF (ipt < 1) CYCLE @@ -35554,8 +35269,7 @@ PURE REAL(wp) FUNCTION line_geom_value(kind, deck_node, nnode, q_flat, stride, s !! (anchor->fairlead) with `stride` reals per node (3 for EI=0, 6 for finite-EI). !! kind: 5 curvature, 7 declination, 8 azimuth. Bend moment is NOT geometric -- it is !! the MATERIAL moment EI*(kappa - kappa_0), computed per path (zero on EI=0 lines; - !! finite_model_channel_value and range_sample_fmodel on finite-EI lines), so it is not - !! handled here and + !! eval_cable_channel and range_sample_cable on finite-EI lines), so it is not handled here and !! kind = 6 returns 0. signed: the line's azimuth range (DeckLine%azi_signed). INTEGER, INTENT(IN) :: kind, deck_node, nnode, stride REAL(wp), INTENT(IN) :: q_flat(:) @@ -35805,35 +35519,6 @@ SUBROUTINE collect_system_init_summaries(lines, points, system, summaries, ErrSt END IF END SUBROUTINE collect_system_init_summaries - SUBROUTINE collect_finite_init_summaries(lines, points, models, summaries, ErrStat, ErrMsg) - TYPE(DeckLine), INTENT(IN) :: lines(:) - TYPE(DeckPoint), INTENT(IN) :: points(:) - TYPE(FiniteDeckModel), INTENT(IN) :: models(:) - TYPE(CD_LineInitSummary), ALLOCATABLE, INTENT(OUT) :: summaries(:) - INTEGER, INTENT(OUT) :: ErrStat - CHARACTER(*), INTENT(OUT) :: ErrMsg - TYPE(ModelOutputWorkspace) :: work - INTEGER :: i - REAL(wp) :: tension, declination, azimuth - CHARACTER(NAMELEN) :: cten, cdec, cazi - - ErrStat = CD_DECKDRV_OK; ErrMsg = '' - ALLOCATE (summaries(SIZE(lines))) - DO i = 1, SIZE(lines) - CALL init_summary_channels(lines(i)%id, cten, cdec, cazi) - CALL finite_model_channel_value(cten, lines, points, models, work, tension, ErrStat, ErrMsg) - IF (ErrStat == CD_DECKDRV_OK) CALL finite_model_channel_value(cdec, lines, points, models, work, declination, & - ErrStat, ErrMsg) - IF (ErrStat == CD_DECKDRV_OK) CALL finite_model_channel_value(cazi, lines, points, models, work, azimuth, & - ErrStat, ErrMsg) - IF (ErrStat /= CD_DECKDRV_OK) RETURN - ! The retained Cosserat compatibility route does not expose its complete - ! prescribed-DOF reaction. Report the auditable axial component explicitly; - ! the production Hermite/OpenFAST paths above report the full reaction. - CALL set_init_summary(lines(i)%id, tension, declination, azimuth, summaries(i), force_is_total=.FALSE.) - END DO - END SUBROUTINE collect_finite_init_summaries - SUBROUTINE collect_hermite_init_summaries(lines, cables, summaries, ErrStat, ErrMsg) TYPE(DeckLine), INTENT(IN) :: lines(:) TYPE(CD_HFMF_ModuleType), INTENT(INOUT) :: cables(:) @@ -35997,10 +35682,10 @@ SUBROUTINE range_setup(rset, lines, channels, opts, nnodes, by_id, ErrStat, ErrM END DO END SUBROUTINE range_setup - SUBROUTINE range_setup_planned(rset, lines, channels, opts, ErrStat, ErrMsg, models, fmodels, system, cables, & + SUBROUTINE range_setup_planned(rset, lines, channels, opts, ErrStat, ErrMsg, models, system, cables, & bathymetry) !! Range set of a standalone route, in deck line order, sized from the built line - !! objects (exactly one of models, fmodels, system, cables is present). + !! objects (exactly one of models, system, cables is present). TYPE(CD_RangeSet), INTENT(INOUT) :: rset TYPE(DeckLine), INTENT(IN) :: lines(:) CHARACTER(*), INTENT(IN) :: channels(:) @@ -36008,7 +35693,6 @@ SUBROUTINE range_setup_planned(rset, lines, channels, opts, ErrStat, ErrMsg, mod INTEGER, INTENT(OUT) :: ErrStat CHARACTER(*), INTENT(OUT) :: ErrMsg TYPE(CD_ModelType), INTENT(IN), OPTIONAL :: models(:) - TYPE(FiniteDeckModel), INTENT(IN), OPTIONAL :: fmodels(:) TYPE(CD_SystemType), INTENT(IN), OPTIONAL :: system TYPE(CD_HFMF_ModuleType), INTENT(IN), OPTIONAL :: cables(:) TYPE(CD_BathymetryType), INTENT(IN), OPTIONAL :: bathymetry @@ -36022,8 +35706,6 @@ SUBROUTINE range_setup_planned(rset, lines, channels, opts, ErrStat, ErrMsg, mod es = 0 IF (PRESENT(models)) THEN nnodes(il) = CD_Model_NDOF(models(il), es, em)/3 - ELSE IF (PRESENT(fmodels)) THEN - nnodes(il) = fmodels(il)%n_elem + 1 ELSE IF (PRESENT(system)) THEN nnodes(il) = CD_System_Line_NDOF(system, il, es, em)/3 ELSE IF (PRESENT(cables)) THEN @@ -36127,50 +35809,6 @@ SUBROUTINE range_sample_arrays(q_line, ten_line, rl, end_ten) END IF END SUBROUTINE range_sample_arrays - SUBROUTINE range_sample_fmodel(fmodel, rl, ErrStat, ErrMsg) - !! Sample a finite-EI (two-moving-end route) line with the evaluators of - !! finite_model_channel_value: chord-stretch element tension, geometric curvature and - !! the reference-relative bend moment EI * |kappa - kappa_ref|. - TYPE(FiniteDeckModel), INTENT(IN) :: fmodel - TYPE(CD_RangeLine), INTENT(INOUT) :: rl - INTEGER, INTENT(OUT) :: ErrStat - CHARACTER(*), INTENT(OUT) :: ErrMsg - INTEGER :: nn, ne, e, j, inode, es - REAL(wp) :: xa(3), xb(3), length, kc(3), kr(3) - CHARACTER(1024) :: em - - ErrStat = CD_DECKDRV_OK - ErrMsg = '' - nn = rl%nn - ne = nn - 1 - IF (fmodel%n_elem /= ne) THEN - CALL fail_solve(ErrStat, ErrMsg, 'range-graph sample: finite-EI line size changed'); RETURN - END IF - CALL CD_Get_FiniteEI_Model_State(fmodel%model, rl%qs(1:6*nn), rl%vs(1:6*nn), rl%as(1:6*nn), es, em) - IF (es /= 0) THEN - CALL fail_solve(ErrStat, ErrMsg, 'range-graph sample of line '//TRIM(int_to_str(rl%line_id))//' failed: '// & - TRIM(em)); RETURN - END IF - IF (.NOT. rl%want_range) THEN - CALL range_positions(rl, 6) - RETURN - END IF - DO e = 1, ne - xa = rl%qs(6*e - 5:6*e - 3) - xb = rl%qs(6*(e + 1) - 5:6*(e + 1) - 3) - length = SQRT(DOT_PRODUCT(xb - xa, xb - xa)) - rl%ten_e(e) = fmodel%ea(e)*(length/fmodel%l0(e) - CD_ONE) - END DO - CALL range_fill_ei0(rl, 6) - DO j = 1, nn - ! the circumcircle of the reversed node triple is the same circle (bit for bit) - inode = deck_to_internal_node(j, ne) - kc = node_curvature_vector(rl%r, nn, j) - kr = node_curvature_vector(fmodel%model%nodes_ref, nn, inode) - rl%val(CD_RQ_BEND, j) = nodal_ei_value(fmodel%ei, inode)*NORM2(kc - kr) - END DO - END SUBROUTINE range_sample_fmodel - SUBROUTINE range_sample_cable(cable, rl, ErrStat, ErrMsg) !! Sample a cubic-Hermite cable with the definitions of eval_cable_channel: the node !! tension, curvature and bend moment recovered from nodal equilibrium in one pass @@ -36975,8 +36613,8 @@ SUBROUTINE sys_solvefail(ch, em, ErrStat, ErrMsg) END SUBROUTINE sys_solvefail SUBROUTINE eval_cable_channel(cable, ch, val, ErrStat, ErrMsg, mesh_node) - !! Evaluate one channel for a finite-EI Hermite power cable (CD_HFMF). Mirrors the driver's - !! finite_model_channel_value but reads the cable's committed state directly from the CD_HFMF + !! Evaluate one channel for a finite-EI Hermite power cable (CD_HFMF). Reads the cable's + !! committed state directly from the CD_HFMF !! line (stride-6 DOFs: r at 6*(n-1)+1..3, tangent m at +4..6) and recovers the !! complete elastic plus Kelvin-Voigt axial resultant. Node ordering runs anchor (node 1, held) !! -> fairlead (node nn, the coupled endpoint), so deck End A = internal node nn. Bend moment is @@ -37731,10 +37369,13 @@ SUBROUTINE collect_body_point_indices(points, body_id, indices) INTEGER, INTENT(IN) :: body_id INTEGER, ALLOCATABLE, INTENT(OUT) :: indices(:) INTEGER :: i, n + ! the Body points only, as count_body_point_refs counts them: a RodA/B end point keeps + ! its rod's id in body_id, so a rod numbered as the body is not one of the body's points n = count_body_point_refs(points, body_id) ALLOCATE (indices(n)) n = 0 DO i = 1, SIZE(points) + IF (.NOT. starts_with(TRIM(points(i)%ptype), 'body')) CYCLE IF (points(i)%body_id == body_id) THEN n = n + 1 indices(n) = i @@ -37834,6 +37475,15 @@ LOGICAL FUNCTION deck_has_non_rod_dynamic_points(points) RESULT(has_other) END DO END FUNCTION deck_has_non_rod_dynamic_points + LOGICAL FUNCTION end_b_holds_frame(ptype) RESULT(ok) + !! End B can hold an END CONNECTION or a torsion frame: a Fixed point, a Coupled/Vessel point + !! (a second driven end), a body point or a rod end (a line between two objects, on the + !! multibody march, which checks the object). + CHARACTER(*), INTENT(IN) :: ptype + ok = TRIM(ptype) == 'fixed' .OR. TRIM(ptype) == 'coupled' .OR. TRIM(ptype) == 'vessel' .OR. & + starts_with(TRIM(ptype), 'body') .OR. is_rod_point_type(ptype) + END FUNCTION end_b_holds_frame + LOGICAL FUNCTION endpoint_type_supported_dynamic(ptype) RESULT(ok) CHARACTER(*), INTENT(IN) :: ptype ok = ptype == 'fixed' .OR. ptype == 'coupled' .OR. ptype == 'vessel' .OR. & @@ -37967,7 +37617,8 @@ SUBROUTINE apply_coupled_positions(points, lines, is_fin, coupled_positions, ptf !! static solves, in the aggregate moving-set order: the system's BOUND !! Coupled/Vessel points in deck POINT order (a Coupled point bound only to a !! finite-EI cable is NOT in the system's coupled map -- bound-only counting), - !! followed by one coupled fairlead per finite-EI cable in deck LINE order. + !! followed by one coupled fairlead (End A) per finite-EI cable in deck LINE order, then + !! the moving End B of each finite-EI cable between two moving points, in deck LINE order. !! Fails closed on a shape/count mismatch, non-finite input, or combination with !! a nonzero ptfm_init (the two mutate the same points). TYPE(DeckPoint), INTENT(INOUT) :: points(:) @@ -38018,18 +37669,27 @@ SUBROUTINE apply_coupled_positions(points, lines, is_fin, coupled_positions, ptf 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') - icol = icol + 1 - IF (icol > SIZE(coupled_positions, 2)) THEN - CALL fail(ErrStat, ErrMsg, 'coupled_positions has fewer columns than the deck has '// & - 'host-prescribed points'); RETURN - END IF - points(i)%pos = coupled_positions(:, icol) - END SELECT - END DO + i = find_point(points, lines(l)%nodeA) + IF (i < 1) CYCLE + SELECT CASE (TRIM(points(i)%ptype)) + CASE ('coupled', 'vessel') + icol = icol + 1 + IF (icol > SIZE(coupled_positions, 2)) THEN + CALL fail(ErrStat, ErrMsg, 'coupled_positions has fewer columns than the deck has '// & + 'host-prescribed points'); RETURN + END IF + points(i)%pos = coupled_positions(:, icol) + END SELECT + END DO + DO l = 1, SIZE(lines) + IF (.NOT. is_fin(l)) CYCLE + IF (.NOT. moving_end_b_point(points, lines(l))) CYCLE + icol = icol + 1 + IF (icol > SIZE(coupled_positions, 2)) THEN + CALL fail(ErrStat, ErrMsg, 'coupled_positions has fewer columns than the deck has '// & + 'host-prescribed points'); RETURN + END IF + points(find_point(points, lines(l)%nodeB))%pos = coupled_positions(:, icol) END DO IF (icol /= SIZE(coupled_positions, 2)) THEN CALL fail(ErrStat, ErrMsg, 'coupled_positions column count does not match the deck''s '// & @@ -38163,6 +37823,14 @@ PURE LOGICAL FUNCTION line_torsion_at_a(ln) RESULT(at_a) at_a = line_torsion_active(ln) .AND. ln%tors_mode(1) /= TORS_FREE END FUNCTION line_torsion_at_a + PURE LOGICAL FUNCTION line_torsion_at_b(ln) RESULT(at_b) + !! The line is solved in torsion and its End B is restrained in torsion: a moving End B's + !! object (a line between two moving points or two objects) takes the torque, and its turn or + !! roll twists the line. + TYPE(DeckLine), INTENT(IN) :: ln + at_b = line_torsion_active(ln) .AND. ln%tors_mode(2) /= TORS_FREE + END FUNCTION line_torsion_at_b + 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 @@ -38614,7 +38282,7 @@ 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, nx0) + SUBROUTINE clamp_object_frame(ln, points, bodies, rods, rot, d0, ErrStat, ErrMsg, check_axis, nx0, end_b) !! 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 @@ -38623,7 +38291,8 @@ SUBROUTINE clamp_object_frame(ln, points, bodies, rods, rot, d0, ErrStat, ErrMsg !! 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 + !! With end_b the same for End B's connection (a line between two objects). + !! nx0: that end'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. @@ -38634,11 +38303,11 @@ SUBROUTINE clamp_object_frame(ln, points, bodies, rods, rot, d0, ErrStat, ErrMsg REAL(wp), INTENT(OUT) :: rot(3, 3), d0(3) INTEGER, INTENT(OUT) :: ErrStat CHARACTER(*), INTENT(OUT) :: ErrMsg - LOGICAL, INTENT(IN), OPTIONAL :: check_axis + LOGICAL, INTENT(IN), OPTIONAL :: check_axis, end_b REAL(wp), INTENT(OUT), OPTIONAL :: nx0(3) INTEGER :: pa, ib, ir, rid, iend REAL(wp) :: axis(3), ez(3), an - LOGICAL :: check + LOGICAL :: check, at_b CHARACTER(64) :: who ErrStat = CD_DECKDRV_OK @@ -38647,13 +38316,15 @@ SUBROUTINE clamp_object_frame(ln, points, bodies, rods, rot, d0, ErrStat, ErrMsg rot(1, 1) = CD_ONE rot(2, 2) = CD_ONE rot(3, 3) = CD_ONE - ez = ln%endconn_ez_ref(:, 1) + at_b = .FALSE. + IF (PRESENT(end_b)) at_b = end_b + ez = ln%endconn_ez_ref(:, MERGE(2, 1, at_b)) d0 = ez - IF (PRESENT(nx0)) nx0 = ln%tors_nx(:, 1) + IF (PRESENT(nx0)) nx0 = ln%tors_nx(:, MERGE(2, 1, at_b)) check = .TRUE. IF (PRESENT(check_axis)) check = check_axis - who = 'finite-EI LINE '//TRIM(int_to_str(ln%id))//' End A' - pa = find_point(points, ln%nodeA) + who = 'finite-EI LINE '//TRIM(int_to_str(ln%id))//MERGE(' End B', ' End A', at_b) + pa = find_point(points, MERGE(ln%nodeB, ln%nodeA, at_b)) IF (pa < 1) THEN CALL fail(ErrStat, ErrMsg, TRIM(who)//' references an unknown point'); RETURN END IF @@ -38694,7 +38365,8 @@ SUBROUTINE clamp_object_frame(ln, points, bodies, rods, rot, d0, ErrStat, ErrMsg ! 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)) + IF (PRESENT(nx0) .AND. TRIM(rods(ir)%rod_type) == 'fixed') & + nx0 = MATMUL(TRANSPOSE(rot), ln%tors_nx(:, MERGE(2, 1, at_b))) 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 21116950..ba175eee 100644 --- a/src/CableDyn_HermiteCableDynamic.f90 +++ b/src/CableDyn_HermiteCableDynamic.f90 @@ -136,7 +136,7 @@ MODULE CableDyn_HermiteCableDynamic PUBLIC :: CD_HermiteCable_Dyn_Set_VIV PUBLIC :: CD_HermiteCable_Dyn_VIV_Node_Lift PUBLIC :: CD_HermiteCable_Dyn_Restore - PUBLIC :: CD_HermiteCable_Dyn_Energy + PUBLIC :: CD_HermiteCable_Dyn_Energy, CD_HermiteCable_Dyn_Momentum PUBLIC :: CD_HermiteCable_Dyn_Curvature PUBLIC :: CD_HermiteCable_Dyn_Section_Curvature PUBLIC :: CD_HermiteCable_Dyn_Reaction @@ -5861,6 +5861,30 @@ SUBROUTINE CD_HermiteCable_Dyn_Energy(model, kinetic, strain, ErrStat, ErrMsg, c IF (PRESENT(connection)) connection = connection_energy END SUBROUTINE CD_HermiteCable_Dyn_Energy + SUBROUTINE CD_HermiteCable_Dyn_Momentum(model, p, ErrStat, ErrMsg) + !! Linear momentum of the line at the current state (solve frame) with the mass matrix of + !! CD_HermiteCable_Dyn_Energy (the consistent structural mass plus any discrete attachment's + !! mass and added mass): the sum over the nodes of the translation rows of M v (the position + !! shape functions of an element sum to one, its tangent ones to zero). A conservation + !! diagnostic, as the energy. + TYPE(CD_HermiteCableDynType), INTENT(IN) :: model + REAL(wp), INTENT(OUT) :: p(3) + INTEGER, INTENT(OUT) :: ErrStat + CHARACTER(*), INTENT(OUT) :: ErrMsg + INTEGER :: i + ErrStat = CD_HCDYN_OK; ErrMsg = ''; p = CD_ZERO + IF (.NOT. model%initialized) THEN + ErrStat = CD_HCDYN_BADINPUT; ErrMsg = 'CD_HermiteCable_Dyn_Momentum: model not initialised'; RETURN + END IF + BLOCK + REAL(wp) :: Mv(model%ndof) + CALL band_matvec(model%Mgb, model%v, Mv) + DO i = 1, model%nn + p = p + Mv(6*(i - 1) + 1:6*(i - 1) + 3) + END DO + END BLOCK + END SUBROUTINE CD_HermiteCable_Dyn_Momentum + SUBROUTINE CD_HermiteCable_Dyn_Curvature(model, curv_out, ErrStat, ErrMsg) !! Per-node curvature at the current state, the definition of the CurvN channels: the !! bend moment recovered from nodal equilibrium over EI (CD_HermiteCable_Dyn_Node_Recovery), diff --git a/src/CableDyn_OpenFAST_Aggregate.f90 b/src/CableDyn_OpenFAST_Aggregate.f90 index 2652e6b8..e8e75e9e 100644 --- a/src/CableDyn_OpenFAST_Aggregate.f90 +++ b/src/CableDyn_OpenFAST_Aggregate.f90 @@ -54,6 +54,7 @@ MODULE CableDyn_OpenFAST_Aggregate USE CableDyn_OpenFAST_HermiteFMF, ONLY: CD_HFMF_ModuleType, CD_HFMF_UpdateStates, CD_HFMF_CalcOutput, & CD_HFMF_PreflightCoupledKinematics, & CD_HFMF_SetCoupledKinematics, CD_HFMF_GetCoupledKinematics, & + CD_HFMF_GetEndBKinematics, & 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, & @@ -140,6 +141,8 @@ MODULE CableDyn_OpenFAST_Aggregate ! maps a sub-module status onto the same integer meaning. INTEGER, PARAMETER, PUBLIC :: CD_AGG_OK = 0, CD_AGG_BADINPUT = 1, CD_AGG_SOLVEFAIL = 2, & CD_AGG_NOT_INITIALIZED = 3, CD_AGG_ALLOCFAIL = 4 + ! cable_two_ends modes + INTEGER, PARAMETER :: CABLE_PREFLIGHT = 1, CABLE_SET = 2, CABLE_STEP = 3 TYPE :: CD_AGG_ModuleType !! Owner of the composed {EI=0 system + N Hermite cables} behind the FMF facade. @@ -157,6 +160,12 @@ MODULE CableDyn_OpenFAST_Aggregate REAL(wp) :: max_strain = 0.5_wp INTEGER :: ncp_sys = 0 ! moving points owned by sys INTEGER :: ncable = 0 ! number of cables (= trailing moving points) + ! Cables with a moving End B (a finite-EI line between two moving points): their count and, + ! per cable, the moving column of End B (0 for a held End B). The End B columns follow the End + ! A columns of all cables, in cable order (host rods and bodies, after them, never share a deck + ! with a finite-EI cable). + INTEGER :: ncable_b = 0 + INTEGER, ALLOCATABLE :: cable_col_b(:) INTEGER :: n_lines = 0, n_points = 0, n_sections = 0 INTEGER :: n_ei0_lines = 0, n_finite_ei_lines = 0 TYPE(CD_LineInitSummary), ALLOCATABLE :: init_lines(:) @@ -463,6 +472,22 @@ SUBROUTINE CD_AGG_Init_From_Deck(self, deck_path, dt, ErrStat, ErrMsg, env_gravi ELSE candidate%ncable = 0 END IF + ALLOCATE (candidate%cable_col_b(candidate%ncable)) + candidate%cable_col_b = 0 + candidate%ncable_b = 0 + DO ich = 1, candidate%ncable + IF (.NOT. candidate%cables(ich)%moving_b) CYCLE + candidate%ncable_b = candidate%ncable_b + 1 + candidate%cable_col_b(ich) = candidate%ncp_sys + candidate%ncable + candidate%ncable_b + END DO + IF (candidate%ncable_b > 0 .AND. (candidate%nhost_rod > 0 .OR. candidate%nhost_body > 0)) THEN + ErrStat = CD_AGG_BADINPUT + ErrMsg = 'CableDyn_OpenFAST_Aggregate: a finite-EI cable with a moving End B does not share a deck with '// & + 'host-driven rods or bodies' + CALL CD_End_Deck_Aggregate(parts) + CALL CD_AGG_End(candidate, es, em) + RETURN + END IF ! Take the deck OUTPUTS channels + the deck-line-id -> object map (MOVE, then derive the unit ! label per channel). CD_Init_Deck_Aggregate populates these ONLY when the deck declares an ! OUTPUTS section; a channel-free deck leaves them unallocated, so this module reports @@ -503,11 +528,12 @@ SUBROUTINE CD_AGG_Init_From_Deck(self, deck_path, dt, ErrStat, ErrMsg, env_gravi END DO END IF ! Host rod and body nodes append after the cables; outside farm mode they drive no turbine. - IF (ncp_total > candidate%ncp_sys + candidate%ncable .AND. ALLOCATED(candidate%turbine_of_moving)) THEN + IF (ncp_total > candidate%ncp_sys + candidate%ncable + candidate%ncable_b .AND. & + ALLOCATED(candidate%turbine_of_moving)) THEN candidate%turbine_of_moving = [candidate%turbine_of_moving, & - (0, ich=1, ncp_total - candidate%ncp_sys - candidate%ncable)] + (0, ich=1, ncp_total - candidate%ncp_sys - candidate%ncable - candidate%ncable_b)] END IF - IF (ncp_total > candidate%ncp_sys + candidate%ncable) THEN + IF (ncp_total > candidate%ncp_sys + candidate%ncable + candidate%ncable_b) THEN ich = fmf_nblocks(candidate%sys) ALLOCATE (candidate%hb_pos(3, ich), candidate%hb_vel(3, ich), candidate%hb_acc(3, ich), & candidate%hb_load(3, ich), STAT=istat) @@ -645,8 +671,8 @@ SUBROUTINE CD_AGG_GetMovingPointMesh(self, position, velocity, acceleration, loa ! reactions write only the cable's scratch, so the other outputs are unchanged. LOGICAL, INTENT(IN), OPTIONAL :: cable_loads - INTEGER :: c, col, es - REAL(wp) :: y_fair(3) + INTEGER :: c, col, colb, es + REAL(wp) :: y_fair(3), y_b(3), m_a(3), m_b(3) LOGICAL :: want_cable_loads CHARACTER(1024) :: em @@ -730,6 +756,39 @@ SUBROUTINE CD_AGG_GetMovingPointMesh(self, position, velocity, acceleration, loa CALL map_hfmf_status(es, em, ErrStat, ErrMsg) RETURN END IF + IF (self%cable_col_b(c) > 0) THEN + ! a moving End B: its column carries node 1's kinematics and the load on End B's host, + ! both ends' loads from one evaluation of the committed state + colb = self%cable_col_b(c) + CALL CD_HFMF_GetEndBKinematics(self%cables(c), position(:, colb), velocity(:, colb), & + acceleration(:, colb), es, em, self%mv_orient(:, :, colb), & + self%mv_omega(:, colb), self%mv_alpha(:, colb)) + IF (es /= CD_HFMF_OK) THEN + CALL map_hfmf_status(es, em, ErrStat, ErrMsg) + RETURN + END IF + IF (.NOT. want_cable_loads) CYCLE + CALL CD_HFMF_CalcOutput(self%cables(c), y_fair, es, em, y_moment=m_a, y_end_b=y_b, y_moment_b=m_b) + IF (es /= CD_HFMF_OK) THEN + CALL map_hfmf_status(es, em, ErrStat, ErrMsg) + RETURN + END IF + load(:, col) = y_fair + load(:, colb) = y_b + IF (PRESENT(moment)) THEN + moment(:, col) = m_a + moment(:, colb) = m_b + END IF + IF (.NOT. self%cable_load_feedback) THEN + load(:, col) = CD_ZERO + load(:, colb) = CD_ZERO + IF (PRESENT(moment)) THEN + moment(:, col) = CD_ZERO + moment(:, colb) = CD_ZERO + END IF + END IF + CYCLE + END IF IF (.NOT. want_cable_loads) CYCLE IF (PRESENT(moment)) THEN CALL CD_HFMF_CalcOutput(self%cables(c), y_fair, es, em, moment(:, col)) @@ -756,7 +815,7 @@ SUBROUTINE CD_AGG_GetMovingPointMesh(self, position, velocity, acceleration, loa RETURN END IF DO c = 1, self%nhost_rod - col = self%ncp_sys + self%ncable + c + col = self%ncp_sys + self%ncable + self%ncable_b + c CALL CD_Rod_GetHostKinematics(self%rod, c, position(:, col), velocity(:, col), acceleration(:, col), & self%mv_orient(:, :, col), self%mv_omega(:, col), self%mv_alpha(:, col)) CALL CD_Rod_HostWrench(self%sys%fast%system, self%rod, self%hb_load, c, load(:, col), y_fair, es, em) @@ -776,7 +835,7 @@ SUBROUTINE CD_AGG_GetMovingPointMesh(self, position, velocity, acceleration, loa RETURN END IF DO c = 1, self%nhost_body - col = self%ncp_sys + self%ncable + self%nhost_rod + c + col = self%ncp_sys + self%ncable + self%ncable_b + self%nhost_rod + c CALL CD_Rigid6_GetHostKinematics(self%rigid6, c, position(:, col), velocity(:, col), acceleration(:, col), & self%mv_orient(:, :, col), self%mv_omega(:, col), self%mv_alpha(:, col)) CALL CD_Rigid6_HostWrench(self%sys%fast%system, self%rigid6, self%hb_load, c, load(:, col), y_fair, es, em) @@ -870,7 +929,11 @@ SUBROUTINE CD_AGG_UpdateStates_Moving(self, position, velocity, acceleration, Er ! validating that each supplied orientation is a proper DCM. DO c = 1, self%ncable col = self%ncp_sys + c - IF (PRESENT(orientation)) THEN + IF (self%cable_col_b(c) > 0) THEN + CALL cable_two_ends(self%cables(c), col, self%cable_col_b(c), CABLE_PREFLIGHT, position, velocity, & + acceleration, es, em, orientation, & + angular_velocity, angular_acceleration) + ELSE IF (PRESENT(orientation)) THEN IF (PRESENT(angular_velocity)) THEN CALL CD_HFMF_PreflightCoupledKinematics(self%cables(c), position(:, col), velocity(:, col), & acceleration(:, col), es, em, orientation(:, :, col), & @@ -934,7 +997,11 @@ SUBROUTINE CD_AGG_UpdateStates_Moving(self, position, velocity, acceleration, Er END IF DO c = 1, self%ncable col = self%ncp_sys + c - IF (PRESENT(orientation)) THEN + IF (self%cable_col_b(c) > 0) THEN + CALL cable_two_ends(self%cables(c), col, self%cable_col_b(c), CABLE_SET, position, velocity, & + acceleration, es, em, orientation, & + self%mv_omega, self%mv_alpha) + ELSE IF (PRESENT(orientation)) THEN CALL CD_HFMF_SetCoupledKinematics(self%cables(c), position(:, col), velocity(:, col), & acceleration(:, col), es, em, orientation(:, :, col), & self%mv_omega(:, col), self%mv_alpha(:, col)) @@ -1240,8 +1307,21 @@ SUBROUTINE CD_AGG_Step_Moving(self, dt, position, velocity, acceleration, conver !$OMP DO SCHEDULE(STATIC) DO c = 1, self%ncable col = self%ncp_sys + c - CALL step_cable(self, c, position(:, col), velocity(:, col), acceleration(:, col), use_roll, es, em, & - orientation(:, :, col)) + IF (self%cable_col_b(c) > 0) THEN + IF (use_roll .AND. self%cables(c)%line%torsion%active) THEN + ! the roll of each moving end restrained in torsion: Phi_0 - roll(A) - roll(B) + CALL cable_two_ends(self%cables(c), col, self%cable_col_b(c), CABLE_STEP, position, velocity, & + acceleration, es, em, orientation, self%mv_omega, self%mv_alpha, & + twist=self%cable_phi0(c) - self%mv_roll(col) - self%mv_roll(self%cable_col_b(c))) + ELSE + CALL cable_two_ends(self%cables(c), col, self%cable_col_b(c), CABLE_STEP, position, velocity, & + acceleration, es, em, orientation, & + self%mv_omega, self%mv_alpha) + END IF + ELSE + CALL step_cable(self, c, position(:, col), velocity(:, col), acceleration(:, col), use_roll, es, em, & + orientation(:, :, col)) + END IF self%cable_stat(c) = es self%cable_msg(c) = em END DO @@ -1255,7 +1335,20 @@ SUBROUTINE CD_AGG_Step_Moving(self, dt, position, velocity, acceleration, conver !$OMP DO SCHEDULE(STATIC) DO c = 1, self%ncable col = self%ncp_sys + c - CALL step_cable(self, c, position(:, col), velocity(:, col), acceleration(:, col), use_roll, es, em) + IF (self%cable_col_b(c) > 0) THEN + IF (use_roll .AND. self%cables(c)%line%torsion%active) THEN + CALL cable_two_ends(self%cables(c), col, self%cable_col_b(c), CABLE_STEP, position, velocity, & + acceleration, es, em, & + angular_velocity=self%mv_omega, angular_acceleration=self%mv_alpha, & + twist=self%cable_phi0(c) - self%mv_roll(col) - self%mv_roll(self%cable_col_b(c))) + ELSE + CALL cable_two_ends(self%cables(c), col, self%cable_col_b(c), CABLE_STEP, position, velocity, & + acceleration, es, em, & + angular_velocity=self%mv_omega, angular_acceleration=self%mv_alpha) + END IF + ELSE + CALL step_cable(self, c, position(:, col), velocity(:, col), acceleration(:, col), use_roll, es, em) + END IF self%cable_stat(c) = es self%cable_msg(c) = em END DO @@ -2242,6 +2335,8 @@ SUBROUTINE CD_AGG_End(self, ErrStat, ErrMsg) IF (ALLOCATED(self%host_current_profile_velocity)) DEALLOCATE (self%host_current_profile_velocity) self%ncp_sys = 0 self%ncable = 0 + self%ncable_b = 0 + IF (ALLOCATED(self%cable_col_b)) DEALLOCATE (self%cable_col_b) self%n_lines = 0 self%n_points = 0 self%n_sections = 0 @@ -2651,11 +2746,62 @@ SUBROUTINE host_fairlead_motion(self, position, velocity, acceleration) END SUBROUTINE host_fairlead_motion PURE INTEGER FUNCTION ncp_all(self) RESULT(n) - !! Total moving columns: system moving points, cable fairleads, host rod nodes. + !! Total moving columns: system moving points, cable fairleads, the moving End B of a cable + !! between two moving points, host rod nodes, host body nodes. TYPE(CD_AGG_ModuleType), INTENT(IN) :: self - n = self%ncp_sys + self%ncable + self%nhost_rod + self%nhost_body + n = self%ncp_sys + self%ncable + self%ncable_b + self%nhost_rod + self%nhost_body END FUNCTION ncp_all + SUBROUTINE cable_two_ends(cable, ca, cb, mode, position, velocity, acceleration, es, em, orientation, & + angular_velocity, angular_acceleration, twist) + !! The HFMF boundary call of a cable with a moving End B (CD_HFMF_Set_Moving_End_B): End A takes + !! the moving column ca, End B column cb, each with its orientation and rates (the + !! committed parent orientation and zero rates where the host passes none). mode CABLE_PREFLIGHT + !! validates, CABLE_SET transfers without a step (direct feedthrough), CABLE_STEP advances, + !! with twist the imposed twist of a cable restrained in torsion (the deck's roll columns). + !! Touches only that cable (safe inside the cables' parallel loop). + TYPE(CD_HFMF_ModuleType), INTENT(INOUT) :: cable + INTEGER, INTENT(IN) :: ca, cb, mode + REAL(wp), INTENT(IN) :: position(:, :), velocity(:, :), acceleration(:, :) + INTEGER, INTENT(OUT) :: es + CHARACTER(*), INTENT(OUT) :: em + REAL(wp), INTENT(IN), OPTIONAL :: orientation(:, :, :) + REAL(wp), INTENT(IN), OPTIONAL :: angular_velocity(:, :), angular_acceleration(:, :) + REAL(wp), INTENT(IN), OPTIONAL :: twist + REAL(wp) :: dcm_a(3, 3), dcm_b(3, 3), w_a(3), al_a(3), w_b(3), al_b(3) + dcm_a = cable%parent_dcm + dcm_b = cable%parent_dcm_b + IF (PRESENT(orientation)) THEN + dcm_a = orientation(:, :, ca) + dcm_b = orientation(:, :, cb) + END IF + w_a = CD_ZERO + al_a = CD_ZERO + w_b = CD_ZERO + al_b = CD_ZERO + IF (PRESENT(angular_velocity) .AND. PRESENT(angular_acceleration)) THEN + w_a = angular_velocity(:, ca) + al_a = angular_acceleration(:, ca) + w_b = angular_velocity(:, cb) + al_b = angular_acceleration(:, cb) + END IF + SELECT CASE (mode) + CASE (CABLE_PREFLIGHT) + CALL CD_HFMF_PreflightCoupledKinematics(cable, position(:, ca), velocity(:, ca), acceleration(:, ca), & + es, em, dcm_a, w_a, al_a, position(:, cb), velocity(:, cb), & + acceleration(:, cb), dcm_b, w_b, al_b) + CASE (CABLE_SET) + CALL CD_HFMF_SetCoupledKinematics(cable, position(:, ca), velocity(:, ca), acceleration(:, ca), & + es, em, dcm_a, w_a, al_a, position(:, cb), velocity(:, cb), & + acceleration(:, cb), dcm_b, w_b, al_b) + CASE DEFAULT + CALL CD_HFMF_UpdateStates(cable, position(:, ca), velocity(:, ca), acceleration(:, ca), es, em, & + dcm_a, w_a, al_a, ub_pos=position(:, cb), ub_vel=velocity(:, cb), & + ub_acc=acceleration(:, cb), ub_orientation=dcm_b, ub_angular_velocity=w_b, & + ub_angular_acceleration=al_b, u_twist=twist) + END SELECT + END SUBROUTINE cable_two_ends + INTEGER FUNCTION fmf_nblocks(sys) RESULT(n) !! Coupled 3-DOF blocks of the EI=0 system (the full point-mesh width). TYPE(CD_FMF_ModuleType), INTENT(IN) :: sys @@ -2753,7 +2899,7 @@ SUBROUTINE set_host_objects(self, position, velocity, acceleration, ErrStat, Err at_start = .FALSE. IF (PRESENT(step_start)) at_start = step_start IF (self%nhost_body > 0) THEN - c0 = self%ncp_sys + self%ncable + self%nhost_rod + 1 + c0 = self%ncp_sys + self%ncable + self%ncable_b + self%nhost_rod + 1 c1 = ncp_all(self) IF (PRESENT(orientation)) THEN CALL CD_Rigid6_SetHostKinematics(self%rigid6, position(:, c0:c1), velocity(:, c0:c1), & @@ -2772,8 +2918,8 @@ SUBROUTINE set_host_objects(self, position, velocity, acceleration, ErrStat, Err END IF END IF IF (self%nhost_rod == 0) RETURN - c0 = self%ncp_sys + self%ncable + 1 - c1 = self%ncp_sys + self%ncable + self%nhost_rod + c0 = self%ncp_sys + self%ncable + self%ncable_b + 1 + c1 = self%ncp_sys + self%ncable + self%ncable_b + self%nhost_rod IF (PRESENT(orientation)) THEN IF (PRESENT(angular_velocity)) THEN CALL CD_Rod_SetHostKinematics(self%rod, position(:, c0:c1), velocity(:, c0:c1), acceleration(:, c0:c1), & diff --git a/src/CableDyn_OpenFAST_HermiteFMF.f90 b/src/CableDyn_OpenFAST_HermiteFMF.f90 index 52e57366..1038c1c0 100644 --- a/src/CableDyn_OpenFAST_HermiteFMF.f90 +++ b/src/CableDyn_OpenFAST_HermiteFMF.f90 @@ -83,6 +83,7 @@ MODULE CableDyn_OpenFAST_HermiteFMF PUBLIC :: CD_HFMF_PreflightCoupledKinematics PUBLIC :: CD_HFMF_SetCoupledKinematics PUBLIC :: CD_HFMF_GetCoupledKinematics + PUBLIC :: CD_HFMF_Set_Moving_End_B, CD_HFMF_GetEndBKinematics PUBLIC :: CD_HFMF_CalcOutput PUBLIC :: CD_HFMF_Curvature, CD_HFMF_Curvature_Exact PUBLIC :: CD_HFMF_Set_Section_Reference, CD_HFMF_Section_Curvature @@ -145,6 +146,29 @@ MODULE CableDyn_OpenFAST_HermiteFMF LOGICAL :: tors_parent = .FALSE. INTEGER :: tors_index = 0 REAL(wp) :: tors_frame_parent(3, 2) = CD_ZERO + ! A second host-driven end (CD_HFMF_Set_Moving_End_B): internal node 1 (deck End B), whose + ! three translations the host prescribes like the coupled node's -- a line between two moving + ! points (a cable shared by two floaters, a line between two bodies). Its parent frame, a + ! parent-attached end connection and a parent-attached torsion frame are the End B twins of + ! the coupled end's fields above (end index 1). A moving End B the host leaves exactly at rest + ! (its committed position, zero velocity and acceleration, from rest) is held as a Fixed End B + ! is, so a Fixed End B and a moving one that does not move march bit for bit alike. + LOGICAL :: moving_b = .FALSE. + INTEGER :: pdof_b(3) = 0 + LOGICAL :: has_parent_endconn_b = .FALSE. + REAL(wp) :: parent_endconn_d0_b(3) = CD_ZERO + REAL(wp) :: parent_dcm_b(3, 3) = RESHAPE([CD_ONE, CD_ZERO, CD_ZERO, & + CD_ZERO, CD_ONE, CD_ZERO, & + CD_ZERO, CD_ZERO, CD_ONE], [3, 3]) + REAL(wp) :: parent_omega_b(3) = CD_ZERO + REAL(wp) :: parent_alpha_b(3) = CD_ZERO + REAL(wp) :: snap_parent_dcm_b(3, 3) = RESHAPE([CD_ONE, CD_ZERO, CD_ZERO, & + CD_ZERO, CD_ONE, CD_ZERO, & + CD_ZERO, CD_ZERO, CD_ONE], [3, 3]) + REAL(wp) :: snap_parent_omega_b(3) = CD_ZERO + REAL(wp) :: snap_parent_alpha_b(3) = CD_ZERO + LOGICAL :: tors_parent_b = .FALSE. + REAL(wp) :: tors_frame_parent_b(3, 2) = CD_ZERO ! Deck node -> model node map of a line whose mesh the static solve refined: deck_node(J) is ! the public node (End A = 1) of the final mesh at the reference arc of deck node J (1 + the ! total NumSegs of the deck sections, End A first), 0 if no mesh node lies there. Unallocated @@ -256,6 +280,31 @@ SUBROUTINE fail(msg) END SUBROUTINE fail END SUBROUTINE CD_HFMF_Init + SUBROUTINE CD_HFMF_Set_Moving_End_B(self, ErrStat, ErrMsg) + !! Make internal node 1 (deck End B) a second host-driven end: UpdateStates, SetCoupledKinematics + !! and Preflight then take its kinematics (ub_*) beside the coupled node's, and the step + !! prescribes the six end translations. The coupled node must be the last node (deck End A) and + !! node 1's three translations must be held (in fixed_dofs), as Init requires of the coupled + !! node. Call it after Init and before an End B parent connection or torsion frame is set. + TYPE(CD_HFMF_ModuleType), INTENT(INOUT) :: self + INTEGER, INTENT(OUT) :: ErrStat + CHARACTER(*), INTENT(OUT) :: ErrMsg + ErrStat = CD_HFMF_BADINPUT + IF (.NOT. self%initialized) THEN + ErrMsg = 'CD_HFMF_Set_Moving_End_B: module not initialised'; RETURN + END IF + IF (self%coupled_node /= self%line%nn) THEN + ErrMsg = 'CD_HFMF_Set_Moving_End_B: the coupled node must be the last node (End A)'; RETURN + END IF + IF (ANY(self%line%freemask(1:3))) THEN + ErrMsg = 'CD_HFMF_Set_Moving_End_B: node 1''s three translational DOFs must be in fixed_dofs'; RETURN + END IF + self%moving_b = .TRUE. + self%pdof_b = [1, 2, 3] + ErrStat = CD_HFMF_OK + ErrMsg = '' + END SUBROUTINE CD_HFMF_Set_Moving_End_B + SUBROUTINE CD_HFMF_Set_Drag(self, rho_w, diam, cdn, cdt, waterline_z, current, ErrStat, ErrMsg, gravity) !! Pass-through to the model's Morison drag configuration (call between Init and the !! first UpdateStates). The configuration also sets the free surface above which the @@ -323,21 +372,25 @@ SUBROUTINE CD_HFMF_Set_Axial_Damping(self, BA, ErrStat, ErrMsg) END SUBROUTINE CD_HFMF_Set_Axial_Damping SUBROUTINE CD_HFMF_Set_EndConnection(self, k_rot, d0_global, ErrStat, ErrMsg, & - coupled_d0_parent, parent_orientation, connection_mode) + coupled_d0_parent, parent_orientation, connection_mode, & + end_b_d0_parent, end_b_parent_orientation) !! Install pinned, finite-stiffness, or exact rigid end connections. End order follows the internal !! anchor-to-fairlead model: column 1 is node 1 and column 2 is the final node. !! Preferred directions arrive in the caller's global frame and are rotated - !! into the cable solve frame here. + !! into the cable solve frame here. A moving End B (CD_HFMF_Set_Moving_End_B) may have its + !! direction given in its own parent's axes (end_b_d0_parent with end_b_parent_orientation, + !! the global-to-parent DCM at the static state): it then turns with End B's orientation. TYPE(CD_HFMF_ModuleType), INTENT(INOUT) :: self REAL(wp), INTENT(IN) :: k_rot(2), d0_global(3, 2) INTEGER, INTENT(OUT) :: ErrStat CHARACTER(*), INTENT(OUT) :: ErrMsg REAL(wp), INTENT(IN), OPTIONAL :: coupled_d0_parent(3), parent_orientation(3, 3) INTEGER, INTENT(IN), OPTIONAL :: connection_mode(2) + REAL(wp), INTENT(IN), OPTIONAL :: end_b_d0_parent(3), end_b_parent_orientation(3, 3) INTEGER :: es, iend, coupled_iend, mode_eff(2) LOGICAL :: endpoint_connected REAL(wp) :: d0_local(3, 2) - REAL(wp) :: parent_d0(3), parent_d0_norm, dcm(3, 3) + REAL(wp) :: parent_d0(3), parent_d0_norm, dcm(3, 3), parent_d0_b(3), dcm_b(3, 3) CHARACTER(1024) :: em ErrStat = CD_HFMF_OK @@ -394,12 +447,41 @@ SUBROUTINE CD_HFMF_Set_EndConnection(self, k_rot, d0_global, ErrStat, ErrMsg, & dcm = parent_orientation parent_d0 = coupled_d0_parent/parent_d0_norm END IF + IF (PRESENT(end_b_d0_parent) .NEQV. PRESENT(end_b_parent_orientation)) THEN + ErrStat = CD_HFMF_BADINPUT + ErrMsg = 'CD_HFMF_Set_EndConnection: end_b_d0_parent and end_b_parent_orientation must be supplied together' + RETURN + END IF + dcm_b = identity_dcm() + parent_d0_b = CD_ZERO + IF (PRESENT(end_b_d0_parent)) THEN + IF (.NOT. self%moving_b .OR. mode_eff(1) == CD_ENDCONN_PINNED) THEN + ErrStat = CD_HFMF_BADINPUT + ErrMsg = 'CD_HFMF_Set_EndConnection: an End B parent-relative direction requires a moving, connected End B' + RETURN + END IF + IF (.NOT. valid_parent_dcm(end_b_parent_orientation)) THEN + ErrStat = CD_HFMF_BADINPUT + ErrMsg = 'CD_HFMF_Set_EndConnection: end_b_parent_orientation must be a finite proper orthogonal DCM' + RETURN + END IF + parent_d0_norm = SQRT(DOT_PRODUCT(end_b_d0_parent, end_b_d0_parent)) + IF (.NOT. CD_All_Finite(end_b_d0_parent) .OR. .NOT. CD_Is_Finite(parent_d0_norm) .OR. & + parent_d0_norm <= SQRT(TINY(CD_ONE))) THEN + ErrStat = CD_HFMF_BADINPUT + ErrMsg = 'CD_HFMF_Set_EndConnection: the End B parent direction must be finite and non-null' + RETURN + END IF + dcm_b = end_b_parent_orientation + parent_d0_b = end_b_d0_parent/parent_d0_norm + END IF DO iend = 1, 2 d0_local(:, iend) = frame_to_local(self, d0_global(:, iend)) END DO IF (PRESENT(coupled_d0_parent)) THEN d0_local(:, coupled_iend) = frame_to_local(self, MATMUL(TRANSPOSE(dcm), parent_d0)) END IF + IF (PRESENT(end_b_d0_parent)) d0_local(:, 1) = frame_to_local(self, MATMUL(TRANSPOSE(dcm_b), parent_d0_b)) CALL CD_HermiteCable_Dyn_Set_EndConnection(self%line, k_rot, d0_local, es, em, & connection_mode=mode_eff) IF (es /= CD_HCDYN_OK) THEN @@ -422,9 +504,18 @@ SUBROUTINE CD_HFMF_Set_EndConnection(self, k_rot, d0_global, ErrStat, ErrMsg, & self%parent_dcm = dcm self%snap_parent_dcm = dcm END IF + self%has_parent_endconn_b = PRESENT(end_b_d0_parent) + self%parent_endconn_d0_b = parent_d0_b + self%parent_dcm_b = dcm_b + self%parent_omega_b = CD_ZERO + self%parent_alpha_b = CD_ZERO + self%snap_parent_dcm_b = dcm_b + self%snap_parent_omega_b = CD_ZERO + self%snap_parent_alpha_b = CD_ZERO END SUBROUTINE CD_HFMF_Set_EndConnection - SUBROUTINE CD_HFMF_Set_Torsion(self, torsion, ErrStat, ErrMsg, coupled_frame_parent, parent_orientation) + SUBROUTINE CD_HFMF_Set_Torsion(self, torsion, ErrStat, ErrMsg, coupled_frame_parent, parent_orientation, & + end_b_frame_parent, end_b_parent_orientation) !! Install the condensed torsion of the cable's converged static solve (end frames and GJ in !! the cable solve frame; see CD_HermiteCable_Dyn_Set_Torsion). CalcOutput then returns the !! end force and connection moment with the torque, and UpdateStates carries the torsion. @@ -433,11 +524,14 @@ SUBROUTINE CD_HFMF_Set_Torsion(self, torsion, ErrStat, ErrMsg, coupled_frame_par !! frame was taken) attach that frame to the parent: UpdateStates then turns it with !! u_orientation, for any bending connection (also a pinned one). The parent orientation must !! agree with that of a parent-relative end connection, and the frame with the static one. + !! end_b_frame_parent with end_b_parent_orientation attach a moving End B's torsion frame (end 1) + !! to its own parent in the same way: both end frames then turn with their parents. TYPE(CD_HFMF_ModuleType), INTENT(INOUT) :: self TYPE(CD_HermiteTorsionType), INTENT(IN) :: torsion INTEGER, INTENT(OUT) :: ErrStat CHARACTER(*), INTENT(OUT) :: ErrMsg REAL(wp), INTENT(IN), OPTIONAL :: coupled_frame_parent(3, 2), parent_orientation(3, 3) + REAL(wp), INTENT(IN), OPTIONAL :: end_b_frame_parent(3, 2), end_b_parent_orientation(3, 3) INTEGER :: es, ci REAL(wp) :: dl(3), nl(3) CHARACTER(1024) :: em @@ -488,6 +582,42 @@ SUBROUTINE CD_HFMF_Set_Torsion(self, torsion, ErrStat, ErrMsg, coupled_frame_par RETURN END IF END IF + IF (PRESENT(end_b_frame_parent) .NEQV. PRESENT(end_b_parent_orientation)) THEN + ErrMsg = 'CD_HFMF_Set_Torsion: end_b_frame_parent and end_b_parent_orientation must be supplied together' + RETURN + END IF + IF (PRESENT(end_b_frame_parent) .AND. torsion%active) THEN + IF (.NOT. self%moving_b) THEN + ErrMsg = 'CD_HFMF_Set_Torsion: an End B parent torsion frame needs a moving End B' + RETURN + END IF + IF (.NOT. valid_parent_dcm(end_b_parent_orientation)) THEN + ErrMsg = 'CD_HFMF_Set_Torsion: end_b_parent_orientation must be a finite proper orthogonal DCM' + RETURN + END IF + IF (.NOT. CD_All_Finite(RESHAPE(end_b_frame_parent, [6]))) THEN + ErrMsg = 'CD_HFMF_Set_Torsion: the End B parent torsion frame must be finite' + RETURN + END IF + IF (ABS(NORM2(end_b_frame_parent(:, 1)) - CD_ONE) > 1.0e-8_wp .OR. & + ABS(NORM2(end_b_frame_parent(:, 2)) - CD_ONE) > 1.0e-8_wp .OR. & + ABS(DOT_PRODUCT(end_b_frame_parent(:, 1), end_b_frame_parent(:, 2))) > 1.0e-8_wp) THEN + ErrMsg = 'CD_HFMF_Set_Torsion: the End B parent torsion frame must be orthonormal' + RETURN + END IF + IF (self%has_parent_endconn_b) THEN + IF (MAXVAL(ABS(end_b_parent_orientation - self%parent_dcm_b)) > 1.0e-10_wp) THEN + ErrMsg = 'CD_HFMF_Set_Torsion: end_b_parent_orientation differs from the End B connection''s' + RETURN + END IF + END IF + dl = frame_to_local(self, MATMUL(TRANSPOSE(end_b_parent_orientation), end_b_frame_parent(:, 1))) + nl = frame_to_local(self, MATMUL(TRANSPOSE(end_b_parent_orientation), end_b_frame_parent(:, 2))) + IF (NORM2(dl - torsion%ends(:, 1)) > 1.0e-8_wp .OR. NORM2(nl - torsion%ends(:, 2)) > 1.0e-8_wp) THEN + ErrMsg = 'CD_HFMF_Set_Torsion: the End B parent torsion frame differs from the static end frame' + RETURN + END IF + END IF CALL CD_HermiteCable_Dyn_Set_Torsion(self%line, torsion, es, em) IF (es /= CD_HCDYN_OK) THEN ErrMsg = 'CD_HFMF_Set_Torsion: '//TRIM(em) @@ -511,6 +641,20 @@ SUBROUTINE CD_HFMF_Set_Torsion(self, torsion, ErrStat, ErrMsg, coupled_frame_par self%snap_parent_alpha = CD_ZERO END IF END IF + self%tors_parent_b = .FALSE. + self%tors_frame_parent_b = CD_ZERO + IF (PRESENT(end_b_frame_parent) .AND. torsion%active) THEN + self%tors_parent_b = .TRUE. + self%tors_frame_parent_b = end_b_frame_parent + IF (.NOT. self%has_parent_endconn_b) THEN + self%parent_dcm_b = end_b_parent_orientation + self%snap_parent_dcm_b = end_b_parent_orientation + self%parent_omega_b = CD_ZERO + self%parent_alpha_b = CD_ZERO + self%snap_parent_omega_b = CD_ZERO + self%snap_parent_alpha_b = CD_ZERO + END IF + END IF END SUBROUTINE CD_HFMF_Set_Torsion SUBROUTINE CD_HFMF_Set_ModifiedNewton(self, enabled, ErrStat, ErrMsg) @@ -664,11 +808,16 @@ SUBROUTINE CD_HFMF_Set_Waves(self, height, period, direction_deg, depth, gravity END SUBROUTINE CD_HFMF_Set_Waves SUBROUTINE CD_HFMF_UpdateStates(self, u_pos, u_vel, u_acc, ErrStat, ErrMsg, u_orientation, & - u_angular_velocity, u_angular_acceleration, u_twist) + u_angular_velocity, u_angular_acceleration, u_twist, ub_pos, ub_vel, ub_acc, & + ub_orientation, ub_angular_velocity, ub_angular_acceleration) !! Advance the cable one coupling step of dt with the coupled endpoint's kinematics !! at t_{n+1} prescribed to (u_pos, u_vel, u_acc) -- the FMF kinematics-in boundary. !! With condensed torsion, a parent-attached torsion frame (CD_HFMF_Set_Torsion) turns with !! the orientation, and u_twist [rad] sets the imposed twist Phi at t_{n+1} (held otherwise). + !! A moving End B (CD_HFMF_Set_Moving_End_B) takes its own kinematics at t_{n+1}: ub_pos, ub_vel, + !! ub_acc (required on such a cable, refused on any other) and, for an End B parent connection + !! or torsion frame, its parent orientation and rates ub_orientation, ub_angular_*; the step then + !! prescribes both ends' translations. TYPE(CD_HFMF_ModuleType), INTENT(INOUT) :: self REAL(wp), INTENT(IN) :: u_pos(3), u_vel(3), u_acc(3) INTEGER, INTENT(OUT) :: ErrStat @@ -676,10 +825,17 @@ SUBROUTINE CD_HFMF_UpdateStates(self, u_pos, u_vel, u_acc, ErrStat, ErrMsg, u_or REAL(wp), INTENT(IN), OPTIONAL :: u_orientation(3, 3) REAL(wp), INTENT(IN), OPTIONAL :: u_angular_velocity(3), u_angular_acceleration(3) REAL(wp), INTENT(IN), OPTIONAL :: u_twist + REAL(wp), INTENT(IN), OPTIONAL :: ub_pos(3), ub_vel(3), ub_acc(3), ub_orientation(3, 3) + REAL(wp), INTENT(IN), OPTIONAL :: ub_angular_velocity(3), ub_angular_acceleration(3) INTEGER :: es REAL(wp) :: tors_ends(3, 4), tors_phi REAL(wp) :: target_dcm(3, 3), target_d0(3, 2), target_omega(3), target_alpha(3) REAL(wp) :: target_d0_rate(3, 2), target_d0_acceleration(3, 2), omega_local(3), alpha_local(3) + REAL(wp) :: target_dcm_b(3, 3), target_omega_b(3), target_alpha_b(3) + ! both ends' prescribed translations (End A's, then End B's), fixed size: no allocation per step + INTEGER :: pd(6) + REAL(wp) :: pq(6), pv(6), pa(6) + LOGICAL :: drive_b CHARACTER(1024) :: em ErrStat = CD_HFMF_OK; ErrMsg = '' IF (.NOT. self%initialized) THEN @@ -715,6 +871,11 @@ SUBROUTINE CD_HFMF_UpdateStates(self, u_pos, u_vel, u_acc, ErrStat, ErrMsg, u_or END IF target_dcm = u_orientation END IF + CALL end_b_inputs(self, target_dcm_b, target_omega_b, target_alpha_b, ErrStat, em, ub_pos, ub_vel, ub_acc, & + ub_orientation, ub_angular_velocity, ub_angular_acceleration) + IF (ErrStat /= CD_HFMF_OK) THEN + ErrMsg = 'CD_HFMF_UpdateStates: '//TRIM(em); RETURN + END IF target_d0 = self%line%endconn_d0 target_d0_rate = CD_ZERO target_d0_acceleration = CD_ZERO @@ -731,6 +892,17 @@ SUBROUTINE CD_HFMF_UpdateStates(self, u_pos, u_vel, u_acc, ErrStat, ErrMsg, u_or cross3(omega_local, target_d0_rate(:, self%parent_endconn_index)) END IF END IF + ! End B's connection turns with End B's parent: d = G_B^T d_parent, with the rigid end's + ! direction rate w x d and acceleration al x d + w x (w x d), as End A's above + IF (self%has_parent_endconn_b) THEN + target_d0(:, 1) = frame_to_local(self, MATMUL(TRANSPOSE(target_dcm_b), self%parent_endconn_d0_b)) + IF (self%line%endconn_mode(1) == CD_ENDCONN_RIGID) THEN + omega_local = frame_to_local(self, target_omega_b) + alpha_local = frame_to_local(self, target_alpha_b) + target_d0_rate(:, 1) = cross3(omega_local, target_d0(:, 1)) + target_d0_acceleration(:, 1) = cross3(alpha_local, target_d0(:, 1)) + cross3(omega_local, target_d0_rate(:, 1)) + END IF + END IF IF (PRESENT(u_twist) .AND. .NOT. self%line%torsion%active) THEN ErrStat = CD_HFMF_BADINPUT ErrMsg = 'CD_HFMF_UpdateStates: u_twist needs a cable with torsion' @@ -746,6 +918,10 @@ SUBROUTINE CD_HFMF_UpdateStates(self, u_pos, u_vel, u_acc, ErrStat, ErrMsg, u_or tors_ends(:, 2*self%tors_index) = frame_to_local(self, MATMUL(TRANSPOSE(target_dcm), & self%tors_frame_parent(:, 2))) END IF + IF (self%tors_parent_b) THEN + tors_ends(:, 1) = frame_to_local(self, MATMUL(TRANSPOSE(target_dcm_b), self%tors_frame_parent_b(:, 1))) + tors_ends(:, 2) = frame_to_local(self, MATMUL(TRANSPOSE(target_dcm_b), self%tors_frame_parent_b(:, 2))) + END IF tors_phi = self%line%torsion%phi IF (PRESENT(u_twist)) tors_phi = u_twist CALL CD_HermiteCable_Dyn_Set_Torsion_Drive(self%line, tors_ends, tors_phi, es, em) @@ -755,8 +931,32 @@ SUBROUTINE CD_HFMF_UpdateStates(self, u_pos, u_vel, u_acc, ErrStat, ErrMsg, u_or END IF ! Advance the finite-EI line over the prescribed interval. Internal substeps are used when the ! nominal interval is too large for the boundary-motion or environmental-load increment, while - ! preserving the requested endpoint time. - IF (self%has_parent_endconn) THEN + ! preserving the requested endpoint time. A moving End B that stays exactly at rest is held (a + ! held DOF and one prescribed to (q_n, 0, 0) are the same boundary). + drive_b = .FALSE. + IF (self%moving_b) drive_b = .NOT. end_b_held(self, ub_pos, ub_vel, ub_acc) + IF (drive_b) THEN + pd(1:3) = self%pdof + pd(4:6) = self%pdof_b + pq(1:3) = frame_to_local(self, u_pos) + pq(4:6) = frame_to_local(self, ub_pos) + pv(1:3) = frame_to_local(self, u_vel) + pv(4:6) = frame_to_local(self, ub_vel) + pa(1:3) = frame_to_local(self, u_acc) + pa(4:6) = frame_to_local(self, ub_acc) + IF (self%has_parent_endconn .OR. self%has_parent_endconn_b) THEN + CALL CD_HermiteCable_Dyn_Step_Recovering(self%line, self%dt, self%max_iter, self%tol, es, em, & + pres_dofs=pd, pres_q=pq, pres_v=pv, pres_a=pa, & + max_substeps=self%recovery_max_substeps, & + endconn_direction=target_d0, & + endconn_direction_rate=target_d0_rate, & + endconn_direction_acceleration=target_d0_acceleration) + ELSE + CALL CD_HermiteCable_Dyn_Step_Recovering(self%line, self%dt, self%max_iter, self%tol, es, em, & + pres_dofs=pd, pres_q=pq, pres_v=pv, pres_a=pa, & + max_substeps=self%recovery_max_substeps) + END IF + ELSE IF (self%has_parent_endconn .OR. self%has_parent_endconn_b) THEN CALL CD_HermiteCable_Dyn_Step_Recovering(self%line, self%dt, self%max_iter, self%tol, es, em, & pres_dofs=self%pdof, pres_q=frame_to_local(self, u_pos), & pres_v=frame_to_local(self, u_vel), pres_a=frame_to_local(self, u_acc), & @@ -772,13 +972,102 @@ SUBROUTINE CD_HFMF_UpdateStates(self, u_pos, u_vel, u_acc, ErrStat, ErrMsg, u_or END IF IF (es /= CD_HCDYN_OK) THEN ErrStat = CD_HFMF_SOLVEFAIL; ErrMsg = 'CD_HFMF_UpdateStates: '//TRIM(em) - ELSE IF (self%has_parent_endconn .OR. self%tors_parent) THEN - self%parent_dcm = target_dcm - self%parent_omega = target_omega - self%parent_alpha = target_alpha + ELSE + IF (self%has_parent_endconn .OR. self%tors_parent) THEN + self%parent_dcm = target_dcm + self%parent_omega = target_omega + self%parent_alpha = target_alpha + END IF + IF (self%has_parent_endconn_b .OR. self%tors_parent_b) THEN + self%parent_dcm_b = target_dcm_b + self%parent_omega_b = target_omega_b + self%parent_alpha_b = target_alpha_b + END IF END IF END SUBROUTINE CD_HFMF_UpdateStates + SUBROUTINE end_b_inputs(self, dcm_b, omega_b, alpha_b, ErrStat, ErrMsg, ub_pos, ub_vel, ub_acc, & + ub_orientation, ub_angular_velocity, ub_angular_acceleration) + !! Validate the End B kinematics of an update (UpdateStates, SetCoupledKinematics, Preflight): + !! required (translations) on a cable with a moving End B, refused on any other; returns End B's + !! target parent orientation and rates (the committed orientation and zero rates when absent). + TYPE(CD_HFMF_ModuleType), INTENT(IN) :: self + REAL(wp), INTENT(OUT) :: dcm_b(3, 3), omega_b(3), alpha_b(3) + INTEGER, INTENT(OUT) :: ErrStat + CHARACTER(*), INTENT(OUT) :: ErrMsg + REAL(wp), INTENT(IN), OPTIONAL :: ub_pos(3), ub_vel(3), ub_acc(3), ub_orientation(3, 3) + REAL(wp), INTENT(IN), OPTIONAL :: ub_angular_velocity(3), ub_angular_acceleration(3) + ErrStat = CD_HFMF_OK + ErrMsg = '' + dcm_b = self%parent_dcm_b + omega_b = CD_ZERO + alpha_b = CD_ZERO + IF (.NOT. self%moving_b) THEN + IF (PRESENT(ub_pos) .OR. PRESENT(ub_vel) .OR. PRESENT(ub_acc) .OR. PRESENT(ub_orientation) .OR. & + PRESENT(ub_angular_velocity) .OR. PRESENT(ub_angular_acceleration)) THEN + ErrStat = CD_HFMF_BADINPUT + ErrMsg = 'End B kinematics need a moving End B (CD_HFMF_Set_Moving_End_B)' + END IF + RETURN + END IF + ErrStat = CD_HFMF_BADINPUT + IF (.NOT. (PRESENT(ub_pos) .AND. PRESENT(ub_vel) .AND. PRESENT(ub_acc))) THEN + ErrMsg = 'a moving End B needs its position, velocity and acceleration (ub_pos, ub_vel, ub_acc)' + RETURN + END IF + IF (.NOT. (CD_All_Finite(ub_pos) .AND. CD_All_Finite(ub_vel) .AND. CD_All_Finite(ub_acc))) THEN + ErrMsg = 'End B inputs must be finite' + RETURN + END IF + IF (PRESENT(ub_angular_velocity) .NEQV. PRESENT(ub_angular_acceleration)) THEN + ErrMsg = 'End B angular velocity and acceleration must be supplied together' + RETURN + END IF + IF (PRESENT(ub_angular_velocity)) THEN + IF (.NOT. (CD_All_Finite(ub_angular_velocity) .AND. CD_All_Finite(ub_angular_acceleration))) THEN + ErrMsg = 'End B angular kinematics must be finite' + RETURN + END IF + omega_b = ub_angular_velocity + alpha_b = ub_angular_acceleration + END IF + IF (PRESENT(ub_orientation)) THEN + IF (.NOT. valid_parent_dcm(ub_orientation)) THEN + ErrMsg = 'End B orientation must be a finite proper orthogonal DCM' + RETURN + END IF + dcm_b = ub_orientation + END IF + ErrStat = CD_HFMF_OK + END SUBROUTINE end_b_inputs + + PURE LOGICAL FUNCTION end_b_at_rest(self) RESULT(at_rest) + !! The committed End B is at rest: zero velocity and acceleration of its translations. An End B + !! that is not driven (moving_b false, pdof_b unset) is at rest; Fortran does not short-circuit + !! a caller's moving_b .AND. ..., so the test must not index pdof_b then. + TYPE(CD_HFMF_ModuleType), INTENT(IN) :: self + at_rest = .TRUE. + IF (.NOT. self%moving_b) RETURN + at_rest = .NOT. (ANY(ABS(self%line%v(self%pdof_b)) > CD_ZERO) .OR. ANY(ABS(self%line%a(self%pdof_b)) > CD_ZERO)) + END FUNCTION end_b_at_rest + + PURE LOGICAL FUNCTION end_b_held(self, ub_pos, ub_vel, ub_acc) RESULT(held) + !! End B stays exactly at rest over the step: committed at rest, and the target is its committed + !! position with zero velocity and acceleration (bit for bit), the boundary a Fixed End B holds. + !! The position is the committed one in either frame: the solve frame (a target rotated in, as a + !! motion row is) or the caller's global frame (a target read back by CD_HFMF_GetEndBKinematics, + !! which a rotation round trip at a non-zero chord heading need not return bit for bit). + TYPE(CD_HFMF_ModuleType), INTENT(IN) :: self + REAL(wp), INTENT(IN) :: ub_pos(3), ub_vel(3), ub_acc(3) + held = end_b_at_rest(self) + IF (.NOT. held) RETURN + held = .NOT. (ANY(ABS(ub_vel) > CD_ZERO) .OR. ANY(ABS(ub_acc) > CD_ZERO)) + IF (.NOT. held) RETURN + held = .NOT. ANY(ABS(frame_to_local(self, ub_pos) - self%line%q(self%pdof_b)) > CD_ZERO) + IF (held) RETURN + held = .NOT. ANY(ABS(ub_pos - frame_to_global(self, self%line%q(self%pdof_b))) > CD_ZERO) + END FUNCTION end_b_held + SUBROUTINE CD_HFMF_Snapshot(self, ErrStat, ErrMsg) !! Capture the cable's committed step state (q, v, a, t) for the aggregate !! stage-then-commit contract (delegates to CD_HermiteCable_Dyn_Snapshot). @@ -798,6 +1087,9 @@ SUBROUTINE CD_HFMF_Snapshot(self, ErrStat, ErrMsg) self%snap_parent_dcm = self%parent_dcm self%snap_parent_omega = self%parent_omega self%snap_parent_alpha = self%parent_alpha + self%snap_parent_dcm_b = self%parent_dcm_b + self%snap_parent_omega_b = self%parent_omega_b + self%snap_parent_alpha_b = self%parent_alpha_b END IF END SUBROUTINE CD_HFMF_Snapshot @@ -820,41 +1112,52 @@ SUBROUTINE CD_HFMF_Restore(self, ErrStat, ErrMsg) self%parent_dcm = self%snap_parent_dcm self%parent_omega = self%snap_parent_omega self%parent_alpha = self%snap_parent_alpha + self%parent_dcm_b = self%snap_parent_dcm_b + self%parent_omega_b = self%snap_parent_omega_b + self%parent_alpha_b = self%snap_parent_alpha_b END IF END SUBROUTINE CD_HFMF_Restore SUBROUTINE CD_HFMF_PreflightCoupledKinematics(self, u_pos, u_vel, u_acc, ErrStat, ErrMsg, u_orientation, & - u_angular_velocity, u_angular_acceleration) + u_angular_velocity, u_angular_acceleration, ub_pos, ub_vel, ub_acc, & + ub_orientation, ub_angular_velocity, ub_angular_acceleration) !! Validate every deterministic failure condition in SetCoupledKinematics without !! changing the cable. Aggregate callers use this before updating any sibling !! subsystem, so a bad later cable column cannot leave an earlier column mutated. + !! A moving End B's kinematics (ub_*) are checked with the coupled end's. TYPE(CD_HFMF_ModuleType), INTENT(IN) :: self REAL(wp), INTENT(IN) :: u_pos(3), u_vel(3), u_acc(3) INTEGER, INTENT(OUT) :: ErrStat CHARACTER(*), INTENT(OUT) :: ErrMsg REAL(wp), INTENT(IN), OPTIONAL :: u_orientation(3, 3) REAL(wp), INTENT(IN), OPTIONAL :: u_angular_velocity(3), u_angular_acceleration(3) + REAL(wp), INTENT(IN), OPTIONAL :: ub_pos(3), ub_vel(3), ub_acc(3), ub_orientation(3, 3) + REAL(wp), INTENT(IN), OPTIONAL :: ub_angular_velocity(3), ub_angular_acceleration(3) REAL(wp) :: target_dcm(3, 3), d0_target(3, 2), tangent_q(3), tangent_v(3), tangent_a(3) REAL(wp) :: target_omega(3), target_alpha(3) + REAL(wp) :: target_dcm_b(3, 3), target_omega_b(3), target_alpha_b(3), tangent_b(3, 3) CHARACTER(1024) :: em CALL prepare_coupled_kinematics(self, u_pos, u_vel, u_acc, target_dcm, target_omega, target_alpha, & d0_target, tangent_q, tangent_v, tangent_a, ErrStat, em, & - u_orientation, u_angular_velocity, u_angular_acceleration) + target_dcm_b, target_omega_b, target_alpha_b, tangent_b, & + u_orientation, u_angular_velocity, u_angular_acceleration, & + ub_pos, ub_vel, ub_acc, ub_orientation, ub_angular_velocity, & + ub_angular_acceleration) IF (ErrStat /= CD_HFMF_OK) THEN ErrMsg = 'CD_HFMF_PreflightCoupledKinematics: '//TRIM(em) RETURN END IF ErrMsg = '' - IF (self%tors_parent) THEN - ! the parent-attached torsion frame at the written state: the same acceptance as the + IF (self%tors_parent .OR. self%tors_parent_b) THEN + ! the parent-attached torsion frames at the written state: the same acceptance as the ! frame update of SetCoupledKinematics (fold guard, twist change within pi/2) BLOCK REAL(wp), ALLOCATABLE :: qc(:), g(:) REAL(wp) :: ends(3, 4), raw, th INTEGER :: ks, k CHARACTER(1024) :: km - ends = coupled_torsion_ends(self, target_dcm) + ends = coupled_torsion_ends(self, target_dcm, target_dcm_b) DO k = 1, 3, 2 IF (ABS(NORM2(ends(:, k)) - CD_ONE) > 1.0e-8_wp .OR. ABS(NORM2(ends(:, k + 1)) - CD_ONE) > 1.0e-8_wp & .OR. ABS(DOT_PRODUCT(ends(:, k), ends(:, k + 1))) > 1.0e-8_wp) THEN @@ -864,7 +1167,7 @@ SUBROUTINE CD_HFMF_PreflightCoupledKinematics(self, u_pos, u_vel, u_acc, ErrStat END IF END DO ALLOCATE (qc(SIZE(self%line%q)), g(SIZE(self%line%q))) - CALL coupled_candidate_q(self, u_pos, tangent_q, qc) + CALL coupled_candidate_q(self, u_pos, tangent_q, qc, ub_pos, tangent_b(:, 1)) IF (self%line%tw_active) THEN ! the nodal twist: its own acceptance of the written state (CD_HermiteCable_Dyn_Twist_Check) CALL CD_HermiteCable_Dyn_Twist_Check(self%line, qc, ends, ks, km) @@ -892,23 +1195,34 @@ SUBROUTINE CD_HFMF_PreflightCoupledKinematics(self, u_pos, u_vel, u_acc, ErrStat END IF END SUBROUTINE CD_HFMF_PreflightCoupledKinematics - FUNCTION coupled_torsion_ends(self, target_dcm) RESULT(ends) - !! The torsion end frames with the parent-attached end turned to target_dcm (solve frame). + FUNCTION coupled_torsion_ends(self, target_dcm, target_dcm_b) RESULT(ends) + !! The torsion end frames with the parent-attached ends turned to target_dcm (the coupled end) + !! and target_dcm_b (a moving End B), in the solve frame. TYPE(CD_HFMF_ModuleType), INTENT(IN) :: self REAL(wp), INTENT(IN) :: target_dcm(3, 3) + REAL(wp), INTENT(IN), OPTIONAL :: target_dcm_b(3, 3) REAL(wp) :: ends(3, 4) ends = self%line%torsion%ends - ends(:, 2*self%tors_index - 1) = frame_to_local(self, MATMUL(TRANSPOSE(target_dcm), self%tors_frame_parent(:, 1))) - ends(:, 2*self%tors_index) = frame_to_local(self, MATMUL(TRANSPOSE(target_dcm), self%tors_frame_parent(:, 2))) + IF (self%tors_parent) THEN + ends(:, 2*self%tors_index - 1) = frame_to_local(self, MATMUL(TRANSPOSE(target_dcm), & + self%tors_frame_parent(:, 1))) + ends(:, 2*self%tors_index) = frame_to_local(self, MATMUL(TRANSPOSE(target_dcm), self%tors_frame_parent(:, 2))) + END IF + IF (self%tors_parent_b .AND. PRESENT(target_dcm_b)) THEN + ends(:, 1) = frame_to_local(self, MATMUL(TRANSPOSE(target_dcm_b), self%tors_frame_parent_b(:, 1))) + ends(:, 2) = frame_to_local(self, MATMUL(TRANSPOSE(target_dcm_b), self%tors_frame_parent_b(:, 2))) + END IF END FUNCTION coupled_torsion_ends - SUBROUTINE coupled_candidate_q(self, u_pos, tangent_q, qc) + SUBROUTINE coupled_candidate_q(self, u_pos, tangent_q, qc, ub_pos, tangent_q_b) !! The configuration SetCoupledKinematics writes: the committed q with the coupled node's !! translation and, for a rigid parent connection, its transported tangent (built the same - !! way, in place, by SetCoupledKinematics). qc must not be part of self. + !! way, in place, by SetCoupledKinematics), and the same for a moving End B (ub_pos, tangent_q_b). + !! qc must not be part of self. TYPE(CD_HFMF_ModuleType), INTENT(IN) :: self REAL(wp), INTENT(IN) :: u_pos(3), tangent_q(3) REAL(wp), INTENT(OUT) :: qc(:) + REAL(wp), INTENT(IN), OPTIONAL :: ub_pos(3), tangent_q_b(3) INTEGER :: base, i DO i = 1, SIZE(qc) qc(i) = self%line%q(i) @@ -919,11 +1233,16 @@ SUBROUTINE coupled_candidate_q(self, u_pos, tangent_q, qc) qc(base + 1:base + 3) = tangent_q END IF END IF + IF (self%has_parent_endconn_b .AND. PRESENT(tangent_q_b)) THEN + IF (self%line%endconn_mode(1) == CD_ENDCONN_RIGID) qc(4:6) = tangent_q_b + END IF qc(self%pdof) = frame_to_local(self, u_pos) + IF (self%moving_b .AND. PRESENT(ub_pos)) qc(self%pdof_b) = frame_to_local(self, ub_pos) END SUBROUTINE coupled_candidate_q SUBROUTINE CD_HFMF_SetCoupledKinematics(self, u_pos, u_vel, u_acc, ErrStat, ErrMsg, u_orientation, & - u_angular_velocity, u_angular_acceleration) + u_angular_velocity, u_angular_acceleration, ub_pos, ub_vel, ub_acc, & + ub_orientation, ub_angular_velocity, ub_angular_acceleration) !! Direct-feedthrough transfer: write ONLY the coupled node's three translational (r, v, a) !! DOFs into the line state, WITHOUT stepping the interior or advancing simulation time. Used !! between an UpdateStates_Moving (the host moves the fairlead) and the following CalcOutput so @@ -931,30 +1250,37 @@ SUBROUTINE CD_HFMF_SetCoupledKinematics(self, u_pos, u_vel, u_acc, ErrStat, ErrM !! (the last committed step's shape) -- the instantaneous feedthrough load, rather than the load !! at the last committed fairlead. It does not re-solve, does not touch the interior DOFs, and !! does not advance self%line%t; the next CD_HFMF_UpdateStates re-prescribes the boundary and - !! performs the actual implicit advance. + !! performs the actual implicit advance. A moving End B (ub_*, required on such a cable) is + !! written in the same way. TYPE(CD_HFMF_ModuleType), INTENT(INOUT) :: self REAL(wp), INTENT(IN) :: u_pos(3), u_vel(3), u_acc(3) INTEGER, INTENT(OUT) :: ErrStat CHARACTER(*), INTENT(OUT) :: ErrMsg REAL(wp), INTENT(IN), OPTIONAL :: u_orientation(3, 3) REAL(wp), INTENT(IN), OPTIONAL :: u_angular_velocity(3), u_angular_acceleration(3) + REAL(wp), INTENT(IN), OPTIONAL :: ub_pos(3), ub_vel(3), ub_acc(3), ub_orientation(3, 3) + REAL(wp), INTENT(IN), OPTIONAL :: ub_angular_velocity(3), ub_angular_acceleration(3) REAL(wp) :: target_dcm(3, 3), d0_target(3, 2) REAL(wp) :: tangent_q(3), tangent_v(3), tangent_a(3) REAL(wp) :: target_omega(3), target_alpha(3), tors_ends(3, 4) + REAL(wp) :: target_dcm_b(3, 3), target_omega_b(3), target_alpha_b(3), tangent_b(3, 3) INTEGER :: base, es CHARACTER(1024) :: em CALL prepare_coupled_kinematics(self, u_pos, u_vel, u_acc, target_dcm, target_omega, target_alpha, & d0_target, tangent_q, tangent_v, tangent_a, ErrStat, em, & - u_orientation, u_angular_velocity, u_angular_acceleration) + target_dcm_b, target_omega_b, target_alpha_b, tangent_b, & + u_orientation, u_angular_velocity, u_angular_acceleration, & + ub_pos, ub_vel, ub_acc, ub_orientation, ub_angular_velocity, & + ub_angular_acceleration) IF (ErrStat /= CD_HFMF_OK) THEN ErrMsg = 'CD_HFMF_SetCoupledKinematics: '//TRIM(em) RETURN END IF ! A parent-attached torsion frame is checked at the state about to be written before ! anything is written (the update is all or nothing) - IF (self%tors_parent) THEN - tors_ends = coupled_torsion_ends(self, target_dcm) + IF (self%tors_parent .OR. self%tors_parent_b) THEN + tors_ends = coupled_torsion_ends(self, target_dcm, target_dcm_b) ! the candidate configuration in the line's trial scratch (as coupled_candidate_q builds it) DO base = 1, SIZE(self%line%q) self%line%ws_qtrial(base) = self%line%q(base) @@ -965,7 +1291,11 @@ SUBROUTINE CD_HFMF_SetCoupledKinematics(self, u_pos, u_vel, u_acc, ErrStat, ErrM self%line%ws_qtrial(base + 1:base + 3) = tangent_q END IF END IF + IF (self%has_parent_endconn_b) THEN + IF (self%line%endconn_mode(1) == CD_ENDCONN_RIGID) self%line%ws_qtrial(4:6) = tangent_b(:, 1) + END IF self%line%ws_qtrial(self%pdof) = frame_to_local(self, u_pos) + IF (self%moving_b) self%line%ws_qtrial(self%pdof_b) = frame_to_local(self, ub_pos) CALL CD_HermiteCable_Dyn_Set_Torsion_Frames(self%line, tors_ends, es, em, q_check=self%line%ws_qtrial) IF (es /= CD_HCDYN_OK) THEN ErrStat = CD_HFMF_SOLVEFAIL @@ -989,25 +1319,46 @@ SUBROUTINE CD_HFMF_SetCoupledKinematics(self, u_pos, u_vel, u_acc, ErrStat, ErrM self%parent_omega = target_omega self%parent_alpha = target_alpha END IF + IF (self%has_parent_endconn_b) THEN + IF (self%line%endconn_mode(1) == CD_ENDCONN_RIGID) THEN + self%line%q(4:6) = tangent_b(:, 1) + self%line%v(4:6) = tangent_b(:, 2) + self%line%a(4:6) = tangent_b(:, 3) + END IF + self%line%endconn_d0(:, 1) = d0_target(:, 1) + self%parent_dcm_b = target_dcm_b + self%parent_omega_b = target_omega_b + self%parent_alpha_b = target_alpha_b + END IF ! self%pdof holds the coupled node's three translational DOFs in the cable's local ! frame; the boundary rotates the caller's global kinematics in. self%line%q(self%pdof) = frame_to_local(self, u_pos) self%line%v(self%pdof) = frame_to_local(self, u_vel) self%line%a(self%pdof) = frame_to_local(self, u_acc) - IF (self%tors_parent) THEN - ! the parent-attached torsion frame turns with the written orientation (committed state); - ! checked above at this very state, so it is accepted + IF (self%moving_b) THEN + self%line%q(self%pdof_b) = frame_to_local(self, ub_pos) + self%line%v(self%pdof_b) = frame_to_local(self, ub_vel) + self%line%a(self%pdof_b) = frame_to_local(self, ub_acc) + END IF + IF (self%tors_parent .OR. self%tors_parent_b) THEN + ! the parent-attached torsion frames turn with the written orientations (committed state); + ! checked above at this very state, so they are accepted CALL CD_HermiteCable_Dyn_Set_Torsion_Frames(self%line, tors_ends, es, em) IF (es /= CD_HCDYN_OK) THEN ErrStat = CD_HFMF_SOLVEFAIL ErrMsg = 'CD_HFMF_SetCoupledKinematics: '//TRIM(em) RETURN END IF - IF (.NOT. self%has_parent_endconn) THEN + IF (self%tors_parent .AND. .NOT. self%has_parent_endconn) THEN self%parent_dcm = target_dcm self%parent_omega = target_omega self%parent_alpha = target_alpha END IF + IF (self%tors_parent_b .AND. .NOT. self%has_parent_endconn_b) THEN + self%parent_dcm_b = target_dcm_b + self%parent_omega_b = target_omega_b + self%parent_alpha_b = target_alpha_b + END IF END IF ErrStat = CD_HFMF_OK ErrMsg = '' @@ -1015,23 +1366,25 @@ END SUBROUTINE CD_HFMF_SetCoupledKinematics SUBROUTINE prepare_coupled_kinematics(self, u_pos, u_vel, u_acc, target_dcm, target_omega, target_alpha, & d0_target, tangent_q, tangent_v, tangent_a, ErrStat, ErrMsg, & - u_orientation, u_angular_velocity, u_angular_acceleration) + target_dcm_b, target_omega_b, target_alpha_b, tangent_b, & + u_orientation, u_angular_velocity, u_angular_acceleration, & + ub_pos, ub_vel, ub_acc, ub_orientation, ub_angular_velocity, & + ub_angular_acceleration) !! Prepare the complete non-stepping boundary update without mutating self. Keep - !! every fallible operation here so Preflight and Set have identical acceptance. + !! every fallible operation here so Preflight and Set have identical acceptance. A moving + !! End B's target (orientation, rates and the transported rigid tangent q, v, a in the columns + !! of tangent_b) is prepared the same way. TYPE(CD_HFMF_ModuleType), INTENT(IN) :: self REAL(wp), INTENT(IN) :: u_pos(3), u_vel(3), u_acc(3) REAL(wp), INTENT(OUT) :: target_dcm(3, 3), target_omega(3), target_alpha(3), d0_target(3, 2) REAL(wp), INTENT(OUT) :: tangent_q(3), tangent_v(3), tangent_a(3) INTEGER, INTENT(OUT) :: ErrStat CHARACTER(*), INTENT(OUT) :: ErrMsg + REAL(wp), INTENT(OUT) :: target_dcm_b(3, 3), target_omega_b(3), target_alpha_b(3), tangent_b(3, 3) REAL(wp), INTENT(IN), OPTIONAL :: u_orientation(3, 3) REAL(wp), INTENT(IN), OPTIONAL :: u_angular_velocity(3), u_angular_acceleration(3) - REAL(wp) :: dn, magnitude, magnitude_rate, magnitude_acceleration - REAL(wp) :: old_direction(3), old_direction_rate(3), target_direction(3) - REAL(wp) :: target_direction_rate(3), target_direction_acceleration(3) - REAL(wp) :: omega_local(3), alpha_local(3), rotation_check(3, 3) - INTEGER :: base, ecstat - CHARACTER(1024) :: ecmsg + REAL(wp), INTENT(IN), OPTIONAL :: ub_pos(3), ub_vel(3), ub_acc(3), ub_orientation(3, 3) + REAL(wp), INTENT(IN), OPTIONAL :: ub_angular_velocity(3), ub_angular_acceleration(3) ErrStat = CD_HFMF_OK ErrMsg = '' @@ -1042,6 +1395,10 @@ SUBROUTINE prepare_coupled_kinematics(self, u_pos, u_vel, u_acc, target_dcm, tar tangent_a = CD_ZERO target_omega = CD_ZERO target_alpha = CD_ZERO + target_dcm_b = identity_dcm() + target_omega_b = CD_ZERO + target_alpha_b = CD_ZERO + tangent_b = CD_ZERO IF (.NOT. self%initialized) THEN ErrStat = CD_HFMF_BADINPUT ErrMsg = 'module not initialised' @@ -1077,44 +1434,80 @@ SUBROUTINE prepare_coupled_kinematics(self, u_pos, u_vel, u_acc, target_dcm, tar END IF target_dcm = u_orientation END IF + CALL end_b_inputs(self, target_dcm_b, target_omega_b, target_alpha_b, ErrStat, ErrMsg, ub_pos, ub_vel, ub_acc, & + ub_orientation, ub_angular_velocity, ub_angular_acceleration) + IF (ErrStat /= CD_HFMF_OK) RETURN d0_target = self%line%endconn_d0 - IF (.NOT. self%has_parent_endconn) RETURN + IF (self%has_parent_endconn) THEN + CALL prepare_parent_end(self, self%parent_endconn_index, self%parent_endconn_d0, self%parent_omega, & + target_dcm, target_omega, target_alpha, d0_target(:, self%parent_endconn_index), & + tangent_q, tangent_v, tangent_a, ErrStat, ErrMsg) + IF (ErrStat /= CD_HFMF_OK) RETURN + END IF + IF (self%has_parent_endconn_b) THEN + CALL prepare_parent_end(self, 1, self%parent_endconn_d0_b, self%parent_omega_b, target_dcm_b, & + target_omega_b, target_alpha_b, d0_target(:, 1), tangent_b(:, 1), tangent_b(:, 2), & + tangent_b(:, 3), ErrStat, ErrMsg) + IF (ErrStat /= CD_HFMF_OK) ErrMsg = 'End B: '//TRIM(ErrMsg) + END IF + END SUBROUTINE prepare_coupled_kinematics - d0_target(:, self%parent_endconn_index) = frame_to_local(self, & - MATMUL(TRANSPOSE(target_dcm), self%parent_endconn_d0)) - dn = SQRT(DOT_PRODUCT(d0_target(:, self%parent_endconn_index), & - d0_target(:, self%parent_endconn_index))) + SUBROUTINE prepare_parent_end(self, iend, parent_d0, old_omega, target_dcm, target_omega, target_alpha, & + d0_end, tangent_q, tangent_v, tangent_a, ErrStat, ErrMsg) + !! The non-stepping update of one parent-attached end connection (end iend: 1 = node 1, 2 = the + !! last node): its direction d = G^T d_parent at the target orientation and, for an exact rigid + !! end, the end tangent projected on d and transported with the parent's rotation (q, v, a of + !! m = |m| d: v = |m|' d + |m| w x d, a = |m|'' d + 2 |m|' w x d + |m| (al x d + w x (w x d))). + TYPE(CD_HFMF_ModuleType), INTENT(IN) :: self + INTEGER, INTENT(IN) :: iend + REAL(wp), INTENT(IN) :: parent_d0(3), old_omega(3), target_dcm(3, 3), target_omega(3), target_alpha(3) + REAL(wp), INTENT(INOUT) :: d0_end(3) + REAL(wp), INTENT(OUT) :: tangent_q(3), tangent_v(3), tangent_a(3) + INTEGER, INTENT(OUT) :: ErrStat + CHARACTER(*), INTENT(OUT) :: ErrMsg + REAL(wp) :: dn, magnitude, magnitude_rate, magnitude_acceleration + REAL(wp) :: old_direction(3), old_direction_rate(3), target_direction(3) + REAL(wp) :: target_direction_rate(3), target_direction_acceleration(3) + REAL(wp) :: omega_local(3), alpha_local(3), rotation_check(3, 3) + INTEGER :: base, ecstat + CHARACTER(1024) :: ecmsg + + ErrStat = CD_HFMF_OK + ErrMsg = '' + tangent_q = CD_ZERO + tangent_v = CD_ZERO + tangent_a = CD_ZERO + d0_end = frame_to_local(self, MATMUL(TRANSPOSE(target_dcm), parent_d0)) + dn = SQRT(DOT_PRODUCT(d0_end, d0_end)) IF (.NOT. CD_Is_Finite(dn) .OR. dn <= SQRT(TINY(CD_ONE))) THEN ErrStat = CD_HFMF_BADINPUT ErrMsg = 'rotated end-connection direction is singular' RETURN END IF - d0_target(:, self%parent_endconn_index) = d0_target(:, self%parent_endconn_index)/dn - IF (self%line%endconn_mode(self%parent_endconn_index) /= CD_ENDCONN_RIGID) RETURN + d0_end = d0_end/dn + IF (self%line%endconn_mode(iend) /= CD_ENDCONN_RIGID) RETURN - IF (self%parent_endconn_index == 1) THEN + IF (iend == 1) THEN base = 3 ELSE base = 6*(self%line%nn - 1) + 3 END IF - CALL CD_EndConn_Project(self%line%q(base + 1:base + 3), & - d0_target(:, self%parent_endconn_index), tangent_q, ecstat, ecmsg) + CALL CD_EndConn_Project(self%line%q(base + 1:base + 3), d0_end, tangent_q, ecstat, ecmsg) IF (ecstat /= CD_ENDCONN_OK) THEN ErrStat = CD_HFMF_BADINPUT ErrMsg = 'rigid tangent projection failed: '//TRIM(ecmsg) RETURN END IF - CALL direction_rotation(self%line%endconn_d0(:, self%parent_endconn_index), & - d0_target(:, self%parent_endconn_index), rotation_check, ecstat, ecmsg) + CALL direction_rotation(self%line%endconn_d0(:, iend), d0_end, rotation_check, ecstat, ecmsg) IF (ecstat /= CD_ENDCONN_OK) THEN ErrStat = CD_HFMF_BADINPUT ErrMsg = 'rigid direction update failed: '//TRIM(ecmsg) RETURN END IF - old_direction = self%line%endconn_d0(:, self%parent_endconn_index) - target_direction = d0_target(:, self%parent_endconn_index) + old_direction = self%line%endconn_d0(:, iend) + target_direction = d0_end magnitude = SQRT(DOT_PRODUCT(tangent_q, tangent_q)) - omega_local = frame_to_local(self, self%parent_omega) + omega_local = frame_to_local(self, old_omega) old_direction_rate = cross3(omega_local, old_direction) magnitude_rate = DOT_PRODUCT(self%line%v(base + 1:base + 3), old_direction) magnitude_acceleration = DOT_PRODUCT(self%line%a(base + 1:base + 3), old_direction) + & @@ -1131,7 +1524,7 @@ SUBROUTINE prepare_coupled_kinematics(self, u_pos, u_vel, u_acc, target_dcm, tar ErrStat = CD_HFMF_BADINPUT ErrMsg = 'rigid tangent transport produced non-finite kinematics' END IF - END SUBROUTINE prepare_coupled_kinematics + END SUBROUTINE prepare_parent_end SUBROUTINE CD_HFMF_GetCoupledKinematics(self, pos, vel, acc, ErrStat, ErrMsg, orientation, & angular_velocity, angular_acceleration) @@ -1160,6 +1553,33 @@ SUBROUTINE CD_HFMF_GetCoupledKinematics(self, pos, vel, acc, ErrStat, ErrMsg, or IF (PRESENT(angular_acceleration)) angular_acceleration = self%parent_alpha END SUBROUTINE CD_HFMF_GetCoupledKinematics + SUBROUTINE CD_HFMF_GetEndBKinematics(self, pos, vel, acc, ErrStat, ErrMsg, orientation, & + angular_velocity, angular_acceleration) + !! The End B twin of CD_HFMF_GetCoupledKinematics: the committed kinematics of internal node 1 + !! (deck End B) in the CALLER's global frame, with End B's parent orientation and rates (identity + !! and zero unless a moving End B carries a parent frame). A held End B reads its fixed position. + TYPE(CD_HFMF_ModuleType), INTENT(IN) :: self + REAL(wp), INTENT(OUT) :: pos(3), vel(3), acc(3) + INTEGER, INTENT(OUT) :: ErrStat + CHARACTER(*), INTENT(OUT) :: ErrMsg + REAL(wp), INTENT(OUT), OPTIONAL :: orientation(3, 3) + REAL(wp), INTENT(OUT), OPTIONAL :: angular_velocity(3), angular_acceleration(3) + ErrStat = CD_HFMF_OK; ErrMsg = '' + pos = CD_ZERO; vel = CD_ZERO; acc = CD_ZERO + IF (PRESENT(orientation)) orientation = identity_dcm() + IF (PRESENT(angular_velocity)) angular_velocity = CD_ZERO + IF (PRESENT(angular_acceleration)) angular_acceleration = CD_ZERO + IF (.NOT. self%initialized) THEN + ErrStat = CD_HFMF_BADINPUT; ErrMsg = 'CD_HFMF_GetEndBKinematics: module not initialised'; RETURN + END IF + pos = frame_to_global(self, self%line%q(1:3)) + vel = frame_to_global(self, self%line%v(1:3)) + acc = frame_to_global(self, self%line%a(1:3)) + IF (PRESENT(orientation)) orientation = self%parent_dcm_b + IF (PRESENT(angular_velocity)) angular_velocity = self%parent_omega_b + IF (PRESENT(angular_acceleration)) angular_acceleration = self%parent_alpha_b + END SUBROUTINE CD_HFMF_GetEndBKinematics + SUBROUTINE CD_HFMF_Set_Held_Fluid(self, fluid_velocity, fluid_acceleration, waterline_z, ErrStat, ErrMsg) !! Prescribe the host-sampled ambient-fluid field on the cable's nodes: per-node !! fluid velocity, acceleration, and local free-surface elevation, held frozen until @@ -1259,17 +1679,26 @@ SUBROUTINE CD_HFMF_Refresh_Acceleration(self, ErrStat, ErrMsg) TYPE(CD_HFMF_ModuleType), INTENT(INOUT) :: self INTEGER, INTENT(OUT) :: ErrStat CHARACTER(*), INTENT(OUT) :: ErrMsg - INTEGER :: es - REAL(wp) :: coupled_a(3) + INTEGER :: es, pd(6) + REAL(wp) :: coupled_a(3), pa(6) CHARACTER(1024) :: em ErrStat = CD_HFMF_OK; ErrMsg = '' IF (.NOT. self%initialized) THEN ErrStat = CD_HFMF_BADINPUT; ErrMsg = 'CD_HFMF_Refresh_Acceleration: module not initialised'; RETURN END IF - coupled_a = self%line%a(self%pdof) - CALL CD_HermiteCable_Dyn_Recompute_Acceleration(self%line, es, em, & - pres_dofs=self%pdof, pres_a=coupled_a) + IF (self%moving_b .AND. .NOT. end_b_at_rest(self)) THEN + ! a moving End B's prescribed acceleration enters the consistent-mass solve as End A's does + pd(1:3) = self%pdof + pd(4:6) = self%pdof_b + pa(1:3) = self%line%a(self%pdof) + pa(4:6) = self%line%a(self%pdof_b) + CALL CD_HermiteCable_Dyn_Recompute_Acceleration(self%line, es, em, pres_dofs=pd, pres_a=pa) + ELSE + coupled_a = self%line%a(self%pdof) + CALL CD_HermiteCable_Dyn_Recompute_Acceleration(self%line, es, em, & + pres_dofs=self%pdof, pres_a=coupled_a) + END IF IF (es /= CD_HCDYN_OK) THEN ErrStat = CD_HFMF_BADINPUT; ErrMsg = 'CD_HFMF_Refresh_Acceleration: '//TRIM(em); RETURN END IF @@ -1378,18 +1807,22 @@ SUBROUTINE CD_HFMF_GetNodePositions(self, xyz, ErrStat, ErrMsg) END DO END SUBROUTINE CD_HFMF_GetNodePositions - SUBROUTINE CD_HFMF_CalcOutput(self, y_fair, ErrStat, ErrMsg, y_moment) + SUBROUTINE CD_HFMF_CalcOutput(self, y_fair, ErrStat, ErrMsg, y_moment, y_end_b, y_moment_b) !! The FMF loads-out boundary: the force the cable exerts ON the platform at the - !! coupled endpoint, at the current committed state (global coordinates, N). + !! coupled endpoint, at the current committed state (global coordinates, N). y_end_b and + !! y_moment_b return the same for internal node 1 (deck End B): the load on a moving End B's + !! host (or on the anchor of a held one). TYPE(CD_HFMF_ModuleType), INTENT(INOUT) :: self REAL(wp), INTENT(OUT) :: y_fair(3) INTEGER, INTENT(OUT) :: ErrStat CHARACTER(*), INTENT(OUT) :: ErrMsg - REAL(wp), INTENT(OUT), OPTIONAL :: y_moment(3) + REAL(wp), INTENT(OUT), OPTIONAL :: y_moment(3), y_end_b(3), y_moment_b(3) INTEGER :: es CHARACTER(1024) :: em ErrStat = CD_HFMF_OK; ErrMsg = ''; y_fair = CD_ZERO IF (PRESENT(y_moment)) y_moment = CD_ZERO + IF (PRESENT(y_end_b)) y_end_b = CD_ZERO + IF (PRESENT(y_moment_b)) y_moment_b = CD_ZERO IF (.NOT. self%initialized) THEN ErrStat = CD_HFMF_BADINPUT; ErrMsg = 'CD_HFMF_CalcOutput: module not initialised'; RETURN END IF @@ -1408,6 +1841,22 @@ SUBROUTINE CD_HFMF_CalcOutput(self, y_fair, ErrStat, ErrMsg, y_moment) END IF y_moment = frame_to_global(self, y_moment) END IF + IF (PRESENT(y_end_b)) THEN + CALL CD_HermiteCable_Dyn_Reaction(self%line, 1, y_end_b, es, em) + IF (es /= CD_HCDYN_OK) THEN + ErrStat = CD_HFMF_SOLVEFAIL; ErrMsg = 'CD_HFMF_CalcOutput: End B: '//TRIM(em) + RETURN + END IF + y_end_b = frame_to_global(self, y_end_b) + END IF + IF (PRESENT(y_moment_b)) THEN + CALL CD_HermiteCable_Dyn_EndConnection_Moment(self%line, 1, y_moment_b, es, em) + IF (es /= CD_HCDYN_OK) THEN + ErrStat = CD_HFMF_SOLVEFAIL; ErrMsg = 'CD_HFMF_CalcOutput: End B: '//TRIM(em) + RETURN + END IF + y_moment_b = frame_to_global(self, y_moment_b) + END IF END SUBROUTINE CD_HFMF_CalcOutput PURE FUNCTION identity_dcm() RESULT(dcm) @@ -1742,11 +2191,13 @@ INTEGER FUNCTION CD_HFMF_BoundaryMirrorSize(self) RESULT(n) !! rebuild moves the coupled end to the host's restored input mesh, the glue's input at !! the restart time, which need not carry the bits the uninterrupted run committed (with !! NumCrctn = 0 that run stepped with the extrapolated input); reloading this block after - !! the move continues from exactly the committed state. + !! the move continues from exactly the committed state. A moving End B adds its parent frame + !! (orientation 9, angular velocity 3, angular acceleration 3). TYPE(CD_HFMF_ModuleType), INTENT(IN) :: self n = 0 IF (.NOT. self%initialized) RETURN n = 3*(self%line%ndof - COUNT(self%line%freemask)) + 21 + IF (self%moving_b) n = n + 15 END FUNCTION CD_HFMF_BoundaryMirrorSize INTEGER FUNCTION CD_HFMF_TorsionMirrorSize(self) RESULT(n) @@ -1842,6 +2293,12 @@ SUBROUTINE CD_HFMF_PackMirror(self, buf, ErrStat, ErrMsg) buf(k + 16:k + 18) = self%parent_omega buf(k + 19:k + 21) = self%parent_alpha k = k + 21 + IF (self%moving_b) THEN + buf(k + 1:k + 9) = RESHAPE(self%parent_dcm_b, [9]) + buf(k + 10:k + 12) = self%parent_omega_b + buf(k + 13:k + 15) = self%parent_alpha_b + k = k + 15 + END IF ! force-blend committed force: flag (1 when the cache holds F at the committed state) IF (self%line%force_blend) THEN IF (self%line%fc_valid .AND. .NOT. (ABS(self%line%fc_t - self%line%t) > CD_ZERO)) THEN @@ -1929,6 +2386,13 @@ SUBROUTINE CD_HFMF_UnpackMirror(self, buf, t, ErrStat, ErrMsg) ErrMsg = 'CD_HFMF_UnpackMirror: the parent orientation must be a proper orthogonal DCM' RETURN END IF + IF (self%moving_b) THEN + IF (.NOT. valid_parent_dcm(RESHAPE(buf(kb + 22:kb + 30), [3, 3]))) THEN + ErrStat = CD_HFMF_BADINPUT + ErrMsg = 'CD_HFMF_UnpackMirror: the End B parent orientation must be a proper orthogonal DCM' + RETURN + END IF + END IF ! and the VIV block's mean squares and averaging time, which cannot be negative IF (self%line%has_viv) THEN kb = SIZE(buf) - CD_HFMF_TorsionMirrorSize(self) - CD_HFMF_VIVMirrorSize(self) + self%line%nn @@ -1966,6 +2430,12 @@ SUBROUTINE CD_HFMF_UnpackMirror(self, buf, t, ErrStat, ErrMsg) self%parent_omega = buf(k + 16:k + 18) self%parent_alpha = buf(k + 19:k + 21) k = k + 21 + IF (self%moving_b) THEN + self%parent_dcm_b = RESHAPE(buf(k + 1:k + 9), [3, 3]) + self%parent_omega_b = buf(k + 10:k + 12) + self%parent_alpha_b = buf(k + 13:k + 15) + k = k + 15 + END IF self%line%t = t ! The reloaded acceleration is committed history: a first held fluid field after the ! reload (the host re-sampling its field on the restored state) must keep it. @@ -2046,6 +2516,18 @@ SUBROUTINE CD_HFMF_End(self) self%tors_parent = .FALSE. self%tors_index = 0 self%tors_frame_parent = CD_ZERO + self%moving_b = .FALSE. + self%pdof_b = 0 + self%has_parent_endconn_b = .FALSE. + self%parent_endconn_d0_b = CD_ZERO + self%parent_dcm_b = identity_dcm() + self%parent_omega_b = CD_ZERO + self%parent_alpha_b = CD_ZERO + self%snap_parent_dcm_b = identity_dcm() + self%snap_parent_omega_b = CD_ZERO + self%snap_parent_alpha_b = CD_ZERO + self%tors_parent_b = .FALSE. + self%tors_frame_parent_b = CD_ZERO IF (ALLOCATED(self%deck_node)) DEALLOCATE (self%deck_node) self%initialized = .FALSE. END SUBROUTINE CD_HFMF_End diff --git a/src/openfast/CableDyn_OF.f90 b/src/openfast/CableDyn_OF.f90 index 55864a9f..64cc4138 100644 --- a/src/openfast/CableDyn_OF.f90 +++ b/src/openfast/CableDyn_OF.f90 @@ -860,6 +860,14 @@ SUBROUTINE CD_Init(InitInp, u, p, x, xd, z, other, y, m, DTcoupling, InitOut, Er ! (a line restrained in torsion linearises: its free twist angles and their rates ! are states, lin_state_map, and the coupled-point orientation of the input turns its ! End A frame; a condensed torsion's torque follows q and the frames, see lin_eval) + ! a finite-EI line between two moving points has a second host-driven end, whose input + ! column the linearization does not perturb yet + IF (Inst(id)%agg%cables(ic)%moving_b) THEN + CALL SetErrStat( ErrID_Fatal, 'CableDyn mooring module: formal OpenFAST linearization '// & + 'of a finite-EI line with two moving ends is not supported (anchor its '// & + 'End B on a Fixed point to linearize).', ErrStat, ErrMsg, RoutineName ) + RETURN + END IF END DO END IF CALL CD_AGG_GetInitMetadata( Inst(id)%agg, nreportlines, npoints, nsections, nei0, nfinite, es, em ) diff --git a/tests/test_anchor_uplift.py b/tests/test_anchor_uplift.py index 61648c2c..f6b6b546 100644 --- a/tests/test_anchor_uplift.py +++ b/tests/test_anchor_uplift.py @@ -21,7 +21,10 @@ ``TDPGrd = 0``, and the held end state is the suspended elastic catenary; * sloped seabed: a finite-EI cable laid down a slope from its anchor keeps the down-slope pull, so its anchor force runs along the floor and ``AnchTen`` continues the line tension; -* fail-closed contracts: unknown lines and the two-moving-end finite-EI route reject the names. +* fail-closed contracts: unknown lines reject the names; +* a finite-EI line shared by two turbines (both ends moving, the cubic-Hermite route drives End B + too): AnchFz is the vertical force on its End B point, minus half the line's submerged weight + for the symmetric hang at rest (the end force carries the end node's share of the weight). usage: test_anchor_uplift.py --exe --examples --output

""" @@ -544,7 +547,7 @@ def main() -> int: text=True, env=env) check(proc.returncode != 0 and "exactly one end" in proc.stderr, "TDP1Grd of a line grounded at both ends is rejected, as the other TDP channels") - # a finite-EI line shared by two turbines: both ends move (the two-moving-end route) + # a finite-EI line shared by two turbines: both ends move, driven on the cubic-Hermite route two_end = """two-moving-end finite-EI line --- LINE TYPES --- Name Diam Mass EA BA EI Cdn Cdt Can Cat @@ -579,8 +582,17 @@ def main() -> int: (out / "two_end.dat").write_text(two_end, encoding="utf-8", newline="\n") proc = subprocess.run([args.exe, str(out / "two_end.dat"), str(out / "two_end")], capture_output=True, text=True, env=env) - check(proc.returncode != 0 and "AnchFz/AnchFH channels are not available on the two-moving-end" in - proc.stdout + proc.stderr, "the two-moving-end finite-EI route rejects AnchFz by name") + check(proc.returncode == 0, "the finite-EI line between two turbines runs (rc %d)" % proc.returncode) + if proc.returncode == 0: + rows = [ln.split() for ln in (out / "two_end.out").read_text(encoding="utf-8").splitlines()[2:]] + anch_ten, anch_fz = float(rows[0][1]), float(rows[0][2]) + # the symmetric hang: each end carries half the submerged weight w L / 2 + w_sub = (250.0 - 1025.0 * math.pi * 0.2**2 / 4.0) * 9.80665 + half = 0.5 * w_sub * 75.0 + print(f"two moving ends: AnchFz1 {anch_fz:.6e} N, -w L / 2 = {-half:.6e} N, AnchTen1 {anch_ten:.6e} N") + check(abs(anch_fz + half) <= 1.0e-6 * half, + "AnchFz of a moving End B is the vertical end force, -w L / 2 for the symmetric hang") + check(abs(anch_fz) < anch_ten, "the vertical End B force is below the End B tension") print(f"{len(FAILURES)} failure(s)") return 1 if FAILURES else 0 diff --git a/tests/test_body_rod_numbering.py b/tests/test_body_rod_numbering.py new file mode 100644 index 00000000..199fe5c9 --- /dev/null +++ b/tests/test_body_rod_numbering.py @@ -0,0 +1,131 @@ +#!/usr/bin/env python3 +# SPDX-License-Identifier: Apache-2.0 +# Copyright (c) 2026 Jae Hoon Seo, SMI Lab, Inha University +"""A rod numbered as a body is not one of the body's points. + +A ``RodA/B`` end point keeps its rod's id in the same field a ``Body`` point keeps its +body's id. The body's attachment points must be its ``Body`` points only, as they are +counted; a rod end point on a rod with the body's number, listed before the body's points, was +taken as the body's first point (and the list overran its allocation). + +Gate, on the driver's own output files: a free Rigid6 body on three taut legs with a pinned arm +rod whose tip tether starts from an explicit rod end POINT listed first. The deck with the arm +as ``Rod1`` (the body's number) and the same deck with the arm as ``Rod3`` write identical +outputs, bit for bit (in 1 s the old code turned the arm 172 deg in pitch, the body 1.06 deg in +pitch and 0.14 m in surge, and the leg tension FairTen1 by 3.0 kN). + +usage: test_body_rod_numbering.py --exe --output +""" + +from __future__ import annotations + +import argparse +import subprocess +import sys +from pathlib import Path + +DECK = """--------------------- CableDyn Input File ------------------------------------ +Rod numbered as the body: a free Rigid6 body, a pinned arm rod, a tether from the arm tip +--------------------- LINE TYPES --------------------------------------- +TypeName Diam MassDenInAir EA BA/-zeta EI Cd_n Cd_t Ca_n Ca_t +(-) (m) (kg/m) (N) (N-s/-) (N-m^2) (-) (-) (-) (-) +nylon 0.124 13.76 2.515288e6 -0.8 0.0 1.6 0.05 1.0 0.0 +--------------------- ROD TYPES ---------------------------------------- +Name Diam Mass Cd Ca CdEnd CaEnd +(-) (m) (kg/m) (-) (-) (-) (-) +arm 0.5 600.0 1.0 1.0 0.0 0.0 +--------------------- BODIES ------------------------------------------- +ID Attachment X0 Y0 Z0 r0 p0 y0 Mass CG I Volume CdA Ca +(-) (-) (m) (m) (m) (deg) (deg) (deg) (kg) (m) (kg-m^2) (m^3) (m^2) (-) +1 Free 3.0 0.0 -15.0 0.0 0.0 0.0 1.5e5 0.0 2.0e6 160.0 20|0 0.5 +--------------------- RODS --------------------------------------------- +ID RodType Attachment XA YA ZA XB YB ZB NumSegs Outputs +(-) (-) (-) (m) (m) (m) (m) (m) (m) (-) (-) +{rod} arm Body1Pinned 0.0 0.0 -2.0 0.0 0.0 -12.0 5 - +--------------------- POINTS ------------------------------------------- +ID Type X Y Z Mass Vol CdA Ca +(-) (-) (m) (m) (m) (kg) (m^3) (m^2) (-) +1 Rod{rod}B 0.0 0.0 0.0 0 0 0 0 +2 Body1 3.0 0.0 0.0 0 0 0 0 +3 Body1 -1.5 2.598076 0.0 0 0 0 0 +4 Body1 -1.5 -2.598076 0.0 0 0 0 0 +5 Fixed 150.0 0.0 -70.0 0 0 0 0 +6 Fixed -75.0 129.904 -70.0 0 0 0 0 +7 Fixed -75.0 -129.904 -70.0 0 0 0 0 +8 Fixed 3.0 0.0 -70.0 0 0 0 0 +--------------------- LINES -------------------------------------------- +ID LineType AttachA AttachB UnstrLen NumSegs Outputs +(-) (-) (-) (-) (m) (-) (-) +1 nylon 2 5 150.0 40 - +2 nylon 3 6 150.0 40 - +3 nylon 4 7 150.0 40 - +4 nylon 1 8 42.0 12 - +--------------------- OPTIONS ------------------------------------------ +9.80665 g +1025.0 rhoW +70.0 WtrDpth +0.005 dtM +1.0 TMax +deck bodyIC +--------------------- OUTPUTS ------------------------------------------ +"Body1Px" +"Body1Pz" +"Body1Ry" +"Rod{rod}Ry" +"Rod{rod}TenB" +"FairTen1" +"FairTen4" +--------------------- need this line ----------------------------------- +""" + + +def run(exe: str, out: Path, rod: int) -> list[str]: + deck = out / f"rod{rod}.dat" + deck.write_text(DECK.replace("{rod}", str(rod)), encoding="utf-8", newline="\n") + root = out / f"rod{rod}" + p = subprocess.run( + [exe, str(deck), str(root)], capture_output=True, text=True, check=False + ) + if p.returncode != 0: + print(p.stdout[-2000:] + p.stderr[-2000:]) + raise SystemExit( + f"FAIL: the driver stopped on the Rod{rod} deck (exit {p.returncode})" + ) + rows = (root.parent / (root.name + ".out")).read_text(encoding="utf-8").splitlines() + return [r.replace(f"Rod{rod}", "Rod") for r in rows] + + +def main() -> int: + ap = argparse.ArgumentParser() + ap.add_argument("--exe", required=True) + ap.add_argument("--output", required=True) + args = ap.parse_args() + out = Path(args.output) + out.mkdir(parents=True, exist_ok=True) + same = run(args.exe, out, 1) + other = run(args.exe, out, 3) + # the body moves (the deck pose is off its equilibrium), so a misread point shows + heave = [float(r.split()[2]) for r in same[2:] if r.strip()] + moved = max(heave) - min(heave) + diff = sum(1 for a, b in zip(same, other) if a != b) + abs(len(same) - len(other)) + print( + f"body heave range {moved:.3e} m; rows differing between Rod1 and Rod3: {diff} of {len(same)}" + ) + failures = [] + if not moved > 1.0e-3: + failures.append( + "the body does not move, so the gate does not resolve a misread point" + ) + if diff != 0: + failures.append( + "a rod numbered as the body changes the run (Rod1 and Rod3 decks differ)" + ) + for f in failures: + print("FAIL: " + f) + if not failures: + print("PASS: a rod numbered as the body is not one of the body's points") + return 1 if failures else 0 + + +if __name__ == "__main__": + sys.exit(main()) diff --git a/tests/test_cable_between_bodies.f90 b/tests/test_cable_between_bodies.f90 new file mode 100644 index 00000000..af95a1ac --- /dev/null +++ b/tests/test_cable_between_bodies.f90 @@ -0,0 +1,876 @@ +! File: tests/test_cable_between_bodies.f90 +! SPDX-License-Identifier: Apache-2.0 +! Copyright (c) 2026 Jae Hoon Seo, SMI Lab, Inha University +!> Gates of a finite-EI (cubic-Hermite) line between two objects on the standalone multibody +!> march: End A on a Rigid6 body point, End B on another body point or a rod end, both ends +!> driven by their objects and their end loads returned to them. +!> S symmetry: two identical bodies joined by a cable clamped at both ends and pulled apart by +!> mirrored external loads keep their mirror symmetry (surge, heave, pitch, end tensions), on +!> the monolithic step and, pinned, on the staggered one; +!> F a body joined to an immobile body (mass 1e15 kg) equals the same line to a Fixed point on +!> the established route (body motion, End A force and moment), clamped and twisted; +!> E conservation: two free neutral bodies joined by a taut cable, no drag, added mass or net +!> weight (no external load), body 1 launched: the total linear momentum (bodies plus cable) +!> is constant to 1e-4 and the energy (bodies plus cable kinetic and elastic) to 0.5 % under +!> the rhoInf = 1 monolithic step; +!> T torsion: a cable twisted 90 deg between two bodies returns equal and opposite torques to +!> them, GJ Phi / L at the start, and the bodies counter-rotate; +!> Q statics: two moored bodies joined by a clamped cable start balanced (bodyIC static) and +!> stay at rest in the dynamics; +!> P a stiff (EI 1e6 N m^2) clamped cable between two unequal moored bodies, its ends offset out +!> of the bodies' plane: the static passes converge, written in either direction to the same +!> equilibrium, which the still dynamics hold; with the passes limited the solve fails +!> closed naming the line; +!> D the coupling does not depend on the line's direction (a cable from a Fixed point to a rod +!> end and the reversed one: the same motion and end tensions; written from the Fixed point +!> the line is turned around, as one to a body point, so both write the same output), and an +!> End B on a fixed rod's end is the same Fixed End B (byte for byte); +!> R a cable between a body point and a rod end runs; fail-closed: an End B on a Free point or +!> a Coupled point, a clamped End B on the staggered scheme and a torsion frame at a body +!> End A on the staggered scheme are refused by name. +PROGRAM test_cable_between_bodies + USE CableDyn_Precision, ONLY: wp + USE CableDyn_DeckDriver, ONLY: CD_Run_Deck_Driver, CD_DECKDRV_OK, CD_Multibody_Probe_Arm, CD_Multibody_Probe_Get, & + CD_Body_Static_Pass_Limit + USE, INTRINSIC :: IEEE_ARITHMETIC, ONLY: IEEE_IS_FINITE + IMPLICIT NONE + + REAL(wp), PARAMETER :: PI = 3.14159265358979323846_wp, RHOW = 1025.0_wp + REAL(wp), PARAMETER :: DIAM = 0.2_wp + INTEGER :: n_fail = 0 + + CALL check_symmetry('monolithic', 'Rigid') + CALL check_symmetry('staggered', 'Pinned') + CALL check_fixed_equivalence() + CALL check_conservation() + CALL check_torsion() + CALL check_statics() + CALL check_stiff_statics() + CALL check_direction() + CALL check_rod_and_refusals() + IF (n_fail > 0) THEN + WRITE (*, '(A,I0,A)') 'FAIL: ', n_fail, ' gate(s) of a cable between two objects failed' + ERROR STOP 1 + END IF + WRITE (*, '(A)') 'PASS: a finite-EI cable between two objects (symmetry, Fixed limit, conservation, '// & + 'torsion, statics, 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 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_rows(path, vals, nrow, ok) + !! Every data row of a driver .out file (two header lines) into vals(:, 1:nrow). + CHARACTER(*), INTENT(IN) :: path + REAL(wp), INTENT(OUT) :: vals(:, :) + INTEGER, INTENT(OUT) :: nrow + LOGICAL, INTENT(OUT) :: ok + INTEGER :: u, ios + CHARACTER(512) :: buf + nrow = 0 + vals = 0.0_wp + ok = .FALSE. + 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 WHILE (nrow < SIZE(vals, 2)) + READ (u, *, IOSTAT=ios) vals(:, nrow + 1) + IF (ios /= 0) EXIT + nrow = nrow + 1 + END DO + CLOSE (u) + ok = nrow > 0 .AND. ALL(IEEE_IS_FINITE(vals(:, 1:nrow))) + END SUBROUTINE read_rows + + SUBROUTINE line_type_rows(u, torsion) + !! A neutrally buoyant cable (no net weight), without drag or added mass; with torsion the + !! 14-column row (GJ 5e4 N m^2). + INTEGER, INTENT(IN) :: u + LOGICAL, INTENT(IN) :: torsion + REAL(wp) :: m + m = RHOW*0.25_wp*PI*DIAM**2 + WRITE (u, '(A)') '--- LINE TYPES ---' + IF (torsion) THEN + 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 ', m, ' 1.0e7 0.0 1.0e4 1.0e8 5.0e4 1.0 1.0e-12 0.0 0.0 0.0 0.0' + ELSE + WRITE (u, '(A)') 'Name Diam Mass EA BA EI Cdn Cdt Can Cat' + WRITE (u, '(A)') '(-) (m) (kg/m) (N) (-) (Nm2) (-) (-) (-) (-)' + WRITE (u, '(A,ES24.16,A)') 'cab 0.2 ', m, ' 1.0e6 0.0 1.0e4 0.0 0.0 0.0 0.0' + END IF + END SUBROUTINE line_type_rows + + SUBROUTINE body_rows(u, x1, x2, z, m1, m2, vol, inertia2) + !! Two Rigid6 bodies at (x1, 0, z) and (x2, 0, z), no drag or added mass, inertia (2e3, 3e3, + !! 4e3) kg m^2 (body 2: inertia2 for each axis when positive). + INTEGER, INTENT(IN) :: u + REAL(wp), INTENT(IN) :: x1, x2, z, m1, m2, vol(2), inertia2 + 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)' + WRITE (u, '(A,3(ES24.16,1X),A,2(ES24.16,1X),A)') '1 Rigid6 ', x1, 0.0_wp, z, '0 0 0 ', m1, vol(1), & + '0 0 0 0 0 2.0e3 3.0e3 4.0e3' + IF (inertia2 > 0.0_wp) THEN + WRITE (u, '(A,3(ES24.16,1X),A,2(ES24.16,1X),A,3(1X,ES24.16))') '2 Rigid6 ', x2, 0.0_wp, z, '0 0 0 ', m2, & + vol(2), '0 0 0 0 0', inertia2, inertia2, inertia2 + ELSE + WRITE (u, '(A,3(ES24.16,1X),A,2(ES24.16,1X),A)') '2 Rigid6 ', x2, 0.0_wp, z, '0 0 0 ', m2, vol(2), & + '0 0 0 0 0 2.0e3 3.0e3 4.0e3' + END IF + END SUBROUTINE body_rows + + SUBROUTINE option_rows(u, scheme, ic, dtm, tmax) + INTEGER, INTENT(IN) :: u + CHARACTER(*), INTENT(IN) :: scheme, ic + REAL(wp), INTENT(IN) :: dtm, tmax + WRITE (u, '(A)') '--- OPTIONS ---' + WRITE (u, '(A)') '9.80665 g' + WRITE (u, '(A)') '1025.0 rhoW' + WRITE (u, '(A)') '200.0 WtrDpth' + WRITE (u, '(A)') 'moordyn bodyWetting' + WRITE (u, '(A)') ic//' bodyIC' + WRITE (u, '(A)') scheme//' bodyScheme' + WRITE (u, '(ES12.5,A)') dtm, ' dtM' + WRITE (u, '(ES12.5,A)') tmax, ' TMax' + WRITE (u, '(A)') '1.0 rhoInf' + END SUBROUTINE option_rows + + ! ------------------------------------------------------------------------------------------ + SUBROUTINE write_symmetric_deck(path, scheme, conn) + !! Bodies at x = -10.5 and +10.5 m (6 t, 5 m^3: 875 kg of net weight each), the cable from body + !! 1's point (+0.5, 0, 0) to body 2's (-0.5, 0, 0), 20.2 m long (sagging), End A and End B + !! connection conn along the chord; external loads of 2 kN pull the bodies apart (-x on body + !! 1, +x on body 2) with mirrored damping. + CHARACTER(*), INTENT(IN) :: path, scheme, conn + INTEGER :: u + OPEN (NEWUNIT=u, FILE=path, STATUS='REPLACE', ACTION='WRITE') + WRITE (u, '(A)') 'cable between two bodies: symmetry' + CALL line_type_rows(u, .FALSE.) + CALL body_rows(u, -10.5_wp, 10.5_wp, -50.0_wp, 6.0e3_wp, 6.0e3_wp, [5.0_wp, 5.0_wp], 0.0_wp) + WRITE (u, '(A)') '--- EXTERNAL LOADS ---' + WRITE (u, '(A)') 'ID Object Fext Blin Bquad CSys' + WRITE (u, '(A)') '(-) (-) (N) (Ns/m) (Ns2/m2) (-)' + WRITE (u, '(A)') '1 Body1 -2000|0|0 500 0 G' + WRITE (u, '(A)') '2 Body2 2000|0|0 500 0 G' + 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 Body1 0.5 0 0 0 0 0 0' + WRITE (u, '(A)') '2 Body2 -0.5 0 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 20.2 20' + WRITE (u, '(A)') '--- END CONNECTIONS ---' + WRITE (u, '(A)') 'LineID End Stiffness EzX EzY EzZ' + WRITE (u, '(A)') '(-) (-) (N-m/rad) (-) (-) (-)' + WRITE (u, '(A)') '1 A '//conn//' 1.0 0.0 0.0' + WRITE (u, '(A)') '1 B '//conn//' 1.0 0.0 0.0' + CALL option_rows(u, scheme, 'deck', 0.02_wp, 4.0_wp) + WRITE (u, '(A)') '--- OUTPUTS ---' + WRITE (u, '(A)') 'Body1Px Body1Pz Body1Ry Body2Px Body2Pz Body2Ry FairTen1 AnchTen1' + WRITE (u, '(A)') '--- END ---' + CLOSE (u) + END SUBROUTINE write_symmetric_deck + + SUBROUTINE check_symmetry(scheme, conn) + !! S. Mirror x -> -x maps body 1 to body 2 and End A to End B: Px1 = -Px2, Pz1 = Pz2, + !! Ry1 = -Ry2 and FairTen = AnchTen at every output step. + CHARACTER(*), INTENT(IN) :: scheme, conn + REAL(wp) :: rows(9, 300), dev, amp, tdev, tamp + INTEGER :: n, k + LOGICAL :: ok + CHARACTER(1024) :: em + CHARACTER(64) :: root + root = 'cbb_sym_'//scheme + CALL write_symmetric_deck(TRIM(root)//'.dat', scheme, conn) + CALL run_deck(TRIM(root)//'.dat', TRIM(root), ok, em) + CALL require(ok, 'S: the symmetric two-body deck runs ('//scheme//'): '//TRIM(em)) + IF (.NOT. ok) RETURN + CALL read_rows(TRIM(root)//'.out', rows, n, ok) + CALL require(ok, 'S: symmetric output readable') + IF (.NOT. ok) RETURN + dev = 0.0_wp + tdev = 0.0_wp + amp = 0.0_wp + tamp = 0.0_wp + DO k = 1, n + dev = nan_max_abs([dev, rows(2, k) + rows(5, k), rows(3, k) - rows(6, k), rows(4, k) + rows(7, k)]) + amp = nan_max_abs([amp, rows(2, k) - rows(2, 1), rows(3, k) - rows(3, 1), rows(4, k) - rows(4, 1)]) + tdev = nan_max_abs([tdev, rows(8, k) - rows(9, k)]) + tamp = nan_max_abs([tamp, rows(8, k)]) + END DO + WRITE (*, '(A,A,A,ES10.3,A,ES10.3,A,ES10.3,A,ES10.3,A)') 'S (', scheme, '): mirror deviation ', dev, & + ' (motion ', amp, '), tension deviation ', tdev, ' N (of ', tamp, ' N)' + CALL require(amp > 1.0e-2_wp, 'S: the external loads move the bodies ('//scheme//')') + CALL require(dev <= 1.0e-6_wp*MAX(1.0_wp, amp), 'S: the two bodies stay mirror images ('//scheme//')') + CALL require(tdev <= 1.0e-6_wp*tamp, 'S: equal tensions at both ends ('//scheme//')') + END SUBROUTINE check_symmetry + + ! ------------------------------------------------------------------------------------------ + SUBROUTINE write_pair_deck(path, end_b_kind, torsion, m2, vol2, i2, scheme, bend_a) + !! Body 1 (5 t, neutral) at (0, 0, -50), the cable from its point (1, 0, 0) along +x to + !! (21.1, 0, -50), 20 m long (taut), clamped at End A (and twisted 90 deg with torsion); End + !! B a Fixed point there (end_b_kind 'fixed') or body 2's point (-1, 0, 0) (body 2 at + !! (22.1, 0, -50), mass m2, volume vol2, inertia i2), clamped. + CHARACTER(*), INTENT(IN) :: path, end_b_kind + LOGICAL, INTENT(IN) :: torsion + REAL(wp), INTENT(IN) :: m2, vol2, i2 + ! scheme: bodyScheme (monolithic by default); bend_a: End A's bending connection (Rigid) + CHARACTER(*), INTENT(IN), OPTIONAL :: scheme, bend_a + INTEGER :: u + REAL(wp) :: mb1 + CHARACTER(16) :: sch, bnd + sch = 'monolithic' + IF (PRESENT(scheme)) sch = scheme + bnd = 'Rigid' + IF (PRESENT(bend_a)) bnd = bend_a + mb1 = 5.0e3_wp + OPEN (NEWUNIT=u, FILE=path, STATUS='REPLACE', ACTION='WRITE') + WRITE (u, '(A)') 'cable between two bodies: pair' + CALL line_type_rows(u, torsion) + IF (end_b_kind == 'fixed') 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)' + WRITE (u, '(A,ES24.16,A)') '1 Rigid6 0 0 -50 0 0 0 5.0e3 ', mb1/RHOW, ' 0 0 0 0 0 2.0e3 3.0e3 4.0e3' + ELSE + CALL body_rows(u, 0.0_wp, 22.1_wp, -50.0_wp, mb1, m2, [mb1/RHOW, vol2], i2) + 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) (-)' + WRITE (u, '(A)') '1 Body1 1.0 0 0 0 0 0 0' + IF (end_b_kind == 'fixed') THEN + WRITE (u, '(A)') '2 Fixed 21.1 0 -50 0 0 0 0' + ELSE + WRITE (u, '(A)') '2 Body2 -1.0 0 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)') '1 cab 20.0 20' + WRITE (u, '(A)') '--- END CONNECTIONS ---' + IF (torsion) THEN + 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 '//TRIM(bnd)//' 1.0 0.0 0.0 Rigid 0 0 1 0' + WRITE (u, '(A)') '1 B Rigid 1.0 0.0 0.0 Rigid 0 0 1 90' + ELSE + WRITE (u, '(A)') 'LineID End Stiffness EzX EzY EzZ' + WRITE (u, '(A)') '(-) (-) (N-m/rad) (-) (-) (-)' + WRITE (u, '(A)') '1 A Rigid 1.0 0.0 0.0' + WRITE (u, '(A)') '1 B Rigid 1.0 0.0 0.0' + END IF + CALL option_rows(u, TRIM(sch), 'deck', 0.02_wp, 6.0_wp) + WRITE (u, '(A)') '--- OUTPUTS ---' + WRITE (u, '(A)') 'Body1Px FairTen1' + WRITE (u, '(A)') '--- END ---' + CLOSE (u) + END SUBROUTINE write_pair_deck + + SUBROUTINE run_probed(path, root, v0, w0, rec, ok, em) + CHARACTER(*), INTENT(IN) :: path, root + REAL(wp), INTENT(IN) :: v0(3), w0(3) + REAL(wp), ALLOCATABLE, INTENT(OUT) :: rec(:, :) + LOGICAL, INTENT(OUT) :: ok + CHARACTER(*), INTENT(OUT) :: em + CALL CD_Multibody_Probe_Arm(v0, w0) + CALL run_deck(path, root, ok, em) + CALL CD_Multibody_Probe_Get(rec) + ok = ok .AND. ALLOCATED(rec) + END SUBROUTINE run_probed + + SUBROUTINE check_fixed_equivalence() + !! F. Body 1 launched on a cable clamped to it and to a Fixed point (the established route), + !! and on the same cable clamped to body 2 of 1e15 kg (neutral, inertia 1e15 kg m^2) at + !! that point: body 1's trajectory, the End A force and moment agree, without and with + !! torsion (90 deg of pretwist). + REAL(wp), ALLOCATABLE :: rf(:, :), rb(:, :) + REAL(wp) :: dx, df, dm, sx, sf, sm, d2 + INTEGER :: k, it + LOGICAL :: ok, tors + CHARACTER(1024) :: em + CHARACTER(8) :: tag + DO it = 1, 2 + tors = it == 2 + tag = MERGE('tors', 'bend', tors) + CALL write_pair_deck('cbb_fix_'//TRIM(tag)//'.dat', 'fixed', tors, 0.0_wp, 0.0_wp, 0.0_wp) + CALL run_probed('cbb_fix_'//TRIM(tag)//'.dat', 'cbb_fix_'//TRIM(tag), [0.05_wp, 0.02_wp, 0.05_wp], & + [0.01_wp, 0.03_wp, 0.02_wp], rf, ok, em) + CALL require(ok, 'F: the body-to-Fixed deck runs ('//TRIM(tag)//'): '//TRIM(em)) + IF (.NOT. ok) CYCLE + CALL write_pair_deck('cbb_imm_'//TRIM(tag)//'.dat', 'body', tors, 1.0e15_wp, 1.0e15_wp/RHOW, 1.0e15_wp) + CALL run_probed('cbb_imm_'//TRIM(tag)//'.dat', 'cbb_imm_'//TRIM(tag), [0.05_wp, 0.02_wp, 0.05_wp], & + [0.01_wp, 0.03_wp, 0.02_wp], rb, ok, em) + CALL require(ok, 'F: the body-to-immobile-body deck runs ('//TRIM(tag)//'): '//TRIM(em)) + IF (.NOT. ok) CYCLE + ok = UBOUND(rf, 2) == UBOUND(rb, 2) + CALL require(ok, 'F: same number of steps') + IF (.NOT. ok) CYCLE + dx = 0.0_wp + df = 0.0_wp + dm = 0.0_wp + d2 = 0.0_wp + sx = 0.0_wp + sf = 0.0_wp + sm = 0.0_wp + DO k = 0, UBOUND(rf, 2) + dx = nan_max_abs([dx, rf(2:7, k) - rb(2:7, k), rf(17:19, k) - rb(17:19, k)]) + sx = nan_max_abs([sx, rf(2:4, k) - rf(2:4, 0), rf(5:7, k), rf(17:19, k)]) + df = nan_max_abs([df, rf(27:29, k) - rb(27:29, k)]) + sf = nan_max_abs([sf, rf(27:29, k)]) + dm = nan_max_abs([dm, rf(24:26, k) - rb(24:26, k)]) + sm = nan_max_abs([sm, rf(24:26, k)]) + d2 = nan_max_abs([d2, rb(30:32, k) - rb(30:32, 0)]) + END DO + WRITE (*, '(A,A,A,3(ES10.3,A),ES10.3)') 'F (', TRIM(tag), '): body-to-Fixed vs body-to-immobile body: '// & + 'state ', dx/sx, ', End A force ', df/sf, ', End A moment ', dm/MAX(sm, 1.0_wp), ' (relative); body 2 moves ', d2 + CALL require(dx <= 1.0e-6_wp*sx, 'F: body 1 moves as on a Fixed End B ('//TRIM(tag)//')') + CALL require(df <= 1.0e-6_wp*sf, 'F: End A force as on a Fixed End B ('//TRIM(tag)//')') + CALL require(dm <= 1.0e-6_wp*MAX(sm, 1.0_wp), 'F: End A moment as on a Fixed End B ('//TRIM(tag)//')') + END DO + END SUBROUTINE check_fixed_equivalence + + ! ------------------------------------------------------------------------------------------ + SUBROUTINE check_conservation() + !! E. Two free neutral bodies (5 t each) joined by the taut 20 m cable clamped at both ends, + !! body 1 launched with v = (0.05, 0.02, 0.05) m/s, omega = (0.01, 0.03, 0.02) rad/s; no + !! drag, added mass or net weight: no external load. The total linear momentum (bodies plus + !! the cable's consistent-mass momentum) stays at its value after the first step (the + !! first step brings the cable, at rest at t = 0, to the bodies' end velocities) to 1e-4 of + !! the launch momentum (each step's junction residual, below 1e-6 of the body weight, is an + !! impulse of at most 1e-3 kg m/s), and the energy (bodies plus cable kinetic and elastic) + !! is conserved by the rhoInf = 1 step to 0.5 %. + REAL(wp), PARAMETER :: MB = 5.0e3_wp, IB(3) = [2.0e3_wp, 3.0e3_wp, 4.0e3_wp] + REAL(wp), ALLOCATABLE :: rec(:, :) + REAL(wp) :: p(3), p1(3), dp, e, e1, de, rot(3, 3), wb(3), amp, pscale + INTEGER :: k + LOGICAL :: ok + CHARACTER(1024) :: em + CALL write_pair_deck('cbb_cons.dat', 'body', .FALSE., MB, MB/RHOW, 0.0_wp) + CALL run_probed('cbb_cons.dat', 'cbb_cons', [0.05_wp, 0.02_wp, 0.05_wp], [0.01_wp, 0.03_wp, 0.02_wp], rec, ok, em) + CALL require(ok, 'E: the free two-body deck runs: '//TRIM(em)) + IF (.NOT. ok) RETURN + dp = 0.0_wp + de = 0.0_wp + amp = 0.0_wp + pscale = MB*NORM2([0.05_wp, 0.02_wp, 0.05_wp]) + DO k = 1, UBOUND(rec, 2) + p = MB*rec(5:7, k) + MB*rec(33:35, k) + rec(48:50, k) + rot = RESHAPE(rec(8:16, k), [3, 3]) + wb = MATMUL(TRANSPOSE(rot), rec(17:19, k)) + e = 0.5_wp*MB*DOT_PRODUCT(rec(5:7, k), rec(5:7, k)) + 0.5_wp*DOT_PRODUCT(wb, IB*wb) + rot = RESHAPE(rec(36:44, k), [3, 3]) + wb = MATMUL(TRANSPOSE(rot), rec(45:47, k)) + e = e + 0.5_wp*MB*DOT_PRODUCT(rec(33:35, k), rec(33:35, k)) + 0.5_wp*DOT_PRODUCT(wb, IB*wb) + rec(23, k) + IF (k == 1) THEN + p1 = p + e1 = e + END IF + dp = MAX(dp, NORM2(p - p1)) + de = MAX(de, ABS(e - e1)/e1) + amp = MAX(amp, NORM2(rec(30:32, k) - rec(30:32, 0))) + END DO + WRITE (*, '(A,ES10.3,A,ES10.3,A,ES10.3,A,ES10.3,A)') 'E: free two-body system: momentum drift ', dp/pscale, & + ' (of the launch momentum), energy drift ', de, ', momentum after the first step ', NORM2(p1)/pscale, & + ' (launch 1), body 2 excursion ', amp, ' m' + CALL require(amp > 1.0e-2_wp, 'E: the cable carries body 1''s motion to body 2') + CALL require(dp <= 1.0e-4_wp*pscale, 'E: total linear momentum conserved') + CALL require(de <= 5.0e-3_wp, 'E: energy conserved to 0.5 %') + END SUBROUTINE check_conservation + + ! ------------------------------------------------------------------------------------------ + SUBROUTINE check_torsion() + !! T. The cable of E twisted 90 deg (Pretwist B - A), torsion rigid at both bodies, at rest: + !! the End A and End B moments on the bodies are equal and opposite, GJ Phi / L about the + !! chord at the start, and the bodies counter-rotate about it. + REAL(wp), PARAMETER :: MB = 5.0e3_wp + REAL(wp), ALLOCATABLE :: rec(:, :) + REAL(wp) :: m0, dev, mmax, rx1, rx2, rdev, rot(3, 3) + INTEGER :: k + LOGICAL :: ok + CHARACTER(1024) :: em + CALL write_pair_deck('cbb_tors.dat', 'body', .TRUE., MB, MB/RHOW, 0.0_wp) + CALL run_probed('cbb_tors.dat', 'cbb_tors', [0.0_wp, 0.0_wp, 0.0_wp], [0.0_wp, 0.0_wp, 0.0_wp], rec, ok, em) + CALL require(ok, 'T: the twisted two-body deck runs: '//TRIM(em)) + IF (.NOT. ok) RETURN + m0 = 5.0e4_wp*0.5_wp*PI/20.0_wp + dev = 0.0_wp + mmax = 0.0_wp + rdev = 0.0_wp + DO k = 0, UBOUND(rec, 2) + dev = MAX(dev, NORM2(rec(24:26, k) + rec(51:53, k))) + mmax = MAX(mmax, NORM2(rec(24:26, k))) + rot = RESHAPE(rec(8:16, k), [3, 3]) + rx1 = ATAN2(rot(3, 2), rot(3, 3)) + rot = RESHAPE(rec(36:44, k), [3, 3]) + rx2 = ATAN2(rot(3, 2), rot(3, 3)) + rdev = MAX(rdev, ABS(rx1 + rx2)) + END DO + WRITE (*, '(A,2ES12.5,A,ES12.5,A,ES10.3,A,ES10.3,A,ES10.3,A)') 'T: start moments about x ', rec(24, 0), & + rec(51, 0), ' N m (GJ Phi/L ', m0, '); |M_A + M_B| up to ', dev, ' N m; body roll asymmetry ', rdev, & + ' rad; roll at the end ', rx1, ' rad' + CALL require(ABS(ABS(rec(24, 0)) - m0) <= 1.0e-3_wp*m0, 'T: the start torque is GJ Phi / L') + CALL require(ABS(rec(24, 0) + rec(51, 0)) <= 1.0e-6_wp*m0, 'T: equal and opposite torques at the start') + CALL require(dev <= 1.0e-2_wp*mmax, 'T: equal and opposite end moments through the run') + CALL require(ABS(rx1) > 1.0e-3_wp, 'T: the torque turns the bodies') + CALL require(rdev <= 1.0e-6_wp + 1.0e-4_wp*ABS(rx1), 'T: the bodies counter-rotate') + END SUBROUTINE check_torsion + + ! ------------------------------------------------------------------------------------------ + SUBROUTINE write_moored_pair(path, tmax, conn, stiff, reversed) + !! Two buoyant bodies (2e4 kg, 40 m^3, C44 = C55 = 2e6 N m/rad) at x = -30 and +30 m, each on + !! three EI = 0 legs, joined keel to keel by a 64 m finite-EI cable clamped at both ends + !! (connection conn, Ez along the end tangents); mirror symmetric about x = 0. + CHARACTER(*), INTENT(IN) :: path, conn + REAL(wp), INTENT(IN) :: tmax + ! stiff: EI 1e6 N m^2, body 2 of 2.5e4 kg and its cable point at (0.5, 0.3, -3) (no symmetry); + ! reversed: the cable written from body 2 to body 1 + LOGICAL, INTENT(IN), OPTIONAL :: stiff, reversed + LOGICAL :: stf, rev + INTEGER :: u + stf = .FALSE. + IF (PRESENT(stiff)) stf = stiff + rev = .FALSE. + IF (PRESENT(reversed)) rev = reversed + OPEN (NEWUNIT=u, FILE=path, STATUS='REPLACE', ACTION='WRITE') + WRITE (u, '(A)') 'cable between two moored bodies: statics' + WRITE (u, '(A)') '--- LINE TYPES ---' + WRITE (u, '(A)') 'Name Diam Mass EA BA EI Cdn Cdt Can Cat' + WRITE (u, '(A)') '(-) (m) (kg/m) (N) (-) (Nm2) (-) (-) (-) (-)' + WRITE (u, '(A)') 'poly 0.12 15.0 5.0e7 -1.0 0.0 1.2 0.2 1.0 0.0' + WRITE (u, '(A)') 'cab 0.2 60.0 5.0e8 -1.0 '//MERGE('1.0e6', '2.0e4', stf)//' 1.2 0.0 1.0 0.0' + 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)' + WRITE (u, '(A)') '1 Rigid6 -30 0 -20 0 0 0 2.0e4 40.0 0.0 2.0e6 2.0e6 8.0 0.5 3.5e4 3.5e4 3.5e4' + WRITE (u, '(A)') '2 Rigid6 30 0 -20 0 0 0 '//MERGE('2.5e4', '2.0e4', stf)//' 40.0 0.0 2.0e6 2.0e6 8.0 0.5 '// & + '3.5e4 3.5e4 3.5e4' + 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 Body1 -1.5 0.0 -2.0 0 0 0 0' + WRITE (u, '(A)') '2 Body1 0.75 1.299 -2.0 0 0 0 0' + WRITE (u, '(A)') '3 Body1 0.75 -1.299 -2.0 0 0 0 0' + WRITE (u, '(A)') '4 Fixed -70.0 0.0 -100.0 0 0 0 0' + WRITE (u, '(A)') '5 Fixed -10.0 34.641 -100.0 0 0 0 0' + WRITE (u, '(A)') '6 Fixed -10.0 -34.641 -100.0 0 0 0 0' + WRITE (u, '(A)') '7 Body2 1.5 0.0 -2.0 0 0 0 0' + WRITE (u, '(A)') '8 Body2 -0.75 1.299 -2.0 0 0 0 0' + WRITE (u, '(A)') '9 Body2 -0.75 -1.299 -2.0 0 0 0 0' + WRITE (u, '(A)') '10 Fixed 70.0 0.0 -100.0 0 0 0 0' + WRITE (u, '(A)') '11 Fixed 10.0 34.641 -100.0 0 0 0 0' + WRITE (u, '(A)') '12 Fixed 10.0 -34.641 -100.0 0 0 0 0' + WRITE (u, '(A)') '13 Body1 0.0 0.0 -3.0 0 0 0 0' + WRITE (u, '(A)') '14 Body2 '//MERGE('0.5 0.3', '0.0 0.0', stf)//' -3.0 0 0 0 0' + WRITE (u, '(A)') '--- LINES ---' + WRITE (u, '(A)') 'ID NodeA NodeB Outputs' + WRITE (u, '(A)') '(-) (-) (-) (-)' + WRITE (u, '(A)') '1 1 4 -' + WRITE (u, '(A)') '2 2 5 -' + WRITE (u, '(A)') '3 3 6 -' + WRITE (u, '(A)') '4 7 10 -' + WRITE (u, '(A)') '5 8 11 -' + WRITE (u, '(A)') '6 9 12 -' + WRITE (u, '(A)') MERGE('7 14 13 -', '7 13 14 -', rev) + WRITE (u, '(A)') '--- SECTIONS ---' + WRITE (u, '(A)') 'LineID LineType Length NumSegs' + WRITE (u, '(A)') '(-) (-) (m) (-)' + WRITE (u, '(A)') '1 poly 86.85 20' + WRITE (u, '(A)') '2 poly 86.85 20' + WRITE (u, '(A)') '3 poly 86.85 20' + WRITE (u, '(A)') '4 poly 86.85 20' + WRITE (u, '(A)') '5 poly 86.85 20' + WRITE (u, '(A)') '6 poly 86.85 20' + WRITE (u, '(A)') '7 cab 64.0 40' + WRITE (u, '(A)') '--- END CONNECTIONS ---' + WRITE (u, '(A)') 'LineID End Stiffness EzX EzY EzZ' + WRITE (u, '(A)') '(-) (-) (N-m/rad) (-) (-) (-)' + IF (rev) THEN + ! End A on body 2, the directions from End A to End B + WRITE (u, '(A)') '7 A '//conn//' -0.7071067811865476 0.0 -0.7071067811865476' + WRITE (u, '(A)') '7 B '//conn//' -0.7071067811865476 0.0 0.7071067811865476' + ELSE + WRITE (u, '(A)') '7 A '//conn//' 0.7071067811865476 0.0 -0.7071067811865476' + WRITE (u, '(A)') '7 B '//conn//' 0.7071067811865476 0.0 0.7071067811865476' + END IF + WRITE (u, '(A)') '--- OPTIONS ---' + WRITE (u, '(A)') '100.0 WtrDpth' + WRITE (u, '(A)') '9.80665 g' + WRITE (u, '(A)') '1025.0 rhoW' + WRITE (u, '(A)') '1.0e5 kBot' + WRITE (u, '(A)') '1.0e4 cBot' + WRITE (u, '(A)') '0.05 dtM' + WRITE (u, '(ES12.5,A)') tmax, ' TMax' + WRITE (u, '(A)') 'static bodyIC' + WRITE (u, '(A)') '--- OUTPUTS ---' + IF (stf) THEN + WRITE (u, '(A)') 'Body1Px Body1Py Body1Pz Body1Rx Body1Ry Body1Rz Body2Px Body2Py Body2Pz Body2Rx Body2Ry Body2Rz' + ELSE + WRITE (u, '(A)') 'Body1Px Body1Pz Body1Ry Body2Px Body2Pz Body2Ry' + END IF + WRITE (u, '(A)') '--- END ---' + CLOSE (u) + END SUBROUTINE write_moored_pair + + SUBROUTINE check_stiff_statics() + !! P. The stiff, unequal, out-of-plane pair, written in both directions: the static passes + !! converge to one equilibrium (1e-6 m and deg), held by the still dynamics over 5 s + !! (2e-6); with two passes allowed the solve fails closed naming the line. + REAL(wp) :: rf(13, 200), rr(13, 200), d0, drift + INTEGER :: nf, nr, k + LOGICAL :: okf, okr + CHARACTER(1024) :: em + CALL write_moored_pair('cbb_stiff_fwd.dat', 5.0_wp, 'Rigid', stiff=.TRUE.) + CALL write_moored_pair('cbb_stiff_rev.dat', 5.0_wp, 'Rigid', stiff=.TRUE., reversed=.TRUE.) + CALL run_deck('cbb_stiff_fwd.dat', 'cbb_stiff_fwd', okf, em) + CALL require(okf, 'P: the stiff pair (forward) balances and runs: '//TRIM(em)) + CALL run_deck('cbb_stiff_rev.dat', 'cbb_stiff_rev', okr, em) + CALL require(okr, 'P: the stiff pair (reversed) balances and runs: '//TRIM(em)) + IF (.NOT. (okf .AND. okr)) RETURN + CALL read_rows('cbb_stiff_fwd.out', rf, nf, okf) + CALL read_rows('cbb_stiff_rev.out', rr, nr, okr) + CALL require(okf .AND. okr .AND. nf == nr, 'P: stiff pair outputs readable') + IF (.NOT. (okf .AND. okr .AND. nf == nr)) RETURN + d0 = nan_max_abs(rf(2:13, 1) - rr(2:13, 1)) + drift = 0.0_wp + DO k = 1, nf + drift = nan_max_abs([drift, rf(2:13, k) - rf(2:13, 1), rr(2:13, k) - rr(2:13, 1)]) + END DO + WRITE (*, '(A,ES10.3,A,ES10.3,A,F9.4,A,F9.4,A)') 'P: stiff pair, forward vs reversed start ', d0, & + '; drift over 5 s ', drift, ' (pitches ', rf(6, 1), ' / ', rf(12, 1), ' deg)' + CALL require(d0 <= 1.0e-6_wp, 'P: both directions reach the same equilibrium') + CALL require(drift <= 2.0e-6_wp, 'P: the still dynamics hold the equilibrium') + ! the non-convergence report names the line (whichever end's entry is the worst) + CALL CD_Body_Static_Pass_Limit(2) + CALL run_deck('cbb_stiff_fwd.dat', 'cbb_stiff_lim', okf, em) + CALL CD_Body_Static_Pass_Limit(0) + WRITE (*, '(A,A)') 'P: two passes: ', TRIM(em) + CALL require(.NOT. okf .AND. INDEX(em, 'finite-EI LINE 7') > 0 .AND. INDEX(em, 'after 2 passes') > 0, & + 'P: the limited static passes fail closed naming the line') + END SUBROUTINE check_stiff_statics + + ! ------------------------------------------------------------------------------------------ + SUBROUTINE write_rod_line(path, kind, end_b_conn, rod_type) + !! A cable between a Fixed point (1, 0, -50) and the end A (21, 0, -50) of a rod spanning to + !! (31, 0, -50), rod type rod_type (Free or Fixed): kind 'fr' from the Fixed point to the rod + !! end, 'rf' the reverse, 'bp' from body 1's point to the rod end, 'bf' from body 1's point to + !! a Fixed point at the rod end; End B's connection end_b_conn. + CHARACTER(*), INTENT(IN) :: path, kind, end_b_conn, rod_type + INTEGER :: u + OPEN (NEWUNIT=u, FILE=path, STATUS='REPLACE', ACTION='WRITE') + WRITE (u, '(A)') 'cable to a rod end' + WRITE (u, '(A)') '--- LINE TYPES ---' + WRITE (u, '(A)') 'Name Diam Mass EA BA EI Cdn Cdt Can Cat' + WRITE (u, '(A)') '(-) (m) (kg/m) (N) (-) (Nm2) (-) (-) (-) (-)' + WRITE (u, '(A)') 'cab 0.2 60.0 1.0e6 0.0 1.0e4 0.0 0.0 0.0 0.0' + IF (kind == 'bp' .OR. kind == 'bf') 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)' + WRITE (u, '(A,ES24.16,A)') '1 Rigid6 0 0 -50 0 0 0 5.0e3 ', 5.0e3_wp/RHOW, ' 0 0 0 0 0 2.0e3 3.0e3 4.0e3' + END IF + WRITE (u, '(A)') '--- ROD TYPES ---' + WRITE (u, '(A)') 'Name Diam Mass Cd Ca CdEnd CaEnd CdAx CaAx' + WRITE (u, '(A)') '(-) (m) (kg/m) (-) (-) (-) (-) (-) (-)' + WRITE (u, '(A)') 'spar 1.0 805.0 0.8 1.0 0.0 0.0 0.2 0.0' + WRITE (u, '(A)') '--- RODS ---' + WRITE (u, '(A)') 'ID RodType Type XA YA ZA XB YB ZB NumSegs Outputs' + WRITE (u, '(A)') '(-) (-) (-) (m) (m) (m) (m) (m) (m) (-) (-)' + WRITE (u, '(A)') '1 spar '//rod_type//' 21.0 0 -50 31.0 0 -50 1 -' + 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) (-)' + SELECT CASE (kind) + CASE ('fr', 'rf') + WRITE (u, '(A)') '1 Fixed 1.0 0 -50 0 0 0 0' + WRITE (u, '(A)') '2 Rod1A 21.0 0 -50 0 0 0 0' + CASE ('bp') + WRITE (u, '(A)') '1 Body1 1.0 0 0 0 0 0 0' + WRITE (u, '(A)') '2 Rod1A 21.0 0 -50 0 0 0 0' + CASE DEFAULT + WRITE (u, '(A)') '1 Body1 1.0 0 0 0 0 0 0' + WRITE (u, '(A)') '2 Fixed 21.0 0 -50 0 0 0 0' + END SELECT + WRITE (u, '(A)') '--- LINES ---' + WRITE (u, '(A)') 'ID NodeA NodeB Outputs' + WRITE (u, '(A)') '(-) (-) (-) (-)' + WRITE (u, '(A)') MERGE('1 2 1 -', '1 1 2 -', kind == 'rf') + WRITE (u, '(A)') '--- SECTIONS ---' + WRITE (u, '(A)') 'LineID LineType Length NumSegs' + WRITE (u, '(A)') '(-) (-) (m) (-)' + WRITE (u, '(A)') '1 cab 20.5 20' + WRITE (u, '(A)') '--- END CONNECTIONS ---' + WRITE (u, '(A)') 'LineID End Stiffness EzX EzY EzZ' + WRITE (u, '(A)') '(-) (-) (N-m/rad) (-) (-) (-)' + IF (kind == 'rf') THEN + WRITE (u, '(A)') '1 A '//end_b_conn//' -1.0 0.0 0.0' + WRITE (u, '(A)') '1 B Pinned -1.0 0.0 0.0' + ELSE + WRITE (u, '(A)') '1 A Pinned 1.0 0.0 0.0' + WRITE (u, '(A)') '1 B '//end_b_conn//' 1.0 0.0 0.0' + END IF + CALL option_rows(u, 'monolithic', 'deck', 0.02_wp, 3.0_wp) + WRITE (u, '(A)') '--- OUTPUTS ---' + IF (kind == 'fr' .OR. kind == 'rf') THEN + WRITE (u, '(A)') 'Rod1Px Rod1Pz Rod1Ry FairTen1 AnchTen1' + ELSE + WRITE (u, '(A)') 'Body1Px Body1Pz Body1Ry FairTen1 AnchTen1' + END IF + WRITE (u, '(A)') '--- END ---' + CLOSE (u) + END SUBROUTINE write_rod_line + + SUBROUTINE check_direction() + !! D. A cable from a Fixed point to a free rod's end and the same cable written from the rod + !! end to the Fixed point (pinned, and rigid at the rod) move the rod alike and carry the + !! same end tensions, byte for byte in the output (the line written from the Fixed point is + !! turned around to start at the rod end, so FairTen is the rod end's in both); + !! a body's cable to a fixed rod's end writes the output of the same cable to a Fixed point + !! there: byte for byte pinned, to the output's last digit rigid at End B (whose + !! connection direction passes through the rod's frame). + REAL(wp) :: a(6, 200), b(6, 200) + INTEGER :: na, nb, ic + LOGICAL :: ok, oka, okb + CHARACTER(1024) :: em + CHARACTER(8) :: conn + DO ic = 1, 2 + conn = MERGE('Pinned', 'Rigid ', ic == 1) + CALL write_rod_line('cbb_fr.dat', 'fr', TRIM(conn), 'Free') + CALL write_rod_line('cbb_rf.dat', 'rf', TRIM(conn), 'Free') + CALL run_deck('cbb_fr.dat', 'cbb_fr', oka, em) + CALL require(oka, 'D: Fixed point to rod end runs ('//TRIM(conn)//'): '//TRIM(em)) + CALL run_deck('cbb_rf.dat', 'cbb_rf', okb, em) + CALL require(okb, 'D: rod end to Fixed point runs ('//TRIM(conn)//'): '//TRIM(em)) + IF (.NOT. (oka .AND. okb)) CYCLE + CALL read_rows('cbb_fr.out', a, na, oka) + CALL read_rows('cbb_rf.out', b, nb, okb) + ok = oka .AND. okb .AND. na == nb + IF (ok) ok = ALL(a(1:6, 1:na) == b(1:6, 1:nb)) + WRITE (*, '(A,A,A,L1)') 'D (', TRIM(conn), '): either direction, the same rod motion and end tensions: ', ok + CALL require(ok, 'D: the coupling does not depend on the line direction ('//TRIM(conn)//')') + CALL write_rod_line('cbb_bp.dat', 'bp', TRIM(conn), 'Fixed') + CALL write_rod_line('cbb_bf.dat', 'bf', TRIM(conn), 'Fixed') + CALL run_deck('cbb_bp.dat', 'cbb_bp', oka, em) + CALL run_deck('cbb_bf.dat', 'cbb_bf', okb, em) + CALL require(oka .AND. okb, 'D: body to fixed rod end / Fixed point run ('//TRIM(conn)//'): '//TRIM(em)) + IF (.NOT. (oka .AND. okb)) CYCLE + IF (ic == 1) THEN + ok = same_file('cbb_bp.out', 'cbb_bf.out') + WRITE (*, '(A,A,A,L1)') 'D (', TRIM(conn), '): End B on a fixed rod''s end is the Fixed End B, byte for '// & + 'byte: ', ok + ELSE + CALL read_rows('cbb_bp.out', a, na, oka) + CALL read_rows('cbb_bf.out', b, nb, okb) + ok = oka .AND. okb .AND. na == nb + IF (ok) ok = ALL(ABS(a(:, 1:na) - b(:, 1:nb)) <= 1.0e-7_wp*MAX(1.0_wp, ABS(b(:, 1:nb)))) + WRITE (*, '(A,A,A,L1)') 'D (', TRIM(conn), '): End B on a fixed rod''s end is the Fixed End B, to the '// & + 'output precision: ', ok + END IF + CALL require(ok, 'D: an End B on a fixed rod writes the Fixed End B''s output ('//TRIM(conn)//')') + END DO + END SUBROUTINE check_direction + + LOGICAL FUNCTION same_file(p1, p2) RESULT(same) + !! The two files are equal line by line. + CHARACTER(*), INTENT(IN) :: p1, p2 + INTEGER :: u1, u2, i1, i2 + CHARACTER(2048) :: l1, l2 + same = .FALSE. + OPEN (NEWUNIT=u1, FILE=p1, STATUS='OLD', ACTION='READ', IOSTAT=i1) + OPEN (NEWUNIT=u2, FILE=p2, STATUS='OLD', ACTION='READ', IOSTAT=i2) + IF (i1 /= 0 .OR. i2 /= 0) RETURN + DO + READ (u1, '(A)', IOSTAT=i1) l1 + READ (u2, '(A)', IOSTAT=i2) l2 + IF (i1 /= 0 .OR. i2 /= 0) EXIT + IF (l1 /= l2) THEN + CLOSE (u1) + CLOSE (u2) + RETURN + END IF + END DO + same = i1 /= 0 .AND. i2 /= 0 + CLOSE (u1) + CLOSE (u2) + END FUNCTION same_file + + SUBROUTINE check_statics() + !! Q. bodyIC static balances both bodies on the clamped cable: over 5 s of dynamics they + !! stay at rest (1 mm, 1e-3 deg), mirror images of each other, and the connection moments + !! turn them from their pitch on the pinned cable. + REAL(wp) :: rows(7, 200), drift, rdrift, sym, prow(7, 2) + INTEGER :: n, k + LOGICAL :: ok + CHARACTER(1024) :: em + CALL write_moored_pair('cbb_static.dat', 5.0_wp, 'Rigid') + CALL run_deck('cbb_static.dat', 'cbb_static', ok, em) + CALL require(ok, 'Q: the moored two-body deck runs: '//TRIM(em)) + IF (.NOT. ok) RETURN + CALL read_rows('cbb_static.out', rows, n, ok) + CALL require(ok, 'Q: output readable') + IF (.NOT. ok) RETURN + drift = 0.0_wp + rdrift = 0.0_wp + sym = 0.0_wp + DO k = 1, n + drift = nan_max_abs([drift, rows(2:3, k) - rows(2:3, 1), rows(5:6, k) - rows(5:6, 1)]) + rdrift = nan_max_abs([rdrift, rows(4, k) - rows(4, 1), rows(7, k) - rows(7, 1)]) + sym = nan_max_abs([sym, rows(2, k) + rows(5, k), rows(3, k) - rows(6, k), rows(4, k) + rows(7, k)]) + END DO + WRITE (*, '(A,F10.5,A,F10.5,A,ES10.3,A,ES10.3,A,ES10.3)') 'Q: static pitch ', rows(4, 1), ' / ', rows(7, 1), & + ' deg; drift over 5 s ', drift, ' m, ', rdrift, ' deg; mirror deviation ', sym + CALL require(drift <= 1.0e-3_wp, 'Q: both bodies at rest in the dynamics (1 mm)') + CALL require(rdrift <= 1.0e-3_wp, 'Q: both pitches at rest (1e-3 deg)') + CALL require(sym <= 1.0e-5_wp, 'Q: the static pair is mirror symmetric') + CALL write_moored_pair('cbb_static_pin.dat', 0.05_wp, 'Pinned') + CALL run_deck('cbb_static_pin.dat', 'cbb_static_pin', ok, em) + CALL require(ok, 'Q: the moored pair on a pinned cable runs: '//TRIM(em)) + IF (.NOT. ok) RETURN + CALL read_rows('cbb_static_pin.out', prow, n, ok) + IF (.NOT. ok) RETURN + WRITE (*, '(A,F10.5,A,F10.5,A)') 'Q: pitch of body 1, clamped ', rows(4, 1), ' deg, pinned ', prow(4, 1), ' deg' + CALL require(ABS(rows(4, 1) - prow(4, 1)) > 1.0e-2_wp, 'Q: the connection moments turn the bodies in statics') + END SUBROUTINE check_statics + + ! ------------------------------------------------------------------------------------------ + SUBROUTINE check_rod_and_refusals() + !! R. A pinned cable from a body point to the end of a free rod runs (both ends driven); an + !! End B on a Free point or a Coupled point, and a clamped End B on the staggered scheme, + !! are refused by name. + INTEGER :: u + LOGICAL :: ok + CHARACTER(1024) :: em + REAL(wp) :: rows(3, 300) + INTEGER :: n + OPEN (NEWUNIT=u, FILE='cbb_rod.dat', STATUS='REPLACE', ACTION='WRITE') + WRITE (u, '(A)') 'cable between a body and a rod end' + CALL line_type_rows(u, .FALSE.) + 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)' + WRITE (u, '(A,ES24.16,A)') '1 Rigid6 0 0 -50 0 0 0 5.0e3 ', 5.0e3_wp/RHOW, ' 0 0 0 0 0 2.0e3 3.0e3 4.0e3' + WRITE (u, '(A)') '--- ROD TYPES ---' + WRITE (u, '(A)') 'Name Diam Mass Cd Ca CdEnd CaEnd CdAx CaAx' + WRITE (u, '(A)') '(-) (m) (kg/m) (-) (-) (-) (-) (-) (-)' + WRITE (u, '(A)') 'spar 1.0 805.0 0.8 1.0 0.0 0.0 0.2 0.0' + WRITE (u, '(A)') '--- RODS ---' + WRITE (u, '(A)') 'ID RodType Type XA YA ZA XB YB ZB NumSegs Outputs' + WRITE (u, '(A)') '(-) (-) (-) (m) (m) (m) (m) (m) (m) (-) (-)' + WRITE (u, '(A)') '1 spar Free 21.0 0 -50 31.0 0 -50 1 -' + 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 Body1 1.0 0 0 0 0 0 0' + WRITE (u, '(A)') '2 Rod1A 21.0 0 -50 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 20.0 20' + CALL option_rows(u, 'monolithic', 'deck', 0.02_wp, 2.0_wp) + WRITE (u, '(A)') '--- OUTPUTS ---' + WRITE (u, '(A)') 'Body1Px FairTen1' + WRITE (u, '(A)') '--- END ---' + CLOSE (u) + CALL run_deck('cbb_rod.dat', 'cbb_rod', ok, em) + CALL require(ok, 'R: a cable between a body point and a rod end runs: '//TRIM(em)) + IF (ok) THEN + CALL read_rows('cbb_rod.out', rows, n, ok) + CALL require(ok .AND. n == 101, 'R: body-to-rod output complete and finite') + END IF + ! refusals + CALL refused('Free', 'monolithic', 'Pinned', 'Free/Connect point') + CALL refused('Coupled', 'monolithic', 'Pinned', 'Coupled/Vessel End B') + CALL refused('Body2', 'staggered', 'Rigid', 'needs bodyScheme monolithic') + ! a torsion frame at a bending-pinned body End A on the staggered scheme (which would hold + ! the frame still while the body turns) + CALL write_pair_deck('cbb_tors_stag.dat', 'fixed', .TRUE., 0.0_wp, 0.0_wp, 0.0_wp, scheme='staggered', & + bend_a='Pinned') + CALL run_deck('cbb_tors_stag.dat', 'cbb_tors_stag', ok, em) + CALL require(.NOT. ok .AND. INDEX(em, 'or a torsional one on a body or rod needs bodyScheme monolithic') > 0, & + 'R: a torsion frame at a body End A is refused on the staggered scheme: '//TRIM(em)) + CALL write_pair_deck('cbb_tors_mono.dat', 'fixed', .TRUE., 0.0_wp, 0.0_wp, 0.0_wp, bend_a='Pinned') + CALL run_deck('cbb_tors_mono.dat', 'cbb_tors_mono', ok, em) + CALL require(ok, 'R: the same deck runs on the monolithic scheme: '//TRIM(em)) + END SUBROUTINE check_rod_and_refusals + + SUBROUTINE refused(ptype, scheme, conn, key) + CHARACTER(*), INTENT(IN) :: ptype, scheme, conn, key + INTEGER :: u + LOGICAL :: ok + CHARACTER(1024) :: em + OPEN (NEWUNIT=u, FILE='cbb_refuse.dat', STATUS='REPLACE', ACTION='WRITE') + WRITE (u, '(A)') 'refused cable end' + CALL line_type_rows(u, .FALSE.) + WRITE (u, '(A)') 'leg 0.1 10.0 1.0e7 0.0 0.0 0.0 0.0 0.0 0.0' + CALL body_rows(u, 0.0_wp, 22.1_wp, -50.0_wp, 5.0e3_wp, 5.0e3_wp, [5.0e3_wp/RHOW, 5.0e3_wp/RHOW], 0.0_wp) + 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 Body1 1.0 0 0 0 0 0 0' + IF (ptype == 'Body2') THEN + WRITE (u, '(A)') '2 Body2 -1.0 0 0 0 0 0 0' + ELSE + WRITE (u, '(A)') '2 '//ptype//' 21.1 0 -50 0 0 0 0' + END IF + WRITE (u, '(A)') '3 Fixed 21.1 0 -100 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 2 3 -' + WRITE (u, '(A)') '--- SECTIONS ---' + WRITE (u, '(A)') 'LineID LineType Length NumSegs' + WRITE (u, '(A)') '(-) (-) (m) (-)' + WRITE (u, '(A)') '1 cab 20.0 20' + WRITE (u, '(A)') '2 leg 50.0 10' + WRITE (u, '(A)') '--- END CONNECTIONS ---' + WRITE (u, '(A)') 'LineID End Stiffness EzX EzY EzZ' + WRITE (u, '(A)') '(-) (-) (N-m/rad) (-) (-) (-)' + WRITE (u, '(A)') '1 B '//conn//' 1.0 0.0 0.0' + CALL option_rows(u, scheme, 'deck', 0.02_wp, 0.1_wp) + WRITE (u, '(A)') '--- OUTPUTS ---' + WRITE (u, '(A)') 'FairTen1' + WRITE (u, '(A)') '--- END ---' + CLOSE (u) + CALL run_deck('cbb_refuse.dat', 'cbb_refuse', ok, em) + CALL require(.NOT. ok .AND. INDEX(em, key) > 0, 'R: End B on a '//ptype//' point ('//scheme//', '//conn// & + ') is refused naming "'//key//'": '//TRIM(em)) + END SUBROUTINE refused + +END PROGRAM test_cable_between_bodies diff --git a/tests/test_deck_driver.f90 b/tests/test_deck_driver.f90 index 25787d3c..224a106d 100644 --- a/tests/test_deck_driver.f90 +++ b/tests/test_deck_driver.f90 @@ -1710,7 +1710,7 @@ PROGRAM test_deck_driver CALL expect_badinput('deck_equiv_bad.dat', deck_with_bad_equivalent_buoyancy(), 'negative dry mass') CALL expect_badinput('deck_finite_connect.dat', deck_with_finite_ei_connect(), 'finite-EI dynamic') CALL expect_badinput('deck_endconn_two_moving.dat', deck_with_two_moving_end_connection(), & - 'two-moving-end finite-EI END CONNECTIONS', 'Fixed End B') + 'END CONNECTIONS with End B on a Free point', 'need End B on a Fixed, Coupled or Vessel point') CALL expect_badinput('deck_finite_body_mix.dat', deck_with_finite_ei_body_mix(), 'finite-EI dynamic deck') CALL expect_badinput('deck_finite_rod_mix.dat', deck_with_finite_ei_rod_mix(), 'finite-EI dynamic deck') CALL expect_badinput('deck_rigid6_connect.dat', deck_with_rigid6_connect(), 'Rigid6 dynamic deck') @@ -7090,8 +7090,8 @@ CHARACTER(1400) FUNCTION deck_with_finite_ei_connect() RESULT(s) END FUNCTION deck_with_finite_ei_connect CHARACTER(1800) FUNCTION deck_with_two_moving_end_connection() RESULT(s) - !! A non-pinned connection must never fall through to the compatibility model, - !! which prescribes both endpoint translations but has no end-moment residual. + !! A non-pinned connection on a line whose End B is a Free point (a dynamic point the cubic-Hermite + !! boundary cannot hold or drive) is refused by name, never run as a pinned end. s = 'two-moving-end-connection'//NEW_LINE('a')//'--- LINE TYPES ---'//NEW_LINE('a')// & 'Name Diam Mass EA BA EI Cdn Cdt Can Cat'//NEW_LINE('a')// & '(-) (m) (kg/m) (N) (-) (Nm2) (-) (-) (-) (-)'//NEW_LINE('a')// & diff --git a/tests/test_mixed_route_torsion.f90 b/tests/test_mixed_route_torsion.f90 index 57bf791d..ec685c8d 100644 --- a/tests/test_mixed_route_torsion.f90 +++ b/tests/test_mixed_route_torsion.f90 @@ -35,6 +35,13 @@ !> 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. +!> 8. The gate 3 line between two moving points (End B on a Coupled point, its own aggregate +!> column): the roll columns of both ends impose Phi = Pretwist(B) - Pretwist(A) - roll(A) - +!> roll(B). Opposite rolls (a rigid roll of the line about its axis) keep Twist1 = 90 deg and +!> equal rolls give 90 - 2 roll, with Torq = GJ Twist / L at both ends (1e-6 GJ); the same +!> with End B's point listed first in POINTS (the moving columns follow the cables, End A +!> columns then End B columns, not the POINTS order). Fails if the roll of a two-moving-end +!> cable is dropped or an end's motion is read from another moving column. 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, & @@ -82,6 +89,9 @@ PROGRAM test_mixed_route_torsion CALL check_static_row1() CALL check_static_blend() CALL check_attachment_routes() + CALL check_two_moving_roll(-1.0_wp) + CALL check_two_moving_roll(1.0_wp) + CALL check_two_moving_roll(1.0_wp, b_first=.TRUE.) IF (n_fail > 0) THEN WRITE (*, '(A,I0,A)') 'FAIL: ', n_fail, ' mixed-route torsion gate(s) failed' ERROR STOP 1 @@ -654,6 +664,72 @@ SUBROUTINE check_quasi_static(mode) 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_two_moving_roll(sense, b_first) + !! Gate 8: the gate 3 line with End B on the Coupled point 2 at (100, 0, -50), rolled with End + !! A by the roll column, roll(B) = sense roll(A): Twist1 = 90 - (1 + sense) roll. b_first: the + !! same line with the point ids of its ends exchanged (End B on point 1, End A on point 2), so + !! End B's point comes first in POINTS. + REAL(wp), INTENT(IN) :: sense + LOGICAL, INTENT(IN), OPTIONAL :: b_first + REAL(wp), PARAMETER :: GJ = 5.0e4_wp, L = 100.0_wp + CHARACTER(48) :: points(4) + CHARACTER(32) :: names(MAXCOL) + REAL(wp), ALLOCATABLE :: vals(:, :) + REAL(wp) :: t, ro, dro, d2ro, werr, terr, twist + INTEGER :: u, k, nrow, pa, pb + LOGICAL :: ok, bf + CHARACTER(24) :: label + CHARACTER(16) :: line1 + bf = .FALSE. + IF (PRESENT(b_first)) bf = b_first + label = MERGE('8 equal rolls ', '8 opposite rolls', sense > 0.0_wp) + IF (bf) label = '8 End B first' + ! the point ids of End A and End B + pa = MERGE(2, 1, bf) + pb = 3 - pa + OPEN (NEWUNIT=u, FILE='tmrt_two_motion.txt', STATUS='REPLACE', ACTION='WRITE') + DO k = 0, 100 + t = 0.1_wp*k + CALL smooth(15.0_wp, t, ro, dro, d2ro) + WRITE (u, '(F8.3,1X,I0,A,ES25.16E3)') t, pa, ' 0 0 -50 0 0 0 0 0 0 ', ro + WRITE (u, '(F8.3,1X,I0,A,ES25.16E3)') t, pb, ' 100 0 -50 0 0 0 0 0 0 ', sense*ro + WRITE (u, '(F8.3,A)') t, ' 3 0 10 -50 0 0 0 0 0 0' + END DO + CLOSE (u) + points(pa) = ACHAR(48 + pa)//' Coupled 0.0 0.0 -50.0 0 0 0 0' + points(pb) = ACHAR(48 + pb)//' Coupled 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' + line1 = '1 '//ACHAR(48 + pa)//' '//ACHAR(48 + pb)//' -' + CALL write_deck('tmrt_two.dat', [CHARACTER(160) :: neutral_t, CHAIN_T], points, & + [CHARACTER(16) :: line1, '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', '10.0 TMax', 'tmrt_two_motion.txt motionFile'], & + [CHARACTER(16) :: 'Torq1N1', 'Torq1N41', 'Twist1', 'FairTen2']) + CALL run_driver('tmrt_two.dat', 'tmrt_two', ok) + CALL require(ok, TRIM(label)//': the mixed deck with a line between two moving points runs') + ALLOCATE (vals(MAXROW, MAXCOL)) + CALL read_out('tmrt_two.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(15.0_wp, vals(k, 1), ro, dro, d2ro) + twist = 90.0_wp - (1.0_wp + sense)*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(A) - roll(B) 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_two_moving_roll + SUBROUTINE check_refusal() !! Gate 4. LOGICAL :: ok diff --git a/tests/test_rod_end_torsion.f90 b/tests/test_rod_end_torsion.f90 index 3923feb2..c6f5f81e 100644 --- a/tests/test_rod_end_torsion.f90 +++ b/tests/test_rod_end_torsion.f90 @@ -426,17 +426,16 @@ SUBROUTINE check_refusals() ! 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', & + 'or a torsional one 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 + ! a line between two Fixed rods (a J-tube to a J-tube): no torsion frame at End B's 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') + 'line 1: a torsional END CONNECTION on a rod end is not supported at End B') END SUBROUTINE check_refusals SUBROUTINE refused_rows(label, rod_rows, line_row, ez_z, needle) diff --git a/tests/test_static_friction_as_laid.py b/tests/test_static_friction_as_laid.py index 6482c12d..2235fa52 100644 --- a/tests/test_static_friction_as_laid.py +++ b/tests/test_static_friction_as_laid.py @@ -46,8 +46,8 @@ 1e-6 m, end forces) and a march from it stays at rest; * input checks: ``layAzimuth`` of a line that does not exist (also one too large for an integer), an unknown suffix and an unknown policy are rejected, and the ```` rows take - effect; a finite-EI line shared between two turbines (End B not Fixed, the compatibility route, - whose statics have no seabed friction) rejects asLaid by name and runs with none. + effect; a finite-EI line shared between two turbines (both ends moving: no anchored end to lay + the line from) rejects asLaid by name and runs with none. usage: test_static_friction_as_laid.py --exe --output """ @@ -704,8 +704,8 @@ def of_line(row: dict, i: int) -> dict: extra="nan layAzimuth1\n30.0 layAzimuth1\n")) check(rc != 0 and "layAzimuth1" in log, "a NaN layAzimuth1 shadowed by a valid row is rejected") - # a finite-EI line shared between two turbines (End B not Fixed) runs the compatibility route, - # whose statics carry no seabed friction: asLaid fails closed there by name, none runs + # a finite-EI line shared between two turbines (both ends moving) has no anchored end to lay it + # from: asLaid fails closed by name, none runs shared = dict(ei=1.0e4, length=600.0, nseg=60, fair=(0, 0, -10), anch=(0, 0, -10), seabed="200.0 WtrDpth", mu=0.5) for tag, extra in (("shared", ""), ("shared_none", "none staticsFriction\n")): txt = deck("shared " + tag, **shared, extra=extra, tmax=0.2) diff --git a/tests/test_two_moving_ends.f90 b/tests/test_two_moving_ends.f90 new file mode 100644 index 00000000..d7c2aa63 --- /dev/null +++ b/tests/test_two_moving_ends.f90 @@ -0,0 +1,1513 @@ +! File: tests/test_two_moving_ends.f90 +! SPDX-License-Identifier: Apache-2.0 +! Copyright (c) 2026 Jae Hoon Seo, SMI Lab, Inha University +PROGRAM test_two_moving_ends + !! Gates of a finite-EI (cubic-Hermite) line with two moving ends: End B a second host-driven end + !! of the cable (CD_HFMF_Set_Moving_End_B), a line between two moving points. Before this route the + !! decks below were refused (End B had to be Fixed, except a Turbine shared line, which ran on + !! a separate compatibility solver) and the boundary had no End B input. + !! Z zero motion: a line between a driven Coupled End A and a Coupled End B whose motionFile rows + !! hold it at its deck position writes the .out, line, element and static files of the same + !! line with a Fixed End B byte for byte; so does the pair without a motionFile (both held), + !! and the modal analysis (OPTION nModes: the modes hold both ends) writes the same modes file; + !! also with the chord at a 37 deg heading (the cable solves in a frame turned about +z, so a + !! held End B read back in global axes is the rotated committed position); + !! S symmetry: a symmetric suspended cable whose two ends move mirror-symmetrically (apart and up) + !! stays mirror symmetric -- node positions and the two end loads -- to round-off at every step; + !! G rigid translation (Galilean invariance, no fluid drag): both ends translating at one constant + !! velocity v, the line started with that velocity, reproduce the held line shifted by v t: + !! positions and both end loads to round-off, so the tension does not change. + !! Round-off of the end loads: the axial force carries EA times the round-off of the element + !! strain, about EA eps L/h = 1e-5 N on this 8e8 N line (1e-9 of its tension), hence the 1e-8 + !! relative bound of S and G; + !! R reversal: a line driven at its End B equals the same line written in reverse and driven at + !! its End A (the established End A boundary): the end tensions agree to the solver tolerances; + !! C restart: with both ends moving, a run restored from a snapshot, and a cable rebuilt from the + !! deck and reloaded from the checkpoint mirror, continue bit-identically; + !! END CONNECTIONS and torsion at a moving End B (its connection direction and torsion frame are + !! held by End B's own parent and turn with it): + !! ZT zero motion: a straight line clamped and twisted 90 deg between a surging, rolling End A and a + !! held Coupled End B writes the files of the same line with a Fixed End B byte for byte; + !! TS both end frames rolled by the same angle about the line (a vessel rolling about the axis of a + !! twisted line between two of its points): the torque does not change; + !! TO opposite rolls of the two end frames (the motionFile roll column of both ends, each about its + !! inward tangent; and two parent orientations rolled by +phi and -phi): the torque changes by + !! GJ (2 phi) / L; + !! B bending reversal: a line with elastic or clamped connections, driven at End B by a parent that + !! translates and turns, equals the same line written in reverse and driven at its End A by the + !! same parent motion (the established End A boundary): end forces and connection moments; + !! CT restart with torsion, the nodal twist and both end frames turning: snapshot and mirror + !! rebuild continue bit-identically; + !! the coupled aggregate (OpenFAST, FAST.Farm, the C API), one moving column per end: + !! F FAST.Farm: a line shared by two turbines takes its End A from turbine 1's column and its End B + !! from turbine 2's (the turbine map), and, driven by prescribed turbine motions, reports the + !! end tensions of the standalone TURBINES deck run with the same motions (solver tolerances); + !! FT the torsional line between two host-driven columns, each turned by its own host orientation: + !! equal rolls keep the torque, opposite rolls change it by GJ (2 phi) / L; + !! FP a standalone TURBINES deck whose turbines start yawed (PtfmInit) reads each end's Ez and Nx + !! in its turbine's axes, as FAST.Farm does: the clamped, twisted line between the two turbines + !! reports the FAST.Farm aggregate's tensions, torque and end curvature (solver tolerances); + !! FR the same line with the turbines rolling (motionFile TURBINES rows with their quaternions): + !! both end frames turn with their turbines, standalone as in the FAST.Farm aggregate. + USE CableDyn_Precision, ONLY: wp + USE CableDyn_DeckDriver, ONLY: CD_Run_Deck_Driver, CD_Init_Deck_HermiteCable, CD_DECKDRV_OK + USE CableDyn_OpenFAST_Aggregate, ONLY: CD_AGG_ModuleType, CD_AGG_Init_From_Deck, CD_AGG_Step_Moving, & + CD_AGG_NMovingPoints, CD_AGG_TurbineOfMoving, CD_AGG_NumChannels, & + CD_AGG_EvalChannel, CD_AGG_GetMovingPointMesh, CD_AGG_End, CD_AGG_OK + USE CableDyn_OpenFAST_HermiteFMF, ONLY: CD_HFMF_ModuleType, CD_HFMF_UpdateStates, CD_HFMF_CalcOutput, & + CD_HFMF_GetNodePositions, CD_HFMF_GetCoupledKinematics, & + CD_HFMF_GetEndBKinematics, CD_HFMF_Snapshot, CD_HFMF_Restore, & + 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 + REAL(wp), PARAMETER :: DT = 0.05_wp, SPAN = 80.0_wp, ZE = -20.0_wp + INTEGER :: nfail = 0 + + CALL check_zero_motion() + CALL check_symmetry() + CALL check_rigid_translation() + CALL check_reversal() + CALL check_restart() + CALL check_zero_motion_torsion() + CALL check_same_roll() + CALL check_opposite_roll() + CALL check_bending_reversal('finite') + CALL check_bending_reversal('clamped') + CALL check_torsion_restart() + CALL check_farm_shared_line() + CALL check_aggregate_torsion() + CALL check_farm_ptfm_parity() + CALL check_farm_rotation_parity() + + IF (nfail > 0) THEN + WRITE (*, '(A,I0,A)') 'FAIL: ', nfail, ' assertion(s) failed' + ERROR STOP 1 + END IF + WRITE (*, '(A)') 'PASS: two moving ends 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 + + SUBROUTINE write_deck(path, type_b, motion, tmax, cd, pa, pb, flags, extra) + !! A 100 m finite-EI line between POINT 1 (End A, Coupled) at pa and POINT 2 (End B, type_b) at + !! pb, 40 elements, no seabed; cd the normal and tangential drag coefficient; motion a motionFile + !! path or blank; flags the LINES Outputs flags; extra an OPTIONS row. + CHARACTER(*), INTENT(IN) :: path, type_b, motion, flags + REAL(wp), INTENT(IN) :: tmax, cd, pa(3), pb(3) + CHARACTER(*), INTENT(IN), OPTIONAL :: extra + INTEGER :: u + OPEN (NEWUNIT=u, FILE=path, STATUS='REPLACE', ACTION='WRITE') + WRITE (u, '(A)') 'two moving ends gate' + WRITE (u, '(A)') '--- LINE TYPES ---' + WRITE (u, '(A)') 'Name Diam Mass EA BA EI Cdn Cdt Can Cat' + WRITE (u, '(A)') '(-) (m) (kg/m) (N) (-) (Nm2) (-) (-) (-) (-)' + WRITE (u, '(A,F4.2,A,F4.2,A)') 'pcable 0.20 60 8.0e8 0.0 2.0e4 ', cd, ' ', cd, ' 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,3(1X,F8.3),A)') '1 Coupled', pa, ' 0 0 0 0' + WRITE (u, '(A,3(1X,F8.3),A)') '2 '//type_b, pb, ' 0 0 0 0' + WRITE (u, '(A)') '--- LINES ---' + WRITE (u, '(A)') 'ID NodeA NodeB Outputs' + WRITE (u, '(A)') '(-) (-) (-) (-)' + WRITE (u, '(A)') '1 1 2 '//flags + WRITE (u, '(A)') '--- SECTIONS ---' + WRITE (u, '(A)') 'LineID LineType Length NumSegs' + WRITE (u, '(A)') '(-) (-) (m) (-)' + WRITE (u, '(A)') '1 pcable 100.0 40' + WRITE (u, '(A)') '--- OPTIONS ---' + WRITE (u, '(A)') '9.80665 g' + WRITE (u, '(A)') '1025.0 rhoW' + WRITE (u, '(F6.3,A)') DT, ' dtM' + WRITE (u, '(F7.3,A)') tmax, ' TMax' + IF (LEN_TRIM(motion) > 0) WRITE (u, '(A)') TRIM(motion)//' motionFile' + IF (PRESENT(extra)) WRITE (u, '(A)') extra + WRITE (u, '(A)') '--- OUTPUTS ---' + WRITE (u, '(A)') 'FairTen1 AnchTen1 Point1px Point1pz Point2px Point2pz' + WRITE (u, '(A)') '--- END ---' + CLOSE (u) + END SUBROUTINE write_deck + + SUBROUTINE write_heading_deck(path, type_b, with_motion) + !! A 360 m slack cable from (0, 0, -14) to (239.589104, 180.544538, -20) (a 300 m span at a + !! 36.99 deg heading) on an 80 m seabed, 20 s; with_motion: End A surges 3 m by motionFile rows + !! that hold a Coupled End B at its deck position. + CHARACTER(*), INTENT(IN) :: path, type_b + LOGICAL, INTENT(IN) :: with_motion + INTEGER :: u, k + REAL(wp) :: t, x, v, a + IF (with_motion) THEN + OPEN (NEWUNIT=u, FILE='tme_zero_h_'//type_b//'.txt', STATUS='REPLACE', ACTION='WRITE') + DO k = 0, 400 + t = REAL(k, wp)*DT + CALL ramp(t, 3.0_wp, x, v, a) + WRITE (u, '(F10.5,A,9(1X,ES24.16))') t, ' 1', x, 0.0_wp, -14.0_wp, v, 0.0_wp, 0.0_wp, a, 0.0_wp, 0.0_wp + IF (type_b == 'Coupled') WRITE (u, '(F10.5,A)') t, ' 2 239.589104 180.544538 -20.0 0 0 0 0 0 0' + END DO + CLOSE (u) + END IF + OPEN (NEWUNIT=u, FILE=path, STATUS='REPLACE', ACTION='WRITE') + WRITE (u, '(A)') 'two moving ends heading gate' + WRITE (u, '(A)') '--- LINE TYPES ---' + WRITE (u, '(A)') 'Name Diam Mass EA BA EI Cdn Cdt Can Cat' + WRITE (u, '(A)') '(-) (m) (kg/m) (N) (-) (Nm2) (-) (-) (-) (-)' + WRITE (u, '(A)') 'bare 0.160 36.70 4.69e8 0.0 1.99e4 1.2 0.1 1.0 0.0' + WRITE (u, '(A)') '--- POINTS ---' + WRITE (u, '(A)') 'ID Type X Y Z' + WRITE (u, '(A)') '(-) (-) (m) (m) (m)' + WRITE (u, '(A)') '1 Coupled 0.0 0.0 -14.0' + WRITE (u, '(A)') '2 '//type_b//' 239.589104 180.544538 -20.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 bare 360.0 72' + WRITE (u, '(A)') '--- OPTIONS ---' + WRITE (u, '(A)') '9.80665 g' + WRITE (u, '(A)') '1025.0 rhoW' + WRITE (u, '(A)') '80.0 WtrDpth' + WRITE (u, '(A)') '1.0e5 kBot' + WRITE (u, '(A)') '1.0e4 cBot' + WRITE (u, '(A)') '0.05 dtM' + WRITE (u, '(A)') '20.0 TMax' + IF (with_motion) WRITE (u, '(A)') 'tme_zero_h_'//type_b//'.txt motionFile' + WRITE (u, '(A)') '--- OUTPUTS ---' + WRITE (u, '(A)') 'FairTen1 AnchTen1 AnchFz1 Point1Fx Point2Fx' + WRITE (u, '(A)') '--- END ---' + CLOSE (u) + END SUBROUTINE write_heading_deck + + SUBROUTINE ramp(t, amp, x, v, a) + !! amp (1 - cos(w t)) / 2 with w = 2 pi / 8 s: from rest (x = v = 0 at t = 0). + REAL(wp), INTENT(IN) :: t, amp + REAL(wp), INTENT(OUT) :: x, v, a + REAL(wp), PARAMETER :: W = 2.0_wp*PI/8.0_wp + x = 0.5_wp*amp*(1.0_wp - COS(W*t)) + v = 0.5_wp*amp*W*SIN(W*t) + a = 0.5_wp*amp*W*W*COS(W*t) + END SUBROUTINE ramp + + SUBROUTINE write_motion(path, nstep, sa, sb, with_b, pb) + !! motionFile rows: point 1 at (0, 0, ZE) + surge sa ramp, point 2 at (SPAN, 0, ZE) (or pb) + surge + !! sb ramp (written when with_b). + CHARACTER(*), INTENT(IN) :: path + INTEGER, INTENT(IN) :: nstep + REAL(wp), INTENT(IN) :: sa, sb + LOGICAL, INTENT(IN) :: with_b + REAL(wp), INTENT(IN), OPTIONAL :: pb(3) + INTEGER :: u, k + REAL(wp) :: t, x, v, a, b(3) + b = [SPAN, 0.0_wp, ZE] + IF (PRESENT(pb)) b = pb + OPEN (NEWUNIT=u, FILE=path, STATUS='REPLACE', ACTION='WRITE') + DO k = 0, nstep + t = REAL(k, wp)*DT + CALL ramp(t, sa, x, v, a) + WRITE (u, '(F10.5,A,9(1X,ES24.16))') t, ' 1', x, 0.0_wp, ZE, v, 0.0_wp, 0.0_wp, a, 0.0_wp, 0.0_wp + IF (with_b) THEN + CALL ramp(t, sb, x, v, a) + WRITE (u, '(F10.5,A,9(1X,ES24.16))') t, ' 2', b(1) + x, b(2), b(3), v, 0.0_wp, 0.0_wp, a, 0.0_wp, 0.0_wp + END IF + END DO + CLOSE (u) + END SUBROUTINE write_motion + + 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 + + LOGICAL FUNCTION same_file(a, b) RESULT(same) + !! Byte-identical text files (line by line, the same number of lines). + CHARACTER(*), INTENT(IN) :: a, b + INTEGER :: ua, ub, ia, ib + CHARACTER(16384) :: 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 + + SUBROUTINE read_rows(path, vals, nrow, ok) + !! Every data row of a driver .out file (two header lines) into vals(:, 1:nrow). + CHARACTER(*), INTENT(IN) :: path + REAL(wp), INTENT(OUT) :: vals(:, :) + INTEGER, INTENT(OUT) :: nrow + LOGICAL, INTENT(OUT) :: ok + INTEGER :: u, ios + CHARACTER(512) :: buf + nrow = 0 + vals = 0.0_wp + ok = .FALSE. + 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 WHILE (nrow < SIZE(vals, 2)) + READ (u, *, IOSTAT=ios) vals(:, nrow + 1) + IF (ios /= 0) EXIT + nrow = nrow + 1 + END DO + CLOSE (u) + ok = nrow > 0 .AND. ALL(IEEE_IS_FINITE(vals(:, 1:nrow))) + END SUBROUTINE read_rows + + ! ------------------------------------------------------------------------------------------ + SUBROUTINE check_zero_motion() + !! Z. A Coupled End B held by its motionFile rows (or by the absence of a motionFile) is the + !! Fixed End B: every output file byte for byte, while End A surges 2 m. + INTEGER, PARAMETER :: NSTEP = 120 + CHARACTER(16), PARAMETER :: SFX(5) = [CHARACTER(16) :: '.out', '.Line1.p.out', '.Line1.t.out', & + '.static.out', '.elements.out'] + LOGICAL :: ok, same + CHARACTER(1024) :: em + INTEGER :: k + CALL write_motion('tme_zero_a.txt', NSTEP, 2.0_wp, 0.0_wp, .FALSE.) + CALL write_motion('tme_zero_ab.txt', NSTEP, 2.0_wp, 0.0_wp, .TRUE.) + CALL write_deck('tme_zero_fixed.dat', 'Fixed', 'tme_zero_a.txt', NSTEP*DT, 1.0_wp, [0.0_wp, 0.0_wp, ZE], & + [SPAN, 0.0_wp, ZE], 'pt') + CALL write_deck('tme_zero_moving.dat', 'Coupled', 'tme_zero_ab.txt', NSTEP*DT, 1.0_wp, [0.0_wp, 0.0_wp, ZE], & + [SPAN, 0.0_wp, ZE], 'pt') + CALL run_deck('tme_zero_fixed.dat', 'tme_zero_fixed', ok, em) + CALL require(ok, 'Z: the Fixed End B deck runs: '//TRIM(em)) + CALL run_deck('tme_zero_moving.dat', 'tme_zero_moving', ok, em) + CALL require(ok, 'Z: the deck with a Coupled End B held by its motion rows runs: '//TRIM(em)) + same = .TRUE. + DO k = 1, SIZE(SFX) + IF (.NOT. same_file('tme_zero_fixed'//TRIM(SFX(k)), 'tme_zero_moving'//TRIM(SFX(k)))) THEN + same = .FALSE. + WRITE (*, '(A)') ' differs: '//TRIM(SFX(k)) + END IF + END DO + WRITE (*, '(A,L1)') 'zero motion, motionFile: Fixed and held Coupled End B byte-identical: ', same + CALL require(same, 'Z: a Coupled End B held at rest writes the Fixed End B files byte for byte') + ! no motionFile: both Coupled ends are held at their deck positions + CALL write_deck('tme_zero_fixed0.dat', 'Fixed', '', 1.0_wp, 1.0_wp, [0.0_wp, 0.0_wp, ZE], [SPAN, 0.0_wp, ZE], & + '-') + CALL write_deck('tme_zero_moving0.dat', 'Coupled', '', 1.0_wp, 1.0_wp, [0.0_wp, 0.0_wp, ZE], & + [SPAN, 0.0_wp, ZE], '-') + CALL run_deck('tme_zero_fixed0.dat', 'tme_zero_fixed0', ok, em) + CALL require(ok, 'Z: the Fixed End B deck without motion runs: '//TRIM(em)) + CALL run_deck('tme_zero_moving0.dat', 'tme_zero_moving0', ok, em) + CALL require(ok, 'Z: the Coupled End B deck without motion runs: '//TRIM(em)) + same = same_file('tme_zero_fixed0.out', 'tme_zero_moving0.out') + WRITE (*, '(A,L1)') 'zero motion, no motionFile: byte-identical: ', same + CALL require(same, 'Z: without a motionFile a Coupled End B is held as a Fixed one, byte for byte') + ! the modal analysis holds both ends: a Coupled End B is the Fixed End B there too + CALL write_deck('tme_zero_fixedm.dat', 'Fixed', '', 0.0_wp, 1.0_wp, [0.0_wp, 0.0_wp, ZE], [SPAN, 0.0_wp, ZE], & + '-', '6 nModes') + CALL write_deck('tme_zero_movingm.dat', 'Coupled', '', 0.0_wp, 1.0_wp, [0.0_wp, 0.0_wp, ZE], & + [SPAN, 0.0_wp, ZE], '-', '6 nModes') + CALL run_deck('tme_zero_fixedm.dat', 'tme_zero_fixedm', ok, em) + CALL require(ok, 'Z: the modal deck with a Fixed End B runs: '//TRIM(em)) + CALL run_deck('tme_zero_movingm.dat', 'tme_zero_movingm', ok, em) + CALL require(ok, 'Z: the modal deck with a Coupled End B runs: '//TRIM(em)) + same = same_file('tme_zero_fixedm.modes.out', 'tme_zero_movingm.modes.out') + WRITE (*, '(A,L1)') 'zero motion, nModes: modes files byte-identical: ', same + CALL require(same, 'Z: the modes of a line with a Coupled End B are those with a Fixed End B') + ! a 37 deg chord heading: a 360 m slack cable over a 300 m span touching down on an 80 m seabed, + ! 20 s held (End B read back in global axes and stepped at rest), and with End A surging + BLOCK + INTEGER :: ih + DO ih = 1, 2 + CALL write_heading_deck('tme_zero_fixedh.dat', 'Fixed', ih == 2) + CALL write_heading_deck('tme_zero_movingh.dat', 'Coupled', ih == 2) + CALL run_deck('tme_zero_fixedh.dat', 'tme_zero_fixedh', ok, em) + CALL require(ok, 'Z: the 37 deg Fixed End B deck runs: '//TRIM(em)) + CALL run_deck('tme_zero_movingh.dat', 'tme_zero_movingh', ok, em) + CALL require(ok, 'Z: the 37 deg held Coupled End B deck runs: '//TRIM(em)) + same = same_file('tme_zero_fixedh.out', 'tme_zero_movingh.out') + WRITE (*, '(A,A,A,L1)') 'zero motion at a 37 deg heading (', MERGE('no motionFile', 'motionFile ', ih == 1), & + '): byte-identical: ', same + CALL require(same, 'Z: at a 37 deg heading a held Coupled End B is the Fixed End B, byte for byte') + END DO + END BLOCK + END SUBROUTINE check_zero_motion + + ! ------------------------------------------------------------------------------------------ + SUBROUTINE build(cable, path, ok) + !! A cable with two host-driven ends from a deck (CD_Init_Deck_HermiteCable moving_end_b). + TYPE(CD_HFMF_ModuleType), INTENT(INOUT) :: cable + CHARACTER(*), INTENT(IN) :: path + LOGICAL, INTENT(OUT) :: ok + INTEGER :: cn, es + CHARACTER(1024) :: em + CALL CD_Init_Deck_HermiteCable(path, DT, cable, cn, es, em, moving_end_b=.TRUE.) + ok = es == CD_DECKDRV_OK + CALL require(ok, 'the two-moving-end cable builds from '//TRIM(path)//': '//TRIM(em)) + IF (ok) THEN + ok = cable%moving_b + CALL require(ok, 'the cable built from '//TRIM(path)//' has a moving End B') + END IF + END SUBROUTINE build + + SUBROUTINE check_symmetry() + !! S. The line of the decks above hangs symmetrically between (0, 0, -20) and (80, 0, -20). Both + !! ends move apart by 2 m each and rise 1 m: x_A = -d(t), x_B = 80 + d(t), z = -20 + h(t). The + !! mirror x -> 80 - x with the node order reversed (internal node k <-> nn + 1 - k) maps the + !! problem onto itself, so x_k + x_(nn+1-k) = 80, z_k = z_(nn+1-k), y = 0, and the End B load is + !! the mirror image of the End A load (Fx_B = -Fx_A, Fz_B = Fz_A) at every step. + INTEGER, PARAMETER :: NSTEP = 160 + TYPE(CD_HFMF_ModuleType), ALLOCATABLE :: cab + REAL(wp), ALLOCATABLE :: xyz(:, :) + REAL(wp) :: t, d, vd, ad, h, vh, ah, fa(3), fb(3), ex, ez, ey, ef, fscale + INTEGER :: s, k, nn, es + LOGICAL :: ok + CHARACTER(1024) :: em + ALLOCATE (cab) + CALL write_deck('tme_sym.dat', 'Coupled', '', NSTEP*DT, 1.0_wp, [0.0_wp, 0.0_wp, ZE], [SPAN, 0.0_wp, ZE], '-') + CALL build(cab, 'tme_sym.dat', ok) + IF (.NOT. ok) RETURN + nn = cab%line%nn + ALLOCATE (xyz(3, nn)) + ex = 0.0_wp; ez = 0.0_wp; ey = 0.0_wp; ef = 0.0_wp; fscale = 0.0_wp + DO s = 0, NSTEP + IF (s > 0) THEN + t = REAL(s, wp)*DT + CALL ramp(t, 2.0_wp, d, vd, ad) + CALL ramp(t, 1.0_wp, h, vh, ah) + CALL CD_HFMF_UpdateStates(cab, [-d, 0.0_wp, ZE + h], [-vd, 0.0_wp, vh], [-ad, 0.0_wp, ah], es, em, & + ub_pos=[SPAN + d, 0.0_wp, ZE + h], ub_vel=[vd, 0.0_wp, vh], ub_acc=[ad, 0.0_wp, ah]) + CALL require(es == CD_HFMF_OK, 'S: the symmetric step converges: '//TRIM(em)) + IF (es /= CD_HFMF_OK) EXIT + END IF + CALL CD_HFMF_GetNodePositions(cab, xyz, es, em) + CALL CD_HFMF_CalcOutput(cab, fa, es, em, y_end_b=fb) + CALL require(es == CD_HFMF_OK, 'S: the end loads evaluate: '//TRIM(em)) + DO k = 1, nn + ex = nan_max_abs([ex, ABS(xyz(1, k) + xyz(1, nn + 1 - k) - SPAN)]) + ez = nan_max_abs([ez, ABS(xyz(3, k) - xyz(3, nn + 1 - k))]) + ey = nan_max_abs([ey, ABS(xyz(2, k))]) + END DO + ef = nan_max_abs([ef, ABS(fa(1) + fb(1)), ABS(fa(3) - fb(3)), ABS(fa(2)), ABS(fb(2))]) + fscale = MAX(fscale, NORM2(fa)) + END DO + WRITE (*, '(A,3ES10.2,A,ES10.2,A,ES10.3,A)') 'symmetry: mirror error x, z, y ', ex, ez, ey, ' m; end loads ', & + ef, ' N (of ', fscale, ' N)' + CALL require(ex <= 1.0e-9_wp .AND. ez <= 1.0e-9_wp .AND. ey <= 1.0e-12_wp, & + 'S: the node positions stay mirror symmetric to round-off') + CALL require(ef <= 1.0e-8_wp*fscale, 'S: the End B load is the mirror image of the End A load') + CALL CD_HFMF_End(cab) + END SUBROUTINE check_symmetry + + ! ------------------------------------------------------------------------------------------ + SUBROUTINE check_rigid_translation() + !! G. Without drag (Cd = 0) the cable's equations are Galilean invariant (inertia, added mass, + !! elasticity and weight see no constant velocity; the water is at rest and no free surface or + !! seabed is reached), so a line moving at the constant velocity v with both ends prescribed at + !! q_0 + v t, v, 0 is the held line shifted by v t. The generalised-alpha step integrates the + !! rigid motion exactly; the two runs differ by round-off only (positions and both end loads). + INTEGER, PARAMETER :: NSTEP = 100 + REAL(wp), PARAMETER :: V0(3) = [1.3_wp, -0.7_wp, 0.4_wp] + TYPE(CD_HFMF_ModuleType), ALLOCATABLE :: held, moving + REAL(wp), ALLOCATABLE :: xh(:, :), xm(:, :) + REAL(wp) :: qa(3), qb(3), va(3), aa(3), t, fa_h(3), fb_h(3), fa_m(3), fb_m(3), ep, ef, fscale, dten + INTEGER :: s, k, nn, es + LOGICAL :: ok + CHARACTER(1024) :: em + ALLOCATE (held, moving) + CALL write_deck('tme_gal.dat', 'Coupled', '', NSTEP*DT, 0.0_wp, [0.0_wp, 0.0_wp, ZE], [SPAN, 0.0_wp, ZE], '-') + CALL build(held, 'tme_gal.dat', ok) + IF (.NOT. ok) RETURN + CALL build(moving, 'tme_gal.dat', ok) + IF (.NOT. ok) RETURN + nn = held%line%nn + ALLOCATE (xh(3, nn), xm(3, nn)) + CALL CD_HFMF_GetCoupledKinematics(held, qa, va, aa, es, em) + CALL CD_HFMF_GetEndBKinematics(held, qb, va, aa, es, em) + ! the moving line starts with the rigid velocity v at every node (translations; tangents at rest) + DO k = 1, nn + moving%line%v(6*k - 5:6*k - 3) = V0 + END DO + ep = 0.0_wp; ef = 0.0_wp; fscale = 0.0_wp; dten = 0.0_wp + DO s = 1, NSTEP + t = REAL(s, wp)*DT + CALL CD_HFMF_UpdateStates(held, qa, [0.0_wp, 0.0_wp, 0.0_wp], [0.0_wp, 0.0_wp, 0.0_wp], es, em, & + ub_pos=qb, ub_vel=[0.0_wp, 0.0_wp, 0.0_wp], ub_acc=[0.0_wp, 0.0_wp, 0.0_wp]) + CALL require(es == CD_HFMF_OK, 'G: the held step converges: '//TRIM(em)) + CALL CD_HFMF_UpdateStates(moving, qa + V0*t, V0, [0.0_wp, 0.0_wp, 0.0_wp], es, em, & + ub_pos=qb + V0*t, ub_vel=V0, ub_acc=[0.0_wp, 0.0_wp, 0.0_wp]) + CALL require(es == CD_HFMF_OK, 'G: the translating step converges: '//TRIM(em)) + IF (es /= CD_HFMF_OK) EXIT + CALL CD_HFMF_GetNodePositions(held, xh, es, em) + CALL CD_HFMF_GetNodePositions(moving, xm, es, em) + DO k = 1, nn + ep = nan_max_abs([ep, MAXVAL(ABS(xm(:, k) - V0*t - xh(:, k)))]) + END DO + CALL CD_HFMF_CalcOutput(held, fa_h, es, em, y_end_b=fb_h) + CALL CD_HFMF_CalcOutput(moving, fa_m, es, em, y_end_b=fb_m) + ef = nan_max_abs([ef, MAXVAL(ABS(fa_m - fa_h)), MAXVAL(ABS(fb_m - fb_h))]) + dten = nan_max_abs([dten, ABS(NORM2(fa_m) - NORM2(fa_h))]) + fscale = MAX(fscale, NORM2(fa_h)) + END DO + WRITE (*, '(A,ES10.2,A,ES10.2,A,ES10.2,A,ES10.3,A)') 'rigid translation: position error ', ep, & + ' m, end-load error ', ef, ' N, tension change ', dten, ' N (of ', fscale, ' N)' + CALL require(ep <= 1.0e-9_wp, 'G: the translating line is the held line shifted by v t') + CALL require(ef <= 1.0e-8_wp*fscale, 'G: both end loads are unchanged by the rigid translation') + CALL CD_HFMF_End(held) + CALL CD_HFMF_End(moving) + END SUBROUTINE check_rigid_translation + + ! ------------------------------------------------------------------------------------------ + SUBROUTINE check_reversal() + !! R. Deck 1: End A (point 1, x = 0) held, End B (point 2, x = 80) surging 3 m -- the line driven + !! at its End B. Deck 2: the same line written in reverse, End A = point 2 surging, End B = + !! point 1 Fixed -- driven at its End A. The physical problem is one; the two decks run it on + !! reversed meshes, so the end tensions agree to the static and Newton tolerances: + !! AnchTen of deck 1 = FairTen of deck 2 and FairTen of deck 1 = AnchTen of deck 2. + INTEGER, PARAMETER :: NSTEP = 160, NCOL = 7 + REAL(wp) :: r1(NCOL, NSTEP + 1), r2(NCOL, NSTEP + 1), err, scale + INTEGER :: n1, n2, u, k + LOGICAL :: ok + CHARACTER(1024) :: em + REAL(wp) :: t, x, v, a + ! deck 1: motion rows, point 1 still, point 2 surging + OPEN (NEWUNIT=u, FILE='tme_rev1.txt', STATUS='REPLACE', ACTION='WRITE') + DO k = 0, NSTEP + t = REAL(k, wp)*DT + CALL ramp(t, 3.0_wp, x, v, a) + WRITE (u, '(F10.5,A,9(1X,ES24.16))') t, ' 1', 0.0_wp, 0.0_wp, ZE, 0.0_wp, 0.0_wp, 0.0_wp, 0.0_wp, 0.0_wp, & + 0.0_wp + WRITE (u, '(F10.5,A,9(1X,ES24.16))') t, ' 2', SPAN + x, 0.0_wp, ZE, v, 0.0_wp, 0.0_wp, a, 0.0_wp, 0.0_wp + END DO + CLOSE (u) + CALL write_deck('tme_rev1.dat', 'Coupled', 'tme_rev1.txt', NSTEP*DT, 1.0_wp, [0.0_wp, 0.0_wp, ZE], & + [SPAN, 0.0_wp, ZE], '-') + ! deck 2: End A = point 1 at x = 80 surging, End B = point 2 Fixed at x = 0 + OPEN (NEWUNIT=u, FILE='tme_rev2.txt', STATUS='REPLACE', ACTION='WRITE') + DO k = 0, NSTEP + t = REAL(k, wp)*DT + CALL ramp(t, 3.0_wp, x, v, a) + WRITE (u, '(F10.5,A,9(1X,ES24.16))') t, ' 1', SPAN + x, 0.0_wp, ZE, v, 0.0_wp, 0.0_wp, a, 0.0_wp, 0.0_wp + END DO + CLOSE (u) + CALL write_deck('tme_rev2.dat', 'Fixed', 'tme_rev2.txt', NSTEP*DT, 1.0_wp, [SPAN, 0.0_wp, ZE], & + [0.0_wp, 0.0_wp, ZE], '-') + CALL run_deck('tme_rev1.dat', 'tme_rev1', ok, em) + CALL require(ok, 'R: the line driven at End B runs: '//TRIM(em)) + CALL run_deck('tme_rev2.dat', 'tme_rev2', ok, em) + CALL require(ok, 'R: the reversed line driven at End A runs: '//TRIM(em)) + CALL read_rows('tme_rev1.out', r1, n1, ok) + CALL require(ok .AND. n1 == NSTEP + 1, 'R: deck 1 output readable') + CALL read_rows('tme_rev2.out', r2, n2, ok) + CALL require(ok .AND. n2 == NSTEP + 1, 'R: deck 2 output readable') + IF (n1 /= NSTEP + 1 .OR. n2 /= NSTEP + 1) RETURN + err = MAXVAL(ABS(r1(3, :) - r2(2, :))) + err = MAX(err, MAXVAL(ABS(r1(2, :) - r2(3, :)))) + scale = MAXVAL(ABS(r1(2:3, :))) + WRITE (*, '(A,ES10.3,A,ES10.3,A)') 'reversal: end tension difference ', err, ' N (of ', scale, ' N)' + ! the moving point's position is reported from the motion table on both decks + CALL require(MAXVAL(ABS(r1(6, :) - r2(4, :))) <= 1.0e-6_wp, 'R: the driven point moves alike in both decks') + CALL require(err <= 1.0e-5_wp*scale, 'R: the line driven at End B equals the reversed line driven at End A') + END SUBROUTINE check_reversal + + ! ------------------------------------------------------------------------------------------ + SUBROUTINE drive_both(cab, s, es, em) + !! Step s of the restart march: End A surges 2 m and End B heaves 1.5 m from rest. + TYPE(CD_HFMF_ModuleType), INTENT(INOUT) :: cab + INTEGER, INTENT(IN) :: s + INTEGER, INTENT(OUT) :: es + CHARACTER(*), INTENT(OUT) :: em + REAL(wp) :: t, x, v, a, z, vz, az + t = REAL(s, wp)*DT + CALL ramp(t, 2.0_wp, x, v, a) + CALL ramp(t, 1.5_wp, z, vz, az) + CALL CD_HFMF_UpdateStates(cab, [x, 0.0_wp, ZE], [v, 0.0_wp, 0.0_wp], [a, 0.0_wp, 0.0_wp], es, em, & + ub_pos=[SPAN, 0.0_wp, ZE + z], ub_vel=[0.0_wp, 0.0_wp, vz], ub_acc=[0.0_wp, 0.0_wp, az]) + END SUBROUTINE drive_both + + SUBROUTINE check_restart() + !! C. Run 40 steps with both ends moving; at step 20 take a snapshot and the checkpoint mirror. + !! (1) Restore the snapshot and re-run steps 21..40: bit-identical state and end loads. (2) Build + !! a fresh cable from the deck, reload the mirror at t_20 and run steps 21..40: bit-identical. + !! The carried step factor is not part of the mirror, so the cables factor fresh every step, as + !! the coupled aggregate's do. + INTEGER, PARAMETER :: NSPLIT = 20, NEND = 40 + TYPE(CD_HFMF_ModuleType), ALLOCATABLE :: cab, fresh + REAL(wp), ALLOCATABLE :: buf(:), q_ref(:), v_ref(:), a_ref(:) + REAL(wp) :: fa_ref(3), fb_ref(3), fa(3), fb(3) + INTEGER :: s, es + LOGICAL :: ok, same_snap, same_mirror + CHARACTER(1024) :: em + ALLOCATE (cab, fresh) + CALL write_deck('tme_rst.dat', 'Coupled', '', NEND*DT, 1.0_wp, [0.0_wp, 0.0_wp, ZE], [SPAN, 0.0_wp, ZE], '-') + CALL build(cab, 'tme_rst.dat', ok) + IF (.NOT. ok) RETURN + cab%line%tangent_reuse = .FALSE. + cab%line%tr_valid = .FALSE. + DO s = 1, NEND + IF (s == NSPLIT + 1) THEN + CALL CD_HFMF_Snapshot(cab, es, em) + CALL require(es == CD_HFMF_OK, 'C: snapshot: '//TRIM(em)) + ALLOCATE (buf(CD_HFMF_MirrorSize(cab))) + CALL CD_HFMF_PackMirror(cab, buf, es, em) + CALL require(es == CD_HFMF_OK, 'C: pack mirror: '//TRIM(em)) + END IF + CALL drive_both(cab, s, es, em) + CALL require(es == CD_HFMF_OK, 'C: the reference step converges: '//TRIM(em)) + IF (es /= CD_HFMF_OK) RETURN + END DO + q_ref = cab%line%q + v_ref = cab%line%v + a_ref = cab%line%a + CALL CD_HFMF_CalcOutput(cab, fa_ref, es, em, y_end_b=fb_ref) + ! (1) snapshot restore + CALL CD_HFMF_Restore(cab, es, em) + CALL require(es == CD_HFMF_OK, 'C: restore: '//TRIM(em)) + DO s = NSPLIT + 1, NEND + CALL drive_both(cab, s, es, em) + IF (es /= CD_HFMF_OK) EXIT + END DO + CALL CD_HFMF_CalcOutput(cab, fa, es, em, y_end_b=fb) + same_snap = ALL(cab%line%q == q_ref) .AND. ALL(cab%line%v == v_ref) .AND. ALL(cab%line%a == a_ref) .AND. & + ALL(fa == fa_ref) .AND. ALL(fb == fb_ref) + ! (2) mirror reload into a cable rebuilt from the deck + CALL build(fresh, 'tme_rst.dat', ok) + IF (.NOT. ok) RETURN + fresh%line%tangent_reuse = .FALSE. + fresh%line%tr_valid = .FALSE. + CALL CD_HFMF_UnpackMirror(fresh, buf, REAL(NSPLIT, wp)*DT, es, em) + CALL require(es == CD_HFMF_OK, 'C: unpack mirror: '//TRIM(em)) + DO s = NSPLIT + 1, NEND + CALL drive_both(fresh, s, es, em) + IF (es /= CD_HFMF_OK) EXIT + END DO + CALL CD_HFMF_CalcOutput(fresh, fa, es, em, y_end_b=fb) + same_mirror = ALL(fresh%line%q == q_ref) .AND. ALL(fresh%line%v == v_ref) .AND. & + ALL(fresh%line%a == a_ref) .AND. ALL(fa == fa_ref) .AND. ALL(fb == fb_ref) + WRITE (*, '(A,L1,A,L1)') 'restart with two moving ends: snapshot bit-identical ', same_snap, & + ', mirror rebuild bit-identical ', same_mirror + CALL require(same_snap, 'C: a snapshot restore continues bit-identically') + CALL require(same_mirror, 'C: a mirror reload into a rebuilt cable continues bit-identically') + CALL CD_HFMF_End(cab) + CALL CD_HFMF_End(fresh) + END SUBROUTINE check_restart + + ! ------------------------------------------------------------------------------------------ + ! END CONNECTIONS and torsion at a moving End B + ! ------------------------------------------------------------------------------------------ + SUBROUTINE write_tdeck(path, pa, ta, pb, tb, conn_a, conn_b, options, outs, irn) + !! A straight 100 m neutral torsion line (EA 1e7, EI 1e6, GJ 5e4 N m^2, 40 elements) between + !! POINT 1 (End A, type ta) at pa and POINT 2 (End B, type tb) at pb, with END CONNECTIONS rows + !! conn_a, conn_b; irn the polar inertia per length of the LINE TYPES row. + CHARACTER(*), INTENT(IN) :: path, ta, tb, conn_a, conn_b, options(:), outs + REAL(wp), INTENT(IN) :: pa(3), pb(3), irn + INTEGER :: u, i + OPEN (NEWUNIT=u, FILE=path, STATUS='REPLACE', ACTION='WRITE') + WRITE (u, '(A)') 'two moving ends 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,ES24.16,A,ES12.5,A)') 'cab 0.2 ', 1025.0_wp*0.25_wp*PI*0.04_wp, ' 1.0e7 0.0 1.0e6 1.0e8 5.0e4 1.0 ', & + irn, ' 0.0 0.0 0.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,3(1X,F9.3),A)') '1 '//ta, pa, ' 0 0 0 0' + WRITE (u, '(A,3(1X,F9.3),A)') '2 '//tb, pb, ' 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 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)' + WRITE (u, '(A)') '1 A '//conn_a + WRITE (u, '(A)') '1 B '//conn_b + WRITE (u, '(A)') '--- OPTIONS ---' + WRITE (u, '(A)') '9.80665 g' + WRITE (u, '(A)') '1025.0 rhoW' + DO i = 1, SIZE(options) + IF (LEN_TRIM(options(i)) > 0) WRITE (u, '(A)') TRIM(options(i)) + END DO + WRITE (u, '(A)') '--- OUTPUTS ---' + WRITE (u, '(A)') outs + WRITE (u, '(A)') '--- END ---' + CLOSE (u) + END SUBROUTINE write_tdeck + + SUBROUTINE check_zero_motion_torsion() + !! ZT. End A (x = 0) surges 1 m and rolls 20 deg (the motionFile roll column); End B at x = 100 is + !! Fixed, or Coupled with motion rows that hold it at rest. Both ends clamped along the line and + !! restrained in torsion, End B pretwisted 90 deg: the .out files are byte-identical. + INTEGER, PARAMETER :: NSTEP = 40 + REAL(wp), PARAMETER :: DTT = 0.05_wp + INTEGER :: u, k + REAL(wp) :: t, x, v, a + LOGICAL :: ok, same + CHARACTER(1024) :: em + CHARACTER(40) :: opt(3) + OPEN (NEWUNIT=u, FILE='tme_zt_a.txt', STATUS='REPLACE', ACTION='WRITE') + DO k = 0, NSTEP + t = REAL(k, wp)*DTT + CALL ramp(t, 1.0_wp, x, v, a) + WRITE (u, '(F10.5,A,9(1X,ES24.16),1X,ES24.16)') t, ' 1', x, 0.0_wp, -50.0_wp, v, 0.0_wp, 0.0_wp, a, 0.0_wp, & + 0.0_wp, 20.0_wp*(1.0_wp - COS(PI*t/(NSTEP*DTT)))/2.0_wp + END DO + CLOSE (u) + OPEN (NEWUNIT=u, FILE='tme_zt_ab.txt', STATUS='REPLACE', ACTION='WRITE') + DO k = 0, NSTEP + t = REAL(k, wp)*DTT + CALL ramp(t, 1.0_wp, x, v, a) + WRITE (u, '(F10.5,A,9(1X,ES24.16),1X,ES24.16)') t, ' 1', x, 0.0_wp, -50.0_wp, v, 0.0_wp, 0.0_wp, a, 0.0_wp, & + 0.0_wp, 20.0_wp*(1.0_wp - COS(PI*t/(NSTEP*DTT)))/2.0_wp + WRITE (u, '(F10.5,A,10(1X,ES24.16))') t, ' 2', 100.0_wp, 0.0_wp, -50.0_wp, 0.0_wp, 0.0_wp, 0.0_wp, 0.0_wp, & + 0.0_wp, 0.0_wp, 0.0_wp + END DO + CLOSE (u) + opt(1) = '0.05 dtM' + WRITE (opt(2), '(F6.3,A)') NSTEP*DTT, ' TMax' + opt(3) = 'tme_zt_a.txt motionFile' + CALL write_tdeck('tme_zt_fixed.dat', [0.0_wp, 0.0_wp, -50.0_wp], 'Coupled', [100.0_wp, 0.0_wp, -50.0_wp], 'Fixed', & + 'Rigid 1 0 0 Rigid 0 0 1 0', 'Rigid 1 0 0 Rigid 0 0 1 90', opt, & + 'FairTen1 AnchTen1 Torq1N1 Torq1N41 Twist1', 1.0e-12_wp) + opt(3) = 'tme_zt_ab.txt motionFile' + CALL write_tdeck('tme_zt_moving.dat', [0.0_wp, 0.0_wp, -50.0_wp], 'Coupled', [100.0_wp, 0.0_wp, -50.0_wp], & + 'Coupled', 'Rigid 1 0 0 Rigid 0 0 1 0', 'Rigid 1 0 0 Rigid 0 0 1 90', opt, & + 'FairTen1 AnchTen1 Torq1N1 Torq1N41 Twist1', 1.0e-12_wp) + CALL run_deck('tme_zt_fixed.dat', 'tme_zt_fixed', ok, em) + CALL require(ok, 'ZT: the clamped, twisted line with a Fixed End B runs: '//TRIM(em)) + CALL run_deck('tme_zt_moving.dat', 'tme_zt_moving', ok, em) + CALL require(ok, 'ZT: the clamped, twisted line with a held Coupled End B runs: '//TRIM(em)) + same = same_file('tme_zt_fixed.out', 'tme_zt_moving.out') + IF (.NOT. same_file('tme_zt_fixed.static.out', 'tme_zt_moving.static.out')) same = .FALSE. + WRITE (*, '(A,L1)') 'zero motion with END CONNECTIONS and torsion: byte-identical: ', same + CALL require(same, 'ZT: a held Coupled End B with a clamped, torsional connection is the Fixed one, byte for byte') + END SUBROUTINE check_zero_motion_torsion + + SUBROUTINE check_same_roll() + !! TS. A vessel rolls at 30 deg/s about the axis of the line, both line ends on it (Vessel points + !! on the roll axis, vesselRef on the axis): both end frames turn by the same angle, the line + !! turns with them about its own axis, and the torque stays GJ Phi / L with Phi = 90 deg. + INTEGER, PARAMETER :: NSTEP = 20, NCOL = 6 + REAL(wp), PARAMETER :: GJ = 5.0e4_wp, L = 100.0_wp, RATE = 30.0_wp + REAL(wp) :: rows(NCOL, NSTEP + 1), m_ref, err, twist_err + INTEGER :: u, k, n + LOGICAL :: ok + CHARACTER(1024) :: em + CHARACTER(40) :: opt(4) + OPEN (NEWUNIT=u, FILE='tme_ts_vessel.txt', STATUS='REPLACE', ACTION='WRITE') + DO k = 0, NSTEP + WRITE (u, '(F6.2,A,F10.4,A,ES24.16,A)') 0.05_wp*k, ' 0 0 -50 ', RATE*0.05_wp*k, ' 0 0 0 0 0 ', & + RATE*PI/180.0_wp, ' 0 0 0 0 0 0 0 0' + END DO + CLOSE (u) + opt(1) = '0.05 dtM' + WRITE (opt(2), '(F6.3,A)') NSTEP*0.05_wp, ' TMax' + opt(3) = 'tme_ts_vessel.txt vesselMotion' + opt(4) = '0|0|-50 vesselRef' + CALL write_tdeck('tme_ts.dat', [0.0_wp, 0.0_wp, -50.0_wp], 'Vessel', [100.0_wp, 0.0_wp, -50.0_wp], 'Vessel', & + 'Rigid 1 0 0 Rigid 0 0 1 0', 'Rigid 1 0 0 Rigid 0 0 1 90', opt, 'Torq1N1 Torq1N41 Twist1 FairTen1 AnchTen1', & + 1.0e-12_wp) + CALL run_deck('tme_ts.dat', 'tme_ts', ok, em) + CALL require(ok, 'TS: the twisted line between two points of a rolling vessel runs: '//TRIM(em)) + CALL read_rows('tme_ts.out', rows, n, ok) + CALL require(ok .AND. n == NSTEP + 1, 'TS: output readable') + IF (.NOT. ok) RETURN + m_ref = GJ*(0.5_wp*PI)/L + err = 0.0_wp + twist_err = 0.0_wp + DO k = 1, n + err = nan_max_abs([err, ABS(rows(2, k) - m_ref), ABS(rows(3, k) - m_ref)]) + twist_err = nan_max_abs([twist_err, ABS(rows(4, k) - 90.0_wp)]) + END DO + WRITE (*, '(A,F8.1,A,ES10.3,A,ES10.3,A,ES10.3,A)') 'same roll of both end frames: vessel roll up to ', & + RATE*NSTEP*0.05_wp, ' deg, torque error ', err, ' N m (of ', m_ref, ' N m), twist error ', twist_err, ' deg' + CALL require(err <= 1.0e-6_wp*m_ref, 'TS: both end frames rolled by the same angle keep the torque') + CALL require(twist_err <= 1.0e-6_wp, 'TS: and the twist') + END SUBROUTINE check_same_roll + + SUBROUTINE check_opposite_roll() + !! TO. (1) Deck: both ends Coupled, rolled by the motionFile roll column phi(t) at each end (each + !! about its inward tangent, so the two frames turn in opposite senses about the line): + !! Phi = Pretwist(B) - Pretwist(A) - 2 phi, Torq = GJ (Phi0 - 2 phi) / L at every step. + !! (2) Library: the same line with both ends' parent orientations rolled about the line axis by + !! +phi (End A) and -phi (End B): the torque changes by GJ (2 phi) / L; by +phi and +phi it does + !! not change. + INTEGER, PARAMETER :: NSTEP = 20, NCOL = 4 + REAL(wp), PARAMETER :: GJ = 5.0e4_wp, L = 100.0_wp, PHI_MAX = 45.0_wp + REAL(wp) :: rows(NCOL, NSTEP + 1), err, phi, m_ref, m0, mt, ms, fa(3), ma(3), fb(3), mb(3), err_o, err_s + INTEGER :: u, k, n, cn, es + LOGICAL :: ok + CHARACTER(1024) :: em + CHARACTER(40) :: opt(3) + TYPE(CD_HFMF_ModuleType), ALLOCATABLE :: opp, same + OPEN (NEWUNIT=u, FILE='tme_to_roll.txt', STATUS='REPLACE', ACTION='WRITE') + DO k = 0, NSTEP + phi = PHI_MAX*REAL(k, wp)/REAL(NSTEP, wp) + WRITE (u, '(F10.5,A,10(1X,ES24.16))') 0.05_wp*k, ' 1', 0.0_wp, 0.0_wp, -50.0_wp, 0.0_wp, 0.0_wp, 0.0_wp, & + 0.0_wp, 0.0_wp, 0.0_wp, phi + WRITE (u, '(F10.5,A,10(1X,ES24.16))') 0.05_wp*k, ' 2', 100.0_wp, 0.0_wp, -50.0_wp, 0.0_wp, 0.0_wp, 0.0_wp, & + 0.0_wp, 0.0_wp, 0.0_wp, phi + END DO + CLOSE (u) + opt(1) = '0.05 dtM' + WRITE (opt(2), '(F6.3,A)') NSTEP*0.05_wp, ' TMax' + opt(3) = 'tme_to_roll.txt motionFile' + CALL write_tdeck('tme_to.dat', [0.0_wp, 0.0_wp, -50.0_wp], 'Coupled', [100.0_wp, 0.0_wp, -50.0_wp], 'Coupled', & + 'Rigid 1 0 0 Rigid 0 0 1 0', 'Rigid 1 0 0 Rigid 0 0 1 90', opt, 'Torq1N1 Torq1N41 Twist1', & + 1.0e-12_wp) + CALL run_deck('tme_to.dat', 'tme_to', ok, em) + CALL require(ok, 'TO: the twisted line rolled at both ends runs: '//TRIM(em)) + CALL read_rows('tme_to.out', rows, n, ok) + CALL require(ok .AND. n == NSTEP + 1, 'TO: output readable') + err = 0.0_wp + IF (ok) THEN + DO k = 1, n + phi = PHI_MAX*REAL(k - 1, wp)/REAL(NSTEP, wp)*PI/180.0_wp + m_ref = GJ*(0.5_wp*PI - 2.0_wp*phi)/L + err = nan_max_abs([err, ABS(rows(2, k) - m_ref), ABS(rows(3, k) - m_ref)]) + END DO + END IF + WRITE (*, '(A,F6.1,A,ES10.3,A)') 'opposite rolls (roll columns, up to ', PHI_MAX, & + ' deg each): torque error against GJ (Phi0 - 2 phi) / L ', err, ' N m' + CALL require(err <= 1.0e-6_wp*GJ, 'TO: opposite rolls of the end frames change the torque by GJ (2 phi) / L') + ! (2) library: parent orientations of the two ends + ALLOCATE (opp, same) + opt(3) = '' + CALL write_tdeck('tme_to_lib.dat', [0.0_wp, 0.0_wp, -50.0_wp], 'Coupled', [100.0_wp, 0.0_wp, -50.0_wp], 'Coupled', & + 'Rigid 1 0 0 Rigid 0 0 1 0', 'Rigid 1 0 0 Rigid 0 0 1 90', opt, 'FairTen1', 1.0e-12_wp) + CALL CD_Init_Deck_HermiteCable('tme_to_lib.dat', 0.05_wp, opp, cn, es, em, host_orientation=.TRUE., & + moving_end_b=.TRUE.) + CALL require(es == CD_DECKDRV_OK, 'TO: library cable builds: '//TRIM(em)) + IF (es /= CD_DECKDRV_OK) RETURN + CALL CD_Init_Deck_HermiteCable('tme_to_lib.dat', 0.05_wp, same, cn, es, em, host_orientation=.TRUE., & + moving_end_b=.TRUE.) + m0 = opp%line%torsion%torque + err_o = 0.0_wp + err_s = 0.0_wp + DO k = 1, NSTEP + phi = PHI_MAX*REAL(k, wp)/REAL(NSTEP, wp)*PI/180.0_wp + CALL CD_HFMF_UpdateStates(opp, [0.0_wp, 0.0_wp, -50.0_wp], [0.0_wp, 0.0_wp, 0.0_wp], [0.0_wp, 0.0_wp, 0.0_wp], & + es, em, u_orientation=roll_x(phi), ub_pos=[100.0_wp, 0.0_wp, -50.0_wp], & + ub_vel=[0.0_wp, 0.0_wp, 0.0_wp], ub_acc=[0.0_wp, 0.0_wp, 0.0_wp], & + ub_orientation=roll_x(-phi)) + CALL require(es == CD_HFMF_OK, 'TO: opposite-roll step: '//TRIM(em)) + CALL CD_HFMF_UpdateStates(same, [0.0_wp, 0.0_wp, -50.0_wp], [0.0_wp, 0.0_wp, 0.0_wp], [0.0_wp, 0.0_wp, 0.0_wp], & + es, em, u_orientation=roll_x(phi), ub_pos=[100.0_wp, 0.0_wp, -50.0_wp], & + ub_vel=[0.0_wp, 0.0_wp, 0.0_wp], ub_acc=[0.0_wp, 0.0_wp, 0.0_wp], & + ub_orientation=roll_x(phi)) + CALL require(es == CD_HFMF_OK, 'TO: same-roll step: '//TRIM(em)) + mt = opp%line%torsion%torque + ms = same%line%torsion%torque + ! a parent rolled by +phi about +x turns End A's frame by +phi about the line (A -> B), End B's + ! by -phi: the relative roll of End B against End A, Phi, falls by 2 phi + err_o = nan_max_abs([err_o, ABS((mt - m0) + GJ*2.0_wp*phi/L)]) + err_s = nan_max_abs([err_s, ABS(ms - m0)]) + END DO + ! the torque returns to the two parents as equal and opposite moments about the line (the + ! same-roll line, which keeps its torque M = GJ Phi0 / L) + CALL CD_HFMF_CalcOutput(same, fa, es, em, y_moment=ma, y_end_b=fb, y_moment_b=mb) + WRITE (*, '(A,ES10.3,A,ES10.3,A,ES12.5,A,2ES13.5)') 'library rolls: opposite error ', err_o, ' N m, same error ', & + err_s, ' N m (torque ', m0, ' N m); end moments about x ', ma(1), mb(1) + CALL require(err_o <= 1.0e-6_wp*GJ, 'TO: parents rolled by +phi and -phi change the torque by GJ (2 phi) / L') + CALL require(err_s <= 1.0e-6_wp*GJ, 'TO: parents rolled by the same angle keep the torque') + CALL require(ABS(ma(1) + mb(1)) <= 1.0e-6_wp*ABS(ms) .AND. ABS(ABS(ma(1)) - ABS(ms)) <= 1.0e-6_wp*ABS(ms), & + 'TO: the two parents carry the torque as equal and opposite moments about the line') + CALL CD_HFMF_End(opp) + CALL CD_HFMF_End(same) + END SUBROUTINE check_opposite_roll + + FUNCTION roll_x(psi) RESULT(r) + !! Global-to-parent DCM of a parent rolled by psi about +x (the transpose of the rotation). + REAL(wp), INTENT(IN) :: psi + REAL(wp) :: r(3, 3) + r = 0.0_wp + r(1, 1) = 1.0_wp + r(2, 2) = COS(psi) + r(3, 3) = COS(psi) + r(2, 3) = SIN(psi) + r(3, 2) = -SIN(psi) + END FUNCTION roll_x + + FUNCTION turn_dcm(t) RESULT(r) + !! Global-to-parent DCM of a parent turned by yaw 0.15 sin(w t) about z, then pitch 0.1 (1 - cos(w t)) + !! about y (w = 2 pi / 8 s): R = Rz Ry, DCM = R^T. + REAL(wp), INTENT(IN) :: t + REAL(wp) :: r(3, 3), rz(3, 3), ry(3, 3), yaw, pitch + REAL(wp), PARAMETER :: W = 2.0_wp*PI/8.0_wp + yaw = 0.15_wp*SIN(W*t) + pitch = 0.1_wp*(1.0_wp - COS(W*t)) + rz = RESHAPE([COS(yaw), SIN(yaw), 0.0_wp, -SIN(yaw), COS(yaw), 0.0_wp, 0.0_wp, 0.0_wp, 1.0_wp], [3, 3]) + ry = RESHAPE([COS(pitch), 0.0_wp, -SIN(pitch), 0.0_wp, 1.0_wp, 0.0_wp, SIN(pitch), 0.0_wp, COS(pitch)], [3, 3]) + r = TRANSPOSE(MATMUL(rz, ry)) + END FUNCTION turn_dcm + + SUBROUTINE turn_rates(t, w_g, al_g) + !! Angular velocity and acceleration (global axes) of turn_dcm: R = Rz(yaw) Ry(pitch), + !! w = yaw' e_z + pitch' Rz e_y, al = yaw'' e_z + pitch'' Rz e_y + yaw' pitch' e_z x (Rz e_y). + REAL(wp), INTENT(IN) :: t + REAL(wp), INTENT(OUT) :: w_g(3), al_g(3) + REAL(wp), PARAMETER :: W = 2.0_wp*PI/8.0_wp + REAL(wp) :: yaw, yd, ydd, pd, pdd, ey(3) + yaw = 0.15_wp*SIN(W*t) + yd = 0.15_wp*W*COS(W*t) + ydd = -0.15_wp*W*W*SIN(W*t) + pd = 0.1_wp*W*SIN(W*t) + pdd = 0.1_wp*W*W*COS(W*t) + ey = [-SIN(yaw), COS(yaw), 0.0_wp] + w_g = [0.0_wp, 0.0_wp, yd] + pd*ey + al_g = [0.0_wp, 0.0_wp, ydd] + pdd*ey + yd*pd*[-COS(yaw), -SIN(yaw), 0.0_wp] + END SUBROUTINE turn_rates + + SUBROUTINE check_bending_reversal(kind) + !! B. Cable 1: End A (x = 0) held, End B (x = 80) on a parent that surges 2 m from rest and turns + !! (yaw and pitch); its End B connection direction and moment turn with that parent. Cable 2: + !! the same line written in reverse (End A = the parent's point, End B Fixed at x = 0, Ez reversed), + !! driven at End A by the same parent motion. End B's force and connection moment of cable 1 + !! equal End A's of cable 2, and the held ends' alike, to the Newton tolerance (1e-9 here). + CHARACTER(*), INTENT(IN) :: kind + INTEGER, PARAMETER :: NSTEP = 120 + TYPE(CD_HFMF_ModuleType), ALLOCATABLE :: c1, c2 + REAL(wp) :: t, x, v, a, w_g(3), al_g(3), dcm(3, 3), f1a(3), m1a(3), f1b(3), m1b(3), f2a(3), m2a(3), f2b(3), m2b(3) + REAL(wp) :: ef, em_, fs, ms + INTEGER :: s, cn, es + CHARACTER(1024) :: em + CHARACTER(48) :: ca, cb, ca2, cb2 + ALLOCATE (c1, c2) + IF (kind == 'clamped') THEN + ca = 'Rigid 0.6 0 -0.8' + cb = 'Rigid 0.6 0 0.8' + ca2 = 'Rigid -0.6 0 -0.8' + cb2 = 'Rigid -0.6 0 0.8' + ELSE + ca = '2.0e5 0.6 0 -0.8' + cb = '2.0e5 0.6 0 0.8' + ca2 = '2.0e5 -0.6 0 -0.8' + cb2 = '2.0e5 -0.6 0 0.8' + END IF + CALL write_cdeck('tme_b1.dat', [0.0_wp, 0.0_wp, ZE], 'Coupled', [SPAN, 0.0_wp, ZE], 'Coupled', ca, cb) + CALL write_cdeck('tme_b2.dat', [SPAN, 0.0_wp, ZE], 'Coupled', [0.0_wp, 0.0_wp, ZE], 'Fixed', ca2, cb2) + CALL CD_Init_Deck_HermiteCable('tme_b1.dat', DT, c1, cn, es, em, host_orientation=.TRUE., moving_end_b=.TRUE.) + CALL require(es == CD_DECKDRV_OK, 'B: cable 1 builds: '//TRIM(em)) + IF (es /= CD_DECKDRV_OK) RETURN + CALL CD_Init_Deck_HermiteCable('tme_b2.dat', DT, c2, cn, es, em, host_orientation=.TRUE.) + CALL require(es == CD_DECKDRV_OK, 'B: cable 2 builds: '//TRIM(em)) + IF (es /= CD_DECKDRV_OK) RETURN + c1%tol = 1.0e-9_wp + c2%tol = 1.0e-9_wp + ef = 0.0_wp; em_ = 0.0_wp; fs = 0.0_wp; ms = 0.0_wp + DO s = 1, NSTEP + t = REAL(s, wp)*DT + CALL ramp(t, 2.0_wp, x, v, a) + dcm = turn_dcm(t) + CALL turn_rates(t, w_g, al_g) + CALL CD_HFMF_UpdateStates(c1, [0.0_wp, 0.0_wp, ZE], [0.0_wp, 0.0_wp, 0.0_wp], [0.0_wp, 0.0_wp, 0.0_wp], es, em, & + ub_pos=[SPAN + x, 0.0_wp, ZE], ub_vel=[v, 0.0_wp, 0.0_wp], ub_acc=[a, 0.0_wp, 0.0_wp], & + ub_orientation=dcm, ub_angular_velocity=w_g, ub_angular_acceleration=al_g) + CALL require(es == CD_HFMF_OK, 'B: cable 1 step ('//kind//'): '//TRIM(em)) + IF (es /= CD_HFMF_OK) EXIT + CALL CD_HFMF_UpdateStates(c2, [SPAN + x, 0.0_wp, ZE], [v, 0.0_wp, 0.0_wp], [a, 0.0_wp, 0.0_wp], es, em, & + u_orientation=dcm, u_angular_velocity=w_g, u_angular_acceleration=al_g) + CALL require(es == CD_HFMF_OK, 'B: cable 2 step ('//kind//'): '//TRIM(em)) + IF (es /= CD_HFMF_OK) EXIT + CALL CD_HFMF_CalcOutput(c1, f1a, es, em, y_moment=m1a, y_end_b=f1b, y_moment_b=m1b) + CALL CD_HFMF_CalcOutput(c2, f2a, es, em, y_moment=m2a, y_end_b=f2b, y_moment_b=m2b) + ef = nan_max_abs([ef, MAXVAL(ABS(f1b - f2a)), MAXVAL(ABS(f1a - f2b))]) + em_ = nan_max_abs([em_, MAXVAL(ABS(m1b - m2a)), MAXVAL(ABS(m1a - m2b))]) + fs = MAX(fs, NORM2(f2a)) + ms = MAX(ms, NORM2(m2a), NORM2(m2b)) + END DO + WRITE (*, '(A,A,A,ES10.3,A,ES10.3,A,ES10.3,A,ES10.3,A)') 'bending reversal (', kind, '): end force difference ', & + ef, ' N (of ', fs, ' N), connection moment difference ', em_, ' N m (of ', ms, ' N m)' + CALL require(ef <= 1.0e-6_wp*fs, 'B ('//kind//'): End B forces of the line driven at End B equal the reversed line''s') + CALL require(em_ <= 1.0e-6_wp*MAX(ms, 1.0_wp), 'B ('//kind//'): and the connection moments') + CALL require(ms > 1.0e2_wp, 'B ('//kind//'): the turning parent loads its connection (a moment above 100 N m)') + CALL CD_HFMF_End(c1) + CALL CD_HFMF_End(c2) + END SUBROUTINE check_bending_reversal + + SUBROUTINE write_cdeck(path, pa, ta, pb, tb, conn_a, conn_b) + !! The suspended 100 m line of write_deck (no drag) with END CONNECTIONS (bending only). + CHARACTER(*), INTENT(IN) :: path, ta, tb, conn_a, conn_b + REAL(wp), INTENT(IN) :: pa(3), pb(3) + INTEGER :: u + OPEN (NEWUNIT=u, FILE=path, STATUS='REPLACE', ACTION='WRITE') + WRITE (u, '(A)') 'two moving ends bending gate' + WRITE (u, '(A)') '--- LINE TYPES ---' + WRITE (u, '(A)') 'Name Diam Mass EA BA EI Cdn Cdt Can Cat' + WRITE (u, '(A)') '(-) (m) (kg/m) (N) (-) (Nm2) (-) (-) (-) (-)' + WRITE (u, '(A)') 'pcable 0.20 60 8.0e8 0.0 2.0e4 0.0 0.0 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,3(1X,F8.3),A)') '1 '//ta, pa, ' 0 0 0 0' + WRITE (u, '(A,3(1X,F8.3),A)') '2 '//tb, pb, ' 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 pcable 100.0 40' + WRITE (u, '(A)') '--- END CONNECTIONS ---' + WRITE (u, '(A)') 'LineID End Stiffness EzX EzY EzZ' + WRITE (u, '(A)') '(-) (-) (N-m/rad) (-) (-) (-)' + WRITE (u, '(A)') '1 A '//conn_a + WRITE (u, '(A)') '1 B '//conn_b + WRITE (u, '(A)') '--- OPTIONS ---' + WRITE (u, '(A)') '9.80665 g' + WRITE (u, '(A)') '1025.0 rhoW' + WRITE (u, '(F6.3,A)') DT, ' dtM' + WRITE (u, '(A)') '6.0 TMax' + WRITE (u, '(A)') '--- OUTPUTS ---' + WRITE (u, '(A)') 'FairTen1' + WRITE (u, '(A)') '--- END ---' + CLOSE (u) + END SUBROUTINE write_cdeck + + SUBROUTINE drive_torsion(cab, s, es, em) + !! Step s of the torsion restart march: End A rolls by 0.6 (1 - cos) rad and surges; End B's parent + !! rolls the other way and heaves (both frames turning). + TYPE(CD_HFMF_ModuleType), INTENT(INOUT) :: cab + INTEGER, INTENT(IN) :: s + INTEGER, INTENT(OUT) :: es + CHARACTER(*), INTENT(OUT) :: em + REAL(wp) :: t, x, v, a, r, rd, rdd + t = REAL(s, wp)*0.02_wp + CALL ramp(t, 0.5_wp, x, v, a) + CALL ramp(t, 0.6_wp, r, rd, rdd) + CALL CD_HFMF_UpdateStates(cab, [x, 0.0_wp, -50.0_wp], [v, 0.0_wp, 0.0_wp], [a, 0.0_wp, 0.0_wp], es, em, & + u_orientation=roll_x(r), u_angular_velocity=[rd, 0.0_wp, 0.0_wp], & + u_angular_acceleration=[rdd, 0.0_wp, 0.0_wp], & + ub_pos=[100.0_wp, 0.0_wp, -50.0_wp + x], ub_vel=[0.0_wp, 0.0_wp, v], & + ub_acc=[0.0_wp, 0.0_wp, a], ub_orientation=roll_x(-r), & + ub_angular_velocity=[-rd, 0.0_wp, 0.0_wp], ub_angular_acceleration=[-rdd, 0.0_wp, 0.0_wp]) + END SUBROUTINE drive_torsion + + SUBROUTINE check_torsion_restart() + !! CT. The clamped, twisted straight line with a real polar inertia (Irn = 2 kg m, the nodal twist) + !! driven at both ends, both frames turning: snapshot restore and mirror rebuild at step 30 of 60 + !! continue bit-identically (state, twist state and both end loads). + INTEGER, PARAMETER :: NSPLIT = 30, NEND = 60 + TYPE(CD_HFMF_ModuleType), ALLOCATABLE :: cab, fresh + REAL(wp), ALLOCATABLE :: buf(:), q_ref(:), v_ref(:), tw_ref(:) + REAL(wp) :: fa_ref(3), fb_ref(3), ma_ref(3), mb_ref(3), fa(3), fb(3), ma(3), mb(3) + INTEGER :: s, es, cn + LOGICAL :: same_snap, same_mirror + CHARACTER(1024) :: em + CHARACTER(40) :: opt(2) + ALLOCATE (cab, fresh) + opt(1) = '0.02 dtM' + opt(2) = '1.2 TMax' + CALL write_tdeck('tme_ct.dat', [0.0_wp, 0.0_wp, -50.0_wp], 'Coupled', [100.0_wp, 0.0_wp, -50.0_wp], 'Coupled', & + 'Rigid 1 0 0 Rigid 0 0 1 0', 'Rigid 1 0 0 Rigid 0 0 1 90', opt, 'FairTen1', 2.0_wp) + CALL CD_Init_Deck_HermiteCable('tme_ct.dat', 0.02_wp, cab, cn, es, em, host_orientation=.TRUE., moving_end_b=.TRUE.) + CALL require(es == CD_DECKDRV_OK, 'CT: cable builds: '//TRIM(em)) + IF (es /= CD_DECKDRV_OK) RETURN + CALL require(cab%line%tw_active, 'CT: the cable carries the nodal twist') + cab%line%tangent_reuse = .FALSE. + cab%line%tr_valid = .FALSE. + DO s = 1, NEND + IF (s == NSPLIT + 1) THEN + CALL CD_HFMF_Snapshot(cab, es, em) + ALLOCATE (buf(CD_HFMF_MirrorSize(cab))) + CALL CD_HFMF_PackMirror(cab, buf, es, em) + CALL require(es == CD_HFMF_OK, 'CT: pack mirror: '//TRIM(em)) + END IF + CALL drive_torsion(cab, s, es, em) + CALL require(es == CD_HFMF_OK, 'CT: reference step: '//TRIM(em)) + IF (es /= CD_HFMF_OK) RETURN + END DO + q_ref = cab%line%q + v_ref = cab%line%v + tw_ref = cab%line%tw_phi + CALL CD_HFMF_CalcOutput(cab, fa_ref, es, em, y_moment=ma_ref, y_end_b=fb_ref, y_moment_b=mb_ref) + CALL CD_HFMF_Restore(cab, es, em) + DO s = NSPLIT + 1, NEND + CALL drive_torsion(cab, s, es, em) + IF (es /= CD_HFMF_OK) EXIT + END DO + CALL CD_HFMF_CalcOutput(cab, fa, es, em, y_moment=ma, y_end_b=fb, y_moment_b=mb) + same_snap = ALL(cab%line%q == q_ref) .AND. ALL(cab%line%v == v_ref) .AND. ALL(cab%line%tw_phi == tw_ref) .AND. & + ALL(fa == fa_ref) .AND. ALL(fb == fb_ref) .AND. ALL(ma == ma_ref) .AND. ALL(mb == mb_ref) + CALL CD_Init_Deck_HermiteCable('tme_ct.dat', 0.02_wp, fresh, cn, es, em, host_orientation=.TRUE., & + moving_end_b=.TRUE.) + fresh%line%tangent_reuse = .FALSE. + fresh%line%tr_valid = .FALSE. + CALL CD_HFMF_UnpackMirror(fresh, buf, REAL(NSPLIT, wp)*0.02_wp, es, em) + CALL require(es == CD_HFMF_OK, 'CT: unpack mirror: '//TRIM(em)) + DO s = NSPLIT + 1, NEND + CALL drive_torsion(fresh, s, es, em) + IF (es /= CD_HFMF_OK) EXIT + END DO + CALL CD_HFMF_CalcOutput(fresh, fa, es, em, y_moment=ma, y_end_b=fb, y_moment_b=mb) + same_mirror = ALL(fresh%line%q == q_ref) .AND. ALL(fresh%line%v == v_ref) .AND. ALL(fresh%line%tw_phi == tw_ref) & + .AND. ALL(fa == fa_ref) .AND. ALL(fb == fb_ref) .AND. ALL(ma == ma_ref) .AND. ALL(mb == mb_ref) + WRITE (*, '(A,L1,A,L1,A,ES12.5,A)') 'restart with torsion, both frames turning: snapshot ', same_snap, & + ', mirror rebuild ', same_mirror, ' (torque ', cab%line%torsion%torque, ' N m)' + CALL require(same_snap, 'CT: snapshot restore continues bit-identically') + CALL require(same_mirror, 'CT: mirror rebuild continues bit-identically') + CALL CD_HFMF_End(cab) + CALL CD_HFMF_End(fresh) + END SUBROUTINE check_torsion_restart + + ! ------------------------------------------------------------------------------------------ + ! the coupled aggregate + ! ------------------------------------------------------------------------------------------ + SUBROUTINE write_farm_deck(path, motion, tmax) + !! The suspended line of write_deck shared by two turbines: TURBINES 1 at the origin and 2 at + !! x = 80, the line between their fairleads (0, 0, -20) in turbine axes; motion a motionFile or + !! blank. + CHARACTER(*), INTENT(IN) :: path, motion + REAL(wp), INTENT(IN) :: tmax + INTEGER :: u + OPEN (NEWUNIT=u, FILE=path, STATUS='REPLACE', ACTION='WRITE') + WRITE (u, '(A)') 'two moving ends farm gate' + WRITE (u, '(A)') '--- LINE TYPES ---' + WRITE (u, '(A)') 'Name Diam Mass EA BA EI Cdn Cdt Can Cat' + WRITE (u, '(A)') '(-) (m) (kg/m) (N) (-) (Nm2) (-) (-) (-) (-)' + WRITE (u, '(A)') 'pcable 0.20 60 8.0e8 0.0 2.0e4 1.0 0.0 1.0 0.0' + WRITE (u, '(A)') '--- TURBINES ---' + WRITE (u, '(A)') 'J X0 Y0 Z0' + WRITE (u, '(A)') '(-) (m) (m) (m)' + WRITE (u, '(A)') '1 0 0 0' + WRITE (u, '(A)') '2 80 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 Turbine1 0 0 -20 0 0 0 0' + WRITE (u, '(A)') '2 Turbine2 0 0 -20 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 pcable 100.0 40' + WRITE (u, '(A)') '--- OPTIONS ---' + WRITE (u, '(A)') '9.80665 g' + WRITE (u, '(A)') '1025.0 rhoW' + WRITE (u, '(F6.3,A)') DT, ' dtM' + WRITE (u, '(F7.3,A)') tmax, ' TMax' + IF (LEN_TRIM(motion) > 0) WRITE (u, '(A)') TRIM(motion)//' motionFile' + WRITE (u, '(A)') '--- OUTPUTS ---' + WRITE (u, '(A)') 'FairTen1 AnchTen1' + WRITE (u, '(A)') '--- END ---' + CLOSE (u) + END SUBROUTINE write_farm_deck + + SUBROUTINE ramp0(t, amp, x, v, a) + !! amp (1 - cos(w t))^2 / 4 with w = 2 pi / 8 s: from rest with zero acceleration at t = 0, so a + !! host that starts from the static state (no first-row acceleration) sees the same motion. + REAL(wp), INTENT(IN) :: t, amp + REAL(wp), INTENT(OUT) :: x, v, a + REAL(wp), PARAMETER :: W = 2.0_wp*PI/8.0_wp + x = 0.25_wp*amp*(1.0_wp - COS(W*t))**2 + v = 0.5_wp*amp*W*(1.0_wp - COS(W*t))*SIN(W*t) + a = 0.5_wp*amp*W*W*(SIN(W*t)**2 + (1.0_wp - COS(W*t))*COS(W*t)) + END SUBROUTINE ramp0 + + SUBROUTINE turbine_motion(j, t, x, v, a) + !! Prescribed rigid motion of turbine j (no rotation): turbine 1 surges 2 m, turbine 2 sways + !! 1.5 m and heaves 1 m, each from rest (ramp0); x is the turbine reference point. + INTEGER, INTENT(IN) :: j + REAL(wp), INTENT(IN) :: t + REAL(wp), INTENT(OUT) :: x(3), v(3), a(3) + REAL(wp) :: s, sv, sa, h, hv, ha + x = 0.0_wp; v = 0.0_wp; a = 0.0_wp + IF (j == 1) THEN + CALL ramp0(t, 2.0_wp, s, sv, sa) + x(1) = s; v(1) = sv; a(1) = sa + ELSE + CALL ramp0(t, 1.5_wp, s, sv, sa) + CALL ramp0(t, 1.0_wp, h, hv, ha) + x = [SPAN, s, h]; v = [0.0_wp, sv, hv]; a = [0.0_wp, sa, ha] + END IF + END SUBROUTINE turbine_motion + + SUBROUTINE check_farm_shared_line() + !! F. The standalone TURBINES deck (motionFile turbine rows) and the FAST.Farm aggregate (n_turbines + !! = 2, the same reference positions) of one shared line, driven by the same turbine motions. + !! The aggregate maps its two moving columns to turbines 1 and 2; FairTen and AnchTen agree to + !! the solver tolerances (the standalone route solves its statics to 1e-8 and the aggregate's + !! to 1e-6; both step to 1e-8 here) at every step. + INTEGER, PARAMETER :: NSTEP = 160, NCOL = 3 + TYPE(CD_AGG_ModuleType), ALLOCATABLE :: agg + REAL(wp) :: rows(NCOL, NSTEP + 1), pos(3, 2), vel(3, 2), acc(3, 2), x(3), v(3), a(3), t, fa, fb, err, scale + INTEGER :: u, k, j, n, es, nit, turb(2) + LOGICAL :: ok, conv, stalled + CHARACTER(1024) :: em + OPEN (NEWUNIT=u, FILE='tme_farm.txt', STATUS='REPLACE', ACTION='WRITE') + DO k = 0, NSTEP + t = REAL(k, wp)*DT + DO j = 1, 2 + CALL turbine_motion(j, t, x, v, a) + WRITE (u, '(F10.5,1X,I0,3(1X,ES24.16),A,3(1X,ES24.16),A,3(1X,ES24.16),A)') t, j, x, ' 1 0 0 0', v, & + ' 0 0 0', a, ' 0 0 0' + END DO + END DO + CLOSE (u) + CALL write_farm_deck('tme_farm_sa.dat', 'tme_farm.txt', NSTEP*DT) + CALL run_deck('tme_farm_sa.dat', 'tme_farm_sa', ok, em) + CALL require(ok, 'F: the standalone TURBINES deck runs: '//TRIM(em)) + CALL read_rows('tme_farm_sa.out', rows, n, ok) + CALL require(ok .AND. n == NSTEP + 1, 'F: standalone output readable') + IF (.NOT. ok) RETURN + ALLOCATE (agg) + CALL write_farm_deck('tme_farm_agg.dat', '', NSTEP*DT) + CALL CD_AGG_Init_From_Deck(agg, 'tme_farm_agg.dat', DT, es, em, n_turbines=2, & + turbine_ref_pos=RESHAPE([0.0_wp, 0.0_wp, 0.0_wp, SPAN, 0.0_wp, 0.0_wp], [3, 2]), & + forbid_deck_ambient=.TRUE.) + CALL require(es == CD_AGG_OK, 'F: the FAST.Farm aggregate builds the shared line: '//TRIM(em)) + IF (es /= CD_AGG_OK) RETURN + CALL require(CD_AGG_NMovingPoints(agg, es, em) == 2, 'F: two moving columns, one per end') + CALL CD_AGG_TurbineOfMoving(agg, turb, es, em) + CALL require(es == CD_AGG_OK .AND. turb(1) == 1 .AND. turb(2) == 2, & + 'F: End A is driven by turbine 1 and End B by turbine 2') + agg%cables(1)%tol = 1.0e-8_wp + agg%cables(1)%max_iter = 30 + err = 0.0_wp + scale = MAXVAL(ABS(rows(2:3, 1:n))) + DO k = 0, NSTEP + IF (k > 0) THEN + t = REAL(k, wp)*DT + DO j = 1, 2 + CALL turbine_motion(j, t, x, v, a) + pos(:, j) = x + [0.0_wp, 0.0_wp, ZE] + vel(:, j) = v + acc(:, j) = a + END DO + CALL CD_AGG_Step_Moving(agg, DT, pos, vel, acc, conv, stalled, nit, es, em, t_committed=t) + CALL require(es == CD_AGG_OK, 'F: aggregate step: '//TRIM(em)) + IF (es /= CD_AGG_OK) EXIT + END IF + CALL CD_AGG_EvalChannel(agg, 1, fa, es, em) + CALL CD_AGG_EvalChannel(agg, 2, fb, es, em) + IF (k == 0) WRITE (*, '(A,2ES16.8,A,2ES16.8)') ' static FairTen, AnchTen: aggregate ', fa, fb, & + ' standalone ', rows(2:3, 1) + err = nan_max_abs([err, ABS(fa - rows(2, k + 1)), ABS(fb - rows(3, k + 1))]) + END DO + WRITE (*, '(A,ES10.3,A,ES10.3,A)') 'FAST.Farm shared line: aggregate vs standalone end tensions ', err, & + ' N (of ', scale, ' N)' + CALL require(err <= 1.0e-6_wp*scale, 'F: the aggregate reports the standalone route''s end tensions') + CALL CD_AGG_End(agg, es, em) + END SUBROUTINE check_farm_shared_line + + SUBROUTINE check_aggregate_torsion() + !! FT. The clamped line twisted 90 deg between two Coupled points of the aggregate (host + !! orientations): the host rolls column 1 by +phi and column 2 by -phi about the line (End B + !! frame against End A's: the twist falls by 2 phi), or both by +phi (a rigid roll). + INTEGER, PARAMETER :: NSTEP = 10 + REAL(wp), PARAMETER :: GJ = 5.0e4_wp, L = 100.0_wp, PHI_MAX = 30.0_wp + TYPE(CD_AGG_ModuleType), ALLOCATABLE :: agg + REAL(wp) :: pos(3, 2), zero3(3, 2), ori(3, 3, 2), phi, m0, mt, err(2) + INTEGER :: k, es, nit, isame + LOGICAL :: conv, stalled + CHARACTER(1024) :: em + CHARACTER(40) :: opt(2) + opt(1) = '0.05 dtM' + opt(2) = '0.5 TMax' + CALL write_tdeck('tme_aggt.dat', [0.0_wp, 0.0_wp, -50.0_wp], 'Coupled', [100.0_wp, 0.0_wp, -50.0_wp], 'Coupled', & + 'Rigid 1 0 0 Rigid 0 0 1 0', 'Rigid 1 0 0 Rigid 0 0 1 90', opt, 'Torq1N1', 1.0e-12_wp) + pos(:, 1) = [0.0_wp, 0.0_wp, -50.0_wp] + pos(:, 2) = [100.0_wp, 0.0_wp, -50.0_wp] + zero3 = 0.0_wp + err = 0.0_wp + DO isame = 1, 2 + ALLOCATE (agg) + CALL CD_AGG_Init_From_Deck(agg, 'tme_aggt.dat', 0.05_wp, es, em, host_orientation=.TRUE.) + CALL require(es == CD_AGG_OK, 'FT: the aggregate builds the twisted line: '//TRIM(em)) + IF (es /= CD_AGG_OK) RETURN + m0 = agg%cables(1)%line%torsion%torque + DO k = 1, NSTEP + phi = PHI_MAX*REAL(k, wp)/REAL(NSTEP, wp)*PI/180.0_wp + ori(:, :, 1) = roll_x(phi) + ori(:, :, 2) = roll_x(MERGE(phi, -phi, isame == 2)) + CALL CD_AGG_Step_Moving(agg, 0.05_wp, pos, zero3, zero3, conv, stalled, nit, es, em, & + t_committed=0.05_wp*k, orientation=ori, angular_velocity=zero3, & + angular_acceleration=zero3) + CALL require(es == CD_AGG_OK, 'FT: aggregate step: '//TRIM(em)) + IF (es /= CD_AGG_OK) EXIT + mt = agg%cables(1)%line%torsion%torque + IF (isame == 1) THEN + err(1) = nan_max_abs([err(1), ABS((mt - m0) + GJ*2.0_wp*phi/L)]) + ELSE + err(2) = nan_max_abs([err(2), ABS(mt - m0)]) + END IF + END DO + CALL CD_AGG_End(agg, es, em) + DEALLOCATE (agg) + END DO + WRITE (*, '(A,ES10.3,A,ES10.3,A,ES12.5,A)') 'aggregate host rolls: opposite error ', err(1), ' N m, same error ', & + err(2), ' N m (torque ', m0, ' N m)' + CALL require(err(1) <= 1.0e-6_wp*GJ, 'FT: opposite host rolls change the torque by GJ (2 phi) / L') + CALL require(err(2) <= 1.0e-6_wp*GJ, 'FT: equal host rolls keep the torque') + END SUBROUTINE check_aggregate_torsion + + SUBROUTINE write_farm_tdeck(path, ptfm, motion, tmax) + !! The clamped straight torsion line of write_tdeck between two turbines 100 m apart, End A on + !! Turbine1 and End B on Turbine2 at (0, 0, -50) in turbine axes; ptfm: write the TURBINES PtfmInit + !! columns (turbine 1 yawed +15 deg, turbine 2 -8 deg). + CHARACTER(*), INTENT(IN) :: path, motion + LOGICAL, INTENT(IN) :: ptfm + REAL(wp), INTENT(IN) :: tmax + INTEGER :: u + OPEN (NEWUNIT=u, FILE=path, STATUS='REPLACE', ACTION='WRITE') + WRITE (u, '(A)') 'two moving ends farm 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,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 1.0 1.0e-12 0.0 0.0 0.0 0.0' + WRITE (u, '(A)') '--- TURBINES ---' + IF (ptfm) THEN + WRITE (u, '(A)') 'J X0 Y0 Z0 PtfmSurge PtfmSway PtfmHeave PtfmRoll PtfmPitch PtfmYaw' + WRITE (u, '(A)') '1 0 0 0 0 0 0 0 0 15' + WRITE (u, '(A)') '2 100 0 0 0 0 0 0 0 -8' + ELSE + WRITE (u, '(A)') 'J X0 Y0 Z0' + WRITE (u, '(A)') '1 0 0 0' + WRITE (u, '(A)') '2 100 0 0' + 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) (-)' + WRITE (u, '(A)') '1 Turbine1 0 0 -50 0 0 0 0' + WRITE (u, '(A)') '2 Turbine2 0 0 -50 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 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)' + 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, '(F7.3,A)') tmax, ' TMax' + IF (LEN_TRIM(motion) > 0) WRITE (u, '(A)') TRIM(motion)//' motionFile' + WRITE (u, '(A)') '--- OUTPUTS ---' + WRITE (u, '(A)') 'FairTen1 AnchTen1 Torq1N1 Torq1N41 Curv1N2 Curv1N40' + WRITE (u, '(A)') '--- END ---' + CLOSE (u) + END SUBROUTINE write_farm_tdeck + + SUBROUTINE check_farm_ptfm_parity() + !! FP. Turbines yawed by PtfmInit (+15 and -8 deg about their reference points, which carry the + !! fairleads on their z axes, so the ends do not move but their frames turn): the clamped line, + !! twisted 90 deg, is bent at both ends by the turned Ez and twisted by the turned Nx. The + !! standalone run (held, 10 steps) and the FAST.Farm aggregate (farm_ptfm_init, the host + !! passing each turbine's orientation) agree in every channel at every step. + INTEGER, PARAMETER :: NSTEP = 10, NCOL = 7 + REAL(wp) :: rows(NCOL, NSTEP + 1), pos(3, 2), zero3(3, 2), ori(3, 3, 2), v, err, scale, yaw(2) + TYPE(CD_AGG_ModuleType), ALLOCATABLE :: agg + INTEGER :: n, k, ic, es, nit + LOGICAL :: ok, conv, stalled + CHARACTER(1024) :: em + CALL write_farm_tdeck('tme_fp_sa.dat', .TRUE., '', NSTEP*0.05_wp) + CALL run_deck('tme_fp_sa.dat', 'tme_fp_sa', ok, em) + CALL require(ok, 'FP: the standalone TURBINES torsion deck runs: '//TRIM(em)) + CALL read_rows('tme_fp_sa.out', rows, n, ok) + CALL require(ok .AND. n == NSTEP + 1, 'FP: standalone output readable') + IF (.NOT. ok) RETURN + yaw = [15.0_wp, -8.0_wp]*PI/180.0_wp + ALLOCATE (agg) + CALL write_farm_tdeck('tme_fp_agg.dat', .FALSE., '', NSTEP*0.05_wp) + CALL CD_AGG_Init_From_Deck(agg, 'tme_fp_agg.dat', 0.05_wp, es, em, n_turbines=2, & + turbine_ref_pos=RESHAPE([0.0_wp, 0.0_wp, 0.0_wp, 100.0_wp, 0.0_wp, 0.0_wp], [3, 2]), & + farm_ptfm_init=RESHAPE([0.0_wp, 0.0_wp, 0.0_wp, 0.0_wp, 0.0_wp, yaw(1), & + 0.0_wp, 0.0_wp, 0.0_wp, 0.0_wp, 0.0_wp, yaw(2)], [6, 2]), & + forbid_deck_ambient=.TRUE., host_orientation=.TRUE.) + CALL require(es == CD_AGG_OK, 'FP: the FAST.Farm aggregate builds: '//TRIM(em)) + IF (es /= CD_AGG_OK) RETURN + agg%cables(1)%tol = 1.0e-8_wp + agg%cables(1)%max_iter = 30 + pos(:, 1) = [0.0_wp, 0.0_wp, -50.0_wp] + pos(:, 2) = [100.0_wp, 0.0_wp, -50.0_wp] + zero3 = 0.0_wp + DO k = 1, 2 + ori(:, :, k) = RESHAPE([COS(yaw(k)), -SIN(yaw(k)), 0.0_wp, SIN(yaw(k)), COS(yaw(k)), 0.0_wp, & + 0.0_wp, 0.0_wp, 1.0_wp], [3, 3]) + END DO + err = 0.0_wp + scale = 0.0_wp + DO k = 0, NSTEP + IF (k > 0) THEN + CALL CD_AGG_Step_Moving(agg, 0.05_wp, pos, zero3, zero3, conv, stalled, nit, es, em, t_committed=0.05_wp*k, & + orientation=ori, angular_velocity=zero3, angular_acceleration=zero3) + CALL require(es == CD_AGG_OK, 'FP: aggregate step: '//TRIM(em)) + IF (es /= CD_AGG_OK) EXIT + END IF + DO ic = 1, NCOL - 1 + CALL CD_AGG_EvalChannel(agg, ic, v, es, em) + err = nan_max_abs([err, ABS(v - rows(ic + 1, k + 1))/MAX(1.0_wp, ABS(rows(ic + 1, k + 1)))]) + scale = MAX(scale, ABS(rows(ic + 1, k + 1))) + END DO + END DO + WRITE (*, '(A,ES10.3,A,4ES12.4)') 'FAST.Farm vs standalone, yawed turbines, torsion: largest relative channel '// & + 'difference ', err, '; standalone t = 0: FairTen, AnchTen, Torq ', rows(2:4, 1), rows(6, 1) + CALL require(err <= 1.0e-5_wp, 'FP: the standalone TURBINES deck reads its end frames in the turbines'' axes') + CALL CD_AGG_End(agg, es, em) + END SUBROUTINE check_farm_ptfm_parity + + SUBROUTINE turbine_pose(j, t, x, v, a, r, w, al) + !! Turbine j of FR: reference (0, 0, 0) or (100, 0, 0), rotation R = Rz(yaw_j) Rx(+-phi(t)) with + !! yaw +15 / -8 deg (the PtfmInit) and phi a 10 deg roll over 1 s from rest with zero initial + !! acceleration (as a host starting from the static state sees it); x, v, a the motion + !! of the fairlead (0, 0, -50) in turbine axes, r the rotation, w and al its global angular + !! velocity and acceleration (w = phi' Rz e_x). + INTEGER, INTENT(IN) :: j + REAL(wp), INTENT(IN) :: t + REAL(wp), INTENT(OUT) :: x(3), v(3), a(3), r(3, 3), w(3), al(3) + REAL(wp) :: yaw, sg, phi, pd, pdd, rz(3, 3), rx(3, 3), p(3), ax(3) + REAL(wp), PARAMETER :: WR = PI + yaw = MERGE(15.0_wp, -8.0_wp, j == 1)*PI/180.0_wp + sg = MERGE(1.0_wp, -1.0_wp, j == 1) + ! 10 deg (1 - cos)^2 / 4 with w = pi: phi(1 s) = 10 deg, phi'(0) = phi''(0) = 0 + phi = sg*0.25_wp*(10.0_wp*PI/180.0_wp)*(1.0_wp - COS(WR*t))**2 + pd = sg*0.5_wp*(10.0_wp*PI/180.0_wp)*WR*(1.0_wp - COS(WR*t))*SIN(WR*t) + pdd = sg*0.5_wp*(10.0_wp*PI/180.0_wp)*WR*WR*(SIN(WR*t)**2 + (1.0_wp - COS(WR*t))*COS(WR*t)) + rz = RESHAPE([COS(yaw), SIN(yaw), 0.0_wp, -SIN(yaw), COS(yaw), 0.0_wp, 0.0_wp, 0.0_wp, 1.0_wp], [3, 3]) + rx = RESHAPE([1.0_wp, 0.0_wp, 0.0_wp, 0.0_wp, COS(phi), SIN(phi), 0.0_wp, -SIN(phi), COS(phi)], [3, 3]) + r = MATMUL(rz, rx) + ax = [COS(yaw), SIN(yaw), 0.0_wp] + w = pd*ax + al = pdd*ax + p = MATMUL(r, [0.0_wp, 0.0_wp, -50.0_wp]) + x = MERGE(0.0_wp, 100.0_wp, j == 1)*[1.0_wp, 0.0_wp, 0.0_wp] + p + v = [w(2)*p(3) - w(3)*p(2), w(3)*p(1) - w(1)*p(3), w(1)*p(2) - w(2)*p(1)] + a = [al(2)*p(3) - al(3)*p(2), al(3)*p(1) - al(1)*p(3), al(1)*p(2) - al(2)*p(1)] + & + [w(2)*v(3) - w(3)*v(2), w(3)*v(1) - w(1)*v(3), w(1)*v(2) - w(2)*v(1)] + END SUBROUTINE turbine_pose + + SUBROUTINE check_farm_rotation_parity() + !! FR. The turbines of FP roll their fairleads by +-10 deg about their (yawed) x axes: the TURBINES + !! rows give each turbine's quaternion, which turns its end's connection and torsion frames; + !! the FAST.Farm aggregate takes the same rotations as host orientations. Every channel + !! agrees at every step, and the twist changes (the two frames turn oppositely). + INTEGER, PARAMETER :: NSTEP = 20, NCOL = 7 + REAL(wp) :: rows(NCOL, NSTEP + 1), pos(3, 2), vel(3, 2), acc(3, 2), ori(3, 3, 2), om(3, 2), al(3, 2) + REAL(wp) :: x(3), v(3), a(3), r(3, 3), w(3), aa(3), tt, val, err, yaw(2), q(4), trq0 + TYPE(CD_AGG_ModuleType), ALLOCATABLE :: agg + INTEGER :: n, k, j, ic, es, nit, u + LOGICAL :: ok, conv, stalled + CHARACTER(1024) :: em + OPEN (NEWUNIT=u, FILE='tme_fr.txt', STATUS='REPLACE', ACTION='WRITE') + DO k = 0, NSTEP + tt = REAL(k, wp)*0.05_wp + DO j = 1, 2 + CALL turbine_pose(j, tt, x, v, a, r, w, aa) + ! the row's quaternion of R = Rz(yaw) Rx(phi) + q = rot_quaternion(r) + WRITE (u, '(F10.5,1X,I0,3(1X,ES24.16),4(1X,ES24.16),12(1X,ES24.16))') tt, j, & + MERGE(0.0_wp, 100.0_wp, j == 1), 0.0_wp, 0.0_wp, q, 0.0_wp, 0.0_wp, 0.0_wp, w, 0.0_wp, 0.0_wp, 0.0_wp, aa + END DO + END DO + CLOSE (u) + CALL write_farm_tdeck('tme_fr_sa.dat', .TRUE., 'tme_fr.txt', NSTEP*0.05_wp) + CALL run_deck('tme_fr_sa.dat', 'tme_fr_sa', ok, em) + CALL require(ok, 'FR: the rolling TURBINES deck runs: '//TRIM(em)) + CALL read_rows('tme_fr_sa.out', rows, n, ok) + CALL require(ok .AND. n == NSTEP + 1, 'FR: standalone output readable') + IF (.NOT. ok) RETURN + yaw = [15.0_wp, -8.0_wp]*PI/180.0_wp + ALLOCATE (agg) + CALL write_farm_tdeck('tme_fr_agg.dat', .FALSE., '', NSTEP*0.05_wp) + CALL CD_AGG_Init_From_Deck(agg, 'tme_fr_agg.dat', 0.05_wp, es, em, n_turbines=2, & + turbine_ref_pos=RESHAPE([0.0_wp, 0.0_wp, 0.0_wp, 100.0_wp, 0.0_wp, 0.0_wp], [3, 2]), & + farm_ptfm_init=RESHAPE([0.0_wp, 0.0_wp, 0.0_wp, 0.0_wp, 0.0_wp, yaw(1), & + 0.0_wp, 0.0_wp, 0.0_wp, 0.0_wp, 0.0_wp, yaw(2)], [6, 2]), & + forbid_deck_ambient=.TRUE., host_orientation=.TRUE.) + CALL require(es == CD_AGG_OK, 'FR: the FAST.Farm aggregate builds: '//TRIM(em)) + IF (es /= CD_AGG_OK) RETURN + agg%cables(1)%tol = 1.0e-8_wp + agg%cables(1)%max_iter = 30 + err = 0.0_wp + trq0 = rows(4, 1) + DO k = 0, NSTEP + IF (k > 0) THEN + tt = REAL(k, wp)*0.05_wp + DO j = 1, 2 + CALL turbine_pose(j, tt, pos(:, j), vel(:, j), acc(:, j), r, om(:, j), al(:, j)) + ori(:, :, j) = TRANSPOSE(r) + END DO + CALL CD_AGG_Step_Moving(agg, 0.05_wp, pos, vel, acc, conv, stalled, nit, es, em, t_committed=tt, & + orientation=ori, angular_velocity=om, angular_acceleration=al) + CALL require(es == CD_AGG_OK, 'FR: aggregate step: '//TRIM(em)) + IF (es /= CD_AGG_OK) EXIT + END IF + DO ic = 1, NCOL - 1 + CALL CD_AGG_EvalChannel(agg, ic, val, es, em) + err = nan_max_abs([err, ABS(val - rows(ic + 1, k + 1))/MAX(1.0_wp, ABS(rows(ic + 1, k + 1)))]) + END DO + END DO + WRITE (*, '(A,ES10.3,A,ES12.5,A,ES12.5,A)') 'FAST.Farm vs standalone, rolling turbines: largest relative '// & + 'channel difference ', err, '; Torq1N1 ', trq0, ' -> ', rows(4, n), ' N m' + CALL require(err <= 1.0e-5_wp, 'FR: TURBINES rows turn both end frames as the FAST.Farm host does') + CALL require(ABS(rows(4, n) - trq0) > 1.0e-2_wp*ABS(trq0), 'FR: the turbines'' rolls twist the line') + CALL CD_AGG_End(agg, es, em) + END SUBROUTINE check_farm_rotation_parity + + FUNCTION rot_quaternion(r) RESULT(q) + !! Unit quaternion (q0, q1, q2, q3) of a proper rotation matrix (Shepperd's method, q0 >= 0). + REAL(wp), INTENT(IN) :: r(3, 3) + REAL(wp) :: q(4), tr, s + tr = r(1, 1) + r(2, 2) + r(3, 3) + IF (tr > 0.0_wp) THEN + s = 0.5_wp/SQRT(tr + 1.0_wp) + q = [0.25_wp/s, (r(3, 2) - r(2, 3))*s, (r(1, 3) - r(3, 1))*s, (r(2, 1) - r(1, 2))*s] + ELSE IF (r(1, 1) > r(2, 2) .AND. r(1, 1) > r(3, 3)) THEN + s = 2.0_wp*SQRT(1.0_wp + r(1, 1) - r(2, 2) - r(3, 3)) + q = [(r(3, 2) - r(2, 3))/s, 0.25_wp*s, (r(1, 2) + r(2, 1))/s, (r(1, 3) + r(3, 1))/s] + ELSE IF (r(2, 2) > r(3, 3)) THEN + s = 2.0_wp*SQRT(1.0_wp + r(2, 2) - r(1, 1) - r(3, 3)) + q = [(r(1, 3) - r(3, 1))/s, (r(1, 2) + r(2, 1))/s, 0.25_wp*s, (r(2, 3) + r(3, 2))/s] + ELSE + s = 2.0_wp*SQRT(1.0_wp + r(3, 3) - r(1, 1) - r(2, 2)) + q = [(r(2, 1) - r(1, 2))/s, (r(1, 3) + r(3, 1))/s, (r(2, 3) + r(3, 2))/s, 0.25_wp*s] + END IF + IF (q(1) < 0.0_wp) q = -q + END FUNCTION rot_quaternion + +END PROGRAM test_two_moving_ends