diff --git a/CHANGELOG.md b/CHANGELOG.md index 5424649a..96b44608 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -30,6 +30,17 @@ All notable changes to CableDyn are recorded in this file. The format follows and `SYROPE IC` applies to every Syrope section of the line. On a 400 m polyester section between chains every element starts on its OWC to 2e-11, and a still run keeps the fairlead tension. Example `composite_chain_syrope_chain.dat`, on a moving vessel. +- Torque–tension coupling of finite-EI cables: the 14-column LINE TYPES row's `GJ` column takes + `GJ|K`, with `K` the coupling of an armoured cable or wire rope (`T = EA ε + K τ`, + `M = GJ τ + K ε`). The cable carries the axial stiffness `EA − K²/GJ` of a section free to twist. + A line restrained in torsion adds the stretch's share of the twist, `−Σ (K/GJ)(l − L)`, to its + condensed torque, in statics and dynamics and on every route that carries torsion. The node + and element tensions, the element profile, the twist channels and the static and dynamic + `tensile_safety` audits include the coupling, so a stretched cable that opposite-sense torsion + puts into compression is caught. A stretched straight cable reproduces + `T = EA ε`, `M = K ε` between rigid ends and `T = (EA − K²/GJ) ε` with a free end. `GJ|0` is the + uncoupled cable bit for bit. The Python deck reader and builder take `GJ|K` (builder + `gj=(GJ, K)`). - Section-frame curvature channels `CurvXN` and `CurvYN` on finite-EI lines: the curvature vector on the cable's cross-section axes, for the fatigue of an armour wire or conductor at a fixed point of the section. The axes start at End A from the end connection diff --git a/CMakeLists.txt b/CMakeLists.txt index b5bd24c0..9e19ea88 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -2081,6 +2081,11 @@ target_link_libraries(test_syrope_composite PRIVATE cabledyn_core) add_test(NAME syrope_composite COMMAND test_syrope_composite) set_tests_properties(syrope_composite PROPERTIES LABELS "fortran;driver;integration;static;dynamic") +add_executable(test_torsion_coupling tests/test_torsion_coupling.f90) +target_link_libraries(test_torsion_coupling PRIVATE cabledyn_core) +add_test(NAME torsion_coupling COMMAND test_torsion_coupling) +set_tests_properties(torsion_coupling PROPERTIES LABELS "fortran;unit;driver;integration;static") + add_executable(test_coupled_torsion tests/test_coupled_torsion.f90) target_link_libraries(test_coupled_torsion PRIVATE cabledyn_core) add_test(NAME coupled_torsion COMMAND test_coupled_torsion WORKING_DIRECTORY ${CMAKE_BINARY_DIR}) @@ -2735,7 +2740,8 @@ if(CMAKE_Fortran_COMPILER_ID STREQUAL "GNU") test_hermite_drag_dynamics test_hermite_axial_damping test_hermite_cable_control - test_endconn_spring) + test_endconn_spring + test_torsion_coupling) target_compile_options(${_cabledyn_exact_real_test} PRIVATE -Wno-compare-reals) endforeach() target_compile_options(test_openfast_aggregate PRIVATE diff --git a/VALIDATION.md b/VALIDATION.md index 10f1362e..530965a0 100644 --- a/VALIDATION.md +++ b/VALIDATION.md @@ -102,6 +102,7 @@ article's methods, are compared in | **T-8** | Cross-check with the Cosserat rod path | Cosserat path | shape 4.2e-4 L, torque 5.2e-5 | <1% | Pass | | **T-9** | Bordered Newton step on post-buckled states | predicted linear rate without the rank-one term | 3 iterations; rate 0.055 / 0.217 vs 0.055 / 0.218 | ≤4; within 25% | Pass | | **T-10** | Torsion dynamics, restart and body torque | quasi-static torque, energy, uninterrupted run, pendulum | torque 2.2e-16; energy band 4.9e-4; restart bit-identical; pendulum 6.4e-5 | see [Torsion](#torsion) | Pass | +| **T-12** | Torque–tension coupling | `T = EA ε + K τ`, `M = GJ τ + K ε` closed forms; kernel FD; march | ≤1e-7 against every closed form; kernel gradient 1.7e-10, Hessian 9.8e-11 | see [Torsion](#torsion) | Pass | | **T-11** | Torsion on the coupled OpenFAST / FAST.Farm route | `GJ (−roll)/L`; single coupled cable; uninterrupted run | twist ≤1.8e-15°, torque ≤1.7e-13 N·m; aggregate = single cable bit for bit; restart bit-identical (aggregate and `openfast -restart`) | see [Torsion](#torsion) | Pass | **Pass** meets the stated acceptance value. **Pass measured** records a measured @@ -988,6 +989,16 @@ in parentheses). ±0.12°), and `openfast -restart` from 30 s reproduces all 1200 later rows of the OpenFAST and CableDyn outputs bit for bit. No full FAST.Farm run is part of this record. +- **T-12 torque–tension coupling** (`torsion_coupling`). The effective twist + `Θ − Σ (K/GJ)(l_e − L_e)` of the kernel has the gradient and Hessian of its finite differences on + a curved line (1.7e-10, 9.8e-11). A straight neutral 99 m cable (EA 1e7 N, GJ 5e4 N·m², K 4e5 N·m) + stretched to 100 m gives the closed forms to the printed digits: + - both ends rigid in torsion: `T = EA ε` and `M = K ε`; + - free at one end: `T = (EA − K²/GJ) ε`; + - with a 90° pretwist: `T = EA ε + K Φ/L`, `M = GJ Φ/L + K ε` and `Twist1 = 90°`. + + A 20 s march that moves End A 0.1 m away and rolls it −90° ends on the static values of that + state to 1e-7. `GJ|0` equals the uncoupled cable bit for bit, and `K² ≥ EA GJ` stops by name. - **Backward compatibility and refusals** (`torsion_deck`, full suite). Without torsion columns, with `Free` columns (whatever their normal), or with one restrained end, every output is byte-identical to the 6-column deck, and `Rigid`, `Infinity`, `Inf` and a quoted `"Rigid"` @@ -998,7 +1009,8 @@ in parentheses). errors. Limits. The torsion model is quasi-static (no torsional inertia), takes no seabed friction -against twist and no torque–tension coupling, and does not resolve self-contact. Dynamic loop +against twist, and does not resolve self-contact. The torque–tension coupling is checked against +closed forms only; there is no cross-code or experimental record of it. Dynamic loop formation (hockling) and a twisted slack catenary against OrcaFlex are not part of this record, and there is no experimental torsion case. diff --git a/doc/capabilities.rst b/doc/capabilities.rst index 257140f9..25943f26 100644 --- a/doc/capabilities.rst +++ b/doc/capabilities.rst @@ -85,7 +85,7 @@ Line and constitutive capability - Supported with limits - condensed isotropic torsion (uniform torque, quasi-static: no torsional inertia) of a finite-EI line restrained in torsion at both ends (``END CONNECTIONS`` torsion columns, - explicit ``GJ``), in statics with a stability check and buckling descent, and in dynamics + explicit ``GJ``), with torque–tension coupling (``GJ|K``), in statics with a stability check and buckling descent, and in dynamics with turning Rigid6 bodies, ``vesselMotion``/``vesselRAO`` and the ``motionFile`` roll column standalone, and with the platform orientation in coupled OpenFAST and FAST.Farm runs (torque returned to the platform, ``PtfmInit``, checkpoints; see diff --git a/doc/driver_format.md b/doc/driver_format.md index 550d19d1..0be83193 100644 --- a/doc/driver_format.md +++ b/doc/driver_format.md @@ -264,6 +264,10 @@ serves the secondary Cosserat 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. `GAs`, `Irt` and `Irn` are not used by the cubic-Hermite route, but the all-or-nothing rule still asks for positive values. +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`. **Viscoelastic axial stiffness (MoorDyn `ElasticMod`).** The EA and BA columns accept bar-separated parts: diff --git a/doc/outputs.rst b/doc/outputs.rst index 03e4af94..52c64afd 100644 --- a/doc/outputs.rst +++ b/doc/outputs.rst @@ -734,12 +734,14 @@ Line-node channels * - ``TorqN`` - torque (twisting moment) at node ``J`` of a line restrained in torsion at both ends (``END CONNECTIONS`` ``TorsStiffness``, see :doc:`driver_format`). It is uniform along the - line, :math:`M = (\Phi - \Theta)/C`; positive for a right-handed twist of End B relative + line, :math:`M = (\Phi - \Theta_{\text{eff}})/C` (:math:`\Theta_{\text{eff}} = \Theta` + without torque–tension coupling); positive for a right-handed twist of End B relative to End A about the End A → End B tangent, as OrcaFlex's ``Torque`` - N·m * - ``TwistN`` - - material twist of the cable itself from End A to node ``J``, - :math:`M \sum L_e/GJ_e` over the elements between them: 0 at End A, and at End B the + - material twist of the cable itself from End A to node ``J``, the sum of the element + twists :math:`M L_e/GJ_e` (less :math:`(K/GJ)(l_e - L_e)` under torque–tension coupling) + over the elements between them: 0 at End A, and at End B the twist of the line without the windup of its torsional end springs. OrcaFlex reports the twist rate (``Twist``, deg/m) instead; here it is integrated from End A - deg diff --git a/doc/theory.rst b/doc/theory.rst index 93b844e5..37f91c5f 100644 --- a/doc/theory.rst +++ b/doc/theory.rst @@ -471,11 +471,38 @@ and the end tangent together), so the virtual work of the body moment is exact; line it is the torque along the line axis. The static body equilibrium uses the same moment and its stiffness :math:`\mathbf{a}\mathbf{a}^{\mathsf T}/C`, :math:`\mathbf{a} = \partial\Theta/\partial\boldsymbol{\omega}_A`. +**Torque–tension coupling.** The helical armour of a power cable or a wire rope couples +stretch and twist. With the coupling :math:`K` of the section (``GJ|K`` in the ``GJ`` column, see +:doc:`driver_format`), the section laws are + +.. math:: + + T = EA\,\varepsilon + K\,\tau, \qquad M = GJ\,\tau + K\,\varepsilon , + +with :math:`\tau` the material twist rate and :math:`EA\,GJ > K^2`. The torque is still uniform +along the line, so the twist rate :math:`\tau = (M - K\varepsilon)/GJ` follows the strain +pointwise and the condensation stays exact. The cable carries the axial stiffness +:math:`EA - K^2/GJ` of a section free to twist, and the twist the ends see is + +.. math:: + + \Theta_{\text{eff}} = \Theta - \sum_e \frac{K_e}{GJ_e}\,(l_e - L_{0,e}), \qquad + M = \frac{\Phi - \Theta_{\text{eff}}}{C} , + +where :math:`l_e = \int_e \lvert\mathbf{r}'\rvert\,\mathrm{d}s` is the stretched element +length, integrated on the bending rule with its gradient and Hessian. Everything else above, +including the rank-one tangent, the step limit and the stability test, holds with +:math:`\Theta_{\text{eff}}`. The coupling part has no :math:`2\pi` ambiguity, so the first +evaluation unwraps the holonomy alone. A line free to twist at one end carries no torque and +the axial stiffness :math:`EA - K^2/GJ`. Restrained at both ends, a straight stretched line +cannot twist, so it carries :math:`T = EA\,\varepsilon` and :math:`M = K\varepsilon`. The node +tension adds the element's :math:`(K/GJ)\,M`, and the twist channels sum the element twists +:math:`M L_0/GJ - (K/GJ)(l - L_0)`. + **Limits.** Seabed friction does not resist twist, so the laid part of a line twists freely (the friction torque of a cable on the seabed can be comparable with the twist torque near -touchdown). There is no torque–tension coupling of armoured cables or wire ropes, no -anisotropic or pre-twisted section, and no self-contact: a loop that closes on itself is not -resolved. The model is that of :ref:`Meier, Popp & Wall (2014) ` and +touchdown). There is no anisotropic or pre-twisted section, and no self-contact: a loop that +closes on itself is not resolved. The model is that of :ref:`Meier, Popp & Wall (2014) ` and :ref:`Bergou et al. (2008) ` restricted to the isotropic, torque-free-span case; it is not a new formulation. diff --git a/python/cabledyn/builder.py b/python/cabledyn/builder.py index 13f6cabc..cb8cda73 100644 --- a/python/cabledyn/builder.py +++ b/python/cabledyn/builder.py @@ -192,7 +192,8 @@ class LineType: gas, gj, irt, irn : float | None Optional finite-EI columns (shear and torsional stiffness, rotary inertias). All four set writes the 14-column row; all ``None`` writes - the 10-column row. + the 10-column row. ``gj`` may be ``(GJ, K)``, with ``K`` the + torque-tension coupling in N m (written ``GJ|K``). cl, df, cf : float | None Optional cross-flow VIV columns of a type (MoorDyn's lift coefficient and the half-range and centre of the synchronisation band @@ -211,7 +212,7 @@ class LineType: can: float = 0.0 cat: float = 0.0 gas: float | None = None - gj: float | None = None + gj: float | tuple[float, float] | None = None irt: float | None = None irn: float | None = None cl: float | None = None @@ -1627,7 +1628,7 @@ def add_line_type( can: float = 0.0, cat: float = 0.0, gas: float | None = None, - gj: float | None = None, + gj: float | tuple[float, float] | None = None, irt: float | None = None, irn: float | None = None, cl: float | None = None, @@ -2658,7 +2659,12 @@ def _line_type_table(self) -> tuple[str, str, list[list[str]]]: extra = (item.gas, item.gj, item.irt, item.irn) if all(value is not None for value in extra): wide = True - row += [_num(value, what) for value in extra] + if isinstance(item.gj, tuple) and len(item.gj) != 2: + raise ValueError(f"{what}: gj is GJ or (GJ, K)") + row += [ + _multi(value, what) if index == 1 else _num(value, what) + for index, value in enumerate(extra) + ] elif any(value is not None for value in extra): raise ValueError(f"{what}: give all of gas, gj, irt, irn or none") row += [_num(v, what) for v in (item.cdn, item.cdt, item.can, item.cat)] @@ -3165,7 +3171,7 @@ def line_type(self, row: DeckRecord) -> None: can=_f(values["can"]), cat=_f(values["cat"]), gas=_f(values["gas"]) if wide else None, - gj=_f(values["gj"]) if wide else None, + gj=_fmulti(values["gj"]) if wide else None, irt=_f(values["irt"]) if wide else None, irn=_f(values["irn"]) if wide else None, cl=_f(values["cl"]) if "cl" in values else None, diff --git a/python/cabledyn/deck_file.py b/python/cabledyn/deck_file.py index 2963c432..3fe4a0c7 100644 --- a/python/cabledyn/deck_file.py +++ b/python/cabledyn/deck_file.py @@ -2654,6 +2654,8 @@ def numeric(token: str, row: DeckRecord, field: str) -> float: viv_type_names: set[str] = set() for row in self.line_types: for index in (1, 2, *range(5, len(row.tokens))): + if len(row.tokens) == 14 and index == 7: + continue # the GJ column, GJ or GJ|K, is read below numeric(row.tokens[index], row, f"LINE TYPES column {index + 1}") ea_parts = row.tokens[3].split("|") ba_parts = row.tokens[4].split("|") @@ -2740,10 +2742,21 @@ def numeric(token: str, row: DeckRecord, field: str) -> float: if ei > 0.0 and (is_syrope or len(ea_parts) > 1): model = "Syrope" if is_syrope else "viscoelastic stiffness" raise DeckFormatError(f"{self._at(row)}: {model} is not supported with EI > 0") + gj_value = 0.0 if len(row.tokens) == 14: + # the GJ column is GJ or GJ|K (K the torque-tension coupling, N m) + gj_parts = row.tokens[7].split("|") + if len(gj_parts) > 2: + raise DeckFormatError( + f'{self._at(row)}: LINE TYPES GJ column "{row.tokens[7]}" takes GJ or GJ|K' + ) + gj_value = numeric(gj_parts[0], row, "GJ") + ktt = numeric(gj_parts[1], row, "GJ|K coupling") if len(gj_parts) == 2 else 0.0 finite_ei = [ - numeric(row.tokens[index], row, f"LINE TYPES column {index + 1}") - for index in range(6, 10) + numeric(row.tokens[6], row, "LINE TYPES column 7"), + gj_value, + numeric(row.tokens[8], row, "LINE TYPES column 9"), + numeric(row.tokens[9], row, "LINE TYPES column 10"), ] if any(value != 0.0 for value in finite_ei) and any( value <= 0.0 for value in finite_ei @@ -2751,15 +2764,30 @@ def numeric(token: str, row: DeckRecord, field: str) -> float: raise DeckFormatError( f"{self._at(row)}: explicit GAs/GJ/Irt/Irn must all be positive" ) + if ktt != 0.0: + name = row.tokens[0] + if not ei > 0.0: + raise DeckFormatError( + f"{self._at(row)}: LINE TYPES {name}: torque-tension coupling (GJ|K) " + "needs a finite-EI cable (EI > 0)" + ) + if is_syrope or len(ea_parts) > 1: + raise DeckFormatError( + f"{self._at(row)}: LINE TYPES {name}: torque-tension coupling (GJ|K) " + "needs a linear-elastic EA" + ) + if not (gj_value > 0.0 and ea_static * gj_value > ktt * ktt): + raise DeckFormatError( + f"{self._at(row)}: LINE TYPES {name}: torque-tension coupling needs " + "GJ > 0 and K^2 < EA GJ" + ) line_type_meta[row.tokens[0].lower()] = ( numeric(row.tokens[1], row, "Diam"), numeric(row.tokens[2], row, "Mass"), ea_static, ei, ) - line_type_gj[row.tokens[0].lower()] = ( - numeric(row.tokens[7], row, "GJ") if len(row.tokens) == 14 else 0.0 - ) + line_type_gj[row.tokens[0].lower()] = gj_value # Syrope keeps its BA_s on the working-curve model (native BA slot = 0) line_type_scales[row.tokens[0].lower()] = ( 0.0 if is_syrope else ba_values[0], diff --git a/python/tests/test_builder.py b/python/tests/test_builder.py index f483ffc1..c0996a74 100644 --- a/python/tests/test_builder.py +++ b/python/tests/test_builder.py @@ -938,3 +938,51 @@ def test_title_is_read_only_after_the_banner() -> None: assert DeckModel.from_text(banner_only).title == "CableDyn deck" preamble = "preamble" + chr(10) + text assert DeckModel.from_text(preamble).title == "single chain catenary" + + +def test_torque_tension_coupling_round_trips_in_the_gj_column(tmp_path: Path) -> None: + model = _chain_model(tmp_path) + cable = model.add_line_type( + "cable", + diam=0.2, + mass=40.0, + ea=5.0e8, + ei=1.0e4, + gas=1.0e8, + gj=(1.0e4, 2.0e5), + irt=0.1, + irn=0.05, + ) + assert cable.gj == (1.0e4, 2.0e5) + target = model.save(tmp_path / "coupled.dat") + deck = DeckFile.read(target) + row = next(r for r in deck.line_types if r.tokens[0] == "cable") + assert [float(v) for v in row.tokens[7].split("|")] == [1.0e4, 2.0e5] + loaded = DeckModel.load(target) + assert next(t for t in loaded.line_types if t.name == "cable").gj == (1.0e4, 2.0e5) + + +@pytest.mark.parametrize( + ("gj", "ei", "message"), + [ + ("1.0e4|1.0e7", "1.0e4", r"K\^2 < EA GJ"), + ("1.0e4|1.0e3", "0.0", "needs a finite-EI cable"), + ("1.0e4|1.0e3|5.0", "1.0e4", r"takes GJ or GJ\|K"), + ], +) +def test_torque_tension_coupling_refusals(tmp_path: Path, gj: str, ei: str, message: str) -> None: + model = _chain_model(tmp_path) + model.add_line_type( + "cable", diam=0.2, mass=40.0, ea=5.0e8, ei=1.0e4, gas=1.0e8, gj=1.0e4, irt=0.1, irn=0.05 + ) + text = model.to_text(validate=False) + bad = re.sub( + r"^cable\s.*$", + f"cable 0.2 40.0 5.0e8 0.0 {ei} 1.0e8 {gj} 0.1 0.05 0.0 0.0 0.0 0.0", + text, + flags=re.M, + ) + path = tmp_path / "bad.dat" + path.write_text(bad, encoding="utf-8") + with pytest.raises(DeckFormatError, match=message): + DeckFile.read(path) diff --git a/src/CableDyn_DeckDriver.f90 b/src/CableDyn_DeckDriver.f90 index f4cf1b08..67f916cd 100644 --- a/src/CableDyn_DeckDriver.f90 +++ b/src/CableDyn_DeckDriver.f90 @@ -109,7 +109,8 @@ 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_Attachment_Drag, CD_HermiteCable_Dyn_Torsion_State + CD_HermiteCable_Attachment_Drag, CD_HermiteCable_Dyn_Torsion_State, & + CD_HermiteCable_Dyn_Element_Twist, CD_HermiteCable_Dyn_Coupling_Tension USE CableDyn_HermiteTorsion, ONLY: CD_HermiteTorsionType, CD_HermiteTorsion_Compliance, CD_HTORS_MAX_STEP, & CD_HTORS_MAX_TWIST USE CableDyn_EndConnection, ONLY: CD_ENDCONN_PINNED, CD_ENDCONN_FINITE, CD_ENDCONN_RIGID @@ -362,6 +363,9 @@ MODULE CableDyn_DeckDriver REAL(wp) :: diam = CD_ZERO, mass = CD_ZERO, ea = CD_ZERO REAL(wp) :: ba = CD_ZERO, ei = CD_ZERO REAL(wp) :: gas = CD_ZERO, gj = CD_ZERO + ! torque-tension coupling K [N m] of the 14-column row's GJ column (GJ|K): the axial force + ! T = EA eps + K tau and the torque M = GJ tau + K eps of a finite-EI cable + REAL(wp) :: ktt = CD_ZERO REAL(wp) :: i_rt = CD_ZERO, i_rn = CD_ZERO REAL(wp) :: cdn = CD_ZERO, cdt = CD_ZERO, can = CD_ZERO, cat = CD_ZERO ! Viscoelastic stiffness (MoorDyn ElasticMod): the EA column's bar-separated @@ -1525,7 +1529,8 @@ SUBROUTINE init_finite_deck_models(types, points, lines, sections, opts, models, 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. + !! 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(:) @@ -1570,6 +1575,17 @@ SUBROUTINE init_one_finite_model(ln, sections, types, points, opts, deck_model, '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 @@ -1720,6 +1736,7 @@ RECURSIVE SUBROUTINE build_one_hermite_cable(ln, sections, types, points, opts, 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(:) + REAL(wp), ALLOCATABLE :: ktt_in(:) REAL(wp), ALLOCATABLE :: gas(:), gj(:), rho_a(:), i_rt(:), i_rn(:), w(:), nodes_ref(:, :), q0(:), q_static(:) REAL(wp), ALLOCATABLE :: q_sequence(:) REAL(wp), ALLOCATABLE :: curv(:), cdn(:), cdt(:), can(:), cat(:), catenary_pos(:) @@ -1801,6 +1818,9 @@ RECURSIVE SUBROUTINE build_one_hermite_cable(ln, sections, types, points, opts, ! static load stage on the final mesh, then installed in the cable. LOGICAL :: tors_line TYPE(CD_HermiteTorsionType) :: tors + ! the torque-tension coupling force (K/GJ) M_t of every element of the twisted static state + ! (allocated by torsion_stage under coupling only), for the final mesh safety diagnosis + REAL(wp), ALLOCATABLE :: tors_axial_offset(:) ErrStat = CD_DECKDRV_OK ErrMsg = '' @@ -1963,7 +1983,7 @@ RECURSIVE SUBROUTINE build_one_hermite_cable(ln, sections, types, points, opts, IF (as_laid_off_plane()) require_3d_static = .TRUE. CALL build_finite_section_mesh(ln, sections, types, conn, l0, ea, mpl, diam, ei, & - gas_in, gj_in, i_rt_in, i_rn_in, ErrStat, ErrMsg) + gas_in, gj_in, i_rt_in, i_rn_in, ErrStat, ErrMsg, ktt=ktt_in) IF (ErrStat /= CD_DECKDRV_OK) RETURN IF (ALLOCATED(ln%stf)) THEN ALLOCATE (ei_cable(SIZE(l0))) @@ -2954,16 +2974,19 @@ RECURSIVE SUBROUTINE build_one_hermite_cable(ln, sections, types, points, opts, IF (contact_enabled) CALL anchor_overshoot_note() ! Safety is independent of the opt-in adaptive accuracy policy. Diagnose the ! equilibrium on the FINAL user/refined mesh and reject an element-localized fold - ! even when Newton balanced its residual and adaptive_mesh is false. + ! even when Newton balanced its residual and adaptive_mesh is false. A twisted line under + ! torque-tension coupling is judged on its section tension (the coupling force added). IF (PRESENT(bathymetry) .AND. .NOT. bathymetry_flat) THEN CALL CD_HermiteCable_Resolution_Metrics(l0_am, q_static, contact_z, CD_ZERO, & CD_HC_KINK_LIMIT, diag, es, em, & bathymetry=bathymetry, contact_frame_cs=frame_cs, & - EA=ea_am, EI=ei_am, compression_mode=CD_HC_COMPRESSION_STRICT) + EA=ea_am, EI=ei_am, compression_mode=CD_HC_COMPRESSION_STRICT, & + axial_offset=tors_axial_offset) ELSE CALL CD_HermiteCable_Resolution_Metrics(l0_am, q_static, contact_z, CD_ZERO, & CD_HC_KINK_LIMIT, diag, es, em, EA=ea_am, EI=ei_am, & - compression_mode=CD_HC_COMPRESSION_STRICT) + compression_mode=CD_HC_COMPRESSION_STRICT, & + axial_offset=tors_axial_offset) END IF IF (es /= CD_HCSTAT_OK) THEN CALL fail_solve(ErrStat, ErrMsg, 'finite-EI mesh safety diagnosis failed: '//TRIM(em)); RETURN @@ -3297,6 +3320,11 @@ SUBROUTINE torsion_stage(est, emt) tors%quadrature_order = opts%bending_quadrature_order tors%gj = gj_in IF (SIZE(l0_am) /= SIZE(l0)) CALL remap_elem_by_reference_arc(tors%gj, l0, l0_am) + ! torque-tension coupling: K/GJ per element (left unallocated without coupling) + IF (ANY(ABS(ktt_in) > CD_ZERO)) THEN + tors%couple = ktt_in/gj_in + IF (SIZE(l0_am) /= SIZE(l0)) CALL remap_elem_by_reference_arc(tors%couple, l0, l0_am) + END IF DO k = 1, 2 dvec = endconn_d0_local(:, k)/NORM2(endconn_d0_local(:, k)) IF (k == 1) THEN @@ -3350,6 +3378,7 @@ SUBROUTINE torsion_stage(est, emt) CALL report_note(tnote) END IF IF (est /= CD_DECKDRV_OK) RETURN + IF (ALLOCATED(tors%couple)) tors_axial_offset = tors%couple*tors%torque WRITE (tnote, '(A,I0,A,ES12.5,A,ES12.5,A,I0,A,I0,A)') 'line ', ln%id, ': torsion solved, imposed twist ', & tors%phi*45.0_wp/QUARTER_PI, ' deg, torque ', tors%torque, ' N m (', tors%ramp_steps, & ' twist stage(s), ', tors%descents, ' buckling descent(s))' @@ -9830,10 +9859,12 @@ SUBROUTINE end_hermite_cables(cables) END SUBROUTINE end_hermite_cables SUBROUTINE build_finite_section_mesh(ln, sections, types, conn, l0, ea, mpl, diam, ei, gas, gj, i_rt, i_rn, & - ErrStat, ErrMsg) + ErrStat, ErrMsg, ktt) !! Build a sectioned finite-EI mesh directly from deck sections. The EI=0 !! CableDyn_Line mesh builder intentionally rejects EI>0, so this path owns - !! the simple serial connectivity needed by the Cosserat model. + !! the simple serial connectivity needed by the Cosserat model. A type with torque-tension + !! coupling K gives its elements the axial stiffness EA - K^2/GJ (the stretch twists the + !! cable; a line restrained in torsion adds the rest through its torque) and, with ktt, its K. TYPE(DeckLine), INTENT(IN) :: ln TYPE(DeckSection), INTENT(IN) :: sections(:) TYPE(DeckLineType), INTENT(IN) :: types(:) @@ -9842,8 +9873,10 @@ SUBROUTINE build_finite_section_mesh(ln, sections, types, conn, l0, ea, mpl, dia REAL(wp), ALLOCATABLE, INTENT(OUT) :: gas(:), gj(:), i_rt(:), i_rn(:) INTEGER, INTENT(OUT) :: ErrStat CHARACTER(*), INTENT(OUT) :: ErrMsg + REAL(wp), ALLOCATABLE, INTENT(OUT), OPTIONAL :: ktt(:) INTEGER :: n_elem, i, j, e, tidx + REAL(wp), ALLOCATABLE :: kc(:) ErrStat = CD_DECKDRV_OK ErrMsg = '' @@ -9856,7 +9889,7 @@ SUBROUTINE build_finite_section_mesh(ln, sections, types, conn, l0, ea, mpl, dia RETURN END IF ALLOCATE (conn(2, n_elem), l0(n_elem), ea(n_elem), mpl(n_elem), diam(n_elem), ei(n_elem)) - ALLOCATE (gas(n_elem), gj(n_elem), i_rt(n_elem), i_rn(n_elem)) + ALLOCATE (gas(n_elem), gj(n_elem), i_rt(n_elem), i_rn(n_elem), kc(n_elem)) e = 0 DO i = 1, SIZE(sections) IF (sections(i)%line_id /= ln%id) CYCLE @@ -9873,6 +9906,8 @@ SUBROUTINE build_finite_section_mesh(ln, sections, types, conn, l0, ea, mpl, dia gj(e) = types(tidx)%gj i_rt(e) = types(tidx)%i_rt i_rn(e) = types(tidx)%i_rn + kc(e) = types(tidx)%ktt + IF (ABS(kc(e)) > CD_ZERO) ea(e) = ea(e) - kc(e)**2/gj(e) END DO END DO IF (ALLOCATED(ln%stf)) CALL CD_Stiffener_Overlay(ln%stf, l0, diam, ei=ei, mpl=mpl) @@ -9885,6 +9920,7 @@ SUBROUTINE build_finite_section_mesh(ln, sections, types, conn, l0, ea, mpl, dia gj = gj(n_elem:1:-1) i_rt = i_rt(n_elem:1:-1) i_rn = i_rn(n_elem:1:-1) + IF (PRESENT(ktt)) ktt = kc(n_elem:1:-1) END SUBROUTINE build_finite_section_mesh SUBROUTINE finite_raw_ba_array(ln, sections, types, ba_raw) @@ -13321,6 +13357,35 @@ SUBROUTINE sniff_types_header(line, stock_cols) END IF END SUBROUTINE sniff_types_header + SUBROUTINE parse_gj_column(gj_str, t, ErrStat, ErrMsg) + !! The 14-column row's GJ column: GJ, or GJ|K with K the torque-tension coupling [N m] + !! (M = GJ tau + K eps, T = EA eps + K tau; K > 0 when stretching the cable twists it in the + !! sense its positive torque turns). + CHARACTER(*), INTENT(IN) :: gj_str + TYPE(DeckLineType), INTENT(INOUT) :: t + INTEGER, INTENT(OUT) :: ErrStat + CHARACTER(*), INTENT(OUT) :: ErrMsg + INTEGER :: bar, ios + ErrStat = 0; ErrMsg = '' + t%ktt = CD_ZERO + bar = INDEX(gj_str, '|') + IF (bar == 0) THEN + READ (gj_str, *, IOSTAT=ios) t%gj + ELSE + IF (INDEX(gj_str(bar + 1:), '|') > 0) THEN + CALL fail(ErrStat, ErrMsg, 'LINE TYPES GJ column "'//TRIM(gj_str)//'" takes GJ or GJ|K'); RETURN + END IF + READ (gj_str(1:bar - 1), *, IOSTAT=ios) t%gj + IF (ios == 0) READ (gj_str(bar + 1:), *, IOSTAT=ios) t%ktt + END IF + IF (ios /= 0) THEN + CALL fail(ErrStat, ErrMsg, 'LINE TYPES GJ column "'//TRIM(gj_str)//'" is not GJ or GJ|K'); RETURN + END IF + IF (.NOT. (IEEE_IS_FINITE(t%gj) .AND. IEEE_IS_FINITE(t%ktt))) THEN + CALL fail(ErrStat, ErrMsg, 'LINE TYPES GJ column "'//TRIM(gj_str)//'" must be finite'); RETURN + END IF + END SUBROUTINE parse_gj_column + SUBROUTINE append_type(line, types, nt, stock_cols, ErrStat, ErrMsg) CHARACTER(*), INTENT(IN) :: line TYPE(DeckLineType), ALLOCATABLE, INTENT(INOUT) :: types(:) @@ -13331,7 +13396,7 @@ SUBROUTINE append_type(line, types, nt, stock_cols, ErrStat, ErrMsg) TYPE(DeckLineType) :: t ! EA may hold SYROPE:|alpha|beta, so it gets a path-length buffer CHARACTER(CD_DECK_PATHLEN) :: ea_str - CHARACTER(NAMELEN) :: ba_str + CHARACTER(NAMELEN) :: ba_str, gj_str INTEGER :: ios, ntok ErrStat = 0; ErrMsg = '' ntok = count_tokens(line) @@ -13373,12 +13438,16 @@ SUBROUTINE append_type(line, types, nt, stock_cols, ErrStat, ErrMsg) CALL fail(ErrStat, ErrMsg, 'the 14-column LINE TYPES row is a CableDyn form (... Cd_n Cd_t '// & 'Ca_n Ca_t); it does not combine with a stock-order header (Cd Ca CdAx CaAx)'); RETURN END IF - READ (line, *, IOSTAT=ios) t%name, t%diam, t%mass, ea_str, ba_str, t%ei, t%gas, t%gj, t%i_rt, t%i_rn, & + READ (line, *, IOSTAT=ios) t%name, t%diam, t%mass, ea_str, ba_str, t%ei, t%gas, gj_str, t%i_rt, t%i_rn, & t%cdn, t%cdt, t%can, t%cat END IF IF (ios /= 0) THEN CALL fail(ErrStat, ErrMsg, 'malformed LINE TYPES row'); RETURN END IF + IF (ntok == 14) THEN + CALL parse_gj_column(gj_str, t, ErrStat, ErrMsg) + IF (ErrStat /= 0) RETURN + END IF ! Drag and added-mass coefficients are magnitudes; a negative value would inject ! energy. Rejected here, with the row, on every route (static decks included). IF (t%cdn < CD_ZERO .OR. t%cdt < CD_ZERO .OR. t%can < CD_ZERO .OR. t%cat < CD_ZERO) THEN @@ -13391,6 +13460,21 @@ SUBROUTINE append_type(line, types, nt, stock_cols, ErrStat, ErrMsg) CALL check_viv_columns(t, ErrStat, ErrMsg) IF (ErrStat /= 0) RETURN END IF + IF (ABS(t%ktt) > CD_ZERO) THEN + ! the coupled section energy 1/2 (EA eps^2 + 2 K eps tau + GJ tau^2) must stay positive + IF (.NOT. (t%ei > CD_ZERO)) THEN + CALL fail(ErrStat, ErrMsg, 'LINE TYPES '//TRIM(t%name)//': torque-tension coupling (GJ|K) needs a '// & + 'finite-EI cable (EI > 0)'); RETURN + END IF + IF (t%is_syrope .OR. t%elastic_mod > 1) THEN + CALL fail(ErrStat, ErrMsg, 'LINE TYPES '//TRIM(t%name)//': torque-tension coupling (GJ|K) needs a '// & + 'linear-elastic EA'); RETURN + END IF + IF (.NOT. (t%gj > CD_ZERO .AND. t%ea*t%gj > t%ktt**2)) THEN + CALL fail(ErrStat, ErrMsg, 'LINE TYPES '//TRIM(t%name)//': torque-tension coupling needs GJ > 0 and '// & + 'K^2 < EA GJ'); RETURN + END IF + END IF CALL grow_types(types, nt) nt = nt + 1; types(nt) = t END SUBROUTINE append_type @@ -28895,6 +28979,10 @@ SUBROUTINE write_hermite_static_element_profile(out_root, lines, cables, ErrStat CLOSE (unit, STATUS='DELETE') CALL fail_solve(ErrStat, ErrMsg, 'continuous axial-resultant extraction failed: '//TRIM(em)); RETURN END IF + ! the section's tension under torque-tension coupling: the element's (K/GJ) M_t added + ! to the kernel's EA - K^2/GJ resultant (constant along the element) + minimum_resultant = minimum_resultant + CD_HermiteCable_Dyn_Coupling_Tension(cables(li)%line, internal_element) + maximum_resultant = maximum_resultant + CD_HermiteCable_Dyn_Coupling_Tension(cables(li)%line, internal_element) arc_end = arc_start + l0 u_curvature_public = CD_ONE - u_curvature_internal minimum_u_public = CD_ONE - minimum_u_internal @@ -34511,11 +34599,17 @@ SUBROUTINE range_sample_cable(cable, rl, ErrStat, ErrMsg) ! (public node 1, the last internal node), as the TorqN and TwistN channels rl%val(CD_RQ_TORQUE, :) = cable%line%torsion%torque rl%val(CD_RQ_TWIST, 1) = CD_ZERO - DO j = 2, nn - inode = nn + 1 - j - rl%val(CD_RQ_TWIST, j) = rl%val(CD_RQ_TWIST, j - 1) + cable%line%torsion%torque* & - cable%line%l0(inode)/cable%line%torsion%gj(inode)*45.0_wp/QUARTER_PI - END DO + BLOCK + REAL(wp) :: etw(cable%line%ne) + CALL CD_HermiteCable_Dyn_Element_Twist(cable%line, etw, es, em) + IF (es /= CD_HCDYN_OK) THEN + CALL fail_solve(ErrStat, ErrMsg, 'range-graph twist recovery failed: '//TRIM(em)); RETURN + END IF + DO j = 2, nn + inode = nn + 1 - j + rl%val(CD_RQ_TWIST, j) = rl%val(CD_RQ_TWIST, j - 1) + etw(inode)*45.0_wp/QUARTER_PI + END DO + END BLOCK END IF CONTAINS @@ -35402,22 +35496,28 @@ SUBROUTINE eval_cable_channel(cable, ch, val, ErrStat, ErrMsg, mesh_node) CASE (9, 10, 11) ! condensed torsion: torque [N m], twist from End A to node J, total twist [deg] BLOCK REAL(wp) :: th, mt - INTEGER :: e CALL CD_HermiteCable_Dyn_Torsion_State(cable%line, th, mt, es, em) IF (es /= CD_HCDYN_OK) THEN CALL fail_solve(ErrStat, ErrMsg, 'OUTPUT "'//TRIM(ch)//'": '//TRIM(em)); RETURN END IF IF (kind == 9) THEN val = mt - ELSE IF (kind == 11) THEN - val = mt*CD_HermiteTorsion_Compliance(cable%line%torsion, cable%line%l0)*45.0_wp/QUARTER_PI ELSE IF (cable%line%torsion%active) THEN - ! End A is the last internal node: the cable's own twist over the elements inode..ne - val = CD_ZERO - DO e = inode, nelem - val = val + cable%line%l0(e)/cable%line%torsion%gj(e) - END DO - val = mt*val*45.0_wp/QUARTER_PI + ! the element twists (M_t l0/GJ, less the stretch's under torque-tension coupling); + ! kind 11 the whole line with its end compliances, kind 10 the cable's own twist from + ! End A, the last internal node, over the elements inode..ne + BLOCK + REAL(wp) :: etw(nelem) + CALL CD_HermiteCable_Dyn_Element_Twist(cable%line, etw, es, em) + IF (es /= CD_HCDYN_OK) THEN + CALL fail_solve(ErrStat, ErrMsg, 'OUTPUT "'//TRIM(ch)//'": '//TRIM(em)); RETURN + END IF + IF (kind == 11) THEN + val = (mt*SUM(cable%line%torsion%end_compliance) + SUM(etw))*45.0_wp/QUARTER_PI + ELSE + val = SUM(etw(inode:nelem))*45.0_wp/QUARTER_PI + END IF + END BLOCK END IF END BLOCK CASE (8) ! azimuth: local-frame azimuth plus the cable's frame heading, wrapped @@ -35531,6 +35631,8 @@ END FUNCTION cable_element_tension REAL(wp) FUNCTION cable_axial_tension(cable, e, xi) RESULT(t) !! Constitutive axial force at xi in [0,1]. Hermite tangent DOFs are dr/ds, !! while the public shape derivative is with respect to xi, hence division by L. + !! Under torque-tension coupling the section's tension adds (K/GJ) M_t to the + !! kernel's EA - K^2/GJ resultant. TYPE(CD_HFMF_ModuleType), INTENT(IN) :: cable INTEGER, INTENT(IN) :: e REAL(wp), INTENT(IN) :: xi @@ -35548,6 +35650,7 @@ REAL(wp) FUNCTION cable_axial_tension(cable, e, xi) RESULT(t) t = CD_ZERO RETURN END IF + t = t + CD_HermiteCable_Dyn_Coupling_Tension(cable%line, e) IF (cable%line%has_axial_damping) THEN vr(1:6) = cable%line%v(6*(e - 1) + 1:6*(e - 1) + 6) vr(7:12) = cable%line%v(6*e + 1:6*e + 6) diff --git a/src/CableDyn_HermiteCableDynamic.f90 b/src/CableDyn_HermiteCableDynamic.f90 index b0a5d1da..cd696c9a 100644 --- a/src/CableDyn_HermiteCableDynamic.f90 +++ b/src/CableDyn_HermiteCableDynamic.f90 @@ -78,7 +78,8 @@ MODULE CableDyn_HermiteCableDynamic USE CableDyn_HermiteTorsion, ONLY: CD_HermiteTorsionType, CD_HermiteTorsion_Line, CD_HermiteTorsion_Unwrap, & CD_HermiteTorsion_Compliance, CD_HermiteTorsion_Validate, CD_HTORS_OK, & CD_HTORS_MAX_STEP, CD_HermiteTorsionWorkType, CD_HermiteTorsion_Work_Init, & - CD_HermiteTorsion_Work_End, CD_HermiteTorsion_Work_Add_Hessian + CD_HermiteTorsion_Work_End, CD_HermiteTorsion_Work_Add_Hessian, & + CD_HermiteTorsion_Element_Stretch USE, INTRINSIC :: ISO_FORTRAN_ENV, ONLY: INT64 !$ USE OMP_LIB, ONLY: omp_get_max_threads, omp_in_parallel IMPLICIT NONE @@ -91,6 +92,8 @@ MODULE CableDyn_HermiteCableDynamic PUBLIC :: CD_HermiteCable_Dyn_Set_EndConnection PUBLIC :: CD_HermiteCable_Dyn_Set_Torsion PUBLIC :: CD_HermiteCable_Dyn_Torsion_State + PUBLIC :: CD_HermiteCable_Dyn_Element_Twist + PUBLIC :: CD_HermiteCable_Dyn_Coupling_Tension PUBLIC :: CD_HermiteCable_Dyn_Set_Torsion_Drive PUBLIC :: CD_HermiteCable_Dyn_Set_Torsion_Frames PUBLIC :: CD_HermiteCable_Dyn_EndConnection_Moment @@ -3509,7 +3512,7 @@ SUBROUTINE dyn_step_core(model, dt, max_iter, tol, ErrStat, ErrMsg, iters_out, r INTEGER :: ndof, it, es, i, np, ip, ls, gdof, nsolve_step, axial_element, axial_es INTEGER :: axial_worst_element, iv, attempt, n_attempt REAL(wp) :: c_a, c_v, c_a2, am, af, bt, gm, rnorm, fscale, rnt, lambda, chosen, lam_ok, cw, t_alpha, dth_lin - REAL(wp) :: e_bal, e_ma, tors_theta_new + REAL(wp) :: e_bal, e_ma, tors_theta_new, tors_mt_new REAL(wp) :: axial_qe(12), axial_min REAL(wp) :: axial_threshold, axial_margin, axial_worst_margin, axial_worst_force, axial_worst_xi REAL(wp) :: axial_worst_threshold @@ -4231,6 +4234,20 @@ SUBROUTINE dyn_step_core(model, dt, max_iter, tol, ErrStat, ErrMsg, iters_out, r END IF END IF + ! Condensed torsion: Theta at q_{n+1} with the step's end frames, unwrapped against the + ! committed value (within pi/2: every accepted evaluation already was), before anything is + ! committed so that a failure leaves the step-start state; its torque enters the axial + ! audit under torque-tension coupling. + tors_theta_new = model%torsion%theta + tors_mt_new = CD_ZERO + IF (model%torsion%active) THEN + CALL torsion_theta_at(model, model%ws_qk, model%tors_step_ends, tors_theta_new, es, em2) + IF (es /= CD_HCDYN_OK) THEN + ErrStat = es; ErrMsg = 'CD_HermiteCable_Dyn_Step: '//TRIM(em2); RETURN + END IF + tors_mt_new = (model%tors_step_phi - tors_theta_new)/CD_HermiteTorsion_Compliance(model%torsion, model%l0) + END IF + ! Axial audit of the converged field. ERROR is the hard gate; WARN commits the converged ! state and records one event for this accepted step. The audited force is the one that ! enters equilibrium, as in the static branch audit: the element-mean axial force (the @@ -4241,8 +4258,9 @@ SUBROUTINE dyn_step_core(model, dt, max_iter, tol, ErrStat, ErrMsg, iters_out, r ! the element length: judged pointwise, a coarse mesh whose tensions and curvatures are ! converged reads as compressed. A compressed span of three or more elements is never ! averaged away. The band is tensile_strain_tolerance times the length-weighted EA of the - ! same three elements; a window whose elements all have a strain lower bound inside the - ! band cannot fall below it and is skipped. + ! same three elements; a window whose elements all have a force lower bound inside the + ! band cannot fall below it and is skipped. Under torque-tension coupling the element's + ! axial force adds (K/GJ) M_t at the converged torque to the kernel's EA - K^2/GJ resultant. IF (model%tensile_mode /= CD_HCDYN_TENSILE_OFF) THEN axial_worst_margin = HUGE(CD_ONE) axial_worst_force = CD_ZERO; axial_worst_threshold = CD_ZERO @@ -4319,17 +4337,6 @@ SUBROUTINE dyn_step_core(model, dt, max_iter, tol, ErrStat, ErrMsg, iters_out, r END IF END IF - ! Condensed torsion: Theta at q_{n+1} with the step's end frames, unwrapped against the - ! committed value (within pi/2: every accepted evaluation already was), before anything is - ! committed so that a failure leaves the step-start state. - tors_theta_new = model%torsion%theta - IF (model%torsion%active) THEN - CALL torsion_theta_at(model, model%ws_qk, model%tors_step_ends, tors_theta_new, es, em2) - IF (es /= CD_HCDYN_OK) THEN - ErrStat = es; ErrMsg = 'CD_HermiteCable_Dyn_Step: '//TRIM(em2); RETURN - END IF - END IF - ! Adaptive modified Newton: this step CONVERGED (a non-converged step returned above and ! does not count). Accumulate the warmup's full-Newton solve counts and, at the end of ! the warmup, latch tangent reuse on for the rest of the run iff the warmup averaged more @@ -4436,19 +4443,33 @@ SUBROUTINE dyn_step_core(model, dt, max_iter, tol, ErrStat, ErrMsg, iters_out, r CONTAINS SUBROUTINE window_load(slot, e) - !! Axial audit window slot for element e: whether its strain lower bound lies inside the - !! band (its element mean cannot then be below -tolerance*EA); the mean is computed on - !! demand (window_mean). + !! Axial audit window slot for element e: whether its force lower bound (EA times the + !! strain lower bound, plus the coupling force) lies inside the band (its element mean + !! cannot then be below -tolerance*EA); the mean is computed on demand (window_mean). INTEGER, INTENT(IN) :: slot, e win_elem(slot) = e win_done(slot) = .FALSE. win_mean(slot) = CD_ZERO axial_qe(1:6) = model%ws_qk(6*(e - 1) + 1:6*e) axial_qe(7:12) = model%ws_qk(6*e + 1:6*(e + 1)) - win_clear(slot) = CD_HermiteCable_Axial_Strain_Lower_Bound(axial_qe, model%l0(e)) >= & - -model%tensile_strain_tolerance + IF (.NOT. ABS(audit_coupling(e)) > CD_ZERO) THEN + win_clear(slot) = CD_HermiteCable_Axial_Strain_Lower_Bound(axial_qe, model%l0(e)) >= & + -model%tensile_strain_tolerance + ELSE + win_clear(slot) = model%EA(e)*CD_HermiteCable_Axial_Strain_Lower_Bound(axial_qe, model%l0(e)) + & + audit_coupling(e) >= -model%tensile_strain_tolerance*model%EA(e) + END IF END SUBROUTINE window_load + REAL(wp) FUNCTION audit_coupling(e) RESULT(tc) + !! The torque-tension coupling force (K/GJ) M_t of element e at the converged torque. + INTEGER, INTENT(IN) :: e + tc = CD_ZERO + IF (.NOT. model%torsion%active) RETURN + IF (.NOT. ALLOCATED(model%torsion%couple)) RETURN + tc = model%torsion%couple(e)*tors_mt_new + END FUNCTION audit_coupling + SUBROUTINE window_mean(slot, esx) !! Element-mean axial force of the element in window slot: the three-point Gauss mean !! of the signed axial resultant (the static branch audit's element mean). @@ -4467,6 +4488,7 @@ SUBROUTINE window_mean(slot, esx) IF (esx /= CD_HCABLE_OK) RETURN win_mean(slot) = win_mean(slot) + GW(kg)*ng END DO + win_mean(slot) = win_mean(slot) + audit_coupling(e) win_done(slot) = .TRUE. END SUBROUTINE window_mean @@ -4779,7 +4801,8 @@ SUBROUTINE torsion_theta_at(model, q_cfg, ends, theta, ErrStat, ErrMsg) CHARACTER(1024) :: em theta = model%torsion%theta CALL CD_HermiteTorsion_Line(q_cfg, model%l0, ends, raw, model%tors_gq, es, em, & - quadrature_order=model%torsion%quadrature_order, work=model%tors_work) + couple=model%torsion%couple, quadrature_order=model%torsion%quadrature_order, & + work=model%tors_work) IF (es /= CD_HTORS_OK) THEN ErrStat = CD_HCDYN_NOCONVERGE ErrMsg = 'torsion: '//TRIM(em) @@ -5632,7 +5655,7 @@ SUBROUTINE CD_HermiteCable_Dyn_Section_Curvature(model, ref_a, kx, ky, ErrStat, IF (model%torsion%active) THEN CALL CD_HermiteCable_Dyn_Torsion_State(model, th, mt, ErrStat, ErrMsg) IF (ErrStat /= CD_HCDYN_OK) RETURN - comp = model%torsion%end_compliance(2) + comp = mt*model%torsion%end_compliance(2) END IF DO a = model%nn, 1, -1 IF (a < model%nn) THEN @@ -5655,9 +5678,9 @@ SUBROUTINE CD_HermiteCable_Dyn_Section_Curvature(model, ref_a, kx, ky, ErrStat, t = -unit_tangent(model, a) d1 = d1 - DOT_PRODUCT(d1, t)*t d1 = d1/NORM2(d1) - IF (model%torsion%active) comp = comp + model%l0(e)/model%torsion%gj(e) + IF (model%torsion%active) comp = comp + element_twist(model, e, mt) END IF - phi = mt*comp + phi = comp d = COS(phi)*d1 + SIN(phi)*cross3_local(t, d1) IF (PRESENT(frame)) frame(:, a) = d kx(a) = DOT_PRODUCT(kvec(:, a), d) @@ -6134,7 +6157,9 @@ SUBROUTINE CD_HermiteCable_Dyn_Node_Recovery(model, ErrStat, ErrMsg, tension, cu !! !! The condensed torque of a line restrained in torsion is not part of g_e: it adds a shear !! normal to the tangent and does no work on bending rotations, so tension and bend moment - !! are its axial and normal parts without it. Read-only. + !! are its axial and normal parts without it. Under torque-tension coupling the tension adds + !! the element's (K/GJ) M_t (coupling_tension), the axial force K tau that the kernel's + !! EA - K^2/GJ does not carry. Read-only. TYPE(CD_HermiteCableDynType), INTENT(IN) :: model INTEGER, INTENT(OUT) :: ErrStat CHARACTER(*), INTENT(OUT) :: ErrMsg @@ -6173,7 +6198,7 @@ SUBROUTINE CD_HermiteCable_Dyn_Node_Recovery(model, ErrStat, ErrMsg, tension, cu IF (PRESENT(segment_tension)) THEN ta = unit_tangent(model, e) tb = unit_tangent(model, e + 1) - segment_tension(e) = 0.5_wp*(DOT_PRODUCT(ta, fp) + DOT_PRODUCT(tb, g(7:9))) + segment_tension(e) = 0.5_wp*(DOT_PRODUCT(ta, fp) + DOT_PRODUCT(tb, g(7:9))) + coupling_tension(model, e) END IF fm = g(7:9); mm = g(10:12) END DO @@ -6200,6 +6225,68 @@ PURE LOGICAL FUNCTION size_ok(x, n) RESULT(ok) END FUNCTION size_ok END SUBROUTINE CD_HermiteCable_Dyn_Node_Recovery + PURE REAL(wp) FUNCTION coupling_tension(model, e) RESULT(tc) + !! The axial force (K/GJ) M_t of element e of a line restrained in torsion under torque-tension + !! coupling (T = EA eps + K tau with tau = (M_t - K eps)/GJ, the kernel carrying the + !! EA - K^2/GJ part); zero without coupling, without torsion, or outside the elements. + TYPE(CD_HermiteCableDynType), INTENT(IN) :: model + INTEGER, INTENT(IN) :: e + tc = CD_ZERO + IF (e < 1 .OR. e > model%ne) RETURN + IF (.NOT. model%torsion%active) RETURN + IF (.NOT. ALLOCATED(model%torsion%couple)) RETURN + tc = model%torsion%couple(e)*model%torsion%torque + END FUNCTION coupling_tension + + PURE REAL(wp) FUNCTION CD_HermiteCable_Dyn_Coupling_Tension(model, e) RESULT(tc) + !! The axial force of element e (model order, End B first) that torque-tension coupling adds + !! to the kernel's EA - K^2/GJ resultant at the committed state, (K/GJ) M_t [N]: a host + !! reading the axial resultant of an element (CD_HermiteCable_Axial_Resultant with the + !! model's EA) adds it for the section's tension. Zero without coupling or torsion. + TYPE(CD_HermiteCableDynType), INTENT(IN) :: model + INTEGER, INTENT(IN) :: e + tc = coupling_tension(model, e) + END FUNCTION CD_HermiteCable_Dyn_Coupling_Tension + + REAL(wp) FUNCTION element_twist(model, e, mt) RESULT(tw) + !! The twist of element e under the torque mt: mt l0/GJ, less the twist its stretch takes up + !! under torque-tension coupling, (K/GJ)(l_e - l0) [rad]. + TYPE(CD_HermiteCableDynType), INTENT(IN) :: model + INTEGER, INTENT(IN) :: e + REAL(wp), INTENT(IN) :: mt + REAL(wp) :: qe(12), ls + tw = mt*model%l0(e)/model%torsion%gj(e) + IF (.NOT. ALLOCATED(model%torsion%couple)) RETURN + IF (.NOT. ABS(model%torsion%couple(e)) > CD_ZERO) RETURN + CALL gather_elem(model, e, qe) + ls = CD_HermiteTorsion_Element_Stretch(qe, model%l0(e), model%torsion%quadrature_order) + tw = tw - model%torsion%couple(e)*(ls - model%l0(e)) + END FUNCTION element_twist + + SUBROUTINE CD_HermiteCable_Dyn_Element_Twist(model, twist, ErrStat, ErrMsg) + !! The twist of every element of a line restrained in torsion at the committed state [rad]: + !! M_t l0/GJ less, under torque-tension coupling, the twist the element's stretch takes up. + !! Element order is the model's (End B first); zero for a line without torsion. + TYPE(CD_HermiteCableDynType), INTENT(IN) :: model + REAL(wp), INTENT(OUT) :: twist(:) + INTEGER, INTENT(OUT) :: ErrStat + CHARACTER(*), INTENT(OUT) :: ErrMsg + REAL(wp) :: th, mt + INTEGER :: e + twist = CD_ZERO + ErrStat = CD_HCDYN_OK; ErrMsg = '' + IF (SIZE(twist) /= model%ne) THEN + ErrStat = CD_HCDYN_BADINPUT + ErrMsg = 'CD_HermiteCable_Dyn_Element_Twist: twist must have one entry per element'; RETURN + END IF + IF (.NOT. model%torsion%active) RETURN + CALL CD_HermiteCable_Dyn_Torsion_State(model, th, mt, ErrStat, ErrMsg) + IF (ErrStat /= CD_HCDYN_OK) RETURN + DO e = 1, model%ne + twist(e) = element_twist(model, e, mt) + END DO + END SUBROUTINE CD_HermiteCable_Dyn_Element_Twist + SUBROUTINE node_values(model, node, fm, mm, fp, mp, tension, curvature, bend_moment, ErrStat, ErrMsg, & sleeve_moment, curvature_vector) !! Node values from the one-sided section force and moment before (fm, mm) and after @@ -6234,7 +6321,7 @@ SUBROUTINE node_values(model, node, fm, mm, fp, mp, tension, curvature, bend_mom IF (ErrStat /= CD_HCDYN_OK) RETURN tension = NORM2(fend) ELSE - tension = DOT_PRODUCT(t, f) + tension = DOT_PRODUCT(t, f) + 0.5_wp*(coupling_tension(model, node - 1) + coupling_tension(model, node)) END IF m_perp = m - DOT_PRODUCT(m, t)*t section_moment = NORM2(m_perp) @@ -6911,10 +6998,10 @@ SUBROUTINE CD_HermiteCable_Dyn_Torsion_State(model, theta, torque, ErrStat, ErrM ALLOCATE (g(model%ndof)) IF (PRESENT(q_eval)) THEN CALL CD_HermiteTorsion_Line(q_eval, model%l0, model%torsion%ends, raw, g, es, em, end_grad=eg, & - quadrature_order=model%torsion%quadrature_order) + couple=model%torsion%couple, quadrature_order=model%torsion%quadrature_order) ELSE CALL CD_HermiteTorsion_Line(model%q, model%l0, model%torsion%ends, raw, g, es, em, end_grad=eg, & - quadrature_order=model%torsion%quadrature_order) + couple=model%torsion%couple, quadrature_order=model%torsion%quadrature_order) END IF IF (es /= CD_HTORS_OK) THEN ErrStat = CD_HCDYN_NOCONVERGE @@ -6980,7 +7067,8 @@ SUBROUTINE torsion_cache_fill(model, ErrStat, ErrMsg) IF (.NOT. ALLOCATED(model%tors_c_q) .OR. .NOT. ALLOCATED(model%tors_gq)) RETURN IF (SIZE(model%tors_c_q) /= SIZE(model%q) .OR. model%tors_work%nn /= model%nn) RETURN CALL CD_HermiteTorsion_Line(model%q, model%l0, model%torsion%ends, raw, model%tors_gq, es, em, end_grad=eg, & - quadrature_order=model%torsion%quadrature_order, work=model%tors_work) + couple=model%torsion%couple, quadrature_order=model%torsion%quadrature_order, & + work=model%tors_work) IF (es /= CD_HTORS_OK) THEN ErrStat = CD_HCDYN_NOCONVERGE ErrMsg = 'torsion: '//TRIM(em) @@ -7859,12 +7947,14 @@ SUBROUTINE assemble_torsion(model, q_cfg, want_residual, want_tangent, ErrStat, IF (model%tors_use_step) THEN phi = model%tors_step_phi CALL CD_HermiteTorsion_Line(q_cfg, model%l0, model%tors_step_ends, raw, g, es, em, & - quadrature_order=model%torsion%quadrature_order, work=model%tors_work, & + couple=model%torsion%couple, quadrature_order=model%torsion%quadrature_order, & + work=model%tors_work, & keep_hessian=want_tangent) ELSE phi = model%torsion%phi CALL CD_HermiteTorsion_Line(q_cfg, model%l0, model%torsion%ends, raw, g, es, em, & - quadrature_order=model%torsion%quadrature_order, work=model%tors_work, & + couple=model%torsion%couple, quadrature_order=model%torsion%quadrature_order, & + work=model%tors_work, & keep_hessian=want_tangent) END IF IF (es /= CD_HTORS_OK) THEN diff --git a/src/CableDyn_HermiteCableStatic.f90 b/src/CableDyn_HermiteCableStatic.f90 index ee3a8387..eb5c46ef 100644 --- a/src/CableDyn_HermiteCableStatic.f90 +++ b/src/CableDyn_HermiteCableStatic.f90 @@ -51,6 +51,7 @@ MODULE CableDyn_HermiteCableStatic USE CableDyn_Static, ONLY: CD_Static_As_Laid_Reference, CD_STATIC_OK USE CableDyn_Hydro, ONLY: CD_Current_Profile_Velocity, CD_HYDRO_OK USE CableDyn_HermiteTorsion, ONLY: CD_HermiteTorsionType, CD_HermiteTorsion_Line, CD_HermiteTorsion_Unwrap, & + CD_HermiteTorsion_Coupling_Twist, & CD_HermiteTorsion_Accept, CD_HermiteTorsion_Compliance, & CD_HermiteTorsion_Validate, CD_HermiteTorsion_Bordered_Solve, & CD_HermiteTorsion_Inertia, CD_HermiteTorsion_Lowest_Mode, CD_HTORS_OK, & @@ -1735,11 +1736,11 @@ SUBROUTINE add_torsion(ecs, ecm) ecm = '' IF (skip_tangent) THEN CALL CD_HermiteTorsion_Line(q, l0, torsion%ends, raw, tors_g, ks, km, & - quadrature_order=torsion%quadrature_order) + couple=torsion%couple, quadrature_order=torsion%quadrature_order) ELSE tors_h = CD_ZERO CALL CD_HermiteTorsion_Line(q, l0, torsion%ends, raw, tors_g, ks, km, hband=tors_h, & - quadrature_order=torsion%quadrature_order) + couple=torsion%couple, quadrature_order=torsion%quadrature_order) END IF IF (ks /= CD_HTORS_OK) THEN ecs = CD_HCSTAT_NOCONVERGE @@ -1804,7 +1805,7 @@ SUBROUTINE torsion_take_step(scale, ecs, ecm) DO k = 0, 30 q = tors_q + sfac*dq CALL CD_HermiteTorsion_Line(q, l0, torsion%ends, raw, tors_gt, ks, km, & - quadrature_order=torsion%quadrature_order) + couple=torsion%couple, quadrature_order=torsion%quadrature_order) IF (ks == CD_HTORS_OK) THEN CALL CD_HermiteTorsion_Accept(tors_theta_acc, raw, th, ks, km) IF (ks == CD_HTORS_OK) THEN @@ -1846,7 +1847,8 @@ SUBROUTINE torsion_continuation(ecs, ecm) torsion%stable = .FALSE. torsion%n_negative = 0 torsion%lambda_min = CD_ZERO - CALL CD_HermiteTorsion_Line(q, l0, torsion%ends, raw, tors_g, ks, km, quadrature_order=torsion%quadrature_order) + CALL CD_HermiteTorsion_Line(q, l0, torsion%ends, raw, tors_g, ks, km, & + couple=torsion%couple, quadrature_order=torsion%quadrature_order) IF (ks /= CD_HTORS_OK) THEN ecs = CD_HCSTAT_NOCONVERGE ecm = 'CD_HermiteCable_Static_Solve: torsion at the untwisted equilibrium: '//TRIM(km) @@ -1863,6 +1865,11 @@ SUBROUTINE torsion_continuation(ecs, ecm) 'state (has_theta false) with theta_hint on the intended branch' RETURN END IF + ELSE IF (ALLOCATED(torsion%couple)) THEN + ! the hint is the holonomy's; the coupling twist is unambiguous + tors_theta_acc = CD_HermiteTorsion_Unwrap(raw, torsion%theta_hint + & + CD_HermiteTorsion_Coupling_Twist(q, l0, torsion%couple, & + torsion%quadrature_order)) ELSE tors_theta_acc = CD_HermiteTorsion_Unwrap(raw, torsion%theta_hint) END IF @@ -5120,7 +5127,7 @@ END SUBROUTINE reject_unresolved_sequence SUBROUTINE CD_HermiteCable_Resolution_Metrics(l0, q, seabed_z, contact_band, & h_kappa_target, diag, ErrStat, ErrMsg, & bathymetry, contact_frame_cs, EA, EI, compression_mode, & - elem_h_kappa, chatter_node) + elem_h_kappa, chatter_node, axial_offset) !! Diagnose the mesh resolution of a converged finite-EI static IC and recommend a global !! refinement factor. This is the preflight trigger for the adaptive mesh policy: a lazy-wave !! arch or touchdown transition resolved with too few elements carries a large h*kappa and @@ -5146,6 +5153,10 @@ SUBROUTINE CD_HermiteCable_Resolution_Metrics(l0, q, seabed_z, contact_band, & !! maximum is h_kappa_peak (the local refinement of AutoMesh marks from it). !! chatter_node(ne+1) (optional out): every interior node whose contact state differs from !! both of its neighbours (the nodes behind diag%contact_chatter). + !! axial_offset(ne) (optional, with EA): an axial force constant along each element added to + !! its EA resultant wherever the axial force is judged, such as the + !! (K/GJ) M_t of torque-tension coupling on a line restrained in torsion (EA + !! then the kernel's EA - K^2/GJ). REAL(wp), INTENT(IN) :: l0(:), q(:), seabed_z, contact_band, h_kappa_target TYPE(CD_HermiteResolutionType), INTENT(OUT) :: diag INTEGER, INTENT(OUT) :: ErrStat @@ -5156,6 +5167,7 @@ SUBROUTINE CD_HermiteCable_Resolution_Metrics(l0, q, seabed_z, contact_band, & INTEGER, INTENT(IN), OPTIONAL :: compression_mode REAL(wp), INTENT(OUT), OPTIONAL :: elem_h_kappa(:) LOGICAL, INTENT(OUT), OPTIONAL :: chatter_node(:) + REAL(wp), INTENT(IN), OPTIONAL :: axial_offset(:) INTEGER :: ne, nn, e, a, es3, mode REAL(wp) :: qe(12), ke, ke_prev, hk, u_peak, z, z_floor, xg, yg, contact_cs(2), & @@ -5188,6 +5200,12 @@ SUBROUTINE CD_HermiteCable_Resolution_Metrics(l0, q, seabed_z, contact_band, & ErrStat = CD_HCSTAT_BADINPUT ErrMsg = 'CD_HermiteCable_Resolution_Metrics: q must be 6*(ne+1)'; RETURN END IF + IF (PRESENT(axial_offset)) THEN + IF (SIZE(axial_offset) /= ne .OR. .NOT. PRESENT(EA)) THEN + ErrStat = CD_HCSTAT_BADINPUT + ErrMsg = 'CD_HermiteCable_Resolution_Metrics: axial_offset must be ne, with EA'; RETURN + END IF + END IF IF (PRESENT(elem_h_kappa)) THEN IF (SIZE(elem_h_kappa) /= ne) THEN ErrStat = CD_HCSTAT_BADINPUT @@ -5300,6 +5318,10 @@ SUBROUTINE CD_HermiteCable_Resolution_Metrics(l0, q, seabed_z, contact_band, & ErrMsg = 'CD_HermiteCable_Resolution_Metrics: axial-resultant extraction failed: '//TRIM(em3) RETURN END IF + IF (PRESENT(axial_offset)) THEN + axial_element_min = axial_element_min + axial_offset(e) + axial_element_max = axial_element_max + axial_offset(e) + END IF elem_min(e) = axial_element_min elem_min_xi(e) = axial_element_min_xi elem_max(e) = axial_element_max @@ -5337,7 +5359,7 @@ SUBROUTINE CD_HermiteCable_Resolution_Metrics(l0, q, seabed_z, contact_band, & ! dynamic tensile audit does; the others judge the pointwise resultant, whose ! oscillation about that mean grows with the element length. IF (mode == CD_HC_COMPRESSION_STRICT) THEN - CALL smoothed_element_means(l0, q, EA, elem_min, es3, em3) + CALL smoothed_element_means(l0, q, EA, elem_min, es3, em3, axial_offset) IF (es3 /= CD_HCSTAT_OK) THEN ErrStat = CD_HCSTAT_BADINPUT ErrMsg = 'CD_HermiteCable_Resolution_Metrics: '//TRIM(em3) @@ -5383,6 +5405,10 @@ SUBROUTINE CD_HermiteCable_Resolution_Metrics(l0, q, seabed_z, contact_band, & ErrMsg = 'CD_HermiteCable_Resolution_Metrics: end axial-resultant extraction failed: '//TRIM(em3) RETURN END IF + IF (PRESENT(axial_offset)) THEN + diag%hop_axial = diag%hop_axial + axial_offset(1) + diag%end_axial = diag%end_axial + axial_offset(ne) + END IF IF (EI(1) > CD_ZERO .AND. diag%hop_axial > CD_HC_AXIAL_STRAIN_TOL*EA(1)) & diag%hop_boundary_ratio = l0(1)/SQRT(EI(1)/diag%hop_axial) IF (EI(ne) > CD_ZERO .AND. diag%end_axial > CD_HC_AXIAL_STRAIN_TOL*EA(ne)) & @@ -5943,16 +5969,18 @@ END SUBROUTINE fail_ref END SUBROUTINE CD_HermiteCable_Refine_Mesh - SUBROUTINE smoothed_element_means(l0, q, EA, sm, ErrStat, ErrMsg) + SUBROUTINE smoothed_element_means(l0, q, EA, sm, ErrStat, ErrMsg, axial_offset) !! Three-element mean of the element-mean axial force: sm(e) is the length-weighted !! mean, over elements e-1, e, e+1 (clipped at the line ends), of the three-point Gauss !! mean of the signed axial resultant EA (|r'| - 1) -- the force that enters equilibrium, !! free of the pointwise oscillation of a stiff-EA cubic-Hermite element (per element, - !! the smoothed_axial_min of CD_HermiteCable_Branch_Audit). + !! the smoothed_axial_min of CD_HermiteCable_Branch_Audit) -- plus axial_offset(e) where + !! given (the coupling force of CD_HermiteCable_Resolution_Metrics). REAL(wp), INTENT(IN) :: l0(:), q(:), EA(:) REAL(wp), INTENT(OUT) :: sm(:) INTEGER, INTENT(OUT) :: ErrStat CHARACTER(*), INTENT(OUT) :: ErrMsg + REAL(wp), INTENT(IN), OPTIONAL :: axial_offset(:) REAL(wp), PARAMETER :: GX(3) = [0.5_wp - 0.5_wp*SQRT(0.6_wp), 0.5_wp, 0.5_wp + 0.5_wp*SQRT(0.6_wp)] REAL(wp), PARAMETER :: GW(3) = [5.0_wp/18.0_wp, 8.0_wp/18.0_wp, 5.0_wp/18.0_wp] REAL(wp) :: emean(SIZE(l0)), ng @@ -5969,6 +5997,7 @@ SUBROUTINE smoothed_element_means(l0, q, EA, sm, ErrStat, ErrMsg) END IF emean(e) = emean(e) + GW(k)*ng END DO + IF (PRESENT(axial_offset)) emean(e) = emean(e) + axial_offset(e) END DO ErrStat = CD_HCSTAT_OK DO e = 1, ne diff --git a/src/CableDyn_HermiteTorsion.f90 b/src/CableDyn_HermiteTorsion.f90 index 998ef475..35de7d21 100644 --- a/src/CableDyn_HermiteTorsion.f90 +++ b/src/CableDyn_HermiteTorsion.f90 @@ -40,6 +40,8 @@ MODULE CableDyn_HermiteTorsion PRIVATE PUBLIC :: CD_HermiteTorsion_Element + PUBLIC :: CD_HermiteTorsion_Element_Stretch + PUBLIC :: CD_HermiteTorsion_Coupling_Twist PUBLIC :: CD_HermiteTorsion_Line PUBLIC :: CD_HermiteTorsion_Fold_Check PUBLIC :: CD_HermiteTorsion_Unwrap @@ -103,6 +105,10 @@ MODULE CableDyn_HermiteTorsion !! Torsional stiffness GJ of every element [N m^2/rad] (the line compliance is the sum of !! l0/GJ over the elements plus the end compliances). REAL(wp), ALLOCATABLE :: gj(:) + !! Torque-tension coupling K/GJ of every element [1] (M = GJ tau + K eps, T = EA eps + K tau); + !! unallocated: no coupling. The line's axial stiffness is then EA - K^2/GJ (the stretch + !! twists the line) and its twist Theta less sum (K/GJ)(l - l0) (CD_HermiteTorsion_Line). + REAL(wp), ALLOCATABLE :: couple(:) INTEGER :: quadrature_order = 4 !! State: the accepted Theta (unwrapped) once has_theta; before that theta_hint selects the !! 2 pi branch of the first evaluation (0 for an untwisted start). @@ -183,6 +189,17 @@ PURE SUBROUTINE CD_HermiteTorsion_Validate(tors, l0, ErrStat, ErrMsg) ErrMsg = 'torsion: GJ must be positive on every element' RETURN END IF + IF (ALLOCATED(tors%couple)) THEN + IF (SIZE(tors%couple) /= SIZE(l0)) THEN + ErrMsg = 'torsion: the torque-tension coupling must have one entry per element' + RETURN + END IF + IF (.NOT. CD_All_Finite(tors%couple)) THEN + ErrStat = CD_HTORS_NONFINITE + ErrMsg = 'torsion: non-finite torque-tension coupling' + RETURN + END IF + END IF IF (ANY(tors%end_compliance < CD_ZERO)) THEN ErrMsg = 'torsion: end compliances must be non-negative' RETURN @@ -896,7 +913,7 @@ END SUBROUTINE CD_HermiteTorsion_Work_Add_Hessian PURE SUBROUTINE CD_HermiteTorsion_Line(q, Le, ends, theta_raw, grad, ErrStat, ErrMsg, hband, band_scale, & end_grad, end_hess, end_cross, fold_margin, quadrature_order, work, & - keep_hessian) + keep_hessian, couple) !! Theta, dTheta/dq and d2Theta/dq2 of one line. !! !! q(6 n) nodal DOFs [r_k, m_k], k = 1..n (n >= 2), as in the cable solvers @@ -922,6 +939,11 @@ PURE SUBROUTINE CD_HermiteTorsion_Line(q, Le, ends, theta_raw, grad, ErrStat, Er !! the evaluation then allocates nothing !! keep_hessian with work: compute d2Theta/dq2 into work (unscaled) for a later !! CD_HermiteTorsion_Work_Add_Hessian, also without hband + !! couple(n - 1) optional torque-tension coupling K/GJ per element: theta_raw is then the + !! effective twist Theta - sum_e (K/GJ)_e (l_e - Le_e), l_e the stretched + !! element length, with its derivatives. With M = GJ tau + K eps uniform along + !! the line, the twist the ends see is Theta less the twist the stretch takes + !! up, so the condensed torque is M = (Phi - Theta_eff)/C. !! !! On any failure every output is zero and hband is left unchanged. REAL(wp), INTENT(IN) :: q(:), Le(:), ends(3, 4) @@ -935,6 +957,7 @@ PURE SUBROUTINE CD_HermiteTorsion_Line(q, Le, ends, theta_raw, grad, ErrStat, Er INTEGER, INTENT(IN), OPTIONAL :: quadrature_order TYPE(CD_HermiteTorsionWorkType), INTENT(INOUT), OPTIONAL :: work LOGICAL, INTENT(IN), OPTIONAL :: keep_hessian + REAL(wp), INTENT(IN), OPTIONAL :: couple(:) TYPE(CD_HermiteTorsionWorkType) :: local INTEGER :: nn LOGICAL :: keep @@ -957,7 +980,7 @@ PURE SUBROUTINE CD_HermiteTorsion_Line(q, Le, ends, theta_raw, grad, ErrStat, Er work%hess_valid = .FALSE. CALL line_core(q, Le, ends, theta_raw, grad, ErrStat, ErrMsg, work%nn, work%u, work%pole, work%gu, work%huu, & work%huv, work%band, keep, hband, band_scale, end_grad, end_hess, end_cross, fold_margin, & - quadrature_order) + quadrature_order, couple) work%hess_valid = keep .AND. ErrStat == CD_HTORS_OK ELSE nn = MAX(SIZE(q)/6, 2) @@ -965,12 +988,12 @@ PURE SUBROUTINE CD_HermiteTorsion_Line(q, Le, ends, theta_raw, grad, ErrStat, Er local%huv(3, 3, 0:nn), local%band(2*CD_HTORS_KBAND + 1, 6*nn)) CALL line_core(q, Le, ends, theta_raw, grad, ErrStat, ErrMsg, nn, local%u, local%pole, local%gu, local%huu, & local%huv, local%band, .FALSE., hband, band_scale, end_grad, end_hess, end_cross, & - fold_margin, quadrature_order) + fold_margin, quadrature_order, couple) END IF END SUBROUTINE CD_HermiteTorsion_Line PURE SUBROUTINE line_core(q, Le, ends, theta_raw, grad, ErrStat, ErrMsg, nw, u, pole, gu, huu, huv, band, keep, & - hband, band_scale, end_grad, end_hess, end_cross, fold_margin, quadrature_order) + hband, band_scale, end_grad, end_hess, end_cross, fold_margin, quadrature_order, couple) !! CD_HermiteTorsion_Line on caller scratch for nw nodes (the scratch is explicit-shape so !! that no expression on it needs a heap temporary); keep: compute the Hessian into band !! even without hband. A q of another node count fails validation before any use. @@ -987,6 +1010,7 @@ PURE SUBROUTINE line_core(q, Le, ends, theta_raw, grad, ErrStat, ErrMsg, nw, u, REAL(wp), INTENT(OUT), OPTIONAL :: end_grad(6), end_hess(3, 3, 2), end_cross(3, 3, 2) REAL(wp), INTENT(OUT), OPTIONAL :: fold_margin INTEGER, INTENT(IN), OPTIONAL :: quadrature_order + REAL(wp), INTENT(IN), OPTIONAL :: couple(:) INTEGER :: order, nn, n, e, j, k, i0, i, jj, row0 LOGICAL :: want_hess, finite @@ -1027,6 +1051,18 @@ PURE SUBROUTINE line_core(q, Le, ends, theta_raw, grad, ErrStat, ErrMsg, nw, u, ErrMsg = 'CD_HermiteTorsion_Line: non-finite band_scale' RETURN END IF + IF (PRESENT(couple)) THEN + IF (SIZE(couple) /= nn - 1) THEN + ErrStat = CD_HTORS_BADINPUT + ErrMsg = 'CD_HermiteTorsion_Line: couple must have one entry per element' + RETURN + END IF + IF (.NOT. CD_All_Finite(couple)) THEN + ErrStat = CD_HTORS_NONFINITE + ErrMsg = 'CD_HermiteTorsion_Line: non-finite torque-tension coupling' + RETURN + END IF + END IF row0 = CD_HTORS_KBAND + 1 ! diagonal row of the local band IF (want_hess) band(:, 1:n) = CD_ZERO @@ -1051,6 +1087,21 @@ PURE SUBROUTINE line_core(q, Le, ends, theta_raw, grad, ErrStat, ErrMsg, nw, u, END DO END DO END IF + ! torque-tension coupling: the twist the element's stretch takes up, -(K/GJ)(l_e - Le) + IF (PRESENT(couple)) THEN + IF (ABS(couple(e)) > CD_ZERO) THEN + CALL element_stretch(q(i0 + 1:i0 + 12), Le(e), order, want_hess, he, ge, hk) + sum_h = sum_h - couple(e)*(he - Le(e)) + grad(i0 + 1:i0 + 12) = grad(i0 + 1:i0 + 12) - couple(e)*ge + IF (want_hess) THEN + DO jj = 1, 12 + DO i = 1, 12 + band(row0 + i - jj, i0 + jj) = band(row0 + i - jj, i0 + jj) - couple(e)*hk(i, jj) + END DO + END DO + END IF + END IF + END IF END DO ! smallest-rotation chain: value by sequential composition @@ -1230,6 +1281,67 @@ PURE SUBROUTINE shape_derivatives(L, x, dh, ddh) ddh = [-6.0_wp + 12.0_wp*x, L*(-4.0_wp + 6.0_wp*x), 6.0_wp - 12.0_wp*x, L*(-2.0_wp + 6.0_wp*x)]/(L*L) END SUBROUTINE shape_derivatives + PURE REAL(wp) FUNCTION CD_HermiteTorsion_Coupling_Twist(q, Le, couple, quadrature_order) RESULT(tw) + !! The coupling part of the effective twist, -sum_e (K/GJ)_e (l_e - Le_e) [rad]: unlike the + !! holonomy it has no 2 pi ambiguity, so a first evaluation unwraps the holonomy alone about + !! its branch hint by passing the hint plus this to CD_HermiteTorsion_Unwrap. + REAL(wp), INTENT(IN) :: q(:), Le(:), couple(:) + INTEGER, INTENT(IN), OPTIONAL :: quadrature_order + INTEGER :: e + tw = CD_ZERO + DO e = 1, MIN(SIZE(Le), SIZE(couple), SIZE(q)/6 - 1) + IF (.NOT. ABS(couple(e)) > CD_ZERO) CYCLE + tw = tw - couple(e)*(CD_HermiteTorsion_Element_Stretch(q(6*e - 5:6*e + 6), Le(e), quadrature_order) - Le(e)) + END DO + END FUNCTION CD_HermiteTorsion_Coupling_Twist + + PURE REAL(wp) FUNCTION CD_HermiteTorsion_Element_Stretch(qe, L, quadrature_order) RESULT(ls) + !! The stretched length of one cubic-Hermite element [r1, m1, r2, m2] of reference length L, + !! on the quadrature of the torsion kernel (the l_e of the torque-tension coupling). + REAL(wp), INTENT(IN) :: qe(12), L + INTEGER, INTENT(IN), OPTIONAL :: quadrature_order + REAL(wp) :: g(12), h(12, 12) + INTEGER :: order + order = NG_DEFAULT + IF (PRESENT(quadrature_order)) order = quadrature_order + CALL element_stretch(qe, L, order, .FALSE., ls, g, h) + END FUNCTION CD_HermiteTorsion_Element_Stretch + + PURE SUBROUTINE element_stretch(qe, L, order, want_hess, ls, grad, hess) + !! The stretched length l_e = L sum_g w_g |a_g| of one cubic-Hermite element (a = dr/ds), its + !! gradient L sum_g w_g dh_i a/|a| and Hessian L sum_g w_g dh_i dh_j (I - t t^T)/|a| over the + !! 12 DOFs [r1, m1, r2, m2]. + REAL(wp), INTENT(IN) :: qe(12), L + INTEGER, INTENT(IN) :: order + LOGICAL, INTENT(IN) :: want_hess + REAL(wp), INTENT(OUT) :: ls, grad(12), hess(12, 12) + REAL(wp) :: gp(NG_MAX), gw(NG_MAX), dh(4), ddh(4), a(3), b(3), sa, t(3), pmat(3, 3) + INTEGER :: ig, i, j + ls = CD_ZERO + grad = CD_ZERO + hess = CD_ZERO + CALL CD_HermiteCable_Gauss_Rule(order, gp, gw) + DO ig = 1, order + CALL element_ab(qe, L, gp(ig), a, b) + CALL shape_derivatives(L, gp(ig), dh, ddh) + sa = NORM2(a) + IF (.NOT. (sa > GEOM_TOL)) CYCLE + t = a/sa + ls = ls + L*gw(ig)*sa + DO i = 1, 4 + grad(3*i - 2:3*i) = grad(3*i - 2:3*i) + L*gw(ig)*dh(i)*t + END DO + IF (want_hess) THEN + pmat = (identity3() - outer(t, t))/sa + DO j = 1, 4 + DO i = 1, 4 + hess(3*i - 2:3*i, 3*j - 2:3*j) = hess(3*i - 2:3*i, 3*j - 2:3*j) + L*gw(ig)*dh(i)*dh(j)*pmat + END DO + END DO + END IF + END DO + END SUBROUTINE element_stretch + PURE SUBROUTINE element_holonomy(qe, L, order, want_hess, h, grad, hess, margin, ErrStat, ErrMsg) !! h_e = L sum_g w_g f(a_g, b_g, t1), f = t1.(a x b) / (|a|**2 + |a| (t1.a)), t1 = m1/|m1|. !! f = N/D is differentiated in closed form in x = (a, b, t1) and chained to the 12 DOFs by diff --git a/src/CableDyn_OpenFAST_HermiteFMF.f90 b/src/CableDyn_OpenFAST_HermiteFMF.f90 index c4588703..93b1e901 100644 --- a/src/CableDyn_OpenFAST_HermiteFMF.f90 +++ b/src/CableDyn_OpenFAST_HermiteFMF.f90 @@ -863,6 +863,7 @@ SUBROUTINE CD_HFMF_PreflightCoupledKinematics(self, u_pos, u_vel, u_acc, ErrStat ALLOCATE (qc(SIZE(self%line%q)), g(SIZE(self%line%q))) CALL coupled_candidate_q(self, u_pos, tangent_q, qc) CALL CD_HermiteTorsion_Line(qc, self%line%l0, ends, raw, g, ks, km, & + couple=self%line%torsion%couple, & quadrature_order=self%line%torsion%quadrature_order) IF (ks /= CD_HTORS_OK) THEN ErrStat = CD_HFMF_SOLVEFAIL diff --git a/tests/test_torsion_coupling.f90 b/tests/test_torsion_coupling.f90 new file mode 100644 index 00000000..e47055bf --- /dev/null +++ b/tests/test_torsion_coupling.f90 @@ -0,0 +1,444 @@ +! File: tests/test_torsion_coupling.f90 +! SPDX-License-Identifier: Apache-2.0 +! Copyright (c) 2026 Jae Hoon Seo, SMI Lab, Inha University +PROGRAM test_torsion_coupling + !! Torque-tension coupling of a finite-EI cable (LINE TYPES GJ column GJ|K: the section laws + !! T = EA eps + K tau and M = GJ tau + K eps). + !! 1. The kernel: with the coupling, CD_HermiteTorsion_Line's effective twist + !! Theta - sum (K/GJ)(l_e - l0_e) has the gradient and Hessian of its finite differences + !! on a curved line. + !! 2. A straight neutral cable stretched by eps between its two held ends, both ends rigid in + !! torsion: the twist cannot relax, so T = EA eps and M = K eps. + !! 3. The same cable free in torsion at one end: the stretch twists it, so T = (EA - K^2/GJ) eps + !! and M = 0. + !! 4. Both ends rigid with an imposed twist Phi: tau = Phi/L, so T = EA eps + K Phi/L and + !! M = GJ Phi/L + K eps; the twist channel reads the element twists. + !! 5. K = 0 written as GJ|0 is the uncoupled cable bit for bit; K^2 >= EA GJ fails closed. + !! 6. The element recovery (OutputRecovery element) and the static element profile read the + !! section tension EA eps of the rigid-end case, the coupling force included. + !! 7. Compression by opposite-sense torsion: a cable stretched by 1e-4 between rigid ends and + !! twisted by -45 deg carries T = EA eps + K Phi/L < 0 although its kernel resultant is + !! tensile; tensile_safety True refuses it in the statics and in a march that rolls the + !! end there, and accepts the march rolled the other way. + !! 8. The coupled aggregate: a non-stepping update at the unchanged boundary is accepted (the + !! preflight's twist carries the coupling, -8 rad here). + USE CableDyn_Precision, ONLY: wp + USE CableDyn_HermiteTorsion, ONLY: CD_HermiteTorsion_Line, CD_HTORS_OK, CD_HTORS_KBAND + USE CableDyn_DeckDriver, ONLY: CD_Run_Deck_Driver, CD_DECKDRV_OK + USE CableDyn_OpenFAST_Aggregate, ONLY: CD_AGG_ModuleType, CD_AGG_Init_From_Deck, CD_AGG_GetMovingPointMesh, & + CD_AGG_UpdateStates_Moving, CD_AGG_End, CD_AGG_OK + IMPLICIT NONE + + REAL(wp), PARAMETER :: PI = 3.14159265358979323846_wp, RHOW = 1025.0_wp + ! the section: EA 1e7 N, EI 1e6 N m2, GJ 5e4 N m2, K 4e5 N m (K^2 / EA GJ = 0.32) + REAL(wp), PARAMETER :: EA = 1.0e7_wp, GJ = 5.0e4_wp, KTT = 4.0e5_wp, SPAN = 100.0_wp, L0 = 99.0_wp + INTEGER :: nfail = 0 + + CALL check_kernel() + CALL check_rigid_ends() + CALL check_free_end() + CALL check_pretwist() + CALL check_zero_and_refusal() + CALL check_dynamic() + CALL check_recovery() + CALL check_compression() + CALL check_aggregate() + IF (nfail > 0) THEN + PRINT '(I0,A)', nfail, ' assertion(s) failed' + ERROR STOP 1 + END IF + PRINT '(A)', 'all torque-tension coupling checks passed' + +CONTAINS + + SUBROUTINE check_kernel() + !! Finite differences of the effective twist on a curved, stretched 6-node line. + INTEGER, PARAMETER :: NN = 6, ND = 6*NN, KB = CD_HTORS_KBAND + REAL(wp) :: q(ND), le(NN - 1), ends(3, 4), cpl(NN - 1), th, thp, thm, g(ND), gp(ND), gm(ND) + REAL(wp) :: hb(2*KB + 1, ND), hfd(ND, ND), herr, gerr, h, s, r(3), m(3) + INTEGER :: k, i, j, es + CHARACTER(256) :: em + DO k = 1, NN + s = REAL(k - 1, wp)*2.0_wp + r = [s, 0.3_wp*SIN(0.4_wp*s), 0.2_wp*s*s/10.0_wp] + m = [1.0_wp, 0.12_wp*COS(0.4_wp*s), 0.04_wp*s] + m = 1.01_wp*m/NORM2(m) + q(6*k - 5:6*k) = [r, m] + END DO + le = 2.0_wp + cpl = [0.3_wp, -0.2_wp, 0.5_wp, 0.1_wp, 0.4_wp] + ends(:, 1) = q(4:6)/NORM2(q(4:6)) + ends(:, 2) = unit(cross([0.0_wp, 0.0_wp, 1.0_wp], ends(:, 1))) + ends(:, 3) = q(ND - 2:ND)/NORM2(q(ND - 2:ND)) + ends(:, 4) = unit(cross([0.0_wp, 0.0_wp, 1.0_wp], ends(:, 3))) + hb = 0.0_wp + CALL CD_HermiteTorsion_Line(q, le, ends, th, g, es, em, hband=hb, couple=cpl) + CALL require(es == CD_HTORS_OK, 'kernel with coupling evaluates: '//TRIM(em)) + h = 1.0e-6_wp + gerr = 0.0_wp + herr = 0.0_wp + DO j = 1, ND + q(j) = q(j) + h + CALL CD_HermiteTorsion_Line(q, le, ends, thp, gp, es, em, couple=cpl) + q(j) = q(j) - 2*h + CALL CD_HermiteTorsion_Line(q, le, ends, thm, gm, es, em, couple=cpl) + q(j) = q(j) + h + gerr = MAX(gerr, ABS((thp - thm)/(2*h) - g(j))) + hfd(:, j) = (gp - gm)/(2*h) + END DO + DO j = 1, ND + DO i = MAX(1, j - KB), MIN(ND, j + KB) + herr = MAX(herr, ABS(hb(KB + 1 + i - j, j) - hfd(i, j))) + END DO + END DO + PRINT '(A,ES10.3,A,ES10.3)', ' kernel: max |grad - FD| ', gerr, ', max |Hessian - FD| ', herr + CALL require(gerr <= 1.0e-7_wp .AND. herr <= 1.0e-6_wp, 'kernel: the effective twist''s derivatives') + END SUBROUTINE check_kernel + + SUBROUTINE check_rigid_ends() + REAL(wp) :: v(4), eps + CALL straight_case('tcpl_rigid', 'Rigid 1 0 0 Rigid 0 0 1 0', 'Rigid 1 0 0 Rigid 0 0 1 0', KTT, v) + eps = SPAN/L0 - 1.0_wp + PRINT '(A,2ES15.7,A,2ES15.7)', ' rigid ends: T, M ', v(1), v(2), ' expected ', EA*eps, KTT*eps + CALL require(ABS(v(1) - EA*eps) <= 1.0e-5_wp*EA*eps, 'rigid ends: T = EA eps') + CALL require(ABS(v(2) - KTT*eps) <= 1.0e-5_wp*KTT*eps, 'rigid ends: M = K eps') + END SUBROUTINE check_rigid_ends + + SUBROUTINE check_free_end() + REAL(wp) :: v(4), eps + CALL straight_case('tcpl_free', 'Rigid 1 0 0 Free 0 0 1', 'Rigid 1 0 0 Rigid 0 0 1 0', KTT, v, torsion=.FALSE.) + eps = SPAN/L0 - 1.0_wp + PRINT '(A,ES15.7,A,ES15.7)', ' free end: T ', v(1), ' expected ', (EA - KTT**2/GJ)*eps + CALL require(ABS(v(1) - (EA - KTT**2/GJ)*eps) <= 1.0e-5_wp*EA*eps, 'free end: T = (EA - K^2/GJ) eps') + END SUBROUTINE check_free_end + + SUBROUTINE check_pretwist() + REAL(wp) :: v(4), eps, phi, t_ref, m_ref, tw_ref + phi = 90.0_wp*PI/180.0_wp + CALL straight_case('tcpl_twist', 'Rigid 1 0 0 Rigid 0 0 1 0', 'Rigid 1 0 0 Rigid 0 0 1 90', KTT, v) + eps = SPAN/L0 - 1.0_wp + t_ref = EA*eps + KTT*phi/L0 + m_ref = GJ*phi/L0 + KTT*eps + tw_ref = 90.0_wp + PRINT '(A,3ES15.7,A,3ES15.7)', ' pretwist: T, M, Twist ', v(1:3), ' expected ', t_ref, m_ref, tw_ref + CALL require(ABS(v(1) - t_ref) <= 1.0e-5_wp*t_ref, 'pretwist: T = EA eps + K Phi/L') + CALL require(ABS(v(2) - m_ref) <= 1.0e-5_wp*m_ref, 'pretwist: M = GJ Phi/L + K eps') + CALL require(ABS(v(3) - tw_ref) <= 1.0e-4_wp, 'pretwist: Twist is the imposed twist') + CALL require(ABS(v(4) - v(1)) <= 1.0e-5_wp*v(1), 'pretwist: the mid-line tension equals the end tension') + END SUBROUTINE check_pretwist + + SUBROUTINE check_zero_and_refusal() + REAL(wp) :: v0(4), v1(4) + LOGICAL :: conv + INTEGER :: es + CHARACTER(512) :: em + CALL straight_case('tcpl_k0', 'Rigid 1 0 0 Rigid 0 0 1 0', 'Rigid 1 0 0 Rigid 0 0 1 30', -1.0_wp, v0) + CALL straight_case('tcpl_k0b', 'Rigid 1 0 0 Rigid 0 0 1 0', 'Rigid 1 0 0 Rigid 0 0 1 30', 0.0_wp, v1) + CALL require(ALL(v0 == v1), 'GJ|0 is the uncoupled cable bit for bit') + CALL write_case('tcpl_bad.dat', 'Rigid 1 0 0 Rigid 0 0 1 0', 'Rigid 1 0 0 Rigid 0 0 1 0', 1.0e6_wp) + CALL CD_Run_Deck_Driver('tcpl_bad.dat', 'tcpl_bad', conv, es, em) + CALL require(es /= CD_DECKDRV_OK .AND. INDEX(em, 'K^2 < EA GJ') > 0, 'K^2 >= EA GJ fails closed: '//TRIM(em)) + END SUBROUTINE check_zero_and_refusal + + SUBROUTINE check_dynamic() + !! The march: End A moves 0.1 m away from End B and rolls -90 deg (Phi + 90 deg) over 20 s on a + !! C2 quintic, then holds 5 s; the line, far stiffer axially than the ramp is slow, ends at the + !! static state of the 100.1 m span with Phi = 90 deg: T = EA eps + K Phi/L, M = GJ Phi/L + K eps. + INTEGER, PARAMETER :: NSTEP = 500 + REAL(wp), PARAMETER :: TR = 20.0_wp, DTM = 0.05_wp, DX = 0.1_wp + REAL(wp) :: t, tau, s, sd, sdd, v(4), eps, phi, t_ref, m_ref, last(5) + INTEGER :: u, k, ios + LOGICAL :: conv + INTEGER :: es + CHARACTER(512) :: em + CHARACTER(4096) :: buf + OPEN (NEWUNIT=u, FILE='tcpl_motion.txt', STATUS='REPLACE', ACTION='WRITE') + WRITE (u, '(A)') '# time id x y z vx vy vz ax ay az roll' + DO k = 0, NSTEP + t = DTM*REAL(k, wp) + tau = MIN(t/TR, 1.0_wp) + s = 10.0_wp*tau**3 - 15.0_wp*tau**4 + 6.0_wp*tau**5 + sd = (30.0_wp*tau**2 - 60.0_wp*tau**3 + 30.0_wp*tau**4)/TR + sdd = (60.0_wp*tau - 180.0_wp*tau**2 + 120.0_wp*tau**3)/TR**2 + IF (t > TR) THEN + sd = 0.0_wp + sdd = 0.0_wp + END IF + WRITE (u, '(ES16.8,A,ES16.8,A,3ES16.8,A,ES16.8)') t, ' 1 ', -DX*s, ' 0.0 -50.0 ', -DX*sd, 0.0_wp, 0.0_wp, & + ' 0 0 0 ', -90.0_wp*s + END DO + CLOSE (u) + CALL write_case('tcpl_dyn.dat', 'Rigid 1 0 0 Rigid 0 0 1 0', 'Rigid 1 0 0 Rigid 0 0 1 0', KTT, dynamic=.TRUE.) + CALL CD_Run_Deck_Driver('tcpl_dyn.dat', 'tcpl_dyn', conv, es, em) + CALL require(es == CD_DECKDRV_OK .AND. conv, 'the coupled march runs: '//TRIM(em)) + IF (es /= CD_DECKDRV_OK) RETURN + OPEN (NEWUNIT=u, FILE='tcpl_dyn.out', STATUS='OLD', ACTION='READ', IOSTAT=ios) + READ (u, '(A)') buf + READ (u, '(A)') buf + last = 0.0_wp + DO + READ (u, *, IOSTAT=ios) v(1), v(2:4) + IF (ios /= 0) EXIT + last(1:4) = v + END DO + CLOSE (u) + eps = (SPAN + DX)/L0 - 1.0_wp + phi = 90.0_wp*PI/180.0_wp + t_ref = EA*eps + KTT*phi/L0 + m_ref = GJ*phi/L0 + KTT*eps + PRINT '(A,3ES15.7,A,2ES15.7)', ' march end: t, T, M ', last(1:3), ' expected ', t_ref, m_ref + CALL require(ABS(last(2) - t_ref) <= 1.0e-6_wp*t_ref, 'march: T at the end of the ramp is the static one') + CALL require(ABS(last(3) - m_ref) <= 1.0e-6_wp*m_ref, 'march: M at the end of the ramp is the static one') + END SUBROUTINE check_dynamic + + SUBROUTINE check_recovery() + !! The rigid-end case under OutputRecovery element: Ten1N21 and the element profile's axial + !! resultant extremes are the section tension EA eps. + REAL(wp) :: v(4), eps, row(12), tmin, tmax + INTEGER :: u, ios, n + CHARACTER(4096) :: buf + CALL straight_case('tcpl_rec', 'Rigid 1 0 0 Rigid 0 0 1 0', 'Rigid 1 0 0 Rigid 0 0 1 0', KTT, v, & + option='element OutputRecovery') + eps = SPAN/L0 - 1.0_wp + PRINT '(A,ES15.7,A,ES15.7)', ' element recovery: Ten1N21 ', v(4), ' expected ', EA*eps + CALL require(ABS(v(4) - EA*eps) <= 1.0e-5_wp*EA*eps, 'element recovery: the node tension is EA eps') + tmin = HUGE(1.0_wp) + tmax = -HUGE(1.0_wp) + n = 0 + OPEN (NEWUNIT=u, FILE='tcpl_rec.elements.out', STATUS='OLD', ACTION='READ', IOSTAT=ios) + CALL require(ios == 0, 'the static element profile is written') + IF (ios /= 0) RETURN + READ (u, '(A)') buf + READ (u, '(A)') buf + READ (u, '(A)') buf + DO + READ (u, *, IOSTAT=ios) row + IF (ios /= 0) EXIT + n = n + 1 + tmin = MIN(tmin, row(9)) + tmax = MAX(tmax, row(11)) + END DO + CLOSE (u) + PRINT '(A,I0,A,2ES15.7)', ' element profile: ', n, ' elements, axial resultant range ', tmin, tmax + CALL require(n == 40 .AND. ABS(tmin - EA*eps) <= 1.0e-5_wp*EA*eps .AND. ABS(tmax - EA*eps) <= 1.0e-5_wp*EA*eps, & + 'element profile: the axial resultant is EA eps') + END SUBROUTINE check_recovery + + SUBROUTINE check_compression() + !! 99.99 m between the ends 100 m apart (eps = 1e-4): T = EA eps + K Phi/L is -2.1 kN at + !! Phi = -45 deg, while the kernel's (EA - K^2/GJ) eps stays +680 N. + REAL(wp), PARAMETER :: LC = 99.99_wp + REAL(wp) :: v(4), eps, phi, t_ref + LOGICAL :: conv + INTEGER :: es + CHARACTER(512) :: em + eps = SPAN/LC - 1.0_wp + phi = -45.0_wp*PI/180.0_wp + t_ref = EA*eps + KTT*phi/LC + ! the statics: without tensile_safety the twisted state carries the compression ... + CALL straight_case('tcpl_comp', 'Rigid 1 0 0 Rigid 0 0 1 0', 'Rigid 1 0 0 Rigid 0 0 1 -45', KTT, v, length=LC) + PRINT '(A,ES15.7,A,ES15.7)', ' twisted into compression: Ten1N21 ', v(4), ' expected ', t_ref + CALL require(t_ref < 0.0_wp .AND. ABS(v(4) - t_ref) <= 1.0e-4_wp*ABS(t_ref), & + 'opposite-sense torsion: the node tension is EA eps + K Phi/L < 0') + ! ... which tensile_safety True refuses + CALL write_case('tcpl_comp_ts.dat', 'Rigid 1 0 0 Rigid 0 0 1 0', 'Rigid 1 0 0 Rigid 0 0 1 -45', KTT, & + length=LC, option='True tensile_safety') + CALL CD_Run_Deck_Driver('tcpl_comp_ts.dat', 'tcpl_comp_ts', conv, es, em) + CALL require(es /= CD_DECKDRV_OK .AND. INDEX(em, 'axial compression') > 0, & + 'tensile_safety True refuses the static compression of the coupling: '//TRIM(em)) + ! ... the march from the untwisted state to Phi = -45 deg (End A rolled +45 deg) is refused ... + CALL write_roll(45.0_wp) + CALL write_case('tcpl_comp_dyn.dat', 'Rigid 1 0 0 Rigid 0 0 1 0', 'Rigid 1 0 0 Rigid 0 0 1 0', KTT, & + dynamic=.TRUE., length=LC, option='True tensile_safety') + CALL CD_Run_Deck_Driver('tcpl_comp_dyn.dat', 'tcpl_comp_dyn', conv, es, em) + CALL require(es /= CD_DECKDRV_OK .AND. INDEX(em, 'axial compression') > 0, & + 'tensile_safety True refuses the march into the compression of the coupling: '//TRIM(em)) + ! ... and the march to Phi = +45 deg, in tension, is not + CALL write_roll(-45.0_wp) + CALL CD_Run_Deck_Driver('tcpl_comp_dyn.dat', 'tcpl_comp_dyn', conv, es, em) + CALL require(es == CD_DECKDRV_OK .AND. conv, 'the march into tension passes tensile_safety True: '//TRIM(em)) + END SUBROUTINE check_compression + + SUBROUTINE write_roll(roll) + !! tcpl_motion.txt: End A held at its place and rolled by roll [deg] over 20 s on a C2 + !! quintic, then held to 25 s. + REAL(wp), INTENT(IN) :: roll + INTEGER, PARAMETER :: NSTEP = 500 + REAL(wp), PARAMETER :: TR = 20.0_wp, DTM = 0.05_wp + REAL(wp) :: t, tau, s + INTEGER :: u, k + OPEN (NEWUNIT=u, FILE='tcpl_motion.txt', STATUS='REPLACE', ACTION='WRITE') + WRITE (u, '(A)') '# time id x y z vx vy vz ax ay az roll' + DO k = 0, NSTEP + t = DTM*REAL(k, wp) + tau = MIN(t/TR, 1.0_wp) + s = 10.0_wp*tau**3 - 15.0_wp*tau**4 + 6.0_wp*tau**5 + WRITE (u, '(ES16.8,A,ES16.8)') t, ' 1 0.0 0.0 -50.0 0 0 0 0 0 0 ', roll*s + END DO + CLOSE (u) + END SUBROUTINE write_roll + + SUBROUTINE check_aggregate() + !! The stretched rigid-end case on the coupled aggregate: its twist carries the coupling's + !! -(K/GJ) sum (l - L) = -8 rad; a non-stepping update at the unchanged boundary must pass the + !! preflight's pi/2 bound. + TYPE(CD_AGG_ModuleType) :: agg + REAL(wp) :: pos(3, 1), vel(3, 1), acc(3, 1), load(3, 1), orient(3, 3, 1) + INTEGER :: es + CHARACTER(512) :: em + CALL write_case('tcpl_agg.dat', 'Rigid 1 0 0 Rigid 0 0 1 0', 'Rigid 1 0 0 Rigid 0 0 1 0', KTT) + CALL CD_AGG_Init_From_Deck(agg, 'tcpl_agg.dat', 0.1_wp, es, em, host_orientation=.TRUE.) + CALL require(es == CD_AGG_OK, 'the coupled cable builds on the aggregate: '//TRIM(em)) + IF (es /= CD_AGG_OK) RETURN + CALL CD_AGG_GetMovingPointMesh(agg, pos, vel, acc, load, es, em, orientation=orient) + CALL require(es == CD_AGG_OK, 'aggregate: the moving point mesh: '//TRIM(em)) + CALL CD_AGG_UpdateStates_Moving(agg, pos, vel, acc, es, em, orientation=orient) + CALL require(es == CD_AGG_OK, 'aggregate: an update at the unchanged boundary is accepted: '//TRIM(em)) + CALL CD_AGG_End(agg, es, em) + END SUBROUTINE check_aggregate + + SUBROUTINE straight_case(root, conn_a, conn_b, k, v, torsion, length, option) + !! The straight case at TMax = 0: v = FairTen1, Torq1N1, Twist1, Ten1N21 (Twist and Torq zero + !! for a line without torsion). + CHARACTER(*), INTENT(IN) :: root, conn_a, conn_b + REAL(wp), INTENT(IN) :: k + REAL(wp), INTENT(OUT) :: v(4) + LOGICAL, INTENT(IN), OPTIONAL :: torsion + REAL(wp), INTENT(IN), OPTIONAL :: length + CHARACTER(*), INTENT(IN), OPTIONAL :: option + LOGICAL :: conv, tors + INTEGER :: es, u, ios + CHARACTER(512) :: em + CHARACTER(4096) :: buf + REAL(wp) :: row(5) + tors = .TRUE. + IF (PRESENT(torsion)) tors = torsion + v = 0.0_wp + CALL write_case(root//'.dat', conn_a, conn_b, k, tors, length=length, option=option) + CALL CD_Run_Deck_Driver(root//'.dat', root, conv, es, em) + CALL require(es == CD_DECKDRV_OK .AND. conv, root//' runs: '//TRIM(em)) + IF (es /= CD_DECKDRV_OK) RETURN + OPEN (NEWUNIT=u, FILE=root//'.out', STATUS='OLD', ACTION='READ', IOSTAT=ios) + READ (u, '(A)') buf + READ (u, '(A)') buf + row = 0.0_wp + IF (tors) THEN + READ (u, *, IOSTAT=ios) row(1:5) + v = row(2:5) + ELSE + READ (u, *, IOSTAT=ios) row(1:3) + v(1) = row(2) + v(4) = row(3) + END IF + CLOSE (u) + END SUBROUTINE straight_case + + SUBROUTINE write_case(path, conn_a, conn_b, k, torsion, dynamic, length, option) + !! A 99 m (or length) neutral cable from a Coupled End A to a Fixed End B 100 m apart along +x, 40 + !! elements, TMax 0; the GJ column carries GJ|K (k < 0 writes the plain GJ); option is one more + !! OPTIONS row. + CHARACTER(*), INTENT(IN) :: path, conn_a, conn_b + REAL(wp), INTENT(IN) :: k + LOGICAL, INTENT(IN), OPTIONAL :: torsion, dynamic + REAL(wp), INTENT(IN), OPTIONAL :: length + CHARACTER(*), INTENT(IN), OPTIONAL :: option + INTEGER :: u + CHARACTER(64) :: gjcol, lcol + LOGICAL :: tors, dyn + dyn = .FALSE. + IF (PRESENT(dynamic)) dyn = dynamic + tors = .TRUE. + IF (PRESENT(torsion)) tors = torsion + IF (k < 0.0_wp) THEN + WRITE (gjcol, '(ES12.5)') GJ + ELSE + WRITE (gjcol, '(ES12.5,A,ES12.5)') GJ, '|', k + END IF + gjcol = remove_blanks(gjcol) + lcol = '99.0' + IF (PRESENT(length)) WRITE (lcol, '(F10.4)') length + OPEN (NEWUNIT=u, FILE=path, STATUS='REPLACE', ACTION='WRITE') + WRITE (u, '(A)') 'torque-tension coupling 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 ', RHOW*0.25_wp*PI*0.04_wp, ' 1.0e7 0.0 1.0e6 1.0e8 '//TRIM(gjcol)// & + ' 1.0 1.0 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)') '1 Coupled 0.0 0.0 -50.0 0 0 0 0' + WRITE (u, '(A)') '2 Fixed 100.0 0.0 -50.0 0 0 0 0' + WRITE (u, '(A)') '--- LINES ---' + WRITE (u, '(A)') 'ID NodeA NodeB Outputs' + WRITE (u, '(A)') '(-) (-) (-) (-)' + WRITE (u, '(A)') '1 1 2 -' + WRITE (u, '(A)') '--- SECTIONS ---' + WRITE (u, '(A)') 'LineID LineType Length NumSegs' + WRITE (u, '(A)') '(-) (-) (m) (-)' + WRITE (u, '(A)') '1 cab '//TRIM(ADJUSTL(lcol))//' 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' + IF (PRESENT(option)) WRITE (u, '(A)') option + IF (dyn) THEN + WRITE (u, '(A)') '0.05 dtM' + WRITE (u, '(A)') '25.0 TMax' + WRITE (u, '(A)') 'tcpl_motion.txt motionFile' + ELSE + WRITE (u, '(A)') '0.1 dtM' + WRITE (u, '(A)') '0.0 TMax' + END IF + WRITE (u, '(A)') '--- OUTPUTS ---' + WRITE (u, '(A)') 'FairTen1' + IF (tors) THEN + WRITE (u, '(A)') 'Torq1N1' + WRITE (u, '(A)') 'Twist1' + END IF + WRITE (u, '(A)') 'Ten1N21' + WRITE (u, '(A)') '--- END ---' + CLOSE (u) + END SUBROUTINE write_case + + PURE FUNCTION remove_blanks(s) RESULT(r) + CHARACTER(*), INTENT(IN) :: s + CHARACTER(LEN(s)) :: r + INTEGER :: i, k + r = '' + k = 0 + DO i = 1, LEN(s) + IF (s(i:i) /= ' ') THEN + k = k + 1 + r(k:k) = s(i:i) + END IF + END DO + END FUNCTION remove_blanks + + PURE FUNCTION cross(a, b) RESULT(c) + REAL(wp), INTENT(IN) :: a(3), b(3) + REAL(wp) :: c(3) + c = [a(2)*b(3) - a(3)*b(2), a(3)*b(1) - a(1)*b(3), a(1)*b(2) - a(2)*b(1)] + END FUNCTION cross + + PURE FUNCTION unit(a) RESULT(b) + REAL(wp), INTENT(IN) :: a(3) + REAL(wp) :: b(3) + b = a/NORM2(a) + END FUNCTION unit + + SUBROUTINE require(ok, what) + LOGICAL, INTENT(IN) :: ok + CHARACTER(*), INTENT(IN) :: what + IF (ok) THEN + PRINT '(A)', 'PASS: '//what + ELSE + PRINT '(A)', 'FAIL: '//what + nfail = nfail + 1 + END IF + END SUBROUTINE require +END PROGRAM test_torsion_coupling